@ankhorage/contracts 1.10.0 → 1.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/ui.d.ts +37 -0
- package/dist/ui.d.ts.map +1 -1
- package/dist/ui.js.map +1 -1
- package/package.json +1 -1
- package/src/ui.test.ts +169 -0
- package/src/ui.ts +53 -0
package/CHANGELOG.md
CHANGED
package/dist/ui.d.ts
CHANGED
|
@@ -46,6 +46,42 @@ export interface UiComponentEventMeta {
|
|
|
46
46
|
readonly description?: string;
|
|
47
47
|
readonly payloadFields?: readonly UiComponentEventPayloadFieldMeta[];
|
|
48
48
|
}
|
|
49
|
+
export type UiBindableValueType = 'array' | 'boolean' | 'date' | 'imageAsset' | 'number' | 'object' | 'record' | 'string' | 'unknown';
|
|
50
|
+
export interface UiBindableValueFieldMeta {
|
|
51
|
+
readonly path: string;
|
|
52
|
+
readonly type: UiBindableValueType;
|
|
53
|
+
readonly label?: string;
|
|
54
|
+
readonly description?: string;
|
|
55
|
+
readonly required?: boolean;
|
|
56
|
+
}
|
|
57
|
+
export interface UiBindableValueMeta {
|
|
58
|
+
readonly type: UiBindableValueType;
|
|
59
|
+
readonly label?: string;
|
|
60
|
+
readonly description?: string;
|
|
61
|
+
readonly fields?: readonly UiBindableValueFieldMeta[];
|
|
62
|
+
readonly itemType?: UiBindableValueType;
|
|
63
|
+
}
|
|
64
|
+
export interface UiBindablePropMeta {
|
|
65
|
+
readonly value: UiBindableValueMeta;
|
|
66
|
+
readonly label?: string;
|
|
67
|
+
readonly description?: string;
|
|
68
|
+
readonly required?: boolean;
|
|
69
|
+
readonly acceptsFallback?: boolean;
|
|
70
|
+
readonly acceptsTransforms?: boolean;
|
|
71
|
+
}
|
|
72
|
+
export interface UiBindableEventPayloadMeta {
|
|
73
|
+
readonly eventType: UiComponentEventPayloadKind;
|
|
74
|
+
readonly fields?: readonly UiComponentEventPayloadFieldMeta[];
|
|
75
|
+
}
|
|
76
|
+
export interface UiBindableEventMeta {
|
|
77
|
+
readonly label?: string;
|
|
78
|
+
readonly description?: string;
|
|
79
|
+
readonly payload?: UiBindableEventPayloadMeta;
|
|
80
|
+
}
|
|
81
|
+
export interface UiComponentBindingMeta {
|
|
82
|
+
readonly props?: Readonly<Record<string, UiBindablePropMeta>>;
|
|
83
|
+
readonly events?: Readonly<Record<string, UiBindableEventMeta>>;
|
|
84
|
+
}
|
|
49
85
|
export interface UiComponentSlotMeta {
|
|
50
86
|
readonly label?: string;
|
|
51
87
|
readonly allowedChildren?: readonly string[];
|
|
@@ -56,6 +92,7 @@ export interface UiComponentMeta {
|
|
|
56
92
|
readonly description?: string;
|
|
57
93
|
readonly directManifestNode: boolean;
|
|
58
94
|
readonly allowedChildren: readonly string[];
|
|
95
|
+
readonly bindings?: UiComponentBindingMeta;
|
|
59
96
|
readonly blueprint?: UiComponentBlueprint;
|
|
60
97
|
readonly events?: Readonly<Record<string, UiComponentEventMeta>>;
|
|
61
98
|
readonly i18n?: UiComponentI18nMeta;
|
package/dist/ui.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ui.d.ts","sourceRoot":"","sources":["../src/ui.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAErD,MAAM,MAAM,mBAAmB,GAAG,WAAW,GAAG,YAAY,GAAG,QAAQ,GAAG,SAAS,CAAC;AAEpF,MAAM,MAAM,mBAAmB,GAC3B,QAAQ,GACR,OAAO,GACP,SAAS,GACT,OAAO,GACP,MAAM,GACN,YAAY,GACZ,QAAQ,GACR,QAAQ,GACR,QAAQ,GACR,SAAS,GACT,QAAQ,GACR,gBAAgB,GAChB,kBAAkB,CAAC;AAEvB,MAAM,MAAM,oBAAoB,GAC5B,MAAM,GACN,MAAM,GACN,OAAO,GACP,IAAI,GACJ,SAAS,oBAAoB,EAAE,GAC/B;IACE,QAAQ,EAAE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,QAAQ,CAAC,IAAI,CAAC,EAAE,mBAAmB,CAAC;IACpC,QAAQ,CAAC,KAAK,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC,CAAC;IAC/D,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC,CAAC;CACjE;AAED,MAAM,MAAM,uBAAuB,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC,CAAC;AAEhF,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,UAAU,EAAE,uBAAuB,CAAC;CAC9C"}
|
package/dist/ui.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ui.js","sourceRoot":"","sources":["../src/ui.ts"],"names":[],"mappings":"","sourcesContent":["import type { ComponentEventDtoKind } from './types';\n\nexport type UiComponentCategory = 'component' | 'foundation' | 'layout' | 'pattern';\n\nexport type UiComponentPropType =\n | 'action'\n | 'array'\n | 'boolean'\n | 'color'\n | 'enum'\n | 'imageAsset'\n | 'number'\n | 'radius'\n | 'shadow'\n | 'spacing'\n | 'string'\n | 'typographySize'\n | 'typographyWeight';\n\nexport type UiComponentPropValue =\n | string\n | number\n | boolean\n | null\n | readonly UiComponentPropValue[]\n | {\n readonly [key: string]: UiComponentPropValue;\n };\n\nexport interface UiComponentPropArrayItemSchema {\n readonly key: string;\n readonly schema: UiComponentPropSchema;\n}\n\nexport interface UiComponentPropSchema {\n readonly type: UiComponentPropType;\n readonly category: string;\n readonly label?: string;\n readonly enum?: readonly (number | string)[];\n readonly default?: UiComponentPropValue;\n readonly itemSchema?: readonly UiComponentPropArrayItemSchema[];\n}\n\nexport interface UiComponentBlueprintIcon {\n readonly name: string;\n readonly provider?: string;\n}\n\nexport interface UiComponentBlueprint {\n readonly label: string;\n readonly icon?: UiComponentBlueprintIcon;\n readonly defaultProps?: Readonly<Record<string, UiComponentPropValue>>;\n}\n\nexport interface UiComponentI18nFieldMeta {\n readonly keyProp: string;\n readonly defaultTextProp: string;\n}\n\nexport interface UiComponentI18nMeta {\n readonly fields: readonly UiComponentI18nFieldMeta[];\n}\n\nexport type UiComponentEventPayloadKind = ComponentEventDtoKind | (string & {});\n\nexport type UiComponentEventPayloadFieldType =\n | 'boolean'\n | 'number'\n | 'object'\n | 'record'\n | 'string'\n | 'unknown';\n\nexport interface UiComponentEventPayloadFieldMeta {\n readonly path: string;\n readonly type: UiComponentEventPayloadFieldType;\n readonly label?: string;\n readonly description?: string;\n}\n\nexport interface UiComponentEventMeta {\n readonly label: string;\n readonly eventType: UiComponentEventPayloadKind;\n readonly description?: string;\n readonly payloadFields?: readonly UiComponentEventPayloadFieldMeta[];\n}\n\nexport interface UiComponentSlotMeta {\n readonly label?: string;\n readonly allowedChildren?: readonly string[];\n}\n\nexport interface UiComponentMeta {\n readonly name: string;\n readonly category: UiComponentCategory;\n readonly description?: string;\n readonly directManifestNode: boolean;\n readonly allowedChildren: readonly string[];\n readonly blueprint?: UiComponentBlueprint;\n readonly events?: Readonly<Record<string, UiComponentEventMeta>>;\n readonly i18n?: UiComponentI18nMeta;\n readonly slots?: Readonly<Record<string, UiComponentSlotMeta>>;\n readonly note?: string;\n readonly props: Readonly<Record<string, UiComponentPropSchema>>;\n}\n\nexport type UiComponentMetaRegistry = Readonly<Record<string, UiComponentMeta>>;\n\nexport interface UiComponentPackageManifest {\n readonly packageName: string;\n readonly displayName?: string;\n readonly components: UiComponentMetaRegistry;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ui.js","sourceRoot":"","sources":["../src/ui.ts"],"names":[],"mappings":"","sourcesContent":["import type { ComponentEventDtoKind } from './types';\n\nexport type UiComponentCategory = 'component' | 'foundation' | 'layout' | 'pattern';\n\nexport type UiComponentPropType =\n | 'action'\n | 'array'\n | 'boolean'\n | 'color'\n | 'enum'\n | 'imageAsset'\n | 'number'\n | 'radius'\n | 'shadow'\n | 'spacing'\n | 'string'\n | 'typographySize'\n | 'typographyWeight';\n\nexport type UiComponentPropValue =\n | string\n | number\n | boolean\n | null\n | readonly UiComponentPropValue[]\n | {\n readonly [key: string]: UiComponentPropValue;\n };\n\nexport interface UiComponentPropArrayItemSchema {\n readonly key: string;\n readonly schema: UiComponentPropSchema;\n}\n\nexport interface UiComponentPropSchema {\n readonly type: UiComponentPropType;\n readonly category: string;\n readonly label?: string;\n readonly enum?: readonly (number | string)[];\n readonly default?: UiComponentPropValue;\n readonly itemSchema?: readonly UiComponentPropArrayItemSchema[];\n}\n\nexport interface UiComponentBlueprintIcon {\n readonly name: string;\n readonly provider?: string;\n}\n\nexport interface UiComponentBlueprint {\n readonly label: string;\n readonly icon?: UiComponentBlueprintIcon;\n readonly defaultProps?: Readonly<Record<string, UiComponentPropValue>>;\n}\n\nexport interface UiComponentI18nFieldMeta {\n readonly keyProp: string;\n readonly defaultTextProp: string;\n}\n\nexport interface UiComponentI18nMeta {\n readonly fields: readonly UiComponentI18nFieldMeta[];\n}\n\nexport type UiComponentEventPayloadKind = ComponentEventDtoKind | (string & {});\n\nexport type UiComponentEventPayloadFieldType =\n | 'boolean'\n | 'number'\n | 'object'\n | 'record'\n | 'string'\n | 'unknown';\n\nexport interface UiComponentEventPayloadFieldMeta {\n readonly path: string;\n readonly type: UiComponentEventPayloadFieldType;\n readonly label?: string;\n readonly description?: string;\n}\n\nexport interface UiComponentEventMeta {\n readonly label: string;\n readonly eventType: UiComponentEventPayloadKind;\n readonly description?: string;\n readonly payloadFields?: readonly UiComponentEventPayloadFieldMeta[];\n}\n\nexport type UiBindableValueType =\n | 'array'\n | 'boolean'\n | 'date'\n | 'imageAsset'\n | 'number'\n | 'object'\n | 'record'\n | 'string'\n | 'unknown';\n\nexport interface UiBindableValueFieldMeta {\n readonly path: string;\n readonly type: UiBindableValueType;\n readonly label?: string;\n readonly description?: string;\n readonly required?: boolean;\n}\n\nexport interface UiBindableValueMeta {\n readonly type: UiBindableValueType;\n readonly label?: string;\n readonly description?: string;\n readonly fields?: readonly UiBindableValueFieldMeta[];\n readonly itemType?: UiBindableValueType;\n}\n\nexport interface UiBindablePropMeta {\n readonly value: UiBindableValueMeta;\n readonly label?: string;\n readonly description?: string;\n readonly required?: boolean;\n readonly acceptsFallback?: boolean;\n readonly acceptsTransforms?: boolean;\n}\n\nexport interface UiBindableEventPayloadMeta {\n readonly eventType: UiComponentEventPayloadKind;\n readonly fields?: readonly UiComponentEventPayloadFieldMeta[];\n}\n\nexport interface UiBindableEventMeta {\n readonly label?: string;\n readonly description?: string;\n readonly payload?: UiBindableEventPayloadMeta;\n}\n\nexport interface UiComponentBindingMeta {\n readonly props?: Readonly<Record<string, UiBindablePropMeta>>;\n readonly events?: Readonly<Record<string, UiBindableEventMeta>>;\n}\n\nexport interface UiComponentSlotMeta {\n readonly label?: string;\n readonly allowedChildren?: readonly string[];\n}\n\nexport interface UiComponentMeta {\n readonly name: string;\n readonly category: UiComponentCategory;\n readonly description?: string;\n readonly directManifestNode: boolean;\n readonly allowedChildren: readonly string[];\n readonly bindings?: UiComponentBindingMeta;\n readonly blueprint?: UiComponentBlueprint;\n readonly events?: Readonly<Record<string, UiComponentEventMeta>>;\n readonly i18n?: UiComponentI18nMeta;\n readonly slots?: Readonly<Record<string, UiComponentSlotMeta>>;\n readonly note?: string;\n readonly props: Readonly<Record<string, UiComponentPropSchema>>;\n}\n\nexport type UiComponentMetaRegistry = Readonly<Record<string, UiComponentMeta>>;\n\nexport interface UiComponentPackageManifest {\n readonly packageName: string;\n readonly displayName?: string;\n readonly components: UiComponentMetaRegistry;\n}\n"]}
|
package/package.json
CHANGED
package/src/ui.test.ts
CHANGED
|
@@ -113,6 +113,134 @@ describe('ui component metadata contracts', () => {
|
|
|
113
113
|
expect(meta.props.columns?.itemSchema?.map((item) => item.key)).toEqual(['id', 'label']);
|
|
114
114
|
});
|
|
115
115
|
|
|
116
|
+
it('serializes bindable prop and event metadata on component metadata', () => {
|
|
117
|
+
const meta: UiComponentMeta = {
|
|
118
|
+
name: 'Button',
|
|
119
|
+
category: 'component',
|
|
120
|
+
directManifestNode: true,
|
|
121
|
+
allowedChildren: [],
|
|
122
|
+
bindings: {
|
|
123
|
+
props: {
|
|
124
|
+
children: {
|
|
125
|
+
label: 'Label',
|
|
126
|
+
description: 'Text content rendered inside the button.',
|
|
127
|
+
acceptsFallback: true,
|
|
128
|
+
acceptsTransforms: true,
|
|
129
|
+
value: {
|
|
130
|
+
type: 'string',
|
|
131
|
+
label: 'Button label',
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
disabled: {
|
|
135
|
+
label: 'Disabled',
|
|
136
|
+
value: {
|
|
137
|
+
type: 'boolean',
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
},
|
|
141
|
+
events: {
|
|
142
|
+
press: {
|
|
143
|
+
label: 'Press',
|
|
144
|
+
description: 'Runs when the button is pressed.',
|
|
145
|
+
payload: {
|
|
146
|
+
eventType: 'button.press',
|
|
147
|
+
fields: [],
|
|
148
|
+
},
|
|
149
|
+
},
|
|
150
|
+
},
|
|
151
|
+
},
|
|
152
|
+
events: {
|
|
153
|
+
press: {
|
|
154
|
+
label: 'Press',
|
|
155
|
+
eventType: 'button.press',
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
props: {
|
|
159
|
+
children: {
|
|
160
|
+
type: 'string',
|
|
161
|
+
category: 'Content',
|
|
162
|
+
label: 'Label',
|
|
163
|
+
},
|
|
164
|
+
disabled: {
|
|
165
|
+
type: 'boolean',
|
|
166
|
+
category: 'State',
|
|
167
|
+
label: 'Disabled',
|
|
168
|
+
},
|
|
169
|
+
},
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
assertSerializable(meta);
|
|
173
|
+
expect(meta.bindings?.props?.children?.value.type).toBe('string');
|
|
174
|
+
expect(meta.bindings?.events?.press?.payload?.eventType).toBe('button.press');
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
it('serializes bindable collection item metadata with nested value fields', () => {
|
|
178
|
+
const meta: UiComponentMeta = {
|
|
179
|
+
name: 'List',
|
|
180
|
+
category: 'pattern',
|
|
181
|
+
directManifestNode: true,
|
|
182
|
+
allowedChildren: [],
|
|
183
|
+
bindings: {
|
|
184
|
+
props: {
|
|
185
|
+
items: {
|
|
186
|
+
label: 'Items',
|
|
187
|
+
value: {
|
|
188
|
+
type: 'array',
|
|
189
|
+
itemType: 'object',
|
|
190
|
+
fields: [
|
|
191
|
+
{
|
|
192
|
+
path: '$.id',
|
|
193
|
+
type: 'string',
|
|
194
|
+
label: 'ID',
|
|
195
|
+
required: true,
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
path: '$.title',
|
|
199
|
+
type: 'string',
|
|
200
|
+
label: 'Title',
|
|
201
|
+
},
|
|
202
|
+
],
|
|
203
|
+
},
|
|
204
|
+
},
|
|
205
|
+
},
|
|
206
|
+
events: {
|
|
207
|
+
itemPress: {
|
|
208
|
+
label: 'Item press',
|
|
209
|
+
payload: {
|
|
210
|
+
eventType: 'collection.itemPress',
|
|
211
|
+
fields: [
|
|
212
|
+
{
|
|
213
|
+
path: 'payload.itemId',
|
|
214
|
+
type: 'string',
|
|
215
|
+
label: 'Item ID',
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
path: 'payload.item',
|
|
219
|
+
type: 'record',
|
|
220
|
+
label: 'Item',
|
|
221
|
+
},
|
|
222
|
+
],
|
|
223
|
+
},
|
|
224
|
+
},
|
|
225
|
+
},
|
|
226
|
+
},
|
|
227
|
+
props: {
|
|
228
|
+
items: {
|
|
229
|
+
type: 'array',
|
|
230
|
+
category: 'Data',
|
|
231
|
+
label: 'Items',
|
|
232
|
+
},
|
|
233
|
+
},
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
assertSerializable(meta);
|
|
237
|
+
expect(meta.bindings?.props?.items?.value.fields?.map((field) => field.path)).toEqual([
|
|
238
|
+
'$.id',
|
|
239
|
+
'$.title',
|
|
240
|
+
]);
|
|
241
|
+
expect(meta.bindings?.events?.itemPress?.payload?.eventType).toBe('collection.itemPress');
|
|
242
|
+
});
|
|
243
|
+
|
|
116
244
|
it('serializes a component metadata registry', () => {
|
|
117
245
|
const registry: UiComponentMetaRegistry = {
|
|
118
246
|
Text: {
|
|
@@ -120,6 +248,15 @@ describe('ui component metadata contracts', () => {
|
|
|
120
248
|
category: 'component',
|
|
121
249
|
directManifestNode: true,
|
|
122
250
|
allowedChildren: [],
|
|
251
|
+
bindings: {
|
|
252
|
+
props: {
|
|
253
|
+
children: {
|
|
254
|
+
value: {
|
|
255
|
+
type: 'string',
|
|
256
|
+
},
|
|
257
|
+
},
|
|
258
|
+
},
|
|
259
|
+
},
|
|
123
260
|
props: {
|
|
124
261
|
children: {
|
|
125
262
|
type: 'string',
|
|
@@ -139,6 +276,7 @@ describe('ui component metadata contracts', () => {
|
|
|
139
276
|
|
|
140
277
|
assertSerializable(registry);
|
|
141
278
|
expect(registry.Screen?.allowedChildren).toEqual(['Text']);
|
|
279
|
+
expect(registry.Text?.bindings?.props?.children?.value.type).toBe('string');
|
|
142
280
|
});
|
|
143
281
|
|
|
144
282
|
it('serializes a component package manifest for extension packages', () => {
|
|
@@ -151,6 +289,36 @@ describe('ui component metadata contracts', () => {
|
|
|
151
289
|
category: 'component',
|
|
152
290
|
directManifestNode: true,
|
|
153
291
|
allowedChildren: [],
|
|
292
|
+
bindings: {
|
|
293
|
+
props: {
|
|
294
|
+
fen: {
|
|
295
|
+
value: {
|
|
296
|
+
type: 'string',
|
|
297
|
+
label: 'FEN',
|
|
298
|
+
},
|
|
299
|
+
},
|
|
300
|
+
},
|
|
301
|
+
events: {
|
|
302
|
+
move: {
|
|
303
|
+
label: 'Move',
|
|
304
|
+
payload: {
|
|
305
|
+
eventType: 'chess.move',
|
|
306
|
+
fields: [
|
|
307
|
+
{
|
|
308
|
+
path: 'payload.from',
|
|
309
|
+
type: 'string',
|
|
310
|
+
label: 'From square',
|
|
311
|
+
},
|
|
312
|
+
{
|
|
313
|
+
path: 'payload.to',
|
|
314
|
+
type: 'string',
|
|
315
|
+
label: 'To square',
|
|
316
|
+
},
|
|
317
|
+
],
|
|
318
|
+
},
|
|
319
|
+
},
|
|
320
|
+
},
|
|
321
|
+
},
|
|
154
322
|
events: {
|
|
155
323
|
move: {
|
|
156
324
|
label: 'Move',
|
|
@@ -189,5 +357,6 @@ describe('ui component metadata contracts', () => {
|
|
|
189
357
|
|
|
190
358
|
assertSerializable(manifest);
|
|
191
359
|
expect(manifest.components.Chessboard?.events?.move?.eventType).toBe('chess.move');
|
|
360
|
+
expect(manifest.components.Chessboard?.bindings?.props?.fen?.value.type).toBe('string');
|
|
192
361
|
});
|
|
193
362
|
});
|
package/src/ui.ts
CHANGED
|
@@ -85,6 +85,58 @@ export interface UiComponentEventMeta {
|
|
|
85
85
|
readonly payloadFields?: readonly UiComponentEventPayloadFieldMeta[];
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
+
export type UiBindableValueType =
|
|
89
|
+
| 'array'
|
|
90
|
+
| 'boolean'
|
|
91
|
+
| 'date'
|
|
92
|
+
| 'imageAsset'
|
|
93
|
+
| 'number'
|
|
94
|
+
| 'object'
|
|
95
|
+
| 'record'
|
|
96
|
+
| 'string'
|
|
97
|
+
| 'unknown';
|
|
98
|
+
|
|
99
|
+
export interface UiBindableValueFieldMeta {
|
|
100
|
+
readonly path: string;
|
|
101
|
+
readonly type: UiBindableValueType;
|
|
102
|
+
readonly label?: string;
|
|
103
|
+
readonly description?: string;
|
|
104
|
+
readonly required?: boolean;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export interface UiBindableValueMeta {
|
|
108
|
+
readonly type: UiBindableValueType;
|
|
109
|
+
readonly label?: string;
|
|
110
|
+
readonly description?: string;
|
|
111
|
+
readonly fields?: readonly UiBindableValueFieldMeta[];
|
|
112
|
+
readonly itemType?: UiBindableValueType;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export interface UiBindablePropMeta {
|
|
116
|
+
readonly value: UiBindableValueMeta;
|
|
117
|
+
readonly label?: string;
|
|
118
|
+
readonly description?: string;
|
|
119
|
+
readonly required?: boolean;
|
|
120
|
+
readonly acceptsFallback?: boolean;
|
|
121
|
+
readonly acceptsTransforms?: boolean;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export interface UiBindableEventPayloadMeta {
|
|
125
|
+
readonly eventType: UiComponentEventPayloadKind;
|
|
126
|
+
readonly fields?: readonly UiComponentEventPayloadFieldMeta[];
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export interface UiBindableEventMeta {
|
|
130
|
+
readonly label?: string;
|
|
131
|
+
readonly description?: string;
|
|
132
|
+
readonly payload?: UiBindableEventPayloadMeta;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export interface UiComponentBindingMeta {
|
|
136
|
+
readonly props?: Readonly<Record<string, UiBindablePropMeta>>;
|
|
137
|
+
readonly events?: Readonly<Record<string, UiBindableEventMeta>>;
|
|
138
|
+
}
|
|
139
|
+
|
|
88
140
|
export interface UiComponentSlotMeta {
|
|
89
141
|
readonly label?: string;
|
|
90
142
|
readonly allowedChildren?: readonly string[];
|
|
@@ -96,6 +148,7 @@ export interface UiComponentMeta {
|
|
|
96
148
|
readonly description?: string;
|
|
97
149
|
readonly directManifestNode: boolean;
|
|
98
150
|
readonly allowedChildren: readonly string[];
|
|
151
|
+
readonly bindings?: UiComponentBindingMeta;
|
|
99
152
|
readonly blueprint?: UiComponentBlueprint;
|
|
100
153
|
readonly events?: Readonly<Record<string, UiComponentEventMeta>>;
|
|
101
154
|
readonly i18n?: UiComponentI18nMeta;
|