@canonical/react-ds-global-form 0.47.0 → 0.49.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/README.md +5 -6
- package/dist/esm/density.css +40 -79
- package/dist/esm/index.css +39 -22
- package/dist/esm/lib/{component → _work_in_progress/component}/ColorField/ColorField.js +2 -2
- package/dist/esm/lib/_work_in_progress/component/ColorField/ColorField.js.map +1 -0
- package/dist/esm/lib/_work_in_progress/component/ColorField/index.js.map +1 -0
- package/dist/esm/lib/_work_in_progress/component/ColorField/types.js.map +1 -0
- package/dist/esm/lib/{component → _work_in_progress/component}/ComboboxField/ComboboxField.js +2 -2
- package/dist/esm/lib/_work_in_progress/component/ComboboxField/ComboboxField.js.map +1 -0
- package/dist/esm/lib/_work_in_progress/component/ComboboxField/index.js.map +1 -0
- package/dist/esm/lib/_work_in_progress/component/ComboboxField/types.js.map +1 -0
- package/dist/esm/lib/{component → _work_in_progress/component}/RatingField/RatingField.js +2 -2
- package/dist/esm/lib/_work_in_progress/component/RatingField/RatingField.js.map +1 -0
- package/dist/esm/lib/_work_in_progress/component/RatingField/index.js.map +1 -0
- package/dist/esm/lib/_work_in_progress/component/RatingField/types.js.map +1 -0
- package/dist/esm/lib/_work_in_progress/subcomponent/ColorInput/ColorInput.js.map +1 -0
- package/dist/esm/lib/_work_in_progress/subcomponent/ColorInput/index.js.map +1 -0
- package/dist/esm/lib/_work_in_progress/subcomponent/ColorInput/types.js.map +1 -0
- package/dist/esm/lib/_work_in_progress/subcomponent/ComboboxInput/ComboboxInput.js.map +1 -0
- package/dist/esm/lib/_work_in_progress/subcomponent/ComboboxInput/MultipleCombobox.js +199 -0
- package/dist/esm/lib/_work_in_progress/subcomponent/ComboboxInput/MultipleCombobox.js.map +1 -0
- package/dist/esm/lib/_work_in_progress/subcomponent/ComboboxInput/SingleCombobox.js +120 -0
- package/dist/esm/lib/_work_in_progress/subcomponent/ComboboxInput/SingleCombobox.js.map +1 -0
- package/dist/esm/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/common/List/List.js +16 -4
- package/dist/esm/lib/_work_in_progress/subcomponent/ComboboxInput/common/List/List.js.map +1 -0
- package/dist/esm/lib/_work_in_progress/subcomponent/ComboboxInput/common/List/index.js.map +1 -0
- package/dist/esm/lib/_work_in_progress/subcomponent/ComboboxInput/common/List/types.js.map +1 -0
- package/dist/esm/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/common/ResetButton/ResetButton.js +3 -3
- package/dist/esm/lib/_work_in_progress/subcomponent/ComboboxInput/common/ResetButton/ResetButton.js.map +1 -0
- package/dist/esm/lib/_work_in_progress/subcomponent/ComboboxInput/common/ResetButton/index.js.map +1 -0
- package/dist/esm/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/common/ResetButton/styles.css +3 -0
- package/dist/esm/lib/_work_in_progress/subcomponent/ComboboxInput/common/ResetButton/types.js.map +1 -0
- package/dist/esm/lib/_work_in_progress/subcomponent/ComboboxInput/common/index.js.map +1 -0
- package/dist/esm/lib/_work_in_progress/subcomponent/ComboboxInput/constants.js.map +1 -0
- package/dist/esm/lib/_work_in_progress/subcomponent/ComboboxInput/index.js.map +1 -0
- package/dist/esm/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/messages.js +1 -0
- package/dist/esm/lib/_work_in_progress/subcomponent/ComboboxInput/messages.js.map +1 -0
- package/dist/esm/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/styles.css +1 -2
- package/dist/esm/lib/_work_in_progress/subcomponent/ComboboxInput/types.js.map +1 -0
- package/dist/esm/lib/_work_in_progress/subcomponent/ComboboxInput/utils/convertItemToString.js.map +1 -0
- package/dist/esm/lib/_work_in_progress/subcomponent/ComboboxInput/utils/convertValueToItem.js.map +1 -0
- package/dist/esm/lib/_work_in_progress/subcomponent/ComboboxInput/utils/filterItems.js.map +1 -0
- package/dist/esm/lib/_work_in_progress/subcomponent/ComboboxInput/utils/index.js +7 -0
- package/dist/esm/lib/_work_in_progress/subcomponent/ComboboxInput/utils/index.js.map +1 -0
- package/dist/esm/lib/_work_in_progress/subcomponent/ComboboxInput/utils/isPromise.js +6 -0
- package/dist/esm/lib/_work_in_progress/subcomponent/ComboboxInput/utils/isPromise.js.map +1 -0
- package/dist/esm/lib/_work_in_progress/subcomponent/ComboboxInput/utils/settleLookup.js +10 -0
- package/dist/esm/lib/_work_in_progress/subcomponent/ComboboxInput/utils/settleLookup.js.map +1 -0
- package/dist/esm/lib/_work_in_progress/subcomponent/ComboboxInput/utils/stopPageMovesAtEnds.js +25 -0
- package/dist/esm/lib/_work_in_progress/subcomponent/ComboboxInput/utils/stopPageMovesAtEnds.js.map +1 -0
- package/dist/esm/lib/_work_in_progress/subcomponent/RatingInput/RatingInput.js.map +1 -0
- package/dist/esm/lib/_work_in_progress/subcomponent/RatingInput/index.js.map +1 -0
- package/dist/esm/lib/{subcomponent → _work_in_progress/subcomponent}/RatingInput/styles.css +7 -7
- package/dist/esm/lib/_work_in_progress/subcomponent/RatingInput/types.js.map +1 -0
- package/dist/esm/lib/common/Wrapper/InvisibleWrapper.js +3 -1
- package/dist/esm/lib/common/Wrapper/InvisibleWrapper.js.map +1 -1
- package/dist/esm/lib/common/Wrapper/ToggleWrapper.css +0 -6
- package/dist/esm/lib/common/Wrapper/ToggleWrapper.js +2 -1
- package/dist/esm/lib/common/Wrapper/ToggleWrapper.js.map +1 -1
- package/dist/esm/lib/common/Wrapper/Wrapper.js +10 -6
- package/dist/esm/lib/common/Wrapper/Wrapper.js.map +1 -1
- package/dist/esm/lib/common/Wrapper/createMiddleware.js +70 -0
- package/dist/esm/lib/common/Wrapper/createMiddleware.js.map +1 -0
- package/dist/esm/lib/common/Wrapper/hooks/useFieldWrapper.js +2 -2
- package/dist/esm/lib/common/Wrapper/hooks/useFieldWrapper.js.map +1 -1
- package/dist/esm/lib/common/Wrapper/withConditionalDisplay.js +17 -12
- package/dist/esm/lib/common/Wrapper/withConditionalDisplay.js.map +1 -1
- package/dist/esm/lib/common/Wrapper/withWrapper.js +16 -10
- package/dist/esm/lib/common/Wrapper/withWrapper.js.map +1 -1
- package/dist/esm/lib/component/ChoicesField/Choices.js +2 -2
- package/dist/esm/lib/component/ChoicesField/Choices.js.map +1 -1
- package/dist/esm/lib/component/ChoicesField/ChoicesField.js +3 -2
- package/dist/esm/lib/component/ChoicesField/ChoicesField.js.map +1 -1
- package/dist/esm/lib/component/ChoicesField/styles.css +3 -65
- package/dist/esm/lib/component/DateTimeField/DateTimeField.js +2 -1
- package/dist/esm/lib/component/DateTimeField/DateTimeField.js.map +1 -1
- package/dist/esm/lib/component/FileUploadField/FileUploadField.js +45 -41
- package/dist/esm/lib/component/FileUploadField/FileUploadField.js.map +1 -1
- package/dist/esm/lib/component/FileUploadField/fileUploadRules.js +39 -0
- package/dist/esm/lib/component/FileUploadField/fileUploadRules.js.map +1 -0
- package/dist/esm/lib/component/FileUploadField/styles.css +30 -0
- package/dist/esm/lib/component/RichChoicesField/RichChoices.js +2 -2
- package/dist/esm/lib/component/RichChoicesField/RichChoices.js.map +1 -1
- package/dist/esm/lib/component/RichChoicesField/RichChoicesField.js +2 -2
- package/dist/esm/lib/component/index.js +5 -4
- package/dist/esm/lib/component/index.js.map +1 -1
- package/dist/esm/lib/index.js.map +1 -1
- package/dist/esm/lib/pattern/Field/Field.js +3 -3
- package/dist/esm/lib/pattern/Field/Field.js.map +1 -1
- package/dist/esm/lib/subcomponent/DateInput/styles.css +16 -0
- package/dist/esm/lib/subcomponent/DateTimeInput/styles.css +24 -7
- package/dist/esm/lib/subcomponent/Field/Description/Description.js +1 -3
- package/dist/esm/lib/subcomponent/Field/Description/Description.js.map +1 -1
- package/dist/esm/lib/subcomponent/Field/Description/styles.css +4 -0
- package/dist/esm/lib/subcomponent/Field/Error/Error.js +4 -4
- package/dist/esm/lib/subcomponent/Field/Error/Error.js.map +1 -1
- package/dist/esm/lib/subcomponent/Field/Error/styles.css +8 -0
- package/dist/esm/lib/subcomponent/Field/Label/styles.css +1 -0
- package/dist/esm/lib/subcomponent/FileUploadInput/FileUploadInput.js +119 -64
- package/dist/esm/lib/subcomponent/FileUploadInput/FileUploadInput.js.map +1 -1
- package/dist/esm/lib/subcomponent/FileUploadInput/common/FileItem/FileItem.js +52 -0
- package/dist/esm/lib/subcomponent/FileUploadInput/common/FileItem/FileItem.js.map +1 -0
- package/dist/esm/lib/subcomponent/FileUploadInput/common/FileItem/index.js +2 -0
- package/dist/esm/lib/subcomponent/FileUploadInput/common/FileItem/index.js.map +1 -0
- package/dist/esm/lib/subcomponent/FileUploadInput/common/FileItem/types.js +2 -0
- package/dist/esm/lib/subcomponent/FileUploadInput/common/FileItem/types.js.map +1 -0
- package/dist/esm/lib/subcomponent/FileUploadInput/common/Thumbnail/Thumbnail.js +40 -0
- package/dist/esm/lib/subcomponent/FileUploadInput/common/Thumbnail/Thumbnail.js.map +1 -0
- package/dist/esm/lib/subcomponent/FileUploadInput/common/Thumbnail/index.js +2 -0
- package/dist/esm/lib/subcomponent/FileUploadInput/common/Thumbnail/index.js.map +1 -0
- package/dist/esm/lib/subcomponent/FileUploadInput/common/Thumbnail/types.js +2 -0
- package/dist/esm/lib/subcomponent/FileUploadInput/common/Thumbnail/types.js.map +1 -0
- package/dist/esm/lib/subcomponent/FileUploadInput/constants.js +3 -0
- package/dist/esm/lib/subcomponent/FileUploadInput/constants.js.map +1 -0
- package/dist/esm/lib/subcomponent/FileUploadInput/hooks/index.js +3 -0
- package/dist/esm/lib/subcomponent/FileUploadInput/hooks/index.js.map +1 -0
- package/dist/esm/lib/subcomponent/FileUploadInput/hooks/useFileUploads.js +148 -0
- package/dist/esm/lib/subcomponent/FileUploadInput/hooks/useFileUploads.js.map +1 -0
- package/dist/esm/lib/subcomponent/FileUploadInput/hooks/useObjectUrl.js +22 -0
- package/dist/esm/lib/subcomponent/FileUploadInput/hooks/useObjectUrl.js.map +1 -0
- package/dist/esm/lib/subcomponent/FileUploadInput/messages.js +25 -0
- package/dist/esm/lib/subcomponent/FileUploadInput/messages.js.map +1 -0
- package/dist/esm/lib/subcomponent/FileUploadInput/styles.css +255 -94
- package/dist/esm/lib/subcomponent/FileUploadInput/utils/formatFileSize.js +21 -0
- package/dist/esm/lib/subcomponent/FileUploadInput/utils/formatFileSize.js.map +1 -0
- package/dist/esm/lib/subcomponent/FileUploadInput/utils/getFileMessage.js +20 -0
- package/dist/esm/lib/subcomponent/FileUploadInput/utils/getFileMessage.js.map +1 -0
- package/dist/esm/lib/subcomponent/FileUploadInput/utils/index.js +4 -0
- package/dist/esm/lib/subcomponent/FileUploadInput/utils/index.js.map +1 -0
- package/dist/esm/lib/subcomponent/FileUploadInput/utils/matchesAccept.js +26 -0
- package/dist/esm/lib/subcomponent/FileUploadInput/utils/matchesAccept.js.map +1 -0
- package/dist/esm/lib/subcomponent/NumberInput/NumberInput.js +1 -1
- package/dist/esm/lib/subcomponent/NumberInput/NumberInput.js.map +1 -1
- package/dist/esm/lib/subcomponent/NumberInput/styles.css +17 -0
- package/dist/esm/lib/subcomponent/PasswordInput/styles.css +7 -1
- package/dist/esm/lib/subcomponent/PhoneInput/PhoneInput.js +8 -2
- package/dist/esm/lib/subcomponent/PhoneInput/PhoneInput.js.map +1 -1
- package/dist/esm/lib/subcomponent/RadioInput/styles.css +15 -13
- package/dist/esm/lib/subcomponent/SelectInput/SelectInput.js +3 -2
- package/dist/esm/lib/subcomponent/SelectInput/SelectInput.js.map +1 -1
- package/dist/esm/lib/subcomponent/SelectInput/styles.css +39 -48
- package/dist/esm/lib/subcomponent/TextInput/TextInput.js +3 -1
- package/dist/esm/lib/subcomponent/TextInput/TextInput.js.map +1 -1
- package/dist/esm/lib/subcomponent/index.js +5 -5
- package/dist/esm/lib/subcomponent/index.js.map +1 -1
- package/dist/esm/lib/utils/hooks/useFieldAriaProperties.js +6 -4
- package/dist/esm/lib/utils/hooks/useFieldAriaProperties.js.map +1 -1
- package/dist/esm/lib/utils/hooks/useOptionAriaProperties.js +3 -3
- package/dist/esm/lib/utils/hooks/useOptionAriaProperties.js.map +1 -1
- package/dist/esm/lib/utils/middleware/addRESTOptions.js +99 -39
- package/dist/esm/lib/utils/middleware/addRESTOptions.js.map +1 -1
- package/dist/esm/lib/utils/middleware/addRESTValidation.js +246 -32
- package/dist/esm/lib/utils/middleware/addRESTValidation.js.map +1 -1
- package/dist/esm/lib/utils/middleware/index.js +1 -0
- package/dist/esm/lib/utils/middleware/index.js.map +1 -1
- package/dist/esm/testing/expectNoAxeViolations.js +30 -0
- package/dist/esm/testing/expectNoAxeViolations.js.map +1 -0
- package/dist/types/lib/{component → _work_in_progress/component}/ColorField/ColorField.d.ts +7 -12
- package/dist/types/lib/_work_in_progress/component/ColorField/ColorField.d.ts.map +1 -0
- package/dist/types/lib/_work_in_progress/component/ColorField/index.d.ts.map +1 -0
- package/dist/types/lib/{component → _work_in_progress/component}/ColorField/types.d.ts +1 -1
- package/dist/types/lib/_work_in_progress/component/ColorField/types.d.ts.map +1 -0
- package/dist/types/lib/_work_in_progress/component/ComboboxField/ComboboxField.d.ts +53 -0
- package/dist/types/lib/_work_in_progress/component/ComboboxField/ComboboxField.d.ts.map +1 -0
- package/dist/types/lib/_work_in_progress/component/ComboboxField/index.d.ts.map +1 -0
- package/dist/types/lib/{component → _work_in_progress/component}/ComboboxField/types.d.ts +1 -1
- package/dist/types/lib/_work_in_progress/component/ComboboxField/types.d.ts.map +1 -0
- package/dist/types/lib/{component → _work_in_progress/component}/RatingField/RatingField.d.ts +7 -12
- package/dist/types/lib/_work_in_progress/component/RatingField/RatingField.d.ts.map +1 -0
- package/dist/types/lib/_work_in_progress/component/RatingField/index.d.ts.map +1 -0
- package/dist/types/lib/{component → _work_in_progress/component}/RatingField/types.d.ts +1 -1
- package/dist/types/lib/_work_in_progress/component/RatingField/types.d.ts.map +1 -0
- package/dist/types/lib/_work_in_progress/subcomponent/ColorInput/ColorInput.d.ts.map +1 -0
- package/dist/types/lib/_work_in_progress/subcomponent/ColorInput/index.d.ts.map +1 -0
- package/dist/types/lib/{subcomponent → _work_in_progress/subcomponent}/ColorInput/types.d.ts +1 -1
- package/dist/types/lib/_work_in_progress/subcomponent/ColorInput/types.d.ts.map +1 -0
- package/dist/types/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/ComboboxInput.d.ts +13 -5
- package/dist/types/lib/_work_in_progress/subcomponent/ComboboxInput/ComboboxInput.d.ts.map +1 -0
- package/dist/types/lib/_work_in_progress/subcomponent/ComboboxInput/MultipleCombobox.d.ts +24 -0
- package/dist/types/lib/_work_in_progress/subcomponent/ComboboxInput/MultipleCombobox.d.ts.map +1 -0
- package/dist/types/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/SingleCombobox.d.ts +19 -4
- package/dist/types/lib/_work_in_progress/subcomponent/ComboboxInput/SingleCombobox.d.ts.map +1 -0
- package/dist/types/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/common/List/List.d.ts +1 -1
- package/dist/types/lib/_work_in_progress/subcomponent/ComboboxInput/common/List/List.d.ts.map +1 -0
- package/dist/types/lib/_work_in_progress/subcomponent/ComboboxInput/common/List/index.d.ts.map +1 -0
- package/dist/types/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/common/List/types.d.ts +2 -1
- package/dist/types/lib/_work_in_progress/subcomponent/ComboboxInput/common/List/types.d.ts.map +1 -0
- package/dist/types/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/common/ResetButton/ResetButton.d.ts +1 -1
- package/dist/types/lib/_work_in_progress/subcomponent/ComboboxInput/common/ResetButton/ResetButton.d.ts.map +1 -0
- package/dist/types/lib/_work_in_progress/subcomponent/ComboboxInput/common/ResetButton/index.d.ts.map +1 -0
- package/dist/types/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/common/ResetButton/types.d.ts +1 -0
- package/dist/types/lib/_work_in_progress/subcomponent/ComboboxInput/common/ResetButton/types.d.ts.map +1 -0
- package/dist/types/lib/_work_in_progress/subcomponent/ComboboxInput/common/index.d.ts.map +1 -0
- package/dist/types/lib/_work_in_progress/subcomponent/ComboboxInput/constants.d.ts.map +1 -0
- package/dist/types/lib/_work_in_progress/subcomponent/ComboboxInput/index.d.ts.map +1 -0
- package/dist/types/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/messages.d.ts +1 -0
- package/dist/types/lib/_work_in_progress/subcomponent/ComboboxInput/messages.d.ts.map +1 -0
- package/dist/types/lib/_work_in_progress/subcomponent/ComboboxInput/types.d.ts +52 -0
- package/dist/types/lib/_work_in_progress/subcomponent/ComboboxInput/types.d.ts.map +1 -0
- package/dist/types/lib/_work_in_progress/subcomponent/ComboboxInput/utils/convertItemToString.d.ts +4 -0
- package/dist/types/lib/_work_in_progress/subcomponent/ComboboxInput/utils/convertItemToString.d.ts.map +1 -0
- package/dist/types/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/utils/convertValueToItem.d.ts +1 -1
- package/dist/types/lib/_work_in_progress/subcomponent/ComboboxInput/utils/convertValueToItem.d.ts.map +1 -0
- package/dist/types/lib/_work_in_progress/subcomponent/ComboboxInput/utils/filterItems.d.ts +4 -0
- package/dist/types/lib/_work_in_progress/subcomponent/ComboboxInput/utils/filterItems.d.ts.map +1 -0
- package/dist/types/lib/_work_in_progress/subcomponent/ComboboxInput/utils/index.d.ts +7 -0
- package/dist/types/lib/_work_in_progress/subcomponent/ComboboxInput/utils/index.d.ts.map +1 -0
- package/dist/types/lib/_work_in_progress/subcomponent/ComboboxInput/utils/isPromise.d.ts +4 -0
- package/dist/types/lib/_work_in_progress/subcomponent/ComboboxInput/utils/isPromise.d.ts.map +1 -0
- package/dist/types/lib/_work_in_progress/subcomponent/ComboboxInput/utils/settleLookup.d.ts +8 -0
- package/dist/types/lib/_work_in_progress/subcomponent/ComboboxInput/utils/settleLookup.d.ts.map +1 -0
- package/dist/types/lib/_work_in_progress/subcomponent/ComboboxInput/utils/stopPageMovesAtEnds.d.ts +13 -0
- package/dist/types/lib/_work_in_progress/subcomponent/ComboboxInput/utils/stopPageMovesAtEnds.d.ts.map +1 -0
- package/dist/types/lib/_work_in_progress/subcomponent/RatingInput/RatingInput.d.ts.map +1 -0
- package/dist/types/lib/_work_in_progress/subcomponent/RatingInput/index.d.ts.map +1 -0
- package/dist/types/lib/_work_in_progress/subcomponent/RatingInput/types.d.ts.map +1 -0
- package/dist/types/lib/common/Wrapper/InvisibleWrapper.d.ts.map +1 -1
- package/dist/types/lib/common/Wrapper/ToggleWrapper.d.ts.map +1 -1
- package/dist/types/lib/common/Wrapper/Wrapper.d.ts +1 -1
- package/dist/types/lib/common/Wrapper/Wrapper.d.ts.map +1 -1
- package/dist/types/lib/common/Wrapper/createMiddleware.d.ts +43 -0
- package/dist/types/lib/common/Wrapper/createMiddleware.d.ts.map +1 -0
- package/dist/types/lib/common/Wrapper/hooks/useFieldWrapper.d.ts +2 -0
- package/dist/types/lib/common/Wrapper/hooks/useFieldWrapper.d.ts.map +1 -1
- package/dist/types/lib/common/Wrapper/withConditionalDisplay.d.ts +9 -3
- package/dist/types/lib/common/Wrapper/withConditionalDisplay.d.ts.map +1 -1
- package/dist/types/lib/common/Wrapper/withWrapper.d.ts +3 -5
- package/dist/types/lib/common/Wrapper/withWrapper.d.ts.map +1 -1
- package/dist/types/lib/common/types.d.ts +19 -7
- package/dist/types/lib/common/types.d.ts.map +1 -1
- package/dist/types/lib/component/ChoicesField/Choices.d.ts +1 -1
- package/dist/types/lib/component/ChoicesField/Choices.d.ts.map +1 -1
- package/dist/types/lib/component/ChoicesField/ChoicesField.d.ts +9 -13
- package/dist/types/lib/component/ChoicesField/ChoicesField.d.ts.map +1 -1
- package/dist/types/lib/component/ChoicesField/types.d.ts +2 -2
- package/dist/types/lib/component/ChoicesField/types.d.ts.map +1 -1
- package/dist/types/lib/component/DateField/DateField.d.ts +6 -11
- package/dist/types/lib/component/DateTimeField/DateTimeField.d.ts +7 -11
- package/dist/types/lib/component/DateTimeField/DateTimeField.d.ts.map +1 -1
- package/dist/types/lib/component/FileUploadField/FileUploadField.d.ts +299 -19
- package/dist/types/lib/component/FileUploadField/FileUploadField.d.ts.map +1 -1
- package/dist/types/lib/component/FileUploadField/fileUploadRules.d.ts +24 -0
- package/dist/types/lib/component/FileUploadField/fileUploadRules.d.ts.map +1 -0
- package/dist/types/lib/component/HiddenField/HiddenField.d.ts +6 -11
- package/dist/types/lib/component/NumberField/NumberField.d.ts +6 -11
- package/dist/types/lib/component/PasswordField/PasswordField.d.ts +6 -11
- package/dist/types/lib/component/PhoneField/PhoneField.d.ts +7 -11
- package/dist/types/lib/component/RangeField/RangeField.d.ts +6 -11
- package/dist/types/lib/component/RichChoicesField/RichChoices.d.ts +1 -1
- package/dist/types/lib/component/RichChoicesField/RichChoices.d.ts.map +1 -1
- package/dist/types/lib/component/RichChoicesField/RichChoicesField.d.ts +8 -13
- package/dist/types/lib/component/RichChoicesField/types.d.ts +2 -2
- package/dist/types/lib/component/RichChoicesField/types.d.ts.map +1 -1
- package/dist/types/lib/component/SelectField/SelectField.d.ts +6 -11
- package/dist/types/lib/component/TextField/TextField.d.ts +6 -11
- package/dist/types/lib/component/TextareaField/TextareaField.d.ts +6 -11
- package/dist/types/lib/component/TimeField/TimeField.d.ts +6 -11
- package/dist/types/lib/component/index.d.ts +3 -3
- package/dist/types/lib/component/index.d.ts.map +1 -1
- package/dist/types/lib/index.d.ts +1 -1
- package/dist/types/lib/index.d.ts.map +1 -1
- package/dist/types/lib/pattern/Field/types.d.ts +4 -4
- package/dist/types/lib/pattern/Field/types.d.ts.map +1 -1
- package/dist/types/lib/subcomponent/Field/Description/Description.d.ts.map +1 -1
- package/dist/types/lib/subcomponent/Field/Error/Error.d.ts.map +1 -1
- package/dist/types/lib/subcomponent/FileUploadInput/FileUploadInput.d.ts +25 -4
- package/dist/types/lib/subcomponent/FileUploadInput/FileUploadInput.d.ts.map +1 -1
- package/dist/types/lib/subcomponent/FileUploadInput/common/FileItem/FileItem.d.ts +15 -0
- package/dist/types/lib/subcomponent/FileUploadInput/common/FileItem/FileItem.d.ts.map +1 -0
- package/dist/types/lib/subcomponent/FileUploadInput/common/FileItem/index.d.ts +3 -0
- package/dist/types/lib/subcomponent/FileUploadInput/common/FileItem/index.d.ts.map +1 -0
- package/dist/types/lib/subcomponent/FileUploadInput/common/FileItem/types.d.ts +28 -0
- package/dist/types/lib/subcomponent/FileUploadInput/common/FileItem/types.d.ts.map +1 -0
- package/dist/types/lib/subcomponent/FileUploadInput/common/Thumbnail/Thumbnail.d.ts +14 -0
- package/dist/types/lib/subcomponent/FileUploadInput/common/Thumbnail/Thumbnail.d.ts.map +1 -0
- package/dist/types/lib/subcomponent/FileUploadInput/common/Thumbnail/index.d.ts +3 -0
- package/dist/types/lib/subcomponent/FileUploadInput/common/Thumbnail/index.d.ts.map +1 -0
- package/dist/types/lib/subcomponent/FileUploadInput/common/Thumbnail/types.d.ts +9 -0
- package/dist/types/lib/subcomponent/FileUploadInput/common/Thumbnail/types.d.ts.map +1 -0
- package/dist/types/lib/subcomponent/FileUploadInput/constants.d.ts +3 -0
- package/dist/types/lib/subcomponent/FileUploadInput/constants.d.ts.map +1 -0
- package/dist/types/lib/subcomponent/FileUploadInput/hooks/index.d.ts +3 -0
- package/dist/types/lib/subcomponent/FileUploadInput/hooks/index.d.ts.map +1 -0
- package/dist/types/lib/subcomponent/FileUploadInput/hooks/useFileUploads.d.ts +33 -0
- package/dist/types/lib/subcomponent/FileUploadInput/hooks/useFileUploads.d.ts.map +1 -0
- package/dist/types/lib/subcomponent/FileUploadInput/hooks/useObjectUrl.d.ts +8 -0
- package/dist/types/lib/subcomponent/FileUploadInput/hooks/useObjectUrl.d.ts.map +1 -0
- package/dist/types/lib/subcomponent/FileUploadInput/index.d.ts +1 -1
- package/dist/types/lib/subcomponent/FileUploadInput/index.d.ts.map +1 -1
- package/dist/types/lib/subcomponent/FileUploadInput/messages.d.ts +4 -0
- package/dist/types/lib/subcomponent/FileUploadInput/messages.d.ts.map +1 -0
- package/dist/types/lib/subcomponent/FileUploadInput/types.d.ts +165 -8
- package/dist/types/lib/subcomponent/FileUploadInput/types.d.ts.map +1 -1
- package/dist/types/lib/subcomponent/FileUploadInput/utils/formatFileSize.d.ts +7 -0
- package/dist/types/lib/subcomponent/FileUploadInput/utils/formatFileSize.d.ts.map +1 -0
- package/dist/types/lib/subcomponent/FileUploadInput/utils/getFileMessage.d.ts +14 -0
- package/dist/types/lib/subcomponent/FileUploadInput/utils/getFileMessage.d.ts.map +1 -0
- package/dist/types/lib/subcomponent/FileUploadInput/utils/index.d.ts +5 -0
- package/dist/types/lib/subcomponent/FileUploadInput/utils/index.d.ts.map +1 -0
- package/dist/types/lib/subcomponent/FileUploadInput/utils/matchesAccept.d.ts +10 -0
- package/dist/types/lib/subcomponent/FileUploadInput/utils/matchesAccept.d.ts.map +1 -0
- package/dist/types/lib/subcomponent/PhoneInput/PhoneInput.d.ts +12 -0
- package/dist/types/lib/subcomponent/PhoneInput/PhoneInput.d.ts.map +1 -1
- package/dist/types/lib/subcomponent/PhoneInput/types.d.ts +11 -2
- package/dist/types/lib/subcomponent/PhoneInput/types.d.ts.map +1 -1
- package/dist/types/lib/subcomponent/SelectInput/SelectInput.d.ts.map +1 -1
- package/dist/types/lib/subcomponent/TextInput/TextInput.d.ts +2 -0
- package/dist/types/lib/subcomponent/TextInput/TextInput.d.ts.map +1 -1
- package/dist/types/lib/subcomponent/index.d.ts +7 -7
- package/dist/types/lib/subcomponent/index.d.ts.map +1 -1
- package/dist/types/lib/subcomponent/types.d.ts +6 -0
- package/dist/types/lib/subcomponent/types.d.ts.map +1 -1
- package/dist/types/lib/utils/hooks/useFieldAriaProperties.d.ts +2 -1
- package/dist/types/lib/utils/hooks/useFieldAriaProperties.d.ts.map +1 -1
- package/dist/types/lib/utils/hooks/useOptionAriaProperties.d.ts +3 -2
- package/dist/types/lib/utils/hooks/useOptionAriaProperties.d.ts.map +1 -1
- package/dist/types/lib/utils/middleware/addRESTOptions.d.ts +37 -4
- package/dist/types/lib/utils/middleware/addRESTOptions.d.ts.map +1 -1
- package/dist/types/lib/utils/middleware/addRESTValidation.d.ts +38 -3
- package/dist/types/lib/utils/middleware/addRESTValidation.d.ts.map +1 -1
- package/dist/types/lib/utils/middleware/index.d.ts +2 -0
- package/dist/types/lib/utils/middleware/index.d.ts.map +1 -1
- package/dist/types/testing/expectNoAxeViolations.d.ts +10 -0
- package/dist/types/testing/expectNoAxeViolations.d.ts.map +1 -0
- package/package.json +21 -18
- package/dist/esm/lib/component/ColorField/ColorField.js.map +0 -1
- package/dist/esm/lib/component/ColorField/index.js.map +0 -1
- package/dist/esm/lib/component/ColorField/types.js.map +0 -1
- package/dist/esm/lib/component/ComboboxField/ComboboxField.js.map +0 -1
- package/dist/esm/lib/component/ComboboxField/index.js.map +0 -1
- package/dist/esm/lib/component/ComboboxField/types.js.map +0 -1
- package/dist/esm/lib/component/RatingField/RatingField.js.map +0 -1
- package/dist/esm/lib/component/RatingField/index.js.map +0 -1
- package/dist/esm/lib/component/RatingField/types.js.map +0 -1
- package/dist/esm/lib/subcomponent/ColorInput/ColorInput.js.map +0 -1
- package/dist/esm/lib/subcomponent/ColorInput/index.js.map +0 -1
- package/dist/esm/lib/subcomponent/ColorInput/types.js.map +0 -1
- package/dist/esm/lib/subcomponent/ComboboxInput/ComboboxInput.js.map +0 -1
- package/dist/esm/lib/subcomponent/ComboboxInput/MultipleCombobox.js +0 -84
- package/dist/esm/lib/subcomponent/ComboboxInput/MultipleCombobox.js.map +0 -1
- package/dist/esm/lib/subcomponent/ComboboxInput/SingleCombobox.js +0 -67
- package/dist/esm/lib/subcomponent/ComboboxInput/SingleCombobox.js.map +0 -1
- package/dist/esm/lib/subcomponent/ComboboxInput/common/List/List.js.map +0 -1
- package/dist/esm/lib/subcomponent/ComboboxInput/common/List/index.js.map +0 -1
- package/dist/esm/lib/subcomponent/ComboboxInput/common/List/types.js.map +0 -1
- package/dist/esm/lib/subcomponent/ComboboxInput/common/ResetButton/ResetButton.js.map +0 -1
- package/dist/esm/lib/subcomponent/ComboboxInput/common/ResetButton/index.js.map +0 -1
- package/dist/esm/lib/subcomponent/ComboboxInput/common/ResetButton/types.js.map +0 -1
- package/dist/esm/lib/subcomponent/ComboboxInput/common/index.js.map +0 -1
- package/dist/esm/lib/subcomponent/ComboboxInput/constants.js.map +0 -1
- package/dist/esm/lib/subcomponent/ComboboxInput/index.js.map +0 -1
- package/dist/esm/lib/subcomponent/ComboboxInput/messages.js.map +0 -1
- package/dist/esm/lib/subcomponent/ComboboxInput/types.js.map +0 -1
- package/dist/esm/lib/subcomponent/ComboboxInput/utils/convertItemToString.js.map +0 -1
- package/dist/esm/lib/subcomponent/ComboboxInput/utils/convertValueToItem.js.map +0 -1
- package/dist/esm/lib/subcomponent/ComboboxInput/utils/filterItems.js.map +0 -1
- package/dist/esm/lib/subcomponent/ComboboxInput/utils/index.js +0 -4
- package/dist/esm/lib/subcomponent/ComboboxInput/utils/index.js.map +0 -1
- package/dist/esm/lib/subcomponent/RatingInput/RatingInput.js.map +0 -1
- package/dist/esm/lib/subcomponent/RatingInput/index.js.map +0 -1
- package/dist/esm/lib/subcomponent/RatingInput/types.js.map +0 -1
- package/dist/types/lib/component/ColorField/ColorField.d.ts.map +0 -1
- package/dist/types/lib/component/ColorField/index.d.ts.map +0 -1
- package/dist/types/lib/component/ColorField/types.d.ts.map +0 -1
- package/dist/types/lib/component/ComboboxField/ComboboxField.d.ts +0 -56
- package/dist/types/lib/component/ComboboxField/ComboboxField.d.ts.map +0 -1
- package/dist/types/lib/component/ComboboxField/index.d.ts.map +0 -1
- package/dist/types/lib/component/ComboboxField/types.d.ts.map +0 -1
- package/dist/types/lib/component/RatingField/RatingField.d.ts.map +0 -1
- package/dist/types/lib/component/RatingField/index.d.ts.map +0 -1
- package/dist/types/lib/component/RatingField/types.d.ts.map +0 -1
- package/dist/types/lib/subcomponent/ColorInput/ColorInput.d.ts.map +0 -1
- package/dist/types/lib/subcomponent/ColorInput/index.d.ts.map +0 -1
- package/dist/types/lib/subcomponent/ColorInput/types.d.ts.map +0 -1
- package/dist/types/lib/subcomponent/ComboboxInput/ComboboxInput.d.ts.map +0 -1
- package/dist/types/lib/subcomponent/ComboboxInput/MultipleCombobox.d.ts +0 -16
- package/dist/types/lib/subcomponent/ComboboxInput/MultipleCombobox.d.ts.map +0 -1
- package/dist/types/lib/subcomponent/ComboboxInput/SingleCombobox.d.ts.map +0 -1
- package/dist/types/lib/subcomponent/ComboboxInput/common/List/List.d.ts.map +0 -1
- package/dist/types/lib/subcomponent/ComboboxInput/common/List/index.d.ts.map +0 -1
- package/dist/types/lib/subcomponent/ComboboxInput/common/List/types.d.ts.map +0 -1
- package/dist/types/lib/subcomponent/ComboboxInput/common/ResetButton/ResetButton.d.ts.map +0 -1
- package/dist/types/lib/subcomponent/ComboboxInput/common/ResetButton/index.d.ts.map +0 -1
- package/dist/types/lib/subcomponent/ComboboxInput/common/ResetButton/types.d.ts.map +0 -1
- package/dist/types/lib/subcomponent/ComboboxInput/common/index.d.ts.map +0 -1
- package/dist/types/lib/subcomponent/ComboboxInput/constants.d.ts.map +0 -1
- package/dist/types/lib/subcomponent/ComboboxInput/index.d.ts.map +0 -1
- package/dist/types/lib/subcomponent/ComboboxInput/messages.d.ts.map +0 -1
- package/dist/types/lib/subcomponent/ComboboxInput/types.d.ts +0 -27
- package/dist/types/lib/subcomponent/ComboboxInput/types.d.ts.map +0 -1
- package/dist/types/lib/subcomponent/ComboboxInput/utils/convertItemToString.d.ts +0 -4
- package/dist/types/lib/subcomponent/ComboboxInput/utils/convertItemToString.d.ts.map +0 -1
- package/dist/types/lib/subcomponent/ComboboxInput/utils/convertValueToItem.d.ts.map +0 -1
- package/dist/types/lib/subcomponent/ComboboxInput/utils/filterItems.d.ts +0 -4
- package/dist/types/lib/subcomponent/ComboboxInput/utils/filterItems.d.ts.map +0 -1
- package/dist/types/lib/subcomponent/ComboboxInput/utils/index.d.ts +0 -4
- package/dist/types/lib/subcomponent/ComboboxInput/utils/index.d.ts.map +0 -1
- package/dist/types/lib/subcomponent/RatingInput/RatingInput.d.ts.map +0 -1
- package/dist/types/lib/subcomponent/RatingInput/index.d.ts.map +0 -1
- package/dist/types/lib/subcomponent/RatingInput/types.d.ts.map +0 -1
- /package/dist/esm/lib/{component → _work_in_progress/component}/ColorField/index.js +0 -0
- /package/dist/esm/lib/{component → _work_in_progress/component}/ColorField/types.js +0 -0
- /package/dist/esm/lib/{component → _work_in_progress/component}/ComboboxField/index.js +0 -0
- /package/dist/esm/lib/{component → _work_in_progress/component}/ComboboxField/types.js +0 -0
- /package/dist/esm/lib/{component → _work_in_progress/component}/RatingField/index.js +0 -0
- /package/dist/esm/lib/{component → _work_in_progress/component}/RatingField/types.js +0 -0
- /package/dist/esm/lib/{subcomponent → _work_in_progress/subcomponent}/ColorInput/ColorInput.js +0 -0
- /package/dist/esm/lib/{subcomponent → _work_in_progress/subcomponent}/ColorInput/index.js +0 -0
- /package/dist/esm/lib/{subcomponent → _work_in_progress/subcomponent}/ColorInput/styles.css +0 -0
- /package/dist/esm/lib/{subcomponent → _work_in_progress/subcomponent}/ColorInput/types.js +0 -0
- /package/dist/esm/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/ComboboxInput.js +0 -0
- /package/dist/esm/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/common/List/index.js +0 -0
- /package/dist/esm/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/common/List/styles.css +0 -0
- /package/dist/esm/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/common/List/types.js +0 -0
- /package/dist/esm/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/common/ResetButton/index.js +0 -0
- /package/dist/esm/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/common/ResetButton/types.js +0 -0
- /package/dist/esm/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/common/index.js +0 -0
- /package/dist/esm/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/constants.js +0 -0
- /package/dist/esm/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/index.js +0 -0
- /package/dist/esm/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/types.js +0 -0
- /package/dist/esm/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/utils/convertItemToString.js +0 -0
- /package/dist/esm/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/utils/convertValueToItem.js +0 -0
- /package/dist/esm/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/utils/filterItems.js +0 -0
- /package/dist/esm/lib/{subcomponent → _work_in_progress/subcomponent}/RatingInput/RatingInput.js +0 -0
- /package/dist/esm/lib/{subcomponent → _work_in_progress/subcomponent}/RatingInput/index.js +0 -0
- /package/dist/esm/lib/{subcomponent → _work_in_progress/subcomponent}/RatingInput/types.js +0 -0
- /package/dist/types/lib/{component → _work_in_progress/component}/ColorField/index.d.ts +0 -0
- /package/dist/types/lib/{component → _work_in_progress/component}/ComboboxField/index.d.ts +0 -0
- /package/dist/types/lib/{component → _work_in_progress/component}/RatingField/index.d.ts +0 -0
- /package/dist/types/lib/{subcomponent → _work_in_progress/subcomponent}/ColorInput/ColorInput.d.ts +0 -0
- /package/dist/types/lib/{subcomponent → _work_in_progress/subcomponent}/ColorInput/index.d.ts +0 -0
- /package/dist/types/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/common/List/index.d.ts +0 -0
- /package/dist/types/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/common/ResetButton/index.d.ts +0 -0
- /package/dist/types/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/common/index.d.ts +0 -0
- /package/dist/types/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/constants.d.ts +0 -0
- /package/dist/types/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/index.d.ts +0 -0
- /package/dist/types/lib/{subcomponent → _work_in_progress/subcomponent}/RatingInput/RatingInput.d.ts +0 -0
- /package/dist/types/lib/{subcomponent → _work_in_progress/subcomponent}/RatingInput/index.d.ts +0 -0
- /package/dist/types/lib/{subcomponent → _work_in_progress/subcomponent}/RatingInput/types.d.ts +0 -0
|
@@ -1,44 +1,104 @@
|
|
|
1
|
-
import { createElement, useEffect, useState } from "react";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
1
|
+
import { createElement, useEffect, useEffectEvent, useState, } from "react";
|
|
2
|
+
import { useFormContext } from "react-hook-form";
|
|
3
|
+
import createMiddleware, {} from "../../common/Wrapper/createMiddleware.js";
|
|
4
|
+
/** The error type the middleware sets, so it only ever clears its own error. */
|
|
5
|
+
const REST_OPTIONS_ERROR_TYPE = "restOptions";
|
|
6
|
+
/** The options of a field before, or without, a successful request. */
|
|
7
|
+
const NO_OPTIONS = [];
|
|
8
|
+
/** Reads a displayable message from whatever a failed request rejected with. */
|
|
9
|
+
const readErrorMessage = (error) => error instanceof Error ? error.message : String(error);
|
|
10
|
+
/**
|
|
11
|
+
* Requests the options and transforms the body.
|
|
12
|
+
* @note Impure: performs a network request.
|
|
13
|
+
*/
|
|
14
|
+
const requestOptions = async (url, { method, headers, transform }, signal) => {
|
|
15
|
+
const response = await fetch(url, { method, headers, signal });
|
|
16
|
+
if (!response.ok) {
|
|
17
|
+
throw new Error("Failed to fetch options");
|
|
18
|
+
}
|
|
19
|
+
return transform(await response.json());
|
|
20
|
+
};
|
|
21
|
+
/** Builds the component that fetches the options and passes them on. */
|
|
22
|
+
const buildRESTOptions = (WrappedComponent, useSettings) => {
|
|
23
|
+
function WithRESTOptions(props) {
|
|
24
|
+
const { name } = props;
|
|
25
|
+
const settings = useSettings();
|
|
26
|
+
const { url } = settings;
|
|
27
|
+
const { setError, clearErrors, getFieldState } = useFormContext();
|
|
28
|
+
const [status, setStatus] = useState("loading");
|
|
29
|
+
const [fetchedOptions, setFetchedOptions] = useState(NO_OPTIONS);
|
|
30
|
+
// The request reads the newest method, headers and transform, but only a
|
|
31
|
+
// new URL starts one.
|
|
32
|
+
const fetchOptions = useEffectEvent((requestUrl, signal) => requestOptions(requestUrl, settings, signal));
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
const controller = new AbortController();
|
|
35
|
+
/** Clears the field's error when this middleware set it. */
|
|
36
|
+
const clearOwnError = () => {
|
|
37
|
+
if (getFieldState(name).error?.type === REST_OPTIONS_ERROR_TYPE) {
|
|
38
|
+
clearErrors(name);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
// The failure of the previous URL is part of its answer: drop it too.
|
|
42
|
+
clearOwnError();
|
|
43
|
+
setStatus("loading");
|
|
44
|
+
setFetchedOptions(NO_OPTIONS);
|
|
45
|
+
fetchOptions(url, controller.signal)
|
|
46
|
+
.then((result) => {
|
|
47
|
+
if (controller.signal.aborted)
|
|
48
|
+
return;
|
|
49
|
+
setFetchedOptions(result);
|
|
50
|
+
setStatus("ready");
|
|
51
|
+
clearOwnError();
|
|
52
|
+
})
|
|
53
|
+
.catch((error) => {
|
|
54
|
+
if (controller.signal.aborted)
|
|
55
|
+
return;
|
|
56
|
+
setStatus("failed");
|
|
57
|
+
setError(name, {
|
|
58
|
+
type: REST_OPTIONS_ERROR_TYPE,
|
|
59
|
+
message: readErrorMessage(error),
|
|
28
60
|
});
|
|
29
|
-
}, []);
|
|
30
|
-
if (loading) {
|
|
31
|
-
return createElement("div", null, "Loading options...");
|
|
32
|
-
}
|
|
33
|
-
if (error) {
|
|
34
|
-
return createElement("div", null, `Error: ${error}`);
|
|
35
|
-
}
|
|
36
|
-
return createElement(WrappedComponent, {
|
|
37
|
-
...props,
|
|
38
|
-
options: optionsData,
|
|
39
61
|
});
|
|
40
|
-
|
|
41
|
-
|
|
62
|
+
return () => controller.abort();
|
|
63
|
+
}, [url, name, setError, clearErrors, getFieldState]);
|
|
64
|
+
const isLoading = status === "loading";
|
|
65
|
+
return createElement(WrappedComponent, {
|
|
66
|
+
...props,
|
|
67
|
+
options: fetchedOptions,
|
|
68
|
+
disabled: props.disabled || isLoading,
|
|
69
|
+
"aria-busy": isLoading || undefined,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
return WithRESTOptions;
|
|
73
|
+
};
|
|
74
|
+
const configureRESTOptions = createMiddleware(buildRESTOptions);
|
|
75
|
+
/**
|
|
76
|
+
* Fetches a field's options from a REST endpoint and passes them as the
|
|
77
|
+
* `options` prop.
|
|
78
|
+
*
|
|
79
|
+
* The field keeps its normal markup in every state. While loading it is
|
|
80
|
+
* disabled, marked `aria-busy`, and has no options. A failed request is set as
|
|
81
|
+
* the field's error, so it shows where the field shows any other error, and
|
|
82
|
+
* leaves the field enabled. The middleware can be created inline: the field
|
|
83
|
+
* keeps one instance, which fetches again only when the URL changes, and
|
|
84
|
+
* drops the answer for the previous URL, its error included. The request is
|
|
85
|
+
* aborted when the field unmounts. Use one per field: an inner instance's
|
|
86
|
+
* options replace the outer one's.
|
|
87
|
+
*
|
|
88
|
+
* @param url - The endpoint returning the options.
|
|
89
|
+
* @param options - Request and transform options.
|
|
90
|
+
* @returns A middleware for any field that takes `options`.
|
|
91
|
+
*
|
|
92
|
+
* `import { addRESTOptions } from "@canonical/react-ds-global-form";`
|
|
93
|
+
*/
|
|
94
|
+
function addRESTFieldOptions(url, options = {}) {
|
|
95
|
+
const { method = "GET", headers = {}, transformData } = options;
|
|
96
|
+
return configureRESTOptions({
|
|
97
|
+
url,
|
|
98
|
+
method,
|
|
99
|
+
headers,
|
|
100
|
+
transform: (data) => transformData ? transformData(data) : data,
|
|
101
|
+
});
|
|
42
102
|
}
|
|
43
103
|
export default addRESTFieldOptions;
|
|
44
104
|
//# sourceMappingURL=addRESTOptions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addRESTOptions.js","sourceRoot":"","sources":["../../../../../src/lib/utils/middleware/addRESTOptions.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"addRESTOptions.js","sourceRoot":"","sources":["../../../../../src/lib/utils/middleware/addRESTOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,aAAa,EACb,SAAS,EACT,cAAc,EACd,QAAQ,GACT,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEjD,OAAO,gBAAgB,EAAE,EAGxB,MAAM,0CAA0C,CAAC;AAGlD,gFAAgF;AAChF,MAAM,uBAAuB,GAAG,aAAa,CAAC;AAiC9C,uEAAuE;AACvE,MAAM,UAAU,GAAa,EAAE,CAAC;AAEhC,gFAAgF;AAChF,MAAM,gBAAgB,GAAG,CAAC,KAAc,EAAU,EAAE,CAClD,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAEzD;;;GAGG;AACH,MAAM,cAAc,GAAG,KAAK,EAC1B,GAAW,EACX,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAmB,EAC/C,MAAmB,EACA,EAAE;IACrB,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;IAC/D,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACjB,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;IACD,OAAO,SAAS,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;AAC1C,CAAC,CAAC;AAEF,wEAAwE;AACxE,MAAM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AAE,IAAiB;KACnE,CAAC,CAAC;AACL,CAAC;AAED,eAAe,mBAAmB,CAAC"}
|
|
@@ -1,38 +1,252 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
1
|
+
import { createElement, useEffect, useEffectEvent, useRef, } from "react";
|
|
2
|
+
import { useFormContext, useWatch, } from "react-hook-form";
|
|
3
|
+
import createMiddleware, {} from "../../common/Wrapper/createMiddleware.js";
|
|
4
|
+
/**
|
|
5
|
+
* The error type the middleware sets, and the name of the `validate` rule it
|
|
6
|
+
* registers, so it only ever clears its own error.
|
|
7
|
+
*/
|
|
8
|
+
const REST_VALIDATION_ERROR_TYPE = "restValidation";
|
|
9
|
+
/** The message shown when the endpoint rejects a value without a readable one. */
|
|
10
|
+
const DEFAULT_ERROR_MESSAGE = "Validation failed";
|
|
11
|
+
const VALID = { kind: "valid" };
|
|
12
|
+
const NO_ANSWER = { kind: "none" };
|
|
13
|
+
/** Reads the message of an error set by a REST check, if it is one. */
|
|
14
|
+
const readRESTMessage = (error) => error?.type === REST_VALIDATION_ERROR_TYPE ? error.message : undefined;
|
|
15
|
+
/** Whether a value is long enough, and a string, to be sent. */
|
|
16
|
+
const isCheckable = (value, minLength) => typeof value === "string" && value.length >= minLength;
|
|
17
|
+
/**
|
|
18
|
+
* Reads the message of a rejected value, falling back to the default when
|
|
19
|
+
* `errorExtractor` cannot read the response, so the value still shows as
|
|
20
|
+
* rejected.
|
|
21
|
+
*/
|
|
22
|
+
const readErrorMessage = async (response, errorExtractor) => {
|
|
23
|
+
try {
|
|
24
|
+
return await errorExtractor(response);
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
return DEFAULT_ERROR_MESSAGE;
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Sends the value and reads the endpoint's answer. A request that fails to
|
|
32
|
+
* complete says nothing about the value. An aborted request's answer is never
|
|
33
|
+
* read: `startCheck` settles the check before it aborts the request.
|
|
34
|
+
* @note Impure: performs a network request.
|
|
35
|
+
*/
|
|
36
|
+
const requestAnswer = async (url, value, { method, headers, bodyFormatter, errorExtractor }, signal) => {
|
|
37
|
+
try {
|
|
38
|
+
const response = await fetch(url, {
|
|
39
|
+
method,
|
|
40
|
+
headers,
|
|
41
|
+
body: JSON.stringify(bodyFormatter(value)),
|
|
42
|
+
signal,
|
|
43
|
+
});
|
|
44
|
+
if (response.ok)
|
|
45
|
+
return VALID;
|
|
46
|
+
const message = await readErrorMessage(response, errorExtractor);
|
|
47
|
+
return { kind: "invalid", message };
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
return NO_ANSWER;
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Starts a check that sends the value once `debounceWait` has passed, and
|
|
55
|
+
* gives up on the request after `timeout`.
|
|
56
|
+
* @note Impure: schedules timers and a network request.
|
|
57
|
+
*/
|
|
58
|
+
const startCheck = (url, value, settings) => {
|
|
59
|
+
const controller = new AbortController();
|
|
60
|
+
let settle;
|
|
61
|
+
const answer = new Promise((resolve) => {
|
|
62
|
+
settle = resolve;
|
|
63
|
+
});
|
|
64
|
+
let requestTimer;
|
|
65
|
+
const cancel = () => {
|
|
66
|
+
clearTimeout(debounceTimer);
|
|
67
|
+
clearTimeout(requestTimer);
|
|
68
|
+
settle(NO_ANSWER);
|
|
69
|
+
controller.abort();
|
|
70
|
+
};
|
|
71
|
+
const debounceTimer = setTimeout(() => {
|
|
72
|
+
requestTimer = setTimeout(cancel, settings.timeout);
|
|
73
|
+
requestAnswer(url, value, settings, controller.signal).then((result) => {
|
|
74
|
+
clearTimeout(requestTimer);
|
|
75
|
+
settle(result);
|
|
76
|
+
});
|
|
77
|
+
}, settings.debounceWait);
|
|
78
|
+
return { url, value, answer, cancel };
|
|
79
|
+
};
|
|
80
|
+
/** Whether a `validate` rule's result lets the value through. */
|
|
81
|
+
const isPassing = (result) => result === true || result === undefined || result === null;
|
|
82
|
+
/**
|
|
83
|
+
* Runs two `validate` rules together and returns the first failure, so a
|
|
84
|
+
* second REST check on the field keeps the first one under the same name.
|
|
85
|
+
*/
|
|
86
|
+
const combineRules = (first, second) => async (value, formValues) => {
|
|
87
|
+
const [firstResult, secondResult] = await Promise.all([
|
|
88
|
+
first(value, formValues),
|
|
89
|
+
second(value, formValues),
|
|
90
|
+
]);
|
|
91
|
+
return isPassing(firstResult) ? secondResult : firstResult;
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* Adds a rule to the field's `validate` rules, keeping the rules it has. A
|
|
95
|
+
* single `validate` function stays under the `validate` name, the error type
|
|
96
|
+
* react-hook-form gives it. A `restValidation` rule already there, from
|
|
97
|
+
* another REST check on the field, runs together with the new one.
|
|
98
|
+
*/
|
|
99
|
+
const addValidateRule = (registerProps, rule) => {
|
|
100
|
+
const validate = registerProps?.validate;
|
|
101
|
+
const rules = typeof validate === "function" ? { validate } : validate;
|
|
102
|
+
const previous = rules?.[REST_VALIDATION_ERROR_TYPE];
|
|
103
|
+
return {
|
|
104
|
+
...registerProps,
|
|
105
|
+
validate: {
|
|
106
|
+
...rules,
|
|
107
|
+
[REST_VALIDATION_ERROR_TYPE]: previous
|
|
108
|
+
? combineRules(previous, rule)
|
|
109
|
+
: rule,
|
|
110
|
+
},
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
/** Builds the component that checks the value and owns the REST error. */
|
|
114
|
+
const buildRESTValidation = (WrappedComponent, useSettings) => {
|
|
115
|
+
function WithRESTValidation(props) {
|
|
116
|
+
const { name } = props;
|
|
117
|
+
const settings = useSettings();
|
|
118
|
+
const { url } = settings;
|
|
119
|
+
const { setError, clearErrors, getFieldState } = useFormContext();
|
|
120
|
+
const value = useWatch({ name });
|
|
121
|
+
const pending = useRef(null);
|
|
122
|
+
// The message this instance last gave, so a second REST check on the
|
|
123
|
+
// field cannot clear or keep the other one's message. A REST message left
|
|
124
|
+
// from before the field mounted is adopted, so it can still be cleared.
|
|
125
|
+
const ownMessage = useRef(readRESTMessage(getFieldState(name).error));
|
|
126
|
+
/** Reads the field's error message when this instance set it. */
|
|
127
|
+
const readOwnMessage = () => {
|
|
128
|
+
const message = readRESTMessage(getFieldState(name).error);
|
|
129
|
+
return message === ownMessage.current ? message : undefined;
|
|
130
|
+
};
|
|
131
|
+
/** Clears the field's error when this instance set it. */
|
|
132
|
+
const clearOwnError = () => {
|
|
133
|
+
if (readOwnMessage() !== undefined)
|
|
134
|
+
clearErrors(name);
|
|
135
|
+
ownMessage.current = undefined;
|
|
136
|
+
};
|
|
137
|
+
/** Sets the endpoint's rejection as the field's error. */
|
|
138
|
+
const setOwnError = (message) => {
|
|
139
|
+
ownMessage.current = message;
|
|
140
|
+
setError(name, { type: REST_VALIDATION_ERROR_TYPE, message });
|
|
141
|
+
};
|
|
142
|
+
/** Stops the pending check, if any. */
|
|
143
|
+
const cancelPending = () => {
|
|
144
|
+
pending.current?.cancel();
|
|
145
|
+
pending.current = null;
|
|
146
|
+
};
|
|
147
|
+
/**
|
|
148
|
+
* Resolves to the answer for a value, sharing the pending check when it is
|
|
149
|
+
* for the same value and URL, so typing and submitting send one request.
|
|
150
|
+
* A newer value cancels the previous check, so only the answer for the
|
|
151
|
+
* latest value is ever used. A check that got no answer is dropped, so the
|
|
152
|
+
* next one asks again.
|
|
153
|
+
*/
|
|
154
|
+
const check = (checkUrl, checkValue) => {
|
|
155
|
+
const current = pending.current;
|
|
156
|
+
if (current?.url === checkUrl && current.value === checkValue) {
|
|
157
|
+
return current.answer;
|
|
158
|
+
}
|
|
159
|
+
cancelPending();
|
|
160
|
+
const next = startCheck(checkUrl, checkValue, settings);
|
|
161
|
+
pending.current = next;
|
|
162
|
+
next.answer.then((answer) => {
|
|
163
|
+
if (answer.kind === "none" && pending.current === next) {
|
|
164
|
+
pending.current = null;
|
|
23
165
|
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
166
|
+
});
|
|
167
|
+
return next.answer;
|
|
168
|
+
};
|
|
169
|
+
/**
|
|
170
|
+
* The `validate` rule react-hook-form runs, on submit among others, so a
|
|
171
|
+
* value the endpoint rejected cannot be submitted. Without an answer it
|
|
172
|
+
* keeps the message this middleware last set.
|
|
173
|
+
*/
|
|
174
|
+
const validateRemotely = async (fieldValue) => {
|
|
175
|
+
if (!isCheckable(fieldValue, settings.minLength))
|
|
176
|
+
return true;
|
|
177
|
+
const answer = await check(url, fieldValue);
|
|
178
|
+
if (answer.kind === "valid") {
|
|
179
|
+
ownMessage.current = undefined;
|
|
180
|
+
return true;
|
|
181
|
+
}
|
|
182
|
+
if (answer.kind === "invalid") {
|
|
183
|
+
ownMessage.current = answer.message;
|
|
184
|
+
return answer.message;
|
|
185
|
+
}
|
|
186
|
+
return readOwnMessage() || true;
|
|
187
|
+
};
|
|
188
|
+
const followValue = useEffectEvent((nextValue, nextUrl) => {
|
|
189
|
+
if (!isCheckable(nextValue, settings.minLength)) {
|
|
190
|
+
cancelPending();
|
|
191
|
+
clearOwnError();
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
check(nextUrl, nextValue).then((answer) => {
|
|
195
|
+
if (answer.kind === "valid") {
|
|
196
|
+
clearOwnError();
|
|
28
197
|
}
|
|
29
|
-
else {
|
|
30
|
-
|
|
198
|
+
else if (answer.kind === "invalid") {
|
|
199
|
+
setOwnError(answer.message);
|
|
31
200
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
};
|
|
35
|
-
|
|
201
|
+
// A check without an answer leaves the field's error as it is.
|
|
202
|
+
});
|
|
203
|
+
});
|
|
204
|
+
useEffect(() => followValue(value, url), [value, url]);
|
|
205
|
+
useEffect(() => () => {
|
|
206
|
+
pending.current?.cancel();
|
|
207
|
+
pending.current = null;
|
|
208
|
+
}, []);
|
|
209
|
+
return createElement(WrappedComponent, {
|
|
210
|
+
...props,
|
|
211
|
+
registerProps: addValidateRule(props.registerProps, validateRemotely),
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
return WithRESTValidation;
|
|
215
|
+
};
|
|
216
|
+
const configureRESTValidation = createMiddleware(buildRESTValidation);
|
|
217
|
+
/**
|
|
218
|
+
* Validates a field's value against a REST endpoint once the user stops
|
|
219
|
+
* typing, and sets the field's error when the endpoint rejects it.
|
|
220
|
+
*
|
|
221
|
+
* The check is also registered as the field's `restValidation` rule, so
|
|
222
|
+
* submitting re-checks the value and a rejected value blocks the submit. Each
|
|
223
|
+
* change cancels the pending timer and aborts the request in flight, so only
|
|
224
|
+
* the answer for the latest value can set or clear the error; unmounting the
|
|
225
|
+
* field does the same. A request that fails to complete keeps the previous
|
|
226
|
+
* message, and a request still unanswered after `timeout` is given up. It
|
|
227
|
+
* only clears the error it set, so an error from the field's own rules or
|
|
228
|
+
* another middleware stays in place. Two instances on one field each keep
|
|
229
|
+
* their own message, and submit runs both checks. The middleware can be
|
|
230
|
+
* created inline: the field keeps one instance.
|
|
231
|
+
*
|
|
232
|
+
* @param url - The endpoint validating the value.
|
|
233
|
+
* @param options - Request, debounce and error options.
|
|
234
|
+
* @returns A middleware for any field.
|
|
235
|
+
*
|
|
236
|
+
* `import { addRESTValidation } from "@canonical/react-ds-global-form";`
|
|
237
|
+
*/
|
|
238
|
+
function addRESTFieldValidation(url, options = {}) {
|
|
239
|
+
const { method = "POST", headers = { "Content-Type": "application/json" }, bodyFormatter = (value) => ({ value }), errorExtractor = () => DEFAULT_ERROR_MESSAGE, minLength = 3, debounceWait = 300, timeout = 10000, } = options;
|
|
240
|
+
return configureRESTValidation({
|
|
241
|
+
url,
|
|
242
|
+
method,
|
|
243
|
+
headers,
|
|
244
|
+
bodyFormatter,
|
|
245
|
+
errorExtractor,
|
|
246
|
+
minLength,
|
|
247
|
+
debounceWait,
|
|
248
|
+
timeout,
|
|
249
|
+
});
|
|
36
250
|
}
|
|
37
251
|
export default addRESTFieldValidation;
|
|
38
252
|
//# sourceMappingURL=addRESTValidation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addRESTValidation.js","sourceRoot":"","sources":["../../../../../src/lib/utils/middleware/addRESTValidation.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"addRESTValidation.js","sourceRoot":"","sources":["../../../../../src/lib/utils/middleware/addRESTValidation.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,aAAa,EACb,SAAS,EACT,cAAc,EACd,MAAM,GACP,MAAM,OAAO,CAAC;AACf,OAAO,EAIL,cAAc,EACd,QAAQ,GAET,MAAM,iBAAiB,CAAC;AAEzB,OAAO,gBAAgB,EAAE,EAGxB,MAAM,0CAA0C,CAAC;AAyBlD;;;GAGG;AACH,MAAM,0BAA0B,GAAG,gBAAgB,CAAC;AAEpD,kFAAkF;AAClF,MAAM,qBAAqB,GAAG,mBAAmB,CAAC;AAWlD,MAAM,KAAK,GAAW,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AACxC,MAAM,SAAS,GAAW,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;AAiB3C,uEAAuE;AACvE,MAAM,eAAe,GAAG,CAAC,KAA6B,EAAsB,EAAE,CAC5E,KAAK,EAAE,IAAI,KAAK,0BAA0B,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC;AAEzE,gEAAgE;AAChE,MAAM,WAAW,GAAG,CAAC,KAAc,EAAE,SAAiB,EAAmB,EAAE,CACzE,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,IAAI,SAAS,CAAC;AAEzD;;;;GAIG;AACH,MAAM,gBAAgB,GAAG,KAAK,EAC5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/middleware/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/lib/utils/middleware/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AACvF,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import axe from "axe-core";
|
|
2
|
+
import { expect } from "vitest";
|
|
3
|
+
/**
|
|
4
|
+
* The WCAG 2.x A and AA rules, and nothing a page-level or layout rule adds:
|
|
5
|
+
* a component renders a fragment, not a page with landmarks, and jsdom lays
|
|
6
|
+
* nothing out, so a contrast result here would be a guess.
|
|
7
|
+
*/
|
|
8
|
+
const RULES = {
|
|
9
|
+
runOnly: {
|
|
10
|
+
type: "tag",
|
|
11
|
+
values: ["wcag2a", "wcag2aa", "wcag21a", "wcag21aa", "wcag22aa"],
|
|
12
|
+
},
|
|
13
|
+
rules: { "color-contrast": { enabled: false } },
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Asserts that axe finds no violation in a rendered element, naming every
|
|
17
|
+
* rule it breaks and where, so a failure reads as the finding itself.
|
|
18
|
+
*
|
|
19
|
+
* Necessary evidence, not a conformance claim: axe checks what markup can
|
|
20
|
+
* prove, and says nothing of keyboard journeys or what a screen reader
|
|
21
|
+
* announces.
|
|
22
|
+
*/
|
|
23
|
+
export default async function expectNoAxeViolations(element) {
|
|
24
|
+
const results = await axe.run(element, RULES);
|
|
25
|
+
expect(results.violations.map((violation) => ({
|
|
26
|
+
rule: violation.id,
|
|
27
|
+
targets: violation.nodes.map((node) => node.target.join(" ")),
|
|
28
|
+
}))).toEqual([]);
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=expectNoAxeViolations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"expectNoAxeViolations.js","sourceRoot":"","sources":["../../../src/testing/expectNoAxeViolations.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,UAAU,CAAC;AAC3B,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC;;;;GAIG;AACH,MAAM,KAAK,GAAmB;IAC5B,OAAO,EAAE;QACP,IAAI,EAAE,KAAK;QACX,MAAM,EAAE,CAAC,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,CAAC;KACjE;IACD,KAAK,EAAE,EAAE,gBAAgB,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE;CAChD,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,qBAAqB,CACjD,OAAgB;IAEhB,MAAM,OAAO,GAAG,MAAM,GAAG,CAAC,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IAC9C,MAAM,CACJ,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;QACrC,IAAI,EAAE,SAAS,CAAC,EAAE;QAClB,OAAO,EAAE,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;KAC9D,CAAC,CAAC,CACJ,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;AAChB,CAAC"}
|
|
@@ -6,7 +6,7 @@ import type { ColorFieldProps } from "./types.js";
|
|
|
6
6
|
*
|
|
7
7
|
* @implements ds:global.component.color_field
|
|
8
8
|
*/
|
|
9
|
-
declare const _default: (
|
|
9
|
+
declare const _default: import("react").ComponentType<{
|
|
10
10
|
id?: string;
|
|
11
11
|
className?: string;
|
|
12
12
|
style?: React.CSSProperties;
|
|
@@ -21,17 +21,14 @@ declare const _default: (props: {
|
|
|
21
21
|
controlLabel?: string;
|
|
22
22
|
labelPosition?: "before" | "after";
|
|
23
23
|
isOptional?: boolean;
|
|
24
|
-
requiredIndicator?: import("
|
|
24
|
+
requiredIndicator?: import("../../../subcomponent/index.js").RequiredIndicator;
|
|
25
|
+
descriptionPosition?: "leading" | "trailing";
|
|
25
26
|
nestedRegisterProps?: import("react-hook-form").RegisterOptions;
|
|
26
27
|
unregisterOnUnmount?: boolean;
|
|
27
28
|
mockLabel?: boolean;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
WrapperComponent?: (import("react").ComponentType<import("../../index.js").WrapperProps<ColorFieldProps>> & import("react").ComponentType<import("../../index.js").WrapperProps<Omit<import("../../index.js").WrappedComponentProps<ColorFieldProps>, "Component"> & {
|
|
32
|
-
condition?: import("../../index.js").Condition;
|
|
33
|
-
}>>) | undefined;
|
|
34
|
-
condition?: import("../../index.js").Condition;
|
|
29
|
+
errorSlot?: "payload" | "input";
|
|
30
|
+
middleware?: import("../../../index.js").Middleware<ColorFieldProps>[] | undefined;
|
|
31
|
+
WrapperComponent?: import("react").ComponentType<import("../../../index.js").WrapperProps<ColorFieldProps>> | undefined;
|
|
35
32
|
value?: string;
|
|
36
33
|
onChange?: (value: string) => void;
|
|
37
34
|
disabled?: boolean;
|
|
@@ -39,8 +36,6 @@ declare const _default: (props: {
|
|
|
39
36
|
showHexInput?: boolean;
|
|
40
37
|
showCurrentColor?: boolean;
|
|
41
38
|
hexFormats?: import("../../subcomponent/ColorInput/types.js").HexFormat[];
|
|
42
|
-
}
|
|
43
|
-
condition?: import("../../index.js").Condition;
|
|
44
|
-
}, string | import("react").JSXElementConstructor<any>> | null;
|
|
39
|
+
} & import("../../../index.js").ConditionalDisplayProps>;
|
|
45
40
|
export default _default;
|
|
46
41
|
//# sourceMappingURL=ColorField.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ColorField.d.ts","sourceRoot":"","sources":["../../../../../../src/lib/_work_in_progress/component/ColorField/ColorField.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD;;;;;;GAMG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/lib/_work_in_progress/component/ColorField/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,iBAAiB,CAAC;AACxD,YAAY,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { InputProps } from "
|
|
1
|
+
import type { InputProps } from "../../../common/types.js";
|
|
2
2
|
import type { ColorInputProps } from "../../subcomponent/ColorInput/index.js";
|
|
3
3
|
/** Props for the react-hook-form-bound Color field. */
|
|
4
4
|
export type ColorFieldProps = InputProps<ColorInputProps>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../src/lib/_work_in_progress/component/ColorField/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAC;AAE9E,uDAAuD;AACvD,MAAM,MAAM,eAAe,GAAG,UAAU,CAAC,eAAe,CAAC,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { ComboboxFieldProps } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* ComboboxInput bound to react-hook-form (controlled), wrapped with field chrome.
|
|
4
|
+
* The single composite value is owned by the field; the presentational
|
|
5
|
+
* ComboboxInput decomposes it across its input/list/chips internally.
|
|
6
|
+
*
|
|
7
|
+
* `import { ComboboxField } from "@canonical/react-ds-global-form";`
|
|
8
|
+
*
|
|
9
|
+
* @implements ds:global.component.combobox_field
|
|
10
|
+
*/
|
|
11
|
+
declare const _default: import("react").ComponentType<{
|
|
12
|
+
"aria-label"?: string | undefined;
|
|
13
|
+
"aria-required"?: ("false" | "true" | boolean) | undefined;
|
|
14
|
+
id?: string;
|
|
15
|
+
className?: string;
|
|
16
|
+
style?: React.CSSProperties;
|
|
17
|
+
options: import("../../../index.js").Option[];
|
|
18
|
+
name: string;
|
|
19
|
+
registerProps?: import("react-hook-form").RegisterOptions;
|
|
20
|
+
"aria-labelledby"?: string;
|
|
21
|
+
"aria-describedby"?: string;
|
|
22
|
+
"aria-errormessage"?: string;
|
|
23
|
+
"aria-invalid"?: boolean;
|
|
24
|
+
description?: string;
|
|
25
|
+
label?: string;
|
|
26
|
+
controlLabel?: string;
|
|
27
|
+
labelPosition?: "before" | "after";
|
|
28
|
+
isOptional?: boolean;
|
|
29
|
+
requiredIndicator?: import("../../../subcomponent/index.js").RequiredIndicator;
|
|
30
|
+
descriptionPosition?: "leading" | "trailing";
|
|
31
|
+
nestedRegisterProps?: import("react-hook-form").RegisterOptions;
|
|
32
|
+
unregisterOnUnmount?: boolean;
|
|
33
|
+
mockLabel?: boolean;
|
|
34
|
+
errorSlot?: "payload" | "input";
|
|
35
|
+
middleware?: import("../../../index.js").Middleware<ComboboxFieldProps>[] | undefined;
|
|
36
|
+
WrapperComponent?: import("react").ComponentType<import("../../../index.js").WrapperProps<ComboboxFieldProps>> | undefined;
|
|
37
|
+
value?: string | string[];
|
|
38
|
+
onChange?: (value: string | string[] | undefined) => void;
|
|
39
|
+
onBlur?: () => void;
|
|
40
|
+
disabled?: boolean;
|
|
41
|
+
placeholder?: string;
|
|
42
|
+
valueKey?: keyof import("../../../index.js").Option;
|
|
43
|
+
openOnReset?: boolean;
|
|
44
|
+
isMultiple?: boolean;
|
|
45
|
+
filterItems?: (options: import("../../../index.js").Option[], inputValue: string) => import("../../../index.js").Option[];
|
|
46
|
+
convertItemToString?: typeof import("../../subcomponent/ComboboxInput/utils/convertItemToString.js").default;
|
|
47
|
+
convertValueToItem?: import("../../subcomponent/ComboboxInput/types.js").ConvertValueToItem;
|
|
48
|
+
onInputValueChangeFactory?: (setItems: React.Dispatch<React.SetStateAction<import("../../../index.js").Option[]>>) => ({ inputValue }: {
|
|
49
|
+
inputValue: string;
|
|
50
|
+
}) => void;
|
|
51
|
+
} & import("../../../index.js").ConditionalDisplayProps>;
|
|
52
|
+
export default _default;
|
|
53
|
+
//# sourceMappingURL=ComboboxField.d.ts.map
|