@canonical/react-ds-global-form 0.37.0 → 0.38.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
@@ -7,358 +7,384 @@
7
7
  * Terminology:
8
8
  * block = vertical axis (block-start = top, block-end = bottom)
9
9
  * inline = horizontal axis (inline-start = left in LTR, right in RTL)
10
+ *
11
+ * Layer: ds.components.global (@canonical/styles README, "Cascade layers").
10
12
  */
11
13
 
12
- /* Density & baseline alignment (context × density → control height + baseline). */
14
+ /* Density & baseline alignment (context × density → control height + baseline).
15
+ *
16
+ * No `layer()` keyword on this import: density.css declares `ds.components.global`
17
+ * itself, like every other sheet here, and `layer()` would nest that declaration
18
+ * one level deeper — `ds.components.global.ds.components.global`, a sublayer that
19
+ * loses to this file's own rules. Measured in Chromium 151. An `@import` here
20
+ * takes `layer(ds.components.global)` only when the sheet it names is not itself
21
+ * wrapped. */
13
22
  @import url("./density.css");
14
23
 
15
- :root {
16
- /* ── Form grid layout ───────────────────────────────────────────── */
17
- /* Forms are subgrids: they inherit columns from a parent .grid */
18
- /* context (either .grid.responsive or .grid.intrinsic). */
19
-
20
- /* Field position within form grid — default: full width */
21
- --form-field-columns: 1 / -1;
22
-
23
- /* Label and payload column placement — stacked by default */
24
- --form-label-columns: 1 / -1;
25
- --form-payload-columns: 1 / -1;
26
-
27
- /* Side layout (set on form wrapper to switch all fields): */
28
- /* --form-label-columns: 1 / 3; */ /* label in first 2 cols */
29
- /* --form-payload-columns: 3 / -1; */ /* payload in remaining */
30
-
31
- /* Per-field column overrides (set via style prop on individual fields): */
32
- /* --form-field-columns: 1 / 7; */ /* field spans first 6 columns */
33
- /* --form-field-columns: 7 / -1; */ /* field spans last 6 columns */
34
-
35
- /* ── Field layout spacing ───────────────────────────────────────── */
36
- /* Container-owned: the form/field wrapper controls all spacing. */
37
-
38
- /* Gaps are split by AXIS so no token spans both directions (a density tier can
39
- then tune each axis independently, and the names stay honest):
40
- BLOCK (vertical): field-block-gap · field-label-gap · group-gap
41
- INLINE (horizontal): field-inline-gap */
42
- /* No-density-class defaults — mirror the density matrix's app/comfortable cell
43
- (F-O4, 15/07 review). The density-scoped block further down re-derives these
44
- per cell when a context/density class is present. */
45
- --form-field-block-gap: calc(
46
- var(--baseline-height) *
47
- 10
48
- ); /* 40px — block: gap BETWEEN fields */
49
- --form-field-label-gap: var(
50
- --space-100
51
- ); /* 8px — block: gap from a field's LABEL down to its control */
52
- --form-field-label-description-gap: var(
53
- --space-050
54
- ); /* 4px — block: gap from a LABEL down to a leading description */
55
- --form-group-gap: var(
56
- --space-100
57
- ); /* 8px — block: gap from desc/error to the input */
58
- --form-field-inline-gap: var(
59
- --container-gap-default
60
- ); /* 16px — inline: label↔input, prefix/suffix (HORIZONTAL only) */
61
-
62
- /* ── Input chrome ───────────────────────────────────────────────── */
63
- /* Component-owned: internal padding regardless of context. */
64
-
65
- --form-input-padding-block: var(
66
- --component-padding-block
67
- ); /* 8px — block (vertical) */
68
-
69
- /* Chrome height snapped to baseline grid — border-box includes border */
70
- --form-input-height: calc(var(--space-baseline) * 6); /* 40px — 5bU */
71
- --form-input-padding-inline: var(
72
- --component-padding-inline
73
- ); /* 16px — inline (horizontal) */
74
-
75
- /* Per-side input padding overrides: */
76
- /* --form-input-padding-block-start: … ; */ /* top padding */
77
- /* --form-input-padding-block-end: … ; */ /* bottom padding */
78
- /* --form-input-padding-inline-start: … ; */ /* left padding */
79
- /* --form-input-padding-inline-end: … ; */ /* right padding */
80
-
81
- /* ── Borders ────────────────────────────────────────────────────── */
82
-
83
- --form-input-border-width: var(
84
- --dimension-stroke-thickness-medium
85
- ); /* 1px */
86
- --form-input-border-color: var(--color-border);
87
- --form-input-border-radius: var(--dimension-radius-small); /* 0 */
88
-
89
- /* ── Canonical theme: bottom-border-only inputs ──────────────── */
90
- /* Only the sides that DIFFER from the base are declared. */
91
- /* Bottom border inherits --form-input-border-color (no override) */
92
- --form-input-border-color-top: transparent;
93
- --form-input-border-color-right: transparent;
94
- --form-input-border-color-left: transparent;
95
-
96
- /* Per-side border overrides — themes set only sides that differ.
97
- * When undefined, var() falls through to the base value above. */
98
- /* --form-input-border-color-bottom: … ; */ /* bottom border color */
99
- /* --form-input-border-width-top: … ; */ /* top border width */
100
- /* --form-input-border-width-right: … ; */ /* right border width */
101
- /* --form-input-border-width-bottom: … ; */ /* bottom border width */
102
- /* --form-input-border-width-left: … ; */ /* left border width */
103
-
104
- /* Per-corner radius overrides: */
105
- /* --form-input-border-radius-top-left: … ; */
106
- /* --form-input-border-radius-top-right: … ; */
107
- /* --form-input-border-radius-bottom-right: … ; */
108
- /* --form-input-border-radius-bottom-left: … ; */
109
-
110
- /* ── Colors ─────────────────────────────────────────────────────── */
111
-
112
- --form-input-background: var(--color-foreground-input);
113
- --form-input-color: var(--color-text);
114
- --form-input-font-size: var(--typography-text-primary-font-size);
115
- --form-input-line-height: var(--typography-text-primary-line-height);
116
-
117
- /* ── Label ──────────────────────────────────────────────────────── */
118
-
119
- /* Field labels use regular paragraph weight, not bold (per design review). */
120
- --form-label-font-weight: var(--typography-text-primary-font-weight);
121
- --form-label-font-size: var(--typography-text-primary-font-size);
122
- --form-label-color: var(--color-text);
123
- /* --form-label-padding-block: … ; */ /* block padding for label */
124
- /* --form-label-padding-inline: … ; */ /* inline padding for label */
125
- /* Required marker (shown before the label of required fields in the default
126
- * "required" indicator mode): */
127
- /* --form-required-marker: "*"; */ /* marker glyph */
128
- /* --form-required-marker-gap: 0.25ch; */ /* gap after marker*/
129
- /* --form-required-marker-color: var(--form-label-color);*/ /* marker colour */
130
-
131
- /* ── Description ────────────────────────────────────────────────── */
132
-
133
- /* Description reads the SECONDARY type ramp (design review): it is subordinate
134
- supporting text, so it takes the smaller secondary size, not the primary
135
- body size. Colour is already the muted token. */
136
- --form-description-font-size: var(--typography-text-secondary-font-size);
137
- --form-description-color: var(--color-text-muted);
138
-
139
- /* ── Error ──────────────────────────────────────────────────────── */
140
-
141
- --form-error-font-size: var(--typography-text-primary-font-size);
142
- --form-error-color: var(--modifier-color-text, var(--color-text-error));
143
-
144
- /* ── State colors ───────────────────────────────────────────────── */
145
-
146
- --form-input-border-color-focus: var(--color-focusRing);
147
- --form-input-border-color-error: var(--color-border-error);
148
- --form-input-background-disabled: var(--color-foreground-input-disabled);
149
- --form-input-color-disabled: var(--disabled--color-text);
150
- /* Design review (15/07): a disabled control shows no border. Default the
151
- * disabled border to transparent; a theme wanting a visible disabled border
152
- * can still override this token (e.g. back to `--disabled--color-border`). */
153
- --form-input-border-color-disabled: transparent;
154
-
155
- /* ── Focus ring ─────────────────────────────────────────────────── */
156
-
157
- --form-focus-ring-color: var(--color-focusRing);
158
- --form-focus-ring-color-error: var(--color-focusRing-error);
159
- /* --form-focus-ring-width: … ; */ /* focus ring thickness (default: 1px via box-shadow) */
160
- /* --form-focus-ring-offset: … ; */ /* focus ring offset from border */
161
- }
162
-
163
- /* ── Density → form channel mapping ──────────────────────────────────────────
164
- * The FORM layer decides which generic density primitive (density.css exposes
165
- * --density-line-height, --density-padding-inline, and the neutral vertical rungs
166
- * --density-space-sm/-md/-lg) each of its own tokens follows. Density knows
167
- * nothing about "field"; this is where the form makes that choice.
168
- *
169
- * Scoped to the density classes so a plain form (no density class) keeps the
170
- * :root defaults above. The var() fallbacks keep values sane if only a CONTEXT
171
- * class (.app/.site/.docs) is present without a density class.
172
- *
173
- * INLINE (horizontal): control padding + label↔input / prefix-suffix gap
174
- * → --density-padding-inline
175
- * BLOCK (vertical), by magnitude:
176
- * between-fields → --density-space-lg (widest structural gap, 40px app)
177
- * label → control → --density-space-md (label to its own control, 8px app)
178
- * desc/error → input → --density-space-sm (tight annotation gap, 8px)
179
- * label → description → --density-space-xs (tightest, 4px)
180
- * All rungs are whole baseline multiples, so vertical rhythm holds.
181
- * (space-md/-lg were retuned + space-xs added per the 15/07 review — F-O4;
182
- * the density matrix now carries Diana's numbers directly, so the form maps
183
- * straight onto the rungs rather than pinning literals.) */
184
- :where(.comfortable, .dense, .app, .site, .docs) {
185
- --form-input-padding-inline: var(--density-padding-inline, var(--space-200));
186
- --form-field-inline-gap: var(--density-padding-inline, var(--space-200));
187
- --form-field-block-gap: var(
188
- --density-space-lg,
189
- calc(var(--baseline-height) * 10)
190
- );
191
- --form-field-label-gap: var(
192
- --density-space-md,
193
- calc(var(--baseline-height) * 2)
194
- );
195
- --form-group-gap: var(--density-space-sm, calc(var(--baseline-height) * 2));
196
- --form-field-label-description-gap: var(
197
- --density-space-xs,
198
- calc(var(--baseline-height) * 1)
199
- );
200
- }
24
+ @layer ds.components.global {
25
+ :root {
26
+ /* ── Form grid layout ───────────────────────────────────────────── */
27
+ /* Forms are subgrids: they inherit columns from a parent .grid */
28
+ /* context (either .grid.responsive or .grid.intrinsic). */
29
+
30
+ /* Field position within form grid — default: full width */
31
+ --form-field-columns: 1 / -1;
32
+
33
+ /* Label and payload column placement — stacked by default */
34
+ --form-label-columns: 1 / -1;
35
+ --form-payload-columns: 1 / -1;
36
+
37
+ /* Side layout (set on form wrapper to switch all fields): */
38
+ /* --form-label-columns: 1 / 3; */ /* label in first 2 cols */
39
+ /* --form-payload-columns: 3 / -1; */ /* payload in remaining */
40
+
41
+ /* Per-field column overrides (set via style prop on individual fields): */
42
+ /* --form-field-columns: 1 / 7; */ /* field spans first 6 columns */
43
+ /* --form-field-columns: 7 / -1; */ /* field spans last 6 columns */
44
+
45
+ /* ── Field layout spacing ───────────────────────────────────────── */
46
+ /* Container-owned: the form/field wrapper controls all spacing. */
47
+
48
+ /* Gaps are split by AXIS so no token spans both directions (a density tier can
49
+ then tune each axis independently, and the names stay honest):
50
+ BLOCK (vertical): field-block-gap · field-label-gap · group-gap
51
+ INLINE (horizontal): field-inline-gap */
52
+ /* No-density-class defaults — mirror the density matrix's app/comfortable cell
53
+ (F-O4, 15/07 review). The density-scoped block further down re-derives these
54
+ per cell when a context/density class is present. */
55
+ --form-field-block-gap: calc(
56
+ var(--baseline-height) *
57
+ 10
58
+ ); /* 40px — block: gap BETWEEN fields */
59
+ --form-field-label-gap: var(
60
+ --space-100
61
+ ); /* 8px — block: gap from a field's LABEL down to its control */
62
+ --form-field-label-description-gap: var(
63
+ --space-050
64
+ ); /* 4px — block: gap from a LABEL down to a leading description */
65
+ --form-group-gap: var(
66
+ --space-100
67
+ ); /* 8px — block: gap from desc/error to the input */
68
+ --form-field-inline-gap: var(
69
+ --container-gap-default
70
+ ); /* 16px — inline: label↔input, prefix/suffix (HORIZONTAL only) */
71
+
72
+ /* ── Input chrome ───────────────────────────────────────────────── */
73
+ /* Component-owned: internal padding regardless of context. */
74
+
75
+ --form-input-padding-block: var(
76
+ --component-padding-block
77
+ ); /* 8px — block (vertical) */
78
+
79
+ /* Chrome height snapped to baseline grid — border-box includes border */
80
+ --form-input-height: calc(var(--space-baseline) * 6); /* 40px — 5bU */
81
+ --form-input-padding-inline: var(
82
+ --component-padding-inline
83
+ ); /* 16px — inline (horizontal) */
84
+
85
+ /* Per-side input padding overrides: */
86
+ /* --form-input-padding-block-start: … ; */ /* top padding */
87
+ /* --form-input-padding-block-end: … ; */ /* bottom padding */
88
+ /* --form-input-padding-inline-start: … ; */ /* left padding */
89
+ /* --form-input-padding-inline-end: … ; */ /* right padding */
90
+
91
+ /* ── Borders ────────────────────────────────────────────────────── */
92
+
93
+ --form-input-border-width: var(
94
+ --dimension-stroke-thickness-medium
95
+ ); /* 1px */
96
+ --form-input-border-color: var(--color-border);
97
+ --form-input-border-radius: var(--dimension-radius-small); /* 0 */
98
+
99
+ /* ── Canonical theme: bottom-border-only inputs ──────────────── */
100
+ /* Only the sides that DIFFER from the base are declared. */
101
+ /* Bottom border inherits --form-input-border-color (no override) */
102
+ --form-input-border-color-top: transparent;
103
+ --form-input-border-color-right: transparent;
104
+ --form-input-border-color-left: transparent;
105
+
106
+ /* Per-side border overrides — themes set only sides that differ.
107
+ * When undefined, var() falls through to the base value above. */
108
+ /* --form-input-border-color-bottom: … ; */ /* bottom border color */
109
+ /* --form-input-border-width-top: … ; */ /* top border width */
110
+ /* --form-input-border-width-right: … ; */ /* right border width */
111
+ /* --form-input-border-width-bottom: … ; */ /* bottom border width */
112
+ /* --form-input-border-width-left: … ; */ /* left border width */
113
+
114
+ /* Per-corner radius overrides: */
115
+ /* --form-input-border-radius-top-left: … ; */
116
+ /* --form-input-border-radius-top-right: … ; */
117
+ /* --form-input-border-radius-bottom-right: … ; */
118
+ /* --form-input-border-radius-bottom-left: … ; */
119
+
120
+ /* ── Colors ─────────────────────────────────────────────────────── */
121
+
122
+ --form-input-background: var(--color-foreground-input);
123
+ --form-input-color: var(--color-text);
124
+ --form-input-font-size: var(--typography-text-primary-font-size);
125
+ --form-input-line-height: var(--typography-text-primary-line-height);
126
+
127
+ /* ── Label ──────────────────────────────────────────────────────── */
128
+
129
+ /* Field labels use regular paragraph weight, not bold (per design review). */
130
+ --form-label-font-weight: var(--typography-text-primary-font-weight);
131
+ --form-label-font-size: var(--typography-text-primary-font-size);
132
+ --form-label-color: var(--color-text);
133
+ /* --form-label-padding-block: … ; */ /* block padding for label */
134
+ /* --form-label-padding-inline: … ; */ /* inline padding for label */
135
+ /* Required marker (shown after the label of required fields in the default
136
+ * "required" indicator mode): */
137
+ /* --form-required-marker: "*"; */ /* marker glyph */
138
+ /* --form-required-marker-gap: 0.25ch; */ /* gap after marker*/
139
+ /* --form-required-marker-color: var(--form-label-color);*/ /* marker colour */
140
+
141
+ /* ── Description ────────────────────────────────────────────────── */
142
+
143
+ /* Description reads the SECONDARY type ramp (design review): it is subordinate
144
+ supporting text, so it takes the smaller secondary size, not the primary
145
+ body size. Colour is already the muted token. */
146
+ --form-description-font-size: var(--typography-text-secondary-font-size);
147
+ --form-description-color: var(--color-text-muted);
148
+
149
+ /* ── Error ──────────────────────────────────────────────────────── */
150
+
151
+ --form-error-font-size: var(--typography-text-primary-font-size);
152
+ --form-error-color: var(--modifier-color-text, var(--color-text-error));
153
+
154
+ /* ── State colors ───────────────────────────────────────────────── */
155
+
156
+ --form-input-border-color-focus: var(--color-focus-ring);
157
+ --form-input-border-color-error: var(--color-border-error);
158
+ --form-input-background-disabled: var(--color-foreground-input-disabled);
159
+ --form-input-color-disabled: var(--disabled--color-text);
160
+ /* Design review (15/07): a disabled control shows no border. Default the
161
+ * disabled border to transparent; a theme wanting a visible disabled border
162
+ * can still override this token (e.g. back to `--disabled--color-border`). */
163
+ --form-input-border-color-disabled: transparent;
164
+
165
+ /* ── Focus ring ─────────────────────────────────────────────────── */
166
+
167
+ --form-focus-ring-color: var(--color-focus-ring);
168
+ --form-focus-ring-color-error: var(--color-focus-ring-error);
169
+ /* --form-focus-ring-width: … ; */ /* focus ring thickness (default: 1px via box-shadow) */
170
+ /* --form-focus-ring-offset: … ; */ /* focus ring offset from border */
171
+ }
201
172
 
202
- /* ── .ds.input.chrome — shared input chrome ─────────────────────────
203
- * Applied on native <textarea>/<select> directly, and on the
204
- * composite .ds.input.text wrapper for <input> + prefix/suffix.
205
- *
206
- * Inline padding is deliberately NOT set here. On composite wrappers the
207
- * text-bearing leaf is the inner <input>, which carries its own
208
- * `padding-inline`; if the wrapper ALSO had it the text would be inset twice
209
- * (and prefix/suffix would sit off the edge). So the inline padding lives on
210
- * the leaf in every case: the inner <input> for composite inputs (text,
211
- * number, password, phone …), and the element itself for the direct-chrome
212
- * inputs (date, time, datetime, select, textarea), which set it locally.
213
- * Only the block padding (baseline-grid height) is shared here.
214
- */
215
- .ds.input.chrome {
216
- display: block;
217
- box-sizing: border-box;
218
- width: 100%;
219
- /* Explicit height snapped to baseline grid — border-box includes border */
220
- height: var(--form-input-height);
221
- padding-block: var(--form-input-padding-block);
222
-
223
- /* Base border */
224
- border: var(--form-input-border-width) solid var(--form-input-border-color);
225
-
226
- /* Per-side overrides — only effective when a theme defines them.
227
- * When undefined, var() falls through to the base shorthand. */
228
- border-top-color: var(
229
- --form-input-border-color-top,
230
- var(--form-input-border-color)
231
- );
232
- border-right-color: var(
233
- --form-input-border-color-right,
234
- var(--form-input-border-color)
235
- );
236
- border-bottom-color: var(
237
- --form-input-border-color-bottom,
238
- var(--form-input-border-color)
239
- );
240
- border-left-color: var(
241
- --form-input-border-color-left,
242
- var(--form-input-border-color)
243
- );
244
-
245
- border-top-width: var(
246
- --form-input-border-width-top,
247
- var(--form-input-border-width)
248
- );
249
- border-right-width: var(
250
- --form-input-border-width-right,
251
- var(--form-input-border-width)
252
- );
253
- border-bottom-width: var(
254
- --form-input-border-width-bottom,
255
- var(--form-input-border-width)
256
- );
257
- border-left-width: var(
258
- --form-input-border-width-left,
259
- var(--form-input-border-width)
260
- );
261
-
262
- border-radius: var(--form-input-border-radius);
263
- background-color: var(--form-input-background);
264
- color: var(--form-input-color);
265
- font-family: var(--typography-text-primary-font-family);
266
- font-size: var(--form-input-font-size);
267
- line-height: var(--form-input-line-height);
268
- transition:
269
- border-color 150ms ease,
270
- box-shadow 150ms ease;
271
-
272
- &:hover:not(:disabled, :has(input:disabled)) {
273
- background-color: var(
274
- --hover--color-foreground-input,
275
- var(--color-foreground-input-hover)
173
+ /* ── Density → form channel mapping ──────────────────────────────────────────
174
+ * The FORM layer decides which generic density primitive (density.css exposes
175
+ * --density-line-height, --density-padding-inline, and the neutral vertical rungs
176
+ * --density-space-sm/-md/-lg) each of its own tokens follows. Density knows
177
+ * nothing about "field"; this is where the form makes that choice.
178
+ *
179
+ * Scoped to the density classes so a plain form (no density class) keeps the
180
+ * :root defaults above. The var() fallbacks keep values sane if only a CONTEXT
181
+ * class (.app/.site/.docs) is present without a density class.
182
+ *
183
+ * INLINE (horizontal): control padding + label↔input / prefix-suffix gap
184
+ * → --density-padding-inline
185
+ * BLOCK (vertical), by magnitude:
186
+ * between-fields → --density-space-lg (widest structural gap, 40px app)
187
+ * label → control → --density-space-md (label to its own control, 8px app)
188
+ * desc/error → input → --density-space-sm (tight annotation gap, 8px)
189
+ * label → description → --density-space-xs (tightest, 4px)
190
+ * All rungs are whole baseline multiples, so vertical rhythm holds.
191
+ * (space-md/-lg were retuned + space-xs added per the 15/07 review — F-O4;
192
+ * the density matrix now carries Diana's numbers directly, so the form maps
193
+ * straight onto the rungs rather than pinning literals.) */
194
+ :where(.comfortable, .dense, .app, .site, .docs) {
195
+ --form-input-padding-inline: var(
196
+ --density-padding-inline,
197
+ var(--space-200)
198
+ );
199
+ --form-field-inline-gap: var(--density-padding-inline, var(--space-200));
200
+ --form-field-block-gap: var(
201
+ --density-space-lg,
202
+ calc(var(--baseline-height) * 10)
203
+ );
204
+ --form-field-label-gap: var(
205
+ --density-space-md,
206
+ calc(var(--baseline-height) * 2)
207
+ );
208
+ --form-group-gap: var(--density-space-sm, calc(var(--baseline-height) * 2));
209
+ --form-field-label-description-gap: var(
210
+ --density-space-xs,
211
+ calc(var(--baseline-height) * 1)
276
212
  );
277
213
  }
278
214
 
279
- /* Focus — all four borders become visible */
280
- &:focus-visible,
281
- &:focus-within {
282
- outline: none;
283
- border-color: var(--form-input-border-color-focus);
284
- border-top-color: var(--form-input-border-color-focus);
285
- border-right-color: var(--form-input-border-color-focus);
286
- border-left-color: var(--form-input-border-color-focus);
287
- box-shadow: 0 0 0 1px var(--form-focus-ring-color);
288
- }
215
+ /* ── .ds.input.chrome — shared input chrome ─────────────────────────
216
+ * Applied on native <textarea>/<select> directly, and on the
217
+ * composite .ds.input.text wrapper for <input> + prefix/suffix.
218
+ *
219
+ * Inline padding is deliberately NOT set here. On composite wrappers the
220
+ * text-bearing leaf is the inner <input>, which carries its own
221
+ * `padding-inline`; if the wrapper ALSO had it the text would be inset twice
222
+ * (and prefix/suffix would sit off the edge). So the inline padding lives on
223
+ * the leaf in every case: the inner <input> for composite inputs (text,
224
+ * number, password, phone …), and the element itself for the direct-chrome
225
+ * inputs (date, time, datetime, select, textarea), which set it locally.
226
+ * Only the block padding (baseline-grid height) is shared here.
227
+ */
228
+ .ds.input.chrome {
229
+ display: block;
230
+ box-sizing: border-box;
231
+ width: 100%;
232
+ /* Explicit height snapped to baseline grid — border-box includes border */
233
+ height: var(--form-input-height);
234
+ padding-block: var(--form-input-padding-block);
235
+
236
+ /* Base border */
237
+ border: var(--form-input-border-width) solid var(--form-input-border-color);
238
+
239
+ /* Per-side overrides — only effective when a theme defines them.
240
+ * When undefined, var() falls through to the base shorthand. */
241
+ border-top-color: var(
242
+ --form-input-border-color-top,
243
+ var(--form-input-border-color)
244
+ );
245
+ border-right-color: var(
246
+ --form-input-border-color-right,
247
+ var(--form-input-border-color)
248
+ );
249
+ border-bottom-color: var(
250
+ --form-input-border-color-bottom,
251
+ var(--form-input-border-color)
252
+ );
253
+ border-left-color: var(
254
+ --form-input-border-color-left,
255
+ var(--form-input-border-color)
256
+ );
289
257
 
290
- /* Disabled — per design review (15/07): a disabled control needs no border.
291
- * The border BOX is kept (transparent) so the border-box height is unchanged
292
- * and a disabled control lines up with an enabled one; only the paint is
293
- * dropped. `--form-input-border-color-disabled` defaults to transparent (see
294
- * :root) but stays a themeable override point. The background + muted text
295
- * carry the disabled affordance instead. */
296
- &:disabled,
297
- &:has(input:disabled) {
298
- border-color: var(--form-input-border-color-disabled);
299
- border-top-color: var(--form-input-border-color-disabled);
300
- border-right-color: var(--form-input-border-color-disabled);
301
- border-bottom-color: var(--form-input-border-color-disabled);
302
- border-left-color: var(--form-input-border-color-disabled);
303
- background-color: var(--form-input-background-disabled);
304
- color: var(--form-input-color-disabled);
305
- cursor: not-allowed;
258
+ border-top-width: var(
259
+ --form-input-border-width-top,
260
+ var(--form-input-border-width)
261
+ );
262
+ border-right-width: var(
263
+ --form-input-border-width-right,
264
+ var(--form-input-border-width)
265
+ );
266
+ border-bottom-width: var(
267
+ --form-input-border-width-bottom,
268
+ var(--form-input-border-width)
269
+ );
270
+ border-left-width: var(
271
+ --form-input-border-width-left,
272
+ var(--form-input-border-width)
273
+ );
274
+
275
+ border-radius: var(--form-input-border-radius);
276
+ background-color: var(--form-input-background);
277
+ color: var(--form-input-color);
278
+ font-family: var(--typography-text-primary-font-family);
279
+ font-size: var(--form-input-font-size);
280
+ line-height: var(--form-input-line-height);
281
+ /* Durations come from the motion token, never from a literal: `@canonical/styles`
282
+ * zeroes the three duration tokens under `prefers-reduced-motion: reduce`, so a
283
+ * literal here would keep animating for a reader who asked their system not to.
284
+ * Every transition in this package reads `--motion-duration-fast` for that
285
+ * reason (motion.css, "Reduced motion"). */
286
+ transition:
287
+ border-color var(--motion-duration-fast) ease,
288
+ box-shadow var(--motion-duration-fast) ease;
289
+
290
+ &:hover:not(:disabled, :has(input:disabled)) {
291
+ background-color: var(
292
+ --hover--color-foreground-input,
293
+ var(--color-foreground-input-hover)
294
+ );
295
+ }
296
+
297
+ /* Focus — all four borders become visible */
298
+ &:focus-visible,
299
+ &:focus-within {
300
+ outline: none;
301
+ border-color: var(--form-input-border-color-focus);
302
+ border-top-color: var(--form-input-border-color-focus);
303
+ border-right-color: var(--form-input-border-color-focus);
304
+ border-left-color: var(--form-input-border-color-focus);
305
+ box-shadow: 0 0 0 1px var(--form-focus-ring-color);
306
+ }
307
+
308
+ /* Disabled — per design review (15/07): a disabled control needs no border.
309
+ * The border BOX is kept (transparent) so the border-box height is unchanged
310
+ * and a disabled control lines up with an enabled one; only the paint is
311
+ * dropped. `--form-input-border-color-disabled` defaults to transparent (see
312
+ * :root) but stays a themeable override point. The background + muted text
313
+ * carry the disabled affordance instead. */
314
+ &:disabled,
315
+ &:has(input:disabled) {
316
+ border-color: var(--form-input-border-color-disabled);
317
+ border-top-color: var(--form-input-border-color-disabled);
318
+ border-right-color: var(--form-input-border-color-disabled);
319
+ border-bottom-color: var(--form-input-border-color-disabled);
320
+ border-left-color: var(--form-input-border-color-disabled);
321
+ background-color: var(--form-input-background-disabled);
322
+ color: var(--form-input-color-disabled);
323
+ cursor: not-allowed;
324
+ }
306
325
  }
307
- }
308
326
 
309
- /* ── Danger ──────────────────────────────────────────────────────────
310
- * Per design review (15/07): a validation colour change must be confined to the
311
- * validation MESSAGE and the input's BOTTOM border — it must not repaint the
312
- * label or the full box outline. So the general label recolour is gone; the
313
- * error signal on a normal bordered input is carried by its bottom border alone
314
- * (below), and the FieldError message carries the error colour in its own text.
315
- *
316
- * EXCEPTION — the borderless choices fieldset. A choices group (radios/checkboxes)
317
- * has no single input border to paint (each option is its own borderless control),
318
- * so its `<legend>` (a `.ds.field-label`) is the ONLY place an error can be shown
319
- * without lighting up every option box. Such a group renders its Wrapper label as
320
- * a `<legend>` (the `mockLabel` path), so the recolour is SCOPED to a legend
321
- * label — a normal field's `<label>` is untouched. */
322
- .danger > legend.ds.field-label {
323
- color: var(--form-error-color);
324
-
325
- /* The required "*" marker recolours WITH the label (it pins its own colour to
326
- * `--form-label-color` by default, so it must be overridden here). The
327
- * "(optional)" hint keeps its muted colour — it is subordinate, not an error
328
- * signal — via its own explicit `color` in the Label styles. */
329
- &[data-required]::before {
327
+ /* ── Danger ──────────────────────────────────────────────────────────
328
+ * Per design review (15/07): a validation colour change must be confined to the
329
+ * validation MESSAGE and the input's BOTTOM border — it must not repaint the
330
+ * label or the full box outline. So the general label recolour is gone; the
331
+ * error signal on a normal bordered input is carried by its bottom border alone
332
+ * (below), and the FieldError message carries the error colour in its own text.
333
+ *
334
+ * EXCEPTION — the borderless choices fieldset. A choices group (radios/checkboxes)
335
+ * has no single input border to paint (each option is its own borderless control),
336
+ * so its `<legend>` (a `.ds.field-label`) is the ONLY place an error can be shown
337
+ * without lighting up every option box. Such a group renders its Wrapper label as
338
+ * a `<legend>` (the `mockLabel` path), so the recolour is SCOPED to a legend
339
+ * label — a normal field's `<label>` is untouched. */
340
+ .danger > legend.ds.field-label {
330
341
  color: var(--form-error-color);
331
- }
332
- }
333
342
 
334
- /* Input chrome: recolour ONLY the bottom border (the base theme keeps the other
335
- * three sides transparent). Setting the bottom-border override token — not the
336
- * four-side `border-color` shorthand — means the error signal cannot bleed onto
337
- * the top/right/left sides. Focus still lights all four (below). */
338
- .danger > .payload .ds.input.chrome {
339
- --form-input-border-color-bottom: var(--form-input-border-color-error);
340
- }
343
+ /* The required "*" marker recolours WITH the label (it pins its own colour to
344
+ * `--form-label-color` by default, so it must be overridden here). The
345
+ * "(optional)" hint keeps its muted colour — it is subordinate, not an error
346
+ * signal — via its own explicit `color` in the Label styles. */
347
+ &[data-required]::after {
348
+ color: var(--form-error-color);
349
+ }
350
+ }
341
351
 
342
- .danger > .payload .ds.input.chrome:focus-visible,
343
- .danger > .payload .ds.input.chrome:focus-within {
344
- border-color: var(--form-focus-ring-color-error);
345
- border-top-color: var(--form-focus-ring-color-error);
346
- border-right-color: var(--form-focus-ring-color-error);
347
- border-left-color: var(--form-focus-ring-color-error);
348
- box-shadow: 0 0 0 1px var(--form-focus-ring-color-error);
349
- }
352
+ /* Input chrome: recolour ONLY the bottom border (the base theme keeps the other
353
+ * three sides transparent). Setting the bottom-border override token — not the
354
+ * four-side `border-color` shorthand — means the error signal cannot bleed onto
355
+ * the top/right/left sides. Focus still lights all four (below). */
356
+ .danger > .payload .ds.input.chrome {
357
+ --form-input-border-color-bottom: var(--form-input-border-color-error);
358
+ }
350
359
 
351
- /* ── .ds.form — form as subgrid ───────────────────────────────────── */
352
- .ds.form {
353
- display: grid;
354
- grid-template-columns: subgrid;
355
- grid-column: 1 / -1;
356
- row-gap: var(--form-field-block-gap);
357
- }
360
+ .danger > .payload .ds.input.chrome:focus-visible,
361
+ .danger > .payload .ds.input.chrome:focus-within {
362
+ border-color: var(--form-focus-ring-color-error);
363
+ border-top-color: var(--form-focus-ring-color-error);
364
+ border-right-color: var(--form-focus-ring-color-error);
365
+ border-left-color: var(--form-focus-ring-color-error);
366
+ box-shadow: 0 0 0 1px var(--form-focus-ring-color-error);
367
+ }
358
368
 
359
- /* ── Layout presets ───────────────────────────────────────────────── */
369
+ /* ── .ds.form — form as subgrid ───────────────────────────────────── */
370
+ .ds.form {
371
+ display: grid;
372
+ grid-template-columns: subgrid;
373
+ grid-column: 1 / -1;
374
+ row-gap: var(--form-field-block-gap);
375
+ }
360
376
 
361
- @layer ds.components {
377
+ /* ── Layout presets ───────────────────────────────────────────────── */
378
+
379
+ /* This preset was the one rule in this package already in a layer, its own
380
+ * `@layer ds.components` — which put it ABOVE both component tiers, not
381
+ * between them: a rule written directly into a layer lands in that layer's
382
+ * implicit final sublayer, and that outranks every named sublayer beneath it,
383
+ * `ds.components.app` included. It is in this file's `ds.components.global`
384
+ * wrap now like every other rule here, which demotes it to where it belongs —
385
+ * below an application tier's rules — and leaves one layer for a reader of
386
+ * this file to hold rather than two. Nothing pragma ships is written directly
387
+ * into `ds.components`. */
362
388
  /* Side layout: label beside input.
363
389
  * Apply on the form or a wrapper to switch all fields to side layout. */
364
390
  .form-layout-side {