@dnb/eufemia 10.70.0 → 10.71.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/CHANGELOG.md +26 -0
- package/cjs/components/autocomplete/AutocompleteDocs.js +3 -3
- package/cjs/components/autocomplete/AutocompleteDocs.js.map +1 -1
- package/cjs/components/avatar/Avatar.js +3 -8
- package/cjs/components/avatar/Avatar.js.map +1 -1
- package/cjs/components/checkbox/CheckboxDocs.js +2 -2
- package/cjs/components/checkbox/CheckboxDocs.js.map +1 -1
- package/cjs/components/date-picker/DatePickerContext.d.ts +0 -1
- package/cjs/components/date-picker/DatePickerContext.js.map +1 -1
- package/cjs/components/date-picker/DatePickerDocs.js +1 -1
- package/cjs/components/date-picker/DatePickerDocs.js.map +1 -1
- package/cjs/components/date-picker/DatePickerInput.js +110 -136
- package/cjs/components/date-picker/DatePickerInput.js.map +1 -1
- package/cjs/components/date-picker/DatePickerProvider.js +0 -2
- package/cjs/components/date-picker/DatePickerProvider.js.map +1 -1
- package/cjs/components/date-picker/hooks/useDates.d.ts +0 -2
- package/cjs/components/date-picker/hooks/useDates.js +5 -5
- package/cjs/components/date-picker/hooks/useDates.js.map +1 -1
- package/cjs/components/date-picker/style/dnb-date-picker.css +4 -0
- package/cjs/components/date-picker/style/dnb-date-picker.min.css +1 -1
- package/cjs/components/date-picker/style/dnb-date-picker.scss +3 -0
- package/cjs/components/dialog/DialogDocs.js +7 -2
- package/cjs/components/dialog/DialogDocs.js.map +1 -1
- package/cjs/components/dropdown/Dropdown.d.ts +20 -20
- package/cjs/components/dropdown/DropdownDocs.d.ts +1 -0
- package/cjs/components/dropdown/DropdownDocs.js +158 -1
- package/cjs/components/dropdown/DropdownDocs.js.map +1 -1
- package/cjs/components/flex/ContainerDocs.js +1 -1
- package/cjs/components/flex/ContainerDocs.js.map +1 -1
- package/cjs/components/flex/ItemDocs.d.ts +2 -0
- package/cjs/components/flex/ItemDocs.js +39 -0
- package/cjs/components/flex/ItemDocs.js.map +1 -0
- package/cjs/components/grid/ItemDocs.d.ts +2 -0
- package/cjs/components/grid/ItemDocs.js +19 -0
- package/cjs/components/grid/ItemDocs.js.map +1 -0
- package/cjs/components/input/InputDocs.js +3 -3
- package/cjs/components/input/InputDocs.js.map +1 -1
- package/cjs/components/input-masked/InputMasked.d.ts +0 -3
- package/cjs/components/input-masked/InputMaskedDocs.d.ts +1 -0
- package/cjs/components/input-masked/InputMaskedDocs.js +58 -1
- package/cjs/components/input-masked/InputMaskedDocs.js.map +1 -1
- package/cjs/components/input-masked/InputMaskedHooks.js +11 -7
- package/cjs/components/input-masked/InputMaskedHooks.js.map +1 -1
- package/cjs/components/input-masked/InputMaskedUtils.d.ts +1 -1
- package/cjs/components/input-masked/InputMaskedUtils.js +2 -1
- package/cjs/components/input-masked/InputMaskedUtils.js.map +1 -1
- package/cjs/components/input-masked/MultiInputMaskedDocs.d.ts +2 -0
- package/cjs/components/input-masked/MultiInputMaskedDocs.js +70 -1
- package/cjs/components/input-masked/MultiInputMaskedDocs.js.map +1 -1
- package/cjs/components/input-masked/style/dnb-input-masked.css +9 -0
- package/cjs/components/input-masked/style/dnb-input-masked.min.css +1 -1
- package/cjs/components/input-masked/style/dnb-input-masked.scss +12 -0
- package/cjs/components/input-masked/text-mask/InputModeNumber.d.ts +8 -0
- package/cjs/components/input-masked/text-mask/InputModeNumber.js +32 -9
- package/cjs/components/input-masked/text-mask/InputModeNumber.js.map +1 -1
- package/cjs/components/input-masked/text-mask/adjustCaretPosition.d.ts +2 -1
- package/cjs/components/input-masked/text-mask/adjustCaretPosition.js +3 -2
- package/cjs/components/input-masked/text-mask/adjustCaretPosition.js.map +1 -1
- package/cjs/components/input-masked/text-mask/createTextMaskInputElement.js +9 -3
- package/cjs/components/input-masked/text-mask/createTextMaskInputElement.js.map +1 -1
- package/cjs/components/modal/ModalDocs.d.ts +5 -0
- package/cjs/components/modal/ModalDocs.js +201 -0
- package/cjs/components/modal/ModalDocs.js.map +1 -0
- package/cjs/components/radio/RadioDocs.js +2 -2
- package/cjs/components/radio/RadioDocs.js.map +1 -1
- package/cjs/components/section/Section.js +2 -7
- package/cjs/components/section/Section.js.map +1 -1
- package/cjs/components/section/SectionDocs.js +1 -1
- package/cjs/components/section/SectionDocs.js.map +1 -1
- package/cjs/components/slider/SliderDocs.js +2 -2
- package/cjs/components/slider/SliderDocs.js.map +1 -1
- package/cjs/components/space/SpaceDocs.d.ts +3 -0
- package/cjs/components/space/SpaceDocs.js +61 -0
- package/cjs/components/space/SpaceDocs.js.map +1 -0
- package/cjs/components/switch/SwitchDocs.js +2 -2
- package/cjs/components/switch/SwitchDocs.js.map +1 -1
- package/cjs/components/textarea/TextareaDocs.js +3 -3
- package/cjs/components/textarea/TextareaDocs.js.map +1 -1
- package/cjs/components/toggle-button/ToggleButtonGroupDocs.js +1 -1
- package/cjs/components/toggle-button/ToggleButtonGroupDocs.js.map +1 -1
- package/cjs/components/tooltip/TooltipDocs.js +1 -1
- package/cjs/components/tooltip/TooltipDocs.js.map +1 -1
- package/cjs/components/upload/Upload.js +6 -3
- package/cjs/components/upload/Upload.js.map +1 -1
- package/cjs/components/upload/UploadDocs.d.ts +1 -0
- package/cjs/components/upload/UploadDocs.js +43 -1
- package/cjs/components/upload/UploadDocs.js.map +1 -1
- package/cjs/components/upload/UploadFileListCell.js +32 -12
- package/cjs/components/upload/UploadFileListCell.js.map +1 -1
- package/cjs/components/upload/types.d.ts +7 -0
- package/cjs/components/upload/types.js.map +1 -1
- package/cjs/extensions/forms/DataContext/At/AtDocs.d.ts +2 -0
- package/cjs/extensions/forms/DataContext/At/AtDocs.js +24 -0
- package/cjs/extensions/forms/DataContext/At/AtDocs.js.map +1 -0
- package/cjs/extensions/forms/DataContext/Provider/ProviderDocs.js +1 -1
- package/cjs/extensions/forms/DataContext/Provider/ProviderDocs.js.map +1 -1
- package/cjs/extensions/forms/Field/Number/Number.js +3 -6
- package/cjs/extensions/forms/Field/Number/Number.js.map +1 -1
- package/cjs/extensions/forms/Field/Password/PasswordDocs.d.ts +1 -0
- package/cjs/extensions/forms/Field/Password/PasswordDocs.js +14 -2
- package/cjs/extensions/forms/Field/Password/PasswordDocs.js.map +1 -1
- package/cjs/extensions/forms/Field/PhoneNumber/PhoneNumber.d.ts +6 -4
- package/cjs/extensions/forms/Field/PhoneNumber/PhoneNumber.js +33 -25
- package/cjs/extensions/forms/Field/PhoneNumber/PhoneNumber.js.map +1 -1
- package/cjs/extensions/forms/Field/PhoneNumber/PhoneNumberDocs.d.ts +2 -2
- package/cjs/extensions/forms/Field/PhoneNumber/PhoneNumberDocs.js +8 -3
- package/cjs/extensions/forms/Field/PhoneNumber/PhoneNumberDocs.js.map +1 -1
- package/cjs/extensions/forms/Field/Provider/useFieldProvider.d.ts +3 -3
- package/cjs/extensions/forms/Field/String/StringDocs.js +1 -1
- package/cjs/extensions/forms/Field/String/StringDocs.js.map +1 -1
- package/cjs/extensions/forms/Field/Upload/Upload.d.ts +1 -1
- package/cjs/extensions/forms/Field/Upload/Upload.js +3 -1
- package/cjs/extensions/forms/Field/Upload/Upload.js.map +1 -1
- package/cjs/extensions/forms/FieldBlock/FieldBlock.js +11 -4
- package/cjs/extensions/forms/FieldBlock/FieldBlock.js.map +1 -1
- package/cjs/extensions/forms/FieldBlock/FieldBlockContext.d.ts +1 -1
- package/cjs/extensions/forms/FieldBlock/FieldBlockContext.js.map +1 -1
- package/cjs/extensions/forms/Form/ButtonRow/ButtonRowDocs.d.ts +2 -0
- package/cjs/extensions/forms/Form/ButtonRow/ButtonRowDocs.js +19 -0
- package/cjs/extensions/forms/Form/ButtonRow/ButtonRowDocs.js.map +1 -0
- package/cjs/extensions/forms/Form/Isolation/IsolationDocs.js +1 -1
- package/cjs/extensions/forms/Form/Isolation/IsolationDocs.js.map +1 -1
- package/cjs/extensions/forms/Wizard/Buttons/ButtonsDocs.d.ts +2 -0
- package/cjs/extensions/forms/Wizard/Buttons/ButtonsDocs.js +14 -0
- package/cjs/extensions/forms/Wizard/Buttons/ButtonsDocs.js.map +1 -0
- package/cjs/extensions/forms/hooks/DataValueWritePropsDocs.js +1 -1
- package/cjs/extensions/forms/hooks/DataValueWritePropsDocs.js.map +1 -1
- package/cjs/extensions/forms/hooks/useFieldProps.js +55 -18
- package/cjs/extensions/forms/hooks/useFieldProps.js.map +1 -1
- package/cjs/extensions/forms/types.d.ts +8 -5
- package/cjs/extensions/forms/types.js.map +1 -1
- package/cjs/extensions/forms/utils/FormError.d.ts +20 -16
- package/cjs/extensions/forms/utils/FormError.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/helpers.d.ts +1 -0
- package/cjs/shared/helpers.js +7 -0
- package/cjs/shared/helpers.js.map +1 -1
- package/cjs/shared/locales/sv-SE.js +2 -2
- package/cjs/shared/locales/sv-SE.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 +13 -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/theme-eiendom/eiendom-theme-components.css +13 -0
- package/cjs/style/themes/theme-eiendom/eiendom-theme-components.min.css +1 -1
- package/cjs/style/themes/theme-sbanken/sbanken-theme-components.css +13 -0
- package/cjs/style/themes/theme-sbanken/sbanken-theme-components.min.css +1 -1
- package/cjs/style/themes/theme-ui/ui-theme-components.css +13 -0
- package/cjs/style/themes/theme-ui/ui-theme-components.min.css +1 -1
- package/components/autocomplete/AutocompleteDocs.js +3 -3
- package/components/autocomplete/AutocompleteDocs.js.map +1 -1
- package/components/avatar/Avatar.js +1 -6
- package/components/avatar/Avatar.js.map +1 -1
- package/components/checkbox/CheckboxDocs.js +2 -2
- package/components/checkbox/CheckboxDocs.js.map +1 -1
- package/components/date-picker/DatePickerContext.d.ts +0 -1
- package/components/date-picker/DatePickerContext.js.map +1 -1
- package/components/date-picker/DatePickerDocs.js +1 -1
- package/components/date-picker/DatePickerDocs.js.map +1 -1
- package/components/date-picker/DatePickerInput.js +111 -137
- package/components/date-picker/DatePickerInput.js.map +1 -1
- package/components/date-picker/DatePickerProvider.js +0 -2
- package/components/date-picker/DatePickerProvider.js.map +1 -1
- package/components/date-picker/hooks/useDates.d.ts +0 -2
- package/components/date-picker/hooks/useDates.js +3 -5
- package/components/date-picker/hooks/useDates.js.map +1 -1
- package/components/date-picker/style/dnb-date-picker.css +4 -0
- package/components/date-picker/style/dnb-date-picker.min.css +1 -1
- package/components/date-picker/style/dnb-date-picker.scss +3 -0
- package/components/dialog/DialogDocs.js +7 -2
- package/components/dialog/DialogDocs.js.map +1 -1
- package/components/dropdown/Dropdown.d.ts +20 -20
- package/components/dropdown/DropdownDocs.d.ts +1 -0
- package/components/dropdown/DropdownDocs.js +157 -0
- package/components/dropdown/DropdownDocs.js.map +1 -1
- package/components/flex/ContainerDocs.js +1 -1
- package/components/flex/ContainerDocs.js.map +1 -1
- package/components/flex/ItemDocs.d.ts +2 -0
- package/components/flex/ItemDocs.js +33 -0
- package/components/flex/ItemDocs.js.map +1 -0
- package/components/grid/ItemDocs.d.ts +2 -0
- package/components/grid/ItemDocs.js +13 -0
- package/components/grid/ItemDocs.js.map +1 -0
- package/components/input/InputDocs.js +3 -3
- package/components/input/InputDocs.js.map +1 -1
- package/components/input-masked/InputMasked.d.ts +0 -3
- package/components/input-masked/InputMaskedDocs.d.ts +1 -0
- package/components/input-masked/InputMaskedDocs.js +57 -0
- package/components/input-masked/InputMaskedDocs.js.map +1 -1
- package/components/input-masked/InputMaskedHooks.js +11 -7
- package/components/input-masked/InputMaskedHooks.js.map +1 -1
- package/components/input-masked/InputMaskedUtils.d.ts +1 -1
- package/components/input-masked/InputMaskedUtils.js +2 -1
- package/components/input-masked/InputMaskedUtils.js.map +1 -1
- package/components/input-masked/MultiInputMaskedDocs.d.ts +2 -0
- package/components/input-masked/MultiInputMaskedDocs.js +69 -0
- package/components/input-masked/MultiInputMaskedDocs.js.map +1 -1
- package/components/input-masked/style/dnb-input-masked.css +9 -0
- package/components/input-masked/style/dnb-input-masked.min.css +1 -1
- package/components/input-masked/style/dnb-input-masked.scss +12 -0
- package/components/input-masked/text-mask/InputModeNumber.d.ts +8 -0
- package/components/input-masked/text-mask/InputModeNumber.js +32 -9
- package/components/input-masked/text-mask/InputModeNumber.js.map +1 -1
- package/components/input-masked/text-mask/adjustCaretPosition.d.ts +2 -1
- package/components/input-masked/text-mask/adjustCaretPosition.js +3 -2
- package/components/input-masked/text-mask/adjustCaretPosition.js.map +1 -1
- package/components/input-masked/text-mask/createTextMaskInputElement.js +9 -3
- package/components/input-masked/text-mask/createTextMaskInputElement.js.map +1 -1
- package/components/modal/ModalDocs.d.ts +5 -0
- package/components/modal/ModalDocs.js +195 -0
- package/components/modal/ModalDocs.js.map +1 -0
- package/components/radio/RadioDocs.js +2 -2
- package/components/radio/RadioDocs.js.map +1 -1
- package/components/section/Section.js +1 -6
- package/components/section/Section.js.map +1 -1
- package/components/section/SectionDocs.js +1 -1
- package/components/section/SectionDocs.js.map +1 -1
- package/components/slider/SliderDocs.js +2 -2
- package/components/slider/SliderDocs.js.map +1 -1
- package/components/space/SpaceDocs.d.ts +3 -0
- package/components/space/SpaceDocs.js +55 -0
- package/components/space/SpaceDocs.js.map +1 -0
- package/components/switch/SwitchDocs.js +2 -2
- package/components/switch/SwitchDocs.js.map +1 -1
- package/components/textarea/TextareaDocs.js +3 -3
- package/components/textarea/TextareaDocs.js.map +1 -1
- package/components/toggle-button/ToggleButtonGroupDocs.js +1 -1
- package/components/toggle-button/ToggleButtonGroupDocs.js.map +1 -1
- package/components/tooltip/TooltipDocs.js +1 -1
- package/components/tooltip/TooltipDocs.js.map +1 -1
- package/components/upload/Upload.js +6 -3
- package/components/upload/Upload.js.map +1 -1
- package/components/upload/UploadDocs.d.ts +1 -0
- package/components/upload/UploadDocs.js +42 -0
- package/components/upload/UploadDocs.js.map +1 -1
- package/components/upload/UploadFileListCell.js +32 -12
- package/components/upload/UploadFileListCell.js.map +1 -1
- package/components/upload/types.d.ts +7 -0
- package/components/upload/types.js.map +1 -1
- package/es/components/autocomplete/AutocompleteDocs.js +3 -3
- package/es/components/autocomplete/AutocompleteDocs.js.map +1 -1
- package/es/components/avatar/Avatar.js +1 -6
- package/es/components/avatar/Avatar.js.map +1 -1
- package/es/components/checkbox/CheckboxDocs.js +2 -2
- package/es/components/checkbox/CheckboxDocs.js.map +1 -1
- package/es/components/date-picker/DatePickerContext.d.ts +0 -1
- package/es/components/date-picker/DatePickerContext.js.map +1 -1
- package/es/components/date-picker/DatePickerDocs.js +1 -1
- package/es/components/date-picker/DatePickerDocs.js.map +1 -1
- package/es/components/date-picker/DatePickerInput.js +103 -130
- package/es/components/date-picker/DatePickerInput.js.map +1 -1
- package/es/components/date-picker/DatePickerProvider.js +0 -2
- package/es/components/date-picker/DatePickerProvider.js.map +1 -1
- package/es/components/date-picker/hooks/useDates.d.ts +0 -2
- package/es/components/date-picker/hooks/useDates.js +3 -5
- package/es/components/date-picker/hooks/useDates.js.map +1 -1
- package/es/components/date-picker/style/dnb-date-picker.css +4 -0
- package/es/components/date-picker/style/dnb-date-picker.min.css +1 -1
- package/es/components/date-picker/style/dnb-date-picker.scss +3 -0
- package/es/components/dialog/DialogDocs.js +7 -2
- package/es/components/dialog/DialogDocs.js.map +1 -1
- package/es/components/dropdown/Dropdown.d.ts +20 -20
- package/es/components/dropdown/DropdownDocs.d.ts +1 -0
- package/es/components/dropdown/DropdownDocs.js +157 -0
- package/es/components/dropdown/DropdownDocs.js.map +1 -1
- package/es/components/flex/ContainerDocs.js +1 -1
- package/es/components/flex/ContainerDocs.js.map +1 -1
- package/es/components/flex/ItemDocs.d.ts +2 -0
- package/es/components/flex/ItemDocs.js +33 -0
- package/es/components/flex/ItemDocs.js.map +1 -0
- package/es/components/grid/ItemDocs.d.ts +2 -0
- package/es/components/grid/ItemDocs.js +13 -0
- package/es/components/grid/ItemDocs.js.map +1 -0
- package/es/components/input/InputDocs.js +3 -3
- package/es/components/input/InputDocs.js.map +1 -1
- package/es/components/input-masked/InputMasked.d.ts +0 -3
- package/es/components/input-masked/InputMaskedDocs.d.ts +1 -0
- package/es/components/input-masked/InputMaskedDocs.js +57 -0
- package/es/components/input-masked/InputMaskedDocs.js.map +1 -1
- package/es/components/input-masked/InputMaskedHooks.js +11 -7
- package/es/components/input-masked/InputMaskedHooks.js.map +1 -1
- package/es/components/input-masked/InputMaskedUtils.d.ts +1 -1
- package/es/components/input-masked/InputMaskedUtils.js +2 -1
- package/es/components/input-masked/InputMaskedUtils.js.map +1 -1
- package/es/components/input-masked/MultiInputMaskedDocs.d.ts +2 -0
- package/es/components/input-masked/MultiInputMaskedDocs.js +69 -0
- package/es/components/input-masked/MultiInputMaskedDocs.js.map +1 -1
- package/es/components/input-masked/style/dnb-input-masked.css +9 -0
- package/es/components/input-masked/style/dnb-input-masked.min.css +1 -1
- package/es/components/input-masked/style/dnb-input-masked.scss +12 -0
- package/es/components/input-masked/text-mask/InputModeNumber.d.ts +8 -0
- package/es/components/input-masked/text-mask/InputModeNumber.js +39 -9
- package/es/components/input-masked/text-mask/InputModeNumber.js.map +1 -1
- package/es/components/input-masked/text-mask/adjustCaretPosition.d.ts +2 -1
- package/es/components/input-masked/text-mask/adjustCaretPosition.js +3 -2
- package/es/components/input-masked/text-mask/adjustCaretPosition.js.map +1 -1
- package/es/components/input-masked/text-mask/createTextMaskInputElement.js +9 -3
- package/es/components/input-masked/text-mask/createTextMaskInputElement.js.map +1 -1
- package/es/components/modal/ModalDocs.d.ts +5 -0
- package/es/components/modal/ModalDocs.js +191 -0
- package/es/components/modal/ModalDocs.js.map +1 -0
- package/es/components/radio/RadioDocs.js +2 -2
- package/es/components/radio/RadioDocs.js.map +1 -1
- package/es/components/section/Section.js +1 -6
- package/es/components/section/Section.js.map +1 -1
- package/es/components/section/SectionDocs.js +1 -1
- package/es/components/section/SectionDocs.js.map +1 -1
- package/es/components/slider/SliderDocs.js +2 -2
- package/es/components/slider/SliderDocs.js.map +1 -1
- package/es/components/space/SpaceDocs.d.ts +3 -0
- package/es/components/space/SpaceDocs.js +55 -0
- package/es/components/space/SpaceDocs.js.map +1 -0
- package/es/components/switch/SwitchDocs.js +2 -2
- package/es/components/switch/SwitchDocs.js.map +1 -1
- package/es/components/textarea/TextareaDocs.js +3 -3
- package/es/components/textarea/TextareaDocs.js.map +1 -1
- package/es/components/toggle-button/ToggleButtonGroupDocs.js +1 -1
- package/es/components/toggle-button/ToggleButtonGroupDocs.js.map +1 -1
- package/es/components/tooltip/TooltipDocs.js +1 -1
- package/es/components/tooltip/TooltipDocs.js.map +1 -1
- package/es/components/upload/Upload.js +6 -3
- package/es/components/upload/Upload.js.map +1 -1
- package/es/components/upload/UploadDocs.d.ts +1 -0
- package/es/components/upload/UploadDocs.js +42 -0
- package/es/components/upload/UploadDocs.js.map +1 -1
- package/es/components/upload/UploadFileListCell.js +32 -12
- package/es/components/upload/UploadFileListCell.js.map +1 -1
- package/es/components/upload/types.d.ts +7 -0
- package/es/components/upload/types.js.map +1 -1
- package/es/extensions/forms/DataContext/At/AtDocs.d.ts +2 -0
- package/es/extensions/forms/DataContext/At/AtDocs.js +18 -0
- package/es/extensions/forms/DataContext/At/AtDocs.js.map +1 -0
- package/es/extensions/forms/DataContext/Provider/ProviderDocs.js +1 -1
- package/es/extensions/forms/DataContext/Provider/ProviderDocs.js.map +1 -1
- package/es/extensions/forms/Field/Number/Number.js +3 -6
- package/es/extensions/forms/Field/Number/Number.js.map +1 -1
- package/es/extensions/forms/Field/Password/PasswordDocs.d.ts +1 -0
- package/es/extensions/forms/Field/Password/PasswordDocs.js +13 -1
- package/es/extensions/forms/Field/Password/PasswordDocs.js.map +1 -1
- package/es/extensions/forms/Field/PhoneNumber/PhoneNumber.d.ts +6 -4
- package/es/extensions/forms/Field/PhoneNumber/PhoneNumber.js +24 -16
- package/es/extensions/forms/Field/PhoneNumber/PhoneNumber.js.map +1 -1
- package/es/extensions/forms/Field/PhoneNumber/PhoneNumberDocs.d.ts +2 -2
- package/es/extensions/forms/Field/PhoneNumber/PhoneNumberDocs.js +7 -2
- package/es/extensions/forms/Field/PhoneNumber/PhoneNumberDocs.js.map +1 -1
- package/es/extensions/forms/Field/Provider/useFieldProvider.d.ts +3 -3
- package/es/extensions/forms/Field/String/StringDocs.js +1 -1
- package/es/extensions/forms/Field/String/StringDocs.js.map +1 -1
- package/es/extensions/forms/Field/Upload/Upload.d.ts +1 -1
- package/es/extensions/forms/Field/Upload/Upload.js +3 -1
- package/es/extensions/forms/Field/Upload/Upload.js.map +1 -1
- package/es/extensions/forms/FieldBlock/FieldBlock.js +11 -4
- package/es/extensions/forms/FieldBlock/FieldBlock.js.map +1 -1
- package/es/extensions/forms/FieldBlock/FieldBlockContext.d.ts +1 -1
- package/es/extensions/forms/FieldBlock/FieldBlockContext.js.map +1 -1
- package/es/extensions/forms/Form/ButtonRow/ButtonRowDocs.d.ts +2 -0
- package/es/extensions/forms/Form/ButtonRow/ButtonRowDocs.js +13 -0
- package/es/extensions/forms/Form/ButtonRow/ButtonRowDocs.js.map +1 -0
- package/es/extensions/forms/Form/Isolation/IsolationDocs.js +1 -1
- package/es/extensions/forms/Form/Isolation/IsolationDocs.js.map +1 -1
- package/es/extensions/forms/Wizard/Buttons/ButtonsDocs.d.ts +2 -0
- package/es/extensions/forms/Wizard/Buttons/ButtonsDocs.js +8 -0
- package/es/extensions/forms/Wizard/Buttons/ButtonsDocs.js.map +1 -0
- package/es/extensions/forms/hooks/DataValueWritePropsDocs.js +1 -1
- package/es/extensions/forms/hooks/DataValueWritePropsDocs.js.map +1 -1
- package/es/extensions/forms/hooks/useFieldProps.js +56 -19
- package/es/extensions/forms/hooks/useFieldProps.js.map +1 -1
- package/es/extensions/forms/types.d.ts +8 -5
- package/es/extensions/forms/types.js.map +1 -1
- package/es/extensions/forms/utils/FormError.d.ts +20 -16
- package/es/extensions/forms/utils/FormError.js +1 -0
- package/es/extensions/forms/utils/FormError.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/helpers.d.ts +1 -0
- package/es/shared/helpers.js +6 -0
- package/es/shared/helpers.js.map +1 -1
- package/es/shared/locales/sv-SE.js +2 -2
- package/es/shared/locales/sv-SE.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 +13 -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/theme-eiendom/eiendom-theme-components.css +13 -0
- package/es/style/themes/theme-eiendom/eiendom-theme-components.min.css +1 -1
- package/es/style/themes/theme-sbanken/sbanken-theme-components.css +13 -0
- package/es/style/themes/theme-sbanken/sbanken-theme-components.min.css +1 -1
- package/es/style/themes/theme-ui/ui-theme-components.css +13 -0
- package/es/style/themes/theme-ui/ui-theme-components.min.css +1 -1
- 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 +1 -1
- package/esm/dnb-ui-lib.min.mjs +1 -1
- package/extensions/forms/DataContext/At/AtDocs.d.ts +2 -0
- package/extensions/forms/DataContext/At/AtDocs.js +18 -0
- package/extensions/forms/DataContext/At/AtDocs.js.map +1 -0
- package/extensions/forms/DataContext/Provider/ProviderDocs.js +1 -1
- package/extensions/forms/DataContext/Provider/ProviderDocs.js.map +1 -1
- package/extensions/forms/Field/Number/Number.js +3 -6
- package/extensions/forms/Field/Number/Number.js.map +1 -1
- package/extensions/forms/Field/Password/PasswordDocs.d.ts +1 -0
- package/extensions/forms/Field/Password/PasswordDocs.js +13 -1
- package/extensions/forms/Field/Password/PasswordDocs.js.map +1 -1
- package/extensions/forms/Field/PhoneNumber/PhoneNumber.d.ts +6 -4
- package/extensions/forms/Field/PhoneNumber/PhoneNumber.js +33 -25
- package/extensions/forms/Field/PhoneNumber/PhoneNumber.js.map +1 -1
- package/extensions/forms/Field/PhoneNumber/PhoneNumberDocs.d.ts +2 -2
- package/extensions/forms/Field/PhoneNumber/PhoneNumberDocs.js +7 -2
- package/extensions/forms/Field/PhoneNumber/PhoneNumberDocs.js.map +1 -1
- package/extensions/forms/Field/Provider/useFieldProvider.d.ts +3 -3
- package/extensions/forms/Field/String/StringDocs.js +1 -1
- package/extensions/forms/Field/String/StringDocs.js.map +1 -1
- package/extensions/forms/Field/Upload/Upload.d.ts +1 -1
- package/extensions/forms/Field/Upload/Upload.js +3 -1
- package/extensions/forms/Field/Upload/Upload.js.map +1 -1
- package/extensions/forms/FieldBlock/FieldBlock.js +11 -4
- package/extensions/forms/FieldBlock/FieldBlock.js.map +1 -1
- package/extensions/forms/FieldBlock/FieldBlockContext.d.ts +1 -1
- package/extensions/forms/FieldBlock/FieldBlockContext.js.map +1 -1
- package/extensions/forms/Form/ButtonRow/ButtonRowDocs.d.ts +2 -0
- package/extensions/forms/Form/ButtonRow/ButtonRowDocs.js +13 -0
- package/extensions/forms/Form/ButtonRow/ButtonRowDocs.js.map +1 -0
- package/extensions/forms/Form/Isolation/IsolationDocs.js +1 -1
- package/extensions/forms/Form/Isolation/IsolationDocs.js.map +1 -1
- package/extensions/forms/Wizard/Buttons/ButtonsDocs.d.ts +2 -0
- package/extensions/forms/Wizard/Buttons/ButtonsDocs.js +8 -0
- package/extensions/forms/Wizard/Buttons/ButtonsDocs.js.map +1 -0
- package/extensions/forms/hooks/DataValueWritePropsDocs.js +1 -1
- package/extensions/forms/hooks/DataValueWritePropsDocs.js.map +1 -1
- package/extensions/forms/hooks/useFieldProps.js +56 -19
- package/extensions/forms/hooks/useFieldProps.js.map +1 -1
- package/extensions/forms/types.d.ts +8 -5
- package/extensions/forms/types.js.map +1 -1
- package/extensions/forms/utils/FormError.d.ts +20 -16
- package/extensions/forms/utils/FormError.js.map +1 -1
- package/package.json +1 -1
- package/shared/Eufemia.d.ts +1 -1
- package/shared/Eufemia.js +2 -2
- package/shared/Eufemia.js.map +1 -1
- package/shared/helpers.d.ts +1 -0
- package/shared/helpers.js +6 -0
- package/shared/helpers.js.map +1 -1
- package/shared/locales/sv-SE.js +2 -2
- package/shared/locales/sv-SE.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 +13 -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/theme-eiendom/eiendom-theme-components.css +13 -0
- package/style/themes/theme-eiendom/eiendom-theme-components.min.css +1 -1
- package/style/themes/theme-sbanken/sbanken-theme-components.css +13 -0
- package/style/themes/theme-sbanken/sbanken-theme-components.min.css +1 -1
- package/style/themes/theme-ui/ui-theme-components.css +13 -0
- package/style/themes/theme-ui/ui-theme-components.min.css +1 -1
- 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 +1 -1
- package/umd/dnb-ui-lib.min.js +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FieldBlock.js","names":["React","useMemo","useContext","useCallback","useRef","useReducer","useEffect","classnames","FieldBlockContext","DataContext","Space","FormLabel","FormStatus","Ul","Li","convertJsxToString","findElementInChildren","useId","HelpButtonInline","HelpButtonInlineContent","SubmitIndicator","createSharedState","useTranslation","FormError","useIterateItemNo","states","FieldBlock","props","_props$id","dataContext","fieldBlockContext","nestedFieldBlockContext","disableStatusSummary","id","forId","sharedData","_Object$assign","Object","assign","data","className","layout","layoutOptions","composition","label","labelProp","labelDescription","labelDescriptionInline","labelSuffix","labelSrOnly","help","asFieldset","required","info","warning","error","fieldState","disabled","width","contentWidth","labelHeight","align","labelSize","contentClassName","children","rest","_objectWithoutProperties","_excluded","hasCustomWidth","test","String","hasCustomContentWidth","infoRef","warningRef","errorRef","blockId","salt","forceUpdate","mountedFieldsRef","Map","fieldStateRef","stateRecordRef","fieldStateIdsRef","contentsRef","hasInitiallyErrorPropRef","Boolean","setInternalRecord","stateId","identifier","type","current","existingIndex","findIndex","item","_objectSpread","push","setBlockRecordNested","setBlockRecord","setFieldState","showFieldError","show","map","showInitially","statusContent","content","statesWithMessages","entries","flatMap","reduce","acc","cur","existing","find","messages","getMessagesFromError","message","undefined","state","width_element","no_animation","process","env","NODE_ENV","globalThis","IS_TEST","found","msg","filter","i","arr","length","createElement","CombineMessages","mainClasses","gridClasses","enableFieldset","useEnableFieldset","labelProps","element","srOnly","space","size","mainStyle","_lO$minWidth","_lO$maxWidth","style","lO","min","getFieldWidth","minWidth","max","maxWidth","prerenderFieldProps","hasLabelDescription","isFragment","fragmentHasChildren","fragmentHasOnlyUndefinedChildren","hasHelp","title","Provider","value","hasErrorProp","_extends","contentId","_br","breakout","outset","parseFloat","ref","result","count","child","_child$props","_child$type","translations","Field","Fragment","errorSummary","stateSummary","key","Array","isArray","errors","Error","isValidElement","toString","fragment","Children","isUndefined","toArray","every","_supportsSpacingProps"],"sources":["../../../../../src/extensions/forms/FieldBlock/FieldBlock.tsx"],"sourcesContent":["import React, {\n useMemo,\n useContext,\n useCallback,\n useRef,\n useReducer,\n useEffect,\n} from 'react'\nimport classnames from 'classnames'\nimport FieldBlockContext, {\n StateWithMessage,\n StatesWithMessages,\n FieldErrorIdsRef,\n MountedFieldsRef,\n StateRecord,\n StateMessage,\n StateTypes,\n StatusContent,\n FieldBlockContextProps,\n StateBasis,\n} from './FieldBlockContext'\nimport DataContext from '../DataContext/Context'\nimport { Space, FormLabel, FormStatus } from '../../../components'\nimport { Ul, Li } from '../../../elements'\nimport {\n convertJsxToString,\n findElementInChildren,\n} from '../../../shared/component-helper'\nimport useId from '../../../shared/helpers/useId'\nimport {\n ComponentProps,\n FieldProps,\n SubmitState,\n Identifier,\n UseFieldProps,\n} from '../types'\nimport type { FormLabelAllProps } from '../../../components/FormLabel'\nimport HelpButtonInline, {\n HelpButtonInlineContent,\n HelpProps,\n} from '../../../components/help-button/HelpButtonInline'\nimport SubmitIndicator from '../Form/SubmitIndicator/SubmitIndicator'\nimport { createSharedState } from '../../../shared/helpers/useSharedState'\nimport useTranslation from '../hooks/useTranslation'\nimport { FormError } from '../utils'\nimport { useIterateItemNo } from '../Iterate/ItemNo/useIItemNo'\n\nexport const states: Array<StateTypes> = ['error', 'info', 'warning']\n\n/**\n * The width of a field block\n */\nexport type CustomWidth = `${number}rem`\nexport type FieldBlockWidth =\n | false\n | 'small'\n | 'medium'\n | 'large'\n | 'stretch'\n | CustomWidth\nexport type FieldBlockHorizontalLabelWidth =\n | 'small'\n | 'medium'\n | 'large'\n | CustomWidth\nexport type FieldBlockHorizontalLabelHeight =\n | 'default'\n | 'small'\n | 'medium'\n | 'large'\n\nexport type SharedFieldBlockProps = {\n /**\n * The layout of the field block\n */\n layout?: 'vertical' | 'horizontal'\n /** Use this to set additional options for the layout */\n layoutOptions?: {\n width?: FieldBlockHorizontalLabelWidth\n minWidth?: FieldBlockHorizontalLabelWidth\n maxWidth?: FieldBlockHorizontalLabelWidth\n }\n /**\n * Main label text for the field\n */\n label?: React.ReactNode\n /**\n * Will append an additional text to the label, like \"(optional)\" or \"(recommended)\"\n */\n labelSuffix?: React.ReactNode\n /**\n * A more discreet text displayed beside the label\n */\n labelDescription?: React.ReactNode\n /**\n * If true, the labelDescription will be displayed on the same line as the label.\n */\n labelDescriptionInline?: boolean\n /**\n * Width of outer block element\n */\n width?: FieldBlockWidth\n /**\n * Width of contents block, while label etc can be wider if space is available\n */\n contentWidth?: FieldBlockWidth\n /**\n * Provide help content for the field.\n */\n help?: HelpProps\n}\n\nexport type Props<Value = unknown> = SharedFieldBlockProps &\n Pick<\n FieldProps<Value>,\n keyof ComponentProps | 'info' | 'warning' | 'error' | 'disabled'\n > & {\n /** The id to link a element with */\n forId?: string\n /** Use true if you have more than one form element */\n asFieldset?: boolean\n /** use `true` to make the label only readable by screen readers. */\n labelSrOnly?: boolean\n /** Defines the layout of nested fields */\n composition?: FieldBlockContextProps['composition']\n /** For composition only: Align the contents vertically */\n align?: 'center' | 'bottom'\n /** Class name for the contents block */\n contentClassName?: string\n /** To show the SubmitIndicator during async validation */\n fieldState?: SubmitState\n /** Typography size */\n labelSize?: 'medium' | 'large'\n /** Defines the height of an component (size prop), so the label can be aligned correctly */\n labelHeight?: FieldBlockHorizontalLabelHeight\n /** Disable the error summary for this field block */\n disableStatusSummary?: boolean\n /** For internal use only */\n required?: boolean\n children?: React.ReactNode\n } & React.HTMLAttributes<HTMLDivElement>\n\nfunction FieldBlock<Value = unknown>(props: Props<Value>) {\n const dataContext = useContext(DataContext)\n const fieldBlockContext = useContext(FieldBlockContext)\n const nestedFieldBlockContext = !fieldBlockContext?.disableStatusSummary\n ? fieldBlockContext\n : null\n\n const id = useId(props.id ?? props.forId)\n const sharedData = createSharedState<Props>('field-block-props-' + id)\n const {\n className,\n forId,\n layout = 'vertical',\n layoutOptions,\n composition,\n label: labelProp,\n labelDescription,\n labelDescriptionInline,\n labelSuffix,\n labelSrOnly,\n help,\n asFieldset,\n required,\n info,\n warning,\n error,\n disableStatusSummary,\n fieldState,\n disabled,\n width,\n contentWidth,\n labelHeight,\n align,\n labelSize,\n contentClassName,\n children,\n ...rest\n } = Object.assign({}, sharedData.data, props)\n const hasCustomWidth = /\\d(rem)$/.test(String(width))\n const hasCustomContentWidth = /\\d(rem)$/.test(String(contentWidth))\n\n const infoRef = useRef<UseFieldProps['info']>()\n const warningRef = useRef<UseFieldProps['warning']>()\n const errorRef = useRef<UseFieldProps['error']>()\n\n const blockId = useId(props.id)\n const [salt, forceUpdate] = useReducer(() => ({}), {})\n const mountedFieldsRef = useRef<MountedFieldsRef>(new Map())\n const fieldStateRef = useRef<SubmitState>(null)\n const stateRecordRef = useRef<StateRecord>({})\n const fieldStateIdsRef = useRef<FieldErrorIdsRef>(null)\n const contentsRef = useRef<HTMLDivElement>(null)\n const hasInitiallyErrorPropRef = useRef(Boolean(error))\n\n const label = useIterateItemNo({\n label: labelProp,\n labelSuffix,\n required,\n })\n\n const setInternalRecord = useCallback((props: StateBasis) => {\n const { stateId, identifier, type } = props\n\n if (!stateRecordRef.current[identifier]) {\n stateRecordRef.current[identifier] = []\n }\n\n fieldStateIdsRef.current = { error: null, warning: null, info: null }\n\n const existingIndex = stateRecordRef.current[identifier].findIndex(\n (item) => {\n return item.stateId === stateId && item.type === type\n }\n )\n\n if (existingIndex > -1) {\n stateRecordRef.current[identifier][existingIndex] = {\n ...stateRecordRef.current[identifier][existingIndex],\n ...props,\n }\n } else {\n stateRecordRef.current[identifier].push(props)\n }\n }, [])\n\n const setBlockRecordNested = nestedFieldBlockContext?.setBlockRecord\n const setBlockRecord = useCallback(\n (props: StateBasis) => {\n if (setBlockRecordNested) {\n // If this FieldBlock is inside another one, forward the call to the outer one\n setBlockRecordNested(props)\n return\n }\n\n setInternalRecord(props)\n\n forceUpdate()\n },\n [setBlockRecordNested, setInternalRecord]\n )\n\n const setFieldState = useCallback(\n (identifier: Identifier, fieldState: SubmitState) => {\n if (fieldState !== fieldStateRef.current) {\n fieldStateRef.current = fieldState\n\n forceUpdate()\n }\n },\n []\n )\n\n const showFieldError = useCallback(\n (identifier: Identifier, show: boolean) => {\n if (nestedFieldBlockContext) {\n // If this FieldBlock is inside another one, forward the call to the outer one\n nestedFieldBlockContext.showFieldError(identifier, show)\n return\n }\n\n if (stateRecordRef.current[identifier]) {\n stateRecordRef.current[identifier] = stateRecordRef.current[\n identifier\n ].map((item) => {\n if (item.showInitially) {\n return item\n }\n\n return {\n ...item,\n show,\n }\n })\n\n forceUpdate()\n }\n },\n [nestedFieldBlockContext]\n )\n\n const statusContent = useMemo(() => {\n if (typeof error !== 'undefined' || (errorRef.current && !error)) {\n errorRef.current = error\n setInternalRecord({\n identifier: blockId,\n showInitially: hasInitiallyErrorPropRef.current,\n type: 'error',\n content: error,\n })\n }\n\n if (typeof warning !== 'undefined' || warningRef.current !== warning) {\n warningRef.current = warning\n setInternalRecord({\n identifier: blockId,\n showInitially: true,\n type: 'warning',\n content: warning,\n })\n }\n\n if (typeof info !== 'undefined' || infoRef.current !== info) {\n infoRef.current = info\n setInternalRecord({\n identifier: blockId,\n showInitially: true,\n type: 'info',\n content: info,\n })\n }\n\n const statesWithMessages: Array<StatesWithMessages> =\n // 1. Prepare the states for later use\n Object.entries(stateRecordRef.current)\n .flatMap(([identifier, states]) =>\n states.map((props) => {\n return {\n identifier,\n ...props,\n }\n })\n )\n\n // 2. Take states and group the same type together\n .reduce((acc, cur) => {\n const existing = acc.find((item) => {\n return item.type === cur.type\n })\n\n const messages = getMessagesFromError(cur).map((message) => {\n return {\n ...cur,\n message,\n }\n })\n\n if (existing) {\n existing.messages.push(...messages)\n } else {\n acc.push({\n ...cur,\n content: undefined,\n messages,\n })\n }\n\n return acc\n }, [] as Array<StatesWithMessages>)\n\n // 3. Return the grouped states/messages\n return states.reduce((acc, type) => {\n const id = `${props.id || forId || blockId}-form-status--${type}`\n acc[type] = {\n id,\n label,\n state: type === 'warning' ? 'warn' : type,\n width_element: contentsRef,\n\n // Enable animation only in the browser and not in tests\n no_animation:\n process.env.NODE_ENV === 'test'\n ? true\n : typeof globalThis !== 'undefined'\n ? globalThis.IS_TEST === true\n : false,\n }\n\n const found = statesWithMessages.find((item) => {\n return item.type === type\n })\n\n if (found?.messages) {\n // Hide/remove messages that should be hidden and are not marked as to be shown initially\n const messages = found.messages\n .map((msg) => {\n if (msg.type === 'error') {\n if (!msg.showInitially && !msg.show) {\n msg.message = null\n }\n }\n\n return msg\n })\n .filter(({ message }) => message)\n .reduce((acc, msg, i, arr) => {\n const existingIndex = arr.findIndex((item) => {\n return (\n convertJsxToString(item.message) ===\n convertJsxToString(msg.message)\n )\n })\n\n // Remove duplicates, use the first found message\n if (existingIndex === i) {\n acc.push(msg)\n }\n\n return acc\n }, [])\n\n // Combine the messages and put them in an ul/li list\n if (messages.length > 0) {\n acc[type] = {\n ...acc[type],\n children: <CombineMessages type={type} messages={messages} />,\n }\n\n fieldStateIdsRef.current[type] = id\n } else {\n fieldStateIdsRef.current[type] = undefined\n }\n }\n\n return acc\n }, salt) as StatusContent\n }, [\n error,\n warning,\n info,\n salt,\n setInternalRecord,\n blockId,\n props.id,\n forId,\n label,\n ])\n\n // Handle the error prop from outside\n useEffect(() => {\n if (!nestedFieldBlockContext) {\n showFieldError(blockId, Boolean(error))\n }\n }, [error, blockId, showFieldError, nestedFieldBlockContext])\n\n useEffect(\n () => () => {\n mountedFieldsRef.current = new Map()\n stateRecordRef.current = {}\n },\n []\n )\n\n const mainClasses = classnames(\n 'dnb-forms-field-block',\n width &&\n `dnb-forms-field-block--width-${hasCustomWidth ? 'custom' : width}`,\n contentWidth &&\n `dnb-forms-field-block--content-width-${\n hasCustomContentWidth ? 'custom' : contentWidth\n }`,\n labelHeight && `dnb-forms-field-block--label-height-${labelHeight}`,\n composition && 'dnb-forms-field-block__composition',\n composition &&\n `dnb-forms-field-block__composition--${\n composition === true ? 'horizontal' : composition\n }`,\n className\n )\n const gridClasses = classnames(\n 'dnb-forms-field-block__grid',\n `dnb-forms-field-block--layout-${layout}`\n )\n\n // A child component with a label was found, use fieldset/legend instead of div/label\n const enableFieldset = useEnableFieldset({\n label,\n asFieldset,\n children,\n nestedFieldBlockContext,\n })\n\n const labelProps: FormLabelAllProps = {\n id: `${id}-label`,\n className: 'dnb-forms-field-block__label',\n element: enableFieldset ? 'legend' : 'label',\n forId: enableFieldset ? undefined : forId,\n srOnly: labelSrOnly,\n space: 0, // Use CSS for spacing, but we need to reset space for doing so\n size: labelSize,\n disabled,\n }\n\n const mainStyle = useMemo(() => {\n const style: React.CSSProperties = {}\n\n if (hasCustomWidth) {\n style['--dnb-forms-field-block-width'] = width\n }\n\n if (hasCustomContentWidth) {\n style['--dnb-forms-field-block-content-width'] = contentWidth\n }\n\n const lO = layoutOptions || {}\n const min = getFieldWidth(lO.minWidth ?? lO.width)\n const max = getFieldWidth(lO.maxWidth ?? lO.width)\n\n if (typeof min === 'string') {\n style['--dnb-forms-field-block-layout-width-min'] = min\n }\n if (typeof max === 'string') {\n style['--dnb-forms-field-block-layout-width-max'] = max\n }\n\n return style\n }, [\n contentWidth,\n hasCustomContentWidth,\n hasCustomWidth,\n layoutOptions,\n width,\n ])\n\n if (dataContext?.prerenderFieldProps) {\n return null\n }\n\n const hasLabelDescription = isFragment(labelDescription)\n ? fragmentHasChildren(labelDescription) &&\n !fragmentHasOnlyUndefinedChildren(labelDescription)\n : labelDescription\n const hasHelp = help?.title || help?.content\n\n return (\n <FieldBlockContext.Provider\n value={{\n setBlockRecord,\n setFieldState,\n showFieldError,\n hasErrorProp: Boolean(error),\n fieldStateIdsRef,\n mountedFieldsRef,\n composition,\n disableStatusSummary,\n }}\n >\n <Space\n element={enableFieldset ? 'fieldset' : 'div'} // use fieldset and legend to enhance a11y\n style={mainStyle}\n className={mainClasses}\n {...rest}\n >\n <div className={gridClasses}>\n {(label || labelDescription || hasHelp) && (\n <FormLabel {...labelProps}>\n <span>\n {label && (\n <span className=\"dnb-forms-field-block__label__content\">\n {label}\n </span>\n )}\n\n {hasHelp && (\n <HelpButtonInline contentId={`${id}-help`} help={help} />\n )}\n\n {hasLabelDescription && !labelDescriptionInline && <br />}\n {hasLabelDescription && (\n <span className=\"dnb-forms-field-block__label__description\">\n {labelDescription}\n </span>\n )}\n </span>\n </FormLabel>\n )}\n\n {hasHelp && (\n <HelpButtonInlineContent\n contentId={`${id}-help`}\n className=\"dnb-forms-field-block__help\"\n help={help}\n breakout={\n layout === 'vertical' &&\n !nestedFieldBlockContext?.composition\n }\n outset={layout !== 'horizontal'}\n />\n )}\n\n <div\n className={classnames(\n 'dnb-forms-field-block__status',\n\n // Handle the width of the status messages\n contentWidth &&\n contentWidth !== 'small' &&\n contentWidth !== 'medium' &&\n !(parseFloat(contentWidth) <= 11) &&\n `dnb-forms-field-block__contents--width-${\n hasCustomContentWidth ? 'custom' : contentWidth\n }`\n )}\n >\n <FormStatus {...statusContent?.error} />\n <FormStatus {...statusContent?.warning} />\n <FormStatus {...statusContent?.info} />\n </div>\n\n <div\n className={classnames(\n 'dnb-forms-field-block__contents',\n contentWidth &&\n `dnb-forms-field-block__contents--width-${\n hasCustomContentWidth ? 'custom' : contentWidth\n }`,\n align && `dnb-forms-field-block__contents--align-${align}`,\n contentClassName\n )}\n ref={contentsRef}\n >\n {children}\n </div>\n\n <SubmitIndicator\n state={fieldState ?? fieldStateRef.current}\n className=\"dnb-forms-field-block__indicator dnb-forms-submit-indicator--inline-wrap\"\n />\n </div>\n </Space>\n </FieldBlockContext.Provider>\n )\n}\n\nfunction useEnableFieldset({\n label,\n asFieldset,\n children,\n nestedFieldBlockContext,\n}) {\n return useMemo(() => {\n if (asFieldset === false) {\n return false\n }\n\n let result = asFieldset\n\n if (label && !result && !nestedFieldBlockContext) {\n let count = 0\n\n findElementInChildren(children, (child: React.ReactElement) => {\n if (\n child?.props?.label ||\n child?.type?.['_formElement'] === true\n ) {\n count++\n }\n if (count > 1) {\n return (result = true)\n }\n })\n }\n\n return Boolean(result)\n }, [asFieldset, children, label, nestedFieldBlockContext])\n}\n\nfunction CombineMessages({\n type,\n messages,\n}: {\n type: StateTypes\n messages: Array<StateWithMessage>\n}) {\n const translations = useTranslation().Field\n\n if (messages.length === 1) {\n return <>{messages[0].message}</>\n }\n\n return (\n <>\n {type === 'error'\n ? translations.errorSummary\n : translations.stateSummary}\n <Ul>\n {messages.map(({ message }, i) => {\n return <Li key={i}>{message}</Li>\n })}\n </Ul>\n </>\n )\n}\n\nexport function getMessagesFromError(\n item: Partial<StateWithMessage>\n): Array<StateMessage> {\n const { content } = item\n\n if (content instanceof FormError && Array.isArray(content.errors)) {\n return content.errors.map((error) => {\n return error.message\n })\n }\n\n if (Array.isArray(content)) {\n return content.map((content) => {\n return content instanceof FormError || content instanceof Error\n ? content.message\n : content\n })\n }\n\n if (content instanceof FormError || content instanceof Error) {\n return [content.message as StateMessage]\n }\n\n return [\n ((React.isValidElement(content) ? content : content?.toString()) ||\n content) as StateMessage,\n ]\n}\n\nfunction isFragment(fragment: React.ReactNode) {\n return React.isValidElement(fragment) && fragment.type === React.Fragment\n}\n\nfunction fragmentHasChildren(fragment: React.ReactNode) {\n return (\n React.isValidElement(fragment) &&\n React.Children.count(fragment.props.children) > 0\n )\n}\n\nfunction fragmentHasOnlyUndefinedChildren(fragment: React.ReactNode) {\n const isUndefined = (child) => child === undefined\n\n return (\n React.isValidElement(fragment) &&\n React.Children.toArray(fragment.props.children).every(isUndefined)\n )\n}\n\nFieldBlock._supportsSpacingProps = true\n\nexport default FieldBlock\n\nfunction getFieldWidth(width: FieldBlockHorizontalLabelWidth) {\n switch (width) {\n case 'small':\n return 'var(--forms-field-width--small)'\n case 'medium':\n return 'var(--forms-field-width--medium)'\n case 'large':\n return 'var(--forms-field-width--large)'\n }\n\n return width\n}\n"],"mappings":";;;;;;;;;AAAA,OAAOA,KAAK,IACVC,OAAO,EACPC,UAAU,EACVC,WAAW,EACXC,MAAM,EACNC,UAAU,EACVC,SAAS,QACJ,OAAO;AACd,OAAOC,UAAU,MAAM,YAAY;AACnC,OAAOC,iBAAiB,MAWjB,qBAAqB;AAC5B,OAAOC,WAAW,MAAM,wBAAwB;AAChD,SAASC,KAAK,EAAEC,SAAS,EAAEC,UAAU,Q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qC,QAAQ,CAAC,GAAG,CAAC;AAErD;AAEA,SAAS4F,gCAAgCA,CAAC8B,QAAyB,EAAE;EACnE,MAAME,WAAW,GAAIjB,KAAK,IAAKA,KAAK,KAAKvD,SAAS;EAElD,OACEpH,KAAK,CAACwL,cAAc,CAACE,QAAQ,CAAC,IAC9B1L,KAAK,CAAC2L,QAAQ,CAACE,OAAO,CAACH,QAAQ,CAAC/J,KAAK,CAACqC,QAAQ,CAAC,CAAC8H,KAAK,CAACF,WAAW,CAAC;AAEtE;AAEAlK,UAAU,CAACqK,qBAAqB,GAAG,IAAI;AAEvC,eAAerK,UAAU;AAEzB,SAAS0H,aAAaA,CAAC1F,KAAqC,EAAE;EAC5D,QAAQA,KAAK;IACX,KAAK,OAAO;MACV,OAAO,iCAAiC;IAC1C,KAAK,QAAQ;MACX,OAAO,kCAAkC;IAC3C,KAAK,OAAO;MACV,OAAO,iCAAiC;EAC5C;EAEA,OAAOA,KAAK;AACd","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"FieldBlock.js","names":["React","useMemo","useContext","useCallback","useRef","useReducer","useEffect","classnames","FieldBlockContext","DataContext","Space","FormLabel","FormStatus","Ul","Li","convertJsxToString","findElementInChildren","useId","HelpButtonInline","HelpButtonInlineContent","SubmitIndicator","createSharedState","useTranslation","FormError","useIterateItemNo","states","FieldBlock","props","_props$id","dataContext","fieldBlockContext","nestedFieldBlockContext","disableStatusSummary","id","forId","sharedData","_Object$assign","Object","assign","data","className","layout","layoutOptions","composition","label","labelProp","labelDescription","labelDescriptionInline","labelSuffix","labelSrOnly","help","asFieldset","required","info","warning","error","fieldState","disabled","width","contentWidth","labelHeight","align","labelSize","contentClassName","children","rest","_objectWithoutProperties","_excluded","hasCustomWidth","test","String","hasCustomContentWidth","infoRef","warningRef","errorRef","blockId","salt","forceUpdate","mountedFieldsRef","Map","fieldStateRef","stateRecordRef","fieldStateIdsRef","contentsRef","hasInitiallyErrorPropRef","Boolean","setInternalRecord","stateId","identifier","type","current","existingIndex","findIndex","item","_objectSpread","push","setBlockRecordNested","setBlockRecord","setFieldState","showFieldError","show","map","showInitially","statusContent","content","statesWithMessages","entries","flatMap","reduce","acc","cur","existing","find","messages","getMessagesFromError","message","undefined","state","width_element","no_animation","process","env","NODE_ENV","globalThis","IS_TEST","found","msg","filter","i","arr","length","createElement","CombineMessages","mainClasses","gridClasses","enableFieldset","useEnableFieldset","labelProps","element","srOnly","space","size","mainStyle","_lO$minWidth","_lO$maxWidth","style","lO","min","getFieldWidth","minWidth","max","maxWidth","prerenderFieldProps","hasLabelDescription","isFragment","fragmentHasChildren","fragmentHasOnlyUndefinedChildren","hasHelp","title","Provider","value","hasErrorProp","_extends","contentId","_br","breakout","outset","parseFloat","ref","result","count","child","_child$props","_child$type","translations","Field","Fragment","errorSummary","stateSummary","key","getMessage","_error$formattedMessa","formattedMessage","Array","isArray","errors","Error","isValidElement","toString","fragment","Children","isUndefined","toArray","every","_supportsSpacingProps"],"sources":["../../../../../src/extensions/forms/FieldBlock/FieldBlock.tsx"],"sourcesContent":["import React, {\n useMemo,\n useContext,\n useCallback,\n useRef,\n useReducer,\n useEffect,\n} from 'react'\nimport classnames from 'classnames'\nimport FieldBlockContext, {\n StateWithMessage,\n StatesWithMessages,\n FieldErrorIdsRef,\n MountedFieldsRef,\n StateRecord,\n StateMessage,\n StateTypes,\n StatusContent,\n FieldBlockContextProps,\n StateBasis,\n} from './FieldBlockContext'\nimport DataContext from '../DataContext/Context'\nimport { Space, FormLabel, FormStatus } from '../../../components'\nimport { Ul, Li } from '../../../elements'\nimport {\n convertJsxToString,\n findElementInChildren,\n} from '../../../shared/component-helper'\nimport useId from '../../../shared/helpers/useId'\nimport {\n ComponentProps,\n FieldProps,\n SubmitState,\n Identifier,\n UseFieldProps,\n} from '../types'\nimport type { FormLabelAllProps } from '../../../components/FormLabel'\nimport HelpButtonInline, {\n HelpButtonInlineContent,\n HelpProps,\n} from '../../../components/help-button/HelpButtonInline'\nimport SubmitIndicator from '../Form/SubmitIndicator/SubmitIndicator'\nimport { createSharedState } from '../../../shared/helpers/useSharedState'\nimport useTranslation from '../hooks/useTranslation'\nimport { FormError } from '../utils'\nimport { useIterateItemNo } from '../Iterate/ItemNo/useIItemNo'\n\nexport const states: Array<StateTypes> = ['error', 'info', 'warning']\n\n/**\n * The width of a field block\n */\nexport type CustomWidth = `${number}rem`\nexport type FieldBlockWidth =\n | false\n | 'small'\n | 'medium'\n | 'large'\n | 'stretch'\n | CustomWidth\nexport type FieldBlockHorizontalLabelWidth =\n | 'small'\n | 'medium'\n | 'large'\n | CustomWidth\nexport type FieldBlockHorizontalLabelHeight =\n | 'default'\n | 'small'\n | 'medium'\n | 'large'\n\nexport type SharedFieldBlockProps = {\n /**\n * The layout of the field block\n */\n layout?: 'vertical' | 'horizontal'\n /** Use this to set additional options for the layout */\n layoutOptions?: {\n width?: FieldBlockHorizontalLabelWidth\n minWidth?: FieldBlockHorizontalLabelWidth\n maxWidth?: FieldBlockHorizontalLabelWidth\n }\n /**\n * Main label text for the field\n */\n label?: React.ReactNode\n /**\n * Will append an additional text to the label, like \"(optional)\" or \"(recommended)\"\n */\n labelSuffix?: React.ReactNode\n /**\n * A more discreet text displayed beside the label\n */\n labelDescription?: React.ReactNode\n /**\n * If true, the labelDescription will be displayed on the same line as the label.\n */\n labelDescriptionInline?: boolean\n /**\n * Width of outer block element\n */\n width?: FieldBlockWidth\n /**\n * Width of contents block, while label etc can be wider if space is available\n */\n contentWidth?: FieldBlockWidth\n /**\n * Provide help content for the field.\n */\n help?: HelpProps\n}\n\nexport type Props<Value = unknown> = SharedFieldBlockProps &\n Pick<\n FieldProps<Value>,\n keyof ComponentProps | 'info' | 'warning' | 'error' | 'disabled'\n > & {\n /** The id to link a element with */\n forId?: string\n /** Use true if you have more than one form element */\n asFieldset?: boolean\n /** use `true` to make the label only readable by screen readers. */\n labelSrOnly?: boolean\n /** Defines the layout of nested fields */\n composition?: FieldBlockContextProps['composition']\n /** For composition only: Align the contents vertically */\n align?: 'center' | 'bottom'\n /** Class name for the contents block */\n contentClassName?: string\n /** To show the SubmitIndicator during async validation */\n fieldState?: SubmitState\n /** Typography size */\n labelSize?: 'medium' | 'large'\n /** Defines the height of an component (size prop), so the label can be aligned correctly */\n labelHeight?: FieldBlockHorizontalLabelHeight\n /** Disable the error summary for this field block */\n disableStatusSummary?: boolean\n /** For internal use only */\n required?: boolean\n children?: React.ReactNode\n } & React.HTMLAttributes<HTMLDivElement>\n\nfunction FieldBlock<Value = unknown>(props: Props<Value>) {\n const dataContext = useContext(DataContext)\n const fieldBlockContext = useContext(FieldBlockContext)\n const nestedFieldBlockContext = !fieldBlockContext?.disableStatusSummary\n ? fieldBlockContext\n : null\n\n const id = useId(props.id ?? props.forId)\n const sharedData = createSharedState<Props>('field-block-props-' + id)\n const {\n className,\n forId,\n layout = 'vertical',\n layoutOptions,\n composition,\n label: labelProp,\n labelDescription,\n labelDescriptionInline,\n labelSuffix,\n labelSrOnly,\n help,\n asFieldset,\n required,\n info,\n warning,\n error,\n disableStatusSummary,\n fieldState,\n disabled,\n width,\n contentWidth,\n labelHeight,\n align,\n labelSize,\n contentClassName,\n children,\n ...rest\n } = Object.assign({}, sharedData.data, props)\n const hasCustomWidth = /\\d(rem)$/.test(String(width))\n const hasCustomContentWidth = /\\d(rem)$/.test(String(contentWidth))\n\n const infoRef = useRef<UseFieldProps['info']>()\n const warningRef = useRef<UseFieldProps['warning']>()\n const errorRef = useRef<UseFieldProps['error']>()\n\n const blockId = useId(props.id)\n const [salt, forceUpdate] = useReducer(() => ({}), {})\n const mountedFieldsRef = useRef<MountedFieldsRef>(new Map())\n const fieldStateRef = useRef<SubmitState>(null)\n const stateRecordRef = useRef<StateRecord>({})\n const fieldStateIdsRef = useRef<FieldErrorIdsRef>(null)\n const contentsRef = useRef<HTMLDivElement>(null)\n const hasInitiallyErrorPropRef = useRef(Boolean(error))\n\n const label = useIterateItemNo({\n label: labelProp,\n labelSuffix,\n required,\n })\n\n const setInternalRecord = useCallback((props: StateBasis) => {\n const { stateId, identifier, type } = props\n\n if (!stateRecordRef.current[identifier]) {\n stateRecordRef.current[identifier] = []\n }\n\n fieldStateIdsRef.current = { error: null, warning: null, info: null }\n\n const existingIndex = stateRecordRef.current[identifier].findIndex(\n (item) => {\n return item.stateId === stateId && item.type === type\n }\n )\n\n if (existingIndex > -1) {\n stateRecordRef.current[identifier][existingIndex] = {\n ...stateRecordRef.current[identifier][existingIndex],\n ...props,\n }\n } else {\n stateRecordRef.current[identifier].push(props)\n }\n }, [])\n\n const setBlockRecordNested = nestedFieldBlockContext?.setBlockRecord\n const setBlockRecord = useCallback(\n (props: StateBasis) => {\n if (setBlockRecordNested) {\n // If this FieldBlock is inside another one, forward the call to the outer one\n setBlockRecordNested(props)\n return\n }\n\n setInternalRecord(props)\n\n forceUpdate()\n },\n [setBlockRecordNested, setInternalRecord]\n )\n\n const setFieldState = useCallback(\n (identifier: Identifier, fieldState: SubmitState) => {\n if (fieldState !== fieldStateRef.current) {\n fieldStateRef.current = fieldState\n\n forceUpdate()\n }\n },\n []\n )\n\n const showFieldError = useCallback(\n (identifier: Identifier, show: boolean) => {\n if (nestedFieldBlockContext) {\n // If this FieldBlock is inside another one, forward the call to the outer one\n nestedFieldBlockContext.showFieldError(identifier, show)\n return\n }\n\n if (stateRecordRef.current[identifier]) {\n stateRecordRef.current[identifier] = stateRecordRef.current[\n identifier\n ].map((item) => {\n if (item.showInitially) {\n return item\n }\n\n return {\n ...item,\n show,\n }\n })\n\n forceUpdate()\n }\n },\n [nestedFieldBlockContext]\n )\n\n const statusContent = useMemo(() => {\n if (typeof error !== 'undefined' || (errorRef.current && !error)) {\n errorRef.current = error\n setInternalRecord({\n identifier: blockId,\n showInitially: hasInitiallyErrorPropRef.current,\n type: 'error',\n content: error,\n })\n }\n\n if (typeof warning !== 'undefined' || warningRef.current !== warning) {\n warningRef.current = warning\n setInternalRecord({\n identifier: blockId,\n showInitially: true,\n type: 'warning',\n content: warning,\n })\n }\n\n if (typeof info !== 'undefined' || infoRef.current !== info) {\n infoRef.current = info\n setInternalRecord({\n identifier: blockId,\n showInitially: true,\n type: 'info',\n content: info,\n })\n }\n\n const statesWithMessages: Array<StatesWithMessages> =\n // 1. Prepare the states for later use\n Object.entries(stateRecordRef.current)\n .flatMap(([identifier, states]) =>\n states.map((props) => {\n return {\n identifier,\n ...props,\n }\n })\n )\n\n // 2. Take states and group the same type together\n .reduce((acc, cur) => {\n const existing = acc.find((item) => {\n return item.type === cur.type\n })\n\n const messages = getMessagesFromError(cur).map((message) => {\n return {\n ...cur,\n message,\n }\n })\n\n if (existing) {\n existing.messages.push(...messages)\n } else {\n acc.push({\n ...cur,\n content: undefined,\n messages,\n })\n }\n\n return acc\n }, [] as Array<StatesWithMessages>)\n\n // 3. Return the grouped states/messages\n return states.reduce((acc, type) => {\n const id = `${props.id || forId || blockId}-form-status--${type}`\n acc[type] = {\n id,\n label,\n state: type === 'warning' ? 'warn' : type,\n width_element: contentsRef,\n\n // Enable animation only in the browser and not in tests\n no_animation:\n process.env.NODE_ENV === 'test'\n ? true\n : typeof globalThis !== 'undefined'\n ? globalThis.IS_TEST === true\n : false,\n }\n\n const found = statesWithMessages.find((item) => {\n return item.type === type\n })\n\n if (found?.messages) {\n // Hide/remove messages that should be hidden and are not marked as to be shown initially\n const messages = found.messages\n .map((msg) => {\n if (msg.type === 'error') {\n if (!msg.showInitially && !msg.show) {\n msg.message = null\n }\n }\n\n return msg\n })\n .filter(({ message }) => message)\n .reduce((acc, msg, i, arr) => {\n const existingIndex = arr.findIndex((item) => {\n return (\n convertJsxToString(item.message) ===\n convertJsxToString(msg.message)\n )\n })\n\n // Remove duplicates, use the first found message\n if (existingIndex === i) {\n acc.push(msg)\n }\n\n return acc\n }, [])\n\n // Combine the messages and put them in an ul/li list\n if (messages.length > 0) {\n acc[type] = {\n ...acc[type],\n children: <CombineMessages type={type} messages={messages} />,\n }\n\n fieldStateIdsRef.current[type] = id\n } else {\n fieldStateIdsRef.current[type] = undefined\n }\n }\n\n return acc\n }, salt) as StatusContent\n }, [\n error,\n warning,\n info,\n salt,\n setInternalRecord,\n blockId,\n props.id,\n forId,\n label,\n ])\n\n // Handle the error prop from outside\n useEffect(() => {\n if (!nestedFieldBlockContext) {\n showFieldError(blockId, Boolean(error))\n }\n }, [error, blockId, showFieldError, nestedFieldBlockContext])\n\n useEffect(\n () => () => {\n mountedFieldsRef.current = new Map()\n stateRecordRef.current = {}\n },\n []\n )\n\n const mainClasses = classnames(\n 'dnb-forms-field-block',\n width &&\n `dnb-forms-field-block--width-${hasCustomWidth ? 'custom' : width}`,\n contentWidth &&\n `dnb-forms-field-block--content-width-${\n hasCustomContentWidth ? 'custom' : contentWidth\n }`,\n labelHeight && `dnb-forms-field-block--label-height-${labelHeight}`,\n composition && 'dnb-forms-field-block__composition',\n composition &&\n `dnb-forms-field-block__composition--${\n composition === true ? 'horizontal' : composition\n }`,\n className\n )\n const gridClasses = classnames(\n 'dnb-forms-field-block__grid',\n `dnb-forms-field-block--layout-${layout}`\n )\n\n // A child component with a label was found, use fieldset/legend instead of div/label\n const enableFieldset = useEnableFieldset({\n label,\n asFieldset,\n children,\n nestedFieldBlockContext,\n })\n\n const labelProps: FormLabelAllProps = {\n id: `${id}-label`,\n className: 'dnb-forms-field-block__label',\n element: enableFieldset ? 'legend' : 'label',\n forId: enableFieldset ? undefined : forId,\n srOnly: labelSrOnly,\n space: 0, // Use CSS for spacing, but we need to reset space for doing so\n size: labelSize,\n disabled,\n }\n\n const mainStyle = useMemo(() => {\n const style: React.CSSProperties = {}\n\n if (hasCustomWidth) {\n style['--dnb-forms-field-block-width'] = width\n }\n\n if (hasCustomContentWidth) {\n style['--dnb-forms-field-block-content-width'] = contentWidth\n }\n\n const lO = layoutOptions || {}\n const min = getFieldWidth(lO.minWidth ?? lO.width)\n const max = getFieldWidth(lO.maxWidth ?? lO.width)\n\n if (typeof min === 'string') {\n style['--dnb-forms-field-block-layout-width-min'] = min\n }\n if (typeof max === 'string') {\n style['--dnb-forms-field-block-layout-width-max'] = max\n }\n\n return style\n }, [\n contentWidth,\n hasCustomContentWidth,\n hasCustomWidth,\n layoutOptions,\n width,\n ])\n\n if (dataContext?.prerenderFieldProps) {\n return null\n }\n\n const hasLabelDescription = isFragment(labelDescription)\n ? fragmentHasChildren(labelDescription) &&\n !fragmentHasOnlyUndefinedChildren(labelDescription)\n : labelDescription\n const hasHelp = help?.title || help?.content\n\n return (\n <FieldBlockContext.Provider\n value={{\n setBlockRecord,\n setFieldState,\n showFieldError,\n hasErrorProp: Boolean(error),\n fieldStateIdsRef,\n mountedFieldsRef,\n composition,\n disableStatusSummary,\n }}\n >\n <Space\n element={enableFieldset ? 'fieldset' : 'div'} // use fieldset and legend to enhance a11y\n style={mainStyle}\n className={mainClasses}\n {...rest}\n >\n <div className={gridClasses}>\n {(label || labelDescription || hasHelp) && (\n <FormLabel {...labelProps}>\n <span>\n {label && (\n <span className=\"dnb-forms-field-block__label__content\">\n {label}\n </span>\n )}\n\n {hasHelp && (\n <HelpButtonInline contentId={`${id}-help`} help={help} />\n )}\n\n {hasLabelDescription && !labelDescriptionInline && <br />}\n {hasLabelDescription && (\n <span className=\"dnb-forms-field-block__label__description\">\n {labelDescription}\n </span>\n )}\n </span>\n </FormLabel>\n )}\n\n {hasHelp && (\n <HelpButtonInlineContent\n contentId={`${id}-help`}\n className=\"dnb-forms-field-block__help\"\n help={help}\n breakout={\n layout === 'vertical' &&\n !nestedFieldBlockContext?.composition\n }\n outset={layout !== 'horizontal'}\n />\n )}\n\n <div\n className={classnames(\n 'dnb-forms-field-block__status',\n\n // Handle the width of the status messages\n contentWidth &&\n contentWidth !== 'small' &&\n contentWidth !== 'medium' &&\n !(parseFloat(contentWidth) <= 11) &&\n `dnb-forms-field-block__contents--width-${\n hasCustomContentWidth ? 'custom' : contentWidth\n }`\n )}\n >\n <FormStatus {...statusContent?.error} />\n <FormStatus {...statusContent?.warning} />\n <FormStatus {...statusContent?.info} />\n </div>\n\n <div\n className={classnames(\n 'dnb-forms-field-block__contents',\n contentWidth &&\n `dnb-forms-field-block__contents--width-${\n hasCustomContentWidth ? 'custom' : contentWidth\n }`,\n align && `dnb-forms-field-block__contents--align-${align}`,\n contentClassName\n )}\n ref={contentsRef}\n >\n {children}\n </div>\n\n <SubmitIndicator\n state={fieldState ?? fieldStateRef.current}\n className=\"dnb-forms-field-block__indicator dnb-forms-submit-indicator--inline-wrap\"\n />\n </div>\n </Space>\n </FieldBlockContext.Provider>\n )\n}\n\nfunction useEnableFieldset({\n label,\n asFieldset,\n children,\n nestedFieldBlockContext,\n}) {\n return useMemo(() => {\n if (asFieldset === false) {\n return false\n }\n\n let result = asFieldset\n\n if (label && !result && !nestedFieldBlockContext) {\n let count = 0\n\n findElementInChildren(children, (child: React.ReactElement) => {\n if (\n child?.props?.label ||\n child?.type?.['_formElement'] === true\n ) {\n count++\n }\n if (count > 1) {\n return (result = true)\n }\n })\n }\n\n return Boolean(result)\n }, [asFieldset, children, label, nestedFieldBlockContext])\n}\n\nfunction CombineMessages({\n type,\n messages,\n}: {\n type: StateTypes\n messages: Array<StateWithMessage>\n}) {\n const translations = useTranslation().Field\n\n if (messages.length === 1) {\n return <>{messages[0].message}</>\n }\n\n return (\n <>\n {type === 'error'\n ? translations.errorSummary\n : translations.stateSummary}\n <Ul>\n {messages.map(({ message }, i) => {\n return <Li key={i}>{message}</Li>\n })}\n </Ul>\n </>\n )\n}\n\nfunction getMessage(error: FormError | Error) {\n if (error instanceof FormError) {\n return error.formattedMessage ?? error.message\n }\n\n return error.message\n}\n\nexport function getMessagesFromError(\n item: Partial<StateWithMessage>\n): Array<StateMessage> {\n const { content } = item\n\n if (content instanceof FormError && Array.isArray(content.errors)) {\n return content.errors.map((content) => {\n return getMessage(content)\n })\n }\n\n if (Array.isArray(content)) {\n return content.map((content) => {\n return content instanceof FormError || content instanceof Error\n ? getMessage(content)\n : content\n })\n }\n\n if (content instanceof FormError || content instanceof Error) {\n return [getMessage(content)]\n }\n\n return [\n ((React.isValidElement(content) ? content : content?.toString()) ||\n content) as StateMessage,\n ]\n}\n\nfunction isFragment(fragment: React.ReactNode) {\n return React.isValidElement(fragment) && fragment.type === React.Fragment\n}\n\nfunction fragmentHasChildren(fragment: React.ReactNode) {\n return (\n React.isValidElement(fragment) &&\n React.Children.count(fragment.props.children) > 0\n )\n}\n\nfunction fragmentHasOnlyUndefinedChildren(fragment: React.ReactNode) {\n const isUndefined = (child) => child === undefined\n\n return (\n React.isValidElement(fragment) &&\n React.Children.toArray(fragment.props.children).every(isUndefined)\n )\n}\n\nFieldBlock._supportsSpacingProps = true\n\nexport default FieldBlock\n\nfunction getFieldWidth(width: FieldBlockHorizontalLabelWidth) {\n switch (width) {\n case 'small':\n return 'var(--forms-field-width--small)'\n case 'medium':\n return 'var(--forms-field-width--medium)'\n case 'large':\n return 'var(--forms-field-width--large)'\n }\n\n return width\n}\n"],"mappings":";;;;;;;;;AAAA,OAAOA,KAAK,IACVC,OAAO,EACPC,UAAU,EACVC,WAAW,EACXC,MAAM,EACNC,UAAU,EACVC,SAAS,QACJ,OAAO;AACd,OAAOC,UAAU,MAAM,YAAY;AACnC,OAAOC,iBAAiB,MAWjB,qBAAqB;AAC5B,OAAOC,WAAW,MAAM,wBAAwB;AAChD,SAASC,KAAK,EAAEC,SAAS,EAAEC,UAAU,QAAQ,qBAAqB;AAClE,SAASC,EAAE,EAAEC,EAAE,QAAQ,mBAAmB;AAC1C,SACEC,kBAAkB,EAClBC,qBAAqB,QAChB,kCAAkC;AACzC,OAAOC,KAAK,MAAM,+BAA+B;AASjD,OAAOC,gBAAgB,IACrBC,uBAAuB,QAElB,kDAAkD;AACzD,OAAOC,eAAe,MAAM,yCAAyC;AACrE,SAASC,iBAAiB,QAAQ,wCAAwC;AAC1E,OAAOC,cAAc,MAAM,yBAAyB;AACpD,SAASC,SAAS,QAAQ,UAAU;AACpC,SAASC,gBAAgB,QAAQ,8BAA8B;AAE/D,OAAO,MAAMC,MAAyB,GAAG,CAAC,OAAO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AS;EAElD,OACEpH,KAAK,CAAC2L,cAAc,CAACE,QAAQ,CAAC,IAC9B7L,KAAK,CAAC8L,QAAQ,CAACE,OAAO,CAACH,QAAQ,CAAClK,KAAK,CAACqC,QAAQ,CAAC,CAACiI,KAAK,CAACF,WAAW,CAAC;AAEtE;AAEArK,UAAU,CAACwK,qBAAqB,GAAG,IAAI;AAEvC,eAAexK,UAAU;AAEzB,SAAS0H,aAAaA,CAAC1F,KAAqC,EAAE;EAC5D,QAAQA,KAAK;IACX,KAAK,OAAO;MACV,OAAO,iCAAiC;IAC1C,KAAK,QAAQ;MACX,OAAO,kCAAkC;IAC3C,KAAK,OAAO;MACV,OAAO,iCAAiC;EAC5C;EAEA,OAAOA,KAAK;AACd","ignoreList":[]}
|
|
@@ -13,7 +13,7 @@ export type StateBasis = {
|
|
|
13
13
|
show?: boolean;
|
|
14
14
|
};
|
|
15
15
|
export type StateRecord = Record<Identifier, Array<Omit<StateBasis, 'identifier'>>>;
|
|
16
|
-
export type StateMessage =
|
|
16
|
+
export type StateMessage = React.ReactNode;
|
|
17
17
|
export type StateWithMessage = StateBasis & {
|
|
18
18
|
message: StateMessage;
|
|
19
19
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FieldBlockContext.js","names":["React","FieldBlockContext","createContext","undefined"],"sources":["../../../../../src/extensions/forms/FieldBlock/FieldBlockContext.ts"],"sourcesContent":["import React from 'react'\nimport type { FieldProps, Identifier, SubmitState } from '../types'\n\nexport type FieldErrorIdsRef = Record<StateTypes, string>\nexport type MountedFieldsRef = Map<Identifier, boolean>\nexport type StateTypes = 'error' | 'warning' | 'info'\nexport type StateContent =\n | FieldProps<unknown>['error']\n | FieldProps<unknown>['warning']\n | FieldProps<unknown>['info']\nexport type StateBasis = {\n identifier: Identifier\n type: StateTypes\n content: StateContent\n stateId?: string\n showInitially?: boolean\n show?: boolean\n}\nexport type StateRecord = Record<\n Identifier,\n Array<Omit<StateBasis, 'identifier'>>\n>\nexport type StateMessage =
|
|
1
|
+
{"version":3,"file":"FieldBlockContext.js","names":["React","FieldBlockContext","createContext","undefined"],"sources":["../../../../../src/extensions/forms/FieldBlock/FieldBlockContext.ts"],"sourcesContent":["import React from 'react'\nimport type { FieldProps, Identifier, SubmitState } from '../types'\n\nexport type FieldErrorIdsRef = Record<StateTypes, string>\nexport type MountedFieldsRef = Map<Identifier, boolean>\nexport type StateTypes = 'error' | 'warning' | 'info'\nexport type StateContent =\n | FieldProps<unknown>['error']\n | FieldProps<unknown>['warning']\n | FieldProps<unknown>['info']\nexport type StateBasis = {\n identifier: Identifier\n type: StateTypes\n content: StateContent\n stateId?: string\n showInitially?: boolean\n show?: boolean\n}\nexport type StateRecord = Record<\n Identifier,\n Array<Omit<StateBasis, 'identifier'>>\n>\nexport type StateMessage = React.ReactNode\nexport type StateWithMessage = StateBasis & {\n message: StateMessage\n}\nexport type StatesWithMessages = StateBasis & {\n messages: Array<StateWithMessage>\n}\nexport type StatusContentState = { id: string; text: React.ReactNode }\nexport type StatusContent = {\n error: StatusContentState\n warning: StatusContentState\n info: StatusContentState\n}\n\nexport type FieldBlockContextProps = {\n setBlockRecord?: ({\n identifier,\n type,\n stateId,\n content,\n showInitially,\n show,\n }: StateBasis) => void\n setFieldState?: (identifier: Identifier, fieldState: SubmitState) => void\n showFieldError?: (identifier: Identifier, showError: boolean) => void\n hasErrorProp?: boolean\n composition?: true\n disableStatusSummary?: boolean\n fieldStateIdsRef?: React.MutableRefObject<FieldErrorIdsRef>\n mountedFieldsRef?: React.MutableRefObject<MountedFieldsRef>\n}\n\nconst FieldBlockContext = React.createContext<\n FieldBlockContextProps | undefined\n>(undefined)\n\nexport default FieldBlockContext\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AAsDzB,MAAMC,iBAAiB,GAAGD,KAAK,CAACE,aAAa,CAE3CC,SAAS,CAAC;AAEZ,eAAeF,iBAAiB","ignoreList":[]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export const ButtonRowProperties = {
|
|
2
|
+
children: {
|
|
3
|
+
doc: 'Buttons.',
|
|
4
|
+
type: 'React.ReactNode',
|
|
5
|
+
status: 'required'
|
|
6
|
+
},
|
|
7
|
+
'[Space](/uilib/layout/space/properties)': {
|
|
8
|
+
doc: 'Spacing properties like `top` or `bottom` are supported.',
|
|
9
|
+
type: ['string', 'object'],
|
|
10
|
+
status: 'optional'
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=ButtonRowDocs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ButtonRowDocs.js","names":["ButtonRowProperties","children","doc","type","status"],"sources":["../../../../../../src/extensions/forms/Form/ButtonRow/ButtonRowDocs.ts"],"sourcesContent":["import { PropertiesTableProps } from '../../../../shared/types'\n\nexport const ButtonRowProperties: PropertiesTableProps = {\n children: {\n doc: 'Buttons.',\n type: 'React.ReactNode',\n status: 'required',\n },\n '[Space](/uilib/layout/space/properties)': {\n doc: 'Spacing properties like `top` or `bottom` are supported.',\n type: ['string', 'object'],\n status: 'optional',\n },\n}\n"],"mappings":"AAEA,OAAO,MAAMA,mBAAyC,GAAG;EACvDC,QAAQ,EAAE;IACRC,GAAG,EAAE,UAAU;IACfC,IAAI,EAAE,iBAAiB;IACvBC,MAAM,EAAE;EACV,CAAC;EACD,yCAAyC,EAAE;IACzCF,GAAG,EAAE,0DAA0D;IAC/DC,IAAI,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC1BC,MAAM,EAAE;EACV;AACF,CAAC","ignoreList":[]}
|
|
@@ -15,7 +15,7 @@ export const IsolationProperties = _objectSpread(_objectSpread({
|
|
|
15
15
|
},
|
|
16
16
|
commitHandleRef: {
|
|
17
17
|
doc: 'Provide a ref to a function that can be called from any location to commit the data to the form.',
|
|
18
|
-
type: 'React.
|
|
18
|
+
type: 'React.RefObject',
|
|
19
19
|
status: 'optional'
|
|
20
20
|
},
|
|
21
21
|
bubbleValidation: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IsolationDocs.js","names":["ProviderEvents","ProviderProperties","IsolationProperties","_objectSpread","path","doc","type","status","transformOnCommit","commitHandleRef","bubbleValidation","minimumAsyncBehaviorTime","undefined","asyncSubmitTimeout","scrollTopOnSubmit","sessionStorageId","globalStatusId","IsolationEvents","onCommit","onSubmit","onSubmitRequest","onSubmitComplete"],"sources":["../../../../../../src/extensions/forms/Form/Isolation/IsolationDocs.ts"],"sourcesContent":["import { PropertiesTableProps } from '../../../../shared/types'\nimport {\n ProviderEvents,\n ProviderProperties,\n} from '../../DataContext/Provider/ProviderDocs'\n\nexport const IsolationProperties: PropertiesTableProps = {\n path: {\n doc: 'JSON Pointer to define the object key for all the generated nested field data.',\n type: 'string',\n status: 'optional',\n },\n transformOnCommit: {\n doc: 'Transform the data before it gets committed to the form. The first parameter is the isolated data object. The second parameter is the outer context data object (Form.Handler).',\n type: 'function',\n status: 'optional',\n },\n commitHandleRef: {\n doc: 'Provide a ref to a function that can be called from any location to commit the data to the form.',\n type: 'React.
|
|
1
|
+
{"version":3,"file":"IsolationDocs.js","names":["ProviderEvents","ProviderProperties","IsolationProperties","_objectSpread","path","doc","type","status","transformOnCommit","commitHandleRef","bubbleValidation","minimumAsyncBehaviorTime","undefined","asyncSubmitTimeout","scrollTopOnSubmit","sessionStorageId","globalStatusId","IsolationEvents","onCommit","onSubmit","onSubmitRequest","onSubmitComplete"],"sources":["../../../../../../src/extensions/forms/Form/Isolation/IsolationDocs.ts"],"sourcesContent":["import { PropertiesTableProps } from '../../../../shared/types'\nimport {\n ProviderEvents,\n ProviderProperties,\n} from '../../DataContext/Provider/ProviderDocs'\n\nexport const IsolationProperties: PropertiesTableProps = {\n path: {\n doc: 'JSON Pointer to define the object key for all the generated nested field data.',\n type: 'string',\n status: 'optional',\n },\n transformOnCommit: {\n doc: 'Transform the data before it gets committed to the form. The first parameter is the isolated data object. The second parameter is the outer context data object (Form.Handler).',\n type: 'function',\n status: 'optional',\n },\n commitHandleRef: {\n doc: 'Provide a ref to a function that can be called from any location to commit the data to the form.',\n type: 'React.RefObject',\n status: 'optional',\n },\n bubbleValidation: {\n doc: 'Prevent the form from being submitted when there are fields with errors inside the Form.Isolation.',\n type: 'boolean',\n status: 'optional',\n },\n ...ProviderProperties,\n minimumAsyncBehaviorTime: undefined,\n asyncSubmitTimeout: undefined,\n scrollTopOnSubmit: undefined,\n sessionStorageId: undefined,\n globalStatusId: undefined,\n}\n\nexport const IsolationEvents: PropertiesTableProps = {\n onCommit: {\n doc: 'Will be called on a nested form context commit – if validation has passed. The first parameter is the committed data object. The second parameter is an object containing a method to clear the internal data `{ clearData }`.',\n type: 'function',\n status: 'optional',\n },\n ...ProviderEvents,\n onSubmit: undefined,\n onSubmitRequest: undefined,\n onSubmitComplete: undefined,\n}\n"],"mappings":";;;AACA,SACEA,cAAc,EACdC,kBAAkB,QACb,yCAAyC;AAEhD,OAAO,MAAMC,mBAAyC,GAAAC,aAAA,CAAAA,aAAA;EACpDC,IAAI,EAAE;IACJC,GAAG,EAAE,gFAAgF;IACrFC,IAAI,EAAE,QAAQ;IACdC,MAAM,EAAE;EACV,CAAC;EACDC,iBAAiB,EAAE;IACjBH,GAAG,EAAE,iLAAiL;IACtLC,IAAI,EAAE,UAAU;IAChBC,MAAM,EAAE;EACV,CAAC;EACDE,eAAe,EAAE;IACfJ,GAAG,EAAE,kGAAkG;IACvGC,IAAI,EAAE,iBAAiB;IACvBC,MAAM,EAAE;EACV,CAAC;EACDG,gBAAgB,EAAE;IAChBL,GAAG,EAAE,oGAAoG;IACzGC,IAAI,EAAE,SAAS;IACfC,MAAM,EAAE;EACV;AAAC,GACEN,kBAAkB;EACrBU,wBAAwB,EAAEC,SAAS;EACnCC,kBAAkB,EAAED,SAAS;EAC7BE,iBAAiB,EAAEF,SAAS;EAC5BG,gBAAgB,EAAEH,SAAS;EAC3BI,cAAc,EAAEJ;AAAS,EAC1B;AAED,OAAO,MAAMK,eAAqC,GAAAd,aAAA,CAAAA,aAAA;EAChDe,QAAQ,EAAE;IACRb,GAAG,EAAE,gOAAgO;IACrOC,IAAI,EAAE,UAAU;IAChBC,MAAM,EAAE;EACV;AAAC,GACEP,cAAc;EACjBmB,QAAQ,EAAEP,SAAS;EACnBQ,eAAe,EAAER,SAAS;EAC1BS,gBAAgB,EAAET;AAAS,EAC5B","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ButtonsDocs.js","names":["WizardButtonsProperties","doc","type","status"],"sources":["../../../../../../src/extensions/forms/Wizard/Buttons/ButtonsDocs.ts"],"sourcesContent":["import { PropertiesTableProps } from '../../../../shared/types'\n\nexport const WizardButtonsProperties: PropertiesTableProps = {\n '[ButtonRow](/uilib/extensions/forms/Form/ButtonRow/properties/)': {\n doc: 'ButtonRow properties.',\n type: 'Various',\n status: 'optional',\n },\n}\n"],"mappings":"AAEA,OAAO,MAAMA,uBAA6C,GAAG;EAC3D,iEAAiE,EAAE;IACjEC,GAAG,EAAE,uBAAuB;IAC5BC,IAAI,EAAE,SAAS;IACfC,MAAM,EAAE;EACV;AACF,CAAC","ignoreList":[]}
|
|
@@ -70,7 +70,7 @@ export const DataValueWritePropsProperties = {
|
|
|
70
70
|
status: 'optional'
|
|
71
71
|
},
|
|
72
72
|
errorMessages: {
|
|
73
|
-
doc: 'Custom error messages for each type of error, overriding default messages.',
|
|
73
|
+
doc: 'Custom error messages for each type of error, overriding default messages. The messages can be a React.ReactNode or a string.',
|
|
74
74
|
type: 'object',
|
|
75
75
|
status: 'optional'
|
|
76
76
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataValueWritePropsDocs.js","names":["DataValueWritePropsProperties","value","doc","type","status","defaultValue","path","info","warning","error","disabled","emptyValue","required","labelSuffix","schema","validateInitially","validateUnchanged","validateContinuously","errorMessages","onChangeValidator","onBlurValidator","transformIn","transformOut","DataValueWritePropsEvents","onChange","onFocus","onBlur"],"sources":["../../../../../src/extensions/forms/hooks/DataValueWritePropsDocs.ts"],"sourcesContent":["import { PropertiesTableProps } from '../../../shared/types'\n\nexport const DataValueWritePropsProperties: PropertiesTableProps = {\n value: {\n doc: 'Source data value for the field. Will take precedence over the path value given in the data context.',\n type: '{valueType}',\n status: 'optional',\n },\n defaultValue: {\n doc: 'Default source data value for the field. Will not take precedence over the path value given in the data context.',\n type: '{valueType}',\n status: 'optional',\n },\n path: {\n doc: 'JSON Pointer for where the data for the field is located in the source dataset (when using Form.Handler or DataContext). The `path` will also be set as the `name` attribute for the [string](/uilib/extensions/forms/base-fields/String/)-field.',\n type: 'string',\n status: 'optional',\n },\n info: {\n doc: \"Info message shown below / after the field. When provided as a function, the function will be called with the current value as argument. The second parameter is an object with `{ conditionally, getValueByPath, getFieldByPath }`. To show the message first after the user has interacted with the field, you can call and return `conditionally` function with a callback and with options: `conditionally(() => 'Your message', { showInitially: true })`\",\n type: ['React.Node', 'Array<React.Node>', 'function'],\n status: 'optional',\n },\n warning: {\n doc: \"Warning message shown below / after the field. When provided as a function, the function will be called with the current value as argument. The second parameter is an object with `{ conditionally, getValueByPath, getFieldByPath }`. To show the message first after the user has interacted with the field, you can call and return `conditionally` function with a callback and with options: `conditionally(() => 'Your message', { showInitially: true })`\",\n type: ['React.Node', 'Array<React.Node>', 'function'],\n status: 'optional',\n },\n error: {\n doc: \"Error message shown below / after the field. When provided as a function, the function will be called with the current value as argument. The second parameter is an object with `{ conditionally, getValueByPath, getFieldByPath }`. To show the message first after the user has interacted with the field, you can call and return `conditionally` function with a callback and with options: `conditionally(() => 'Your message', { showInitially: true })`\",\n type: ['Error', 'FormError', 'Array<Error | FormError>', 'function'],\n status: 'optional',\n },\n disabled: {\n doc: 'Set `true` to show the field but without the possibility of changing the value.',\n type: 'boolean',\n status: 'optional',\n },\n emptyValue: {\n doc: 'The value to use (in `onChange` events etc) when emptying the field. Makes it possible for instance to provide `undefined` instead of an empty string when clearing the content of a text input.',\n type: ['{valueType}', 'undefined'],\n status: 'optional',\n },\n required: {\n doc: 'When set to `true`, the field will give an error if the value fails the required validation. When set to `false`, the field will not be required, but will add a \"(optional)\" suffix to the label.',\n type: 'boolean',\n status: 'optional',\n },\n labelSuffix: {\n doc: 'Will append an additional text to the label, like \"(optional)\". When using `inheritLabel`, the suffix will not be inherited. NB: The visual appearance of the `labelSuffix` may change in the future.',\n type: 'React.Node',\n status: 'optional',\n },\n schema: {\n doc: 'Custom JSON Schema for validating the value.',\n type: 'object',\n status: 'optional',\n },\n validateInitially: {\n doc: 'Set to `true` to show validation based errors initially (from given value-prop or source data) before the user interacts with the field.',\n type: 'boolean',\n status: 'optional',\n },\n validateUnchanged: {\n doc: 'Set to `true` to show validation based errors when the field is touched (like focusing a field and blurring) without having changed the value. Since the user did not introduce a new error, this will apply when the value was initially invalid based on validation.',\n type: 'boolean',\n status: 'optional',\n },\n validateContinuously: {\n doc: 'Set to `true` to show validation based errors continuously while writing, not just when blurring the field.',\n type: 'boolean',\n status: 'optional',\n },\n errorMessages: {\n doc: 'Custom error messages for each type of error, overriding default messages.',\n type: 'object',\n status: 'optional',\n },\n onChangeValidator: {\n doc: 'Custom validator function where you can return `undefined`, `Error`, `FormError` or an Array with either several other validators or several `Error` or `FormError`. It is triggered on every change done by the user. The function can be either asynchronous or synchronous. The first parameter is the value, and the second parameter returns an object containing { errorMessages, connectWithPath, validators }.',\n type: 'function',\n status: 'optional',\n },\n onBlurValidator: {\n doc: 'Custom validator function where you can return `undefined`, `Error`, `FormError` or an Array with either several other validators or several `Error` or `FormError`. It is triggered when the user leaves a field (e.g., blurring a text input or closing a dropdown). The function can be either asynchronous or synchronous. The first parameter is the value, and the second parameter returns an object containing { errorMessages, connectWithPath, validators }.',\n type: 'function',\n status: 'optional',\n },\n transformIn: {\n doc: 'Transforms the `value` before its displayed in the field (e.g. input).',\n type: 'function',\n status: 'optional',\n },\n transformOut: {\n doc: 'Transforms the value before it gets forwarded to the form data object (context) or returned as the `onChange` value parameter. The first parameter is the internal value. Some fields to support a second parameter, like the SelectCountry, where the country object is given.',\n type: 'function',\n status: 'optional',\n },\n}\n\nexport const DataValueWritePropsEvents: PropertiesTableProps = {\n onChange: {\n doc: \"Will be called on value changes made by the user, with the new value as argument. When an `async` function is used, the corresponding [FieldBlock](/uilib/extensions/forms/create-component/FieldBlock/) will show an indicator on the field label. You can return `{ success: 'saved' } as const` to show a success symbol, or an error or an object with these keys `{ info: 'Info message', warning: 'Warning message', error: Error('My error') } as const`. The second parameter is an object that e.g. contains `props` (all given `Field.*` properties).\",\n type: '(value) => void',\n status: 'optional',\n },\n onFocus: {\n doc: 'Will be called when the component gets into focus. Like clicking inside a text input or opening a dropdown. Called with active value as argument. The second parameter is an object that e.g. contains `props` (all given `Field.*` properties).',\n type: '(value) => void',\n status: 'optional',\n },\n onBlur: {\n doc: 'Will be called when the component stop being in focus. Like when going to next field, or closing a dropdown. Called with active value as argument. The second parameter is an object that e.g. contains `props` (all given `Field.*` properties).',\n type: '(value) => void',\n status: 'optional',\n },\n}\n"],"mappings":"AAEA,OAAO,MAAMA,6BAAmD,GAAG;EACjEC,KAAK,EAAE;IACLC,GAAG,EAAE,sGAAsG;IAC3GC,IAAI,EAAE,aAAa;IACnBC,MAAM,EAAE;EACV,CAAC;EACDC,YAAY,EAAE;IACZH,GAAG,EAAE,kHAAkH;IACvHC,IAAI,EAAE,aAAa;IACnBC,MAAM,EAAE;EACV,CAAC;EACDE,IAAI,EAAE;IACJJ,GAAG,EAAE,mPAAmP;IACxPC,IAAI,EAAE,QAAQ;IACdC,MAAM,EAAE;EACV,CAAC;EACDG,IAAI,EAAE;IACJL,GAAG,EAAE,gcAAgc;IACrcC,IAAI,EAAE,CAAC,YAAY,EAAE,mBAAmB,EAAE,UAAU,CAAC;IACrDC,MAAM,EAAE;EACV,CAAC;EACDI,OAAO,EAAE;IACPN,GAAG,EAAE,mcAAmc;IACxcC,IAAI,EAAE,CAAC,YAAY,EAAE,mBAAmB,EAAE,UAAU,CAAC;IACrDC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EAAE;IACflB,GAAG,EAAE,wcAAwc;IAC7cC,IAAI,EAAE,UAAU;IAChBC,MAAM,EAAE;EACV,CAAC;EACDiB,WAAW,EAAE;IACXnB,GAAG,EAAE,wEAAwE;IAC7EC,IAAI,EAAE,UAAU;IAChBC,MAAM,EAAE;EACV,CAAC;EACDkB,YAAY,EAAE;IACZpB,GAAG,EAAE,iRAAiR;IACtRC,IAAI,EAAE,UAAU;IAChBC,MAAM,EAAE;EACV;AACF,CAAC;AAED,OAAO,MAAMmB,yBAA+C,GAAG;EAC7DC,QAAQ,EAAE;IACRtB,GAAG,EAAE,iiBAAiiB;IACtiBC,IAAI,EAAE,iBAAiB;IACvBC,MAAM,EAAE;EACV,CAAC;EACDqB,OAAO,EAAE;IACPvB,GAAG,EAAE,kPAAkP;IACvPC,IAAI,EAAE,iBAAiB;IACvBC,MAAM,EAAE;EACV,CAAC;EACDsB,MAAM,EAAE;IACNxB,GAAG,EAAE,mPAAmP;IACxPC,IAAI,EAAE,iBAAiB;IACvBC,MAAM,EAAE;EACV;AACF,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"DataValueWritePropsDocs.js","names":["DataValueWritePropsProperties","value","doc","type","status","defaultValue","path","info","warning","error","disabled","emptyValue","required","labelSuffix","schema","validateInitially","validateUnchanged","validateContinuously","errorMessages","onChangeValidator","onBlurValidator","transformIn","transformOut","DataValueWritePropsEvents","onChange","onFocus","onBlur"],"sources":["../../../../../src/extensions/forms/hooks/DataValueWritePropsDocs.ts"],"sourcesContent":["import { PropertiesTableProps } from '../../../shared/types'\n\nexport const DataValueWritePropsProperties: PropertiesTableProps = {\n value: {\n doc: 'Source data value for the field. Will take precedence over the path value given in the data context.',\n type: '{valueType}',\n status: 'optional',\n },\n defaultValue: {\n doc: 'Default source data value for the field. Will not take precedence over the path value given in the data context.',\n type: '{valueType}',\n status: 'optional',\n },\n path: {\n doc: 'JSON Pointer for where the data for the field is located in the source dataset (when using Form.Handler or DataContext). The `path` will also be set as the `name` attribute for the [string](/uilib/extensions/forms/base-fields/String/)-field.',\n type: 'string',\n status: 'optional',\n },\n info: {\n doc: \"Info message shown below / after the field. When provided as a function, the function will be called with the current value as argument. The second parameter is an object with `{ conditionally, getValueByPath, getFieldByPath }`. To show the message first after the user has interacted with the field, you can call and return `conditionally` function with a callback and with options: `conditionally(() => 'Your message', { showInitially: true })`\",\n type: ['React.Node', 'Array<React.Node>', 'function'],\n status: 'optional',\n },\n warning: {\n doc: \"Warning message shown below / after the field. When provided as a function, the function will be called with the current value as argument. The second parameter is an object with `{ conditionally, getValueByPath, getFieldByPath }`. To show the message first after the user has interacted with the field, you can call and return `conditionally` function with a callback and with options: `conditionally(() => 'Your message', { showInitially: true })`\",\n type: ['React.Node', 'Array<React.Node>', 'function'],\n status: 'optional',\n },\n error: {\n doc: \"Error message shown below / after the field. When provided as a function, the function will be called with the current value as argument. The second parameter is an object with `{ conditionally, getValueByPath, getFieldByPath }`. To show the message first after the user has interacted with the field, you can call and return `conditionally` function with a callback and with options: `conditionally(() => 'Your message', { showInitially: true })`\",\n type: ['Error', 'FormError', 'Array<Error | FormError>', 'function'],\n status: 'optional',\n },\n disabled: {\n doc: 'Set `true` to show the field but without the possibility of changing the value.',\n type: 'boolean',\n status: 'optional',\n },\n emptyValue: {\n doc: 'The value to use (in `onChange` events etc) when emptying the field. Makes it possible for instance to provide `undefined` instead of an empty string when clearing the content of a text input.',\n type: ['{valueType}', 'undefined'],\n status: 'optional',\n },\n required: {\n doc: 'When set to `true`, the field will give an error if the value fails the required validation. When set to `false`, the field will not be required, but will add a \"(optional)\" suffix to the label.',\n type: 'boolean',\n status: 'optional',\n },\n labelSuffix: {\n doc: 'Will append an additional text to the label, like \"(optional)\". When using `inheritLabel`, the suffix will not be inherited. NB: The visual appearance of the `labelSuffix` may change in the future.',\n type: 'React.Node',\n status: 'optional',\n },\n schema: {\n doc: 'Custom JSON Schema for validating the value.',\n type: 'object',\n status: 'optional',\n },\n validateInitially: {\n doc: 'Set to `true` to show validation based errors initially (from given value-prop or source data) before the user interacts with the field.',\n type: 'boolean',\n status: 'optional',\n },\n validateUnchanged: {\n doc: 'Set to `true` to show validation based errors when the field is touched (like focusing a field and blurring) without having changed the value. Since the user did not introduce a new error, this will apply when the value was initially invalid based on validation.',\n type: 'boolean',\n status: 'optional',\n },\n validateContinuously: {\n doc: 'Set to `true` to show validation based errors continuously while writing, not just when blurring the field.',\n type: 'boolean',\n status: 'optional',\n },\n errorMessages: {\n doc: 'Custom error messages for each type of error, overriding default messages. The messages can be a React.ReactNode or a string.',\n type: 'object',\n status: 'optional',\n },\n onChangeValidator: {\n doc: 'Custom validator function where you can return `undefined`, `Error`, `FormError` or an Array with either several other validators or several `Error` or `FormError`. It is triggered on every change done by the user. The function can be either asynchronous or synchronous. The first parameter is the value, and the second parameter returns an object containing { errorMessages, connectWithPath, validators }.',\n type: 'function',\n status: 'optional',\n },\n onBlurValidator: {\n doc: 'Custom validator function where you can return `undefined`, `Error`, `FormError` or an Array with either several other validators or several `Error` or `FormError`. It is triggered when the user leaves a field (e.g., blurring a text input or closing a dropdown). The function can be either asynchronous or synchronous. The first parameter is the value, and the second parameter returns an object containing { errorMessages, connectWithPath, validators }.',\n type: 'function',\n status: 'optional',\n },\n transformIn: {\n doc: 'Transforms the `value` before its displayed in the field (e.g. input).',\n type: 'function',\n status: 'optional',\n },\n transformOut: {\n doc: 'Transforms the value before it gets forwarded to the form data object (context) or returned as the `onChange` value parameter. The first parameter is the internal value. Some fields to support a second parameter, like the SelectCountry, where the country object is given.',\n type: 'function',\n status: 'optional',\n },\n}\n\nexport const DataValueWritePropsEvents: PropertiesTableProps = {\n onChange: {\n doc: \"Will be called on value changes made by the user, with the new value as argument. When an `async` function is used, the corresponding [FieldBlock](/uilib/extensions/forms/create-component/FieldBlock/) will show an indicator on the field label. You can return `{ success: 'saved' } as const` to show a success symbol, or an error or an object with these keys `{ info: 'Info message', warning: 'Warning message', error: Error('My error') } as const`. The second parameter is an object that e.g. contains `props` (all given `Field.*` properties).\",\n type: '(value) => void',\n status: 'optional',\n },\n onFocus: {\n doc: 'Will be called when the component gets into focus. Like clicking inside a text input or opening a dropdown. Called with active value as argument. The second parameter is an object that e.g. contains `props` (all given `Field.*` properties).',\n type: '(value) => void',\n status: 'optional',\n },\n onBlur: {\n doc: 'Will be called when the component stop being in focus. Like when going to next field, or closing a dropdown. Called with active value as argument. The second parameter is an object that e.g. contains `props` (all given `Field.*` properties).',\n type: '(value) => void',\n status: 'optional',\n },\n}\n"],"mappings":"AAEA,OAAO,MAAMA,6BAAmD,GAAG;EACjEC,KAAK,EAAE;IACLC,GAAG,EAAE,sGAAsG;IAC3GC,IAAI,EAAE,aAAa;IACnBC,MAAM,EAAE;EACV,CAAC;EACDC,YAAY,EAAE;IACZH,GAAG,EAAE,kHAAkH;IACvHC,IAAI,EAAE,aAAa;IACnBC,MAAM,EAAE;EACV,CAAC;EACDE,IAAI,EAAE;IACJJ,GAAG,EAAE,mPAAmP;IACxPC,IAAI,EAAE,QAAQ;IACdC,MAAM,EAAE;EACV,CAAC;EACDG,IAAI,EAAE;IACJL,GAAG,EAAE,gcAAgc;IACrcC,IAAI,EAAE,CAAC,YAAY,EAAE,mBAAmB,EAAE,UAAU,CAAC;IACrDC,MAAM,EAAE;EACV,CAAC;EACDI,OAAO,EAAE;IACPN,GAAG,EAAE,mcAAmc;IACxcC,IAAI,EAAE,CAAC,YAAY,EAAE,mBAAmB,EAAE,UAAU,CAAC;IACrDC,MAAM,EAAE;EACV,CAAC;EACDK,KAAK,EAAE;IACLP,GAAG,EAAE,icAAic;IACtcC,IAAI,EAAE,CAAC,OAAO,EAAE,WAAW,EAAE,0BAA0B,EAAE,UAAU,CAAC;IACpEC,MAAM,EAAE;EACV,CAAC;EACDM,QAAQ,EAAE;IACRR,GAAG,EAAE,iFAAiF;IACtFC,IAAI,EAAE,SAAS;IACfC,MAAM,EAAE;EACV,CAAC;EACDO,UAAU,EAAE;IACVT,GAAG,EAAE,kMAAkM;IACvM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AA+C,GAAG;EAC7DC,QAAQ,EAAE;IACRtB,GAAG,EAAE,iiBAAiiB;IACtiBC,IAAI,EAAE,iBAAiB;IACvBC,MAAM,EAAE;EACV,CAAC;EACDqB,OAAO,EAAE;IACPvB,GAAG,EAAE,kPAAkP;IACvPC,IAAI,EAAE,iBAAiB;IACvBC,MAAM,EAAE;EACV,CAAC;EACDsB,MAAM,EAAE;IACNxB,GAAG,EAAE,mPAAmP;IACxPC,IAAI,EAAE,iBAAiB;IACvBC,MAAM,EAAE;EACV;AACF,CAAC","ignoreList":[]}
|
|
@@ -9,7 +9,7 @@ import { ajvErrorsToOneFormError, errorChanged, overwriteErrorMessagesWithGivenA
|
|
|
9
9
|
import { Context as DataContext } from '../DataContext';
|
|
10
10
|
import { clearedData } from '../DataContext/Provider/Provider';
|
|
11
11
|
import FieldProviderContext from '../Field/Provider/FieldProviderContext';
|
|
12
|
-
import { combineDescribedBy, warn } from '../../../shared/component-helper';
|
|
12
|
+
import { combineDescribedBy, convertJsxToString, warn } from '../../../shared/component-helper';
|
|
13
13
|
import useId from '../../../shared/helpers/useId';
|
|
14
14
|
import useUpdateEffect from '../../../shared/helpers/useUpdateEffect';
|
|
15
15
|
import FieldBlockContext from '../FieldBlock/FieldBlockContext';
|
|
@@ -247,6 +247,28 @@ export default function useFieldProps(localProps, {
|
|
|
247
247
|
id: undefined
|
|
248
248
|
};
|
|
249
249
|
}, [fieldInternalsRef]);
|
|
250
|
+
const errorMessageCacheRef = useRef(new Map());
|
|
251
|
+
const ensureErrorMessageObject = useCallback(error => {
|
|
252
|
+
let key = null;
|
|
253
|
+
let returnValue = error;
|
|
254
|
+
if (typeof error === 'string') {
|
|
255
|
+
key = error;
|
|
256
|
+
returnValue = new Error(error);
|
|
257
|
+
} else if (error && React.isValidElement(error)) {
|
|
258
|
+
key = error.key || convertJsxToString(error);
|
|
259
|
+
returnValue = new FormError('Error', {
|
|
260
|
+
formattedMessage: error
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
if (key) {
|
|
264
|
+
if (errorMessageCacheRef.current.has(key)) {
|
|
265
|
+
return errorMessageCacheRef.current.get(key);
|
|
266
|
+
} else {
|
|
267
|
+
errorMessageCacheRef.current.set(key, returnValue);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
return returnValue;
|
|
271
|
+
}, []);
|
|
250
272
|
const messageCacheRef = useRef({
|
|
251
273
|
isSet: false,
|
|
252
274
|
message: undefined
|
|
@@ -262,7 +284,7 @@ export default function useFieldProps(localProps, {
|
|
|
262
284
|
if (options !== null && options !== void 0 && options.showInitially) {
|
|
263
285
|
currentMode |= INITIALLY;
|
|
264
286
|
}
|
|
265
|
-
return callback();
|
|
287
|
+
return executeMessage(callback());
|
|
266
288
|
},
|
|
267
289
|
getValueByPath,
|
|
268
290
|
getFieldByPath
|
|
@@ -292,8 +314,8 @@ export default function useFieldProps(localProps, {
|
|
|
292
314
|
return undefined;
|
|
293
315
|
}
|
|
294
316
|
}
|
|
295
|
-
return message;
|
|
296
|
-
}, [getFieldByPath, getValueByPath]);
|
|
317
|
+
return ensureErrorMessageObject(message);
|
|
318
|
+
}, [getFieldByPath, getValueByPath, ensureErrorMessageObject]);
|
|
297
319
|
const errorProp = initialErrorProp === 'initial' ? undefined : initialErrorProp;
|
|
298
320
|
const error = executeMessage(errorProp);
|
|
299
321
|
const warning = executeMessage(warningProp);
|
|
@@ -321,7 +343,7 @@ export default function useFieldProps(localProps, {
|
|
|
321
343
|
const asyncBehaviorIsEnabled = useMemo(() => {
|
|
322
344
|
return isAsync(onChange) || isAsync(onChangeContext);
|
|
323
345
|
}, [onChangeContext, onChange]);
|
|
324
|
-
const
|
|
346
|
+
const validatedValueRef = useRef();
|
|
325
347
|
const changeEventResultRef = useRef(null);
|
|
326
348
|
const asyncProcessRef = useRef(null);
|
|
327
349
|
const defineAsyncProcess = useCallback(name => {
|
|
@@ -422,8 +444,8 @@ export default function useFieldProps(localProps, {
|
|
|
422
444
|
return extendedErrorMessages;
|
|
423
445
|
}, [contextErrorMessages, errorMessages, identifier]);
|
|
424
446
|
const prepareError = useCallback(error => {
|
|
425
|
-
|
|
426
|
-
|
|
447
|
+
const prepare = error => {
|
|
448
|
+
if (error instanceof FormError) {
|
|
427
449
|
let message = error.message;
|
|
428
450
|
const {
|
|
429
451
|
ajvKeyword
|
|
@@ -453,9 +475,20 @@ export default function useFieldProps(localProps, {
|
|
|
453
475
|
} else if (message.includes('.')) {
|
|
454
476
|
message = formatMessage(message, error.messageValues);
|
|
455
477
|
}
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
478
|
+
if (React.isValidElement(message)) {
|
|
479
|
+
error.formattedMessage = message;
|
|
480
|
+
} else {
|
|
481
|
+
error.message = message;
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
return ensureErrorMessageObject(error);
|
|
485
|
+
};
|
|
486
|
+
if (Array.isArray(error)) {
|
|
487
|
+
return new FormError('Error', {
|
|
488
|
+
errors: error.map(prepare)
|
|
489
|
+
});
|
|
490
|
+
}
|
|
491
|
+
if (error instanceof FormError) {
|
|
459
492
|
if (Array.isArray(error.errors)) {
|
|
460
493
|
error.errors = error.errors.map(prepare);
|
|
461
494
|
return error;
|
|
@@ -463,7 +496,7 @@ export default function useFieldProps(localProps, {
|
|
|
463
496
|
return prepare(error);
|
|
464
497
|
}
|
|
465
498
|
return error;
|
|
466
|
-
}, [combinedErrorMessages, formatMessage]);
|
|
499
|
+
}, [combinedErrorMessages, ensureErrorMessageObject, formatMessage]);
|
|
467
500
|
contextErrorRef.current = useMemo(() => {
|
|
468
501
|
const dataContextError = dataContextErrors === null || dataContextErrors === void 0 ? void 0 : dataContextErrors[path];
|
|
469
502
|
if (!dataContextError) {
|
|
@@ -558,9 +591,9 @@ export default function useFieldProps(localProps, {
|
|
|
558
591
|
}
|
|
559
592
|
callStackRef.current = [];
|
|
560
593
|
} else {
|
|
561
|
-
return result;
|
|
594
|
+
return ensureErrorMessageObject(result);
|
|
562
595
|
}
|
|
563
|
-
}, [additionalArgs, hasBeenCalledRef]);
|
|
596
|
+
}, [additionalArgs, hasBeenCalledRef, ensureErrorMessageObject]);
|
|
564
597
|
const callValidatorFnSync = useCallback((validator, value = valueRef.current) => {
|
|
565
598
|
if (typeof validator !== 'function') {
|
|
566
599
|
return;
|
|
@@ -594,9 +627,9 @@ export default function useFieldProps(localProps, {
|
|
|
594
627
|
}
|
|
595
628
|
callStackRef.current = [];
|
|
596
629
|
} else {
|
|
597
|
-
return result;
|
|
630
|
+
return ensureErrorMessageObject(result);
|
|
598
631
|
}
|
|
599
|
-
}, [additionalArgs, callValidatorFnAsync, hasBeenCalledRef]);
|
|
632
|
+
}, [additionalArgs, callValidatorFnAsync, hasBeenCalledRef, ensureErrorMessageObject]);
|
|
600
633
|
const stateId = useId();
|
|
601
634
|
const persistErrorState = useCallback((method, initiator, errorArg = undefined) => {
|
|
602
635
|
var _errorMethodRef$curre, _errorMethodRef$curre2;
|
|
@@ -815,7 +848,7 @@ export default function useFieldProps(localProps, {
|
|
|
815
848
|
}
|
|
816
849
|
const value = valueRef.current;
|
|
817
850
|
changeEventResultRef.current = null;
|
|
818
|
-
|
|
851
|
+
validatedValueRef.current = null;
|
|
819
852
|
let initiator = null;
|
|
820
853
|
try {
|
|
821
854
|
const requiredError = transformers.current.validateRequired(value, {
|
|
@@ -828,6 +861,10 @@ export default function useFieldProps(localProps, {
|
|
|
828
861
|
initiator = 'required';
|
|
829
862
|
throw requiredError;
|
|
830
863
|
}
|
|
864
|
+
if (error instanceof Error) {
|
|
865
|
+
initiator = 'errorProp';
|
|
866
|
+
throw error;
|
|
867
|
+
}
|
|
831
868
|
if (value !== undefined && !prioritizeContextSchema && typeof schemaValidatorRef.current === 'function') {
|
|
832
869
|
if (!schemaValidatorRef.current(value)) {
|
|
833
870
|
const error = ajvErrorsToOneFormError(schemaValidatorRef.current.errors, value);
|
|
@@ -856,13 +893,13 @@ export default function useFieldProps(localProps, {
|
|
|
856
893
|
if (isProcessActive()) {
|
|
857
894
|
clearErrorState();
|
|
858
895
|
}
|
|
859
|
-
|
|
896
|
+
validatedValueRef.current = value;
|
|
860
897
|
} catch (error) {
|
|
861
898
|
if (isProcessActive()) {
|
|
862
899
|
persistErrorState('weak', initiator, error);
|
|
863
900
|
}
|
|
864
901
|
}
|
|
865
|
-
}, [clearErrorState, disabled, emptyValue, hideError, persistErrorState, prioritizeContextSchema, required, setFieldState, startOnBlurValidatorProcess, startOnChangeValidatorValidation, startProcess, validateInitially, validateUnchanged]);
|
|
902
|
+
}, [clearErrorState, disabled, emptyValue, error, hideError, persistErrorState, prioritizeContextSchema, required, setFieldState, startOnBlurValidatorProcess, startOnChangeValidatorValidation, startProcess, validateInitially, validateUnchanged]);
|
|
866
903
|
const removeError = useCallback(() => {
|
|
867
904
|
setChanged(false);
|
|
868
905
|
hideError();
|
|
@@ -930,7 +967,7 @@ export default function useFieldProps(localProps, {
|
|
|
930
967
|
withStates,
|
|
931
968
|
hasValue
|
|
932
969
|
}) => {
|
|
933
|
-
const hasMatchingValue = hasValue ===
|
|
970
|
+
const hasMatchingValue = hasValue === validatedValueRef.current;
|
|
934
971
|
const result = (typeof hasValue === 'undefined' ? false : !hasMatchingValue) || (processName ? processName === asyncProcessRef.current : true) && (withStates === null || withStates === void 0 ? void 0 : withStates.some(state => {
|
|
935
972
|
return state === fieldStateRef.current;
|
|
936
973
|
}));
|