@chobantonov/jsonforms-react-renderer-common 0.0.0-stage → 0.1.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/LICENSE +22 -0
- package/README.md +79 -2
- package/lib/cells/CellSummary.cjs.js +2 -0
- package/lib/cells/CellSummary.cjs.js.map +1 -0
- package/lib/cells/CellSummary.d.ts +14 -0
- package/lib/cells/CellSummary.esm.js +29 -0
- package/lib/cells/CellSummary.esm.js.map +1 -0
- package/lib/cells/cellMode.cjs.js +2 -0
- package/lib/cells/cellMode.cjs.js.map +1 -0
- package/lib/cells/cellMode.d.ts +14 -0
- package/lib/cells/cellMode.esm.js +6 -0
- package/lib/cells/cellMode.esm.js.map +1 -0
- package/lib/cells/compositeActions.cjs.js +2 -0
- package/lib/cells/compositeActions.cjs.js.map +1 -0
- package/lib/cells/compositeActions.d.ts +7 -0
- package/lib/cells/compositeActions.esm.js +14 -0
- package/lib/cells/compositeActions.esm.js.map +1 -0
- package/lib/cells/compositeCellTester.cjs.js +2 -0
- package/lib/cells/compositeCellTester.cjs.js.map +1 -0
- package/lib/cells/compositeCellTester.d.ts +2 -0
- package/lib/cells/compositeCellTester.esm.js +12 -0
- package/lib/cells/compositeCellTester.esm.js.map +1 -0
- package/lib/cells/compositeSummary.cjs.js +2 -0
- package/lib/cells/compositeSummary.cjs.js.map +1 -0
- package/lib/cells/compositeSummary.d.ts +10 -0
- package/lib/cells/compositeSummary.esm.js +44 -0
- package/lib/cells/compositeSummary.esm.js.map +1 -0
- package/lib/cells/useCompositeCellPresentation.cjs.js +2 -0
- package/lib/cells/useCompositeCellPresentation.cjs.js.map +1 -0
- package/lib/cells/useCompositeCellPresentation.d.ts +7 -0
- package/lib/cells/useCompositeCellPresentation.esm.js +18 -0
- package/lib/cells/useCompositeCellPresentation.esm.js.map +1 -0
- package/lib/cells/useCompositeDraft.cjs.js +2 -0
- package/lib/cells/useCompositeDraft.cjs.js.map +1 -0
- package/lib/cells/useCompositeDraft.d.ts +52 -0
- package/lib/cells/useCompositeDraft.esm.js +95 -0
- package/lib/cells/useCompositeDraft.esm.js.map +1 -0
- package/lib/collections/CollectionErrorNavigation.cjs.js +2 -0
- package/lib/collections/CollectionErrorNavigation.cjs.js.map +1 -0
- package/lib/collections/CollectionErrorNavigation.d.ts +12 -0
- package/lib/collections/CollectionErrorNavigation.esm.js +68 -0
- package/lib/collections/CollectionErrorNavigation.esm.js.map +1 -0
- package/lib/collections/arrayChoices.cjs.js +2 -0
- package/lib/collections/arrayChoices.cjs.js.map +1 -0
- package/lib/collections/arrayChoices.d.ts +85 -0
- package/lib/collections/arrayChoices.esm.js +54 -0
- package/lib/collections/arrayChoices.esm.js.map +1 -0
- package/lib/collections/collectionPagination.cjs.js +2 -0
- package/lib/collections/collectionPagination.cjs.js.map +1 -0
- package/lib/collections/collectionPagination.d.ts +22 -0
- package/lib/collections/collectionPagination.esm.js +51 -0
- package/lib/collections/collectionPagination.esm.js.map +1 -0
- package/lib/collections/columnResize.cjs.js +2 -0
- package/lib/collections/columnResize.cjs.js.map +1 -0
- package/lib/collections/columnResize.d.ts +16 -0
- package/lib/collections/columnResize.esm.js +85 -0
- package/lib/collections/columnResize.esm.js.map +1 -0
- package/lib/collections/rowDetail.cjs.js +2 -0
- package/lib/collections/rowDetail.cjs.js.map +1 -0
- package/lib/collections/rowDetail.d.ts +34 -0
- package/lib/collections/rowDetail.esm.js +106 -0
- package/lib/collections/rowDetail.esm.js.map +1 -0
- package/lib/collections/tableColumns.cjs.js +2 -0
- package/lib/collections/tableColumns.cjs.js.map +1 -0
- package/lib/collections/tableColumns.d.ts +13 -0
- package/lib/collections/tableColumns.esm.js +16 -0
- package/lib/collections/tableColumns.esm.js.map +1 -0
- package/lib/collections/useArrayPanelState.cjs.js +2 -0
- package/lib/collections/useArrayPanelState.cjs.js.map +1 -0
- package/lib/collections/useArrayPanelState.d.ts +7 -0
- package/lib/collections/useArrayPanelState.esm.js +18 -0
- package/lib/collections/useArrayPanelState.esm.js.map +1 -0
- package/lib/collections/useCollectionDelete.cjs.js +2 -0
- package/lib/collections/useCollectionDelete.cjs.js.map +1 -0
- package/lib/collections/useCollectionDelete.d.ts +17 -0
- package/lib/collections/useCollectionDelete.esm.js +38 -0
- package/lib/collections/useCollectionDelete.esm.js.map +1 -0
- package/lib/collections/useTableSelection.cjs.js +2 -0
- package/lib/collections/useTableSelection.cjs.js.map +1 -0
- package/lib/collections/useTableSelection.d.ts +11 -0
- package/lib/collections/useTableSelection.esm.js +41 -0
- package/lib/collections/useTableSelection.esm.js.map +1 -0
- package/lib/composition/AllOfRenderer.cjs.js +2 -0
- package/lib/composition/AllOfRenderer.cjs.js.map +1 -0
- package/lib/composition/AllOfRenderer.d.ts +5 -0
- package/lib/composition/AllOfRenderer.esm.js +33 -0
- package/lib/composition/AllOfRenderer.esm.js.map +1 -0
- package/lib/composition/CombinatorBranch.cjs.js +2 -0
- package/lib/composition/CombinatorBranch.cjs.js.map +1 -0
- package/lib/composition/CombinatorBranch.d.ts +17 -0
- package/lib/composition/CombinatorBranch.esm.js +54 -0
- package/lib/composition/CombinatorBranch.esm.js.map +1 -0
- package/lib/composition/CombinatorProperties.cjs.js +2 -0
- package/lib/composition/CombinatorProperties.cjs.js.map +1 -0
- package/lib/composition/CombinatorProperties.d.ts +12 -0
- package/lib/composition/CombinatorProperties.esm.js +20 -0
- package/lib/composition/CombinatorProperties.esm.js.map +1 -0
- package/lib/composition/ScalarCompositionControl.cjs.js +2 -0
- package/lib/composition/ScalarCompositionControl.cjs.js.map +1 -0
- package/lib/composition/ScalarCompositionControl.d.ts +6 -0
- package/lib/composition/ScalarCompositionControl.esm.js +22 -0
- package/lib/composition/ScalarCompositionControl.esm.js.map +1 -0
- package/lib/composition/choiceCards.cjs.js +2 -0
- package/lib/composition/choiceCards.cjs.js.map +1 -0
- package/lib/composition/choiceCards.d.ts +36 -0
- package/lib/composition/choiceCards.esm.js +162 -0
- package/lib/composition/choiceCards.esm.js.map +1 -0
- package/lib/composition/combinators.cjs.js +2 -0
- package/lib/composition/combinators.cjs.js.map +1 -0
- package/lib/composition/combinators.d.ts +40 -0
- package/lib/composition/combinators.esm.js +26 -0
- package/lib/composition/combinators.esm.js.map +1 -0
- package/lib/composition/discriminatorBranch.cjs.js +2 -0
- package/lib/composition/discriminatorBranch.cjs.js.map +1 -0
- package/lib/composition/discriminatorBranch.d.ts +6 -0
- package/lib/composition/discriminatorBranch.esm.js +41 -0
- package/lib/composition/discriminatorBranch.esm.js.map +1 -0
- package/lib/composition/scalarComposition.cjs.js +2 -0
- package/lib/composition/scalarComposition.cjs.js.map +1 -0
- package/lib/composition/scalarComposition.d.ts +27 -0
- package/lib/composition/scalarComposition.esm.js +76 -0
- package/lib/composition/scalarComposition.esm.js.map +1 -0
- package/lib/composition/useCombinatorSelection.cjs.js +2 -0
- package/lib/composition/useCombinatorSelection.cjs.js.map +1 -0
- package/lib/composition/useCombinatorSelection.d.ts +6 -0
- package/lib/composition/useCombinatorSelection.esm.js +22 -0
- package/lib/composition/useCombinatorSelection.esm.js.map +1 -0
- package/lib/composition/useScalarComposition.cjs.js +2 -0
- package/lib/composition/useScalarComposition.cjs.js.map +1 -0
- package/lib/composition/useScalarComposition.d.ts +18 -0
- package/lib/composition/useScalarComposition.esm.js +24 -0
- package/lib/composition/useScalarComposition.esm.js.map +1 -0
- package/lib/controls/FileArrayInput.cjs.js +2 -0
- package/lib/controls/FileArrayInput.cjs.js.map +1 -0
- package/lib/controls/FileArrayInput.d.ts +19 -0
- package/lib/controls/FileArrayInput.esm.js +232 -0
- package/lib/controls/FileArrayInput.esm.js.map +1 -0
- package/lib/controls/controlHelp.cjs.js +2 -0
- package/lib/controls/controlHelp.cjs.js.map +1 -0
- package/lib/controls/controlHelp.d.ts +15 -0
- package/lib/controls/controlHelp.esm.js +9 -0
- package/lib/controls/controlHelp.esm.js.map +1 -0
- package/lib/controls/inputAdornments.cjs.js +2 -0
- package/lib/controls/inputAdornments.cjs.js.map +1 -0
- package/lib/controls/inputAdornments.d.ts +32 -0
- package/lib/controls/inputAdornments.esm.js +192 -0
- package/lib/controls/inputAdornments.esm.js.map +1 -0
- package/lib/controls/numeric.cjs.js +2 -0
- package/lib/controls/numeric.cjs.js.map +1 -0
- package/lib/controls/numeric.d.ts +36 -0
- package/lib/controls/numeric.esm.js +9 -0
- package/lib/controls/numeric.esm.js.map +1 -0
- package/lib/controls/useClearAffordance.cjs.js +2 -0
- package/lib/controls/useClearAffordance.cjs.js.map +1 -0
- package/lib/controls/useClearAffordance.d.ts +15 -0
- package/lib/controls/useClearAffordance.esm.js +17 -0
- package/lib/controls/useClearAffordance.esm.js.map +1 -0
- package/lib/controls/useDebouncedChange.cjs.js +2 -0
- package/lib/controls/useDebouncedChange.cjs.js.map +1 -0
- package/lib/controls/useDebouncedChange.d.ts +37 -0
- package/lib/controls/useDebouncedChange.esm.js +40 -0
- package/lib/controls/useDebouncedChange.esm.js.map +1 -0
- package/lib/controls/useFocus.cjs.js +2 -0
- package/lib/controls/useFocus.cjs.js.map +1 -0
- package/lib/controls/useFocus.d.ts +1 -0
- package/lib/controls/useFocus.esm.js +13 -0
- package/lib/controls/useFocus.esm.js.map +1 -0
- package/lib/core/configNamespaces.cjs.js +2 -0
- package/lib/core/configNamespaces.cjs.js.map +1 -0
- package/lib/core/configNamespaces.d.ts +32 -0
- package/lib/core/configNamespaces.esm.js +15 -0
- package/lib/core/configNamespaces.esm.js.map +1 -0
- package/lib/core/dataPointer.cjs.js +2 -0
- package/lib/core/dataPointer.cjs.js.map +1 -0
- package/lib/core/dataPointer.d.ts +1 -0
- package/lib/core/dataPointer.esm.js +5 -0
- package/lib/core/dataPointer.esm.js.map +1 -0
- package/lib/core/detailUiSchema.cjs.js +2 -0
- package/lib/core/detailUiSchema.cjs.js.map +1 -0
- package/lib/core/detailUiSchema.d.ts +7 -0
- package/lib/core/detailUiSchema.esm.js +23 -0
- package/lib/core/detailUiSchema.esm.js.map +1 -0
- package/lib/core/plainRecord.cjs.js +2 -0
- package/lib/core/plainRecord.cjs.js.map +1 -0
- package/lib/core/plainRecord.d.ts +1 -0
- package/lib/core/plainRecord.esm.js +5 -0
- package/lib/core/plainRecord.esm.js.map +1 -0
- package/lib/core/uiSchemaCycle.cjs.js +2 -0
- package/lib/core/uiSchemaCycle.cjs.js.map +1 -0
- package/lib/core/uiSchemaCycle.d.ts +18 -0
- package/lib/core/uiSchemaCycle.esm.js +27 -0
- package/lib/core/uiSchemaCycle.esm.js.map +1 -0
- package/lib/dynamic/DynamicUiProvider.cjs.js +4 -0
- package/lib/dynamic/DynamicUiProvider.cjs.js.map +1 -0
- package/lib/dynamic/DynamicUiProvider.d.ts +35 -0
- package/lib/dynamic/DynamicUiProvider.esm.js +182 -0
- package/lib/dynamic/DynamicUiProvider.esm.js.map +1 -0
- package/lib/dynamic/dynamicCel.cjs.js +2 -0
- package/lib/dynamic/dynamicCel.cjs.js.map +1 -0
- package/lib/dynamic/dynamicCel.d.ts +1 -0
- package/lib/dynamic/dynamicCel.esm.js +43 -0
- package/lib/dynamic/dynamicCel.esm.js.map +1 -0
- package/lib/dynamic/dynamicConfig.cjs.js +2 -0
- package/lib/dynamic/dynamicConfig.cjs.js.map +1 -0
- package/lib/dynamic/dynamicConfig.d.ts +7 -0
- package/lib/dynamic/dynamicConfig.esm.js +13 -0
- package/lib/dynamic/dynamicConfig.esm.js.map +1 -0
- package/lib/dynamic/dynamicRuntime.cjs.js +2 -0
- package/lib/dynamic/dynamicRuntime.cjs.js.map +1 -0
- package/lib/dynamic/dynamicRuntime.d.ts +4 -0
- package/lib/dynamic/dynamicRuntime.esm.js +16 -0
- package/lib/dynamic/dynamicRuntime.esm.js.map +1 -0
- package/lib/dynamic/dynamicScope.cjs.js +2 -0
- package/lib/dynamic/dynamicScope.cjs.js.map +1 -0
- package/lib/dynamic/dynamicScope.d.ts +2 -0
- package/lib/dynamic/dynamicScope.esm.js +17 -0
- package/lib/dynamic/dynamicScope.esm.js.map +1 -0
- package/lib/dynamic/dynamicTree.cjs.js +2 -0
- package/lib/dynamic/dynamicTree.cjs.js.map +1 -0
- package/lib/dynamic/dynamicTree.d.ts +12 -0
- package/lib/dynamic/dynamicTree.esm.js +57 -0
- package/lib/dynamic/dynamicTree.esm.js.map +1 -0
- package/lib/dynamic/dynamicUi.cjs.js +2 -0
- package/lib/dynamic/dynamicUi.cjs.js.map +1 -0
- package/lib/dynamic/dynamicUi.d.ts +39 -0
- package/lib/dynamic/dynamicUi.esm.js +397 -0
- package/lib/dynamic/dynamicUi.esm.js.map +1 -0
- package/lib/formats/colorFormat.cjs.js +2 -0
- package/lib/formats/colorFormat.cjs.js.map +1 -0
- package/lib/formats/colorFormat.d.ts +127 -0
- package/lib/formats/colorFormat.esm.js +139 -0
- package/lib/formats/colorFormat.esm.js.map +1 -0
- package/lib/formats/dateValues.cjs.js +2 -0
- package/lib/formats/dateValues.cjs.js.map +1 -0
- package/lib/formats/dateValues.d.ts +3 -0
- package/lib/formats/dateValues.esm.js +21 -0
- package/lib/formats/dateValues.esm.js.map +1 -0
- package/lib/formats/duration.cjs.js +2 -0
- package/lib/formats/duration.cjs.js.map +1 -0
- package/lib/formats/duration.d.ts +13 -0
- package/lib/formats/duration.esm.js +28 -0
- package/lib/formats/duration.esm.js.map +1 -0
- package/lib/formats/maskControls.cjs.js +2 -0
- package/lib/formats/maskControls.cjs.js.map +1 -0
- package/lib/formats/maskControls.d.ts +32 -0
- package/lib/formats/maskControls.esm.js +16 -0
- package/lib/formats/maskControls.esm.js.map +1 -0
- package/lib/formats/maskFormat.cjs.js +2 -0
- package/lib/formats/maskFormat.cjs.js.map +1 -0
- package/lib/formats/maskFormat.d.ts +198 -0
- package/lib/formats/maskFormat.esm.js +79 -0
- package/lib/formats/maskFormat.esm.js.map +1 -0
- package/lib/formats/temporalBounds.cjs.js +2 -0
- package/lib/formats/temporalBounds.cjs.js.map +1 -0
- package/lib/formats/temporalBounds.d.ts +82 -0
- package/lib/formats/temporalBounds.esm.js +76 -0
- package/lib/formats/temporalBounds.esm.js.map +1 -0
- package/lib/formats/temporalFormats.cjs.js +2 -0
- package/lib/formats/temporalFormats.cjs.js.map +1 -0
- package/lib/formats/temporalFormats.d.ts +62 -0
- package/lib/formats/temporalFormats.esm.js +18 -0
- package/lib/formats/temporalFormats.esm.js.map +1 -0
- package/lib/formats/useMaskedInput.cjs.js +2 -0
- package/lib/formats/useMaskedInput.cjs.js.map +1 -0
- package/lib/formats/useMaskedInput.d.ts +11 -0
- package/lib/formats/useMaskedInput.esm.js +80 -0
- package/lib/formats/useMaskedInput.esm.js.map +1 -0
- package/lib/index.cjs.js +1 -0
- package/lib/index.d.ts +42 -0
- package/lib/index.esm.js +44 -0
- package/lib/interaction/confirmation.cjs.js +2 -0
- package/lib/interaction/confirmation.cjs.js.map +1 -0
- package/lib/interaction/confirmation.d.ts +112 -0
- package/lib/interaction/confirmation.esm.js +18 -0
- package/lib/interaction/confirmation.esm.js.map +1 -0
- package/lib/interaction/createDeleteConfirmation.cjs.js +2 -0
- package/lib/interaction/createDeleteConfirmation.cjs.js.map +1 -0
- package/lib/interaction/createDeleteConfirmation.d.ts +10 -0
- package/lib/interaction/createDeleteConfirmation.esm.js +17 -0
- package/lib/interaction/createDeleteConfirmation.esm.js.map +1 -0
- package/lib/interaction/detailDialog.cjs.js +2 -0
- package/lib/interaction/detailDialog.cjs.js.map +1 -0
- package/lib/interaction/detailDialog.d.ts +30 -0
- package/lib/interaction/detailDialog.esm.js +89 -0
- package/lib/interaction/detailDialog.esm.js.map +1 -0
- package/lib/interaction/pendingChanges.cjs.js +2 -0
- package/lib/interaction/pendingChanges.cjs.js.map +1 -0
- package/lib/interaction/pendingChanges.d.ts +19 -0
- package/lib/interaction/pendingChanges.esm.js +17 -0
- package/lib/interaction/pendingChanges.esm.js.map +1 -0
- package/lib/interaction/useConfirmationState.cjs.js +2 -0
- package/lib/interaction/useConfirmationState.cjs.js.map +1 -0
- package/lib/interaction/useConfirmationState.d.ts +11 -0
- package/lib/interaction/useConfirmationState.esm.js +39 -0
- package/lib/interaction/useConfirmationState.esm.js.map +1 -0
- package/lib/interaction/visuallyHidden.cjs.js +2 -0
- package/lib/interaction/visuallyHidden.cjs.js.map +1 -0
- package/lib/interaction/visuallyHidden.d.ts +9 -0
- package/lib/interaction/visuallyHidden.esm.js +14 -0
- package/lib/interaction/visuallyHidden.esm.js.map +1 -0
- package/lib/layout/categoryState.cjs.js +2 -0
- package/lib/layout/categoryState.cjs.js.map +1 -0
- package/lib/layout/categoryState.d.ts +66 -0
- package/lib/layout/categoryState.esm.js +42 -0
- package/lib/layout/categoryState.esm.js.map +1 -0
- package/lib/layout/groupState.cjs.js +2 -0
- package/lib/layout/groupState.cjs.js.map +1 -0
- package/lib/layout/groupState.d.ts +34 -0
- package/lib/layout/groupState.esm.js +63 -0
- package/lib/layout/groupState.esm.js.map +1 -0
- package/lib/layout/layoutContext.cjs.js +2 -0
- package/lib/layout/layoutContext.cjs.js.map +1 -0
- package/lib/layout/layoutContext.d.ts +16 -0
- package/lib/layout/layoutContext.esm.js +26 -0
- package/lib/layout/layoutContext.esm.js.map +1 -0
- package/lib/layout/layoutSizing.cjs.js +2 -0
- package/lib/layout/layoutSizing.cjs.js.map +1 -0
- package/lib/layout/layoutSizing.d.ts +104 -0
- package/lib/layout/layoutSizing.esm.js +69 -0
- package/lib/layout/layoutSizing.esm.js.map +1 -0
- package/lib/locale/bg.cjs.js +2 -0
- package/lib/locale/bg.cjs.js.map +1 -0
- package/lib/locale/bg.d.ts +279 -0
- package/lib/locale/bg.esm.js +271 -0
- package/lib/locale/bg.esm.js.map +1 -0
- package/lib/locale/calendar.cjs.js +2 -0
- package/lib/locale/calendar.cjs.js.map +1 -0
- package/lib/locale/calendar.d.ts +23 -0
- package/lib/locale/calendar.esm.js +57 -0
- package/lib/locale/calendar.esm.js.map +1 -0
- package/lib/locale/en.cjs.js +2 -0
- package/lib/locale/en.cjs.js.map +1 -0
- package/lib/locale/en.d.ts +275 -0
- package/lib/locale/en.esm.js +271 -0
- package/lib/locale/en.esm.js.map +1 -0
- package/lib/locale/index.cjs.js +1 -0
- package/lib/locale/index.d.ts +3 -0
- package/lib/locale/index.esm.js +3 -0
- package/lib/locale/intl.cjs.js +2 -0
- package/lib/locale/intl.cjs.js.map +1 -0
- package/lib/locale/intl.d.ts +2 -0
- package/lib/locale/intl.esm.js +11 -0
- package/lib/locale/intl.esm.js.map +1 -0
- package/lib/locale/rendererLocale.cjs.js +2 -0
- package/lib/locale/rendererLocale.cjs.js.map +1 -0
- package/lib/locale/rendererLocale.d.ts +40 -0
- package/lib/locale/rendererLocale.esm.js +24 -0
- package/lib/locale/rendererLocale.esm.js.map +1 -0
- package/lib/locale/translate.cjs.js +2 -0
- package/lib/locale/translate.cjs.js.map +1 -0
- package/lib/locale/translate.d.ts +43 -0
- package/lib/locale/translate.esm.js +25 -0
- package/lib/locale/translate.esm.js.map +1 -0
- package/lib/mixed/MixedDetailControl.cjs.js +2 -0
- package/lib/mixed/MixedDetailControl.cjs.js.map +1 -0
- package/lib/mixed/MixedDetailControl.d.ts +20 -0
- package/lib/mixed/MixedDetailControl.esm.js +73 -0
- package/lib/mixed/MixedDetailControl.esm.js.map +1 -0
- package/lib/mixed/RecursiveTreeRenderer.cjs.js +2 -0
- package/lib/mixed/RecursiveTreeRenderer.cjs.js.map +1 -0
- package/lib/mixed/RecursiveTreeRenderer.d.ts +35 -0
- package/lib/mixed/RecursiveTreeRenderer.esm.js +206 -0
- package/lib/mixed/RecursiveTreeRenderer.esm.js.map +1 -0
- package/lib/mixed/createMixedTypeChangeHandler.cjs.js +2 -0
- package/lib/mixed/createMixedTypeChangeHandler.cjs.js.map +1 -0
- package/lib/mixed/createMixedTypeChangeHandler.d.ts +16 -0
- package/lib/mixed/createMixedTypeChangeHandler.esm.js +34 -0
- package/lib/mixed/createMixedTypeChangeHandler.esm.js.map +1 -0
- package/lib/mixed/mixedComposition.cjs.js +2 -0
- package/lib/mixed/mixedComposition.cjs.js.map +1 -0
- package/lib/mixed/mixedComposition.d.ts +7 -0
- package/lib/mixed/mixedComposition.esm.js +37 -0
- package/lib/mixed/mixedComposition.esm.js.map +1 -0
- package/lib/mixed/mixedNodeEditor.cjs.js +2 -0
- package/lib/mixed/mixedNodeEditor.cjs.js.map +1 -0
- package/lib/mixed/mixedNodeEditor.d.ts +12 -0
- package/lib/mixed/mixedNodeEditor.esm.js +20 -0
- package/lib/mixed/mixedNodeEditor.esm.js.map +1 -0
- package/lib/mixed/mixedScalar.cjs.js +2 -0
- package/lib/mixed/mixedScalar.cjs.js.map +1 -0
- package/lib/mixed/mixedScalar.d.ts +4 -0
- package/lib/mixed/mixedScalar.esm.js +6 -0
- package/lib/mixed/mixedScalar.esm.js.map +1 -0
- package/lib/mixed/mixedSchema.cjs.js +2 -0
- package/lib/mixed/mixedSchema.cjs.js.map +1 -0
- package/lib/mixed/mixedSchema.d.ts +22 -0
- package/lib/mixed/mixedSchema.esm.js +88 -0
- package/lib/mixed/mixedSchema.esm.js.map +1 -0
- package/lib/mixed/mixedTree.cjs.js +2 -0
- package/lib/mixed/mixedTree.cjs.js.map +1 -0
- package/lib/mixed/mixedTree.d.ts +19 -0
- package/lib/mixed/mixedTree.esm.js +78 -0
- package/lib/mixed/mixedTree.esm.js.map +1 -0
- package/lib/mixed/mixedTreeActions.cjs.js +2 -0
- package/lib/mixed/mixedTreeActions.cjs.js.map +1 -0
- package/lib/mixed/mixedTreeActions.d.ts +6 -0
- package/lib/mixed/mixedTreeActions.esm.js +17 -0
- package/lib/mixed/mixedTreeActions.esm.js.map +1 -0
- package/lib/mixed/recursiveTree.cjs.js +2 -0
- package/lib/mixed/recursiveTree.cjs.js.map +1 -0
- package/lib/mixed/recursiveTree.d.ts +9 -0
- package/lib/mixed/recursiveTree.esm.js +49 -0
- package/lib/mixed/recursiveTree.esm.js.map +1 -0
- package/lib/mixed/useMixedNavigation.cjs.js +2 -0
- package/lib/mixed/useMixedNavigation.cjs.js.map +1 -0
- package/lib/mixed/useMixedNavigation.d.ts +6 -0
- package/lib/mixed/useMixedNavigation.esm.js +21 -0
- package/lib/mixed/useMixedNavigation.esm.js.map +1 -0
- package/lib/mixed/useMixedRenderer.cjs.js +2 -0
- package/lib/mixed/useMixedRenderer.cjs.js.map +1 -0
- package/lib/mixed/useMixedRenderer.d.ts +61 -0
- package/lib/mixed/useMixedRenderer.esm.js +185 -0
- package/lib/mixed/useMixedRenderer.esm.js.map +1 -0
- package/lib/mixed/useMixedType.cjs.js +2 -0
- package/lib/mixed/useMixedType.cjs.js.map +1 -0
- package/lib/mixed/useMixedType.d.ts +6 -0
- package/lib/mixed/useMixedType.esm.js +23 -0
- package/lib/mixed/useMixedType.esm.js.map +1 -0
- package/lib/objects/IsolatedPropertyEditor.cjs.js +2 -0
- package/lib/objects/IsolatedPropertyEditor.cjs.js.map +1 -0
- package/lib/objects/IsolatedPropertyEditor.d.ts +35 -0
- package/lib/objects/IsolatedPropertyEditor.esm.js +27 -0
- package/lib/objects/IsolatedPropertyEditor.esm.js.map +1 -0
- package/lib/objects/ObjectDetail.cjs.js +2 -0
- package/lib/objects/ObjectDetail.cjs.js.map +1 -0
- package/lib/objects/ObjectDetail.d.ts +42 -0
- package/lib/objects/ObjectDetail.esm.js +103 -0
- package/lib/objects/ObjectDetail.esm.js.map +1 -0
- package/lib/objects/additionalProperties.cjs.js +2 -0
- package/lib/objects/additionalProperties.cjs.js.map +1 -0
- package/lib/objects/additionalProperties.d.ts +14 -0
- package/lib/objects/additionalProperties.esm.js +41 -0
- package/lib/objects/additionalProperties.esm.js.map +1 -0
- package/lib/objects/additionalPropertyName.cjs.js +2 -0
- package/lib/objects/additionalPropertyName.cjs.js.map +1 -0
- package/lib/objects/additionalPropertyName.d.ts +63 -0
- package/lib/objects/additionalPropertyName.esm.js +46 -0
- package/lib/objects/additionalPropertyName.esm.js.map +1 -0
- package/lib/objects/conditionalFields.cjs.js +2 -0
- package/lib/objects/conditionalFields.cjs.js.map +1 -0
- package/lib/objects/conditionalFields.d.ts +18 -0
- package/lib/objects/conditionalFields.esm.js +105 -0
- package/lib/objects/conditionalFields.esm.js.map +1 -0
- package/lib/objects/dynamicProperties.cjs.js +2 -0
- package/lib/objects/dynamicProperties.cjs.js.map +1 -0
- package/lib/objects/dynamicProperties.d.ts +10 -0
- package/lib/objects/dynamicProperties.esm.js +33 -0
- package/lib/objects/dynamicProperties.esm.js.map +1 -0
- package/lib/objects/literalPropertySchema.cjs.js +2 -0
- package/lib/objects/literalPropertySchema.cjs.js.map +1 -0
- package/lib/objects/literalPropertySchema.d.ts +2 -0
- package/lib/objects/literalPropertySchema.esm.js +38 -0
- package/lib/objects/literalPropertySchema.esm.js.map +1 -0
- package/lib/objects/useAdditionalPropertyEntries.cjs.js +2 -0
- package/lib/objects/useAdditionalPropertyEntries.cjs.js.map +1 -0
- package/lib/objects/useAdditionalPropertyEntries.d.ts +72 -0
- package/lib/objects/useAdditionalPropertyEntries.esm.js +71 -0
- package/lib/objects/useAdditionalPropertyEntries.esm.js.map +1 -0
- package/lib/rolldown-runtime-BocRIvOZ.js +1 -0
- package/lib/tuple/TupleControlContent.cjs.js +2 -0
- package/lib/tuple/TupleControlContent.cjs.js.map +1 -0
- package/lib/tuple/TupleControlContent.d.ts +17 -0
- package/lib/tuple/TupleControlContent.esm.js +74 -0
- package/lib/tuple/TupleControlContent.esm.js.map +1 -0
- package/lib/tuple/TupleField.cjs.js +2 -0
- package/lib/tuple/TupleField.cjs.js.map +1 -0
- package/lib/tuple/TupleField.d.ts +15 -0
- package/lib/tuple/TupleField.esm.js +72 -0
- package/lib/tuple/TupleField.esm.js.map +1 -0
- package/lib/tuple/tupleSchema.cjs.js +2 -0
- package/lib/tuple/tupleSchema.cjs.js.map +1 -0
- package/lib/tuple/tupleSchema.d.ts +93 -0
- package/lib/tuple/tupleSchema.esm.js +63 -0
- package/lib/tuple/tupleSchema.esm.js.map +1 -0
- package/lib/tuple/useTupleAdditionalItems.cjs.js +2 -0
- package/lib/tuple/useTupleAdditionalItems.cjs.js.map +1 -0
- package/lib/tuple/useTupleAdditionalItems.d.ts +45 -0
- package/lib/tuple/useTupleAdditionalItems.esm.js +47 -0
- package/lib/tuple/useTupleAdditionalItems.esm.js.map +1 -0
- package/lib/tuple/useTupleControl.cjs.js +3 -0
- package/lib/tuple/useTupleControl.cjs.js.map +1 -0
- package/lib/tuple/useTupleControl.d.ts +26 -0
- package/lib/tuple/useTupleControl.esm.js +84 -0
- package/lib/tuple/useTupleControl.esm.js.map +1 -0
- package/lib/tuple/useTupleField.cjs.js +2 -0
- package/lib/tuple/useTupleField.cjs.js.map +1 -0
- package/lib/tuple/useTupleField.d.ts +38 -0
- package/lib/tuple/useTupleField.esm.js +80 -0
- package/lib/tuple/useTupleField.esm.js.map +1 -0
- package/lib/validation/ItemValidationIndicator.cjs.js +2 -0
- package/lib/validation/ItemValidationIndicator.cjs.js.map +1 -0
- package/lib/validation/ItemValidationIndicator.d.ts +9 -0
- package/lib/validation/ItemValidationIndicator.esm.js +14 -0
- package/lib/validation/ItemValidationIndicator.esm.js.map +1 -0
- package/lib/validation/errorSummary.cjs.js +9 -0
- package/lib/validation/errorSummary.cjs.js.map +1 -0
- package/lib/validation/errorSummary.d.ts +44 -0
- package/lib/validation/errorSummary.esm.js +194 -0
- package/lib/validation/errorSummary.esm.js.map +1 -0
- package/lib/validation/preTouchErrors.cjs.js +2 -0
- package/lib/validation/preTouchErrors.cjs.js.map +1 -0
- package/lib/validation/preTouchErrors.d.ts +77 -0
- package/lib/validation/preTouchErrors.esm.js +42 -0
- package/lib/validation/preTouchErrors.esm.js.map +1 -0
- package/lib/validation/validationIndicator.cjs.js +2 -0
- package/lib/validation/validationIndicator.cjs.js.map +1 -0
- package/lib/validation/validationIndicator.d.ts +72 -0
- package/lib/validation/validationIndicator.esm.js +66 -0
- package/lib/validation/validationIndicator.esm.js.map +1 -0
- package/lib/webcomponent/element.cjs.js +2 -0
- package/lib/webcomponent/element.cjs.js.map +1 -0
- package/lib/webcomponent/element.d.ts +48 -0
- package/lib/webcomponent/element.esm.js +85 -0
- package/lib/webcomponent/element.esm.js.map +1 -0
- package/lib/webcomponent/input.cjs.js +2 -0
- package/lib/webcomponent/input.cjs.js.map +1 -0
- package/lib/webcomponent/input.d.ts +6 -0
- package/lib/webcomponent/input.esm.js +25 -0
- package/lib/webcomponent/input.esm.js.map +1 -0
- package/package.json +86 -3
- package/src/cells/CellSummary.tsx +59 -0
- package/src/cells/cellMode.tsx +21 -0
- package/src/cells/compositeActions.ts +21 -0
- package/src/cells/compositeCellTester.ts +15 -0
- package/src/cells/compositeSummary.ts +149 -0
- package/src/cells/useCompositeCellPresentation.ts +37 -0
- package/src/cells/useCompositeDraft.ts +199 -0
- package/src/collections/CollectionErrorNavigation.tsx +123 -0
- package/src/collections/arrayChoices.ts +235 -0
- package/src/collections/collectionPagination.ts +95 -0
- package/src/collections/columnResize.tsx +151 -0
- package/src/collections/rowDetail.tsx +208 -0
- package/src/collections/tableColumns.ts +39 -0
- package/src/collections/useArrayPanelState.ts +25 -0
- package/src/collections/useCollectionDelete.ts +62 -0
- package/src/collections/useTableSelection.ts +77 -0
- package/src/composition/AllOfRenderer.tsx +79 -0
- package/src/composition/CombinatorBranch.tsx +93 -0
- package/src/composition/CombinatorProperties.tsx +56 -0
- package/src/composition/ScalarCompositionControl.tsx +34 -0
- package/src/composition/choiceCards.tsx +389 -0
- package/src/composition/combinators.ts +131 -0
- package/src/composition/discriminatorBranch.ts +82 -0
- package/src/composition/scalarComposition.ts +193 -0
- package/src/composition/useCombinatorSelection.ts +53 -0
- package/src/composition/useScalarComposition.ts +67 -0
- package/src/controls/FileArrayInput.tsx +407 -0
- package/src/controls/controlHelp.ts +28 -0
- package/src/controls/inputAdornments.tsx +337 -0
- package/src/controls/numeric.ts +43 -0
- package/src/controls/useClearAffordance.ts +22 -0
- package/src/controls/useDebouncedChange.ts +138 -0
- package/src/controls/useFocus.ts +32 -0
- package/src/core/configNamespaces.ts +67 -0
- package/src/core/dataPointer.ts +8 -0
- package/src/core/detailUiSchema.ts +88 -0
- package/src/core/plainRecord.ts +8 -0
- package/src/core/uiSchemaCycle.tsx +122 -0
- package/src/dynamic/DynamicUiProvider.tsx +414 -0
- package/src/dynamic/dynamicCel.ts +68 -0
- package/src/dynamic/dynamicConfig.ts +26 -0
- package/src/dynamic/dynamicRuntime.ts +25 -0
- package/src/dynamic/dynamicScope.ts +22 -0
- package/src/dynamic/dynamicTree.ts +128 -0
- package/src/dynamic/dynamicUi.ts +711 -0
- package/src/formats/colorFormat.ts +390 -0
- package/src/formats/dateValues.ts +45 -0
- package/src/formats/duration.ts +60 -0
- package/src/formats/maskControls.ts +88 -0
- package/src/formats/maskFormat.ts +375 -0
- package/src/formats/temporalBounds.ts +219 -0
- package/src/formats/temporalFormats.ts +128 -0
- package/src/formats/useMaskedInput.ts +194 -0
- package/src/index.ts +42 -0
- package/src/interaction/confirmation.ts +211 -0
- package/src/interaction/createDeleteConfirmation.ts +23 -0
- package/src/interaction/detailDialog.ts +138 -0
- package/src/interaction/pendingChanges.tsx +55 -0
- package/src/interaction/useConfirmationState.ts +55 -0
- package/src/interaction/visuallyHidden.ts +19 -0
- package/src/layout/categoryState.ts +189 -0
- package/src/layout/groupState.ts +201 -0
- package/src/layout/layoutContext.tsx +49 -0
- package/src/layout/layoutSizing.ts +369 -0
- package/src/locale/bg.ts +309 -0
- package/src/locale/calendar.ts +57 -0
- package/src/locale/en.ts +375 -0
- package/src/locale/index.ts +5 -0
- package/src/locale/intl.ts +10 -0
- package/src/locale/rendererLocale.ts +74 -0
- package/src/locale/translate.ts +98 -0
- package/src/mixed/MixedDetailControl.tsx +182 -0
- package/src/mixed/RecursiveTreeRenderer.tsx +388 -0
- package/src/mixed/createMixedTypeChangeHandler.ts +77 -0
- package/src/mixed/mixedComposition.ts +76 -0
- package/src/mixed/mixedNodeEditor.ts +47 -0
- package/src/mixed/mixedScalar.ts +7 -0
- package/src/mixed/mixedSchema.ts +283 -0
- package/src/mixed/mixedTree.ts +199 -0
- package/src/mixed/mixedTreeActions.ts +60 -0
- package/src/mixed/recursiveTree.ts +105 -0
- package/src/mixed/useMixedNavigation.ts +36 -0
- package/src/mixed/useMixedRenderer.ts +300 -0
- package/src/mixed/useMixedType.ts +45 -0
- package/src/objects/IsolatedPropertyEditor.tsx +86 -0
- package/src/objects/ObjectDetail.tsx +232 -0
- package/src/objects/additionalProperties.ts +151 -0
- package/src/objects/additionalPropertyName.ts +185 -0
- package/src/objects/conditionalFields.ts +173 -0
- package/src/objects/dynamicProperties.tsx +68 -0
- package/src/objects/literalPropertySchema.ts +100 -0
- package/src/objects/useAdditionalPropertyEntries.ts +204 -0
- package/src/tuple/TupleControlContent.tsx +152 -0
- package/src/tuple/TupleField.tsx +150 -0
- package/src/tuple/tupleSchema.ts +245 -0
- package/src/tuple/useTupleAdditionalItems.ts +131 -0
- package/src/tuple/useTupleControl.tsx +173 -0
- package/src/tuple/useTupleField.ts +164 -0
- package/src/validation/ItemValidationIndicator.tsx +21 -0
- package/src/validation/errorSummary.tsx +489 -0
- package/src/validation/preTouchErrors.ts +185 -0
- package/src/validation/validationIndicator.ts +202 -0
- package/src/webcomponent/element.ts +107 -0
- package/src/webcomponent/input.ts +56 -0
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { ControlElement, type Translator, type ErrorTranslator, JsonSchema } from '@jsonforms/core';
|
|
2
|
+
import type { ErrorObject } from 'ajv';
|
|
3
|
+
/**
|
|
4
|
+
* Pre-touch error-message filtering.
|
|
5
|
+
*
|
|
6
|
+
* A form opened on incomplete data greets the user with a required error on
|
|
7
|
+
* every field they have not reached yet. These two options hide those messages
|
|
8
|
+
* until the user has actually visited the field:
|
|
9
|
+
*
|
|
10
|
+
* - `enableFilterErrorsBeforeTouch` - false when absent; true turns filtering on.
|
|
11
|
+
* - `filterErrorKeywordsBeforeTouch` - the keywords to suppress. Absent or
|
|
12
|
+
* empty, with filtering on, suppresses **all** of a control's error text
|
|
13
|
+
* before touch.
|
|
14
|
+
*
|
|
15
|
+
* Both are renderer options with global config defaults that a control's own
|
|
16
|
+
* `options` override, in either direction.
|
|
17
|
+
*
|
|
18
|
+
* **Presentation only.** The form's validity, the structured errors, and the
|
|
19
|
+
* data are all untouched; this decides what one control prints. It cannot make
|
|
20
|
+
* an error appear either - a control whose errors the validation mode already
|
|
21
|
+
* hides stays quiet when filtering is switched off.
|
|
22
|
+
*
|
|
23
|
+
* The algorithm is the one the Vuetify (`vue-vuetify/src/util/composition.ts`)
|
|
24
|
+
* and Svelte renderer families already use, deliberately: these are their
|
|
25
|
+
* option names, so a form authored against them has to behave the same here.
|
|
26
|
+
*/
|
|
27
|
+
export interface FilterErrorsBeforeTouchInput {
|
|
28
|
+
/** Whether this control has been blurred at least once. */
|
|
29
|
+
touched: boolean;
|
|
30
|
+
/** The control's formatted errors, as JSON Forms computed them. */
|
|
31
|
+
errors: string;
|
|
32
|
+
/** `config` merged with the element's `options`. */
|
|
33
|
+
appliedOptions: Record<string, any>;
|
|
34
|
+
/** Every error in the form, from `core`. */
|
|
35
|
+
coreErrors: ErrorObject[] | undefined;
|
|
36
|
+
path: string;
|
|
37
|
+
schema?: JsonSchema;
|
|
38
|
+
uischema?: ControlElement;
|
|
39
|
+
translate?: Translator;
|
|
40
|
+
translateError?: ErrorTranslator;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* The filtered message for one control.
|
|
44
|
+
*
|
|
45
|
+
* Returns `errors` unchanged whenever filtering does not apply, so a control
|
|
46
|
+
* that opts out - or one nobody configured - pays nothing and cannot have its
|
|
47
|
+
* text rewritten by a formatting difference.
|
|
48
|
+
*/
|
|
49
|
+
export declare const filterErrorsBeforeTouch: ({ touched, errors, appliedOptions, coreErrors, path, schema, uischema, translate, translateError, }: FilterErrorsBeforeTouchInput) => string;
|
|
50
|
+
export interface PreTouchErrorsProps {
|
|
51
|
+
errors?: string;
|
|
52
|
+
path: string;
|
|
53
|
+
schema?: JsonSchema;
|
|
54
|
+
uischema?: ControlElement;
|
|
55
|
+
config?: any;
|
|
56
|
+
}
|
|
57
|
+
export interface PreTouchErrors {
|
|
58
|
+
/** What the control should print: `errors`, a subset of it, or nothing. */
|
|
59
|
+
errors: string;
|
|
60
|
+
focused: boolean;
|
|
61
|
+
touched: boolean;
|
|
62
|
+
onFocus: () => void;
|
|
63
|
+
onBlur: () => void;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* `useFocus` plus the touch state the filter needs.
|
|
67
|
+
*
|
|
68
|
+
* Touch is per control and local, as it is in both reference implementations -
|
|
69
|
+
* there is no shared registry, because nothing outside a control needs to know
|
|
70
|
+
* that it was visited.
|
|
71
|
+
*
|
|
72
|
+
* **Touch is blur, not focus.** "The control becomes touched on blur:
|
|
73
|
+
* receiving focus alone is insufficient, and leaving the control counts even
|
|
74
|
+
* if the user did not change its data." It is also one-way: editing the value,
|
|
75
|
+
* clearing it, or its becoming valid again does not untouch the control.
|
|
76
|
+
*/
|
|
77
|
+
export declare const usePreTouchErrors: (props: PreTouchErrorsProps) => PreTouchErrors;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { useCallback as e, useMemo as t, useState as n } from "react";
|
|
2
|
+
import { defaultTranslator as r, getCombinedErrorMessage as i, getControlPath as a } from "@jsonforms/core";
|
|
3
|
+
import { useJsonForms as o } from "@jsonforms/react";
|
|
4
|
+
import s from "lodash/merge";
|
|
5
|
+
// src/validation/preTouchErrors.ts
|
|
6
|
+
var c = ({ touched: e, errors: t, appliedOptions: n, coreErrors: o, path: s, schema: c, uischema: l, translate: u, translateError: d }) => {
|
|
7
|
+
if (e || !t || !n.enableFilterErrorsBeforeTouch) return t;
|
|
8
|
+
let f = n.filterErrorKeywordsBeforeTouch;
|
|
9
|
+
if (Array.isArray(f) && f.length > 0) {
|
|
10
|
+
let e = (o ?? []).filter((e) => s === a(e)), n = e.filter((e) => !e.keyword || !f.includes(e.keyword));
|
|
11
|
+
return n.length === e.length || !d ? t : i(n, d, u ?? r, c, l, s);
|
|
12
|
+
}
|
|
13
|
+
return "";
|
|
14
|
+
}, l = (r) => {
|
|
15
|
+
var i, a, l;
|
|
16
|
+
let [u, d] = n(!1), [f, p] = n(!1), m = o(), h = e(() => d(!0), []), g = e(() => {
|
|
17
|
+
p(!0), d(!1);
|
|
18
|
+
}, []), _ = t(() => {
|
|
19
|
+
var e;
|
|
20
|
+
return s({}, r.config ?? {}, ((e = r.uischema) == null ? void 0 : e.options) ?? {});
|
|
21
|
+
}, [r.config, r.uischema]);
|
|
22
|
+
return {
|
|
23
|
+
errors: c({
|
|
24
|
+
touched: f,
|
|
25
|
+
errors: r.errors ?? "",
|
|
26
|
+
appliedOptions: _,
|
|
27
|
+
coreErrors: (i = m.core) == null ? void 0 : i.errors,
|
|
28
|
+
path: r.path,
|
|
29
|
+
schema: r.schema,
|
|
30
|
+
uischema: r.uischema,
|
|
31
|
+
translate: (a = m.i18n) == null ? void 0 : a.translate,
|
|
32
|
+
translateError: (l = m.i18n) == null ? void 0 : l.translateError
|
|
33
|
+
}),
|
|
34
|
+
focused: u,
|
|
35
|
+
touched: f,
|
|
36
|
+
onFocus: h,
|
|
37
|
+
onBlur: g
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
export { c as filterErrorsBeforeTouch, l as usePreTouchErrors };
|
|
41
|
+
|
|
42
|
+
//# sourceMappingURL=preTouchErrors.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preTouchErrors.esm.js","names":["merge","filterErrorsBeforeTouch","touched","errors","appliedOptions","filterKeywords","errorsAtControl","coreErrors","path","getControlPath","error","errorsToShow","translateError","getCombinedErrorMessage","translate","defaultTranslator","schema","uischema","usePreTouchErrors","_ctx$core","_ctx$i18n","_ctx$i18n2","focused","setFocused","useState","setTouched","ctx","useJsonForms","onFocus","useCallback","onBlur","useMemo","_props$uischema","props"],"sources":["../../src/validation/preTouchErrors.ts"],"sourcesContent":["import {\n ControlElement,\n defaultTranslator,\n type Translator,\n type ErrorTranslator,\n JsonSchema,\n getCombinedErrorMessage,\n getControlPath,\n} from '@jsonforms/core';\nimport type { ErrorObject } from 'ajv';\nimport { useCallback, useMemo, useState } from 'react';\nimport { useJsonForms } from '@jsonforms/react';\nimport merge from 'lodash/merge';\n\n/**\n * Pre-touch error-message filtering.\n *\n * A form opened on incomplete data greets the user with a required error on\n * every field they have not reached yet. These two options hide those messages\n * until the user has actually visited the field:\n *\n * - `enableFilterErrorsBeforeTouch` - false when absent; true turns filtering on.\n * - `filterErrorKeywordsBeforeTouch` - the keywords to suppress. Absent or\n * empty, with filtering on, suppresses **all** of a control's error text\n * before touch.\n *\n * Both are renderer options with global config defaults that a control's own\n * `options` override, in either direction.\n *\n * **Presentation only.** The form's validity, the structured errors, and the\n * data are all untouched; this decides what one control prints. It cannot make\n * an error appear either - a control whose errors the validation mode already\n * hides stays quiet when filtering is switched off.\n *\n * The algorithm is the one the Vuetify (`vue-vuetify/src/util/composition.ts`)\n * and Svelte renderer families already use, deliberately: these are their\n * option names, so a form authored against them has to behave the same here.\n */\n\nexport interface FilterErrorsBeforeTouchInput {\n /** Whether this control has been blurred at least once. */\n touched: boolean;\n /** The control's formatted errors, as JSON Forms computed them. */\n errors: string;\n /** `config` merged with the element's `options`. */\n appliedOptions: Record<string, any>;\n /** Every error in the form, from `core`. */\n coreErrors: ErrorObject[] | undefined;\n path: string;\n schema?: JsonSchema;\n uischema?: ControlElement;\n translate?: Translator;\n translateError?: ErrorTranslator;\n}\n\n/**\n * The filtered message for one control.\n *\n * Returns `errors` unchanged whenever filtering does not apply, so a control\n * that opts out - or one nobody configured - pays nothing and cannot have its\n * text rewritten by a formatting difference.\n */\nexport const filterErrorsBeforeTouch = ({\n touched,\n errors,\n appliedOptions,\n coreErrors,\n path,\n schema,\n uischema,\n translate,\n translateError,\n}: FilterErrorsBeforeTouchInput): string => {\n if (touched || !errors || !appliedOptions.enableFilterErrorsBeforeTouch) {\n return errors;\n }\n\n const filterKeywords = appliedOptions.filterErrorKeywordsBeforeTouch;\n\n if (Array.isArray(filterKeywords) && filterKeywords.length > 0) {\n /*\n Granular filtering needs the keyword, which the formatted `errors` string\n no longer carries - so the structured errors are read back from core and\n narrowed to this control. `getControlPath` is what maps an Ajv\n `instancePath` onto a JSON Forms path, including for `additionalErrors`\n a host published.\n */\n const errorsAtControl = (coreErrors ?? []).filter(\n (error) => path === getControlPath(error),\n );\n\n const errorsToShow = errorsAtControl.filter(\n (error) => !error.keyword || !filterKeywords.includes(error.keyword),\n );\n\n /*\n Nothing matched, so nothing is hidden - and the original string is\n returned rather than a recomposed one. Recomposing would be a no-op in\n the ordinary case and a silent difference wherever the control's own\n props carry more than core's errors do.\n */\n if (errorsToShow.length === errorsAtControl.length) {\n return errors;\n }\n\n if (!translateError) {\n return errors;\n }\n\n return getCombinedErrorMessage(\n errorsToShow,\n translateError,\n translate ?? defaultTranslator,\n schema,\n uischema,\n path,\n );\n }\n\n // \"an absent or empty array suppresses all otherwise displayable control\n // error text before touch\"\n return '';\n};\n\nexport interface PreTouchErrorsProps {\n errors?: string;\n path: string;\n schema?: JsonSchema;\n uischema?: ControlElement;\n config?: any;\n}\n\nexport interface PreTouchErrors {\n /** What the control should print: `errors`, a subset of it, or nothing. */\n errors: string;\n focused: boolean;\n touched: boolean;\n onFocus: () => void;\n onBlur: () => void;\n}\n\n/**\n * `useFocus` plus the touch state the filter needs.\n *\n * Touch is per control and local, as it is in both reference implementations -\n * there is no shared registry, because nothing outside a control needs to know\n * that it was visited.\n *\n * **Touch is blur, not focus.** \"The control becomes touched on blur:\n * receiving focus alone is insufficient, and leaving the control counts even\n * if the user did not change its data.\" It is also one-way: editing the value,\n * clearing it, or its becoming valid again does not untouch the control.\n */\nexport const usePreTouchErrors = (\n props: PreTouchErrorsProps,\n): PreTouchErrors => {\n const [focused, setFocused] = useState(false);\n const [touched, setTouched] = useState(false);\n const ctx = useJsonForms();\n\n const onFocus = useCallback(() => setFocused(true), []);\n const onBlur = useCallback(() => {\n setTouched(true);\n setFocused(false);\n }, []);\n\n const appliedOptions = useMemo(\n () => merge({}, props.config ?? {}, props.uischema?.options ?? {}),\n [props.config, props.uischema],\n );\n\n const errors = filterErrorsBeforeTouch({\n touched,\n errors: props.errors ?? '',\n appliedOptions,\n coreErrors: ctx.core?.errors as ErrorObject[] | undefined,\n path: props.path,\n schema: props.schema,\n uischema: props.uischema,\n translate: ctx.i18n?.translate,\n translateError: ctx.i18n?.translateError,\n });\n\n return { errors, focused, touched, onFocus, onBlur };\n};\n"],"mappings":";;;;;AA8DA,IAAaC,KAA2B,EACtC,YACA,WACA,mBACA,eACA,SACA,WACA,aACA,cACA,wBAC0C;CAC1C,IAAIC,KAAW,CAACC,KAAU,CAACC,EAAe,+BACxC,OAAOD;CAGT,IAAME,IAAiBD,EAAe;CAEtC,IAAI,MAAM,QAAQC,CAAc,KAAKA,EAAe,SAAS,GAAG;EAQ9D,IAAMC,KAAmBC,KAAc,CAAC,EAAA,CAAG,QACxC,MAAUC,MAASC,EAAeC,CAAK,CAC1C,GAEMC,IAAeL,EAAgB,QAClC,MAAU,CAACI,EAAM,WAAW,CAACL,EAAe,SAASK,EAAM,OAAO,CACrE;EAgBA,OARIC,EAAa,WAAWL,EAAgB,UAIxC,CAACM,IACIT,IAGFU,EACLF,GACAC,GACAE,KAAaC,GACbC,GACAC,GACAT,CACF;CACF;CAIA,OAAO;AACT,GA+BaU,KACX,MACmB;;CACnB,IAAM,CAACI,GAASC,KAAcC,EAAS,EAAK,GACtC,CAACtB,GAASuB,KAAcD,EAAS,EAAK,GACtCE,IAAMC,EAAa,GAEnBC,IAAUC,QAAkBN,EAAW,EAAI,GAAG,CAAC,CAAC,GAChDO,IAASD,QAAkB;EAE/B,AADAJ,EAAW,EAAI,GACfF,EAAW,EAAK;CAClB,GAAG,CAAC,CAAC,GAECnB,IAAiB2B,QACf;;EAAM,OAAA/B,EAAA,CAAC,GAAGiC,EAAM,UAAU,CAAC,KAAA,IAAGA,EAAM,aAAA,OAAA,KAAA,IAAAD,EAAU,YAAW,CAAC,CAAC;CACjE,GAAA,CAACC,EAAM,QAAQA,EAAM,QAAQ,CAC/B;CAcA,OAAO;EAAE,QAZMhC,EAAwB;GACrC;GACA,QAAQgC,EAAM,UAAU;GACxB;GACA,aAAA,IAAYP,EAAI,SAAA,OAAA,KAAA,IAAAP,EAAM;GACtB,MAAMc,EAAM;GACZ,QAAQA,EAAM;GACd,UAAUA,EAAM;GAChB,YAAA,IAAWP,EAAI,SAAA,OAAA,KAAA,IAAAN,EAAM;GACrB,iBAAA,IAAgBM,EAAI,SAAA,OAAA,KAAA,IAAAL,EAAM;EAC5B,CAES;EAAQ;EAAS;EAAS;EAAS;CAAO;AACrD"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../dynamic/DynamicUiProvider.cjs.js"),t=require("../layout/groupState.cjs.js");require("../core/configNamespaces.cjs.js");let n=require("react"),r=require("@jsonforms/core"),i=require("@jsonforms/react");var a=e=>(0,r.getControlPath)(e),o=[],s=(...e)=>{let t=new Set;for(let n of e)for(let e of n??o){t.add(``);let n=``;for(let r of a(e).split(`.`))r!==``&&(n=n?`${n}.${r}`:r,t.add(n))}return t},c=new WeakMap,l=(e,t)=>{let n=e??o,r=t??o,i=c.get(n);i||(i=new WeakMap,c.set(n,i));let a=i.get(r);if(a)return a;let l=s(n,r);return i.set(r,l),l},u=e=>[e.validationMode===`ValidateAndShow`||e.validationMode===void 0?e.errors:void 0,e.additionalErrors],d=(e,t,n,r=`showValidationIndicator`)=>{var i,a;let o=e==null||(i=e.options)==null?void 0:i[r];if(o!==void 0)return o===!0;let s=t==null||(a=t.jsonformsExtended)==null?void 0:a[r];return s===void 0?n:s===!0},f=(e,t)=>t.some(t=>e===t||e.startsWith(`${t}.`)||t===``),p=(r,s,c,p)=>{let{core:m}=(0,i.useJsonForms)(),h=e.useDynamicTreeResolver(s)(r),g=d(h,c,p),_=d(h,c,!1,`showValidationIndicatorCount`),[v,y]=m?u(m):[void 0,void 0];return(0,n.useMemo)(()=>{if(!g)return{show:!1,count:0};let e=l(v,y);if(e.size===0)return{show:!1,count:0};let n=t.boundDataPaths(h,s);if(!n.some(t=>e.has(t)))return{show:!1,count:0};if(!_)return{show:!0,count:void 0};let r=[...v??o,...y??o].filter(e=>f(a(e),n)).length;return{show:r>0,count:r}},[g,_,v,y,h,s])};exports.buildErrorIndex=s,exports.displayableErrors=u,exports.errorDataPath=a,exports.resolveIndicatorOption=d,exports.sharedErrorIndex=l,exports.useContainerValidation=p;
|
|
2
|
+
//# sourceMappingURL=validationIndicator.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validationIndicator.cjs.js","names":["getControlPath","useJsonForms","useDynamicTreeResolver","useMemo","boundDataPaths","require_dynamic_DynamicUiProvider","require_layout_groupState","react","_jsonforms_core","_jsonforms_react","errorDataPath","error","EMPTY","buildErrorIndex","errorLists","index","errors","prefix","segment","indexCache","sharedErrorIndex","primary","secondary","additionalErrors","byAdditional","cached","displayableErrors","core","resolveIndicatorOption","_uischema$options","_config$JSONFORMS_EXT","local","uischema","name","namespaced","config","\"jsonformsExtended\"","fallback","belowAny","boundPaths","path","bound","useContainerValidation","effectiveUi","enabled","wantCount","candidate","count"],"sources":["../../src/validation/validationIndicator.ts"],"sourcesContent":["import { useDynamicTreeResolver } from '../dynamic/DynamicUiProvider';\nimport { ErrorObject } from 'ajv';\nimport { UISchemaElement, getControlPath } from '@jsonforms/core';\nimport { useJsonForms } from '@jsonforms/react';\nimport { useMemo } from 'react';\nimport { boundDataPaths } from '../layout/groupState';\nimport { JSONFORMS_EXTENDED_CONFIG_KEY } from '../core/configNamespaces';\n\n/**\n * The dotted data path an error should be attributed to.\n *\n * Delegates to core's `getControlPath`, so the indicator agrees with wherever\n * core puts the message. That matters most for `required`: ajv reports it on\n * the *containing object* (`/contact`, `params.missingProperty: 'phone'`), and\n * core relocates it to `contact.phone`. Matching on the raw `instancePath`\n * makes a required error invisible to every container bound below the object -\n * clearing a field would make its indicator vanish rather than update.\n *\n * `dependencies` and `additionalProperties` are relocated the same way, and\n * `getControlPath` also decodes JSON Pointer escapes.\n */\nexport const errorDataPath = (error: ErrorObject): string =>\n getControlPath(error);\n\nconst EMPTY: ErrorObject[] = [];\n\n/**\n * Every ancestor path of every error, so a container can ask \"is anything below\n * me failing?\" in O(1).\n *\n * An error at `/emergencyContact/phone` contributes `''`, `emergencyContact`\n * and `emergencyContact.phone`. Building costs O(errors x depth) once, against\n * O(containers x errors) for the obvious per-container scan - see Adjustment 5.\n *\n * The segment-boundary rule the specification requires falls out of this:\n * `employees.10.name` never contributes `employees.1`, so a sibling item cannot\n * match. A `startsWith` test is where that bug would otherwise live.\n */\nexport const buildErrorIndex = (\n ...errorLists: (ErrorObject[] | undefined)[]\n): Set<string> => {\n const index = new Set<string>();\n for (const errors of errorLists) {\n for (const error of errors ?? EMPTY) {\n index.add('');\n let prefix = '';\n for (const segment of errorDataPath(error).split('.')) {\n if (segment === '') continue;\n prefix = prefix ? `${prefix}.${segment}` : segment;\n index.add(prefix);\n }\n }\n }\n return index;\n};\n\n/**\n * One index per pair of error arrays, shared by every container.\n *\n * Core replaces these arrays on each validation, so their identity is a sound\n * cache key and stale entries are collected. A `useMemo` per container would\n * instead rebuild the index per container, which is worse than not having one.\n */\nconst indexCache = new WeakMap<\n ErrorObject[],\n WeakMap<ErrorObject[], Set<string>>\n>();\n\nexport const sharedErrorIndex = (\n errors: ErrorObject[] | undefined,\n additionalErrors: ErrorObject[] | undefined,\n): Set<string> => {\n const primary = errors ?? EMPTY;\n const secondary = additionalErrors ?? EMPTY;\n let byAdditional = indexCache.get(primary);\n if (!byAdditional) {\n byAdditional = new WeakMap();\n indexCache.set(primary, byAdditional);\n }\n const cached = byAdditional.get(secondary);\n if (cached) {\n return cached;\n }\n const index = buildErrorIndex(primary, secondary);\n byAdditional.set(secondary, index);\n return index;\n};\n\n/**\n * Errors eligible to feed an indicator under the active validation mode.\n *\n * `ValidateAndHide` hides schema errors from ordinary presentation, and\n * `NoValidation` computes none. Host `additionalErrors` remain available in\n * every mode, so they are never filtered out here.\n */\nexport const displayableErrors = (core: {\n errors?: ErrorObject[];\n additionalErrors?: ErrorObject[];\n validationMode?: string;\n}): [ErrorObject[] | undefined, ErrorObject[] | undefined] => [\n core.validationMode === 'ValidateAndShow' || core.validationMode === undefined\n ? core.errors\n : undefined,\n core.additionalErrors,\n];\n\n/**\n * Resolves a project-extension option: the element's flat `options.<name>`,\n * then `config.jsonformsExtended.<name>`, then the container-type default.\n * Only `undefined` falls through, so an explicit `false` is a real override.\n */\nexport const resolveIndicatorOption = (\n uischema: UISchemaElement | undefined,\n config: Record<string, unknown> | undefined,\n fallback: boolean,\n name = 'showValidationIndicator',\n): boolean => {\n const local = uischema?.options?.[name];\n if (local !== undefined) {\n return local === true;\n }\n const namespaced = (\n config?.[JSONFORMS_EXTENDED_CONFIG_KEY] as\n | Record<string, unknown>\n | undefined\n )?.[name];\n return namespaced === undefined ? fallback : namespaced === true;\n};\n\nexport interface ContainerValidation {\n /** Whether the indicator should be rendered at all. */\n show: boolean;\n /**\n * How many eligible errors sit at or below this container, or `undefined`\n * when `showValidationIndicatorCount` is off and the count was never\n * computed.\n *\n * This counts **validator errors, not controls**. Two Controls bound to the\n * same property share one error object, so an invalid value there counts\n * once - fixing either control fixes both. Counting per control would be\n * both wrong and more work.\n */\n count?: number;\n}\n\nconst belowAny = (path: string, boundPaths: string[]): boolean =>\n boundPaths.some(\n (bound) => path === bound || path.startsWith(`${bound}.`) || bound === '',\n );\n\n/**\n * Whether a scope-less container - a Group, a Category - has failing\n * descendants, and how many.\n *\n * Presence is an O(1) index lookup per bound path. The count needs the error\n * list, so it is computed only for containers that are actually showing an\n * indicator, which is few.\n */\nexport const useContainerValidation = (\n uischema: UISchemaElement,\n path: string,\n config: Record<string, unknown> | undefined,\n fallback: boolean,\n): ContainerValidation => {\n const { core } = useJsonForms();\n const resolveTree = useDynamicTreeResolver(path);\n const effectiveUi = resolveTree(uischema);\n const enabled = resolveIndicatorOption(effectiveUi, config, fallback);\n // Presence is O(1) per bound path; the count needs a pass over the errors.\n // Hosts that only want the marker can skip that pass entirely.\n const wantCount = resolveIndicatorOption(\n effectiveUi,\n config,\n false,\n 'showValidationIndicatorCount',\n );\n const [errors, additionalErrors] = core\n ? displayableErrors(core)\n : [undefined, undefined];\n\n return useMemo(() => {\n if (!enabled) {\n return { show: false, count: 0 };\n }\n const index = sharedErrorIndex(errors, additionalErrors);\n if (index.size === 0) {\n return { show: false, count: 0 };\n }\n const bound = boundDataPaths(effectiveUi, path);\n if (!bound.some((candidate) => index.has(candidate))) {\n return { show: false, count: 0 };\n }\n if (!wantCount) {\n return { show: true, count: undefined };\n }\n const eligible = [...(errors ?? EMPTY), ...(additionalErrors ?? EMPTY)];\n const count = eligible.filter((error) =>\n belowAny(errorDataPath(error), bound),\n ).length;\n return { show: count > 0, count };\n }, [enabled, wantCount, errors, additionalErrors, effectiveUi, path]);\n};\n"],"mappings":"A,gSAqBA,IAAaU,EAAiB,IAAA,EAC5BV,EAAAA,eAAAA,CAAeW,CAAK,EAEhBC,EAAuB,CAAC,EAcjBC,GACX,GAAGC,IACa,CAChB,IAAMC,EAAQ,IAAI,IAClB,IAAK,IAAMC,KAAUF,EACnB,IAAK,IAAMH,KAASK,GAAUJ,EAAO,CACnCG,EAAM,IAAI,EAAE,EACZ,IAAIE,EAAS,GACb,IAAK,IAAMC,KAAWR,EAAcC,CAAK,CAAC,CAAC,MAAM,GAAG,EAC9CO,IAAY,KAChB,EAASD,EAAS,GAAGA,EAAO,GAAGC,IAAYA,EAC3CH,EAAM,IAAIE,CAAM,EAEpB,CAEF,OAAOF,CACT,EASMI,EAAa,IAAI,QAKVC,GACX,EACA,IACgB,CAChB,IAAMC,EAAUL,GAAUJ,EACpBU,EAAYC,GAAoBX,EAClCY,EAAeL,EAAW,IAAIE,CAAO,EACpCG,IACH,EAAe,IAAI,QACnBL,EAAW,IAAIE,EAASG,CAAY,GAEtC,IAAMC,EAASD,EAAa,IAAIF,CAAS,EACzC,GAAIG,EACF,OAAOA,EAET,IAAMV,EAAQF,EAAgBQ,EAASC,CAAS,EAEhD,OADAE,EAAa,IAAIF,EAAWP,CAAK,EAC1BA,CACT,EASaW,EAAqB,GAI4B,CAC5DC,EAAK,iBAAmB,mBAAqBA,EAAK,iBAAmB,IAAA,GACjEA,EAAK,OACL,IAAA,GACJA,EAAK,gBACP,EAOaC,GACX,EACA,EACA,EACA,EAAO,4BACK,C,QACZ,IAAMG,EAAAC,GAAA,OAAA,EAAQA,EAAU,UAAA,KAAA,IAAA,GAAAH,EAAUI,GAClC,GAAIF,IAAU,IAAA,GACZ,OAAOA,IAAU,GAEnB,IAAMG,EAAAC,GAAA,OAAA,EACJA,EAAAC,oBAAA,KAAA,IAAA,GAAAN,EAGEG,GACJ,OAAOC,IAAe,IAAA,GAAYG,EAAWH,IAAe,EAC9D,EAkBMI,GAAY,EAAc,IAC9BC,EAAW,KACR,GAAUC,IAASC,GAASD,EAAK,WAAW,GAAGC,EAAM,EAAE,GAAKA,IAAU,EACzE,EAUWC,GACX,EACA,EACA,EACA,IACwB,CACxB,GAAM,CAAE,SAAA,EAASzC,EAAAA,aAAAA,CAAa,EAExB0C,EADczC,EAAAA,uBAAuBsC,CACvB,CAAA,CAAYR,CAAQ,EAClCY,EAAUhB,EAAuBe,EAAaR,EAAQE,CAAQ,EAG9DQ,EAAYjB,EAChBe,EACAR,EACA,GACA,8BACF,EACM,CAACnB,EAAQO,GAAoBI,EAC/BD,EAAkBC,CAAI,EACtB,CAAC,IAAA,GAAW,IAAA,EAAS,EAEzB,OAAA,EAAOxB,EAAAA,QAAAA,KAAc,CACnB,GAAI,CAACyC,EACH,MAAO,CAAE,KAAM,GAAO,MAAO,CAAE,EAEjC,IAAM7B,EAAQK,EAAiBJ,EAAQO,CAAgB,EACvD,GAAIR,EAAM,OAAS,EACjB,MAAO,CAAE,KAAM,GAAO,MAAO,CAAE,EAEjC,IAAM0B,EAAQrC,EAAAA,eAAeuC,EAAaH,CAAI,EAC9C,GAAI,CAACC,EAAM,KAAM,GAAc1B,EAAM,IAAI+B,CAAS,CAAC,EACjD,MAAO,CAAE,KAAM,GAAO,MAAO,CAAE,EAEjC,GAAI,CAACD,EACH,MAAO,CAAE,KAAM,GAAM,MAAO,IAAA,EAAU,EAGxC,IAAME,EAAQ,CADI,GAAI/B,GAAUJ,EAAQ,GAAIW,GAAoBX,CAClD,CAAA,CAAS,OAAQ,GAC7B0B,EAAS5B,EAAcC,CAAK,EAAG8B,CAAK,CACtC,CAAC,CAAC,OACF,MAAO,CAAE,KAAMM,EAAQ,EAAG,OAAM,CAClC,EAAG,CAACH,EAASC,EAAW7B,EAAQO,EAAkBoB,EAAaH,CAAI,CAAC,CACtE,E"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { ErrorObject } from 'ajv';
|
|
2
|
+
import { UISchemaElement } from '@jsonforms/core';
|
|
3
|
+
/**
|
|
4
|
+
* The dotted data path an error should be attributed to.
|
|
5
|
+
*
|
|
6
|
+
* Delegates to core's `getControlPath`, so the indicator agrees with wherever
|
|
7
|
+
* core puts the message. That matters most for `required`: ajv reports it on
|
|
8
|
+
* the *containing object* (`/contact`, `params.missingProperty: 'phone'`), and
|
|
9
|
+
* core relocates it to `contact.phone`. Matching on the raw `instancePath`
|
|
10
|
+
* makes a required error invisible to every container bound below the object -
|
|
11
|
+
* clearing a field would make its indicator vanish rather than update.
|
|
12
|
+
*
|
|
13
|
+
* `dependencies` and `additionalProperties` are relocated the same way, and
|
|
14
|
+
* `getControlPath` also decodes JSON Pointer escapes.
|
|
15
|
+
*/
|
|
16
|
+
export declare const errorDataPath: (error: ErrorObject) => string;
|
|
17
|
+
/**
|
|
18
|
+
* Every ancestor path of every error, so a container can ask "is anything below
|
|
19
|
+
* me failing?" in O(1).
|
|
20
|
+
*
|
|
21
|
+
* An error at `/emergencyContact/phone` contributes `''`, `emergencyContact`
|
|
22
|
+
* and `emergencyContact.phone`. Building costs O(errors x depth) once, against
|
|
23
|
+
* O(containers x errors) for the obvious per-container scan - see Adjustment 5.
|
|
24
|
+
*
|
|
25
|
+
* The segment-boundary rule the specification requires falls out of this:
|
|
26
|
+
* `employees.10.name` never contributes `employees.1`, so a sibling item cannot
|
|
27
|
+
* match. A `startsWith` test is where that bug would otherwise live.
|
|
28
|
+
*/
|
|
29
|
+
export declare const buildErrorIndex: (...errorLists: (ErrorObject[] | undefined)[]) => Set<string>;
|
|
30
|
+
export declare const sharedErrorIndex: (errors: ErrorObject[] | undefined, additionalErrors: ErrorObject[] | undefined) => Set<string>;
|
|
31
|
+
/**
|
|
32
|
+
* Errors eligible to feed an indicator under the active validation mode.
|
|
33
|
+
*
|
|
34
|
+
* `ValidateAndHide` hides schema errors from ordinary presentation, and
|
|
35
|
+
* `NoValidation` computes none. Host `additionalErrors` remain available in
|
|
36
|
+
* every mode, so they are never filtered out here.
|
|
37
|
+
*/
|
|
38
|
+
export declare const displayableErrors: (core: {
|
|
39
|
+
errors?: ErrorObject[];
|
|
40
|
+
additionalErrors?: ErrorObject[];
|
|
41
|
+
validationMode?: string;
|
|
42
|
+
}) => [ErrorObject[] | undefined, ErrorObject[] | undefined];
|
|
43
|
+
/**
|
|
44
|
+
* Resolves a project-extension option: the element's flat `options.<name>`,
|
|
45
|
+
* then `config.jsonformsExtended.<name>`, then the container-type default.
|
|
46
|
+
* Only `undefined` falls through, so an explicit `false` is a real override.
|
|
47
|
+
*/
|
|
48
|
+
export declare const resolveIndicatorOption: (uischema: UISchemaElement | undefined, config: Record<string, unknown> | undefined, fallback: boolean, name?: string) => boolean;
|
|
49
|
+
export interface ContainerValidation {
|
|
50
|
+
/** Whether the indicator should be rendered at all. */
|
|
51
|
+
show: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* How many eligible errors sit at or below this container, or `undefined`
|
|
54
|
+
* when `showValidationIndicatorCount` is off and the count was never
|
|
55
|
+
* computed.
|
|
56
|
+
*
|
|
57
|
+
* This counts **validator errors, not controls**. Two Controls bound to the
|
|
58
|
+
* same property share one error object, so an invalid value there counts
|
|
59
|
+
* once - fixing either control fixes both. Counting per control would be
|
|
60
|
+
* both wrong and more work.
|
|
61
|
+
*/
|
|
62
|
+
count?: number;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Whether a scope-less container - a Group, a Category - has failing
|
|
66
|
+
* descendants, and how many.
|
|
67
|
+
*
|
|
68
|
+
* Presence is an O(1) index lookup per bound path. The count needs the error
|
|
69
|
+
* list, so it is computed only for containers that are actually showing an
|
|
70
|
+
* indicator, which is few.
|
|
71
|
+
*/
|
|
72
|
+
export declare const useContainerValidation: (uischema: UISchemaElement, path: string, config: Record<string, unknown> | undefined, fallback: boolean) => ContainerValidation;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { useDynamicTreeResolver as e } from "../dynamic/DynamicUiProvider.esm.js";
|
|
2
|
+
import { boundDataPaths as t } from "../layout/groupState.esm.js";
|
|
3
|
+
import "../core/configNamespaces.esm.js";
|
|
4
|
+
import { useMemo as n } from "react";
|
|
5
|
+
import { getControlPath as r } from "@jsonforms/core";
|
|
6
|
+
import { useJsonForms as i } from "@jsonforms/react";
|
|
7
|
+
// src/validation/validationIndicator.ts
|
|
8
|
+
var a = (e) => r(e), o = [], s = (...e) => {
|
|
9
|
+
let t = /* @__PURE__ */ new Set();
|
|
10
|
+
for (let n of e) for (let e of n ?? o) {
|
|
11
|
+
t.add("");
|
|
12
|
+
let n = "";
|
|
13
|
+
for (let r of a(e).split(".")) r !== "" && (n = n ? `${n}.${r}` : r, t.add(n));
|
|
14
|
+
}
|
|
15
|
+
return t;
|
|
16
|
+
}, c = /* @__PURE__ */ new WeakMap(), l = (e, t) => {
|
|
17
|
+
let n = e ?? o, r = t ?? o, i = c.get(n);
|
|
18
|
+
i || (i = /* @__PURE__ */ new WeakMap(), c.set(n, i));
|
|
19
|
+
let a = i.get(r);
|
|
20
|
+
if (a) return a;
|
|
21
|
+
let l = s(n, r);
|
|
22
|
+
return i.set(r, l), l;
|
|
23
|
+
}, u = (e) => [e.validationMode === "ValidateAndShow" || e.validationMode === void 0 ? e.errors : void 0, e.additionalErrors], d = (e, t, n, r = "showValidationIndicator") => {
|
|
24
|
+
var i, a;
|
|
25
|
+
let o = e == null || (i = e.options) == null ? void 0 : i[r];
|
|
26
|
+
if (o !== void 0) return o === !0;
|
|
27
|
+
let s = t == null || (a = t.jsonformsExtended) == null ? void 0 : a[r];
|
|
28
|
+
return s === void 0 ? n : s === !0;
|
|
29
|
+
}, f = (e, t) => t.some((t) => e === t || e.startsWith(`${t}.`) || t === ""), p = (r, s, c, p) => {
|
|
30
|
+
let { core: m } = i(), h = e(s)(r), g = d(h, c, p), _ = d(h, c, !1, "showValidationIndicatorCount"), [v, y] = m ? u(m) : [void 0, void 0];
|
|
31
|
+
return n(() => {
|
|
32
|
+
if (!g) return {
|
|
33
|
+
show: !1,
|
|
34
|
+
count: 0
|
|
35
|
+
};
|
|
36
|
+
let e = l(v, y);
|
|
37
|
+
if (e.size === 0) return {
|
|
38
|
+
show: !1,
|
|
39
|
+
count: 0
|
|
40
|
+
};
|
|
41
|
+
let n = t(h, s);
|
|
42
|
+
if (!n.some((t) => e.has(t))) return {
|
|
43
|
+
show: !1,
|
|
44
|
+
count: 0
|
|
45
|
+
};
|
|
46
|
+
if (!_) return {
|
|
47
|
+
show: !0,
|
|
48
|
+
count: void 0
|
|
49
|
+
};
|
|
50
|
+
let r = [...v ?? o, ...y ?? o].filter((e) => f(a(e), n)).length;
|
|
51
|
+
return {
|
|
52
|
+
show: r > 0,
|
|
53
|
+
count: r
|
|
54
|
+
};
|
|
55
|
+
}, [
|
|
56
|
+
g,
|
|
57
|
+
_,
|
|
58
|
+
v,
|
|
59
|
+
y,
|
|
60
|
+
h,
|
|
61
|
+
s
|
|
62
|
+
]);
|
|
63
|
+
};
|
|
64
|
+
export { s as buildErrorIndex, u as displayableErrors, a as errorDataPath, d as resolveIndicatorOption, l as sharedErrorIndex, p as useContainerValidation };
|
|
65
|
+
|
|
66
|
+
//# sourceMappingURL=validationIndicator.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validationIndicator.esm.js","names":["errorDataPath","getControlPath","error","EMPTY","buildErrorIndex","errorLists","index","errors","prefix","segment","indexCache","sharedErrorIndex","primary","secondary","additionalErrors","byAdditional","cached","displayableErrors","core","resolveIndicatorOption","_uischema$options","_config$JSONFORMS_EXT","local","uischema","name","namespaced","config","\"jsonformsExtended\"","fallback","belowAny","boundPaths","path","bound","useContainerValidation","useJsonForms","effectiveUi","useDynamicTreeResolver","enabled","wantCount","useMemo","boundDataPaths","candidate","count"],"sources":["../../src/validation/validationIndicator.ts"],"sourcesContent":["import { useDynamicTreeResolver } from '../dynamic/DynamicUiProvider';\nimport { ErrorObject } from 'ajv';\nimport { UISchemaElement, getControlPath } from '@jsonforms/core';\nimport { useJsonForms } from '@jsonforms/react';\nimport { useMemo } from 'react';\nimport { boundDataPaths } from '../layout/groupState';\nimport { JSONFORMS_EXTENDED_CONFIG_KEY } from '../core/configNamespaces';\n\n/**\n * The dotted data path an error should be attributed to.\n *\n * Delegates to core's `getControlPath`, so the indicator agrees with wherever\n * core puts the message. That matters most for `required`: ajv reports it on\n * the *containing object* (`/contact`, `params.missingProperty: 'phone'`), and\n * core relocates it to `contact.phone`. Matching on the raw `instancePath`\n * makes a required error invisible to every container bound below the object -\n * clearing a field would make its indicator vanish rather than update.\n *\n * `dependencies` and `additionalProperties` are relocated the same way, and\n * `getControlPath` also decodes JSON Pointer escapes.\n */\nexport const errorDataPath = (error: ErrorObject): string =>\n getControlPath(error);\n\nconst EMPTY: ErrorObject[] = [];\n\n/**\n * Every ancestor path of every error, so a container can ask \"is anything below\n * me failing?\" in O(1).\n *\n * An error at `/emergencyContact/phone` contributes `''`, `emergencyContact`\n * and `emergencyContact.phone`. Building costs O(errors x depth) once, against\n * O(containers x errors) for the obvious per-container scan - see Adjustment 5.\n *\n * The segment-boundary rule the specification requires falls out of this:\n * `employees.10.name` never contributes `employees.1`, so a sibling item cannot\n * match. A `startsWith` test is where that bug would otherwise live.\n */\nexport const buildErrorIndex = (\n ...errorLists: (ErrorObject[] | undefined)[]\n): Set<string> => {\n const index = new Set<string>();\n for (const errors of errorLists) {\n for (const error of errors ?? EMPTY) {\n index.add('');\n let prefix = '';\n for (const segment of errorDataPath(error).split('.')) {\n if (segment === '') continue;\n prefix = prefix ? `${prefix}.${segment}` : segment;\n index.add(prefix);\n }\n }\n }\n return index;\n};\n\n/**\n * One index per pair of error arrays, shared by every container.\n *\n * Core replaces these arrays on each validation, so their identity is a sound\n * cache key and stale entries are collected. A `useMemo` per container would\n * instead rebuild the index per container, which is worse than not having one.\n */\nconst indexCache = new WeakMap<\n ErrorObject[],\n WeakMap<ErrorObject[], Set<string>>\n>();\n\nexport const sharedErrorIndex = (\n errors: ErrorObject[] | undefined,\n additionalErrors: ErrorObject[] | undefined,\n): Set<string> => {\n const primary = errors ?? EMPTY;\n const secondary = additionalErrors ?? EMPTY;\n let byAdditional = indexCache.get(primary);\n if (!byAdditional) {\n byAdditional = new WeakMap();\n indexCache.set(primary, byAdditional);\n }\n const cached = byAdditional.get(secondary);\n if (cached) {\n return cached;\n }\n const index = buildErrorIndex(primary, secondary);\n byAdditional.set(secondary, index);\n return index;\n};\n\n/**\n * Errors eligible to feed an indicator under the active validation mode.\n *\n * `ValidateAndHide` hides schema errors from ordinary presentation, and\n * `NoValidation` computes none. Host `additionalErrors` remain available in\n * every mode, so they are never filtered out here.\n */\nexport const displayableErrors = (core: {\n errors?: ErrorObject[];\n additionalErrors?: ErrorObject[];\n validationMode?: string;\n}): [ErrorObject[] | undefined, ErrorObject[] | undefined] => [\n core.validationMode === 'ValidateAndShow' || core.validationMode === undefined\n ? core.errors\n : undefined,\n core.additionalErrors,\n];\n\n/**\n * Resolves a project-extension option: the element's flat `options.<name>`,\n * then `config.jsonformsExtended.<name>`, then the container-type default.\n * Only `undefined` falls through, so an explicit `false` is a real override.\n */\nexport const resolveIndicatorOption = (\n uischema: UISchemaElement | undefined,\n config: Record<string, unknown> | undefined,\n fallback: boolean,\n name = 'showValidationIndicator',\n): boolean => {\n const local = uischema?.options?.[name];\n if (local !== undefined) {\n return local === true;\n }\n const namespaced = (\n config?.[JSONFORMS_EXTENDED_CONFIG_KEY] as\n | Record<string, unknown>\n | undefined\n )?.[name];\n return namespaced === undefined ? fallback : namespaced === true;\n};\n\nexport interface ContainerValidation {\n /** Whether the indicator should be rendered at all. */\n show: boolean;\n /**\n * How many eligible errors sit at or below this container, or `undefined`\n * when `showValidationIndicatorCount` is off and the count was never\n * computed.\n *\n * This counts **validator errors, not controls**. Two Controls bound to the\n * same property share one error object, so an invalid value there counts\n * once - fixing either control fixes both. Counting per control would be\n * both wrong and more work.\n */\n count?: number;\n}\n\nconst belowAny = (path: string, boundPaths: string[]): boolean =>\n boundPaths.some(\n (bound) => path === bound || path.startsWith(`${bound}.`) || bound === '',\n );\n\n/**\n * Whether a scope-less container - a Group, a Category - has failing\n * descendants, and how many.\n *\n * Presence is an O(1) index lookup per bound path. The count needs the error\n * list, so it is computed only for containers that are actually showing an\n * indicator, which is few.\n */\nexport const useContainerValidation = (\n uischema: UISchemaElement,\n path: string,\n config: Record<string, unknown> | undefined,\n fallback: boolean,\n): ContainerValidation => {\n const { core } = useJsonForms();\n const resolveTree = useDynamicTreeResolver(path);\n const effectiveUi = resolveTree(uischema);\n const enabled = resolveIndicatorOption(effectiveUi, config, fallback);\n // Presence is O(1) per bound path; the count needs a pass over the errors.\n // Hosts that only want the marker can skip that pass entirely.\n const wantCount = resolveIndicatorOption(\n effectiveUi,\n config,\n false,\n 'showValidationIndicatorCount',\n );\n const [errors, additionalErrors] = core\n ? displayableErrors(core)\n : [undefined, undefined];\n\n return useMemo(() => {\n if (!enabled) {\n return { show: false, count: 0 };\n }\n const index = sharedErrorIndex(errors, additionalErrors);\n if (index.size === 0) {\n return { show: false, count: 0 };\n }\n const bound = boundDataPaths(effectiveUi, path);\n if (!bound.some((candidate) => index.has(candidate))) {\n return { show: false, count: 0 };\n }\n if (!wantCount) {\n return { show: true, count: undefined };\n }\n const eligible = [...(errors ?? EMPTY), ...(additionalErrors ?? EMPTY)];\n const count = eligible.filter((error) =>\n belowAny(errorDataPath(error), bound),\n ).length;\n return { show: count > 0, count };\n }, [enabled, wantCount, errors, additionalErrors, effectiveUi, path]);\n};\n"],"mappings":";;;;;;;AAqBA,IAAaA,KAAiB,MAC5BC,EAAeC,CAAK,GAEhBC,IAAuB,CAAC,GAcjBC,KACX,GAAGC,MACa;CAChB,IAAMC,oBAAQ,IAAI,IAAY;CAC9B,KAAK,IAAMC,KAAUF,GACnB,KAAK,IAAMH,KAASK,KAAUJ,GAAO;EACnC,EAAM,IAAI,EAAE;EACZ,IAAIK,IAAS;EACb,KAAK,IAAMC,KAAWT,EAAcE,CAAK,CAAC,CAAC,MAAM,GAAG,GAClD,AAAIO,MAAY,OAChB,IAASD,IAAS,GAAGA,EAAO,GAAGC,MAAYA,GAC3CH,EAAM,IAAIE,CAAM;CAEpB;CAEF,OAAOF;AACT,GASMI,oBAAa,IAAI,QAGrB,GAEWC,KACX,GACA,MACgB;CAChB,IAAMC,IAAUL,KAAUJ,GACpBU,IAAYC,KAAoBX,GAClCY,IAAeL,EAAW,IAAIE,CAAO;CACzC,AAAKG,MACH,oBAAe,IAAI,QAAQ,GAC3BL,EAAW,IAAIE,GAASG,CAAY;CAEtC,IAAMC,IAASD,EAAa,IAAIF,CAAS;CACzC,IAAIG,GACF,OAAOA;CAET,IAAMV,IAAQF,EAAgBQ,GAASC,CAAS;CAEhD,OADAE,EAAa,IAAIF,GAAWP,CAAK,GAC1BA;AACT,GASaW,KAAqB,MAI4B,CAC5DC,EAAK,mBAAmB,qBAAqBA,EAAK,mBAAmB,KAAA,IACjEA,EAAK,SACL,KAAA,GACJA,EAAK,gBACP,GAOaC,KACX,GACA,GACA,GACA,IAAO,8BACK;;CACZ,IAAMG,IAAAC,KAAA,SAAA,IAAQA,EAAU,YAAA,OAAA,KAAA,IAAAH,EAAUI;CAClC,IAAIF,MAAU,KAAA,GACZ,OAAOA,MAAU;CAEnB,IAAMG,IAAAC,KAAA,SAAA,IACJA,EAAAC,sBAAA,OAAA,KAAA,IAAAN,EAGEG;CACJ,OAAOC,MAAe,KAAA,IAAYG,IAAWH,MAAe;AAC9D,GAkBMI,KAAY,GAAc,MAC9BC,EAAW,MACR,MAAUC,MAASC,KAASD,EAAK,WAAW,GAAGC,EAAM,EAAE,KAAKA,MAAU,EACzE,GAUWC,KACX,GACA,GACA,GACA,MACwB;CACxB,IAAM,EAAE,YAASC,EAAa,GAExBC,IADcC,EAAuBL,CACvB,CAAA,CAAYR,CAAQ,GAClCc,IAAUlB,EAAuBgB,GAAaT,GAAQE,CAAQ,GAG9DU,IAAYnB,EAChBgB,GACAT,GACA,IACA,8BACF,GACM,CAACnB,GAAQO,KAAoBI,IAC/BD,EAAkBC,CAAI,IACtB,CAAC,KAAA,GAAW,KAAA,CAAS;CAEzB,OAAOqB,QAAc;EACnB,IAAI,CAACF,GACH,OAAO;GAAE,MAAM;GAAO,OAAO;EAAE;EAEjC,IAAM/B,IAAQK,EAAiBJ,GAAQO,CAAgB;EACvD,IAAIR,EAAM,SAAS,GACjB,OAAO;GAAE,MAAM;GAAO,OAAO;EAAE;EAEjC,IAAM0B,IAAQQ,EAAeL,GAAaJ,CAAI;EAC9C,IAAI,CAACC,EAAM,MAAM,MAAc1B,EAAM,IAAImC,CAAS,CAAC,GACjD,OAAO;GAAE,MAAM;GAAO,OAAO;EAAE;EAEjC,IAAI,CAACH,GACH,OAAO;GAAE,MAAM;GAAM,OAAO,KAAA;EAAU;EAGxC,IAAMI,IAAQ,CADI,GAAInC,KAAUJ,GAAQ,GAAIW,KAAoBX,CAClD,CAAA,CAAS,QAAQ,MAC7B0B,EAAS7B,EAAcE,CAAK,GAAG8B,CAAK,CACtC,CAAC,CAAC;EACF,OAAO;GAAE,MAAMU,IAAQ;GAAG;EAAM;CAClC,GAAG;EAACL;EAASC;EAAW/B;EAAQO;EAAkBqB;EAAaJ;CAAI,CAAC;AACtE"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./input.cjs.js");var t=[`data`,`schema`,`uischema`,`uischemas`,`config`,`external`,`readonly`,`validation-mode`,`locale`,`translations`,`additional-errors`,`dark`,`mode`,`rtl`,`custom-style`,`renderer-settings`],n=class extends HTMLElement{readFormInput(){let t=e.parseJson(this.state.schema),n=e.parseJson(this.state.data);if(t!==void 0||n!=null)return{schema:t,data:n}}attributeChangedCallback(e,t,n){this.setValue(e,n)}set data(e){this.setValue(`data`,e)}set schema(e){this.setValue(`schema`,e)}set uischema(e){this.setValue(`uischema`,e)}set uischemas(e){this.setValue(`uischemas`,e)}set external(e){this.setValue(`external`,e)}get external(){return this.state.external}set config(e){this.setValue(`config`,e)}set readonly(e){this.setValue(`readonly`,e)}set validationMode(e){this.setValue(`validationMode`,e)}set locale(e){this.setValue(`locale`,e)}set translations(e){this.setValue(`translations`,e)}set additionalErrors(e){this.setValue(`additionalErrors`,e)}set dark(e){this.setValue(`dark`,e)}set mode(e){this.setValue(`mode`,e)}set rtl(e){this.setValue(`rtl`,e)}set customStyle(e){this.setValue(`customStyle`,e)}set rendererSettings(e){this.setValue(`rendererSettings`,e)}};exports.FormElement=n,exports.formAttributes=t;
|
|
2
|
+
//# sourceMappingURL=element.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"element.cjs.js","names":["parseJson","require_webcomponent_input","formAttributes","FormElement","schema","data","name","newValue","value"],"sources":["../../src/webcomponent/element.ts"],"sourcesContent":["import type { ValidationMode } from '@jsonforms/core';\nimport { parseJson, type JsonInput } from './input';\n\nexport type FormElementState = {\n external?: JsonInput;\n data?: JsonInput;\n schema?: JsonInput;\n uischema?: JsonInput;\n uischemas?: JsonInput;\n config?: JsonInput;\n readonly?: JsonInput;\n validationMode?: ValidationMode;\n locale?: string;\n translations?: JsonInput;\n additionalErrors?: JsonInput;\n dark?: JsonInput;\n mode?: JsonInput;\n rtl?: JsonInput;\n customStyle?: string;\n rendererSettings?: JsonInput;\n};\n\nexport const formAttributes = [\n 'data',\n 'schema',\n 'uischema',\n 'uischemas',\n 'config',\n 'external',\n 'readonly',\n 'validation-mode',\n 'locale',\n 'translations',\n 'additional-errors',\n 'dark',\n 'mode',\n 'rtl',\n 'custom-style',\n 'renderer-settings',\n];\n\nexport abstract class FormElement extends HTMLElement {\n protected abstract state: FormElementState;\n protected abstract setValue(name: string, value: JsonInput): void;\n protected readFormInput() {\n const schema = parseJson(this.state.schema);\n const data = parseJson(this.state.data);\n if (schema === undefined && data == null) return undefined;\n return { schema, data };\n }\n attributeChangedCallback(name: string, _oldValue: string, newValue: string) {\n this.setValue(name, newValue);\n }\n\n set data(value: JsonInput) {\n this.setValue('data', value);\n }\n set schema(value: JsonInput) {\n this.setValue('schema', value);\n }\n set uischema(value: JsonInput) {\n this.setValue('uischema', value);\n }\n set uischemas(value: JsonInput) {\n this.setValue('uischemas', value);\n }\n /** Host-owned external values; JSON attributes and object properties are supported. */\n set external(value: JsonInput) {\n this.setValue('external', value);\n }\n get external() {\n return this.state.external;\n }\n set config(value: JsonInput) {\n this.setValue('config', value);\n }\n set readonly(value: JsonInput) {\n this.setValue('readonly', value);\n }\n set validationMode(value: ValidationMode) {\n this.setValue('validationMode', value);\n }\n set locale(value: string) {\n this.setValue('locale', value);\n }\n set translations(value: JsonInput) {\n this.setValue('translations', value);\n }\n set additionalErrors(value: JsonInput) {\n this.setValue('additionalErrors', value);\n }\n set dark(value: JsonInput) {\n this.setValue('dark', value);\n }\n set mode(value: JsonInput) {\n this.setValue('mode', value);\n }\n set rtl(value: JsonInput) {\n this.setValue('rtl', value);\n }\n set customStyle(value: string) {\n this.setValue('customStyle', value);\n }\n set rendererSettings(value: JsonInput) {\n this.setValue('rendererSettings', value);\n }\n}\n"],"mappings":"A,qGAsBA,IAAaE,EAAiB,CAC5B,OACA,SACA,WACA,YACA,SACA,WACA,WACA,kBACA,SACA,eACA,oBACA,OACA,OACA,MACA,eACA,mBACF,EAEsBC,EAAtB,cAA0C,WAAY,CAGpD,eAA0B,CACxB,IAAMC,EAASJ,EAAAA,UAAU,KAAK,MAAM,MAAM,EACpCK,EAAOL,EAAAA,UAAU,KAAK,MAAM,IAAI,EACtC,GAAII,IAAW,IAAA,IAAaC,GAAQ,KACpC,MAAO,CAAE,SAAQ,MAAK,CACxB,CACA,yBAAyB,EAAc,EAAmB,EAAkB,CAC1E,KAAK,SAASC,EAAMC,CAAQ,CAC9B,CAEA,IAAI,KAAK,EAAkB,CACzB,KAAK,SAAS,OAAQC,CAAK,CAC7B,CACA,IAAI,OAAO,EAAkB,CAC3B,KAAK,SAAS,SAAUA,CAAK,CAC/B,CACA,IAAI,SAAS,EAAkB,CAC7B,KAAK,SAAS,WAAYA,CAAK,CACjC,CACA,IAAI,UAAU,EAAkB,CAC9B,KAAK,SAAS,YAAaA,CAAK,CAClC,CAEA,IAAI,SAAS,EAAkB,CAC7B,KAAK,SAAS,WAAYA,CAAK,CACjC,CACA,IAAI,UAAW,CACb,OAAO,KAAK,MAAM,QACpB,CACA,IAAI,OAAO,EAAkB,CAC3B,KAAK,SAAS,SAAUA,CAAK,CAC/B,CACA,IAAI,SAAS,EAAkB,CAC7B,KAAK,SAAS,WAAYA,CAAK,CACjC,CACA,IAAI,eAAe,EAAuB,CACxC,KAAK,SAAS,iBAAkBA,CAAK,CACvC,CACA,IAAI,OAAO,EAAe,CACxB,KAAK,SAAS,SAAUA,CAAK,CAC/B,CACA,IAAI,aAAa,EAAkB,CACjC,KAAK,SAAS,eAAgBA,CAAK,CACrC,CACA,IAAI,iBAAiB,EAAkB,CACrC,KAAK,SAAS,mBAAoBA,CAAK,CACzC,CACA,IAAI,KAAK,EAAkB,CACzB,KAAK,SAAS,OAAQA,CAAK,CAC7B,CACA,IAAI,KAAK,EAAkB,CACzB,KAAK,SAAS,OAAQA,CAAK,CAC7B,CACA,IAAI,IAAI,EAAkB,CACxB,KAAK,SAAS,MAAOA,CAAK,CAC5B,CACA,IAAI,YAAY,EAAe,CAC7B,KAAK,SAAS,cAAeA,CAAK,CACpC,CACA,IAAI,iBAAiB,EAAkB,CACrC,KAAK,SAAS,mBAAoBA,CAAK,CACzC,CACF,E"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { ValidationMode } from '@jsonforms/core';
|
|
2
|
+
import { type JsonInput } from './input';
|
|
3
|
+
export type FormElementState = {
|
|
4
|
+
external?: JsonInput;
|
|
5
|
+
data?: JsonInput;
|
|
6
|
+
schema?: JsonInput;
|
|
7
|
+
uischema?: JsonInput;
|
|
8
|
+
uischemas?: JsonInput;
|
|
9
|
+
config?: JsonInput;
|
|
10
|
+
readonly?: JsonInput;
|
|
11
|
+
validationMode?: ValidationMode;
|
|
12
|
+
locale?: string;
|
|
13
|
+
translations?: JsonInput;
|
|
14
|
+
additionalErrors?: JsonInput;
|
|
15
|
+
dark?: JsonInput;
|
|
16
|
+
mode?: JsonInput;
|
|
17
|
+
rtl?: JsonInput;
|
|
18
|
+
customStyle?: string;
|
|
19
|
+
rendererSettings?: JsonInput;
|
|
20
|
+
};
|
|
21
|
+
export declare const formAttributes: string[];
|
|
22
|
+
export declare abstract class FormElement extends HTMLElement {
|
|
23
|
+
protected abstract state: FormElementState;
|
|
24
|
+
protected abstract setValue(name: string, value: JsonInput): void;
|
|
25
|
+
protected readFormInput(): {
|
|
26
|
+
schema: any;
|
|
27
|
+
data: any;
|
|
28
|
+
} | undefined;
|
|
29
|
+
attributeChangedCallback(name: string, _oldValue: string, newValue: string): void;
|
|
30
|
+
set data(value: JsonInput);
|
|
31
|
+
set schema(value: JsonInput);
|
|
32
|
+
set uischema(value: JsonInput);
|
|
33
|
+
set uischemas(value: JsonInput);
|
|
34
|
+
/** Host-owned external values; JSON attributes and object properties are supported. */
|
|
35
|
+
set external(value: JsonInput);
|
|
36
|
+
get external(): JsonInput;
|
|
37
|
+
set config(value: JsonInput);
|
|
38
|
+
set readonly(value: JsonInput);
|
|
39
|
+
set validationMode(value: ValidationMode);
|
|
40
|
+
set locale(value: string);
|
|
41
|
+
set translations(value: JsonInput);
|
|
42
|
+
set additionalErrors(value: JsonInput);
|
|
43
|
+
set dark(value: JsonInput);
|
|
44
|
+
set mode(value: JsonInput);
|
|
45
|
+
set rtl(value: JsonInput);
|
|
46
|
+
set customStyle(value: string);
|
|
47
|
+
set rendererSettings(value: JsonInput);
|
|
48
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { parseJson as e } from "./input.esm.js";
|
|
2
|
+
// src/webcomponent/element.ts
|
|
3
|
+
var t = [
|
|
4
|
+
"data",
|
|
5
|
+
"schema",
|
|
6
|
+
"uischema",
|
|
7
|
+
"uischemas",
|
|
8
|
+
"config",
|
|
9
|
+
"external",
|
|
10
|
+
"readonly",
|
|
11
|
+
"validation-mode",
|
|
12
|
+
"locale",
|
|
13
|
+
"translations",
|
|
14
|
+
"additional-errors",
|
|
15
|
+
"dark",
|
|
16
|
+
"mode",
|
|
17
|
+
"rtl",
|
|
18
|
+
"custom-style",
|
|
19
|
+
"renderer-settings"
|
|
20
|
+
], n = class extends HTMLElement {
|
|
21
|
+
readFormInput() {
|
|
22
|
+
let t = e(this.state.schema), n = e(this.state.data);
|
|
23
|
+
if (t !== void 0 || n != null) return {
|
|
24
|
+
schema: t,
|
|
25
|
+
data: n
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
attributeChangedCallback(e, t, n) {
|
|
29
|
+
this.setValue(e, n);
|
|
30
|
+
}
|
|
31
|
+
set data(e) {
|
|
32
|
+
this.setValue("data", e);
|
|
33
|
+
}
|
|
34
|
+
set schema(e) {
|
|
35
|
+
this.setValue("schema", e);
|
|
36
|
+
}
|
|
37
|
+
set uischema(e) {
|
|
38
|
+
this.setValue("uischema", e);
|
|
39
|
+
}
|
|
40
|
+
set uischemas(e) {
|
|
41
|
+
this.setValue("uischemas", e);
|
|
42
|
+
}
|
|
43
|
+
set external(e) {
|
|
44
|
+
this.setValue("external", e);
|
|
45
|
+
}
|
|
46
|
+
get external() {
|
|
47
|
+
return this.state.external;
|
|
48
|
+
}
|
|
49
|
+
set config(e) {
|
|
50
|
+
this.setValue("config", e);
|
|
51
|
+
}
|
|
52
|
+
set readonly(e) {
|
|
53
|
+
this.setValue("readonly", e);
|
|
54
|
+
}
|
|
55
|
+
set validationMode(e) {
|
|
56
|
+
this.setValue("validationMode", e);
|
|
57
|
+
}
|
|
58
|
+
set locale(e) {
|
|
59
|
+
this.setValue("locale", e);
|
|
60
|
+
}
|
|
61
|
+
set translations(e) {
|
|
62
|
+
this.setValue("translations", e);
|
|
63
|
+
}
|
|
64
|
+
set additionalErrors(e) {
|
|
65
|
+
this.setValue("additionalErrors", e);
|
|
66
|
+
}
|
|
67
|
+
set dark(e) {
|
|
68
|
+
this.setValue("dark", e);
|
|
69
|
+
}
|
|
70
|
+
set mode(e) {
|
|
71
|
+
this.setValue("mode", e);
|
|
72
|
+
}
|
|
73
|
+
set rtl(e) {
|
|
74
|
+
this.setValue("rtl", e);
|
|
75
|
+
}
|
|
76
|
+
set customStyle(e) {
|
|
77
|
+
this.setValue("customStyle", e);
|
|
78
|
+
}
|
|
79
|
+
set rendererSettings(e) {
|
|
80
|
+
this.setValue("rendererSettings", e);
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
export { n as FormElement, t as formAttributes };
|
|
84
|
+
|
|
85
|
+
//# sourceMappingURL=element.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"element.esm.js","names":["formAttributes","FormElement","schema","parseJson","data","name","newValue","value"],"sources":["../../src/webcomponent/element.ts"],"sourcesContent":["import type { ValidationMode } from '@jsonforms/core';\nimport { parseJson, type JsonInput } from './input';\n\nexport type FormElementState = {\n external?: JsonInput;\n data?: JsonInput;\n schema?: JsonInput;\n uischema?: JsonInput;\n uischemas?: JsonInput;\n config?: JsonInput;\n readonly?: JsonInput;\n validationMode?: ValidationMode;\n locale?: string;\n translations?: JsonInput;\n additionalErrors?: JsonInput;\n dark?: JsonInput;\n mode?: JsonInput;\n rtl?: JsonInput;\n customStyle?: string;\n rendererSettings?: JsonInput;\n};\n\nexport const formAttributes = [\n 'data',\n 'schema',\n 'uischema',\n 'uischemas',\n 'config',\n 'external',\n 'readonly',\n 'validation-mode',\n 'locale',\n 'translations',\n 'additional-errors',\n 'dark',\n 'mode',\n 'rtl',\n 'custom-style',\n 'renderer-settings',\n];\n\nexport abstract class FormElement extends HTMLElement {\n protected abstract state: FormElementState;\n protected abstract setValue(name: string, value: JsonInput): void;\n protected readFormInput() {\n const schema = parseJson(this.state.schema);\n const data = parseJson(this.state.data);\n if (schema === undefined && data == null) return undefined;\n return { schema, data };\n }\n attributeChangedCallback(name: string, _oldValue: string, newValue: string) {\n this.setValue(name, newValue);\n }\n\n set data(value: JsonInput) {\n this.setValue('data', value);\n }\n set schema(value: JsonInput) {\n this.setValue('schema', value);\n }\n set uischema(value: JsonInput) {\n this.setValue('uischema', value);\n }\n set uischemas(value: JsonInput) {\n this.setValue('uischemas', value);\n }\n /** Host-owned external values; JSON attributes and object properties are supported. */\n set external(value: JsonInput) {\n this.setValue('external', value);\n }\n get external() {\n return this.state.external;\n }\n set config(value: JsonInput) {\n this.setValue('config', value);\n }\n set readonly(value: JsonInput) {\n this.setValue('readonly', value);\n }\n set validationMode(value: ValidationMode) {\n this.setValue('validationMode', value);\n }\n set locale(value: string) {\n this.setValue('locale', value);\n }\n set translations(value: JsonInput) {\n this.setValue('translations', value);\n }\n set additionalErrors(value: JsonInput) {\n this.setValue('additionalErrors', value);\n }\n set dark(value: JsonInput) {\n this.setValue('dark', value);\n }\n set mode(value: JsonInput) {\n this.setValue('mode', value);\n }\n set rtl(value: JsonInput) {\n this.setValue('rtl', value);\n }\n set customStyle(value: string) {\n this.setValue('customStyle', value);\n }\n set rendererSettings(value: JsonInput) {\n this.setValue('rendererSettings', value);\n }\n}\n"],"mappings":";;AAsBA,IAAaA,IAAiB;CAC5B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,GAEsBC,IAAtB,cAA0C,YAAY;CAGpD,gBAA0B;EACxB,IAAMC,IAASC,EAAU,KAAK,MAAM,MAAM,GACpCC,IAAOD,EAAU,KAAK,MAAM,IAAI;EACtC,IAAID,MAAW,KAAA,KAAaE,KAAQ,MACpC,OAAO;GAAE;GAAQ;EAAK;CACxB;CACA,yBAAyB,GAAc,GAAmB,GAAkB;EAC1E,KAAK,SAASC,GAAMC,CAAQ;CAC9B;CAEA,IAAI,KAAK,GAAkB;EACzB,KAAK,SAAS,QAAQC,CAAK;CAC7B;CACA,IAAI,OAAO,GAAkB;EAC3B,KAAK,SAAS,UAAUA,CAAK;CAC/B;CACA,IAAI,SAAS,GAAkB;EAC7B,KAAK,SAAS,YAAYA,CAAK;CACjC;CACA,IAAI,UAAU,GAAkB;EAC9B,KAAK,SAAS,aAAaA,CAAK;CAClC;CAEA,IAAI,SAAS,GAAkB;EAC7B,KAAK,SAAS,YAAYA,CAAK;CACjC;CACA,IAAI,WAAW;EACb,OAAO,KAAK,MAAM;CACpB;CACA,IAAI,OAAO,GAAkB;EAC3B,KAAK,SAAS,UAAUA,CAAK;CAC/B;CACA,IAAI,SAAS,GAAkB;EAC7B,KAAK,SAAS,YAAYA,CAAK;CACjC;CACA,IAAI,eAAe,GAAuB;EACxC,KAAK,SAAS,kBAAkBA,CAAK;CACvC;CACA,IAAI,OAAO,GAAe;EACxB,KAAK,SAAS,UAAUA,CAAK;CAC/B;CACA,IAAI,aAAa,GAAkB;EACjC,KAAK,SAAS,gBAAgBA,CAAK;CACrC;CACA,IAAI,iBAAiB,GAAkB;EACrC,KAAK,SAAS,oBAAoBA,CAAK;CACzC;CACA,IAAI,KAAK,GAAkB;EACzB,KAAK,SAAS,QAAQA,CAAK;CAC7B;CACA,IAAI,KAAK,GAAkB;EACzB,KAAK,SAAS,QAAQA,CAAK;CAC7B;CACA,IAAI,IAAI,GAAkB;EACxB,KAAK,SAAS,OAAOA,CAAK;CAC5B;CACA,IAAI,YAAY,GAAe;EAC7B,KAAK,SAAS,eAAeA,CAAK;CACpC;CACA,IAAI,iBAAiB,GAAkB;EACrC,KAAK,SAAS,oBAAoBA,CAAK;CACzC;AACF"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=e=>{if(typeof e!=`string`)return e;if(e.trim()!==``)return JSON.parse(e)},t=e=>{if(typeof e==`boolean`)return e;if(typeof e==`string`){if(e===``||e.toLowerCase()===`true`)return!0;if(e.toLowerCase()===`false`)return!1}},n=e=>e===`dark`||e===`light`||e===`system`?e:`system`,r=(t,n=`en`)=>{if(typeof t==`function`)return t;let r=e(t),i=(e,t)=>typeof e==`object`&&e&&Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0,a=(e,t)=>{let n=i(e,t);if(typeof n==`string`)return n;let r=t.split(`.`).reduce((e,t)=>i(e,t),e);if(typeof r==`string`)return r;let a=i(n,`label`);return typeof a==`string`?a:void 0},o=n.toLowerCase().replaceAll(`_`,`-`);return(e,t)=>a(i(r,n),e)??a(i(r,o),e)??a(i(r,o.split(`-`)[0]),e)??a(r,e)??t??e};exports.createTranslator=r,exports.parseBoolean=t,exports.parseJson=e,exports.parseMode=n;
|
|
2
|
+
//# sourceMappingURL=input.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input.cjs.js","names":["parseJson","value","parseBoolean","parseMode","createTranslator","translations","dictionary","own","object","key","lookup","exact","catalog","id","nested","part","label","normalized","locale","defaultMessage"],"sources":["../../src/webcomponent/input.ts"],"sourcesContent":["import type { Translator } from '@jsonforms/core';\n\nexport type JsonInput = unknown;\n\nexport const parseJson = (value: JsonInput) => {\n if (typeof value !== 'string') return value;\n if (value.trim() === '') return undefined;\n return JSON.parse(value);\n};\n\nexport const parseBoolean = (value: JsonInput) => {\n if (typeof value === 'boolean') return value;\n if (typeof value === 'string') {\n if (value === '' || value.toLowerCase() === 'true') return true;\n if (value.toLowerCase() === 'false') return false;\n }\n return undefined;\n};\n\nexport const parseMode = (value: JsonInput) =>\n value === 'dark' || value === 'light' || value === 'system'\n ? value\n : 'system';\n\nexport const createTranslator = (\n translations: JsonInput,\n locale = 'en',\n): Translator => {\n if (typeof translations === 'function') return translations as Translator;\n const dictionary = parseJson(translations) as any;\n const own = (object: unknown, key: string): unknown =>\n object !== null &&\n typeof object === 'object' &&\n Object.prototype.hasOwnProperty.call(object, key)\n ? (object as Record<string, unknown>)[key]\n : undefined;\n const lookup = (catalog: unknown, id: string): string | undefined => {\n const exact = own(catalog, id);\n if (typeof exact === 'string') return exact;\n const nested = id\n .split('.')\n .reduce<unknown>((value, part) => own(value, part), catalog);\n if (typeof nested === 'string') return nested;\n // Compatibility with the wrapper's existing { key: { label: text } } catalogs.\n const label = own(exact, 'label');\n return typeof label === 'string' ? label : undefined;\n };\n const normalized = locale.toLowerCase().replaceAll('_', '-');\n return (id: string, defaultMessage: string | undefined) =>\n lookup(own(dictionary, locale), id) ??\n lookup(own(dictionary, normalized), id) ??\n lookup(own(dictionary, normalized.split('-')[0]), id) ??\n lookup(dictionary, id) ??\n defaultMessage ??\n id;\n};\n"],"mappings":"A,mEAIA,IAAaA,EAAa,GAAqB,CAC7C,GAAI,OAAOC,GAAU,SAAU,OAAOA,EACtC,GAAIA,EAAM,KAAK,IAAM,GACrB,OAAO,KAAK,MAAMA,CAAK,CACzB,EAEaC,EAAgB,GAAqB,CAChD,GAAI,OAAOD,GAAU,UAAW,OAAOA,EACvC,GAAI,OAAOA,GAAU,SAAU,CAC7B,GAAIA,IAAU,IAAMA,EAAM,YAAY,IAAM,OAAQ,MAAO,GAC3D,GAAIA,EAAM,YAAY,IAAM,QAAS,MAAO,EAC9C,CAEF,EAEaE,EAAa,GACxBF,IAAU,QAAUA,IAAU,SAAWA,IAAU,SAC/CA,EACA,SAEOG,GACX,EACA,EAAS,OACM,CACf,GAAI,OAAOC,GAAiB,WAAY,OAAOA,EAC/C,IAAMC,EAAaN,EAAUK,CAAY,EACnCE,GAAO,EAAiB,IAE5B,OAAOC,GAAW,UADlBA,GAEA,OAAO,UAAU,eAAe,KAAKA,EAAQC,CAAG,EAC3CD,EAAmCC,GACpC,IAAA,GACAC,GAAU,EAAkB,IAAmC,CACnE,IAAMC,EAAQJ,EAAIK,EAASC,CAAE,EAC7B,GAAI,OAAOF,GAAU,SAAU,OAAOA,EACtC,IAAMG,EAASD,EACZ,MAAM,GAAG,CAAC,CACV,QAAiB,EAAO,IAASN,EAAIN,EAAOc,CAAI,EAAGH,CAAO,EAC7D,GAAI,OAAOE,GAAW,SAAU,OAAOA,EAEvC,IAAME,EAAQT,EAAII,EAAO,OAAO,EAChC,OAAO,OAAOK,GAAU,SAAWA,EAAQ,IAAA,EAC7C,EACMC,EAAaC,EAAO,YAAY,CAAC,CAAC,WAAW,IAAK,GAAG,EAC3D,OAAQ,EAAY,IAClBR,EAAOH,EAAID,EAAYY,CAAM,EAAGL,CAAE,GAClCH,EAAOH,EAAID,EAAYW,CAAU,EAAGJ,CAAE,GACtCH,EAAOH,EAAID,EAAYW,EAAW,MAAM,GAAG,CAAC,CAAC,EAAE,EAAGJ,CAAE,GACpDH,EAAOJ,EAAYO,CAAE,GACrBM,GACAN,CACJ,E"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Translator } from '@jsonforms/core';
|
|
2
|
+
export type JsonInput = unknown;
|
|
3
|
+
export declare const parseJson: (value: JsonInput) => any;
|
|
4
|
+
export declare const parseBoolean: (value: JsonInput) => boolean | undefined;
|
|
5
|
+
export declare const parseMode: (value: JsonInput) => "dark" | "light" | "system";
|
|
6
|
+
export declare const createTranslator: (translations: JsonInput, locale?: string) => Translator;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// src/webcomponent/input.ts
|
|
2
|
+
var e = (e) => {
|
|
3
|
+
if (typeof e != "string") return e;
|
|
4
|
+
if (e.trim() !== "") return JSON.parse(e);
|
|
5
|
+
}, t = (e) => {
|
|
6
|
+
if (typeof e == "boolean") return e;
|
|
7
|
+
if (typeof e == "string") {
|
|
8
|
+
if (e === "" || e.toLowerCase() === "true") return !0;
|
|
9
|
+
if (e.toLowerCase() === "false") return !1;
|
|
10
|
+
}
|
|
11
|
+
}, n = (e) => e === "dark" || e === "light" || e === "system" ? e : "system", r = (t, n = "en") => {
|
|
12
|
+
if (typeof t == "function") return t;
|
|
13
|
+
let r = e(t), i = (e, t) => typeof e == "object" && e && Object.prototype.hasOwnProperty.call(e, t) ? e[t] : void 0, a = (e, t) => {
|
|
14
|
+
let n = i(e, t);
|
|
15
|
+
if (typeof n == "string") return n;
|
|
16
|
+
let r = t.split(".").reduce((e, t) => i(e, t), e);
|
|
17
|
+
if (typeof r == "string") return r;
|
|
18
|
+
let a = i(n, "label");
|
|
19
|
+
return typeof a == "string" ? a : void 0;
|
|
20
|
+
}, o = n.toLowerCase().replaceAll("_", "-");
|
|
21
|
+
return (e, t) => a(i(r, n), e) ?? a(i(r, o), e) ?? a(i(r, o.split("-")[0]), e) ?? a(r, e) ?? t ?? e;
|
|
22
|
+
};
|
|
23
|
+
export { r as createTranslator, t as parseBoolean, e as parseJson, n as parseMode };
|
|
24
|
+
|
|
25
|
+
//# sourceMappingURL=input.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input.esm.js","names":["parseJson","value","parseBoolean","parseMode","createTranslator","translations","dictionary","own","object","key","lookup","exact","catalog","id","nested","part","label","normalized","locale","defaultMessage"],"sources":["../../src/webcomponent/input.ts"],"sourcesContent":["import type { Translator } from '@jsonforms/core';\n\nexport type JsonInput = unknown;\n\nexport const parseJson = (value: JsonInput) => {\n if (typeof value !== 'string') return value;\n if (value.trim() === '') return undefined;\n return JSON.parse(value);\n};\n\nexport const parseBoolean = (value: JsonInput) => {\n if (typeof value === 'boolean') return value;\n if (typeof value === 'string') {\n if (value === '' || value.toLowerCase() === 'true') return true;\n if (value.toLowerCase() === 'false') return false;\n }\n return undefined;\n};\n\nexport const parseMode = (value: JsonInput) =>\n value === 'dark' || value === 'light' || value === 'system'\n ? value\n : 'system';\n\nexport const createTranslator = (\n translations: JsonInput,\n locale = 'en',\n): Translator => {\n if (typeof translations === 'function') return translations as Translator;\n const dictionary = parseJson(translations) as any;\n const own = (object: unknown, key: string): unknown =>\n object !== null &&\n typeof object === 'object' &&\n Object.prototype.hasOwnProperty.call(object, key)\n ? (object as Record<string, unknown>)[key]\n : undefined;\n const lookup = (catalog: unknown, id: string): string | undefined => {\n const exact = own(catalog, id);\n if (typeof exact === 'string') return exact;\n const nested = id\n .split('.')\n .reduce<unknown>((value, part) => own(value, part), catalog);\n if (typeof nested === 'string') return nested;\n // Compatibility with the wrapper's existing { key: { label: text } } catalogs.\n const label = own(exact, 'label');\n return typeof label === 'string' ? label : undefined;\n };\n const normalized = locale.toLowerCase().replaceAll('_', '-');\n return (id: string, defaultMessage: string | undefined) =>\n lookup(own(dictionary, locale), id) ??\n lookup(own(dictionary, normalized), id) ??\n lookup(own(dictionary, normalized.split('-')[0]), id) ??\n lookup(dictionary, id) ??\n defaultMessage ??\n id;\n};\n"],"mappings":";AAIA,IAAaA,KAAa,MAAqB;CAC7C,IAAI,OAAOC,KAAU,UAAU,OAAOA;CACtC,IAAIA,EAAM,KAAK,MAAM,IACrB,OAAO,KAAK,MAAMA,CAAK;AACzB,GAEaC,KAAgB,MAAqB;CAChD,IAAI,OAAOD,KAAU,WAAW,OAAOA;CACvC,IAAI,OAAOA,KAAU,UAAU;EAC7B,IAAIA,MAAU,MAAMA,EAAM,YAAY,MAAM,QAAQ,OAAO;EAC3D,IAAIA,EAAM,YAAY,MAAM,SAAS,OAAO;CAC9C;AAEF,GAEaE,KAAa,MACxBF,MAAU,UAAUA,MAAU,WAAWA,MAAU,WAC/CA,IACA,UAEOG,KACX,GACA,IAAS,SACM;CACf,IAAI,OAAOC,KAAiB,YAAY,OAAOA;CAC/C,IAAMC,IAAaN,EAAUK,CAAY,GACnCE,KAAO,GAAiB,MAE5B,OAAOC,KAAW,YADlBA,KAEA,OAAO,UAAU,eAAe,KAAKA,GAAQC,CAAG,IAC3CD,EAAmCC,KACpC,KAAA,GACAC,KAAU,GAAkB,MAAmC;EACnE,IAAMC,IAAQJ,EAAIK,GAASC,CAAE;EAC7B,IAAI,OAAOF,KAAU,UAAU,OAAOA;EACtC,IAAMG,IAASD,EACZ,MAAM,GAAG,CAAC,CACV,QAAiB,GAAO,MAASN,EAAIN,GAAOc,CAAI,GAAGH,CAAO;EAC7D,IAAI,OAAOE,KAAW,UAAU,OAAOA;EAEvC,IAAME,IAAQT,EAAII,GAAO,OAAO;EAChC,OAAO,OAAOK,KAAU,WAAWA,IAAQ,KAAA;CAC7C,GACMC,IAAaC,EAAO,YAAY,CAAC,CAAC,WAAW,KAAK,GAAG;CAC3D,QAAQ,GAAY,MAClBR,EAAOH,EAAID,GAAYY,CAAM,GAAGL,CAAE,KAClCH,EAAOH,EAAID,GAAYW,CAAU,GAAGJ,CAAE,KACtCH,EAAOH,EAAID,GAAYW,EAAW,MAAM,GAAG,CAAC,CAAC,EAAE,GAAGJ,CAAE,KACpDH,EAAOJ,GAAYO,CAAE,KACrBM,KACAN;AACJ"}
|