@axdspub/axiom-ui-forms 0.2.4 → 0.2.5
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/library/axiom-ui-forms.d.ts +12 -17
- package/library/esm/_virtual/index2.js +2 -2
- package/library/esm/_virtual/index3.js +2 -2
- package/library/esm/_virtual/index6.js +2 -2
- package/library/esm/_virtual/index8.js +2 -2
- package/library/esm/_virtual/index9.js +2 -2
- package/library/esm/node_modules/ajv/dist/compile/codegen/index.js +1 -1
- package/library/esm/node_modules/ajv/dist/compile/validate/index.js +1 -1
- package/library/esm/node_modules/ajv/dist/vocabularies/applicator/index.js +1 -1
- package/library/esm/node_modules/ajv/dist/vocabularies/core/index.js +1 -1
- package/library/esm/node_modules/ajv/dist/vocabularies/format/index.js +1 -1
- package/library/esm/src/Form/Components/FieldCreator.js +10 -9
- package/library/esm/src/Form/Components/FieldCreator.js.map +1 -1
- package/library/esm/src/Form/Components/FieldLabel.js +6 -6
- package/library/esm/src/Form/Components/FieldLabel.js.map +1 -1
- package/library/esm/src/Form/Components/Inputs/Date.js +8 -12
- package/library/esm/src/Form/Components/Inputs/Date.js.map +1 -1
- package/library/esm/src/Form/Components/Inputs/GeoJSON.js +49 -48
- package/library/esm/src/Form/Components/Inputs/GeoJSON.js.map +1 -1
- package/library/esm/src/Form/Components/Inputs/Geometry.js +81 -59
- package/library/esm/src/Form/Components/Inputs/Geometry.js.map +1 -1
- package/library/esm/src/Form/Components/Inputs/Object.js +3 -3
- package/library/esm/src/Form/Components/Inputs/Object.js.map +1 -1
- package/library/esm/src/Form/Creator/FormContextProvider.js +17 -0
- package/library/esm/src/Form/Creator/FormContextProvider.js.map +1 -0
- package/library/esm/src/Form/Creator/FormCreator.js +22 -23
- package/library/esm/src/Form/Creator/FormCreator.js.map +1 -1
- package/library/esm/src/Form/Creator/FormFields.js +2 -2
- package/library/esm/src/Form/Creator/FormFields.js.map +1 -1
- package/library/esm/src/Form/Creator/FormSection.js +4 -4
- package/library/esm/src/Form/Creator/FormSection.js.map +1 -1
- package/library/esm/src/Form/Creator/FormSectionContextProvider.js +23 -0
- package/library/esm/src/Form/Creator/FormSectionContextProvider.js.map +1 -0
- package/library/esm/src/Form/Creator/Page.js +23 -34
- package/library/esm/src/Form/Creator/Page.js.map +1 -1
- package/library/esm/src/Form/Creator/Wizard.js +38 -48
- package/library/esm/src/Form/Creator/Wizard.js.map +1 -1
- package/library/esm/src/Form/helpers.js +14 -6
- package/library/esm/src/Form/helpers.js.map +1 -1
- package/library/esm/src/Form/resolveRefs.js.map +1 -1
- package/library/esm/src/Form/schemaToFormHelpers.js +45 -25
- package/library/esm/src/Form/schemaToFormHelpers.js.map +1 -1
- package/package.json +14 -7
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Wizard.js","sources":["../../../../../src/Form/Creator/Wizard.tsx"],"sourcesContent":["import { calculateSectionStatus } from '@/Form/helpers'\nimport { type IFormSectionStatus } from '@/Form/Creator/FormCreator'\nimport { type IForm, type IFormSection, type IWizardStep } from '@/Form/Creator/FormCreatorTypes'\nimport { type IPageLayoutProps, ActivePage } from '@/Form/Creator/Page'\nimport { utils } from '@axdspub/axiom-ui-utilities'\nimport { CaretRightIcon, CaretLeftIcon } from '@radix-ui/react-icons'\nimport React, { useEffect, useState, type ReactElement } from 'react'\nimport { useParams } from 'react-router-dom'\nimport NavElement from '@/Form/Creator/NavElement'\n\nexport const WizardNav = ({\n form,\n activeIdState,\n sections,\n sectionStatus,\n level\n}: {\n form: IForm\n activeIdState: [string | null, (v: string | null) => void]\n sections?: IFormSection[]\n sectionStatus: IFormSectionStatus\n level: number\n}): ReactElement => {\n const steps = ((sections ?? []) as IWizardStep[]).sort((a, b) => a.order - b.order)\n const params = (useParams()['*'] ?? '').split('/')\n const path = params.slice(0, level).join('/')\n const [activeId, setActiveId] = activeIdState\n return (\n <div className='relative'>\n <div className='h-[2px] top-5 bg-slate-300 absolute left-0 right-0 z-0' />\n <div className='flex flex-row gap-1'>\n {\n steps.map((p, i) => {\n return (\n <div key={p.id} className='flex-grow first:flex-shrink last:flex-shrink text-center first:text-left first:ml-4 last:text-right last:mr-4 z-10 relative'>\n <NavElement\n path={path}\n id={p.id}\n navigable={form?.settings?.url_navigable ?? true}\n className={`px-8 bg-white z-20 border-none text-sm ${activeId === p.id ? 'bg-slate-600 text-white' : 'hover:bg-slate-100'}`}\n onClick={() => { setActiveId(p.id) }}\n >\n {p.label}\n </NavElement>\n {\n i < steps.length - 1 && steps.length > 1\n ? <span className='hidden absolute right-0 top-2 w-4 h-full bg-white'><CaretRightIcon className='w-4 h-6 fill-slate-300 stroke-slate-300' /></span>\n : ''\n }\n <p className='text-xs mt-4'>{sectionStatus[p.id]?.completed} of {sectionStatus[p.id]?.total} total</p>\n <p className='text-xs mt-2'>{sectionStatus[p.id]?.requiredCompleted} of {sectionStatus[p.id]?.requiredTotal} required</p>\n </div>\n )\n })\n }</div>\n </div>\n )\n}\n\nexport const WizardNavSmall = ({\n form,\n activeIdState,\n sections,\n sectionStatus,\n level\n}: {\n form: IForm\n activeIdState: [string | null, (v: string | null) => void]\n sections?: IFormSection[]\n sectionStatus: IFormSectionStatus\n level: number\n}): ReactElement => {\n const [activeId, setActiveId] = activeIdState\n const steps = ((sections ?? []) as IWizardStep[]).sort((a, b) => a.order - b.order)\n const stepsMap = Object.fromEntries(steps.map(p => [p.id, p]))\n const currentStep = stepsMap[activeId ?? ''] ?? steps[0]\n const currentIndex = steps.indexOf(currentStep)\n const nextIndex = currentIndex + 1\n const prevIndex = currentIndex - 1\n const params = (useParams()['*'] ?? '').split('/')\n const path = params.slice(0, level).join('/')\n return (\n <div className='flex flex-row gap-4 justify-end'>{\n prevIndex >= 0\n ? <NavElement\n className='px-4 bg-slate-600 text-white border-none text-sm hover:bg-slate-700'\n path={path}\n id={steps[prevIndex].id}\n navigable={form?.settings?.url_navigable ?? true}\n onClick={() => { setActiveId(steps[prevIndex].id) }}\n >\n <CaretLeftIcon className='inline' /> Previous\n </NavElement>\n : <span className={utils.createButtonClass({\n className: 'px-4 bg-white border-none text-sm text-slate-400'\n })}>Previous</span>\n }\n {\n nextIndex < steps.length\n ? <NavElement\n path={path}\n id={steps[nextIndex].id}\n navigable={form?.settings?.url_navigable ?? true}\n className='px-4 bg-slate-600 text-white border-none text-sm hover:bg-slate-700'\n onClick={() => { setActiveId(steps[nextIndex].id) }}\n >\n Next <CaretRightIcon className='inline' />\n </NavElement>\n : <span className={utils.createButtonClass({\n className: 'px-4 bg-white border-none text-sm text-slate-400'\n })}>Next</span>\n }\n </div>\n )\n}\n\nexport interface IWizardLayoutProps extends IPageLayoutProps {\n SmallNavComponent?: React.FC<{\n form: IForm\n level: number\n sections?: IFormSection[]\n activeIdState: [string | null, (v: string | null) => void]\n sectionStatus: IFormSectionStatus\n className?: string\n }>\n}\n\nconst WizardLayout = ({\n form,\n sections,\n formValueState,\n onChange,\n ContentComponent = ActivePage,\n NavComponent = WizardNav,\n SmallNavComponent = WizardNavSmall,\n className = 'flex flex-col gap-16 pt-8',\n inputOverrides,\n level\n}: IWizardLayoutProps): ReactElement => {\n if (sections === undefined) {\n return <></>\n }\n const params = useParams()['*']?.split('/') ?? []\n const activeIdState = useState<string | null>(form?.settings?.url_navigable\n ? params[level] ?? sections[0]?.id ?? null\n : sections[0]?.id ?? null\n )\n const [sectionStatus, setSectionStatus] = useState<IFormSectionStatus>(calculateSectionStatus(sections, formValueState))\n useEffect(() => {\n setSectionStatus(calculateSectionStatus(sections, formValueState))\n }, [formValueState, sections])\n\n const [formSection, setFormSection] = useState<IFormSection | undefined>(sections?.find(s => s.id === activeIdState[0]) ?? sections?.[0])\n useEffect(() => {\n setFormSection(sections?.find(s => s.id === activeIdState[0]) ?? sections?.[0])\n }, [activeIdState[0]])\n\n useEffect(() => {\n if (form?.settings?.url_navigable === true && params[level] !== activeIdState[0]) {\n activeIdState[1](params[level] ?? sections[0]?.id ?? null)\n }\n }, [useParams()['*']])\n\n return (\n <div className={className}>\n <NavComponent\n form={form}\n sections={sections}\n activeIdState={activeIdState}\n sectionStatus={sectionStatus}\n level={level}\n />\n <ContentComponent\n activeIdState={activeIdState}\n formSection={formSection}\n inputOverrides={inputOverrides}\n form={form}\n formValueState={formValueState}\n sectionStatus={sectionStatus}\n onChange={onChange}\n level={level}\n />\n <SmallNavComponent\n form={form}\n sections={sections}\n activeIdState={activeIdState}\n sectionStatus={sectionStatus}\n level={level}\n />\n </div>\n )\n}\n\nexport default WizardLayout\n"],"names":["React","utils"],"mappings":";;;;;;;;AAUO,IAAM,SAAS,GAAG,UAAC,EAYzB,EAAA;;AAXC,IAAA,IAAA,IAAI,GAAA,EAAA,CAAA,IAAA,EACJ,aAAa,GAAA,EAAA,CAAA,aAAA,EACb,QAAQ,GAAA,EAAA,CAAA,QAAA,EACR,aAAa,GAAA,EAAA,CAAA,aAAA,EACb,KAAK,GAAA,EAAA,CAAA,KAAA;AAQL,IAAA,IAAM,KAAK,GAAI,CAAC,QAAQ,KAAR,IAAA,IAAA,QAAQ,KAAR,MAAA,GAAA,QAAQ,GAAI,EAAE,EAAoB,IAAI,CAAC,UAAC,CAAC,EAAE,CAAC,EAAA,EAAK,OAAA,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAjB,EAAiB,CAAC;AACnF,IAAA,IAAM,MAAM,GAAG,CAAC,CAAA,EAAA,GAAA,SAAS,EAAE,CAAC,GAAG,CAAC,MAAA,IAAA,IAAA,EAAA,KAAA,MAAA,GAAA,EAAA,GAAI,EAAE,EAAE,KAAK,CAAC,GAAG,CAAC;AAClD,IAAA,IAAM,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;IACtC,IAAA,QAAQ,GAAiB,aAAa,CAAA,CAAA,CAA9B,EAAE,WAAW,GAAI,aAAa,CAAA,CAAA,CAAjB;AAC5B,IAAA,QACIA,cAAA,CAAA,aAAA,CAAA,KAAA,EAAA,EAA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,EAAE,KAAK,EACV,CAAA;QACNA,cAAC,CAAA,aAAA,CAAA,iBAAiB,EAChB,EAAA,IAAI,EAAE,IAAI,EACV,QAAQ,EAAE,QAAQ,EAClB,aAAa,EAAE,aAAa,EAC5B,aAAa,EAAE,aAAa,EAC5B,KAAK,EAAE,KAAK,EAAA,CACV,CACA;AAEZ;;;;"}
|
1
|
+
{"version":3,"file":"Wizard.js","sources":["../../../../../src/Form/Creator/Wizard.tsx"],"sourcesContent":["import { calculateSectionStatus } from '@/Form/helpers'\nimport { type IFormSectionStatus } from '@/Form/Creator/FormCreator'\nimport { type IFormSection, type IWizardStep } from '@/Form/Creator/FormCreatorTypes'\nimport { type IPageLayoutProps, ActivePage } from '@/Form/Creator/Page'\nimport { utils } from '@axdspub/axiom-ui-utilities'\nimport { CaretRightIcon, CaretLeftIcon } from '@radix-ui/react-icons'\nimport React, { type ReactElement } from 'react'\nimport { useParams } from 'react-router-dom'\nimport NavElement from '@/Form/Creator/NavElement'\nimport { FormSectionContextProvider, useFormSectionContext } from '@/Form/Creator/FormSectionContextProvider'\nimport { useFormContext } from '@/Form/Creator/FormContextProvider'\n\nexport const WizardNav = ({\n sections,\n sectionStatus,\n level\n}: {\n sections?: IFormSection[]\n sectionStatus: IFormSectionStatus\n level: number\n}): ReactElement => {\n const steps = ((sections ?? []) as IWizardStep[]).sort((a, b) => a.order - b.order)\n const { activeId, setActiveId, path } = useFormSectionContext()\n const { urlNavigable } = useFormContext()\n\n return (\n <div className='relative'>\n <div className='h-[2px] top-5 bg-slate-300 absolute left-0 right-0 z-0' />\n <div className='flex flex-row gap-1'>\n {\n steps.map((p, i) => {\n return (\n <div key={p.id} className='flex-grow first:flex-shrink last:flex-shrink text-center first:text-left first:ml-4 last:text-right last:mr-4 z-10 relative'>\n <NavElement\n path={path}\n id={p.id}\n navigable={urlNavigable ?? true}\n className={`px-8 bg-white z-20 border-none text-sm ${activeId === p.id ? 'bg-slate-600 text-white' : 'hover:bg-slate-100'}`}\n onClick={() => { setActiveId(p.id) }}\n >\n {p.label}\n </NavElement>\n {\n i < steps.length - 1 && steps.length > 1\n ? <span className='hidden absolute right-0 top-2 w-4 h-full bg-white'><CaretRightIcon className='w-4 h-6 fill-slate-300 stroke-slate-300' /></span>\n : ''\n }\n <p className='text-xs mt-4'>{sectionStatus[p.id]?.completed} of {sectionStatus[p.id]?.total} total</p>\n <p className='text-xs mt-2'>{sectionStatus[p.id]?.requiredCompleted} of {sectionStatus[p.id]?.requiredTotal} required</p>\n </div>\n )\n })\n }</div>\n </div>\n )\n}\n\nexport const WizardNavSmall = ({\n sections,\n sectionStatus,\n level\n}: {\n sections?: IFormSection[]\n sectionStatus: IFormSectionStatus\n level: number\n}): ReactElement => {\n const { activeId, setActiveId, path } = useFormSectionContext()\n const { urlNavigable } = useFormContext()\n const steps = ((sections ?? []) as IWizardStep[]).sort((a, b) => a.order - b.order)\n const stepsMap = Object.fromEntries(steps.map(p => [p.id, p]))\n const currentStep = stepsMap[activeId ?? ''] ?? steps[0]\n const currentIndex = steps.indexOf(currentStep)\n const nextIndex = currentIndex + 1\n const prevIndex = currentIndex - 1\n // const params = (useParams()['*'] ?? '').split('/')\n // const path = params.slice(0, level).join('/')\n return (\n <div className='flex flex-row gap-4 justify-end'>{\n prevIndex >= 0\n ? <NavElement\n className='px-4 bg-slate-600 text-white border-none text-sm hover:bg-slate-700'\n path={path}\n id={steps[prevIndex].id}\n navigable={urlNavigable ?? true}\n onClick={() => { setActiveId(steps[prevIndex].id) }}\n >\n <CaretLeftIcon className='inline' /> Previous\n </NavElement>\n : <span className={utils.createButtonClass({\n className: 'px-4 bg-white border-none text-sm text-slate-400'\n })}>Previous</span>\n }\n {\n nextIndex < steps.length\n ? <NavElement\n path={path}\n id={steps[nextIndex].id}\n navigable={urlNavigable ?? true}\n className='px-4 bg-slate-600 text-white border-none text-sm hover:bg-slate-700'\n onClick={() => { setActiveId(steps[nextIndex].id) }}\n >\n Next <CaretRightIcon className='inline' />\n </NavElement>\n : <span className={utils.createButtonClass({\n className: 'px-4 bg-white border-none text-sm text-slate-400'\n })}>Next</span>\n }\n </div>\n )\n}\n\nexport interface IWizardLayoutProps extends IPageLayoutProps {\n SmallNavComponent?: React.FC<{\n level: number\n sections?: IFormSection[]\n sectionStatus: IFormSectionStatus\n className?: string\n }>\n}\n\nconst WizardLayout = ({\n sections,\n onChange,\n ContentComponent = ActivePage,\n NavComponent = WizardNav,\n SmallNavComponent = WizardNavSmall,\n className = 'flex flex-col gap-16 pt-8',\n level\n}: IWizardLayoutProps): ReactElement => {\n if (sections === undefined) {\n return <></>\n }\n const { form, formValues, setFormValues } = useFormContext()\n const params = useParams()['*']?.split('/')?.filter(d => d !== '') ?? []\n const id = form?.settings?.url_navigable\n ? params[level] ?? sections[0]?.id ?? null\n : sections[0]?.id ?? null\n\n const formSection = sections?.find(s => s.id === id) ?? sections?.[0]\n const sectionStatus = calculateSectionStatus(sections, [formValues, setFormValues])\n\n return (\n <FormSectionContextProvider path={params.slice(0, level).join('/')} id={id}>\n <div className={className}>\n <NavComponent\n sections={sections}\n sectionStatus={sectionStatus}\n level={level}\n />\n <ContentComponent\n formSection={formSection}\n sectionStatus={sectionStatus}\n onChange={onChange}\n level={level}\n />\n <SmallNavComponent\n sections={sections}\n sectionStatus={sectionStatus}\n level={level}\n />\n </div>\n </FormSectionContextProvider>\n )\n}\n\nexport default WizardLayout\n"],"names":["React","utils"],"mappings":";;;;;;;;;;AAYO,IAAM,SAAS,GAAG,UAAC,EAQzB,EAAA;AAPC,IAAA,IAAA,QAAQ,cAAA,CACR,CAAA,aAAa,GAAA,EAAA,CAAA,aAAA,CAAA,CACR,EAAA,CAAA;AAML,IAAA,IAAM,KAAK,GAAI,CAAC,QAAQ,KAAR,IAAA,IAAA,QAAQ,KAAR,MAAA,GAAA,QAAQ,GAAI,EAAE,EAAoB,IAAI,CAAC,UAAC,CAAC,EAAE,CAAC,EAAA,EAAK,OAAA,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KA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,QAAQ,EAClB,aAAa,EAAE,aAAa,EAC5B,KAAK,EAAE,KAAK,GACV,CACA,CACuB;AAEnC;;;;"}
|
@@ -63,8 +63,13 @@ function copyAndAddPathToFields(formOrContainer) {
|
|
63
63
|
var form = addPathsToFormSections(JSON.parse(JSON.stringify(formOrContainer)));
|
64
64
|
return form;
|
65
65
|
}
|
66
|
+
function getValueFromPath(path, formValues) {
|
67
|
+
return get(formValues, path);
|
68
|
+
}
|
66
69
|
function getFieldValue(field, formValues) {
|
67
|
-
|
70
|
+
var path = makeJsonPath(field);
|
71
|
+
var val = getValueFromPath(path, formValues); // formValues[field.id]
|
72
|
+
return val;
|
68
73
|
}
|
69
74
|
function getPathFromField(field) {
|
70
75
|
// console.log(`${field.path !== undefined ? field.path.join('.') : 'nopath'} = ${field.id}`)
|
@@ -75,9 +80,13 @@ var checkCondition = function (field, formValues) {
|
|
75
80
|
if (field.conditions !== undefined) {
|
76
81
|
var dependsOn = Array.isArray(field.conditions.dependsOn) ? field.conditions.dependsOn : [field.conditions.dependsOn];
|
77
82
|
var val_1 = field.conditions.value;
|
78
|
-
|
79
|
-
|
80
|
-
|
83
|
+
var check = dependsOn.every(function (d) {
|
84
|
+
var fieldValue = getValueFromPath(d, formValues);
|
85
|
+
return val_1 !== undefined
|
86
|
+
? fieldValue === val_1
|
87
|
+
: fieldValue !== null && fieldValue !== undefined && fieldValue !== false && fieldValue !== '';
|
88
|
+
});
|
89
|
+
return check;
|
81
90
|
}
|
82
91
|
return true;
|
83
92
|
};
|
@@ -113,8 +122,7 @@ var makeJsonPath = function (field, index) {
|
|
113
122
|
}
|
114
123
|
};
|
115
124
|
var testField = function (field, formValues) {
|
116
|
-
var
|
117
|
-
var val = get(formValues, path); // formValues[field.id]
|
125
|
+
var val = getFieldValue(field, formValues);
|
118
126
|
return val !== undefined && val !== null && val !== '';
|
119
127
|
};
|
120
128
|
var calculateSectionStatus = function (sections, formValueState) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"helpers.js","sources":["../../../../src/Form/helpers.ts"],"sourcesContent":["import { type IFormSectionStatus } from '@/Form/Creator/FormCreator'\nimport { type IForm, type IFormField, type IValueType, type IFormValues, type IFormSection, type IFormValueState, type IPage, type IWizardStep } from '@/Form/Creator/FormCreatorTypes'\nimport { get } from 'lodash'\n\nexport const getChildFields = (field: { id: string, fields?: IFormField[] }): IFormField[] => {\n return field?.fields ?? []\n}\n\nexport const addFieldPath = (field: IFormField, parentPath?: IFormField[]): IFormField => {\n if (field.type === 'object' && field.skip_path === true) {\n field.path = parentPath !== undefined ? parentPath.slice() : []\n field.level = parentPath !== undefined ? parentPath.length : 0\n } else {\n const newSegment = field // `${field.id}${field.multiple === true ? '[]' : ''}`\n field.path = parentPath !== undefined ? parentPath.slice().concat(newSegment) : [newSegment]\n field.level = parentPath !== undefined ? parentPath.length + 1 : 1\n }\n if ((field.type === 'object' || field.type === 'section') && field.fields !== undefined) {\n field.fields = field.fields.map(childField => {\n return addFieldPath(childField, field.path?.slice())\n })\n }\n return field\n}\n\nexport const getUniqueFormFields = (form: IForm): IFormField[] => {\n const fieldMap = Object.fromEntries((form?.fields ?? []).map(f => [f.id, f]))\n return Object.values(fieldMap)\n}\n\nexport const getFields = (fields?: Array<{ id: string, fields?: IFormField[] }>): IFormField[] => {\n if (fields === undefined) {\n return []\n }\n const all = fields.map(field => {\n let fields = [field]\n const children = getChildFields(field)\n children.forEach(c => {\n fields = fields.concat(getFields([c]))\n })\n return fields\n }).flat(Infinity) as IFormField[]\n return all\n}\n\nfunction addPathsToFormSections (section: IFormSection): IFormSection {\n if (section.pages !== undefined) {\n section.pages = section.pages.map(page => {\n return addPathsToFormSections(page)\n }) as IPage[]\n }\n if (section.wizard_steps !== undefined) {\n section.wizard_steps = section.wizard_steps.map(wizardStep => {\n return addPathsToFormSections(wizardStep)\n }) as IWizardStep[]\n }\n if (section.fields !== undefined) {\n section.fields = section.fields.map(field => {\n return addFieldPath(field)\n })\n }\n return section\n}\n\nexport function copyAndAddPathToFields (formOrContainer: IForm): IForm {\n const form = addPathsToFormSections(JSON.parse(JSON.stringify(formOrContainer))) as IForm\n return form\n}\n\nexport function getFieldValue (field: IFormField, formValues: IFormValues): IValueType | IValueType[] | undefined {\n return formValues[getPathFromField(field)]\n}\n\nexport function getPathFromField (field: IFormField): string {\n // console.log(`${field.path !== undefined ? field.path.join('.') : 'nopath'} = ${field.id}`)\n return field.path !== undefined ? field.path.filter(f => !(f.type === 'object' && f.skip_path === true)).map(f => f.id).join('.') : field.id\n}\n\n// THIS DOESN'T HANDLE NESTED YET\nexport const checkCondition = (field: IFormField, formValues: IFormValues): boolean => {\n if (field.conditions !== undefined) {\n const dependsOn = Array.isArray(field.conditions.dependsOn) ? field.conditions.dependsOn : [field.conditions.dependsOn]\n\n const val = field.conditions.value\n return dependsOn.every(d => val !== undefined\n ? formValues[d] === val\n : formValues !== null && formValues[d] !== undefined && formValues[d] !== false\n )\n }\n return true\n}\n\nexport function getFieldsFromFormSection (formSection: IFormSection): IFormField[] {\n const pageFields = formSection?.pages?.map(p => getFieldsFromFormSection(p)).flat(1)\n const wizardFields = formSection?.wizard_steps?.map(p => getFieldsFromFormSection(p)).flat(1)\n const fields = getFields((formSection?.fields ?? [])).concat(pageFields ?? []).concat(wizardFields ?? [])\n return fields\n}\n\nexport function cleanUnusedDependenciesFromFormValues (form: IForm, formValues: IFormValues): IFormValues {\n const fields = getFieldsFromFormSection(form)\n Object.keys(formValues).forEach(key => {\n const field = fields?.find(f => f.id === key)\n if (field !== undefined && !checkCondition(field, formValues)) {\n formValues[key] = undefined\n }\n })\n\n const fieldIds = fields.map(f => f.id)\n const newFormValues = Object.fromEntries(Object.entries(formValues).filter(([key]) => fieldIds.includes(key)))\n return newFormValues\n}\n\nexport const makeJsonPath = (field: IFormField, index: number = 0): string => {\n if (field.path === undefined) {\n return field.id\n } else {\n return field.path.map(f => f.multiple ? `${f.id}[${index}]` : f.id).join('.')\n }\n}\n\nconst testField = (field: IFormField, formValues: IFormValues): boolean => {\n const path = makeJsonPath(field)\n const val = get(formValues, path) // formValues[field.id]\n return val !== undefined && val !== null && val !== ''\n}\n\nexport const calculateSectionStatus = (sections: IFormSection[], formValueState: IFormValueState): IFormSectionStatus => {\n const [formValues] = formValueState\n return Object.fromEntries(sections.map(s => {\n const fields = getFieldsFromFormSection(s).filter(f => f.type !== 'object')\n const total = fields.length\n const completed = fields.filter(f => testField(f, formValues)).length\n const required = fields.filter(f => f.required)\n const requiredTotal = required.length\n const requiredCompleted = required.filter(f => testField(f, formValues)).length\n const valid = requiredTotal === requiredCompleted\n return [s.id, { completed, total, requiredTotal, requiredCompleted, valid }]\n }))\n}\n"],"names":[],"mappings":";;AAIO,IAAM,cAAc,GAAG,UAAC,KAA4C,EAAA;;IACzE,OAAO,CAAA,EAAA,GAAA,KAAK,KAAA,IAAA,IAAL,KAAK,KAAA,MAAA,GAAA,MAAA,GAAL,KAAK,CAAE,MAAM,MAAI,IAAA,IAAA,EAAA,KAAA,MAAA,GAAA,EAAA,GAAA,EAAE;AAC5B;AAEa,IAAA,YAAY,GAAG,UAAC,KAAiB,EAAE,UAAyB,EAAA;AACvE,IAAA,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ,IAAI,KAAK,CAAC,SAAS,KAAK,IAAI,EAAE;AACvD,QAAA,KAAK,CAAC,IAAI,GAAG,UAAU,KAAK,SAAS,GAAG,UAAU,CAAC,KAAK,EAAE,GAAG,EAAE;AAC/D,QAAA,KAAK,CAAC,KAAK,GAAG,UAAU,KAAK,SAAS,GAAG,UAAU,CAAC,MAAM,GAAG,CAAC;;SACzD;AACL,QAAA,IAAM,UAAU,GAAG,KAAK,CAAA;QACxB,KAAK,CAAC,IAAI,GAAG,UAAU,KAAK,SAAS,GAAG,UAAU,CAAC,KAAK,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,UAAU,CAAC;AAC5F,QAAA,KAAK,CAAC,KAAK,GAAG,UAAU,KAAK,SAAS,GAAG,UAAU,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AwB,EAAE,cAA+B,EAAA;AACvF,IAAA,IAAA,UAAU,GAAI,cAAc,CAAA,CAAA,CAAlB;IACjB,OAAO,MAAM,CAAC,WAAW,CAAC,QAAQ,CAAC,GAAG,CAAC,UAAA,CAAC,EAAA;QACtC,IAAM,MAAM,GAAG,wBAAwB,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,UAAA,CAAC,EAAI,EAAA,OAAA,CAAC,CAAC,IAAI,KAAK,QAAQ,CAAA,EAAA,CAAC;AAC3E,QAAA,IAAM,KAAK,GAAG,MAAM,CAAC,MAAM;QAC3B,IAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,UAAA,CAAC,EAAI,EAAA,OAAA,SAAS,CAAC,CAAC,EAAE,UAAU,CAAC,GAAA,CAAC,CAAC,MAAM;AACrE,QAAA,IAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,UAAA,CAAC,EAAI,EAAA,OAAA,CAAC,CAAC,QAAQ,CAAV,EAAU,CAAC;AAC/C,QAAA,IAAM,aAAa,GAAG,QAAQ,CAAC,MAAM;QACrC,IAAM,iBAAiB,GAAG,QAAQ,CAAC,MAAM,CAAC,UAAA,CAAC,EAAI,EAAA,OAAA,SAAS,CAAC,CAAC,EAAE,UAAU,CAAC,GAAA,CAAC,CAAC,MAAM;AAC/E,QAAA,IAAM,KAAK,GAAG,aAAa,KAAK,iBAAiB;QACjD,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,SAAS,EAAA,SAAA,EAAE,KAAK,EAAA,KAAA,EAAE,aAAa,EAAA,aAAA,EAAE,iBAAiB,EAAA,iBAAA,EAAE,KAAK,EAAA,KAAA,EAAE,CAAC;KAC7E,CAAC,CAAC;AACL;;;;"}
|
1
|
+
{"version":3,"file":"helpers.js","sources":["../../../../src/Form/helpers.ts"],"sourcesContent":["import { type IFormSectionStatus } from '@/Form/Creator/FormCreator'\nimport { type IForm, type IFormField, type IValueType, type IFormValues, type IFormSection, type IFormValueState, type IPage, type IWizardStep } from '@/Form/Creator/FormCreatorTypes'\nimport { get } from 'lodash'\n\nexport const getChildFields = (field: { id: string, fields?: IFormField[] }): IFormField[] => {\n return field?.fields ?? []\n}\n\nexport const addFieldPath = (field: IFormField, parentPath?: IFormField[]): IFormField => {\n if (field.type === 'object' && field.skip_path === true) {\n field.path = parentPath !== undefined ? parentPath.slice() : []\n field.level = parentPath !== undefined ? parentPath.length : 0\n } else {\n const newSegment = field // `${field.id}${field.multiple === true ? '[]' : ''}`\n field.path = parentPath !== undefined ? parentPath.slice().concat(newSegment) : [newSegment]\n field.level = parentPath !== undefined ? parentPath.length + 1 : 1\n }\n if ((field.type === 'object' || field.type === 'section') && field.fields !== undefined) {\n field.fields = field.fields.map(childField => {\n return addFieldPath(childField, field.path?.slice())\n })\n }\n return field\n}\n\nexport const getUniqueFormFields = (form: IForm): IFormField[] => {\n const fieldMap = Object.fromEntries((form?.fields ?? []).map(f => [f.id, f]))\n return Object.values(fieldMap)\n}\n\nexport const getFields = (fields?: Array<{ id: string, fields?: IFormField[] }>): IFormField[] => {\n if (fields === undefined) {\n return []\n }\n const all = fields.map(field => {\n let fields = [field]\n const children = getChildFields(field)\n children.forEach(c => {\n fields = fields.concat(getFields([c]))\n })\n return fields\n }).flat(Infinity) as IFormField[]\n return all\n}\n\nfunction addPathsToFormSections (section: IFormSection): IFormSection {\n if (section.pages !== undefined) {\n section.pages = section.pages.map(page => {\n return addPathsToFormSections(page)\n }) as IPage[]\n }\n if (section.wizard_steps !== undefined) {\n section.wizard_steps = section.wizard_steps.map(wizardStep => {\n return addPathsToFormSections(wizardStep)\n }) as IWizardStep[]\n }\n if (section.fields !== undefined) {\n section.fields = section.fields.map(field => {\n return addFieldPath(field)\n })\n }\n return section\n}\n\nexport function copyAndAddPathToFields (formOrContainer: IForm): IForm {\n const form = addPathsToFormSections(JSON.parse(JSON.stringify(formOrContainer))) as IForm\n return form\n}\n\nfunction getValueFromPath (path: string, formValues: IFormValues): IValueType | IValueType[] | undefined {\n return get(formValues, path)\n}\n\nexport function getFieldValue (field: IFormField, formValues: IFormValues): IValueType | IValueType[] | undefined {\n const path = makeJsonPath(field)\n const val = getValueFromPath(path, formValues) // formValues[field.id]\n return val\n}\n\nexport function getPathFromField (field: IFormField): string {\n // console.log(`${field.path !== undefined ? field.path.join('.') : 'nopath'} = ${field.id}`)\n return field.path !== undefined ? field.path.filter(f => !(f.type === 'object' && f.skip_path === true)).map(f => f.id).join('.') : field.id\n}\n\n// THIS DOESN'T HANDLE NESTED YET\nexport const checkCondition = (field: IFormField, formValues: IFormValues): boolean => {\n if (field.conditions !== undefined) {\n const dependsOn = Array.isArray(field.conditions.dependsOn) ? field.conditions.dependsOn : [field.conditions.dependsOn]\n\n const val = field.conditions.value\n const check = dependsOn.every(d => {\n const fieldValue = getValueFromPath(d, formValues)\n return val !== undefined\n ? fieldValue === val\n : fieldValue !== null && fieldValue !== undefined && fieldValue !== false && fieldValue !== ''\n })\n return check\n }\n return true\n}\n\nexport function getFieldsFromFormSection (formSection: IFormSection): IFormField[] {\n const pageFields = formSection?.pages?.map(p => getFieldsFromFormSection(p)).flat(1)\n const wizardFields = formSection?.wizard_steps?.map(p => getFieldsFromFormSection(p)).flat(1)\n const fields = getFields((formSection?.fields ?? [])).concat(pageFields ?? []).concat(wizardFields ?? [])\n return fields\n}\n\nexport function cleanUnusedDependenciesFromFormValues (form: IForm, formValues: IFormValues): IFormValues {\n const fields = getFieldsFromFormSection(form)\n Object.keys(formValues).forEach(key => {\n const field = fields?.find(f => f.id === key)\n if (field !== undefined && !checkCondition(field, formValues)) {\n formValues[key] = undefined\n }\n })\n\n const fieldIds = fields.map(f => f.id)\n const newFormValues = Object.fromEntries(Object.entries(formValues).filter(([key]) => fieldIds.includes(key)))\n return newFormValues\n}\n\nexport const makeJsonPath = (field: IFormField, index: number = 0): string => {\n if (field.path === undefined) {\n return field.id\n } else {\n return field.path.map(f => f.multiple ? `${f.id}[${index}]` : f.id).join('.')\n }\n}\n\nconst testField = (field: IFormField, formValues: IFormValues): boolean => {\n const val = getFieldValue(field, formValues)\n return val !== undefined && val !== null && val !== ''\n}\n\nexport const calculateSectionStatus = (sections: IFormSection[], formValueState: IFormValueState): IFormSectionStatus => {\n const [formValues] = formValueState\n return Object.fromEntries(sections.map(s => {\n const fields = getFieldsFromFormSection(s).filter(f => f.type !== 'object')\n const total = fields.length\n const completed = fields.filter(f => testField(f, formValues)).length\n const required = fields.filter(f => f.required)\n const requiredTotal = required.length\n const requiredCompleted = required.filter(f => testField(f, formValues)).length\n const valid = requiredTotal === requiredCompleted\n return [s.id, { completed, total, requiredTotal, requiredCompleted, valid }]\n }))\n}\n"],"names":[],"mappings":";;AAIO,IAAM,cAAc,GAAG,UAAC,KAA4C,EAAA;;IACzE,OAAO,CAAA,EAAA,GAAA,KAAK,KAAA,IAAA,IAAL,KAAK,KAAA,MAAA,GAAA,MAAA,GAAL,KAAK,CAAE,MAAM,MAAI,IAAA,IAAA,EAAA,KAAA,MAAA,GAAA,EAAA,GAAA,EAAE;AAC5B;AAEa,IAAA,YAAY,GAAG,UAAC,KAAiB,EAAE,UAAyB,EAAA;AACvE,IAAA,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ,IAAI,KAAK,CAAC,SAAS,KAAK,IAAI,EAAE;AACvD,QAAA,KAAK,CAAC,IAAI,GAAG,UAAU,KAAK,SAAS,GAAG,UAAU,CAAC,KAAK,EAAE,GAAG,EAAE;AAC/D,QAAA,KAAK,CAAC,KAAK,GAAG,UAAU,KAAK,SAAS,GAAG,UAAU,CAAC,MAAM,GAAG,CAAC;;SACzD;AACL,QAAA,IAAM,UAAU,GAAG,KAAK,CAAA;QACxB,KAAK,CAAC,IAAI,GAAG,UAAU,KAAK,SAAS,GAAG,UAAU,CAAC,KAAK,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,UAAU,CAAC;AAC5F,QAAA,KAAK,CAAC,KAAK,GAAG,UAAU,KAAK,SAAS,GAAG,UAAU,CAAC,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KAAA,EAAE,CAAC;KAC7E,CAAC,CAAC;AACL;;;;"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"resolveRefs.js","sources":["../../../../src/Form/resolveRefs.ts"],"sourcesContent":["import { type
|
1
|
+
{"version":3,"file":"resolveRefs.js","sources":["../../../../src/Form/resolveRefs.ts"],"sourcesContent":["import { type JSONSchema6 } from 'json-schema'\n\nexport function resolveRefs<T extends JSONSchema6> (schema: T, root: JSONSchema6 = schema): T {\n if (typeof schema !== 'object' || schema === null) return schema\n\n if (schema.$ref) {\n const refPath = schema.$ref.replace('#/', '').split('/')\n let refValue: any = root\n\n for (const key of refPath) {\n refValue = refValue[key]\n if (!refValue) throw new Error(`Invalid reference: ${schema.$ref}`)\n }\n return resolveRefs(refValue, root) as T // Recursively resolve\n }\n\n if (Array.isArray(schema)) {\n return schema.map((item) => resolveRefs(item, root)) as unknown as T\n }\n\n return Object.fromEntries(\n Object.entries(schema).map(([key, value]) => [key, resolveRefs(value, root)])\n ) as T\n}\n"],"names":[],"mappings":"AAEgB,SAAA,WAAW,CAAyB,MAAS,EAAE,IAA0B,EAAA;AAA1B,IAAA,IAAA,IAAA,KAAA,MAAA,EAAA,EAAA,IAA0B,GAAA,MAAA,CAAA;AACvF,IAAA,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,IAAI;AAAE,QAAA,OAAO,MAAM;AAEhE,IAAA,IAAI,MAAM,CAAC,IAAI,EAAE;AACf,QAAA,IAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC;QACxD,IAAI,QAAQ,GAAQ,IAAI;QAExB,KAAkB,IAAA,EAAA,GAAA,CAAO,EAAP,SAAO,GAAA,OAAA,EAAP,qBAAO,EAAP,EAAA,EAAO,EAAE;AAAtB,YAAA,IAAM,GAAG,GAAA,SAAA,CAAA,EAAA,CAAA;AACZ,YAAA,QAAQ,GAAG,QAAQ,CAAC,GAAG,CAAC;AACxB,YAAA,IAAI,CAAC,QAAQ;gBAAE,MAAM,IAAI,KAAK,CAAC,qBAAA,CAAA,MAAA,CAAsB,MAAM,CAAC,IAAI,CAAE,CAAC;;QAErE,OAAO,WAAW,CAAC,QAAQ,EAAE,IAAI,CAAM,CAAA;;AAGzC,IAAA,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;AACzB,QAAA,OAAO,MAAM,CAAC,GAAG,CAAC,UAAC,IAAI,EAAK,EAAA,OAAA,WAAW,CAAC,IAAI,EAAE,IAAI,CAAC,CAAvB,EAAuB,CAAiB;;AAGtE,IAAA,OAAO,MAAM,CAAC,WAAW,CACvB,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,UAAC,EAAY,EAAA;YAAX,GAAG,GAAA,EAAA,CAAA,CAAA,CAAA,EAAE,KAAK,GAAA,EAAA,CAAA,CAAA,CAAA;QAAM,OAAA,CAAC,GAAG,EAAE,WAAW,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;KAAA,CAAC,CACzE;AACR;;;;"}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import {
|
1
|
+
import { __assign } from '../../node_modules/tslib/tslib.es6.js';
|
2
2
|
import Ajv from '../../_virtual/ajv.js';
|
3
3
|
import metaSchemaDraftV7 from '../../node_modules/ajv/lib/refs/json-schema-draft-07.json.js';
|
4
4
|
import metaSchemaDraftV6 from '../../node_modules/ajv/lib/refs/json-schema-draft-06.json.js';
|
@@ -22,27 +22,26 @@ var getValidator = function (schema) {
|
|
22
22
|
return ajv.compile(metaSchemaV5);
|
23
23
|
}
|
24
24
|
};
|
25
|
-
var validateSchema = function (
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
}
|
40
|
-
resolved = resolveRefs(schemaOb);
|
41
|
-
return [2 /*return*/, { schema: resolved }];
|
42
|
-
});
|
43
|
-
});
|
25
|
+
var validateSchema = function (schemaOb, version) {
|
26
|
+
if (version === void 0) { version = 6; }
|
27
|
+
var ajv = new Ajv({ strict: false });
|
28
|
+
var validator = getValidator(version);
|
29
|
+
var valid = validator(schemaOb);
|
30
|
+
if (!valid) {
|
31
|
+
return { error: ajv.errorsText(validator.errors) };
|
32
|
+
}
|
33
|
+
// const v = ajv.compile<JSONSchema6>(schemaOb as JSONSchema6)
|
34
|
+
/* registerSchema(schemaOb as SchemaObject, 'https://axds.co/test')
|
35
|
+
const bundledSchema = await bundle('https://axds.co/test')
|
36
|
+
return { schema: bundledSchema as JSONSchema6 } */
|
37
|
+
var resolved = resolveRefs(structuredClone(schemaOb));
|
38
|
+
return { schema: resolved, unrefed: schemaOb };
|
44
39
|
};
|
45
40
|
var validateAgainstSchema = function (schema, formValues) {
|
41
|
+
var validSchema = validateSchema(schema);
|
42
|
+
if (validSchema.error !== undefined) {
|
43
|
+
return [validSchema.error];
|
44
|
+
}
|
46
45
|
var ajv = new Ajv({ strict: false, allErrors: true });
|
47
46
|
var validator = ajv.compile(schema);
|
48
47
|
var valid = validator(formValues);
|
@@ -53,10 +52,13 @@ var validateAgainstSchema = function (schema, formValues) {
|
|
53
52
|
}
|
54
53
|
return undefined;
|
55
54
|
};
|
55
|
+
var makeRandom = function () {
|
56
|
+
return crypto !== undefined ? crypto.randomUUID() : Math.random().toString(36).substring(2);
|
57
|
+
};
|
56
58
|
var makeFormFieldId = function (options) {
|
57
59
|
var validOptions = options.filter(function (o) { return o !== undefined && o !== null; });
|
58
60
|
if (validOptions.length === 0) {
|
59
|
-
return
|
61
|
+
return makeRandom();
|
60
62
|
}
|
61
63
|
return String(validOptions[0]);
|
62
64
|
};
|
@@ -104,6 +106,9 @@ var getFieldType = function (schema) {
|
|
104
106
|
else if (schemaType === 'object') {
|
105
107
|
return 'object';
|
106
108
|
}
|
109
|
+
if (!schemaType && (schema.anyOf !== undefined || schema.enum !== undefined)) {
|
110
|
+
return 'object';
|
111
|
+
}
|
107
112
|
return 'text';
|
108
113
|
};
|
109
114
|
var getValueFromSchema = function (schema) {
|
@@ -146,7 +151,7 @@ var getLabelFromSchema = function (schema) {
|
|
146
151
|
return String(getValueFromSchema(schema));
|
147
152
|
};
|
148
153
|
var schemaToFormField = function (schema, property, schemaField, multiple) {
|
149
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
154
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
150
155
|
if (schemaField === undefined) {
|
151
156
|
return {
|
152
157
|
id: makeFormFieldId([schema.$id, property]),
|
@@ -206,14 +211,29 @@ var schemaToFormField = function (schema, property, schemaField, multiple) {
|
|
206
211
|
return __assign(__assign({}, ob), { type: type, options: options });
|
207
212
|
}
|
208
213
|
if (type === 'object') {
|
214
|
+
// const anyOfAsProps = schemaField.anyOf !== undefined && schemaField.anyOf.filter(d => typeof d !== 'boolean' && d.type !== 'null').length > 0
|
209
215
|
var properties = (_g = schemaField.properties) !== null && _g !== void 0 ? _g : {};
|
210
|
-
var
|
216
|
+
var fields_1 = [];
|
211
217
|
for (var key in properties) {
|
212
218
|
if (properties[key] !== undefined && typeof properties[key] !== 'boolean') {
|
213
|
-
|
219
|
+
fields_1.push(schemaToFormField(schemaField, key, properties[key]));
|
214
220
|
}
|
215
221
|
}
|
216
|
-
|
222
|
+
var ofArr = ((_h = schemaField.anyOf) !== null && _h !== void 0 ? _h : []).concat((_j = schemaField.allOf) !== null && _j !== void 0 ? _j : []);
|
223
|
+
ofArr.forEach(function (anyOf) {
|
224
|
+
var _a;
|
225
|
+
var anyOfId = schemaField.$id;
|
226
|
+
if (typeof anyOf !== 'boolean' && anyOf.type !== 'null') {
|
227
|
+
var field = schemaToFormField(schemaField, anyOfId !== null && anyOfId !== void 0 ? anyOfId : makeRandom(), typeof anyOf === 'boolean'
|
228
|
+
? anyOf
|
229
|
+
: __assign({ title: (_a = anyOf.title) !== null && _a !== void 0 ? _a : '' }, anyOf), true);
|
230
|
+
if (anyOfId === undefined && field.type === 'object') {
|
231
|
+
field.skip_path = true;
|
232
|
+
}
|
233
|
+
fields_1.push(field);
|
234
|
+
}
|
235
|
+
});
|
236
|
+
return __assign(__assign({}, ob), { type: type, fields: fields_1, multiple: multiple });
|
217
237
|
}
|
218
238
|
return {
|
219
239
|
id: id,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"schemaToFormHelpers.js","sources":["../../../../src/Form/schemaToFormHelpers.ts"],"sourcesContent":["import { type IForm, type IFormField, type IFormFieldType, type IFormValues } from '@/Form/Creator/FormCreatorTypes'\nimport Ajv, { type ValidateFunction } from 'ajv'\n\nimport { type JSONSchema7, type JSONSchema7Type, type JSONSchema7Definition } from 'json-schema'\n\nimport metaSchemaDraftV7 from 'ajv/lib/refs/json-schema-draft-07.json'\nimport metaSchemaDraftV6 from 'ajv/lib/refs/json-schema-draft-06.json'\nimport metaSchemaV5 from 'ajv/lib/refs/json-schema-2020-12/schema.json'\nimport metaSchemaV4 from 'ajv/lib/refs/json-schema-2019-09/schema.json'\n\nimport { resolveRefs } from '@/Form/resolveRefs'\nimport { omit } from 'lodash'\n\nconst getValidator = (schema: number): ValidateFunction => {\n const ajv = new Ajv({ strict: false })\n switch (schema) {\n case 4:\n return ajv.compile(metaSchemaV4)\n case 5:\n return ajv.compile(metaSchemaV5)\n case 6:\n return ajv.compile(metaSchemaDraftV6)\n case 7:\n return ajv.compile(metaSchemaDraftV7)\n default:\n return ajv.compile(metaSchemaV5)\n }\n}\n\nexport const validateSchema = async (schemaOb: unknown, version: number = 6): Promise<{ schema?: JSONSchema7, error?: string }> => {\n const ajv = new Ajv({ strict: false })\n const validator = getValidator(version)\n const valid = validator(schemaOb)\n if (!valid) {\n return { error: ajv.errorsText(validator.errors) }\n }\n // const v = ajv.compile<JSONSchema7>(schemaOb as JSONSchema7)\n /* registerSchema(schemaOb as SchemaObject, 'https://axds.co/test')\n const bundledSchema = await bundle('https://axds.co/test')\n return { schema: bundledSchema as JSONSchema7 } */\n\n const resolved = resolveRefs(schemaOb as JSONSchema7)\n return { schema: resolved }\n}\n\nexport const validateAgainstSchema = (schema: JSONSchema7, formValues: IFormValues): string[] | undefined => {\n const ajv = new Ajv({ strict: false, allErrors: true })\n const validator = ajv.compile(schema)\n const valid = validator(formValues)\n if (validator.errors !== null && validator.errors !== undefined && !valid) {\n return validator.errors.map(e => {\n return `${e.instancePath} ${e.message}`\n })\n }\n return undefined\n}\n\nconst makeFormFieldId = (options: Array<string | number | undefined | null>): string => {\n const validOptions = options.filter((o) => o !== undefined && o !== null)\n if (validOptions.length === 0) {\n return crypto !== undefined ? crypto.randomUUID() : Math.random().toString(36).substring(2)\n }\n return String(validOptions[0])\n}\n\nconst makeLabel = (options: Array<string | number | undefined | null>): string | undefined => {\n const validOptions = options.filter((o) => o !== undefined && o !== null)\n if (validOptions.length === 0) {\n return undefined\n }\n return String(validOptions[0])\n .replace(/_/g, ' ')\n .split(' ')\n .map((s, i) => {\n return i === 0 ? `${s.charAt(0).toUpperCase()}${s.slice(1)}` : s\n }).join(' ')\n}\n\nconst getFieldType = (schema: JSONSchema7): IFormFieldType => {\n const schemaType = schema.type\n if (schemaType === 'string' || schemaType === 'number' || schemaType === 'integer') {\n if (schema.enum !== undefined || schema.oneOf !== undefined) {\n return 'select'\n } else if (schema.anyOf !== undefined) {\n return 'checkbox'\n } else if (schemaType === 'string' && (schema.maxLength !== undefined && schema.maxLength <= 100)) {\n return 'text'\n } else if (schemaType === 'number' || schemaType === 'integer') {\n return 'number'\n } else if (schema.format === 'date-time') {\n return 'datetime'\n } else if (schema.format === 'date') {\n return 'date'\n } else if (schema.format === 'time') {\n return 'time'\n }\n return 'long_text'\n } else if (schemaType === 'boolean') {\n return 'boolean'\n } else if (schemaType === 'object') {\n return 'object'\n }\n\n return 'text'\n}\n\nexport const getValueFromSchema = (schema: JSONSchema7Type | JSONSchema7Definition | undefined): string | number | boolean | undefined => {\n if (schema === undefined || schema === null) {\n return undefined\n }\n if (typeof schema === 'string' || typeof schema === 'number' || typeof schema === 'boolean') {\n return schema\n }\n if (Array.isArray(schema)) {\n if (schema.length > 0) {\n return getValueFromSchema(schema[0])\n }\n return undefined\n }\n if (schema.const !== undefined) {\n return String(schema.const)\n }\n return undefined\n}\n\nexport const getLabelFromSchema = (schema: JSONSchema7Type | JSONSchema7Definition | undefined): string | undefined => {\n if (schema === undefined || schema === null) {\n return undefined\n }\n if (typeof schema === 'boolean') {\n return schema ? 'true' : 'false'\n }\n if (typeof schema === 'string' || typeof schema === 'number' || typeof schema === 'boolean') {\n return String(schema)\n }\n if (Array.isArray(schema)) {\n if (schema.length > 0) {\n return getLabelFromSchema(schema[0])\n }\n return undefined\n }\n if (schema.title !== undefined && schema.title !== null) {\n return getLabelFromSchema(schema.title)\n }\n return String(getValueFromSchema(schema))\n}\n\nconst schemaToFormField = (schema: JSONSchema7, property: string, schemaField: JSONSchema7, multiple?: boolean): IFormField => {\n if (schemaField === undefined) {\n return {\n id: makeFormFieldId([schema.$id, property]),\n label: property,\n type: 'text',\n multiple\n }\n }\n if (typeof schemaField === 'boolean') {\n return {\n id: makeFormFieldId([schema.$id, property]),\n label: property,\n type: 'boolean',\n multiple\n }\n }\n if (schemaField.type === 'array' && schemaField.items !== undefined) {\n return schemaToFormField(schemaField, property, schemaField.items as JSONSchema7, true)\n }\n if (schemaField.anyOf !== undefined && schemaField.anyOf.length === 2 && schemaField.anyOf.filter(d => typeof d !== 'boolean' && d.type === 'null').length === 1) {\n const notNull = schemaField.anyOf.filter(d => typeof d !== 'boolean' && d.type !== 'null')[0]\n return schemaToFormField(schemaField, property, { ...omit(schemaField, 'anyOf'), ...(typeof notNull !== 'boolean' ? notNull : {}) }, multiple)\n }\n const type = getFieldType(schemaField)\n const id = makeFormFieldId([\n schemaField.$id,\n property,\n schemaField.title?.toLowerCase().replace(' ', '-')\n ])\n const label = makeLabel([\n schemaField.title,\n property\n ])\n const schemaRequired = schema.required ?? []\n const ob: Pick<IFormField, 'id' | 'label' | 'description' | 'multiple' | 'required'> = {\n id,\n label,\n description: schemaField.description,\n multiple,\n required: schemaRequired.includes(property) ?? false\n }\n if (type === 'text' || type === 'number' || type === 'long_text' || type === 'boolean' || type === 'datetime' || type === 'date' || type === 'time') {\n return {\n ...ob,\n type\n }\n }\n\n if (type === 'select' || type === 'checkbox') {\n const schemaOptions = schemaField.enum ?? schemaField.oneOf ?? schemaField.anyOf ?? []\n const options = schemaOptions.map(e => {\n const value = getValueFromSchema(e)\n const label = getLabelFromSchema(e)\n return value !== undefined\n ? {\n value: String(value),\n label: label ?? String(value)\n }\n : null\n }).filter(d => d !== null)\n return {\n ...ob,\n type,\n options\n }\n }\n if (type === 'object') {\n const properties = schemaField.properties ?? {}\n const fields: IFormField[] = []\n for (const key in properties) {\n if (properties[key] !== undefined && typeof properties[key] !== 'boolean') {\n fields.push(schemaToFormField(schemaField, key, properties[key]))\n }\n }\n return {\n ...ob,\n type,\n fields,\n multiple\n }\n }\n\n return {\n id,\n type: 'text',\n multiple\n }\n}\n\nexport const schemaToFormObject = (schema: JSONSchema7): IForm => {\n const formFields: IFormField[] = []\n for (const key in schema.properties) {\n if (schema.properties[key] !== undefined && typeof schema.properties[key] !== 'boolean') {\n formFields.push(schemaToFormField(schema, key, schema.properties[key]))\n }\n }\n return {\n id: makeFormFieldId([schema.$id, schema.title?.toLowerCase().replace(' ', '-')]),\n label: schema.title ?? 'Untitled',\n fields: formFields\n }\n}\n"],"names":[],"mappings":";;;;;;;;;AAaA,IAAM,YAAY,GAAG,UAAC,MAAc,EAAA;IAClC,IAAM,GAAG,GAAG,IAAI,GAAG,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;IACtC,QAAQ,MAAM;AACZ,QAAA,KAAK,CAAC;AACJ,YAAA,OAAO,GAAG,CAAC,OAAO,CAAC,YAAY,CAAC;AAClC,QAAA,KAAK,CAAC;AACJ,YAAA,OAAO,GAAG,CAAC,OAA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AM,CAAC,GAAG,EAAE,CAAA,EAAA,GAAA,MAAM,CAAC,KAAK,MAAE,IAAA,IAAA,EAAA,KAAA,MAAA,GAAA,MAAA,GAAA,EAAA,CAAA,WAAW,GAAG,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;AAChF,QAAA,KAAK,EAAE,CAAA,EAAA,GAAA,MAAM,CAAC,KAAK,mCAAI,UAAU;AACjC,QAAA,MAAM,EAAE;KACT;AACH;;;;"}
|
1
|
+
{"version":3,"file":"schemaToFormHelpers.js","sources":["../../../../src/Form/schemaToFormHelpers.ts"],"sourcesContent":["import { type IForm, type IFormField, type IFormFieldType, type IFormValues } from '@/Form/Creator/FormCreatorTypes'\nimport Ajv, { type ValidateFunction } from 'ajv'\n\nimport { type JSONSchema6Type, type JSONSchema6Definition, type JSONSchema6 } from 'json-schema'\n\nimport metaSchemaDraftV7 from 'ajv/lib/refs/json-schema-draft-07.json'\nimport metaSchemaDraftV6 from 'ajv/lib/refs/json-schema-draft-06.json'\nimport metaSchemaV5 from 'ajv/lib/refs/json-schema-2020-12/schema.json'\nimport metaSchemaV4 from 'ajv/lib/refs/json-schema-2019-09/schema.json'\n\nimport { resolveRefs } from '@/Form/resolveRefs'\nimport { omit } from 'lodash'\n\nconst getValidator = (schema: number): ValidateFunction => {\n const ajv = new Ajv({ strict: false })\n switch (schema) {\n case 4:\n return ajv.compile(metaSchemaV4)\n case 5:\n return ajv.compile(metaSchemaV5)\n case 6:\n return ajv.compile(metaSchemaDraftV6)\n case 7:\n return ajv.compile(metaSchemaDraftV7)\n default:\n return ajv.compile(metaSchemaV5)\n }\n}\n\nexport const validateSchema = (schemaOb: unknown, version: number = 6): { schema?: JSONSchema6, error?: string, unrefed?: JSONSchema6 } => {\n const ajv = new Ajv({ strict: false })\n const validator = getValidator(version)\n const valid = validator(schemaOb)\n if (!valid) {\n return { error: ajv.errorsText(validator.errors) }\n }\n // const v = ajv.compile<JSONSchema6>(schemaOb as JSONSchema6)\n /* registerSchema(schemaOb as SchemaObject, 'https://axds.co/test')\n const bundledSchema = await bundle('https://axds.co/test')\n return { schema: bundledSchema as JSONSchema6 } */\n\n const resolved = resolveRefs(structuredClone(schemaOb) as JSONSchema6)\n return { schema: resolved, unrefed: schemaOb as JSONSchema6 }\n}\n\nexport const validateAgainstSchema = (schema: JSONSchema6, formValues: IFormValues): string[] | undefined => {\n const validSchema = validateSchema(schema)\n if (validSchema.error !== undefined) {\n return [validSchema.error]\n }\n const ajv = new Ajv({ strict: false, allErrors: true })\n const validator = ajv.compile(schema)\n const valid = validator(formValues)\n if (validator.errors !== null && validator.errors !== undefined && !valid) {\n return validator.errors.map(e => {\n return `${e.instancePath} ${e.message}`\n })\n }\n return undefined\n}\n\nconst makeRandom = (): string => {\n return crypto !== undefined ? crypto.randomUUID() : Math.random().toString(36).substring(2)\n}\n\nconst makeFormFieldId = (options: Array<string | number | undefined | null>): string => {\n const validOptions = options.filter((o) => o !== undefined && o !== null)\n if (validOptions.length === 0) {\n return makeRandom()\n }\n return String(validOptions[0])\n}\n\nconst makeLabel = (options: Array<string | number | undefined | null>): string | undefined => {\n const validOptions = options.filter((o) => o !== undefined && o !== null)\n if (validOptions.length === 0) {\n return undefined\n }\n return String(validOptions[0])\n .replace(/_/g, ' ')\n .split(' ')\n .map((s, i) => {\n return i === 0 ? `${s.charAt(0).toUpperCase()}${s.slice(1)}` : s\n }).join(' ')\n}\n\nconst getFieldType = (schema: JSONSchema6): IFormFieldType => {\n const schemaType = schema.type\n if (schemaType === 'string' || schemaType === 'number' || schemaType === 'integer') {\n if (schema.enum !== undefined || schema.oneOf !== undefined) {\n return 'select'\n } else if (schema.anyOf !== undefined) {\n return 'checkbox'\n } else if (schemaType === 'string' && (schema.maxLength !== undefined && schema.maxLength <= 100)) {\n return 'text'\n } else if (schemaType === 'number' || schemaType === 'integer') {\n return 'number'\n } else if (schema.format === 'date-time') {\n return 'datetime'\n } else if (schema.format === 'date') {\n return 'date'\n } else if (schema.format === 'time') {\n return 'time'\n }\n return 'long_text'\n } else if (schemaType === 'boolean') {\n return 'boolean'\n } else if (schemaType === 'object') {\n return 'object'\n }\n if (!schemaType && (schema.anyOf !== undefined || schema.enum !== undefined)) {\n return 'object'\n }\n\n return 'text'\n}\n\nexport const getValueFromSchema = (schema: JSONSchema6Type | JSONSchema6Definition | undefined): string | number | boolean | undefined => {\n if (schema === undefined || schema === null) {\n return undefined\n }\n if (typeof schema === 'string' || typeof schema === 'number' || typeof schema === 'boolean') {\n return schema\n }\n if (Array.isArray(schema)) {\n if (schema.length > 0) {\n return getValueFromSchema(schema[0])\n }\n return undefined\n }\n if (schema.const !== undefined) {\n return String(schema.const)\n }\n return undefined\n}\n\nexport const getLabelFromSchema = (schema: JSONSchema6Type | JSONSchema6Definition | undefined): string | undefined => {\n if (schema === undefined || schema === null) {\n return undefined\n }\n if (typeof schema === 'boolean') {\n return schema ? 'true' : 'false'\n }\n if (typeof schema === 'string' || typeof schema === 'number' || typeof schema === 'boolean') {\n return String(schema)\n }\n if (Array.isArray(schema)) {\n if (schema.length > 0) {\n return getLabelFromSchema(schema[0])\n }\n return undefined\n }\n if (schema.title !== undefined && schema.title !== null) {\n return getLabelFromSchema(schema.title)\n }\n return String(getValueFromSchema(schema))\n}\n\nconst schemaToFormField = (schema: JSONSchema6, property: string, schemaField: JSONSchema6, multiple?: boolean): IFormField => {\n if (schemaField === undefined) {\n return {\n id: makeFormFieldId([schema.$id, property]),\n label: property,\n type: 'text',\n multiple\n }\n }\n if (typeof schemaField === 'boolean') {\n return {\n id: makeFormFieldId([schema.$id, property]),\n label: property,\n type: 'boolean',\n multiple\n }\n }\n if (schemaField.type === 'array' && schemaField.items !== undefined) {\n return schemaToFormField(schemaField, property, schemaField.items as JSONSchema6, true)\n }\n if (schemaField.anyOf !== undefined && schemaField.anyOf.length === 2 && schemaField.anyOf.filter(d => typeof d !== 'boolean' && d.type === 'null').length === 1) {\n const notNull = schemaField.anyOf.filter(d => typeof d !== 'boolean' && d.type !== 'null')[0]\n return schemaToFormField(schemaField, property, { ...omit(schemaField, 'anyOf'), ...(typeof notNull !== 'boolean' ? notNull : {}) }, multiple)\n }\n const type = getFieldType(schemaField)\n const id = makeFormFieldId([\n schemaField.$id,\n property,\n schemaField.title?.toLowerCase().replace(' ', '-')\n ])\n const label = makeLabel([\n schemaField.title,\n property\n ])\n const schemaRequired = schema.required ?? []\n const ob: Pick<IFormField, 'id' | 'label' | 'description' | 'multiple' | 'required'> = {\n id,\n label,\n description: schemaField.description,\n multiple,\n required: schemaRequired.includes(property) ?? false\n }\n if (type === 'text' || type === 'number' || type === 'long_text' || type === 'boolean' || type === 'datetime' || type === 'date' || type === 'time') {\n return {\n ...ob,\n type\n }\n }\n\n if (type === 'select' || type === 'checkbox') {\n const schemaOptions = schemaField.enum ?? schemaField.oneOf ?? schemaField.anyOf ?? []\n const options = schemaOptions.map(e => {\n const value = getValueFromSchema(e)\n const label = getLabelFromSchema(e)\n return value !== undefined\n ? {\n value: String(value),\n label: label ?? String(value)\n }\n : null\n }).filter(d => d !== null)\n return {\n ...ob,\n type,\n options\n }\n }\n if (type === 'object') {\n // const anyOfAsProps = schemaField.anyOf !== undefined && schemaField.anyOf.filter(d => typeof d !== 'boolean' && d.type !== 'null').length > 0\n const properties = schemaField.properties ?? {}\n const fields: IFormField[] = []\n for (const key in properties) {\n if (properties[key] !== undefined && typeof properties[key] !== 'boolean') {\n fields.push(schemaToFormField(schemaField, key, properties[key]))\n }\n }\n\n const ofArr = (schemaField.anyOf ?? []).concat(schemaField.allOf ?? [])\n\n ofArr.forEach((anyOf) => {\n const anyOfId = schemaField.$id\n if (typeof anyOf !== 'boolean' && anyOf.type !== 'null') {\n const field = schemaToFormField(\n schemaField,\n anyOfId ?? makeRandom(),\n typeof anyOf === 'boolean'\n ? anyOf\n : {\n title: anyOf.title ?? '',\n ...anyOf\n },\n true\n )\n if (anyOfId === undefined && field.type === 'object') {\n field.skip_path = true\n }\n fields.push(field)\n }\n })\n\n return {\n ...ob,\n type,\n fields,\n multiple\n }\n }\n\n return {\n id,\n type: 'text',\n multiple\n }\n}\n\nexport const schemaToFormObject = (schema: JSONSchema6): IForm => {\n const formFields: IFormField[] = []\n for (const key in schema.properties) {\n if (schema.properties[key] !== undefined && typeof schema.properties[key] !== 'boolean') {\n formFields.push(schemaToFormField(schema, key, schema.properties[key]))\n }\n }\n return {\n id: makeFormFieldId([schema.$id, schema.title?.toLowerCase().replace(' ', '-')]),\n label: schema.title ?? 'Untitled',\n fields: formFields\n }\n}\n"],"names":[],"mappings":";;;;;;;;;AAaA,IAAM,YAAY,GAAG,UAAC,MAAc,EAAA;IAClC,IAAM,GAAG,GAAG,IAAI,GAAG,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;IACtC,QAAQ,MAAM;AACZ,QAAA,KAAK,CAAC;AACJ,YAAA,OAAO,GAAG,CAAC,OAAO,CAAC,YAAY,CAAC;AAClC,QAAA,KAAK,CAAC;AACJ,YAAA,OAAO,GAAG,CAAC,OAAO,CAAC,YAAY,CAAC;AAClC,QAAA,KAAK,CAAC;AACJ,YAAA,OAAO,GAAG,CAAC,OAAO,CAAC,iBAAiB,CAAC;AACvC,QAAA,KAAK,CAAC;AACJ,YAAA,OAAO,GAAG,CAAC,OAAO,CAAC,iBAAiB,CAAC;AACvC,QAAA;AACE,YAAA,OAAO,GAAG,CAAC,OAAO,CAAC,YAAY,CAAC;;AAEtC,CAAC;AAEY,IAAA,cAAc,GAAG,UAAC,QAAiB,EAAE,OAAmB,EAAA;AAAnB,IAAA,IAAA,OAAA,KAAA,MAAA,EAAA,EAAA,OAAmB,GAAA,CAAA,CAAA;IACnE,IAAM,GAAG,GAAG,IAAI,GAAG,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;AACtC,IAAA,IAAM,SAAS,GAAG,YAAY,CAAC,OAAO,CAAC;AACvC,IAAA,IAAM,KAAK,GAAG,SAAS,CAAC,QAAQ,CAAC;IACjC,IAAI,CAAC,KAAK,EAA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A,EAAE,EAAA,EAAA;AACF,QAAA,IAAI,EAAE,MAAM;AACZ,QAAA,QAAQ,EAAA;KACT;AACH,CAAC;AAEM,IAAM,kBAAkB,GAAG,UAAC,MAAmB,EAAA;;IACpD,IAAM,UAAU,GAAiB,EAAE;AACnC,IAAA,KAAK,IAAM,GAAG,IAAI,MAAM,CAAC,UAAU,EAAE;AACnC,QAAA,IAAI,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,SAAS,IAAI,OAAO,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,SAAS,EAAE;AACvF,YAAA,UAAU,CAAC,IAAI,CAAC,iBAAiB,CAAC,MAAM,EAAE,GAAG,EAAE,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC;;;IAG3E,OAAO;QACL,EAAE,EAAE,eAAe,CAAC,CAAC,MAAM,CAAC,GAAG,EAAE,CAAA,EAAA,GAAA,MAAM,CAAC,KAAK,MAAE,IAAA,IAAA,EAAA,KAAA,MAAA,GAAA,MAAA,GAAA,EAAA,CAAA,WAAW,GAAG,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;AAChF,QAAA,KAAK,EAAE,CAAA,EAAA,GAAA,MAAM,CAAC,KAAK,mCAAI,UAAU;AACjC,QAAA,MAAM,EAAE;KACT;AACH;;;;"}
|
package/package.json
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
{
|
2
2
|
"name": "@axdspub/axiom-ui-forms",
|
3
|
-
"version": "0.2.
|
3
|
+
"version": "0.2.5",
|
4
4
|
"private": false,
|
5
|
+
"type": "module",
|
6
|
+
"description": "Axiom UI Forms",
|
5
7
|
"main": "./library/umd/library.js",
|
6
8
|
"module": "./library/esm/src/library.js",
|
7
9
|
"types": "./library/axiom-ui-forms.d.ts",
|
@@ -25,32 +27,35 @@
|
|
25
27
|
"@rollup/plugin-json": "^6.1.0",
|
26
28
|
"@rollup/plugin-node-resolve": "^16.0.0",
|
27
29
|
"@rollup/plugin-typescript": "^12.1.2",
|
30
|
+
"@tanstack/react-query": "^5.68.0",
|
28
31
|
"@types/geojson": "^7946.0.16",
|
29
32
|
"@types/json-schema": "^7.0.15",
|
30
33
|
"@types/react": "^18.2.28",
|
31
34
|
"@types/react-dom": "^18.2.13",
|
32
35
|
"ajv": "^8.17.1",
|
36
|
+
"autoprefixer": "^10.4.21",
|
33
37
|
"cbor-x": "^1.6.0",
|
34
38
|
"generate-schema": "^2.6.0",
|
35
39
|
"jotai": "^2.7.0",
|
36
40
|
"jotai-tanstack-query": "^0.8.5",
|
37
41
|
"lodash.set": "^4.3.2",
|
42
|
+
"postcss": "^8.5.3",
|
38
43
|
"react": "^18.0.0",
|
39
44
|
"react-dom": "^18.0.0",
|
40
45
|
"react-media": "^1.10.0",
|
41
46
|
"react-router-dom": "^7.2.0",
|
42
|
-
"react-scripts": "5.0.1",
|
43
47
|
"rimraf": "^6.0.1",
|
44
48
|
"rollup": "^4.34.8",
|
45
49
|
"rollup-plugin-dts": "^6.1.1",
|
46
50
|
"rollup-plugin-polyfill-node": "^0.13.0",
|
51
|
+
"to-json-schema": "^0.2.5",
|
47
52
|
"typescript": "^5.2.2"
|
48
53
|
},
|
49
54
|
"scripts": {
|
50
|
-
"start": "set PORT=3080 &&
|
51
|
-
"build": "
|
52
|
-
"
|
53
|
-
"
|
55
|
+
"start": "set PORT=3080 && vite",
|
56
|
+
"build": "vite build",
|
57
|
+
"serve": "vite preview",
|
58
|
+
"test": "react-scripts test",
|
54
59
|
"clean": "rimraf library",
|
55
60
|
"rollup": "rollup -c",
|
56
61
|
"prepublishOnly": "npm run clean && rollup -c"
|
@@ -89,11 +94,12 @@
|
|
89
94
|
},
|
90
95
|
"devDependencies": {
|
91
96
|
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
|
92
|
-
"@craco/craco": "^7.1.0",
|
93
97
|
"@types/lodash": "^4.17.12",
|
94
98
|
"@types/rison": "^0.1.0",
|
99
|
+
"@types/to-json-schema": "^0.2.4",
|
95
100
|
"@typescript-eslint/eslint-plugin": "^6.8.0",
|
96
101
|
"@typescript-eslint/parser": "^6.8.0",
|
102
|
+
"@vitejs/plugin-react": "^4.3.4",
|
97
103
|
"babel-plugin-named-exports-order": "^0.0.2",
|
98
104
|
"eslint": "^8.51.0",
|
99
105
|
"eslint-config-standard-with-typescript": "^39.1.1",
|
@@ -104,6 +110,7 @@
|
|
104
110
|
"tailwindcss": "^3.3.3",
|
105
111
|
"ts-node": "^10.9.1",
|
106
112
|
"typedoc": "^0.27.7",
|
113
|
+
"vite": "^6.2.2",
|
107
114
|
"web-vitals": "^2.1.4",
|
108
115
|
"webpack": "^5.88.2"
|
109
116
|
}
|