@dnb/eufemia 10.29.0 → 10.30.1
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/CHANGELOG.md +31 -0
- package/cjs/components/checkbox/Checkbox.d.ts +1 -1
- package/cjs/components/checkbox/Checkbox.js +6 -3
- package/cjs/components/checkbox/Checkbox.js.map +1 -1
- package/cjs/components/flex/style/dnb-flex.css +4 -0
- package/cjs/components/flex/style/dnb-flex.min.css +1 -1
- package/cjs/components/flex/style/flex-stack.scss +3 -0
- package/cjs/components/height-animation/HeightAnimationInstance.js +4 -3
- package/cjs/components/height-animation/HeightAnimationInstance.js.map +1 -1
- package/cjs/components/table/useTableAnimationHandler.js +1 -1
- package/cjs/components/table/useTableAnimationHandler.js.map +1 -1
- package/cjs/extensions/forms/DataContext/Context.d.ts +2 -1
- package/cjs/extensions/forms/DataContext/Context.js +0 -1
- package/cjs/extensions/forms/DataContext/Context.js.map +1 -1
- package/cjs/extensions/forms/DataContext/Provider/Provider.d.ts +13 -0
- package/cjs/extensions/forms/DataContext/Provider/Provider.js +17 -6
- package/cjs/extensions/forms/DataContext/Provider/Provider.js.map +1 -1
- package/cjs/extensions/forms/DataContext/Provider/ProviderDocs.js +15 -0
- package/cjs/extensions/forms/DataContext/Provider/ProviderDocs.js.map +1 -1
- package/cjs/extensions/forms/Form/FieldProps/FieldProps.d.ts +15 -0
- package/cjs/extensions/forms/Form/FieldProps/FieldProps.js +87 -0
- package/cjs/extensions/forms/Form/FieldProps/FieldProps.js.map +1 -0
- package/cjs/extensions/forms/Form/FieldProps/FieldPropsContext.d.ts +8 -0
- package/cjs/extensions/forms/Form/FieldProps/FieldPropsContext.js +15 -0
- package/cjs/extensions/forms/Form/FieldProps/FieldPropsContext.js.map +1 -0
- package/cjs/extensions/forms/Form/FieldProps/FieldPropsDocs.d.ts +2 -0
- package/cjs/extensions/forms/Form/FieldProps/FieldPropsDocs.js +18 -0
- package/cjs/extensions/forms/Form/FieldProps/FieldPropsDocs.js.map +1 -0
- package/cjs/extensions/forms/Form/FieldProps/index.d.ts +2 -0
- package/cjs/extensions/forms/Form/FieldProps/index.js +27 -0
- package/cjs/extensions/forms/Form/FieldProps/index.js.map +1 -0
- package/cjs/extensions/forms/Form/Handler/Handler.d.ts +1 -1
- package/cjs/extensions/forms/Form/Handler/Handler.js +11 -3
- package/cjs/extensions/forms/Form/Handler/Handler.js.map +1 -1
- package/cjs/extensions/forms/Form/Visibility/Visibility.d.ts +6 -2
- package/cjs/extensions/forms/Form/Visibility/Visibility.js +20 -11
- package/cjs/extensions/forms/Form/Visibility/Visibility.js.map +1 -1
- package/cjs/extensions/forms/Form/Visibility/VisibilityDocs.js +5 -0
- package/cjs/extensions/forms/Form/Visibility/VisibilityDocs.js.map +1 -1
- package/cjs/extensions/forms/Form/index.d.ts +1 -0
- package/cjs/extensions/forms/Form/index.js +7 -0
- package/cjs/extensions/forms/Form/index.js.map +1 -1
- package/cjs/extensions/forms/ValueBlock/ValueBlock.js +17 -1
- package/cjs/extensions/forms/ValueBlock/ValueBlock.js.map +1 -1
- package/cjs/extensions/forms/Wizard/hooks/useNextRouter.js +7 -5
- package/cjs/extensions/forms/Wizard/hooks/useNextRouter.js.map +1 -1
- package/cjs/extensions/forms/Wizard/hooks/useQueryLocator.d.ts +1 -1
- package/cjs/extensions/forms/Wizard/hooks/useQueryLocator.js +7 -5
- package/cjs/extensions/forms/Wizard/hooks/useQueryLocator.js.map +1 -1
- package/cjs/extensions/forms/Wizard/hooks/useReachRouter.js +8 -6
- package/cjs/extensions/forms/Wizard/hooks/useReachRouter.js.map +1 -1
- package/cjs/extensions/forms/Wizard/hooks/useReactRouter.js +7 -5
- package/cjs/extensions/forms/Wizard/hooks/useReactRouter.js.map +1 -1
- package/cjs/extensions/forms/hooks/useFieldProps.d.ts +2 -2
- package/cjs/extensions/forms/hooks/useFieldProps.js +11 -5
- package/cjs/extensions/forms/hooks/useFieldProps.js.map +1 -1
- package/cjs/extensions/forms/hooks/useTranslation.js +3 -1
- package/cjs/extensions/forms/hooks/useTranslation.js.map +1 -1
- package/cjs/shared/Context.d.ts +2 -0
- package/cjs/shared/Context.js.map +1 -1
- package/cjs/shared/Eufemia.d.ts +1 -1
- package/cjs/shared/Eufemia.js +2 -2
- package/cjs/shared/Eufemia.js.map +1 -1
- package/cjs/shared/component-helper.d.ts +1 -0
- package/cjs/shared/component-helper.js +7 -0
- package/cjs/shared/component-helper.js.map +1 -1
- package/cjs/shared/helpers/assignPropsWithContext.d.ts +1 -0
- package/cjs/shared/helpers/assignPropsWithContext.js +27 -0
- package/cjs/shared/helpers/assignPropsWithContext.js.map +1 -0
- package/cjs/shared/helpers/extendPropsWithContext.d.ts +1 -0
- package/cjs/shared/helpers/extendPropsWithContext.js +1 -0
- package/cjs/shared/helpers/extendPropsWithContext.js.map +1 -1
- package/cjs/shared/helpers/filterValidProps.d.ts +1 -0
- package/cjs/shared/helpers/filterValidProps.js.map +1 -1
- package/cjs/shared/helpers/runCssVersionMismatchWarning.js +13 -3
- package/cjs/shared/helpers/runCssVersionMismatchWarning.js.map +1 -1
- package/cjs/style/core/scopes.scss +1 -1
- package/cjs/style/dnb-ui-basis.css +1 -1
- package/cjs/style/dnb-ui-basis.min.css +1 -1
- package/cjs/style/dnb-ui-body.css +1 -1
- package/cjs/style/dnb-ui-body.min.css +1 -1
- package/cjs/style/dnb-ui-components.css +4 -0
- package/cjs/style/dnb-ui-components.min.css +1 -1
- package/cjs/style/dnb-ui-core.css +1 -1
- package/cjs/style/dnb-ui-core.min.css +1 -1
- package/cjs/style/themes/eiendom/basis.js +4 -0
- package/cjs/style/themes/eiendom/basis.js.map +1 -0
- package/cjs/style/themes/eiendom/index.js +5 -0
- package/cjs/style/themes/eiendom/index.js.map +1 -0
- package/cjs/style/themes/sbanken/basis.js +4 -0
- package/cjs/style/themes/sbanken/basis.js.map +1 -0
- package/cjs/style/themes/sbanken/index.js +5 -0
- package/cjs/style/themes/sbanken/index.js.map +1 -0
- package/cjs/style/themes/theme-eiendom/eiendom-theme-components.css +4 -0
- package/cjs/style/themes/theme-eiendom/eiendom-theme-components.min.css +1 -1
- package/cjs/style/themes/theme-sbanken/sbanken-theme-components.css +4 -0
- package/cjs/style/themes/theme-sbanken/sbanken-theme-components.min.css +1 -1
- package/cjs/style/themes/theme-ui/ui-theme-components.css +4 -0
- package/cjs/style/themes/theme-ui/ui-theme-components.min.css +1 -1
- package/cjs/style/themes/ui/basis.js +4 -0
- package/cjs/style/themes/ui/basis.js.map +1 -0
- package/cjs/style/themes/ui/index.js +5 -0
- package/cjs/style/themes/ui/index.js.map +1 -0
- package/components/checkbox/Checkbox.d.ts +1 -1
- package/components/checkbox/Checkbox.js +6 -3
- package/components/checkbox/Checkbox.js.map +1 -1
- package/components/flex/style/dnb-flex.css +4 -0
- package/components/flex/style/dnb-flex.min.css +1 -1
- package/components/flex/style/flex-stack.scss +3 -0
- package/components/height-animation/HeightAnimationInstance.js +4 -3
- package/components/height-animation/HeightAnimationInstance.js.map +1 -1
- package/components/table/useTableAnimationHandler.js +1 -1
- package/components/table/useTableAnimationHandler.js.map +1 -1
- package/es/components/checkbox/Checkbox.d.ts +1 -1
- package/es/components/checkbox/Checkbox.js +6 -3
- package/es/components/checkbox/Checkbox.js.map +1 -1
- package/es/components/flex/style/dnb-flex.css +4 -0
- package/es/components/flex/style/dnb-flex.min.css +1 -1
- package/es/components/flex/style/flex-stack.scss +3 -0
- package/es/components/height-animation/HeightAnimationInstance.js +4 -3
- package/es/components/height-animation/HeightAnimationInstance.js.map +1 -1
- package/es/components/table/useTableAnimationHandler.js +1 -1
- package/es/components/table/useTableAnimationHandler.js.map +1 -1
- package/es/extensions/forms/DataContext/Context.d.ts +2 -1
- package/es/extensions/forms/DataContext/Context.js +0 -1
- package/es/extensions/forms/DataContext/Context.js.map +1 -1
- package/es/extensions/forms/DataContext/Provider/Provider.d.ts +13 -0
- package/es/extensions/forms/DataContext/Provider/Provider.js +17 -6
- package/es/extensions/forms/DataContext/Provider/Provider.js.map +1 -1
- package/es/extensions/forms/DataContext/Provider/ProviderDocs.js +15 -0
- package/es/extensions/forms/DataContext/Provider/ProviderDocs.js.map +1 -1
- package/es/extensions/forms/Form/FieldProps/FieldProps.d.ts +15 -0
- package/es/extensions/forms/Form/FieldProps/FieldProps.js +78 -0
- package/es/extensions/forms/Form/FieldProps/FieldProps.js.map +1 -0
- package/es/extensions/forms/Form/FieldProps/FieldPropsContext.d.ts +8 -0
- package/es/extensions/forms/Form/FieldProps/FieldPropsContext.js +7 -0
- package/es/extensions/forms/Form/FieldProps/FieldPropsContext.js.map +1 -0
- package/es/extensions/forms/Form/FieldProps/FieldPropsDocs.d.ts +2 -0
- package/es/extensions/forms/Form/FieldProps/FieldPropsDocs.js +11 -0
- package/es/extensions/forms/Form/FieldProps/FieldPropsDocs.js.map +1 -0
- package/es/extensions/forms/Form/FieldProps/index.d.ts +2 -0
- package/es/extensions/forms/Form/FieldProps/index.js +3 -0
- package/es/extensions/forms/Form/FieldProps/index.js.map +1 -0
- package/es/extensions/forms/Form/Handler/Handler.d.ts +1 -1
- package/es/extensions/forms/Form/Handler/Handler.js +11 -3
- package/es/extensions/forms/Form/Handler/Handler.js.map +1 -1
- package/es/extensions/forms/Form/Visibility/Visibility.d.ts +6 -2
- package/es/extensions/forms/Form/Visibility/Visibility.js +20 -11
- package/es/extensions/forms/Form/Visibility/Visibility.js.map +1 -1
- package/es/extensions/forms/Form/Visibility/VisibilityDocs.js +5 -0
- package/es/extensions/forms/Form/Visibility/VisibilityDocs.js.map +1 -1
- package/es/extensions/forms/Form/index.d.ts +1 -0
- package/es/extensions/forms/Form/index.js +1 -0
- package/es/extensions/forms/Form/index.js.map +1 -1
- package/es/extensions/forms/ValueBlock/ValueBlock.js +18 -2
- package/es/extensions/forms/ValueBlock/ValueBlock.js.map +1 -1
- package/es/extensions/forms/Wizard/hooks/useNextRouter.js +5 -4
- package/es/extensions/forms/Wizard/hooks/useNextRouter.js.map +1 -1
- package/es/extensions/forms/Wizard/hooks/useQueryLocator.d.ts +1 -1
- package/es/extensions/forms/Wizard/hooks/useQueryLocator.js +6 -5
- package/es/extensions/forms/Wizard/hooks/useQueryLocator.js.map +1 -1
- package/es/extensions/forms/Wizard/hooks/useReachRouter.js +6 -5
- package/es/extensions/forms/Wizard/hooks/useReachRouter.js.map +1 -1
- package/es/extensions/forms/Wizard/hooks/useReactRouter.js +5 -4
- package/es/extensions/forms/Wizard/hooks/useReactRouter.js.map +1 -1
- package/es/extensions/forms/hooks/useFieldProps.d.ts +2 -2
- package/es/extensions/forms/hooks/useFieldProps.js +11 -4
- package/es/extensions/forms/hooks/useFieldProps.js.map +1 -1
- package/es/extensions/forms/hooks/useTranslation.js +3 -1
- package/es/extensions/forms/hooks/useTranslation.js.map +1 -1
- package/es/shared/Context.d.ts +2 -0
- package/es/shared/Context.js.map +1 -1
- package/es/shared/Eufemia.d.ts +1 -1
- package/es/shared/Eufemia.js +2 -2
- package/es/shared/Eufemia.js.map +1 -1
- package/es/shared/component-helper.d.ts +1 -0
- package/es/shared/component-helper.js +1 -0
- package/es/shared/component-helper.js.map +1 -1
- package/es/shared/helpers/assignPropsWithContext.d.ts +1 -0
- package/es/shared/helpers/assignPropsWithContext.js +15 -0
- package/es/shared/helpers/assignPropsWithContext.js.map +1 -0
- package/es/shared/helpers/extendPropsWithContext.d.ts +1 -0
- package/es/shared/helpers/extendPropsWithContext.js +1 -1
- package/es/shared/helpers/extendPropsWithContext.js.map +1 -1
- package/es/shared/helpers/filterValidProps.d.ts +1 -0
- package/es/shared/helpers/filterValidProps.js.map +1 -1
- package/es/shared/helpers/runCssVersionMismatchWarning.js +13 -3
- package/es/shared/helpers/runCssVersionMismatchWarning.js.map +1 -1
- package/es/style/core/scopes.scss +1 -1
- package/es/style/dnb-ui-basis.css +1 -1
- package/es/style/dnb-ui-basis.min.css +1 -1
- package/es/style/dnb-ui-body.css +1 -1
- package/es/style/dnb-ui-body.min.css +1 -1
- package/es/style/dnb-ui-components.css +4 -0
- package/es/style/dnb-ui-components.min.css +1 -1
- package/es/style/dnb-ui-core.css +1 -1
- package/es/style/dnb-ui-core.min.css +1 -1
- package/es/style/themes/eiendom/basis.js +1 -0
- package/es/style/themes/eiendom/basis.js.map +1 -0
- package/es/style/themes/eiendom/index.js +3 -0
- package/es/style/themes/eiendom/index.js.map +1 -0
- package/es/style/themes/sbanken/basis.js +1 -0
- package/es/style/themes/sbanken/basis.js.map +1 -0
- package/es/style/themes/sbanken/index.d.ts +1 -0
- package/es/style/themes/sbanken/index.js +3 -0
- package/es/style/themes/sbanken/index.js.map +1 -0
- package/es/style/themes/theme-eiendom/eiendom-theme-components.css +4 -0
- package/es/style/themes/theme-eiendom/eiendom-theme-components.min.css +1 -1
- package/es/style/themes/theme-sbanken/sbanken-theme-components.css +4 -0
- package/es/style/themes/theme-sbanken/sbanken-theme-components.min.css +1 -1
- package/es/style/themes/theme-ui/ui-theme-components.css +4 -0
- package/es/style/themes/theme-ui/ui-theme-components.min.css +1 -1
- package/es/style/themes/ui/basis.d.ts +1 -0
- package/es/style/themes/ui/basis.js +1 -0
- package/es/style/themes/ui/basis.js.map +1 -0
- package/es/style/themes/ui/index.d.ts +1 -0
- package/es/style/themes/ui/index.js +3 -0
- package/es/style/themes/ui/index.js.map +1 -0
- package/esm/dnb-ui-basis.min.mjs +1 -1
- package/esm/dnb-ui-components.min.mjs +1 -1
- package/esm/dnb-ui-elements.min.mjs +1 -1
- package/esm/dnb-ui-extensions.min.mjs +3 -3
- package/esm/dnb-ui-lib.min.mjs +1 -1
- package/extensions/forms/DataContext/Context.d.ts +2 -1
- package/extensions/forms/DataContext/Context.js +0 -1
- package/extensions/forms/DataContext/Context.js.map +1 -1
- package/extensions/forms/DataContext/Provider/Provider.d.ts +13 -0
- package/extensions/forms/DataContext/Provider/Provider.js +17 -6
- package/extensions/forms/DataContext/Provider/Provider.js.map +1 -1
- package/extensions/forms/DataContext/Provider/ProviderDocs.js +15 -0
- package/extensions/forms/DataContext/Provider/ProviderDocs.js.map +1 -1
- package/extensions/forms/Form/FieldProps/FieldProps.d.ts +15 -0
- package/extensions/forms/Form/FieldProps/FieldProps.js +78 -0
- package/extensions/forms/Form/FieldProps/FieldProps.js.map +1 -0
- package/extensions/forms/Form/FieldProps/FieldPropsContext.d.ts +8 -0
- package/extensions/forms/Form/FieldProps/FieldPropsContext.js +7 -0
- package/extensions/forms/Form/FieldProps/FieldPropsContext.js.map +1 -0
- package/extensions/forms/Form/FieldProps/FieldPropsDocs.d.ts +2 -0
- package/extensions/forms/Form/FieldProps/FieldPropsDocs.js +11 -0
- package/extensions/forms/Form/FieldProps/FieldPropsDocs.js.map +1 -0
- package/extensions/forms/Form/FieldProps/index.d.ts +2 -0
- package/extensions/forms/Form/FieldProps/index.js +3 -0
- package/extensions/forms/Form/FieldProps/index.js.map +1 -0
- package/extensions/forms/Form/Handler/Handler.d.ts +1 -1
- package/extensions/forms/Form/Handler/Handler.js +11 -3
- package/extensions/forms/Form/Handler/Handler.js.map +1 -1
- package/extensions/forms/Form/Visibility/Visibility.d.ts +6 -2
- package/extensions/forms/Form/Visibility/Visibility.js +20 -11
- package/extensions/forms/Form/Visibility/Visibility.js.map +1 -1
- package/extensions/forms/Form/Visibility/VisibilityDocs.js +5 -0
- package/extensions/forms/Form/Visibility/VisibilityDocs.js.map +1 -1
- package/extensions/forms/Form/index.d.ts +1 -0
- package/extensions/forms/Form/index.js +1 -0
- package/extensions/forms/Form/index.js.map +1 -1
- package/extensions/forms/ValueBlock/ValueBlock.js +18 -2
- package/extensions/forms/ValueBlock/ValueBlock.js.map +1 -1
- package/extensions/forms/Wizard/hooks/useNextRouter.js +7 -5
- package/extensions/forms/Wizard/hooks/useNextRouter.js.map +1 -1
- package/extensions/forms/Wizard/hooks/useQueryLocator.d.ts +1 -1
- package/extensions/forms/Wizard/hooks/useQueryLocator.js +7 -5
- package/extensions/forms/Wizard/hooks/useQueryLocator.js.map +1 -1
- package/extensions/forms/Wizard/hooks/useReachRouter.js +8 -6
- package/extensions/forms/Wizard/hooks/useReachRouter.js.map +1 -1
- package/extensions/forms/Wizard/hooks/useReactRouter.js +7 -5
- package/extensions/forms/Wizard/hooks/useReactRouter.js.map +1 -1
- package/extensions/forms/hooks/useFieldProps.d.ts +2 -2
- package/extensions/forms/hooks/useFieldProps.js +11 -5
- package/extensions/forms/hooks/useFieldProps.js.map +1 -1
- package/extensions/forms/hooks/useTranslation.js +3 -1
- package/extensions/forms/hooks/useTranslation.js.map +1 -1
- package/package.json +1 -1
- package/shared/Context.d.ts +2 -0
- package/shared/Context.js.map +1 -1
- package/shared/Eufemia.d.ts +1 -1
- package/shared/Eufemia.js +2 -2
- package/shared/Eufemia.js.map +1 -1
- package/shared/component-helper.d.ts +1 -0
- package/shared/component-helper.js +1 -0
- package/shared/component-helper.js.map +1 -1
- package/shared/helpers/assignPropsWithContext.d.ts +1 -0
- package/shared/helpers/assignPropsWithContext.js +19 -0
- package/shared/helpers/assignPropsWithContext.js.map +1 -0
- package/shared/helpers/extendPropsWithContext.d.ts +1 -0
- package/shared/helpers/extendPropsWithContext.js +1 -1
- package/shared/helpers/extendPropsWithContext.js.map +1 -1
- package/shared/helpers/filterValidProps.d.ts +1 -0
- package/shared/helpers/filterValidProps.js.map +1 -1
- package/shared/helpers/runCssVersionMismatchWarning.js +13 -3
- package/shared/helpers/runCssVersionMismatchWarning.js.map +1 -1
- package/style/core/scopes.scss +1 -1
- package/style/dnb-ui-basis.css +1 -1
- package/style/dnb-ui-basis.min.css +1 -1
- package/style/dnb-ui-body.css +1 -1
- package/style/dnb-ui-body.min.css +1 -1
- package/style/dnb-ui-components.css +4 -0
- package/style/dnb-ui-components.min.css +1 -1
- package/style/dnb-ui-core.css +1 -1
- package/style/dnb-ui-core.min.css +1 -1
- package/style/themes/eiendom/basis.d.ts +1 -0
- package/style/themes/eiendom/basis.js +1 -0
- package/style/themes/eiendom/basis.js.map +1 -0
- package/style/themes/eiendom/index.d.ts +1 -0
- package/style/themes/eiendom/index.js +3 -0
- package/style/themes/eiendom/index.js.map +1 -0
- package/style/themes/sbanken/basis.d.ts +1 -0
- package/style/themes/sbanken/basis.js +1 -0
- package/style/themes/sbanken/basis.js.map +1 -0
- package/style/themes/sbanken/index.d.ts +1 -0
- package/style/themes/sbanken/index.js +3 -0
- package/style/themes/sbanken/index.js.map +1 -0
- package/style/themes/theme-eiendom/eiendom-theme-components.css +4 -0
- package/style/themes/theme-eiendom/eiendom-theme-components.min.css +1 -1
- package/style/themes/theme-sbanken/sbanken-theme-components.css +4 -0
- package/style/themes/theme-sbanken/sbanken-theme-components.min.css +1 -1
- package/style/themes/theme-ui/ui-theme-components.css +4 -0
- package/style/themes/theme-ui/ui-theme-components.min.css +1 -1
- package/style/themes/ui/basis.d.ts +1 -0
- package/style/themes/ui/basis.js +1 -0
- package/style/themes/ui/basis.js.map +1 -0
- package/style/themes/ui/index.d.ts +1 -0
- package/style/themes/ui/index.js +3 -0
- package/style/themes/ui/index.js.map +1 -0
- package/umd/dnb-ui-basis.min.js +1 -1
- package/umd/dnb-ui-components.min.js +1 -1
- package/umd/dnb-ui-elements.min.js +1 -1
- package/umd/dnb-ui-extensions.min.js +2 -2
- package/umd/dnb-ui-lib.min.js +1 -1
- package/cjs/style/themes/eiendom.js +0 -5
- package/cjs/style/themes/eiendom.js.map +0 -1
- package/cjs/style/themes/sbanken.js +0 -5
- package/cjs/style/themes/sbanken.js.map +0 -1
- package/cjs/style/themes/ui.js +0 -5
- package/cjs/style/themes/ui.js.map +0 -1
- package/es/style/themes/eiendom.js +0 -3
- package/es/style/themes/eiendom.js.map +0 -1
- package/es/style/themes/sbanken.js +0 -3
- package/es/style/themes/sbanken.js.map +0 -1
- package/es/style/themes/ui.js +0 -3
- package/es/style/themes/ui.js.map +0 -1
- package/style/themes/eiendom.js +0 -3
- package/style/themes/eiendom.js.map +0 -1
- package/style/themes/sbanken.js +0 -3
- package/style/themes/sbanken.js.map +0 -1
- package/style/themes/ui.js +0 -3
- package/style/themes/ui.js.map +0 -1
- /package/cjs/style/themes/{eiendom.d.ts → eiendom/basis.d.ts} +0 -0
- /package/cjs/style/themes/{sbanken.d.ts → eiendom/index.d.ts} +0 -0
- /package/cjs/style/themes/{ui.d.ts → sbanken/basis.d.ts} +0 -0
- /package/{es/style/themes/eiendom.d.ts → cjs/style/themes/sbanken/index.d.ts} +0 -0
- /package/{es/style/themes/sbanken.d.ts → cjs/style/themes/ui/basis.d.ts} +0 -0
- /package/{es/style/themes/ui.d.ts → cjs/style/themes/ui/index.d.ts} +0 -0
- /package/{style/themes/eiendom.d.ts → es/style/themes/eiendom/basis.d.ts} +0 -0
- /package/{style/themes/sbanken.d.ts → es/style/themes/eiendom/index.d.ts} +0 -0
- /package/{style/themes/ui.d.ts → es/style/themes/sbanken/basis.d.ts} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FieldProps.js","names":["React","useContext","useRef","DataContext","assignPropsWithContext","FieldPropsContext","SharedProvider","FieldProps","props","children","formElement","FormStatus","rest","_objectWithoutProperties","_excluded","nestedContext","dataContextRef","current","sharedProviderProps","_ref","Object","assign","inheritedContext","locale","translations","restOfRest","_excluded2","disabled","wrapFormsTranslations","extend","fieldProps","required","createElement","Provider","value","result","trObj","newObj","Forms","key","newKeyObj","subKey"],"sources":["../../../../../../src/extensions/forms/Form/FieldProps/FieldProps.tsx"],"sourcesContent":["import React, { useContext, useRef } from 'react'\nimport DataContext, { ContextState } from '../../DataContext/Context'\nimport { Props as DataContextProps } from '../../DataContext/Provider'\nimport { UseFieldProps } from '../../types'\nimport { FormStatusProps } from '../../../../components/FormStatus'\nimport { assignPropsWithContext } from '../../../../shared/component-helper'\nimport FieldPropsContext from './FieldPropsContext'\nimport SharedProvider from '../../../../shared/Provider'\nimport { ContextProps } from '../../../../shared/Context'\n\nexport type FieldPropsProps = UseFieldProps & {\n children: React.ReactNode\n formElement?: ContextProps['formElement']\n FormStatus?: { globalStatus: FormStatusProps }\n locale?: DataContextProps<unknown>['locale']\n translations?: DataContextProps<unknown>['translations']\n}\n\nexport default function FieldProps(props: FieldPropsProps) {\n const { children, formElement, FormStatus, ...rest } = props\n\n const nestedContext = useContext(FieldPropsContext)\n const dataContextRef = useRef<ContextState>()\n dataContextRef.current = useContext<ContextState>(DataContext)\n\n const sharedProviderProps: ContextProps = {}\n\n // Extract props to be used in the shared global context\n const { locale, translations, ...restOfRest } = Object.assign(\n nestedContext?.inheritedContext || {},\n rest\n ) as ContextProps & {\n disabled?: boolean\n }\n if (typeof restOfRest.disabled === 'boolean') {\n sharedProviderProps.formElement = { disabled: restOfRest.disabled }\n }\n if (formElement) {\n sharedProviderProps.formElement = formElement\n }\n if (FormStatus) {\n sharedProviderProps.FormStatus = FormStatus\n }\n if (locale) {\n sharedProviderProps.locale = locale\n }\n if (translations) {\n sharedProviderProps.translations = wrapFormsTranslations(translations)\n }\n\n function extend<T>(fieldProps: T) {\n // Extract props from data context to be used in fields\n const { required } = dataContextRef.current\n\n return nestedContext.extend(\n assignPropsWithContext(fieldProps, { required }, restOfRest)\n ) as T\n }\n\n return (\n <FieldPropsContext.Provider value={{ extend, inheritedContext: rest }}>\n <SharedProvider {...sharedProviderProps}>{children}</SharedProvider>\n </FieldPropsContext.Provider>\n )\n}\n\nfunction wrapFormsTranslations(\n translations: ContextProps['translations']\n) {\n const result = {}\n const trObj = translations as Record<\n ContextProps['locale'],\n Record<string, Record<string, string>>\n >\n\n for (const locale in trObj) {\n const newObj: Record<\n 'Forms',\n Record<string, Record<string, string>>\n > = {\n Forms: {},\n }\n\n for (const key in trObj[locale]) {\n const newKeyObj: Record<string, string> = {}\n\n for (const subKey in trObj[locale][key]) {\n newKeyObj[subKey] = trObj[locale][key][subKey]\n }\n\n newObj.Forms[key] = newKeyObj\n }\n\n result[locale] = newObj\n }\n\n return result\n}\n"],"mappings":";;;;;AAAA,OAAOA,KAAK,IAAIC,UAAU,EAAEC,MAAM,QAAQ,OAAO;AACjD,OAAOC,WAAW,MAAwB,2BAA2B;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hC,MAAM;MAAEC;IAAS,CAAC,GAAGf,cAAc,CAACC,OAAO;IAE3C,OAAOF,aAAa,CAACc,MAAM,CACzBzB,sBAAsB,CAAC0B,UAAU,EAAE;MAAEC;IAAS,CAAC,EAAEN,UAAU,CAC7D,CAAC;EACH;EAEA,OACEzB,KAAA,CAAAgC,aAAA,CAAC3B,iBAAiB,CAAC4B,QAAQ;IAACC,KAAK,EAAE;MAAEL,MAAM;MAAEP,gBAAgB,EAAEV;IAAK;EAAE,GACpEZ,KAAA,CAAAgC,aAAA,CAAC1B,cAAc,EAAKY,mBAAmB,EAAGT,QAAyB,CACzC,CAAC;AAEjC;AAEA,SAASmB,qBAAqBA,CAC5BJ,YAA0C,EAC1C;EACA,MAAMW,MAAM,GAAG,CAAC,CAAC;EACjB,MAAMC,KAAK,GAAGZ,YAGb;EAED,KAAK,MAAMD,MAAM,IAAIa,KAAK,EAAE;IAC1B,MAAMC,MAGL,GAAG;MACFC,KAAK,EAAE,CAAC;IACV,CAAC;IAED,KAAK,MAAMC,GAAG,IAAIH,KAAK,CAACb,MAAM,CAAC,EAAE;MAC/B,MAAMiB,SAAiC,GAAG,CAAC,CAAC;MAE5C,KAAK,MAAMC,MAAM,IAAIL,KAAK,CAACb,MAAM,CAAC,CAACgB,GAAG,CAAC,EAAE;QACvCC,SAAS,CAACC,MAAM,CAAC,GAAGL,KAAK,CAACb,MAAM,CAAC,CAACgB,GAAG,CAAC,CAACE,MAAM,CAAC;MAChD;MAEAJ,MAAM,CAACC,KAAK,CAACC,GAAG,CAAC,GAAGC,SAAS;IAC/B;IAEAL,MAAM,CAACZ,MAAM,CAAC,GAAGc,MAAM;EACzB;EAEA,OAAOF,MAAM;AACf"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { UseFieldProps } from '../../types';
|
|
3
|
+
export type FieldPropsContextProps = {
|
|
4
|
+
extend: <T = UseFieldProps>(props: T) => T;
|
|
5
|
+
inheritedContext?: UseFieldProps;
|
|
6
|
+
};
|
|
7
|
+
declare const FieldPropsContext: React.Context<FieldPropsContextProps>;
|
|
8
|
+
export default FieldPropsContext;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FieldPropsContext.js","names":["React","extend","props","FieldPropsContext","createContext"],"sources":["../../../../../../src/extensions/forms/Form/FieldProps/FieldPropsContext.ts"],"sourcesContent":["import React from 'react'\nimport { UseFieldProps } from '../../types'\n\nexport type FieldPropsContextProps = {\n extend: <T = UseFieldProps>(props: T) => T\n inheritedContext?: UseFieldProps\n}\n\nconst extend: FieldPropsContextProps['extend'] = (props) => props\nconst FieldPropsContext = React.createContext<FieldPropsContextProps>({\n extend,\n})\n\nexport default FieldPropsContext\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AAQzB,MAAMC,MAAwC,GAAIC,KAAK,IAAKA,KAAK;AACjE,MAAMC,iBAAiB,GAAGH,KAAK,CAACI,aAAa,CAAyB;EACpEH;AACF,CAAC,CAAC;AAEF,eAAeE,iBAAiB"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { dataValueProperties } from '../../hooks/DataValueDocs';
|
|
2
|
+
export const FieldPropsProperties = {
|
|
3
|
+
required: dataValueProperties.required,
|
|
4
|
+
disabled: dataValueProperties.disabled,
|
|
5
|
+
locale: {
|
|
6
|
+
doc: 'Locale (language) to use for all nested Eufemia components.',
|
|
7
|
+
type: 'string',
|
|
8
|
+
status: 'optional'
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=FieldPropsDocs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FieldPropsDocs.js","names":["dataValueProperties","FieldPropsProperties","required","disabled","locale","doc","type","status"],"sources":["../../../../../../src/extensions/forms/Form/FieldProps/FieldPropsDocs.ts"],"sourcesContent":["import { PropertiesTableProps } from '../../../../shared/types'\nimport { dataValueProperties } from '../../hooks/DataValueDocs'\n\nexport const FieldPropsProperties: PropertiesTableProps = {\n required: dataValueProperties.required,\n disabled: dataValueProperties.disabled,\n locale: {\n doc: 'Locale (language) to use for all nested Eufemia components.',\n type: 'string',\n status: 'optional',\n },\n}\n"],"mappings":"AACA,SAASA,mBAAmB,QAAQ,2BAA2B;AAE/D,OAAO,MAAMC,oBAA0C,GAAG;EACxDC,QAAQ,EAAEF,mBAAmB,CAACE,QAAQ;EACtCC,QAAQ,EAAEH,mBAAmB,CAACG,QAAQ;EACtCC,MAAM,EAAE;IACNC,GAAG,EAAE,6DAA6D;IAClEC,IAAI,EAAE,QAAQ;IACdC,MAAM,EAAE;EACV;AACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["default"],"sources":["../../../../../../src/extensions/forms/Form/FieldProps/index.ts"],"sourcesContent":["export { default } from './FieldProps'\nexport * from './FieldProps'\n"],"mappings":"AAAA,SAASA,OAAO,QAAQ,cAAc;AACtC,cAAc,cAAc"}
|
|
@@ -7,4 +7,4 @@ export type Props = Omit<ElementAllProps, 'data' | 'as' | 'autoComplete'> & {
|
|
|
7
7
|
*/
|
|
8
8
|
autoComplete?: boolean;
|
|
9
9
|
};
|
|
10
|
-
export default function FormHandler<Data extends JsonObject>({ children, defaultData, data, schema, ajvInstance, errorMessages, globalStatusId, filterSubmitData, filterData, transformIn, onChange, onPathChange, onSubmit, onSubmitRequest, onSubmitComplete, minimumAsyncBehaviorTime, asyncSubmitTimeout, scrollTopOnSubmit, sessionStorageId, autoComplete, ...rest }: ProviderProps<Data> & Omit<Props, keyof ProviderProps<Data>>): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export default function FormHandler<Data extends JsonObject>({ children, defaultData, data, schema, ajvInstance, errorMessages, globalStatusId, filterSubmitData, filterData, transformIn, onChange, onPathChange, onSubmit, onSubmitRequest, onSubmitComplete, minimumAsyncBehaviorTime, asyncSubmitTimeout, scrollTopOnSubmit, sessionStorageId, autoComplete, locale, translations, disabled, required, ...rest }: ProviderProps<Data> & Omit<Props, keyof ProviderProps<Data>>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
4
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
5
|
-
const _excluded = ["children", "defaultData", "data", "schema", "ajvInstance", "errorMessages", "globalStatusId", "filterSubmitData", "filterData", "transformIn", "onChange", "onPathChange", "onSubmit", "onSubmitRequest", "onSubmitComplete", "minimumAsyncBehaviorTime", "asyncSubmitTimeout", "scrollTopOnSubmit", "sessionStorageId", "autoComplete"],
|
|
5
|
+
const _excluded = ["children", "defaultData", "data", "schema", "ajvInstance", "errorMessages", "globalStatusId", "filterSubmitData", "filterData", "transformIn", "onChange", "onPathChange", "onSubmit", "onSubmitRequest", "onSubmitComplete", "minimumAsyncBehaviorTime", "asyncSubmitTimeout", "scrollTopOnSubmit", "sessionStorageId", "autoComplete", "locale", "translations", "disabled", "required"],
|
|
6
6
|
_excluded2 = ["children"];
|
|
7
7
|
import React, { useContext } from 'react';
|
|
8
8
|
import DataContextProvider from '../../DataContext/Provider';
|
|
@@ -32,7 +32,11 @@ export default function FormHandler(_ref) {
|
|
|
32
32
|
asyncSubmitTimeout,
|
|
33
33
|
scrollTopOnSubmit,
|
|
34
34
|
sessionStorageId,
|
|
35
|
-
autoComplete
|
|
35
|
+
autoComplete,
|
|
36
|
+
locale,
|
|
37
|
+
translations,
|
|
38
|
+
disabled,
|
|
39
|
+
required
|
|
36
40
|
} = _ref,
|
|
37
41
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
38
42
|
const providerProps = {
|
|
@@ -55,7 +59,11 @@ export default function FormHandler(_ref) {
|
|
|
55
59
|
asyncSubmitTimeout,
|
|
56
60
|
scrollTopOnSubmit,
|
|
57
61
|
sessionStorageId,
|
|
58
|
-
autoComplete
|
|
62
|
+
autoComplete,
|
|
63
|
+
locale,
|
|
64
|
+
translations,
|
|
65
|
+
disabled,
|
|
66
|
+
required
|
|
59
67
|
};
|
|
60
68
|
return React.createElement(DataContextProvider, providerProps, React.createElement(FormElementWithState, rest, children));
|
|
61
69
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Handler.js","names":["React","useContext","DataContextProvider","DataContext","FormElement","FormStatus","useId","combineLabelledBy","FormHandler","_ref","children","defaultData","data","schema","ajvInstance","errorMessages","globalStatusId","filterSubmitData","filterData","transformIn","onChange","onPathChange","onSubmit","onSubmitRequest","onSubmitComplete","minimumAsyncBehaviorTime","asyncSubmitTimeout","scrollTopOnSubmit","sessionStorageId","autoComplete","rest","_objectWithoutProperties","_excluded","providerProps","id","createElement","FormElementWithState","_ref2","_excluded2","submitState","states","Object","entries","filter","_ref3","value","_extends","map","_ref4","key","undefined","state","className","show","Boolean","no_animation","shellSpace","top","bottom","String"],"sources":["../../../../../../src/extensions/forms/Form/Handler/Handler.tsx"],"sourcesContent":["import React, { useContext } from 'react'\nimport { JsonObject } from 'json-pointer'\nimport DataContextProvider, {\n Props as ProviderProps,\n} from '../../DataContext/Provider'\nimport DataContext from '../../DataContext/Context'\nimport FormElement from '../Element'\nimport type { ElementAllProps } from '../../../../elements/Element'\nimport FormStatus from '../../../../components/FormStatus'\nimport useId from '../../../../shared/helpers/useId'\nimport { combineLabelledBy } from '../../../../shared/component-helper'\n\nexport type Props = Omit<\n ElementAllProps,\n 'data' | 'as' | 'autoComplete'\n> & {\n /**\n * Will enable autoComplete for all nested Field.String fields\n */\n autoComplete?: boolean\n}\n\nexport default function FormHandler<Data extends JsonObject>({\n children,\n defaultData,\n data,\n schema,\n ajvInstance,\n errorMessages,\n globalStatusId,\n filterSubmitData,\n filterData,\n transformIn,\n onChange,\n onPathChange,\n onSubmit,\n onSubmitRequest,\n onSubmitComplete,\n minimumAsyncBehaviorTime,\n asyncSubmitTimeout,\n scrollTopOnSubmit,\n sessionStorageId,\n autoComplete,\n ...rest\n}: ProviderProps<Data> & Omit<Props, keyof ProviderProps<Data>>) {\n const providerProps = {\n id: rest.id,\n defaultData,\n data,\n schema,\n ajvInstance,\n errorMessages,\n globalStatusId,\n filterSubmitData,\n filterData,\n transformIn,\n onChange,\n onPathChange,\n onSubmit,\n onSubmitRequest,\n onSubmitComplete,\n minimumAsyncBehaviorTime,\n asyncSubmitTimeout,\n scrollTopOnSubmit,\n sessionStorageId,\n autoComplete,\n }\n\n return (\n <DataContextProvider {...providerProps}>\n <FormElementWithState {...rest}>{children}</FormElementWithState>\n </DataContextProvider>\n )\n}\n\nfunction FormElementWithState({ children, ...rest }) {\n const id = useId()\n const { submitState } = useContext(DataContext) || {}\n const states = Object.entries(submitState).filter(([, value]) => value)\n\n return (\n <FormElement\n {...rest}\n aria-labelledby={\n combineLabelledBy(\n rest,\n states.map(([key]) => {\n return `${id}-form-status-${key}`\n })\n ) || undefined\n }\n >\n {children}\n\n {['error', 'warning', 'info'].map((key) => {\n const value = submitState[key]\n return (\n <FormStatus\n key={key}\n state={key}\n id={`${id}-form-status-${key}`}\n className=\"dnb-forms-status\"\n show={Boolean(value)}\n no_animation={false}\n shellSpace={{ top: 'small', bottom: 'medium' }}\n >\n {String(value?.['message'] || value || '')}\n </FormStatus>\n )\n })}\n </FormElement>\n )\n}\n"],"mappings":";;;;;;AAAA,OAAOA,KAAK,IAAIC,UAAU,QAAQ,OAAO;AAEzC,OAAOC,mBAAmB,MAEnB,4BAA4B;AACnC,OAAOC,WAAW,MAAM,2BAA2B;AACnD,OAAOC,WAAW,MAAM,YAAY;AAEpC,OAAOC,UAAU,MAAM,mCAAmC;AAC1D,OAAOC,KAAK,MAAM,kCAAkC;AACpD,SAASC,iBAAiB,QAAQ,qCAAqC;AAYvE,eAAe,SAASC,WAAWA,CAAAC,IAAA,
|
|
1
|
+
{"version":3,"file":"Handler.js","names":["React","useContext","DataContextProvider","DataContext","FormElement","FormStatus","useId","combineLabelledBy","FormHandler","_ref","children","defaultData","data","schema","ajvInstance","errorMessages","globalStatusId","filterSubmitData","filterData","transformIn","onChange","onPathChange","onSubmit","onSubmitRequest","onSubmitComplete","minimumAsyncBehaviorTime","asyncSubmitTimeout","scrollTopOnSubmit","sessionStorageId","autoComplete","locale","translations","disabled","required","rest","_objectWithoutProperties","_excluded","providerProps","id","createElement","FormElementWithState","_ref2","_excluded2","submitState","states","Object","entries","filter","_ref3","value","_extends","map","_ref4","key","undefined","state","className","show","Boolean","no_animation","shellSpace","top","bottom","String"],"sources":["../../../../../../src/extensions/forms/Form/Handler/Handler.tsx"],"sourcesContent":["import React, { useContext } from 'react'\nimport { JsonObject } from 'json-pointer'\nimport DataContextProvider, {\n Props as ProviderProps,\n} from '../../DataContext/Provider'\nimport DataContext from '../../DataContext/Context'\nimport FormElement from '../Element'\nimport type { ElementAllProps } from '../../../../elements/Element'\nimport FormStatus from '../../../../components/FormStatus'\nimport useId from '../../../../shared/helpers/useId'\nimport { combineLabelledBy } from '../../../../shared/component-helper'\n\nexport type Props = Omit<\n ElementAllProps,\n 'data' | 'as' | 'autoComplete'\n> & {\n /**\n * Will enable autoComplete for all nested Field.String fields\n */\n autoComplete?: boolean\n}\n\nexport default function FormHandler<Data extends JsonObject>({\n children,\n defaultData,\n data,\n schema,\n ajvInstance,\n errorMessages,\n globalStatusId,\n filterSubmitData,\n filterData,\n transformIn,\n onChange,\n onPathChange,\n onSubmit,\n onSubmitRequest,\n onSubmitComplete,\n minimumAsyncBehaviorTime,\n asyncSubmitTimeout,\n scrollTopOnSubmit,\n sessionStorageId,\n autoComplete,\n locale,\n translations,\n disabled,\n required,\n ...rest\n}: ProviderProps<Data> & Omit<Props, keyof ProviderProps<Data>>) {\n const providerProps = {\n id: rest.id,\n defaultData,\n data,\n schema,\n ajvInstance,\n errorMessages,\n globalStatusId,\n filterSubmitData,\n filterData,\n transformIn,\n onChange,\n onPathChange,\n onSubmit,\n onSubmitRequest,\n onSubmitComplete,\n minimumAsyncBehaviorTime,\n asyncSubmitTimeout,\n scrollTopOnSubmit,\n sessionStorageId,\n autoComplete,\n locale,\n translations,\n disabled,\n required,\n }\n\n return (\n <DataContextProvider {...providerProps}>\n <FormElementWithState {...rest}>{children}</FormElementWithState>\n </DataContextProvider>\n )\n}\n\nfunction FormElementWithState({ children, ...rest }) {\n const id = useId()\n const { submitState } = useContext(DataContext) || {}\n const states = Object.entries(submitState).filter(([, value]) => value)\n\n return (\n <FormElement\n {...rest}\n aria-labelledby={\n combineLabelledBy(\n rest,\n states.map(([key]) => {\n return `${id}-form-status-${key}`\n })\n ) || undefined\n }\n >\n {children}\n\n {['error', 'warning', 'info'].map((key) => {\n const value = submitState[key]\n return (\n <FormStatus\n key={key}\n state={key}\n id={`${id}-form-status-${key}`}\n className=\"dnb-forms-status\"\n show={Boolean(value)}\n no_animation={false}\n shellSpace={{ top: 'small', bottom: 'medium' }}\n >\n {String(value?.['message'] || value || '')}\n </FormStatus>\n )\n })}\n </FormElement>\n )\n}\n"],"mappings":";;;;;;AAAA,OAAOA,KAAK,IAAIC,UAAU,QAAQ,OAAO;AAEzC,OAAOC,mBAAmB,MAEnB,4BAA4B;AACnC,OAAOC,WAAW,MAAM,2BAA2B;AACnD,OAAOC,WAAW,MAAM,YAAY;AAEpC,OAAOC,UAAU,MAAM,mCAAmC;AAC1D,OAAOC,KAAK,MAAM,kCAAkC;AACpD,SAASC,iBAAiB,QAAQ,qCAAqC;AAYvE,eAAe,SAASC,WAAWA,CAAAC,IAAA,EA0B8B;EAAA,IA1BJ;MAC3DC,QAAQ;MACRC,WAAW;MACXC,IAAI;MACJC,MAAM;MACNC,WAAW;MACXC,aAAa;MACbC,cAAc;MACdC,gBAAgB;MAChBC,UAAU;MACVC,WAAW;MACXC,QAAQ;MACRC,YAAY;MACZC,QAAQ;MACRC,eAAe;MACfC,gBAAgB;MAChBC,wBAAwB;MACxBC,kBAAkB;MAClBC,iBAAiB;MACjBC,gBAAgB;MAChBC,YAAY;MACZC,MAAM;MACNC,YAAY;MACZC,QAAQ;MACRC;IAE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AC,GAAAD,KAAA;MACf,OAAQ,GAAEd,EAAG,gBAAee,GAAI,EAAC;IACnC,CAAC,CACH,CAAC,IAAIC;EACN,IAEA5C,QAAQ,EAER,CAAC,OAAO,EAAE,SAAS,EAAE,MAAM,CAAC,CAACyC,GAAG,CAAEE,GAAG,IAAK;IACzC,MAAMJ,KAAK,GAAGN,WAAW,CAACU,GAAG,CAAC;IAC9B,OACErD,KAAA,CAAAuC,aAAA,CAAClC,UAAU;MACTgD,GAAG,EAAEA,GAAI;MACTE,KAAK,EAAEF,GAAI;MACXf,EAAE,EAAG,GAAEA,EAAG,gBAAee,GAAI,EAAE;MAC/BG,SAAS,EAAC,kBAAkB;MAC5BC,IAAI,EAAEC,OAAO,CAACT,KAAK,CAAE;MACrBU,YAAY,EAAE,KAAM;MACpBC,UAAU,EAAE;QAAEC,GAAG,EAAE,OAAO;QAAEC,MAAM,EAAE;MAAS;IAAE,GAE9CC,MAAM,CAAC,CAAAd,KAAK,aAALA,KAAK,uBAALA,KAAK,CAAG,SAAS,CAAC,KAAIA,KAAK,IAAI,EAAE,CAC/B,CAAC;EAEjB,CAAC,CACU,CAAC;AAElB"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { AriaAttributes } from 'react';
|
|
2
2
|
import { HeightAnimationProps } from '../../../../components/HeightAnimation';
|
|
3
|
+
import type { UseFieldProps } from '../../types';
|
|
4
|
+
import type { DataAttributes } from '../../hooks/useFieldProps';
|
|
3
5
|
export type Props = {
|
|
4
6
|
visible?: boolean;
|
|
5
7
|
/** Given data context path must be defined to show children */
|
|
@@ -24,10 +26,12 @@ export type Props = {
|
|
|
24
26
|
animate?: boolean;
|
|
25
27
|
/** Keep the content in the DOM, even if it's not visible */
|
|
26
28
|
keepInDOM?: boolean;
|
|
29
|
+
/** When visibility is hidden, and `keepInDOM` is true, pass these props to the children */
|
|
30
|
+
fieldPropsWhenHidden?: UseFieldProps & DataAttributes & AriaAttributes;
|
|
27
31
|
element?: HeightAnimationProps['element'];
|
|
28
32
|
children: React.ReactNode;
|
|
29
33
|
};
|
|
30
|
-
declare function Visibility({ visible, pathDefined, pathUndefined, pathTruthy, pathFalsy, pathTrue, pathFalse, pathValue, whenValue, inferData, animate, keepInDOM, children, ...rest }: Props): import("react/jsx-runtime").JSX.Element
|
|
34
|
+
declare function Visibility({ visible, pathDefined, pathUndefined, pathTruthy, pathFalsy, pathTrue, pathFalse, pathValue, whenValue, inferData, animate, keepInDOM, fieldPropsWhenHidden, children, ...rest }: Props): string | number | boolean | import("react/jsx-runtime").JSX.Element | Iterable<React.ReactNode>;
|
|
31
35
|
declare namespace Visibility {
|
|
32
36
|
var _supportsSpacingProps: string;
|
|
33
37
|
}
|
|
@@ -2,11 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
4
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
5
|
-
const _excluded = ["visible", "pathDefined", "pathUndefined", "pathTruthy", "pathFalsy", "pathTrue", "pathFalse", "pathValue", "whenValue", "inferData", "animate", "keepInDOM", "children"];
|
|
5
|
+
const _excluded = ["visible", "pathDefined", "pathUndefined", "pathTruthy", "pathFalsy", "pathTrue", "pathFalse", "pathValue", "whenValue", "inferData", "animate", "keepInDOM", "fieldPropsWhenHidden", "children"];
|
|
6
6
|
import React, { useContext } from 'react';
|
|
7
7
|
import pointer from 'json-pointer';
|
|
8
|
-
import
|
|
8
|
+
import { warn } from '../../../../shared/helpers';
|
|
9
|
+
import useMountEffect from '../../../../shared/helpers/useMountEffect';
|
|
9
10
|
import HeightAnimation from '../../../../components/HeightAnimation';
|
|
11
|
+
import DataContext from '../../DataContext/Context';
|
|
12
|
+
import FieldProps from '../FieldProps';
|
|
10
13
|
function Visibility(_ref) {
|
|
11
14
|
let {
|
|
12
15
|
visible,
|
|
@@ -21,10 +24,16 @@ function Visibility(_ref) {
|
|
|
21
24
|
inferData,
|
|
22
25
|
animate,
|
|
23
26
|
keepInDOM,
|
|
27
|
+
fieldPropsWhenHidden,
|
|
24
28
|
children
|
|
25
29
|
} = _ref,
|
|
26
30
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
27
|
-
const dataContext = useContext(DataContext
|
|
31
|
+
const dataContext = useContext(DataContext);
|
|
32
|
+
useMountEffect(() => {
|
|
33
|
+
if (fieldPropsWhenHidden && !keepInDOM) {
|
|
34
|
+
warn('Using "fieldPropsWhenHidden" requires "keepInDOM" to be true.');
|
|
35
|
+
}
|
|
36
|
+
});
|
|
28
37
|
const check = () => {
|
|
29
38
|
if (visible === false) {
|
|
30
39
|
return;
|
|
@@ -55,23 +64,23 @@ function Visibility(_ref) {
|
|
|
55
64
|
}
|
|
56
65
|
return true;
|
|
57
66
|
};
|
|
67
|
+
const open = Boolean(check());
|
|
58
68
|
if (animate) {
|
|
69
|
+
const props = !open ? fieldPropsWhenHidden : null;
|
|
59
70
|
return React.createElement(HeightAnimation, _extends({
|
|
60
|
-
open:
|
|
71
|
+
open: open,
|
|
61
72
|
keepInDOM: keepInDOM,
|
|
62
73
|
className: "dnb-forms-visibility"
|
|
63
|
-
}, rest), children);
|
|
64
|
-
}
|
|
65
|
-
if (check()) {
|
|
66
|
-
return React.createElement(React.Fragment, null, children);
|
|
74
|
+
}, rest), React.createElement(FieldProps, props, children));
|
|
67
75
|
}
|
|
68
76
|
if (keepInDOM) {
|
|
77
|
+
const props = !open ? fieldPropsWhenHidden : null;
|
|
69
78
|
return React.createElement("span", {
|
|
70
79
|
className: "dnb-forms-visibility",
|
|
71
|
-
hidden:
|
|
72
|
-
}, children);
|
|
80
|
+
hidden: !open
|
|
81
|
+
}, React.createElement(FieldProps, props, children));
|
|
73
82
|
}
|
|
74
|
-
return null;
|
|
83
|
+
return open ? children : null;
|
|
75
84
|
}
|
|
76
85
|
Visibility._supportsSpacingProps = 'children';
|
|
77
86
|
export default Visibility;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Visibility.js","names":["React","useContext","pointer","
|
|
1
|
+
{"version":3,"file":"Visibility.js","names":["React","useContext","pointer","warn","useMountEffect","HeightAnimation","DataContext","FieldProps","Visibility","_ref","visible","pathDefined","pathUndefined","pathTruthy","pathFalsy","pathTrue","pathFalse","pathValue","whenValue","inferData","animate","keepInDOM","fieldPropsWhenHidden","children","rest","_objectWithoutProperties","_excluded","dataContext","check","has","data","get","Boolean","open","props","createElement","_extends","className","hidden","_supportsSpacingProps"],"sources":["../../../../../../src/extensions/forms/Form/Visibility/Visibility.tsx"],"sourcesContent":["import React, { AriaAttributes, useContext } from 'react'\nimport pointer from 'json-pointer'\nimport { warn } from '../../../../shared/helpers'\nimport useMountEffect from '../../../../shared/helpers/useMountEffect'\nimport HeightAnimation, {\n HeightAnimationProps,\n} from '../../../../components/HeightAnimation'\nimport DataContext from '../../DataContext/Context'\nimport FieldProps from '../FieldProps'\nimport type { UseFieldProps } from '../../types'\nimport type { DataAttributes } from '../../hooks/useFieldProps'\n\nexport type Props = {\n visible?: boolean\n /** Given data context path must be defined to show children */\n pathDefined?: string\n /** Given data context path must be undefined to show children */\n pathUndefined?: string\n /** Given data context path must be truthy to show children */\n pathTruthy?: string\n /** Given data context path must be falsy to show children */\n pathFalsy?: string\n /** Given data context path must be true to show children */\n pathTrue?: string\n /** Given data context path must be false to show children */\n pathFalse?: string\n /** Given data context path must match, as well as the \"whenValue\" value */\n pathValue?: string\n /** Given data context value must match this value to show children */\n whenValue?: unknown\n /** Infer visibility calling given derivative function with the whole data set. Should return true/false for visibility. */\n inferData?: (data: unknown) => boolean\n /** Animate the visibility change */\n animate?: boolean\n /** Keep the content in the DOM, even if it's not visible */\n keepInDOM?: boolean\n /** When visibility is hidden, and `keepInDOM` is true, pass these props to the children */\n fieldPropsWhenHidden?: UseFieldProps & DataAttributes & AriaAttributes\n element?: HeightAnimationProps['element']\n children: React.ReactNode\n}\n\nfunction Visibility({\n visible,\n pathDefined,\n pathUndefined,\n pathTruthy,\n pathFalsy,\n pathTrue,\n pathFalse,\n pathValue,\n whenValue,\n inferData,\n animate,\n keepInDOM,\n fieldPropsWhenHidden,\n children,\n ...rest\n}: Props) {\n const dataContext = useContext(DataContext)\n\n useMountEffect(() => {\n if (fieldPropsWhenHidden && !keepInDOM) {\n warn('Using \"fieldPropsWhenHidden\" requires \"keepInDOM\" to be true.')\n }\n })\n\n const check = () => {\n if (visible === false) {\n return\n }\n\n if (pathDefined && !pointer.has(dataContext.data, pathDefined)) {\n return\n }\n if (pathUndefined && pointer.has(dataContext.data, pathUndefined)) {\n return\n }\n\n if (\n pathTruthy &&\n (!pointer.has(dataContext.data, pathTruthy) ||\n !pointer.get(dataContext.data, pathTruthy))\n ) {\n return\n }\n if (\n pathFalsy &&\n pointer.has(dataContext.data, pathFalsy) &&\n Boolean(pointer.get(dataContext.data, pathFalsy))\n ) {\n return\n }\n\n if (\n pathTrue &&\n (!pointer.has(dataContext.data, pathTrue) ||\n pointer.get(dataContext.data, pathTrue) !== true)\n ) {\n return\n }\n if (\n pathFalse &&\n (!pointer.has(dataContext.data, pathFalse) ||\n pointer.get(dataContext.data, pathFalse) !== false)\n ) {\n return\n }\n\n if (\n pathValue &&\n !(\n pointer.has(dataContext.data, pathValue) &&\n pointer.get(dataContext.data, pathValue) === whenValue\n )\n ) {\n return\n }\n\n if (inferData && !inferData(dataContext.data)) {\n return\n }\n\n return true\n }\n\n const open = Boolean(check())\n\n if (animate) {\n const props = !open ? fieldPropsWhenHidden : null\n\n return (\n <HeightAnimation\n open={open}\n keepInDOM={keepInDOM}\n className=\"dnb-forms-visibility\"\n {...rest}\n >\n <FieldProps {...props}>{children}</FieldProps>\n </HeightAnimation>\n )\n }\n\n if (keepInDOM) {\n const props = !open ? fieldPropsWhenHidden : null\n return (\n <span className=\"dnb-forms-visibility\" hidden={!open}>\n <FieldProps {...props}>{children}</FieldProps>\n </span>\n )\n }\n\n return open ? children : null\n}\n\nVisibility._supportsSpacingProps = 'children'\nexport default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,GAC5Bb,IAAI,GAERxB,KAAA,CAAAmC,aAAA,CAAC5B,UAAU,EAAK2B,KAAK,EAAGX,QAAqB,CAC9B,CAAC;EAEtB;EAEA,IAAIF,SAAS,EAAE;IACb,MAAMa,KAAK,GAAG,CAACD,IAAI,GAAGX,oBAAoB,GAAG,IAAI;IACjD,OACEtB,KAAA,CAAAmC,aAAA;MAAME,SAAS,EAAC,sBAAsB;MAACC,MAAM,EAAE,CAACL;IAAK,GACnDjC,KAAA,CAAAmC,aAAA,CAAC5B,UAAU,EAAK2B,KAAK,EAAGX,QAAqB,CACzC,CAAC;EAEX;EAEA,OAAOU,IAAI,GAAGV,QAAQ,GAAG,IAAI;AAC/B;AAEAf,UAAU,CAAC+B,qBAAqB,GAAG,UAAU;AAC7C,eAAe/B,UAAU"}
|
|
@@ -59,6 +59,11 @@ export const VisibilityProperties = {
|
|
|
59
59
|
type: 'boolean',
|
|
60
60
|
status: 'optional'
|
|
61
61
|
},
|
|
62
|
+
fieldPropsWhenHidden: {
|
|
63
|
+
doc: 'When visibility is hidden, and `keepInDOM` is true, pass these props to the children.',
|
|
64
|
+
type: 'various',
|
|
65
|
+
status: 'optional'
|
|
66
|
+
},
|
|
62
67
|
element: {
|
|
63
68
|
doc: 'Define the type of element. Defaults to `div`. Only for when `animate` is true.',
|
|
64
69
|
type: 'string or React.Element',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VisibilityDocs.js","names":["VisibilityProperties","pathDefined","doc","type","status","pathUndefined","pathTruthy","pathFalsy","pathTrue","pathFalse","pathValue","whenValue","inferData","visible","animate","keepInDOM","element","children"],"sources":["../../../../../../src/extensions/forms/Form/Visibility/VisibilityDocs.ts"],"sourcesContent":["import { PropertiesTableProps } from '../../../../shared/types'\n\nexport const VisibilityProperties: PropertiesTableProps = {\n pathDefined: {\n doc: 'Given data context path must be defined to show children.',\n type: 'string',\n status: 'optional',\n },\n pathUndefined: {\n doc: 'Given data context path must be undefined to show children.',\n type: 'string',\n status: 'optional',\n },\n pathTruthy: {\n doc: 'Given data context path must be truthy to show children.',\n type: 'string',\n status: 'optional',\n },\n pathFalsy: {\n doc: 'Given data context path must be falsy to show children.',\n type: 'string',\n status: 'optional',\n },\n pathTrue: {\n doc: 'Given data context path must be true to show children.',\n type: 'string',\n status: 'optional',\n },\n pathFalse: {\n doc: 'Given data context path must be false to show children.',\n type: 'string',\n status: 'optional',\n },\n pathValue: {\n doc: 'Given data context path must match, as well as the `whenValue` value.',\n type: 'string',\n status: 'optional',\n },\n whenValue: {\n doc: 'The value to match. Should be used together with `pathValue`.',\n type: 'string',\n status: 'optional',\n },\n inferData: {\n doc: 'Will be called to decide by external logic, and show/hide contents based on the return value.',\n type: 'function',\n status: 'optional',\n },\n visible: {\n doc: 'Control visibility directly by boolean value.',\n type: 'boolean',\n status: 'optional',\n },\n animate: {\n doc: 'Define if the content should animate during show/hide.',\n type: 'boolean',\n status: 'optional',\n },\n keepInDOM: {\n doc: \"Keep the content in the DOM, even if it's not visible. Can be used to let fields run validation.\",\n type: 'boolean',\n status: 'optional',\n },\n element: {\n doc: 'Define the type of element. Defaults to `div`. Only for when `animate` is true.',\n type: 'string or React.Element',\n status: 'optional',\n },\n children: {\n doc: 'Contents.',\n type: 'React.Node',\n status: 'required',\n },\n}\n"],"mappings":"AAEA,OAAO,MAAMA,oBAA0C,GAAG;EACxDC,WAAW,EAAE;IACXC,GAAG,EAAE,2DAA2D;IAChEC,IAAI,EAAE,QAAQ;IACdC,MAAM,EAAE;EACV,CAAC;EACDC,aAAa,EAAE;IACbH,GAAG,EAAE,6DAA6D;IAClEC,IAAI,EAAE,QAAQ;IACdC,MAAM,EAAE;EACV,CAAC;EACDE,UAAU,EAAE;IACVJ,GAAG,EAAE,0DAA0D;IAC/DC,IAAI,EAAE,QAAQ;IACdC,MAAM,EAAE;EACV,CAAC;EACDG,SAAS,EAAE;IACTL,GAAG,EAAE,yDAAyD;IAC9DC,IAAI,EAAE,QAAQ;IACdC,MAAM,EAAE;EACV,CAAC;EACDI,QAAQ,EAAE;IACRN,GAAG,EAAE,wDAAwD;IAC7DC,IAAI,EAAE,QAAQ;IACdC,MAAM,EAAE;EACV,CAAC;EACDK,SAAS,EAAE;IACTP,GAAG,EAAE,yDAAyD;IAC9DC,IAAI,EAAE,QAAQ;IACdC,MAAM,EAAE;EACV,CAAC;EACDM,SAAS,EAAE;IACTR,GAAG,EAAE,uEAAuE;IAC5EC,IAAI,EAAE,QAAQ;IACdC,MAAM,EAAE;EACV,CAAC;EACDO,SAAS,EAAE;IACTT,GAAG,EAAE,+DAA+D;IACpEC,IAAI,EAAE,QAAQ;IACdC,MAAM,EAAE;EACV,CAAC;EACDQ,SAAS,EAAE;IACTV,GAAG,EAAE,+FAA+F;IACpGC,IAAI,EAAE,UAAU;IAChBC,MAAM,EAAE;EACV,CAAC;EACDS,OAAO,EAAE;IACPX,GAAG,EAAE,+CAA+C;IACpDC,IAAI,EAAE,SAAS;IACfC,MAAM,EAAE;EACV,CAAC;EACDU,OAAO,EAAE;IACPZ,GAAG,EAAE,wDAAwD;IAC7DC,IAAI,EAAE,SAAS;IACfC,MAAM,EAAE;EACV,CAAC;EACDW,SAAS,EAAE;IACTb,GAAG,EAAE,kGAAkG;IACvGC,IAAI,EAAE,SAAS;IACfC,MAAM,EAAE;EACV,CAAC;EACDY,OAAO,EAAE;
|
|
1
|
+
{"version":3,"file":"VisibilityDocs.js","names":["VisibilityProperties","pathDefined","doc","type","status","pathUndefined","pathTruthy","pathFalsy","pathTrue","pathFalse","pathValue","whenValue","inferData","visible","animate","keepInDOM","fieldPropsWhenHidden","element","children"],"sources":["../../../../../../src/extensions/forms/Form/Visibility/VisibilityDocs.ts"],"sourcesContent":["import { PropertiesTableProps } from '../../../../shared/types'\n\nexport const VisibilityProperties: PropertiesTableProps = {\n pathDefined: {\n doc: 'Given data context path must be defined to show children.',\n type: 'string',\n status: 'optional',\n },\n pathUndefined: {\n doc: 'Given data context path must be undefined to show children.',\n type: 'string',\n status: 'optional',\n },\n pathTruthy: {\n doc: 'Given data context path must be truthy to show children.',\n type: 'string',\n status: 'optional',\n },\n pathFalsy: {\n doc: 'Given data context path must be falsy to show children.',\n type: 'string',\n status: 'optional',\n },\n pathTrue: {\n doc: 'Given data context path must be true to show children.',\n type: 'string',\n status: 'optional',\n },\n pathFalse: {\n doc: 'Given data context path must be false to show children.',\n type: 'string',\n status: 'optional',\n },\n pathValue: {\n doc: 'Given data context path must match, as well as the `whenValue` value.',\n type: 'string',\n status: 'optional',\n },\n whenValue: {\n doc: 'The value to match. Should be used together with `pathValue`.',\n type: 'string',\n status: 'optional',\n },\n inferData: {\n doc: 'Will be called to decide by external logic, and show/hide contents based on the return value.',\n type: 'function',\n status: 'optional',\n },\n visible: {\n doc: 'Control visibility directly by boolean value.',\n type: 'boolean',\n status: 'optional',\n },\n animate: {\n doc: 'Define if the content should animate during show/hide.',\n type: 'boolean',\n status: 'optional',\n },\n keepInDOM: {\n doc: \"Keep the content in the DOM, even if it's not visible. Can be used to let fields run validation.\",\n type: 'boolean',\n status: 'optional',\n },\n fieldPropsWhenHidden: {\n doc: 'When visibility is hidden, and `keepInDOM` is true, pass these props to the children.',\n type: 'various',\n status: 'optional',\n },\n element: {\n doc: 'Define the type of element. Defaults to `div`. Only for when `animate` is true.',\n type: 'string or React.Element',\n status: 'optional',\n },\n children: {\n doc: 'Contents.',\n type: 'React.Node',\n status: 'required',\n },\n}\n"],"mappings":"AAEA,OAAO,MAAMA,oBAA0C,GAAG;EACxDC,WAAW,EAAE;IACXC,GAAG,EAAE,2DAA2D;IAChEC,IAAI,EAAE,QAAQ;IACdC,MAAM,EAAE;EACV,CAAC;EACDC,aAAa,EAAE;IACbH,GAAG,EAAE,6DAA6D;IAClEC,IAAI,EAAE,QAAQ;IACdC,MAAM,EAAE;EACV,CAAC;EACDE,UAAU,EAAE;IACVJ,GAAG,EAAE,0DAA0D;IAC/DC,IAAI,EAAE,QAAQ;IACdC,MAAM,EAAE;EACV,CAAC;EACD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,7 @@ export { default as ButtonRow } from './ButtonRow';
|
|
|
7
7
|
export { default as MainHeading } from './MainHeading';
|
|
8
8
|
export { default as SubHeading } from './SubHeading';
|
|
9
9
|
export { default as Visibility } from './Visibility';
|
|
10
|
+
export { default as FieldProps } from './FieldProps';
|
|
10
11
|
export { default as useData } from './data-context/useData';
|
|
11
12
|
export { default as setData } from './data-context/setData';
|
|
12
13
|
export { default as getData } from './data-context/getData';
|
|
@@ -7,6 +7,7 @@ export { default as ButtonRow } from './ButtonRow';
|
|
|
7
7
|
export { default as MainHeading } from './MainHeading';
|
|
8
8
|
export { default as SubHeading } from './SubHeading';
|
|
9
9
|
export { default as Visibility } from './Visibility';
|
|
10
|
+
export { default as FieldProps } from './FieldProps';
|
|
10
11
|
export { default as useData } from './data-context/useData';
|
|
11
12
|
export { default as setData } from './data-context/setData';
|
|
12
13
|
export { default as getData } from './data-context/getData';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["default","Handler","Element","Appearance","SubmitButton","SubmitIndicator","ButtonRow","MainHeading","SubHeading","Visibility","useData","setData","getData","useError","useTranslation","useLocale"],"sources":["../../../../../src/extensions/forms/Form/index.ts"],"sourcesContent":["export { default as Handler } from './Handler'\nexport { default as Element } from './Element'\nexport { default as Appearance } from './Appearance'\nexport { default as SubmitButton } from './SubmitButton'\nexport { default as SubmitIndicator } from './SubmitIndicator'\nexport { default as ButtonRow } from './ButtonRow'\nexport { default as MainHeading } from './MainHeading'\nexport { default as SubHeading } from './SubHeading'\nexport { default as Visibility } from './Visibility'\nexport { default as useData } from './data-context/useData'\nexport { default as setData } from './data-context/setData'\nexport { default as getData } from './data-context/getData'\nexport { default as useError } from './data-context/useError'\nexport { default as useTranslation } from '../hooks/useTranslation'\n\n/**\n * Can be removed in v11\n * @deprecated Use `useTranslation` instead\n */\nexport { default as useLocale } from '../hooks/useTranslation'\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,OAAO,QAAQ,WAAW;AAC9C,SAASD,OAAO,IAAIE,OAAO,QAAQ,WAAW;AAC9C,SAASF,OAAO,IAAIG,UAAU,QAAQ,cAAc;AACpD,SAASH,OAAO,IAAII,YAAY,QAAQ,gBAAgB;AACxD,SAASJ,OAAO,IAAIK,eAAe,QAAQ,mBAAmB;AAC9D,SAASL,OAAO,IAAIM,SAAS,QAAQ,aAAa;AAClD,SAASN,OAAO,IAAIO,WAAW,QAAQ,eAAe;AACtD,SAASP,OAAO,IAAIQ,UAAU,QAAQ,cAAc;AACpD,SAASR,OAAO,IAAIS,UAAU,QAAQ,cAAc;AACpD,SAAST,OAAO,IAAIU,
|
|
1
|
+
{"version":3,"file":"index.js","names":["default","Handler","Element","Appearance","SubmitButton","SubmitIndicator","ButtonRow","MainHeading","SubHeading","Visibility","FieldProps","useData","setData","getData","useError","useTranslation","useLocale"],"sources":["../../../../../src/extensions/forms/Form/index.ts"],"sourcesContent":["export { default as Handler } from './Handler'\nexport { default as Element } from './Element'\nexport { default as Appearance } from './Appearance'\nexport { default as SubmitButton } from './SubmitButton'\nexport { default as SubmitIndicator } from './SubmitIndicator'\nexport { default as ButtonRow } from './ButtonRow'\nexport { default as MainHeading } from './MainHeading'\nexport { default as SubHeading } from './SubHeading'\nexport { default as Visibility } from './Visibility'\nexport { default as FieldProps } from './FieldProps'\nexport { default as useData } from './data-context/useData'\nexport { default as setData } from './data-context/setData'\nexport { default as getData } from './data-context/getData'\nexport { default as useError } from './data-context/useError'\nexport { default as useTranslation } from '../hooks/useTranslation'\n\n/**\n * Can be removed in v11\n * @deprecated Use `useTranslation` instead\n */\nexport { default as useLocale } from '../hooks/useTranslation'\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,OAAO,QAAQ,WAAW;AAC9C,SAASD,OAAO,IAAIE,OAAO,QAAQ,WAAW;AAC9C,SAASF,OAAO,IAAIG,UAAU,QAAQ,cAAc;AACpD,SAASH,OAAO,IAAII,YAAY,QAAQ,gBAAgB;AACxD,SAASJ,OAAO,IAAIK,eAAe,QAAQ,mBAAmB;AAC9D,SAASL,OAAO,IAAIM,SAAS,QAAQ,aAAa;AAClD,SAASN,OAAO,IAAIO,WAAW,QAAQ,eAAe;AACtD,SAASP,OAAO,IAAIQ,UAAU,QAAQ,cAAc;AACpD,SAASR,OAAO,IAAIS,UAAU,QAAQ,cAAc;AACpD,SAAST,OAAO,IAAIU,UAAU,QAAQ,cAAc;AACpD,SAASV,OAAO,IAAIW,OAAO,QAAQ,wBAAwB;AAC3D,SAASX,OAAO,IAAIY,OAAO,QAAQ,wBAAwB;AAC3D,SAASZ,OAAO,IAAIa,OAAO,QAAQ,wBAAwB;AAC3D,SAASb,OAAO,IAAIc,QAAQ,QAAQ,yBAAyB;AAC7D,SAASd,OAAO,IAAIe,cAAc,QAAQ,yBAAyB;AAMnE,SAASf,OAAO,IAAIgB,SAAS,QAAQ,yBAAyB"}
|
|
@@ -4,8 +4,9 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
4
4
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
5
5
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
6
6
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
7
|
-
import React, { Fragment, useContext } from 'react';
|
|
7
|
+
import React, { Fragment, useContext, useEffect, useRef } from 'react';
|
|
8
8
|
import classnames from 'classnames';
|
|
9
|
+
import { warn } from '../../../shared/helpers';
|
|
9
10
|
import { Dd, Dl, Dt, Span } from '../../../elements';
|
|
10
11
|
import { FormLabel } from '../../../components';
|
|
11
12
|
import SummaryListContext from '../Value/SummaryList/SummaryListContext';
|
|
@@ -26,11 +27,13 @@ function ValueBlock(props) {
|
|
|
26
27
|
gap = 'xx-small'
|
|
27
28
|
} = props;
|
|
28
29
|
const label = inline ? null : labelProp;
|
|
30
|
+
const ref = useRef(null);
|
|
31
|
+
useNotInSummaryList(valueBlockContext !== null && valueBlockContext !== void 0 && valueBlockContext.composition ? null : ref, label);
|
|
29
32
|
if ((children === undefined || children === null || children === false) && !showEmpty && !placeholder) {
|
|
30
33
|
return null;
|
|
31
34
|
}
|
|
32
35
|
let content = null;
|
|
33
|
-
const compositionClass = composition
|
|
36
|
+
const compositionClass = composition && `dnb-forms-value-block__composition--${composition === true ? 'horizontal' : composition}`;
|
|
34
37
|
if (summaryListContext) {
|
|
35
38
|
const Element = summaryListContext.isNested ? Dl : summaryListContext.layout === 'horizontal' ? Dl.Item : Fragment;
|
|
36
39
|
if (!label && valueBlockContext !== null && valueBlockContext !== void 0 && valueBlockContext.composition) {
|
|
@@ -57,6 +60,7 @@ function ValueBlock(props) {
|
|
|
57
60
|
}
|
|
58
61
|
} else {
|
|
59
62
|
content = React.createElement(Span, _extends({
|
|
63
|
+
ref: ref,
|
|
60
64
|
className: classnames('dnb-forms-value-block', compositionClass, className, inline && 'dnb-forms-value-block--inline', maxWidth && `dnb-forms-value-block--max-width-${maxWidth}`)
|
|
61
65
|
}, pickSpacingProps(props)), label && React.createElement(FormLabel, {
|
|
62
66
|
element: "strong",
|
|
@@ -72,6 +76,18 @@ function ValueBlock(props) {
|
|
|
72
76
|
value: props
|
|
73
77
|
}, content);
|
|
74
78
|
}
|
|
79
|
+
function useNotInSummaryList(ref, label) {
|
|
80
|
+
useEffect(() => {
|
|
81
|
+
if (ref !== null && ref !== void 0 && ref.current) {
|
|
82
|
+
try {
|
|
83
|
+
const sibling = ref.current.previousElementSibling;
|
|
84
|
+
if (sibling !== null && sibling !== void 0 && sibling.classList.contains('dnb-forms-value-block') && !ref.current.closest('.dnb-forms-summary-list')) {
|
|
85
|
+
warn.apply(warn, ['Value components as siblings should be wrapped inside a Value.SummaryList!', label].filter(Boolean));
|
|
86
|
+
}
|
|
87
|
+
} catch (error) {}
|
|
88
|
+
}
|
|
89
|
+
}, [label, ref]);
|
|
90
|
+
}
|
|
75
91
|
ValueBlock._supportsSpacingProps = true;
|
|
76
92
|
export default ValueBlock;
|
|
77
93
|
//# sourceMappingURL=ValueBlock.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ValueBlock.js","names":["React","Fragment","useContext","classnames","Dd","Dl","Dt","Span","FormLabel","SummaryListContext","pickSpacingProps","ValueBlockContext","ValueBlock","props","summaryListContext","valueBlockContext","className","label","labelProp","inline","maxWidth","composition","placeholder","showEmpty","children","gap","undefined","content","compositionClass","Element","isNested","layout","Item","_span","createElement","Provider","value","_objectSpread","_extends","element","labelDirection","_supportsSpacingProps"],"sources":["../../../../../src/extensions/forms/ValueBlock/ValueBlock.tsx"],"sourcesContent":["import React, { Fragment, useContext } from 'react'\nimport classnames from 'classnames'\nimport { Dd, Dl, Dt, Span } from '../../../elements'\nimport { FormLabel } from '../../../components'\nimport SummaryListContext from '../Value/SummaryList/SummaryListContext'\nimport { ValueProps } from '../types'\nimport { pickSpacingProps } from '../../../components/flex/utils'\nimport ValueBlockContext from './ValueBlockContext'\n\n/**\n * Props are documented in ValueDocs.ts\n */\nexport type Props = Omit<ValueProps<unknown>, 'value'> & {\n children?: React.ReactNode\n\n /**\n * Used internally by the Composition component\n */\n composition?: boolean\n\n /**\n * Used internally by the Composition component\n */\n gap?: 'xx-small' | 'x-small' | 'small' | 'medium' | 'large' | false\n}\n\nfunction ValueBlock(props: Props) {\n const summaryListContext = useContext(SummaryListContext)\n const valueBlockContext = useContext(ValueBlockContext)\n\n const {\n className,\n label: labelProp,\n inline,\n maxWidth = props.composition ? props.maxWidth : 'large',\n placeholder,\n showEmpty,\n children,\n composition,\n gap = 'xx-small',\n } = props\n\n const label = inline ? null : labelProp\n\n if (\n (children === undefined || children === null || children === false) &&\n !showEmpty &&\n !placeholder\n ) {\n return null\n }\n\n let content = null\n\n const compositionClass
|
|
1
|
+
{"version":3,"file":"ValueBlock.js","names":["React","Fragment","useContext","useEffect","useRef","classnames","warn","Dd","Dl","Dt","Span","FormLabel","SummaryListContext","pickSpacingProps","ValueBlockContext","ValueBlock","props","summaryListContext","valueBlockContext","className","label","labelProp","inline","maxWidth","composition","placeholder","showEmpty","children","gap","ref","useNotInSummaryList","undefined","content","compositionClass","Element","isNested","layout","Item","_span","createElement","Provider","value","_objectSpread","_extends","element","labelDirection","current","sibling","previousElementSibling","classList","contains","closest","apply","filter","Boolean","error","_supportsSpacingProps"],"sources":["../../../../../src/extensions/forms/ValueBlock/ValueBlock.tsx"],"sourcesContent":["import React, { Fragment, useContext, useEffect, useRef } from 'react'\nimport classnames from 'classnames'\nimport { warn } from '../../../shared/helpers'\nimport { Dd, Dl, Dt, Span } from '../../../elements'\nimport { FormLabel } from '../../../components'\nimport SummaryListContext from '../Value/SummaryList/SummaryListContext'\nimport { ValueProps } from '../types'\nimport { pickSpacingProps } from '../../../components/flex/utils'\nimport ValueBlockContext from './ValueBlockContext'\n\n/**\n * Props are documented in ValueDocs.ts\n */\nexport type Props = Omit<ValueProps<unknown>, 'value'> & {\n children?: React.ReactNode\n\n /**\n * Used internally by the Composition component\n */\n composition?: boolean\n\n /**\n * Used internally by the Composition component\n */\n gap?: 'xx-small' | 'x-small' | 'small' | 'medium' | 'large' | false\n}\n\nfunction ValueBlock(props: Props) {\n const summaryListContext = useContext(SummaryListContext)\n const valueBlockContext = useContext(ValueBlockContext)\n\n const {\n className,\n label: labelProp,\n inline,\n maxWidth = props.composition ? props.maxWidth : 'large',\n placeholder,\n showEmpty,\n children,\n composition,\n gap = 'xx-small',\n } = props\n\n const label = inline ? null : labelProp\n\n const ref = useRef<HTMLElement>(null)\n useNotInSummaryList(valueBlockContext?.composition ? null : ref, label)\n\n if (\n (children === undefined || children === null || children === false) &&\n !showEmpty &&\n !placeholder\n ) {\n return null\n }\n\n let content = null\n\n const compositionClass =\n composition &&\n classnames(\n `dnb-forms-value-block__composition--${\n composition === true ? 'horizontal' : composition\n }`\n )\n\n if (summaryListContext) {\n const Element = summaryListContext.isNested\n ? Dl\n : summaryListContext.layout === 'horizontal'\n ? Dl.Item\n : Fragment\n\n if (!label && valueBlockContext?.composition) {\n content = (\n <span\n className={classnames(\n 'dnb-forms-value-block__content',\n gap && `dnb-forms-value-block__content--gap-${gap}`\n )}\n >\n {children}\n </span>\n ) ?? (\n <span className=\"dnb-forms-value-block__placeholder\">\n {placeholder}\n </span>\n )\n } else {\n content = (\n <Element>\n <SummaryListContext.Provider\n value={{ ...summaryListContext, isNested: true }}\n >\n {label && (\n <Dt className=\"dnb-forms-value-block__label\">\n <strong>{label}</strong>\n </Dt>\n )}\n <Dd\n className={classnames(\n summaryListContext.layout !== 'grid' &&\n !summaryListContext.isNested &&\n maxWidth &&\n `dnb-forms-value-block--max-width-${maxWidth}`,\n compositionClass\n )}\n >\n {children ? (\n <span\n className={classnames(\n 'dnb-forms-value-block__content',\n gap && `dnb-forms-value-block__content--gap-${gap}`\n )}\n >\n {children}\n </span>\n ) : (\n <span className=\"dnb-forms-value-block__placeholder\">\n {placeholder}\n </span>\n )}\n </Dd>\n </SummaryListContext.Provider>\n </Element>\n )\n }\n } else {\n content = (\n <Span\n ref={ref}\n className={classnames(\n 'dnb-forms-value-block',\n inline && 'dnb-forms-value-block--inline',\n maxWidth && `dnb-forms-value-block--max-width-${maxWidth}`,\n compositionClass,\n className\n )}\n {...pickSpacingProps(props)}\n >\n {label && (\n <FormLabel\n element=\"strong\" // enhance a11y: https://www.w3.org/WAI/WCAG21/Techniques/html/H49\n className=\"dnb-forms-value-block__label\"\n labelDirection={inline ? 'horizontal' : 'vertical'}\n >\n {label}\n </FormLabel>\n )}\n {children ? (\n <span\n className={classnames(\n 'dnb-forms-value-block__content',\n gap && `dnb-forms-value-block__content--gap-${gap}`\n )}\n >\n {children}\n </span>\n ) : (\n <span className=\"dnb-forms-value-block__placeholder\">\n {placeholder}\n </span>\n )}\n </Span>\n )\n }\n\n return (\n <ValueBlockContext.Provider value={props}>\n {content}\n </ValueBlockContext.Provider>\n )\n}\n\nfunction useNotInSummaryList(\n ref: React.RefObject<HTMLElement>,\n label?: React.ReactNode\n) {\n useEffect(() => {\n if (ref?.current) {\n try {\n const sibling = ref.current.previousElementSibling\n\n if (\n sibling?.classList.contains('dnb-forms-value-block') &&\n !ref.current.closest('.dnb-forms-summary-list')\n ) {\n warn.apply(\n warn,\n [\n 'Value components as siblings should be wrapped inside a Value.SummaryList!',\n label,\n ].filter(Boolean)\n )\n }\n } catch (error) {\n //\n }\n }\n }, [label, ref])\n}\n\nValueBlock._supportsSpacingProps = true\nexport default ValueBlock\n"],"mappings":";;;;;;AAAA,OAAOA,KAAK,IAAIC,QAAQ,EAAEC,UAAU,EAAEC,SAAS,EAAEC,MAAM,QAAQ,OAAO;AACtE,OAAOC,UAAU,MAAM,YAAY;AACnC,SAASC,IAAI,QAAQ,yBAAyB;AAC9C,SAASC,EAAE,EAAEC,EAAE,EAAEC,EAAE,EAAEC,IAAI,QAAQ,mBAAmB;AACpD,SAASC,SAAS,QAAQ,qBAAqB;AAC/C,OAAOC,kBAAkB,MAAM,yCAAyC;AAExE,SAASC,gBAAgB,QAAQ,gCAAgC;AACjE,OAAOC,iBAAiB,MAAM,qBAAqB;AAmBnD,SAASC,UAAUA,CAACC,KAAY,EAAE;EAChC,MAAMC,kBAAkB,GAAGf,UAAU,CAACU,kBAAkB,CAAC;EACzD,MAAMM,iBAAiB,GAAGhB,UAAU,CAACY,iBAAiB,CAAC;EAEvD,MAAM;IACJK,SAAS;IACTC,KAAK,EAAEC,SAAS;IAChBC,MAAM;IACNC,QAAQ,GAAGP,KAAK,CAACQ,W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KAAA,CAAAuC,aAAA;MACEpB,SAAS,EACP,gCAAgC,IAChCS,GAAG,2CAA2CA,GAAI;IAClD,GAEDD,QACG,CAAC,GAEP3B,KAAA,CAAAuC,aAAA;MAAMpB,SAAS,EAAC;IAAoC,GACjDM,WACG,CAEJ,CACP;EACH;EAEA,OACEzB,KAAA,CAAAuC,aAAA,CAACzB,iBAAiB,CAAC0B,QAAQ;IAACC,KAAK,EAAEzB;EAAM,GACtCgB,OACyB,CAAC;AAEjC;AAEA,SAASF,mBAAmBA,CAC1BD,GAAiC,EACjCT,KAAuB,EACvB;EACAjB,SAAS,CAAC,MAAM;IACd,IAAI0B,GAAG,aAAHA,GAAG,eAAHA,GAAG,CAAEiB,OAAO,EAAE;MAChB,IAAI;QACF,MAAMC,OAAO,GAAGlB,GAAG,CAACiB,OAAO,CAACE,sBAAsB;QAElD,IACED,OAAO,aAAPA,OAAO,eAAPA,OAAO,CAAEE,SAAS,CAACC,QAAQ,CAAC,uBAAuB,CAAC,IACpD,CAACrB,GAAG,CAACiB,OAAO,CAACK,OAAO,CAAC,yBAAyB,CAAC,EAC/C;UACA7C,IAAI,CAAC8C,KAAK,CACR9C,IAAI,EACJ,CACE,4EAA4E,EAC5Ec,KAAK,CACN,CAACiC,MAAM,CAACC,OAAO,CAClB,CAAC;QACH;MACF,CAAC,CAAC,OAAOC,KAAK,EAAE,CAEhB;IACF;EACF,CAAC,EAAE,CAACnC,KAAK,EAAES,GAAG,CAAC,CAAC;AAClB;AAEAd,UAAU,CAACyC,qBAAqB,GAAG,IAAI;AACvC,eAAezC,UAAU"}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import React, { useCallback } from 'react';
|
|
2
2
|
import useStep from './useStep';
|
|
3
3
|
const useLayoutEffect = typeof window === 'undefined' ? React.useEffect : React.useLayoutEffect;
|
|
4
|
-
export default function useNextRouter(
|
|
4
|
+
export default function useNextRouter() {
|
|
5
|
+
let id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
5
6
|
let {
|
|
6
7
|
useRouter,
|
|
7
8
|
usePathname,
|
|
8
9
|
useSearchParams
|
|
9
|
-
} =
|
|
10
|
+
} = arguments.length > 1 ? arguments[1] : undefined;
|
|
11
|
+
const name = id ? `${id}-step` : 'step';
|
|
10
12
|
const {
|
|
11
13
|
setFormError
|
|
12
14
|
} = useStep(id);
|
|
@@ -16,18 +18,18 @@ export default function useNextRouter(id, _ref) {
|
|
|
16
18
|
const onStepChange = useCallback(index => {
|
|
17
19
|
try {
|
|
18
20
|
const params = new URLSearchParams(searchParams.toString());
|
|
19
|
-
params.set(
|
|
21
|
+
params.set(name, String(index));
|
|
20
22
|
router.push(`${pathname}?${params.toString()}`);
|
|
21
23
|
} catch (error) {
|
|
22
24
|
setFormError(error);
|
|
23
25
|
}
|
|
24
|
-
}, [
|
|
26
|
+
}, [name, pathname, router, searchParams, setFormError]);
|
|
25
27
|
const {
|
|
26
28
|
setActiveIndex
|
|
27
29
|
} = useStep(id, {
|
|
28
30
|
onStepChange
|
|
29
31
|
});
|
|
30
|
-
const getIndex = useCallback(() => parseFloat(searchParams.get(
|
|
32
|
+
const getIndex = useCallback(() => parseFloat(searchParams.get(name)), [name, searchParams]);
|
|
31
33
|
useLayoutEffect(() => {
|
|
32
34
|
const routerIndex = getIndex();
|
|
33
35
|
if (!isNaN(routerIndex)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useNextRouter.js","names":["React","useCallback","useStep","useLayoutEffect","window","useEffect","useNextRouter","id","
|
|
1
|
+
{"version":3,"file":"useNextRouter.js","names":["React","useCallback","useStep","useLayoutEffect","window","useEffect","useNextRouter","id","arguments","length","undefined","useRouter","usePathname","useSearchParams","name","setFormError","router","pathname","searchParams","onStepChange","index","params","URLSearchParams","toString","set","String","push","error","setActiveIndex","getIndex","parseFloat","get","routerIndex","isNaN","skipStepChangeCallFromHook","skipStepChangeCallBeforeMounted"],"sources":["../../../../../../src/extensions/forms/Wizard/hooks/useNextRouter.tsx"],"sourcesContent":["import React, { useCallback } from 'react'\nimport useStep from './useStep'\n\n// SSR warning fix: https://gist.github.com/gaearon/e7d97cdf38a2907924ea12e4ebdf3c85\nconst useLayoutEffect =\n typeof window === 'undefined' ? React.useEffect : React.useLayoutEffect\n\nexport default function useNextRouter(\n id: string = null,\n { useRouter, usePathname, useSearchParams }\n) {\n const name = id ? `${id}-step` : 'step'\n const { setFormError } = useStep(id)\n const router = useRouter()\n const pathname = usePathname()\n const searchParams = useSearchParams()\n\n const onStepChange = useCallback(\n (index: number) => {\n try {\n const params = new URLSearchParams(searchParams.toString())\n params.set(name, String(index))\n router.push(`${pathname}?${params.toString()}`)\n } catch (error) {\n setFormError(error)\n }\n },\n [name, pathname, router, searchParams, setFormError]\n )\n\n const { setActiveIndex } = useStep(id, { onStepChange })\n\n const getIndex = useCallback(\n () => parseFloat(searchParams.get(name)),\n [name, searchParams]\n )\n\n useLayoutEffect(() => {\n const routerIndex = getIndex()\n if (!isNaN(routerIndex)) {\n setActiveIndex(routerIndex, {\n skipStepChangeCallFromHook: true,\n skipStepChangeCallBeforeMounted: true,\n })\n }\n }, [getIndex, id, searchParams, setActiveIndex, setFormError])\n\n return { getIndex }\n}\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,WAAW,QAAQ,OAAO;AAC1C,OAAOC,OAAO,MAAM,WAAW;AAG/B,MAAMC,eAAe,GACnB,OAAOC,MAAM,KAAK,WAAW,GAAGJ,KAAK,CAACK,SAAS,GAAGL,KAAK,CAACG,eAAe;AAEzE,eAAe,SAASG,aAAaA,CAAA,EAGnC;EAAA,IAFAC,EAAU,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,IAAI;EAAA,IACjB;IAAEG,SAAS;IAAEC,WAAW;IAAEC;EAAgB,CAAC,GAAAL,SAAA,CAAAC,MAAA,OAAAD,SAAA,MAAAE,SAAA;EAE3C,MAAMI,IAAI,GAAGP,EAAE,GAAI,G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EAAEW,YAAY,EAAEU,cAAc,EAAEb,YAAY,CAAC,CAAC;EAE9D,OAAO;IAAEc;EAAS,CAAC;AACrB"}
|
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
import React, { useCallback } from 'react';
|
|
2
2
|
import useStep from './useStep';
|
|
3
3
|
const useLayoutEffect = typeof window === 'undefined' ? React.useEffect : React.useLayoutEffect;
|
|
4
|
-
export default function useQueryLocator(
|
|
4
|
+
export default function useQueryLocator() {
|
|
5
|
+
let id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : undefined;
|
|
5
6
|
const {
|
|
6
7
|
setFormError
|
|
7
8
|
} = useStep(id);
|
|
9
|
+
const name = id ? `${id}-step` : 'step';
|
|
8
10
|
const onStepChange = useCallback(index => {
|
|
9
11
|
try {
|
|
10
12
|
const url = new URL(window.location.href);
|
|
11
|
-
url.searchParams.set(
|
|
13
|
+
url.searchParams.set(name, String(index));
|
|
12
14
|
window.history.pushState({}, '', url.toString());
|
|
13
15
|
} catch (error) {
|
|
14
16
|
setFormError(error);
|
|
15
17
|
}
|
|
16
|
-
}, [
|
|
18
|
+
}, [name, setFormError]);
|
|
17
19
|
const {
|
|
18
20
|
setActiveIndex
|
|
19
21
|
} = useStep(id, {
|
|
@@ -22,11 +24,11 @@ export default function useQueryLocator(id) {
|
|
|
22
24
|
const getIndex = useCallback(() => {
|
|
23
25
|
try {
|
|
24
26
|
const searchParams = new URLSearchParams(window.location.search);
|
|
25
|
-
return parseFloat(searchParams.get(
|
|
27
|
+
return parseFloat(searchParams.get(name));
|
|
26
28
|
} catch (error) {
|
|
27
29
|
setFormError(error);
|
|
28
30
|
}
|
|
29
|
-
}, [
|
|
31
|
+
}, [name, setFormError]);
|
|
30
32
|
useLayoutEffect(() => {
|
|
31
33
|
try {
|
|
32
34
|
const popstateListener = () => {
|