@canonical/react-ds-global-form 0.36.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.
- package/README.md +40 -0
- package/dist/esm/density.css +320 -302
- package/dist/esm/docs/examples/density-examples.css +19 -14
- package/dist/esm/index.css +361 -335
- package/dist/esm/lib/_work_in_progress/DensityTestbed/baseline-system.css +71 -64
- package/dist/esm/lib/_work_in_progress/DensityTestbed/density.testbed.css +127 -123
- package/dist/esm/lib/common/Wrapper/ToggleWrapper.css +73 -54
- package/dist/esm/lib/common/Wrapper/styles.css +35 -31
- package/dist/esm/lib/component/ChoicesField/common/Option/Option.js +4 -1
- package/dist/esm/lib/component/ChoicesField/common/Option/Option.js.map +1 -1
- package/dist/esm/lib/component/ChoicesField/styles.css +195 -163
- package/dist/esm/lib/component/RangeField/common/RangeControl/styles.css +39 -35
- package/dist/esm/lib/component/RichChoicesField/styles.css +93 -89
- package/dist/esm/lib/index.js +2 -0
- package/dist/esm/lib/index.js.map +1 -1
- package/dist/esm/lib/subcomponent/CheckboxInput/styles.css +115 -111
- package/dist/esm/lib/subcomponent/ColorInput/styles.css +177 -173
- package/dist/esm/lib/subcomponent/ComboboxInput/SingleCombobox.js +2 -1
- package/dist/esm/lib/subcomponent/ComboboxInput/SingleCombobox.js.map +1 -1
- package/dist/esm/lib/subcomponent/ComboboxInput/common/List/List.js +1 -1
- package/dist/esm/lib/subcomponent/ComboboxInput/common/List/List.js.map +1 -1
- package/dist/esm/lib/subcomponent/ComboboxInput/common/List/styles.css +33 -29
- package/dist/esm/lib/subcomponent/ComboboxInput/common/ResetButton/styles.css +21 -17
- package/dist/esm/lib/subcomponent/ComboboxInput/styles.css +59 -55
- package/dist/esm/lib/subcomponent/ComboboxInput/utils/index.js +0 -1
- package/dist/esm/lib/subcomponent/ComboboxInput/utils/index.js.map +1 -1
- package/dist/esm/lib/subcomponent/DateInput/styles.css +23 -19
- package/dist/esm/lib/subcomponent/DateTimeInput/styles.css +24 -20
- package/dist/esm/lib/subcomponent/Field/Description/styles.css +9 -5
- package/dist/esm/lib/subcomponent/Field/Error/styles.css +9 -5
- package/dist/esm/lib/subcomponent/Field/Label/Label.js +2 -2
- package/dist/esm/lib/subcomponent/Field/Label/Label.js.map +1 -1
- package/dist/esm/lib/subcomponent/Field/Label/styles.css +25 -21
- package/dist/esm/lib/subcomponent/FileUploadInput/styles.css +125 -119
- package/dist/esm/lib/subcomponent/NumberInput/styles.css +32 -28
- package/dist/esm/lib/subcomponent/PasswordInput/styles.css +58 -54
- package/dist/esm/lib/subcomponent/PhoneInput/PhoneInput.js +44 -20
- package/dist/esm/lib/subcomponent/PhoneInput/PhoneInput.js.map +1 -1
- package/dist/esm/lib/subcomponent/PhoneInput/styles.css +53 -49
- package/dist/esm/lib/subcomponent/RadioInput/styles.css +70 -66
- package/dist/esm/lib/subcomponent/RangeInput/styles.css +74 -70
- package/dist/esm/lib/subcomponent/RatingInput/styles.css +132 -128
- package/dist/esm/lib/subcomponent/SelectInput/styles.css +44 -40
- package/dist/esm/lib/subcomponent/SwitchInput/styles.css +90 -86
- package/dist/esm/lib/subcomponent/TextInput/styles.css +30 -26
- package/dist/esm/lib/subcomponent/TextareaInput/styles.css +14 -10
- package/dist/esm/lib/subcomponent/TimeInput/styles.css +19 -15
- package/dist/esm/lib/utils/countries/index.js +3 -3
- package/dist/esm/lib/utils/countries/index.js.map +1 -1
- package/dist/esm/lib/utils/formatter/applyPattern.js +38 -0
- package/dist/esm/lib/utils/formatter/applyPattern.js.map +1 -0
- package/dist/esm/lib/utils/formatter/createFormatterRegisterOptions.js +22 -0
- package/dist/esm/lib/utils/formatter/createFormatterRegisterOptions.js.map +1 -0
- package/dist/esm/lib/utils/formatter/createPatternFormatter.js +25 -0
- package/dist/esm/lib/utils/formatter/createPatternFormatter.js.map +1 -0
- package/dist/esm/lib/utils/formatter/index.js +8 -0
- package/dist/esm/lib/utils/formatter/index.js.map +1 -0
- package/dist/esm/lib/utils/formatter/stripToDigits.js +12 -0
- package/dist/esm/lib/utils/formatter/stripToDigits.js.map +1 -0
- package/dist/esm/lib/utils/formatter/types.js +2 -0
- package/dist/esm/lib/utils/formatter/types.js.map +1 -0
- package/dist/esm/lib/utils/hooks/index.js +1 -0
- package/dist/esm/lib/utils/hooks/index.js.map +1 -1
- package/dist/esm/lib/utils/hooks/types.js +2 -0
- package/dist/esm/lib/utils/hooks/types.js.map +1 -0
- package/dist/esm/lib/utils/hooks/useFormattedValue.js +195 -0
- package/dist/esm/lib/utils/hooks/useFormattedValue.js.map +1 -0
- package/dist/esm/lib/utils/index.js +6 -2
- package/dist/esm/lib/utils/index.js.map +1 -1
- package/dist/esm/lib/utils/mergeRefs.js +25 -0
- package/dist/esm/lib/utils/mergeRefs.js.map +1 -0
- package/dist/esm/lib/utils/middleware/addRESTValidation.js +1 -1
- package/dist/esm/lib/utils/middleware/addRESTValidation.js.map +1 -1
- package/dist/types/lib/component/ChoicesField/common/Option/Option.d.ts.map +1 -1
- package/dist/types/lib/component/PhoneField/PhoneField.d.ts +2 -1
- package/dist/types/lib/component/PhoneField/PhoneField.d.ts.map +1 -1
- package/dist/types/lib/index.d.ts +4 -0
- package/dist/types/lib/index.d.ts.map +1 -1
- package/dist/types/lib/subcomponent/ComboboxInput/SingleCombobox.d.ts.map +1 -1
- package/dist/types/lib/subcomponent/ComboboxInput/utils/index.d.ts +0 -1
- package/dist/types/lib/subcomponent/ComboboxInput/utils/index.d.ts.map +1 -1
- package/dist/types/lib/subcomponent/PhoneInput/PhoneInput.d.ts +19 -2
- package/dist/types/lib/subcomponent/PhoneInput/PhoneInput.d.ts.map +1 -1
- package/dist/types/lib/subcomponent/PhoneInput/types.d.ts +20 -7
- package/dist/types/lib/subcomponent/PhoneInput/types.d.ts.map +1 -1
- package/dist/types/lib/utils/countries/index.d.ts +0 -3
- package/dist/types/lib/utils/countries/index.d.ts.map +1 -1
- package/dist/types/lib/utils/formatter/applyPattern.d.ts +17 -0
- package/dist/types/lib/utils/formatter/applyPattern.d.ts.map +1 -0
- package/dist/types/lib/utils/formatter/createFormatterRegisterOptions.d.ts +20 -0
- package/dist/types/lib/utils/formatter/createFormatterRegisterOptions.d.ts.map +1 -0
- package/dist/types/lib/utils/formatter/createPatternFormatter.d.ts +19 -0
- package/dist/types/lib/utils/formatter/createPatternFormatter.d.ts.map +1 -0
- package/dist/types/lib/utils/formatter/index.d.ts +6 -0
- package/dist/types/lib/utils/formatter/index.d.ts.map +1 -0
- package/dist/types/lib/utils/formatter/stripToDigits.d.ts +10 -0
- package/dist/types/lib/utils/formatter/stripToDigits.d.ts.map +1 -0
- package/dist/types/lib/utils/formatter/types.d.ts +30 -0
- package/dist/types/lib/utils/formatter/types.d.ts.map +1 -0
- package/dist/types/lib/utils/hooks/index.d.ts +2 -0
- package/dist/types/lib/utils/hooks/index.d.ts.map +1 -1
- package/dist/types/lib/utils/hooks/types.d.ts +33 -0
- package/dist/types/lib/utils/hooks/types.d.ts.map +1 -0
- package/dist/types/lib/utils/hooks/useFormattedValue.d.ts +30 -0
- package/dist/types/lib/utils/hooks/useFormattedValue.d.ts.map +1 -0
- package/dist/types/lib/utils/index.d.ts +2 -0
- package/dist/types/lib/utils/index.d.ts.map +1 -1
- package/dist/types/lib/utils/mergeRefs.d.ts +14 -0
- package/dist/types/lib/utils/mergeRefs.d.ts.map +1 -0
- package/package.json +17 -16
- package/dist/esm/lib/subcomponent/ComboboxInput/utils/mergeRefs.js +0 -12
- package/dist/esm/lib/subcomponent/ComboboxInput/utils/mergeRefs.js.map +0 -1
- package/dist/esm/lib/utils/countries/applyPhoneMask.js +0 -35
- package/dist/esm/lib/utils/countries/applyPhoneMask.js.map +0 -1
- package/dist/esm/lib/utils/countries/phoneRegisterOptions.js +0 -18
- package/dist/esm/lib/utils/countries/phoneRegisterOptions.js.map +0 -1
- package/dist/esm/lib/utils/countries/removePhoneMask.js +0 -12
- package/dist/esm/lib/utils/countries/removePhoneMask.js.map +0 -1
- package/dist/types/lib/subcomponent/ComboboxInput/utils/mergeRefs.d.ts +0 -3
- package/dist/types/lib/subcomponent/ComboboxInput/utils/mergeRefs.d.ts.map +0 -1
- package/dist/types/lib/utils/countries/applyPhoneMask.d.ts +0 -14
- package/dist/types/lib/utils/countries/applyPhoneMask.d.ts.map +0 -1
- package/dist/types/lib/utils/countries/phoneRegisterOptions.d.ts +0 -14
- package/dist/types/lib/utils/countries/phoneRegisterOptions.d.ts.map +0 -1
- package/dist/types/lib/utils/countries/removePhoneMask.d.ts +0 -10
- package/dist/types/lib/utils/countries/removePhoneMask.d.ts.map +0 -1
package/dist/esm/index.css
CHANGED
|
@@ -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
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
--
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
--
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
--
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
--
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
--
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
--
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
--
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
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
|
-
/* ──
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
--form-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
--form-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
--form-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
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
|
-
/*
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
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
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
border-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
border-left-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
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
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
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
|
-
/*
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
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
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
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
|
-
|
|
352
|
-
.ds.
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
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
|
-
/* ──
|
|
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
|
-
|
|
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 {
|