@bluprynt/forms-viewer 2.0.0 → 3.0.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/index.cjs CHANGED
@@ -4,6 +4,7 @@ let react = require("react");
4
4
  let react_jsx_runtime = require("react/jsx-runtime");
5
5
  //#region src/constants.ts
6
6
  const ROOT = Symbol("ROOT");
7
+ const DEFAULT = Symbol("DEFAULT");
7
8
  //#endregion
8
9
  //#region src/form-context.tsx
9
10
  const FormContext = (0, react.createContext)(void 0);
@@ -246,15 +247,16 @@ const FormContent = (props) => {
246
247
  components: props.components,
247
248
  showInlineValidation
248
249
  };
249
- if (section === void 0) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FormItems, {
250
+ const selectedSection = section === DEFAULT ? resolveDefaultSection(items, visibilityMap) : section;
251
+ if (selectedSection === void 0) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FormItems, {
250
252
  items,
251
253
  ...sharedProps
252
254
  });
253
- if (section === ROOT) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FormItems, {
255
+ if (selectedSection === ROOT) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FormItems, {
254
256
  items: items.filter((item) => item.type !== "section"),
255
257
  ...sharedProps
256
258
  });
257
- const foundSection = findSection(items, section);
259
+ const foundSection = findSection(items, selectedSection);
258
260
  if (!foundSection || !visibilityMap.get(foundSection.id)) return null;
259
261
  const Section = props.components.section;
260
262
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Section, {
@@ -265,6 +267,10 @@ const FormContent = (props) => {
265
267
  })
266
268
  }, foundSection.id);
267
269
  };
270
+ const resolveDefaultSection = (items, visibilityMap) => {
271
+ if (items.filter((item) => item.type !== "section").some((item) => visibilityMap.get(item.id))) return ROOT;
272
+ return items.find((item) => item.type === "section" && visibilityMap.get(item.id) !== false)?.id;
273
+ };
268
274
  //#endregion
269
275
  //#region src/form-editor.tsx
270
276
  const FormEditor = ({ components, onChange }) => {
@@ -452,7 +458,7 @@ const FormSections = ({ container: Container, item: Item, defaultSectionTitle, d
452
458
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Container, { children: entries.map((entry, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Item, {
453
459
  index,
454
460
  section: entry,
455
- active: entry.id === section,
461
+ active: section === DEFAULT ? index === 0 : entry.id === section,
456
462
  select: () => onSelect?.(entry.id)
457
463
  }, entry.id === ROOT ? "root" : String(entry.id))) });
458
464
  };
@@ -473,6 +479,7 @@ const FormViewer = ({ components }) => {
473
479
  });
474
480
  };
475
481
  //#endregion
482
+ exports.DEFAULT = DEFAULT;
476
483
  Object.defineProperty(exports, "DocumentError", {
477
484
  enumerable: true,
478
485
  get: function() {
package/dist/index.d.cts CHANGED
@@ -4,6 +4,8 @@ import { ComponentType, FC, PropsWithChildren, ReactNode } from "react";
4
4
  //#region src/constants.d.ts
5
5
  declare const ROOT: unique symbol;
6
6
  type ROOT = typeof ROOT;
7
+ declare const DEFAULT: unique symbol;
8
+ type DEFAULT = typeof DEFAULT;
7
9
  //#endregion
8
10
  //#region src/form-context.d.ts
9
11
  type FormContextValue = {
@@ -14,14 +16,14 @@ type FormContextValue = {
14
16
  validation: FormValidationResult$1 | undefined;
15
17
  documentErrors: readonly DocumentValidationError$1[] | undefined;
16
18
  fieldErrors: Map<number, FieldValidationError$1[]>;
17
- section: typeof ROOT | number | undefined;
19
+ section: typeof ROOT | typeof DEFAULT | number | undefined;
18
20
  showInlineValidation: boolean;
19
21
  };
20
22
  declare const useFormContext: () => FormContextValue;
21
23
  type FormProps = {
22
24
  definition?: FormDefinition$1;
23
25
  data?: FormDocument$1;
24
- section?: typeof ROOT | number;
26
+ section?: typeof ROOT | typeof DEFAULT | number;
25
27
  showInlineValidation?: boolean;
26
28
  children: ReactNode;
27
29
  };
@@ -184,7 +186,7 @@ type FormSectionsProps = {
184
186
  item: ComponentType<FormSectionItemProps>;
185
187
  defaultSectionTitle?: string;
186
188
  defaultSectionDescription?: string;
187
- onSelect?: (id: typeof ROOT | number) => void;
189
+ onSelect?: (id: typeof ROOT | typeof DEFAULT | number) => void;
188
190
  };
189
191
  declare const FormSections: FC<FormSectionsProps>;
190
192
  //#endregion
@@ -194,5 +196,5 @@ type FormViewerProps = {
194
196
  };
195
197
  declare const FormViewer: FC<FormViewerProps>;
196
198
  //#endregion
197
- export { type ArrayEditProps, type ArrayItemDef, type ArrayViewProps, type BaseEditFieldProps, type BaseViewFieldProps, type BooleanEditProps, type BooleanViewProps, type ContentItem, type DateEditProps, type DateViewProps, DocumentError, type DocumentValidationError, type DocumentValidationErrorCode, type EditorArrayItemProps, type EditorComponentMap, type EditorFieldProps, type ErrorProps, type FieldContentItem, type FieldEntry, type FieldType, type FieldValidationError, type FieldValidationFieldEntry, type FileEditProps, type FileValue, type FileViewProps, Form, type FormDefinition, type FormDocument, FormDocumentValidation, FormEditor, FormFieldsValidation, type FormSectionEntry, type FormSectionItemProps, FormSections, type FormSnapshot, type FormValidationResult, type FormValues, FormValuesEditor, FormViewer, type NumberEditProps, type NumberViewProps, ROOT, type SectionContentItem, type SectionEditProps, type SectionViewProps, type SelectEditProps, type SelectOption, type SelectViewProps, type StringEditProps, type StringViewProps, type ViewerComponentMap, useFormContext, useFormSections };
199
+ export { type ArrayEditProps, type ArrayItemDef, type ArrayViewProps, type BaseEditFieldProps, type BaseViewFieldProps, type BooleanEditProps, type BooleanViewProps, type ContentItem, DEFAULT, type DateEditProps, type DateViewProps, DocumentError, type DocumentValidationError, type DocumentValidationErrorCode, type EditorArrayItemProps, type EditorComponentMap, type EditorFieldProps, type ErrorProps, type FieldContentItem, type FieldEntry, type FieldType, type FieldValidationError, type FieldValidationFieldEntry, type FileEditProps, type FileValue, type FileViewProps, Form, type FormDefinition, type FormDocument, FormDocumentValidation, FormEditor, FormFieldsValidation, type FormSectionEntry, type FormSectionItemProps, FormSections, type FormSnapshot, type FormValidationResult, type FormValues, FormValuesEditor, FormViewer, type NumberEditProps, type NumberViewProps, ROOT, type SectionContentItem, type SectionEditProps, type SectionViewProps, type SelectEditProps, type SelectOption, type SelectViewProps, type StringEditProps, type StringViewProps, type ViewerComponentMap, useFormContext, useFormSections };
198
200
  //# sourceMappingURL=index.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../src/constants.ts","../src/form-context.tsx","../src/form-document-validation.tsx","../src/types/base.ts","../src/types/editor.ts","../src/types/viewer.ts","../src/form-editor.tsx","../src/form-fields-validation.tsx","../src/use-form-sections.ts","../src/form-sections.tsx","../src/form-viewer.tsx"],"mappings":";;;;cAAa,IAAA;AAAA,KACD,IAAA,UAAc,IAAA;;;KCarB,gBAAA;EACD,UAAA,EAAY,gBAAA;EACZ,IAAA,EAAM,cAAA;EACN,MAAA,EAAQ,UAAA;EACR,aAAA,EAAe,GAAA;EACf,UAAA,EAAY,sBAAA;EACZ,cAAA,WAAyB,yBAAA;EACzB,WAAA,EAAa,GAAA,SAAY,sBAAA;EACzB,OAAA,SAAgB,IAAA;EAChB,oBAAA;AAAA;AAAA,cAKS,cAAA,QAAqB,gBAAA;AAAA,KAO7B,SAAA;EACD,UAAA,GAAa,gBAAA;EACb,IAAA,GAAO,cAAA;EACP,OAAA,UAAiB,IAAA;EACjB,oBAAA;EACA,QAAA,EAAU,SAAA;AAAA;AAAA,cAGD,IAAA,EAAM,EAAA,CAAG,SAAA;;;KCrCjB,2BAAA;EACD,SAAA,EAAW,aAAA,CAAc,iBAAA;EACzB,KAAA,EAAO,aAAA,CAAc,yBAAA;AAAA;AAAA,cAGZ,sBAAA,EAAwB,EAAA,CAAG,2BAAA;;;KCT5B,kBAAA;EACR,KAAA,EAAO,kBAAA;EACP,MAAA,EAAQ,sBAAA;AAAA;AAAA,KAGA,kBAAA,GAAqB,kBAAA;EAC7B,QAAA,GAAW,KAAA;AAAA;AAAA,KAGH,UAAA;EACR,MAAA,EAAQ,sBAAA;EACR,KAAA,EAAO,kBAAA;AAAA;;;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,EAAO,aAAA,CAAc,sBAAA;AAAA;AAAA,cAGZ,oBAAA,EAAsB,EAAA,CAAG,yBAAA;;;KCV1B,gBAAA,GAAmB,IAAA,CAAK,oBAAA;EAChC,EAAA,SAAW,IAAA;AAAA;AAAA,cAGF,eAAA,GACT,mBAAA,WACA,yBAAA,cACD,gBAAA;;;KCNS,oBAAA;EACR,KAAA;EACA,OAAA,EAAS,gBAAA;EACT,MAAA;EACA,MAAA;AAAA;AAAA,KAGC,iBAAA;EACD,SAAA,EAAW,aAAA,CAAc,iBAAA;EACzB,IAAA,EAAM,aAAA,CAAc,oBAAA;EACpB,mBAAA;EACA,yBAAA;EACA,QAAA,IAAY,EAAA,SAAW,IAAA;AAAA;AAAA,cAGd,YAAA,EAAc,EAAA,CAAG,iBAAA;;;KCjBzB,eAAA;EACD,UAAA,EAAY,kBAAA;AAAA;AAAA,cAGH,UAAA,EAAY,EAAA,CAAG,eAAA"}
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../src/constants.ts","../src/form-context.tsx","../src/form-document-validation.tsx","../src/types/base.ts","../src/types/editor.ts","../src/types/viewer.ts","../src/form-editor.tsx","../src/form-fields-validation.tsx","../src/use-form-sections.ts","../src/form-sections.tsx","../src/form-viewer.tsx"],"mappings":";;;;cAAa,IAAA;AAAA,KACD,IAAA,UAAc,IAAA;AAAA,cAEb,OAAA;AAAA,KACD,OAAA,UAAiB,OAAA;;;KCUxB,gBAAA;EACD,UAAA,EAAY,gBAAA;EACZ,IAAA,EAAM,cAAA;EACN,MAAA,EAAQ,UAAA;EACR,aAAA,EAAe,GAAA;EACf,UAAA,EAAY,sBAAA;EACZ,cAAA,WAAyB,yBAAA;EACzB,WAAA,EAAa,GAAA,SAAY,sBAAA;EACzB,OAAA,SAAgB,IAAA,UAAc,OAAA;EAC9B,oBAAA;AAAA;AAAA,cAKS,cAAA,QAAqB,gBAAA;AAAA,KAO7B,SAAA;EACD,UAAA,GAAa,gBAAA;EACb,IAAA,GAAO,cAAA;E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O,aAAA,CAAc,cAAA;EACrB,IAAA,EAAM,aAAA,CAAc,aAAA;EACpB,OAAA,EAAS,aAAA,CAAc,gBAAA;EACvB,KAAA,GAAQ,aAAA,CAAc,UAAA;AAAA;;;KC3CrB,eAAA;EACD,UAAA,EAAY,kBAAA;EACZ,QAAA,GAAW,IAAA,EAAM,cAAA,EAAc,UAAA,EAAY,sBAAA;AAAA;AAAA,cAGlC,UAAA,EAAY,EAAA,CAAG,eAAA;;;KCPhB,yBAAA;EACR,KAAA,EAAO,YAAA;EACP,MAAA,EAAQ,sBAAA;AAAA;AAAA,KAGP,yBAAA;EACD,SAAA,EAAW,aAAA,CAAc,iBAAA;EACzB,KAAA,EAAO,aAAA,CAAc,iBAAA,CAAkB,yBAAA;EACvC,KAAA,EAAO,aAAA,CAAc,sBAAA;AAAA;AAAA,cAGZ,oBAAA,EAAsB,EAAA,CAAG,yBAAA;;;KCV1B,gBAAA,GAAmB,IAAA,CAAK,oBAAA;EAChC,EAAA,SAAW,IAAA;AAAA;AAAA,cAGF,eAAA,GACT,mBAAA,WACA,yBAAA,cACD,gBAAA;;;KCNS,oBAAA;EACR,KAAA;EACA,OAAA,EAAS,gBAAA;EACT,MAAA;EACA,MAAA;AAAA;AAAA,KAGC,iBAAA;EACD,SAAA,EAAW,aAAA,CAAc,iBAAA;EACzB,IAAA,EAAM,aAAA,CAAc,oBAAA;EACpB,mBAAA;EACA,yBAAA;EACA,QAAA,IAAY,EAAA,SAAW,IAAA,UAAc,OAAA;AAAA;AAAA,cAG5B,YAAA,EAAc,EAAA,CAAG,iBAAA;;;KCjBzB,eAAA;EACD,UAAA,EAAY,kBAAA;AAAA;AAAA,cAGH,UAAA,EAAY,EAAA,CAAG,eAAA"}
package/dist/index.d.mts CHANGED
@@ -4,6 +4,8 @@ import { ComponentType, FC, PropsWithChildren, ReactNode } from "react";
4
4
  //#region src/constants.d.ts
5
5
  declare const ROOT: unique symbol;
6
6
  type ROOT = typeof ROOT;
7
+ declare const DEFAULT: unique symbol;
8
+ type DEFAULT = typeof DEFAULT;
7
9
  //#endregion
8
10
  //#region src/form-context.d.ts
9
11
  type FormContextValue = {
@@ -14,14 +16,14 @@ type FormContextValue = {
14
16
  validation: FormValidationResult$1 | undefined;
15
17
  documentErrors: readonly DocumentValidationError$1[] | undefined;
16
18
  fieldErrors: Map<number, FieldValidationError$1[]>;
17
- section: typeof ROOT | number | undefined;
19
+ section: typeof ROOT | typeof DEFAULT | number | undefined;
18
20
  showInlineValidation: boolean;
19
21
  };
20
22
  declare const useFormContext: () => FormContextValue;
21
23
  type FormProps = {
22
24
  definition?: FormDefinition$1;
23
25
  data?: FormDocument$1;
24
- section?: typeof ROOT | number;
26
+ section?: typeof ROOT | typeof DEFAULT | number;
25
27
  showInlineValidation?: boolean;
26
28
  children: ReactNode;
27
29
  };
@@ -184,7 +186,7 @@ type FormSectionsProps = {
184
186
  item: ComponentType<FormSectionItemProps>;
185
187
  defaultSectionTitle?: string;
186
188
  defaultSectionDescription?: string;
187
- onSelect?: (id: typeof ROOT | number) => void;
189
+ onSelect?: (id: typeof ROOT | typeof DEFAULT | number) => void;
188
190
  };
189
191
  declare const FormSections: FC<FormSectionsProps>;
190
192
  //#endregion
@@ -194,5 +196,5 @@ type FormViewerProps = {
194
196
  };
195
197
  declare const FormViewer: FC<FormViewerProps>;
196
198
  //#endregion
197
- export { type ArrayEditProps, type ArrayItemDef, type ArrayViewProps, type BaseEditFieldProps, type BaseViewFieldProps, type BooleanEditProps, type BooleanViewProps, type ContentItem, type DateEditProps, type DateViewProps, DocumentError, type DocumentValidationError, type DocumentValidationErrorCode, type EditorArrayItemProps, type EditorComponentMap, type EditorFieldProps, type ErrorProps, type FieldContentItem, type FieldEntry, type FieldType, type FieldValidationError, type FieldValidationFieldEntry, type FileEditProps, type FileValue, type FileViewProps, Form, type FormDefinition, type FormDocument, FormDocumentValidation, FormEditor, FormFieldsValidation, type FormSectionEntry, type FormSectionItemProps, FormSections, type FormSnapshot, type FormValidationResult, type FormValues, FormValuesEditor, FormViewer, type NumberEditProps, type NumberViewProps, ROOT, type SectionContentItem, type SectionEditProps, type SectionViewProps, type SelectEditProps, type SelectOption, type SelectViewProps, type StringEditProps, type StringViewProps, type ViewerComponentMap, useFormContext, useFormSections };
199
+ export { type ArrayEditProps, type ArrayItemDef, type ArrayViewProps, type BaseEditFieldProps, type BaseViewFieldProps, type BooleanEditProps, type BooleanViewProps, type ContentItem, DEFAULT, type DateEditProps, type DateViewProps, DocumentError, type DocumentValidationError, type DocumentValidationErrorCode, type EditorArrayItemProps, type EditorComponentMap, type EditorFieldProps, type ErrorProps, type FieldContentItem, type FieldEntry, type FieldType, type FieldValidationError, type FieldValidationFieldEntry, type FileEditProps, type FileValue, type FileViewProps, Form, type FormDefinition, type FormDocument, FormDocumentValidation, FormEditor, FormFieldsValidation, type FormSectionEntry, type FormSectionItemProps, FormSections, type FormSnapshot, type FormValidationResult, type FormValues, FormValuesEditor, FormViewer, type NumberEditProps, type NumberViewProps, ROOT, type SectionContentItem, type SectionEditProps, type SectionViewProps, type SelectEditProps, type SelectOption, type SelectViewProps, type StringEditProps, type StringViewProps, type ViewerComponentMap, useFormContext, useFormSections };
198
200
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/constants.ts","../src/form-context.tsx","../src/form-document-validation.tsx","../src/types/base.ts","../src/types/editor.ts","../src/types/viewer.ts","../src/form-editor.tsx","../src/form-fields-validation.tsx","../src/use-form-sections.ts","../src/form-sections.tsx","../src/form-viewer.tsx"],"mappings":";;;;cAAa,IAAA;AAAA,KACD,IAAA,UAAc,IAAA;;;KCarB,gBAAA;EACD,UAAA,EAAY,gBAAA;EACZ,IAAA,EAAM,cAAA;EACN,MAAA,EAAQ,UAAA;EACR,aAAA,EAAe,GAAA;EACf,UAAA,EAAY,sBAAA;EACZ,cAAA,WAAyB,yBAAA;EACzB,WAAA,EAAa,GAAA,SAAY,sBAAA;EACzB,OAAA,S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x","../src/form-document-validation.tsx","../src/types/base.ts","../src/types/editor.ts","../src/types/viewer.ts","../src/form-editor.tsx","../src/form-fields-validation.tsx","../src/use-form-sections.ts","../src/form-sections.tsx","../src/form-viewer.tsx"],"mappings":";;;;cAAa,IAAA;AAAA,KACD,IAAA,UAAc,IAAA;AAAA,cAEb,OAAA;AAAA,KACD,OAAA,UAAiB,OAAA;;;KCUxB,gBAAA;EACD,UAAA,EAAY,gBAAA;EACZ,IAAA,EAAM,cAAA;EACN,MAAA,EAAQ,UAAA;EACR,aAAA,EAAe,GAAA;EACf,UAAA,EAAY,sBAAA;EACZ,cAAA,WAAyB,yBAAA;EACzB,WAAA,EAAa,GAAA,SAAY,sBAAA;EACzB,OAAA,SAAgB,IAAA,UAAc,OAAA;EAC9B,oBAAA;AAAA;AAAA,cAKS,cAAA,QAAqB,gBAAA;AAAA,KAO7B,SAAA;EACD,UAAA,GAAa,gBAAA;EACb,IAAA,GAAO,cAAA;EACP,OAAA,UAAiB,IAAA,UAAc,OAAA;EAC/B,oBAAA;EACA,QAAA,EAAU,SAAA;AAAA;AAAA,cAGD,IAAA,EAAM,EAAA,CAAG,SAAA;;;KCrCjB,2BAAA;EACD,SAAA,EAAW,aAAA,CAAc,iBAAA;EACzB,KAAA,EAAO,aAAA,CAAc,yBAAA;AAAA;AAAA,cAGZ,sBAAA,EAAwB,EAAA,CAAG,2BAAA;;;KCT5B,kBAAA;EACR,KAAA,EAAO,kBAAA;EACP,MAAA,EAAQ,sBAAA;AAAA;AAAA,KAGA,kBAAA,GAAqB,kBAAA;EAC7B,QAAA,GAAW,KAAA;AAAA;AAAA,KAGH,UAAA;EACR,MAAA,EAAQ,sBAAA;EACR,KAAA,EAAO,kBAAA;AAAA;;;KCPC,eAAA,GAAkB,kBAAA;EAC1B,KAAA;EACA,QAAA,GAAW,KAAA;AAAA;AAAA,KAGH,eAAA,GAAkB,kBAAA;EAC1B,KAAA;EACA,QAAA,GAAW,KAAA;AAAA;AAAA,KAGH,gBA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cAGF,eAAA,GACT,mBAAA,WACA,yBAAA,cACD,gBAAA;;;KCNS,oBAAA;EACR,KAAA;EACA,OAAA,EAAS,gBAAA;EACT,MAAA;EACA,MAAA;AAAA;AAAA,KAGC,iBAAA;EACD,SAAA,EAAW,aAAA,CAAc,iBAAA;EACzB,IAAA,EAAM,aAAA,CAAc,oBAAA;EACpB,mBAAA;EACA,yBAAA;EACA,QAAA,IAAY,EAAA,SAAW,IAAA,UAAc,OAAA;AAAA;AAAA,cAG5B,YAAA,EAAc,EAAA,CAAG,iBAAA;;;KCjBzB,eAAA;EACD,UAAA,EAAY,kBAAA;AAAA;AAAA,cAGH,UAAA,EAAY,EAAA,CAAG,eAAA"}
package/dist/index.mjs CHANGED
@@ -3,6 +3,7 @@ import { Fragment, createContext, useCallback, useContext, useMemo, useRef } fro
3
3
  import { jsx, jsxs } from "react/jsx-runtime";
4
4
  //#region src/constants.ts
5
5
  const ROOT = Symbol("ROOT");
6
+ const DEFAULT = Symbol("DEFAULT");
6
7
  //#endregion
7
8
  //#region src/form-context.tsx
8
9
  const FormContext = createContext(void 0);
@@ -245,15 +246,16 @@ const FormContent = (props) => {
245
246
  components: props.components,
246
247
  showInlineValidation
247
248
  };
248
- if (section === void 0) return /* @__PURE__ */ jsx(FormItems, {
249
+ const selectedSection = section === DEFAULT ? resolveDefaultSection(items, visibilityMap) : section;
250
+ if (selectedSection === void 0) return /* @__PURE__ */ jsx(FormItems, {
249
251
  items,
250
252
  ...sharedProps
251
253
  });
252
- if (section === ROOT) return /* @__PURE__ */ jsx(FormItems, {
254
+ if (selectedSection === ROOT) return /* @__PURE__ */ jsx(FormItems, {
253
255
  items: items.filter((item) => item.type !== "section"),
254
256
  ...sharedProps
255
257
  });
256
- const foundSection = findSection(items, section);
258
+ const foundSection = findSection(items, selectedSection);
257
259
  if (!foundSection || !visibilityMap.get(foundSection.id)) return null;
258
260
  const Section = props.components.section;
259
261
  return /* @__PURE__ */ jsx(Section, {
@@ -264,6 +266,10 @@ const FormContent = (props) => {
264
266
  })
265
267
  }, foundSection.id);
266
268
  };
269
+ const resolveDefaultSection = (items, visibilityMap) => {
270
+ if (items.filter((item) => item.type !== "section").some((item) => visibilityMap.get(item.id))) return ROOT;
271
+ return items.find((item) => item.type === "section" && visibilityMap.get(item.id) !== false)?.id;
272
+ };
267
273
  //#endregion
268
274
  //#region src/form-editor.tsx
269
275
  const FormEditor = ({ components, onChange }) => {
@@ -451,7 +457,7 @@ const FormSections = ({ container: Container, item: Item, defaultSectionTitle, d
451
457
  return /* @__PURE__ */ jsx(Container, { children: entries.map((entry, index) => /* @__PURE__ */ jsx(Item, {
452
458
  index,
453
459
  section: entry,
454
- active: entry.id === section,
460
+ active: section === DEFAULT ? index === 0 : entry.id === section,
455
461
  select: () => onSelect?.(entry.id)
456
462
  }, entry.id === ROOT ? "root" : String(entry.id))) });
457
463
  };
@@ -472,6 +478,6 @@ const FormViewer = ({ components }) => {
472
478
  });
473
479
  };
474
480
  //#endregion
475
- export { DocumentError, Form, FormDocumentValidation, FormEditor, FormFieldsValidation, FormSections, FormValuesEditor, FormViewer, ROOT, useFormContext, useFormSections };
481
+ export { DEFAULT, DocumentError, Form, FormDocumentValidation, FormEditor, FormFieldsValidation, FormSections, FormValuesEditor, FormViewer, ROOT, useFormContext, useFormSections };
476
482
 
477
483
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["DocumentError"],"sources":["../src/constants.ts","../src/form-context.tsx","../src/form-document-validation.tsx","../src/form/utils.ts","../src/form/form-items.tsx","../src/form/form-content.tsx","../src/form-editor.tsx","../src/form-fields-validation.tsx","../src/use-form-sections.ts","../src/form-sections.tsx","../src/form-viewer.tsx"],"sourcesContent":["export const ROOT: unique symbol = Symbol('ROOT')\nexport type ROOT = typeof ROOT\n","import { createContext, type FC, type ReactNode, useContext, useMemo } from 'react'\n\nimport {\n DocumentError,\n DocumentValidationError,\n FieldValidationError,\n FormDefinition,\n FormDocument,\n FormEngine,\n FormValidationResult,\n} from '@bluprynt/forms-core'\n\nimport type { ROOT } from './constants'\n\ntype FormContextValue = {\n definition: FormDefinition | undefined\n data: FormDocument | undefined\n engine: FormEngine | undefined\n visibilityMap: Map<number, boolean>\n validation: FormValidationResult | undefined\n documentErrors: readonly DocumentValidationError[] | undefined\n fieldErrors: Map<number, FieldValidationError[]>\n section: typeof ROOT | number | undefined\n showInlineValidation: boolean\n}\n\nconst FormContext = createContext<FormContextValue | undefined>(undefined)\n\nexport const useFormContext = (): FormContextValue => {\n const context = useContext(FormContext)\n if (!context) throw new Error('useFormContext must be used within a <Form> provider')\n\n return context\n}\n\ntype FormProps = {\n definition?: FormDefinition\n data?: FormDocument\n section?: typeof ROOT | number\n showInlineValidation?: boolean\n children: ReactNode\n}\n\nexport const Form: FC<FormProps> = ({ definition, data, section, showInlineValidation = true, children }) => {\n const { engine, documentErrors: definitionErrors } = useMemo(() => {\n if (!definition) return {}\n\n try {\n return { engine: new FormEngine(definition) }\n } catch (error) {\n if (error instanceof DocumentError) return { documentErrors: error.errors }\n throw error\n }\n }, [definition])\n\n const { visibilityMap, validation, documentErrors, fieldErrors } = useMemo(() => {\n const visibilityMap = engine && data ? engine.getVisibilityMap(data) : new Map<number, boolean>()\n const validation =\n engine && data\n ? engine.validate(data)\n : ({\n valid: true,\n fieldErrors: new Map<number, FieldValidationError[]>(),\n } satisfies FormValidationResult)\n\n return {\n visibilityMap,\n validation,\n documentErrors: [...(definitionErrors ?? []), ...(validation?.documentErrors ?? [])],\n fieldErrors: validation?.fieldErrors ?? new Map<number, FieldValidationError[]>(),\n } as const\n }, [engine, data, definitionErrors])\n\n const value: FormContextValue = {\n definition,\n data,\n engine,\n visibilityMap,\n validation,\n documentErrors,\n fieldErrors,\n section,\n showInlineValidation,\n } as const\n\n return <FormContext.Provider value={value}>{children}</FormContext.Provider>\n}\n","import type { ComponentType, FC, PropsWithChildren } from 'react'\n\nimport type { DocumentValidationError } from '@bluprynt/forms-core'\n\nimport { useFormContext } from './form-context'\n\ntype FormDocumentValidationProps = {\n container: ComponentType<PropsWithChildren>\n error: ComponentType<DocumentValidationError>\n}\n\nexport const FormDocumentValidation: FC<FormDocumentValidationProps> = ({\n container: ContainerComponent,\n error: ErrorComponent,\n}) => {\n const { documentErrors } = useFormContext()\n\n if (!documentErrors?.length) return null\n\n return (\n <ContainerComponent>\n {documentErrors.map((error, index) => (\n <ErrorComponent\n // biome-ignore lint/suspicious/noArrayIndexKey: index is unique in array\n key={`error-${error.code}-${error.itemId ?? ''}-${index}`}\n {...error}\n />\n ))}\n </ContainerComponent>\n )\n}\n","import type {\n ArrayItemDef,\n ContentItem,\n FieldContentItem,\n FieldType,\n FieldValidationError,\n SectionContentItem,\n} from '@bluprynt/forms-core'\n\n/**\n * Retrieves validation errors for a specific field from the pre-indexed error map.\n *\n * Uses O(1) map lookup by `fieldId`. When `itemIndex` is omitted, returns only\n * **field-level** errors (those without an `itemIndex`). When `itemIndex` is\n * provided, returns only **item-level** errors matching the given array item index.\n *\n * @param fieldErrors - Map from field id to its validation errors.\n * @param fieldId - The numeric ID of the field to retrieve errors for.\n * @param itemIndex - Optional zero-based index of the array item. When omitted, only\n * field-level errors (where `itemIndex` is `null` / `undefined`) are returned.\n * @returns Errors for the given field (and optionally item index). Empty array if none.\n *\n * @example\n * ```ts\n * // Field-level errors only (no itemIndex on the error)\n * getFieldErrors(fieldErrors, 5)\n *\n * // Errors for the third item of array field 5\n * getFieldErrors(fieldErrors, 5, 2)\n * ```\n */\nexport const getFieldErrors = (\n fieldErrors: Map<number, FieldValidationError[]>,\n fieldId: number,\n itemIndex?: number,\n): FieldValidationError[] => {\n const errors = fieldErrors.get(fieldId) ?? []\n if (itemIndex === undefined) return errors.filter((e) => e.itemIndex == null)\n return errors.filter((e) => e.itemIndex === itemIndex)\n}\n\n/**\n * Creates a synthetic {@link FieldContentItem} that represents a single item inside an array field.\n *\n * Array fields store their per-item schema in `arrayField.item` ({@link ArrayItemDef}).\n * Components that render individual array items need a standard `FieldContentItem` shape,\n * so this helper projects the item definition into one, preserving the parent field's `id`\n * while adopting the item's `type`, `label`, `description`, `validation`, and `options`.\n *\n * @param arrayField - The array field definition whose `.item` property describes the item schema.\n * @param _index - The zero-based position of the item in the array (reserved for future use,\n * e.g. per-item overrides).\n * @returns A `FieldContentItem` that can be passed directly to a typed field component.\n *\n * @example\n * ```ts\n * const arrayField: FieldContentItem = {\n * id: 10, type: 'array', label: 'Tags',\n * item: { type: 'string', label: 'Tag' },\n * }\n *\n * const itemDef = getArrayField(arrayField, 0)\n * // → { id: 10, type: 'string', label: 'Tag', ... }\n * ```\n */\nexport const getArrayField = (arrayField: FieldContentItem, _index: number): FieldContentItem => {\n const itemDef = arrayField.item as ArrayItemDef\n return {\n id: arrayField.id,\n type: itemDef.type as FieldType,\n label: itemDef.label,\n description: itemDef.description,\n validation: itemDef.validation as FieldContentItem['validation'],\n options: itemDef.options,\n }\n}\n\n/**\n * Recursively searches content items for a section with the given id.\n *\n * Walks the content tree depth-first, checking sections and their nested\n * content. Returns the first matching {@link SectionContentItem}, or\n * `undefined` if no section with that id exists.\n *\n * @param items - The content items to search through.\n * @param sectionId - The numeric id of the section to find.\n * @returns The matching section, or `undefined` if not found.\n *\n * @example\n * ```ts\n * const section = findSection(definition.content, 42)\n * if (section) {\n * // render section.content\n * }\n * ```\n */\nexport const findSection = (items: ContentItem[], sectionId: number): SectionContentItem | undefined => {\n for (const item of items) {\n if (item.type === 'section') {\n if (item.id === sectionId) return item\n const found = findSection(item.content, sectionId)\n if (found) return found\n }\n }\n return undefined\n}\n","import { type FC, Fragment } from 'react'\n\nimport type {\n ArrayItemDef,\n ContentItem,\n FieldContentItem,\n FieldValidationError,\n FormValues,\n} from '@bluprynt/forms-core'\n\nimport type { EditorArrayItemProps, EditorComponentMap, EditorFieldProps, ViewerComponentMap } from '../types'\nimport { getArrayField, getFieldErrors } from './utils'\n\ntype FormItemsProps = {\n items: ContentItem[]\n visibilityMap: Map<number, boolean>\n values: FormValues\n fieldErrors: Map<number, FieldValidationError[]>\n components: ViewerComponentMap | EditorComponentMap\n showInlineValidation: boolean\n renderFieldProps?: (field: FieldContentItem) => EditorFieldProps\n renderArrayItemProps?: (arrayField: FieldContentItem, index: number) => EditorArrayItemProps\n}\n\nexport const FormItems: FC<FormItemsProps> = ({\n items,\n visibilityMap,\n values,\n fieldErrors,\n components,\n showInlineValidation,\n renderFieldProps,\n renderArrayItemProps,\n}) => {\n const SectionComponent = components.section\n const ErrorComponent = showInlineValidation ? components.error : undefined\n\n const elements: React.ReactNode[] = []\n\n for (const item of items) {\n if (!visibilityMap.get(item.id)) continue\n\n if (item.type === 'section') {\n elements.push(\n <SectionComponent key={item.id} section={item}>\n <FormItems\n items={item.content}\n visibilityMap={visibilityMap}\n values={values}\n fieldErrors={fieldErrors}\n components={components}\n showInlineValidation={showInlineValidation}\n renderFieldProps={renderFieldProps}\n renderArrayItemProps={renderArrayItemProps}\n />\n </SectionComponent>,\n )\n } else if (item.type === 'array') {\n const errors = getFieldErrors(fieldErrors, item.id)\n const modeProps = renderFieldProps?.(item) ?? {}\n\n const ArrayComponent = components.array as React.ComponentType<Record<string, unknown>>\n const arrayValue = (values[String(item.id)] as unknown[] | undefined) ?? []\n const itemDef = item.item as ArrayItemDef\n const ItemComponent = components[\n itemDef.type as keyof Omit<ViewerComponentMap, 'array' | 'section' | 'error'>\n ] as React.ComponentType<Record<string, unknown>> | undefined\n\n elements.push(\n <ArrayComponent\n key={item.id}\n field={item}\n value={values[String(item.id)]}\n itemDef={item.item}\n errors={errors}\n {...modeProps}>\n {ItemComponent\n ? arrayValue.map((itemValue, index) => {\n const itemErrors = getFieldErrors(fieldErrors, item.id, index)\n const synthetic = getArrayField(item, index)\n const itemModeProps = renderArrayItemProps?.(item, index) ?? {}\n\n const baseProps: Record<string, unknown> = {\n field: synthetic,\n value: itemValue,\n errors: itemErrors,\n ...itemModeProps,\n }\n\n if (itemDef.type === 'select') {\n baseProps.options = itemDef.options ?? []\n }\n\n return (\n // biome-ignore lint/suspicious/noArrayIndexKey: index is unique in array\n <Fragment key={`${item.id}-${index}`}>\n <ItemComponent {...baseProps} />\n {ErrorComponent && itemErrors.length > 0 && (\n <ErrorComponent errors={itemErrors} field={synthetic} />\n )}\n </Fragment>\n )\n })\n : null}\n </ArrayComponent>,\n )\n\n if (ErrorComponent && errors.length > 0) {\n elements.push(<ErrorComponent key={`${item.id}-error`} errors={errors} field={item} />)\n }\n } else {\n const errors = getFieldErrors(fieldErrors, item.id)\n const modeProps = renderFieldProps?.(item) ?? {}\n\n const fieldProps: Record<string, unknown> = {\n field: item,\n value: values[String(item.id)],\n errors,\n ...modeProps,\n }\n\n if (item.type === 'select') fieldProps.options = (item as FieldContentItem).options ?? []\n\n const fieldType = item.type as keyof Omit<ViewerComponentMap, 'array' | 'section' | 'error'>\n const FieldComponent = components[fieldType] as React.ComponentType<Record<string, unknown>>\n\n elements.push(<FieldComponent key={item.id} {...fieldProps} />)\n\n if (ErrorComponent && errors.length > 0)\n elements.push(<ErrorComponent key={`${item.id}-error`} errors={errors} field={item} />)\n }\n }\n\n if (elements.length === 0) return null\n\n return elements\n}\n","import type { FC } from 'react'\n\nimport type { ContentItem, FieldContentItem, FieldValidationError, FormValues } from '@bluprynt/forms-core'\n\nimport { ROOT } from '../constants'\nimport type { EditorArrayItemProps, EditorComponentMap, EditorFieldProps, ViewerComponentMap } from '../types'\nimport { FormItems } from './form-items'\nimport { findSection } from './utils'\n\ntype FormContentBaseProps = {\n items: ContentItem[]\n visibilityMap: Map<number, boolean>\n values: FormValues\n fieldErrors: Map<number, FieldValidationError[]>\n section?: typeof ROOT | number\n showInlineValidation: boolean\n}\n\ntype FormContentViewerProps = FormContentBaseProps & {\n mode: 'viewer'\n components: ViewerComponentMap\n}\n\ntype FormContentEditorProps = FormContentBaseProps & {\n mode: 'editor'\n components: EditorComponentMap\n renderFieldProps: (field: FieldContentItem) => EditorFieldProps\n renderArrayItemProps: (arrayField: FieldContentItem, index: number) => EditorArrayItemProps\n}\n\nexport type FormContentProps = FormContentViewerProps | FormContentEditorProps\n\nexport const FormContent: FC<FormContentProps> = (props) => {\n const { items, visibilityMap, values, fieldErrors, section, showInlineValidation } = props\n\n const sharedProps =\n props.mode === 'editor'\n ? {\n visibilityMap,\n values,\n fieldErrors,\n components: props.components,\n showInlineValidation,\n renderFieldProps: props.renderFieldProps,\n renderArrayItemProps: props.renderArrayItemProps,\n }\n : {\n visibilityMap,\n values,\n fieldErrors,\n components: props.components,\n showInlineValidation,\n }\n\n if (section === undefined) return <FormItems items={items} {...sharedProps} />\n\n if (section === ROOT) {\n const nonSectionItems = items.filter((item) => item.type !== 'section')\n return <FormItems items={nonSectionItems} {...sharedProps} />\n }\n\n const foundSection = findSection(items, section)\n if (!foundSection || !visibilityMap.get(foundSection.id)) return null\n\n const Section = props.components.section\n return (\n <Section key={foundSection.id} section={foundSection}>\n <FormItems items={foundSection.content} {...sharedProps} />\n </Section>\n )\n}\n","import { type FC, useCallback, useRef } from 'react'\n\nimport { FieldContentItem, FormDocument, FormEngine, FormValidationResult } from '@bluprynt/forms-core'\n\nimport { FormContent } from './form'\nimport { useFormContext } from './form-context'\nimport type { EditorArrayItemProps, EditorComponentMap, EditorFieldProps } from './types'\n\ntype FormEditorProps = {\n components: EditorComponentMap\n onChange: (data: FormDocument, validation: FormValidationResult) => void\n}\n\nexport const FormEditor: FC<FormEditorProps> = ({ components, onChange }) => {\n const { definition, data, visibilityMap, fieldErrors, section, engine, showInlineValidation, documentErrors } =\n useFormContext()\n\n const { renderFieldProps, renderArrayItemProps } = useEditorHandlers(engine, data, onChange)\n\n if (!definition || !data || (documentErrors && documentErrors.length > 0)) return null\n\n return (\n <FormContent\n mode=\"editor\"\n items={definition.content}\n visibilityMap={visibilityMap}\n values={data.values}\n fieldErrors={fieldErrors}\n components={components}\n section={section}\n showInlineValidation={showInlineValidation}\n renderFieldProps={renderFieldProps}\n renderArrayItemProps={renderArrayItemProps}\n />\n )\n}\n\nexport const useEditorHandlers = (\n engine: FormEngine | undefined,\n data: FormDocument | undefined,\n onChange: (data: FormDocument, validation: FormValidationResult) => void,\n): {\n renderFieldProps: (field: FieldContentItem) => EditorFieldProps\n renderArrayItemProps: (field: FieldContentItem, index: number) => EditorArrayItemProps\n} => {\n // Latest ref pattern\n const stateRef = useRef({ data, onChange, engine })\n stateRef.current = { data, onChange, engine }\n\n // Per-field onChange handler\n\n const fieldOnChangeMap = useRef(new Map<string, (value: unknown) => void>())\n const getFieldOnChange = useCallback((fieldId: number): ((value: unknown) => void) => {\n const key = String(fieldId)\n\n let handler = fieldOnChangeMap.current.get(key)\n if (!handler) {\n handler = (newValue: unknown) => {\n const { data, onChange, engine } = stateRef.current\n if (!data || !engine) return\n\n const document: FormDocument = { ...data, values: { ...data.values, [key]: newValue } }\n\n onChange(document, engine.validate(document))\n }\n fieldOnChangeMap.current.set(key, handler)\n }\n return handler\n }, [])\n\n // Array mutation handlers\n\n const arrayHandlersMap = useRef(\n new Map<\n string,\n {\n onAddItem: () => void\n onRemoveItem: (index: number) => void\n onMoveItem: (fromIndex: number, toIndex: number) => void\n }\n >(),\n )\n const getArrayHandlers = useCallback((fieldId: number) => {\n const key = String(fieldId)\n\n let handlers = arrayHandlersMap.current.get(key)\n if (!handlers) {\n const fire = (mutate: (arr: unknown[]) => unknown[]) => {\n const { data, onChange, engine } = stateRef.current\n if (!data || !engine) return\n\n const items = (data.values[key] as unknown[] | undefined) ?? []\n const document: FormDocument = { ...data, values: { ...data.values, [key]: mutate([...items]) } }\n\n onChange(document, engine.validate(document))\n }\n\n handlers = {\n onAddItem: () =>\n fire((values) => {\n values.push(undefined)\n return values\n }),\n onRemoveItem: (index: number) =>\n fire((values) => {\n values.splice(index, 1)\n return values\n }),\n onMoveItem: (fromIndex: number, toIndex: number) =>\n fire((values) => {\n const [moved] = values.splice(fromIndex, 1)\n values.splice(toIndex, 0, moved)\n return values\n }),\n }\n arrayHandlersMap.current.set(key, handlers)\n }\n return handlers\n }, [])\n\n // Array item onChange handler\n\n const arrayItemOnChangeMap = useRef(new Map<string, (value: unknown) => void>())\n const getArrayItemOnChange = useCallback((fieldId: number, index: number): ((value: unknown) => void) => {\n const mapKey = `${fieldId}-${index}`\n\n let handler = arrayItemOnChangeMap.current.get(mapKey)\n if (!handler) {\n handler = (newValue: unknown) => {\n const fieldKey = String(fieldId)\n\n const { data, onChange, engine } = stateRef.current\n if (!data || !engine) return\n\n const items = [...((data.values[fieldKey] as unknown[] | undefined) ?? [])]\n items[index] = newValue\n\n const document: FormDocument = { ...data, values: { ...data.values, [fieldKey]: items } }\n onChange(document, engine.validate(document))\n }\n arrayItemOnChangeMap.current.set(mapKey, handler)\n }\n return handler\n }, [])\n\n return {\n renderFieldProps: (field: FieldContentItem): EditorFieldProps => {\n if (field.type === 'array') {\n return {\n onChange: getFieldOnChange(field.id),\n ...getArrayHandlers(field.id),\n }\n }\n return { onChange: getFieldOnChange(field.id) }\n },\n renderArrayItemProps: (field: FieldContentItem, index: number): EditorArrayItemProps => ({\n onChange: getArrayItemOnChange(field.id, index),\n }),\n } as const\n}\n","import { type ComponentType, type FC, type PropsWithChildren, useMemo } from 'react'\n\nimport type { FieldEntry, FieldValidationError } from '@bluprynt/forms-core'\n\nimport { useFormContext } from './form-context'\n\nexport type FieldValidationFieldEntry = {\n field: FieldEntry | undefined\n errors: FieldValidationError[]\n}\n\ntype FormFieldsValidationProps = {\n container: ComponentType<PropsWithChildren>\n field: ComponentType<PropsWithChildren<FieldValidationFieldEntry>>\n error: ComponentType<FieldValidationError>\n}\n\nexport const FormFieldsValidation: FC<FormFieldsValidationProps> = ({\n container: ContainerComponent,\n field: FieldComponent,\n error: ErrorComponent,\n}) => {\n const { engine, data, fieldErrors, visibilityMap } = useFormContext()\n\n const groups = useMemo(() => {\n if (!engine || !data || fieldErrors.size === 0) return []\n\n const result: FieldValidationFieldEntry[] = []\n\n for (const [fieldId, errors] of fieldErrors) {\n if (visibilityMap.get(fieldId) === false) continue\n\n result.push({\n field: engine.getFieldDef(fieldId),\n errors,\n })\n }\n\n return result\n }, [engine, data, fieldErrors, visibilityMap])\n\n if (groups.length === 0) return null\n\n return (\n <ContainerComponent>\n {groups.map((group) => (\n <FieldComponent key={group.field?.id} {...group}>\n {group.errors.map((error) => (\n <ErrorComponent key={`${error.fieldId}-${error.rule}-${error.itemIndex ?? ''}`} {...error} />\n ))}\n </FieldComponent>\n ))}\n </ContainerComponent>\n )\n}\n","import { useMemo } from 'react'\n\nimport type { SectionContentItem } from '@bluprynt/forms-core'\n\nimport { ROOT } from './constants'\nimport { useFormContext } from './form-context'\n\nexport type FormSectionEntry = Omit<SectionContentItem, 'id' | 'type'> & {\n id: typeof ROOT | number\n}\n\nexport const useFormSections = (\n defaultSectionTitle = 'General',\n defaultSectionDescription?: string,\n): FormSectionEntry[] => {\n const { definition, visibilityMap, data } = useFormContext()\n\n // biome-ignore lint/correctness/useExhaustiveDependencies: invalidate section list when data changes\n return useMemo(() => {\n if (!definition) return []\n\n const result: FormSectionEntry[] = []\n\n const rootFields = definition.content.filter((item) => item.type !== 'section')\n if (rootFields.some((item) => visibilityMap.get(item.id)))\n result.push({\n id: ROOT,\n title: defaultSectionTitle,\n description: defaultSectionDescription,\n content: rootFields,\n condition: undefined,\n })\n\n for (const item of definition.content) {\n if (item.type === 'section') {\n if (visibilityMap.get(item.id) === false) continue\n\n result.push(item)\n }\n }\n\n return result\n }, [definition?.content, visibilityMap, data, defaultSectionTitle, defaultSectionDescription])\n}\n","import { type ComponentType, type FC, type PropsWithChildren } from 'react'\n\nimport { ROOT } from './constants'\nimport { useFormContext } from './form-context'\nimport { type FormSectionEntry, useFormSections } from './use-form-sections'\n\nexport type { FormSectionEntry }\n\nexport type FormSectionItemProps = {\n index: number\n section: FormSectionEntry\n active: boolean\n select: () => void\n}\n\ntype FormSectionsProps = {\n container: ComponentType<PropsWithChildren>\n item: ComponentType<FormSectionItemProps>\n defaultSectionTitle?: string\n defaultSectionDescription?: string\n onSelect?: (id: typeof ROOT | number) => void\n}\n\nexport const FormSections: FC<FormSectionsProps> = ({\n container: Container,\n item: Item,\n defaultSectionTitle,\n defaultSectionDescription,\n onSelect,\n}) => {\n const { definition, data, documentErrors, section } = useFormContext()\n const entries = useFormSections(defaultSectionTitle, defaultSectionDescription)\n\n if (!definition || !data || (documentErrors && documentErrors.length > 0)) return null\n\n return (\n <Container>\n {entries.map((entry, index) => (\n <Item\n key={entry.id === ROOT ? 'root' : String(entry.id)}\n index={index}\n section={entry}\n active={entry.id === section}\n select={() => onSelect?.(entry.id)}\n />\n ))}\n </Container>\n )\n}\n","import type { FC } from 'react'\n\nimport { FormContent } from './form'\nimport { useFormContext } from './form-context'\nimport type { ViewerComponentMap } from './types'\n\ntype FormViewerProps = {\n components: ViewerComponentMap\n}\n\nexport const FormViewer: FC<FormViewerProps> = ({ components }) => {\n const { definition, data, visibilityMap, fieldErrors, section, showInlineValidation, documentErrors } =\n useFormContext()\n\n if (!definition || !data || (documentErrors && documentErrors.length > 0)) return null\n\n return (\n <FormContent\n mode=\"viewer\"\n items={definition.content}\n visibilityMap={visibilityMap}\n values={data.values}\n fieldErrors={fieldErrors}\n components={components}\n section={section}\n showInlineValidation={showInlineValidation}\n />\n )\n}\n"],"mappings":";;;;AAAA,MAAa,OAAsB,OAAO,OAAO;;;AC0BjD,MAAM,cAAc,cAA4C,KAAA,EAAU;AAE1E,MAAa,uBAAyC;CAClD,MAAM,UAAU,WAAW,YAAY;AACvC,KAAI,CAAC,QAAS,OAAM,IAAI,MAAM,uDAAuD;AAErF,QAAO;;AAWX,MAAa,QAAuB,EAAE,YAAY,MAAM,SAAS,uBAAuB,MAAM,eAAe;CACzG,MAAM,EAAE,QAAQ,gBAAgB,qBAAqB,cAAc;AAC/D,MAAI,CAAC,WAAY,QAAO,EAAE;AAE1B,MAAI;AACA,UAAO,EAAE,QAAQ,IAAI,WAAW,WAAW,EAAE;WACxC,OAAO;AACZ,OAAI,iBAAiBA,gBAAe,QAAO,EAAE,gBAAgB,MAA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QACI,oBAAC,WAAD,EAAA,UACK,QAAQ,KAAK,OAAO,UACjB,oBAAC,MAAD;EAEW;EACP,SAAS;EACT,QAAQ,MAAM,OAAO;EACrB,cAAc,WAAW,MAAM,GAAG;EACpC,EALO,MAAM,OAAO,OAAO,SAAS,OAAO,MAAM,GAAG,CAKpD,CACJ,EACM,CAAA;;;;ACpCpB,MAAa,cAAmC,EAAE,iBAAiB;CAC/D,MAAM,EAAE,YAAY,MAAM,eAAe,aAAa,SAAS,sBAAsB,mBACjF,gBAAgB;AAEpB,KAAI,CAAC,cAAc,CAAC,QAAS,kBAAkB,eAAe,SAAS,EAAI,QAAO;AAElF,QACI,oBAAC,aAAD;EACI,MAAK;EACL,OAAO,WAAW;EACH;EACf,QAAQ,KAAK;EACA;EACD;EACH;EACa;EACxB,CAAA"}
1
+ {"version":3,"file":"index.mjs","names":["DocumentError"],"sources":["../src/constants.ts","../src/form-context.tsx","../src/form-document-validation.tsx","../src/form/utils.ts","../src/form/form-items.tsx","../src/form/form-content.tsx","../src/form-editor.tsx","../src/form-fields-validation.tsx","../src/use-form-sections.ts","../src/form-sections.tsx","../src/form-viewer.tsx"],"sourcesContent":["export const ROOT: unique symbol = Symbol('ROOT')\nexport type ROOT = typeof ROOT\n\nexport const DEFAULT: unique symbol = Symbol('DEFAULT')\nexport type DEFAULT = typeof DEFAULT\n","import { createContext, type FC, type ReactNode, useContext, useMemo } from 'react'\n\nimport {\n DocumentError,\n DocumentValidationError,\n FieldValidationError,\n FormDefinition,\n FormDocument,\n FormEngine,\n FormValidationResult,\n} from '@bluprynt/forms-core'\n\nimport type { DEFAULT, ROOT } from './constants'\n\ntype FormContextValue = {\n definition: FormDefinition | undefined\n data: FormDocument | undefined\n engine: FormEngine | undefined\n visibilityMap: Map<number, boolean>\n validation: FormValidationResult | undefined\n documentErrors: readonly DocumentValidationError[] | undefined\n fieldErrors: Map<number, FieldValidationError[]>\n section: typeof ROOT | typeof DEFAULT | number | undefined\n showInlineValidation: boolean\n}\n\nconst FormContext = createContext<FormContextValue | undefined>(undefined)\n\nexport const useFormContext = (): FormContextValue => {\n const context = useContext(FormContext)\n if (!context) throw new Error('useFormContext must be used within a <Form> provider')\n\n return context\n}\n\ntype FormProps = {\n definition?: FormDefinition\n data?: FormDocument\n section?: typeof ROOT | typeof DEFAULT | number\n showInlineValidation?: boolean\n children: ReactNode\n}\n\nexport const Form: FC<FormProps> = ({ definition, data, section, showInlineValidation = true, children }) => {\n const { engine, documentErrors: definitionErrors } = useMemo(() => {\n if (!definition) return {}\n\n try {\n return { engine: new FormEngine(definition) }\n } catch (error) {\n if (error instanceof DocumentError) return { documentErrors: error.errors }\n throw error\n }\n }, [definition])\n\n const { visibilityMap, validation, documentErrors, fieldErrors } = useMemo(() => {\n const visibilityMap = engine && data ? engine.getVisibilityMap(data) : new Map<number, boolean>()\n const validation =\n engine && data\n ? engine.validate(data)\n : ({\n valid: true,\n fieldErrors: new Map<number, FieldValidationError[]>(),\n } satisfies FormValidationResult)\n\n return {\n visibilityMap,\n validation,\n documentErrors: [...(definitionErrors ?? []), ...(validation?.documentErrors ?? [])],\n fieldErrors: validation?.fieldErrors ?? new Map<number, FieldValidationError[]>(),\n } as const\n }, [engine, data, definitionErrors])\n\n const value: FormContextValue = {\n definition,\n data,\n engine,\n visibilityMap,\n validation,\n documentErrors,\n fieldErrors,\n section,\n showInlineValidation,\n } as const\n\n return <FormContext.Provider value={value}>{children}</FormContext.Provider>\n}\n","import type { ComponentType, FC, PropsWithChildren } from 'react'\n\nimport type { DocumentValidationError } from '@bluprynt/forms-core'\n\nimport { useFormContext } from './form-context'\n\ntype FormDocumentValidationProps = {\n container: ComponentType<PropsWithChildren>\n error: ComponentType<DocumentValidationError>\n}\n\nexport const FormDocumentValidation: FC<FormDocumentValidationProps> = ({\n container: ContainerComponent,\n error: ErrorComponent,\n}) => {\n const { documentErrors } = useFormContext()\n\n if (!documentErrors?.length) return null\n\n return (\n <ContainerComponent>\n {documentErrors.map((error, index) => (\n <ErrorComponent\n // biome-ignore lint/suspicious/noArrayIndexKey: index is unique in array\n key={`error-${error.code}-${error.itemId ?? ''}-${index}`}\n {...error}\n />\n ))}\n </ContainerComponent>\n )\n}\n","import type {\n ArrayItemDef,\n ContentItem,\n FieldContentItem,\n FieldType,\n FieldValidationError,\n SectionContentItem,\n} from '@bluprynt/forms-core'\n\n/**\n * Retrieves validation errors for a specific field from the pre-indexed error map.\n *\n * Uses O(1) map lookup by `fieldId`. When `itemIndex` is omitted, returns only\n * **field-level** errors (those without an `itemIndex`). When `itemIndex` is\n * provided, returns only **item-level** errors matching the given array item index.\n *\n * @param fieldErrors - Map from field id to its validation errors.\n * @param fieldId - The numeric ID of the field to retrieve errors for.\n * @param itemIndex - Optional zero-based index of the array item. When omitted, only\n * field-level errors (where `itemIndex` is `null` / `undefined`) are returned.\n * @returns Errors for the given field (and optionally item index). Empty array if none.\n *\n * @example\n * ```ts\n * // Field-level errors only (no itemIndex on the error)\n * getFieldErrors(fieldErrors, 5)\n *\n * // Errors for the third item of array field 5\n * getFieldErrors(fieldErrors, 5, 2)\n * ```\n */\nexport const getFieldErrors = (\n fieldErrors: Map<number, FieldValidationError[]>,\n fieldId: number,\n itemIndex?: number,\n): FieldValidationError[] => {\n const errors = fieldErrors.get(fieldId) ?? []\n if (itemIndex === undefined) return errors.filter((e) => e.itemIndex == null)\n return errors.filter((e) => e.itemIndex === itemIndex)\n}\n\n/**\n * Creates a synthetic {@link FieldContentItem} that represents a single item inside an array field.\n *\n * Array fields store their per-item schema in `arrayField.item` ({@link ArrayItemDef}).\n * Components that render individual array items need a standard `FieldContentItem` shape,\n * so this helper projects the item definition into one, preserving the parent field's `id`\n * while adopting the item's `type`, `label`, `description`, `validation`, and `options`.\n *\n * @param arrayField - The array field definition whose `.item` property describes the item schema.\n * @param _index - The zero-based position of the item in the array (reserved for future use,\n * e.g. per-item overrides).\n * @returns A `FieldContentItem` that can be passed directly to a typed field component.\n *\n * @example\n * ```ts\n * const arrayField: FieldContentItem = {\n * id: 10, type: 'array', label: 'Tags',\n * item: { type: 'string', label: 'Tag' },\n * }\n *\n * const itemDef = getArrayField(arrayField, 0)\n * // → { id: 10, type: 'string', label: 'Tag', ... }\n * ```\n */\nexport const getArrayField = (arrayField: FieldContentItem, _index: number): FieldContentItem => {\n const itemDef = arrayField.item as ArrayItemDef\n return {\n id: arrayField.id,\n type: itemDef.type as FieldType,\n label: itemDef.label,\n description: itemDef.description,\n validation: itemDef.validation as FieldContentItem['validation'],\n options: itemDef.options,\n }\n}\n\n/**\n * Recursively searches content items for a section with the given id.\n *\n * Walks the content tree depth-first, checking sections and their nested\n * content. Returns the first matching {@link SectionContentItem}, or\n * `undefined` if no section with that id exists.\n *\n * @param items - The content items to search through.\n * @param sectionId - The numeric id of the section to find.\n * @returns The matching section, or `undefined` if not found.\n *\n * @example\n * ```ts\n * const section = findSection(definition.content, 42)\n * if (section) {\n * // render section.content\n * }\n * ```\n */\nexport const findSection = (items: ContentItem[], sectionId: number): SectionContentItem | undefined => {\n for (const item of items) {\n if (item.type === 'section') {\n if (item.id === sectionId) return item\n const found = findSection(item.content, sectionId)\n if (found) return found\n }\n }\n return undefined\n}\n","import { type FC, Fragment } from 'react'\n\nimport type {\n ArrayItemDef,\n ContentItem,\n FieldContentItem,\n FieldValidationError,\n FormValues,\n} from '@bluprynt/forms-core'\n\nimport type { EditorArrayItemProps, EditorComponentMap, EditorFieldProps, ViewerComponentMap } from '../types'\nimport { getArrayField, getFieldErrors } from './utils'\n\ntype FormItemsProps = {\n items: ContentItem[]\n visibilityMap: Map<number, boolean>\n values: FormValues\n fieldErrors: Map<number, FieldValidationError[]>\n components: ViewerComponentMap | EditorComponentMap\n showInlineValidation: boolean\n renderFieldProps?: (field: FieldContentItem) => EditorFieldProps\n renderArrayItemProps?: (arrayField: FieldContentItem, index: number) => EditorArrayItemProps\n}\n\nexport const FormItems: FC<FormItemsProps> = ({\n items,\n visibilityMap,\n values,\n fieldErrors,\n components,\n showInlineValidation,\n renderFieldProps,\n renderArrayItemProps,\n}) => {\n const SectionComponent = components.section\n const ErrorComponent = showInlineValidation ? components.error : undefined\n\n const elements: React.ReactNode[] = []\n\n for (const item of items) {\n if (!visibilityMap.get(item.id)) continue\n\n if (item.type === 'section') {\n elements.push(\n <SectionComponent key={item.id} section={item}>\n <FormItems\n items={item.content}\n visibilityMap={visibilityMap}\n values={values}\n fieldErrors={fieldErrors}\n components={components}\n showInlineValidation={showInlineValidation}\n renderFieldProps={renderFieldProps}\n renderArrayItemProps={renderArrayItemProps}\n />\n </SectionComponent>,\n )\n } else if (item.type === 'array') {\n const errors = getFieldErrors(fieldErrors, item.id)\n const modeProps = renderFieldProps?.(item) ?? {}\n\n const ArrayComponent = components.array as React.ComponentType<Record<string, unknown>>\n const arrayValue = (values[String(item.id)] as unknown[] | undefined) ?? []\n const itemDef = item.item as ArrayItemDef\n const ItemComponent = components[\n itemDef.type as keyof Omit<ViewerComponentMap, 'array' | 'section' | 'error'>\n ] as React.ComponentType<Record<string, unknown>> | undefined\n\n elements.push(\n <ArrayComponent\n key={item.id}\n field={item}\n value={values[String(item.id)]}\n itemDef={item.item}\n errors={errors}\n {...modeProps}>\n {ItemComponent\n ? arrayValue.map((itemValue, index) => {\n const itemErrors = getFieldErrors(fieldErrors, item.id, index)\n const synthetic = getArrayField(item, index)\n const itemModeProps = renderArrayItemProps?.(item, index) ?? {}\n\n const baseProps: Record<string, unknown> = {\n field: synthetic,\n value: itemValue,\n errors: itemErrors,\n ...itemModeProps,\n }\n\n if (itemDef.type === 'select') {\n baseProps.options = itemDef.options ?? []\n }\n\n return (\n // biome-ignore lint/suspicious/noArrayIndexKey: index is unique in array\n <Fragment key={`${item.id}-${index}`}>\n <ItemComponent {...baseProps} />\n {ErrorComponent && itemErrors.length > 0 && (\n <ErrorComponent errors={itemErrors} field={synthetic} />\n )}\n </Fragment>\n )\n })\n : null}\n </ArrayComponent>,\n )\n\n if (ErrorComponent && errors.length > 0) {\n elements.push(<ErrorComponent key={`${item.id}-error`} errors={errors} field={item} />)\n }\n } else {\n const errors = getFieldErrors(fieldErrors, item.id)\n const modeProps = renderFieldProps?.(item) ?? {}\n\n const fieldProps: Record<string, unknown> = {\n field: item,\n value: values[String(item.id)],\n errors,\n ...modeProps,\n }\n\n if (item.type === 'select') fieldProps.options = (item as FieldContentItem).options ?? []\n\n const fieldType = item.type as keyof Omit<ViewerComponentMap, 'array' | 'section' | 'error'>\n const FieldComponent = components[fieldType] as React.ComponentType<Record<string, unknown>>\n\n elements.push(<FieldComponent key={item.id} {...fieldProps} />)\n\n if (ErrorComponent && errors.length > 0)\n elements.push(<ErrorComponent key={`${item.id}-error`} errors={errors} field={item} />)\n }\n }\n\n if (elements.length === 0) return null\n\n return elements\n}\n","import type { FC } from 'react'\n\nimport type { ContentItem, FieldContentItem, FieldValidationError, FormValues } from '@bluprynt/forms-core'\n\nimport { DEFAULT, ROOT } from '../constants'\nimport type { EditorArrayItemProps, EditorComponentMap, EditorFieldProps, ViewerComponentMap } from '../types'\nimport { FormItems } from './form-items'\nimport { findSection } from './utils'\n\ntype FormContentBaseProps = {\n items: ContentItem[]\n visibilityMap: Map<number, boolean>\n values: FormValues\n fieldErrors: Map<number, FieldValidationError[]>\n section?: typeof ROOT | typeof DEFAULT | number\n showInlineValidation: boolean\n}\n\ntype FormContentViewerProps = FormContentBaseProps & {\n mode: 'viewer'\n components: ViewerComponentMap\n}\n\ntype FormContentEditorProps = FormContentBaseProps & {\n mode: 'editor'\n components: EditorComponentMap\n renderFieldProps: (field: FieldContentItem) => EditorFieldProps\n renderArrayItemProps: (arrayField: FieldContentItem, index: number) => EditorArrayItemProps\n}\n\nexport type FormContentProps = FormContentViewerProps | FormContentEditorProps\n\nexport const FormContent: FC<FormContentProps> = (props) => {\n const { items, visibilityMap, values, fieldErrors, section, showInlineValidation } = props\n\n const sharedProps =\n props.mode === 'editor'\n ? {\n visibilityMap,\n values,\n fieldErrors,\n components: props.components,\n showInlineValidation,\n renderFieldProps: props.renderFieldProps,\n renderArrayItemProps: props.renderArrayItemProps,\n }\n : {\n visibilityMap,\n values,\n fieldErrors,\n components: props.components,\n showInlineValidation,\n }\n\n const selectedSection = section === DEFAULT ? resolveDefaultSection(items, visibilityMap) : section\n\n if (selectedSection === undefined) return <FormItems items={items} {...sharedProps} />\n\n if (selectedSection === ROOT) {\n const nonSectionItems = items.filter((item) => item.type !== 'section')\n return <FormItems items={nonSectionItems} {...sharedProps} />\n }\n\n const foundSection = findSection(items, selectedSection)\n if (!foundSection || !visibilityMap.get(foundSection.id)) return null\n\n const Section = props.components.section\n return (\n <Section key={foundSection.id} section={foundSection}>\n <FormItems items={foundSection.content} {...sharedProps} />\n </Section>\n )\n}\n\nconst resolveDefaultSection = (\n items: ContentItem[],\n visibilityMap: Map<number, boolean>,\n): typeof ROOT | number | undefined => {\n const rootFields = items.filter((item) => item.type !== 'section')\n if (rootFields.some((item) => visibilityMap.get(item.id))) return ROOT\n\n const firstVisibleSection = items.find((item) => item.type === 'section' && visibilityMap.get(item.id) !== false)\n\n return firstVisibleSection?.id\n}\n","import { type FC, useCallback, useRef } from 'react'\n\nimport { FieldContentItem, FormDocument, FormEngine, FormValidationResult } from '@bluprynt/forms-core'\n\nimport { FormContent } from './form'\nimport { useFormContext } from './form-context'\nimport type { EditorArrayItemProps, EditorComponentMap, EditorFieldProps } from './types'\n\ntype FormEditorProps = {\n components: EditorComponentMap\n onChange: (data: FormDocument, validation: FormValidationResult) => void\n}\n\nexport const FormEditor: FC<FormEditorProps> = ({ components, onChange }) => {\n const { definition, data, visibilityMap, fieldErrors, section, engine, showInlineValidation, documentErrors } =\n useFormContext()\n\n const { renderFieldProps, renderArrayItemProps } = useEditorHandlers(engine, data, onChange)\n\n if (!definition || !data || (documentErrors && documentErrors.length > 0)) return null\n\n return (\n <FormContent\n mode=\"editor\"\n items={definition.content}\n visibilityMap={visibilityMap}\n values={data.values}\n fieldErrors={fieldErrors}\n components={components}\n section={section}\n showInlineValidation={showInlineValidation}\n renderFieldProps={renderFieldProps}\n renderArrayItemProps={renderArrayItemProps}\n />\n )\n}\n\nexport const useEditorHandlers = (\n engine: FormEngine | undefined,\n data: FormDocument | undefined,\n onChange: (data: FormDocument, validation: FormValidationResult) => void,\n): {\n renderFieldProps: (field: FieldContentItem) => EditorFieldProps\n renderArrayItemProps: (field: FieldContentItem, index: number) => EditorArrayItemProps\n} => {\n // Latest ref pattern\n const stateRef = useRef({ data, onChange, engine })\n stateRef.current = { data, onChange, engine }\n\n // Per-field onChange handler\n\n const fieldOnChangeMap = useRef(new Map<string, (value: unknown) => void>())\n const getFieldOnChange = useCallback((fieldId: number): ((value: unknown) => void) => {\n const key = String(fieldId)\n\n let handler = fieldOnChangeMap.current.get(key)\n if (!handler) {\n handler = (newValue: unknown) => {\n const { data, onChange, engine } = stateRef.current\n if (!data || !engine) return\n\n const document: FormDocument = { ...data, values: { ...data.values, [key]: newValue } }\n\n onChange(document, engine.validate(document))\n }\n fieldOnChangeMap.current.set(key, handler)\n }\n return handler\n }, [])\n\n // Array mutation handlers\n\n const arrayHandlersMap = useRef(\n new Map<\n string,\n {\n onAddItem: () => void\n onRemoveItem: (index: number) => void\n onMoveItem: (fromIndex: number, toIndex: number) => void\n }\n >(),\n )\n const getArrayHandlers = useCallback((fieldId: number) => {\n const key = String(fieldId)\n\n let handlers = arrayHandlersMap.current.get(key)\n if (!handlers) {\n const fire = (mutate: (arr: unknown[]) => unknown[]) => {\n const { data, onChange, engine } = stateRef.current\n if (!data || !engine) return\n\n const items = (data.values[key] as unknown[] | undefined) ?? []\n const document: FormDocument = { ...data, values: { ...data.values, [key]: mutate([...items]) } }\n\n onChange(document, engine.validate(document))\n }\n\n handlers = {\n onAddItem: () =>\n fire((values) => {\n values.push(undefined)\n return values\n }),\n onRemoveItem: (index: number) =>\n fire((values) => {\n values.splice(index, 1)\n return values\n }),\n onMoveItem: (fromIndex: number, toIndex: number) =>\n fire((values) => {\n const [moved] = values.splice(fromIndex, 1)\n values.splice(toIndex, 0, moved)\n return values\n }),\n }\n arrayHandlersMap.current.set(key, handlers)\n }\n return handlers\n }, [])\n\n // Array item onChange handler\n\n const arrayItemOnChangeMap = useRef(new Map<string, (value: unknown) => void>())\n const getArrayItemOnChange = useCallback((fieldId: number, index: number): ((value: unknown) => void) => {\n const mapKey = `${fieldId}-${index}`\n\n let handler = arrayItemOnChangeMap.current.get(mapKey)\n if (!handler) {\n handler = (newValue: unknown) => {\n const fieldKey = String(fieldId)\n\n const { data, onChange, engine } = stateRef.current\n if (!data || !engine) return\n\n const items = [...((data.values[fieldKey] as unknown[] | undefined) ?? [])]\n items[index] = newValue\n\n const document: FormDocument = { ...data, values: { ...data.values, [fieldKey]: items } }\n onChange(document, engine.validate(document))\n }\n arrayItemOnChangeMap.current.set(mapKey, handler)\n }\n return handler\n }, [])\n\n return {\n renderFieldProps: (field: FieldContentItem): EditorFieldProps => {\n if (field.type === 'array') {\n return {\n onChange: getFieldOnChange(field.id),\n ...getArrayHandlers(field.id),\n }\n }\n return { onChange: getFieldOnChange(field.id) }\n },\n renderArrayItemProps: (field: FieldContentItem, index: number): EditorArrayItemProps => ({\n onChange: getArrayItemOnChange(field.id, index),\n }),\n } as const\n}\n","import { type ComponentType, type FC, type PropsWithChildren, useMemo } from 'react'\n\nimport type { FieldEntry, FieldValidationError } from '@bluprynt/forms-core'\n\nimport { useFormContext } from './form-context'\n\nexport type FieldValidationFieldEntry = {\n field: FieldEntry | undefined\n errors: FieldValidationError[]\n}\n\ntype FormFieldsValidationProps = {\n container: ComponentType<PropsWithChildren>\n field: ComponentType<PropsWithChildren<FieldValidationFieldEntry>>\n error: ComponentType<FieldValidationError>\n}\n\nexport const FormFieldsValidation: FC<FormFieldsValidationProps> = ({\n container: ContainerComponent,\n field: FieldComponent,\n error: ErrorComponent,\n}) => {\n const { engine, data, fieldErrors, visibilityMap } = useFormContext()\n\n const groups = useMemo(() => {\n if (!engine || !data || fieldErrors.size === 0) return []\n\n const result: FieldValidationFieldEntry[] = []\n\n for (const [fieldId, errors] of fieldErrors) {\n if (visibilityMap.get(fieldId) === false) continue\n\n result.push({\n field: engine.getFieldDef(fieldId),\n errors,\n })\n }\n\n return result\n }, [engine, data, fieldErrors, visibilityMap])\n\n if (groups.length === 0) return null\n\n return (\n <ContainerComponent>\n {groups.map((group) => (\n <FieldComponent key={group.field?.id} {...group}>\n {group.errors.map((error) => (\n <ErrorComponent key={`${error.fieldId}-${error.rule}-${error.itemIndex ?? ''}`} {...error} />\n ))}\n </FieldComponent>\n ))}\n </ContainerComponent>\n )\n}\n","import { useMemo } from 'react'\n\nimport type { SectionContentItem } from '@bluprynt/forms-core'\n\nimport { ROOT } from './constants'\nimport { useFormContext } from './form-context'\n\nexport type FormSectionEntry = Omit<SectionContentItem, 'id' | 'type'> & {\n id: typeof ROOT | number\n}\n\nexport const useFormSections = (\n defaultSectionTitle = 'General',\n defaultSectionDescription?: string,\n): FormSectionEntry[] => {\n const { definition, visibilityMap, data } = useFormContext()\n\n // biome-ignore lint/correctness/useExhaustiveDependencies: invalidate section list when data changes\n return useMemo(() => {\n if (!definition) return []\n\n const result: FormSectionEntry[] = []\n\n const rootFields = definition.content.filter((item) => item.type !== 'section')\n if (rootFields.some((item) => visibilityMap.get(item.id)))\n result.push({\n id: ROOT,\n title: defaultSectionTitle,\n description: defaultSectionDescription,\n content: rootFields,\n condition: undefined,\n })\n\n for (const item of definition.content) {\n if (item.type === 'section') {\n if (visibilityMap.get(item.id) === false) continue\n\n result.push(item)\n }\n }\n\n return result\n }, [definition?.content, visibilityMap, data, defaultSectionTitle, defaultSectionDescription])\n}\n","import { type ComponentType, type FC, type PropsWithChildren } from 'react'\n\nimport { DEFAULT, ROOT } from './constants'\nimport { useFormContext } from './form-context'\nimport { type FormSectionEntry, useFormSections } from './use-form-sections'\n\nexport type { FormSectionEntry }\n\nexport type FormSectionItemProps = {\n index: number\n section: FormSectionEntry\n active: boolean\n select: () => void\n}\n\ntype FormSectionsProps = {\n container: ComponentType<PropsWithChildren>\n item: ComponentType<FormSectionItemProps>\n defaultSectionTitle?: string\n defaultSectionDescription?: string\n onSelect?: (id: typeof ROOT | typeof DEFAULT | number) => void\n}\n\nexport const FormSections: FC<FormSectionsProps> = ({\n container: Container,\n item: Item,\n defaultSectionTitle,\n defaultSectionDescription,\n onSelect,\n}) => {\n const { definition, data, documentErrors, section } = useFormContext()\n const entries = useFormSections(defaultSectionTitle, defaultSectionDescription)\n\n if (!definition || !data || (documentErrors && documentErrors.length > 0)) return null\n\n return (\n <Container>\n {entries.map((entry, index) => (\n <Item\n key={entry.id === ROOT ? 'root' : String(entry.id)}\n index={index}\n section={entry}\n active={section === DEFAULT ? index === 0 : entry.id === section}\n select={() => onSelect?.(entry.id)}\n />\n ))}\n </Container>\n )\n}\n","import type { FC } from 'react'\n\nimport { FormContent } from './form'\nimport { useFormContext } from './form-context'\nimport type { ViewerComponentMap } from './types'\n\ntype FormViewerProps = {\n components: ViewerComponentMap\n}\n\nexport const FormViewer: FC<FormViewerProps> = ({ components }) => {\n const { definition, data, visibilityMap, fieldErrors, section, showInlineValidation, documentErrors } =\n useFormContext()\n\n if (!definition || !data || (documentErrors && documentErrors.length > 0)) return null\n\n return (\n <FormContent\n mode=\"viewer\"\n items={definition.content}\n visibilityMap={visibilityMap}\n values={data.values}\n fieldErrors={fieldErrors}\n components={components}\n section={section}\n showInlineValidation={showInlineValidation}\n />\n )\n}\n"],"mappings":";;;;AAAA,MAAa,OAAsB,OAAO,OAAO;AAGjD,MAAa,UAAyB,OAAO,UAAU;;;ACuBvD,MAAM,cAAc,cAA4C,KAAA,EAAU;AAE1E,MAAa,uBAAyC;CAClD,MAAM,UAAU,WAAW,YAAY;AACvC,KAAI,CAAC,QAAS,OAAM,IAAI,MAAM,uDAAuD;AAErF,QAAO;;AAWX,MAAa,QAAuB,EAAE,YAAY,MAAM,SAAS,uBAAuB,MAAM,eAAe;CACzG,MAAM,EAAE,QAAQ,gBAAgB,qBAAqB,cAAc;AAC/D,MAAI,CAAC,WAAY,QAAO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MAAM,QAAQ,WAAW,QAC1B,KAAI,KAAK,SAAS,WAAW;AACzB,OAAI,cAAc,IAAI,KAAK,GAAG,KAAK,MAAO;AAE1C,UAAO,KAAK,KAAK;;AAIzB,SAAO;IACR;EAAC,YAAY;EAAS;EAAe;EAAM;EAAqB;EAA0B,CAAC;;;;ACnBlG,MAAa,gBAAuC,EAChD,WAAW,WACX,MAAM,MACN,qBACA,2BACA,eACE;CACF,MAAM,EAAE,YAAY,MAAM,gBAAgB,YAAY,gBAAgB;CACtE,MAAM,UAAU,gBAAgB,qBAAqB,0BAA0B;AAE/E,KAAI,CAAC,cAAc,CAAC,QAAS,kBAAkB,eAAe,SAAS,EAAI,QAAO;AAElF,QACI,oBAAC,WAAD,EAAA,UACK,QAAQ,KAAK,OAAO,UACjB,oBAAC,MAAD;EAEW;EACP,SAAS;EACT,QAAQ,YAAY,UAAU,UAAU,IAAI,MAAM,OAAO;EACzD,cAAc,WAAW,MAAM,GAAG;EACpC,EALO,MAAM,OAAO,OAAO,SAAS,OAAO,MAAM,GAAG,CAKpD,CACJ,EACM,CAAA;;;;ACpCpB,MAAa,cAAmC,EAAE,iBAAiB;CAC/D,MAAM,EAAE,YAAY,MAAM,eAAe,aAAa,SAAS,sBAAsB,mBACjF,gBAAgB;AAEpB,KAAI,CAAC,cAAc,CAAC,QAAS,kBAAkB,eAAe,SAAS,EAAI,QAAO;AAElF,QACI,oBAAC,aAAD;EACI,MAAK;EACL,OAAO,WAAW;EACH;EACf,QAAQ,KAAK;EACA;EACD;EACH;EACa;EACxB,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bluprynt/forms-viewer",
3
- "version": "2.0.0",
3
+ "version": "3.0.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/blupryntco/forms-engine.git",
@@ -24,7 +24,7 @@
24
24
  "peerDependencies": {
25
25
  "react": "^18.0.0 || ^19.0.0",
26
26
  "react-dom": "^18.0.0 || ^19.0.0",
27
- "@bluprynt/forms-core": "2.0.0"
27
+ "@bluprynt/forms-core": "3.0.0"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@testing-library/react": "16.3.2",
@@ -38,7 +38,7 @@
38
38
  "ts-jest": "29.4.6",
39
39
  "tsdown": "0.21.1",
40
40
  "typescript": "5.9.3",
41
- "@bluprynt/forms-core": "2.0.0",
41
+ "@bluprynt/forms-core": "3.0.0",
42
42
  "@repo/typescript-config": "0.0.0"
43
43
  },
44
44
  "scripts": {