@duke333/builder-ui 0.2.3 → 0.2.4

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.
@@ -46,6 +46,10 @@ type BuilderEditorField<TFieldType extends string> = {
46
46
  required: boolean;
47
47
  hidden?: boolean;
48
48
  disabled?: boolean;
49
+ storage?: "s3" | "server";
50
+ contentKind?: "image" | "file";
51
+ multiple?: boolean;
52
+ maxBytes?: number;
49
53
  placeholder?: string;
50
54
  description?: string;
51
55
  options?: BuilderEditorSelectOption[];
@@ -123,6 +127,10 @@ type BuilderFormEditorFieldValues<TFieldType extends string = string> = {
123
127
  required: boolean;
124
128
  hidden: boolean;
125
129
  disabled: boolean;
130
+ storage?: "s3" | "server";
131
+ contentKind?: "image" | "file";
132
+ multiple?: boolean;
133
+ maxMegabytes?: number;
126
134
  placeholder?: string;
127
135
  optionsText?: string;
128
136
  optionsMode: "static" | "table";
@@ -261,6 +269,10 @@ declare function builderFormEditorInputFromValues<TFieldType extends string, TTr
261
269
  required: boolean;
262
270
  hidden: boolean;
263
271
  disabled: boolean;
272
+ storage: "s3" | "server" | undefined;
273
+ contentKind: "file" | "image" | undefined;
274
+ multiple: boolean | undefined;
275
+ maxBytes: number | undefined;
264
276
  placeholder: string;
265
277
  options: BuilderEditorSelectOption[] | undefined;
266
278
  optionsSource: {
@@ -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, BuilderRuntimePresentation, BuilderRuntimeEntryValues } from './runtime/index.js';
5
+ import { a as BuilderRuntimeFormSchemaLike, d as BuilderRuntimeFormValues, b as BuilderRuntimeEntryLike, e as BuilderRuntimeViewLike, B as BuilderRuntimePresentation, c as BuilderRuntimeEntryValues } from './runtimeUtils-CCtLyIf1.js';
6
6
 
7
7
  type DynamicFormContracts = BuilderApiContracts & {
8
8
  BuilderForm: {
@@ -1,5 +1,5 @@
1
- import { C as BuilderViewEditorEntity, D as BuilderViewEditorValues, X as BuilderFormEditorLayoutGroupValues, u as BuilderFormEditorValues, s as BuilderFormEditorFieldValues, Y as BuilderFormEditorSubformValues } from '../BuilderAdminPages-DrOrFyIX.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 BuilderListEditorOrderByValues, z as BuilderListEditorPageDependencies, A as BuilderListEditorValues, E as builderEditorOptionsToText, F as builderEditorSearchFieldsToText, G as builderEditorTextToOptions, H as builderEditorTextToSearchFields, Z as builderFormEditorDefaultLayoutGroups, _ as builderFormEditorDefaultSpan, I as builderFormEditorFieldsFromTable, J as builderFormEditorInputFromValues, K as builderFormEditorValuesFromEntity, L as builderListEditorColumnsFromTable, M as builderListEditorInputFromValues, N as builderListEditorValuesFromEntity, O as builderViewEditorInputFromValues, P as builderViewEditorValuesFromEntity, Q as createBuilderAdminPages, R as createBuilderDefaultEntityManagerComponent, S as createBuilderDefaultFormEditorBody, T as createBuilderDefaultListEditorBody, U as createBuilderFormEditorPageComponent, V as createBuilderListEditorPageComponent, W as getBuilderEditorTriggerRoute } from '../BuilderAdminPages-DrOrFyIX.js';
1
+ import { C as BuilderViewEditorEntity, D as BuilderViewEditorValues, X as BuilderFormEditorLayoutGroupValues, u as BuilderFormEditorValues, s as BuilderFormEditorFieldValues, Y as BuilderFormEditorSubformValues } from '../BuilderAdminPages-DwwdA8Dv.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 BuilderListEditorOrderByValues, z as BuilderListEditorPageDependencies, A as BuilderListEditorValues, E as builderEditorOptionsToText, F as builderEditorSearchFieldsToText, G as builderEditorTextToOptions, H as builderEditorTextToSearchFields, Z as builderFormEditorDefaultLayoutGroups, _ as builderFormEditorDefaultSpan, I as builderFormEditorFieldsFromTable, J as builderFormEditorInputFromValues, K as builderFormEditorValuesFromEntity, L as builderListEditorColumnsFromTable, M as builderListEditorInputFromValues, N as builderListEditorValuesFromEntity, O as builderViewEditorInputFromValues, P as builderViewEditorValuesFromEntity, Q as createBuilderAdminPages, R as createBuilderDefaultEntityManagerComponent, S as createBuilderDefaultFormEditorBody, T as createBuilderDefaultListEditorBody, U as createBuilderFormEditorPageComponent, V as createBuilderListEditorPageComponent, W as getBuilderEditorTriggerRoute } from '../BuilderAdminPages-DwwdA8Dv.js';
3
3
  import * as react from 'react';
4
4
  import { ComponentType, ReactNode } from 'react';
5
5
  import { BuilderApiContracts } from '../api/index.js';
@@ -45,7 +45,7 @@ function clampLayoutSpan(span, columns) {
45
45
  return Math.max(1, Math.min(columns, Math.trunc(span)));
46
46
  }
47
47
  function builderFormEditorDefaultSpan(field) {
48
- if (field.type === "textarea" || field.type === "checkbox") return 12;
48
+ if (field.type === "textarea" || field.type === "richtext" || field.type === "checkbox") return 12;
49
49
  return 6;
50
50
  }
51
51
  function builderFormEditorDefaultLayoutGroups(fields, subforms = []) {
@@ -112,6 +112,10 @@ function builderFormEditorValuesFromEntity(form, emptyValues) {
112
112
  required: field.required,
113
113
  hidden: field.hidden ?? false,
114
114
  disabled: field.disabled ?? false,
115
+ storage: field.storage ?? "s3",
116
+ contentKind: field.contentKind ?? "image",
117
+ multiple: field.multiple ?? false,
118
+ maxMegabytes: field.maxBytes ? field.maxBytes / (1024 * 1024) : 10,
115
119
  placeholder: field.placeholder ?? "",
116
120
  optionsText: builderEditorOptionsToText(field.options),
117
121
  optionsMode: field.optionsSource?.type === "dbTable" ? "table" : "static",
@@ -194,6 +198,10 @@ function builderFormEditorFieldsFromTable(table) {
194
198
  required: !column.nullable,
195
199
  hidden: false,
196
200
  disabled: false,
201
+ storage: "s3",
202
+ contentKind: "image",
203
+ multiple: false,
204
+ maxMegabytes: 10,
197
205
  placeholder: column.label,
198
206
  optionsText: "",
199
207
  optionsMode: "static",
@@ -230,6 +238,10 @@ function builderFormEditorInputFromValues(values) {
230
238
  required: field.required,
231
239
  hidden: field.hidden,
232
240
  disabled: field.disabled,
241
+ storage: field.type === "file" ? field.storage : void 0,
242
+ contentKind: field.type === "file" ? field.contentKind : void 0,
243
+ multiple: field.type === "file" ? field.multiple : void 0,
244
+ maxBytes: field.type === "file" && typeof field.maxMegabytes === "number" && field.maxMegabytes > 0 ? Math.round(field.maxMegabytes * 1024 * 1024) : void 0,
233
245
  placeholder: field.placeholder?.trim() || field.label,
234
246
  options: field.type === "select" && field.optionsMode === "static" ? builderEditorTextToOptions(field.optionsText) : void 0,
235
247
  optionsSource: field.type === "select" && field.optionsMode === "table" && field.optionsTable !== BUILDER_EDITOR_NONE_VALUE && field.optionsValueField !== BUILDER_EDITOR_NONE_VALUE && field.optionsLabelField !== BUILDER_EDITOR_NONE_VALUE ? {
@@ -320,7 +332,7 @@ function builderViewEditorInputFromValues(values, parseTriggers) {
320
332
  }
321
333
 
322
334
  // src/admin/BuilderDefaultEditorBodies.tsx
323
- import { jsx, jsxs } from "react/jsx-runtime";
335
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
324
336
  var styles = {
325
337
  page: {
326
338
  display: "grid",
@@ -583,6 +595,30 @@ function createBuilderDefaultFormEditorBody(options) {
583
595
  /* @__PURE__ */ jsx("input", { type: "checkbox", ...form.register(`fields.${index}.disabled`) }),
584
596
  "Disabled"
585
597
  ] }),
598
+ fields[index]?.type === "file" ? /* @__PURE__ */ jsxs(Fragment, { children: [
599
+ /* @__PURE__ */ jsxs("label", { style: styles.field, children: [
600
+ /* @__PURE__ */ jsx("span", { style: styles.label, children: "Storage" }),
601
+ /* @__PURE__ */ jsxs("select", { style: styles.input, ...form.register(`fields.${index}.storage`), children: [
602
+ /* @__PURE__ */ jsx("option", { value: "s3", children: "S3" }),
603
+ /* @__PURE__ */ jsx("option", { value: "server", children: "Server" })
604
+ ] })
605
+ ] }),
606
+ /* @__PURE__ */ jsxs("label", { style: styles.field, children: [
607
+ /* @__PURE__ */ jsx("span", { style: styles.label, children: "Content type" }),
608
+ /* @__PURE__ */ jsxs("select", { style: styles.input, ...form.register(`fields.${index}.contentKind`), children: [
609
+ /* @__PURE__ */ jsx("option", { value: "image", children: "Image" }),
610
+ /* @__PURE__ */ jsx("option", { value: "file", children: "File" })
611
+ ] })
612
+ ] }),
613
+ /* @__PURE__ */ jsxs("label", { style: styles.checkboxField, children: [
614
+ /* @__PURE__ */ jsx("input", { type: "checkbox", ...form.register(`fields.${index}.multiple`) }),
615
+ "Multiple"
616
+ ] }),
617
+ /* @__PURE__ */ jsxs("label", { style: styles.field, children: [
618
+ /* @__PURE__ */ jsx("span", { style: styles.label, children: "Max size (MB)" }),
619
+ /* @__PURE__ */ jsx("input", { type: "number", min: "1", max: "100", style: styles.input, ...form.register(`fields.${index}.maxMegabytes`, { valueAsNumber: true }) })
620
+ ] })
621
+ ] }) : null,
586
622
  /* @__PURE__ */ jsxs("label", { style: styles.field, children: [
587
623
  /* @__PURE__ */ jsx("span", { style: styles.label, children: "Placeholder" }),
588
624
  /* @__PURE__ */ jsx("input", { style: styles.input, ...form.register(`fields.${index}.placeholder`) })
@@ -1193,7 +1229,7 @@ function createBuilderDefaultEntityManagerComponent(deps) {
1193
1229
  // src/admin/BuilderDefaultViewEditorPage.tsx
1194
1230
  import { useEffect } from "react";
1195
1231
  import { useForm } from "react-hook-form";
1196
- import { Fragment, jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
1232
+ import { Fragment as Fragment2, jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
1197
1233
  var styles3 = {
1198
1234
  page: {
1199
1235
  display: "grid",
@@ -1380,7 +1416,7 @@ function createBuilderDefaultViewEditorPage(options) {
1380
1416
  (lists.data ?? []).map((item) => /* @__PURE__ */ jsx3("option", { value: item.id, children: item.title }, item.id))
1381
1417
  ] })
1382
1418
  ] }),
1383
- showPermissions ? /* @__PURE__ */ jsxs3(Fragment, { children: [
1419
+ showPermissions ? /* @__PURE__ */ jsxs3(Fragment2, { children: [
1384
1420
  /* @__PURE__ */ jsxs3("label", { style: styles3.field, children: [
1385
1421
  /* @__PURE__ */ jsx3("span", { style: styles3.label, children: "Read permission" }),
1386
1422
  /* @__PURE__ */ jsxs3("select", { style: styles3.input, ...form.register("permissionRead"), children: [
@@ -1544,6 +1580,7 @@ import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
1544
1580
  var defaultFieldTypeOptions = [
1545
1581
  { value: "text", label: "Text" },
1546
1582
  { value: "textarea", label: "Textarea" },
1583
+ { value: "richtext", label: "Rich text" },
1547
1584
  { value: "number", label: "Number" },
1548
1585
  { value: "money", label: "Money" },
1549
1586
  { value: "select", label: "Select" },
@@ -1654,6 +1691,10 @@ function createBuilderAdminPages({
1654
1691
  required: true,
1655
1692
  hidden: false,
1656
1693
  disabled: false,
1694
+ storage: "s3",
1695
+ contentKind: "image",
1696
+ multiple: false,
1697
+ maxMegabytes: 10,
1657
1698
  placeholder: "",
1658
1699
  optionsText: "",
1659
1700
  optionsMode: "static",