@canonical/svelte-ds-global-form 0.0.0-stage → 0.48.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +166 -0
- package/README.md +260 -2
- package/dist/_work_in_progress/DensityTestbed/SPIKE.md +198 -0
- package/dist/_work_in_progress/DensityTestbed/baseline-system.css +88 -0
- package/dist/_work_in_progress/DensityTestbed/density.testbed.css +157 -0
- package/dist/_work_in_progress/component/ColorField/ColorField.svelte +21 -0
- package/dist/_work_in_progress/component/ColorField/ColorField.svelte.d.ts +12 -0
- package/dist/_work_in_progress/component/ColorField/index.d.ts +2 -0
- package/dist/_work_in_progress/component/ColorField/index.js +1 -0
- package/dist/_work_in_progress/component/ColorField/types.d.ts +7 -0
- package/dist/_work_in_progress/component/ColorField/types.js +1 -0
- package/dist/_work_in_progress/component/ComboboxField/ComboboxField.svelte +23 -0
- package/dist/_work_in_progress/component/ComboboxField/ComboboxField.svelte.d.ts +14 -0
- package/dist/_work_in_progress/component/ComboboxField/index.d.ts +2 -0
- package/dist/_work_in_progress/component/ComboboxField/index.js +1 -0
- package/dist/_work_in_progress/component/ComboboxField/types.d.ts +7 -0
- package/dist/_work_in_progress/component/ComboboxField/types.js +1 -0
- package/dist/_work_in_progress/component/RatingField/RatingField.svelte +26 -0
- package/dist/_work_in_progress/component/RatingField/RatingField.svelte.d.ts +11 -0
- package/dist/_work_in_progress/component/RatingField/index.d.ts +2 -0
- package/dist/_work_in_progress/component/RatingField/index.js +1 -0
- package/dist/_work_in_progress/component/RatingField/types.d.ts +7 -0
- package/dist/_work_in_progress/component/RatingField/types.js +1 -0
- package/dist/_work_in_progress/index.d.ts +6 -0
- package/dist/_work_in_progress/index.js +7 -0
- package/dist/_work_in_progress/subcomponent/ColorInput/ColorInput.svelte +111 -0
- package/dist/_work_in_progress/subcomponent/ColorInput/ColorInput.svelte.d.ts +13 -0
- package/dist/_work_in_progress/subcomponent/ColorInput/constants.d.ts +5 -0
- package/dist/_work_in_progress/subcomponent/ColorInput/constants.js +23 -0
- package/dist/_work_in_progress/subcomponent/ColorInput/index.d.ts +2 -0
- package/dist/_work_in_progress/subcomponent/ColorInput/index.js +1 -0
- package/dist/_work_in_progress/subcomponent/ColorInput/styles.css +204 -0
- package/dist/_work_in_progress/subcomponent/ColorInput/types.d.ts +24 -0
- package/dist/_work_in_progress/subcomponent/ColorInput/types.js +1 -0
- package/dist/_work_in_progress/subcomponent/ComboboxInput/ComboboxInput.svelte +29 -0
- package/dist/_work_in_progress/subcomponent/ComboboxInput/ComboboxInput.svelte.d.ts +15 -0
- package/dist/_work_in_progress/subcomponent/ComboboxInput/MultipleCombobox.svelte +254 -0
- package/dist/_work_in_progress/subcomponent/ComboboxInput/MultipleCombobox.svelte.d.ts +23 -0
- package/dist/_work_in_progress/subcomponent/ComboboxInput/SingleCombobox.svelte +157 -0
- package/dist/_work_in_progress/subcomponent/ComboboxInput/SingleCombobox.svelte.d.ts +19 -0
- package/dist/_work_in_progress/subcomponent/ComboboxInput/common/List/List.svelte +54 -0
- package/dist/_work_in_progress/subcomponent/ComboboxInput/common/List/List.svelte.d.ts +9 -0
- package/dist/_work_in_progress/subcomponent/ComboboxInput/common/List/index.d.ts +2 -0
- package/dist/_work_in_progress/subcomponent/ComboboxInput/common/List/index.js +1 -0
- package/dist/_work_in_progress/subcomponent/ComboboxInput/common/List/styles.css +41 -0
- package/dist/_work_in_progress/subcomponent/ComboboxInput/common/List/types.d.ts +40 -0
- package/dist/_work_in_progress/subcomponent/ComboboxInput/common/List/types.js +1 -0
- package/dist/_work_in_progress/subcomponent/ComboboxInput/common/ResetButton/ResetButton.svelte +23 -0
- package/dist/_work_in_progress/subcomponent/ComboboxInput/common/ResetButton/ResetButton.svelte.d.ts +9 -0
- package/dist/_work_in_progress/subcomponent/ComboboxInput/common/ResetButton/index.d.ts +2 -0
- package/dist/_work_in_progress/subcomponent/ComboboxInput/common/ResetButton/index.js +1 -0
- package/dist/_work_in_progress/subcomponent/ComboboxInput/common/ResetButton/styles.css +28 -0
- package/dist/_work_in_progress/subcomponent/ComboboxInput/common/ResetButton/types.d.ts +19 -0
- package/dist/_work_in_progress/subcomponent/ComboboxInput/common/ResetButton/types.js +1 -0
- package/dist/_work_in_progress/subcomponent/ComboboxInput/common/index.d.ts +2 -0
- package/dist/_work_in_progress/subcomponent/ComboboxInput/common/index.js +2 -0
- package/dist/_work_in_progress/subcomponent/ComboboxInput/constants.d.ts +2 -0
- package/dist/_work_in_progress/subcomponent/ComboboxInput/constants.js +2 -0
- package/dist/_work_in_progress/subcomponent/ComboboxInput/createCombobox.svelte.d.ts +148 -0
- package/dist/_work_in_progress/subcomponent/ComboboxInput/createCombobox.svelte.js +414 -0
- package/dist/_work_in_progress/subcomponent/ComboboxInput/createMultipleSelection.svelte.d.ts +48 -0
- package/dist/_work_in_progress/subcomponent/ComboboxInput/createMultipleSelection.svelte.js +147 -0
- package/dist/_work_in_progress/subcomponent/ComboboxInput/index.d.ts +2 -0
- package/dist/_work_in_progress/subcomponent/ComboboxInput/index.js +1 -0
- package/dist/_work_in_progress/subcomponent/ComboboxInput/messages.d.ts +5 -0
- package/dist/_work_in_progress/subcomponent/ComboboxInput/messages.js +4 -0
- package/dist/_work_in_progress/subcomponent/ComboboxInput/styles.css +73 -0
- package/dist/_work_in_progress/subcomponent/ComboboxInput/types.d.ts +55 -0
- package/dist/_work_in_progress/subcomponent/ComboboxInput/types.js +1 -0
- package/dist/_work_in_progress/subcomponent/ComboboxInput/utils/convertItemToString.d.ts +3 -0
- package/dist/_work_in_progress/subcomponent/ComboboxInput/utils/convertItemToString.js +4 -0
- package/dist/_work_in_progress/subcomponent/ComboboxInput/utils/convertValueToItem.d.ts +3 -0
- package/dist/_work_in_progress/subcomponent/ComboboxInput/utils/convertValueToItem.js +5 -0
- package/dist/_work_in_progress/subcomponent/ComboboxInput/utils/filterItems.d.ts +3 -0
- package/dist/_work_in_progress/subcomponent/ComboboxInput/utils/filterItems.js +5 -0
- package/dist/_work_in_progress/subcomponent/ComboboxInput/utils/getHighlightedIndex.d.ts +11 -0
- package/dist/_work_in_progress/subcomponent/ComboboxInput/utils/getHighlightedIndex.js +22 -0
- package/dist/_work_in_progress/subcomponent/ComboboxInput/utils/index.d.ts +6 -0
- package/dist/_work_in_progress/subcomponent/ComboboxInput/utils/index.js +6 -0
- package/dist/_work_in_progress/subcomponent/ComboboxInput/utils/isPromise.d.ts +2 -0
- package/dist/_work_in_progress/subcomponent/ComboboxInput/utils/isPromise.js +4 -0
- package/dist/_work_in_progress/subcomponent/ComboboxInput/utils/settleLookup.d.ts +7 -0
- package/dist/_work_in_progress/subcomponent/ComboboxInput/utils/settleLookup.js +9 -0
- package/dist/_work_in_progress/subcomponent/RatingInput/RatingInput.svelte +76 -0
- package/dist/_work_in_progress/subcomponent/RatingInput/RatingInput.svelte.d.ts +13 -0
- package/dist/_work_in_progress/subcomponent/RatingInput/index.d.ts +2 -0
- package/dist/_work_in_progress/subcomponent/RatingInput/index.js +1 -0
- package/dist/_work_in_progress/subcomponent/RatingInput/styles.css +163 -0
- package/dist/_work_in_progress/subcomponent/RatingInput/types.d.ts +30 -0
- package/dist/_work_in_progress/subcomponent/RatingInput/types.js +1 -0
- package/dist/common/Adornment/Adornment.svelte +11 -0
- package/dist/common/Adornment/Adornment.svelte.d.ts +8 -0
- package/dist/common/Wrapper/ToggleWrapper.css +77 -0
- package/dist/common/Wrapper/ToggleWrapper.svelte +75 -0
- package/dist/common/Wrapper/ToggleWrapper.svelte.d.ts +11 -0
- package/dist/common/Wrapper/Wrapper.svelte +72 -0
- package/dist/common/Wrapper/Wrapper.svelte.d.ts +12 -0
- package/dist/common/Wrapper/createControlProps.d.ts +9 -0
- package/dist/common/Wrapper/createControlProps.js +21 -0
- package/dist/common/Wrapper/index.d.ts +3 -0
- package/dist/common/Wrapper/index.js +3 -0
- package/dist/common/Wrapper/styles.css +41 -0
- package/dist/common/constants.d.ts +6 -0
- package/dist/common/constants.js +6 -0
- package/dist/common/index.d.ts +3 -0
- package/dist/common/index.js +3 -0
- package/dist/common/splitChromeProps.d.ts +17 -0
- package/dist/common/splitChromeProps.js +38 -0
- package/dist/common/types.d.ts +99 -0
- package/dist/common/types.js +1 -0
- package/dist/common/useConditionalDisplay.svelte.d.ts +13 -0
- package/dist/common/useConditionalDisplay.svelte.js +32 -0
- package/dist/common/useNativeValidity.svelte.d.ts +18 -0
- package/dist/common/useNativeValidity.svelte.js +66 -0
- package/dist/component/CheckboxField/CheckboxField.svelte +20 -0
- package/dist/component/CheckboxField/CheckboxField.svelte.d.ts +11 -0
- package/dist/component/CheckboxField/index.d.ts +2 -0
- package/dist/component/CheckboxField/index.js +1 -0
- package/dist/component/CheckboxField/types.d.ts +10 -0
- package/dist/component/CheckboxField/types.js +1 -0
- package/dist/component/ChoicesField/Choices.svelte +61 -0
- package/dist/component/ChoicesField/Choices.svelte.d.ts +9 -0
- package/dist/component/ChoicesField/ChoicesField.svelte +23 -0
- package/dist/component/ChoicesField/ChoicesField.svelte.d.ts +13 -0
- package/dist/component/ChoicesField/common/Option/Option.svelte +33 -0
- package/dist/component/ChoicesField/common/Option/Option.svelte.d.ts +8 -0
- package/dist/component/ChoicesField/common/Option/index.d.ts +2 -0
- package/dist/component/ChoicesField/common/Option/index.js +1 -0
- package/dist/component/ChoicesField/common/Option/types.d.ts +13 -0
- package/dist/component/ChoicesField/common/Option/types.js +1 -0
- package/dist/component/ChoicesField/common/index.d.ts +1 -0
- package/dist/component/ChoicesField/common/index.js +1 -0
- package/dist/component/ChoicesField/index.d.ts +3 -0
- package/dist/component/ChoicesField/index.js +2 -0
- package/dist/component/ChoicesField/isChoiceChecked.d.ts +5 -0
- package/dist/component/ChoicesField/isChoiceChecked.js +9 -0
- package/dist/component/ChoicesField/styles.css +162 -0
- package/dist/component/ChoicesField/toggleChoice.d.ts +7 -0
- package/dist/component/ChoicesField/toggleChoice.js +13 -0
- package/dist/component/ChoicesField/types.d.ts +37 -0
- package/dist/component/ChoicesField/types.js +1 -0
- package/dist/component/DateField/DateField.svelte +20 -0
- package/dist/component/DateField/DateField.svelte.d.ts +11 -0
- package/dist/component/DateField/index.d.ts +2 -0
- package/dist/component/DateField/index.js +1 -0
- package/dist/component/DateField/types.d.ts +7 -0
- package/dist/component/DateField/types.js +1 -0
- package/dist/component/DateTimeField/DateTimeField.svelte +21 -0
- package/dist/component/DateTimeField/DateTimeField.svelte.d.ts +11 -0
- package/dist/component/DateTimeField/index.d.ts +2 -0
- package/dist/component/DateTimeField/index.js +1 -0
- package/dist/component/DateTimeField/types.d.ts +7 -0
- package/dist/component/DateTimeField/types.js +1 -0
- package/dist/component/FileUploadField/FileUploadField.svelte +92 -0
- package/dist/component/FileUploadField/FileUploadField.svelte.d.ts +20 -0
- package/dist/component/FileUploadField/findFileUploadError.d.ts +21 -0
- package/dist/component/FileUploadField/findFileUploadError.js +28 -0
- package/dist/component/FileUploadField/index.d.ts +2 -0
- package/dist/component/FileUploadField/index.js +1 -0
- package/dist/component/FileUploadField/styles.css +30 -0
- package/dist/component/FileUploadField/types.d.ts +9 -0
- package/dist/component/FileUploadField/types.js +1 -0
- package/dist/component/HiddenField/HiddenField.svelte +31 -0
- package/dist/component/HiddenField/HiddenField.svelte.d.ts +12 -0
- package/dist/component/HiddenField/index.d.ts +2 -0
- package/dist/component/HiddenField/index.js +1 -0
- package/dist/component/HiddenField/types.d.ts +13 -0
- package/dist/component/HiddenField/types.js +1 -0
- package/dist/component/NumberField/NumberField.svelte +20 -0
- package/dist/component/NumberField/NumberField.svelte.d.ts +11 -0
- package/dist/component/NumberField/index.d.ts +2 -0
- package/dist/component/NumberField/index.js +1 -0
- package/dist/component/NumberField/types.d.ts +7 -0
- package/dist/component/NumberField/types.js +1 -0
- package/dist/component/PasswordField/PasswordField.svelte +20 -0
- package/dist/component/PasswordField/PasswordField.svelte.d.ts +11 -0
- package/dist/component/PasswordField/index.d.ts +2 -0
- package/dist/component/PasswordField/index.js +1 -0
- package/dist/component/PasswordField/types.d.ts +7 -0
- package/dist/component/PasswordField/types.js +1 -0
- package/dist/component/PhoneField/PhoneField.svelte +23 -0
- package/dist/component/PhoneField/PhoneField.svelte.d.ts +14 -0
- package/dist/component/PhoneField/index.d.ts +2 -0
- package/dist/component/PhoneField/index.js +1 -0
- package/dist/component/PhoneField/types.d.ts +7 -0
- package/dist/component/PhoneField/types.js +1 -0
- package/dist/component/RangeField/RangeField.svelte +21 -0
- package/dist/component/RangeField/RangeField.svelte.d.ts +12 -0
- package/dist/component/RangeField/common/RangeControl/RangeControl.svelte +54 -0
- package/dist/component/RangeField/common/RangeControl/RangeControl.svelte.d.ts +9 -0
- package/dist/component/RangeField/common/RangeControl/clampToSlider.d.ts +7 -0
- package/dist/component/RangeField/common/RangeControl/clampToSlider.js +11 -0
- package/dist/component/RangeField/common/RangeControl/index.d.ts +2 -0
- package/dist/component/RangeField/common/RangeControl/index.js +1 -0
- package/dist/component/RangeField/common/RangeControl/styles.css +46 -0
- package/dist/component/RangeField/common/RangeControl/types.d.ts +16 -0
- package/dist/component/RangeField/common/RangeControl/types.js +1 -0
- package/dist/component/RangeField/common/index.d.ts +1 -0
- package/dist/component/RangeField/common/index.js +1 -0
- package/dist/component/RangeField/index.d.ts +2 -0
- package/dist/component/RangeField/index.js +1 -0
- package/dist/component/RangeField/types.d.ts +7 -0
- package/dist/component/RangeField/types.js +1 -0
- package/dist/component/RichChoicesField/RichChoices.svelte +52 -0
- package/dist/component/RichChoicesField/RichChoices.svelte.d.ts +10 -0
- package/dist/component/RichChoicesField/RichChoicesField.svelte +23 -0
- package/dist/component/RichChoicesField/RichChoicesField.svelte.d.ts +13 -0
- package/dist/component/RichChoicesField/common/Option/Option.svelte +38 -0
- package/dist/component/RichChoicesField/common/Option/Option.svelte.d.ts +8 -0
- package/dist/component/RichChoicesField/common/Option/index.d.ts +2 -0
- package/dist/component/RichChoicesField/common/Option/index.js +1 -0
- package/dist/component/RichChoicesField/common/Option/types.d.ts +13 -0
- package/dist/component/RichChoicesField/common/Option/types.js +1 -0
- package/dist/component/RichChoicesField/common/index.d.ts +1 -0
- package/dist/component/RichChoicesField/common/index.js +1 -0
- package/dist/component/RichChoicesField/index.d.ts +3 -0
- package/dist/component/RichChoicesField/index.js +2 -0
- package/dist/component/RichChoicesField/styles.css +103 -0
- package/dist/component/RichChoicesField/types.d.ts +37 -0
- package/dist/component/RichChoicesField/types.js +1 -0
- package/dist/component/SelectField/SelectField.svelte +20 -0
- package/dist/component/SelectField/SelectField.svelte.d.ts +11 -0
- package/dist/component/SelectField/index.d.ts +2 -0
- package/dist/component/SelectField/index.js +1 -0
- package/dist/component/SelectField/types.d.ts +7 -0
- package/dist/component/SelectField/types.js +1 -0
- package/dist/component/SwitchField/SwitchField.svelte +23 -0
- package/dist/component/SwitchField/SwitchField.svelte.d.ts +13 -0
- package/dist/component/SwitchField/index.d.ts +2 -0
- package/dist/component/SwitchField/index.js +1 -0
- package/dist/component/SwitchField/types.d.ts +10 -0
- package/dist/component/SwitchField/types.js +1 -0
- package/dist/component/TextField/TextField.svelte +20 -0
- package/dist/component/TextField/TextField.svelte.d.ts +11 -0
- package/dist/component/TextField/index.d.ts +2 -0
- package/dist/component/TextField/index.js +1 -0
- package/dist/component/TextField/types.d.ts +7 -0
- package/dist/component/TextField/types.js +1 -0
- package/dist/component/TextareaField/TextareaField.svelte +20 -0
- package/dist/component/TextareaField/TextareaField.svelte.d.ts +11 -0
- package/dist/component/TextareaField/index.d.ts +2 -0
- package/dist/component/TextareaField/index.js +1 -0
- package/dist/component/TextareaField/types.d.ts +7 -0
- package/dist/component/TextareaField/types.js +1 -0
- package/dist/component/TimeField/TimeField.svelte +20 -0
- package/dist/component/TimeField/TimeField.svelte.d.ts +11 -0
- package/dist/component/TimeField/index.d.ts +2 -0
- package/dist/component/TimeField/index.js +1 -0
- package/dist/component/TimeField/types.d.ts +7 -0
- package/dist/component/TimeField/types.js +1 -0
- package/dist/component/index.d.ts +16 -0
- package/dist/component/index.js +18 -0
- package/dist/density.css +367 -0
- package/dist/index.css +409 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.js +5 -0
- package/dist/pattern/Field/Field.svelte +95 -0
- package/dist/pattern/Field/Field.svelte.d.ts +35 -0
- package/dist/pattern/Field/index.d.ts +2 -0
- package/dist/pattern/Field/index.js +1 -0
- package/dist/pattern/Field/types.d.ts +90 -0
- package/dist/pattern/Field/types.js +1 -0
- package/dist/pattern/Form/Form.svelte +49 -0
- package/dist/pattern/Form/Form.svelte.d.ts +40 -0
- package/dist/pattern/Form/index.d.ts +2 -0
- package/dist/pattern/Form/index.js +1 -0
- package/dist/pattern/Form/types.d.ts +18 -0
- package/dist/pattern/Form/types.js +1 -0
- package/dist/pattern/index.d.ts +2 -0
- package/dist/pattern/index.js +2 -0
- package/dist/subcomponent/CheckboxInput/CheckboxInput.svelte +24 -0
- package/dist/subcomponent/CheckboxInput/CheckboxInput.svelte.d.ts +12 -0
- package/dist/subcomponent/CheckboxInput/index.d.ts +2 -0
- package/dist/subcomponent/CheckboxInput/index.js +1 -0
- package/dist/subcomponent/CheckboxInput/styles.css +135 -0
- package/dist/subcomponent/CheckboxInput/types.d.ts +6 -0
- package/dist/subcomponent/CheckboxInput/types.js +1 -0
- package/dist/subcomponent/DateInput/DateInput.svelte +28 -0
- package/dist/subcomponent/DateInput/DateInput.svelte.d.ts +14 -0
- package/dist/subcomponent/DateInput/index.d.ts +2 -0
- package/dist/subcomponent/DateInput/index.js +1 -0
- package/dist/subcomponent/DateInput/styles.css +47 -0
- package/dist/subcomponent/DateInput/types.d.ts +10 -0
- package/dist/subcomponent/DateInput/types.js +1 -0
- package/dist/subcomponent/DateTimeInput/DateTimeInput.svelte +29 -0
- package/dist/subcomponent/DateTimeInput/DateTimeInput.svelte.d.ts +14 -0
- package/dist/subcomponent/DateTimeInput/index.d.ts +2 -0
- package/dist/subcomponent/DateTimeInput/index.js +1 -0
- package/dist/subcomponent/DateTimeInput/styles.css +49 -0
- package/dist/subcomponent/DateTimeInput/types.d.ts +12 -0
- package/dist/subcomponent/DateTimeInput/types.js +1 -0
- package/dist/subcomponent/Field/Description/Description.svelte +17 -0
- package/dist/subcomponent/Field/Description/Description.svelte.d.ts +11 -0
- package/dist/subcomponent/Field/Description/index.d.ts +2 -0
- package/dist/subcomponent/Field/Description/index.js +1 -0
- package/dist/subcomponent/Field/Description/styles.css +14 -0
- package/dist/subcomponent/Field/Description/types.d.ts +12 -0
- package/dist/subcomponent/Field/Description/types.js +1 -0
- package/dist/subcomponent/Field/Error/Error.svelte +16 -0
- package/dist/subcomponent/Field/Error/Error.svelte.d.ts +10 -0
- package/dist/subcomponent/Field/Error/index.d.ts +2 -0
- package/dist/subcomponent/Field/Error/index.js +1 -0
- package/dist/subcomponent/Field/Error/styles.css +18 -0
- package/dist/subcomponent/Field/Error/types.d.ts +12 -0
- package/dist/subcomponent/Field/Error/types.js +1 -0
- package/dist/subcomponent/Field/Label/Label.svelte +52 -0
- package/dist/subcomponent/Field/Label/Label.svelte.d.ts +11 -0
- package/dist/subcomponent/Field/Label/index.d.ts +2 -0
- package/dist/subcomponent/Field/Label/index.js +1 -0
- package/dist/subcomponent/Field/Label/styles.css +30 -0
- package/dist/subcomponent/Field/Label/types.d.ts +37 -0
- package/dist/subcomponent/Field/Label/types.js +1 -0
- package/dist/subcomponent/Field/index.d.ts +3 -0
- package/dist/subcomponent/Field/index.js +3 -0
- package/dist/subcomponent/FileUploadInput/FileUploadInput.svelte +189 -0
- package/dist/subcomponent/FileUploadInput/FileUploadInput.svelte.d.ts +34 -0
- package/dist/subcomponent/FileUploadInput/common/FileItem/FileItem.svelte +76 -0
- package/dist/subcomponent/FileUploadInput/common/FileItem/FileItem.svelte.d.ts +13 -0
- package/dist/subcomponent/FileUploadInput/common/FileItem/index.d.ts +2 -0
- package/dist/subcomponent/FileUploadInput/common/FileItem/index.js +1 -0
- package/dist/subcomponent/FileUploadInput/common/FileItem/types.d.ts +27 -0
- package/dist/subcomponent/FileUploadInput/common/FileItem/types.js +1 -0
- package/dist/subcomponent/FileUploadInput/common/Thumbnail/Thumbnail.svelte +12 -0
- package/dist/subcomponent/FileUploadInput/common/Thumbnail/Thumbnail.svelte.d.ts +8 -0
- package/dist/subcomponent/FileUploadInput/common/Thumbnail/index.d.ts +2 -0
- package/dist/subcomponent/FileUploadInput/common/Thumbnail/index.js +1 -0
- package/dist/subcomponent/FileUploadInput/common/Thumbnail/types.d.ts +7 -0
- package/dist/subcomponent/FileUploadInput/common/Thumbnail/types.js +1 -0
- package/dist/subcomponent/FileUploadInput/constants.d.ts +2 -0
- package/dist/subcomponent/FileUploadInput/constants.js +2 -0
- package/dist/subcomponent/FileUploadInput/hooks/index.d.ts +2 -0
- package/dist/subcomponent/FileUploadInput/hooks/index.js +2 -0
- package/dist/subcomponent/FileUploadInput/hooks/useFileUploads.svelte.d.ts +38 -0
- package/dist/subcomponent/FileUploadInput/hooks/useFileUploads.svelte.js +139 -0
- package/dist/subcomponent/FileUploadInput/hooks/useObjectUrl.svelte.d.ts +11 -0
- package/dist/subcomponent/FileUploadInput/hooks/useObjectUrl.svelte.js +27 -0
- package/dist/subcomponent/FileUploadInput/index.d.ts +2 -0
- package/dist/subcomponent/FileUploadInput/index.js +1 -0
- package/dist/subcomponent/FileUploadInput/messages.d.ts +3 -0
- package/dist/subcomponent/FileUploadInput/messages.js +24 -0
- package/dist/subcomponent/FileUploadInput/styles.css +305 -0
- package/dist/subcomponent/FileUploadInput/types.d.ts +175 -0
- package/dist/subcomponent/FileUploadInput/types.js +1 -0
- package/dist/subcomponent/FileUploadInput/utils/formatFileSize.d.ts +6 -0
- package/dist/subcomponent/FileUploadInput/utils/formatFileSize.js +20 -0
- package/dist/subcomponent/FileUploadInput/utils/getFileMessage.d.ts +13 -0
- package/dist/subcomponent/FileUploadInput/utils/getFileMessage.js +19 -0
- package/dist/subcomponent/FileUploadInput/utils/index.d.ts +4 -0
- package/dist/subcomponent/FileUploadInput/utils/index.js +3 -0
- package/dist/subcomponent/FileUploadInput/utils/matchesAccept.d.ts +9 -0
- package/dist/subcomponent/FileUploadInput/utils/matchesAccept.js +25 -0
- package/dist/subcomponent/HiddenInput/HiddenInput.svelte +23 -0
- package/dist/subcomponent/HiddenInput/HiddenInput.svelte.d.ts +11 -0
- package/dist/subcomponent/HiddenInput/index.d.ts +2 -0
- package/dist/subcomponent/HiddenInput/index.js +1 -0
- package/dist/subcomponent/HiddenInput/types.d.ts +6 -0
- package/dist/subcomponent/HiddenInput/types.js +1 -0
- package/dist/subcomponent/NumberInput/NumberInput.svelte +29 -0
- package/dist/subcomponent/NumberInput/NumberInput.svelte.d.ts +13 -0
- package/dist/subcomponent/NumberInput/index.d.ts +2 -0
- package/dist/subcomponent/NumberInput/index.js +1 -0
- package/dist/subcomponent/NumberInput/styles.css +54 -0
- package/dist/subcomponent/NumberInput/types.d.ts +11 -0
- package/dist/subcomponent/NumberInput/types.js +1 -0
- package/dist/subcomponent/PasswordInput/PasswordInput.svelte +49 -0
- package/dist/subcomponent/PasswordInput/PasswordInput.svelte.d.ts +13 -0
- package/dist/subcomponent/PasswordInput/index.d.ts +2 -0
- package/dist/subcomponent/PasswordInput/index.js +1 -0
- package/dist/subcomponent/PasswordInput/styles.css +76 -0
- package/dist/subcomponent/PasswordInput/types.d.ts +12 -0
- package/dist/subcomponent/PasswordInput/types.js +1 -0
- package/dist/subcomponent/PhoneInput/PhoneInput.svelte +214 -0
- package/dist/subcomponent/PhoneInput/PhoneInput.svelte.d.ts +21 -0
- package/dist/subcomponent/PhoneInput/index.d.ts +2 -0
- package/dist/subcomponent/PhoneInput/index.js +1 -0
- package/dist/subcomponent/PhoneInput/styles.css +62 -0
- package/dist/subcomponent/PhoneInput/types.d.ts +50 -0
- package/dist/subcomponent/PhoneInput/types.js +1 -0
- package/dist/subcomponent/RadioInput/RadioInput.svelte +56 -0
- package/dist/subcomponent/RadioInput/RadioInput.svelte.d.ts +13 -0
- package/dist/subcomponent/RadioInput/index.d.ts +2 -0
- package/dist/subcomponent/RadioInput/index.js +1 -0
- package/dist/subcomponent/RadioInput/styles.css +81 -0
- package/dist/subcomponent/RadioInput/types.d.ts +6 -0
- package/dist/subcomponent/RadioInput/types.js +1 -0
- package/dist/subcomponent/RangeInput/RangeInput.svelte +38 -0
- package/dist/subcomponent/RangeInput/RangeInput.svelte.d.ts +13 -0
- package/dist/subcomponent/RangeInput/index.d.ts +2 -0
- package/dist/subcomponent/RangeInput/index.js +1 -0
- package/dist/subcomponent/RangeInput/styles.css +97 -0
- package/dist/subcomponent/RangeInput/types.d.ts +10 -0
- package/dist/subcomponent/RangeInput/types.js +1 -0
- package/dist/subcomponent/SelectInput/SelectInput.svelte +59 -0
- package/dist/subcomponent/SelectInput/SelectInput.svelte.d.ts +13 -0
- package/dist/subcomponent/SelectInput/index.d.ts +2 -0
- package/dist/subcomponent/SelectInput/index.js +1 -0
- package/dist/subcomponent/SelectInput/styles.css +56 -0
- package/dist/subcomponent/SelectInput/types.d.ts +10 -0
- package/dist/subcomponent/SelectInput/types.js +1 -0
- package/dist/subcomponent/SwitchInput/SwitchInput.svelte +26 -0
- package/dist/subcomponent/SwitchInput/SwitchInput.svelte.d.ts +13 -0
- package/dist/subcomponent/SwitchInput/index.d.ts +2 -0
- package/dist/subcomponent/SwitchInput/index.js +1 -0
- package/dist/subcomponent/SwitchInput/styles.css +109 -0
- package/dist/subcomponent/SwitchInput/types.d.ts +9 -0
- package/dist/subcomponent/SwitchInput/types.js +1 -0
- package/dist/subcomponent/TextInput/TextInput.svelte +30 -0
- package/dist/subcomponent/TextInput/TextInput.svelte.d.ts +14 -0
- package/dist/subcomponent/TextInput/index.d.ts +2 -0
- package/dist/subcomponent/TextInput/index.js +1 -0
- package/dist/subcomponent/TextInput/styles.css +34 -0
- package/dist/subcomponent/TextInput/types.d.ts +15 -0
- package/dist/subcomponent/TextInput/types.js +1 -0
- package/dist/subcomponent/TextareaInput/TextareaInput.svelte +24 -0
- package/dist/subcomponent/TextareaInput/TextareaInput.svelte.d.ts +12 -0
- package/dist/subcomponent/TextareaInput/index.d.ts +2 -0
- package/dist/subcomponent/TextareaInput/index.js +1 -0
- package/dist/subcomponent/TextareaInput/styles.css +16 -0
- package/dist/subcomponent/TextareaInput/types.d.ts +6 -0
- package/dist/subcomponent/TextareaInput/types.js +1 -0
- package/dist/subcomponent/TimeInput/TimeInput.svelte +29 -0
- package/dist/subcomponent/TimeInput/TimeInput.svelte.d.ts +14 -0
- package/dist/subcomponent/TimeInput/index.d.ts +2 -0
- package/dist/subcomponent/TimeInput/index.js +1 -0
- package/dist/subcomponent/TimeInput/styles.css +27 -0
- package/dist/subcomponent/TimeInput/types.d.ts +12 -0
- package/dist/subcomponent/TimeInput/types.js +1 -0
- package/dist/subcomponent/index.d.ts +17 -0
- package/dist/subcomponent/index.js +19 -0
- package/dist/subcomponent/types.d.ts +30 -0
- package/dist/subcomponent/types.js +1 -0
- package/dist/utils/index.d.ts +5 -0
- package/dist/utils/index.js +5 -0
- package/dist/utils/middleware/createRemoteOptions.svelte.d.ts +30 -0
- package/dist/utils/middleware/createRemoteOptions.svelte.js +83 -0
- package/dist/utils/middleware/fetchOptions.d.ts +20 -0
- package/dist/utils/middleware/fetchOptions.js +25 -0
- package/dist/utils/middleware/index.d.ts +4 -0
- package/dist/utils/middleware/index.js +3 -0
- package/dist/utils/middleware/types.d.ts +69 -0
- package/dist/utils/middleware/types.js +1 -0
- package/dist/utils/middleware/validateRemotely.d.ts +34 -0
- package/dist/utils/middleware/validateRemotely.js +263 -0
- package/dist/utils/owner/bindField.d.ts +16 -0
- package/dist/utils/owner/bindField.js +22 -0
- package/dist/utils/owner/createBinding.d.ts +8 -0
- package/dist/utils/owner/createBinding.js +23 -0
- package/dist/utils/owner/createFormState.svelte.d.ts +17 -0
- package/dist/utils/owner/createFormState.svelte.js +101 -0
- package/dist/utils/owner/createValidatedBinding.d.ts +15 -0
- package/dist/utils/owner/createValidatedBinding.js +70 -0
- package/dist/utils/owner/formOwnerContext.d.ts +15 -0
- package/dist/utils/owner/formOwnerContext.js +17 -0
- package/dist/utils/owner/index.d.ts +7 -0
- package/dist/utils/owner/index.js +6 -0
- package/dist/utils/owner/runLatest.d.ts +13 -0
- package/dist/utils/owner/runLatest.js +31 -0
- package/dist/utils/owner/types.d.ts +107 -0
- package/dist/utils/owner/types.js +1 -0
- package/dist/utils/phone/index.d.ts +1 -0
- package/dist/utils/phone/index.js +1 -0
- package/dist/utils/phone/phone.d.ts +30 -0
- package/dist/utils/phone/phone.js +121 -0
- package/dist/utils/readEditedChoices.d.ts +11 -0
- package/dist/utils/readEditedChoices.js +17 -0
- package/dist/utils/readEditedSelection.d.ts +9 -0
- package/dist/utils/readEditedSelection.js +16 -0
- package/package.json +100 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
GNU LESSER GENERAL PUBLIC LICENSE
|
|
2
|
+
Version 3, 29 June 2007
|
|
3
|
+
|
|
4
|
+
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
|
5
|
+
Everyone is permitted to copy and distribute verbatim copies
|
|
6
|
+
of this license document, but changing it is not allowed.
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
This version of the GNU Lesser General Public License incorporates
|
|
10
|
+
the terms and conditions of version 3 of the GNU General Public
|
|
11
|
+
License, supplemented by the additional permissions listed below.
|
|
12
|
+
|
|
13
|
+
0. Additional Definitions.
|
|
14
|
+
|
|
15
|
+
As used herein, "this License" refers to version 3 of the GNU Lesser
|
|
16
|
+
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
|
17
|
+
General Public License.
|
|
18
|
+
|
|
19
|
+
"The Library" refers to a covered work governed by this License,
|
|
20
|
+
other than an Application or a Combined Work as defined below.
|
|
21
|
+
|
|
22
|
+
An "Application" is any work that makes use of an interface provided
|
|
23
|
+
by the Library, but which is not otherwise based on the Library.
|
|
24
|
+
Defining a subclass of a class defined by the Library is deemed a mode
|
|
25
|
+
of using an interface provided by the Library.
|
|
26
|
+
|
|
27
|
+
A "Combined Work" is a work produced by combining or linking an
|
|
28
|
+
Application with the Library. The particular version of the Library
|
|
29
|
+
with which the Combined Work was made is also called the "Linked
|
|
30
|
+
Version".
|
|
31
|
+
|
|
32
|
+
The "Minimal Corresponding Source" for a Combined Work means the
|
|
33
|
+
Corresponding Source for the Combined Work, excluding any source code
|
|
34
|
+
for portions of the Combined Work that, considered in isolation, are
|
|
35
|
+
based on the Application, and not on the Linked Version.
|
|
36
|
+
|
|
37
|
+
The "Corresponding Application Code" for a Combined Work means the
|
|
38
|
+
object code and/or source code for the Application, including any data
|
|
39
|
+
and utility programs needed for reproducing the Combined Work from the
|
|
40
|
+
Application, but excluding the System Libraries of the Combined Work.
|
|
41
|
+
|
|
42
|
+
1. Exception to Section 3 of the GNU GPL.
|
|
43
|
+
|
|
44
|
+
You may convey a covered work under sections 3 and 4 of this License
|
|
45
|
+
without being bound by section 3 of the GNU GPL.
|
|
46
|
+
|
|
47
|
+
2. Conveying Modified Versions.
|
|
48
|
+
|
|
49
|
+
If you modify a copy of the Library, and, in your modifications, a
|
|
50
|
+
facility refers to a function or data to be supplied by an Application
|
|
51
|
+
that uses the facility (other than as an argument passed when the
|
|
52
|
+
facility is invoked), then you may convey a copy of the modified
|
|
53
|
+
version:
|
|
54
|
+
|
|
55
|
+
a) under this License, provided that you make a good faith effort to
|
|
56
|
+
ensure that, in the event an Application does not supply the
|
|
57
|
+
function or data, the facility still operates, and performs
|
|
58
|
+
whatever part of its purpose remains meaningful, or
|
|
59
|
+
|
|
60
|
+
b) under the GNU GPL, with none of the additional permissions of
|
|
61
|
+
this License applicable to that copy.
|
|
62
|
+
|
|
63
|
+
3. Object Code Incorporating Material from Library Header Files.
|
|
64
|
+
|
|
65
|
+
The object code form of an Application may incorporate material from
|
|
66
|
+
a header file that is part of the Library. You may convey such object
|
|
67
|
+
code under terms of your choice, provided that, if the incorporated
|
|
68
|
+
material is not limited to numerical parameters, data structure
|
|
69
|
+
layouts and accessors, or small macros, inline functions and templates
|
|
70
|
+
(ten or fewer lines in length), you do both of the following:
|
|
71
|
+
|
|
72
|
+
a) Give prominent notice with each copy of the object code that the
|
|
73
|
+
Library is used in it and that the Library and its use are
|
|
74
|
+
covered by this License.
|
|
75
|
+
|
|
76
|
+
b) Accompany the object code with a copy of the GNU GPL and this license
|
|
77
|
+
document.
|
|
78
|
+
|
|
79
|
+
4. Combined Works.
|
|
80
|
+
|
|
81
|
+
You may convey a Combined Work under terms of your choice that,
|
|
82
|
+
taken together, effectively do not restrict modification of the
|
|
83
|
+
portions of the Library contained in the Combined Work and reverse
|
|
84
|
+
engineering for debugging such modifications, if you also do each of
|
|
85
|
+
the following:
|
|
86
|
+
|
|
87
|
+
a) Give prominent notice with each copy of the Combined Work that
|
|
88
|
+
the Library is used in it and that the Library and its use are
|
|
89
|
+
covered by this License.
|
|
90
|
+
|
|
91
|
+
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
|
92
|
+
document.
|
|
93
|
+
|
|
94
|
+
c) For a Combined Work that displays copyright notices during
|
|
95
|
+
execution, include the copyright notice for the Library among
|
|
96
|
+
these notices, as well as a reference directing the user to the
|
|
97
|
+
copies of the GNU GPL and this license document.
|
|
98
|
+
|
|
99
|
+
d) Do one of the following:
|
|
100
|
+
|
|
101
|
+
0) Convey the Minimal Corresponding Source under the terms of this
|
|
102
|
+
License, and the Corresponding Application Code in a form
|
|
103
|
+
suitable for, and under terms that permit, the user to
|
|
104
|
+
recombine or relink the Application with a modified version of
|
|
105
|
+
the Linked Version to produce a modified Combined Work, in the
|
|
106
|
+
manner specified by section 6 of the GNU GPL for conveying
|
|
107
|
+
Corresponding Source.
|
|
108
|
+
|
|
109
|
+
1) Use a suitable shared library mechanism for linking with the
|
|
110
|
+
Library. A suitable mechanism is one that (a) uses at run time
|
|
111
|
+
a copy of the Library already present on the user's computer
|
|
112
|
+
system, and (b) will operate properly with a modified version
|
|
113
|
+
of the Library that is interface-compatible with the Linked
|
|
114
|
+
Version.
|
|
115
|
+
|
|
116
|
+
e) Provide Installation Information, but only if you would otherwise
|
|
117
|
+
be required to provide such information under section 6 of the
|
|
118
|
+
GNU GPL, and only to the extent that such information is
|
|
119
|
+
necessary to install and execute a modified version of the
|
|
120
|
+
Combined Work produced by recombining or relinking the
|
|
121
|
+
Application with a modified version of the Linked Version. (If
|
|
122
|
+
you use option 4d0, the Installation Information must accompany
|
|
123
|
+
the Minimal Corresponding Source and Corresponding Application
|
|
124
|
+
Code. If you use option 4d1, you must provide the Installation
|
|
125
|
+
Information in the manner specified by section 6 of the GNU GPL
|
|
126
|
+
for conveying Corresponding Source.)
|
|
127
|
+
|
|
128
|
+
5. Combined Libraries.
|
|
129
|
+
|
|
130
|
+
You may place library facilities that are a work based on the
|
|
131
|
+
Library side by side in a single library together with other library
|
|
132
|
+
facilities that are not Applications and are not covered by this
|
|
133
|
+
License, and convey such a combined library under terms of your
|
|
134
|
+
choice, if you do both of the following:
|
|
135
|
+
|
|
136
|
+
a) Accompany the combined library with a copy of the same work based
|
|
137
|
+
on the Library, uncombined with any other library facilities,
|
|
138
|
+
conveyed under the terms of this License.
|
|
139
|
+
|
|
140
|
+
b) Give prominent notice with the combined library that part of it
|
|
141
|
+
is a work based on the Library, and explaining where to find the
|
|
142
|
+
accompanying uncombined form of the same work.
|
|
143
|
+
|
|
144
|
+
6. Revised Versions of the GNU Lesser General Public License.
|
|
145
|
+
|
|
146
|
+
The Free Software Foundation may publish revised and/or new versions
|
|
147
|
+
of the GNU Lesser General Public License from time to time. Such new
|
|
148
|
+
versions will be similar in spirit to the present version, but may
|
|
149
|
+
differ in detail to address new problems or concerns.
|
|
150
|
+
|
|
151
|
+
Each version is given a distinguishing version number. If the
|
|
152
|
+
Library as you received it specifies that a certain numbered version
|
|
153
|
+
of the GNU Lesser General Public License "or any later version"
|
|
154
|
+
applies to it, you have the option of following the terms and
|
|
155
|
+
conditions either of that published version or of any later version
|
|
156
|
+
published by the Free Software Foundation. If the Library as you
|
|
157
|
+
received it does not specify a version number of the GNU Lesser
|
|
158
|
+
General Public License, you may choose any version of the GNU Lesser
|
|
159
|
+
General Public License ever published by the Free Software Foundation.
|
|
160
|
+
|
|
161
|
+
If the Library as you received it specifies that a proxy can decide
|
|
162
|
+
whether future versions of the GNU Lesser General Public License shall
|
|
163
|
+
apply, that proxy's public statement of acceptance of any version is
|
|
164
|
+
permanent authorization for you to choose that version for the
|
|
165
|
+
Library.
|
|
166
|
+
|
package/README.md
CHANGED
|
@@ -1,3 +1,261 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @canonical/svelte-ds-global-form
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Svelte 5 form fields for the Pragma design system. The markup, class names and
|
|
4
|
+
stylesheets are the same as `@canonical/react-ds-global-form`; the API is
|
|
5
|
+
Svelte's: every value is `$bindable`, and native attributes, handlers and
|
|
6
|
+
attachments are spread onto the real control.
|
|
7
|
+
|
|
8
|
+
```svelte
|
|
9
|
+
<script lang="ts">
|
|
10
|
+
import "@canonical/styles";
|
|
11
|
+
import "@canonical/svelte-ds-global-form/index.css";
|
|
12
|
+
import { Field, Form } from "@canonical/svelte-ds-global-form";
|
|
13
|
+
|
|
14
|
+
let { form } = $props(); // for example a SvelteKit action result
|
|
15
|
+
let email = $state("");
|
|
16
|
+
let newsletter = $state(false);
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<Form method="POST">
|
|
20
|
+
<Field inputType="email" name="email" label="Email" bind:value={email} error={form?.errors?.email} />
|
|
21
|
+
<Field inputType="checkbox" name="newsletter" label="Send me news" isOptional bind:value={newsletter} />
|
|
22
|
+
<Field
|
|
23
|
+
inputType="text"
|
|
24
|
+
name="company"
|
|
25
|
+
label="Company"
|
|
26
|
+
isOptional
|
|
27
|
+
condition={() => email.endsWith("@example.com")}
|
|
28
|
+
/>
|
|
29
|
+
<button type="submit">Send</button>
|
|
30
|
+
</Form>
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Styles
|
|
34
|
+
|
|
35
|
+
Import the global Pragma styles once, then either every form stylesheet:
|
|
36
|
+
|
|
37
|
+
```css
|
|
38
|
+
@import url("@canonical/styles");
|
|
39
|
+
@import url("@canonical/svelte-ds-global-form/index.css");
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
or nothing more: each component imports its own stylesheet, so a bundler that
|
|
43
|
+
handles CSS imports (Vite, SvelteKit) loads only the styles of the components
|
|
44
|
+
you use. The package marks `**/*.css` as side effects so they are not
|
|
45
|
+
tree-shaken.
|
|
46
|
+
|
|
47
|
+
## Fields
|
|
48
|
+
|
|
49
|
+
- `Field` routes on `inputType` (`text`, `email`, `tel`, `url`, `password`,
|
|
50
|
+
`number`, `textarea`, `select`, `checkbox`, `switch`, `choices`,
|
|
51
|
+
`rich-choices`, `range`, `date`, `time`, `datetime`, `file`, `phone`,
|
|
52
|
+
`hidden`, `custom`, and the work-in-progress `color`, `rating`, `combobox`).
|
|
53
|
+
- `value` is bindable and its type follows `inputType`: a string for text-like
|
|
54
|
+
inputs, a number (or `null` while empty) for `number` and `range`, a boolean
|
|
55
|
+
for `checkbox` and `switch`, a `string[]` for multiple `select` and
|
|
56
|
+
`choices`, `File[]` for `file`. An unbound value is local state, so a plain
|
|
57
|
+
HTML form works unchanged and server rendering shows the value.
|
|
58
|
+
- Fields are required unless `isOptional`. Pass a validation message with
|
|
59
|
+
`error`.
|
|
60
|
+
- `condition: (values) => boolean` decides whether a field is shown. Inside a
|
|
61
|
+
`Form` with an owner it receives the owner's values; otherwise it closes over
|
|
62
|
+
your own state (it receives `{}`). A hidden field is not rendered, so it is
|
|
63
|
+
not submitted; when a shown field becomes hidden, its value becomes
|
|
64
|
+
`undefined` (in the owner, or in your binding), as in React.
|
|
65
|
+
- `inputType: "custom"` renders `component` with no field chrome, as React's
|
|
66
|
+
`CustomComponent`: it receives every prop but `inputType` and `component`
|
|
67
|
+
(`CustomControlProps<Value>` plus any extra props), binds `value`, and
|
|
68
|
+
renders its own label, description and error.
|
|
69
|
+
- `Form` renders `form.ds.form.subgrid` and passes native attributes through.
|
|
70
|
+
Use SvelteKit's `enhance` as an attachment:
|
|
71
|
+
`<Form {@attach fromAction(enhance)}>` (`fromAction` from `svelte/attachments`).
|
|
72
|
+
|
|
73
|
+
## Form owners
|
|
74
|
+
|
|
75
|
+
Without an `owner`, `Form` is native: fields hold their own values and the
|
|
76
|
+
browser posts them, so it works with SvelteKit actions and without JavaScript.
|
|
77
|
+
Give `Form` an `owner` and every `Field` inside reads and writes its value,
|
|
78
|
+
error and blur through it by `name`, and the owner sees each submit first. An
|
|
79
|
+
explicit `bind:value` (when defined) or `error` on a field wins. A field shows
|
|
80
|
+
every error the owner returns; when errors appear is the owner's business.
|
|
81
|
+
|
|
82
|
+
`createFormState()` is the package's owner, opted into per form. It holds
|
|
83
|
+
values, errors and touched fields in `$state`, with react-hook-form's options:
|
|
84
|
+
|
|
85
|
+
```svelte
|
|
86
|
+
<Form
|
|
87
|
+
owner={createFormState({
|
|
88
|
+
defaultValues: { email: "" },
|
|
89
|
+
validate: (values) => ({ email: values.email ? undefined : "Email is required" }),
|
|
90
|
+
mode: "onSubmit", // or "onChange", "onBlur", "onTouched"
|
|
91
|
+
onSubmit: (values) => save(values), // unset: a valid form posts natively
|
|
92
|
+
})}
|
|
93
|
+
>
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Every mode validates on submit, and after the first submit a field again on
|
|
97
|
+
its every change. An invalid submit does not post and focuses the first
|
|
98
|
+
invalid control. The browser's own validation runs first; add `novalidate` to
|
|
99
|
+
show the owner's message for a missing required value. The owner also exposes
|
|
100
|
+
`errors`, `touched`, `isSubmitted`, `isSubmitting` and `reset()`.
|
|
101
|
+
|
|
102
|
+
The owner sees each submit before the form's other listeners, and a submit it
|
|
103
|
+
stops reaches `onsubmit` but none of them, so `<Form method="POST" owner={…}
|
|
104
|
+
{@attach fromAction(enhance)}>` posts only a valid form.
|
|
105
|
+
|
|
106
|
+
Any object meeting the contract is an owner:
|
|
107
|
+
|
|
108
|
+
```ts
|
|
109
|
+
type FormOwner<Values> = {
|
|
110
|
+
readonly values: Values; // must be reactive under runes, as `$state` is
|
|
111
|
+
setValue(name, value): void; // `undefined` drops the value
|
|
112
|
+
getError?(name): string | undefined;
|
|
113
|
+
blur?(name): void;
|
|
114
|
+
submit?(event: SubmitEvent): void; // may call event.preventDefault()
|
|
115
|
+
};
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
- `createBinding(source)` adapts a store that is not reactive under runes, such
|
|
119
|
+
as TanStack Form (`getValues`, `setValue`, `subscribe`, plus the optional
|
|
120
|
+
methods above), into an owner.
|
|
121
|
+
- `createValidatedBinding(owner, checks)` adds latest-only asynchronous checks
|
|
122
|
+
per field to an owner that can `reset`. A field keeps its previous message
|
|
123
|
+
while its check runs and when the check fails; a submit is stopped while a
|
|
124
|
+
check's message shows; `validate()` waits for every check.
|
|
125
|
+
- `runLatest(work)` runs asynchronous work so only its latest run counts.
|
|
126
|
+
- Outside a `Form` with an owner, bind a field yourself:
|
|
127
|
+
`bind:value={() => owner.values.email, (v) => owner.setValue("email", v)}`
|
|
128
|
+
and spread `{...bindField(owner, "email")}` for `error` and `onblur`.
|
|
129
|
+
|
|
130
|
+
## Remote validation and options
|
|
131
|
+
|
|
132
|
+
Middleware that changes the control is a Svelte attachment. `{@attach}` on a
|
|
133
|
+
`Field` or field component is forwarded to its control, as native attributes
|
|
134
|
+
and handlers are.
|
|
135
|
+
|
|
136
|
+
`validateRemotely(target, options)` checks the value once the user stops
|
|
137
|
+
typing and sets the answer as the control's custom validity, so the browser
|
|
138
|
+
blocks the submit and the field shows the message:
|
|
139
|
+
|
|
140
|
+
```svelte
|
|
141
|
+
<Field
|
|
142
|
+
inputType="text"
|
|
143
|
+
name="username"
|
|
144
|
+
label="Username"
|
|
145
|
+
{@attach validateRemotely("/api/validate-username", {
|
|
146
|
+
errorExtractor: async (response) => (await response.json()).error,
|
|
147
|
+
})}
|
|
148
|
+
/>
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
- `target` is a REST endpoint (`POST { value }` by default; `method`, `headers`,
|
|
152
|
+
`bodyFormatter`, `errorExtractor`), or your own check:
|
|
153
|
+
`(value, signal) => Promise<string | undefined>`, resolving to a message or
|
|
154
|
+
`undefined` when valid.
|
|
155
|
+
- `minLength` (3), `debounceWait` (300 ms) and `timeout` (10000 ms) set when it
|
|
156
|
+
checks and how long it waits. Each change cancels the pending check, so only
|
|
157
|
+
the answer for the latest value counts.
|
|
158
|
+
- A check that fails to complete, or times out, keeps the previous message.
|
|
159
|
+
A value shorter than `minLength` clears it. Each attachment clears only the
|
|
160
|
+
message it set.
|
|
161
|
+
- A submit of a value not yet answered waits for its check, then submits again
|
|
162
|
+
when the value passed. In a `novalidate` form a rejected value still blocks
|
|
163
|
+
the submit.
|
|
164
|
+
- Only string values typed or picked by the user are followed; a value written
|
|
165
|
+
by code is checked on submit. Without JavaScript nothing is checked, so
|
|
166
|
+
validate on the server too.
|
|
167
|
+
|
|
168
|
+
Options are data. Fetch them in a SvelteKit `load` for server rendering, with
|
|
169
|
+
`fetchOptions(url, { fetch, transformData })`, and pass them as `options`. To
|
|
170
|
+
fetch them in the browser, and again when the URL changes, use
|
|
171
|
+
`createRemoteOptions`:
|
|
172
|
+
|
|
173
|
+
```svelte
|
|
174
|
+
<script>
|
|
175
|
+
const fruits = createRemoteOptions(() => `/api/fruits?season=${season}`);
|
|
176
|
+
</script>
|
|
177
|
+
|
|
178
|
+
<Field inputType="select" name="fruit" label="Fruit" {...fruits.fieldProps} />
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
While loading the field is disabled, `aria-busy` and empty; a failed request
|
|
182
|
+
becomes its `error` and leaves it enabled; a new URL clears the options and
|
|
183
|
+
error while the new ones load. Spread `fieldProps` before your own props.
|
|
184
|
+
|
|
185
|
+
## Native validity
|
|
186
|
+
|
|
187
|
+
A field given no `error` (by you or by the owner) shows its control's native
|
|
188
|
+
`validationMessage`, from the control's first `invalid` event: a failed
|
|
189
|
+
submit, `checkValidity()`, `reportValidity()` or a `validateRemotely`
|
|
190
|
+
rejection. From then on it reads the message again on `input`, `change`,
|
|
191
|
+
`focusout` and the `ds:validity` event (`VALIDITY_EVENT`), so a fixed value
|
|
192
|
+
clears it. A form reset, or hiding the field, stops it until the next
|
|
193
|
+
`invalid`. If you call `setCustomValidity("")` yourself, dispatch
|
|
194
|
+
`new Event("ds:validity", { bubbles: true })` on the control afterwards, since
|
|
195
|
+
the browser fires no event. A custom `component` renders its own error.
|
|
196
|
+
|
|
197
|
+
## Without JavaScript
|
|
198
|
+
|
|
199
|
+
Fields render their values on the server, carry native `name`, `required` and
|
|
200
|
+
constraint attributes, and post with the form, so a `Form` without an owner
|
|
201
|
+
works with SvelteKit actions and with JavaScript disabled. Pass the action's
|
|
202
|
+
messages back as `error`. Owners, `condition`, `validateRemotely` and
|
|
203
|
+
`createRemoteOptions` need JavaScript; fetch options in `load` to have them on
|
|
204
|
+
the server.
|
|
205
|
+
|
|
206
|
+
`file` fields post their files without JavaScript: the named file input mirrors
|
|
207
|
+
the bound files, including dropped ones. A plain form needs
|
|
208
|
+
`enctype="multipart/form-data"` for the browser to send file contents:
|
|
209
|
+
`<Form method="POST" enctype="multipart/form-data">`.
|
|
210
|
+
|
|
211
|
+
Text typed, options chosen and boxes checked before the page hydrates are kept:
|
|
212
|
+
the bound value adopts them. `RadioInput` and `PhoneInput` find their server
|
|
213
|
+
markup by `id`, which every field provides; used on their own without an `id`,
|
|
214
|
+
they lose edits made before hydration.
|
|
215
|
+
|
|
216
|
+
## Inputs
|
|
217
|
+
|
|
218
|
+
The presentational inputs work outside a form, for example in a filter bar:
|
|
219
|
+
`TextInput`, `NumberInput`, `PasswordInput`, `TextareaInput`, `SelectInput`,
|
|
220
|
+
`DateInput`, `TimeInput`, `DateTimeInput`, `RangeInput`, `HiddenInput` and
|
|
221
|
+
`PhoneInput` bind `value`; `CheckboxInput`, `SwitchInput` and `RadioInput` bind
|
|
222
|
+
`checked`; `FileUploadInput` binds `files`.
|
|
223
|
+
|
|
224
|
+
## File upload
|
|
225
|
+
|
|
226
|
+
`inputType: "file"` (and `FileUploadInput`) binds `File[]`. An `upload`
|
|
227
|
+
function makes it live: each valid file is sent as soon as it is chosen, with
|
|
228
|
+
an abort signal and a progress callback, and closing a running upload removes
|
|
229
|
+
the file. Upload state stays in the input; the bound value is always the
|
|
230
|
+
chosen files.
|
|
231
|
+
|
|
232
|
+
```svelte
|
|
233
|
+
<script lang="ts">
|
|
234
|
+
import { Field, type UploadFunction } from "@canonical/svelte-ds-global-form";
|
|
235
|
+
|
|
236
|
+
const upload: UploadFunction = async (file, { signal }) => {
|
|
237
|
+
const response = await fetch("/api/files", { method: "POST", body: file, signal });
|
|
238
|
+
if (!response.ok) throw new Error(response.statusText);
|
|
239
|
+
};
|
|
240
|
+
</script>
|
|
241
|
+
|
|
242
|
+
<Field inputType="file" name="attachments" label="Attachments" multiple
|
|
243
|
+
accept=".pdf,image/*" maxSize={10 * 1024 * 1024} maxFiles={5} {upload} />
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
`accept`, `maxSize` and `validateFile` put a warning or an error under a file.
|
|
247
|
+
`maxFiles`, a file with an error, and an upload still running or failed make
|
|
248
|
+
the field invalid: the message is the file input's custom validity, so the
|
|
249
|
+
browser holds the submit back, as for `required`. In a `novalidate` form the
|
|
250
|
+
field stops the submit itself. `messages` replaces any text, and
|
|
251
|
+
`onuploadstatuschange` reports the running and failed uploads.
|
|
252
|
+
|
|
253
|
+
## Phone
|
|
254
|
+
|
|
255
|
+
`PhoneInput` (and `inputType: "phone"`) binds an E.164 string, or a structured
|
|
256
|
+
`{ countryCode, number }` with `valueFormat="structured"`. Countries come from
|
|
257
|
+
`phoneCountries` in `@canonical/ds-utils`. With a `name`, both controls post
|
|
258
|
+
without JavaScript: the number as `<name>` and the country code as
|
|
259
|
+
`<name>-country`. On the server, `decodePhone(formData, name)` turns the two
|
|
260
|
+
entries into both formats (pass a third `countries` argument for a custom
|
|
261
|
+
dataset).
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
# Baseline-alignment spike — findings
|
|
2
|
+
|
|
3
|
+
Exploratory spike, not a production refactor. It covers two linked changes:
|
|
4
|
+
|
|
5
|
+
1. Moving the baseline unit from **8px to 4px**.
|
|
6
|
+
2. An alternative baseline-alignment model for **boxed controls** (buttons,
|
|
7
|
+
inputs, nav items, list/table rows) that stops forcing the bottom border onto
|
|
8
|
+
the grid.
|
|
9
|
+
|
|
10
|
+
Everything is scoped to `_work_in_progress`; the only shared-package edits are
|
|
11
|
+
the 4px default (in `styles`, not tokens) and the grid overlay (in
|
|
12
|
+
`styles-debug`), both called out below.
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## 1. What the shipped engine does today
|
|
17
|
+
|
|
18
|
+
The typography engine (`@canonical/styles-typography`, default
|
|
19
|
+
`baseline-cap.css`) snaps each text element's box to the grid with two padding
|
|
20
|
+
nudges computed live in CSS:
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
--start-nudge = baseline − mod(baseline-position, baseline) /* seat the text baseline */
|
|
24
|
+
--end-nudge = baseline − start-nudge /* fill to a whole grid multiple */
|
|
25
|
+
|
|
26
|
+
padding-block-start: var(--start-nudge);
|
|
27
|
+
padding-block-end: var(--end-nudge);
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Because `start-nudge + end-nudge = baseline`, the box height is always a whole
|
|
31
|
+
number of baseline units **and both the top and bottom borders sit on the grid**.
|
|
32
|
+
|
|
33
|
+
The cost: whenever `start-nudge ≠ end-nudge`, the interior is asymmetric — the
|
|
34
|
+
text is nudged down from the top by one amount and up from the bottom by a
|
|
35
|
+
different amount. On a control with a visible border and a fixed look (a 24px or
|
|
36
|
+
32px button), that reads as the label sitting slightly high or low in its box.
|
|
37
|
+
|
|
38
|
+
## 2. The proposed model
|
|
39
|
+
|
|
40
|
+
Keep the top alignment; make the interior symmetric; move the leftover outside
|
|
41
|
+
the box:
|
|
42
|
+
|
|
43
|
+
```
|
|
44
|
+
padding-block-start: var(--start-nudge); /* unchanged — seat the baseline */
|
|
45
|
+
padding-block-end: var(--start-nudge); /* MIRROR the top nudge, not end-nudge */
|
|
46
|
+
|
|
47
|
+
/* the box is now NOT a whole grid multiple, so compensate outside it */
|
|
48
|
+
--visible: calc(2*border + 2*start-nudge + line-height);
|
|
49
|
+
margin-block-end: calc(round(up, var(--visible), var(--baseline-height)) − var(--visible));
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
- Top border stays on the grid.
|
|
53
|
+
- Interior spacing above and below the text is equal → visually balanced.
|
|
54
|
+
- Bottom border floats where it naturally lands.
|
|
55
|
+
- External `margin-block-end` (0…<1 baseline) pads the *occupied* height back to
|
|
56
|
+
a 4px multiple, so downstream layout rhythm is preserved.
|
|
57
|
+
|
|
58
|
+
Worked example (the brief's numbers): borders + top nudge + line-height + bottom
|
|
59
|
+
nudge come to a 21px visible box → `margin-block-end: 3px` → 24px occupied.
|
|
60
|
+
|
|
61
|
+
The alternative (top-align + external-margin) model was prototyped and then
|
|
62
|
+
dropped: the testbed now renders the **shipped engine model only** (the asymmetric
|
|
63
|
+
start/end nudges), with no `.model-current` / `.model-proposed` toggle. This
|
|
64
|
+
section is kept as the record of what was considered and why the external-margin
|
|
65
|
+
approach was not adopted (see §4).
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
## 3. Architectural & token changes required
|
|
70
|
+
|
|
71
|
+
**Baseline unit (4px).** Set in `packages/styles/main/src/spacing.css`:
|
|
72
|
+
`--space-baseline: 0.25rem`, no longer reading `--dimension-size-height-baseline`
|
|
73
|
+
(which stays 8px). Promoting 4px into `@canonical/design-tokens` is a **separate
|
|
74
|
+
tokens PR** — not done here on purpose. The engine reads `--baseline-height`
|
|
75
|
+
live, so nothing else changed to move the grid.
|
|
76
|
+
|
|
77
|
+
**Grid overlay (debug).** `packages/styles/debug/src/baseline-grid.css` now
|
|
78
|
+
defaults to 4px and paints **alternating bands** (tinted 4px / clear 4px) plus a
|
|
79
|
+
major line every 4th baseline, so the denser grid stays readable. Applied only
|
|
80
|
+
via the plugin — the story opts in with `parameters: { baseline: true }` and
|
|
81
|
+
`storybook-addon-utils` toggles `.with-baseline-grid`. (The addon was extended to
|
|
82
|
+
honor that parameter, not just the toolbar global; its `dist` must be rebuilt for
|
|
83
|
+
the change to take effect.)
|
|
84
|
+
|
|
85
|
+
**The alignment model itself** would live in the engine
|
|
86
|
+
(`baseline-cap.css` / `-metrics` / `-trim`), because that is where `start-nudge`
|
|
87
|
+
/ `end-nudge` are defined. Concretely:
|
|
88
|
+
|
|
89
|
+
- Add an opt-in mode (class or custom property, e.g. `.baseline-boxed` /
|
|
90
|
+
`--baseline-mode: boxed`) that swaps `padding-block-end` from `--end-nudge` to
|
|
91
|
+
`--start-nudge` and emits the compensating `margin-block-end`.
|
|
92
|
+
- The engine currently reserves `margin-block-end` for `--space-after`
|
|
93
|
+
(editorial). The boxed mode has to **add to** that margin, not overwrite it:
|
|
94
|
+
`margin-block-end: calc(space-after-margin + compensation)`. This is the one
|
|
95
|
+
real coupling to untangle.
|
|
96
|
+
- `round()` is already relied on elsewhere in the engine, so no new browser
|
|
97
|
+
floor.
|
|
98
|
+
|
|
99
|
+
**Per-component.** Boxed controls (`Button`, form inputs, future Tabs/SideNav
|
|
100
|
+
items, list/table rows) opt into the boxed mode on their outer element. Their
|
|
101
|
+
own `padding-block` (where they set it) must be reconciled with the nudges so the
|
|
102
|
+
two don't stack.
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## 4. Risks introduced by external margin compensation
|
|
107
|
+
|
|
108
|
+
- **Margin collapsing.** `margin-block-end` collapses with adjacent block
|
|
109
|
+
margins and through empty parents. In flex/grid containers margins don't
|
|
110
|
+
collapse (safe — that is where most controls live), but in plain block flow a
|
|
111
|
+
control's compensation can merge with a following sibling's top margin and the
|
|
112
|
+
rhythm silently shifts. The engine deliberately used *padding* to avoid exactly
|
|
113
|
+
this; the proposed model reintroduces the hazard by design.
|
|
114
|
+
- **Last-child / container edges.** Trailing compensation adds phantom space at
|
|
115
|
+
the bottom of a container (extra gap under the last row of a table, below the
|
|
116
|
+
last field in a form). Needs a `:last-child` reset in boxed contexts —
|
|
117
|
+
analogous to the existing `.content-flow > :last-child { margin-bottom: 0 }`.
|
|
118
|
+
- **`gap` double-counts.** In a flex/grid layout that already sets `gap`, each
|
|
119
|
+
item's external margin **adds to** the gap, so spacing between controls grows
|
|
120
|
+
by the compensation amount. Either the layout drops `gap` in favour of the
|
|
121
|
+
margins, or boxed controls suppress their margin when a gap owns the spacing.
|
|
122
|
+
(The testbed sets `gap: 0` on the control column precisely so the compensation
|
|
123
|
+
stays visible instead of being masked.)
|
|
124
|
+
- **Backgrounds / borders / dividers.** The compensation is outside the box, so
|
|
125
|
+
a full-bleed row background or a shared list divider stops at the border, not
|
|
126
|
+
at the occupied edge — a 3px unpainted strip appears between rows. The
|
|
127
|
+
shared-border list case in the testbed is there to show this.
|
|
128
|
+
- **Vertical centering.** Anything relying on the control's *box* being a grid
|
|
129
|
+
multiple to center it (icon next to label, absolutely-positioned affordances)
|
|
130
|
+
now centers against a non-grid box; the external margin doesn't participate.
|
|
131
|
+
- **Sticky / scroll math.** Occupied height ≠ border-box height means
|
|
132
|
+
`scroll-margin`, sticky offsets and `IntersectionObserver` thresholds computed
|
|
133
|
+
from `getBoundingClientRect()` are off by the compensation.
|
|
134
|
+
|
|
135
|
+
## 5. Where this model should NOT be used
|
|
136
|
+
|
|
137
|
+
- **Inline text / prose.** Paragraphs and inline runs already balance naturally;
|
|
138
|
+
the whole point of the symmetric-interior model is boxed controls with a
|
|
139
|
+
visible border. Prose keeps the current engine (`.p`, headings unchanged).
|
|
140
|
+
- **Controls whose height is externally fixed** (`height: 32px`, icon-only
|
|
141
|
+
square buttons). If the height is pinned, interior symmetry is governed by
|
|
142
|
+
`align-items`, not the nudges, and the external margin just adds stray space.
|
|
143
|
+
- **Grid/flex items that must fill a track** (`align-items: stretch`, table cells
|
|
144
|
+
with row-spanning). Stretch overrides the box height and the compensation
|
|
145
|
+
margin is ignored or fights the track.
|
|
146
|
+
- **Anything inside `gap`-based layouts** unless the gap-vs-margin
|
|
147
|
+
double-count is resolved for that container.
|
|
148
|
+
- **Overlapping / absolutely positioned** elements — margin does nothing there.
|
|
149
|
+
|
|
150
|
+
## 6. Recommended implementation strategy
|
|
151
|
+
|
|
152
|
+
Ship it as an **opt-in engine mode**, defaulted off, so nothing changes until a
|
|
153
|
+
component asks for it.
|
|
154
|
+
|
|
155
|
+
1. **Engine flag.** Add `--baseline-mode: grid | boxed` (default `grid`). In
|
|
156
|
+
`boxed`, `padding-block-end` mirrors `--start-nudge` and the engine emits
|
|
157
|
+
`margin-block-end: calc(var(--space-after-margin) + var(--baseline-compensation))`.
|
|
158
|
+
Keep `grid` byte-for-byte as today.
|
|
159
|
+
2. **Container reset.** Provide a `.baseline-boxed-flow` (or reuse
|
|
160
|
+
`content-flow`) that zeroes the trailing compensation on the last child and
|
|
161
|
+
documents the gap-vs-margin rule.
|
|
162
|
+
3. **Adopt on one control first** (Button), verify against prose in the testbed
|
|
163
|
+
at several sizes, then inputs, then nav items, then list/table rows (the
|
|
164
|
+
shared-border case last, since it exposes the divider gap).
|
|
165
|
+
4. **Only then** consider promoting 4px + a `density: boxed` token set into
|
|
166
|
+
`@canonical/design-tokens`.
|
|
167
|
+
|
|
168
|
+
### Before / after
|
|
169
|
+
|
|
170
|
+
```css
|
|
171
|
+
/* BEFORE — grid mode (ships today): both borders on grid, interior can be asymmetric */
|
|
172
|
+
.ds.button > .p {
|
|
173
|
+
padding-block-start: var(--start-nudge); /* e.g. 3px */
|
|
174
|
+
padding-block-end: var(--end-nudge); /* e.g. 1px → text sits high */
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/* AFTER — boxed mode: symmetric interior, bottom border free, rhythm via margin */
|
|
178
|
+
.ds.button {
|
|
179
|
+
--visible: calc(2px + calc(2 * var(--start-nudge)) + var(--computed-line-height));
|
|
180
|
+
margin-block-end: calc(
|
|
181
|
+
var(--space-after-margin, 0px) +
|
|
182
|
+
(round(up, var(--visible), var(--baseline-height)) - var(--visible))
|
|
183
|
+
);
|
|
184
|
+
}
|
|
185
|
+
.ds.button > .p {
|
|
186
|
+
padding-block-start: var(--start-nudge); /* 3px */
|
|
187
|
+
padding-block-end: var(--start-nudge); /* 3px → text balanced */
|
|
188
|
+
}
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
### Caveat surfaced by the testbed
|
|
192
|
+
|
|
193
|
+
At the default body size on a 4px grid, `start-nudge ≈ end-nudge`, so the two
|
|
194
|
+
models render nearly identically — the asymmetry the model fixes only becomes
|
|
195
|
+
visible at particular font-size / line-height / border combinations. Any adoption
|
|
196
|
+
decision should be made against a size where the current asymmetry is actually
|
|
197
|
+
visible, not the default paragraph tier. The testbed should grow a row at such a
|
|
198
|
+
size before this is taken forward.
|