@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 @@
|
|
|
1
|
+
{"version":3,"file":"dynamicUi.esm.js","names":["expression","isEqual","dynamicBoundValue","authored","dynamicCellValue","data","pathSegments","scopeDataSegments","current","key","forbidden","arrayData","value","property","index","read","safeSnapshot","budget","depth","seen","result","child","isPlainRecord","descriptor","validatedSnapshots","permittedConfigSnapshots","validatedSnapshot","cached","permittedConfigSnapshot","config","permitted","dynamicPath","parts","first","source","rest","match","quoted","roots","part","template","i","close","quote","escaped","char","leaf","trustedFunctions","keys","evaluateDynamicExpression","descriptorKey","environmentRoots","rootReference","descriptorRoots","usedEnvironmentRoots","used","visit","root","name","mapOverlayRecord","map","jsonValue","trustedMetadata","entry","assertAcyclic","active","arrayValue","resolveDynamicUi","_dynamic","base","failures","referenced","nodes","input","snapshot","rules","effective","rule","ruleIndex","condition","overlay","next","target","path","prefix","metadata","isDescriptor","interpretDescriptors","resolved","merged","createDynamicUiMemo","previous","share","old","createDynamicUiCache","entries","element","sameInputs","inputs","evaluate","left","right","createDynamicUiResolver","stabilize","previousElement","previousInputs","previousResult","values","dynamicUiExpressionsReady","shared","dynamicItemAt","item","fallback","segment","segments","parent"],"sources":["../../src/dynamic/dynamicUi.ts"],"sourcesContent":["import { isPlainRecord } from '../core/plainRecord';\n// Framework-neutral resolution for experimental spec §11. Keep parity with the Svelte resolver.\nimport {\n evaluateDynamicExpression as expression,\n dynamicUiExpressionsReady,\n} from './dynamicRuntime';\nimport isEqual from 'lodash/isEqual';\nimport type { UISchemaElement } from '@jsonforms/core';\nimport { scopeDataSegments } from './dynamicScope';\n\n/** Explicit opt-in; replacing external with a new immutable snapshot reevaluates overlays. */\nexport interface DynamicUiOptions {\n external?: Readonly<Record<string, unknown>>;\n /** Admit synchronous function leaves from trusted in-process UI schemas. */\n trustedFunctions?: boolean;\n}\nexport interface DynamicUiEnvironment {\n data: unknown;\n external?: Readonly<Record<string, unknown>>;\n config?: Readonly<Record<string, unknown>>;\n locale?: string;\n path: string;\n value?: unknown;\n item?: unknown;\n errors?: readonly unknown[];\n trustedFunctions?: boolean;\n}\n\nexport interface DynamicUiResult {\n element: UISchemaElement;\n failures: readonly string[];\n}\n\n/** The value root is fixed at the authored scope for one resolution pass. */\nexport function dynamicBoundValue(\n authored: UISchemaElement,\n data: unknown,\n pathSegments: readonly string[],\n): unknown {\n if (!('scope' in authored) || typeof authored.scope !== 'string')\n return undefined;\n return dynamicCellValue(data, [\n ...pathSegments,\n ...scopeDataSegments(authored.scope),\n ]);\n}\n\n/** Cells already receive their complete bound data path. */\nexport function dynamicCellValue(\n data: unknown,\n pathSegments: readonly string[],\n): unknown {\n return pathSegments.reduce<unknown>(\n (current, key) =>\n current &&\n typeof current === 'object' &&\n Object.prototype.hasOwnProperty.call(current, key)\n ? (current as Record<string, unknown>)[key]\n : undefined,\n data,\n );\n}\n\nconst forbidden = new Set(['__proto__', 'prototype', 'constructor']);\n\n/** Read array data without invoking indexed accessors or accepting sparse entries. */\nfunction arrayData<T>(\n value: readonly unknown[],\n read: (entry: unknown) => T,\n): T[] {\n if (value.length > 10_000) throw Error('array size limit exceeded');\n return Array.from({ length: value.length }, (_, index) => {\n const property = Object.getOwnPropertyDescriptor(value, String(index));\n if (!property || !('value' in property))\n throw Error('array contains a getter or hole');\n return read(property.value);\n });\n}\n\nfunction safeSnapshot(\n value: unknown,\n depth = 0,\n seen = new WeakSet<object>(),\n budget = { remaining: 10_000 },\n): unknown {\n if (--budget.remaining < 0) throw Error('environment size limit exceeded');\n if (depth > 32) throw Error('environment depth limit exceeded');\n if (\n value === undefined ||\n value === null ||\n ['string', 'boolean', 'number'].includes(typeof value)\n )\n return value;\n if (Array.isArray(value)) {\n if (seen.has(value)) throw Error('cyclic environment');\n seen.add(value);\n const result = arrayData(value, (child) =>\n safeSnapshot(child, depth + 1, seen, budget),\n );\n seen.delete(value);\n return Object.freeze(result);\n }\n if (!isPlainRecord(value))\n throw Error('environment contains a non-data value');\n if (seen.has(value)) throw Error('cyclic environment');\n seen.add(value);\n const result: Record<string, unknown> = Object.create(null);\n for (const key of Object.keys(value)) {\n if (forbidden.has(key)) continue;\n const descriptor = Object.getOwnPropertyDescriptor(value, key);\n if (!descriptor || !('value' in descriptor))\n throw Error('environment contains a getter');\n result[key] = safeSnapshot(descriptor.value, depth + 1, seen, budget);\n }\n seen.delete(value);\n return Object.freeze(result);\n}\n\nconst validatedSnapshots = new WeakMap<\n object,\n { value: unknown; nodes: number }\n>();\nconst permittedConfigSnapshots = new WeakMap<\n object,\n { value: unknown; nodes: number }\n>();\n\n/** A new immutable root is validated once, even when many occurrences read it. */\nfunction validatedSnapshot(value: unknown): { value: unknown; nodes: number } {\n if (value !== null && typeof value === 'object') {\n const cached = validatedSnapshots.get(value);\n if (cached) return cached;\n }\n const budget = { remaining: 10_000 };\n const result = {\n value: safeSnapshot(value, 0, new WeakSet<object>(), budget),\n nodes: 10_000 - budget.remaining,\n };\n if (value !== null && typeof value === 'object')\n validatedSnapshots.set(value, result);\n return result;\n}\n\nfunction permittedConfigSnapshot(config: Readonly<Record<string, unknown>>): {\n value: unknown;\n nodes: number;\n} {\n const cached = permittedConfigSnapshots.get(config);\n if (cached) return cached;\n const permitted: Record<string, unknown> = Object.create(null);\n for (const key of Object.keys(config)) {\n if (key === 'jsonformsExtended') continue;\n const property = Object.getOwnPropertyDescriptor(config, key);\n if (!property || !('value' in property))\n throw Error('configuration contains a getter');\n permitted[key] = property.value;\n }\n const result = validatedSnapshot(permitted);\n permittedConfigSnapshots.set(config, result);\n return result;\n}\n\n/** Restricted own-property path grammar: roots, dotted keys, quoted keys and array indices. */\nexport function dynamicPath(\n source: string,\n roots: Record<string, unknown>,\n): unknown {\n const parts: string[] = [];\n let index = 0;\n const first = /^[A-Za-z_][\\w]*/.exec(source);\n if (!first) throw Error('invalid path');\n parts.push(first[0]);\n index += first[0].length;\n while (index < source.length) {\n const rest = source.slice(index);\n if (rest.startsWith('.')) {\n const match = /^[A-Za-z_][\\w]*/.exec(rest.slice(1));\n if (!match) throw Error('invalid path');\n parts.push(match[0]);\n index += match[0].length + 1;\n } else if (rest.startsWith('[')) {\n const match = /^\\[(\\d+)\\]/.exec(rest);\n if (match) {\n parts.push(match[1]);\n index += match[0].length;\n continue;\n }\n const quoted = /^\\[(['\"])((?:\\\\.|(?!\\1)[^\\\\])*)\\1\\]/.exec(rest);\n if (!quoted) throw Error('invalid path');\n parts.push(quoted[2].replace(/\\\\(['\"\\\\])/g, '$1'));\n index += quoted[0].length;\n } else throw Error('invalid path');\n }\n let current: unknown = roots;\n for (const part of parts) {\n if (forbidden.has(part)) throw Error('forbidden path');\n if (\n part === 'length' &&\n (typeof current === 'string' || Array.isArray(current))\n ) {\n current = current.length;\n continue;\n }\n if (\n current === null ||\n typeof current !== 'object' ||\n !Object.prototype.hasOwnProperty.call(current, part)\n )\n return undefined;\n current = (current as Record<string, unknown>)[part];\n }\n return current;\n}\n\nfunction template(source: string, roots: Record<string, unknown>): string {\n let result = '';\n for (let i = 0; i < source.length;) {\n if (source.startsWith('{{', i)) {\n result += '{';\n i += 2;\n continue;\n }\n if (source.startsWith('}}', i)) {\n result += '}';\n i += 2;\n continue;\n }\n if (source[i] !== '{') {\n result += source[i++];\n continue;\n }\n let close = i + 1;\n let quote: \"'\" | '\"' | undefined;\n let escaped = false;\n for (; close < source.length; close++) {\n const char = source[close];\n if (quote) {\n if (escaped) escaped = false;\n else if (char === '\\\\') escaped = true;\n else if (char === quote) quote = undefined;\n } else if (char === \"'\" || char === '\"') quote = char;\n else if (char === '}') break;\n }\n if (close === source.length) throw Error('unclosed template path');\n const value = dynamicPath(source.slice(i + 1, close), roots);\n if (value === undefined || value === null || typeof value === 'object')\n throw Error('unresolved template path');\n result += String(value);\n i = close + 1;\n }\n return result;\n}\n\nfunction leaf(\n value: unknown,\n roots: Record<string, unknown>,\n trustedFunctions = false,\n): unknown {\n if (typeof value === 'function') {\n if (!trustedFunctions) throw Error('trusted functions are disabled');\n const result = value(roots);\n if (result instanceof Promise) throw Error('asynchronous dynamic function');\n return result;\n }\n if (!isPlainRecord(value)) return value;\n const keys = Object.keys(value);\n if (keys.length !== 1) return value;\n const key = keys[0];\n const property = Object.getOwnPropertyDescriptor(value, key);\n if (!property || !('value' in property))\n throw Error('descriptor contains a getter');\n if (key === 'literal') return property.value;\n if (!['bind', 'expression', 'template'].includes(key)) return value;\n if (typeof property.value !== 'string')\n throw Error('descriptor source must be a string');\n if (key === 'bind') return dynamicPath(property.value, roots);\n if (key === 'template') return template(property.value, roots);\n return expression(value, property.value, roots);\n}\n\nconst descriptorKey = (value: unknown): string | undefined => {\n if (!isPlainRecord(value)) return undefined;\n const keys = Object.keys(value);\n return keys.length === 1 &&\n ['bind', 'expression', 'template', 'literal'].includes(keys[0])\n ? keys[0]\n : undefined;\n};\n\nconst environmentRoots = [\n 'data',\n 'item',\n 'value',\n 'path',\n 'locale',\n 'external',\n 'errors',\n 'config',\n] as const;\nconst rootReference =\n /(?:^|[^\\w])(data|item|value|path|locale|external|errors|config)(?=$|[^\\w])/g;\nconst descriptorRoots = new WeakMap<object, ReadonlySet<string>>();\n\n/** Conservative root inventory: false positives cost work; false negatives would hide inputs. */\nfunction usedEnvironmentRoots(descriptor: unknown): ReadonlySet<string> {\n if (descriptor === null || typeof descriptor !== 'object') return new Set();\n const cached = descriptorRoots.get(descriptor);\n if (cached) return cached;\n const used = new Set<string>();\n const seen = new WeakSet<object>();\n const visit = (value: unknown) => {\n if (typeof value === 'function') {\n environmentRoots.forEach((root) => used.add(root));\n return;\n }\n if (value === null || typeof value !== 'object' || seen.has(value)) return;\n seen.add(value);\n if (Array.isArray(value)) {\n for (const property of Object.values(\n Object.getOwnPropertyDescriptors(value),\n ))\n if ('value' in property) visit(property.value);\n return;\n }\n if (!isPlainRecord(value)) return;\n const key = descriptorKey(value);\n if (key === 'literal') return;\n if (key === 'bind' || key === 'expression' || key === 'template') {\n const property = Object.getOwnPropertyDescriptor(value, key);\n const source =\n property && 'value' in property ? property.value : undefined;\n if (typeof source === 'string') {\n for (const match of source.matchAll(rootReference)) used.add(match[1]);\n }\n return;\n }\n for (const [name, child] of Object.entries(\n Object.getOwnPropertyDescriptors(value),\n ))\n if (name !== '$dynamic' && 'value' in child) visit(child.value);\n };\n visit(descriptor);\n descriptorRoots.set(descriptor, used);\n return used;\n}\n\n/** Validate and copy a JSON value before it reaches an arbitrary extension renderer. */\nfunction mapOverlayRecord(\n value: Record<string, unknown>,\n map: (value: unknown, key: string) => unknown,\n) {\n const result: Record<string, unknown> = {};\n for (const key of Object.keys(value)) {\n if (forbidden.has(key)) throw Error('forbidden overlay key');\n const property = Object.getOwnPropertyDescriptor(value, key);\n if (!property || !('value' in property))\n throw Error('overlay contains a getter');\n result[key] = map(property.value, key);\n }\n return result;\n}\n\nfunction jsonValue(\n value: unknown,\n depth = 0,\n seen = new WeakSet<object>(),\n budget = { remaining: 10_000 },\n trustedMetadata = false,\n): unknown {\n if (trustedMetadata && typeof value === 'function') return value;\n if (--budget.remaining < 0) throw Error('overlay size limit exceeded');\n if (depth > 32) throw Error('overlay depth limit exceeded');\n if (value === null || typeof value === 'string' || typeof value === 'boolean')\n return value;\n if (typeof value === 'number' && Number.isFinite(value)) return value;\n if (!value || typeof value !== 'object')\n throw Error('overlay must resolve to JSON');\n if (seen.has(value)) throw Error('cyclic overlay');\n seen.add(value);\n if (Array.isArray(value)) {\n const result = arrayData(value, (entry) =>\n jsonValue(entry, depth + 1, seen, budget, trustedMetadata),\n );\n seen.delete(value);\n return result;\n }\n if (!isPlainRecord(value)) throw Error('overlay must resolve to plain data');\n const result = mapOverlayRecord(value, (child) =>\n jsonValue(child, depth + 1, seen, budget, trustedMetadata),\n );\n seen.delete(value);\n return result;\n}\n\nfunction assertAcyclic(\n value: unknown,\n depth = 0,\n active = new WeakSet<object>(),\n): void {\n if (depth > 32) throw Error('overlay depth limit exceeded');\n if (value === null || typeof value !== 'object') return;\n if (active.has(value)) throw Error('cyclic overlay');\n active.add(value);\n for (const key of Object.keys(value)) {\n const property = Object.getOwnPropertyDescriptor(value, key);\n if (property && 'value' in property)\n assertAcyclic(property.value, depth + 1, active);\n }\n active.delete(value);\n}\n\n/** Resolve descriptors inside an array before replacing it as one unit. */\nfunction arrayValue(\n value: unknown,\n roots: Record<string, unknown>,\n trustedFunctions: boolean,\n depth = 0,\n): unknown {\n if (depth > 32) throw Error('overlay depth limit exceeded');\n if (descriptorKey(value) || typeof value === 'function')\n return jsonValue(leaf(value, roots, trustedFunctions));\n if (Array.isArray(value))\n return arrayData(value, (entry) =>\n arrayValue(entry, roots, trustedFunctions, depth + 1),\n );\n if (isPlainRecord(value)) {\n return mapOverlayRecord(value, (child, key) =>\n key === '$dynamic'\n ? jsonValue(\n child,\n depth + 1,\n new WeakSet(),\n { remaining: 10_000 },\n trustedFunctions,\n )\n : arrayValue(child, roots, trustedFunctions, depth + 1),\n );\n }\n return jsonValue(value);\n}\n\n/** Resolve only the current element. Descendants retain their own descriptors. */\nexport function resolveDynamicUi(\n authored: UISchemaElement,\n input: DynamicUiEnvironment,\n): DynamicUiResult {\n const descriptor = (authored as UISchemaElement & { $dynamic?: unknown })\n .$dynamic;\n if (descriptor === undefined) return { element: authored, failures: [] };\n const { $dynamic: _dynamic, ...base } = authored as UISchemaElement & {\n $dynamic: unknown;\n };\n const failures: string[] = [];\n let roots: Record<string, unknown>;\n try {\n const referenced = usedEnvironmentRoots(descriptor);\n roots = Object.create(null) as Record<string, unknown>;\n let nodes = 1;\n for (const key of environmentRoots) {\n if (!referenced.has(key)) continue;\n const value = input[key];\n if (value === undefined) continue;\n const snapshot =\n key === 'config'\n ? permittedConfigSnapshot(value as Readonly<Record<string, unknown>>)\n : validatedSnapshot(value);\n nodes += snapshot.nodes;\n if (nodes > 10_000) throw Error('environment size limit exceeded');\n roots[key] = snapshot.value;\n }\n Object.freeze(roots);\n } catch {\n return {\n element: base as UISchemaElement,\n failures: ['invalid environment'],\n };\n }\n const rules = Array.isArray(descriptor)\n ? descriptor\n : [{ overlay: descriptor }];\n let effective: Record<string, unknown> = base;\n rules.forEach((rule, ruleIndex) => {\n if (!isPlainRecord(rule)) {\n failures.push(`rule ${ruleIndex}: invalid rule`);\n return;\n }\n if ('when' in rule) {\n try {\n if (\n typeof rule.when !== 'boolean' &&\n typeof rule.when !== 'function' &&\n descriptorKey(rule.when) !== 'expression'\n )\n throw Error('unsupported condition');\n const condition = leaf(rule.when, roots, input.trustedFunctions);\n if (typeof condition !== 'boolean')\n throw Error('condition must be boolean');\n if (!condition) return;\n } catch {\n failures.push(`rule ${ruleIndex}: invalid condition`);\n return;\n }\n }\n if (!isPlainRecord(rule.overlay)) {\n failures.push(`rule ${ruleIndex}: invalid overlay`);\n return;\n }\n const active = new WeakSet<object>();\n const visit = (\n target: Record<string, unknown>,\n overlay: Record<string, unknown>,\n prefix: string[],\n interpretDescriptors = true,\n depth = 0,\n ): Record<string, unknown> => {\n if (depth > 32) throw Error('overlay depth limit exceeded');\n if (active.has(overlay)) throw Error('cyclic overlay');\n active.add(overlay);\n let next = target;\n try {\n for (const key of Object.keys(overlay)) {\n const path = [...prefix, key];\n // The current element's descriptor is metadata for this pass. Nested\n // elements keep their own descriptors until their dispatch boundary.\n if (forbidden.has(key) || (!prefix.length && key === '$dynamic')) {\n failures.push(\n `rule ${ruleIndex}: unsupported target ${path.join('.')}`,\n );\n continue;\n }\n try {\n const property = Object.getOwnPropertyDescriptor(overlay, key);\n if (!property || !('value' in property))\n throw Error('overlay contains a getter');\n const source = property.value;\n if (key === '$dynamic') {\n // Nested metadata belongs to a later UI-element dispatch. Never\n // interpret it using this occurrence's roots, even in object slots.\n const metadata = jsonValue(\n source,\n depth + 1,\n new WeakSet(),\n { remaining: 10_000 },\n !!input.trustedFunctions,\n );\n next = { ...next, [key]: metadata };\n continue;\n }\n const isDescriptor =\n interpretDescriptors &&\n (typeof source === 'function' || !!descriptorKey(source));\n const resolved = isDescriptor\n ? leaf(source, roots, input.trustedFunctions)\n : source;\n if (resolved === undefined) throw Error('missing target value');\n if (isPlainRecord(resolved) && !isDescriptor) {\n // Authored objects are patches; descriptor results are complete values.\n assertAcyclic(resolved);\n const value = resolved;\n const merged = visit(\n isPlainRecord(next[key]) ? next[key] : {},\n value as Record<string, unknown>,\n path,\n !isDescriptor && interpretDescriptors,\n depth + 1,\n );\n if (merged !== next[key]) next = { ...next, [key]: merged };\n } else {\n const value =\n Array.isArray(resolved) && interpretDescriptors && !isDescriptor\n ? arrayValue(resolved, roots, !!input.trustedFunctions)\n : jsonValue(resolved);\n if (!Object.is(next[key], value))\n next = { ...next, [key]: value };\n }\n } catch {\n failures.push(\n `rule ${ruleIndex}: invalid target ${path.join('.')}`,\n );\n }\n }\n return next;\n } finally {\n active.delete(overlay);\n }\n };\n effective = visit(effective, rule.overlay, []);\n });\n return { element: effective as unknown as UISchemaElement, failures };\n}\n\n/** Stabilize equivalent resolutions for a mounted authored occurrence. */\nexport function createDynamicUiMemo() {\n let previous: UISchemaElement | undefined;\n return (result: DynamicUiResult): DynamicUiResult => {\n if (previous && isEqual(previous, result.element))\n return { ...result, element: previous };\n const share = (old: unknown, next: unknown): unknown => {\n if (Object.is(old, next) || isEqual(old, next)) return old;\n if (Array.isArray(old) && Array.isArray(next))\n return next.map((entry, index) => share(old[index], entry));\n if (isPlainRecord(old) && isPlainRecord(next))\n return Object.fromEntries(\n Object.entries(next).map(([key, value]) => [\n key,\n share(old[key], value),\n ]),\n );\n return next;\n };\n previous = share(previous, result.element) as UISchemaElement;\n return { ...result, element: previous };\n };\n}\n\n/** Pure, form-owned reuse across dispatch and parent consumers. One entry per authored element. */\nexport function createDynamicUiCache() {\n const entries = new WeakMap<\n UISchemaElement,\n { inputs: readonly unknown[]; result: DynamicUiResult }\n >();\n return (\n element: UISchemaElement,\n inputs: readonly unknown[],\n evaluate: () => DynamicUiResult,\n ): DynamicUiResult => {\n const cached = entries.get(element);\n if (cached && sameInputs(cached.inputs, inputs)) return cached.result;\n const result = evaluate();\n entries.set(element, { inputs, result });\n return result;\n };\n}\nexport type DynamicUiCache = ReturnType<typeof createDynamicUiCache>;\n\nconst sameInputs = (left: readonly unknown[], right: readonly unknown[]) =>\n left.length === right.length &&\n left.every((value, index) => Object.is(value, right[index]));\n\n/** One mounted occurrence: cache evaluation by the immutable roots it actually reads. */\nexport function createDynamicUiResolver(shared?: DynamicUiCache) {\n const stabilize = createDynamicUiMemo();\n let previousElement: UISchemaElement | undefined;\n let previousInputs: readonly unknown[] = [];\n let previousResult: DynamicUiResult | undefined;\n return (\n element: UISchemaElement,\n input: DynamicUiEnvironment,\n ): DynamicUiResult => {\n const descriptor = (element as UISchemaElement & { $dynamic?: unknown })\n .$dynamic;\n const roots = usedEnvironmentRoots(descriptor);\n const values: DynamicUiEnvironment = {\n data: undefined,\n path: '',\n trustedFunctions: input.trustedFunctions,\n };\n const inputs: unknown[] = [\n input.trustedFunctions,\n dynamicUiExpressionsReady(),\n ];\n for (const key of environmentRoots) {\n if (!roots.has(key)) continue;\n const value = input[key];\n Object.defineProperty(values, key, {\n value,\n enumerable: true,\n configurable: true,\n });\n inputs.push(value);\n }\n if (\n previousElement === element &&\n previousResult &&\n inputs.length === previousInputs.length &&\n inputs.every((value, index) => Object.is(value, previousInputs[index]))\n )\n return previousResult;\n previousElement = element;\n previousInputs = inputs;\n previousResult = stabilize(\n shared\n ? shared(element, inputs, () => resolveDynamicUi(element, values))\n : resolveDynamicUi(element, values),\n );\n return previousResult;\n };\n}\n\n/** Nearest array entry on the dispatch path; numeric object keys are not items. */\nexport function dynamicItemAt(\n data: unknown,\n segments: readonly string[],\n fallback?: unknown,\n): unknown {\n let current = data;\n let item: unknown = fallback;\n for (const segment of segments) {\n if (\n current === null ||\n typeof current !== 'object' ||\n !Object.prototype.hasOwnProperty.call(current, segment)\n )\n break;\n const parent = current;\n current = (current as Record<string, unknown>)[segment];\n if (Array.isArray(parent) && /^(0|[1-9][0-9]*)$/.test(segment))\n item = current;\n }\n return item;\n}\n"],"mappings":";;;;;AAkCA,SAAgBE,EACd,GACA,GACA,GACS;CACT,IAAM,WAAWC,KAAa,OAAOA,EAAS,SAAU,UAExD,OAAOC,EAAiBC,GAAM,CAC5B,GAAGC,GACH,GAAGC,EAAkBJ,EAAS,KAAK,CACrC,CAAC;AACH;AAGA,SAAgBC,EACd,GACA,GACS;CACT,OAAOE,EAAa,QACjB,GAAS,MACRE,KACA,OAAOA,KAAY,YACnB,OAAO,UAAU,eAAe,KAAKA,GAASC,CAAG,IAC5CD,EAAoCC,KACrC,KAAA,GACNJ,CACF;AACF;AAEA,IAAMK,oBAAY,IAAI,IAAI;CAAC;CAAa;CAAa;AAAa,CAAC;AAGnE,SAASC,EACP,GACA,GACK;CACL,IAAIC,EAAM,SAAS,KAAQ,MAAM,MAAM,2BAA2B;CAClE,OAAO,MAAM,KAAK,EAAE,QAAQA,EAAM,OAA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ACMyB,IAAoB,CACxBzB,EAAM,kBACNmC,EAA0B,CAC5B;EACA,KAAK,IAAMnG,KAAO0C,GAAkB;GAClC,IAAI,CAACb,EAAM,IAAI7B,CAAG,GAAG;GACrB,IAAMG,IAAQ6D,EAAMhE;GAMpB,AALA,OAAO,eAAekG,GAAQlG,GAAK;IACjC;IACA,YAAY;IACZ,cAAc;GAChB,CAAC,GACDyF,EAAO,KAAKtF,CAAK;EACnB;EAeA,OAbE4F,MAAoBR,KACpBU,KACAR,EAAO,WAAWO,EAAe,UACjCP,EAAO,OAAO,GAAO,MAAU,OAAO,GAAGtF,GAAO6F,EAAe3F,EAAM,CAAC,MAGxE,IAAkBkF,GAClB,IAAiBE,GACjB,IAAiBK,EACfM,IACIA,EAAOb,GAASE,SAAc/B,EAAiB6B,GAASW,CAAM,CAAC,IAC/DxC,EAAiB6B,GAASW,CAAM,CACtC,IACOD;CACT;AACF;AAGA,SAAgBI,EACd,GACA,GACA,GACS;CACT,IAAItG,IAAUH,GACV0G,IAAgBC;CACpB,KAAK,IAAMC,KAAWC,GAAU;EAC9B,IAEE,OAAO1G,KAAY,aADnBA,KAEA,CAAC,OAAO,UAAU,eAAe,KAAKA,GAASyG,CAAO,GAEtD;EACF,IAAME,IAAS3G;EAEf,AADA,IAAWA,EAAoCyG,IAC3C,MAAM,QAAQE,CAAM,KAAK,oBAAoB,KAAKF,CAAO,MAC3D,IAAOzG;CACX;CACA,OAAOuG;AACT"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=[`hex`,`hex3`,`rgb`,`hsb`],t=`hex`,n=t=>e.includes(t)?t:`hex`,r=(e,t,n)=>Math.min(n,Math.max(t,e)),i=e=>(Math.round(e)%360+360)%360,a=/^#(?:[0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i,o=/^(rgba?|hsla?|hsba?)\(([^()]*)\)$/i,s=/^[+-]?(?:\d+\.?\d*|\.\d+)%?$/,c=e=>{let t=e.split(`,`).map(e=>e.trim()).map(e=>{if(!s.test(e))return;let t=e.endsWith(`%`);return{value:Number(t?e.slice(0,-1):e),percent:t}});return t.every(e=>e!==void 0)?t:void 0},l=e=>{if(e===void 0)return 1;let t=e.percent?e.value/100:e.value;return t>=0&&t<=1?t:void 0},u=e=>[...e].map(e=>e+e).join(``),d=e=>{if(typeof e!=`string`)return;let t=e.trim();if(a.test(t)){let e=t.slice(1),n=e.length===3?u(e):e;return{r:parseInt(n.slice(0,2),16),g:parseInt(n.slice(2,4),16),b:parseInt(n.slice(4,6),16),a:n.length===8?parseInt(n.slice(6,8),16)/255:1}}let n=o.exec(t);if(!n)return;let r=n[1].toLowerCase(),i=c(n[2]);if(!i||i.length<3||i.length>4)return;let s=l(i[3]);if(s===void 0)return;if(r.startsWith(`rgb`)){let e=i.slice(0,3);return e.some(({value:e,percent:t})=>t||!Number.isInteger(e)||e<0||e>255)?void 0:{r:e[0].value,g:e[1].value,b:e[2].value,a:s}}let d=i[0].percent?void 0:i[0].value;if(d===void 0)return;let f=i[1].value,p=i[2].value;if(!(f<0||f>100||p<0||p>100))return{...r.startsWith(`hsl`)?h(d,f,p):g(d,f,p),a:s}},f=e=>d(e)!==void 0,p=e=>e.a<1,m=(e,t,n)=>{let r=n;return r<0&&(r+=1),r>1&&--r,r<1/6?e+(t-e)*6*r:r<1/2?t:r<2/3?e+(t-e)*(2/3-r)*6:e},h=(e,t,n)=>{let a=i(e)/360,o=r(t,0,100)/100,s=r(n,0,100)/100;if(o===0){let e=Math.round(s*255);return{r:e,g:e,b:e}}let c=s<.5?s*(1+o):s+o-s*o,l=2*s-c;return{r:Math.round(m(l,c,a+1/3)*255),g:Math.round(m(l,c,a)*255),b:Math.round(m(l,c,a-1/3)*255)}},g=(e,t,n)=>{let a=i(e)/60,o=r(t,0,100)/100,s=r(n,0,100)/100,c=Math.floor(a)%6,l=a-Math.floor(a),u=s*(1-o),d=s*(1-o*l),f=s*(1-o*(1-l)),[p,m,h]=[[s,f,u],[d,s,u],[u,s,f],[u,d,s],[f,u,s],[s,u,d]][c];return{r:Math.round(p*255),g:Math.round(m*255),b:Math.round(h*255)}},_=e=>{let t=e.r/255,n=e.g/255,r=e.b/255,a=Math.max(t,n,r),o=a-Math.min(t,n,r);return{h:o===0?0:i(v(t,n,r,a,o)),s:a===0?0:Math.round(o/a*100),b:Math.round(a*100)}},v=(e,t,n,r,i)=>(r===e?((t-n)/i+(t<n?6:0))/6:r===t?((n-e)/i+2)/6:((e-t)/i+4)/6)*360,y=e=>e.toString(16).padStart(2,`0`),b=e=>String(Math.round(e*100)/100),x=e=>Math.round(e/17).toString(16),S=(e,t)=>{let n=!p(e);switch(t){case`hex3`:return n?`#${x(e.r)}${x(e.g)}${x(e.b)}`:void 0;case`rgb`:return n?`rgb(${e.r}, ${e.g}, ${e.b})`:`rgba(${e.r}, ${e.g}, ${e.b}, ${b(e.a)})`;case`hsb`:{let{h:t,s:r,b:i}=_(e);return n?`hsb(${t}, ${r}%, ${i}%)`:`hsba(${t}, ${r}%, ${i}%, ${b(e.a)})`}default:{let t=`#${y(e.r)}${y(e.g)}${y(e.b)}`;return n?t:`${t}${y(Math.round(e.a*255))}`}}},C=e=>{let t=d(e);return t?S(t,`hex`):void 0},w=e=>`color.placeholder.${e}`;exports.COLOR_SAVE_FORMATS=e,exports.DEFAULT_COLOR_SAVE_FORMAT=t,exports.asColorSaveFormat=n,exports.hsbToRgb=g,exports.hslToRgb=h,exports.isColor=f,exports.isTransparent=p,exports.normalizeHue=i,exports.parseColor=d,exports.placeholderKeyFor=w,exports.rgbToHsb=_,exports.serializeColor=S,exports.toCssColor=C;
|
|
2
|
+
//# sourceMappingURL=colorFormat.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"colorFormat.cjs.js","names":["COLOR_SAVE_FORMATS","DEFAULT_COLOR_SAVE_FORMAT","asColorSaveFormat","value","clamp","max","min","normalizeHue","hue","HEX","FUNCTIONAL","NUMBER","parseArgs","parsed","text","part","percent","parseAlpha","arg","alpha","expand3","hex","digit","parseColor","digits","full","functional","name","args","channels","channel","second","third","hslToRgb","hsbToRgb","isColor","isTransparent","color","hueToRgbChannel","shifted","t","p","q","h","saturation","s","lightness","l","gray","brightness","b","sector","offset","r","g","blue","rgbToHsb","delta","hueOf","pad","formatAlpha","a","toHex3Digit","serializeColor","opaque","format","base","toCssColor","placeholderKeyFor"],"sources":["../../src/formats/colorFormat.ts"],"sourcesContent":["/**\n * Color parsing and serialization for the color control.\n *\n * Section 18 of the portable specification makes \"color syntax, parsing,\n * serialization, and validator registration one coherent contract\", so all of\n * it lives in one module with no React and no antd in it: the control wires\n * widgets to these functions and nothing else decides what a stored color\n * looks like.\n *\n * Why not delegate to the picker's own color object? Two reasons.\n *\n * - **It cannot report failure.** antd's `AggregationColor` wraps\n * `@ant-design/fast-color`, which silently yields opaque black for anything\n * it does not recognize. The specification requires the opposite: \"invalid or\n * unsupported incoming values remain visible with errors rather than being\n * replaced by the picker's fallback color\". A parser that answers `#000000`\n * to `not a color` cannot support that, so {@link parseColor} returns\n * `undefined` instead and the raw text stays in the data for validation to\n * report.\n * - **Its output text is not the specified text.** `toRgbString()` emits\n * `rgb(0,255,0)` - no spaces - while the specification fixes the serialized\n * form as `rgb(r, g, b)`. `@ant-design/fast-color` is also a transitive\n * dependency of antd rather than one this package declares, so its exact\n * spelling is not ours to rely on.\n *\n * Hue normalization policy, which section 18 asks each implementation to\n * document: hue is reduced into `[0, 360)` and rounded to a whole degree, so\n * `hsb(-30, ...)` and `hsb(330, ...)` serialize identically. Saturation,\n * lightness and brightness are rounded to whole percentages; alpha is rounded\n * to two decimals. Round-tripping through a representation with fewer bits than\n * 8-bit RGB is therefore lossy by construction - see {@link serializeColor}.\n */\n\n/**\n * The representations a stored color can be serialized to.\n *\n * `hsl` is **accepted as input but never emitted**, which differs from section\n * 18's list of four save formats. antd's picker edits in HSB and offers no HSL\n * panel, and a save format the editor cannot display is a trap: the user drags\n * one model and the data records another, with a double rounding between them.\n * Every format here is one the picker can show, so what is edited is what is\n * stored. See Adjustment 8.1.\n */\nexport type ColorSaveFormat = 'hex' | 'hex3' | 'rgb' | 'hsb';\n\n/** Every supported save format, in the order the documentation lists them. */\nexport const COLOR_SAVE_FORMATS: ColorSaveFormat[] = [\n 'hex',\n 'hex3',\n 'rgb',\n 'hsb',\n];\n\nexport const DEFAULT_COLOR_SAVE_FORMAT: ColorSaveFormat = 'hex';\n\n/** A parsed color: 8-bit channels plus alpha in `[0, 1]`. */\nexport interface Rgba {\n r: number;\n g: number;\n b: number;\n a: number;\n}\n\n/**\n * Narrows an authored `colorSaveFormat` to a supported one.\n *\n * An unrecognized value falls back to `hex` rather than being passed through:\n * before this existed, `colorSaveFormat: \"rgb\"` was simply not matched and\n * silently produced hex, which is the same outcome but by accident. Doing it\n * here keeps the fallback in one place and lets a caller detect the mismatch.\n */\nexport const asColorSaveFormat = (value: unknown): ColorSaveFormat =>\n COLOR_SAVE_FORMATS.includes(value as ColorSaveFormat)\n ? (value as ColorSaveFormat)\n : DEFAULT_COLOR_SAVE_FORMAT;\n\nconst clamp = (value: number, min: number, max: number): number =>\n Math.min(max, Math.max(min, value));\n\n/** Reduces a hue in degrees into `[0, 360)`, rounded to a whole degree. */\nexport const normalizeHue = (hue: number): number => {\n const rounded = Math.round(hue);\n return ((rounded % 360) + 360) % 360;\n};\n\nconst HEX = /^#(?:[0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i;\nconst FUNCTIONAL = /^(rgba?|hsla?|hsba?)\\(([^()]*)\\)$/i;\n\n/** `12`, `12.5`, `-3`, `50%` - a single functional-notation argument. */\nconst NUMBER = /^[+-]?(?:\\d+\\.?\\d*|\\.\\d+)%?$/;\n\nconst parseArgs = (\n text: string,\n): { value: number; percent: boolean }[] | undefined => {\n // CSS Color 4 permits `rgb(0 255 0 / 50%)`; the specification's initial\n // profile is the comma-separated form only, so a space-separated argument\n // list is a parse failure rather than a second accepted syntax.\n const parts = text.split(',').map((part) => part.trim());\n const parsed = parts.map((part) => {\n if (!NUMBER.test(part)) {\n return undefined;\n }\n const percent = part.endsWith('%');\n return {\n value: Number(percent ? part.slice(0, -1) : part),\n percent,\n };\n });\n return parsed.every((part) => part !== undefined)\n ? (parsed as { value: number; percent: boolean }[])\n : undefined;\n};\n\nconst parseAlpha = (\n arg: { value: number; percent: boolean } | undefined,\n): number | undefined => {\n if (arg === undefined) {\n return 1;\n }\n const alpha = arg.percent ? arg.value / 100 : arg.value;\n return alpha >= 0 && alpha <= 1 ? alpha : undefined;\n};\n\nconst expand3 = (hex: string): string =>\n [...hex].map((digit) => digit + digit).join('');\n\n/**\n * Parses any representation in the supported input profile.\n *\n * The profile, per section 18: `#RGB`, `#RRGGBB` and `#RRGGBBAA` in either\n * letter case, plus `rgb()`/`rgba()`, `hsl()`/`hsla()` and - by Adjustment 8 -\n * `hsb()`/`hsba()`. Named CSS colors, further color spaces and the remaining\n * CSS syntaxes are explicitly outside it.\n *\n * Returns `undefined` for anything else, including `#RGBA`: four-digit hex is\n * not in the profile, and accepting it here would mean emitting a\n * representation the registered format validator is not required to accept.\n */\nexport const parseColor = (value: unknown): Rgba | undefined => {\n if (typeof value !== 'string') {\n return undefined;\n }\n const text = value.trim();\n if (HEX.test(text)) {\n const digits = text.slice(1);\n const full = digits.length === 3 ? expand3(digits) : digits;\n return {\n r: parseInt(full.slice(0, 2), 16),\n g: parseInt(full.slice(2, 4), 16),\n b: parseInt(full.slice(4, 6), 16),\n a: full.length === 8 ? parseInt(full.slice(6, 8), 16) / 255 : 1,\n };\n }\n const functional = FUNCTIONAL.exec(text);\n if (!functional) {\n return undefined;\n }\n const name = functional[1].toLowerCase();\n const args = parseArgs(functional[2]);\n if (!args || args.length < 3 || args.length > 4) {\n return undefined;\n }\n // `rgba(...)` with three arguments is opaque, and `rgb(...)` with four\n // carries alpha; CSS Color 4 made the two names synonyms, and rejecting the\n // combination would refuse text browsers accept.\n const alpha = parseAlpha(args[3]);\n if (alpha === undefined) {\n return undefined;\n }\n if (name.startsWith('rgb')) {\n // Section 18: \"RGB channels are integers from 0 to 255\". Percentage\n // channels are not in the profile, and a value outside the range is a\n // typing error worth reporting rather than clamping into a different\n // color the author did not write.\n const channels = args.slice(0, 3);\n if (\n channels.some(\n ({ value: channel, percent }) =>\n percent || !Number.isInteger(channel) || channel < 0 || channel > 255,\n )\n ) {\n return undefined;\n }\n return {\n r: channels[0].value,\n g: channels[1].value,\n b: channels[2].value,\n a: alpha,\n };\n }\n // The `%` sign is optional on input for saturation, lightness and\n // brightness - a hand-typed `hsl(120, 100, 50)` means the obvious thing -\n // but serialization always writes it.\n const hue = args[0].percent ? undefined : args[0].value;\n if (hue === undefined) {\n return undefined;\n }\n const second = args[1].value;\n const third = args[2].value;\n if (second < 0 || second > 100 || third < 0 || third > 100) {\n return undefined;\n }\n const rgb = name.startsWith('hsl')\n ? hslToRgb(hue, second, third)\n : hsbToRgb(hue, second, third);\n return { ...rgb, a: alpha };\n};\n\n/** Whether a value is a color this profile recognizes. */\nexport const isColor = (value: unknown): boolean =>\n parseColor(value) !== undefined;\n\n/** Whether a parsed color carries transparency. */\nexport const isTransparent = (color: Rgba): boolean => color.a < 1;\n\nconst hueToRgbChannel = (p: number, q: number, t: number): number => {\n let shifted = t;\n if (shifted < 0) shifted += 1;\n if (shifted > 1) shifted -= 1;\n if (shifted < 1 / 6) return p + (q - p) * 6 * shifted;\n if (shifted < 1 / 2) return q;\n if (shifted < 2 / 3) return p + (q - p) * (2 / 3 - shifted) * 6;\n return p;\n};\n\n/** `h` in degrees, `s`/`l` as percentages. */\nexport const hslToRgb = (\n h: number,\n s: number,\n l: number,\n): { r: number; g: number; b: number } => {\n const hue = normalizeHue(h) / 360;\n const saturation = clamp(s, 0, 100) / 100;\n const lightness = clamp(l, 0, 100) / 100;\n if (saturation === 0) {\n const gray = Math.round(lightness * 255);\n return { r: gray, g: gray, b: gray };\n }\n const q =\n lightness < 0.5\n ? lightness * (1 + saturation)\n : lightness + saturation - lightness * saturation;\n const p = 2 * lightness - q;\n return {\n r: Math.round(hueToRgbChannel(p, q, hue + 1 / 3) * 255),\n g: Math.round(hueToRgbChannel(p, q, hue) * 255),\n b: Math.round(hueToRgbChannel(p, q, hue - 1 / 3) * 255),\n };\n};\n\n/** `h` in degrees, `s`/`b` as percentages. HSB is HSV under antd's name. */\nexport const hsbToRgb = (\n h: number,\n s: number,\n b: number,\n): { r: number; g: number; b: number } => {\n const hue = normalizeHue(h) / 60;\n const saturation = clamp(s, 0, 100) / 100;\n const brightness = clamp(b, 0, 100) / 100;\n const sector = Math.floor(hue) % 6;\n const offset = hue - Math.floor(hue);\n const p = brightness * (1 - saturation);\n const q = brightness * (1 - saturation * offset);\n const t = brightness * (1 - saturation * (1 - offset));\n const [r, g, blue] = [\n [brightness, t, p],\n [q, brightness, p],\n [p, brightness, t],\n [p, q, brightness],\n [t, p, brightness],\n [brightness, p, q],\n ][sector];\n return {\n r: Math.round(r * 255),\n g: Math.round(g * 255),\n b: Math.round(blue * 255),\n };\n};\n\nexport const rgbToHsb = (color: Rgba): { h: number; s: number; b: number } => {\n const r = color.r / 255;\n const g = color.g / 255;\n const b = color.b / 255;\n const max = Math.max(r, g, b);\n const delta = max - Math.min(r, g, b);\n return {\n h: delta === 0 ? 0 : normalizeHue(hueOf(r, g, b, max, delta)),\n s: max === 0 ? 0 : Math.round((delta / max) * 100),\n b: Math.round(max * 100),\n };\n};\n\nconst hueOf = (\n r: number,\n g: number,\n b: number,\n max: number,\n delta: number,\n): number => {\n const sixth =\n max === r\n ? ((g - b) / delta + (g < b ? 6 : 0)) / 6\n : max === g\n ? ((b - r) / delta + 2) / 6\n : ((r - g) / delta + 4) / 6;\n return sixth * 360;\n};\n\nconst pad = (channel: number): string => channel.toString(16).padStart(2, '0');\n\n/** Two decimals, with no trailing zeros: `0.5`, `0.25`, `1`. */\nconst formatAlpha = (a: number): string => String(Math.round(a * 100) / 100);\n\n/**\n * Quantizes an 8-bit channel to its nearest three-digit-hex digit.\n *\n * Section 18 fixes the arithmetic as `round(channel / 17)`, and names the\n * vector: `#ed5050` becomes `#e55`, which represents `#ee5555`. This picks the\n * nearest of the 4,096 representable colors; it is not a lossless abbreviation.\n */\nconst toHex3Digit = (channel: number): string =>\n Math.round(channel / 17).toString(16);\n\n/**\n * Writes a parsed color in the requested representation.\n *\n * Returns `undefined` only for `hex3` with transparency, which the\n * specification says must never silently discard alpha: the caller refuses the\n * edit and shows `color.hex3Transparency` instead of committing an opaque\n * replacement.\n *\n * Every other format round-trips through 8-bit RGB, so `hsb` output is\n * quantized twice - once into 8-bit channels and once into whole percentages.\n * Re-saving the same color is stable.\n *\n * There is no `hsl` case: HSL is accepted as *input*, via {@link hslToRgb},\n * but is never written, because the picker cannot edit it. There is\n * deliberately no rgb-to-hsl conversion here at all - an unused inverse would\n * read as an output format that exists. See {@link ColorSaveFormat}.\n */\nexport const serializeColor = (\n color: Rgba,\n format: ColorSaveFormat,\n): string | undefined => {\n const opaque = !isTransparent(color);\n switch (format) {\n case 'hex3':\n if (!opaque) {\n return undefined;\n }\n return `#${toHex3Digit(color.r)}${toHex3Digit(color.g)}${toHex3Digit(\n color.b,\n )}`;\n case 'rgb':\n return opaque\n ? `rgb(${color.r}, ${color.g}, ${color.b})`\n : `rgba(${color.r}, ${color.g}, ${color.b}, ${formatAlpha(color.a)})`;\n case 'hsb': {\n const { h, s, b } = rgbToHsb(color);\n return opaque\n ? `hsb(${h}, ${s}%, ${b}%)`\n : `hsba(${h}, ${s}%, ${b}%, ${formatAlpha(color.a)})`;\n }\n case 'hex':\n default: {\n const base = `#${pad(color.r)}${pad(color.g)}${pad(color.b)}`;\n // Eight-digit hex quantizes alpha to 1/255, so `rgba(..., 0.5)` stores as\n // `#...80` and reads back as 0.502. That is the precision limit section\n // 18 asks to be documented, not a rounding bug.\n return opaque ? base : `${base}${pad(Math.round(color.a * 255))}`;\n }\n }\n};\n\n/**\n * A CSS color string for a stored value, for a swatch's `background`.\n *\n * `hsb()` is not CSS, and a browser given it paints nothing, so a swatch must\n * never be handed the stored text directly once HSB output is available.\n * Returns `undefined` when the value is not a color, so the caller can draw an\n * empty swatch rather than a misleading one.\n */\nexport const toCssColor = (value: unknown): string | undefined => {\n const parsed = parseColor(value);\n return parsed ? serializeColor(parsed, 'hex') : undefined;\n};\n\n/** The i18n key whose default is the entry syntax for a save format. */\nexport const placeholderKeyFor = (format: ColorSaveFormat) =>\n `color.placeholder.${format}` as const;\n"],"mappings":"A,mEA8CA,IAAaA,EAAwC,CACnD,MACA,OACA,MACA,KACF,EAEaC,EAA6C,MAkB7CC,EAAqB,GAChCF,EAAmB,SAASG,CAAwB,EAC/CA,EAAA,MAGDC,GAAS,EAAe,EAAa,IACzC,KAAK,IAAIC,EAAK,KAAK,IAAIC,EAAKH,CAAK,CAAC,EAGvBI,EAAgB,IACX,KAAK,MAAMC,CAClB,EAAU,IAAO,KAAO,IAG7BC,EAAM,8CACNC,EAAa,qCAGbC,EAAS,+BAETC,EACJ,GACsD,CAKtD,IAAMC,EADQC,EAAK,MAAM,GAAG,CAAC,CAAC,IAAK,GAASC,EAAK,KAAK,CACvC,CAAA,CAAM,IAAK,GAAS,CACjC,GAAI,CAACJ,EAAO,KAAKI,CAAI,EACnB,OAEF,IAAMC,EAAUD,EAAK,SAAS,GAAG,EACjC,MAAO,CACL,MAAO,OAAOC,EAAUD,EAAK,MAAM,EAAG,EAAE,EAAIA,CAAI,EAChD,SACF,CACF,CAAC,EACD,OAAOF,EAAO,MAAO,GAASE,IAAS,IAAA,EAAS,EAC3CF,EACD,IAAA,EACN,EAEMI,EACJ,GACuB,CACvB,GAAIC,IAAQ,IAAA,GACV,MAAO,GAET,IAAMC,EAAQD,EAAI,QAAUA,EAAI,MAAQ,IAAMA,EAAI,MAClD,OAAOC,GAAS,GAAKA,GAAS,EAAIA,EAAQ,IAAA,EAC5C,EAEMC,EAAW,GACf,CAAC,GAAGC,CAAG,CAAC,CAAC,IAAK,GAAUC,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AAc,GAAuC,CAChE,IAAMtD,EAASU,EAAWpB,CAAK,EAC/B,OAAOU,EAASkD,EAAelD,EAAQ,KAAK,EAAI,IAAA,EAClD,EAGauD,EAAqB,GAChC,qBAAqBH,I"}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Color parsing and serialization for the color control.
|
|
3
|
+
*
|
|
4
|
+
* Section 18 of the portable specification makes "color syntax, parsing,
|
|
5
|
+
* serialization, and validator registration one coherent contract", so all of
|
|
6
|
+
* it lives in one module with no React and no antd in it: the control wires
|
|
7
|
+
* widgets to these functions and nothing else decides what a stored color
|
|
8
|
+
* looks like.
|
|
9
|
+
*
|
|
10
|
+
* Why not delegate to the picker's own color object? Two reasons.
|
|
11
|
+
*
|
|
12
|
+
* - **It cannot report failure.** antd's `AggregationColor` wraps
|
|
13
|
+
* `@ant-design/fast-color`, which silently yields opaque black for anything
|
|
14
|
+
* it does not recognize. The specification requires the opposite: "invalid or
|
|
15
|
+
* unsupported incoming values remain visible with errors rather than being
|
|
16
|
+
* replaced by the picker's fallback color". A parser that answers `#000000`
|
|
17
|
+
* to `not a color` cannot support that, so {@link parseColor} returns
|
|
18
|
+
* `undefined` instead and the raw text stays in the data for validation to
|
|
19
|
+
* report.
|
|
20
|
+
* - **Its output text is not the specified text.** `toRgbString()` emits
|
|
21
|
+
* `rgb(0,255,0)` - no spaces - while the specification fixes the serialized
|
|
22
|
+
* form as `rgb(r, g, b)`. `@ant-design/fast-color` is also a transitive
|
|
23
|
+
* dependency of antd rather than one this package declares, so its exact
|
|
24
|
+
* spelling is not ours to rely on.
|
|
25
|
+
*
|
|
26
|
+
* Hue normalization policy, which section 18 asks each implementation to
|
|
27
|
+
* document: hue is reduced into `[0, 360)` and rounded to a whole degree, so
|
|
28
|
+
* `hsb(-30, ...)` and `hsb(330, ...)` serialize identically. Saturation,
|
|
29
|
+
* lightness and brightness are rounded to whole percentages; alpha is rounded
|
|
30
|
+
* to two decimals. Round-tripping through a representation with fewer bits than
|
|
31
|
+
* 8-bit RGB is therefore lossy by construction - see {@link serializeColor}.
|
|
32
|
+
*/
|
|
33
|
+
/**
|
|
34
|
+
* The representations a stored color can be serialized to.
|
|
35
|
+
*
|
|
36
|
+
* `hsl` is **accepted as input but never emitted**, which differs from section
|
|
37
|
+
* 18's list of four save formats. antd's picker edits in HSB and offers no HSL
|
|
38
|
+
* panel, and a save format the editor cannot display is a trap: the user drags
|
|
39
|
+
* one model and the data records another, with a double rounding between them.
|
|
40
|
+
* Every format here is one the picker can show, so what is edited is what is
|
|
41
|
+
* stored. See Adjustment 8.1.
|
|
42
|
+
*/
|
|
43
|
+
export type ColorSaveFormat = 'hex' | 'hex3' | 'rgb' | 'hsb';
|
|
44
|
+
/** Every supported save format, in the order the documentation lists them. */
|
|
45
|
+
export declare const COLOR_SAVE_FORMATS: ColorSaveFormat[];
|
|
46
|
+
export declare const DEFAULT_COLOR_SAVE_FORMAT: ColorSaveFormat;
|
|
47
|
+
/** A parsed color: 8-bit channels plus alpha in `[0, 1]`. */
|
|
48
|
+
export interface Rgba {
|
|
49
|
+
r: number;
|
|
50
|
+
g: number;
|
|
51
|
+
b: number;
|
|
52
|
+
a: number;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Narrows an authored `colorSaveFormat` to a supported one.
|
|
56
|
+
*
|
|
57
|
+
* An unrecognized value falls back to `hex` rather than being passed through:
|
|
58
|
+
* before this existed, `colorSaveFormat: "rgb"` was simply not matched and
|
|
59
|
+
* silently produced hex, which is the same outcome but by accident. Doing it
|
|
60
|
+
* here keeps the fallback in one place and lets a caller detect the mismatch.
|
|
61
|
+
*/
|
|
62
|
+
export declare const asColorSaveFormat: (value: unknown) => ColorSaveFormat;
|
|
63
|
+
/** Reduces a hue in degrees into `[0, 360)`, rounded to a whole degree. */
|
|
64
|
+
export declare const normalizeHue: (hue: number) => number;
|
|
65
|
+
/**
|
|
66
|
+
* Parses any representation in the supported input profile.
|
|
67
|
+
*
|
|
68
|
+
* The profile, per section 18: `#RGB`, `#RRGGBB` and `#RRGGBBAA` in either
|
|
69
|
+
* letter case, plus `rgb()`/`rgba()`, `hsl()`/`hsla()` and - by Adjustment 8 -
|
|
70
|
+
* `hsb()`/`hsba()`. Named CSS colors, further color spaces and the remaining
|
|
71
|
+
* CSS syntaxes are explicitly outside it.
|
|
72
|
+
*
|
|
73
|
+
* Returns `undefined` for anything else, including `#RGBA`: four-digit hex is
|
|
74
|
+
* not in the profile, and accepting it here would mean emitting a
|
|
75
|
+
* representation the registered format validator is not required to accept.
|
|
76
|
+
*/
|
|
77
|
+
export declare const parseColor: (value: unknown) => Rgba | undefined;
|
|
78
|
+
/** Whether a value is a color this profile recognizes. */
|
|
79
|
+
export declare const isColor: (value: unknown) => boolean;
|
|
80
|
+
/** Whether a parsed color carries transparency. */
|
|
81
|
+
export declare const isTransparent: (color: Rgba) => boolean;
|
|
82
|
+
/** `h` in degrees, `s`/`l` as percentages. */
|
|
83
|
+
export declare const hslToRgb: (h: number, s: number, l: number) => {
|
|
84
|
+
r: number;
|
|
85
|
+
g: number;
|
|
86
|
+
b: number;
|
|
87
|
+
};
|
|
88
|
+
/** `h` in degrees, `s`/`b` as percentages. HSB is HSV under antd's name. */
|
|
89
|
+
export declare const hsbToRgb: (h: number, s: number, b: number) => {
|
|
90
|
+
r: number;
|
|
91
|
+
g: number;
|
|
92
|
+
b: number;
|
|
93
|
+
};
|
|
94
|
+
export declare const rgbToHsb: (color: Rgba) => {
|
|
95
|
+
h: number;
|
|
96
|
+
s: number;
|
|
97
|
+
b: number;
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* Writes a parsed color in the requested representation.
|
|
101
|
+
*
|
|
102
|
+
* Returns `undefined` only for `hex3` with transparency, which the
|
|
103
|
+
* specification says must never silently discard alpha: the caller refuses the
|
|
104
|
+
* edit and shows `color.hex3Transparency` instead of committing an opaque
|
|
105
|
+
* replacement.
|
|
106
|
+
*
|
|
107
|
+
* Every other format round-trips through 8-bit RGB, so `hsb` output is
|
|
108
|
+
* quantized twice - once into 8-bit channels and once into whole percentages.
|
|
109
|
+
* Re-saving the same color is stable.
|
|
110
|
+
*
|
|
111
|
+
* There is no `hsl` case: HSL is accepted as *input*, via {@link hslToRgb},
|
|
112
|
+
* but is never written, because the picker cannot edit it. There is
|
|
113
|
+
* deliberately no rgb-to-hsl conversion here at all - an unused inverse would
|
|
114
|
+
* read as an output format that exists. See {@link ColorSaveFormat}.
|
|
115
|
+
*/
|
|
116
|
+
export declare const serializeColor: (color: Rgba, format: ColorSaveFormat) => string | undefined;
|
|
117
|
+
/**
|
|
118
|
+
* A CSS color string for a stored value, for a swatch's `background`.
|
|
119
|
+
*
|
|
120
|
+
* `hsb()` is not CSS, and a browser given it paints nothing, so a swatch must
|
|
121
|
+
* never be handed the stored text directly once HSB output is available.
|
|
122
|
+
* Returns `undefined` when the value is not a color, so the caller can draw an
|
|
123
|
+
* empty swatch rather than a misleading one.
|
|
124
|
+
*/
|
|
125
|
+
export declare const toCssColor: (value: unknown) => string | undefined;
|
|
126
|
+
/** The i18n key whose default is the entry syntax for a save format. */
|
|
127
|
+
export declare const placeholderKeyFor: (format: ColorSaveFormat) => "color.placeholder.hex" | "color.placeholder.hex3" | "color.placeholder.rgb" | "color.placeholder.hsb";
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
// src/formats/colorFormat.ts
|
|
2
|
+
var e = [
|
|
3
|
+
"hex",
|
|
4
|
+
"hex3",
|
|
5
|
+
"rgb",
|
|
6
|
+
"hsb"
|
|
7
|
+
], t = "hex", n = (t) => e.includes(t) ? t : "hex", r = (e, t, n) => Math.min(n, Math.max(t, e)), i = (e) => (Math.round(e) % 360 + 360) % 360, a = /^#(?:[0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i, o = /^(rgba?|hsla?|hsba?)\(([^()]*)\)$/i, s = /^[+-]?(?:\d+\.?\d*|\.\d+)%?$/, c = (e) => {
|
|
8
|
+
let t = e.split(",").map((e) => e.trim()).map((e) => {
|
|
9
|
+
if (!s.test(e)) return;
|
|
10
|
+
let t = e.endsWith("%");
|
|
11
|
+
return {
|
|
12
|
+
value: Number(t ? e.slice(0, -1) : e),
|
|
13
|
+
percent: t
|
|
14
|
+
};
|
|
15
|
+
});
|
|
16
|
+
return t.every((e) => e !== void 0) ? t : void 0;
|
|
17
|
+
}, l = (e) => {
|
|
18
|
+
if (e === void 0) return 1;
|
|
19
|
+
let t = e.percent ? e.value / 100 : e.value;
|
|
20
|
+
return t >= 0 && t <= 1 ? t : void 0;
|
|
21
|
+
}, u = (e) => [...e].map((e) => e + e).join(""), d = (e) => {
|
|
22
|
+
if (typeof e != "string") return;
|
|
23
|
+
let t = e.trim();
|
|
24
|
+
if (a.test(t)) {
|
|
25
|
+
let e = t.slice(1), n = e.length === 3 ? u(e) : e;
|
|
26
|
+
return {
|
|
27
|
+
r: parseInt(n.slice(0, 2), 16),
|
|
28
|
+
g: parseInt(n.slice(2, 4), 16),
|
|
29
|
+
b: parseInt(n.slice(4, 6), 16),
|
|
30
|
+
a: n.length === 8 ? parseInt(n.slice(6, 8), 16) / 255 : 1
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
let n = o.exec(t);
|
|
34
|
+
if (!n) return;
|
|
35
|
+
let r = n[1].toLowerCase(), i = c(n[2]);
|
|
36
|
+
if (!i || i.length < 3 || i.length > 4) return;
|
|
37
|
+
let s = l(i[3]);
|
|
38
|
+
if (s === void 0) return;
|
|
39
|
+
if (r.startsWith("rgb")) {
|
|
40
|
+
let e = i.slice(0, 3);
|
|
41
|
+
return e.some(({ value: e, percent: t }) => t || !Number.isInteger(e) || e < 0 || e > 255) ? void 0 : {
|
|
42
|
+
r: e[0].value,
|
|
43
|
+
g: e[1].value,
|
|
44
|
+
b: e[2].value,
|
|
45
|
+
a: s
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
let d = i[0].percent ? void 0 : i[0].value;
|
|
49
|
+
if (d === void 0) return;
|
|
50
|
+
let f = i[1].value, p = i[2].value;
|
|
51
|
+
if (!(f < 0 || f > 100 || p < 0 || p > 100)) return {
|
|
52
|
+
...r.startsWith("hsl") ? h(d, f, p) : g(d, f, p),
|
|
53
|
+
a: s
|
|
54
|
+
};
|
|
55
|
+
}, f = (e) => d(e) !== void 0, p = (e) => e.a < 1, m = (e, t, n) => {
|
|
56
|
+
let r = n;
|
|
57
|
+
return r < 0 && (r += 1), r > 1 && --r, r < 1 / 6 ? e + (t - e) * 6 * r : r < 1 / 2 ? t : r < 2 / 3 ? e + (t - e) * (2 / 3 - r) * 6 : e;
|
|
58
|
+
}, h = (e, t, n) => {
|
|
59
|
+
let a = i(e) / 360, o = r(t, 0, 100) / 100, s = r(n, 0, 100) / 100;
|
|
60
|
+
if (o === 0) {
|
|
61
|
+
let e = Math.round(s * 255);
|
|
62
|
+
return {
|
|
63
|
+
r: e,
|
|
64
|
+
g: e,
|
|
65
|
+
b: e
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
let c = s < .5 ? s * (1 + o) : s + o - s * o, l = 2 * s - c;
|
|
69
|
+
return {
|
|
70
|
+
r: Math.round(m(l, c, a + 1 / 3) * 255),
|
|
71
|
+
g: Math.round(m(l, c, a) * 255),
|
|
72
|
+
b: Math.round(m(l, c, a - 1 / 3) * 255)
|
|
73
|
+
};
|
|
74
|
+
}, g = (e, t, n) => {
|
|
75
|
+
let a = i(e) / 60, o = r(t, 0, 100) / 100, s = r(n, 0, 100) / 100, c = Math.floor(a) % 6, l = a - Math.floor(a), u = s * (1 - o), d = s * (1 - o * l), f = s * (1 - o * (1 - l)), [p, m, h] = [
|
|
76
|
+
[
|
|
77
|
+
s,
|
|
78
|
+
f,
|
|
79
|
+
u
|
|
80
|
+
],
|
|
81
|
+
[
|
|
82
|
+
d,
|
|
83
|
+
s,
|
|
84
|
+
u
|
|
85
|
+
],
|
|
86
|
+
[
|
|
87
|
+
u,
|
|
88
|
+
s,
|
|
89
|
+
f
|
|
90
|
+
],
|
|
91
|
+
[
|
|
92
|
+
u,
|
|
93
|
+
d,
|
|
94
|
+
s
|
|
95
|
+
],
|
|
96
|
+
[
|
|
97
|
+
f,
|
|
98
|
+
u,
|
|
99
|
+
s
|
|
100
|
+
],
|
|
101
|
+
[
|
|
102
|
+
s,
|
|
103
|
+
u,
|
|
104
|
+
d
|
|
105
|
+
]
|
|
106
|
+
][c];
|
|
107
|
+
return {
|
|
108
|
+
r: Math.round(p * 255),
|
|
109
|
+
g: Math.round(m * 255),
|
|
110
|
+
b: Math.round(h * 255)
|
|
111
|
+
};
|
|
112
|
+
}, _ = (e) => {
|
|
113
|
+
let t = e.r / 255, n = e.g / 255, r = e.b / 255, a = Math.max(t, n, r), o = a - Math.min(t, n, r);
|
|
114
|
+
return {
|
|
115
|
+
h: o === 0 ? 0 : i(v(t, n, r, a, o)),
|
|
116
|
+
s: a === 0 ? 0 : Math.round(o / a * 100),
|
|
117
|
+
b: Math.round(a * 100)
|
|
118
|
+
};
|
|
119
|
+
}, v = (e, t, n, r, i) => (r === e ? ((t - n) / i + (t < n ? 6 : 0)) / 6 : r === t ? ((n - e) / i + 2) / 6 : ((e - t) / i + 4) / 6) * 360, y = (e) => e.toString(16).padStart(2, "0"), b = (e) => String(Math.round(e * 100) / 100), x = (e) => Math.round(e / 17).toString(16), S = (e, t) => {
|
|
120
|
+
let n = !p(e);
|
|
121
|
+
switch (t) {
|
|
122
|
+
case "hex3": return n ? `#${x(e.r)}${x(e.g)}${x(e.b)}` : void 0;
|
|
123
|
+
case "rgb": return n ? `rgb(${e.r}, ${e.g}, ${e.b})` : `rgba(${e.r}, ${e.g}, ${e.b}, ${b(e.a)})`;
|
|
124
|
+
case "hsb": {
|
|
125
|
+
let { h: t, s: r, b: i } = _(e);
|
|
126
|
+
return n ? `hsb(${t}, ${r}%, ${i}%)` : `hsba(${t}, ${r}%, ${i}%, ${b(e.a)})`;
|
|
127
|
+
}
|
|
128
|
+
default: {
|
|
129
|
+
let t = `#${y(e.r)}${y(e.g)}${y(e.b)}`;
|
|
130
|
+
return n ? t : `${t}${y(Math.round(e.a * 255))}`;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}, C = (e) => {
|
|
134
|
+
let t = d(e);
|
|
135
|
+
return t ? S(t, "hex") : void 0;
|
|
136
|
+
}, w = (e) => `color.placeholder.${e}`;
|
|
137
|
+
export { e as COLOR_SAVE_FORMATS, t as DEFAULT_COLOR_SAVE_FORMAT, n as asColorSaveFormat, g as hsbToRgb, h as hslToRgb, f as isColor, p as isTransparent, i as normalizeHue, d as parseColor, w as placeholderKeyFor, _ as rgbToHsb, S as serializeColor, C as toCssColor };
|
|
138
|
+
|
|
139
|
+
//# sourceMappingURL=colorFormat.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"colorFormat.esm.js","names":["COLOR_SAVE_FORMATS","DEFAULT_COLOR_SAVE_FORMAT","asColorSaveFormat","value","clamp","max","min","normalizeHue","hue","HEX","FUNCTIONAL","NUMBER","parseArgs","parsed","text","part","percent","parseAlpha","arg","alpha","expand3","hex","digit","parseColor","digits","full","functional","name","args","channels","channel","second","third","hslToRgb","hsbToRgb","isColor","isTransparent","color","hueToRgbChannel","shifted","t","p","q","h","saturation","s","lightness","l","gray","brightness","b","sector","offset","r","g","blue","rgbToHsb","delta","hueOf","pad","formatAlpha","a","toHex3Digit","serializeColor","opaque","format","base","toCssColor","placeholderKeyFor"],"sources":["../../src/formats/colorFormat.ts"],"sourcesContent":["/**\n * Color parsing and serialization for the color control.\n *\n * Section 18 of the portable specification makes \"color syntax, parsing,\n * serialization, and validator registration one coherent contract\", so all of\n * it lives in one module with no React and no antd in it: the control wires\n * widgets to these functions and nothing else decides what a stored color\n * looks like.\n *\n * Why not delegate to the picker's own color object? Two reasons.\n *\n * - **It cannot report failure.** antd's `AggregationColor` wraps\n * `@ant-design/fast-color`, which silently yields opaque black for anything\n * it does not recognize. The specification requires the opposite: \"invalid or\n * unsupported incoming values remain visible with errors rather than being\n * replaced by the picker's fallback color\". A parser that answers `#000000`\n * to `not a color` cannot support that, so {@link parseColor} returns\n * `undefined` instead and the raw text stays in the data for validation to\n * report.\n * - **Its output text is not the specified text.** `toRgbString()` emits\n * `rgb(0,255,0)` - no spaces - while the specification fixes the serialized\n * form as `rgb(r, g, b)`. `@ant-design/fast-color` is also a transitive\n * dependency of antd rather than one this package declares, so its exact\n * spelling is not ours to rely on.\n *\n * Hue normalization policy, which section 18 asks each implementation to\n * document: hue is reduced into `[0, 360)` and rounded to a whole degree, so\n * `hsb(-30, ...)` and `hsb(330, ...)` serialize identically. Saturation,\n * lightness and brightness are rounded to whole percentages; alpha is rounded\n * to two decimals. Round-tripping through a representation with fewer bits than\n * 8-bit RGB is therefore lossy by construction - see {@link serializeColor}.\n */\n\n/**\n * The representations a stored color can be serialized to.\n *\n * `hsl` is **accepted as input but never emitted**, which differs from section\n * 18's list of four save formats. antd's picker edits in HSB and offers no HSL\n * panel, and a save format the editor cannot display is a trap: the user drags\n * one model and the data records another, with a double rounding between them.\n * Every format here is one the picker can show, so what is edited is what is\n * stored. See Adjustment 8.1.\n */\nexport type ColorSaveFormat = 'hex' | 'hex3' | 'rgb' | 'hsb';\n\n/** Every supported save format, in the order the documentation lists them. */\nexport const COLOR_SAVE_FORMATS: ColorSaveFormat[] = [\n 'hex',\n 'hex3',\n 'rgb',\n 'hsb',\n];\n\nexport const DEFAULT_COLOR_SAVE_FORMAT: ColorSaveFormat = 'hex';\n\n/** A parsed color: 8-bit channels plus alpha in `[0, 1]`. */\nexport interface Rgba {\n r: number;\n g: number;\n b: number;\n a: number;\n}\n\n/**\n * Narrows an authored `colorSaveFormat` to a supported one.\n *\n * An unrecognized value falls back to `hex` rather than being passed through:\n * before this existed, `colorSaveFormat: \"rgb\"` was simply not matched and\n * silently produced hex, which is the same outcome but by accident. Doing it\n * here keeps the fallback in one place and lets a caller detect the mismatch.\n */\nexport const asColorSaveFormat = (value: unknown): ColorSaveFormat =>\n COLOR_SAVE_FORMATS.includes(value as ColorSaveFormat)\n ? (value as ColorSaveFormat)\n : DEFAULT_COLOR_SAVE_FORMAT;\n\nconst clamp = (value: number, min: number, max: number): number =>\n Math.min(max, Math.max(min, value));\n\n/** Reduces a hue in degrees into `[0, 360)`, rounded to a whole degree. */\nexport const normalizeHue = (hue: number): number => {\n const rounded = Math.round(hue);\n return ((rounded % 360) + 360) % 360;\n};\n\nconst HEX = /^#(?:[0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i;\nconst FUNCTIONAL = /^(rgba?|hsla?|hsba?)\\(([^()]*)\\)$/i;\n\n/** `12`, `12.5`, `-3`, `50%` - a single functional-notation argument. */\nconst NUMBER = /^[+-]?(?:\\d+\\.?\\d*|\\.\\d+)%?$/;\n\nconst parseArgs = (\n text: string,\n): { value: number; percent: boolean }[] | undefined => {\n // CSS Color 4 permits `rgb(0 255 0 / 50%)`; the specification's initial\n // profile is the comma-separated form only, so a space-separated argument\n // list is a parse failure rather than a second accepted syntax.\n const parts = text.split(',').map((part) => part.trim());\n const parsed = parts.map((part) => {\n if (!NUMBER.test(part)) {\n return undefined;\n }\n const percent = part.endsWith('%');\n return {\n value: Number(percent ? part.slice(0, -1) : part),\n percent,\n };\n });\n return parsed.every((part) => part !== undefined)\n ? (parsed as { value: number; percent: boolean }[])\n : undefined;\n};\n\nconst parseAlpha = (\n arg: { value: number; percent: boolean } | undefined,\n): number | undefined => {\n if (arg === undefined) {\n return 1;\n }\n const alpha = arg.percent ? arg.value / 100 : arg.value;\n return alpha >= 0 && alpha <= 1 ? alpha : undefined;\n};\n\nconst expand3 = (hex: string): string =>\n [...hex].map((digit) => digit + digit).join('');\n\n/**\n * Parses any representation in the supported input profile.\n *\n * The profile, per section 18: `#RGB`, `#RRGGBB` and `#RRGGBBAA` in either\n * letter case, plus `rgb()`/`rgba()`, `hsl()`/`hsla()` and - by Adjustment 8 -\n * `hsb()`/`hsba()`. Named CSS colors, further color spaces and the remaining\n * CSS syntaxes are explicitly outside it.\n *\n * Returns `undefined` for anything else, including `#RGBA`: four-digit hex is\n * not in the profile, and accepting it here would mean emitting a\n * representation the registered format validator is not required to accept.\n */\nexport const parseColor = (value: unknown): Rgba | undefined => {\n if (typeof value !== 'string') {\n return undefined;\n }\n const text = value.trim();\n if (HEX.test(text)) {\n const digits = text.slice(1);\n const full = digits.length === 3 ? expand3(digits) : digits;\n return {\n r: parseInt(full.slice(0, 2), 16),\n g: parseInt(full.slice(2, 4), 16),\n b: parseInt(full.slice(4, 6), 16),\n a: full.length === 8 ? parseInt(full.slice(6, 8), 16) / 255 : 1,\n };\n }\n const functional = FUNCTIONAL.exec(text);\n if (!functional) {\n return undefined;\n }\n const name = functional[1].toLowerCase();\n const args = parseArgs(functional[2]);\n if (!args || args.length < 3 || args.length > 4) {\n return undefined;\n }\n // `rgba(...)` with three arguments is opaque, and `rgb(...)` with four\n // carries alpha; CSS Color 4 made the two names synonyms, and rejecting the\n // combination would refuse text browsers accept.\n const alpha = parseAlpha(args[3]);\n if (alpha === undefined) {\n return undefined;\n }\n if (name.startsWith('rgb')) {\n // Section 18: \"RGB channels are integers from 0 to 255\". Percentage\n // channels are not in the profile, and a value outside the range is a\n // typing error worth reporting rather than clamping into a different\n // color the author did not write.\n const channels = args.slice(0, 3);\n if (\n channels.some(\n ({ value: channel, percent }) =>\n percent || !Number.isInteger(channel) || channel < 0 || channel > 255,\n )\n ) {\n return undefined;\n }\n return {\n r: channels[0].value,\n g: channels[1].value,\n b: channels[2].value,\n a: alpha,\n };\n }\n // The `%` sign is optional on input for saturation, lightness and\n // brightness - a hand-typed `hsl(120, 100, 50)` means the obvious thing -\n // but serialization always writes it.\n const hue = args[0].percent ? undefined : args[0].value;\n if (hue === undefined) {\n return undefined;\n }\n const second = args[1].value;\n const third = args[2].value;\n if (second < 0 || second > 100 || third < 0 || third > 100) {\n return undefined;\n }\n const rgb = name.startsWith('hsl')\n ? hslToRgb(hue, second, third)\n : hsbToRgb(hue, second, third);\n return { ...rgb, a: alpha };\n};\n\n/** Whether a value is a color this profile recognizes. */\nexport const isColor = (value: unknown): boolean =>\n parseColor(value) !== undefined;\n\n/** Whether a parsed color carries transparency. */\nexport const isTransparent = (color: Rgba): boolean => color.a < 1;\n\nconst hueToRgbChannel = (p: number, q: number, t: number): number => {\n let shifted = t;\n if (shifted < 0) shifted += 1;\n if (shifted > 1) shifted -= 1;\n if (shifted < 1 / 6) return p + (q - p) * 6 * shifted;\n if (shifted < 1 / 2) return q;\n if (shifted < 2 / 3) return p + (q - p) * (2 / 3 - shifted) * 6;\n return p;\n};\n\n/** `h` in degrees, `s`/`l` as percentages. */\nexport const hslToRgb = (\n h: number,\n s: number,\n l: number,\n): { r: number; g: number; b: number } => {\n const hue = normalizeHue(h) / 360;\n const saturation = clamp(s, 0, 100) / 100;\n const lightness = clamp(l, 0, 100) / 100;\n if (saturation === 0) {\n const gray = Math.round(lightness * 255);\n return { r: gray, g: gray, b: gray };\n }\n const q =\n lightness < 0.5\n ? lightness * (1 + saturation)\n : lightness + saturation - lightness * saturation;\n const p = 2 * lightness - q;\n return {\n r: Math.round(hueToRgbChannel(p, q, hue + 1 / 3) * 255),\n g: Math.round(hueToRgbChannel(p, q, hue) * 255),\n b: Math.round(hueToRgbChannel(p, q, hue - 1 / 3) * 255),\n };\n};\n\n/** `h` in degrees, `s`/`b` as percentages. HSB is HSV under antd's name. */\nexport const hsbToRgb = (\n h: number,\n s: number,\n b: number,\n): { r: number; g: number; b: number } => {\n const hue = normalizeHue(h) / 60;\n const saturation = clamp(s, 0, 100) / 100;\n const brightness = clamp(b, 0, 100) / 100;\n const sector = Math.floor(hue) % 6;\n const offset = hue - Math.floor(hue);\n const p = brightness * (1 - saturation);\n const q = brightness * (1 - saturation * offset);\n const t = brightness * (1 - saturation * (1 - offset));\n const [r, g, blue] = [\n [brightness, t, p],\n [q, brightness, p],\n [p, brightness, t],\n [p, q, brightness],\n [t, p, brightness],\n [brightness, p, q],\n ][sector];\n return {\n r: Math.round(r * 255),\n g: Math.round(g * 255),\n b: Math.round(blue * 255),\n };\n};\n\nexport const rgbToHsb = (color: Rgba): { h: number; s: number; b: number } => {\n const r = color.r / 255;\n const g = color.g / 255;\n const b = color.b / 255;\n const max = Math.max(r, g, b);\n const delta = max - Math.min(r, g, b);\n return {\n h: delta === 0 ? 0 : normalizeHue(hueOf(r, g, b, max, delta)),\n s: max === 0 ? 0 : Math.round((delta / max) * 100),\n b: Math.round(max * 100),\n };\n};\n\nconst hueOf = (\n r: number,\n g: number,\n b: number,\n max: number,\n delta: number,\n): number => {\n const sixth =\n max === r\n ? ((g - b) / delta + (g < b ? 6 : 0)) / 6\n : max === g\n ? ((b - r) / delta + 2) / 6\n : ((r - g) / delta + 4) / 6;\n return sixth * 360;\n};\n\nconst pad = (channel: number): string => channel.toString(16).padStart(2, '0');\n\n/** Two decimals, with no trailing zeros: `0.5`, `0.25`, `1`. */\nconst formatAlpha = (a: number): string => String(Math.round(a * 100) / 100);\n\n/**\n * Quantizes an 8-bit channel to its nearest three-digit-hex digit.\n *\n * Section 18 fixes the arithmetic as `round(channel / 17)`, and names the\n * vector: `#ed5050` becomes `#e55`, which represents `#ee5555`. This picks the\n * nearest of the 4,096 representable colors; it is not a lossless abbreviation.\n */\nconst toHex3Digit = (channel: number): string =>\n Math.round(channel / 17).toString(16);\n\n/**\n * Writes a parsed color in the requested representation.\n *\n * Returns `undefined` only for `hex3` with transparency, which the\n * specification says must never silently discard alpha: the caller refuses the\n * edit and shows `color.hex3Transparency` instead of committing an opaque\n * replacement.\n *\n * Every other format round-trips through 8-bit RGB, so `hsb` output is\n * quantized twice - once into 8-bit channels and once into whole percentages.\n * Re-saving the same color is stable.\n *\n * There is no `hsl` case: HSL is accepted as *input*, via {@link hslToRgb},\n * but is never written, because the picker cannot edit it. There is\n * deliberately no rgb-to-hsl conversion here at all - an unused inverse would\n * read as an output format that exists. See {@link ColorSaveFormat}.\n */\nexport const serializeColor = (\n color: Rgba,\n format: ColorSaveFormat,\n): string | undefined => {\n const opaque = !isTransparent(color);\n switch (format) {\n case 'hex3':\n if (!opaque) {\n return undefined;\n }\n return `#${toHex3Digit(color.r)}${toHex3Digit(color.g)}${toHex3Digit(\n color.b,\n )}`;\n case 'rgb':\n return opaque\n ? `rgb(${color.r}, ${color.g}, ${color.b})`\n : `rgba(${color.r}, ${color.g}, ${color.b}, ${formatAlpha(color.a)})`;\n case 'hsb': {\n const { h, s, b } = rgbToHsb(color);\n return opaque\n ? `hsb(${h}, ${s}%, ${b}%)`\n : `hsba(${h}, ${s}%, ${b}%, ${formatAlpha(color.a)})`;\n }\n case 'hex':\n default: {\n const base = `#${pad(color.r)}${pad(color.g)}${pad(color.b)}`;\n // Eight-digit hex quantizes alpha to 1/255, so `rgba(..., 0.5)` stores as\n // `#...80` and reads back as 0.502. That is the precision limit section\n // 18 asks to be documented, not a rounding bug.\n return opaque ? base : `${base}${pad(Math.round(color.a * 255))}`;\n }\n }\n};\n\n/**\n * A CSS color string for a stored value, for a swatch's `background`.\n *\n * `hsb()` is not CSS, and a browser given it paints nothing, so a swatch must\n * never be handed the stored text directly once HSB output is available.\n * Returns `undefined` when the value is not a color, so the caller can draw an\n * empty swatch rather than a misleading one.\n */\nexport const toCssColor = (value: unknown): string | undefined => {\n const parsed = parseColor(value);\n return parsed ? serializeColor(parsed, 'hex') : undefined;\n};\n\n/** The i18n key whose default is the entry syntax for a save format. */\nexport const placeholderKeyFor = (format: ColorSaveFormat) =>\n `color.placeholder.${format}` as const;\n"],"mappings":";AA8CA,IAAaA,IAAwC;CACnD;CACA;CACA;CACA;AACF,GAEaC,IAA6C,OAkB7CC,KAAqB,MAChCF,EAAmB,SAASG,CAAwB,IAC/CA,IAAA,OAGDC,KAAS,GAAe,GAAa,MACzC,KAAK,IAAIC,GAAK,KAAK,IAAIC,GAAKH,CAAK,CAAC,GAGvBI,KAAgB,OACX,KAAK,MAAMC,CAClB,IAAU,MAAO,OAAO,KAG7BC,IAAM,+CACNC,IAAa,sCAGbC,IAA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K,OACH,OAAO2B,IACH,OAAO3B,EAAM,EAAE,IAAIA,EAAM,EAAE,IAAIA,EAAM,EAAE,KACvC,QAAQA,EAAM,EAAE,IAAIA,EAAM,EAAE,IAAIA,EAAM,EAAE,IAAIuB,EAAYvB,EAAM,CAAC,EAAE;EACvE,KAAK,OAAO;GACV,IAAM,EAAE,MAAG,MAAG,SAAMmB,EAASnB,CAAK;GAClC,OAAO2B,IACH,OAAOrB,EAAE,IAAIE,EAAE,KAAKK,EAAE,MACtB,QAAQP,EAAE,IAAIE,EAAE,KAAKK,EAAE,KAAKU,EAAYvB,EAAM,CAAC,EAAE;EACvD;EAEA,SAAS;GACP,IAAM6B,IAAO,IAAIP,EAAItB,EAAM,CAAC,IAAIsB,EAAItB,EAAM,CAAC,IAAIsB,EAAItB,EAAM,CAAC;GAI1D,OAAO2B,IAASE,IAAO,GAAGA,IAAOP,EAAI,KAAK,MAAMtB,EAAM,IAAI,GAAG,CAAC;EAChE;CACF;AACF,GAUa8B,KAAc,MAAuC;CAChE,IAAMtD,IAASU,EAAWpB,CAAK;CAC/B,OAAOU,IAASkD,EAAelD,GAAQ,KAAK,IAAI,KAAA;AAClD,GAGauD,KAAqB,MAChC,qBAAqBH"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../rolldown-runtime-BocRIvOZ.js");let t=require("dayjs");t=e.t(t);let n=require("dayjs/plugin/customParseFormat");n=e.t(n);let r=require("dayjs/plugin/advancedFormat");r=e.t(r);let i=require("dayjs/plugin/localeData");i=e.t(i);let a=require("dayjs/plugin/weekday");a=e.t(a);let o=require("dayjs/plugin/weekOfYear");o=e.t(o);let s=require("dayjs/plugin/weekYear");s=e.t(s);let c=require("dayjs/plugin/utc");c=e.t(c);let l=require("dayjs/plugin/timezone");l=e.t(l),t.default.extend(n.default),t.default.extend(r.default),t.default.extend(a.default),t.default.extend(i.default),t.default.extend(o.default),t.default.extend(s.default),t.default.extend(c.default),t.default.extend(l.default);var u=(e,t)=>{let n=`__JSONFORMS_FOUR_DIGIT_YEAR__`,r=t.replace(/YYYY/g,`[${n}]`);return e.format(r).replace(RegExp(n,`g`),String(e.year()).padStart(4,`0`))},d=(e,n)=>{if(!e)return null;let r=(0,t.default)(e,n);return r.isValid()?r:null};exports.formatDate=u,exports.parseDateValue=d;
|
|
2
|
+
//# sourceMappingURL=dateValues.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dateValues.cjs.js","names":["customParsing","advancedFormat","weekday","localeData","weekOfYear","weekYear","utc","timezone","require_rolldown_runtime","dayjs","dayjs_plugin_customParseFormat","dayjs_plugin_advancedFormat","dayjs_plugin_localeData","dayjs_plugin_weekday","dayjs_plugin_weekOfYear","dayjs_plugin_weekYear","dayjs_plugin_utc","dayjs_plugin_timezone","formatDate","yearToken","formatWithYearPlaceholder","saveFormat","date","parseDateValue","data","dayjsData","format"],"sources":["../../src/formats/dateValues.ts"],"sourcesContent":["import dayjs from 'dayjs';\nimport customParsing from 'dayjs/plugin/customParseFormat';\nimport advancedFormat from 'dayjs/plugin/advancedFormat';\nimport localeData from 'dayjs/plugin/localeData';\nimport weekday from 'dayjs/plugin/weekday';\nimport weekOfYear from 'dayjs/plugin/weekOfYear';\nimport weekYear from 'dayjs/plugin/weekYear';\nimport utc from 'dayjs/plugin/utc';\nimport timezone from 'dayjs/plugin/timezone'; // dependent on utc plugin\n\n// required for the custom save formats in the date, time and date-time pickers\ndayjs.extend(customParsing);\ndayjs.extend(advancedFormat);\ndayjs.extend(weekday);\ndayjs.extend(localeData);\ndayjs.extend(weekOfYear);\ndayjs.extend(weekYear);\ndayjs.extend(utc);\ndayjs.extend(timezone);\n\nexport const formatDate = (date: dayjs.Dayjs, saveFormat: string) => {\n const yearToken = '__JSONFORMS_FOUR_DIGIT_YEAR__';\n const formatWithYearPlaceholder = saveFormat.replace(\n /YYYY/g,\n `[${yearToken}]`,\n );\n\n return date\n .format(formatWithYearPlaceholder)\n .replace(new RegExp(yearToken, 'g'), String(date.year()).padStart(4, '0'));\n};\n\nexport const parseDateValue = (\n data: dayjs.ConfigType,\n format?: string | string[],\n): dayjs.Dayjs | null => {\n if (!data) {\n return null;\n }\n const dayjsData = dayjs(data, format);\n if (!dayjsData.isValid()) {\n return null;\n }\n return dayjsData;\n};\n"],"mappings":"A,miBAWAS,EAAA,QAAM,OAAOT,EAAAA,OAAa,EAC1BS,EAAA,QAAM,OAAOR,EAAAA,OAAc,EAC3BQ,EAAA,QAAM,OAAOP,EAAAA,OAAO,EACpBO,EAAA,QAAM,OAAON,EAAAA,OAAU,EACvBM,EAAA,QAAM,OAAOL,EAAAA,OAAU,EACvBK,EAAA,QAAM,OAAOJ,EAAAA,OAAQ,EACrBI,EAAA,QAAM,OAAOH,EAAAA,OAAG,EAChBG,EAAA,QAAM,OAAOF,EAAAA,OAAQ,EAErB,IAAaW,GAAc,EAAmB,IAAuB,CACnE,IAAMC,EAAY,gCACZC,EAA4BC,EAAW,QAC3C,QACA,IAAIF,EAAU,EAChB,EAEA,OAAOG,EACJ,OAAOF,CAAyB,CAAC,CACjC,QAAY,OAAOD,EAAW,GAAG,EAAG,OAAOG,EAAK,KAAK,CAAC,CAAC,CAAC,SAAS,EAAG,GAAG,CAAC,CAC7E,EAEaC,GACX,EACA,IACuB,CACvB,GAAI,CAACC,EACH,OAAO,KAET,IAAMC,GAAA,EAAYhB,EAAA,QAAA,CAAMe,EAAME,CAAM,EAIpC,OAHKD,EAAU,QAAQ,EAGhBA,EAFE,IAGX,E"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import e from "dayjs";
|
|
2
|
+
import t from "dayjs/plugin/customParseFormat";
|
|
3
|
+
import n from "dayjs/plugin/advancedFormat";
|
|
4
|
+
import r from "dayjs/plugin/localeData";
|
|
5
|
+
import i from "dayjs/plugin/weekday";
|
|
6
|
+
import a from "dayjs/plugin/weekOfYear";
|
|
7
|
+
import o from "dayjs/plugin/weekYear";
|
|
8
|
+
import s from "dayjs/plugin/utc";
|
|
9
|
+
import c from "dayjs/plugin/timezone";
|
|
10
|
+
e.extend(t), e.extend(n), e.extend(i), e.extend(r), e.extend(a), e.extend(o), e.extend(s), e.extend(c);
|
|
11
|
+
var l = (e, t) => {
|
|
12
|
+
let n = "__JSONFORMS_FOUR_DIGIT_YEAR__", r = t.replace(/YYYY/g, `[${n}]`);
|
|
13
|
+
return e.format(r).replace(RegExp(n, "g"), String(e.year()).padStart(4, "0"));
|
|
14
|
+
}, u = (t, n) => {
|
|
15
|
+
if (!t) return null;
|
|
16
|
+
let r = e(t, n);
|
|
17
|
+
return r.isValid() ? r : null;
|
|
18
|
+
};
|
|
19
|
+
export { l as formatDate, u as parseDateValue };
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=dateValues.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dateValues.esm.js","names":["dayjs","customParsing","advancedFormat","localeData","weekday","weekOfYear","weekYear","utc","timezone","formatDate","yearToken","formatWithYearPlaceholder","saveFormat","date","parseDateValue","data","dayjsData","format"],"sources":["../../src/formats/dateValues.ts"],"sourcesContent":["import dayjs from 'dayjs';\nimport customParsing from 'dayjs/plugin/customParseFormat';\nimport advancedFormat from 'dayjs/plugin/advancedFormat';\nimport localeData from 'dayjs/plugin/localeData';\nimport weekday from 'dayjs/plugin/weekday';\nimport weekOfYear from 'dayjs/plugin/weekOfYear';\nimport weekYear from 'dayjs/plugin/weekYear';\nimport utc from 'dayjs/plugin/utc';\nimport timezone from 'dayjs/plugin/timezone'; // dependent on utc plugin\n\n// required for the custom save formats in the date, time and date-time pickers\ndayjs.extend(customParsing);\ndayjs.extend(advancedFormat);\ndayjs.extend(weekday);\ndayjs.extend(localeData);\ndayjs.extend(weekOfYear);\ndayjs.extend(weekYear);\ndayjs.extend(utc);\ndayjs.extend(timezone);\n\nexport const formatDate = (date: dayjs.Dayjs, saveFormat: string) => {\n const yearToken = '__JSONFORMS_FOUR_DIGIT_YEAR__';\n const formatWithYearPlaceholder = saveFormat.replace(\n /YYYY/g,\n `[${yearToken}]`,\n );\n\n return date\n .format(formatWithYearPlaceholder)\n .replace(new RegExp(yearToken, 'g'), String(date.year()).padStart(4, '0'));\n};\n\nexport const parseDateValue = (\n data: dayjs.ConfigType,\n format?: string | string[],\n): dayjs.Dayjs | null => {\n if (!data) {\n return null;\n }\n const dayjsData = dayjs(data, format);\n if (!dayjsData.isValid()) {\n return null;\n }\n return dayjsData;\n};\n"],"mappings":";;;;;;;;;AAWAA,EAAM,OAAOC,CAAa,GAC1BD,EAAM,OAAOE,CAAc,GAC3BF,EAAM,OAAOI,CAAO,GACpBJ,EAAM,OAAOG,CAAU,GACvBH,EAAM,OAAOK,CAAU,GACvBL,EAAM,OAAOM,CAAQ,GACrBN,EAAM,OAAOO,CAAG,GAChBP,EAAM,OAAOQ,CAAQ;AAErB,IAAaC,KAAc,GAAmB,MAAuB;CACnE,IAAMC,IAAY,iCACZC,IAA4BC,EAAW,QAC3C,SACA,IAAIF,EAAU,EAChB;CAEA,OAAOG,EACJ,OAAOF,CAAyB,CAAC,CACjC,QAAY,OAAOD,GAAW,GAAG,GAAG,OAAOG,EAAK,KAAK,CAAC,CAAC,CAAC,SAAS,GAAG,GAAG,CAAC;AAC7E,GAEaC,KACX,GACA,MACuB;CACvB,IAAI,CAACC,GACH,OAAO;CAET,IAAMC,IAAYhB,EAAMe,GAAME,CAAM;CAIpC,OAHKD,EAAU,QAAQ,IAGhBA,IAFE;AAGX"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e={years:0,months:0,days:0,hours:0,minutes:0,seconds:0},t=/^P(?:(?<years>\d+)Y)?(?:(?<months>\d+)M)?(?:(?<days>\d+)D)?(?:T(?:(?<hours>\d+)H)?(?:(?<minutes>\d+)M)?(?:(?<seconds>\d+)S)?)?$/i,n=e=>{if(typeof e!=`string`||!e.trim())return null;let n=e.trim().match(t);if(!(n!=null&&n.groups)||!Object.values(n.groups).some(Boolean))return null;let r=e=>e?Number.parseInt(e,10):0;return{years:r(n.groups.years),months:r(n.groups.months),days:r(n.groups.days),hours:r(n.groups.hours),minutes:r(n.groups.minutes),seconds:r(n.groups.seconds)}},r=e=>Object.fromEntries(Object.entries(e).map(([e,t])=>[e,Math.max(0,Math.floor(t||0))])),i=e=>a(r(e)),a=e=>{let t=(e,t)=>e?`${e}${t}`:``,n=t(e.years,`Y`)+t(e.months,`M`)+t(e.days,`D`),r=t(e.hours,`H`)+t(e.minutes,`M`)+t(e.seconds,`S`);return n||r?`P${n}${r?`T${r}`:``}`:`P0D`};exports.EMPTY_DURATION=e,exports.formatDuration=i,exports.formatDurationComponents=a,exports.parseDuration=n,exports.sanitizeComponents=r;
|
|
2
|
+
//# sourceMappingURL=duration.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"duration.cjs.js","names":["EMPTY_DURATION","DURATION","parseDuration","value","match","number","part","sanitizeComponents","parts","key","formatDuration","formatDurationComponents","unit","suffix","date","time"],"sources":["../../src/formats/duration.ts"],"sourcesContent":["export interface DurationParts {\n years: number;\n months: number;\n days: number;\n hours: number;\n minutes: number;\n seconds: number;\n}\n\nexport const EMPTY_DURATION: DurationParts = {\n years: 0,\n months: 0,\n days: 0,\n hours: 0,\n minutes: 0,\n seconds: 0,\n};\n\nconst DURATION =\n /^P(?:(?<years>\\d+)Y)?(?:(?<months>\\d+)M)?(?:(?<days>\\d+)D)?(?:T(?:(?<hours>\\d+)H)?(?:(?<minutes>\\d+)M)?(?:(?<seconds>\\d+)S)?)?$/i;\n\nexport const parseDuration = (value: unknown): DurationParts | null => {\n if (typeof value !== 'string' || !value.trim()) return null;\n const match = value.trim().match(DURATION);\n if (!match?.groups || !Object.values(match.groups).some(Boolean)) return null;\n const number = (part?: string) => (part ? Number.parseInt(part, 10) : 0);\n return {\n years: number(match.groups.years),\n months: number(match.groups.months),\n days: number(match.groups.days),\n hours: number(match.groups.hours),\n minutes: number(match.groups.minutes),\n seconds: number(match.groups.seconds),\n };\n};\n\nexport const sanitizeComponents = <T extends DurationParts>(parts: T): T =>\n Object.fromEntries(\n Object.entries(parts).map(([key, value]) => [\n key,\n Math.max(0, Math.floor(value || 0)),\n ]),\n ) as unknown as T;\n\nexport const formatDuration = (parts: DurationParts) => {\n const safe = sanitizeComponents(parts);\n return formatDurationComponents(safe);\n};\n\nexport const formatDurationComponents = (parts: DurationParts) => {\n const unit = (value: number, suffix: string) =>\n value ? `${value}${suffix}` : '';\n const date =\n unit(parts.years, 'Y') + unit(parts.months, 'M') + unit(parts.days, 'D');\n const time =\n unit(parts.hours, 'H') +\n unit(parts.minutes, 'M') +\n unit(parts.seconds, 'S');\n return date || time ? `P${date}${time ? `T${time}` : ''}` : 'P0D';\n};\n"],"mappings":"A,mEASA,IAAaA,EAAgC,CAC3C,MAAO,EACP,OAAQ,EACR,KAAM,EACN,MAAO,EACP,QAAS,EACT,QAAS,CACX,EAEMC,EACJ,mIAEWC,EAAiB,GAAyC,CACrE,GAAI,OAAOC,GAAU,UAAY,CAACA,EAAM,KAAK,EAAG,OAAO,KACvD,IAAMC,EAAQD,EAAM,KAAK,CAAC,CAAC,MAAMF,CAAQ,EACzC,GAAI,EAAAG,GAAA,MAACA,EAAO,SAAU,CAAC,OAAO,OAAOA,EAAM,MAAM,CAAC,CAAC,KAAK,OAAO,EAAG,OAAO,KACzE,IAAMC,EAAU,GAAmBC,EAAO,OAAO,SAASA,EAAM,EAAE,EAAI,EACtE,MAAO,CACL,MAAOD,EAAOD,EAAM,OAAO,KAAK,EAChC,OAAQC,EAAOD,EAAM,OAAO,MAAM,EAClC,KAAMC,EAAOD,EAAM,OAAO,IAAI,EAC9B,MAAOC,EAAOD,EAAM,OAAO,KAAK,EAChC,QAASC,EAAOD,EAAM,OAAO,OAAO,EACpC,QAASC,EAAOD,EAAM,OAAO,OAAO,CACtC,CACF,EAEaG,EAA+C,GAC1D,OAAO,YACL,OAAO,QAAQC,CAAK,CAAC,CAAC,KAAK,CAACC,EAAKN,KAAW,CAC1CM,EACA,KAAK,IAAI,EAAG,KAAK,MAAMN,GAAS,CAAC,CAAC,CACpC,CAAC,CACH,EAEWO,EAAkB,GAEtBC,EADMJ,EAAmBC,CACA,CAAI,EAGzBG,EAA4B,GAAyB,CAChE,IAAMC,GAAQ,EAAe,IAC3BT,EAAQ,GAAGA,IAAQU,IAAW,GAC1BC,EACJF,EAAKJ,EAAM,MAAO,GAAG,EAAII,EAAKJ,EAAM,OAAQ,GAAG,EAAII,EAAKJ,EAAM,KAAM,GAAG,EACnEO,EACJH,EAAKJ,EAAM,MAAO,GAAG,EACrBI,EAAKJ,EAAM,QAAS,GAAG,EACvBI,EAAKJ,EAAM,QAAS,GAAG,EACzB,OAAOM,GAAQC,EAAO,IAAID,IAAOC,EAAO,IAAIA,IAAS,KAAO,KAC9D,E"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface DurationParts {
|
|
2
|
+
years: number;
|
|
3
|
+
months: number;
|
|
4
|
+
days: number;
|
|
5
|
+
hours: number;
|
|
6
|
+
minutes: number;
|
|
7
|
+
seconds: number;
|
|
8
|
+
}
|
|
9
|
+
export declare const EMPTY_DURATION: DurationParts;
|
|
10
|
+
export declare const parseDuration: (value: unknown) => DurationParts | null;
|
|
11
|
+
export declare const sanitizeComponents: <T extends DurationParts>(parts: T) => T;
|
|
12
|
+
export declare const formatDuration: (parts: DurationParts) => string;
|
|
13
|
+
export declare const formatDurationComponents: (parts: DurationParts) => string;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// src/formats/duration.ts
|
|
2
|
+
var e = {
|
|
3
|
+
years: 0,
|
|
4
|
+
months: 0,
|
|
5
|
+
days: 0,
|
|
6
|
+
hours: 0,
|
|
7
|
+
minutes: 0,
|
|
8
|
+
seconds: 0
|
|
9
|
+
}, t = /^P(?:(?<years>\d+)Y)?(?:(?<months>\d+)M)?(?:(?<days>\d+)D)?(?:T(?:(?<hours>\d+)H)?(?:(?<minutes>\d+)M)?(?:(?<seconds>\d+)S)?)?$/i, n = (e) => {
|
|
10
|
+
if (typeof e != "string" || !e.trim()) return null;
|
|
11
|
+
let n = e.trim().match(t);
|
|
12
|
+
if (!(n != null && n.groups) || !Object.values(n.groups).some(Boolean)) return null;
|
|
13
|
+
let r = (e) => e ? Number.parseInt(e, 10) : 0;
|
|
14
|
+
return {
|
|
15
|
+
years: r(n.groups.years),
|
|
16
|
+
months: r(n.groups.months),
|
|
17
|
+
days: r(n.groups.days),
|
|
18
|
+
hours: r(n.groups.hours),
|
|
19
|
+
minutes: r(n.groups.minutes),
|
|
20
|
+
seconds: r(n.groups.seconds)
|
|
21
|
+
};
|
|
22
|
+
}, r = (e) => Object.fromEntries(Object.entries(e).map(([e, t]) => [e, Math.max(0, Math.floor(t || 0))])), i = (e) => a(r(e)), a = (e) => {
|
|
23
|
+
let t = (e, t) => e ? `${e}${t}` : "", n = t(e.years, "Y") + t(e.months, "M") + t(e.days, "D"), r = t(e.hours, "H") + t(e.minutes, "M") + t(e.seconds, "S");
|
|
24
|
+
return n || r ? `P${n}${r ? `T${r}` : ""}` : "P0D";
|
|
25
|
+
};
|
|
26
|
+
export { e as EMPTY_DURATION, i as formatDuration, a as formatDurationComponents, n as parseDuration, r as sanitizeComponents };
|
|
27
|
+
|
|
28
|
+
//# sourceMappingURL=duration.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"duration.esm.js","names":["EMPTY_DURATION","DURATION","parseDuration","value","match","number","part","sanitizeComponents","parts","key","formatDuration","formatDurationComponents","unit","suffix","date","time"],"sources":["../../src/formats/duration.ts"],"sourcesContent":["export interface DurationParts {\n years: number;\n months: number;\n days: number;\n hours: number;\n minutes: number;\n seconds: number;\n}\n\nexport const EMPTY_DURATION: DurationParts = {\n years: 0,\n months: 0,\n days: 0,\n hours: 0,\n minutes: 0,\n seconds: 0,\n};\n\nconst DURATION =\n /^P(?:(?<years>\\d+)Y)?(?:(?<months>\\d+)M)?(?:(?<days>\\d+)D)?(?:T(?:(?<hours>\\d+)H)?(?:(?<minutes>\\d+)M)?(?:(?<seconds>\\d+)S)?)?$/i;\n\nexport const parseDuration = (value: unknown): DurationParts | null => {\n if (typeof value !== 'string' || !value.trim()) return null;\n const match = value.trim().match(DURATION);\n if (!match?.groups || !Object.values(match.groups).some(Boolean)) return null;\n const number = (part?: string) => (part ? Number.parseInt(part, 10) : 0);\n return {\n years: number(match.groups.years),\n months: number(match.groups.months),\n days: number(match.groups.days),\n hours: number(match.groups.hours),\n minutes: number(match.groups.minutes),\n seconds: number(match.groups.seconds),\n };\n};\n\nexport const sanitizeComponents = <T extends DurationParts>(parts: T): T =>\n Object.fromEntries(\n Object.entries(parts).map(([key, value]) => [\n key,\n Math.max(0, Math.floor(value || 0)),\n ]),\n ) as unknown as T;\n\nexport const formatDuration = (parts: DurationParts) => {\n const safe = sanitizeComponents(parts);\n return formatDurationComponents(safe);\n};\n\nexport const formatDurationComponents = (parts: DurationParts) => {\n const unit = (value: number, suffix: string) =>\n value ? `${value}${suffix}` : '';\n const date =\n unit(parts.years, 'Y') + unit(parts.months, 'M') + unit(parts.days, 'D');\n const time =\n unit(parts.hours, 'H') +\n unit(parts.minutes, 'M') +\n unit(parts.seconds, 'S');\n return date || time ? `P${date}${time ? `T${time}` : ''}` : 'P0D';\n};\n"],"mappings":";AASA,IAAaA,IAAgC;CAC3C,OAAO;CACP,QAAQ;CACR,MAAM;CACN,OAAO;CACP,SAAS;CACT,SAAS;AACX,GAEMC,IACJ,oIAEWC,KAAiB,MAAyC;CACrE,IAAI,OAAOC,KAAU,YAAY,CAACA,EAAM,KAAK,GAAG,OAAO;CACvD,IAAMC,IAAQD,EAAM,KAAK,CAAC,CAAC,MAAMF,CAAQ;CACzC,IAAI,EAAAG,KAAA,QAACA,EAAO,WAAU,CAAC,OAAO,OAAOA,EAAM,MAAM,CAAC,CAAC,KAAK,OAAO,GAAG,OAAO;CACzE,IAAMC,KAAU,MAAmBC,IAAO,OAAO,SAASA,GAAM,EAAE,IAAI;CACtE,OAAO;EACL,OAAOD,EAAOD,EAAM,OAAO,KAAK;EAChC,QAAQC,EAAOD,EAAM,OAAO,MAAM;EAClC,MAAMC,EAAOD,EAAM,OAAO,IAAI;EAC9B,OAAOC,EAAOD,EAAM,OAAO,KAAK;EAChC,SAASC,EAAOD,EAAM,OAAO,OAAO;EACpC,SAASC,EAAOD,EAAM,OAAO,OAAO;CACtC;AACF,GAEaG,KAA+C,MAC1D,OAAO,YACL,OAAO,QAAQC,CAAK,CAAC,CAAC,KAAK,CAACC,GAAKN,OAAW,CAC1CM,GACA,KAAK,IAAI,GAAG,KAAK,MAAMN,KAAS,CAAC,CAAC,CACpC,CAAC,CACH,GAEWO,KAAkB,MAEtBC,EADMJ,EAAmBC,CACA,CAAI,GAGzBG,KAA4B,MAAyB;CAChE,IAAMC,KAAQ,GAAe,MAC3BT,IAAQ,GAAGA,IAAQU,MAAW,IAC1BC,IACJF,EAAKJ,EAAM,OAAO,GAAG,IAAII,EAAKJ,EAAM,QAAQ,GAAG,IAAII,EAAKJ,EAAM,MAAM,GAAG,GACnEO,IACJH,EAAKJ,EAAM,OAAO,GAAG,IACrBI,EAAKJ,EAAM,SAAS,GAAG,IACvBI,EAAKJ,EAAM,SAAS,GAAG;CACzB,OAAOM,KAAQC,IAAO,IAAID,IAAOC,IAAO,IAAIA,MAAS,OAAO;AAC9D"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("@jsonforms/core");var t=e=>typeof e==`string`?e.length>0:Array.isArray(e)&&e.length>0&&e.every(e=>typeof e==`string`&&e.length>0),n=e=>{var n;return t((n=e.options)==null?void 0:n.mask)},r=(0,e.or)(...[`color`,`date`,`date-time`,`duration`,`password`,`time`].flatMap(t=>[(0,e.formatIs)(t),(0,e.optionIs)(`format`,t)])),i=(0,e.rankWith)(4,(0,e.and)(e.isStringControl,n,(0,e.not)(r)));exports.extendedMaskTester=i,exports.hasMaskPattern=n,exports.isMaskPattern=t;
|
|
2
|
+
//# sourceMappingURL=maskControls.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"maskControls.cjs.js","names":["or","formatIs","optionIs","rankWith","and","isStringControl","not","_jsonforms_core","isMaskPattern","value","entry","hasMaskPattern","_uischema$options","uischema","hasSpecializedFormat","format","extendedMaskTester"],"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":"A,oGAoCA,IAAaQ,EAAiB,GACxB,OAAOC,GAAU,SACZA,EAAM,OAAS,EAGtB,MAAM,QAAQA,CAAK,GACnBA,EAAM,OAAS,GACfA,EAAM,MAAO,GAAU,OAAOC,GAAU,UAAYA,EAAM,OAAS,CAAC,EAI3DC,EAA0B,GACrC,C,MACG,OAAAH,GAAA,EAAAK,EAAmD,UAAA,KAAA,IAAA,GAAAD,EAAS,IAC/D,C,EAsBIE,GAAA,EAA+Bd,EAAAA,GAAAA,CACnC,GAAG,CATH,QACA,OACA,YACA,WACA,WACA,MAIG,CAAA,CAA2B,QAAS,GAAW,EAAA,EAChDC,EAAAA,SAAAA,CAASc,CAAM,GAAA,EACfb,EAAAA,SAAAA,CAAS,SAAUa,CAAM,CAC3B,CAAC,CACH,EAOaC,GAAA,EAAqBb,EAAAA,SAAAA,CAChC,GAAA,EACAC,EAAAA,IAAAA,CAAIC,EAAAA,gBAAiBM,GAAA,EAAgBL,EAAAA,IAAAA,CAAIQ,CAAoB,CAAC,CAChE,E"}
|