@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,32 @@
|
|
|
1
|
+
import { Tester, UISchemaElement } from '@jsonforms/core';
|
|
2
|
+
/**
|
|
3
|
+
* A mask pattern as the UI model may serialize it: one pattern, or a set of
|
|
4
|
+
* alternatives the masking engine picks between by length.
|
|
5
|
+
*
|
|
6
|
+
* A function-valued mask is deliberately not part of this type. The
|
|
7
|
+
* specification is explicit that "function-valued masking-library options are
|
|
8
|
+
* not portable serialized UI-model features", and a UI schema is JSON.
|
|
9
|
+
*/
|
|
10
|
+
export type MaskPattern = string | string[];
|
|
11
|
+
/**
|
|
12
|
+
* Whether `options.mask` carries an actual pattern.
|
|
13
|
+
*
|
|
14
|
+
* This is the whole of the fix for the selection defect the Svelte review
|
|
15
|
+
* recorded. Those families select with `hasOption('mask')`, which tests
|
|
16
|
+
* *presence*: the temporal controls take a **boolean** `mask` that turns their
|
|
17
|
+
* format-derived mask off, so `"mask": false` - an author asking for less
|
|
18
|
+
* masking - made the field eligible for the generic masked renderer instead.
|
|
19
|
+
* The specification names the case directly: "a boolean temporal option must
|
|
20
|
+
* not by itself request a generic masked field."
|
|
21
|
+
*
|
|
22
|
+
* Requiring a non-empty string (or a non-empty array of them) excludes `false`,
|
|
23
|
+
* `true`, `""`, `[]` and a function in one predicate.
|
|
24
|
+
*/
|
|
25
|
+
export declare const isMaskPattern: (value: unknown) => value is MaskPattern;
|
|
26
|
+
export declare const hasMaskPattern: Tester;
|
|
27
|
+
/**
|
|
28
|
+
* Rank 4, above the plain text control at 1 and the color and duration
|
|
29
|
+
* controls at 3, and never in a tie with the temporal controls at 4 because
|
|
30
|
+
* {@link hasSpecializedFormat} excludes every schema they match.
|
|
31
|
+
*/
|
|
32
|
+
export declare const extendedMaskTester: (uischema: UISchemaElement, schema: import("@jsonforms/core").JsonSchema, context: import("@jsonforms/core").TesterContext) => number;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { and as e, formatIs as t, isStringControl as n, not as r, optionIs as i, or as a, rankWith as o } from "@jsonforms/core";
|
|
2
|
+
// src/formats/maskControls.ts
|
|
3
|
+
var s = (e) => typeof e == "string" ? e.length > 0 : Array.isArray(e) && e.length > 0 && e.every((e) => typeof e == "string" && e.length > 0), c = (e) => {
|
|
4
|
+
var t;
|
|
5
|
+
return s((t = e.options) == null ? void 0 : t.mask);
|
|
6
|
+
}, l = a(...[
|
|
7
|
+
"color",
|
|
8
|
+
"date",
|
|
9
|
+
"date-time",
|
|
10
|
+
"duration",
|
|
11
|
+
"password",
|
|
12
|
+
"time"
|
|
13
|
+
].flatMap((e) => [t(e), i("format", e)])), u = o(4, e(n, c, r(l)));
|
|
14
|
+
export { u as extendedMaskTester, c as hasMaskPattern, s as isMaskPattern };
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=maskControls.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"maskControls.esm.js","names":["isMaskPattern","value","entry","hasMaskPattern","_uischema$options","uischema","hasSpecializedFormat","or","formatIs","format","optionIs","extendedMaskTester","rankWith","and","isStringControl","not"],"sources":["../../src/formats/maskControls.ts"],"sourcesContent":["import {\n Tester,\n UISchemaElement,\n and,\n formatIs,\n isStringControl,\n not,\n optionIs,\n or,\n rankWith,\n} from '@jsonforms/core';\n\n/**\n * A mask pattern as the UI model may serialize it: one pattern, or a set of\n * alternatives the masking engine picks between by length.\n *\n * A function-valued mask is deliberately not part of this type. The\n * specification is explicit that \"function-valued masking-library options are\n * not portable serialized UI-model features\", and a UI schema is JSON.\n */\nexport type MaskPattern = string | string[];\n\n/**\n * Whether `options.mask` carries an actual pattern.\n *\n * This is the whole of the fix for the selection defect the Svelte review\n * recorded. Those families select with `hasOption('mask')`, which tests\n * *presence*: the temporal controls take a **boolean** `mask` that turns their\n * format-derived mask off, so `\"mask\": false` - an author asking for less\n * masking - made the field eligible for the generic masked renderer instead.\n * The specification names the case directly: \"a boolean temporal option must\n * not by itself request a generic masked field.\"\n *\n * Requiring a non-empty string (or a non-empty array of them) excludes `false`,\n * `true`, `\"\"`, `[]` and a function in one predicate.\n */\nexport const isMaskPattern = (value: unknown): value is MaskPattern => {\n if (typeof value === 'string') {\n return value.length > 0;\n }\n return (\n Array.isArray(value) &&\n value.length > 0 &&\n value.every((entry) => typeof entry === 'string' && entry.length > 0)\n );\n};\n\nexport const hasMaskPattern: Tester = (uischema: UISchemaElement) =>\n isMaskPattern(\n (uischema as { options?: Record<string, unknown> }).options?.mask,\n );\n\n/**\n * The string formats that name their own editor.\n *\n * A `format` says what the value *is*; a mask only says how it is typed. So\n * when both are present the format wins and the mask is ignored, rather than a\n * date being edited through a generic text mask that knows nothing about\n * calendars. The specification leaves this to us - \"handling of competing\n * specialized string presentations belong in renderer-family specifications\" -\n * and it is the reason this tester can sit at a rank of its own without\n * tie-breaking against the temporal controls by registration order.\n */\nconst SPECIALIZED_STRING_FORMATS = [\n 'color',\n 'date',\n 'date-time',\n 'duration',\n 'password',\n 'time',\n];\n\nconst hasSpecializedFormat: Tester = or(\n ...SPECIALIZED_STRING_FORMATS.flatMap((format) => [\n formatIs(format),\n optionIs('format', format),\n ]),\n);\n\n/**\n * Rank 4, above the plain text control at 1 and the color and duration\n * controls at 3, and never in a tie with the temporal controls at 4 because\n * {@link hasSpecializedFormat} excludes every schema they match.\n */\nexport const extendedMaskTester = rankWith(\n 4,\n and(isStringControl, hasMaskPattern, not(hasSpecializedFormat)),\n);\n"],"mappings":";;AAoCA,IAAaA,KAAiB,MACxB,OAAOC,KAAU,WACZA,EAAM,SAAS,IAGtB,MAAM,QAAQA,CAAK,KACnBA,EAAM,SAAS,KACfA,EAAM,OAAO,MAAU,OAAOC,KAAU,YAAYA,EAAM,SAAS,CAAC,GAI3DC,KAA0B,MACrC;;CACG,OAAAH,GAAA,IAAAK,EAAmD,YAAA,OAAA,KAAA,IAAAD,EAAS,IAC/D;A,GAsBIE,IAA+BC,EACnC,GAAG;CATH;CACA;CACA;CACA;CACA;CACA;AAIG,CAAA,CAA2B,SAAS,MAAW,CAChDC,EAASC,CAAM,GACfC,EAAS,UAAUD,CAAM,CAC3B,CAAC,CACH,GAOaE,IAAqBC,EAChC,GACAC,EAAIC,GAAiBX,GAAgBY,EAAIT,CAAoB,CAAC,CAChE"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./maskControls.cjs.js");let t=require("maska");var n={"#":{pattern:/[0-9]/},"@":{pattern:/[a-zA-Z]/},"*":{pattern:/[a-zA-Z0-9]/}},r=t.tokens,i=[`multiple`,`optional`,`repeated`],a=e=>{try{return new RegExp(e,`u`)}catch{}try{return new RegExp(e)}catch{return}},o=(e,t)=>{if(!e||typeof e!=`object`||Array.isArray(e))return;let r={...n};for(let[n,o]of Object.entries(e)){if(!o){delete r[n];continue}let e=typeof o==`string`?o:o.pattern;if(typeof e!=`string`)continue;let s=a(e);if(!s){t==null||t(n,e);continue}let c={pattern:s};if(typeof o!=`string`)for(let e of i)o[e]===!0&&(c[e]=!0);r[n]=c}return r},s={tokensReplace:!0,eager:!1,reversed:!1,returnMaskedValue:!1},c=(t,r,i)=>{let a=t==null?void 0:t.mask;if(!e.isMaskPattern(a))return;let c={...r,...t},l=c.tokens,u=e=>(c[e]??s[e])===!0;return{mask:a,tokens:o(l,i)??n,tokensReplace:u(`tokensReplace`),eager:u(`eager`),reversed:u(`reversed`),returnMaskedValue:u(`returnMaskedValue`)}},l=e=>new t.Mask({mask:e.mask,tokens:e.tokens,tokensReplace:e.tokensReplace,eager:e.eager,reversed:e.reversed}),u=(e,t,n)=>n?e.masked(t):e.unmasked(t),d=(e,t,n)=>n?e.masked(t)===t:e.unmasked(e.masked(t))===t,f=(e,t,n)=>d(e,t,n)?e.masked(t):t,p=e=>[...e].length,m=(e,t)=>t===void 0||p(e)<=t,h=(e,t,n,r,i)=>{if(n===null||n===t.length&&!i)return;let a=t.slice(0,n);if(a===r.slice(0,n))return n;if(i)return n+r.length-t.length;let o=e.unmasked(a);if(o.length===0)return 0;for(let t=1;t<=r.length;t+=1)if(e.unmasked(r.slice(0,t)).length>=o.length)return t;return r.length},g=(e,t,n)=>n&&e.isEager()&&e.unmasked(t)===``?``:e.masked(t);exports.DEFAULT_MASK_SETTINGS=s,exports.DEFAULT_MASK_TOKENS=n,exports.MASKA_DEFAULT_TOKENS=r,exports.codePointLength=p,exports.compileTokenPattern=a,exports.createMask=l,exports.displayValue=f,exports.fitsMask=d,exports.isMaskPattern=e.isMaskPattern,exports.maskEdit=g,exports.nextCaret=h,exports.resolveMaskSettings=c,exports.storedValue=u,exports.toMaskTokens=o,exports.withinMaxLength=m;
|
|
2
|
+
//# sourceMappingURL=maskFormat.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"maskFormat.cjs.js","names":["maskaTokens","isMaskPattern","Mask","require_formats_maskControls","maska","DEFAULT_MASK_TOKENS","MASKA_DEFAULT_TOKENS","TOKEN_FLAGS","compileTokenPattern","source","toMaskTokens","specs","result","key","spec","pattern","onInvalid","token","flag","DEFAULT_MASK_SETTINGS","resolveMaskSettings","mask","options","applied","config","name","createMask","settings","storedValue","returnMaskedValue","displayed","fitsMask","stored","displayValue","codePointLength","value","withinMaxLength","maxLength","nextCaret","caret","raw","deleting","rawHead","masked","typed","index","maskEdit"],"sources":["../../src/formats/maskFormat.ts"],"sourcesContent":["import { Mask, tokens as maskaTokens } from 'maska';\nimport type { MaskTokens } from 'maska';\nimport { MaskPattern, isMaskPattern } from './maskControls';\n\n/**\n * Masking, with no React and no antd in it.\n *\n * The whole storage contract - what is displayed, what is stored, what a\n * partial edit means, where the caret lands - is decidable from strings alone,\n * so it is settled here and tested without rendering anything. The renderer\n * above is then only a binding.\n *\n * The engine is [maska](https://github.com/beholdr/maska), the same library the\n * Svelte and Vuetify families use. That is the point: the specification's\n * option table *is* maska's API - `#`/`@`/`*`, `tokens`, `tokensReplace`,\n * `eager`, `reversed` - and it requires cross-platform implementations to\n * \"document their mask/token grammar and regex compatibility\". Sharing the\n * engine makes the grammars identical by construction rather than by two teams\n * reading the same paragraph.\n */\n\nexport { isMaskPattern };\nexport type { MaskPattern };\n\n/**\n * The default token table, exactly as the specification states it.\n *\n * Written out here rather than imported so the normative table is readable in\n * the code that implements it; `maskFormat.test.ts` asserts it still equals\n * maska's own, so a library bump that changed the grammar would fail rather\n * than quietly re-interpret every authored mask.\n */\nexport const DEFAULT_MASK_TOKENS: MaskTokens = {\n '#': { pattern: /[0-9]/ },\n '@': { pattern: /[a-zA-Z]/ },\n '*': { pattern: /[a-zA-Z0-9]/ },\n};\n\n/** maska's own defaults, for the guard test. */\nexport const MASKA_DEFAULT_TOKENS: MaskTokens = maskaTokens;\n\n/**\n * A token as a UI schema may spell it: a bare regex source, or an object\n * carrying one plus the engine's repetition flags. A falsy entry *removes* a\n * token, which is how an author narrows the default table.\n */\nexport type MaskTokenSpec =\n | string\n | {\n pattern: string;\n multiple?: boolean;\n optional?: boolean;\n repeated?: boolean;\n }\n | false\n | null\n | undefined;\n\nexport type MaskTokenSpecs = Record<string, MaskTokenSpec>;\n\n/**\n * The token-object fields that survive serialization.\n *\n * maska's `transform` is deliberately absent: it is a function, and the\n * specification rules that out - \"function-valued masking-library options are\n * not portable serialized UI-model features\". Any other field an author writes\n * is dropped rather than passed through, so a UI schema cannot come to depend\n * on a library detail that another family has no way to honor.\n */\nconst TOKEN_FLAGS = ['multiple', 'optional', 'repeated'] as const;\n\n/**\n * Compiles an authored regex source.\n *\n * Tried with the `u` flag first so `\\p{L}` and friends work, then without it,\n * because `u` rejects escapes that are legal in an ordinary regex (`\\-` among\n * them) and an author should not have to know which mode they are in. A source\n * that compiles under neither is reported and dropped: an invalid regex in one\n * token must not take the whole form down with a render-time throw.\n */\nexport const compileTokenPattern = (source: string): RegExp | undefined => {\n try {\n return new RegExp(source, 'u');\n } catch {\n // fall through to the unflagged attempt\n }\n try {\n return new RegExp(source);\n } catch {\n return undefined;\n }\n};\n\n/**\n * Builds the token table from the default one plus the authored entries.\n *\n * This starts from the defaults and applies the author's entries over them,\n * which is what the neighbouring families do, so `\"tokens\": { \"#\": ... }`\n * changes one token rather than replacing the table.\n */\nexport const toMaskTokens = (\n specs: unknown,\n onInvalid?: (token: string, pattern: string) => void,\n): MaskTokens | undefined => {\n if (!specs || typeof specs !== 'object' || Array.isArray(specs)) {\n return undefined;\n }\n const result: MaskTokens = { ...DEFAULT_MASK_TOKENS };\n for (const [key, spec] of Object.entries(specs as MaskTokenSpecs)) {\n if (!spec) {\n // An author removing a default token. This only takes effect while\n // `tokensReplace` is on; see `resolveMaskSettings`.\n delete result[key];\n continue;\n }\n const source = typeof spec === 'string' ? spec : spec.pattern;\n if (typeof source !== 'string') {\n continue;\n }\n const pattern = compileTokenPattern(source);\n if (!pattern) {\n onInvalid?.(key, source);\n continue;\n }\n const token: MaskTokens[string] = { pattern };\n if (typeof spec !== 'string') {\n for (const flag of TOKEN_FLAGS) {\n if (spec[flag] === true) {\n token[flag] = true;\n }\n }\n }\n result[key] = token;\n }\n return result;\n};\n\nexport interface MaskSettings {\n mask: MaskPattern;\n tokens: MaskTokens;\n tokensReplace: boolean;\n eager: boolean;\n reversed: boolean;\n returnMaskedValue: boolean;\n}\n\nexport const DEFAULT_MASK_SETTINGS = {\n tokensReplace: true,\n eager: false,\n reversed: false,\n returnMaskedValue: false,\n} as const;\n\n/**\n * Resolves the authored options into the settings the engine takes.\n *\n * These options are **not** namespaced under `jsonformsExtended`. Adjustment 1\n * places a config key by where it comes from, and every one of them is an\n * established convention of the inspected Vuetify and Svelte families, so they\n * sit at the top level of `config` under the names those families already use -\n * alongside `clearable`, `restrict` and `placeholder`, which this control also\n * reads flat.\n *\n * `mask` is the exception: it is read from the element only. A form-wide\n * default mask would claim every string field in the form, and the tester\n * inspects `uischema.options.mask` too, so a config-level one could never have\n * selected this renderer in the first place.\n *\n * Every boolean means what it says: `\"eager\": true` is eager. That is worth\n * stating because the inspected Svelte families compute `eager` and `reversed`\n * as `appliedOptions.<option> === false`, so omission gives false, an explicit\n * `true` *also* gives false, and only an explicit `false` turns the behaviour\n * on - the inversion their own gap review records. The options are spelled the\n * same way here and behave as documented instead.\n */\nexport const resolveMaskSettings = (\n options: unknown,\n config: unknown,\n onInvalid?: (token: string, pattern: string) => void,\n): MaskSettings | undefined => {\n const mask = (options as { mask?: unknown } | undefined)?.mask;\n if (!isMaskPattern(mask)) {\n return undefined;\n }\n const applied = {\n ...(config as Record<string, unknown> | undefined),\n ...(options as Record<string, unknown> | undefined),\n };\n const specs = applied.tokens;\n\n const flag = (name: keyof typeof DEFAULT_MASK_SETTINGS) =>\n (applied[name] ?? DEFAULT_MASK_SETTINGS[name]) === true;\n\n return {\n mask,\n tokens: toMaskTokens(specs, onInvalid) ?? DEFAULT_MASK_TOKENS,\n tokensReplace: flag('tokensReplace'),\n eager: flag('eager'),\n reversed: flag('reversed'),\n returnMaskedValue: flag('returnMaskedValue'),\n };\n};\n\n/**\n * `tokensReplace` is passed straight through to the engine, and it decides\n * what happens to a *removed* token. The table built above already contains\n * the defaults, so with `tokensReplace: true` - the documented default - it is\n * used verbatim and a removal holds. With `tokensReplace: false` the engine\n * merges its own defaults back underneath, so an override still applies but a\n * removal is undone. That is the neighbouring families' behaviour, kept for\n * parity rather than because it reads well.\n */\nexport const createMask = (settings: MaskSettings): Mask =>\n new Mask({\n mask: settings.mask,\n tokens: settings.tokens,\n tokensReplace: settings.tokensReplace,\n eager: settings.eager,\n reversed: settings.reversed,\n });\n\n/**\n * The stored form of what is currently displayed.\n *\n * `returnMaskedValue` is the whole of the storage decision: false stores the\n * characters the user supplied, true stores them with the mask's literals in\n * place. The specification is firm that choosing it is an authoring decision\n * with a schema consequence - \"if `returnMaskedValue: true` is chosen, the\n * schema must instead describe the stored representation containing the\n * separator\" - and that the renderer \"must not rewrite the schema when this\n * option changes\". Nothing here touches the schema.\n */\nexport const storedValue = (\n mask: Mask,\n displayed: string,\n returnMaskedValue: boolean,\n): string =>\n returnMaskedValue ? mask.masked(displayed) : mask.unmasked(displayed);\n\n/**\n * Whether a stored string is one this mask could have produced.\n *\n * The test is a round trip rather than a syntax check, because the question is\n * not \"does this look plausible\" but \"would displaying this and reading it back\n * return the same value\". A value that fails is one the mask cannot carry\n * without changing it - `\"1234567890\"` under `###-###` loses four digits, and\n * `\"unknown\"` loses everything.\n */\nexport const fitsMask = (\n mask: Mask,\n stored: string,\n returnMaskedValue: boolean,\n): boolean =>\n returnMaskedValue\n ? mask.masked(stored) === stored\n : mask.unmasked(mask.masked(stored)) === stored;\n\n/**\n * What the field shows for a stored value.\n *\n * A value the mask fits is displayed masked. **A value it does not fit is shown\n * verbatim**, which is the whole of this renderer's answer to the question the\n * specification leaves open - \"treatment of existing values that do not fit\" -\n * and it is not a free choice: section 19 requires out-of-domain data to be\n * rendered honestly, and the shared editing contract says in as many words to\n * \"preserve invalid incoming data for correction; do not truncate it\n * automatically on rendering.\"\n *\n * The alternative - showing the masked remnant - would put `123-456` on screen\n * for a stored `1234567890` while the data still held ten digits, so the field\n * would disagree with the form it belongs to and a validation error would point\n * at something invisible.\n */\nexport const displayValue = (\n mask: Mask,\n stored: string,\n returnMaskedValue: boolean,\n): string =>\n fitsMask(mask, stored, returnMaskedValue) ? mask.masked(stored) : stored;\n\n/**\n * String length as JSON Schema counts it.\n *\n * \"JSON Schema strings are sequences of Unicode code points; HTML maxlength\n * measures UTF-16 code units. A direct mapping is therefore not equivalent for\n * all valid input.\" Iterating a string yields code points, so `\"😀\"` is 1 here\n * and 2 to `String.prototype.length` - and a `maxLength: 1` schema accepts it.\n */\nexport const codePointLength = (value: string): number => [...value].length;\n\n/**\n * Whether an edit is allowed to stand under `restrict` and `maxLength`.\n *\n * The limit is checked against the **stored** string, never the displayed one.\n * With `returnMaskedValue: false` those differ by every mask literal, so a\n * `maxLength: 6` field masked `###-###` displays seven characters for six\n * stored digits: forwarding the limit to the input's `maxlength`, as the\n * neighbouring families do, blocks the seventh keystroke and makes the sixth\n * digit untypeable. The specification asks for exactly this distinction - \"for\n * masked or formatted inputs, distinguish display characters from the stored\n * representation to which the schema constraint applies.\"\n */\nexport const withinMaxLength = (\n stored: string,\n maxLength: number | undefined,\n): boolean => maxLength === undefined || codePointLength(stored) <= maxLength;\n\n/**\n * Where the caret belongs after the mask has rewritten what was typed.\n *\n * Inserting a literal moves every later character right, so leaving the caret\n * at its raw offset drops it a character behind after each separator - type\n * `123` into `###-###` and the `-` appears, but the next digit lands before it.\n * The rule is to keep the caret after the same *token* character it was after,\n * which is found by walking the masked text until it carries as many token\n * characters as the raw text did up to the caret.\n *\n * This mirrors maska's own `MaskInput.fixCursor`, reimplemented rather than\n * reused because that method is private to a class whose binding writes\n * `input.value` directly and dispatches a non-bubbling `CustomEvent` - the two\n * things React's controlled inputs and synthetic events do not survive. Keeping\n * it pure also makes it testable without a DOM.\n *\n * Returns `undefined` when the caret should be left where the browser put it.\n */\nexport const nextCaret = (\n mask: Mask,\n raw: string,\n caret: number | null,\n masked: string,\n deleting: boolean,\n): number | undefined => {\n // Typing at the end: the browser has already left the caret at the end, and\n // the masked text only ever grows to the right of it.\n if (caret === null || (caret === raw.length && !deleting)) {\n return undefined;\n }\n const rawHead = raw.slice(0, caret);\n const maskedHead = masked.slice(0, caret);\n if (rawHead === maskedHead) {\n return caret;\n }\n if (deleting) {\n return caret + masked.length - raw.length;\n }\n const typed = mask.unmasked(rawHead);\n if (typed.length === 0) {\n return 0;\n }\n for (let index = 1; index <= masked.length; index += 1) {\n if (mask.unmasked(masked.slice(0, index)).length >= typed.length) {\n return index;\n }\n }\n return masked.length;\n};\n\n/**\n * The text an edit should leave on screen.\n *\n * The one special case is maska's: deleting the last token character of an\n * eager mask would otherwise leave its literals stranded - `1` backspaced under\n * an eager `###-###` masks back to `1-`, which cannot be deleted - so an eager\n * delete that empties the value empties the field.\n */\nexport const maskEdit = (\n mask: Mask,\n raw: string,\n deleting: boolean,\n): string => {\n if (deleting && mask.isEager() && mask.unmasked(raw) === '') {\n return '';\n }\n return mask.masked(raw);\n};\n"],"mappings":"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"}
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import { Mask } from 'maska';
|
|
2
|
+
import type { MaskTokens } from 'maska';
|
|
3
|
+
import { MaskPattern, isMaskPattern } from './maskControls';
|
|
4
|
+
/**
|
|
5
|
+
* Masking, with no React and no antd in it.
|
|
6
|
+
*
|
|
7
|
+
* The whole storage contract - what is displayed, what is stored, what a
|
|
8
|
+
* partial edit means, where the caret lands - is decidable from strings alone,
|
|
9
|
+
* so it is settled here and tested without rendering anything. The renderer
|
|
10
|
+
* above is then only a binding.
|
|
11
|
+
*
|
|
12
|
+
* The engine is [maska](https://github.com/beholdr/maska), the same library the
|
|
13
|
+
* Svelte and Vuetify families use. That is the point: the specification's
|
|
14
|
+
* option table *is* maska's API - `#`/`@`/`*`, `tokens`, `tokensReplace`,
|
|
15
|
+
* `eager`, `reversed` - and it requires cross-platform implementations to
|
|
16
|
+
* "document their mask/token grammar and regex compatibility". Sharing the
|
|
17
|
+
* engine makes the grammars identical by construction rather than by two teams
|
|
18
|
+
* reading the same paragraph.
|
|
19
|
+
*/
|
|
20
|
+
export { isMaskPattern };
|
|
21
|
+
export type { MaskPattern };
|
|
22
|
+
/**
|
|
23
|
+
* The default token table, exactly as the specification states it.
|
|
24
|
+
*
|
|
25
|
+
* Written out here rather than imported so the normative table is readable in
|
|
26
|
+
* the code that implements it; `maskFormat.test.ts` asserts it still equals
|
|
27
|
+
* maska's own, so a library bump that changed the grammar would fail rather
|
|
28
|
+
* than quietly re-interpret every authored mask.
|
|
29
|
+
*/
|
|
30
|
+
export declare const DEFAULT_MASK_TOKENS: MaskTokens;
|
|
31
|
+
/** maska's own defaults, for the guard test. */
|
|
32
|
+
export declare const MASKA_DEFAULT_TOKENS: MaskTokens;
|
|
33
|
+
/**
|
|
34
|
+
* A token as a UI schema may spell it: a bare regex source, or an object
|
|
35
|
+
* carrying one plus the engine's repetition flags. A falsy entry *removes* a
|
|
36
|
+
* token, which is how an author narrows the default table.
|
|
37
|
+
*/
|
|
38
|
+
export type MaskTokenSpec = string | {
|
|
39
|
+
pattern: string;
|
|
40
|
+
multiple?: boolean;
|
|
41
|
+
optional?: boolean;
|
|
42
|
+
repeated?: boolean;
|
|
43
|
+
} | false | null | undefined;
|
|
44
|
+
export type MaskTokenSpecs = Record<string, MaskTokenSpec>;
|
|
45
|
+
/**
|
|
46
|
+
* Compiles an authored regex source.
|
|
47
|
+
*
|
|
48
|
+
* Tried with the `u` flag first so `\p{L}` and friends work, then without it,
|
|
49
|
+
* because `u` rejects escapes that are legal in an ordinary regex (`\-` among
|
|
50
|
+
* them) and an author should not have to know which mode they are in. A source
|
|
51
|
+
* that compiles under neither is reported and dropped: an invalid regex in one
|
|
52
|
+
* token must not take the whole form down with a render-time throw.
|
|
53
|
+
*/
|
|
54
|
+
export declare const compileTokenPattern: (source: string) => RegExp | undefined;
|
|
55
|
+
/**
|
|
56
|
+
* Builds the token table from the default one plus the authored entries.
|
|
57
|
+
*
|
|
58
|
+
* This starts from the defaults and applies the author's entries over them,
|
|
59
|
+
* which is what the neighbouring families do, so `"tokens": { "#": ... }`
|
|
60
|
+
* changes one token rather than replacing the table.
|
|
61
|
+
*/
|
|
62
|
+
export declare const toMaskTokens: (specs: unknown, onInvalid?: (token: string, pattern: string) => void) => MaskTokens | undefined;
|
|
63
|
+
export interface MaskSettings {
|
|
64
|
+
mask: MaskPattern;
|
|
65
|
+
tokens: MaskTokens;
|
|
66
|
+
tokensReplace: boolean;
|
|
67
|
+
eager: boolean;
|
|
68
|
+
reversed: boolean;
|
|
69
|
+
returnMaskedValue: boolean;
|
|
70
|
+
}
|
|
71
|
+
export declare const DEFAULT_MASK_SETTINGS: {
|
|
72
|
+
readonly tokensReplace: true;
|
|
73
|
+
readonly eager: false;
|
|
74
|
+
readonly reversed: false;
|
|
75
|
+
readonly returnMaskedValue: false;
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Resolves the authored options into the settings the engine takes.
|
|
79
|
+
*
|
|
80
|
+
* These options are **not** namespaced under `jsonformsExtended`. Adjustment 1
|
|
81
|
+
* places a config key by where it comes from, and every one of them is an
|
|
82
|
+
* established convention of the inspected Vuetify and Svelte families, so they
|
|
83
|
+
* sit at the top level of `config` under the names those families already use -
|
|
84
|
+
* alongside `clearable`, `restrict` and `placeholder`, which this control also
|
|
85
|
+
* reads flat.
|
|
86
|
+
*
|
|
87
|
+
* `mask` is the exception: it is read from the element only. A form-wide
|
|
88
|
+
* default mask would claim every string field in the form, and the tester
|
|
89
|
+
* inspects `uischema.options.mask` too, so a config-level one could never have
|
|
90
|
+
* selected this renderer in the first place.
|
|
91
|
+
*
|
|
92
|
+
* Every boolean means what it says: `"eager": true` is eager. That is worth
|
|
93
|
+
* stating because the inspected Svelte families compute `eager` and `reversed`
|
|
94
|
+
* as `appliedOptions.<option> === false`, so omission gives false, an explicit
|
|
95
|
+
* `true` *also* gives false, and only an explicit `false` turns the behaviour
|
|
96
|
+
* on - the inversion their own gap review records. The options are spelled the
|
|
97
|
+
* same way here and behave as documented instead.
|
|
98
|
+
*/
|
|
99
|
+
export declare const resolveMaskSettings: (options: unknown, config: unknown, onInvalid?: (token: string, pattern: string) => void) => MaskSettings | undefined;
|
|
100
|
+
/**
|
|
101
|
+
* `tokensReplace` is passed straight through to the engine, and it decides
|
|
102
|
+
* what happens to a *removed* token. The table built above already contains
|
|
103
|
+
* the defaults, so with `tokensReplace: true` - the documented default - it is
|
|
104
|
+
* used verbatim and a removal holds. With `tokensReplace: false` the engine
|
|
105
|
+
* merges its own defaults back underneath, so an override still applies but a
|
|
106
|
+
* removal is undone. That is the neighbouring families' behaviour, kept for
|
|
107
|
+
* parity rather than because it reads well.
|
|
108
|
+
*/
|
|
109
|
+
export declare const createMask: (settings: MaskSettings) => Mask;
|
|
110
|
+
/**
|
|
111
|
+
* The stored form of what is currently displayed.
|
|
112
|
+
*
|
|
113
|
+
* `returnMaskedValue` is the whole of the storage decision: false stores the
|
|
114
|
+
* characters the user supplied, true stores them with the mask's literals in
|
|
115
|
+
* place. The specification is firm that choosing it is an authoring decision
|
|
116
|
+
* with a schema consequence - "if `returnMaskedValue: true` is chosen, the
|
|
117
|
+
* schema must instead describe the stored representation containing the
|
|
118
|
+
* separator" - and that the renderer "must not rewrite the schema when this
|
|
119
|
+
* option changes". Nothing here touches the schema.
|
|
120
|
+
*/
|
|
121
|
+
export declare const storedValue: (mask: Mask, displayed: string, returnMaskedValue: boolean) => string;
|
|
122
|
+
/**
|
|
123
|
+
* Whether a stored string is one this mask could have produced.
|
|
124
|
+
*
|
|
125
|
+
* The test is a round trip rather than a syntax check, because the question is
|
|
126
|
+
* not "does this look plausible" but "would displaying this and reading it back
|
|
127
|
+
* return the same value". A value that fails is one the mask cannot carry
|
|
128
|
+
* without changing it - `"1234567890"` under `###-###` loses four digits, and
|
|
129
|
+
* `"unknown"` loses everything.
|
|
130
|
+
*/
|
|
131
|
+
export declare const fitsMask: (mask: Mask, stored: string, returnMaskedValue: boolean) => boolean;
|
|
132
|
+
/**
|
|
133
|
+
* What the field shows for a stored value.
|
|
134
|
+
*
|
|
135
|
+
* A value the mask fits is displayed masked. **A value it does not fit is shown
|
|
136
|
+
* verbatim**, which is the whole of this renderer's answer to the question the
|
|
137
|
+
* specification leaves open - "treatment of existing values that do not fit" -
|
|
138
|
+
* and it is not a free choice: section 19 requires out-of-domain data to be
|
|
139
|
+
* rendered honestly, and the shared editing contract says in as many words to
|
|
140
|
+
* "preserve invalid incoming data for correction; do not truncate it
|
|
141
|
+
* automatically on rendering."
|
|
142
|
+
*
|
|
143
|
+
* The alternative - showing the masked remnant - would put `123-456` on screen
|
|
144
|
+
* for a stored `1234567890` while the data still held ten digits, so the field
|
|
145
|
+
* would disagree with the form it belongs to and a validation error would point
|
|
146
|
+
* at something invisible.
|
|
147
|
+
*/
|
|
148
|
+
export declare const displayValue: (mask: Mask, stored: string, returnMaskedValue: boolean) => string;
|
|
149
|
+
/**
|
|
150
|
+
* String length as JSON Schema counts it.
|
|
151
|
+
*
|
|
152
|
+
* "JSON Schema strings are sequences of Unicode code points; HTML maxlength
|
|
153
|
+
* measures UTF-16 code units. A direct mapping is therefore not equivalent for
|
|
154
|
+
* all valid input." Iterating a string yields code points, so `"😀"` is 1 here
|
|
155
|
+
* and 2 to `String.prototype.length` - and a `maxLength: 1` schema accepts it.
|
|
156
|
+
*/
|
|
157
|
+
export declare const codePointLength: (value: string) => number;
|
|
158
|
+
/**
|
|
159
|
+
* Whether an edit is allowed to stand under `restrict` and `maxLength`.
|
|
160
|
+
*
|
|
161
|
+
* The limit is checked against the **stored** string, never the displayed one.
|
|
162
|
+
* With `returnMaskedValue: false` those differ by every mask literal, so a
|
|
163
|
+
* `maxLength: 6` field masked `###-###` displays seven characters for six
|
|
164
|
+
* stored digits: forwarding the limit to the input's `maxlength`, as the
|
|
165
|
+
* neighbouring families do, blocks the seventh keystroke and makes the sixth
|
|
166
|
+
* digit untypeable. The specification asks for exactly this distinction - "for
|
|
167
|
+
* masked or formatted inputs, distinguish display characters from the stored
|
|
168
|
+
* representation to which the schema constraint applies."
|
|
169
|
+
*/
|
|
170
|
+
export declare const withinMaxLength: (stored: string, maxLength: number | undefined) => boolean;
|
|
171
|
+
/**
|
|
172
|
+
* Where the caret belongs after the mask has rewritten what was typed.
|
|
173
|
+
*
|
|
174
|
+
* Inserting a literal moves every later character right, so leaving the caret
|
|
175
|
+
* at its raw offset drops it a character behind after each separator - type
|
|
176
|
+
* `123` into `###-###` and the `-` appears, but the next digit lands before it.
|
|
177
|
+
* The rule is to keep the caret after the same *token* character it was after,
|
|
178
|
+
* which is found by walking the masked text until it carries as many token
|
|
179
|
+
* characters as the raw text did up to the caret.
|
|
180
|
+
*
|
|
181
|
+
* This mirrors maska's own `MaskInput.fixCursor`, reimplemented rather than
|
|
182
|
+
* reused because that method is private to a class whose binding writes
|
|
183
|
+
* `input.value` directly and dispatches a non-bubbling `CustomEvent` - the two
|
|
184
|
+
* things React's controlled inputs and synthetic events do not survive. Keeping
|
|
185
|
+
* it pure also makes it testable without a DOM.
|
|
186
|
+
*
|
|
187
|
+
* Returns `undefined` when the caret should be left where the browser put it.
|
|
188
|
+
*/
|
|
189
|
+
export declare const nextCaret: (mask: Mask, raw: string, caret: number | null, masked: string, deleting: boolean) => number | undefined;
|
|
190
|
+
/**
|
|
191
|
+
* The text an edit should leave on screen.
|
|
192
|
+
*
|
|
193
|
+
* The one special case is maska's: deleting the last token character of an
|
|
194
|
+
* eager mask would otherwise leave its literals stranded - `1` backspaced under
|
|
195
|
+
* an eager `###-###` masks back to `1-`, which cannot be deleted - so an eager
|
|
196
|
+
* delete that empties the value empties the field.
|
|
197
|
+
*/
|
|
198
|
+
export declare const maskEdit: (mask: Mask, raw: string, deleting: boolean) => string;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { isMaskPattern as e } from "./maskControls.esm.js";
|
|
2
|
+
import { Mask as t, tokens as n } from "maska";
|
|
3
|
+
// src/formats/maskFormat.ts
|
|
4
|
+
var r = {
|
|
5
|
+
"#": { pattern: /[0-9]/ },
|
|
6
|
+
"@": { pattern: /[a-zA-Z]/ },
|
|
7
|
+
"*": { pattern: /[a-zA-Z0-9]/ }
|
|
8
|
+
}, i = n, a = [
|
|
9
|
+
"multiple",
|
|
10
|
+
"optional",
|
|
11
|
+
"repeated"
|
|
12
|
+
], o = (e) => {
|
|
13
|
+
try {
|
|
14
|
+
return new RegExp(e, "u");
|
|
15
|
+
} catch {}
|
|
16
|
+
try {
|
|
17
|
+
return new RegExp(e);
|
|
18
|
+
} catch {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
}, s = (e, t) => {
|
|
22
|
+
if (!e || typeof e != "object" || Array.isArray(e)) return;
|
|
23
|
+
let n = { ...r };
|
|
24
|
+
for (let [r, i] of Object.entries(e)) {
|
|
25
|
+
if (!i) {
|
|
26
|
+
delete n[r];
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
let e = typeof i == "string" ? i : i.pattern;
|
|
30
|
+
if (typeof e != "string") continue;
|
|
31
|
+
let s = o(e);
|
|
32
|
+
if (!s) {
|
|
33
|
+
t == null || t(r, e);
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
let c = { pattern: s };
|
|
37
|
+
if (typeof i != "string") for (let e of a) i[e] === !0 && (c[e] = !0);
|
|
38
|
+
n[r] = c;
|
|
39
|
+
}
|
|
40
|
+
return n;
|
|
41
|
+
}, c = {
|
|
42
|
+
tokensReplace: !0,
|
|
43
|
+
eager: !1,
|
|
44
|
+
reversed: !1,
|
|
45
|
+
returnMaskedValue: !1
|
|
46
|
+
}, l = (t, n, i) => {
|
|
47
|
+
let a = t == null ? void 0 : t.mask;
|
|
48
|
+
if (!e(a)) return;
|
|
49
|
+
let o = {
|
|
50
|
+
...n,
|
|
51
|
+
...t
|
|
52
|
+
}, l = o.tokens, u = (e) => (o[e] ?? c[e]) === !0;
|
|
53
|
+
return {
|
|
54
|
+
mask: a,
|
|
55
|
+
tokens: s(l, i) ?? r,
|
|
56
|
+
tokensReplace: u("tokensReplace"),
|
|
57
|
+
eager: u("eager"),
|
|
58
|
+
reversed: u("reversed"),
|
|
59
|
+
returnMaskedValue: u("returnMaskedValue")
|
|
60
|
+
};
|
|
61
|
+
}, u = (e) => new t({
|
|
62
|
+
mask: e.mask,
|
|
63
|
+
tokens: e.tokens,
|
|
64
|
+
tokensReplace: e.tokensReplace,
|
|
65
|
+
eager: e.eager,
|
|
66
|
+
reversed: e.reversed
|
|
67
|
+
}), d = (e, t, n) => n ? e.masked(t) : e.unmasked(t), f = (e, t, n) => n ? e.masked(t) === t : e.unmasked(e.masked(t)) === t, p = (e, t, n) => f(e, t, n) ? e.masked(t) : t, m = (e) => [...e].length, h = (e, t) => t === void 0 || m(e) <= t, g = (e, t, n, r, i) => {
|
|
68
|
+
if (n === null || n === t.length && !i) return;
|
|
69
|
+
let a = t.slice(0, n);
|
|
70
|
+
if (a === r.slice(0, n)) return n;
|
|
71
|
+
if (i) return n + r.length - t.length;
|
|
72
|
+
let o = e.unmasked(a);
|
|
73
|
+
if (o.length === 0) return 0;
|
|
74
|
+
for (let t = 1; t <= r.length; t += 1) if (e.unmasked(r.slice(0, t)).length >= o.length) return t;
|
|
75
|
+
return r.length;
|
|
76
|
+
}, _ = (e, t, n) => n && e.isEager() && e.unmasked(t) === "" ? "" : e.masked(t);
|
|
77
|
+
export { c as DEFAULT_MASK_SETTINGS, r as DEFAULT_MASK_TOKENS, i as MASKA_DEFAULT_TOKENS, m as codePointLength, o as compileTokenPattern, u as createMask, p as displayValue, f as fitsMask, e as isMaskPattern, _ as maskEdit, g as nextCaret, l as resolveMaskSettings, d as storedValue, s as toMaskTokens, h as withinMaxLength };
|
|
78
|
+
|
|
79
|
+
//# sourceMappingURL=maskFormat.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"maskFormat.esm.js","names":["maskaTokens","DEFAULT_MASK_TOKENS","MASKA_DEFAULT_TOKENS","tokens","TOKEN_FLAGS","compileTokenPattern","source","toMaskTokens","specs","result","key","spec","pattern","onInvalid","token","flag","DEFAULT_MASK_SETTINGS","resolveMaskSettings","mask","options","isMaskPattern","applied","config","name","createMask","Mask","settings","storedValue","returnMaskedValue","displayed","fitsMask","stored","displayValue","codePointLength","value","withinMaxLength","maxLength","nextCaret","caret","raw","deleting","rawHead","masked","typed","index","maskEdit"],"sources":["../../src/formats/maskFormat.ts"],"sourcesContent":["import { Mask, tokens as maskaTokens } from 'maska';\nimport type { MaskTokens } from 'maska';\nimport { MaskPattern, isMaskPattern } from './maskControls';\n\n/**\n * Masking, with no React and no antd in it.\n *\n * The whole storage contract - what is displayed, what is stored, what a\n * partial edit means, where the caret lands - is decidable from strings alone,\n * so it is settled here and tested without rendering anything. The renderer\n * above is then only a binding.\n *\n * The engine is [maska](https://github.com/beholdr/maska), the same library the\n * Svelte and Vuetify families use. That is the point: the specification's\n * option table *is* maska's API - `#`/`@`/`*`, `tokens`, `tokensReplace`,\n * `eager`, `reversed` - and it requires cross-platform implementations to\n * \"document their mask/token grammar and regex compatibility\". Sharing the\n * engine makes the grammars identical by construction rather than by two teams\n * reading the same paragraph.\n */\n\nexport { isMaskPattern };\nexport type { MaskPattern };\n\n/**\n * The default token table, exactly as the specification states it.\n *\n * Written out here rather than imported so the normative table is readable in\n * the code that implements it; `maskFormat.test.ts` asserts it still equals\n * maska's own, so a library bump that changed the grammar would fail rather\n * than quietly re-interpret every authored mask.\n */\nexport const DEFAULT_MASK_TOKENS: MaskTokens = {\n '#': { pattern: /[0-9]/ },\n '@': { pattern: /[a-zA-Z]/ },\n '*': { pattern: /[a-zA-Z0-9]/ },\n};\n\n/** maska's own defaults, for the guard test. */\nexport const MASKA_DEFAULT_TOKENS: MaskTokens = maskaTokens;\n\n/**\n * A token as a UI schema may spell it: a bare regex source, or an object\n * carrying one plus the engine's repetition flags. A falsy entry *removes* a\n * token, which is how an author narrows the default table.\n */\nexport type MaskTokenSpec =\n | string\n | {\n pattern: string;\n multiple?: boolean;\n optional?: boolean;\n repeated?: boolean;\n }\n | false\n | null\n | undefined;\n\nexport type MaskTokenSpecs = Record<string, MaskTokenSpec>;\n\n/**\n * The token-object fields that survive serialization.\n *\n * maska's `transform` is deliberately absent: it is a function, and the\n * specification rules that out - \"function-valued masking-library options are\n * not portable serialized UI-model features\". Any other field an author writes\n * is dropped rather than passed through, so a UI schema cannot come to depend\n * on a library detail that another family has no way to honor.\n */\nconst TOKEN_FLAGS = ['multiple', 'optional', 'repeated'] as const;\n\n/**\n * Compiles an authored regex source.\n *\n * Tried with the `u` flag first so `\\p{L}` and friends work, then without it,\n * because `u` rejects escapes that are legal in an ordinary regex (`\\-` among\n * them) and an author should not have to know which mode they are in. A source\n * that compiles under neither is reported and dropped: an invalid regex in one\n * token must not take the whole form down with a render-time throw.\n */\nexport const compileTokenPattern = (source: string): RegExp | undefined => {\n try {\n return new RegExp(source, 'u');\n } catch {\n // fall through to the unflagged attempt\n }\n try {\n return new RegExp(source);\n } catch {\n return undefined;\n }\n};\n\n/**\n * Builds the token table from the default one plus the authored entries.\n *\n * This starts from the defaults and applies the author's entries over them,\n * which is what the neighbouring families do, so `\"tokens\": { \"#\": ... }`\n * changes one token rather than replacing the table.\n */\nexport const toMaskTokens = (\n specs: unknown,\n onInvalid?: (token: string, pattern: string) => void,\n): MaskTokens | undefined => {\n if (!specs || typeof specs !== 'object' || Array.isArray(specs)) {\n return undefined;\n }\n const result: MaskTokens = { ...DEFAULT_MASK_TOKENS };\n for (const [key, spec] of Object.entries(specs as MaskTokenSpecs)) {\n if (!spec) {\n // An author removing a default token. This only takes effect while\n // `tokensReplace` is on; see `resolveMaskSettings`.\n delete result[key];\n continue;\n }\n const source = typeof spec === 'string' ? spec : spec.pattern;\n if (typeof source !== 'string') {\n continue;\n }\n const pattern = compileTokenPattern(source);\n if (!pattern) {\n onInvalid?.(key, source);\n continue;\n }\n const token: MaskTokens[string] = { pattern };\n if (typeof spec !== 'string') {\n for (const flag of TOKEN_FLAGS) {\n if (spec[flag] === true) {\n token[flag] = true;\n }\n }\n }\n result[key] = token;\n }\n return result;\n};\n\nexport interface MaskSettings {\n mask: MaskPattern;\n tokens: MaskTokens;\n tokensReplace: boolean;\n eager: boolean;\n reversed: boolean;\n returnMaskedValue: boolean;\n}\n\nexport const DEFAULT_MASK_SETTINGS = {\n tokensReplace: true,\n eager: false,\n reversed: false,\n returnMaskedValue: false,\n} as const;\n\n/**\n * Resolves the authored options into the settings the engine takes.\n *\n * These options are **not** namespaced under `jsonformsExtended`. Adjustment 1\n * places a config key by where it comes from, and every one of them is an\n * established convention of the inspected Vuetify and Svelte families, so they\n * sit at the top level of `config` under the names those families already use -\n * alongside `clearable`, `restrict` and `placeholder`, which this control also\n * reads flat.\n *\n * `mask` is the exception: it is read from the element only. A form-wide\n * default mask would claim every string field in the form, and the tester\n * inspects `uischema.options.mask` too, so a config-level one could never have\n * selected this renderer in the first place.\n *\n * Every boolean means what it says: `\"eager\": true` is eager. That is worth\n * stating because the inspected Svelte families compute `eager` and `reversed`\n * as `appliedOptions.<option> === false`, so omission gives false, an explicit\n * `true` *also* gives false, and only an explicit `false` turns the behaviour\n * on - the inversion their own gap review records. The options are spelled the\n * same way here and behave as documented instead.\n */\nexport const resolveMaskSettings = (\n options: unknown,\n config: unknown,\n onInvalid?: (token: string, pattern: string) => void,\n): MaskSettings | undefined => {\n const mask = (options as { mask?: unknown } | undefined)?.mask;\n if (!isMaskPattern(mask)) {\n return undefined;\n }\n const applied = {\n ...(config as Record<string, unknown> | undefined),\n ...(options as Record<string, unknown> | undefined),\n };\n const specs = applied.tokens;\n\n const flag = (name: keyof typeof DEFAULT_MASK_SETTINGS) =>\n (applied[name] ?? DEFAULT_MASK_SETTINGS[name]) === true;\n\n return {\n mask,\n tokens: toMaskTokens(specs, onInvalid) ?? DEFAULT_MASK_TOKENS,\n tokensReplace: flag('tokensReplace'),\n eager: flag('eager'),\n reversed: flag('reversed'),\n returnMaskedValue: flag('returnMaskedValue'),\n };\n};\n\n/**\n * `tokensReplace` is passed straight through to the engine, and it decides\n * what happens to a *removed* token. The table built above already contains\n * the defaults, so with `tokensReplace: true` - the documented default - it is\n * used verbatim and a removal holds. With `tokensReplace: false` the engine\n * merges its own defaults back underneath, so an override still applies but a\n * removal is undone. That is the neighbouring families' behaviour, kept for\n * parity rather than because it reads well.\n */\nexport const createMask = (settings: MaskSettings): Mask =>\n new Mask({\n mask: settings.mask,\n tokens: settings.tokens,\n tokensReplace: settings.tokensReplace,\n eager: settings.eager,\n reversed: settings.reversed,\n });\n\n/**\n * The stored form of what is currently displayed.\n *\n * `returnMaskedValue` is the whole of the storage decision: false stores the\n * characters the user supplied, true stores them with the mask's literals in\n * place. The specification is firm that choosing it is an authoring decision\n * with a schema consequence - \"if `returnMaskedValue: true` is chosen, the\n * schema must instead describe the stored representation containing the\n * separator\" - and that the renderer \"must not rewrite the schema when this\n * option changes\". Nothing here touches the schema.\n */\nexport const storedValue = (\n mask: Mask,\n displayed: string,\n returnMaskedValue: boolean,\n): string =>\n returnMaskedValue ? mask.masked(displayed) : mask.unmasked(displayed);\n\n/**\n * Whether a stored string is one this mask could have produced.\n *\n * The test is a round trip rather than a syntax check, because the question is\n * not \"does this look plausible\" but \"would displaying this and reading it back\n * return the same value\". A value that fails is one the mask cannot carry\n * without changing it - `\"1234567890\"` under `###-###` loses four digits, and\n * `\"unknown\"` loses everything.\n */\nexport const fitsMask = (\n mask: Mask,\n stored: string,\n returnMaskedValue: boolean,\n): boolean =>\n returnMaskedValue\n ? mask.masked(stored) === stored\n : mask.unmasked(mask.masked(stored)) === stored;\n\n/**\n * What the field shows for a stored value.\n *\n * A value the mask fits is displayed masked. **A value it does not fit is shown\n * verbatim**, which is the whole of this renderer's answer to the question the\n * specification leaves open - \"treatment of existing values that do not fit\" -\n * and it is not a free choice: section 19 requires out-of-domain data to be\n * rendered honestly, and the shared editing contract says in as many words to\n * \"preserve invalid incoming data for correction; do not truncate it\n * automatically on rendering.\"\n *\n * The alternative - showing the masked remnant - would put `123-456` on screen\n * for a stored `1234567890` while the data still held ten digits, so the field\n * would disagree with the form it belongs to and a validation error would point\n * at something invisible.\n */\nexport const displayValue = (\n mask: Mask,\n stored: string,\n returnMaskedValue: boolean,\n): string =>\n fitsMask(mask, stored, returnMaskedValue) ? mask.masked(stored) : stored;\n\n/**\n * String length as JSON Schema counts it.\n *\n * \"JSON Schema strings are sequences of Unicode code points; HTML maxlength\n * measures UTF-16 code units. A direct mapping is therefore not equivalent for\n * all valid input.\" Iterating a string yields code points, so `\"😀\"` is 1 here\n * and 2 to `String.prototype.length` - and a `maxLength: 1` schema accepts it.\n */\nexport const codePointLength = (value: string): number => [...value].length;\n\n/**\n * Whether an edit is allowed to stand under `restrict` and `maxLength`.\n *\n * The limit is checked against the **stored** string, never the displayed one.\n * With `returnMaskedValue: false` those differ by every mask literal, so a\n * `maxLength: 6` field masked `###-###` displays seven characters for six\n * stored digits: forwarding the limit to the input's `maxlength`, as the\n * neighbouring families do, blocks the seventh keystroke and makes the sixth\n * digit untypeable. The specification asks for exactly this distinction - \"for\n * masked or formatted inputs, distinguish display characters from the stored\n * representation to which the schema constraint applies.\"\n */\nexport const withinMaxLength = (\n stored: string,\n maxLength: number | undefined,\n): boolean => maxLength === undefined || codePointLength(stored) <= maxLength;\n\n/**\n * Where the caret belongs after the mask has rewritten what was typed.\n *\n * Inserting a literal moves every later character right, so leaving the caret\n * at its raw offset drops it a character behind after each separator - type\n * `123` into `###-###` and the `-` appears, but the next digit lands before it.\n * The rule is to keep the caret after the same *token* character it was after,\n * which is found by walking the masked text until it carries as many token\n * characters as the raw text did up to the caret.\n *\n * This mirrors maska's own `MaskInput.fixCursor`, reimplemented rather than\n * reused because that method is private to a class whose binding writes\n * `input.value` directly and dispatches a non-bubbling `CustomEvent` - the two\n * things React's controlled inputs and synthetic events do not survive. Keeping\n * it pure also makes it testable without a DOM.\n *\n * Returns `undefined` when the caret should be left where the browser put it.\n */\nexport const nextCaret = (\n mask: Mask,\n raw: string,\n caret: number | null,\n masked: string,\n deleting: boolean,\n): number | undefined => {\n // Typing at the end: the browser has already left the caret at the end, and\n // the masked text only ever grows to the right of it.\n if (caret === null || (caret === raw.length && !deleting)) {\n return undefined;\n }\n const rawHead = raw.slice(0, caret);\n const maskedHead = masked.slice(0, caret);\n if (rawHead === maskedHead) {\n return caret;\n }\n if (deleting) {\n return caret + masked.length - raw.length;\n }\n const typed = mask.unmasked(rawHead);\n if (typed.length === 0) {\n return 0;\n }\n for (let index = 1; index <= masked.length; index += 1) {\n if (mask.unmasked(masked.slice(0, index)).length >= typed.length) {\n return index;\n }\n }\n return masked.length;\n};\n\n/**\n * The text an edit should leave on screen.\n *\n * The one special case is maska's: deleting the last token character of an\n * eager mask would otherwise leave its literals stranded - `1` backspaced under\n * an eager `###-###` masks back to `1-`, which cannot be deleted - so an eager\n * delete that empties the value empties the field.\n */\nexport const maskEdit = (\n mask: Mask,\n raw: string,\n deleting: boolean,\n): string => {\n if (deleting && mask.isEager() && mask.unmasked(raw) === '') {\n return '';\n }\n return mask.masked(raw);\n};\n"],"mappings":"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"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../rolldown-runtime-BocRIvOZ.js"),t=require("./dateValues.cjs.js");let n=require("dayjs");n=e.t(n);var r=`2000-01-01`,i=(e,i,a,o=!1)=>{let s,c;for(let[n,r,l]of[[`formatMinimum`,!0,!1],[`formatExclusiveMinimum`,!0,!0],[`formatMaximum`,!1,!1],[`formatExclusiveMaximum`,!1,!0]]){let u=e==null?void 0:e[n];if(typeof u!=`string`)continue;let d=t.parseDateValue(u,i);if(!d)continue;o&&(d=d.year(2e3).month(0).date(1));let f=d.startOf(a);r&&(f.isBefore(d)||l&&f.isSame(d))?f=f.add(1,a):!r&&l&&f.isSame(d)&&(f=f.subtract(1,a)),r?(!s||f.isAfter(s))&&(s=f):(!c||f.isBefore(c))&&(c=f)}let l=(0,n.default)(r).startOf(`day`),u=!!(s&&c&&s.isAfter(c))||o&&!!(s&&!s.isBefore(l.add(1,`day`))||c&&c.isBefore(l));return{min:s,max:c,empty:u}},a=(e,t)=>{if(typeof(e==null?void 0:e.restrict)==`boolean`)return e.restrict;let n=t==null?void 0:t.restrict;return typeof n!=`boolean`||n},o=(e,t,n)=>{let r=/^(\d+)(?:\/(.*))?$/.exec(e);if(!r)return;let i=Number(r[1]),a=(t??``).split(`.`).filter(Boolean);if(i>a.length)return;let o=i===0?a:a.slice(0,a.length-i),s=(r[2]??``).split(`/`).filter(Boolean),c=n;for(let e of[...o,...s]){if(typeof c!=`object`||!c)return;c=c[e]}return c},s=(e,t,n)=>{if(!e)return e;let r=!1,i={...e};for(let a of[`formatMinimum`,`formatMaximum`,`formatExclusiveMinimum`,`formatExclusiveMaximum`]){let s=e[a],c=s==null?void 0:s.$data;if(typeof c!=`string`)continue;r=!0;let l=o(c,t,n);typeof l==`string`?i[a]=l:delete i[a]}return r?i:e};exports.effectiveRestrict=a,exports.resolveDataBounds=s,exports.resolveDataPointer=o,exports.temporalBounds=i;
|
|
2
|
+
//# sourceMappingURL=temporalBounds.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"temporalBounds.cjs.js","names":["parseDateValue","require_rolldown_runtime","require_formats_dateValues","dayjs","CLOCK_DAY","temporalBounds","min","max","key","lower","exclusive","raw","schema","bound","formats","timeOnly","candidate","precision","clockStart","empty","effectiveRestrict","options","flat","config","resolveDataPointer","match","pointer","up","segments","path","base","rest","current","rootData","segment","resolveDataBounds","changed","resolved","value"],"sources":["../../src/formats/temporalBounds.ts"],"sourcesContent":["import dayjs from 'dayjs';\nimport { parseDateValue } from './dateValues';\n\n/**\n * Picker limits from `formatMinimum` and friends.\n *\n * Section 18's temporal contract:\n *\n * | Keyword | Meaning for the widget |\n * | --- | --- |\n * | `formatMinimum` | Inclusive lower bound: prevent choices and completed commits before it. |\n * | `formatExclusiveMinimum` | Exclusive lower bound: \"the boundary itself is not selectable\". |\n * | `formatMaximum` | Inclusive upper bound. |\n * | `formatExclusiveMaximum` | Exclusive upper bound. |\n *\n * \"The preventive bound behavior above follows effective `restrict`\" - these\n * limits are about what the picker *offers*. They never clamp a value that is\n * already stored: \"does not authorize clamping existing data\". A value outside\n * the bounds stays exactly as it is, shown with its validation error, and the\n * validator remains the thing that decides validity.\n *\n * The four keywords come from `ajv-formats`, not from JSON Schema itself, and\n * Ajv only compares them when the schema carries a `format` it knows how to\n * order. A UI-only `options.format` cannot supply that, so a control selected\n * that way gets bounds in the picker and no validation behind them.\n */\n\n/**\n * Just the four keywords, read off whatever schema object is to hand.\n *\n * An index signature rather than four optional fields: they are `ajv-formats`\n * extensions, so `JsonSchema` does not declare them and a structural type of\n * four optional unknowns has no property in common with it.\n */\nexport type TemporalBoundsSchema = Record<string, unknown>;\n\nexport type BoundPrecision = 'day' | 'minute' | 'second';\n\nexport interface TemporalBounds {\n min?: dayjs.Dayjs;\n max?: dayjs.Dayjs;\n /** True when the bounds leave nothing selectable at all. */\n empty: boolean;\n}\n\n/** The arbitrary day a bare time is placed on, so two clock values compare. */\nconst CLOCK_DAY = '2000-01-01';\n\n/**\n * Resolves the four keywords into one selectable range.\n *\n * **Exclusivity is resolved at the picker's precision**, which the section\n * requires: \"exclusivity must be preserved at the picker's supported\n * precision\". A date picker offering whole days cannot express \"after\n * 2026-09-19 but not 2026-09-19 itself\" except by starting at the 20th, so an\n * exclusive lower bound steps one unit forward and an exclusive upper bound\n * one unit back.\n *\n * `timeOnly` normalises both bounds onto one arbitrary day, so a time picker\n * compares clock values without inventing a reference date - the approach the\n * Svelte renderer family takes for the same reason.\n */\nexport const temporalBounds = (\n schema: TemporalBoundsSchema | undefined,\n formats: string[],\n precision: BoundPrecision,\n timeOnly = false,\n): TemporalBounds => {\n let min: dayjs.Dayjs | undefined;\n let max: dayjs.Dayjs | undefined;\n\n for (const [key, lower, exclusive] of [\n ['formatMinimum', true, false],\n ['formatExclusiveMinimum', true, true],\n ['formatMaximum', false, false],\n ['formatExclusiveMaximum', false, true],\n ] as const) {\n const raw = (schema as Record<string, unknown> | undefined)?.[key];\n if (typeof raw !== 'string') {\n continue;\n }\n let bound = parseDateValue(raw, formats);\n if (!bound) {\n continue;\n }\n if (timeOnly) {\n bound = bound.year(2000).month(0).date(1);\n }\n\n let candidate = bound.startOf(precision);\n if (\n lower &&\n (candidate.isBefore(bound) || (exclusive && candidate.isSame(bound)))\n ) {\n // Either the bound sits mid-unit - so the first whole unit at or after\n // it is the next one - or it is exclusive and must be stepped past.\n candidate = candidate.add(1, precision);\n } else if (!lower && exclusive && candidate.isSame(bound)) {\n candidate = candidate.subtract(1, precision);\n }\n\n // Several keywords may apply at once; the tightest one wins.\n if (lower) {\n if (!min || candidate.isAfter(min)) {\n min = candidate;\n }\n } else if (!max || candidate.isBefore(max)) {\n max = candidate;\n }\n }\n\n const clockStart = dayjs(CLOCK_DAY).startOf('day');\n const empty =\n !!(min && max && min.isAfter(max)) ||\n (timeOnly &&\n !!(\n (min && !min.isBefore(clockStart.add(1, 'day'))) ||\n (max && max.isBefore(clockStart))\n ));\n\n return { min, max, empty };\n};\n\n/** Preventive picker limits follow the local option, then flat form config. */\nexport const effectiveRestrict = (\n options: Record<string, unknown> | undefined,\n config: unknown,\n): boolean => {\n if (typeof options?.restrict === 'boolean') {\n return options.restrict;\n }\n const flat = (config as Record<string, unknown> | undefined)?.restrict;\n return typeof flat === 'boolean' ? flat : true;\n};\n\n/**\n * A bound written as an Ajv `$data` reference, resolved against the form data.\n *\n * `{ \"formatMinimum\": { \"$data\": \"1/from\" } }` is how a date range says \"not\n * before the other end\", and it is the reason the four bound keywords exist in\n * pairs at all. The pointer is a **JSON Relative Pointer**, relative to the\n * *instance* being validated: `1/from` means up one level from this property,\n * then `from`.\n *\n * Section 18 keeps this separate from literal bounds - \"literal bounds and\n * `$data` references are separate support capabilities. A renderer claiming\n * literal-bound support must not imply that it resolves `$data` bounds\" - so\n * it is resolved deliberately here rather than being assumed to come for free.\n *\n * Returns undefined for anything it cannot follow, which leaves the bound\n * simply unapplied: the picker offers more than it might, and the validator\n * still has the final say.\n */\nexport const resolveDataPointer = (\n pointer: string,\n path: string | undefined,\n rootData: unknown,\n): unknown => {\n const match = /^(\\d+)(?:\\/(.*))?$/.exec(pointer);\n if (!match) {\n // Absolute pointers and the `#` key-name suffix are not supported; a\n // relative pointer is what a sibling bound needs.\n return undefined;\n }\n const up = Number(match[1]);\n const segments = (path ?? '').split('.').filter(Boolean);\n if (up > segments.length) {\n return undefined;\n }\n const base = up === 0 ? segments : segments.slice(0, segments.length - up);\n const rest = (match[2] ?? '').split('/').filter(Boolean);\n let current: unknown = rootData;\n for (const segment of [...base, ...rest]) {\n if (current === null || typeof current !== 'object') {\n return undefined;\n }\n current = (current as Record<string, unknown>)[segment];\n }\n return current;\n};\n\n/**\n * The bound keywords with any `$data` references replaced by their values.\n *\n * Keeps `temporalBounds` working on strings alone, which is what makes its\n * arithmetic testable without a form around it.\n */\nexport const resolveDataBounds = (\n schema: TemporalBoundsSchema | undefined,\n path: string | undefined,\n rootData: unknown,\n): TemporalBoundsSchema | undefined => {\n if (!schema) {\n return schema;\n }\n let changed = false;\n const resolved: Record<string, unknown> = { ...schema };\n for (const key of [\n 'formatMinimum',\n 'formatMaximum',\n 'formatExclusiveMinimum',\n 'formatExclusiveMaximum',\n ]) {\n const raw = (schema as Record<string, unknown>)[key];\n const pointer = (raw as { $data?: unknown } | undefined)?.$data;\n if (typeof pointer !== 'string') {\n continue;\n }\n changed = true;\n const value = resolveDataPointer(pointer, path, rootData);\n if (typeof value === 'string') {\n resolved[key] = value;\n } else {\n // Not filled in yet, or not a string: no bound rather than a wrong one.\n delete resolved[key];\n }\n }\n return changed ? resolved : schema;\n};\n"],"mappings":"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"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import dayjs from 'dayjs';
|
|
2
|
+
/**
|
|
3
|
+
* Picker limits from `formatMinimum` and friends.
|
|
4
|
+
*
|
|
5
|
+
* Section 18's temporal contract:
|
|
6
|
+
*
|
|
7
|
+
* | Keyword | Meaning for the widget |
|
|
8
|
+
* | --- | --- |
|
|
9
|
+
* | `formatMinimum` | Inclusive lower bound: prevent choices and completed commits before it. |
|
|
10
|
+
* | `formatExclusiveMinimum` | Exclusive lower bound: "the boundary itself is not selectable". |
|
|
11
|
+
* | `formatMaximum` | Inclusive upper bound. |
|
|
12
|
+
* | `formatExclusiveMaximum` | Exclusive upper bound. |
|
|
13
|
+
*
|
|
14
|
+
* "The preventive bound behavior above follows effective `restrict`" - these
|
|
15
|
+
* limits are about what the picker *offers*. They never clamp a value that is
|
|
16
|
+
* already stored: "does not authorize clamping existing data". A value outside
|
|
17
|
+
* the bounds stays exactly as it is, shown with its validation error, and the
|
|
18
|
+
* validator remains the thing that decides validity.
|
|
19
|
+
*
|
|
20
|
+
* The four keywords come from `ajv-formats`, not from JSON Schema itself, and
|
|
21
|
+
* Ajv only compares them when the schema carries a `format` it knows how to
|
|
22
|
+
* order. A UI-only `options.format` cannot supply that, so a control selected
|
|
23
|
+
* that way gets bounds in the picker and no validation behind them.
|
|
24
|
+
*/
|
|
25
|
+
/**
|
|
26
|
+
* Just the four keywords, read off whatever schema object is to hand.
|
|
27
|
+
*
|
|
28
|
+
* An index signature rather than four optional fields: they are `ajv-formats`
|
|
29
|
+
* extensions, so `JsonSchema` does not declare them and a structural type of
|
|
30
|
+
* four optional unknowns has no property in common with it.
|
|
31
|
+
*/
|
|
32
|
+
export type TemporalBoundsSchema = Record<string, unknown>;
|
|
33
|
+
export type BoundPrecision = 'day' | 'minute' | 'second';
|
|
34
|
+
export interface TemporalBounds {
|
|
35
|
+
min?: dayjs.Dayjs;
|
|
36
|
+
max?: dayjs.Dayjs;
|
|
37
|
+
/** True when the bounds leave nothing selectable at all. */
|
|
38
|
+
empty: boolean;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Resolves the four keywords into one selectable range.
|
|
42
|
+
*
|
|
43
|
+
* **Exclusivity is resolved at the picker's precision**, which the section
|
|
44
|
+
* requires: "exclusivity must be preserved at the picker's supported
|
|
45
|
+
* precision". A date picker offering whole days cannot express "after
|
|
46
|
+
* 2026-09-19 but not 2026-09-19 itself" except by starting at the 20th, so an
|
|
47
|
+
* exclusive lower bound steps one unit forward and an exclusive upper bound
|
|
48
|
+
* one unit back.
|
|
49
|
+
*
|
|
50
|
+
* `timeOnly` normalises both bounds onto one arbitrary day, so a time picker
|
|
51
|
+
* compares clock values without inventing a reference date - the approach the
|
|
52
|
+
* Svelte renderer family takes for the same reason.
|
|
53
|
+
*/
|
|
54
|
+
export declare const temporalBounds: (schema: TemporalBoundsSchema | undefined, formats: string[], precision: BoundPrecision, timeOnly?: boolean) => TemporalBounds;
|
|
55
|
+
/** Preventive picker limits follow the local option, then flat form config. */
|
|
56
|
+
export declare const effectiveRestrict: (options: Record<string, unknown> | undefined, config: unknown) => boolean;
|
|
57
|
+
/**
|
|
58
|
+
* A bound written as an Ajv `$data` reference, resolved against the form data.
|
|
59
|
+
*
|
|
60
|
+
* `{ "formatMinimum": { "$data": "1/from" } }` is how a date range says "not
|
|
61
|
+
* before the other end", and it is the reason the four bound keywords exist in
|
|
62
|
+
* pairs at all. The pointer is a **JSON Relative Pointer**, relative to the
|
|
63
|
+
* *instance* being validated: `1/from` means up one level from this property,
|
|
64
|
+
* then `from`.
|
|
65
|
+
*
|
|
66
|
+
* Section 18 keeps this separate from literal bounds - "literal bounds and
|
|
67
|
+
* `$data` references are separate support capabilities. A renderer claiming
|
|
68
|
+
* literal-bound support must not imply that it resolves `$data` bounds" - so
|
|
69
|
+
* it is resolved deliberately here rather than being assumed to come for free.
|
|
70
|
+
*
|
|
71
|
+
* Returns undefined for anything it cannot follow, which leaves the bound
|
|
72
|
+
* simply unapplied: the picker offers more than it might, and the validator
|
|
73
|
+
* still has the final say.
|
|
74
|
+
*/
|
|
75
|
+
export declare const resolveDataPointer: (pointer: string, path: string | undefined, rootData: unknown) => unknown;
|
|
76
|
+
/**
|
|
77
|
+
* The bound keywords with any `$data` references replaced by their values.
|
|
78
|
+
*
|
|
79
|
+
* Keeps `temporalBounds` working on strings alone, which is what makes its
|
|
80
|
+
* arithmetic testable without a form around it.
|
|
81
|
+
*/
|
|
82
|
+
export declare const resolveDataBounds: (schema: TemporalBoundsSchema | undefined, path: string | undefined, rootData: unknown) => TemporalBoundsSchema | undefined;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { parseDateValue as e } from "./dateValues.esm.js";
|
|
2
|
+
import t from "dayjs";
|
|
3
|
+
// src/formats/temporalBounds.ts
|
|
4
|
+
var n = "2000-01-01", r = (r, i, a, o = !1) => {
|
|
5
|
+
let s, c;
|
|
6
|
+
for (let [t, n, l] of [
|
|
7
|
+
[
|
|
8
|
+
"formatMinimum",
|
|
9
|
+
!0,
|
|
10
|
+
!1
|
|
11
|
+
],
|
|
12
|
+
[
|
|
13
|
+
"formatExclusiveMinimum",
|
|
14
|
+
!0,
|
|
15
|
+
!0
|
|
16
|
+
],
|
|
17
|
+
[
|
|
18
|
+
"formatMaximum",
|
|
19
|
+
!1,
|
|
20
|
+
!1
|
|
21
|
+
],
|
|
22
|
+
[
|
|
23
|
+
"formatExclusiveMaximum",
|
|
24
|
+
!1,
|
|
25
|
+
!0
|
|
26
|
+
]
|
|
27
|
+
]) {
|
|
28
|
+
let u = r == null ? void 0 : r[t];
|
|
29
|
+
if (typeof u != "string") continue;
|
|
30
|
+
let d = e(u, i);
|
|
31
|
+
if (!d) continue;
|
|
32
|
+
o && (d = d.year(2e3).month(0).date(1));
|
|
33
|
+
let f = d.startOf(a);
|
|
34
|
+
n && (f.isBefore(d) || l && f.isSame(d)) ? f = f.add(1, a) : !n && l && f.isSame(d) && (f = f.subtract(1, a)), n ? (!s || f.isAfter(s)) && (s = f) : (!c || f.isBefore(c)) && (c = f);
|
|
35
|
+
}
|
|
36
|
+
let l = t(n).startOf("day"), u = !!(s && c && s.isAfter(c)) || o && !!(s && !s.isBefore(l.add(1, "day")) || c && c.isBefore(l));
|
|
37
|
+
return {
|
|
38
|
+
min: s,
|
|
39
|
+
max: c,
|
|
40
|
+
empty: u
|
|
41
|
+
};
|
|
42
|
+
}, i = (e, t) => {
|
|
43
|
+
if (typeof (e == null ? void 0 : e.restrict) == "boolean") return e.restrict;
|
|
44
|
+
let n = t == null ? void 0 : t.restrict;
|
|
45
|
+
return typeof n != "boolean" || n;
|
|
46
|
+
}, a = (e, t, n) => {
|
|
47
|
+
let r = /^(\d+)(?:\/(.*))?$/.exec(e);
|
|
48
|
+
if (!r) return;
|
|
49
|
+
let i = Number(r[1]), a = (t ?? "").split(".").filter(Boolean);
|
|
50
|
+
if (i > a.length) return;
|
|
51
|
+
let o = i === 0 ? a : a.slice(0, a.length - i), s = (r[2] ?? "").split("/").filter(Boolean), c = n;
|
|
52
|
+
for (let e of [...o, ...s]) {
|
|
53
|
+
if (typeof c != "object" || !c) return;
|
|
54
|
+
c = c[e];
|
|
55
|
+
}
|
|
56
|
+
return c;
|
|
57
|
+
}, o = (e, t, n) => {
|
|
58
|
+
if (!e) return e;
|
|
59
|
+
let r = !1, i = { ...e };
|
|
60
|
+
for (let o of [
|
|
61
|
+
"formatMinimum",
|
|
62
|
+
"formatMaximum",
|
|
63
|
+
"formatExclusiveMinimum",
|
|
64
|
+
"formatExclusiveMaximum"
|
|
65
|
+
]) {
|
|
66
|
+
let s = e[o], c = s == null ? void 0 : s.$data;
|
|
67
|
+
if (typeof c != "string") continue;
|
|
68
|
+
r = !0;
|
|
69
|
+
let l = a(c, t, n);
|
|
70
|
+
typeof l == "string" ? i[o] = l : delete i[o];
|
|
71
|
+
}
|
|
72
|
+
return r ? i : e;
|
|
73
|
+
};
|
|
74
|
+
export { i as effectiveRestrict, o as resolveDataBounds, a as resolveDataPointer, r as temporalBounds };
|
|
75
|
+
|
|
76
|
+
//# sourceMappingURL=temporalBounds.esm.js.map
|