Skip to content

Commit 7c2f036

Browse files
committed
fix API issues
1 parent 0f673ee commit 7c2f036

File tree

15 files changed

+82
-66
lines changed

15 files changed

+82
-66
lines changed

packages/core/src/api/Validators.ts

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import type {
1919
} from 'packages/core/src/parsers/inputFieldParser/InputFieldDeclaration';
2020
import {
2121
type BindTargetDeclaration,
22-
type SimpleBindTargetDeclaration,
2322
type SimplePropAccess,
2423
type UnvalidatedBindTargetDeclaration,
2524
type UnvalidatedPropAccess,
@@ -149,44 +148,35 @@ export const V_SimplePropAccess = schemaForType<SimplePropAccess>()(
149148
}),
150149
);
151150

152-
export const V_SimpleBindTargetDeclaration = schemaForType<SimpleBindTargetDeclaration>()(
153-
z.object({
154-
storageType: z.string().optional(),
155-
storagePath: z.string().optional(),
156-
storageProp: V_SimplePropAccess.array(),
157-
listenToChildren: z.boolean(),
158-
}),
159-
);
160-
161151
export const V_SimpleInputFieldDeclaration = schemaForType<SimpleInputFieldDeclaration>()(
162152
z.object({
163153
inputFieldType: V_InputFieldType.optional(),
164154
templateName: z.string().optional(),
165-
bindTarget: V_SimpleBindTargetDeclaration.optional(),
155+
bindTarget: V_BindTargetDeclaration.optional(),
166156
arguments: V_SimpleFieldArgument.array().optional(),
167157
}),
168158
);
169159

170160
export const V_SimpleViewFieldDeclaration = schemaForType<SimpleViewFieldDeclaration>()(
171161
z.object({
172162
viewFieldType: V_InputFieldType.optional(),
173-
templateDeclaration: z.union([z.string(), V_SimpleBindTargetDeclaration]).array().optional(),
163+
templateDeclaration: z.union([z.string(), V_BindTargetDeclaration]).array().optional(),
174164
arguments: V_SimpleFieldArgument.array().optional(),
175-
writeToBindTarget: V_SimpleBindTargetDeclaration.optional(),
165+
writeToBindTarget: V_BindTargetDeclaration.optional(),
176166
}),
177167
);
178168

179169
export const V_SimpleJsViewFieldBindTargetMapping = schemaForType<SimpleJsViewFieldBindTargetMapping>()(
180170
z.object({
181-
bindTarget: V_SimpleBindTargetDeclaration,
171+
bindTarget: V_BindTargetDeclaration,
182172
name: z.string(),
183173
}),
184174
);
185175

186176
export const V_SimpleJsViewFieldDeclaration = schemaForType<SimpleJsViewFieldDeclaration>()(
187177
z.object({
188178
bindTargetMappings: V_SimpleJsViewFieldBindTargetMapping.array(),
189-
writeToBindTarget: V_SimpleBindTargetDeclaration.optional(),
179+
writeToBindTarget: V_BindTargetDeclaration.optional(),
190180
code: z.string(),
191181
}),
192182
);

packages/core/src/fields/inputFields/fields/ImageListSuggester/ImageListSuggesterComponent.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@
8888

8989
<div class="mb-image-card-grid">
9090
{#each value as image, i}
91-
<div class="mb-image-card" on:contextmenu={e => openContextMenuForElement(e, i)}>
91+
<div class="mb-image-card" on:contextmenu={e => openContextMenuForElement(e, i)} role="listitem">
9292
<img class="mb-image-card-image" src={plugin.internal.imagePathToUri(image)} alt={image} />
9393
<div class="mb-image-card-footer">
9494
<span>{image}</span>

packages/core/src/fields/inputFields/fields/InlineList/InlineListComponent.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696

9797
<div class="mb-inline-list">
9898
{#each value as entry, i}
99-
<div class="mb-inline-list-item" on:contextmenu={e => openContextMenuForElement(e, i)}>
99+
<div class="mb-inline-list-item" on:contextmenu={e => openContextMenuForElement(e, i)} role="listitem">
100100
<LiteralRenderComponent value={entry}></LiteralRenderComponent>
101101
</div>
102102
{/each}

packages/core/src/fields/inputFields/fields/InlineListSuggester/InlineListSuggesterComponent.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@
100100

101101
<div class="mb-inline-list">
102102
{#each value as entry, i}
103-
<div class="mb-inline-list-item" on:contextmenu={e => openContextMenuForElement(e, i)}>
103+
<div class="mb-inline-list-item" on:contextmenu={e => openContextMenuForElement(e, i)} role="listitem">
104104
<LiteralRenderComponent value={entry}></LiteralRenderComponent>
105105
</div>
106106
{/each}

packages/core/src/fields/inputFields/fields/List/ListComponent.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@
104104

105105
<div class="mb-list-items">
106106
{#each value as entry, i}
107-
<div class="mb-list-item" on:contextmenu={e => openContextMenuForElement(e, i)}>
107+
<div class="mb-list-item" on:contextmenu={e => openContextMenuForElement(e, i)} role="listitem">
108108
<LiteralRenderComponent value={entry}></LiteralRenderComponent>
109109
</div>
110110
{:else}

packages/core/src/fields/inputFields/fields/ListSuggester/ListSuggesterComponent.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080

8181
<div class="mb-list-items">
8282
{#each value as entry, i}
83-
<div class="mb-list-item" on:contextmenu={e => openContextMenuForElement(e, i)}>
83+
<div class="mb-list-item" on:contextmenu={e => openContextMenuForElement(e, i)} role="listitem">
8484
<LiteralRenderComponent value={entry}></LiteralRenderComponent>
8585
</div>
8686
{:else}

packages/core/src/parsers/bindTargetParser/BindTargetDeclaration.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,6 @@ export interface UnvalidatedPropAccess {
2121
prop: ParsingResultNode;
2222
}
2323

24-
export interface SimpleBindTargetDeclaration {
25-
storageType?: string | undefined;
26-
storagePath?: string | undefined;
27-
storageProp: SimplePropAccess[];
28-
listenToChildren: boolean;
29-
}
30-
3124
export interface SimplePropAccess {
3225
type: PropAccessType;
3326
prop: string;

packages/core/src/parsers/bindTargetParser/BindTargetParser.ts

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@ import { type BindTargetScope } from 'packages/core/src/metadata/BindTargetScope
33
import { ParsingValidationError, runParser } from 'packages/core/src/parsers/ParsingError';
44
import {
55
type BindTargetDeclaration,
6-
type SimpleBindTargetDeclaration,
76
type UnvalidatedBindTargetDeclaration,
87
} from 'packages/core/src/parsers/bindTargetParser/BindTargetDeclaration';
98
import { P_BindTarget } from 'packages/core/src/parsers/nomParsers/BindTargetNomParsers';
10-
import { type ParsingResultNode } from 'packages/core/src/parsers/nomParsers/GeneralNomParsers';
9+
import { type ParsingResultNode, toResultNode } from 'packages/core/src/parsers/nomParsers/GeneralNomParsers';
1110
import { ErrorLevel, MetaBindInternalError } from 'packages/core/src/utils/errors/MetaBindErrors';
1211
import { PropAccess } from 'packages/core/src/utils/prop/PropAccess';
1312
import { PropPath } from 'packages/core/src/utils/prop/PropPath';
@@ -31,23 +30,27 @@ export class BindTargetParser {
3130
return this.validate(bindTargetString, this.fromString(bindTargetString), filePath, scope);
3231
}
3332

34-
fromSimpleDeclaration(simpleDeclaration: SimpleBindTargetDeclaration): UnvalidatedBindTargetDeclaration {
33+
fromExistingDeclaration(declaration: BindTargetDeclaration): UnvalidatedBindTargetDeclaration;
34+
fromExistingDeclaration(
35+
declaration: BindTargetDeclaration | undefined,
36+
): UnvalidatedBindTargetDeclaration | undefined;
37+
fromExistingDeclaration(
38+
declaration: BindTargetDeclaration | undefined,
39+
): UnvalidatedBindTargetDeclaration | undefined {
40+
if (declaration === undefined) {
41+
return undefined;
42+
}
3543
return {
36-
storageType: simpleDeclaration.storageType ? { value: simpleDeclaration.storageType } : undefined,
37-
storagePath: simpleDeclaration.storagePath ? { value: simpleDeclaration.storagePath } : undefined,
38-
storageProp: simpleDeclaration.storageProp.map(x => ({ type: x.type, prop: { value: x.prop } })),
39-
listenToChildren: simpleDeclaration.listenToChildren,
44+
storageType: toResultNode(declaration.storageType),
45+
storagePath: toResultNode(declaration.storagePath),
46+
storageProp: declaration.storageProp.path.map(x => ({
47+
type: x.type,
48+
prop: toResultNode(x.prop),
49+
})),
50+
listenToChildren: declaration.listenToChildren,
4051
};
4152
}
4253

43-
fromSimpleDeclarationAndValidate(
44-
simpleDeclaration: SimpleBindTargetDeclaration,
45-
filePath: string,
46-
scope?: BindTargetScope | undefined,
47-
): BindTargetDeclaration {
48-
return this.validate(undefined, this.fromSimpleDeclaration(simpleDeclaration), filePath, scope);
49-
}
50-
5154
validate(
5255
fullDeclaration: string | undefined,
5356
unvalidatedBindTargetDeclaration: UnvalidatedBindTargetDeclaration,

packages/core/src/parsers/inputFieldParser/InputFieldDeclaration.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { type InputFieldType } from 'packages/core/src/config/FieldConfigs';
22
import { type InputFieldArgumentContainer } from 'packages/core/src/fields/fieldArguments/inputFieldArguments/InputFieldArgumentContainer';
33
import {
44
type BindTargetDeclaration,
5-
type SimpleBindTargetDeclaration,
65
type UnvalidatedBindTargetDeclaration,
76
} from 'packages/core/src/parsers/bindTargetParser/BindTargetDeclaration';
87
import { type ParsingResultNode } from 'packages/core/src/parsers/nomParsers/GeneralNomParsers';
@@ -30,6 +29,6 @@ export interface UnvalidatedInputFieldDeclaration extends PartialUnvalidatedInpu
3029
export interface SimpleInputFieldDeclaration {
3130
inputFieldType?: InputFieldType | undefined;
3231
templateName?: string | undefined;
33-
bindTarget?: SimpleBindTargetDeclaration | undefined;
32+
bindTarget?: BindTargetDeclaration | undefined;
3433
arguments?: SimpleFieldArgument[] | undefined;
3534
}

packages/core/src/parsers/inputFieldParser/InputFieldParser.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import { ErrorCollection } from 'packages/core/src/utils/errors/ErrorCollection'
2323
import { ErrorLevel } from 'packages/core/src/utils/errors/MetaBindErrors';
2424
import { type UnvalidatedBindTargetDeclaration } from 'packages/core/src/parsers/bindTargetParser/BindTargetDeclaration';
2525
import { type UnvalidatedFieldArgument } from 'packages/core/src/parsers/nomParsers/FieldArgumentNomParsers';
26+
import { toResultNode } from 'packages/core/src/parsers/nomParsers/GeneralNomParsers';
2627

2728
export type InputFieldDeclarationTemplate = TemplateSupplierTemplate<UnvalidatedInputFieldDeclaration>;
2829

@@ -76,13 +77,11 @@ export class InputFieldParser implements ITemplateSupplier<UnvalidatedInputField
7677

7778
return {
7879
declarationString: undefined,
79-
inputFieldType: simpleDeclaration.inputFieldType ? { value: simpleDeclaration.inputFieldType } : undefined,
80-
bindTarget: simpleDeclaration.bindTarget
81-
? this.plugin.api.bindTargetParser.fromSimpleDeclaration(simpleDeclaration.bindTarget)
82-
: undefined,
80+
inputFieldType: toResultNode(simpleDeclaration.inputFieldType),
81+
bindTarget: this.plugin.api.bindTargetParser.fromExistingDeclaration(simpleDeclaration.bindTarget),
8382
arguments: (simpleDeclaration.arguments ?? []).map(x => ({
84-
name: { value: x.name },
85-
value: x.value.map(y => ({ value: y })),
83+
name: toResultNode(x.name),
84+
value: x.value.map(y => toResultNode(y)),
8685
})),
8786
errorCollection: errorCollection,
8887
};

0 commit comments

Comments
 (0)