@duke333/builder-ui 0.1.4 → 0.1.5
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/README.md +7 -0
- package/dist/{BuilderAdminPages-Buy2nvjs.d.ts → BuilderAdminPages-C-jaMLOa.d.ts} +6 -0
- package/dist/{RuntimeEntryDialog-DAO74GFp.d.ts → RuntimeEntryDialog-Bw741XbS.d.ts} +12 -5
- package/dist/admin/index.d.ts +2 -2
- package/dist/admin/index.js +30 -3
- package/dist/admin/index.js.map +1 -1
- package/dist/components/index.d.ts +5 -3
- package/dist/components/index.js +53 -25
- package/dist/components/index.js.map +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.js +76 -8
- package/dist/index.js.map +1 -1
- package/dist/integration/index.d.ts +1 -1
- package/dist/integration/index.js +30 -3
- package/dist/integration/index.js.map +1 -1
- package/dist/runtime/index.d.ts +3 -1
- package/dist/runtime/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -65,6 +65,13 @@ Use:
|
|
|
65
65
|
- `DynamicList` for list-only read flow
|
|
66
66
|
- `DynamicView` for full CRUD flow
|
|
67
67
|
|
|
68
|
+
Runtime form schemas expose `presentation: "dialog" | "drawer"`. The injected main-form and
|
|
69
|
+
subform `DialogShell` components receive that value and choose the matching host UI shell.
|
|
70
|
+
|
|
71
|
+
When binding a data grid, forward the row click event through `onRowClick(row, event)`. Action
|
|
72
|
+
buttons should pass their click event to `actions.onEdit(row, event)` or
|
|
73
|
+
`actions.onDelete(row, event)` so an action click cannot also open the row editor.
|
|
74
|
+
|
|
68
75
|
## Validation
|
|
69
76
|
|
|
70
77
|
```bash
|
|
@@ -70,6 +70,7 @@ type BuilderEditorSubform = {
|
|
|
70
70
|
childField: string;
|
|
71
71
|
buttonLabel?: string;
|
|
72
72
|
icon?: string;
|
|
73
|
+
presentation?: "dialog" | "drawer";
|
|
73
74
|
};
|
|
74
75
|
type BuilderEditorFormLayoutField = {
|
|
75
76
|
key: string;
|
|
@@ -96,6 +97,7 @@ type BuilderFormEditorEntity<TFieldType extends string = string, TTriggerEvent e
|
|
|
96
97
|
version: number;
|
|
97
98
|
source: BuilderEditorSource;
|
|
98
99
|
schema: {
|
|
100
|
+
presentation?: "dialog" | "drawer";
|
|
99
101
|
fields: BuilderEditorField<TFieldType>[];
|
|
100
102
|
layout?: BuilderEditorFormLayout;
|
|
101
103
|
subforms?: BuilderEditorSubform[];
|
|
@@ -138,6 +140,7 @@ type BuilderFormEditorSubformValues = {
|
|
|
138
140
|
childField: string;
|
|
139
141
|
buttonLabel?: string;
|
|
140
142
|
icon?: string;
|
|
143
|
+
presentation?: "dialog" | "drawer";
|
|
141
144
|
};
|
|
142
145
|
type BuilderFormEditorLayoutFieldValues = {
|
|
143
146
|
key: string;
|
|
@@ -171,6 +174,7 @@ type BuilderEditorFieldTriggerValues = {
|
|
|
171
174
|
type BuilderFormEditorValues<TFieldType extends string = string, TTriggerEvent extends string = string> = {
|
|
172
175
|
title: string;
|
|
173
176
|
description?: string;
|
|
177
|
+
presentation?: "dialog" | "drawer";
|
|
174
178
|
sourceType: "none" | "dbTable" | "apiEndpoint";
|
|
175
179
|
sourceTable: string;
|
|
176
180
|
apiBasePath?: string;
|
|
@@ -241,6 +245,7 @@ declare function builderFormEditorInputFromValues<TFieldType extends string, TTr
|
|
|
241
245
|
tableName?: undefined;
|
|
242
246
|
} | null;
|
|
243
247
|
schema: {
|
|
248
|
+
presentation: "dialog" | "drawer";
|
|
244
249
|
fields: {
|
|
245
250
|
key: string;
|
|
246
251
|
label: string;
|
|
@@ -280,6 +285,7 @@ declare function builderFormEditorInputFromValues<TFieldType extends string, TTr
|
|
|
280
285
|
childField: string;
|
|
281
286
|
buttonLabel: string | undefined;
|
|
282
287
|
icon: string | undefined;
|
|
288
|
+
presentation: "dialog" | "drawer";
|
|
283
289
|
}[];
|
|
284
290
|
};
|
|
285
291
|
triggers: {
|
|
@@ -2,7 +2,7 @@ import * as react from 'react';
|
|
|
2
2
|
import { ComponentType, ReactNode } from 'react';
|
|
3
3
|
import { BuilderApiContracts } from './api/index.js';
|
|
4
4
|
import { BuilderHooks } from './hooks/index.js';
|
|
5
|
-
import { BuilderRuntimeFormSchemaLike, BuilderRuntimeFormValues, BuilderRuntimeEntryLike, BuilderRuntimeViewLike, BuilderRuntimeEntryValues } from './runtime/index.js';
|
|
5
|
+
import { BuilderRuntimeFormSchemaLike, BuilderRuntimeFormValues, BuilderRuntimeEntryLike, BuilderRuntimeViewLike, BuilderRuntimePresentation, BuilderRuntimeEntryValues } from './runtime/index.js';
|
|
6
6
|
|
|
7
7
|
type DynamicFormContracts = BuilderApiContracts & {
|
|
8
8
|
BuilderForm: {
|
|
@@ -114,9 +114,14 @@ type DynamicViewContracts = BuilderApiContracts & {
|
|
|
114
114
|
type DynamicViewProps = {
|
|
115
115
|
viewId: string;
|
|
116
116
|
};
|
|
117
|
+
type DynamicViewInteractionEvent = {
|
|
118
|
+
defaultPrevented?: boolean;
|
|
119
|
+
target?: unknown;
|
|
120
|
+
stopPropagation?(): void;
|
|
121
|
+
};
|
|
117
122
|
type DynamicViewColumnActions<TEntry> = {
|
|
118
|
-
onEdit(entry: TEntry): void;
|
|
119
|
-
onDelete(entry: TEntry): void;
|
|
123
|
+
onEdit(entry: TEntry, event?: DynamicViewInteractionEvent): void;
|
|
124
|
+
onDelete(entry: TEntry, event?: DynamicViewInteractionEvent): void;
|
|
120
125
|
};
|
|
121
126
|
type DynamicViewDataGridProps<TController> = {
|
|
122
127
|
title?: string;
|
|
@@ -126,7 +131,7 @@ type DynamicViewDataGridProps<TController> = {
|
|
|
126
131
|
searchPlaceholder?: string;
|
|
127
132
|
emptyTitle?: string;
|
|
128
133
|
emptyDescription?: string;
|
|
129
|
-
onRowClick?: (row: unknown) => void;
|
|
134
|
+
onRowClick?: (row: unknown, event?: DynamicViewInteractionEvent) => void;
|
|
130
135
|
toolbarExtra?: ReactNode;
|
|
131
136
|
};
|
|
132
137
|
type DynamicViewAddButtonProps = {
|
|
@@ -154,6 +159,7 @@ type DynamicViewErrorStateProps = {
|
|
|
154
159
|
title: string;
|
|
155
160
|
description: string;
|
|
156
161
|
};
|
|
162
|
+
declare function shouldHandleDynamicViewRowClick(event?: DynamicViewInteractionEvent): boolean;
|
|
157
163
|
type DynamicViewDependencies<C extends DynamicViewContracts, TColumn, TState extends {
|
|
158
164
|
query: C["ListBuilderViewEntriesQuery"];
|
|
159
165
|
}, TController> = {
|
|
@@ -216,6 +222,7 @@ type RuntimeEntryDialogProps<TView, TEntry, TInput> = {
|
|
|
216
222
|
};
|
|
217
223
|
type RuntimeEntryDialogShellProps = {
|
|
218
224
|
open: boolean;
|
|
225
|
+
presentation: BuilderRuntimePresentation;
|
|
219
226
|
title: string;
|
|
220
227
|
description: string;
|
|
221
228
|
onClose: () => void;
|
|
@@ -279,4 +286,4 @@ type RuntimeEntryDialogDependencies<TView extends RuntimeEntryDialogViewLike, TE
|
|
|
279
286
|
};
|
|
280
287
|
declare function createRuntimeEntryDialogComponent<TView extends RuntimeEntryDialogViewLike, TEntry extends BuilderRuntimeEntryLike, TInput extends BuilderRuntimeEntryValues>(deps: RuntimeEntryDialogDependencies<TView, TEntry>): ({ open, view, editing, onClose, onSave, isSaving, }: RuntimeEntryDialogProps<TView, TEntry, TInput>) => react.JSX.Element;
|
|
281
288
|
|
|
282
|
-
export { type
|
|
289
|
+
export { type RuntimeEntryDialogProps as A, type RuntimeEntryDialogSaveArgs as B, type RuntimeEntryDialogShellProps as C, type DynamicFormContracts as D, type RuntimeEntryDialogViewLike as E, createDynamicFormComponent as F, createDynamicListComponent as G, createDynamicViewComponent as H, createRuntimeEntryDialogComponent as I, shouldHandleDynamicViewRowClick as J, type RuntimeEntryDialogDraftRowsChange as R, type DynamicFormDependencies as a, type DynamicFormErrorStateProps as b, type DynamicFormFieldsProps as c, type DynamicFormNotifications as d, type DynamicFormProps as e, type DynamicFormShellProps as f, type DynamicFormSubmitProps as g, type DynamicListContracts as h, type DynamicListDataGridProps as i, type DynamicListDependencies as j, type DynamicListErrorStateProps as k, type DynamicListProps as l, type DynamicViewAddButtonProps as m, type DynamicViewColumnActions as n, type DynamicViewContracts as o, type DynamicViewDataGridProps as p, type DynamicViewDeleteDialogProps as q, type DynamicViewDependencies as r, type DynamicViewEntryDialogProps as s, type DynamicViewErrorStateProps as t, type DynamicViewInteractionEvent as u, type DynamicViewProps as v, type RuntimeEntryDialogActionsProps as w, type RuntimeEntryDialogDependencies as x, type RuntimeEntryDialogFieldsProps as y, type RuntimeEntryDialogNotifications as z };
|
package/dist/admin/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as BuilderViewEditorEntity, C as BuilderViewEditorValues, W as BuilderFormEditorLayoutGroupValues, u as BuilderFormEditorValues, s as BuilderFormEditorFieldValues, X as BuilderFormEditorSubformValues } from '../BuilderAdminPages-
|
|
2
|
-
export { B as BUILDER_EDITOR_NONE_VALUE, a as BuilderAdminPageContracts, b as BuilderAdminPagesOptions, c as BuilderAdminPagesRoutes, d as BuilderDefaultEntity, e as BuilderDefaultEntityListResult, f as BuilderDefaultEntityManagerDependencies, g as BuilderDefaultEntityManagerLabels, h as BuilderDefaultEntityManagerState, i as BuilderDefaultEntityMutation, j as BuilderDefaultEntityQueryResult, k as BuilderDefaultFormEditorBodyOptions, l as BuilderDefaultListEditorBodyOptions, m as BuilderDefaultOption, n as BuilderEditorDbTable, o as BuilderEditorSelectOption, p as BuilderEditorTriggerValues, q as BuilderFormEditorBodyProps, r as BuilderFormEditorEntity, t as BuilderFormEditorPageDependencies, v as BuilderListEditorBodyProps, w as BuilderListEditorColumnValues, x as BuilderListEditorEntity, y as BuilderListEditorPageDependencies, z as BuilderListEditorValues, D as builderEditorOptionsToText, E as builderEditorSearchFieldsToText, F as builderEditorTextToOptions, G as builderEditorTextToSearchFields, Y as builderFormEditorDefaultLayoutGroups, Z as builderFormEditorDefaultSpan, H as builderFormEditorFieldsFromTable, I as builderFormEditorInputFromValues, J as builderFormEditorValuesFromEntity, K as builderListEditorColumnsFromTable, L as builderListEditorInputFromValues, M as builderListEditorValuesFromEntity, N as builderViewEditorInputFromValues, O as builderViewEditorValuesFromEntity, P as createBuilderAdminPages, Q as createBuilderDefaultEntityManagerComponent, R as createBuilderDefaultFormEditorBody, S as createBuilderDefaultListEditorBody, T as createBuilderFormEditorPageComponent, U as createBuilderListEditorPageComponent, V as getBuilderEditorTriggerRoute } from '../BuilderAdminPages-
|
|
1
|
+
import { A as BuilderViewEditorEntity, C as BuilderViewEditorValues, W as BuilderFormEditorLayoutGroupValues, u as BuilderFormEditorValues, s as BuilderFormEditorFieldValues, X as BuilderFormEditorSubformValues } from '../BuilderAdminPages-C-jaMLOa.js';
|
|
2
|
+
export { B as BUILDER_EDITOR_NONE_VALUE, a as BuilderAdminPageContracts, b as BuilderAdminPagesOptions, c as BuilderAdminPagesRoutes, d as BuilderDefaultEntity, e as BuilderDefaultEntityListResult, f as BuilderDefaultEntityManagerDependencies, g as BuilderDefaultEntityManagerLabels, h as BuilderDefaultEntityManagerState, i as BuilderDefaultEntityMutation, j as BuilderDefaultEntityQueryResult, k as BuilderDefaultFormEditorBodyOptions, l as BuilderDefaultListEditorBodyOptions, m as BuilderDefaultOption, n as BuilderEditorDbTable, o as BuilderEditorSelectOption, p as BuilderEditorTriggerValues, q as BuilderFormEditorBodyProps, r as BuilderFormEditorEntity, t as BuilderFormEditorPageDependencies, v as BuilderListEditorBodyProps, w as BuilderListEditorColumnValues, x as BuilderListEditorEntity, y as BuilderListEditorPageDependencies, z as BuilderListEditorValues, D as builderEditorOptionsToText, E as builderEditorSearchFieldsToText, F as builderEditorTextToOptions, G as builderEditorTextToSearchFields, Y as builderFormEditorDefaultLayoutGroups, Z as builderFormEditorDefaultSpan, H as builderFormEditorFieldsFromTable, I as builderFormEditorInputFromValues, J as builderFormEditorValuesFromEntity, K as builderListEditorColumnsFromTable, L as builderListEditorInputFromValues, M as builderListEditorValuesFromEntity, N as builderViewEditorInputFromValues, O as builderViewEditorValuesFromEntity, P as createBuilderAdminPages, Q as createBuilderDefaultEntityManagerComponent, R as createBuilderDefaultFormEditorBody, S as createBuilderDefaultListEditorBody, T as createBuilderFormEditorPageComponent, U as createBuilderListEditorPageComponent, V as getBuilderEditorTriggerRoute } from '../BuilderAdminPages-C-jaMLOa.js';
|
|
3
3
|
import * as react from 'react';
|
|
4
4
|
import { ComponentType, ReactNode } from 'react';
|
|
5
5
|
import { BuilderApiContracts } from '../api/index.js';
|
package/dist/admin/index.js
CHANGED
|
@@ -128,11 +128,13 @@ function builderFormEditorValuesFromEntity(form, emptyValues) {
|
|
|
128
128
|
parentField: subform.parentField,
|
|
129
129
|
childField: subform.childField,
|
|
130
130
|
buttonLabel: subform.buttonLabel ?? "",
|
|
131
|
-
icon: subform.icon ?? ""
|
|
131
|
+
icon: subform.icon ?? "",
|
|
132
|
+
presentation: subform.presentation ?? "dialog"
|
|
132
133
|
}));
|
|
133
134
|
return {
|
|
134
135
|
title: form.title,
|
|
135
136
|
description: form.description ?? "",
|
|
137
|
+
presentation: form.schema.presentation ?? "dialog",
|
|
136
138
|
sourceType: source?.type ?? "none",
|
|
137
139
|
sourceTable: source?.type === "dbTable" ? source.tableName : BUILDER_EDITOR_NONE_VALUE,
|
|
138
140
|
apiBasePath: source?.type === "apiEndpoint" ? source.basePath : "",
|
|
@@ -214,6 +216,7 @@ function builderFormEditorInputFromValues(values) {
|
|
|
214
216
|
description: values.description || null,
|
|
215
217
|
source,
|
|
216
218
|
schema: {
|
|
219
|
+
presentation: values.presentation ?? "dialog",
|
|
217
220
|
fields: values.fields.map((field) => ({
|
|
218
221
|
key: field.key,
|
|
219
222
|
label: field.label,
|
|
@@ -258,7 +261,8 @@ function builderFormEditorInputFromValues(values) {
|
|
|
258
261
|
parentField: subform.parentField,
|
|
259
262
|
childField: subform.childField,
|
|
260
263
|
buttonLabel: subform.buttonLabel?.trim() || void 0,
|
|
261
|
-
icon: subform.icon?.trim() || void 0
|
|
264
|
+
icon: subform.icon?.trim() || void 0,
|
|
265
|
+
presentation: subform.presentation ?? "dialog"
|
|
262
266
|
}))
|
|
263
267
|
},
|
|
264
268
|
triggers: values.triggers.map((trigger) => ({
|
|
@@ -463,6 +467,13 @@ function createBuilderDefaultFormEditorBody(options) {
|
|
|
463
467
|
/* @__PURE__ */ jsx("span", { style: styles.label, children: "Description" }),
|
|
464
468
|
/* @__PURE__ */ jsx("input", { style: styles.input, ...form.register("description") })
|
|
465
469
|
] }),
|
|
470
|
+
/* @__PURE__ */ jsxs("label", { style: styles.field, children: [
|
|
471
|
+
/* @__PURE__ */ jsx("span", { style: styles.label, children: "Presentation" }),
|
|
472
|
+
/* @__PURE__ */ jsxs("select", { style: styles.input, ...form.register("presentation"), children: [
|
|
473
|
+
/* @__PURE__ */ jsx("option", { value: "dialog", children: "Dialog" }),
|
|
474
|
+
/* @__PURE__ */ jsx("option", { value: "drawer", children: "Drawer" })
|
|
475
|
+
] })
|
|
476
|
+
] }),
|
|
466
477
|
/* @__PURE__ */ jsxs("label", { style: styles.field, children: [
|
|
467
478
|
/* @__PURE__ */ jsx("span", { style: styles.label, children: "Datasource" }),
|
|
468
479
|
/* @__PURE__ */ jsxs("select", { style: styles.input, ...form.register("sourceType"), children: [
|
|
@@ -644,7 +655,8 @@ function createBuilderDefaultFormEditorBody(options) {
|
|
|
644
655
|
parentField: "id",
|
|
645
656
|
childField: "parentId",
|
|
646
657
|
buttonLabel: "",
|
|
647
|
-
icon: ""
|
|
658
|
+
icon: "",
|
|
659
|
+
presentation: "dialog"
|
|
648
660
|
}),
|
|
649
661
|
children: "Add subform"
|
|
650
662
|
}
|
|
@@ -671,6 +683,20 @@ function createBuilderDefaultFormEditorBody(options) {
|
|
|
671
683
|
/* @__PURE__ */ jsx("span", { style: styles.label, children: "Child field" }),
|
|
672
684
|
/* @__PURE__ */ jsx("input", { style: styles.input, ...form.register(`subforms.${index}.childField`) })
|
|
673
685
|
] }),
|
|
686
|
+
/* @__PURE__ */ jsxs("label", { style: styles.field, children: [
|
|
687
|
+
/* @__PURE__ */ jsx("span", { style: styles.label, children: "Presentation" }),
|
|
688
|
+
/* @__PURE__ */ jsxs(
|
|
689
|
+
"select",
|
|
690
|
+
{
|
|
691
|
+
style: styles.input,
|
|
692
|
+
...form.register(`subforms.${index}.presentation`),
|
|
693
|
+
children: [
|
|
694
|
+
/* @__PURE__ */ jsx("option", { value: "dialog", children: "Dialog" }),
|
|
695
|
+
/* @__PURE__ */ jsx("option", { value: "drawer", children: "Drawer" })
|
|
696
|
+
]
|
|
697
|
+
}
|
|
698
|
+
)
|
|
699
|
+
] }),
|
|
674
700
|
/* @__PURE__ */ jsx("button", { type: "button", style: styles.button, onClick: () => subformArray.remove(index), children: "Remove" })
|
|
675
701
|
] }, subform.id))
|
|
676
702
|
] }),
|
|
@@ -1534,6 +1560,7 @@ function createBuilderAdminPages({
|
|
|
1534
1560
|
const emptyFormValues = {
|
|
1535
1561
|
title: "",
|
|
1536
1562
|
description: "",
|
|
1563
|
+
presentation: "dialog",
|
|
1537
1564
|
sourceType: "none",
|
|
1538
1565
|
sourceTable: BUILDER_EDITOR_NONE_VALUE,
|
|
1539
1566
|
apiBasePath: "",
|