@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
@@ -1,99 +1,103 @@
1
- .ds.form-rich-choices {
2
- border: none;
3
- padding: 0;
4
- margin: 0;
5
- display: grid;
6
- grid-template-columns: subgrid;
7
- grid-column: 1 / -1;
8
- row-gap: var(--form-group-gap);
1
+ /* Layer: ds.components.global (@canonical/styles README, "Cascade layers"). */
9
2
 
10
- /* Each option (common/Option, `.ds.option`) is styled here, scoped to this
11
- * group so the generic class cannot collide with options elsewhere. */
12
- & > .ds.option {
13
- grid-column: var(--rich-choices-span, auto);
14
- position: relative;
15
- display: flex;
3
+ @layer ds.components.global {
4
+ .ds.form-rich-choices {
5
+ border: none;
6
+ padding: 0;
7
+ margin: 0;
8
+ display: grid;
9
+ grid-template-columns: subgrid;
10
+ grid-column: 1 / -1;
11
+ row-gap: var(--form-group-gap);
16
12
 
17
- /* Hide the native input */
18
- & > input {
19
- position: absolute;
20
- width: 1px;
21
- height: 1px;
22
- overflow: hidden;
23
- clip: rect(0, 0, 0, 0);
24
- white-space: nowrap;
25
- border: 0;
26
- }
27
-
28
- /* Label is the visible card surface */
29
- & > label {
13
+ /* Each option (common/Option, `.ds.option`) is styled here, scoped to this
14
+ * group so the generic class cannot collide with options elsewhere. */
15
+ & > .ds.option {
16
+ grid-column: var(--rich-choices-span, auto);
17
+ position: relative;
30
18
  display: flex;
31
- flex-direction: column;
32
- flex: 1;
33
- box-sizing: border-box;
34
- gap: var(--form-group-gap);
35
- padding-inline: var(--form-input-padding-inline);
36
- /* Block padding: chrome padding + baseline nudges, minus border */
37
- padding-block-start: calc(
38
- var(--form-input-padding-block) +
39
- var(--start-nudge, 0px) -
40
- var(--form-input-border-width)
41
- );
42
- padding-block-end: calc(
43
- var(--form-input-padding-block) +
44
- var(--end-nudge, 0px) -
45
- var(--form-input-border-width)
46
- );
47
- border: var(--form-input-border-width) solid
48
- var(--form-input-border-color);
49
- border-radius: var(--form-input-border-radius);
50
- background-color: var(--form-input-background);
51
- color: var(--form-input-color);
52
- cursor: pointer;
53
- transition:
54
- border-color 150ms ease,
55
- background-color 150ms ease,
56
- box-shadow 150ms ease;
57
- user-select: none;
58
- }
59
19
 
60
- /* Hover */
61
- & > input:not(:disabled) + label:hover {
62
- background-color: var(
63
- --hover--color-foreground-input,
64
- var(--color-foreground-input-hover)
65
- );
66
- }
20
+ /* Hide the native input */
21
+ & > input {
22
+ position: absolute;
23
+ width: 1px;
24
+ height: 1px;
25
+ overflow: hidden;
26
+ clip: rect(0, 0, 0, 0);
27
+ white-space: nowrap;
28
+ border: 0;
29
+ }
67
30
 
68
- /* Focus */
69
- /* biome-ignore lint/style/noDescendingSpecificity: state rules are ordered by
70
- interaction semantics (hover → focus → checked → disabled); the preceding
71
- :hover rule only reads as higher specificity because of its :not(:disabled)
72
- guard. Reordering to satisfy the linter would change the cascade. */
73
- & > input:focus-visible + label {
74
- outline: none;
75
- border-color: var(--form-input-border-color-focus);
76
- box-shadow: 0 0 0 1px var(--form-focus-ring-color);
77
- }
31
+ /* Label is the visible card surface */
32
+ & > label {
33
+ display: flex;
34
+ flex-direction: column;
35
+ flex: 1;
36
+ box-sizing: border-box;
37
+ gap: var(--form-group-gap);
38
+ padding-inline: var(--form-input-padding-inline);
39
+ /* Block padding: chrome padding + baseline nudges, minus border */
40
+ padding-block-start: calc(
41
+ var(--form-input-padding-block) +
42
+ var(--start-nudge, 0px) -
43
+ var(--form-input-border-width)
44
+ );
45
+ padding-block-end: calc(
46
+ var(--form-input-padding-block) +
47
+ var(--end-nudge, 0px) -
48
+ var(--form-input-border-width)
49
+ );
50
+ border: var(--form-input-border-width) solid
51
+ var(--form-input-border-color);
52
+ border-radius: var(--form-input-border-radius);
53
+ background-color: var(--form-input-background);
54
+ color: var(--form-input-color);
55
+ cursor: pointer;
56
+ transition:
57
+ border-color var(--motion-duration-fast) ease,
58
+ background-color var(--motion-duration-fast) ease,
59
+ box-shadow var(--motion-duration-fast) ease;
60
+ user-select: none;
61
+ }
78
62
 
79
- /* Checked / selected */
80
- /* biome-ignore lint/style/noDescendingSpecificity: see the focus rule above. */
81
- & > input:checked + label {
82
- border-color: var(--form-input-border-color-focus);
83
- background-color: var(
84
- --hover--color-foreground-input,
85
- var(--color-foreground-input-hover)
86
- );
87
- box-shadow: 0 0 0 1px var(--form-input-border-color-focus);
88
- }
63
+ /* Hover */
64
+ & > input:not(:disabled) + label:hover {
65
+ background-color: var(
66
+ --hover--color-foreground-input,
67
+ var(--color-foreground-input-hover)
68
+ );
69
+ }
70
+
71
+ /* Focus */
72
+ /* biome-ignore lint/style/noDescendingSpecificity: state rules are ordered by
73
+ interaction semantics (hover → focus → checked → disabled); the preceding
74
+ :hover rule only reads as higher specificity because of its :not(:disabled)
75
+ guard. Reordering to satisfy the linter would change the cascade. */
76
+ & > input:focus-visible + label {
77
+ outline: none;
78
+ border-color: var(--form-input-border-color-focus);
79
+ box-shadow: 0 0 0 1px var(--form-focus-ring-color);
80
+ }
81
+
82
+ /* Checked / selected */
83
+ /* biome-ignore lint/style/noDescendingSpecificity: see the focus rule above. */
84
+ & > input:checked + label {
85
+ border-color: var(--form-input-border-color-focus);
86
+ background-color: var(
87
+ --hover--color-foreground-input,
88
+ var(--color-foreground-input-hover)
89
+ );
90
+ box-shadow: 0 0 0 1px var(--form-input-border-color-focus);
91
+ }
89
92
 
90
- /* Disabled */
91
- /* biome-ignore lint/style/noDescendingSpecificity: see the focus rule above. */
92
- & > input:disabled + label {
93
- border-color: var(--form-input-border-color-disabled);
94
- background-color: var(--form-input-background-disabled);
95
- color: var(--form-input-color-disabled);
96
- cursor: not-allowed;
93
+ /* Disabled */
94
+ /* biome-ignore lint/style/noDescendingSpecificity: see the focus rule above. */
95
+ & > input:disabled + label {
96
+ border-color: var(--form-input-border-color-disabled);
97
+ background-color: var(--form-input-background-disabled);
98
+ color: var(--form-input-color-disabled);
99
+ cursor: not-allowed;
100
+ }
97
101
  }
98
102
  }
99
103
  }
@@ -1,131 +1,135 @@
1
- .ds.form-checkbox {
2
- appearance: none;
3
- box-sizing: border-box;
4
- /* Positioning context for the masked checkmark/minus glyph (`::before`). */
5
- position: relative;
6
- /* Align to the field edge like the label (no side margin by default), not to
7
- * the input's inner padding. Overridable via the shared variable. */
8
- margin-inline: var(--form-label-padding-inline, 0);
9
- /* A 16px control — a fixed element size, NOT a baseline multiple. It was
10
- `--space-baseline × 2` (16px when the baseline was 8px), but the 4px-baseline
11
- spike halved it to 8px. Size to the stable --dimension-200 (16px) so the
12
- control size is decoupled from the baseline grid unit. */
13
- width: var(--dimension-200);
14
- height: var(--dimension-200);
15
- border: var(--dimension-stroke-thickness-medium) solid var(--color-border);
16
- border-radius: var(--dimension-radius-small);
17
- background: var(
18
- --surface-color-foreground-checkbox-unselected,
19
- var(--color-foreground-checkbox-unselected)
20
- );
21
- cursor: pointer;
22
- transition:
23
- background-color 150ms ease,
24
- border-color 150ms ease;
1
+ /* Layer: ds.components.global (@canonical/styles README, "Cascade layers"). */
25
2
 
26
- /* The glyph is a masked pseudo-element layered over the box, NOT a
27
- * background-image: a background-image SVG can't be recoloured by CSS, so the
28
- * checkmark would ignore the theme. Masking + `background-color` lets the
29
- * glyph take the checkmark token (same technique as PasswordInput's eye
30
- * icon). The box keeps its own `background` for the selected fill.
31
- *
32
- * IMPORTANT: only the :checked / :indeterminate rules give the ::before a
33
- * `mask-image` AND a `background-color`. The base ::before sets geometry only
34
- * — with no mask-image the mask is `none`, which means NO clipping, so a
35
- * `background-color` here would paint the WHOLE box as a solid square in the
36
- * unchecked state (visible under any theme where the checkmark colour differs
37
- * from the box). So the paint lives with the mask, never on its own. */
38
- &::before {
39
- content: "";
40
- position: absolute;
41
- inset: 0;
42
- mask-repeat: no-repeat;
43
- mask-position: center;
44
- mask-size: 75%;
45
- -webkit-mask-repeat: no-repeat;
46
- -webkit-mask-position: center;
47
- -webkit-mask-size: 75%;
48
- }
49
-
50
- &:checked {
3
+ @layer ds.components.global {
4
+ .ds.form-checkbox {
5
+ appearance: none;
6
+ box-sizing: border-box;
7
+ /* Positioning context for the masked checkmark/minus glyph (`::before`). */
51
8
  position: relative;
52
- /* Selected fill + checkmark read the surface-provided tokens (with a flat
53
- * fallback) so the control adapts to OnSurface stepping. */
9
+ /* Align to the field edge like the label (no side margin by default), not to
10
+ * the input's inner padding. Overridable via the shared variable. */
11
+ margin-inline: var(--form-label-padding-inline, 0);
12
+ /* A 16px control — a fixed element size, NOT a baseline multiple. It was
13
+ `--space-baseline × 2` (16px when the baseline was 8px), but the 4px-baseline
14
+ spike halved it to 8px. Size to the stable --dimension-200 (16px) so the
15
+ control size is decoupled from the baseline grid unit. */
16
+ width: var(--dimension-200);
17
+ height: var(--dimension-200);
18
+ border: var(--dimension-stroke-thickness-medium) solid var(--color-border);
19
+ border-radius: var(--dimension-radius-small);
54
20
  background: var(
55
- --surface-color-foreground-checkbox-selected,
56
- var(--color-foreground-checkbox-selected)
57
- );
58
- border-color: var(
59
- --surface-color-foreground-checkbox-selected,
60
- var(--color-foreground-checkbox-selected)
21
+ --surface-color-foreground-checkbox-unselected,
22
+ var(--color-foreground-checkbox-unselected)
61
23
  );
24
+ cursor: pointer;
25
+ transition:
26
+ background-color var(--motion-duration-fast) ease,
27
+ border-color var(--motion-duration-fast) ease;
62
28
 
29
+ /* The glyph is a masked pseudo-element layered over the box, NOT a
30
+ * background-image: a background-image SVG can't be recoloured by CSS, so the
31
+ * checkmark would ignore the theme. Masking + `background-color` lets the
32
+ * glyph take the checkmark token (same technique as PasswordInput's eye
33
+ * icon). The box keeps its own `background` for the selected fill.
34
+ *
35
+ * IMPORTANT: only the :checked / :indeterminate rules give the ::before a
36
+ * `mask-image` AND a `background-color`. The base ::before sets geometry only
37
+ * — with no mask-image the mask is `none`, which means NO clipping, so a
38
+ * `background-color` here would paint the WHOLE box as a solid square in the
39
+ * unchecked state (visible under any theme where the checkmark colour differs
40
+ * from the box). So the paint lives with the mask, never on its own. */
63
41
  &::before {
64
- background-color: var(
65
- --surface-color-foreground-checkbox-checkmark,
66
- var(--color-foreground-checkbox-checkmark)
67
- );
68
- mask-image: url("/icons/checkmark.svg#checkmark");
69
- -webkit-mask-image: url("/icons/checkmark.svg#checkmark");
42
+ content: "";
43
+ position: absolute;
44
+ inset: 0;
45
+ mask-repeat: no-repeat;
46
+ mask-position: center;
47
+ mask-size: 100%;
48
+ -webkit-mask-repeat: no-repeat;
49
+ -webkit-mask-position: center;
50
+ -webkit-mask-size: 100%;
70
51
  }
71
- }
72
52
 
73
- &:indeterminate {
74
- position: relative;
75
- background: var(
76
- --surface-color-foreground-checkbox-selected,
77
- var(--color-foreground-checkbox-selected)
78
- );
79
- border-color: var(
80
- --surface-color-foreground-checkbox-selected,
81
- var(--color-foreground-checkbox-selected)
82
- );
53
+ &:checked {
54
+ position: relative;
55
+ /* Selected fill + checkmark read the surface-provided tokens (with a flat
56
+ * fallback) so the control adapts to OnSurface stepping. */
57
+ background: var(
58
+ --surface-color-foreground-checkbox-selected,
59
+ var(--color-foreground-checkbox-selected)
60
+ );
61
+ border-color: var(
62
+ --surface-color-foreground-checkbox-selected,
63
+ var(--color-foreground-checkbox-selected)
64
+ );
83
65
 
84
- &::before {
85
- background-color: var(
86
- --surface-color-foreground-checkbox-checkmark,
87
- var(--color-foreground-checkbox-checkmark)
66
+ &::before {
67
+ background-color: var(
68
+ --surface-color-foreground-checkbox-checkmark,
69
+ var(--color-foreground-checkbox-checkmark)
70
+ );
71
+ mask-image: url("/icons/checkmark.svg#checkmark");
72
+ -webkit-mask-image: url("/icons/checkmark.svg#checkmark");
73
+ }
74
+ }
75
+
76
+ &:indeterminate {
77
+ position: relative;
78
+ background: var(
79
+ --surface-color-foreground-checkbox-selected,
80
+ var(--color-foreground-checkbox-selected)
81
+ );
82
+ border-color: var(
83
+ --surface-color-foreground-checkbox-selected,
84
+ var(--color-foreground-checkbox-selected)
88
85
  );
89
- mask-image: url("/icons/minus.svg#minus");
90
- -webkit-mask-image: url("/icons/minus.svg#minus");
86
+
87
+ &::before {
88
+ background-color: var(
89
+ --surface-color-foreground-checkbox-checkmark,
90
+ var(--color-foreground-checkbox-checkmark)
91
+ );
92
+ mask-image: url("/icons/minus.svg#minus");
93
+ -webkit-mask-image: url("/icons/minus.svg#minus");
94
+ }
91
95
  }
92
- }
93
96
 
94
- &:hover:not(:disabled):not(:checked):not(:indeterminate) {
95
- background: var(--color-foreground-checkbox-unselected-hover);
96
- }
97
+ &:hover:not(:disabled):not(:checked):not(:indeterminate) {
98
+ background: var(--color-foreground-checkbox-unselected-hover);
99
+ }
97
100
 
98
- /* Hover on a selected/indeterminate box shifts ONLY the fill, not the
99
- * checkmark/minus glyph (per design review): the background swaps to the
100
- * hovered selected shade while `::before` keeps its own colour. The hover
101
- * shade comes from the `--hover--…-selected` channel (criticality-style OKLCH
102
- * delta shim), replacing the old whole-element `filter: brightness()` that
103
- * also dimmed the glyph. */
104
- &:checked:hover:not(:disabled),
105
- &:indeterminate:hover:not(:disabled) {
106
- background-color: var(--hover--color-foreground-checkbox-selected);
107
- border-color: var(--hover--color-foreground-checkbox-selected);
108
- }
101
+ /* Hover on a selected/indeterminate box shifts ONLY the fill, not the
102
+ * checkmark/minus glyph (per design review): the background swaps to the
103
+ * hovered selected shade while `::before` keeps its own colour. The hover
104
+ * shade comes from the `--hover--…-selected` channel (criticality-style OKLCH
105
+ * delta shim), replacing the old whole-element `filter: brightness()` that
106
+ * also dimmed the glyph. */
107
+ &:checked:hover:not(:disabled),
108
+ &:indeterminate:hover:not(:disabled) {
109
+ background-color: var(--hover--color-foreground-checkbox-selected);
110
+ border-color: var(--hover--color-foreground-checkbox-selected);
111
+ }
109
112
 
110
- &:focus-visible {
111
- outline: none;
112
- border-color: var(--color-focusRing);
113
- box-shadow: 0 0 0 1px var(--color-focusRing);
114
- }
113
+ &:focus-visible {
114
+ outline: none;
115
+ border-color: var(--color-focus-ring);
116
+ box-shadow: 0 0 0 1px var(--color-focus-ring);
117
+ }
115
118
 
116
- &:disabled {
117
- border-color: var(--color-border-disabled);
118
- background: var(--color-foreground-checkbox-unselected-disabled);
119
- cursor: not-allowed;
120
- }
119
+ &:disabled {
120
+ border-color: var(--color-border-disabled);
121
+ background: var(--color-foreground-checkbox-unselected-disabled);
122
+ cursor: not-allowed;
123
+ }
121
124
 
122
- &:checked:disabled,
123
- &:indeterminate:disabled {
124
- background: var(--color-foreground-checkbox-selected-disabled);
125
- border-color: var(--color-foreground-checkbox-selected-disabled);
125
+ &:checked:disabled,
126
+ &:indeterminate:disabled {
127
+ background: var(--color-foreground-checkbox-selected-disabled);
128
+ border-color: var(--color-foreground-checkbox-selected-disabled);
126
129
 
127
- &::before {
128
- background-color: var(--color-foreground-checkbox-checkmark-disabled);
130
+ &::before {
131
+ background-color: var(--color-foreground-checkbox-checkmark-disabled);
132
+ }
129
133
  }
130
134
  }
131
135
  }