@middag-io/react 0.46.0 → 0.47.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/dist-lib/{FormField-Csx8hGAW.js → FormField-BGqAQLtX.js} +1863 -1806
- package/dist-lib/{FormPanelBlock-Bmd0DpiX.js → FormPanelBlock-CGgA83Mu.js} +50 -49
- package/dist-lib/base/blocks/CardGridBlock.d.ts.map +1 -1
- package/dist-lib/base/blocks/DenseTableBlock.d.ts.map +1 -1
- package/dist-lib/base/blocks/DetailPanelBlock.d.ts.map +1 -1
- package/dist-lib/base/blocks/FormPanelBlock.d.ts.map +1 -1
- package/dist-lib/base/partials/ActionBar/index.d.ts.map +1 -1
- package/dist-lib/base/partials/FilterBar/index.d.ts.map +1 -1
- package/dist-lib/base/shell/BasicShell.js +1 -1
- package/dist-lib/base/shell/partials/InlineEditablePanel.d.ts.map +1 -1
- package/dist-lib/base/shell/partials/InlineEditablePanel.js +131 -127
- package/dist-lib/base/shell/partials/PageActionButton.d.ts.map +1 -1
- package/dist-lib/base/shell/partials/PageActionButton.js +1 -1
- package/dist-lib/base/theme/appearance.d.ts.map +1 -1
- package/dist-lib/base/theme/appearance.js +1 -1
- package/dist-lib/base/utils/action-intent.d.ts +3 -0
- package/dist-lib/base/utils/action-intent.d.ts.map +1 -0
- package/dist-lib/base/utils/action-intent.js +16 -0
- package/dist-lib/chunks/subpath-Bs35txZS.js +166 -0
- package/dist-lib/contracts/generated/index.d.ts +7 -7
- package/dist-lib/contracts/generated/index.d.ts.map +1 -1
- package/dist-lib/contracts/generated/schemas.d.ts +3992 -0
- package/dist-lib/contracts/generated/schemas.d.ts.map +1 -0
- package/dist-lib/contracts/generated/{contract-types.d.ts → types.d.ts} +26 -16
- package/dist-lib/contracts/generated/types.d.ts.map +1 -0
- package/dist-lib/contracts/page-contract-schema.d.ts +217 -27
- package/dist-lib/contracts/page-contract-schema.d.ts.map +1 -1
- package/dist-lib/middag-react.js +10111 -10782
- package/dist-lib/primitives/reui/button.d.ts +1 -1
- package/docs/public/schemas/fragment.json +66 -2
- package/docs/public/schemas/page-contract.json +66 -2
- package/package.json +1 -1
- package/src/base/blocks/CardGridBlock.tsx +2 -1
- package/src/base/blocks/DenseTableBlock.tsx +2 -1
- package/src/base/blocks/DetailPanelBlock.tsx +2 -1
- package/src/base/blocks/FormPanelBlock.tsx +2 -1
- package/src/base/partials/ActionBar/index.tsx +3 -2
- package/src/base/partials/FilterBar/index.tsx +12 -1
- package/src/base/shell/partials/InlineEditablePanel.tsx +14 -7
- package/src/base/shell/partials/PageActionButton.tsx +3 -1
- package/src/base/theme/appearance.ts +2 -1
- package/src/base/utils/action-intent.ts +22 -0
- package/src/contracts/generated/index.ts +7 -7
- package/src/contracts/generated/schemas.ts +565 -0
- package/src/contracts/generated/{contract-types.ts → types.ts} +42 -15
- package/dist-lib/chunks/subpath-Bh1MAmBT.js +0 -165
- package/dist-lib/contracts/generated/contract-schema.d.ts +0 -183
- package/dist-lib/contracts/generated/contract-schema.d.ts.map +0 -1
- package/dist-lib/contracts/generated/contract-types.d.ts.map +0 -1
- package/src/contracts/generated/contract-schema.ts +0 -1237
|
@@ -0,0 +1,565 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @generated by @middag-io/ui-contracts-codegen — DO NOT EDIT BY HAND.
|
|
3
|
+
*
|
|
4
|
+
* Zod schemas of the wire contract, one per $def. Lenient on unknown keys.
|
|
5
|
+
*
|
|
6
|
+
* Source of truth: middag-io/ui value objects -> JSON Schema (draft 2020-12).
|
|
7
|
+
* Regenerate: npm run gen:contracts
|
|
8
|
+
* Drift gate: npm run gen:contracts:check
|
|
9
|
+
*
|
|
10
|
+
* @source middag-io/middag-php-ui@v1.11.0 schema/{page-contract.json,fragment.json}
|
|
11
|
+
* @contract-version 1
|
|
12
|
+
* @hash 63f5044005aa4225
|
|
13
|
+
*/
|
|
14
|
+
import { z } from "zod";
|
|
15
|
+
import type { NavigationNode, FormSectionNode, FormGroupNode, FormSchemaNode } from "./types.js";
|
|
16
|
+
|
|
17
|
+
export const TranslatableSchema = z.object({
|
|
18
|
+
"key": z.string(),
|
|
19
|
+
"domain": z.string(),
|
|
20
|
+
"params": z.record(z.string(), z.unknown()).optional(),
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
export const LabelSchema = z.union([z.string(), TranslatableSchema]);
|
|
24
|
+
|
|
25
|
+
export const BreadcrumbSchema = z.object({
|
|
26
|
+
"label": LabelSchema,
|
|
27
|
+
"href": z.string().optional(),
|
|
28
|
+
"external": z.literal(true).optional(),
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
export const HttpMethodSchema = z.enum(["get", "post", "put", "patch", "delete"]);
|
|
32
|
+
|
|
33
|
+
export const ActionTargetSchema = z.union([z.object({
|
|
34
|
+
"kind": z.literal("link"),
|
|
35
|
+
"href": z.string(),
|
|
36
|
+
"external": z.literal(true).optional(),
|
|
37
|
+
}), z.object({
|
|
38
|
+
"kind": z.literal("route"),
|
|
39
|
+
"route": z.string(),
|
|
40
|
+
"params": z.record(z.string(), z.unknown()).optional(),
|
|
41
|
+
}), z.object({
|
|
42
|
+
"kind": z.literal("request"),
|
|
43
|
+
"endpoint": z.string(),
|
|
44
|
+
"method": HttpMethodSchema,
|
|
45
|
+
}), z.object({
|
|
46
|
+
"kind": z.literal("panel"),
|
|
47
|
+
})]);
|
|
48
|
+
|
|
49
|
+
export const ActionIntentSchema = z.union([z.enum(["primary", "secondary", "danger", "success", "warning", "info", "link", "ghost"]), z.string()]);
|
|
50
|
+
|
|
51
|
+
export const ConfirmationSchema = z.object({
|
|
52
|
+
"title": LabelSchema,
|
|
53
|
+
"message": LabelSchema,
|
|
54
|
+
"variant": z.string(),
|
|
55
|
+
"confirmLabel": LabelSchema.optional(),
|
|
56
|
+
"cancelLabel": LabelSchema.optional(),
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
export const ActionSchema = z.object({
|
|
60
|
+
"id": z.string(),
|
|
61
|
+
"label": LabelSchema,
|
|
62
|
+
"target": ActionTargetSchema,
|
|
63
|
+
"intent": ActionIntentSchema,
|
|
64
|
+
"icon": z.string().optional(),
|
|
65
|
+
"confirmation": ConfirmationSchema.optional(),
|
|
66
|
+
"capability": z.string().optional(),
|
|
67
|
+
"disabled": z.literal(true).optional(),
|
|
68
|
+
"loading": z.literal(true).optional(),
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
export const PageMetaSchema = z.object({
|
|
72
|
+
"key": z.string(),
|
|
73
|
+
"title": LabelSchema,
|
|
74
|
+
"subtitle": LabelSchema.optional(),
|
|
75
|
+
"breadcrumbs": z.array(BreadcrumbSchema).optional(),
|
|
76
|
+
"actions": z.array(ActionSchema).optional(),
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
export const PollConfigSchema = z.object({
|
|
80
|
+
"endpoint": z.string(),
|
|
81
|
+
"intervalMs": z.number().int(),
|
|
82
|
+
"pauseWhenHidden": z.boolean(),
|
|
83
|
+
"stopAfterMs": z.number().int().optional(),
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
export const BlockDescriptorSchema = z.object({
|
|
87
|
+
"type": z.string(),
|
|
88
|
+
"key": z.string(),
|
|
89
|
+
"data": z.union([z.record(z.string(), z.unknown()), z.array(z.unknown()).max(0)]),
|
|
90
|
+
"variant": z.string().optional(),
|
|
91
|
+
"title": LabelSchema.optional(),
|
|
92
|
+
"subtitle": LabelSchema.optional(),
|
|
93
|
+
"actions": z.array(ActionSchema).optional(),
|
|
94
|
+
"meta": z.record(z.string(), z.unknown()).optional(),
|
|
95
|
+
"poll": PollConfigSchema.optional(),
|
|
96
|
+
"deferred": z.boolean().optional(),
|
|
97
|
+
"remember": z.boolean().optional(),
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
export const LayoutDescriptorSchema = z.object({
|
|
101
|
+
"template": z.string(),
|
|
102
|
+
"regions": z.union([z.record(z.string(), z.array(BlockDescriptorSchema)), z.array(z.unknown()).max(0)]),
|
|
103
|
+
"meta": z.record(z.string(), z.unknown()).optional(),
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
export const ThemeModeSchema = z.union([z.enum(["light", "dark", "system"]), z.string()]);
|
|
107
|
+
|
|
108
|
+
export const UserPreferencesSchema = z.object({
|
|
109
|
+
"theme": ThemeModeSchema,
|
|
110
|
+
"locale": z.string(),
|
|
111
|
+
"timezone": z.string().optional(),
|
|
112
|
+
"dateFormat": z.string().optional(),
|
|
113
|
+
"numberFormat": z.string().optional(),
|
|
114
|
+
}).catchall(z.unknown());
|
|
115
|
+
|
|
116
|
+
export const IdentitySchema = z.object({
|
|
117
|
+
"id": z.string(),
|
|
118
|
+
"name": z.string(),
|
|
119
|
+
"email": z.string().optional(),
|
|
120
|
+
"avatarUrl": z.string().optional(),
|
|
121
|
+
"roles": z.array(z.string()).optional(),
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
export const BrandingSchema = z.object({
|
|
125
|
+
"appName": z.string(),
|
|
126
|
+
"logoUrl": z.string().optional(),
|
|
127
|
+
"logoCompactUrl": z.string().optional(),
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
export const PageResourcesSchema = z.object({
|
|
131
|
+
"preferences": UserPreferencesSchema,
|
|
132
|
+
"capabilities": z.union([z.record(z.string(), z.boolean()), z.array(z.unknown()).max(0)]),
|
|
133
|
+
"featureFlags": z.union([z.record(z.string(), z.boolean()), z.array(z.unknown()).max(0)]),
|
|
134
|
+
"user": IdentitySchema.optional(),
|
|
135
|
+
"branding": BrandingSchema.optional(),
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
export const NotificationLevelSchema = z.union([z.enum(["success", "info", "warning", "error"]), z.string()]);
|
|
139
|
+
|
|
140
|
+
export const NotificationSchema = z.object({
|
|
141
|
+
"level": NotificationLevelSchema,
|
|
142
|
+
"message": LabelSchema,
|
|
143
|
+
"dismissible": z.boolean(),
|
|
144
|
+
"title": LabelSchema.optional(),
|
|
145
|
+
"timeout": z.number().int().optional(),
|
|
146
|
+
"action": ActionSchema.optional(),
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
export const PageContractSchema = z.object({
|
|
150
|
+
"version": z.literal("1"),
|
|
151
|
+
"shell": z.string(),
|
|
152
|
+
"page": PageMetaSchema,
|
|
153
|
+
"layout": LayoutDescriptorSchema,
|
|
154
|
+
"resources": PageResourcesSchema.optional(),
|
|
155
|
+
"notifications": z.array(NotificationSchema).optional(),
|
|
156
|
+
"entities": z.record(z.string(), z.string()).optional(),
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
export const FragmentKindSchema = z.enum(["block", "region", "table", "form", "detail", "inspector", "notifications", "custom"]);
|
|
160
|
+
|
|
161
|
+
export const ResourcePatchSchema = z.union([z.object({
|
|
162
|
+
"preferences": UserPreferencesSchema.optional(),
|
|
163
|
+
"capabilities": z.record(z.string(), z.boolean()).optional(),
|
|
164
|
+
"featureFlags": z.record(z.string(), z.boolean()).optional(),
|
|
165
|
+
}), z.array(z.unknown()).max(0)]);
|
|
166
|
+
|
|
167
|
+
export const FragmentSchema = z.object({
|
|
168
|
+
"version": z.literal("1"),
|
|
169
|
+
"kind": FragmentKindSchema,
|
|
170
|
+
"payload": z.record(z.string(), z.unknown()).optional(),
|
|
171
|
+
"notifications": z.array(NotificationSchema).optional(),
|
|
172
|
+
"resources": ResourcePatchSchema.optional(),
|
|
173
|
+
"customType": z.string().optional(),
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
export const InspectorDescriptorSchema = z.object({
|
|
177
|
+
"endpoint": z.string(),
|
|
178
|
+
"width": z.number().int(),
|
|
179
|
+
"poll": PollConfigSchema.optional(),
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
export const EditablePanelDescriptorSchema = z.object({
|
|
183
|
+
"endpoint": z.string(),
|
|
184
|
+
"submitEndpoint": z.string().optional(),
|
|
185
|
+
"submitMethod": z.enum(["post", "put", "patch"]),
|
|
186
|
+
"width": z.number().int(),
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
export const NavigationNodeSchema: z.ZodType<NavigationNode> = z.object({
|
|
190
|
+
"key": z.string(),
|
|
191
|
+
"label": LabelSchema,
|
|
192
|
+
"icon": z.string().optional(),
|
|
193
|
+
"href": z.string().optional(),
|
|
194
|
+
"badge": z.string().optional(),
|
|
195
|
+
"active": z.literal(true).optional(),
|
|
196
|
+
"drilldown": z.literal(true).optional(),
|
|
197
|
+
"collapsible": z.literal(true).optional(),
|
|
198
|
+
"defaultOpen": z.literal(true).optional(),
|
|
199
|
+
"children": z.array(z.lazy(() => NavigationNodeSchema)).optional(),
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
export const ValueFormatSchema = z.union([z.enum(["text", "date", "datetime", "time", "number", "currency", "boolean", "badge"]), z.string()]);
|
|
203
|
+
|
|
204
|
+
export const ColumnVariantSchema = z.union([z.enum(["text", "status", "badge", "boolean", "timestamp", "link", "rich_status", "html", "link_group", "annotated", "progress"]), z.string()]);
|
|
205
|
+
|
|
206
|
+
export const ColumnSchema = z.object({
|
|
207
|
+
"key": z.string(),
|
|
208
|
+
"label": LabelSchema,
|
|
209
|
+
"sortable": z.boolean(),
|
|
210
|
+
"searchable": z.boolean(),
|
|
211
|
+
"format": ValueFormatSchema,
|
|
212
|
+
"formatOptions": z.record(z.string(), z.unknown()).optional(),
|
|
213
|
+
"options": z.record(z.string(), z.unknown()).optional(),
|
|
214
|
+
"variant": ColumnVariantSchema.optional(),
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
export const FilterTypeSchema = z.union([z.enum(["select", "text", "date", "date_range", "boolean", "number_range"]), z.string()]);
|
|
218
|
+
|
|
219
|
+
export const FilterDefinitionSchema = z.object({
|
|
220
|
+
"key": z.string(),
|
|
221
|
+
"label": LabelSchema,
|
|
222
|
+
"type": FilterTypeSchema,
|
|
223
|
+
"options": z.array(z.object({
|
|
224
|
+
"value": z.unknown(),
|
|
225
|
+
"label": LabelSchema,
|
|
226
|
+
})).optional(),
|
|
227
|
+
"placeholder": LabelSchema.optional(),
|
|
228
|
+
"default": z.unknown().optional(),
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
export const TableDisplayOptionsSchema = z.object({
|
|
232
|
+
"perPage": z.number().int(),
|
|
233
|
+
"sortDirection": z.string(),
|
|
234
|
+
"selectable": z.boolean(),
|
|
235
|
+
"searchable": z.boolean(),
|
|
236
|
+
"sortColumn": z.string().optional(),
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
export const TableConfigSchema = z.object({
|
|
240
|
+
"columns": z.array(ColumnSchema),
|
|
241
|
+
"filters": z.array(FilterDefinitionSchema).optional(),
|
|
242
|
+
"rowActions": z.array(ActionSchema).optional(),
|
|
243
|
+
"bulkActions": z.array(ActionSchema).optional(),
|
|
244
|
+
"options": TableDisplayOptionsSchema,
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
export const PaginationSchema = z.object({
|
|
248
|
+
"page": z.number().int(),
|
|
249
|
+
"perPage": z.number().int(),
|
|
250
|
+
"total": z.number().int(),
|
|
251
|
+
"lastPage": z.number().int(),
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
export const ChartSeriesSchema = z.object({
|
|
255
|
+
"key": z.string(),
|
|
256
|
+
"label": z.string(),
|
|
257
|
+
"color": z.string().optional(),
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
export const TabSchema = z.object({
|
|
261
|
+
"id": z.string(),
|
|
262
|
+
"label": LabelSchema,
|
|
263
|
+
"blocks": z.array(BlockDescriptorSchema),
|
|
264
|
+
"disabled": z.boolean().optional(),
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
export const FormStepSchema = z.object({
|
|
268
|
+
"id": z.string(),
|
|
269
|
+
"label": LabelSchema,
|
|
270
|
+
"fields": z.array(z.string()),
|
|
271
|
+
"help": LabelSchema.optional(),
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
export const FieldConstraintsSchema = z.union([z.object({
|
|
275
|
+
"required": z.literal(true).optional(),
|
|
276
|
+
"min": z.number().int().optional(),
|
|
277
|
+
"max": z.number().int().optional(),
|
|
278
|
+
"minLength": z.number().int().optional(),
|
|
279
|
+
"maxLength": z.number().int().optional(),
|
|
280
|
+
"pattern": z.string().optional(),
|
|
281
|
+
"step": z.string().optional(),
|
|
282
|
+
}), z.array(z.unknown()).max(0)]);
|
|
283
|
+
|
|
284
|
+
export const FileValueSchema = z.union([z.string(), z.object({
|
|
285
|
+
"url": z.string(),
|
|
286
|
+
"name": z.string().optional(),
|
|
287
|
+
"size": z.number().int().optional(),
|
|
288
|
+
"type": z.string().optional(),
|
|
289
|
+
"id": z.string().optional(),
|
|
290
|
+
"uploadToken": z.string().optional(),
|
|
291
|
+
})]);
|
|
292
|
+
|
|
293
|
+
export const FieldErrorSchema = z.union([z.string(), z.array(z.string())]);
|
|
294
|
+
|
|
295
|
+
export const FormErrorsSchema = z.record(z.string(), FieldErrorSchema);
|
|
296
|
+
|
|
297
|
+
export const FormFieldValidationSchema = z.object({
|
|
298
|
+
"minLength": z.number().int().optional(),
|
|
299
|
+
"maxLength": z.number().int().optional(),
|
|
300
|
+
"pattern": z.string().optional(),
|
|
301
|
+
"patternMessage": z.string().optional(),
|
|
302
|
+
});
|
|
303
|
+
|
|
304
|
+
export const FormConditionSchema = z.object({
|
|
305
|
+
"field": z.string(),
|
|
306
|
+
"operator": z.enum(["equals", "not_equals", "in", "not_in"]),
|
|
307
|
+
"value": z.union([z.string(), z.array(z.string())]),
|
|
308
|
+
});
|
|
309
|
+
|
|
310
|
+
export const FieldPropsBaseSchema = z.object({
|
|
311
|
+
"label": z.string(),
|
|
312
|
+
"placeholder": z.string().optional(),
|
|
313
|
+
"helpText": z.string().optional(),
|
|
314
|
+
"required": z.boolean().optional(),
|
|
315
|
+
"disabled": z.boolean().optional(),
|
|
316
|
+
"readOnly": z.boolean().optional(),
|
|
317
|
+
"validation": FormFieldValidationSchema.optional(),
|
|
318
|
+
"visible_when": FormConditionSchema.optional(),
|
|
319
|
+
"hidden_when": FormConditionSchema.optional(),
|
|
320
|
+
"disabled_when": FormConditionSchema.optional(),
|
|
321
|
+
"required_when": FormConditionSchema.optional(),
|
|
322
|
+
});
|
|
323
|
+
|
|
324
|
+
export const OptionFieldPropsSchema = z.intersection(FieldPropsBaseSchema, z.object({
|
|
325
|
+
"options": z.array(z.object({
|
|
326
|
+
"value": z.string(),
|
|
327
|
+
"label": z.string(),
|
|
328
|
+
})).optional(),
|
|
329
|
+
}));
|
|
330
|
+
|
|
331
|
+
export const FormFieldDocumentMaskSchema = z.object({
|
|
332
|
+
"pattern": z.string(),
|
|
333
|
+
"maxLength": z.number().int(),
|
|
334
|
+
"placeholder": z.string().optional(),
|
|
335
|
+
});
|
|
336
|
+
|
|
337
|
+
export const FormFieldNodeSchema = z.union([z.object({
|
|
338
|
+
"kind": z.literal("field"),
|
|
339
|
+
"key": z.string(),
|
|
340
|
+
"component": z.enum(["text", "email", "url", "password", "color"]),
|
|
341
|
+
"props": FieldPropsBaseSchema,
|
|
342
|
+
}), z.object({
|
|
343
|
+
"kind": z.literal("field"),
|
|
344
|
+
"key": z.string(),
|
|
345
|
+
"component": z.literal("textarea"),
|
|
346
|
+
"props": z.intersection(FieldPropsBaseSchema, z.object({
|
|
347
|
+
"rows": z.number().int().optional(),
|
|
348
|
+
})),
|
|
349
|
+
}), z.object({
|
|
350
|
+
"kind": z.literal("field"),
|
|
351
|
+
"key": z.string(),
|
|
352
|
+
"component": z.literal("otp"),
|
|
353
|
+
"props": z.intersection(FieldPropsBaseSchema, z.object({
|
|
354
|
+
"maxLength": z.number().int().optional(),
|
|
355
|
+
"pattern": z.enum(["digits", "alphanumeric"]).optional(),
|
|
356
|
+
"groupSize": z.number().int().optional(),
|
|
357
|
+
})),
|
|
358
|
+
}), z.object({
|
|
359
|
+
"kind": z.literal("field"),
|
|
360
|
+
"key": z.string(),
|
|
361
|
+
"component": z.enum(["int", "float"]),
|
|
362
|
+
"props": z.intersection(FieldPropsBaseSchema, z.object({
|
|
363
|
+
"min": z.number().optional(),
|
|
364
|
+
"max": z.number().optional(),
|
|
365
|
+
"step": z.number().optional(),
|
|
366
|
+
})),
|
|
367
|
+
}), z.object({
|
|
368
|
+
"kind": z.literal("field"),
|
|
369
|
+
"key": z.string(),
|
|
370
|
+
"component": z.literal("slider"),
|
|
371
|
+
"props": z.intersection(FieldPropsBaseSchema, z.object({
|
|
372
|
+
"min": z.number().optional(),
|
|
373
|
+
"max": z.number().optional(),
|
|
374
|
+
"step": z.number().optional(),
|
|
375
|
+
"multiple": z.boolean().optional(),
|
|
376
|
+
})),
|
|
377
|
+
}), z.object({
|
|
378
|
+
"kind": z.literal("field"),
|
|
379
|
+
"key": z.string(),
|
|
380
|
+
"component": z.enum(["select", "radio"]),
|
|
381
|
+
"props": OptionFieldPropsSchema,
|
|
382
|
+
}), z.object({
|
|
383
|
+
"kind": z.literal("field"),
|
|
384
|
+
"key": z.string(),
|
|
385
|
+
"component": z.literal("multiselect"),
|
|
386
|
+
"props": OptionFieldPropsSchema,
|
|
387
|
+
}), z.object({
|
|
388
|
+
"kind": z.literal("field"),
|
|
389
|
+
"key": z.string(),
|
|
390
|
+
"component": z.literal("native_select"),
|
|
391
|
+
"props": OptionFieldPropsSchema,
|
|
392
|
+
}), z.object({
|
|
393
|
+
"kind": z.literal("field"),
|
|
394
|
+
"key": z.string(),
|
|
395
|
+
"component": z.enum(["checkbox", "switch"]),
|
|
396
|
+
"props": FieldPropsBaseSchema,
|
|
397
|
+
}), z.object({
|
|
398
|
+
"kind": z.literal("field"),
|
|
399
|
+
"key": z.string(),
|
|
400
|
+
"component": z.enum(["date", "datetime"]),
|
|
401
|
+
"props": FieldPropsBaseSchema,
|
|
402
|
+
}), z.object({
|
|
403
|
+
"kind": z.literal("field"),
|
|
404
|
+
"key": z.string(),
|
|
405
|
+
"component": z.literal("duration"),
|
|
406
|
+
"props": FieldPropsBaseSchema,
|
|
407
|
+
}), z.object({
|
|
408
|
+
"kind": z.literal("field"),
|
|
409
|
+
"key": z.string(),
|
|
410
|
+
"component": z.literal("file"),
|
|
411
|
+
"props": z.intersection(FieldPropsBaseSchema, z.object({
|
|
412
|
+
"accept": z.string().optional(),
|
|
413
|
+
"multiple": z.boolean().optional(),
|
|
414
|
+
"maxFiles": z.number().int().optional(),
|
|
415
|
+
"maxSize": z.number().int().optional(),
|
|
416
|
+
})),
|
|
417
|
+
}), z.object({
|
|
418
|
+
"kind": z.literal("field"),
|
|
419
|
+
"key": z.string(),
|
|
420
|
+
"component": z.literal("entity_picker"),
|
|
421
|
+
"props": z.intersection(OptionFieldPropsSchema, z.object({
|
|
422
|
+
"autocompleteHref": z.string().optional(),
|
|
423
|
+
"autocompleteMinChars": z.number().int().optional(),
|
|
424
|
+
"entityDisplayField": z.string().optional(),
|
|
425
|
+
"entitySubtitleField": z.string().optional(),
|
|
426
|
+
"entityAvatarField": z.string().optional(),
|
|
427
|
+
})),
|
|
428
|
+
}), z.object({
|
|
429
|
+
"kind": z.literal("field"),
|
|
430
|
+
"key": z.string(),
|
|
431
|
+
"component": z.literal("phone"),
|
|
432
|
+
"props": z.intersection(FieldPropsBaseSchema, z.object({
|
|
433
|
+
"defaultCountry": z.string().optional(),
|
|
434
|
+
"fixedCountry": z.boolean().optional(),
|
|
435
|
+
})),
|
|
436
|
+
}), z.object({
|
|
437
|
+
"kind": z.literal("field"),
|
|
438
|
+
"key": z.string(),
|
|
439
|
+
"component": z.literal("document"),
|
|
440
|
+
"props": z.intersection(FieldPropsBaseSchema, z.object({
|
|
441
|
+
"documentType": z.string().optional(),
|
|
442
|
+
"documentScope": z.enum(["person", "company", "any"]).optional(),
|
|
443
|
+
"documentMasks": z.record(z.string(), FormFieldDocumentMaskSchema).optional(),
|
|
444
|
+
})),
|
|
445
|
+
}), z.object({
|
|
446
|
+
"kind": z.literal("field"),
|
|
447
|
+
"key": z.string(),
|
|
448
|
+
"component": z.literal("currency"),
|
|
449
|
+
"props": z.intersection(FieldPropsBaseSchema, z.object({
|
|
450
|
+
"currency": z.string().optional(),
|
|
451
|
+
"currencyLocale": z.string().optional(),
|
|
452
|
+
})),
|
|
453
|
+
}), z.object({
|
|
454
|
+
"kind": z.literal("field"),
|
|
455
|
+
"key": z.string(),
|
|
456
|
+
"component": z.literal("slug"),
|
|
457
|
+
"props": z.intersection(FieldPropsBaseSchema, z.object({
|
|
458
|
+
"sourceField": z.string().optional(),
|
|
459
|
+
"prefix": z.string().optional(),
|
|
460
|
+
})),
|
|
461
|
+
}), z.object({
|
|
462
|
+
"kind": z.literal("field"),
|
|
463
|
+
"key": z.string(),
|
|
464
|
+
"component": z.literal("tags"),
|
|
465
|
+
"props": z.intersection(FieldPropsBaseSchema, z.object({
|
|
466
|
+
"maxTags": z.number().int().optional(),
|
|
467
|
+
})),
|
|
468
|
+
}), z.object({
|
|
469
|
+
"kind": z.literal("field"),
|
|
470
|
+
"key": z.string(),
|
|
471
|
+
"component": z.literal("rating"),
|
|
472
|
+
"props": z.intersection(FieldPropsBaseSchema, z.object({
|
|
473
|
+
"maxRating": z.number().int().optional(),
|
|
474
|
+
})),
|
|
475
|
+
}), z.object({
|
|
476
|
+
"kind": z.literal("field"),
|
|
477
|
+
"key": z.string(),
|
|
478
|
+
"component": z.literal("date_range"),
|
|
479
|
+
"props": z.intersection(FieldPropsBaseSchema, z.object({
|
|
480
|
+
"operator": z.string().optional(),
|
|
481
|
+
})),
|
|
482
|
+
}), z.object({
|
|
483
|
+
"kind": z.literal("field"),
|
|
484
|
+
"key": z.string(),
|
|
485
|
+
"component": z.literal("hidden"),
|
|
486
|
+
"props": FieldPropsBaseSchema,
|
|
487
|
+
}), z.object({
|
|
488
|
+
"kind": z.literal("field"),
|
|
489
|
+
"key": z.string(),
|
|
490
|
+
"component": z.literal("static"),
|
|
491
|
+
"props": FieldPropsBaseSchema,
|
|
492
|
+
}), z.object({
|
|
493
|
+
"kind": z.literal("field"),
|
|
494
|
+
"key": z.string(),
|
|
495
|
+
"component": z.literal("header"),
|
|
496
|
+
"props": z.object({
|
|
497
|
+
"label": z.string(),
|
|
498
|
+
}),
|
|
499
|
+
}), z.object({
|
|
500
|
+
"kind": z.literal("field"),
|
|
501
|
+
"key": z.string(),
|
|
502
|
+
"component": z.enum(["richtext", "time"]),
|
|
503
|
+
"props": FieldPropsBaseSchema,
|
|
504
|
+
}), z.object({
|
|
505
|
+
"kind": z.literal("field"),
|
|
506
|
+
"key": z.string(),
|
|
507
|
+
"component": z.literal("autocomplete"),
|
|
508
|
+
"props": OptionFieldPropsSchema,
|
|
509
|
+
})]);
|
|
510
|
+
|
|
511
|
+
export const FormSectionNodeSchema: z.ZodType<FormSectionNode> = z.object({
|
|
512
|
+
"kind": z.literal("section"),
|
|
513
|
+
"id": z.string(),
|
|
514
|
+
"label": z.union([z.string(), TranslatableSchema, z.null()]),
|
|
515
|
+
"defaultCollapsed": z.boolean().optional(),
|
|
516
|
+
"children": z.array(z.lazy(() => FormSchemaNodeSchema)),
|
|
517
|
+
});
|
|
518
|
+
|
|
519
|
+
export const FormGroupNodeSchema: z.ZodType<FormGroupNode> = z.object({
|
|
520
|
+
"kind": z.literal("group"),
|
|
521
|
+
"id": z.string(),
|
|
522
|
+
"columns": z.union([z.literal(1), z.literal(2)]).optional(),
|
|
523
|
+
"children": z.array(z.lazy(() => FormSchemaNodeSchema)),
|
|
524
|
+
});
|
|
525
|
+
|
|
526
|
+
export const FormHeaderNodeSchema = z.object({
|
|
527
|
+
"kind": z.literal("header"),
|
|
528
|
+
"label": z.string(),
|
|
529
|
+
});
|
|
530
|
+
|
|
531
|
+
export const FormSchemaNodeSchema: z.ZodType<FormSchemaNode> = z.union([FormFieldNodeSchema, FormSectionNodeSchema, FormGroupNodeSchema, FormHeaderNodeSchema]);
|
|
532
|
+
|
|
533
|
+
export const RegionUpdateModeSchema = z.enum(["replace", "append", "prepend", "remove", "update"]);
|
|
534
|
+
|
|
535
|
+
export const RegionUpdateSchema = z.object({
|
|
536
|
+
"region": z.string(),
|
|
537
|
+
"mode": RegionUpdateModeSchema,
|
|
538
|
+
"blocks": z.array(BlockDescriptorSchema).optional(),
|
|
539
|
+
"keys": z.array(z.string()).optional(),
|
|
540
|
+
});
|
|
541
|
+
|
|
542
|
+
export const ActionResultSchema = z.object({
|
|
543
|
+
"success": z.boolean(),
|
|
544
|
+
"notifications": z.array(NotificationSchema).optional(),
|
|
545
|
+
"redirect": z.string().optional(),
|
|
546
|
+
"refreshBlocks": z.array(z.string()).optional(),
|
|
547
|
+
"errors": FormErrorsSchema.optional(),
|
|
548
|
+
"fragments": z.array(FragmentSchema).optional(),
|
|
549
|
+
"resources": ResourcePatchSchema.optional(),
|
|
550
|
+
});
|
|
551
|
+
|
|
552
|
+
export const ActionTargetKindSchema = z.enum(["link", "route", "request", "panel"]);
|
|
553
|
+
|
|
554
|
+
export const ChartTypeSchema = z.union([z.enum(["line", "bar", "area"]), z.string()]);
|
|
555
|
+
|
|
556
|
+
export const ConditionOperatorSchema = z.enum(["eq", "neq", "in", "not_in", "gt", "gte", "lt", "lte", "truthy", "falsy", "exists", "empty", "matches"]);
|
|
557
|
+
|
|
558
|
+
export const FieldTypeSchema = z.union([z.enum(["text", "textarea", "richtext", "password", "otp", "email", "url", "int", "float", "slider", "select", "multiselect", "native_select", "radio", "checkbox", "switch", "date", "datetime", "time", "duration", "file", "entity_picker", "autocomplete", "tags", "hidden", "static", "header"]), z.string()]);
|
|
559
|
+
|
|
560
|
+
export const FormComponentSchema = z.union([z.enum(["text", "textarea", "password", "otp", "email", "url", "int", "float", "slider", "select", "native_select", "multiselect", "radio", "checkbox", "switch", "date", "datetime", "duration", "file", "entity_picker", "phone", "document", "currency", "color", "slug", "tags", "rating", "date_range", "hidden", "static", "header", "richtext", "time", "autocomplete"]), z.string()]);
|
|
561
|
+
|
|
562
|
+
export const RenderTargetSchema = z.enum(["html", "props"]);
|
|
563
|
+
|
|
564
|
+
export const pageContractSchemaCore = PageContractSchema;
|
|
565
|
+
export const fragmentSchemaCore = FragmentSchema;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @generated by
|
|
2
|
+
* @generated by @middag-io/ui-contracts-codegen — DO NOT EDIT BY HAND.
|
|
3
3
|
*
|
|
4
|
-
* TypeScript types
|
|
4
|
+
* TypeScript types of the wire contract.
|
|
5
5
|
*
|
|
6
|
-
* Source of truth: middag-
|
|
6
|
+
* Source of truth: middag-io/ui value objects -> JSON Schema (draft 2020-12).
|
|
7
7
|
* Regenerate: npm run gen:contracts
|
|
8
8
|
* Drift gate: npm run gen:contracts:check
|
|
9
9
|
*
|
|
10
|
-
* @source middag-php-ui
|
|
10
|
+
* @source middag-io/middag-php-ui@v1.11.0 schema/{page-contract.json,fragment.json}
|
|
11
11
|
* @contract-version 1
|
|
12
|
-
* @hash
|
|
12
|
+
* @hash 63f5044005aa4225
|
|
13
13
|
*/
|
|
14
14
|
export type Label = string | Translatable;
|
|
15
15
|
export type ActionTarget =
|
|
@@ -42,9 +42,10 @@ export type ActionIntent =
|
|
|
42
42
|
| "warning"
|
|
43
43
|
| "info"
|
|
44
44
|
| "link"
|
|
45
|
-
| "ghost"
|
|
46
|
-
|
|
47
|
-
export type
|
|
45
|
+
| "ghost"
|
|
46
|
+
| (string & {});
|
|
47
|
+
export type ThemeMode = "light" | "dark" | "system" | (string & {});
|
|
48
|
+
export type NotificationLevel = "success" | "info" | "warning" | "error" | (string & {});
|
|
48
49
|
export type FragmentKind =
|
|
49
50
|
| "block"
|
|
50
51
|
| "region"
|
|
@@ -73,7 +74,8 @@ export type ValueFormat =
|
|
|
73
74
|
| "number"
|
|
74
75
|
| "currency"
|
|
75
76
|
| "boolean"
|
|
76
|
-
| "badge"
|
|
77
|
+
| "badge"
|
|
78
|
+
| (string & {});
|
|
77
79
|
export type ColumnVariant =
|
|
78
80
|
| "text"
|
|
79
81
|
| "status"
|
|
@@ -85,8 +87,16 @@ export type ColumnVariant =
|
|
|
85
87
|
| "html"
|
|
86
88
|
| "link_group"
|
|
87
89
|
| "annotated"
|
|
88
|
-
| "progress"
|
|
89
|
-
|
|
90
|
+
| "progress"
|
|
91
|
+
| (string & {});
|
|
92
|
+
export type FilterType =
|
|
93
|
+
| "select"
|
|
94
|
+
| "text"
|
|
95
|
+
| "date"
|
|
96
|
+
| "date_range"
|
|
97
|
+
| "boolean"
|
|
98
|
+
| "number_range"
|
|
99
|
+
| (string & {});
|
|
90
100
|
export type FieldConstraints =
|
|
91
101
|
| {
|
|
92
102
|
required?: true;
|
|
@@ -297,6 +307,18 @@ export type FormFieldNode =
|
|
|
297
307
|
props: {
|
|
298
308
|
label: string;
|
|
299
309
|
};
|
|
310
|
+
}
|
|
311
|
+
| {
|
|
312
|
+
kind: "field";
|
|
313
|
+
key: string;
|
|
314
|
+
component: "richtext" | "time";
|
|
315
|
+
props: FieldPropsBase;
|
|
316
|
+
}
|
|
317
|
+
| {
|
|
318
|
+
kind: "field";
|
|
319
|
+
key: string;
|
|
320
|
+
component: "autocomplete";
|
|
321
|
+
props: OptionFieldProps;
|
|
300
322
|
};
|
|
301
323
|
export type OptionFieldProps = FieldPropsBase & {
|
|
302
324
|
options?: {
|
|
@@ -306,7 +328,7 @@ export type OptionFieldProps = FieldPropsBase & {
|
|
|
306
328
|
};
|
|
307
329
|
export type RegionUpdateMode = "replace" | "append" | "prepend" | "remove" | "update";
|
|
308
330
|
export type ActionTargetKind = "link" | "route" | "request" | "panel";
|
|
309
|
-
export type ChartType = "line" | "bar" | "area";
|
|
331
|
+
export type ChartType = "line" | "bar" | "area" | (string & {});
|
|
310
332
|
export type ConditionOperator =
|
|
311
333
|
| "eq"
|
|
312
334
|
| "neq"
|
|
@@ -348,7 +370,8 @@ export type FieldType =
|
|
|
348
370
|
| "tags"
|
|
349
371
|
| "hidden"
|
|
350
372
|
| "static"
|
|
351
|
-
| "header"
|
|
373
|
+
| "header"
|
|
374
|
+
| (string & {});
|
|
352
375
|
export type FormComponent =
|
|
353
376
|
| "text"
|
|
354
377
|
| "textarea"
|
|
@@ -380,7 +403,11 @@ export type FormComponent =
|
|
|
380
403
|
| "date_range"
|
|
381
404
|
| "hidden"
|
|
382
405
|
| "static"
|
|
383
|
-
| "header"
|
|
406
|
+
| "header"
|
|
407
|
+
| "richtext"
|
|
408
|
+
| "time"
|
|
409
|
+
| "autocomplete"
|
|
410
|
+
| (string & {});
|
|
384
411
|
export type RenderTarget = "html" | "props";
|
|
385
412
|
|
|
386
413
|
export interface PageContract {
|
|
@@ -643,7 +670,7 @@ export interface FormFieldDocumentMask {
|
|
|
643
670
|
export interface FormSectionNode {
|
|
644
671
|
kind: "section";
|
|
645
672
|
id: string;
|
|
646
|
-
label: string;
|
|
673
|
+
label: string | Translatable | null;
|
|
647
674
|
defaultCollapsed?: boolean;
|
|
648
675
|
children: FormSchemaNode[];
|
|
649
676
|
}
|