@canonical/react-ds-global-form 0.37.0 → 0.40.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.
Files changed (43) hide show
  1. package/README.md +40 -0
  2. package/dist/esm/density.css +320 -302
  3. package/dist/esm/docs/examples/density-examples.css +19 -14
  4. package/dist/esm/index.css +361 -335
  5. package/dist/esm/lib/_work_in_progress/DensityTestbed/baseline-system.css +71 -64
  6. package/dist/esm/lib/_work_in_progress/DensityTestbed/density.testbed.css +127 -123
  7. package/dist/esm/lib/common/Wrapper/ToggleWrapper.css +73 -54
  8. package/dist/esm/lib/common/Wrapper/styles.css +35 -31
  9. package/dist/esm/lib/component/ChoicesField/common/Option/Option.js +4 -1
  10. package/dist/esm/lib/component/ChoicesField/common/Option/Option.js.map +1 -1
  11. package/dist/esm/lib/component/ChoicesField/styles.css +195 -163
  12. package/dist/esm/lib/component/RangeField/common/RangeControl/styles.css +39 -35
  13. package/dist/esm/lib/component/RichChoicesField/styles.css +93 -89
  14. package/dist/esm/lib/subcomponent/CheckboxInput/styles.css +115 -111
  15. package/dist/esm/lib/subcomponent/ColorInput/styles.css +177 -173
  16. package/dist/esm/lib/subcomponent/ComboboxInput/SingleCombobox.js.map +1 -1
  17. package/dist/esm/lib/subcomponent/ComboboxInput/common/List/styles.css +33 -29
  18. package/dist/esm/lib/subcomponent/ComboboxInput/common/ResetButton/styles.css +21 -17
  19. package/dist/esm/lib/subcomponent/ComboboxInput/styles.css +59 -55
  20. package/dist/esm/lib/subcomponent/DateInput/styles.css +23 -19
  21. package/dist/esm/lib/subcomponent/DateTimeInput/styles.css +24 -20
  22. package/dist/esm/lib/subcomponent/Field/Description/styles.css +9 -5
  23. package/dist/esm/lib/subcomponent/Field/Error/styles.css +9 -5
  24. package/dist/esm/lib/subcomponent/Field/Label/Label.js +2 -2
  25. package/dist/esm/lib/subcomponent/Field/Label/Label.js.map +1 -1
  26. package/dist/esm/lib/subcomponent/Field/Label/styles.css +25 -21
  27. package/dist/esm/lib/subcomponent/FileUploadInput/styles.css +125 -119
  28. package/dist/esm/lib/subcomponent/NumberInput/styles.css +32 -28
  29. package/dist/esm/lib/subcomponent/PasswordInput/styles.css +58 -54
  30. package/dist/esm/lib/subcomponent/PhoneInput/styles.css +53 -49
  31. package/dist/esm/lib/subcomponent/RadioInput/styles.css +70 -66
  32. package/dist/esm/lib/subcomponent/RangeInput/styles.css +74 -70
  33. package/dist/esm/lib/subcomponent/RatingInput/styles.css +132 -128
  34. package/dist/esm/lib/subcomponent/SelectInput/styles.css +44 -40
  35. package/dist/esm/lib/subcomponent/SwitchInput/styles.css +90 -86
  36. package/dist/esm/lib/subcomponent/TextInput/styles.css +30 -26
  37. package/dist/esm/lib/subcomponent/TextareaInput/styles.css +14 -10
  38. package/dist/esm/lib/subcomponent/TimeInput/styles.css +19 -15
  39. package/dist/esm/lib/utils/middleware/addRESTValidation.js +1 -1
  40. package/dist/esm/lib/utils/middleware/addRESTValidation.js.map +1 -1
  41. package/dist/types/lib/component/ChoicesField/common/Option/Option.d.ts.map +1 -1
  42. package/dist/types/lib/subcomponent/ComboboxInput/SingleCombobox.d.ts.map +1 -1
  43. package/package.json +17 -16
@@ -1,4 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { CheckboxInput } from "../../../../subcomponent/CheckboxInput/index.js";
3
+ import { Label } from "../../../../subcomponent/Field/index.js";
4
+ import { RadioInput } from "../../../../subcomponent/RadioInput/index.js";
2
5
  import useOptionAriaProperties from "../../../../utils/hooks/useOptionAriaProperties.js";
3
6
  const componentCssClassName = "ds option";
4
7
  /**
@@ -11,7 +14,7 @@ const Option = ({ name, type, option, checked, disabled, onChange, }) => {
11
14
  const ariaProps = useOptionAriaProperties(name, option.value);
12
15
  return (_jsxs("div", { className: [componentCssClassName, disabled && "disabled"]
13
16
  .filter(Boolean)
14
- .join(" "), children: [_jsx("input", { name: name, value: option.value, disabled: disabled, type: type, checked: checked, onChange: onChange, ...ariaProps.input }), _jsx("label", { className: "p", ...ariaProps.label, children: option.label })] }));
17
+ .join(" "), children: [type === "radio" ? (_jsx(RadioInput, { name: name, value: option.value, disabled: disabled, checked: checked, onChange: onChange, ...ariaProps.input })) : (_jsx(CheckboxInput, { name: name, value: option.value, disabled: disabled, checked: checked, onChange: onChange, ...ariaProps.input })), _jsx(Label, { name: name, isOptional: true, className: "p", ...ariaProps.label, children: option.label })] }));
15
18
  };
16
19
  export default Option;
17
20
  //# sourceMappingURL=Option.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Option.js","sourceRoot":"","sources":["../../../../../../../src/lib/component/ChoicesField/common/Option/Option.tsx"],"names":[],"mappings":";AAGA,OAAO,uBAAuB,MAAM,oDAAoD,CAAC;AAGzF,MAAM,qBAAqB,GAAG,WAAW,CAAC;AAE1C;;;;;GAKG;AACH,MAAM,MAAM,GAAG,CAAC,EACd,IAAI,EACJ,IAAI,EACJ,MAAM,EACN,OAAO,EACP,QAAQ,EACR,QAAQ,GACI,EAAsB,EAAE;IACpC,MAAM,SAAS,GAAG,uBAAuB,CAAC,IAAI,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;IAC9D,OAAO,CACL,eACE,SAAS,EAAE,CAAC,qBAAqB,EAAE,QAAQ,IAAI,UAAU,CAAC;aACvD,MAAM,CAAC,OAAO,CAAC;aACf,IAAI,CAAC,GAAG,CAAC,aAEZ,gBACE,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,MAAM,CAAC,KAAK,EACnB,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,QAAQ,KACd,SAAS,CAAC,KAAK,GACnB,EAEF,gBAAO,SAAS,EAAC,GAAG,KAAK,SAAS,CAAC,KAAK,YACrC,MAAM,CAAC,KAAK,GACP,IACJ,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,MAAM,CAAC"}
1
+ {"version":3,"file":"Option.js","sourceRoot":"","sources":["../../../../../../../src/lib/component/ChoicesField/common/Option/Option.tsx"],"names":[],"mappings":";AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,iDAAiD,CAAC;AAChF,OAAO,EAAE,KAAK,EAAE,MAAM,yCAAyC,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,8CAA8C,CAAC;AAC1E,OAAO,uBAAuB,MAAM,oDAAoD,CAAC;AAGzF,MAAM,qBAAqB,GAAG,WAAW,CAAC;AAE1C;;;;;GAKG;AACH,MAAM,MAAM,GAAG,CAAC,EACd,IAAI,EACJ,IAAI,EACJ,MAAM,EACN,OAAO,EACP,QAAQ,EACR,QAAQ,GACI,EAAsB,EAAE;IACpC,MAAM,SAAS,GAAG,uBAAuB,CAAC,IAAI,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;IAC9D,OAAO,CACL,eACE,SAAS,EAAE,CAAC,qBAAqB,EAAE,QAAQ,IAAI,UAAU,CAAC;aACvD,MAAM,CAAC,OAAO,CAAC;aACf,IAAI,CAAC,GAAG,CAAC,aAEX,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,CAClB,KAAC,UAAU,IACT,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,MAAM,CAAC,KAAK,EACnB,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,QAAQ,KACd,SAAS,CAAC,KAAK,GACnB,CACH,CAAC,CAAC,CAAC,CACF,KAAC,aAAa,IACZ,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,MAAM,CAAC,KAAK,EACnB,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,QAAQ,KACd,SAAS,CAAC,KAAK,GACnB,CACH,EAID,KAAC,KAAK,IAAC,IAAI,EAAE,IAAI,EAAE,UAAU,QAAC,SAAS,EAAC,GAAG,KAAK,SAAS,CAAC,KAAK,YAC5D,MAAM,CAAC,KAAK,GACP,IACJ,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,MAAM,CAAC"}
@@ -1,190 +1,222 @@
1
- .ds.form-choices {
2
- border: none;
3
- padding: 0;
4
- padding-inline: var(--form-input-padding-inline);
5
- margin: 0;
6
- display: flex;
7
- flex-wrap: wrap;
8
- /* Row gap gives stacked/wrapped options vertical breathing room (was 0, so
9
- * stacked items touched); column gap is the inline separation (per review). */
10
- gap: var(--form-group-gap) var(--container-gap-loose);
11
-
12
- /* Stacked: one option per line */
13
- &.stacked {
14
- flex-direction: column;
15
- flex-wrap: nowrap;
16
- }
17
-
18
- /* Columns: a grid of equal-width columns. Each option fills its cell, so the
19
- * option WIDTH is column-based rather than content-based. The column count
20
- * comes from `--choices-columns` (set from the `columns` prop). */
21
- &.columns {
22
- display: grid;
23
- grid-template-columns: repeat(var(--choices-columns, 2), 1fr);
1
+ /* Layer: ds.components.global (@canonical/styles README, "Cascade layers"). */
2
+
3
+ @layer ds.components.global {
4
+ .ds.form-choices {
5
+ border: none;
6
+ padding: 0;
7
+ padding-inline: var(--form-input-padding-inline);
8
+ margin: 0;
9
+ display: flex;
10
+ flex-wrap: wrap;
11
+ /* Row gap gives stacked/wrapped options vertical breathing room (was 0, so
12
+ * stacked items touched); column gap is the inline separation (per review). */
24
13
  gap: var(--form-group-gap) var(--container-gap-loose);
25
- }
26
14
 
27
- /* Each option (common/Option, `.ds.option`) is styled here, scoped to this
28
- * group so the generic class cannot collide with options elsewhere. */
29
- & > .ds.option {
30
- direction: inherit;
31
- display: flex;
32
- align-items: baseline;
33
- gap: var(--space-100);
34
- cursor: pointer;
15
+ /* Stacked: one option per line */
16
+ &.stacked {
17
+ flex-direction: column;
18
+ flex-wrap: nowrap;
19
+ }
35
20
 
36
- &.disabled {
37
- cursor: not-allowed;
38
- opacity: 0.5;
21
+ /* Columns: a grid of equal-width columns. Each option fills its cell, so the
22
+ * option WIDTH is column-based rather than content-based. The column count
23
+ * comes from `--choices-columns` (set from the `columns` prop). */
24
+ &.columns {
25
+ display: grid;
26
+ grid-template-columns: repeat(var(--choices-columns, 2), 1fr);
27
+ gap: var(--form-group-gap) var(--container-gap-loose);
39
28
  }
40
29
 
41
- & > input[type="radio"] {
42
- appearance: none;
43
- box-sizing: border-box;
44
- width: var(--dimension-200); /* 16px */
45
- height: var(--dimension-200); /* 16px */
46
- border: var(--dimension-stroke-thickness-medium) solid var(--color-border);
47
- border-radius: 50%;
48
- background-color: var(
49
- --surface-color-foreground-radio-unselected,
50
- var(--color-foreground-radio-unselected)
51
- );
52
- cursor: inherit;
53
- transition:
54
- background-color 150ms ease,
55
- border-color 150ms ease;
56
-
57
- &:checked {
58
- border-color: var(
59
- --surface-color-foreground-radio-selected,
60
- var(--color-foreground-radio-selected)
61
- );
62
- background: radial-gradient(
63
- var(
64
- --surface-color-foreground-radio-selected,
65
- var(--color-foreground-radio-selected)
66
- )
67
- 40%,
68
- var(
69
- --surface-color-foreground-radio-unselected,
70
- var(--color-foreground-radio-unselected)
71
- )
72
- 41%
73
- );
30
+ /* Each option (common/Option, `.ds.option`) is styled here, scoped to this
31
+ * group so the generic class cannot collide with options elsewhere. */
32
+ & > .ds.option {
33
+ direction: inherit;
34
+ display: flex;
35
+ align-items: center;
36
+ gap: var(--space-100);
37
+ cursor: pointer;
38
+
39
+ label {
40
+ padding: 0;
74
41
  }
75
42
 
76
- &:hover:not(:disabled):not(:checked) {
77
- background-color: var(--color-foreground-radio-unselected-hover);
43
+ /* RadioInput/CheckboxInput carry their own padding margins
44
+ * (--form-input-padding-inline); options align to the group edge. */
45
+ & > input {
46
+ margin-inline: 0;
78
47
  }
79
48
 
80
- /* Hover shifts only the dot's fill (channel shade), not a whole-element
81
- * brightness filter that would also dim the ring. */
82
- &:checked:hover:not(:disabled) {
83
- border-color: var(--hover--color-foreground-radio-selected);
84
- background: radial-gradient(
85
- var(--hover--color-foreground-radio-selected) 40%,
86
- var(
87
- --surface-color-foreground-radio-unselected,
88
- var(--color-foreground-radio-unselected)
89
- )
90
- 41%
91
- );
49
+ &.disabled {
50
+ cursor: not-allowed;
51
+
52
+ /* A disabled option reads as unavailable: the label text takes the
53
+ disabled text token (color.text.disabled), matching the input's
54
+ own disabled chrome instead of dimming the whole row with opacity. */
55
+ & label {
56
+ color: var(--form-label-color-disabled, var(--color-text-disabled));
57
+ &[data-required]::after {
58
+ color: var(
59
+ --form-required-marker-color-disabled,
60
+ var(--form-label-color-disabled, var(--color-text-disabled))
61
+ );
62
+ }
63
+ }
92
64
  }
93
65
 
94
- &:focus-visible {
95
- outline: none;
96
- border-color: var(--color-focusRing);
97
- box-shadow: 0 0 0 1px var(--color-focusRing);
98
- }
66
+ & > input[type="radio"] {
67
+ appearance: none;
68
+ box-sizing: border-box;
69
+ width: var(--dimension-200); /* 16px */
70
+ height: var(--dimension-200); /* 16px */
71
+ border: var(--dimension-stroke-thickness-medium) solid
72
+ var(--color-border);
73
+ border-radius: 50%;
74
+ background-color: var(
75
+ --surface-color-foreground-radio-unselected,
76
+ var(--color-foreground-radio-unselected)
77
+ );
78
+ cursor: inherit;
79
+ transition:
80
+ background-color var(--motion-duration-fast) ease,
81
+ border-color var(--motion-duration-fast) ease;
82
+
83
+ &:checked {
84
+ border-color: var(
85
+ --surface-color-foreground-radio-selected,
86
+ var(--color-foreground-radio-selected)
87
+ );
88
+ background: radial-gradient(
89
+ var(
90
+ --surface-color-foreground-radio-unselected,
91
+ var(--color-foreground-radio-unselected)
92
+ )
93
+ 30%,
94
+ var(
95
+ --surface-color-foreground-radio-selected,
96
+ var(--color-foreground-radio-selected)
97
+ )
98
+ 31%
99
+ );
100
+ }
99
101
 
100
- &:disabled {
101
- border-color: var(--color-border-disabled);
102
- background-color: var(--color-foreground-radio-unselected-disabled);
103
- }
104
- }
102
+ &:hover:not(:disabled):not(:checked) {
103
+ background-color: var(--color-foreground-radio-unselected-hover);
104
+ }
105
+
106
+ /* Hover shifts only the dot's fill (channel shade), not a whole-element
107
+ * brightness filter that would also dim the ring. */
108
+ &:checked:hover:not(:disabled) {
109
+ border-color: var(--hover--color-foreground-radio-selected);
110
+ background: radial-gradient(
111
+ var(
112
+ --surface-color-foreground-radio-unselected,
113
+ var(--color-foreground-radio-unselected)
114
+ )
115
+ 30%,
116
+ var(--hover--color-foreground-radio-selected) 31%
117
+ );
118
+ }
119
+
120
+ &:focus-visible {
121
+ outline: none;
122
+ border-color: var(--color-focus-ring);
123
+ box-shadow: 0 0 0 1px var(--color-focus-ring);
124
+ }
105
125
 
106
- & > input[type="checkbox"] {
107
- appearance: none;
108
- box-sizing: border-box;
109
- position: relative;
110
- width: var(--dimension-200); /* 16px */
111
- height: var(--dimension-200); /* 16px */
112
- border: var(--dimension-stroke-thickness-medium) solid var(--color-border);
113
- border-radius: var(--dimension-radius-small);
114
- background-color: var(
115
- --surface-color-foreground-checkbox-unselected,
116
- var(--color-foreground-checkbox-unselected)
117
- );
118
- cursor: inherit;
119
- transition:
120
- background-color 150ms ease,
121
- border-color 150ms ease;
122
-
123
- /* Glyph as a masked pseudo-element so it takes the checkmark token
124
- * (see CheckboxInput); the colour+mask live together under :checked so
125
- * the unchecked box never paints a solid square. */
126
- &::before {
127
- content: "";
128
- position: absolute;
129
- inset: 0;
130
- mask-repeat: no-repeat;
131
- mask-position: center;
132
- mask-size: 75%;
133
- -webkit-mask-repeat: no-repeat;
134
- -webkit-mask-position: center;
135
- -webkit-mask-size: 75%;
126
+ &:disabled {
127
+ border-color: var(--color-border-disabled);
128
+ background-color: var(--color-foreground-radio-unselected-disabled);
129
+ }
136
130
  }
137
131
 
138
- &:checked {
139
- background: var(
140
- --surface-color-foreground-checkbox-selected,
141
- var(--color-foreground-checkbox-selected)
142
- );
143
- border-color: var(
144
- --surface-color-foreground-checkbox-selected,
145
- var(--color-foreground-checkbox-selected)
132
+ & > input[type="checkbox"] {
133
+ appearance: none;
134
+ box-sizing: border-box;
135
+ position: relative;
136
+ width: var(--dimension-200); /* 16px */
137
+ height: var(--dimension-200); /* 16px */
138
+ border: var(--dimension-stroke-thickness-medium) solid
139
+ var(--color-border);
140
+ border-radius: var(--dimension-radius-small);
141
+ background-color: var(
142
+ --surface-color-foreground-checkbox-unselected,
143
+ var(--color-foreground-checkbox-unselected)
146
144
  );
147
-
145
+ cursor: inherit;
146
+ transition:
147
+ background-color var(--motion-duration-fast) ease,
148
+ border-color var(--motion-duration-fast) ease;
149
+
150
+ /* Glyph as a masked pseudo-element so it takes the checkmark token
151
+ * (see CheckboxInput); the colour+mask live together under :checked so
152
+ * the unchecked box never paints a solid square. */
148
153
  &::before {
149
- background-color: var(
150
- --surface-color-foreground-checkbox-checkmark,
151
- var(--color-foreground-checkbox-checkmark)
152
- );
153
- mask-image: url("/icons/checkmark.svg#checkmark");
154
- -webkit-mask-image: url("/icons/checkmark.svg#checkmark");
154
+ content: "";
155
+ position: absolute;
156
+ inset: 0;
157
+ mask-repeat: no-repeat;
158
+ mask-position: center;
159
+ mask-size: 100%;
160
+ -webkit-mask-repeat: no-repeat;
161
+ -webkit-mask-position: center;
162
+ -webkit-mask-size: 100%;
155
163
  }
156
- }
157
164
 
158
- &:hover:not(:disabled):not(:checked) {
159
- background-color: var(--color-foreground-checkbox-unselected-hover);
160
- }
165
+ &:checked {
166
+ background: var(
167
+ --surface-color-foreground-checkbox-selected,
168
+ var(--color-foreground-checkbox-selected)
169
+ );
170
+ border-color: var(
171
+ --surface-color-foreground-checkbox-selected,
172
+ var(--color-foreground-checkbox-selected)
173
+ );
161
174
 
162
- /* Hover shifts only the fill (channel shade), not the masked checkmark. */
163
- &:checked:hover:not(:disabled) {
164
- background-color: var(--hover--color-foreground-checkbox-selected);
165
- border-color: var(--hover--color-foreground-checkbox-selected);
166
- }
175
+ &::before {
176
+ background-color: var(
177
+ --surface-color-foreground-checkbox-checkmark,
178
+ var(--color-foreground-checkbox-checkmark)
179
+ );
180
+ mask-image: url("/icons/checkmark.svg#checkmark");
181
+ -webkit-mask-image: url("/icons/checkmark.svg#checkmark");
182
+ }
183
+ }
167
184
 
168
- &:focus-visible {
169
- outline: none;
170
- border-color: var(--color-focusRing);
171
- box-shadow: 0 0 0 1px var(--color-focusRing);
172
- }
185
+ &:hover:not(:disabled):not(:checked) {
186
+ background-color: var(--color-foreground-checkbox-unselected-hover);
187
+ }
173
188
 
174
- &:disabled {
175
- border-color: var(--color-border-disabled);
176
- background-color: var(--color-foreground-checkbox-unselected-disabled);
177
- }
189
+ /* Hover shifts only the fill (channel shade), not the masked checkmark. */
190
+ &:checked:hover:not(:disabled) {
191
+ background-color: var(--hover--color-foreground-checkbox-selected);
192
+ border-color: var(--hover--color-foreground-checkbox-selected);
193
+ }
178
194
 
179
- /* A checked+disabled box must keep the SELECTED (not unselected) disabled
180
- * fill — the generic `:disabled` above would otherwise leave the checkmark
181
- * on the unselected-disabled background. Matches CheckboxInput. */
182
- &:checked:disabled {
183
- background: var(--color-foreground-checkbox-selected-disabled);
184
- border-color: var(--color-foreground-checkbox-selected-disabled);
195
+ &:focus-visible {
196
+ outline: none;
197
+ border-color: var(--color-focus-ring);
198
+ box-shadow: 0 0 0 1px var(--color-focus-ring);
199
+ }
185
200
 
186
- &::before {
187
- background-color: var(--color-foreground-checkbox-checkmark-disabled);
201
+ &:disabled {
202
+ border-color: var(--color-border-disabled);
203
+ background-color: var(
204
+ --color-foreground-checkbox-unselected-disabled
205
+ );
206
+ }
207
+
208
+ /* A checked+disabled box must keep the SELECTED (not unselected) disabled
209
+ * fill — the generic `:disabled` above would otherwise leave the checkmark
210
+ * on the unselected-disabled background. Matches CheckboxInput. */
211
+ &:checked:disabled {
212
+ background: var(--color-foreground-checkbox-selected-disabled);
213
+ border-color: var(--color-foreground-checkbox-selected-disabled);
214
+
215
+ &::before {
216
+ background-color: var(
217
+ --color-foreground-checkbox-checkmark-disabled
218
+ );
219
+ }
188
220
  }
189
221
  }
190
222
  }
@@ -1,42 +1,46 @@
1
- /* A canonical number input beside its mirroring slider (the slider is appended
2
- * on hydration). The number sits at the inline-END (right in LTR, left in RTL)
3
- * at a fixed width for precise entry; the slider flexes to fill the rest.
4
- *
5
- * The number input is kept FIRST in the DOM (it is the canonical, labelled,
6
- * no-JS control, so it must lead in source order); we move it visually to the
7
- * inline-end with `order`, which follows the writing direction automatically. */
8
- .ds.range-control {
9
- display: flex;
10
- flex-direction: row;
11
- align-items: center;
12
- gap: var(--form-group-gap);
1
+ /* Layer: ds.components.global (@canonical/styles README, "Cascade layers"). */
13
2
 
14
- /* `.range-number` is the NumberInput WRAPPER (a <div>). Size/order the whole
15
- * control here: fixed, non-flexing width so the slider takes the slack, and
16
- * ordered last so it paints at the inline-end. */
17
- & > .range-number {
18
- order: 1;
19
- flex: 0 0 var(--form-range-number-width, 5rem);
20
- width: var(--form-range-number-width, 5rem);
21
- }
3
+ @layer ds.components.global {
4
+ /* A canonical number input beside its mirroring slider (the slider is appended
5
+ * on hydration). The number sits at the inline-END (right in LTR, left in RTL)
6
+ * at a fixed width for precise entry; the slider flexes to fill the rest.
7
+ *
8
+ * The number input is kept FIRST in the DOM (it is the canonical, labelled,
9
+ * no-JS control, so it must lead in source order); we move it visually to the
10
+ * inline-end with `order`, which follows the writing direction automatically. */
11
+ .ds.range-control {
12
+ display: flex;
13
+ flex-direction: row;
14
+ align-items: center;
15
+ gap: var(--form-group-gap);
16
+
17
+ /* `.range-number` is the NumberInput WRAPPER (a <div>). Size/order the whole
18
+ * control here: fixed, non-flexing width so the slider takes the slack, and
19
+ * ordered last so it paints at the inline-end. */
20
+ & > .range-number {
21
+ order: 1;
22
+ flex: 0 0 var(--form-range-number-width, 5rem);
23
+ width: var(--form-range-number-width, 5rem);
24
+ }
22
25
 
23
- /* Spinner removal targets the INNER <input> (the wrapper is a <div>, which
24
- * has no spinner): the slider is the coarse control, the number is for
25
- * precise entry, so no native steppers. */
26
- & > .range-number > input {
27
- appearance: textfield;
28
- -moz-appearance: textfield;
26
+ /* Spinner removal targets the INNER <input> (the wrapper is a <div>, which
27
+ * has no spinner): the slider is the coarse control, the number is for
28
+ * precise entry, so no native steppers. */
29
+ & > .range-number > input {
30
+ appearance: textfield;
31
+ -moz-appearance: textfield;
29
32
 
30
- &::-webkit-outer-spin-button,
31
- &::-webkit-inner-spin-button {
32
- appearance: none;
33
- margin: 0;
33
+ &::-webkit-outer-spin-button,
34
+ &::-webkit-inner-spin-button {
35
+ appearance: none;
36
+ margin: 0;
37
+ }
34
38
  }
35
- }
36
39
 
37
- /* The slider flexes to fill whatever space the number input leaves. */
38
- & > .range-slider {
39
- flex: 1 1 auto;
40
- min-width: 0;
40
+ /* The slider flexes to fill whatever space the number input leaves. */
41
+ & > .range-slider {
42
+ flex: 1 1 auto;
43
+ min-width: 0;
44
+ }
41
45
  }
42
46
  }