@gravity-ui/dynamic-forms 5.18.0 → 5.19.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/build/cjs/lib/unstable/core/Entity/Entity.js +78 -0
- package/build/cjs/lib/unstable/core/Entity/index.js +5 -0
- package/build/cjs/lib/unstable/core/Entity/types.js +2 -0
- package/build/cjs/lib/unstable/core/Entity/utils.js +40 -0
- package/build/cjs/lib/unstable/core/SchemaRenderer/SchemaRenderer.js +12 -0
- package/build/cjs/lib/unstable/core/SchemaRenderer/index.js +5 -0
- package/build/cjs/lib/unstable/core/constants.js +28 -0
- package/build/cjs/lib/unstable/core/index.js +15 -0
- package/build/cjs/lib/unstable/core/types/components.js +2 -0
- package/build/cjs/lib/unstable/core/types/config.js +2 -0
- package/build/cjs/lib/unstable/core/types/helpers.js +2 -0
- package/build/cjs/lib/unstable/core/types/index.js +8 -0
- package/build/cjs/lib/unstable/core/types/schema.js +2 -0
- package/build/cjs/lib/unstable/core/types/validation.js +2 -0
- package/build/cjs/lib/unstable/core/types/values.js +2 -0
- package/build/cjs/lib/unstable/core/useSchemaRenderer/constants.js +4 -0
- package/build/cjs/lib/unstable/core/useSchemaRenderer/hooks/index.js +7 -0
- package/build/cjs/lib/unstable/core/useSchemaRenderer/hooks/useEntitiesState.js +25 -0
- package/build/cjs/lib/unstable/core/useSchemaRenderer/hooks/useSchemaRendererMutators.js +17 -0
- package/build/cjs/lib/unstable/core/useSchemaRenderer/index.js +10 -0
- package/build/cjs/lib/unstable/core/useSchemaRenderer/mutators/async-validation/async-validation.js +35 -0
- package/build/cjs/lib/unstable/core/useSchemaRenderer/mutators/async-validation/index.js +5 -0
- package/build/cjs/lib/unstable/core/useSchemaRenderer/mutators/async-validation/types.js +2 -0
- package/build/cjs/lib/unstable/core/useSchemaRenderer/mutators/external-errors/external-errors.js +60 -0
- package/build/cjs/lib/unstable/core/useSchemaRenderer/mutators/external-errors/index.js +5 -0
- package/build/cjs/lib/unstable/core/useSchemaRenderer/mutators/external-errors/types.js +2 -0
- package/build/cjs/lib/unstable/core/useSchemaRenderer/mutators/index.js +16 -0
- package/build/cjs/lib/unstable/core/useSchemaRenderer/mutators/schema-mutators/index.js +5 -0
- package/build/cjs/lib/unstable/core/useSchemaRenderer/mutators/schema-mutators/schema-mutators.js +81 -0
- package/build/cjs/lib/unstable/core/useSchemaRenderer/mutators/schema-mutators/types.js +2 -0
- package/build/cjs/lib/unstable/core/useSchemaRenderer/mutators/trigger-fields/index.js +5 -0
- package/build/cjs/lib/unstable/core/useSchemaRenderer/mutators/trigger-fields/trigger-fields.js +12 -0
- package/build/cjs/lib/unstable/core/useSchemaRenderer/mutators/trigger-fields/types.js +2 -0
- package/build/cjs/lib/unstable/core/useSchemaRenderer/types.js +2 -0
- package/build/cjs/lib/unstable/core/useSchemaRenderer/useSchemaRenderer.js +86 -0
- package/build/cjs/lib/unstable/core/useSchemaRenderer/utils/common.js +11 -0
- package/build/cjs/lib/unstable/core/useSchemaRenderer/utils/get-ajv-validate.js +39 -0
- package/build/cjs/lib/unstable/core/useSchemaRenderer/utils/get-validate.js +67 -0
- package/build/cjs/lib/unstable/core/useSchemaRenderer/utils/index.js +7 -0
- package/build/cjs/lib/unstable/core/useSchemaRenderer/utils/process-ajv-error.js +51 -0
- package/build/cjs/lib/unstable/core/useSchemaRenderer/utils/process-ajv-validate-errors.js +43 -0
- package/build/cjs/lib/unstable/core/useSchemaRenderer/utils/process-entity-parameters-error.js +36 -0
- package/build/cjs/lib/unstable/core/useSchemaRenderer/utils/process-errors-state.js +17 -0
- package/build/cjs/lib/unstable/core/utils/common.js +180 -0
- package/build/cjs/lib/unstable/core/utils/index.js +4 -0
- package/build/cjs/lib/unstable/kit/Accordeon.js +31 -0
- package/build/cjs/lib/unstable/kit/Any.js +21 -0
- package/build/cjs/lib/unstable/kit/ArrayBase.css +23 -0
- package/build/cjs/lib/unstable/kit/ArrayBase.js +101 -0
- package/build/cjs/lib/unstable/kit/MultiSelect.css +6 -0
- package/build/cjs/lib/unstable/kit/MultiSelect.js +66 -0
- package/build/cjs/lib/unstable/kit/ObjectBase.css +10 -0
- package/build/cjs/lib/unstable/kit/ObjectBase.js +71 -0
- package/build/cjs/lib/unstable/kit/Row.css +73 -0
- package/build/cjs/lib/unstable/kit/Row.js +50 -0
- package/build/cjs/lib/unstable/kit/Text.js +259 -0
- package/build/cjs/lib/unstable/kit/components/ArrayRemoveButton/ArrayRemoveButton.js +29 -0
- package/build/cjs/lib/unstable/kit/components/ArrayRemoveButton/index.js +5 -0
- package/build/cjs/lib/unstable/kit/components/ControlError/ControlError.css +33 -0
- package/build/cjs/lib/unstable/kit/components/ControlError/ControlError.js +15 -0
- package/build/cjs/lib/unstable/kit/components/ControlError/index.js +5 -0
- package/build/cjs/lib/unstable/kit/components/HTMLContent/HTMLContent.js +11 -0
- package/build/cjs/lib/unstable/kit/components/HTMLContent/index.js +5 -0
- package/build/cjs/lib/unstable/kit/components/index.js +9 -0
- package/build/cjs/lib/unstable/kit/config.js +68 -0
- package/build/cjs/lib/unstable/kit/constants/config.js +62 -0
- package/build/cjs/lib/unstable/kit/constants/index.js +6 -0
- package/build/cjs/lib/unstable/kit/controls/ArrayBase/ArrayBase.js +46 -0
- package/build/cjs/lib/unstable/kit/controls/ArrayBase/index.js +4 -0
- package/build/cjs/lib/unstable/kit/controls/Checkbox/Checkbox.css +5 -0
- package/build/cjs/lib/unstable/kit/controls/Checkbox/Checkbox.js +16 -0
- package/build/cjs/lib/unstable/kit/controls/Checkbox/index.js +5 -0
- package/build/cjs/lib/unstable/kit/controls/CheckboxGroup/CheckboxGroup.css +3 -0
- package/build/cjs/lib/unstable/kit/controls/CheckboxGroup/CheckboxGroup.js +37 -0
- package/build/cjs/lib/unstable/kit/controls/CheckboxGroup/index.js +5 -0
- package/build/cjs/lib/unstable/kit/controls/ColorPicker/ColorPicker.js +24 -0
- package/build/cjs/lib/unstable/kit/controls/ColorPicker/index.js +5 -0
- package/build/cjs/lib/unstable/kit/controls/DateInput/DateInput.css +3 -0
- package/build/cjs/lib/unstable/kit/controls/DateInput/DateInput.js +55 -0
- package/build/cjs/lib/unstable/kit/controls/DateInput/index.js +5 -0
- package/build/cjs/lib/unstable/kit/controls/MultiSelect/MultiSelect.js +35 -0
- package/build/cjs/lib/unstable/kit/controls/MultiSelect/index.js +5 -0
- package/build/cjs/lib/unstable/kit/controls/NumberBase/Number.js +12 -0
- package/build/cjs/lib/unstable/kit/controls/NumberBase/index.js +5 -0
- package/build/cjs/lib/unstable/kit/controls/ObjectBase/ObjectBase.js +33 -0
- package/build/cjs/lib/unstable/kit/controls/ObjectBase/index.js +5 -0
- package/build/cjs/lib/unstable/kit/controls/Password/Password.js +12 -0
- package/build/cjs/lib/unstable/kit/controls/Password/index.js +5 -0
- package/build/cjs/lib/unstable/kit/controls/RadioGroup/RadioGroup.css +3 -0
- package/build/cjs/lib/unstable/kit/controls/RadioGroup/RadioGroup.js +24 -0
- package/build/cjs/lib/unstable/kit/controls/RadioGroup/index.js +5 -0
- package/build/cjs/lib/unstable/kit/controls/RangeSlider/RangeSlider.css +3 -0
- package/build/cjs/lib/unstable/kit/controls/RangeSlider/RangeSlider.js +33 -0
- package/build/cjs/lib/unstable/kit/controls/RangeSlider/index.js +5 -0
- package/build/cjs/lib/unstable/kit/controls/Select/Select.js +32 -0
- package/build/cjs/lib/unstable/kit/controls/Select/index.js +5 -0
- package/build/cjs/lib/unstable/kit/controls/Slider/Slider.css +3 -0
- package/build/cjs/lib/unstable/kit/controls/Slider/Slider.js +19 -0
- package/build/cjs/lib/unstable/kit/controls/Slider/index.js +5 -0
- package/build/cjs/lib/unstable/kit/controls/StringBase/StringBase.js +12 -0
- package/build/cjs/lib/unstable/kit/controls/StringBase/index.js +5 -0
- package/build/cjs/lib/unstable/kit/controls/Switch/Switch.css +5 -0
- package/build/cjs/lib/unstable/kit/controls/Switch/Switch.js +16 -0
- package/build/cjs/lib/unstable/kit/controls/Switch/index.js +5 -0
- package/build/cjs/lib/unstable/kit/controls/TextArea/TextArea.js +12 -0
- package/build/cjs/lib/unstable/kit/controls/TextArea/index.js +5 -0
- package/build/cjs/lib/unstable/kit/controls/index.js +35 -0
- package/build/cjs/lib/unstable/kit/styles/functions.css +0 -0
- package/build/cjs/lib/unstable/kit/styles/variables.css +0 -0
- package/build/cjs/lib/unstable/kit/utils/cn.js +6 -0
- package/build/cjs/lib/unstable/kit/utils/common.js +27 -0
- package/build/cjs/lib/unstable/kit/utils/index.js +11 -0
- package/build/cjs/lib/unstable/kit/wrappers/Row/Row.css +27 -0
- package/build/cjs/lib/unstable/kit/wrappers/Row/Row.js +34 -0
- package/build/cjs/lib/unstable/kit/wrappers/Row/index.js +5 -0
- package/build/cjs/lib/unstable/kit/wrappers/Transparent/Transparent.css +6 -0
- package/build/cjs/lib/unstable/kit/wrappers/Transparent/Transparent.js +15 -0
- package/build/cjs/lib/unstable/kit/wrappers/Transparent/index.js +5 -0
- package/build/cjs/lib/unstable/kit/wrappers/index.js +7 -0
- package/build/cjs/unstable.js +10 -0
- package/build/esm/lib/unstable/core/Entity/Entity.d.ts +10 -0
- package/build/esm/lib/unstable/core/Entity/Entity.js +74 -0
- package/build/esm/lib/unstable/core/Entity/index.d.ts +2 -0
- package/build/esm/lib/unstable/core/Entity/index.js +1 -0
- package/build/esm/lib/unstable/core/Entity/types.d.ts +27 -0
- package/build/esm/lib/unstable/core/Entity/types.js +1 -0
- package/build/esm/lib/unstable/core/Entity/utils.d.ts +3 -0
- package/build/esm/lib/unstable/core/Entity/utils.js +35 -0
- package/build/esm/lib/unstable/core/SchemaRenderer/SchemaRenderer.d.ts +5 -0
- package/build/esm/lib/unstable/core/SchemaRenderer/SchemaRenderer.js +8 -0
- package/build/esm/lib/unstable/core/SchemaRenderer/index.d.ts +1 -0
- package/build/esm/lib/unstable/core/SchemaRenderer/index.js +1 -0
- package/build/esm/lib/unstable/core/constants.d.ts +22 -0
- package/build/esm/lib/unstable/core/constants.js +25 -0
- package/build/esm/lib/unstable/core/index.d.ts +5 -0
- package/build/esm/lib/unstable/core/index.js +4 -0
- package/build/esm/lib/unstable/core/types/components.d.ts +29 -0
- package/build/esm/lib/unstable/core/types/components.js +1 -0
- package/build/esm/lib/unstable/core/types/config.d.ts +36 -0
- package/build/esm/lib/unstable/core/types/config.js +1 -0
- package/build/esm/lib/unstable/core/types/helpers.d.ts +18 -0
- package/build/esm/lib/unstable/core/types/helpers.js +1 -0
- package/build/esm/lib/unstable/core/types/index.d.ts +5 -0
- package/build/esm/lib/unstable/core/types/index.js +5 -0
- package/build/esm/lib/unstable/core/types/schema.d.ts +1186 -0
- package/build/esm/lib/unstable/core/types/schema.js +1 -0
- package/build/esm/lib/unstable/core/types/validation.d.ts +39 -0
- package/build/esm/lib/unstable/core/types/validation.js +1 -0
- package/build/esm/lib/unstable/core/types/values.d.ts +4 -0
- package/build/esm/lib/unstable/core/types/values.js +1 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/constants.d.ts +1 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/constants.js +1 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/hooks/index.d.ts +2 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/hooks/index.js +2 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/hooks/useEntitiesState.d.ts +7 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/hooks/useEntitiesState.js +20 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/hooks/useSchemaRendererMutators.d.ts +10 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/hooks/useSchemaRendererMutators.js +13 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/index.d.ts +3 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/index.js +3 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/mutators/async-validation/async-validation.d.ts +3 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/mutators/async-validation/async-validation.js +29 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/mutators/async-validation/index.d.ts +2 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/mutators/async-validation/index.js +2 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/mutators/async-validation/types.d.ts +34 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/mutators/async-validation/types.js +1 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/mutators/external-errors/external-errors.d.ts +3 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/mutators/external-errors/external-errors.js +54 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/mutators/external-errors/index.d.ts +2 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/mutators/external-errors/index.js +2 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/mutators/external-errors/types.d.ts +25 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/mutators/external-errors/types.js +1 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/mutators/index.d.ts +13 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/mutators/index.js +13 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/mutators/schema-mutators/index.d.ts +2 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/mutators/schema-mutators/index.js +2 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/mutators/schema-mutators/schema-mutators.d.ts +3 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/mutators/schema-mutators/schema-mutators.js +75 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/mutators/schema-mutators/types.d.ts +26 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/mutators/schema-mutators/types.js +1 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/mutators/trigger-fields/index.d.ts +2 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/mutators/trigger-fields/index.js +2 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/mutators/trigger-fields/trigger-fields.d.ts +2 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/mutators/trigger-fields/trigger-fields.js +8 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/mutators/trigger-fields/types.d.ts +6 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/mutators/trigger-fields/types.js +1 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/types.d.ts +22 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/types.js +1 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/useSchemaRenderer.d.ts +37 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/useSchemaRenderer.js +81 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/utils/common.d.ts +1 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/utils/common.js +7 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/utils/get-ajv-validate.d.ts +11 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/utils/get-ajv-validate.js +34 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/utils/get-validate.d.ts +14 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/utils/get-validate.js +62 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/utils/index.d.ts +2 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/utils/index.js +2 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/utils/process-ajv-error.d.ts +10 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/utils/process-ajv-error.js +46 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/utils/process-ajv-validate-errors.d.ts +20 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/utils/process-ajv-validate-errors.js +39 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/utils/process-entity-parameters-error.d.ts +15 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/utils/process-entity-parameters-error.js +31 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/utils/process-errors-state.d.ts +12 -0
- package/build/esm/lib/unstable/core/useSchemaRenderer/utils/process-errors-state.js +12 -0
- package/build/esm/lib/unstable/core/utils/common.d.ts +49 -0
- package/build/esm/lib/unstable/core/utils/common.js +165 -0
- package/build/esm/lib/unstable/core/utils/index.d.ts +1 -0
- package/build/esm/lib/unstable/core/utils/index.js +1 -0
- package/build/esm/lib/unstable/kit/Accordeon.d.ts +3 -0
- package/build/esm/lib/unstable/kit/Accordeon.js +26 -0
- package/build/esm/lib/unstable/kit/Any.d.ts +2 -0
- package/build/esm/lib/unstable/kit/Any.js +16 -0
- package/build/esm/lib/unstable/kit/ArrayBase.css +23 -0
- package/build/esm/lib/unstable/kit/ArrayBase.d.ts +3 -0
- package/build/esm/lib/unstable/kit/ArrayBase.js +97 -0
- package/build/esm/lib/unstable/kit/MultiSelect.css +6 -0
- package/build/esm/lib/unstable/kit/MultiSelect.d.ts +7 -0
- package/build/esm/lib/unstable/kit/MultiSelect.js +62 -0
- package/build/esm/lib/unstable/kit/ObjectBase.css +10 -0
- package/build/esm/lib/unstable/kit/ObjectBase.d.ts +8 -0
- package/build/esm/lib/unstable/kit/ObjectBase.js +66 -0
- package/build/esm/lib/unstable/kit/Row.css +73 -0
- package/build/esm/lib/unstable/kit/Row.d.ts +11 -0
- package/build/esm/lib/unstable/kit/Row.js +47 -0
- package/build/esm/lib/unstable/kit/Text.d.ts +6 -0
- package/build/esm/lib/unstable/kit/Text.js +255 -0
- package/build/esm/lib/unstable/kit/components/ArrayRemoveButton/ArrayRemoveButton.d.ts +5 -0
- package/build/esm/lib/unstable/kit/components/ArrayRemoveButton/ArrayRemoveButton.js +24 -0
- package/build/esm/lib/unstable/kit/components/ArrayRemoveButton/index.d.ts +1 -0
- package/build/esm/lib/unstable/kit/components/ArrayRemoveButton/index.js +1 -0
- package/build/esm/lib/unstable/kit/components/ControlError/ControlError.css +33 -0
- package/build/esm/lib/unstable/kit/components/ControlError/ControlError.d.ts +9 -0
- package/build/esm/lib/unstable/kit/components/ControlError/ControlError.js +11 -0
- package/build/esm/lib/unstable/kit/components/ControlError/index.d.ts +1 -0
- package/build/esm/lib/unstable/kit/components/ControlError/index.js +1 -0
- package/build/esm/lib/unstable/kit/components/HTMLContent/HTMLContent.d.ts +6 -0
- package/build/esm/lib/unstable/kit/components/HTMLContent/HTMLContent.js +7 -0
- package/build/esm/lib/unstable/kit/components/HTMLContent/index.d.ts +1 -0
- package/build/esm/lib/unstable/kit/components/HTMLContent/index.js +1 -0
- package/build/esm/lib/unstable/kit/components/index.d.ts +3 -0
- package/build/esm/lib/unstable/kit/components/index.js +3 -0
- package/build/esm/lib/unstable/kit/config.d.ts +95 -0
- package/build/esm/lib/unstable/kit/config.js +65 -0
- package/build/esm/lib/unstable/kit/constants/config.d.ts +112 -0
- package/build/esm/lib/unstable/kit/constants/config.js +59 -0
- package/build/esm/lib/unstable/kit/constants/index.d.ts +1 -0
- package/build/esm/lib/unstable/kit/constants/index.js +1 -0
- package/build/esm/lib/unstable/kit/controls/ArrayBase/ArrayBase.d.ts +8 -0
- package/build/esm/lib/unstable/kit/controls/ArrayBase/ArrayBase.js +42 -0
- package/build/esm/lib/unstable/kit/controls/ArrayBase/index.d.ts +1 -0
- package/build/esm/lib/unstable/kit/controls/ArrayBase/index.js +1 -0
- package/build/esm/lib/unstable/kit/controls/Checkbox/Checkbox.css +5 -0
- package/build/esm/lib/unstable/kit/controls/Checkbox/Checkbox.d.ts +7 -0
- package/build/esm/lib/unstable/kit/controls/Checkbox/Checkbox.js +13 -0
- package/build/esm/lib/unstable/kit/controls/Checkbox/index.d.ts +1 -0
- package/build/esm/lib/unstable/kit/controls/Checkbox/index.js +1 -0
- package/build/esm/lib/unstable/kit/controls/CheckboxGroup/CheckboxGroup.css +3 -0
- package/build/esm/lib/unstable/kit/controls/CheckboxGroup/CheckboxGroup.d.ts +10 -0
- package/build/esm/lib/unstable/kit/controls/CheckboxGroup/CheckboxGroup.js +34 -0
- package/build/esm/lib/unstable/kit/controls/CheckboxGroup/index.d.ts +1 -0
- package/build/esm/lib/unstable/kit/controls/CheckboxGroup/index.js +1 -0
- package/build/esm/lib/unstable/kit/controls/ColorPicker/ColorPicker.d.ts +6 -0
- package/build/esm/lib/unstable/kit/controls/ColorPicker/ColorPicker.js +21 -0
- package/build/esm/lib/unstable/kit/controls/ColorPicker/index.d.ts +1 -0
- package/build/esm/lib/unstable/kit/controls/ColorPicker/index.js +1 -0
- package/build/esm/lib/unstable/kit/controls/DateInput/DateInput.css +3 -0
- package/build/esm/lib/unstable/kit/controls/DateInput/DateInput.d.ts +9 -0
- package/build/esm/lib/unstable/kit/controls/DateInput/DateInput.js +53 -0
- package/build/esm/lib/unstable/kit/controls/DateInput/index.d.ts +1 -0
- package/build/esm/lib/unstable/kit/controls/DateInput/index.js +1 -0
- package/build/esm/lib/unstable/kit/controls/MultiSelect/MultiSelect.d.ts +8 -0
- package/build/esm/lib/unstable/kit/controls/MultiSelect/MultiSelect.js +32 -0
- package/build/esm/lib/unstable/kit/controls/MultiSelect/index.d.ts +1 -0
- package/build/esm/lib/unstable/kit/controls/MultiSelect/index.js +1 -0
- package/build/esm/lib/unstable/kit/controls/NumberBase/Number.d.ts +6 -0
- package/build/esm/lib/unstable/kit/controls/NumberBase/Number.js +8 -0
- package/build/esm/lib/unstable/kit/controls/NumberBase/index.d.ts +1 -0
- package/build/esm/lib/unstable/kit/controls/NumberBase/index.js +1 -0
- package/build/esm/lib/unstable/kit/controls/ObjectBase/ObjectBase.d.ts +8 -0
- package/build/esm/lib/unstable/kit/controls/ObjectBase/ObjectBase.js +29 -0
- package/build/esm/lib/unstable/kit/controls/ObjectBase/index.d.ts +1 -0
- package/build/esm/lib/unstable/kit/controls/ObjectBase/index.js +1 -0
- package/build/esm/lib/unstable/kit/controls/Password/Password.d.ts +6 -0
- package/build/esm/lib/unstable/kit/controls/Password/Password.js +8 -0
- package/build/esm/lib/unstable/kit/controls/Password/index.d.ts +1 -0
- package/build/esm/lib/unstable/kit/controls/Password/index.js +1 -0
- package/build/esm/lib/unstable/kit/controls/RadioGroup/RadioGroup.css +3 -0
- package/build/esm/lib/unstable/kit/controls/RadioGroup/RadioGroup.d.ts +9 -0
- package/build/esm/lib/unstable/kit/controls/RadioGroup/RadioGroup.js +22 -0
- package/build/esm/lib/unstable/kit/controls/RadioGroup/index.d.ts +1 -0
- package/build/esm/lib/unstable/kit/controls/RadioGroup/index.js +1 -0
- package/build/esm/lib/unstable/kit/controls/RangeSlider/RangeSlider.css +3 -0
- package/build/esm/lib/unstable/kit/controls/RangeSlider/RangeSlider.d.ts +8 -0
- package/build/esm/lib/unstable/kit/controls/RangeSlider/RangeSlider.js +31 -0
- package/build/esm/lib/unstable/kit/controls/RangeSlider/index.d.ts +1 -0
- package/build/esm/lib/unstable/kit/controls/RangeSlider/index.js +1 -0
- package/build/esm/lib/unstable/kit/controls/Select/Select.d.ts +9 -0
- package/build/esm/lib/unstable/kit/controls/Select/Select.js +29 -0
- package/build/esm/lib/unstable/kit/controls/Select/index.d.ts +1 -0
- package/build/esm/lib/unstable/kit/controls/Select/index.js +1 -0
- package/build/esm/lib/unstable/kit/controls/Slider/Slider.css +3 -0
- package/build/esm/lib/unstable/kit/controls/Slider/Slider.d.ts +7 -0
- package/build/esm/lib/unstable/kit/controls/Slider/Slider.js +16 -0
- package/build/esm/lib/unstable/kit/controls/Slider/index.d.ts +1 -0
- package/build/esm/lib/unstable/kit/controls/Slider/index.js +1 -0
- package/build/esm/lib/unstable/kit/controls/StringBase/StringBase.d.ts +6 -0
- package/build/esm/lib/unstable/kit/controls/StringBase/StringBase.js +8 -0
- package/build/esm/lib/unstable/kit/controls/StringBase/index.d.ts +1 -0
- package/build/esm/lib/unstable/kit/controls/StringBase/index.js +1 -0
- package/build/esm/lib/unstable/kit/controls/Switch/Switch.css +5 -0
- package/build/esm/lib/unstable/kit/controls/Switch/Switch.d.ts +7 -0
- package/build/esm/lib/unstable/kit/controls/Switch/Switch.js +13 -0
- package/build/esm/lib/unstable/kit/controls/Switch/index.d.ts +1 -0
- package/build/esm/lib/unstable/kit/controls/Switch/index.js +1 -0
- package/build/esm/lib/unstable/kit/controls/TextArea/TextArea.d.ts +6 -0
- package/build/esm/lib/unstable/kit/controls/TextArea/TextArea.js +8 -0
- package/build/esm/lib/unstable/kit/controls/TextArea/index.d.ts +1 -0
- package/build/esm/lib/unstable/kit/controls/TextArea/index.js +1 -0
- package/build/esm/lib/unstable/kit/controls/index.d.ts +16 -0
- package/build/esm/lib/unstable/kit/controls/index.js +16 -0
- package/build/esm/lib/unstable/kit/styles/functions.css +0 -0
- package/build/esm/lib/unstable/kit/styles/variables.css +0 -0
- package/build/esm/lib/unstable/kit/utils/cn.d.ts +1 -0
- package/build/esm/lib/unstable/kit/utils/cn.js +3 -0
- package/build/esm/lib/unstable/kit/utils/common.d.ts +7 -0
- package/build/esm/lib/unstable/kit/utils/common.js +19 -0
- package/build/esm/lib/unstable/kit/utils/index.d.ts +2 -0
- package/build/esm/lib/unstable/kit/utils/index.js +2 -0
- package/build/esm/lib/unstable/kit/wrappers/Row/Row.css +27 -0
- package/build/esm/lib/unstable/kit/wrappers/Row/Row.d.ts +7 -0
- package/build/esm/lib/unstable/kit/wrappers/Row/Row.js +31 -0
- package/build/esm/lib/unstable/kit/wrappers/Row/index.d.ts +1 -0
- package/build/esm/lib/unstable/kit/wrappers/Row/index.js +1 -0
- package/build/esm/lib/unstable/kit/wrappers/Transparent/Transparent.css +6 -0
- package/build/esm/lib/unstable/kit/wrappers/Transparent/Transparent.d.ts +4 -0
- package/build/esm/lib/unstable/kit/wrappers/Transparent/Transparent.js +12 -0
- package/build/esm/lib/unstable/kit/wrappers/Transparent/index.d.ts +1 -0
- package/build/esm/lib/unstable/kit/wrappers/Transparent/index.js +1 -0
- package/build/esm/lib/unstable/kit/wrappers/index.d.ts +2 -0
- package/build/esm/lib/unstable/kit/wrappers/index.js +2 -0
- package/build/esm/unstable.d.ts +4 -0
- package/build/esm/unstable.js +4 -0
- package/package.json +24 -2
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import cloneDeep from 'lodash/cloneDeep';
|
|
3
|
+
import noop from 'lodash/noop';
|
|
4
|
+
import { useForm } from 'react-final-form';
|
|
5
|
+
import { EMPTY_OBJECT } from '../constants';
|
|
6
|
+
import { ENTITY_SERVICE_FIELD } from './constants';
|
|
7
|
+
import { useSchemaRendererMutators } from './hooks';
|
|
8
|
+
import { getValidate } from './utils';
|
|
9
|
+
export const useSchemaRenderer = ({ config, connectValidate = true, errorMessages = EMPTY_OBJECT, mode, name, schema: originalSchema, }) => {
|
|
10
|
+
const form = useForm();
|
|
11
|
+
const { setAsyncValidationCache, setAsyncValidationWaiters, triggerFields } = useSchemaRendererMutators();
|
|
12
|
+
const errorsRef = React.useRef({});
|
|
13
|
+
const schemaRef = React.useRef(undefined);
|
|
14
|
+
const [schema, setSchema] = React.useState(undefined);
|
|
15
|
+
const [fieldsToTrigger, setFieldsToTrigger] = React.useState([]);
|
|
16
|
+
const setErrors = React.useCallback((errors) => {
|
|
17
|
+
const formState = form.getState();
|
|
18
|
+
const fieldsToTrigger = Object.keys(Object.assign(Object.assign({}, errorsRef.current), errors)).filter((key) => {
|
|
19
|
+
if (errorsRef.current[key] !== errors[key]) {
|
|
20
|
+
const field = form.getFieldState(key);
|
|
21
|
+
if ((field === null || field === void 0 ? void 0 : field.touched) || formState.submitFailed) {
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return false;
|
|
26
|
+
});
|
|
27
|
+
errorsRef.current = errors;
|
|
28
|
+
if (fieldsToTrigger.length) {
|
|
29
|
+
setFieldsToTrigger(fieldsToTrigger);
|
|
30
|
+
}
|
|
31
|
+
}, [form]);
|
|
32
|
+
const validate = React.useMemo(() => getValidate({
|
|
33
|
+
config,
|
|
34
|
+
errorMessages,
|
|
35
|
+
name,
|
|
36
|
+
setAsyncValidationCache,
|
|
37
|
+
setAsyncValidationWaiters,
|
|
38
|
+
setErrors,
|
|
39
|
+
}), [
|
|
40
|
+
config,
|
|
41
|
+
errorMessages,
|
|
42
|
+
name,
|
|
43
|
+
setAsyncValidationCache,
|
|
44
|
+
setAsyncValidationWaiters,
|
|
45
|
+
setErrors,
|
|
46
|
+
]);
|
|
47
|
+
const returnValue = React.useMemo(() => {
|
|
48
|
+
if (connectValidate) {
|
|
49
|
+
return { schema };
|
|
50
|
+
}
|
|
51
|
+
return {
|
|
52
|
+
schema,
|
|
53
|
+
validate: (value) => {
|
|
54
|
+
const allValues = form.getState().values;
|
|
55
|
+
const meta = form.getFieldState(name);
|
|
56
|
+
return validate(value, allValues, meta);
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
}, [connectValidate, form, name, schema, validate]);
|
|
60
|
+
React.useEffect(() => {
|
|
61
|
+
schemaRef.current = cloneDeep(originalSchema);
|
|
62
|
+
setSchema(schemaRef.current);
|
|
63
|
+
}, [originalSchema]);
|
|
64
|
+
React.useEffect(() => {
|
|
65
|
+
const data = { originalSchema, schema: schemaRef.current };
|
|
66
|
+
const getValidator = connectValidate ? () => validate : undefined;
|
|
67
|
+
const unsubscribe = form.registerField(name, noop, EMPTY_OBJECT, { data, getValidator });
|
|
68
|
+
return () => unsubscribe();
|
|
69
|
+
}, [connectValidate, form, name, originalSchema, validate]);
|
|
70
|
+
React.useEffect(() => {
|
|
71
|
+
const data = { config, errorsRef, headName: name, mode, schema: schemaRef.current };
|
|
72
|
+
const unsubscribe = form.registerField(`${ENTITY_SERVICE_FIELD}.${name}`, noop, EMPTY_OBJECT, { data });
|
|
73
|
+
return () => unsubscribe();
|
|
74
|
+
}, [config, form, mode, name]);
|
|
75
|
+
React.useEffect(() => {
|
|
76
|
+
if (fieldsToTrigger.length) {
|
|
77
|
+
triggerFields === null || triggerFields === void 0 ? void 0 : triggerFields({ fields: fieldsToTrigger });
|
|
78
|
+
}
|
|
79
|
+
}, [fieldsToTrigger, triggerFields]);
|
|
80
|
+
return returnValue;
|
|
81
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const guessHeadName: (registeredFields: string[], name: string) => string | undefined;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ENTITY_SERVICE_FIELD } from '../constants';
|
|
2
|
+
export const guessHeadName = (registeredFields, name) => {
|
|
3
|
+
const registeredServiceFields = registeredFields
|
|
4
|
+
.filter((n) => n.startsWith(ENTITY_SERVICE_FIELD))
|
|
5
|
+
.map((n) => n.slice(`${ENTITY_SERVICE_FIELD}.`.length));
|
|
6
|
+
return registeredServiceFields.find((n) => name === n || name.startsWith(`${n}.`) || name.startsWith(`${n}[`));
|
|
7
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ErrorObject, ValidateFunction } from 'ajv';
|
|
2
|
+
import type { JsonSchema, SchemaRendererConfig } from '../../types';
|
|
3
|
+
import type { EntityParametersError } from '../types';
|
|
4
|
+
export interface GetAjvValidateParams {
|
|
5
|
+
config: SchemaRendererConfig;
|
|
6
|
+
schema: JsonSchema;
|
|
7
|
+
}
|
|
8
|
+
export interface GetAjvValidateReturn extends ValidateFunction {
|
|
9
|
+
errors?: (ErrorObject | EntityParametersError)[];
|
|
10
|
+
}
|
|
11
|
+
export declare const getAjvValidate: ({ config, schema }: GetAjvValidateParams) => GetAjvValidateReturn;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import Ajv from 'ajv';
|
|
2
|
+
import get from 'lodash/get';
|
|
3
|
+
export const getAjvValidate = ({ config, schema }) => {
|
|
4
|
+
function entityParametersValidate(_, value, schema) {
|
|
5
|
+
if (schema && schema.entityParameters) {
|
|
6
|
+
const entityType = get(schema, 'entityParameters.type');
|
|
7
|
+
const validatorType = schema.entityParameters.validatorType;
|
|
8
|
+
const validator = get(config, `${entityType}.validators.${validatorType}`);
|
|
9
|
+
if (validator) {
|
|
10
|
+
const error = {
|
|
11
|
+
keyword: 'entityParameters',
|
|
12
|
+
message: '',
|
|
13
|
+
params: { validator, value, schema },
|
|
14
|
+
};
|
|
15
|
+
entityParametersValidate.errors = [error];
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
const ajv = new Ajv({
|
|
22
|
+
allErrors: true,
|
|
23
|
+
allowMatchingProperties: true,
|
|
24
|
+
keywords: [
|
|
25
|
+
{
|
|
26
|
+
errors: true,
|
|
27
|
+
keyword: 'entityParameters',
|
|
28
|
+
validate: entityParametersValidate,
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
});
|
|
32
|
+
const ajvValidate = ajv.compile(schema);
|
|
33
|
+
return ajvValidate;
|
|
34
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type FieldValidator } from 'final-form';
|
|
2
|
+
import type { ErrorMessages, FieldValue, SchemaRendererConfig, SyncValidateError } from '../../types';
|
|
3
|
+
import type { SetAsyncValidationCacheMutator, SetAsyncValidationWaitersMutator } from '../mutators';
|
|
4
|
+
export type GetValidateParams = {
|
|
5
|
+
config: SchemaRendererConfig;
|
|
6
|
+
errorMessages: ErrorMessages;
|
|
7
|
+
name: string;
|
|
8
|
+
setAsyncValidationCache?: SetAsyncValidationCacheMutator;
|
|
9
|
+
setAsyncValidationWaiters?: SetAsyncValidationWaitersMutator;
|
|
10
|
+
setErrors: (errors: Record<string, SyncValidateError>) => void;
|
|
11
|
+
};
|
|
12
|
+
type GetValidateReturn = FieldValidator<FieldValue>;
|
|
13
|
+
export declare const getValidate: ({ config, errorMessages, name, setAsyncValidationCache, setAsyncValidationWaiters, setErrors, }: GetValidateParams) => GetValidateReturn;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import get from 'lodash/get';
|
|
2
|
+
import isBoolean from 'lodash/isBoolean';
|
|
3
|
+
import isObjectLike from 'lodash/isObjectLike';
|
|
4
|
+
import isString from 'lodash/isString';
|
|
5
|
+
import { formatFinalFormPath, getValuePaths } from '../../utils';
|
|
6
|
+
import { getAjvValidate } from './get-ajv-validate';
|
|
7
|
+
import { processAjvValidateErrors } from './process-ajv-validate-errors';
|
|
8
|
+
import { processErrorsState } from './process-errors-state';
|
|
9
|
+
export const getValidate = ({ config, errorMessages, name, setAsyncValidationCache, setAsyncValidationWaiters, setErrors, }) => {
|
|
10
|
+
let schema;
|
|
11
|
+
let ajvValidate;
|
|
12
|
+
return (value, allValues, meta) => {
|
|
13
|
+
const data = meta === null || meta === void 0 ? void 0 : meta.data;
|
|
14
|
+
if (!(data === null || data === void 0 ? void 0 : data.schema)) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
if (schema !== data.schema) {
|
|
18
|
+
schema = data.schema;
|
|
19
|
+
ajvValidate = getAjvValidate({ config, schema });
|
|
20
|
+
}
|
|
21
|
+
ajvValidate(value);
|
|
22
|
+
const { ajvErrorItems, entityParametersErrorItems, waiters } = processAjvValidateErrors({
|
|
23
|
+
ajvValidateErrors: ajvValidate.errors || [],
|
|
24
|
+
allValues: allValues,
|
|
25
|
+
errorMessages,
|
|
26
|
+
name,
|
|
27
|
+
schema,
|
|
28
|
+
setAsyncValidationCache,
|
|
29
|
+
validationState: data,
|
|
30
|
+
});
|
|
31
|
+
const { externalPriorityErrorItems, externalRegularErrorItems } = processErrorsState({
|
|
32
|
+
errorsState: data,
|
|
33
|
+
name,
|
|
34
|
+
});
|
|
35
|
+
if (Object.keys(waiters).length) {
|
|
36
|
+
setAsyncValidationWaiters === null || setAsyncValidationWaiters === void 0 ? void 0 : setAsyncValidationWaiters({ headName: name, waiters });
|
|
37
|
+
}
|
|
38
|
+
const result = { errors: {} };
|
|
39
|
+
[
|
|
40
|
+
...externalRegularErrorItems,
|
|
41
|
+
...ajvErrorItems,
|
|
42
|
+
...entityParametersErrorItems,
|
|
43
|
+
...externalPriorityErrorItems,
|
|
44
|
+
].forEach((item) => {
|
|
45
|
+
if (!item.error) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
if (isObjectLike(item.error)) {
|
|
49
|
+
getValuePaths(item.error).forEach((childPath) => {
|
|
50
|
+
result.errors[formatFinalFormPath([name, ...item.path, ...childPath])] = get(item.error, childPath);
|
|
51
|
+
});
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
if (isBoolean(item.error) || isString(item.error)) {
|
|
55
|
+
result.errors[formatFinalFormPath([name, ...item.path])] = item.error;
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
setErrors(result.errors);
|
|
60
|
+
return Object.keys(result.errors).length ? 'error' : false;
|
|
61
|
+
};
|
|
62
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ErrorObject } from 'ajv';
|
|
2
|
+
import type { ErrorMessages, JsonSchema } from '../../types';
|
|
3
|
+
import type { ValidateErrorItem } from '../types';
|
|
4
|
+
export interface ProcessAjvErrorParams<Schema extends JsonSchema> {
|
|
5
|
+
error: ErrorObject;
|
|
6
|
+
errorMessages: ErrorMessages;
|
|
7
|
+
schema: Schema;
|
|
8
|
+
onError: (error: ValidateErrorItem) => void;
|
|
9
|
+
}
|
|
10
|
+
export declare const processAjvError: <Schema extends JsonSchema>({ error, errorMessages, schema, onError, }: ProcessAjvErrorParams<Schema>) => void;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import get from 'lodash/get';
|
|
2
|
+
import isString from 'lodash/isString';
|
|
3
|
+
import { getSchemaByInstancePath, getSchemaBySchemaPath, parseInstancePath } from '../../utils';
|
|
4
|
+
export const processAjvError = ({ error, errorMessages, schema, onError, }) => {
|
|
5
|
+
let instancePath = error.instancePath;
|
|
6
|
+
let keyword = error.keyword;
|
|
7
|
+
let schemaPath = error.schemaPath;
|
|
8
|
+
if (keyword === 'anyOf' ||
|
|
9
|
+
(keyword === 'if' &&
|
|
10
|
+
(error.params.failingKeyword === 'then' || error.params.failingKeyword === 'else')) ||
|
|
11
|
+
keyword === 'false schema') {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
if (error.propertyName) {
|
|
15
|
+
instancePath += `/${error.propertyName}`;
|
|
16
|
+
}
|
|
17
|
+
if (keyword === 'required') {
|
|
18
|
+
instancePath += `/${error.params.missingProperty}`;
|
|
19
|
+
}
|
|
20
|
+
else if (keyword === 'dependencies') {
|
|
21
|
+
instancePath += `/${error.params.missingProperty}`;
|
|
22
|
+
schemaPath =
|
|
23
|
+
schemaPath.slice(0, -'dependencies'.length) +
|
|
24
|
+
`properties/${error.params.missingProperty}/dependencies`;
|
|
25
|
+
}
|
|
26
|
+
else if (keyword === 'if') {
|
|
27
|
+
keyword = error.params.failingKeyword;
|
|
28
|
+
schemaPath = schemaPath.slice(0, -'if'.length) + error.params.failingKeyword;
|
|
29
|
+
}
|
|
30
|
+
const getErrorMessageBySchema = (schema) => {
|
|
31
|
+
const propertyName = instancePath.split('/').pop();
|
|
32
|
+
const errorOrMap = get(schema, `entityParameters.errorMessages.${keyword}`);
|
|
33
|
+
const message = isString(errorOrMap)
|
|
34
|
+
? errorOrMap
|
|
35
|
+
: get(errorOrMap, propertyName);
|
|
36
|
+
return message;
|
|
37
|
+
};
|
|
38
|
+
onError({
|
|
39
|
+
path: parseInstancePath(instancePath),
|
|
40
|
+
error: getErrorMessageBySchema(getSchemaBySchemaPath(schemaPath, schema)) ||
|
|
41
|
+
getErrorMessageBySchema(getSchemaBySchemaPath(schemaPath.slice(0, -`/${keyword}`.length), schema)) ||
|
|
42
|
+
getErrorMessageBySchema(getSchemaByInstancePath(instancePath, schema)) ||
|
|
43
|
+
errorMessages[keyword] ||
|
|
44
|
+
error.message,
|
|
45
|
+
});
|
|
46
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ErrorObject } from 'ajv';
|
|
2
|
+
import type { ErrorMessages, JsonSchema, ObjectValue } from '../../types';
|
|
3
|
+
import type { AsyncValidationState, AsyncValidationWaiter, SetAsyncValidationCacheMutator } from '../mutators';
|
|
4
|
+
import type { EntityParametersError, ValidateErrorItem } from '../types';
|
|
5
|
+
export interface ProcessAjvValidateErrorsParams<Schema extends JsonSchema> {
|
|
6
|
+
ajvValidateErrors: (ErrorObject | EntityParametersError)[];
|
|
7
|
+
allValues: ObjectValue;
|
|
8
|
+
errorMessages: ErrorMessages;
|
|
9
|
+
name: string;
|
|
10
|
+
schema: Schema;
|
|
11
|
+
setAsyncValidationCache?: SetAsyncValidationCacheMutator;
|
|
12
|
+
validationState: AsyncValidationState | undefined;
|
|
13
|
+
}
|
|
14
|
+
interface ProcessAjvValidateErrorsReturn {
|
|
15
|
+
ajvErrorItems: ValidateErrorItem[];
|
|
16
|
+
entityParametersErrorItems: ValidateErrorItem[];
|
|
17
|
+
waiters: Record<string, AsyncValidationWaiter>;
|
|
18
|
+
}
|
|
19
|
+
export declare const processAjvValidateErrors: <Schema extends JsonSchema>({ ajvValidateErrors, allValues, errorMessages, name, schema, setAsyncValidationCache, validationState, }: ProcessAjvValidateErrorsParams<Schema>) => ProcessAjvValidateErrorsReturn;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { processAjvError } from './process-ajv-error';
|
|
2
|
+
import { processEntityParametersError } from './process-entity-parameters-error';
|
|
3
|
+
export const processAjvValidateErrors = ({ ajvValidateErrors, allValues, errorMessages, name, schema, setAsyncValidationCache, validationState, }) => {
|
|
4
|
+
const waiters = {};
|
|
5
|
+
const ajvErrorItems = [];
|
|
6
|
+
const entityParametersErrorItems = [];
|
|
7
|
+
ajvValidateErrors.forEach((ajvOrEntityParametersError) => {
|
|
8
|
+
if (ajvOrEntityParametersError.keyword === 'entityParameters') {
|
|
9
|
+
const error = ajvOrEntityParametersError;
|
|
10
|
+
processEntityParametersError({
|
|
11
|
+
allValues,
|
|
12
|
+
error,
|
|
13
|
+
onAsyncError: (w) => {
|
|
14
|
+
waiters[w.instancePath] = w.params;
|
|
15
|
+
w.promise.then((result) => {
|
|
16
|
+
setAsyncValidationCache === null || setAsyncValidationCache === void 0 ? void 0 : setAsyncValidationCache({
|
|
17
|
+
headName: name,
|
|
18
|
+
cache: {
|
|
19
|
+
[w.instancePath]: Object.assign(Object.assign({}, w.params), { result }),
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
},
|
|
24
|
+
onError: (e) => entityParametersErrorItems.push(e),
|
|
25
|
+
validationState,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
const error = ajvOrEntityParametersError;
|
|
30
|
+
processAjvError({
|
|
31
|
+
error,
|
|
32
|
+
errorMessages,
|
|
33
|
+
schema,
|
|
34
|
+
onError: (e) => ajvErrorItems.push(e),
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
return { ajvErrorItems, entityParametersErrorItems, waiters };
|
|
39
|
+
};
|
package/build/esm/lib/unstable/core/useSchemaRenderer/utils/process-entity-parameters-error.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { AsyncValidateError, ObjectValue } from '../../types';
|
|
2
|
+
import type { AsyncValidationState } from '../mutators';
|
|
3
|
+
import type { EntityParametersError, ValidateErrorItem } from '../types';
|
|
4
|
+
export interface ProcessEntityParametersErrorParams {
|
|
5
|
+
allValues: ObjectValue;
|
|
6
|
+
error: EntityParametersError;
|
|
7
|
+
onAsyncError: (waiter: {
|
|
8
|
+
instancePath: string;
|
|
9
|
+
params: EntityParametersError['params'];
|
|
10
|
+
promise: AsyncValidateError;
|
|
11
|
+
}) => void;
|
|
12
|
+
onError: (error: ValidateErrorItem) => void;
|
|
13
|
+
validationState: AsyncValidationState | undefined;
|
|
14
|
+
}
|
|
15
|
+
export declare const processEntityParametersError: ({ allValues, error, onAsyncError, onError, validationState, }: ProcessEntityParametersErrorParams) => void;
|
package/build/esm/lib/unstable/core/useSchemaRenderer/utils/process-entity-parameters-error.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import isEqual from 'lodash/isEqual';
|
|
2
|
+
import omit from 'lodash/omit';
|
|
3
|
+
import { parseInstancePath } from '../../utils';
|
|
4
|
+
export const processEntityParametersError = ({ allValues, error, onAsyncError, onError, validationState, }) => {
|
|
5
|
+
var _a, _b;
|
|
6
|
+
const waiter = (_a = validationState === null || validationState === void 0 ? void 0 : validationState.waiters) === null || _a === void 0 ? void 0 : _a[error.instancePath];
|
|
7
|
+
const cache = (_b = validationState === null || validationState === void 0 ? void 0 : validationState.cache) === null || _b === void 0 ? void 0 : _b[error.instancePath];
|
|
8
|
+
const cacheItem = cache === null || cache === void 0 ? void 0 : cache.find((item) => isEqual(error.params, omit(item, 'result')));
|
|
9
|
+
if (cacheItem === null || cacheItem === void 0 ? void 0 : cacheItem.result) {
|
|
10
|
+
onError({
|
|
11
|
+
error: cacheItem.result,
|
|
12
|
+
path: parseInstancePath(error.instancePath),
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
else if (!waiter || !isEqual(error.params, waiter)) {
|
|
16
|
+
const errorOrPromise = error.params.validator(error.params.value, allValues);
|
|
17
|
+
if (errorOrPromise instanceof Promise) {
|
|
18
|
+
onAsyncError({
|
|
19
|
+
instancePath: error.instancePath,
|
|
20
|
+
params: error.params,
|
|
21
|
+
promise: errorOrPromise,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
onError({
|
|
26
|
+
error: errorOrPromise,
|
|
27
|
+
path: parseInstancePath(error.instancePath),
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ExternalErrorsState } from '../mutators';
|
|
2
|
+
import type { ValidateErrorItem } from '../types';
|
|
3
|
+
interface ProcessErrorsStateParams {
|
|
4
|
+
errorsState: ExternalErrorsState | undefined;
|
|
5
|
+
name: string;
|
|
6
|
+
}
|
|
7
|
+
interface ProcessErrorsStateReturn {
|
|
8
|
+
externalPriorityErrorItems: ValidateErrorItem[];
|
|
9
|
+
externalRegularErrorItems: ValidateErrorItem[];
|
|
10
|
+
}
|
|
11
|
+
export declare const processErrorsState: ({ errorsState, name, }: ProcessErrorsStateParams) => ProcessErrorsStateReturn;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import mapValues from 'lodash/mapValues';
|
|
2
|
+
import { parseFinalFormName } from '../../utils';
|
|
3
|
+
export const processErrorsState = ({ errorsState, name, }) => {
|
|
4
|
+
const getErrorItems = (errors) => Object.values(mapValues(errors, (value, key) => ({
|
|
5
|
+
path: parseFinalFormName(key).slice(parseFinalFormName(name).length),
|
|
6
|
+
error: value,
|
|
7
|
+
})));
|
|
8
|
+
return {
|
|
9
|
+
externalPriorityErrorItems: getErrorItems(errorsState === null || errorsState === void 0 ? void 0 : errorsState.priorityErrors),
|
|
10
|
+
externalRegularErrorItems: getErrorItems(errorsState === null || errorsState === void 0 ? void 0 : errorsState.regularErrors),
|
|
11
|
+
};
|
|
12
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { JsonSchema } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Parses an AJV `schemaPath` (JSON Pointer) into an array of path segments
|
|
4
|
+
* suitable for lodash `get`.
|
|
5
|
+
*
|
|
6
|
+
* Strips the `#/` prefix, decodes URI-encoded characters, splits on `/`,
|
|
7
|
+
* and unescapes JSON Pointer tokens (`~1` → `/`, `~0` → `~`).
|
|
8
|
+
*
|
|
9
|
+
* Returns all segments unchanged; stripping a trailing validation keyword
|
|
10
|
+
* (e.g. `minLength`) before lookup is the caller's responsibility.
|
|
11
|
+
*
|
|
12
|
+
* @param schemaPath - JSON Pointer string, e.g. `"#/properties/name/minLength"`.
|
|
13
|
+
* @returns Path segments, e.g. `['properties', 'name', 'minLength']`.
|
|
14
|
+
*/
|
|
15
|
+
export declare const parseSchemaPath: (schemaPath: string) => string[];
|
|
16
|
+
export declare const parseInstancePath: (instancePath: string) => string[];
|
|
17
|
+
export declare const parseFinalFormName: (finalFormName: string) => string[];
|
|
18
|
+
export declare const formatFinalFormPath: (finalFormPath: string[]) => string;
|
|
19
|
+
export declare const getSchemaPath: (finalFormNameOrPath: string | string[], finalFormHeadName: string, schema: JsonSchema) => string[] | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* Resolves a sub-schema from the root schema by an AJV `schemaPath`.
|
|
22
|
+
*
|
|
23
|
+
* Parses `schemaPath` via `parseSchemaPath` and looks up the node with lodash `get`.
|
|
24
|
+
* The path must point to a schema object, not to a validation keyword — callers
|
|
25
|
+
* should strip the trailing keyword first (see `processAjvError`).
|
|
26
|
+
*
|
|
27
|
+
* @param schemaPath - JSON Pointer string pointing to a schema node,
|
|
28
|
+
* e.g. `"#/properties/name"`.
|
|
29
|
+
* @param schema - The root JSON schema object.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* const nameSchema = {
|
|
33
|
+
* minLength: 5,
|
|
34
|
+
* };
|
|
35
|
+
* const objectSchema = {
|
|
36
|
+
* properties: {
|
|
37
|
+
* name: nameSchema,
|
|
38
|
+
* },
|
|
39
|
+
* };
|
|
40
|
+
* getSchemaBySchemaPath("#/properties/name", objectSchema); // returns nameSchema
|
|
41
|
+
*
|
|
42
|
+
* @returns The sub-schema at the given path, or the root schema when the path is empty.
|
|
43
|
+
*/
|
|
44
|
+
export declare const getSchemaBySchemaPath: (schemaPath: string, schema: JsonSchema) => JsonSchema | undefined;
|
|
45
|
+
export declare const getSchemaByInstancePath: (instancePath: string, schema: JsonSchema) => JsonSchema | undefined;
|
|
46
|
+
export declare const getSchemaByFinalFormPath: (finalFormNameOrPath: string | string[], finalFormHeadName: string, schema: JsonSchema) => JsonSchema | undefined;
|
|
47
|
+
export declare const getValuePaths: (value: unknown, path?: string[]) => string[][];
|
|
48
|
+
export declare const smartSet: (object: object, path: string[], value: unknown) => object;
|
|
49
|
+
export declare const smartMerge: (first: object, second: object, deep?: boolean) => {};
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import get from 'lodash/get';
|
|
2
|
+
import set from 'lodash/set';
|
|
3
|
+
/**
|
|
4
|
+
* Parses an AJV `schemaPath` (JSON Pointer) into an array of path segments
|
|
5
|
+
* suitable for lodash `get`.
|
|
6
|
+
*
|
|
7
|
+
* Strips the `#/` prefix, decodes URI-encoded characters, splits on `/`,
|
|
8
|
+
* and unescapes JSON Pointer tokens (`~1` → `/`, `~0` → `~`).
|
|
9
|
+
*
|
|
10
|
+
* Returns all segments unchanged; stripping a trailing validation keyword
|
|
11
|
+
* (e.g. `minLength`) before lookup is the caller's responsibility.
|
|
12
|
+
*
|
|
13
|
+
* @param schemaPath - JSON Pointer string, e.g. `"#/properties/name/minLength"`.
|
|
14
|
+
* @returns Path segments, e.g. `['properties', 'name', 'minLength']`.
|
|
15
|
+
*/
|
|
16
|
+
export const parseSchemaPath = (schemaPath) => {
|
|
17
|
+
return decodeURIComponent(schemaPath)
|
|
18
|
+
.split('/')
|
|
19
|
+
.slice(1)
|
|
20
|
+
.map((segment) => segment.replace(/~1/g, '/').replace(/~0/g, '~'));
|
|
21
|
+
};
|
|
22
|
+
export const parseInstancePath = (instancePath) => {
|
|
23
|
+
if (!instancePath.length) {
|
|
24
|
+
return [];
|
|
25
|
+
}
|
|
26
|
+
return instancePath
|
|
27
|
+
.slice('/'.length)
|
|
28
|
+
.split('/')
|
|
29
|
+
.map((segment) => segment.replace(/~1/g, '/').replace(/~0/g, '~'));
|
|
30
|
+
};
|
|
31
|
+
export const parseFinalFormName = (finalFormName) => {
|
|
32
|
+
const result = [];
|
|
33
|
+
const regex = /([^[.\]]+)|\[(\d+)\]/g;
|
|
34
|
+
let match;
|
|
35
|
+
while ((match = regex.exec(finalFormName)) !== null) {
|
|
36
|
+
if (match[1] !== undefined) {
|
|
37
|
+
result.push(match[1]);
|
|
38
|
+
}
|
|
39
|
+
else if (match[2] !== undefined) {
|
|
40
|
+
result.push(match[2]);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return result;
|
|
44
|
+
};
|
|
45
|
+
export const formatFinalFormPath = (finalFormPath) => {
|
|
46
|
+
return finalFormPath.reduce((result, segment) => {
|
|
47
|
+
if (/^\d+$/.test(segment)) {
|
|
48
|
+
return `${result}[${segment}]`;
|
|
49
|
+
}
|
|
50
|
+
return result ? `${result}.${segment}` : segment;
|
|
51
|
+
}, '');
|
|
52
|
+
};
|
|
53
|
+
export const getSchemaPath = (finalFormNameOrPath, finalFormHeadName, schema) => {
|
|
54
|
+
const finalFormPath = Array.isArray(finalFormNameOrPath)
|
|
55
|
+
? finalFormNameOrPath
|
|
56
|
+
: parseFinalFormName(finalFormNameOrPath);
|
|
57
|
+
const schemaPath = finalFormPath
|
|
58
|
+
.slice(parseFinalFormName(finalFormHeadName).length)
|
|
59
|
+
.reduce((path, segment, index) => {
|
|
60
|
+
if (path === undefined) {
|
|
61
|
+
return path;
|
|
62
|
+
}
|
|
63
|
+
const schemaByPath = index === 0 ? schema : get(schema, path);
|
|
64
|
+
if (get(schemaByPath, ['properties', segment])) {
|
|
65
|
+
return [...path, 'properties', segment];
|
|
66
|
+
}
|
|
67
|
+
const items = get(schemaByPath, 'items');
|
|
68
|
+
if (items) {
|
|
69
|
+
if (Array.isArray(items)) {
|
|
70
|
+
return [...path, 'items', segment];
|
|
71
|
+
}
|
|
72
|
+
return [...path, 'items'];
|
|
73
|
+
}
|
|
74
|
+
return undefined;
|
|
75
|
+
}, []);
|
|
76
|
+
return schemaPath;
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* Resolves a sub-schema from the root schema by an AJV `schemaPath`.
|
|
80
|
+
*
|
|
81
|
+
* Parses `schemaPath` via `parseSchemaPath` and looks up the node with lodash `get`.
|
|
82
|
+
* The path must point to a schema object, not to a validation keyword — callers
|
|
83
|
+
* should strip the trailing keyword first (see `processAjvError`).
|
|
84
|
+
*
|
|
85
|
+
* @param schemaPath - JSON Pointer string pointing to a schema node,
|
|
86
|
+
* e.g. `"#/properties/name"`.
|
|
87
|
+
* @param schema - The root JSON schema object.
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* const nameSchema = {
|
|
91
|
+
* minLength: 5,
|
|
92
|
+
* };
|
|
93
|
+
* const objectSchema = {
|
|
94
|
+
* properties: {
|
|
95
|
+
* name: nameSchema,
|
|
96
|
+
* },
|
|
97
|
+
* };
|
|
98
|
+
* getSchemaBySchemaPath("#/properties/name", objectSchema); // returns nameSchema
|
|
99
|
+
*
|
|
100
|
+
* @returns The sub-schema at the given path, or the root schema when the path is empty.
|
|
101
|
+
*/
|
|
102
|
+
export const getSchemaBySchemaPath = (schemaPath, schema) => {
|
|
103
|
+
const pathArr = parseSchemaPath(schemaPath);
|
|
104
|
+
if (!pathArr.length) {
|
|
105
|
+
return schema;
|
|
106
|
+
}
|
|
107
|
+
return get(schema, pathArr);
|
|
108
|
+
};
|
|
109
|
+
export const getSchemaByInstancePath = (instancePath, schema) => {
|
|
110
|
+
const schemaPath = getSchemaPath(parseInstancePath(instancePath), '', schema);
|
|
111
|
+
if (schemaPath) {
|
|
112
|
+
return schemaPath.length ? get(schema, schemaPath) : schema;
|
|
113
|
+
}
|
|
114
|
+
return undefined;
|
|
115
|
+
};
|
|
116
|
+
export const getSchemaByFinalFormPath = (finalFormNameOrPath, finalFormHeadName, schema) => {
|
|
117
|
+
const schemaPath = getSchemaPath(finalFormNameOrPath, finalFormHeadName, schema);
|
|
118
|
+
if (schemaPath) {
|
|
119
|
+
return schemaPath.length ? get(schema, schemaPath) : schema;
|
|
120
|
+
}
|
|
121
|
+
return undefined;
|
|
122
|
+
};
|
|
123
|
+
export const getValuePaths = (value, path = []) => {
|
|
124
|
+
const result = [];
|
|
125
|
+
const isObject = (v) => v !== null && typeof v === 'object' && !Array.isArray(v);
|
|
126
|
+
if (Array.isArray(value)) {
|
|
127
|
+
value.forEach((_, index) => {
|
|
128
|
+
result.push(...getValuePaths(value[index], [...path, `${index}`]));
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
else if (isObject(value)) {
|
|
132
|
+
Object.keys(value).forEach((key) => {
|
|
133
|
+
result.push(...getValuePaths(get(value, key), [...path, key]));
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
else if (path.length) {
|
|
137
|
+
result.push(path);
|
|
138
|
+
}
|
|
139
|
+
return result;
|
|
140
|
+
};
|
|
141
|
+
export const smartSet = (object, path, value) => {
|
|
142
|
+
const valuePaths = getValuePaths(value);
|
|
143
|
+
if (valuePaths.length) {
|
|
144
|
+
set(object, path, Object.assign({}, get(object, path)));
|
|
145
|
+
valuePaths.forEach((valuePath) => {
|
|
146
|
+
set(object, [...path, ...valuePath], get(value, valuePath));
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
return object;
|
|
150
|
+
};
|
|
151
|
+
export const smartMerge = (first, second, deep = false) => {
|
|
152
|
+
let result = {};
|
|
153
|
+
if (deep) {
|
|
154
|
+
getValuePaths(first).forEach((path) => {
|
|
155
|
+
set(result, path, get(first, path));
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
result = Object.assign({}, first);
|
|
160
|
+
}
|
|
161
|
+
getValuePaths(second).forEach((path) => {
|
|
162
|
+
set(result, path, get(second, path));
|
|
163
|
+
});
|
|
164
|
+
return result;
|
|
165
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './common';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './common';
|