@bluprynt/forms-viewer 1.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/README.md +279 -0
- package/dist/index.cjs +488 -0
- package/dist/index.d.cts +194 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +194 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +470 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +53 -0
|
@@ -0,0 +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;;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GACb,SAAS;GACT,WAAW,KAAA;GACd,CAAC;AAEN,OAAK,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;AAE9F,KAAI,CAAC,cAAc,CAAC,QAAS,kBAAkB,eAAe,SAAS,EAAI,QAAO;AAElF,QACI,oBAAC,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"}
|
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@bluprynt/forms-viewer",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"repository": {
|
|
5
|
+
"type": "git",
|
|
6
|
+
"url": "https://github.com/blupryntco/forms-engine.git",
|
|
7
|
+
"directory": "packages/viewer"
|
|
8
|
+
},
|
|
9
|
+
"homepage": "https://blupryntco.github.io/forms-engine/",
|
|
10
|
+
"sideEffects": false,
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"import": "./dist/index.mjs",
|
|
15
|
+
"require": "./dist/index.cjs"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"main": "./dist/index.cjs",
|
|
19
|
+
"module": "./dist/index.mjs",
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
21
|
+
"files": [
|
|
22
|
+
"dist"
|
|
23
|
+
],
|
|
24
|
+
"peerDependencies": {
|
|
25
|
+
"react": "^18.0.0 || ^19.0.0",
|
|
26
|
+
"react-dom": "^18.0.0 || ^19.0.0",
|
|
27
|
+
"@bluprynt/forms-core": "1.0.0"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@testing-library/react": "16.3.2",
|
|
31
|
+
"@types/jest": "29.5.14",
|
|
32
|
+
"@types/react": "19.1.8",
|
|
33
|
+
"@types/react-dom": "19.1.6",
|
|
34
|
+
"jest": "29.7.0",
|
|
35
|
+
"jest-environment-jsdom": "30.3.0",
|
|
36
|
+
"react": "19.1.0",
|
|
37
|
+
"react-dom": "19.1.0",
|
|
38
|
+
"ts-jest": "29.4.6",
|
|
39
|
+
"tsdown": "0.21.1",
|
|
40
|
+
"typescript": "5.9.3",
|
|
41
|
+
"@bluprynt/forms-core": "1.0.0",
|
|
42
|
+
"@repo/typescript-config": "0.0.0"
|
|
43
|
+
},
|
|
44
|
+
"scripts": {
|
|
45
|
+
"build": "tsdown",
|
|
46
|
+
"dev": "tsdown --watch",
|
|
47
|
+
"lint": "biome check .",
|
|
48
|
+
"check-types": "tsc --noEmit",
|
|
49
|
+
"test": "jest",
|
|
50
|
+
"test:watch": "jest --watch",
|
|
51
|
+
"test:cov": "jest --coverage"
|
|
52
|
+
}
|
|
53
|
+
}
|