@duke333/builder-ui 0.1.4 → 0.2.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/README.md +20 -32
- 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/api/index.d.ts +5 -2
- package/dist/api/index.js +9 -1
- package/dist/api/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 +2215 -10
- package/dist/index.js +1919 -1145
- package/dist/index.js.map +1 -1
- package/dist/integration/index.d.ts +3 -1
- package/dist/integration/index.js +45 -5
- 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/dist/styles.css +405 -0
- package/dist/styles.css.map +1 -0
- package/dist/styles.d.ts +2 -0
- package/package.json +10 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BuilderApiContracts, BuilderApiClient, BuilderApiTransport } from '../api/index.js';
|
|
2
|
-
import { P as createBuilderAdminPages, b as BuilderAdminPagesOptions, a as BuilderAdminPageContracts } from '../BuilderAdminPages-
|
|
2
|
+
import { P as createBuilderAdminPages, b as BuilderAdminPagesOptions, a as BuilderAdminPageContracts } from '../BuilderAdminPages-C-jaMLOa.js';
|
|
3
3
|
import { BuilderHooks } from '../hooks/index.js';
|
|
4
4
|
import 'react';
|
|
5
5
|
import 'react-hook-form';
|
|
@@ -20,6 +20,7 @@ type BuilderIntegrationConfig = {
|
|
|
20
20
|
transport: BuilderApiTransport;
|
|
21
21
|
adminBasePath?: string;
|
|
22
22
|
runtimeBasePath?: string;
|
|
23
|
+
apiBasePath?: string;
|
|
23
24
|
adminPages?: Omit<BuilderAdminPagesOptions<BuilderAdminPageContracts>, "hooks" | "routes">;
|
|
24
25
|
permissions?: unknown;
|
|
25
26
|
triggers?: unknown;
|
|
@@ -46,6 +47,7 @@ declare function createBuilderPortalIntegration<C extends BuilderApiContracts>(c
|
|
|
46
47
|
declare function validateBuilderFrontendSetup(config: {
|
|
47
48
|
adminBasePath?: string;
|
|
48
49
|
runtimeBasePath?: string;
|
|
50
|
+
apiBasePath?: string;
|
|
49
51
|
transport?: unknown;
|
|
50
52
|
}): BuilderFrontendSetupValidation;
|
|
51
53
|
|
|
@@ -9,7 +9,15 @@ function fieldOptionsQueryParams(query) {
|
|
|
9
9
|
}
|
|
10
10
|
return flatQuery;
|
|
11
11
|
}
|
|
12
|
-
function createBuilderApiClient(
|
|
12
|
+
function createBuilderApiClient(rootTransport, options = {}) {
|
|
13
|
+
const basePath = options.apiBasePath?.trim().replace(/\/+$/g, "") ?? "";
|
|
14
|
+
const path = (value) => `${basePath}${value}`;
|
|
15
|
+
const transport = {
|
|
16
|
+
get: (value, requestOptions) => rootTransport.get(path(value), requestOptions),
|
|
17
|
+
post: (value, body, requestOptions) => rootTransport.post(path(value), body, requestOptions),
|
|
18
|
+
patch: (value, body, requestOptions) => rootTransport.patch(path(value), body, requestOptions),
|
|
19
|
+
delete: (value, requestOptions) => rootTransport.delete(path(value), requestOptions)
|
|
20
|
+
};
|
|
13
21
|
return {
|
|
14
22
|
listBuilderForms: (query) => transport.get("/builder/forms", {
|
|
15
23
|
query: queryParams(query)
|
|
@@ -217,11 +225,13 @@ function builderFormEditorValuesFromEntity(form, emptyValues) {
|
|
|
217
225
|
parentField: subform.parentField,
|
|
218
226
|
childField: subform.childField,
|
|
219
227
|
buttonLabel: subform.buttonLabel ?? "",
|
|
220
|
-
icon: subform.icon ?? ""
|
|
228
|
+
icon: subform.icon ?? "",
|
|
229
|
+
presentation: subform.presentation ?? "dialog"
|
|
221
230
|
}));
|
|
222
231
|
return {
|
|
223
232
|
title: form.title,
|
|
224
233
|
description: form.description ?? "",
|
|
234
|
+
presentation: form.schema.presentation ?? "dialog",
|
|
225
235
|
sourceType: source?.type ?? "none",
|
|
226
236
|
sourceTable: source?.type === "dbTable" ? source.tableName : BUILDER_EDITOR_NONE_VALUE,
|
|
227
237
|
apiBasePath: source?.type === "apiEndpoint" ? source.basePath : "",
|
|
@@ -303,6 +313,7 @@ function builderFormEditorInputFromValues(values) {
|
|
|
303
313
|
description: values.description || null,
|
|
304
314
|
source,
|
|
305
315
|
schema: {
|
|
316
|
+
presentation: values.presentation ?? "dialog",
|
|
306
317
|
fields: values.fields.map((field) => ({
|
|
307
318
|
key: field.key,
|
|
308
319
|
label: field.label,
|
|
@@ -347,7 +358,8 @@ function builderFormEditorInputFromValues(values) {
|
|
|
347
358
|
parentField: subform.parentField,
|
|
348
359
|
childField: subform.childField,
|
|
349
360
|
buttonLabel: subform.buttonLabel?.trim() || void 0,
|
|
350
|
-
icon: subform.icon?.trim() || void 0
|
|
361
|
+
icon: subform.icon?.trim() || void 0,
|
|
362
|
+
presentation: subform.presentation ?? "dialog"
|
|
351
363
|
}))
|
|
352
364
|
},
|
|
353
365
|
triggers: values.triggers.map((trigger) => ({
|
|
@@ -552,6 +564,13 @@ function createBuilderDefaultFormEditorBody(options) {
|
|
|
552
564
|
/* @__PURE__ */ jsx("span", { style: styles.label, children: "Description" }),
|
|
553
565
|
/* @__PURE__ */ jsx("input", { style: styles.input, ...form.register("description") })
|
|
554
566
|
] }),
|
|
567
|
+
/* @__PURE__ */ jsxs("label", { style: styles.field, children: [
|
|
568
|
+
/* @__PURE__ */ jsx("span", { style: styles.label, children: "Presentation" }),
|
|
569
|
+
/* @__PURE__ */ jsxs("select", { style: styles.input, ...form.register("presentation"), children: [
|
|
570
|
+
/* @__PURE__ */ jsx("option", { value: "dialog", children: "Dialog" }),
|
|
571
|
+
/* @__PURE__ */ jsx("option", { value: "drawer", children: "Drawer" })
|
|
572
|
+
] })
|
|
573
|
+
] }),
|
|
555
574
|
/* @__PURE__ */ jsxs("label", { style: styles.field, children: [
|
|
556
575
|
/* @__PURE__ */ jsx("span", { style: styles.label, children: "Datasource" }),
|
|
557
576
|
/* @__PURE__ */ jsxs("select", { style: styles.input, ...form.register("sourceType"), children: [
|
|
@@ -733,7 +752,8 @@ function createBuilderDefaultFormEditorBody(options) {
|
|
|
733
752
|
parentField: "id",
|
|
734
753
|
childField: "parentId",
|
|
735
754
|
buttonLabel: "",
|
|
736
|
-
icon: ""
|
|
755
|
+
icon: "",
|
|
756
|
+
presentation: "dialog"
|
|
737
757
|
}),
|
|
738
758
|
children: "Add subform"
|
|
739
759
|
}
|
|
@@ -760,6 +780,20 @@ function createBuilderDefaultFormEditorBody(options) {
|
|
|
760
780
|
/* @__PURE__ */ jsx("span", { style: styles.label, children: "Child field" }),
|
|
761
781
|
/* @__PURE__ */ jsx("input", { style: styles.input, ...form.register(`subforms.${index}.childField`) })
|
|
762
782
|
] }),
|
|
783
|
+
/* @__PURE__ */ jsxs("label", { style: styles.field, children: [
|
|
784
|
+
/* @__PURE__ */ jsx("span", { style: styles.label, children: "Presentation" }),
|
|
785
|
+
/* @__PURE__ */ jsxs(
|
|
786
|
+
"select",
|
|
787
|
+
{
|
|
788
|
+
style: styles.input,
|
|
789
|
+
...form.register(`subforms.${index}.presentation`),
|
|
790
|
+
children: [
|
|
791
|
+
/* @__PURE__ */ jsx("option", { value: "dialog", children: "Dialog" }),
|
|
792
|
+
/* @__PURE__ */ jsx("option", { value: "drawer", children: "Drawer" })
|
|
793
|
+
]
|
|
794
|
+
}
|
|
795
|
+
)
|
|
796
|
+
] }),
|
|
763
797
|
/* @__PURE__ */ jsx("button", { type: "button", style: styles.button, onClick: () => subformArray.remove(index), children: "Remove" })
|
|
764
798
|
] }, subform.id))
|
|
765
799
|
] }),
|
|
@@ -1623,6 +1657,7 @@ function createBuilderAdminPages({
|
|
|
1623
1657
|
const emptyFormValues = {
|
|
1624
1658
|
title: "",
|
|
1625
1659
|
description: "",
|
|
1660
|
+
presentation: "dialog",
|
|
1626
1661
|
sourceType: "none",
|
|
1627
1662
|
sourceTable: BUILDER_EDITOR_NONE_VALUE,
|
|
1628
1663
|
apiBasePath: "",
|
|
@@ -2205,7 +2240,7 @@ function withQuery(path, query) {
|
|
|
2205
2240
|
function createBuilderIntegration(config) {
|
|
2206
2241
|
const adminBasePath = normalizeBasePath(config.adminBasePath ?? "/admin/dev/builder");
|
|
2207
2242
|
const runtimeBasePath = normalizeBasePath(config.runtimeBasePath ?? "/admin/winu");
|
|
2208
|
-
const api = createBuilderApiClient(config.transport);
|
|
2243
|
+
const api = createBuilderApiClient(config.transport, { apiBasePath: config.apiBasePath });
|
|
2209
2244
|
const hooks = createBuilderHooks(api);
|
|
2210
2245
|
const formsPath = `${adminBasePath}/forms`;
|
|
2211
2246
|
const listsPath = `${adminBasePath}/lists`;
|
|
@@ -2255,6 +2290,11 @@ function validateBuilderFrontendSetup(config) {
|
|
|
2255
2290
|
name: "transport",
|
|
2256
2291
|
ok: Boolean(config.transport),
|
|
2257
2292
|
message: "API transport is required."
|
|
2293
|
+
},
|
|
2294
|
+
{
|
|
2295
|
+
name: "apiBasePath",
|
|
2296
|
+
ok: config.apiBasePath === void 0 || normalizeBasePath(config.apiBasePath).startsWith("/"),
|
|
2297
|
+
message: "apiBasePath must be an absolute API path."
|
|
2258
2298
|
}
|
|
2259
2299
|
].map((check) => check.ok ? { name: check.name, ok: true } : check);
|
|
2260
2300
|
return { ok: checks.every((check) => check.ok), checks };
|