@bluprynt/forms-viewer 1.0.0 → 2.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
@@ -416,10 +416,10 @@ const FormFieldsValidation = ({ container: ContainerComponent, field: FieldCompo
416
416
  }, group.field?.id)) });
417
417
  };
418
418
  //#endregion
419
- //#region src/form-sections.tsx
420
- const FormSections = ({ container: Container, item: Item, defaultSectionTitle = "General", defaultSectionDescription, onSelect }) => {
421
- const { definition, section, visibilityMap, data, documentErrors } = useFormContext();
422
- const entries = (0, react.useMemo)(() => {
419
+ //#region src/use-form-sections.ts
420
+ const useFormSections = (defaultSectionTitle = "General", defaultSectionDescription) => {
421
+ const { definition, visibilityMap, data } = useFormContext();
422
+ return (0, react.useMemo)(() => {
423
423
  if (!definition) return [];
424
424
  const result = [];
425
425
  const rootFields = definition.content.filter((item) => item.type !== "section");
@@ -442,8 +442,15 @@ const FormSections = ({ container: Container, item: Item, defaultSectionTitle =
442
442
  defaultSectionTitle,
443
443
  defaultSectionDescription
444
444
  ]);
445
+ };
446
+ //#endregion
447
+ //#region src/form-sections.tsx
448
+ const FormSections = ({ container: Container, item: Item, defaultSectionTitle, defaultSectionDescription, onSelect }) => {
449
+ const { definition, data, documentErrors, section } = useFormContext();
450
+ const entries = useFormSections(defaultSectionTitle, defaultSectionDescription);
445
451
  if (!definition || !data || documentErrors && documentErrors.length > 0) return null;
446
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Container, { children: entries.map((entry) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Item, {
452
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Container, { children: entries.map((entry, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Item, {
453
+ index,
447
454
  section: entry,
448
455
  active: entry.id === section,
449
456
  select: () => onSelect?.(entry.id)
@@ -486,3 +493,4 @@ Object.defineProperty(exports, "FormValuesEditor", {
486
493
  exports.FormViewer = FormViewer;
487
494
  exports.ROOT = ROOT;
488
495
  exports.useFormContext = useFormContext;
496
+ exports.useFormSections = useFormSections;
package/dist/index.d.cts CHANGED
@@ -166,11 +166,15 @@ type FormFieldsValidationProps = {
166
166
  };
167
167
  declare const FormFieldsValidation: FC<FormFieldsValidationProps>;
168
168
  //#endregion
169
- //#region src/form-sections.d.ts
169
+ //#region src/use-form-sections.d.ts
170
170
  type FormSectionEntry = Omit<SectionContentItem$1, 'id' | 'type'> & {
171
171
  id: typeof ROOT | number;
172
172
  };
173
+ declare const useFormSections: (defaultSectionTitle?: string, defaultSectionDescription?: string) => FormSectionEntry[];
174
+ //#endregion
175
+ //#region src/form-sections.d.ts
173
176
  type FormSectionItemProps = {
177
+ index: number;
174
178
  section: FormSectionEntry;
175
179
  active: boolean;
176
180
  select: () => void;
@@ -190,5 +194,5 @@ type FormViewerProps = {
190
194
  };
191
195
  declare const FormViewer: FC<FormViewerProps>;
192
196
  //#endregion
193
- 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 };
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 };
194
198
  //# 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/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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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,KAGH,oBAAA;EACR,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;;;KCnBzB,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;;;KCarB,gBAAA;EACD,UAAA,EAAY,gBAAA;EACZ,IAAA,EAAM,cAAA;EACN,MAAA,EAAQ,UAAA;EACR,aAAA,EAAe,GAAA;EACf,UAAA,EAAY,sBAAA;EAC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A,CAAG,eAAA"}
package/dist/index.d.mts CHANGED
@@ -166,11 +166,15 @@ type FormFieldsValidationProps = {
166
166
  };
167
167
  declare const FormFieldsValidation: FC<FormFieldsValidationProps>;
168
168
  //#endregion
169
- //#region src/form-sections.d.ts
169
+ //#region src/use-form-sections.d.ts
170
170
  type FormSectionEntry = Omit<SectionContentItem$1, 'id' | 'type'> & {
171
171
  id: typeof ROOT | number;
172
172
  };
173
+ declare const useFormSections: (defaultSectionTitle?: string, defaultSectionDescription?: string) => FormSectionEntry[];
174
+ //#endregion
175
+ //#region src/form-sections.d.ts
173
176
  type FormSectionItemProps = {
177
+ index: number;
174
178
  section: FormSectionEntry;
175
179
  active: boolean;
176
180
  select: () => void;
@@ -190,5 +194,5 @@ type FormViewerProps = {
190
194
  };
191
195
  declare const FormViewer: FC<FormViewerProps>;
192
196
  //#endregion
193
- 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 };
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 };
194
198
  //# 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/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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Ac,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,KAGH,oBAAA;EACR,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;;;KCnBzB,eAAA;EACD,UAAA,EAAY,kBAAA;AAAA;AAAA,cAGH,UAAA,EAAY,EAAA,CAAG,eAAA"}
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,O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({ container: ContainerComponent, field: FieldCompo
415
415
  }, group.field?.id)) });
416
416
  };
417
417
  //#endregion
418
- //#region src/form-sections.tsx
419
- const FormSections = ({ container: Container, item: Item, defaultSectionTitle = "General", defaultSectionDescription, onSelect }) => {
420
- const { definition, section, visibilityMap, data, documentErrors } = useFormContext();
421
- const entries = useMemo(() => {
418
+ //#region src/use-form-sections.ts
419
+ const useFormSections = (defaultSectionTitle = "General", defaultSectionDescription) => {
420
+ const { definition, visibilityMap, data } = useFormContext();
421
+ return useMemo(() => {
422
422
  if (!definition) return [];
423
423
  const result = [];
424
424
  const rootFields = definition.content.filter((item) => item.type !== "section");
@@ -441,8 +441,15 @@ const FormSections = ({ container: Container, item: Item, defaultSectionTitle =
441
441
  defaultSectionTitle,
442
442
  defaultSectionDescription
443
443
  ]);
444
+ };
445
+ //#endregion
446
+ //#region src/form-sections.tsx
447
+ const FormSections = ({ container: Container, item: Item, defaultSectionTitle, defaultSectionDescription, onSelect }) => {
448
+ const { definition, data, documentErrors, section } = useFormContext();
449
+ const entries = useFormSections(defaultSectionTitle, defaultSectionDescription);
444
450
  if (!definition || !data || documentErrors && documentErrors.length > 0) return null;
445
- return /* @__PURE__ */ jsx(Container, { children: entries.map((entry) => /* @__PURE__ */ jsx(Item, {
451
+ return /* @__PURE__ */ jsx(Container, { children: entries.map((entry, index) => /* @__PURE__ */ jsx(Item, {
452
+ index,
446
453
  section: entry,
447
454
  active: entry.id === section,
448
455
  select: () => onSelect?.(entry.id)
@@ -465,6 +472,6 @@ const FormViewer = ({ components }) => {
465
472
  });
466
473
  };
467
474
  //#endregion
468
- export { DocumentError, Form, FormDocumentValidation, FormEditor, FormFieldsValidation, FormSections, FormValuesEditor, FormViewer, ROOT, useFormContext };
475
+ export { DocumentError, Form, FormDocumentValidation, FormEditor, FormFieldsValidation, FormSections, FormValuesEditor, FormViewer, ROOT, useFormContext, useFormSections };
469
476
 
470
477
  //# 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/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 { type ComponentType, type FC, type PropsWithChildren, 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 type FormSectionItemProps = {\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 = 'General',\n defaultSectionDescription,\n onSelect,\n}) => {\n const { definition, section, visibilityMap, data, documentErrors } = useFormContext()\n\n // biome-ignore lint/correctness/useExhaustiveDependencies: invalidate section list when data changes\n const entries = 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 if (!definition || !data || (documentErrors && documentErrors.length > 0)) return null\n\n return (\n <Container>\n {entries.map((entry) => (\n <Item\n key={entry.id === ROOT ? 'root' : String(entry.id)}\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,E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,WAAD,EAAA,UACK,QAAQ,KAAK,UACV,oBAAC,MAAD;EAEI,SAAS;EACT,QAAQ,MAAM,OAAO;EACrB,cAAc,WAAW,MAAM,GAAG;EACpC,EAJO,MAAM,OAAO,OAAO,SAAS,OAAO,MAAM,GAAG,CAIpD,CACJ,EACM,CAAA;;;;AC/DpB,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","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,MAAM,QAAQ;AAC3E,SAAM;;IAEX,CAAC,WAAW,CAAC;CAEhB,MAAM,EAAE,eAAe,YAAY,gBAAgB,gBAAgB,cAAc;EAC7E,MAAM,gBAAgB,UAAU,OAAO,OAAO,iBAAiB,KAAK,mBAAG,IAAI,KAAsB;EACjG,MAAM,aACF,UAAU,OACJ,OAAO,SAAS,KAAK,GACpB;GACG,OAAO;GACP,6BAAa,IAAI,KAAqC;GACzD;AAEX,SAAO;GACH;GACA;GACA,gBAAgB,CAAC,GAAI,oBAAoB,EAAE,EAAG,GAAI,YAAY,kBAAkB,EAAE,CAA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AkB,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": "1.0.0",
3
+ "version": "2.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": "1.0.0"
27
+ "@bluprynt/forms-core": "2.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": "1.0.0",
41
+ "@bluprynt/forms-core": "2.0.0",
42
42
  "@repo/typescript-config": "0.0.0"
43
43
  },
44
44
  "scripts": {