@canonical/react-ds-global-form 0.29.1 → 0.31.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/dist/esm/density.css +234 -0
- package/dist/esm/docs/examples/density-examples.css +20 -0
- package/dist/esm/index.css +66 -6
- package/dist/esm/lib/_work_in_progress/DensityTestbed/Testbed.js +77 -0
- package/dist/esm/lib/_work_in_progress/DensityTestbed/Testbed.js.map +1 -0
- package/dist/esm/lib/_work_in_progress/DensityTestbed/baseline-system.css +81 -0
- package/dist/esm/lib/_work_in_progress/DensityTestbed/density.testbed.css +153 -0
- package/dist/esm/lib/_work_in_progress/DensityTestbed/mocks.js +23 -0
- package/dist/esm/lib/_work_in_progress/DensityTestbed/mocks.js.map +1 -0
- package/dist/esm/lib/common/Wrapper/ToggleWrapper.css +35 -0
- package/dist/esm/lib/common/Wrapper/ToggleWrapper.js +52 -0
- package/dist/esm/lib/common/Wrapper/ToggleWrapper.js.map +1 -0
- package/dist/esm/lib/common/Wrapper/Wrapper.js +2 -2
- package/dist/esm/lib/common/Wrapper/Wrapper.js.map +1 -1
- package/dist/esm/lib/common/Wrapper/hooks/useFieldWrapper.js +1 -1
- package/dist/esm/lib/common/Wrapper/hooks/useFieldWrapper.js.map +1 -1
- package/dist/esm/lib/common/Wrapper/index.js +2 -0
- package/dist/esm/lib/common/Wrapper/index.js.map +1 -1
- package/dist/esm/lib/common/Wrapper/styles.css +3 -1
- package/dist/esm/lib/common/Wrapper/withToggleWrapper.js +14 -0
- package/dist/esm/lib/common/Wrapper/withToggleWrapper.js.map +1 -0
- package/dist/esm/lib/common/bindField/bindField.js +15 -8
- package/dist/esm/lib/common/bindField/bindField.js.map +1 -1
- package/dist/esm/lib/component/CheckboxField/CheckboxField.js +8 -6
- package/dist/esm/lib/component/CheckboxField/CheckboxField.js.map +1 -1
- package/dist/esm/lib/component/ChoicesField/ChoicesField.js +2 -2
- package/dist/esm/lib/component/ChoicesField/ChoicesField.js.map +1 -1
- package/dist/esm/lib/component/ChoicesField/common/Option/Option.js +2 -2
- package/dist/esm/lib/component/ChoicesField/common/Option/Option.js.map +1 -1
- package/dist/esm/lib/component/ChoicesField/styles.css +55 -15
- package/dist/esm/lib/component/ColorField/ColorField.js +3 -3
- package/dist/esm/lib/component/ColorField/ColorField.js.map +1 -1
- package/dist/esm/lib/component/ComboboxField/ComboboxField.js +3 -3
- package/dist/esm/lib/component/ComboboxField/ComboboxField.js.map +1 -1
- package/dist/esm/lib/component/DateField/DateField.js +22 -4
- package/dist/esm/lib/component/DateField/DateField.js.map +1 -1
- package/dist/esm/lib/component/DateTimeField/DateTimeField.js +3 -3
- package/dist/esm/lib/component/DateTimeField/DateTimeField.js.map +1 -1
- package/dist/esm/lib/component/FileUploadField/FileUploadField.js +43 -6
- package/dist/esm/lib/component/FileUploadField/FileUploadField.js.map +1 -1
- package/dist/esm/lib/component/HiddenField/HiddenField.js +3 -3
- package/dist/esm/lib/component/HiddenField/HiddenField.js.map +1 -1
- package/dist/esm/lib/component/NumberField/NumberField.js +4 -4
- package/dist/esm/lib/component/NumberField/NumberField.js.map +1 -1
- package/dist/esm/lib/component/PasswordField/PasswordField.js +3 -3
- package/dist/esm/lib/component/PasswordField/PasswordField.js.map +1 -1
- package/dist/esm/lib/component/PhoneField/PhoneField.js +3 -3
- package/dist/esm/lib/component/PhoneField/PhoneField.js.map +1 -1
- package/dist/esm/lib/component/RangeField/RangeField.js +3 -3
- package/dist/esm/lib/component/RangeField/RangeField.js.map +1 -1
- package/dist/esm/lib/component/RangeField/common/RangeControl/RangeControl.js +1 -1
- package/dist/esm/lib/component/RangeField/common/RangeControl/RangeControl.js.map +1 -1
- package/dist/esm/lib/component/RatingField/RatingField.js +12 -0
- package/dist/esm/lib/component/RatingField/RatingField.js.map +1 -0
- package/dist/esm/lib/component/RatingField/index.js +2 -0
- package/dist/esm/lib/component/RatingField/index.js.map +1 -0
- package/dist/esm/lib/component/RatingField/types.js +2 -0
- package/dist/esm/lib/component/RatingField/types.js.map +1 -0
- package/dist/esm/lib/component/RichChoicesField/RichChoicesField.js +2 -2
- package/dist/esm/lib/component/RichChoicesField/RichChoicesField.js.map +1 -1
- package/dist/esm/lib/component/RichChoicesField/common/Option/Option.js +1 -1
- package/dist/esm/lib/component/RichChoicesField/common/Option/Option.js.map +1 -1
- package/dist/esm/lib/component/RichChoicesField/styles.css +6 -0
- package/dist/esm/lib/component/SelectField/SelectField.js +3 -3
- package/dist/esm/lib/component/SelectField/SelectField.js.map +1 -1
- package/dist/esm/lib/component/SwitchField/SwitchField.js +13 -0
- package/dist/esm/lib/component/SwitchField/SwitchField.js.map +1 -0
- package/dist/esm/lib/component/SwitchField/index.js +2 -0
- package/dist/esm/lib/component/SwitchField/index.js.map +1 -0
- package/dist/esm/lib/component/SwitchField/types.js +2 -0
- package/dist/esm/lib/component/SwitchField/types.js.map +1 -0
- package/dist/esm/lib/component/TextField/TextField.js +3 -3
- package/dist/esm/lib/component/TextField/TextField.js.map +1 -1
- package/dist/esm/lib/component/TextareaField/TextareaField.js +3 -3
- package/dist/esm/lib/component/TextareaField/TextareaField.js.map +1 -1
- package/dist/esm/lib/component/TimeField/TimeField.js +3 -3
- package/dist/esm/lib/component/TimeField/TimeField.js.map +1 -1
- package/dist/esm/lib/component/index.js +2 -0
- package/dist/esm/lib/component/index.js.map +1 -1
- package/dist/esm/lib/index.js +2 -1
- package/dist/esm/lib/index.js.map +1 -1
- package/dist/esm/lib/pattern/Field/Field.js +23 -17
- package/dist/esm/lib/pattern/Field/Field.js.map +1 -1
- package/dist/esm/lib/subcomponent/CheckboxInput/styles.css +45 -16
- package/dist/esm/lib/subcomponent/ComboboxInput/MultipleCombobox.js +14 -8
- package/dist/esm/lib/subcomponent/ComboboxInput/MultipleCombobox.js.map +1 -1
- package/dist/esm/lib/subcomponent/DateInput/styles.css +12 -0
- package/dist/esm/lib/subcomponent/DateTimeInput/styles.css +13 -0
- package/dist/esm/lib/subcomponent/Field/Label/Label.js +1 -3
- package/dist/esm/lib/subcomponent/Field/Label/Label.js.map +1 -1
- package/dist/esm/lib/subcomponent/Field/Label/styles.css +2 -3
- package/dist/esm/lib/subcomponent/FileUploadInput/FileUploadInput.js +11 -21
- package/dist/esm/lib/subcomponent/FileUploadInput/FileUploadInput.js.map +1 -1
- package/dist/esm/lib/subcomponent/FileUploadInput/styles.css +6 -3
- package/dist/esm/lib/subcomponent/PasswordInput/styles.css +5 -6
- package/dist/esm/lib/subcomponent/PhoneInput/PhoneInput.js +1 -1
- package/dist/esm/lib/subcomponent/PhoneInput/PhoneInput.js.map +1 -1
- package/dist/esm/lib/subcomponent/RadioInput/styles.css +36 -7
- package/dist/esm/lib/subcomponent/RangeInput/styles.css +10 -9
- package/dist/esm/lib/subcomponent/RatingInput/RatingInput.js +48 -0
- package/dist/esm/lib/subcomponent/RatingInput/RatingInput.js.map +1 -0
- package/dist/esm/lib/subcomponent/RatingInput/index.js +2 -0
- package/dist/esm/lib/subcomponent/RatingInput/index.js.map +1 -0
- package/dist/esm/lib/subcomponent/RatingInput/styles.css +159 -0
- package/dist/esm/lib/subcomponent/RatingInput/types.js +2 -0
- package/dist/esm/lib/subcomponent/RatingInput/types.js.map +1 -0
- package/dist/esm/lib/subcomponent/SwitchInput/SwitchInput.js +26 -0
- package/dist/esm/lib/subcomponent/SwitchInput/SwitchInput.js.map +1 -0
- package/dist/esm/lib/subcomponent/SwitchInput/index.js +2 -0
- package/dist/esm/lib/subcomponent/SwitchInput/index.js.map +1 -0
- package/dist/esm/lib/subcomponent/SwitchInput/styles.css +105 -0
- package/dist/esm/lib/subcomponent/SwitchInput/types.js +2 -0
- package/dist/esm/lib/subcomponent/SwitchInput/types.js.map +1 -0
- package/dist/esm/lib/subcomponent/TextInput/TextInput.js +1 -1
- package/dist/esm/lib/subcomponent/TextInput/TextInput.js.map +1 -1
- package/dist/esm/lib/subcomponent/TextareaInput/TextareaInput.js +1 -3
- package/dist/esm/lib/subcomponent/TextareaInput/TextareaInput.js.map +1 -1
- package/dist/esm/lib/subcomponent/TextareaInput/styles.css +4 -9
- package/dist/esm/lib/subcomponent/TimeInput/styles.css +8 -0
- package/dist/esm/lib/subcomponent/index.js +2 -0
- package/dist/esm/lib/subcomponent/index.js.map +1 -1
- package/dist/esm/lib/utils/countries/countries.js +1 -1
- package/dist/esm/lib/utils/countries/countries.js.map +1 -1
- package/dist/esm/lib/utils/hooks/useFieldError.js +21 -24
- package/dist/esm/lib/utils/hooks/useFieldError.js.map +1 -1
- package/dist/types/lib/_work_in_progress/DensityTestbed/Testbed.d.ts +42 -0
- package/dist/types/lib/_work_in_progress/DensityTestbed/Testbed.d.ts.map +1 -0
- package/dist/types/lib/_work_in_progress/DensityTestbed/mocks.d.ts +26 -0
- package/dist/types/lib/_work_in_progress/DensityTestbed/mocks.d.ts.map +1 -0
- package/dist/types/lib/common/Wrapper/ToggleWrapper.d.ts +24 -0
- package/dist/types/lib/common/Wrapper/ToggleWrapper.d.ts.map +1 -0
- package/dist/types/lib/common/Wrapper/index.d.ts +2 -0
- package/dist/types/lib/common/Wrapper/index.d.ts.map +1 -1
- package/dist/types/lib/common/Wrapper/withToggleWrapper.d.ts +20 -0
- package/dist/types/lib/common/Wrapper/withToggleWrapper.d.ts.map +1 -0
- package/dist/types/lib/common/Wrapper/withWrapper.d.ts +1 -1
- package/dist/types/lib/common/Wrapper/withWrapper.d.ts.map +1 -1
- package/dist/types/lib/common/bindField/bindField.d.ts.map +1 -1
- package/dist/types/lib/common/bindField/types.d.ts +14 -5
- package/dist/types/lib/common/bindField/types.d.ts.map +1 -1
- package/dist/types/lib/common/types.d.ts +24 -2
- package/dist/types/lib/common/types.d.ts.map +1 -1
- package/dist/types/lib/component/CheckboxField/CheckboxField.d.ts +8 -332
- package/dist/types/lib/component/CheckboxField/CheckboxField.d.ts.map +1 -1
- package/dist/types/lib/component/CheckboxField/types.d.ts +7 -4
- package/dist/types/lib/component/CheckboxField/types.d.ts.map +1 -1
- package/dist/types/lib/component/ChoicesField/ChoicesField.d.ts +1 -0
- package/dist/types/lib/component/ChoicesField/ChoicesField.d.ts.map +1 -1
- package/dist/types/lib/component/ChoicesField/common/Option/types.d.ts +1 -1
- package/dist/types/lib/component/ChoicesField/common/Option/types.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/ColorField/ColorField.d.ts +2 -1
- package/dist/types/lib/component/ColorField/ColorField.d.ts.map +1 -1
- package/dist/types/lib/component/ColorField/types.d.ts +2 -2
- package/dist/types/lib/component/ColorField/types.d.ts.map +1 -1
- package/dist/types/lib/component/ComboboxField/ComboboxField.d.ts +1 -0
- package/dist/types/lib/component/ComboboxField/ComboboxField.d.ts.map +1 -1
- package/dist/types/lib/component/ComboboxField/types.d.ts +2 -2
- package/dist/types/lib/component/ComboboxField/types.d.ts.map +1 -1
- package/dist/types/lib/component/DateField/DateField.d.ts +4 -2
- package/dist/types/lib/component/DateField/DateField.d.ts.map +1 -1
- package/dist/types/lib/component/DateField/types.d.ts +2 -2
- package/dist/types/lib/component/DateField/types.d.ts.map +1 -1
- package/dist/types/lib/component/DateTimeField/DateTimeField.d.ts +1 -0
- package/dist/types/lib/component/DateTimeField/DateTimeField.d.ts.map +1 -1
- package/dist/types/lib/component/DateTimeField/types.d.ts +2 -2
- package/dist/types/lib/component/DateTimeField/types.d.ts.map +1 -1
- package/dist/types/lib/component/FileUploadField/FileUploadField.d.ts +9 -5
- package/dist/types/lib/component/FileUploadField/FileUploadField.d.ts.map +1 -1
- package/dist/types/lib/component/FileUploadField/types.d.ts +2 -2
- package/dist/types/lib/component/FileUploadField/types.d.ts.map +1 -1
- package/dist/types/lib/component/HiddenField/HiddenField.d.ts +1 -0
- package/dist/types/lib/component/HiddenField/HiddenField.d.ts.map +1 -1
- package/dist/types/lib/component/HiddenField/types.d.ts +2 -2
- package/dist/types/lib/component/HiddenField/types.d.ts.map +1 -1
- package/dist/types/lib/component/NumberField/NumberField.d.ts +1 -0
- package/dist/types/lib/component/NumberField/NumberField.d.ts.map +1 -1
- package/dist/types/lib/component/NumberField/types.d.ts +2 -2
- package/dist/types/lib/component/NumberField/types.d.ts.map +1 -1
- package/dist/types/lib/component/PasswordField/PasswordField.d.ts +1 -0
- package/dist/types/lib/component/PasswordField/PasswordField.d.ts.map +1 -1
- package/dist/types/lib/component/PasswordField/types.d.ts +2 -2
- package/dist/types/lib/component/PasswordField/types.d.ts.map +1 -1
- package/dist/types/lib/component/PhoneField/PhoneField.d.ts +3 -2
- package/dist/types/lib/component/PhoneField/PhoneField.d.ts.map +1 -1
- package/dist/types/lib/component/PhoneField/index.d.ts +1 -1
- package/dist/types/lib/component/PhoneField/index.d.ts.map +1 -1
- package/dist/types/lib/component/PhoneField/types.d.ts +2 -2
- package/dist/types/lib/component/PhoneField/types.d.ts.map +1 -1
- package/dist/types/lib/component/RangeField/RangeField.d.ts +1 -0
- package/dist/types/lib/component/RangeField/RangeField.d.ts.map +1 -1
- package/dist/types/lib/component/RangeField/types.d.ts +1 -1
- package/dist/types/lib/component/RangeField/types.d.ts.map +1 -1
- package/dist/types/lib/component/RatingField/RatingField.d.ts +46 -0
- package/dist/types/lib/component/RatingField/RatingField.d.ts.map +1 -0
- package/dist/types/lib/component/RatingField/index.d.ts +3 -0
- package/dist/types/lib/component/RatingField/index.d.ts.map +1 -0
- package/dist/types/lib/component/RatingField/types.d.ts +9 -0
- package/dist/types/lib/component/RatingField/types.d.ts.map +1 -0
- package/dist/types/lib/component/RichChoicesField/RichChoicesField.d.ts +1 -0
- package/dist/types/lib/component/RichChoicesField/RichChoicesField.d.ts.map +1 -1
- 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 +1 -0
- package/dist/types/lib/component/SelectField/SelectField.d.ts.map +1 -1
- package/dist/types/lib/component/SelectField/types.d.ts +2 -2
- package/dist/types/lib/component/SelectField/types.d.ts.map +1 -1
- package/dist/types/lib/component/SwitchField/SwitchField.d.ts +14 -0
- package/dist/types/lib/component/SwitchField/SwitchField.d.ts.map +1 -0
- package/dist/types/lib/component/SwitchField/index.d.ts +3 -0
- package/dist/types/lib/component/SwitchField/index.d.ts.map +1 -0
- package/dist/types/lib/component/SwitchField/types.d.ts +8 -0
- package/dist/types/lib/component/SwitchField/types.d.ts.map +1 -0
- package/dist/types/lib/component/TextField/TextField.d.ts +2 -1
- package/dist/types/lib/component/TextField/TextField.d.ts.map +1 -1
- package/dist/types/lib/component/TextField/types.d.ts +2 -2
- package/dist/types/lib/component/TextField/types.d.ts.map +1 -1
- package/dist/types/lib/component/TextareaField/TextareaField.d.ts +1 -0
- package/dist/types/lib/component/TextareaField/TextareaField.d.ts.map +1 -1
- package/dist/types/lib/component/TextareaField/types.d.ts +2 -2
- package/dist/types/lib/component/TextareaField/types.d.ts.map +1 -1
- package/dist/types/lib/component/TimeField/TimeField.d.ts +1 -0
- package/dist/types/lib/component/TimeField/TimeField.d.ts.map +1 -1
- package/dist/types/lib/component/TimeField/types.d.ts +2 -2
- package/dist/types/lib/component/TimeField/types.d.ts.map +1 -1
- package/dist/types/lib/component/index.d.ts +2 -0
- package/dist/types/lib/component/index.d.ts.map +1 -1
- package/dist/types/lib/index.d.ts +2 -0
- package/dist/types/lib/index.d.ts.map +1 -1
- package/dist/types/lib/pattern/Field/Field.d.ts.map +1 -1
- package/dist/types/lib/pattern/Field/types.d.ts +27 -21
- package/dist/types/lib/pattern/Field/types.d.ts.map +1 -1
- package/dist/types/lib/subcomponent/ComboboxInput/MultipleCombobox.d.ts.map +1 -1
- package/dist/types/lib/subcomponent/Field/Label/Label.d.ts.map +1 -1
- package/dist/types/lib/subcomponent/FileUploadInput/FileUploadInput.d.ts.map +1 -1
- package/dist/types/lib/subcomponent/PhoneInput/types.d.ts +2 -2
- package/dist/types/lib/subcomponent/PhoneInput/types.d.ts.map +1 -1
- package/dist/types/lib/subcomponent/RatingInput/RatingInput.d.ts +23 -0
- package/dist/types/lib/subcomponent/RatingInput/RatingInput.d.ts.map +1 -0
- package/dist/types/lib/subcomponent/RatingInput/index.d.ts +3 -0
- package/dist/types/lib/subcomponent/RatingInput/index.d.ts.map +1 -0
- package/dist/types/lib/subcomponent/RatingInput/types.d.ts +52 -0
- package/dist/types/lib/subcomponent/RatingInput/types.d.ts.map +1 -0
- package/dist/types/lib/subcomponent/SwitchInput/SwitchInput.d.ts +16 -0
- package/dist/types/lib/subcomponent/SwitchInput/SwitchInput.d.ts.map +1 -0
- package/dist/types/lib/subcomponent/SwitchInput/index.d.ts +3 -0
- package/dist/types/lib/subcomponent/SwitchInput/index.d.ts.map +1 -0
- package/dist/types/lib/subcomponent/SwitchInput/types.d.ts +8 -0
- package/dist/types/lib/subcomponent/SwitchInput/types.d.ts.map +1 -0
- package/dist/types/lib/subcomponent/TextareaInput/TextareaInput.d.ts.map +1 -1
- package/dist/types/lib/subcomponent/index.d.ts +4 -0
- package/dist/types/lib/subcomponent/index.d.ts.map +1 -1
- package/dist/types/lib/utils/hooks/useFieldError.d.ts +14 -0
- package/dist/types/lib/utils/hooks/useFieldError.d.ts.map +1 -1
- package/dist/types/lib/utils/middleware/addRESTOptions.d.ts +2 -2
- package/dist/types/lib/utils/middleware/addRESTOptions.d.ts.map +1 -1
- package/dist/types/lib/utils/middleware/addRESTValidation.d.ts +1 -1
- package/dist/types/lib/utils/middleware/addRESTValidation.d.ts.map +1 -1
- package/package.json +14 -20
|
@@ -6,11 +6,18 @@
|
|
|
6
6
|
/* Align to the field edge like the label (no side margin by default), not to
|
|
7
7
|
* the input's inner padding. Overridable via the shared variable. */
|
|
8
8
|
margin-inline: var(--form-label-padding-inline, 0);
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
/* A 16px control — a fixed element size, NOT a baseline multiple. It was
|
|
10
|
+
`--space-baseline × 2` (16px when the baseline was 8px), but the 4px-baseline
|
|
11
|
+
spike halved it to 8px. Size to the stable --dimension-200 (16px) so the
|
|
12
|
+
control size is decoupled from the baseline grid unit. */
|
|
13
|
+
width: var(--dimension-200);
|
|
14
|
+
height: var(--dimension-200);
|
|
11
15
|
border: var(--dimension-stroke-thickness-medium) solid var(--color-border);
|
|
12
16
|
border-radius: var(--dimension-radius-small);
|
|
13
|
-
background: var(
|
|
17
|
+
background: var(
|
|
18
|
+
--surface-color-foreground-checkbox-unselected,
|
|
19
|
+
var(--color-foreground-checkbox-unselected)
|
|
20
|
+
);
|
|
14
21
|
cursor: pointer;
|
|
15
22
|
transition:
|
|
16
23
|
background-color 150ms ease,
|
|
@@ -42,11 +49,22 @@
|
|
|
42
49
|
|
|
43
50
|
&:checked {
|
|
44
51
|
position: relative;
|
|
45
|
-
|
|
46
|
-
|
|
52
|
+
/* Selected fill + checkmark read the surface-provided tokens (with a flat
|
|
53
|
+
* fallback) so the control adapts to OnSurface stepping. */
|
|
54
|
+
background: var(
|
|
55
|
+
--surface-color-foreground-checkbox-selected,
|
|
56
|
+
var(--color-foreground-checkbox-selected)
|
|
57
|
+
);
|
|
58
|
+
border-color: var(
|
|
59
|
+
--surface-color-foreground-checkbox-selected,
|
|
60
|
+
var(--color-foreground-checkbox-selected)
|
|
61
|
+
);
|
|
47
62
|
|
|
48
63
|
&::before {
|
|
49
|
-
background-color: var(
|
|
64
|
+
background-color: var(
|
|
65
|
+
--surface-color-foreground-checkbox-checkmark,
|
|
66
|
+
var(--color-foreground-checkbox-checkmark)
|
|
67
|
+
);
|
|
50
68
|
mask-image: url("/icons/checkmark.svg#checkmark");
|
|
51
69
|
-webkit-mask-image: url("/icons/checkmark.svg#checkmark");
|
|
52
70
|
}
|
|
@@ -54,11 +72,20 @@
|
|
|
54
72
|
|
|
55
73
|
&:indeterminate {
|
|
56
74
|
position: relative;
|
|
57
|
-
background: var(
|
|
58
|
-
|
|
75
|
+
background: var(
|
|
76
|
+
--surface-color-foreground-checkbox-selected,
|
|
77
|
+
var(--color-foreground-checkbox-selected)
|
|
78
|
+
);
|
|
79
|
+
border-color: var(
|
|
80
|
+
--surface-color-foreground-checkbox-selected,
|
|
81
|
+
var(--color-foreground-checkbox-selected)
|
|
82
|
+
);
|
|
59
83
|
|
|
60
84
|
&::before {
|
|
61
|
-
background-color: var(
|
|
85
|
+
background-color: var(
|
|
86
|
+
--surface-color-foreground-checkbox-checkmark,
|
|
87
|
+
var(--color-foreground-checkbox-checkmark)
|
|
88
|
+
);
|
|
62
89
|
mask-image: url("/icons/minus.svg#minus");
|
|
63
90
|
-webkit-mask-image: url("/icons/minus.svg#minus");
|
|
64
91
|
}
|
|
@@ -68,14 +95,16 @@
|
|
|
68
95
|
background: var(--color-foreground-checkbox-unselected-hover);
|
|
69
96
|
}
|
|
70
97
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
98
|
+
/* Hover on a selected/indeterminate box shifts ONLY the fill, not the
|
|
99
|
+
* checkmark/minus glyph (per design review): the background swaps to the
|
|
100
|
+
* hovered selected shade while `::before` keeps its own colour. The hover
|
|
101
|
+
* shade comes from the `--hover--…-selected` channel (criticality-style OKLCH
|
|
102
|
+
* delta shim), replacing the old whole-element `filter: brightness()` that
|
|
103
|
+
* also dimmed the glyph. */
|
|
104
|
+
&:checked:hover:not(:disabled),
|
|
76
105
|
&:indeterminate:hover:not(:disabled) {
|
|
77
|
-
background-color: var(--color-foreground-checkbox-selected);
|
|
78
|
-
|
|
106
|
+
background-color: var(--hover--color-foreground-checkbox-selected);
|
|
107
|
+
border-color: var(--hover--color-foreground-checkbox-selected);
|
|
79
108
|
}
|
|
80
109
|
|
|
81
110
|
&:focus-visible {
|
|
@@ -26,12 +26,13 @@ const MultipleCombobox = ({ id, className, style, options, value, onChange, disa
|
|
|
26
26
|
.map((val) => convertValueToItem(val, options, valueKey))
|
|
27
27
|
.filter(Boolean);
|
|
28
28
|
}, [convertValueToItem, options, valueKey]);
|
|
29
|
-
//
|
|
29
|
+
// Keep selectedItems in sync with the controlled value — on mount and on every
|
|
30
|
+
// change. Must clear as well as populate: an empty/undefined `value` (e.g. after
|
|
31
|
+
// reset) has to drive `selectedItems` back to [], otherwise a later re-render
|
|
32
|
+
// that re-supplies the previous array would resurrect the cleared chips.
|
|
30
33
|
useEffect(() => {
|
|
31
|
-
const values = value;
|
|
32
|
-
|
|
33
|
-
setSelectedItems(convertValuesToItems(values));
|
|
34
|
-
}
|
|
34
|
+
const values = value ?? [];
|
|
35
|
+
setSelectedItems(values.length > 0 ? convertValuesToItems(values) : []);
|
|
35
36
|
}, [value, convertValuesToItems]);
|
|
36
37
|
// Downshift's useMultipleSelection hook for managing multiple selections
|
|
37
38
|
const { getSelectedItemProps, getDropdownProps, addSelectedItem, removeSelectedItem, } = useMultipleSelection({
|
|
@@ -39,8 +40,11 @@ const MultipleCombobox = ({ id, className, style, options, value, onChange, disa
|
|
|
39
40
|
onSelectedItemsChange: ({ selectedItems: newSelectedItems }) => {
|
|
40
41
|
if (newSelectedItems) {
|
|
41
42
|
setSelectedItems(newSelectedItems);
|
|
43
|
+
// Emit [] (never undefined) when the list empties: with a react-hook-form
|
|
44
|
+
// Controller that has a defaultValue, onChange(undefined) reverts the field
|
|
45
|
+
// to that default, resurrecting the removed chips. [] clears cleanly.
|
|
42
46
|
const newValue = newSelectedItems.map((item) => item[valueKey]);
|
|
43
|
-
onChange?.(newValue
|
|
47
|
+
onChange?.(newValue);
|
|
44
48
|
}
|
|
45
49
|
},
|
|
46
50
|
});
|
|
@@ -66,11 +70,13 @@ const MultipleCombobox = ({ id, className, style, options, value, onChange, disa
|
|
|
66
70
|
},
|
|
67
71
|
itemToString: convertItemToString,
|
|
68
72
|
});
|
|
69
|
-
// Reset function to clear selections and input
|
|
73
|
+
// Reset function to clear selections and input. Emits [] (not undefined) so a
|
|
74
|
+
// react-hook-form Controller with a defaultValue stores the cleared state
|
|
75
|
+
// rather than falling back to its default and repopulating the chips.
|
|
70
76
|
const resetSelection = useCallback(() => {
|
|
71
77
|
setSelectedItems([]);
|
|
72
78
|
setInputValue("");
|
|
73
|
-
onChange?.(
|
|
79
|
+
onChange?.([]);
|
|
74
80
|
}, [onChange, setInputValue]);
|
|
75
81
|
return (_jsxs("div", { id: id, style: style, className: [componentCssClassName, className].filter(Boolean).join(" "), children: [_jsx("div", { className: "selected-items", children: selectedItems.map((selectedItem, index) => (_jsxs("button", { ...getSelectedItemProps({ selectedItem, index }), onClick: () => removeSelectedItem(selectedItem), className: "chip", children: [convertItemToString(selectedItem), _jsx("span", { className: "remove-icon", children: "\u00D7" })] }, String(selectedItem[valueKey])))) }), _jsxs("div", { className: "ds input combobox-input chrome", children: [_jsx("input", { className: "p", ...getInputProps(getDropdownProps({ preventKeyAction: isOpen })), placeholder: placeholder, disabled: disabled }), _jsx(ResetButton, { onClick: resetSelection })] }), _jsx(List, { isOpen: isOpen, getMenuProps: getMenuProps, getItemProps: getItemProps, items: items, highlightedIndex: highlightedIndex, convertItemToString: convertItemToString, valueKey: valueKey, fieldValue: selectedItems.map((item) => String(item[valueKey])) })] }));
|
|
76
82
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MultipleCombobox.js","sourceRoot":"","sources":["../../../../../src/lib/subcomponent/ComboboxInput/MultipleCombobox.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAE9D,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEzD,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,OAAO,EACL,mBAAmB,IAAI,0BAA0B,EACjD,kBAAkB,IAAI,yBAAyB,EAC/C,WAAW,IAAI,kBAAkB,GAClC,MAAM,kBAAkB,CAAC;AAC1B,OAAO,cAAc,CAAC;AAEtB,MAAM,qBAAqB,GAAG,kBA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B,QAAQ,EAAE,QAAQ,GAClB,EACF,KAAC,WAAW,IAAC,OAAO,EAAE,cAAc,GAAI,IACpC,EAGN,KAAC,IAAI,IACH,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,YAAY,EAC1B,YAAY,EAAE,YAAY,EAC1B,KAAK,EAAE,KAAK,EACZ,gBAAgB,EAAE,gBAAgB,EAClC,mBAAmB,EAAE,mBAAmB,EACxC,QAAQ,EAAE,QAAQ,EAClB,UAAU,EAAE,aAAa,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,GAC/D,IACE,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
|
@@ -12,4 +12,16 @@
|
|
|
12
12
|
&::-webkit-inner-spin-button {
|
|
13
13
|
display: none;
|
|
14
14
|
}
|
|
15
|
+
|
|
16
|
+
/* NOTE (design review) — two native-<input type="date"> limits parked for Diana:
|
|
17
|
+
* 1. "Suggested" format text → muted: NOT implementable in pure CSS. No
|
|
18
|
+
* placeholder attribute (so `:placeholder-shown` never matches), and
|
|
19
|
+
* `::-webkit-datetime-edit` colours the whole edit region — mask AND typed
|
|
20
|
+
* value — with no empty-state selector, and Firefox ignores it. Needs a
|
|
21
|
+
* custom (non-native) control or a JS empty-state hook.
|
|
22
|
+
* 2. Calendar indicator → pragma icon: no calendar glyph exists in
|
|
23
|
+
* @canonical/ds-assets to mask onto `::-webkit-calendar-picker-indicator`,
|
|
24
|
+
* and that pseudo-element is WebKit/Chromium-only (Firefox draws its own,
|
|
25
|
+
* unstyleable). Needs a new ds-assets glyph + Chrome/Safari-only styling, or
|
|
26
|
+
* a custom control. */
|
|
15
27
|
}
|
|
@@ -12,4 +12,17 @@
|
|
|
12
12
|
&::-webkit-inner-spin-button {
|
|
13
13
|
display: none;
|
|
14
14
|
}
|
|
15
|
+
|
|
16
|
+
/* NOTE (design review) — two native-<input type="datetime-local"> limits
|
|
17
|
+
* parked for Diana:
|
|
18
|
+
* 1. "Suggested" format text → muted: NOT implementable in pure CSS. No
|
|
19
|
+
* placeholder attribute (so `:placeholder-shown` never matches), and
|
|
20
|
+
* `::-webkit-datetime-edit` colours the whole edit region — mask AND typed
|
|
21
|
+
* value — with no empty-state selector, and Firefox ignores it. Needs a
|
|
22
|
+
* custom (non-native) control or a JS empty-state hook.
|
|
23
|
+
* 2. Calendar/clock indicator → pragma icon: no calendar/clock glyph exists in
|
|
24
|
+
* @canonical/ds-assets to mask onto `::-webkit-calendar-picker-indicator`,
|
|
25
|
+
* and that pseudo-element is WebKit/Chromium-only (Firefox draws its own,
|
|
26
|
+
* unstyleable). Needs a new ds-assets glyph + Chrome/Safari-only styling, or
|
|
27
|
+
* a custom control. */
|
|
15
28
|
}
|
|
@@ -21,9 +21,7 @@ const Label = ({ id, children, className, style, name, isOptional, requiredIndic
|
|
|
21
21
|
// informational and belongs in the accessible name.
|
|
22
22
|
const markRequired = requiredIndicator === "required" && !isOptional;
|
|
23
23
|
const showOptionalSuffix = requiredIndicator === "optional" && isOptional;
|
|
24
|
-
return (_jsxs(Element, { id: id, style: style, htmlFor: Element === "label" ? htmlFor : undefined, "data-required": markRequired || undefined, className: [componentCssClassName, "
|
|
25
|
-
.filter(Boolean)
|
|
26
|
-
.join(" "), children: [children || name, showOptionalSuffix && (_jsxs("span", { className: "optional", children: [" (", messages.optional(), ")"] }))] }));
|
|
24
|
+
return (_jsxs(Element, { id: id, style: style, htmlFor: Element === "label" ? htmlFor : undefined, "data-required": markRequired || undefined, className: [componentCssClassName, className].filter(Boolean).join(" "), children: [children || name, showOptionalSuffix && (_jsxs("span", { className: "optional", children: [" (", messages.optional(), ")"] }))] }));
|
|
27
25
|
};
|
|
28
26
|
export default Label;
|
|
29
27
|
//# sourceMappingURL=Label.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Label.js","sourceRoot":"","sources":["../../../../../../src/lib/subcomponent/Field/Label/Label.tsx"],"names":[],"mappings":";AAGA,OAAO,cAAc,CAAC;AAEtB,MAAM,qBAAqB,GAAG,gBAAgB,CAAC;AAE/C,iDAAiD;AACjD,MAAM,eAAe,GAAG;IACtB,QAAQ,EAAE,GAAG,EAAE,CAAC,UAAU;CAC3B,CAAC;AAEF;;;;;GAKG;AACH,MAAM,KAAK,GAAG,CAAC,EACb,EAAE,EACF,QAAQ,EACR,SAAS,EACT,KAAK,EACL,IAAI,EACJ,UAAU,EACV,iBAAiB,GAAG,UAAU,EAC9B,QAAQ,GAAG,eAAe,EAC1B,OAAO,EACP,GAAG,EAAE,OAAO,GAAG,OAAO,GACX,EAAsB,EAAE;IACnC,2EAA2E;IAC3E,uEAAuE;IACvE,8EAA8E;IAC9E,wEAAwE;IACxE,mFAAmF;IACnF,mEAAmE;IACnE,oDAAoD;IACpD,MAAM,YAAY,GAAG,iBAAiB,KAAK,UAAU,IAAI,CAAC,UAAU,CAAC;IACrE,MAAM,kBAAkB,GAAG,iBAAiB,KAAK,UAAU,IAAI,UAAU,CAAC;IAE1E,OAAO,CACL,MAAC,OAAO,IACN,EAAE,EAAE,EAAE,EACN,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,mBACnC,YAAY,IAAI,SAAS,EACxC,SAAS,EAAE,CAAC,qBAAqB,EAAE,
|
|
1
|
+
{"version":3,"file":"Label.js","sourceRoot":"","sources":["../../../../../../src/lib/subcomponent/Field/Label/Label.tsx"],"names":[],"mappings":";AAGA,OAAO,cAAc,CAAC;AAEtB,MAAM,qBAAqB,GAAG,gBAAgB,CAAC;AAE/C,iDAAiD;AACjD,MAAM,eAAe,GAAG;IACtB,QAAQ,EAAE,GAAG,EAAE,CAAC,UAAU;CAC3B,CAAC;AAEF;;;;;GAKG;AACH,MAAM,KAAK,GAAG,CAAC,EACb,EAAE,EACF,QAAQ,EACR,SAAS,EACT,KAAK,EACL,IAAI,EACJ,UAAU,EACV,iBAAiB,GAAG,UAAU,EAC9B,QAAQ,GAAG,eAAe,EAC1B,OAAO,EACP,GAAG,EAAE,OAAO,GAAG,OAAO,GACX,EAAsB,EAAE;IACnC,2EAA2E;IAC3E,uEAAuE;IACvE,8EAA8E;IAC9E,wEAAwE;IACxE,mFAAmF;IACnF,mEAAmE;IACnE,oDAAoD;IACpD,MAAM,YAAY,GAAG,iBAAiB,KAAK,UAAU,IAAI,CAAC,UAAU,CAAC;IACrE,MAAM,kBAAkB,GAAG,iBAAiB,KAAK,UAAU,IAAI,UAAU,CAAC;IAE1E,OAAO,CACL,MAAC,OAAO,IACN,EAAE,EAAE,EAAE,EACN,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,mBACnC,YAAY,IAAI,SAAS,EACxC,SAAS,EAAE,CAAC,qBAAqB,EAAE,SAAS,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,aAEtE,QAAQ,IAAI,IAAI,EAChB,kBAAkB,IAAI,CACrB,gBAAM,SAAS,EAAC,UAAU,mBAAI,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAC3D,IACO,CACX,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,KAAK,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
.ds.field-label {
|
|
2
|
-
font-weight: var(--form-label-font-weight,
|
|
2
|
+
font-weight: var(--form-label-font-weight, normal);
|
|
3
3
|
color: var(--form-label-color);
|
|
4
4
|
/* No side padding by default — the label aligns to the field edge, not the
|
|
5
5
|
* input's inner padding. Overridable via the variable. */
|
|
@@ -18,9 +18,8 @@
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
/* The "(optional)" suffix is a muted hint, visually subordinate to the label
|
|
21
|
-
*
|
|
21
|
+
* — distinguished by colour (the label now uses regular paragraph weight too). */
|
|
22
22
|
& > .optional {
|
|
23
|
-
font-weight: var(--typography-text-primary-font-weight, normal);
|
|
24
23
|
color: var(--color-text-muted);
|
|
25
24
|
}
|
|
26
25
|
}
|
|
@@ -10,34 +10,24 @@ const componentCssClassName = "ds input file-upload";
|
|
|
10
10
|
*
|
|
11
11
|
* `import { FileUploadInput } from "@canonical/react-ds-global-form";`
|
|
12
12
|
*/
|
|
13
|
-
export const FileUploadInput = ({ id, className, style, value, onChange, accept,
|
|
13
|
+
export const FileUploadInput = ({ id, className, style, value, onChange, accept,
|
|
14
|
+
// Destructured out of `otherProps` so they are NOT spread onto the drop-zone
|
|
15
|
+
// <button> as invalid DOM attributes. The FIELD reads them (as RHF validation
|
|
16
|
+
// rules); the presentational input does not enforce them.
|
|
17
|
+
maxSize, maxFiles, multiple = false, disabled = false, ...otherProps }) => {
|
|
14
18
|
const inputRef = useRef(null);
|
|
15
19
|
const [isDragOver, setIsDragOver] = useState(false);
|
|
16
20
|
const files = Array.isArray(value) ? value : [];
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}, [maxSize]);
|
|
21
|
+
/* Presentational only: report the chosen files up via `onChange`. Constraint
|
|
22
|
+
* validation (maxFiles/maxSize) lives on the FIELD as a react-hook-form
|
|
23
|
+
* `validate` rule so violations surface through the standard FieldError,
|
|
24
|
+
* rather than being enforced (and silently dropped) here. `maxFiles`/`maxSize`
|
|
25
|
+
* are still accepted for the field to read and for the native `accept` hint. */
|
|
23
26
|
const addFiles = useCallback((incoming) => {
|
|
24
27
|
const newFiles = Array.from(incoming);
|
|
25
|
-
const errors = [];
|
|
26
|
-
for (const file of newFiles) {
|
|
27
|
-
const error = validateFile(file);
|
|
28
|
-
if (error) {
|
|
29
|
-
errors.push(error);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
if (errors.length > 0) {
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
28
|
const merged = multiple ? [...files, ...newFiles] : newFiles.slice(0, 1);
|
|
36
|
-
if (maxFiles && merged.length > maxFiles) {
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
29
|
onChange?.(merged);
|
|
40
|
-
}, [files, multiple,
|
|
30
|
+
}, [files, multiple, onChange]);
|
|
41
31
|
const removeFile = useCallback((index) => {
|
|
42
32
|
const next = files.filter((_, i) => i !== index);
|
|
43
33
|
onChange?.(next);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileUploadInput.js","sourceRoot":"","sources":["../../../../../src/lib/subcomponent/FileUploadInput/FileUploadInput.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEtD,OAAO,cAAc,CAAC;AAEtB,MAAM,qBAAqB,GAAG,sBAAsB,CAAC;AAErD;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,EAC9B,EAAE,EACF,SAAS,EACT,KAAK,EACL,KAAK,EACL,QAAQ,EACR,MAAM,
|
|
1
|
+
{"version":3,"file":"FileUploadInput.js","sourceRoot":"","sources":["../../../../../src/lib/subcomponent/FileUploadInput/FileUploadInput.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEtD,OAAO,cAAc,CAAC;AAEtB,MAAM,qBAAqB,GAAG,sBAAsB,CAAC;AAErD;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,EAC9B,EAAE,EACF,SAAS,EACT,KAAK,EACL,KAAK,EACL,QAAQ,EACR,MAAM;AACN,6EAA6E;AAC7E,8EAA8E;AAC9E,0DAA0D;AAC1D,OAAO,EACP,QAAQ,EACR,QAAQ,GAAG,KAAK,EAChB,QAAQ,GAAG,KAAK,EAChB,GAAG,UAAU,EACQ,EAAsB,EAAE;IAC7C,MAAM,QAAQ,GAAG,MAAM,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AAC,IAAI,GAAQ,EAChD,eAAM,SAAS,EAAC,aAAa,YAAE,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,GAAQ,EAChE,iBACE,IAAI,EAAC,QAAQ,EACb,SAAS,EAAC,aAAa,EACvB,OAAO,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,gBACpB,UAAU,IAAI,CAAC,IAAI,EAAE,EACjC,QAAQ,EAAE,QAAQ,YAElB,eAAM,SAAS,EAAC,GAAG,uBAAe,GAC3B,KAlBF,GAAG,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,YAAY,EAAE,CAmBvC,CACN,CAAC,GACC,CACN,IACG,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,iDAAiD;AACjD,SAAS,cAAc,CAAC,KAAa;IACnC,IAAI,KAAK,GAAG,IAAI;QAAE,OAAO,GAAG,KAAK,IAAI,CAAC;IACtC,IAAI,KAAK,GAAG,IAAI,GAAG,IAAI;QAAE,OAAO,GAAG,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC;IAClE,OAAO,GAAG,CAAC,KAAK,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC;AACpD,CAAC;AAED,eAAe,eAAe,CAAC"}
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
align-items: center;
|
|
9
9
|
justify-content: center;
|
|
10
10
|
box-sizing: border-box;
|
|
11
|
-
min-height: calc(var(--
|
|
11
|
+
min-height: calc(var(--dimension-400) * 4); /* 128px */
|
|
12
12
|
/* Compensate padding for border so total stays on baseline grid */
|
|
13
13
|
padding: calc(
|
|
14
14
|
var(--form-input-padding-block) -
|
|
@@ -85,8 +85,8 @@
|
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
& > .file-list > .file-item > .file-preview {
|
|
88
|
-
width:
|
|
89
|
-
height:
|
|
88
|
+
width: var(--dimension-400); /* 32px */
|
|
89
|
+
height: var(--dimension-400); /* 32px */
|
|
90
90
|
object-fit: cover;
|
|
91
91
|
border-radius: var(--form-input-border-radius);
|
|
92
92
|
flex-shrink: 0;
|
|
@@ -117,6 +117,9 @@
|
|
|
117
117
|
color: var(--color-text);
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
+
/* biome-ignore lint/style/noDescendingSpecificity: :disabled follows :hover by
|
|
121
|
+
interaction-state order; both target the same element and reordering would
|
|
122
|
+
change the cascade for no visual gain. */
|
|
120
123
|
&:disabled {
|
|
121
124
|
cursor: not-allowed;
|
|
122
125
|
opacity: 0.5;
|
|
@@ -29,12 +29,12 @@
|
|
|
29
29
|
padding-inline: var(--form-field-inline-gap);
|
|
30
30
|
border: none;
|
|
31
31
|
background: transparent;
|
|
32
|
-
color: var(--color-
|
|
32
|
+
color: var(--color-icon);
|
|
33
33
|
cursor: pointer;
|
|
34
34
|
|
|
35
35
|
& > .reveal-icon {
|
|
36
|
-
width:
|
|
37
|
-
height:
|
|
36
|
+
width: var(--dimension-200); /* 16px */
|
|
37
|
+
height: var(--dimension-200);
|
|
38
38
|
background-color: currentColor;
|
|
39
39
|
mask-repeat: no-repeat;
|
|
40
40
|
mask-position: center;
|
|
@@ -54,9 +54,8 @@
|
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
57
|
+
/* No hover colour change: the reveal toggle keeps `--color-icon` in all
|
|
58
|
+
* pointer states (per design review). */
|
|
60
59
|
|
|
61
60
|
&:focus-visible {
|
|
62
61
|
outline: none;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useCallback, useMemo, useState } from "react";
|
|
3
|
-
import { applyPhoneMask, countries as defaultCountries, } from "
|
|
3
|
+
import { applyPhoneMask, countries as defaultCountries, } from "../../utils/countries/index.js";
|
|
4
4
|
import "./styles.css";
|
|
5
5
|
const componentCssClassName = "ds input phone chrome";
|
|
6
6
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PhoneInput.js","sourceRoot":"","sources":["../../../../../src/lib/subcomponent/PhoneInput/PhoneInput.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACvD,OAAO,EACL,cAAc,EAEd,SAAS,IAAI,gBAAgB,GAE9B,MAAM
|
|
1
|
+
{"version":3,"file":"PhoneInput.js","sourceRoot":"","sources":["../../../../../src/lib/subcomponent/PhoneInput/PhoneInput.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACvD,OAAO,EACL,cAAc,EAEd,SAAS,IAAI,gBAAgB,GAE9B,MAAM,gCAAgC,CAAC;AAExC,OAAO,cAAc,CAAC;AAEtB,MAAM,qBAAqB,GAAG,uBAAuB,CAAC;AAEtD;;;;;;GAMG;AACH,SAAS,SAAS,CAAC,IAAY;IAC7B,MAAM,KAAK,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;IACjC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IAC3C,OAAO,KAAK,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,EAAE,CACtC,MAAM,CAAC,aAAa,CAAC,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAClD,CAAC;AACJ,CAAC;AAED,oEAAoE;AACpE,SAAS,aAAa,CAAC,QAAgB;IACrC,OAAO,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;AAC1D,CAAC;AAED,wEAAwE;AACxE,SAAS,YAAY,CACnB,OAAoB,EACpB,OAAiC;IA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IAAI,EAAC,KAAK,EACV,SAAS,EAAC,gBAAgB,EAC1B,SAAS,EAAC,KAAK,EACf,KAAK,EAAE,aAAa,EACpB,QAAQ,EAAE,kBAAkB,EAC5B,QAAQ,EAAE,QAAQ,gBACP,cAAc,GACzB,IACE,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -6,21 +6,39 @@
|
|
|
6
6
|
appearance: none;
|
|
7
7
|
box-sizing: border-box;
|
|
8
8
|
margin-inline: var(--form-input-padding-inline);
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
/* 16px control — a fixed element size, not a baseline multiple (the 4px-baseline
|
|
10
|
+
spike halved the old `--space-baseline × 2`). Stable --dimension-200 (16px). */
|
|
11
|
+
width: var(--dimension-200);
|
|
12
|
+
height: var(--dimension-200);
|
|
11
13
|
border: var(--dimension-stroke-thickness-medium) solid var(--color-border);
|
|
12
14
|
border-radius: 50%;
|
|
13
|
-
background-color: var(
|
|
15
|
+
background-color: var(
|
|
16
|
+
--surface-color-foreground-radio-unselected,
|
|
17
|
+
var(--color-foreground-radio-unselected)
|
|
18
|
+
);
|
|
14
19
|
cursor: pointer;
|
|
15
20
|
transition:
|
|
16
21
|
background-color 150ms ease,
|
|
17
22
|
border-color 150ms ease;
|
|
18
23
|
|
|
19
24
|
&:checked {
|
|
20
|
-
|
|
25
|
+
/* Dot = selected token, ring fill = unselected token; both surface-provided
|
|
26
|
+
* (flat fallback) so the control adapts to OnSurface stepping. */
|
|
27
|
+
border-color: var(
|
|
28
|
+
--surface-color-foreground-radio-selected,
|
|
29
|
+
var(--color-foreground-radio-selected)
|
|
30
|
+
);
|
|
21
31
|
background: radial-gradient(
|
|
22
|
-
var(
|
|
23
|
-
|
|
32
|
+
var(
|
|
33
|
+
--surface-color-foreground-radio-selected,
|
|
34
|
+
var(--color-foreground-radio-selected)
|
|
35
|
+
)
|
|
36
|
+
40%,
|
|
37
|
+
var(
|
|
38
|
+
--surface-color-foreground-radio-unselected,
|
|
39
|
+
var(--color-foreground-radio-unselected)
|
|
40
|
+
)
|
|
41
|
+
41%
|
|
24
42
|
);
|
|
25
43
|
}
|
|
26
44
|
|
|
@@ -28,8 +46,19 @@
|
|
|
28
46
|
background-color: var(--color-foreground-radio-unselected-hover);
|
|
29
47
|
}
|
|
30
48
|
|
|
49
|
+
/* Hover on a selected radio shifts only the dot's fill, not via a whole-element
|
|
50
|
+
* brightness filter (which would also dim the ring). Re-paint the gradient with
|
|
51
|
+
* the hovered selected shade from the `--hover--…-selected` channel. */
|
|
31
52
|
&:checked:hover:not(:disabled) {
|
|
32
|
-
|
|
53
|
+
border-color: var(--hover--color-foreground-radio-selected);
|
|
54
|
+
background: radial-gradient(
|
|
55
|
+
var(--hover--color-foreground-radio-selected) 40%,
|
|
56
|
+
var(
|
|
57
|
+
--surface-color-foreground-radio-unselected,
|
|
58
|
+
var(--color-foreground-radio-unselected)
|
|
59
|
+
)
|
|
60
|
+
41%
|
|
61
|
+
);
|
|
33
62
|
}
|
|
34
63
|
|
|
35
64
|
&:focus-visible {
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
/* Element box is as tall as the THUMB (16px), so the thumb and its focus
|
|
5
5
|
* ring are never clipped in a flex row; the visible 8px track is painted by
|
|
6
6
|
* the track pseudo-elements below, vertically centred within this box. */
|
|
7
|
-
height:
|
|
7
|
+
height: var(--dimension-200); /* 16px */
|
|
8
8
|
background: transparent;
|
|
9
9
|
border: none;
|
|
10
10
|
outline: none;
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* border even after `appearance: none` on the element — THIS is the visible
|
|
15
15
|
* border. Style the track here: flat, no border, 8px tall. */
|
|
16
16
|
&::-webkit-slider-runnable-track {
|
|
17
|
-
height: var(--
|
|
17
|
+
height: var(--dimension-100); /* 8px */
|
|
18
18
|
background: var(--color-foreground-slider-track);
|
|
19
19
|
border: none;
|
|
20
20
|
border-radius: var(--dimension-radius-small);
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
/* Firefox draws the track via its own pseudo-element with its own UA border —
|
|
24
24
|
* zero it and paint the flat track here to match WebKit. */
|
|
25
25
|
&::-moz-range-track {
|
|
26
|
-
height: var(--
|
|
26
|
+
height: var(--dimension-100); /* 8px */
|
|
27
27
|
background: var(--color-foreground-slider-track);
|
|
28
28
|
border: none;
|
|
29
29
|
border-radius: var(--dimension-radius-small);
|
|
@@ -31,10 +31,11 @@
|
|
|
31
31
|
|
|
32
32
|
&::-webkit-slider-thumb {
|
|
33
33
|
appearance: none;
|
|
34
|
-
width:
|
|
35
|
-
height:
|
|
36
|
-
/* Re-centre the 16px thumb on the 8px runnable-track: (8 − 16) / 2 = −4px.
|
|
37
|
-
|
|
34
|
+
width: var(--dimension-200); /* 16px */
|
|
35
|
+
height: var(--dimension-200); /* 16px */
|
|
36
|
+
/* Re-centre the 16px thumb on the 8px runnable-track: (8 − 16) / 2 = −4px.
|
|
37
|
+
Derived from the actual track/thumb dimension tokens, not the baseline unit. */
|
|
38
|
+
margin-top: calc((var(--dimension-100) - var(--dimension-200)) / 2);
|
|
38
39
|
border-radius: 50%;
|
|
39
40
|
background: var(--color-foreground-slider-progress);
|
|
40
41
|
border: none;
|
|
@@ -42,8 +43,8 @@
|
|
|
42
43
|
}
|
|
43
44
|
|
|
44
45
|
&::-moz-range-thumb {
|
|
45
|
-
width:
|
|
46
|
-
height:
|
|
46
|
+
width: var(--dimension-200); /* 16px */
|
|
47
|
+
height: var(--dimension-200); /* 16px */
|
|
47
48
|
border-radius: 50%;
|
|
48
49
|
background: var(--color-foreground-slider-progress);
|
|
49
50
|
border: none;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useId } from "react";
|
|
3
|
+
import "./styles.css";
|
|
4
|
+
const componentCssClassName = "ds form-rating";
|
|
5
|
+
const defaultFormatStarLabel = (value, count) => `${value} of ${count} star${count === 1 ? "" : "s"}`;
|
|
6
|
+
/**
|
|
7
|
+
* Presentational star-rating input — pure markup, no react-hook-form. It is a
|
|
8
|
+
* radio group of `count` stars (5 or 10): exactly one value is selectable, so it
|
|
9
|
+
* inherits the native radio semantics — arrow keys move and select, Tab reaches
|
|
10
|
+
* the group once, and each choice is announced with its name and position.
|
|
11
|
+
*
|
|
12
|
+
* With `allowHalf`, every star carries two overlaid radio targets — the left
|
|
13
|
+
* half selects a half rating (n − 0.5), the right half the full star (n) — so
|
|
14
|
+
* the same five (or ten) stars stay on screen and clicking a star's left side
|
|
15
|
+
* gives a half. The fill is masked: a star is fully or half filled by clipping
|
|
16
|
+
* the solid-star glyph over the outline one.
|
|
17
|
+
*
|
|
18
|
+
* Usable standalone (controlled via `value`/`onChange`, or uncontrolled via
|
|
19
|
+
* `defaultValue`).
|
|
20
|
+
*
|
|
21
|
+
* `import { RatingInput } from "@canonical/react-ds-global-form";`
|
|
22
|
+
*/
|
|
23
|
+
export const RatingInput = ({ id, className, style, name, count = 5, allowHalf = false, value, defaultValue, onChange, disabled = false, formatStarLabel = defaultFormatStarLabel, ...labelling }) => {
|
|
24
|
+
const reactId = useId();
|
|
25
|
+
const groupId = id ?? reactId;
|
|
26
|
+
const stars = Array.from({ length: count }, (_, i) => i + 1);
|
|
27
|
+
// For a star `n`, the selectable ratings it offers: [n] normally, or
|
|
28
|
+
// [n - 0.5, n] when half ratings are allowed (left half then right half).
|
|
29
|
+
const ratingsFor = (star) => allowHalf ? [star - 0.5, star] : [star];
|
|
30
|
+
const isChecked = (rating) => value !== undefined ? value === rating : undefined;
|
|
31
|
+
return (_jsx("div", { id: groupId, style: style, className: [componentCssClassName, allowHalf && "half", className]
|
|
32
|
+
.filter(Boolean)
|
|
33
|
+
.join(" "), role: "radiogroup", "aria-label": labelling["aria-labelledby"]
|
|
34
|
+
? undefined
|
|
35
|
+
: (labelling["aria-label"] ?? "Rating"), "aria-labelledby": labelling["aria-labelledby"], children: stars.map((star) => (_jsxs("span", { className: "star", children: [_jsx("span", { className: "star-glyph", "aria-hidden": "true" }), ratingsFor(star).map((rating) => {
|
|
36
|
+
const half = rating % 1 !== 0;
|
|
37
|
+
const ratingId = `${groupId}-${rating}`;
|
|
38
|
+
const label = formatStarLabel(rating, count);
|
|
39
|
+
return (
|
|
40
|
+
// The label is the positioned click target and wraps its own
|
|
41
|
+
// (visually-hidden) radio, so it is a labelled control.
|
|
42
|
+
_jsxs("label", { className: ["star-target", half ? "left" : "right"].join(" "), title: label, children: [_jsx("input", { id: ratingId, className: "star-input", type: "radio", name: name, value: rating, disabled: disabled, "data-rating": rating, ...(value !== undefined
|
|
43
|
+
? { checked: isChecked(rating) }
|
|
44
|
+
: { defaultChecked: defaultValue === rating }), onChange: () => onChange?.(rating) }), _jsx("span", { className: "ds-visually-hidden", children: label })] }, rating));
|
|
45
|
+
})] }, star))) }));
|
|
46
|
+
};
|
|
47
|
+
export default RatingInput;
|
|
48
|
+
//# sourceMappingURL=RatingInput.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RatingInput.js","sourceRoot":"","sources":["../../../../../src/lib/subcomponent/RatingInput/RatingInput.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAqB,KAAK,EAAE,MAAM,OAAO,CAAC;AAEjD,OAAO,cAAc,CAAC;AAEtB,MAAM,qBAAqB,GAAG,gBAAgB,CAAC;AAE/C,MAAM,sBAAsB,GAAG,CAAC,KAAa,EAAE,KAAa,EAAE,EAAE,CAC9D,GAAG,KAAK,OAAO,KAAK,QAAQ,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC;AAEvD;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,EAC1B,EAAE,EACF,SAAS,EACT,KAAK,EACL,IAAI,EACJ,KAAK,GAAG,CAAC,EACT,SAAS,GAAG,KAAK,EACjB,KAAK,EACL,YAAY,EACZ,QAAQ,EACR,QAAQ,G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