@canonical/react-ds-global-form 0.30.0 → 0.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/density.css +357 -0
- package/dist/esm/docs/examples/density-examples.css +20 -0
- package/dist/esm/index.css +110 -12
- package/dist/esm/lib/_work_in_progress/DensityTestbed/Testbed.js +77 -0
- package/dist/esm/lib/_work_in_progress/DensityTestbed/Testbed.js.map +1 -0
- package/dist/esm/lib/_work_in_progress/DensityTestbed/baseline-system.css +81 -0
- package/dist/esm/lib/_work_in_progress/DensityTestbed/density.testbed.css +153 -0
- package/dist/esm/lib/_work_in_progress/DensityTestbed/mocks.js +23 -0
- package/dist/esm/lib/_work_in_progress/DensityTestbed/mocks.js.map +1 -0
- package/dist/esm/lib/common/Wrapper/ToggleWrapper.css +33 -4
- package/dist/esm/lib/common/Wrapper/ToggleWrapper.js +2 -2
- package/dist/esm/lib/common/Wrapper/ToggleWrapper.js.map +1 -1
- package/dist/esm/lib/common/Wrapper/styles.css +15 -1
- package/dist/esm/lib/common/Wrapper/withToggleWrapper.js +11 -1
- package/dist/esm/lib/common/Wrapper/withToggleWrapper.js.map +1 -1
- package/dist/esm/lib/common/bindField/bindField.js +15 -8
- package/dist/esm/lib/common/bindField/bindField.js.map +1 -1
- package/dist/esm/lib/component/ChoicesField/common/Option/Option.js +1 -1
- package/dist/esm/lib/component/ChoicesField/common/Option/Option.js.map +1 -1
- package/dist/esm/lib/component/ChoicesField/styles.css +55 -15
- package/dist/esm/lib/component/DateField/DateField.js +19 -1
- package/dist/esm/lib/component/DateField/DateField.js.map +1 -1
- package/dist/esm/lib/component/FileUploadField/FileUploadField.js +40 -3
- package/dist/esm/lib/component/FileUploadField/FileUploadField.js.map +1 -1
- package/dist/esm/lib/component/NumberField/NumberField.js +1 -1
- package/dist/esm/lib/component/NumberField/NumberField.js.map +1 -1
- package/dist/esm/lib/component/RangeField/RangeField.js +1 -1
- package/dist/esm/lib/component/RangeField/RangeField.js.map +1 -1
- package/dist/esm/lib/component/SwitchField/SwitchField.js +6 -1
- package/dist/esm/lib/component/SwitchField/SwitchField.js.map +1 -1
- package/dist/esm/lib/subcomponent/CheckboxInput/styles.css +45 -16
- package/dist/esm/lib/subcomponent/DateInput/styles.css +12 -0
- package/dist/esm/lib/subcomponent/DateTimeInput/styles.css +13 -0
- package/dist/esm/lib/subcomponent/Field/Label/Label.js +1 -3
- package/dist/esm/lib/subcomponent/Field/Label/Label.js.map +1 -1
- package/dist/esm/lib/subcomponent/Field/Label/styles.css +2 -3
- package/dist/esm/lib/subcomponent/FileUploadInput/FileUploadInput.js +11 -21
- package/dist/esm/lib/subcomponent/FileUploadInput/FileUploadInput.js.map +1 -1
- package/dist/esm/lib/subcomponent/FileUploadInput/styles.css +3 -3
- package/dist/esm/lib/subcomponent/PasswordInput/styles.css +5 -6
- package/dist/esm/lib/subcomponent/RadioInput/styles.css +36 -7
- package/dist/esm/lib/subcomponent/RangeInput/styles.css +10 -9
- package/dist/esm/lib/subcomponent/SelectInput/styles.css +32 -4
- package/dist/esm/lib/subcomponent/SwitchInput/styles.css +27 -10
- package/dist/esm/lib/subcomponent/TextInput/TextInput.js +1 -1
- package/dist/esm/lib/subcomponent/TextInput/TextInput.js.map +1 -1
- package/dist/esm/lib/subcomponent/TextareaInput/TextareaInput.js +1 -3
- package/dist/esm/lib/subcomponent/TextareaInput/TextareaInput.js.map +1 -1
- package/dist/esm/lib/subcomponent/TextareaInput/styles.css +4 -9
- package/dist/esm/lib/subcomponent/TimeInput/styles.css +8 -0
- package/dist/esm/lib/utils/countries/countries.js +1 -1
- package/dist/esm/lib/utils/countries/countries.js.map +1 -1
- package/dist/esm/lib/utils/hooks/useFieldError.js +21 -24
- package/dist/esm/lib/utils/hooks/useFieldError.js.map +1 -1
- package/dist/types/lib/_work_in_progress/DensityTestbed/Testbed.d.ts +42 -0
- package/dist/types/lib/_work_in_progress/DensityTestbed/Testbed.d.ts.map +1 -0
- package/dist/types/lib/_work_in_progress/DensityTestbed/mocks.d.ts +26 -0
- package/dist/types/lib/_work_in_progress/DensityTestbed/mocks.d.ts.map +1 -0
- package/dist/types/lib/common/Wrapper/ToggleWrapper.d.ts +1 -1
- package/dist/types/lib/common/Wrapper/ToggleWrapper.d.ts.map +1 -1
- package/dist/types/lib/common/Wrapper/withToggleWrapper.d.ts +4 -1
- package/dist/types/lib/common/Wrapper/withToggleWrapper.d.ts.map +1 -1
- package/dist/types/lib/common/Wrapper/withWrapper.d.ts +1 -1
- package/dist/types/lib/common/Wrapper/withWrapper.d.ts.map +1 -1
- package/dist/types/lib/common/bindField/bindField.d.ts.map +1 -1
- package/dist/types/lib/common/bindField/types.d.ts +14 -5
- package/dist/types/lib/common/bindField/types.d.ts.map +1 -1
- package/dist/types/lib/common/types.d.ts +1 -0
- package/dist/types/lib/common/types.d.ts.map +1 -1
- package/dist/types/lib/component/ChoicesField/ChoicesField.d.ts +1 -0
- package/dist/types/lib/component/ChoicesField/ChoicesField.d.ts.map +1 -1
- package/dist/types/lib/component/ColorField/ColorField.d.ts +1 -0
- package/dist/types/lib/component/ColorField/ColorField.d.ts.map +1 -1
- package/dist/types/lib/component/ComboboxField/ComboboxField.d.ts +1 -0
- package/dist/types/lib/component/ComboboxField/ComboboxField.d.ts.map +1 -1
- package/dist/types/lib/component/DateField/DateField.d.ts +4 -2
- package/dist/types/lib/component/DateField/DateField.d.ts.map +1 -1
- package/dist/types/lib/component/DateTimeField/DateTimeField.d.ts +1 -0
- package/dist/types/lib/component/DateTimeField/DateTimeField.d.ts.map +1 -1
- package/dist/types/lib/component/FileUploadField/FileUploadField.d.ts +9 -5
- package/dist/types/lib/component/FileUploadField/FileUploadField.d.ts.map +1 -1
- package/dist/types/lib/component/HiddenField/HiddenField.d.ts +1 -0
- package/dist/types/lib/component/HiddenField/HiddenField.d.ts.map +1 -1
- package/dist/types/lib/component/NumberField/NumberField.d.ts +1 -0
- package/dist/types/lib/component/NumberField/NumberField.d.ts.map +1 -1
- package/dist/types/lib/component/PasswordField/PasswordField.d.ts +1 -0
- package/dist/types/lib/component/PasswordField/PasswordField.d.ts.map +1 -1
- package/dist/types/lib/component/PhoneField/PhoneField.d.ts +1 -0
- package/dist/types/lib/component/PhoneField/PhoneField.d.ts.map +1 -1
- package/dist/types/lib/component/RangeField/RangeField.d.ts +1 -0
- package/dist/types/lib/component/RangeField/RangeField.d.ts.map +1 -1
- package/dist/types/lib/component/RatingField/RatingField.d.ts +1 -0
- package/dist/types/lib/component/RatingField/RatingField.d.ts.map +1 -1
- package/dist/types/lib/component/RichChoicesField/RichChoicesField.d.ts +1 -0
- package/dist/types/lib/component/RichChoicesField/RichChoicesField.d.ts.map +1 -1
- package/dist/types/lib/component/SelectField/SelectField.d.ts +1 -0
- package/dist/types/lib/component/SelectField/SelectField.d.ts.map +1 -1
- package/dist/types/lib/component/SwitchField/SwitchField.d.ts +5 -0
- package/dist/types/lib/component/SwitchField/SwitchField.d.ts.map +1 -1
- package/dist/types/lib/component/TextField/TextField.d.ts +1 -0
- package/dist/types/lib/component/TextField/TextField.d.ts.map +1 -1
- package/dist/types/lib/component/TextareaField/TextareaField.d.ts +1 -0
- package/dist/types/lib/component/TextareaField/TextareaField.d.ts.map +1 -1
- package/dist/types/lib/component/TimeField/TimeField.d.ts +1 -0
- package/dist/types/lib/component/TimeField/TimeField.d.ts.map +1 -1
- package/dist/types/lib/subcomponent/Field/Label/Label.d.ts.map +1 -1
- package/dist/types/lib/subcomponent/FileUploadInput/FileUploadInput.d.ts.map +1 -1
- package/dist/types/lib/subcomponent/TextareaInput/TextareaInput.d.ts.map +1 -1
- package/dist/types/lib/utils/hooks/useFieldError.d.ts +14 -0
- package/dist/types/lib/utils/hooks/useFieldError.d.ts.map +1 -1
- package/package.json +14 -14
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Testbed chrome for the baseline/density spike (WORK IN PROGRESS).
|
|
3
|
+
*
|
|
4
|
+
* The density + baseline MODEL now lives in the package: src/density.css
|
|
5
|
+
* (imported by src/index.css), so real components consume it by default. This
|
|
6
|
+
* file keeps only the TESTBED-ONLY helpers: the size-agnostic `.baseline` proof
|
|
7
|
+
* class and the `.spike-baseline-boxed` prototype + their proof surfaces.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/* ── DS.01 — .baseline: snap any element to the grid, whatever its size ──────
|
|
11
|
+
* Reads whatever --font-size / --line-height is present and computes the same
|
|
12
|
+
* cap-unit nudges the engine uses on h1..h6/p, without assigning a tier. The
|
|
13
|
+
* maths is font-relative, so it holds at any size. */
|
|
14
|
+
.baseline {
|
|
15
|
+
--bl-line-height-ratio: var(--line-height-ratio, 1.4);
|
|
16
|
+
--bl-computed-line-height: var(
|
|
17
|
+
--line-height,
|
|
18
|
+
round(up, calc(1em * var(--bl-line-height-ratio)), var(--baseline-height))
|
|
19
|
+
);
|
|
20
|
+
line-height: var(--bl-computed-line-height);
|
|
21
|
+
|
|
22
|
+
--bl-baseline-position: calc((var(--bl-computed-line-height) + 1cap) / 2);
|
|
23
|
+
--bl-start-nudge: calc(
|
|
24
|
+
var(--baseline-height) -
|
|
25
|
+
mod(var(--bl-baseline-position), var(--baseline-height))
|
|
26
|
+
);
|
|
27
|
+
--bl-end-nudge: calc(var(--baseline-height) - var(--bl-start-nudge));
|
|
28
|
+
|
|
29
|
+
padding-block-start: var(--bl-start-nudge);
|
|
30
|
+
padding-block-end: var(--bl-end-nudge);
|
|
31
|
+
margin-block: 0;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/* ── DS.02 — .spike-baseline-boxed: PROTOTYPE ONLY, NOT CORE API ─────────────
|
|
35
|
+
* `.baseline` with a density-chosen line-height; the box height is snapped to the
|
|
36
|
+
* grid (intrinsic snap via calc-size where supported, fixed grid-multiple
|
|
37
|
+
* fallback). Testbed only; never export. */
|
|
38
|
+
.spike-baseline-boxed {
|
|
39
|
+
--line-height: var(--density-line-height, calc(var(--baseline-height) * 6));
|
|
40
|
+
box-sizing: border-box;
|
|
41
|
+
block-size: var(--density-line-height, calc(var(--baseline-height) * 6));
|
|
42
|
+
}
|
|
43
|
+
@supports (block-size: calc-size(min-content, size)) {
|
|
44
|
+
.spike-baseline-boxed {
|
|
45
|
+
block-size: calc-size(min-content, round(up, size, var(--baseline-height)));
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/* ── Proof surface for .baseline (DS.01) — off-scale sizes on one line ─────── */
|
|
50
|
+
.baseline-proof {
|
|
51
|
+
display: flex;
|
|
52
|
+
align-items: flex-start;
|
|
53
|
+
gap: calc(var(--baseline-height) * 4);
|
|
54
|
+
overflow-x: auto;
|
|
55
|
+
white-space: nowrap;
|
|
56
|
+
}
|
|
57
|
+
.baseline-proof > .baseline {
|
|
58
|
+
font-family: inherit;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/* ── Proof surface for .spike-baseline-boxed (DS.02) — mixed sizes, 2 densities ── */
|
|
62
|
+
.boxed-proof {
|
|
63
|
+
display: flex;
|
|
64
|
+
align-items: flex-start;
|
|
65
|
+
gap: calc(var(--baseline-height) * 3);
|
|
66
|
+
overflow-x: auto;
|
|
67
|
+
white-space: nowrap;
|
|
68
|
+
margin-block: calc(var(--baseline-height) * 2);
|
|
69
|
+
}
|
|
70
|
+
.boxed-proof > .spike-baseline-boxed {
|
|
71
|
+
border: 1px solid var(--color-border, #b3b3b3);
|
|
72
|
+
border-radius: var(--dimension-radius-100, 0.25rem);
|
|
73
|
+
padding-inline: calc(var(--baseline-height) * 2);
|
|
74
|
+
background: transparent; /* let the grid overlay show through */
|
|
75
|
+
}
|
|
76
|
+
.boxed-proof.is-dense {
|
|
77
|
+
--density-line-height: calc(var(--baseline-height) * 6); /* 24px */
|
|
78
|
+
}
|
|
79
|
+
.boxed-proof.is-comfortable {
|
|
80
|
+
--density-line-height: calc(var(--baseline-height) * 8); /* 32px */
|
|
81
|
+
}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Baseline-alignment spike — testbed stylesheet (WORK IN PROGRESS)
|
|
3
|
+
*
|
|
4
|
+
* SPIKE surface, not shipping CSS. Scoped under `.density-testbed`.
|
|
5
|
+
*
|
|
6
|
+
* Layout philosophy (per session S TODOs 2–4, 7):
|
|
7
|
+
* · No cards, no field labels — zero chrome noise.
|
|
8
|
+
* · LINE-BASED: each bucket is ONE horizontal line of inline-block elements.
|
|
9
|
+
* Overflow-x scroll is fine; we are reading vertical alignment, not layout.
|
|
10
|
+
* · One bucket per story.
|
|
11
|
+
* · Every line starts with a few letters of paragraph-style text (the `.p`
|
|
12
|
+
* reference), so controls can be read against prose on the same baseline.
|
|
13
|
+
*
|
|
14
|
+
* The baseline grid overlay comes from the styles-debug plugin (story
|
|
15
|
+
* `parameters.baseline`); the box seat uses the shipped engine model (the
|
|
16
|
+
* alternative top-align + external-margin model lives in SPIKE.md).
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/* ── The testbed root ── */
|
|
20
|
+
.density-testbed {
|
|
21
|
+
/* --baseline-height is 4px. Source of truth, in order:
|
|
22
|
+
1. @canonical/styles-typography's baseline-shim.css registers it via
|
|
23
|
+
`@property … initial-value: 0.25rem`, so the engine ALWAYS has 4px even
|
|
24
|
+
if styles-main did not load (order-independent — learned from the
|
|
25
|
+
typography example, which loads an engine standalone). Then
|
|
26
|
+
2. @canonical/styles' spacing.css sets it explicitly to 0.25rem when present.
|
|
27
|
+
The literal fallback below is belt-and-suspenders; the @property makes it
|
|
28
|
+
redundant. Nothing to override here. */
|
|
29
|
+
padding: 0 var(--baseline-height, 0.25rem);
|
|
30
|
+
color: var(--color-text, #1a1a1a);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/* ───────────────────────────────────────────────────────────────────────────
|
|
34
|
+
* Bucket row — REGULAR component layout, no flattening or overrides
|
|
35
|
+
*
|
|
36
|
+
* A simple inline row: a short prose lead, then the components in their NORMAL
|
|
37
|
+
* structure laid inline. Controls are top-referenced density boxes (the density
|
|
38
|
+
* system seats each one's text on the grid INTERNALLY), so the row aligns the
|
|
39
|
+
* boxes by their TOPS. No block padding — the row must sit at the canvas origin
|
|
40
|
+
* so what we read is the density system's own grid registration, not a nudge. */
|
|
41
|
+
.density-testbed__row {
|
|
42
|
+
display: flex;
|
|
43
|
+
flex-wrap: nowrap; /* one horizontal line — overflow scrolls, never wraps */
|
|
44
|
+
align-items: flex-start;
|
|
45
|
+
gap: calc(var(--baseline-height) * 3); /* 12px */
|
|
46
|
+
overflow-x: auto;
|
|
47
|
+
}
|
|
48
|
+
.density-testbed__row > * {
|
|
49
|
+
flex: 0 0 auto; /* natural width, don't grow/shrink; the row scrolls instead */
|
|
50
|
+
}
|
|
51
|
+
.density-testbed__row > .p {
|
|
52
|
+
margin: 0;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/* Re-seat the reference LEAD to the density target (TESTBED ONLY) ──────────────
|
|
56
|
+
* Prose is engine-seated now (Stage A), which lands it on the NEAREST grid line —
|
|
57
|
+
* one baseline off from the controls' density TARGET line. The lead only exists to
|
|
58
|
+
* be read against the controls, so here (and only here) we opt it back into the
|
|
59
|
+
* exact density seat the controls use: crush to line-height 1, then pad the top by
|
|
60
|
+
* the same `target − (1em+1cap)/2` the shipping controls use. This is calibration
|
|
61
|
+
* of a measuring stick, NOT a change to how prose ships. */
|
|
62
|
+
.density-testbed__row > .density-testbed__lead.p {
|
|
63
|
+
line-height: 1;
|
|
64
|
+
padding-block-start: max(
|
|
65
|
+
0px,
|
|
66
|
+
calc(var(--density-target-baseline-px, 0px) - calc((1em + 1cap) / 2))
|
|
67
|
+
);
|
|
68
|
+
padding-block-end: 0;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/* ───────────────────────────────────────────────────────────────────────────
|
|
72
|
+
* Boxed controls — the two alignment models
|
|
73
|
+
*
|
|
74
|
+
* `.spike-box` is a bordered box whose interior is a single line of `.p` text
|
|
75
|
+
* (button label, input value, nav item, table cell). Inline-block so it sits on
|
|
76
|
+
* the line. The text seat reads the engine's --start-nudge / --end-nudge.
|
|
77
|
+
* ─────────────────────────────────────────────────────────────────────────── */
|
|
78
|
+
.density-testbed .spike-box {
|
|
79
|
+
--box-border-width: 1px;
|
|
80
|
+
--box-padding-inline: var(--density-padding-inline, 0.75rem);
|
|
81
|
+
|
|
82
|
+
display: inline-flex;
|
|
83
|
+
align-items: stretch;
|
|
84
|
+
box-sizing: border-box;
|
|
85
|
+
vertical-align: baseline;
|
|
86
|
+
border: var(--box-border-width) solid var(--color-border, #b3b3b3);
|
|
87
|
+
border-radius: var(--dimension-radius-100, 0.25rem);
|
|
88
|
+
padding-inline: var(--box-padding-inline);
|
|
89
|
+
background: var(--color-background, #fff);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.density-testbed .spike-box > .seat {
|
|
93
|
+
display: block;
|
|
94
|
+
white-space: nowrap;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/* Shared-border stack (list/table rows) — laid horizontally on the line here,
|
|
98
|
+
each cell a box; the shared-border collapse is between inline siblings. */
|
|
99
|
+
.density-testbed .spike-rows {
|
|
100
|
+
display: inline-flex;
|
|
101
|
+
vertical-align: baseline;
|
|
102
|
+
}
|
|
103
|
+
.density-testbed .spike-rows > .spike-box {
|
|
104
|
+
border-radius: 0;
|
|
105
|
+
}
|
|
106
|
+
.density-testbed .spike-rows > .spike-box + .spike-box {
|
|
107
|
+
border-inline-start: none;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/* Box seat — the shipped engine model: engine's asymmetric nudges, both borders
|
|
111
|
+
* on the grid. (The current/proposed model toggle was removed; the alternative
|
|
112
|
+
* top-align + external-margin model is documented in SPIKE.md.) */
|
|
113
|
+
.density-testbed .spike-box > .seat {
|
|
114
|
+
padding-block-start: var(--start-nudge);
|
|
115
|
+
padding-block-end: var(--end-nudge);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/* ───────────────────────────────────────────────────────────────────────────
|
|
119
|
+
* Typography bucket (TODO 5) — real paragraph text at several sizes on one line,
|
|
120
|
+
* to witness how the 4px baseline affects cap-based nudges (TODO 6). Inline so
|
|
121
|
+
* the sizes sit next to each other and can be read against the grid together.
|
|
122
|
+
* ─────────────────────────────────────────────────────────────────────────── */
|
|
123
|
+
.density-testbed__type {
|
|
124
|
+
display: flex;
|
|
125
|
+
align-items: flex-start;
|
|
126
|
+
gap: calc(var(--baseline-height) * 4);
|
|
127
|
+
overflow-x: auto;
|
|
128
|
+
white-space: nowrap;
|
|
129
|
+
padding-block: calc(var(--baseline-height) * 2);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/* Stacked full paragraphs of each tier, one after another, below the inline
|
|
133
|
+
row — so a real prose BLOCK of each tier can be read against the grid. */
|
|
134
|
+
.density-testbed__prose {
|
|
135
|
+
max-width: 40rem;
|
|
136
|
+
margin-top: calc(var(--baseline-height) * 4);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/* Both sections use the package's own tags (h1..h6, p). The engine sizes each
|
|
140
|
+
tier; we only reset the demo margins so the grid reading is clean. No custom
|
|
141
|
+
size classes — each tag IS its tier. */
|
|
142
|
+
.density-testbed__type > :where(h1, h2, h3, h4, h5, h6, p),
|
|
143
|
+
.density-testbed__prose > :where(h1, h2, h3, h4, h5, h6, p) {
|
|
144
|
+
margin: 0;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/* ── Density inline lever (retained) ── */
|
|
148
|
+
.density-comfortable {
|
|
149
|
+
--density-padding-inline: 0.75rem;
|
|
150
|
+
}
|
|
151
|
+
.density-dense {
|
|
152
|
+
--density-padding-inline: 0.5rem;
|
|
153
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Baseline-alignment spike — boxed-control primitive + mocks (WORK IN PROGRESS)
|
|
4
|
+
*
|
|
5
|
+
* `SpikeBox` is the unit under test: a bordered box whose interior is a single
|
|
6
|
+
* line of `.p`-tier text (a stand-in for a button label, input value, nav-item
|
|
7
|
+
* text or table-cell text). Its seat uses the shipped engine model (the
|
|
8
|
+
* asymmetric start/end nudges from `density.testbed.css`); the alternative
|
|
9
|
+
* external-margin model was dropped, so there is no model toggle. Using one
|
|
10
|
+
* primitive keeps buckets comparing like-for-like; the real Button/inputs are
|
|
11
|
+
* shown alongside in the story for reference.
|
|
12
|
+
*/
|
|
13
|
+
/** A boxed control: border + a `.p` text seat, seated on the grid by the engine's
|
|
14
|
+
* start/end nudges (see density.testbed.css). */
|
|
15
|
+
export const SpikeBox = ({ children, as = "div", role, }) => {
|
|
16
|
+
const Tag = as;
|
|
17
|
+
return (_jsx(Tag, { className: "spike-box", role: role, type: as === "button" ? "button" : undefined, children: _jsx("span", { className: "seat p", children: children }) }));
|
|
18
|
+
};
|
|
19
|
+
/** A run of boxed cells sharing one border — the list/table-row case, laid out
|
|
20
|
+
* inline on the bucket line (the CSS collapses the between-borders). Exercises
|
|
21
|
+
* how per-cell external margin interacts with a shared border. */
|
|
22
|
+
export const SpikeRows = ({ rows }) => (_jsx("div", { className: "spike-rows", children: rows.map((r) => (_jsx(SpikeBox, { children: r }, r))) }));
|
|
23
|
+
//# sourceMappingURL=mocks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mocks.js","sourceRoot":"","sources":["../../../../../src/lib/_work_in_progress/DensityTestbed/mocks.tsx"],"names":[],"mappings":";AAEA;;;;;;;;;;GAUG;AAEH;kDACkD;AAClD,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,EACvB,QAAQ,EACR,EAAE,GAAG,KAAK,EACV,IAAI,GAKL,EAAsB,EAAE;IACvB,MAAM,GAAG,GAAG,EAAE,CAAC;IACf,OAAO,CACL,KAAC,GAAG,IACF,SAAS,EAAC,WAAW,EACrB,IAAI,EAAE,IAAI,EACV,IAAI,EAAE,EAAE,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,YAE5C,eAAM,SAAS,EAAC,QAAQ,YAAE,QAAQ,GAAQ,GACtC,CACP,CAAC;AACJ,CAAC,CAAC;AAEF;;mEAEmE;AACnE,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,EAAE,IAAI,EAAsB,EAAsB,EAAE,CAAC,CAC7E,cAAK,SAAS,EAAC,YAAY,YACxB,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CACf,KAAC,QAAQ,cAAU,CAAC,IAAL,CAAC,CAAgB,CACjC,CAAC,GACE,CACP,CAAC"}
|
|
@@ -11,15 +11,36 @@
|
|
|
11
11
|
padding: 0;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
/* Control row: the
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
/* Control row: the control centres on the label's FIRST line, and a multi-line
|
|
15
|
+
(sentence) label wraps below — never centring the box on the whole paragraph
|
|
16
|
+
(AV-325). `align-items: start` tops the row so wrapped lines flow under the
|
|
17
|
+
first; the control is then nudged down half a line-box to sit centred on the
|
|
18
|
+
first line (see the control rule below). The first-line box is one density
|
|
19
|
+
line-height (`--density-line-height-effective`, set on the density scope;
|
|
20
|
+
falls back to `1lh` outside a density context). */
|
|
17
21
|
& > .field-toggle-control {
|
|
22
|
+
--toggle-control-line: var(--density-line-height-effective, 1lh);
|
|
23
|
+
|
|
18
24
|
display: flex;
|
|
19
25
|
flex-direction: row;
|
|
20
|
-
align-items:
|
|
26
|
+
align-items: start;
|
|
21
27
|
column-gap: var(--form-field-inline-gap);
|
|
22
28
|
|
|
29
|
+
/* Every direct child that ISN'T the label is the control (checkbox / switch
|
|
30
|
+
input): a fixed 16px-tall box (--dimension-200 — checkbox 16×16, switch
|
|
31
|
+
track 16 high). Centre it on the first line by pushing it down half the
|
|
32
|
+
leftover between the line-box and the control's own height. The control
|
|
33
|
+
keeps its intrinsic size — only its vertical offset changes, so the click
|
|
34
|
+
target is untouched. */
|
|
35
|
+
& > :not(.ds.field-label) {
|
|
36
|
+
--toggle-control-size: var(--dimension-200);
|
|
37
|
+
align-self: start;
|
|
38
|
+
margin-block-start: max(
|
|
39
|
+
0px,
|
|
40
|
+
calc((var(--toggle-control-line) - var(--toggle-control-size)) / 2)
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
23
44
|
/* The control label is often a full clickable sentence, so it reads as
|
|
24
45
|
regular body prose (not the bold heading weight the field label uses by
|
|
25
46
|
default): normal weight, left-aligned, pointer cursor, and it takes the
|
|
@@ -31,5 +52,13 @@
|
|
|
31
52
|
text-align: start;
|
|
32
53
|
cursor: pointer;
|
|
33
54
|
}
|
|
55
|
+
|
|
56
|
+
/* Label BEFORE the control (switch convention): the DOM stays
|
|
57
|
+
control-then-label for accessibility, so `row-reverse` moves the control
|
|
58
|
+
to the trailing (right) edge and the label to the leading (left) edge.
|
|
59
|
+
Logical `row-reverse` mirrors correctly in RTL. */
|
|
60
|
+
&.label-before {
|
|
61
|
+
flex-direction: row-reverse;
|
|
62
|
+
}
|
|
34
63
|
}
|
|
35
64
|
}
|
|
@@ -22,7 +22,7 @@ const componentCssClassName = "ds field field-toggle";
|
|
|
22
22
|
*
|
|
23
23
|
* `import { ToggleWrapper } from "@canonical/react-ds-global-form";`
|
|
24
24
|
*/
|
|
25
|
-
const ToggleWrapper = ({ id, className, style, name, Component, description, label, controlLabel, isOptional, requiredIndicator, registerProps: userRegisterProps, nestedRegisterProps, unregisterOnUnmount, ...otherProps }) => {
|
|
25
|
+
const ToggleWrapper = ({ id, className, style, name, Component, description, label, controlLabel, labelPosition = "after", isOptional, requiredIndicator, registerProps: userRegisterProps, nestedRegisterProps, unregisterOnUnmount, ...otherProps }) => {
|
|
26
26
|
// The inline label (beside the control) always carries the htmlFor binding;
|
|
27
27
|
// the heading only appears when a distinct controlLabel was supplied. At
|
|
28
28
|
// least one of `label`/`controlLabel` is guaranteed by the type of the toggle
|
|
@@ -46,7 +46,7 @@ const ToggleWrapper = ({ id, className, style, name, Component, description, lab
|
|
|
46
46
|
};
|
|
47
47
|
return (_jsxs("div", { id: id, style: style, className: [componentCssClassName, className, isError && states.Danger]
|
|
48
48
|
.filter(Boolean)
|
|
49
|
-
.join(" "), children: [headingLabel && (_jsx(Label, { name: name, tag: "legend", className: "field-toggle-heading", children: headingLabel })), _jsxs("div", { className: "field-toggle-control", children: [_jsx(Component, { ...componentProps }), _jsx(Label, { name: name, isOptional: isOptional, requiredIndicator: requiredIndicator, ...ariaProps.label, children: inlineLabel })] }), description && (_jsx(Description, { ...ariaProps.description, children: description })), isError && (_jsx(FieldError, { ...ariaProps.error, children: fieldError?.message?.toString() }))] }));
|
|
49
|
+
.join(" "), children: [headingLabel && (_jsx(Label, { name: name, tag: "legend", className: "field-toggle-heading", children: headingLabel })), _jsxs("div", { className: ["field-toggle-control", `label-${labelPosition}`].join(" "), children: [_jsx(Component, { ...componentProps }), _jsx(Label, { name: name, isOptional: isOptional, requiredIndicator: requiredIndicator, ...ariaProps.label, children: inlineLabel })] }), description && (_jsx(Description, { ...ariaProps.description, children: description })), isError && (_jsx(FieldError, { ...ariaProps.error, children: fieldError?.message?.toString() }))] }));
|
|
50
50
|
};
|
|
51
51
|
export default ToggleWrapper;
|
|
52
52
|
//# sourceMappingURL=ToggleWrapper.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToggleWrapper.js","sourceRoot":"","sources":["../../../../../src/lib/common/Wrapper/ToggleWrapper.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EACL,WAAW,EACX,KAAK,IAAI,UAAU,EACnB,KAAK,GACN,MAAM,mCAAmC,CAAC;AAE3C,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,cAAc,CAAC;AACtB,OAAO,qBAAqB,CAAC;AAE7B,MAAM,qBAAqB,GAAG,uBAAuB,CAAC;AAEtD;;;;;;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E,OAAO,IAAI,MAAM,CAAC,MAAM,CAAC;aACpE,MAAM,CAAC,OAAO,CAAC;aACf,IAAI,CAAC,GAAG,CAAC,aAGX,YAAY,IAAI,CACf,KAAC,KAAK,IAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAC,QAAQ,EAAC,SAAS,EAAC,sBAAsB,YAC7D,YAAY,GACP,CACT,EAOD,eACE,SAAS,EAAE,CAAC,sBAAsB,EAAE,SAAS,aAAa,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,aAEvE,KAAC,SAAS,OAAK,cAAc,GAAI,EACjC,KAAC,KAAK,IACJ,IAAI,EAAE,IAAI,EACV,UAAU,EAAE,UAAU,EACtB,iBAAiB,EAAE,iBAAiB,KAChC,SAAS,CAAC,KAAK,YAElB,WAAW,GACN,IACJ,EAGL,WAAW,IAAI,CACd,KAAC,WAAW,OAAK,SAAS,CAAC,WAAW,YAAG,WAAW,GAAe,CACpE,EAEA,OAAO,IAAI,CACV,KAAC,UAAU,OAAK,SAAS,CAAC,KAAK,YAC5B,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,GACrB,CACd,IACG,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -2,9 +2,23 @@
|
|
|
2
2
|
display: grid;
|
|
3
3
|
grid-template-columns: subgrid;
|
|
4
4
|
grid-column: var(--form-field-columns, 1 / -1);
|
|
5
|
-
|
|
5
|
+
/* Vertical gap from the label row down to the payload row. Uses the block-axis
|
|
6
|
+
label-gap token — NOT --form-field-inline-gap (that is horizontal-only now).
|
|
7
|
+
Default is the label→control gap (--form-field-label-gap, 8px); when a
|
|
8
|
+
description LEADS the payload the row below tightens it to the label→
|
|
9
|
+
description gap (--form-field-label-description-gap, 4px), per the 15/07
|
|
10
|
+
review's field-spacing spec. */
|
|
11
|
+
row-gap: var(--form-field-label-gap);
|
|
6
12
|
align-items: baseline;
|
|
7
13
|
|
|
14
|
+
/* Label sits closer to a leading description than to a bare control. */
|
|
15
|
+
&:has(> .payload > .ds.field-description:first-child) {
|
|
16
|
+
row-gap: var(
|
|
17
|
+
--form-field-label-description-gap,
|
|
18
|
+
var(--form-field-label-gap)
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
|
|
8
22
|
& > .ds.field-label {
|
|
9
23
|
grid-column: var(--form-label-columns, 1 / -1);
|
|
10
24
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
2
|
import ToggleWrapper from "./ToggleWrapper.js";
|
|
2
3
|
import withWrapper from "./withWrapper.js";
|
|
3
4
|
/**
|
|
@@ -7,8 +8,17 @@ import withWrapper from "./withWrapper.js";
|
|
|
7
8
|
* here — in the HOC's return type — keeps it out of the shared `withWrapper`
|
|
8
9
|
* generics, which would otherwise widen the union back to all-optional.
|
|
9
10
|
*
|
|
11
|
+
* `defaults` are per-field defaults (e.g. SwitchField's `labelPosition: "before"`).
|
|
12
|
+
* They are spread UNDER the caller's props, so a consumer can still override them.
|
|
13
|
+
*
|
|
10
14
|
* `import { withToggleWrapper } from "@canonical/react-ds-global-form";`
|
|
11
15
|
*/
|
|
12
|
-
const withToggleWrapper = (Component) =>
|
|
16
|
+
const withToggleWrapper = (Component, defaults) => {
|
|
17
|
+
const Wrapped = withWrapper(Component, undefined, ToggleWrapper);
|
|
18
|
+
if (!defaults)
|
|
19
|
+
return Wrapped;
|
|
20
|
+
const WithDefaults = (props) => (_jsx(Wrapped, { ...defaults, ...props }));
|
|
21
|
+
return WithDefaults;
|
|
22
|
+
};
|
|
13
23
|
export default withToggleWrapper;
|
|
14
24
|
//# sourceMappingURL=withToggleWrapper.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withToggleWrapper.js","sourceRoot":"","sources":["../../../../../src/lib/common/Wrapper/withToggleWrapper.
|
|
1
|
+
{"version":3,"file":"withToggleWrapper.js","sourceRoot":"","sources":["../../../../../src/lib/common/Wrapper/withToggleWrapper.tsx"],"names":[],"mappings":";AAMA,OAAO,aAAa,MAAM,oBAAoB,CAAC;AAC/C,OAAO,WAAW,MAAM,kBAAkB,CAAC;AAa3C;;;;;;;;;;;GAWG;AACH,MAAM,iBAAiB,GAAG,CACxB,SAAwC,EACxC,QAAsD,EACd,EAAE;IAC1C,MAAM,OAAO,GAAG,WAAW,CACzB,SAAS,EACT,SAAS,EACT,aAAa,CAC4B,CAAC;IAC5C,IAAI,CAAC,QAAQ;QAAE,OAAO,OAAO,CAAC;IAC9B,MAAM,YAAY,GAA2C,CAAC,KAAK,EAAE,EAAE,CAAC,CACtE,KAAC,OAAO,OAAK,QAAQ,KAAM,KAAK,GAAI,CACrC,CAAC;IACF,OAAO,YAAY,CAAC;AACtB,CAAC,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|
|
@@ -23,17 +23,24 @@ Presentational, mode, options = {}) {
|
|
|
23
23
|
const label = Presentational.displayName ||
|
|
24
24
|
Presentational.name ||
|
|
25
25
|
"Input";
|
|
26
|
-
// Merge the field's
|
|
27
|
-
//
|
|
28
|
-
//
|
|
29
|
-
//
|
|
30
|
-
|
|
26
|
+
// Merge the field's `additionalRegisterProps` UNDER the consumer's
|
|
27
|
+
// registerProps (consumer always wins). `additionalRegisterProps` may be a
|
|
28
|
+
// static object or a function of the component's own props; resolve it per
|
|
29
|
+
// render against `props`. Cast once: RHF's RegisterOptions is a discriminated
|
|
30
|
+
// union (e.g. `valueAsNumber` excludes `pattern`), which an object spread
|
|
31
|
+
// cannot satisfy structurally even though the merged value is valid at runtime.
|
|
32
|
+
const mergeRegister = (registerProps, props) => {
|
|
33
|
+
const extra = typeof options.additionalRegisterProps === "function"
|
|
34
|
+
? options.additionalRegisterProps(props)
|
|
35
|
+
: options.additionalRegisterProps;
|
|
36
|
+
return { ...extra, ...registerProps };
|
|
37
|
+
};
|
|
31
38
|
let Bound;
|
|
32
39
|
if (mode === "controlled") {
|
|
33
40
|
Bound = ({ name, registerProps, ...rest }) => {
|
|
34
41
|
const { field } = useController({
|
|
35
42
|
name,
|
|
36
|
-
rules: registerProps,
|
|
43
|
+
rules: mergeRegister(registerProps, rest),
|
|
37
44
|
...(options.defaultValue !== undefined
|
|
38
45
|
? { defaultValue: options.defaultValue }
|
|
39
46
|
: {}),
|
|
@@ -55,7 +62,7 @@ Presentational, mode, options = {}) {
|
|
|
55
62
|
return createElement(Presentational, {
|
|
56
63
|
...rest,
|
|
57
64
|
value,
|
|
58
|
-
...register(name, mergeRegister(registerProps)),
|
|
65
|
+
...register(name, mergeRegister(registerProps, rest)),
|
|
59
66
|
});
|
|
60
67
|
};
|
|
61
68
|
}
|
|
@@ -64,7 +71,7 @@ Presentational, mode, options = {}) {
|
|
|
64
71
|
const { register } = useFormContext();
|
|
65
72
|
return createElement(Presentational, {
|
|
66
73
|
...rest,
|
|
67
|
-
...register(name, mergeRegister(registerProps)),
|
|
74
|
+
...register(name, mergeRegister(registerProps, rest)),
|
|
68
75
|
});
|
|
69
76
|
};
|
|
70
77
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bindField.js","sourceRoot":"","sources":["../../../../../src/lib/common/bindField/bindField.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,aAAa,EAAW,MAAM,OAAO,CAAC;AACnE,OAAO,EAEL,aAAa,EACb,cAAc,EACd,QAAQ,GACT,MAAM,iBAAiB,CAAC;AAGzB;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,OAAO,UAAU,SAAS;AAC/B,wFAAwF;AACxF,cAAkC,EAClC,IAAc,EACd,UAA4B,EAAE;IAE9B,MAAM,KAAK,GACR,cAA2C,CAAC,WAAW;QACxD,cAAc,CAAC,IAAI;QACnB,OAAO,CAAC;IAEV
|
|
1
|
+
{"version":3,"file":"bindField.js","sourceRoot":"","sources":["../../../../../src/lib/common/bindField/bindField.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,aAAa,EAAW,MAAM,OAAO,CAAC;AAC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,KAAK,CAAC,QAAQ;gBACxB,MAAM,EAAE,KAAK,CAAC,MAAM;gBACpB,GAAG,EAAE,KAAK,CAAC,GAAG;aACf,CAAC,CAAC;QACL,CAAC,CAAC;IACJ,CAAC;SAAM,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;QAC/B,KAAK,GAAG,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,GAAG,IAAI,EAAK,EAAE,EAAE;YAC9C,MAAM,EAAE,QAAQ,EAAE,GAAG,cAAc,EAAE,CAAC;YACtC,MAAM,KAAK,GAAG,QAAQ,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;YACjC,OAAO,aAAa,CAAC,cAAc,EAAE;gBACnC,GAAG,IAAI;gBACP,KAAK;gBACL,GAAG,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC;aACtD,CAAC,CAAC;QACL,CAAC,CAAC;IACJ,CAAC;SAAM,CAAC;QACN,KAAK,GAAG,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,GAAG,IAAI,EAAK,EAAE,EAAE;YAC9C,MAAM,EAAE,QAAQ,EAAE,GAAG,cAAc,EAAE,CAAC;YACtC,OAAO,aAAa,CAAC,cAAc,EAAE;gBACnC,GAAG,IAAI;gBACP,GAAG,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC;aACtD,CAAC,CAAC;QACL,CAAC,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,WAAW,GAAG,aAAa,KAAK,GAAG,CAAC;IAC1C,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -9,7 +9,7 @@ const componentCssClassName = "ds option";
|
|
|
9
9
|
*/
|
|
10
10
|
const Option = ({ name, type, option, checked, disabled, onChange, }) => {
|
|
11
11
|
const ariaProps = useOptionAriaProperties(name, option.value);
|
|
12
|
-
return (_jsxs("div", { className: [componentCssClassName,
|
|
12
|
+
return (_jsxs("div", { className: [componentCssClassName, disabled && "disabled"]
|
|
13
13
|
.filter(Boolean)
|
|
14
14
|
.join(" "), children: [_jsx("input", { name: name, value: option.value, disabled: disabled, type: type, checked: checked, onChange: onChange, ...ariaProps.input }), _jsx("label", { className: "p", ...ariaProps.label, children: option.label })] }));
|
|
15
15
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Option.js","sourceRoot":"","sources":["../../../../../../../src/lib/component/ChoicesField/common/Option/Option.tsx"],"names":[],"mappings":";AAGA,OAAO,uBAAuB,MAAM,oDAAoD,CAAC;AAGzF,MAAM,qBAAqB,GAAG,WAAW,CAAC;AAE1C;;;;;GAKG;AACH,MAAM,MAAM,GAAG,CAAC,EACd,IAAI,EACJ,IAAI,EACJ,MAAM,EACN,OAAO,EACP,QAAQ,EACR,QAAQ,GACI,EAAsB,EAAE;IACpC,MAAM,SAAS,GAAG,uBAAuB,CAAC,IAAI,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;IAC9D,OAAO,CACL,eACE,SAAS,EAAE,CAAC,qBAAqB,EAAE,
|
|
1
|
+
{"version":3,"file":"Option.js","sourceRoot":"","sources":["../../../../../../../src/lib/component/ChoicesField/common/Option/Option.tsx"],"names":[],"mappings":";AAGA,OAAO,uBAAuB,MAAM,oDAAoD,CAAC;AAGzF,MAAM,qBAAqB,GAAG,WAAW,CAAC;AAE1C;;;;;GAKG;AACH,MAAM,MAAM,GAAG,CAAC,EACd,IAAI,EACJ,IAAI,EACJ,MAAM,EACN,OAAO,EACP,QAAQ,EACR,QAAQ,GACI,EAAsB,EAAE;IACpC,MAAM,SAAS,GAAG,uBAAuB,CAAC,IAAI,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;IAC9D,OAAO,CACL,eACE,SAAS,EAAE,CAAC,qBAAqB,EAAE,QAAQ,IAAI,UAAU,CAAC;aACvD,MAAM,CAAC,OAAO,CAAC;aACf,IAAI,CAAC,GAAG,CAAC,aAEZ,gBACE,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,MAAM,CAAC,KAAK,EACnB,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,QAAQ,KACd,SAAS,CAAC,KAAK,GACnB,EAEF,gBAAO,SAAS,EAAC,GAAG,KAAK,SAAS,CAAC,KAAK,YACrC,MAAM,CAAC,KAAK,GACP,IACJ,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
|
@@ -5,7 +5,9 @@
|
|
|
5
5
|
margin: 0;
|
|
6
6
|
display: flex;
|
|
7
7
|
flex-wrap: wrap;
|
|
8
|
-
gap
|
|
8
|
+
/* Row gap gives stacked/wrapped options vertical breathing room (was 0, so
|
|
9
|
+
* stacked items touched); column gap is the inline separation (per review). */
|
|
10
|
+
gap: var(--form-group-gap) var(--container-gap-loose);
|
|
9
11
|
|
|
10
12
|
/* Stacked: one option per line */
|
|
11
13
|
&.stacked {
|
|
@@ -39,21 +41,35 @@
|
|
|
39
41
|
& > input[type="radio"] {
|
|
40
42
|
appearance: none;
|
|
41
43
|
box-sizing: border-box;
|
|
42
|
-
width:
|
|
43
|
-
height:
|
|
44
|
+
width: var(--dimension-200); /* 16px */
|
|
45
|
+
height: var(--dimension-200); /* 16px */
|
|
44
46
|
border: var(--dimension-stroke-thickness-medium) solid var(--color-border);
|
|
45
47
|
border-radius: 50%;
|
|
46
|
-
background-color: var(
|
|
48
|
+
background-color: var(
|
|
49
|
+
--surface-color-foreground-radio-unselected,
|
|
50
|
+
var(--color-foreground-radio-unselected)
|
|
51
|
+
);
|
|
47
52
|
cursor: inherit;
|
|
48
53
|
transition:
|
|
49
54
|
background-color 150ms ease,
|
|
50
55
|
border-color 150ms ease;
|
|
51
56
|
|
|
52
57
|
&:checked {
|
|
53
|
-
border-color: var(
|
|
58
|
+
border-color: var(
|
|
59
|
+
--surface-color-foreground-radio-selected,
|
|
60
|
+
var(--color-foreground-radio-selected)
|
|
61
|
+
);
|
|
54
62
|
background: radial-gradient(
|
|
55
|
-
var(
|
|
56
|
-
|
|
63
|
+
var(
|
|
64
|
+
--surface-color-foreground-radio-selected,
|
|
65
|
+
var(--color-foreground-radio-selected)
|
|
66
|
+
)
|
|
67
|
+
40%,
|
|
68
|
+
var(
|
|
69
|
+
--surface-color-foreground-radio-unselected,
|
|
70
|
+
var(--color-foreground-radio-unselected)
|
|
71
|
+
)
|
|
72
|
+
41%
|
|
57
73
|
);
|
|
58
74
|
}
|
|
59
75
|
|
|
@@ -61,8 +77,18 @@
|
|
|
61
77
|
background-color: var(--color-foreground-radio-unselected-hover);
|
|
62
78
|
}
|
|
63
79
|
|
|
80
|
+
/* Hover shifts only the dot's fill (channel shade), not a whole-element
|
|
81
|
+
* brightness filter that would also dim the ring. */
|
|
64
82
|
&:checked:hover:not(:disabled) {
|
|
65
|
-
|
|
83
|
+
border-color: var(--hover--color-foreground-radio-selected);
|
|
84
|
+
background: radial-gradient(
|
|
85
|
+
var(--hover--color-foreground-radio-selected) 40%,
|
|
86
|
+
var(
|
|
87
|
+
--surface-color-foreground-radio-unselected,
|
|
88
|
+
var(--color-foreground-radio-unselected)
|
|
89
|
+
)
|
|
90
|
+
41%
|
|
91
|
+
);
|
|
66
92
|
}
|
|
67
93
|
|
|
68
94
|
&:focus-visible {
|
|
@@ -81,11 +107,14 @@
|
|
|
81
107
|
appearance: none;
|
|
82
108
|
box-sizing: border-box;
|
|
83
109
|
position: relative;
|
|
84
|
-
width:
|
|
85
|
-
height:
|
|
110
|
+
width: var(--dimension-200); /* 16px */
|
|
111
|
+
height: var(--dimension-200); /* 16px */
|
|
86
112
|
border: var(--dimension-stroke-thickness-medium) solid var(--color-border);
|
|
87
113
|
border-radius: var(--dimension-radius-small);
|
|
88
|
-
background-color: var(
|
|
114
|
+
background-color: var(
|
|
115
|
+
--surface-color-foreground-checkbox-unselected,
|
|
116
|
+
var(--color-foreground-checkbox-unselected)
|
|
117
|
+
);
|
|
89
118
|
cursor: inherit;
|
|
90
119
|
transition:
|
|
91
120
|
background-color 150ms ease,
|
|
@@ -107,11 +136,20 @@
|
|
|
107
136
|
}
|
|
108
137
|
|
|
109
138
|
&:checked {
|
|
110
|
-
background: var(
|
|
111
|
-
|
|
139
|
+
background: var(
|
|
140
|
+
--surface-color-foreground-checkbox-selected,
|
|
141
|
+
var(--color-foreground-checkbox-selected)
|
|
142
|
+
);
|
|
143
|
+
border-color: var(
|
|
144
|
+
--surface-color-foreground-checkbox-selected,
|
|
145
|
+
var(--color-foreground-checkbox-selected)
|
|
146
|
+
);
|
|
112
147
|
|
|
113
148
|
&::before {
|
|
114
|
-
background-color: var(
|
|
149
|
+
background-color: var(
|
|
150
|
+
--surface-color-foreground-checkbox-checkmark,
|
|
151
|
+
var(--color-foreground-checkbox-checkmark)
|
|
152
|
+
);
|
|
115
153
|
mask-image: url("/icons/checkmark.svg#checkmark");
|
|
116
154
|
-webkit-mask-image: url("/icons/checkmark.svg#checkmark");
|
|
117
155
|
}
|
|
@@ -121,8 +159,10 @@
|
|
|
121
159
|
background-color: var(--color-foreground-checkbox-unselected-hover);
|
|
122
160
|
}
|
|
123
161
|
|
|
162
|
+
/* Hover shifts only the fill (channel shade), not the masked checkmark. */
|
|
124
163
|
&:checked:hover:not(:disabled) {
|
|
125
|
-
|
|
164
|
+
background-color: var(--hover--color-foreground-checkbox-selected);
|
|
165
|
+
border-color: var(--hover--color-foreground-checkbox-selected);
|
|
126
166
|
}
|
|
127
167
|
|
|
128
168
|
&:focus-visible {
|
|
@@ -1,11 +1,29 @@
|
|
|
1
1
|
import bindField from "../../common/bindField/index.js";
|
|
2
2
|
import withWrapper from "../../common/Wrapper/withWrapper.js";
|
|
3
3
|
import { DateInput } from "../../subcomponent/DateInput/index.js";
|
|
4
|
+
/**
|
|
5
|
+
* Turn the `min`/`max` date props into react-hook-form `min`/`max` rules so an
|
|
6
|
+
* out-of-range date reports an inline error — the native attributes alone only
|
|
7
|
+
* constrain the picker UI and never reach RHF. ISO `YYYY-MM-DD` strings compare
|
|
8
|
+
* lexicographically, so the native rule works directly on the stored value.
|
|
9
|
+
*/
|
|
10
|
+
const dateRangeRules = ({ min, max, }) => {
|
|
11
|
+
const rules = {};
|
|
12
|
+
if (typeof min === "string" && min) {
|
|
13
|
+
rules.min = { value: min, message: `Date must be on or after ${min}.` };
|
|
14
|
+
}
|
|
15
|
+
if (typeof max === "string" && max) {
|
|
16
|
+
rules.max = { value: max, message: `Date must be on or before ${max}.` };
|
|
17
|
+
}
|
|
18
|
+
return rules;
|
|
19
|
+
};
|
|
4
20
|
/**
|
|
5
21
|
* Date input bound to react-hook-form, wrapped with field chrome
|
|
6
22
|
* (label, description, error) and middleware/conditional-display support.
|
|
7
23
|
*
|
|
8
24
|
* `import { DateField } from "@canonical/react-ds-global-form";`
|
|
9
25
|
*/
|
|
10
|
-
export default withWrapper(bindField(DateInput, "native"
|
|
26
|
+
export default withWrapper(bindField(DateInput, "native", {
|
|
27
|
+
additionalRegisterProps: dateRangeRules,
|
|
28
|
+
}));
|
|
11
29
|
//# sourceMappingURL=DateField.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateField.js","sourceRoot":"","sources":["../../../../../src/lib/component/DateField/DateField.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"DateField.js","sourceRoot":"","sources":["../../../../../src/lib/component/DateField/DateField.tsx"],"names":[],"mappings":"AACA,OAAO,SAAS,MAAM,iCAAiC,CAAC;AACxD,OAAO,WAAW,MAAM,qCAAqC,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,MAAM,uCAAuC,CAAC;AAGlE;;;;;GAKG;AACH,MAAM,cAAc,GAAG,CAAC,EACtB,GAAG,EACH,GAAG,GACqB,EAAmB,EAAE;IAC7C,MAAM,KAAK,GAAoB,EAAE,CAAC;IAClC,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,EAAE,CAAC;QACnC,KAAK,CAAC,GAAG,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,4BAA4B,GAAG,GAAG,EAAE,CAAC;IAC1E,CAAC;IACD,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,EAAE,CAAC;QACnC,KAAK,CAAC,GAAG,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,6BAA6B,GAAG,GAAG,EAAE,CAAC;IAC3E,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF;;;;;GAKG;AACH,eAAe,WAAW,CACxB,SAAS,CAAiB,SAAS,EAAE,QAAQ,EAAE;IAC7C,uBAAuB,EAAE,cAAc;CACxC,CAAC,CACH,CAAC"}
|