basalt-ui 2.27.2 → 2.29.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/CHANGELOG.md +466 -307
- package/MIGRATING.md +358 -12
- package/agent/rules/basalt-batteries.md +1 -1
- package/agent/rules/basalt-mantine.md +1 -1
- package/agent/rules/basalt-tokens.md +2 -2
- package/agent/skills/basalt-app/SKILL.md +3 -3
- package/agent/skills/basalt-charts/SKILL.md +1 -1
- package/agent/skills/basalt-design/SKILL.md +12 -6
- package/agent/skills/basalt-design/references/catalogue.md +42 -36
- package/agent/skills/basalt-design/references/recipes.md +47 -0
- package/agent/skills/basalt-design/references/states.md +1 -1
- package/configs/oxlint-basalt.json +2 -1
- package/configs/oxlint-plugin.js +112 -3
- package/configs/oxlint-plugin.test.ts +99 -4
- package/configs/oxlint.json +1 -0
- package/dist/agent/chat/thread-message.d.ts +1 -160
- package/dist/agent/chat/thread-message.d.ts.map +1 -1
- package/dist/agent/chat/thread-message.js +7 -162
- package/dist/agent/chat/virtualize.d.ts +5 -5
- package/dist/charts/ChartCard.d.ts +14 -7
- package/dist/charts/ChartCard.d.ts.map +1 -1
- package/dist/charts/ChartCard.js +112 -23
- package/dist/charts/Lines.d.ts.map +1 -1
- package/dist/charts/Lines.js +11 -4
- package/dist/charts/Sparkline.d.ts +14 -2
- package/dist/charts/Sparkline.d.ts.map +1 -1
- package/dist/charts/Sparkline.js +155 -44
- package/dist/charts/chart-box.module.css +59 -2
- package/dist/charts/chart-box.module.css.d.ts +5 -0
- package/dist/charts/chart-card.module.css +28 -17
- package/dist/charts/chart-card.module.css.d.ts +3 -0
- package/dist/charts/compile.d.ts +1 -1
- package/dist/charts/compile.d.ts.map +1 -1
- package/dist/charts/compile.js +38 -27
- package/dist/charts/labels.d.ts +13 -3
- package/dist/charts/labels.d.ts.map +1 -1
- package/dist/charts/labels.js +131 -20
- package/dist/charts/legend.d.ts.map +1 -1
- package/dist/charts/legend.js +1 -1
- package/dist/charts/ref-label.d.ts +37 -8
- package/dist/charts/ref-label.d.ts.map +1 -1
- package/dist/charts/ref-label.js +55 -10
- package/dist/charts/sparkline.module.css +50 -0
- package/dist/charts/sparkline.module.css.d.ts +3 -0
- package/dist/charts/state.d.ts +4 -4
- package/dist/charts/state.d.ts.map +1 -1
- package/dist/charts/state.js +23 -5
- package/dist/cli/doctor-upgrade.d.ts +11 -0
- package/dist/cli/doctor-upgrade.d.ts.map +1 -1
- package/dist/cli/doctor-upgrade.js +54 -0
- package/dist/cli/doctor.d.ts.map +1 -1
- package/dist/cli/doctor.js +32 -0
- package/dist/cli/help.d.ts.map +1 -1
- package/dist/cli/help.js +8 -3
- package/dist/cli/index.d.ts +13 -13
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +36 -2
- package/dist/cli/init.d.ts +6 -0
- package/dist/cli/init.d.ts.map +1 -1
- package/dist/cli/init.js +118 -27
- package/dist/cli/router-wiring.d.ts +3 -0
- package/dist/cli/router-wiring.d.ts.map +1 -1
- package/dist/cli/router-wiring.js +2 -0
- package/dist/cli/shot/capture.d.ts +34 -2
- package/dist/cli/shot/capture.d.ts.map +1 -1
- package/dist/cli/shot/capture.js +95 -12
- package/dist/cli/shot/detect.d.ts +4 -1
- package/dist/cli/shot/detect.d.ts.map +1 -1
- package/dist/cli/shot/detect.js +38 -16
- package/dist/cli/shot/index.d.ts.map +1 -1
- package/dist/cli/shot/index.js +9 -2
- package/dist/cli/shot/measure.d.ts.map +1 -1
- package/dist/cli/shot/measure.js +11 -2
- package/dist/cli/shot/types.d.ts +4 -1
- package/dist/cli/shot/types.d.ts.map +1 -1
- package/dist/cli/sync.d.ts.map +1 -1
- package/dist/cli/sync.js +10 -2
- package/dist/common/could-not-load.d.ts +13 -0
- package/dist/common/could-not-load.d.ts.map +1 -0
- package/dist/common/could-not-load.js +14 -0
- package/dist/common/empty-copy.d.ts +16 -0
- package/dist/common/empty-copy.d.ts.map +1 -0
- package/dist/common/empty-copy.js +9 -0
- package/dist/common/index.d.ts +1 -0
- package/dist/common/index.d.ts.map +1 -1
- package/dist/common/index.js +3 -0
- package/dist/common/props.d.ts +20 -0
- package/dist/common/props.d.ts.map +1 -1
- package/dist/common/props.js +13 -1
- package/dist/common/retry-button.module.css +7 -3
- package/dist/common/virtual-rows.d.ts +196 -0
- package/dist/common/virtual-rows.d.ts.map +1 -0
- package/dist/common/virtual-rows.js +290 -0
- package/dist/controls/controls.module.css +33 -1
- package/dist/controls/controls.module.css.d.ts +2 -0
- package/dist/controls/enum-filter.d.ts.map +1 -1
- package/dist/controls/enum-filter.js +8 -2
- package/dist/controls/filter-pill.d.ts +27 -3
- package/dist/controls/filter-pill.d.ts.map +1 -1
- package/dist/controls/filter-pill.js +15 -4
- package/dist/controls/form-layout.d.ts +9 -3
- package/dist/controls/form-layout.d.ts.map +1 -1
- package/dist/controls/form-layout.js +74 -12
- package/dist/controls/form-layout.module.css +112 -7
- package/dist/controls/form-layout.module.css.d.ts +1 -0
- package/dist/controls/multi-select-filter.d.ts +2 -2
- package/dist/controls/multi-select-filter.d.ts.map +1 -1
- package/dist/controls/multi-select-filter.js +12 -6
- package/dist/controls/range-filter.d.ts +1 -1
- package/dist/controls/range-filter.d.ts.map +1 -1
- package/dist/controls/range-filter.js +8 -2
- package/dist/dashboard/bar-list.d.ts +5 -5
- package/dist/dashboard/bar-list.d.ts.map +1 -1
- package/dist/dashboard/bar-list.js +15 -8
- package/dist/dashboard/bar-list.module.css +21 -5
- package/dist/dashboard/board-nav.d.ts +22 -0
- package/dist/dashboard/board-nav.d.ts.map +1 -0
- package/dist/dashboard/board-nav.js +49 -0
- package/dist/dashboard/board.d.ts +52 -0
- package/dist/dashboard/board.d.ts.map +1 -0
- package/dist/dashboard/board.js +247 -0
- package/dist/dashboard/board.module.css +179 -0
- package/dist/dashboard/board.module.css.d.ts +28 -0
- package/dist/dashboard/empty-state.d.ts +6 -6
- package/dist/dashboard/empty-state.d.ts.map +1 -1
- package/dist/dashboard/empty-state.js +17 -8
- package/dist/dashboard/event-list-model.d.ts +54 -0
- package/dist/dashboard/event-list-model.d.ts.map +1 -0
- package/dist/dashboard/event-list-model.js +76 -0
- package/dist/dashboard/event-list-rows.d.ts +23 -0
- package/dist/dashboard/event-list-rows.d.ts.map +1 -0
- package/dist/dashboard/event-list-rows.js +89 -0
- package/dist/dashboard/event-list-scroll.d.ts +55 -0
- package/dist/dashboard/event-list-scroll.d.ts.map +1 -0
- package/dist/dashboard/event-list-scroll.js +216 -0
- package/dist/dashboard/event-list-skeleton.d.ts +10 -0
- package/dist/dashboard/event-list-skeleton.d.ts.map +1 -0
- package/dist/dashboard/event-list-skeleton.js +34 -0
- package/dist/dashboard/event-list.d.ts +65 -0
- package/dist/dashboard/event-list.d.ts.map +1 -0
- package/dist/dashboard/event-list.js +208 -0
- package/dist/dashboard/event-list.module.css +336 -0
- package/dist/dashboard/event-list.module.css.d.ts +34 -0
- package/dist/dashboard/index.d.ts +2 -0
- package/dist/dashboard/index.d.ts.map +1 -1
- package/dist/dashboard/index.js +4 -0
- package/dist/dashboard/meter-model.d.ts +6 -3
- package/dist/dashboard/meter-model.d.ts.map +1 -1
- package/dist/dashboard/meter-model.js +9 -4
- package/dist/dashboard/meter-parts.d.ts +3 -0
- package/dist/dashboard/meter-parts.d.ts.map +1 -1
- package/dist/dashboard/meter-parts.js +36 -6
- package/dist/dashboard/meter.d.ts +3 -3
- package/dist/dashboard/meter.d.ts.map +1 -1
- package/dist/dashboard/meter.js +10 -2
- package/dist/dashboard/meter.module.css +20 -12
- package/dist/dashboard/meter.module.css.d.ts +0 -1
- package/dist/dashboard/page-summary.d.ts +3 -3
- package/dist/dashboard/page-summary.d.ts.map +1 -1
- package/dist/dashboard/page-summary.js +7 -2
- package/dist/dashboard/page-summary.module.css +5 -2
- package/dist/dashboard/query-state.d.ts +9 -8
- package/dist/dashboard/query-state.d.ts.map +1 -1
- package/dist/dashboard/query-state.js +29 -11
- package/dist/dashboard/section.d.ts +11 -3
- package/dist/dashboard/section.d.ts.map +1 -1
- package/dist/dashboard/section.js +34 -7
- package/dist/dashboard/settings-section.d.ts +8 -5
- package/dist/dashboard/settings-section.d.ts.map +1 -1
- package/dist/dashboard/settings-section.js +12 -8
- package/dist/dashboard/settings-section.module.css +25 -4
- package/dist/dashboard/settings-section.module.css.d.ts +1 -0
- package/dist/dashboard/stat-card-parts.d.ts +5 -1
- package/dist/dashboard/stat-card-parts.d.ts.map +1 -1
- package/dist/dashboard/stat-card-parts.js +8 -3
- package/dist/dashboard/stat-card.d.ts +3 -3
- package/dist/dashboard/stat-card.d.ts.map +1 -1
- package/dist/dashboard/stat-card.js +47 -12
- package/dist/dashboard/stat-card.module.css +42 -7
- package/dist/dashboard/stat-card.module.css.d.ts +3 -0
- package/dist/dashboard/stat-group.d.ts +2 -2
- package/dist/dashboard/stat-group.d.ts.map +1 -1
- package/dist/dashboard/stat-group.js +10 -3
- package/dist/dashboard/stat-strip.d.ts +5 -4
- package/dist/dashboard/stat-strip.d.ts.map +1 -1
- package/dist/dashboard/stat-strip.js +41 -31
- package/dist/dashboard/stat-strip.module.css +8 -6
- package/dist/dashboard/visual-slot.d.ts +4 -0
- package/dist/dashboard/visual-slot.d.ts.map +1 -1
- package/dist/dashboard/visual-slot.js +2 -0
- package/dist/dashboard/widget-header.d.ts +6 -6
- package/dist/dashboard/widget-header.d.ts.map +1 -1
- package/dist/dashboard/widget-header.js +4 -2
- package/dist/dashboard/widget-header.module.css +12 -15
- package/dist/format/shared.d.ts.map +1 -1
- package/dist/format/shared.js +24 -1
- package/dist/guard/index.d.ts +1 -1
- package/dist/guard/index.d.ts.map +1 -1
- package/dist/guard/index.js +4 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/shell/app-main.module.css +18 -0
- package/dist/styles.css +69 -0
- package/dist/surfaces.d.ts +2 -2
- package/dist/surfaces.d.ts.map +1 -1
- package/dist/surfaces.js +8 -2
- package/dist/table/cell-kinds.d.ts +47 -0
- package/dist/table/cell-kinds.d.ts.map +1 -0
- package/dist/table/cell-kinds.js +180 -0
- package/dist/table/cell-kinds.module.css +55 -0
- package/dist/table/cell-kinds.module.css.d.ts +15 -0
- package/dist/table/data-table-fold.d.ts +155 -0
- package/dist/table/data-table-fold.d.ts.map +1 -0
- package/dist/table/data-table-fold.js +320 -0
- package/dist/table/data-table-state.d.ts +10 -3
- package/dist/table/data-table-state.d.ts.map +1 -1
- package/dist/table/data-table-state.js +11 -6
- package/dist/table/data-table.d.ts +13 -28
- package/dist/table/data-table.d.ts.map +1 -1
- package/dist/table/data-table.js +362 -255
- package/dist/table/data-table.module.css +282 -3
- package/dist/table/data-table.module.css.d.ts +16 -0
- package/dist/table/table-features.d.ts +34 -4
- package/dist/table/table-features.d.ts.map +1 -1
- package/dist/table/table-features.js +10 -0
- package/dist/theme/card-inset.module.css +35 -0
- package/dist/theme/controls.module.css +55 -2
- package/dist/theme/ctl-theme.d.ts.map +1 -1
- package/dist/theme/ctl-theme.js +5 -0
- package/dist/theme/index.d.ts.map +1 -1
- package/dist/theme/index.js +14 -10
- package/dist/tokens/core.d.ts +1 -0
- package/dist/tokens/core.d.ts.map +1 -1
- package/dist/tokens/core.js +1 -0
- package/dist/tokens/derive.js +1 -1
- package/dist/tokens/palette.d.ts +2 -1
- package/dist/tokens/palette.d.ts.map +1 -1
- package/llms.txt +295 -5
- package/package.json +1 -1
- package/src/agent/chat/thread-message.tsx +10 -403
- package/src/agent/chat/virtualize.ts +5 -5
- package/src/charts/ChartCard.tsx +175 -31
- package/src/charts/Lines.tsx +13 -4
- package/src/charts/Sparkline.tsx +213 -48
- package/src/charts/chart-box.module.css +59 -2
- package/src/charts/chart-box.module.css.d.ts +5 -0
- package/src/charts/chart-card.module.css +28 -17
- package/src/charts/chart-card.module.css.d.ts +3 -0
- package/src/charts/compile.ts +59 -33
- package/src/charts/labels.ts +175 -24
- package/src/charts/legend.tsx +3 -2
- package/src/charts/ref-label.ts +114 -18
- package/src/charts/sparkline.module.css +50 -0
- package/src/charts/sparkline.module.css.d.ts +3 -0
- package/src/charts/state.tsx +40 -10
- package/src/cli/doctor-upgrade.ts +75 -0
- package/src/cli/doctor.ts +36 -0
- package/src/cli/help.ts +16 -6
- package/src/cli/index.ts +73 -67
- package/src/cli/init.ts +157 -36
- package/src/cli/router-wiring.ts +2 -2
- package/src/cli/shot/capture.ts +138 -16
- package/src/cli/shot/detect.ts +46 -22
- package/src/cli/shot/index.ts +8 -2
- package/src/cli/shot/measure.ts +11 -2
- package/src/cli/shot/types.ts +4 -1
- package/src/cli/sync.ts +12 -2
- package/src/common/could-not-load.ts +22 -0
- package/src/common/empty-copy.ts +17 -0
- package/src/common/index.ts +1 -0
- package/src/common/props.ts +30 -0
- package/src/common/retry-button.module.css +7 -3
- package/src/common/virtual-rows.tsx +682 -0
- package/src/controls/controls.module.css +33 -1
- package/src/controls/controls.module.css.d.ts +2 -0
- package/src/controls/enum-filter.tsx +8 -2
- package/src/controls/filter-pill.tsx +80 -27
- package/src/controls/form-layout.module.css +112 -7
- package/src/controls/form-layout.module.css.d.ts +1 -0
- package/src/controls/form-layout.tsx +115 -22
- package/src/controls/multi-select-filter.tsx +22 -11
- package/src/controls/range-filter.tsx +9 -3
- package/src/dashboard/bar-list.module.css +21 -5
- package/src/dashboard/bar-list.tsx +53 -45
- package/src/dashboard/board-nav.ts +67 -0
- package/src/dashboard/board.module.css +179 -0
- package/src/dashboard/board.module.css.d.ts +28 -0
- package/src/dashboard/board.tsx +415 -0
- package/src/dashboard/empty-state.tsx +21 -11
- package/src/dashboard/event-list-model.ts +125 -0
- package/src/dashboard/event-list-rows.tsx +117 -0
- package/src/dashboard/event-list-scroll.ts +291 -0
- package/src/dashboard/event-list-skeleton.tsx +62 -0
- package/src/dashboard/event-list.module.css +336 -0
- package/src/dashboard/event-list.module.css.d.ts +34 -0
- package/src/dashboard/event-list.tsx +336 -0
- package/src/dashboard/index.ts +2 -0
- package/src/dashboard/meter-model.ts +16 -7
- package/src/dashboard/meter-parts.tsx +53 -14
- package/src/dashboard/meter.module.css +20 -12
- package/src/dashboard/meter.module.css.d.ts +0 -1
- package/src/dashboard/meter.tsx +36 -18
- package/src/dashboard/page-summary.module.css +5 -2
- package/src/dashboard/page-summary.tsx +13 -6
- package/src/dashboard/query-state.tsx +55 -30
- package/src/dashboard/section.tsx +83 -41
- package/src/dashboard/settings-section.module.css +25 -4
- package/src/dashboard/settings-section.module.css.d.ts +1 -0
- package/src/dashboard/settings-section.tsx +18 -8
- package/src/dashboard/stat-card-parts.tsx +20 -3
- package/src/dashboard/stat-card.module.css +42 -7
- package/src/dashboard/stat-card.module.css.d.ts +3 -0
- package/src/dashboard/stat-card.tsx +55 -13
- package/src/dashboard/stat-group.tsx +22 -14
- package/src/dashboard/stat-strip.module.css +8 -6
- package/src/dashboard/stat-strip.tsx +29 -20
- package/src/dashboard/visual-slot.ts +5 -0
- package/src/dashboard/widget-header.module.css +12 -15
- package/src/dashboard/widget-header.tsx +8 -5
- package/src/format/shared.ts +30 -1
- package/src/guard/index.ts +7 -1
- package/src/index.ts +4 -0
- package/src/shell/app-main.module.css +18 -0
- package/src/styles.css +69 -0
- package/src/surfaces.ts +7 -1
- package/src/table/cell-kinds.module.css +55 -0
- package/src/table/cell-kinds.module.css.d.ts +15 -0
- package/src/table/cell-kinds.tsx +263 -0
- package/src/table/data-table-fold.tsx +567 -0
- package/src/table/data-table-state.ts +24 -13
- package/src/table/data-table.module.css +282 -3
- package/src/table/data-table.module.css.d.ts +16 -0
- package/src/table/data-table.tsx +430 -362
- package/src/table/table-features.ts +44 -4
- package/src/theme/__snapshots__/plain-theme.test.ts.snap +2 -66
- package/src/theme/card-inset.module.css +35 -0
- package/src/theme/controls.module.css +55 -2
- package/src/theme/ctl-theme.tsx +8 -0
- package/src/theme/index.ts +12 -8
- package/src/tokens/core.ts +1 -0
- package/src/tokens/derive.ts +1 -1
- package/src/tokens/palette.ts +4 -1
|
@@ -131,8 +131,9 @@
|
|
|
131
131
|
padding-inline: var(--button-padding-x-ctl);
|
|
132
132
|
}
|
|
133
133
|
|
|
134
|
+
/* An active filter is selection state, so its border is ink, not the accent (SPEC § 6.12). */
|
|
134
135
|
.pill[data-active] {
|
|
135
|
-
border-color: var(--vx-
|
|
136
|
+
border-color: color-mix(in srgb, var(--vx-ink) 55%, transparent);
|
|
136
137
|
color: var(--vx-ink);
|
|
137
138
|
}
|
|
138
139
|
|
|
@@ -176,6 +177,37 @@
|
|
|
176
177
|
font-weight: 500;
|
|
177
178
|
}
|
|
178
179
|
|
|
180
|
+
/* The two-span anatomy (`filter-pill.tsx`): the facet's name muted, the selection bright. A pill
|
|
181
|
+
* without a value renders neither span, so its single label keeps the button's own colour. */
|
|
182
|
+
.pillName {
|
|
183
|
+
flex-shrink: 0;
|
|
184
|
+
color: var(--vx-muted);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/* The Button label is a flex row (whitespace between its spans collapses), so the gap is the
|
|
188
|
+
* tier's own control gap, and the VALUE is what truncates past the pill's width cap. */
|
|
189
|
+
.pillLabel:has(.pillValue) {
|
|
190
|
+
column-gap: var(--vx-space-control-gap, 0.375rem);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
.pillValue {
|
|
194
|
+
overflow: hidden;
|
|
195
|
+
text-overflow: ellipsis;
|
|
196
|
+
color: var(--vx-ink);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/* A numeric pill that also carries a name keeps the NAME in the body face — only the value is a
|
|
200
|
+
* number. */
|
|
201
|
+
.pill[data-numeric]:has(.pillValue) .pillName {
|
|
202
|
+
font-family: var(--mantine-font-family);
|
|
203
|
+
font-size: var(--vx-text-sm);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
.pill[data-numeric] .pillValue {
|
|
207
|
+
font-family: var(--basalt-font-mono);
|
|
208
|
+
font-size: var(--vx-text-xs);
|
|
209
|
+
}
|
|
210
|
+
|
|
179
211
|
/* Numeric pill labels read mono at the smaller step. The FACE comes from the package-wide
|
|
180
212
|
* `[data-numeric]` law in `styles.css`; the `font-size` is the pill's own decision, which is why
|
|
181
213
|
* this rule exists at all. */
|
|
@@ -33,7 +33,7 @@ import type { FieldOption } from '../state/fields'
|
|
|
33
33
|
import classes from './controls.module.css'
|
|
34
34
|
import { POPOVER_ROW_HIT_GAP, useFilterRegistration, useFilterSurface } from './filter-context'
|
|
35
35
|
import type { FilterBase, FilterOption } from './filter-base'
|
|
36
|
-
import { FilterClearButton, FilterPill } from './filter-pill'
|
|
36
|
+
import { FilterClearButton, FilterPill, filterReading } from './filter-pill'
|
|
37
37
|
import { useControlName } from './control-name'
|
|
38
38
|
import { PanelChoice, PanelRow } from './panel-row'
|
|
39
39
|
|
|
@@ -166,9 +166,15 @@ export function EnumFilter<T extends string>({
|
|
|
166
166
|
</Radio.Group>
|
|
167
167
|
)
|
|
168
168
|
|
|
169
|
+
const shownLabel = selected?.label ?? unmatchedLabel
|
|
169
170
|
return (
|
|
170
171
|
<FilterPill
|
|
171
|
-
|
|
172
|
+
{...filterReading({
|
|
173
|
+
name: label,
|
|
174
|
+
informative: !isDefault,
|
|
175
|
+
value: shownLabel ?? value,
|
|
176
|
+
unsetText: shownLabel ?? label,
|
|
177
|
+
})}
|
|
172
178
|
active={!isDefault}
|
|
173
179
|
{...(numeric === true && { numeric: true })}
|
|
174
180
|
{...(disabled === true && { disabled: true })}
|
|
@@ -9,6 +9,13 @@
|
|
|
9
9
|
* `--button-height-ctl` var set (`docs/CONTROLS-SPEC.md` §5), so the pill is the same height whether
|
|
10
10
|
* or not the home wrapped its slot in `CtlSlot`, and it tracks the density knob for free.
|
|
11
11
|
*
|
|
12
|
+
* **Anatomy.** A facet pill reads `Label Value`: the facet's name muted (`--vx-muted`), the selection
|
|
13
|
+
* bright (`--vx-ink`) — two spans inside the one Button label, so a reader finds the value without
|
|
14
|
+
* parsing a sentence. `value` is the SELECTION and its presence IS the anatomy; an unset facet
|
|
15
|
+
* (`unset`) renders its one text muted, since it names a filter that is not filtering. A pill with
|
|
16
|
+
* neither (`ToggleFilter`, `RangeFilter`, `NumberFilter`, the `+N` fold, `Filters (n)`) keeps its
|
|
17
|
+
* single label exactly as before.
|
|
18
|
+
*
|
|
12
19
|
* Two modes, one component: with `children` the pill is a `Popover` target (every enum-ish filter);
|
|
13
20
|
* with only `onClick` it is a plain button that acts on press (`ToggleFilter`, the `+N` fold's
|
|
14
21
|
* sibling, the `Filters (n)` sheet opener).
|
|
@@ -22,35 +29,66 @@ import { IconSlot } from '../theme/icon-slot'
|
|
|
22
29
|
import classes from './controls.module.css'
|
|
23
30
|
import { UpDownGlyph } from './glyphs'
|
|
24
31
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
readonly
|
|
35
|
-
readonly
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
readonly
|
|
46
|
-
|
|
47
|
-
readonly
|
|
48
|
-
|
|
49
|
-
|
|
32
|
+
/**
|
|
33
|
+
* What the pill SAYS, one of three shapes: a facet name plus its selection (`label` muted, `value`
|
|
34
|
+
* ink), a facet that is not filtering (one muted text), or a plain label (press-to-act pills). An
|
|
35
|
+
* empty or whitespace-only `value` is the second shape — a selection with no text is not a selection.
|
|
36
|
+
*/
|
|
37
|
+
/** A value with nothing visible in it (`''`, `' '`) is not a selection. */
|
|
38
|
+
const hasText = (value: string): boolean => value.trim() !== ''
|
|
39
|
+
|
|
40
|
+
export type FilterPillReading =
|
|
41
|
+
| { readonly label: string; readonly value: string; readonly unset?: never }
|
|
42
|
+
| { readonly label: string; readonly unset: true; readonly value?: never }
|
|
43
|
+
| { readonly label: string; readonly value?: never; readonly unset?: never }
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* The ONE place a facet filter turns its state into a {@link FilterPillReading}: `informative` is
|
|
47
|
+
* the single predicate for "this filter is filtering" (and what the caller hands `active` too, so
|
|
48
|
+
* the muted anatomy and the ink border can never disagree); `value` is the selection's text and
|
|
49
|
+
* `unsetText` what the pill reads while it is not filtering (the control's existing copy).
|
|
50
|
+
*/
|
|
51
|
+
export function filterReading(input: {
|
|
52
|
+
readonly name: string
|
|
53
|
+
readonly informative: boolean
|
|
54
|
+
readonly value: string
|
|
55
|
+
readonly unsetText: string
|
|
56
|
+
}): FilterPillReading {
|
|
57
|
+
if (input.informative && hasText(input.value)) return { label: input.name, value: input.value }
|
|
58
|
+
return { label: input.unsetText, unset: true }
|
|
50
59
|
}
|
|
51
60
|
|
|
61
|
+
export type FilterPillProps = BasaltProps &
|
|
62
|
+
FilterPillReading & {
|
|
63
|
+
readonly icon?: ReactNode
|
|
64
|
+
/** Non-default → ink border (selection is ink, never the accent). Derived from `field.isDefault(value)`, never hand-set. */
|
|
65
|
+
readonly active?: boolean
|
|
66
|
+
/** Mono label, for a numeric preset set (`7d` / `30d`) — the same law `[data-numeric]` applies
|
|
67
|
+
* to a numeric SegmentedControl label (`theme/segmented-control.module.css`). */
|
|
68
|
+
readonly numeric?: boolean
|
|
69
|
+
/** Popover body. Omit for a press-to-act pill. */
|
|
70
|
+
readonly children?: ReactNode
|
|
71
|
+
readonly onClick?: () => void
|
|
72
|
+
/** Accessible name when the visible label is a bare count (`+2`). */
|
|
73
|
+
readonly ariaLabel?: string
|
|
74
|
+
/**
|
|
75
|
+
* `aria-pressed` for the press-to-act mode (`ToggleFilter`) — without it the on/off state is
|
|
76
|
+
* carried by a border colour and nothing else. Deliberately NOT set on a popover-target pill,
|
|
77
|
+
* where `aria-expanded` (which Mantine's `Popover.Target` supplies) is the correct state.
|
|
78
|
+
*/
|
|
79
|
+
readonly pressed?: boolean
|
|
80
|
+
/** Inert: the pill cannot be pressed, so its popover never opens. */
|
|
81
|
+
readonly disabled?: boolean
|
|
82
|
+
/** Set by `FilterSet` on its own fold/sheet pills; a filter never passes either of these. */
|
|
83
|
+
readonly hideGlyph?: boolean
|
|
84
|
+
/** `data-shown` — the CSS hook that reveals the `+N` fold pill once folding is needed. */
|
|
85
|
+
readonly shown?: boolean
|
|
86
|
+
}
|
|
87
|
+
|
|
52
88
|
export function FilterPill({
|
|
53
89
|
label,
|
|
90
|
+
value,
|
|
91
|
+
unset,
|
|
54
92
|
icon,
|
|
55
93
|
active,
|
|
56
94
|
numeric,
|
|
@@ -76,7 +114,7 @@ export function FilterPill({
|
|
|
76
114
|
className={cx(classes.pill, className)}
|
|
77
115
|
data-basalt-hit
|
|
78
116
|
// The label truncates past the pill's width cap; the full name stays one hover away.
|
|
79
|
-
title={label}
|
|
117
|
+
title={value !== undefined && hasText(value) ? `${label} ${value}` : label}
|
|
80
118
|
classNames={{ label: classes.pillLabel }}
|
|
81
119
|
{...(style !== undefined && { style })}
|
|
82
120
|
{...(active === true && { 'data-active': true })}
|
|
@@ -104,7 +142,22 @@ export function FilterPill({
|
|
|
104
142
|
})
|
|
105
143
|
}
|
|
106
144
|
>
|
|
107
|
-
{
|
|
145
|
+
{value !== undefined && hasText(value) ? (
|
|
146
|
+
<>
|
|
147
|
+
<span className={classes.pillName} data-pill-part="name">
|
|
148
|
+
{label}
|
|
149
|
+
</span>
|
|
150
|
+
<span className={classes.pillValue} data-pill-part="value">
|
|
151
|
+
{value}
|
|
152
|
+
</span>
|
|
153
|
+
</>
|
|
154
|
+
) : unset === true || value !== undefined ? (
|
|
155
|
+
<span className={classes.pillName} data-pill-part="name">
|
|
156
|
+
{label}
|
|
157
|
+
</span>
|
|
158
|
+
) : (
|
|
159
|
+
label
|
|
160
|
+
)}
|
|
108
161
|
</Button>
|
|
109
162
|
)
|
|
110
163
|
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
/* ── FormRow ─────────────────────────────────────────────────────────────────────────────────── */
|
|
38
38
|
|
|
39
39
|
/*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
40
|
+
* One row rule for FormRow and SettingsRow: a 15rem label column, then a control column capped at
|
|
41
|
+
* 20rem — beside each other, left-packed, never a 656px field behind a 480px gutter. `align-items: start` so a two-line label does not centre
|
|
42
42
|
* itself against a one-line input.
|
|
43
43
|
*/
|
|
44
44
|
.row {
|
|
@@ -48,7 +48,8 @@
|
|
|
48
48
|
|
|
49
49
|
.grid {
|
|
50
50
|
display: grid;
|
|
51
|
-
grid-template-columns: minmax(0,
|
|
51
|
+
grid-template-columns: minmax(0, 15rem) minmax(0, 20rem);
|
|
52
|
+
justify-content: start;
|
|
52
53
|
align-items: start;
|
|
53
54
|
gap: var(--vx-space-settings-row-gap);
|
|
54
55
|
}
|
|
@@ -56,18 +57,29 @@
|
|
|
56
57
|
.rowLabel {
|
|
57
58
|
display: flex;
|
|
58
59
|
flex-direction: column;
|
|
59
|
-
gap: var(--vx-space-stack-xs);
|
|
60
60
|
min-inline-size: 0;
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
+
/*
|
|
64
|
+
* The label's first line sits on the optical centre of the 32 px field it names (44 under a coarse
|
|
65
|
+
* pointer): top padding is half of field height minus one line. The description then follows the
|
|
66
|
+
* label directly instead of hanging 32 px below it. Stacked, the label is just a line.
|
|
67
|
+
*/
|
|
63
68
|
.label {
|
|
64
|
-
|
|
69
|
+
padding-block-start: calc(
|
|
70
|
+
(max(var(--vx-space-control-height-ctl) * var(--mantine-scale, 1), var(--vx-hit, 0px)) - 1lh) /
|
|
71
|
+
2
|
|
72
|
+
);
|
|
73
|
+
font-size: var(--vx-text-sm);
|
|
65
74
|
color: var(--vx-ink);
|
|
66
75
|
}
|
|
67
76
|
|
|
68
77
|
.hint {
|
|
69
|
-
font-size: var(--vx-text-
|
|
78
|
+
font-size: var(--vx-text-xs);
|
|
70
79
|
color: var(--vx-muted);
|
|
80
|
+
/* Hangs tight under the label and gives back the line it would add to the row: the next row
|
|
81
|
+
reads as near as its own gap, not a description-high further. */
|
|
82
|
+
margin-block-end: calc(-1 * var(--vx-space-stack-xs));
|
|
71
83
|
}
|
|
72
84
|
|
|
73
85
|
.required {
|
|
@@ -90,17 +102,81 @@
|
|
|
90
102
|
padding: 0;
|
|
91
103
|
}
|
|
92
104
|
|
|
105
|
+
/*
|
|
106
|
+
* The error: the bad-status glyph, then one sentence. `1lh` is the glyph's box so it centres on the
|
|
107
|
+
* FIRST line when the sentence wraps. A Mantine input wired through `inputProps` renders its own
|
|
108
|
+
* error (Input.Wrapper), so the same glyph is drawn on that error as a mask, in the same colour:
|
|
109
|
+
* the two paths read as one.
|
|
110
|
+
*/
|
|
111
|
+
/*
|
|
112
|
+
* An auto-height Textarea sizes from its line and padding (35 px for one row), not from the tier:
|
|
113
|
+
* the floor is the field height itself, 44 under a coarse pointer.
|
|
114
|
+
*/
|
|
115
|
+
.control :global(.mantine-Textarea-input) {
|
|
116
|
+
min-block-size: max(
|
|
117
|
+
var(--vx-space-control-height-ctl) * var(--mantine-scale, 1),
|
|
118
|
+
var(--vx-hit, 0px)
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
|
|
93
122
|
.error {
|
|
123
|
+
display: flex;
|
|
124
|
+
align-items: flex-start;
|
|
125
|
+
gap: var(--vx-space-stack-xs);
|
|
126
|
+
font-size: var(--vx-text-sm);
|
|
127
|
+
color: var(--vx-status-bad);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/* The always-mounted live region is empty while clean: out of flow (no flex gap), still in the a11y tree. */
|
|
131
|
+
.error:empty {
|
|
132
|
+
position: absolute;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.errorIcon {
|
|
136
|
+
flex: none;
|
|
137
|
+
inline-size: 1em;
|
|
138
|
+
block-size: 1lh;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
:is(.control, .group) :global(.mantine-InputWrapper-error),
|
|
142
|
+
:is(.control, .group) :global(.mantine-Checkbox-error),
|
|
143
|
+
:is(.control, .group) :global(.mantine-Switch-error),
|
|
144
|
+
:is(.control, .group) :global(.mantine-Radio-error) {
|
|
145
|
+
display: flex;
|
|
146
|
+
align-items: flex-start;
|
|
147
|
+
gap: var(--vx-space-stack-xs);
|
|
148
|
+
margin-block-start: 0;
|
|
94
149
|
font-size: var(--vx-text-sm);
|
|
95
150
|
color: var(--vx-status-bad);
|
|
96
151
|
}
|
|
97
152
|
|
|
153
|
+
:is(.control, .group) :global(.mantine-InputWrapper-error)::before,
|
|
154
|
+
:is(.control, .group) :global(.mantine-Checkbox-error)::before,
|
|
155
|
+
:is(.control, .group) :global(.mantine-Switch-error)::before,
|
|
156
|
+
:is(.control, .group) :global(.mantine-Radio-error)::before {
|
|
157
|
+
content: '';
|
|
158
|
+
flex: none;
|
|
159
|
+
inline-size: 1em;
|
|
160
|
+
block-size: 1lh;
|
|
161
|
+
background-color: currentColor;
|
|
162
|
+
mask: var(--basalt-field-error-glyph) center / contain no-repeat;
|
|
163
|
+
}
|
|
164
|
+
|
|
98
165
|
/* The narrow twin: the control needs the full width, so the label goes above it. */
|
|
99
166
|
@container basalt-form (max-width: 599.9px) {
|
|
100
167
|
.grid {
|
|
101
168
|
grid-template-columns: minmax(0, 1fr);
|
|
102
169
|
gap: var(--vx-space-stack-xs);
|
|
103
170
|
}
|
|
171
|
+
|
|
172
|
+
.label {
|
|
173
|
+
padding-block-start: 0;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/* Stacked, the grid gap is the label-to-control distance: do not pull the description into it. */
|
|
177
|
+
.hint {
|
|
178
|
+
margin-block-end: 0;
|
|
179
|
+
}
|
|
104
180
|
}
|
|
105
181
|
|
|
106
182
|
/* ── FormGroup ───────────────────────────────────────────────────────────────────────────────── */
|
|
@@ -124,10 +200,39 @@
|
|
|
124
200
|
float: left;
|
|
125
201
|
width: 100%;
|
|
126
202
|
padding: 0;
|
|
127
|
-
font-size: var(--vx-text-
|
|
203
|
+
font-size: var(--vx-text-sm);
|
|
128
204
|
color: var(--vx-ink);
|
|
129
205
|
}
|
|
130
206
|
|
|
207
|
+
/* A section: the legend is the section title (`md`, 500), the cluster stacks 12 apart like rows, and
|
|
208
|
+
a section that follows another keeps 24 above it (never before the action row) — the form's whole rhythm, owned here. */
|
|
209
|
+
.group[data-section] {
|
|
210
|
+
gap: var(--vx-space-stack-sm);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
.group[data-section] + .group[data-section] {
|
|
214
|
+
margin-block-start: var(--vx-space-stack-xl);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
.group[data-section] > .legend {
|
|
218
|
+
font-size: var(--vx-text-md);
|
|
219
|
+
font-weight: 500;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
.group[data-section] > .groupControls[data-direction='column'] {
|
|
223
|
+
display: block;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/* D54: the rows of a section divide exactly as `SettingsSection`'s do — the row inset above and below
|
|
227
|
+
and a 1px `--vx-divider` rule under every row but the last, so a form and a settings page read as one system. */
|
|
228
|
+
.group[data-section] > .groupControls[data-direction='column'] > .row {
|
|
229
|
+
padding-block: var(--vx-space-settings-row-inset-y);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
.group[data-section] > .groupControls[data-direction='column'] > .row:not(:last-child) {
|
|
233
|
+
border-block-end: 1px solid var(--vx-divider);
|
|
234
|
+
}
|
|
235
|
+
|
|
131
236
|
.groupControls {
|
|
132
237
|
display: flex;
|
|
133
238
|
clear: both;
|
|
@@ -10,17 +10,18 @@
|
|
|
10
10
|
* label/control geometry, and each one picked its own breakpoint behaviour.
|
|
11
11
|
*
|
|
12
12
|
* **`FormRow` IS law C1's third home, the form row** (`docs/CONTROLS-SPEC.md` §1). Like
|
|
13
|
-
* `SettingsRow` it
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
13
|
+
* `SettingsRow` it mounts a `CtlSlot`, so a bound control is the 32 px field (44 under a coarse
|
|
14
|
+
* pointer, 16 px text) of SPEC § 6.13 and not Mantine's 42 px `md`; a child's own `size` still wins.
|
|
15
|
+
* `SettingsRow` is not deprecated and is not duplicated here — reach for it on a settings page (a
|
|
16
|
+
* stack of divider-separated rows inside a `SettingsSection` card), and for `FormRow` inside a
|
|
17
|
+
* `<form>` with validation, hints and errors.
|
|
18
18
|
*
|
|
19
19
|
* Disabled propagation is native `<fieldset disabled>` driven by `FormStateProvider` — see
|
|
20
20
|
* `form-state.tsx` for why that rather than `cloneElement`.
|
|
21
21
|
*/
|
|
22
22
|
import { VisuallyHidden } from '@mantine/core'
|
|
23
|
-
import
|
|
23
|
+
import { useId } from 'react'
|
|
24
|
+
import type { CSSProperties, ReactNode } from 'react'
|
|
24
25
|
import { cx } from '../common/props'
|
|
25
26
|
import type { BasaltProps, SlotStylesProps } from '../common/props'
|
|
26
27
|
import { assertRequiredProps } from '../common/validate'
|
|
@@ -28,6 +29,7 @@ import { BarActionSlot } from './actions'
|
|
|
28
29
|
import type { SlotActions } from './actions'
|
|
29
30
|
import { WidgetHeader } from '../dashboard/widget-header'
|
|
30
31
|
import type { WidgetHeaderTitleProps } from '../dashboard/widget-header'
|
|
32
|
+
import { CtlSlot } from '../theme'
|
|
31
33
|
import { useFormState } from '../forms/form-state'
|
|
32
34
|
import classes from './form-layout.module.css'
|
|
33
35
|
|
|
@@ -55,15 +57,73 @@ function RequiredMark({ required }: { required: boolean | undefined }) {
|
|
|
55
57
|
}
|
|
56
58
|
|
|
57
59
|
/**
|
|
58
|
-
*
|
|
60
|
+
* True when `error` carries a message. `undefined`, `null`, `false`, `true` and `''` are all
|
|
61
|
+
* "clean": `form.errors[path]` is `undefined` on a clean field, `null` once cleared, `false` from a
|
|
62
|
+
* `cond && message`, and `''` from a validator that returns an empty string.
|
|
63
|
+
*/
|
|
64
|
+
function hasError(error: ReactNode): boolean {
|
|
65
|
+
return error !== undefined && error !== null && typeof error !== 'boolean' && error !== ''
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* The error glyph, drawn once: the inline `FieldError` svg renders these shapes and the Mantine
|
|
70
|
+
* input's own error draws the SAME data URI as a CSS mask (`--basalt-field-error-glyph`, set on the
|
|
71
|
+
* control region), so the two paths cannot drift.
|
|
72
|
+
*/
|
|
73
|
+
const GLYPH_CIRCLE = { cx: 8, cy: 8, r: 6.25 } as const
|
|
74
|
+
const GLYPH_PATH = 'M8 4.75v3.9M8 11.2v.05'
|
|
75
|
+
const GLYPH_MASK = `url("data:image/svg+xml,${encodeURIComponent(
|
|
76
|
+
`<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round'><circle cx='${GLYPH_CIRCLE.cx}' cy='${GLYPH_CIRCLE.cy}' r='${GLYPH_CIRCLE.r}'/><path d='${GLYPH_PATH}'/></svg>`,
|
|
77
|
+
)}")`
|
|
78
|
+
const glyphVars = { '--basalt-field-error-glyph': GLYPH_MASK } as CSSProperties
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* The error line under a control region: the bad-status icon, then one sentence.
|
|
59
82
|
*
|
|
60
83
|
* The falsy test is the reason this is shared: `error` takes `form.errors[path]` verbatim, which is
|
|
61
84
|
* `undefined` on a clean field, `null` after a cleared error and `false` from a `cond && message`
|
|
62
|
-
* — three shapes, and a call site testing only one paints an empty red box on the other two.
|
|
85
|
+
* — three shapes, and a call site testing only one paints an empty red box on the other two. The
|
|
86
|
+
* icon is decorative (`aria-hidden`): colour and a glyph are not the message, the sentence is, and
|
|
87
|
+
* the region it sits in names it through `aria-describedby`.
|
|
63
88
|
*/
|
|
64
|
-
function FieldError({ error }: { error: ReactNode }) {
|
|
65
|
-
|
|
66
|
-
|
|
89
|
+
function FieldError({ error, id }: { error: ReactNode; id: string }) {
|
|
90
|
+
// The live region is always mounted and empty while clean: a region inserted together with its
|
|
91
|
+
// text is not reliably announced, one that gains text is.
|
|
92
|
+
return (
|
|
93
|
+
<span id={id} className={classes.error} aria-live="polite">
|
|
94
|
+
{hasError(error) && <FieldErrorBody error={error} />}
|
|
95
|
+
</span>
|
|
96
|
+
)
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function FieldErrorBody({ error }: { error: ReactNode }) {
|
|
100
|
+
return (
|
|
101
|
+
<>
|
|
102
|
+
<svg
|
|
103
|
+
className={classes.errorIcon}
|
|
104
|
+
viewBox="0 0 16 16"
|
|
105
|
+
fill="none"
|
|
106
|
+
stroke="currentColor"
|
|
107
|
+
strokeWidth="1.5"
|
|
108
|
+
strokeLinecap="round"
|
|
109
|
+
aria-hidden="true"
|
|
110
|
+
data-field-error-icon=""
|
|
111
|
+
>
|
|
112
|
+
<circle {...GLYPH_CIRCLE} />
|
|
113
|
+
<path d={GLYPH_PATH} />
|
|
114
|
+
</svg>
|
|
115
|
+
<span>{error}</span>
|
|
116
|
+
</>
|
|
117
|
+
)
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/** The ids a row/group hangs its description and error on, and the `aria-describedby` that names them. */
|
|
121
|
+
function useDescribedBy(hint: string | undefined, error: ReactNode) {
|
|
122
|
+
const uid = useId()
|
|
123
|
+
const hintId = `${uid}-hint`
|
|
124
|
+
const errorId = `${uid}-error`
|
|
125
|
+
const ids = [hint !== undefined && hintId, hasError(error) && errorId].filter(Boolean)
|
|
126
|
+
return { hintId, errorId, describedBy: ids.length > 0 ? ids.join(' ') : undefined }
|
|
67
127
|
}
|
|
68
128
|
|
|
69
129
|
// ── FormSection ───────────────────────────────────────────────────────────────
|
|
@@ -131,7 +191,7 @@ export type FormRowSlot = 'root' | 'label' | 'control'
|
|
|
131
191
|
|
|
132
192
|
export type FormRowProps = BasaltProps &
|
|
133
193
|
SlotStylesProps<FormRowSlot> & {
|
|
134
|
-
/** The field's label. Ink, `--vx-text-
|
|
194
|
+
/** The field's label. Ink, `--vx-text-sm` — the same size `SettingsRow` gives its own. */
|
|
135
195
|
label: string
|
|
136
196
|
/** Muted line under the label: the rule, the unit, the example. Never the error. */
|
|
137
197
|
hint?: string
|
|
@@ -156,7 +216,7 @@ export type FormRowProps = BasaltProps &
|
|
|
156
216
|
}
|
|
157
217
|
|
|
158
218
|
/**
|
|
159
|
-
* One labelled field: label left / control right
|
|
219
|
+
* One labelled field: label left / control right, label above the control under 600 px of the row (`basalt-form`).
|
|
160
220
|
* The swap is CSS (law C9) — no `useMediaQuery`, so it is correct in SSR markup and it costs no
|
|
161
221
|
* render.
|
|
162
222
|
*
|
|
@@ -174,7 +234,7 @@ export type FormRowProps = BasaltProps &
|
|
|
174
234
|
* @example
|
|
175
235
|
* // A raw control renders no error of its own — pass it explicitly.
|
|
176
236
|
* <FormRow label="Email" required error={inputProps(form, 'email').error}>
|
|
177
|
-
* <
|
|
237
|
+
* <MyEmailField value={form.values.email} onChange={(v) => form.setFieldValue('email', v)} />
|
|
178
238
|
* </FormRow>
|
|
179
239
|
*/
|
|
180
240
|
export function FormRow(props: FormRowProps) {
|
|
@@ -182,6 +242,7 @@ export function FormRow(props: FormRowProps) {
|
|
|
182
242
|
assertRequiredProps('FormRow', props, ['label'])
|
|
183
243
|
const { label, hint, error, required, htmlFor, children, className, style, classNames } = props
|
|
184
244
|
const { disabled } = useFormState()
|
|
245
|
+
const { hintId, errorId, describedBy } = useDescribedBy(hint, error)
|
|
185
246
|
|
|
186
247
|
return (
|
|
187
248
|
<div
|
|
@@ -194,11 +255,20 @@ export function FormRow(props: FormRowProps) {
|
|
|
194
255
|
{label}
|
|
195
256
|
<RequiredMark required={required} />
|
|
196
257
|
</label>
|
|
197
|
-
{hint !== undefined &&
|
|
258
|
+
{hint !== undefined && (
|
|
259
|
+
<span id={hintId} className={classes.hint}>
|
|
260
|
+
{hint}
|
|
261
|
+
</span>
|
|
262
|
+
)}
|
|
198
263
|
</div>
|
|
199
|
-
<fieldset
|
|
200
|
-
{
|
|
201
|
-
|
|
264
|
+
<fieldset
|
|
265
|
+
className={cx(classes.control, classNames?.control)}
|
|
266
|
+
disabled={disabled}
|
|
267
|
+
style={glyphVars}
|
|
268
|
+
{...(describedBy !== undefined && { 'aria-describedby': describedBy })}
|
|
269
|
+
>
|
|
270
|
+
<CtlSlot>{children}</CtlSlot>
|
|
271
|
+
<FieldError error={error} id={errorId} />
|
|
202
272
|
</fieldset>
|
|
203
273
|
</div>
|
|
204
274
|
</div>
|
|
@@ -223,6 +293,12 @@ export type FormGroupProps = BasaltProps & {
|
|
|
223
293
|
* container, so its intrinsic width is zero and it collapses otherwise. @default 'column'
|
|
224
294
|
*/
|
|
225
295
|
direction?: 'row' | 'column'
|
|
296
|
+
/**
|
|
297
|
+
* Sets the group up as a form SECTION: the legend becomes the section title (`md`, 500), the
|
|
298
|
+
* children stack 12 apart like rows, and a section followed by another keeps 24 between them —
|
|
299
|
+
* so a form is a run of `section` groups with no wrapper to space them. @default false
|
|
300
|
+
*/
|
|
301
|
+
section?: boolean
|
|
226
302
|
/** The cluster — checkboxes, radios, chips. */
|
|
227
303
|
children: ReactNode
|
|
228
304
|
}
|
|
@@ -254,24 +330,41 @@ export type FormGroupProps = BasaltProps & {
|
|
|
254
330
|
*/
|
|
255
331
|
export function FormGroup(props: FormGroupProps) {
|
|
256
332
|
assertRequiredProps('FormGroup', props, ['label'])
|
|
257
|
-
const {
|
|
333
|
+
const {
|
|
334
|
+
label,
|
|
335
|
+
hint,
|
|
336
|
+
error,
|
|
337
|
+
required,
|
|
338
|
+
direction = 'column',
|
|
339
|
+
section = false,
|
|
340
|
+
children,
|
|
341
|
+
className,
|
|
342
|
+
style,
|
|
343
|
+
} = props
|
|
258
344
|
const { disabled } = useFormState()
|
|
345
|
+
const { hintId, errorId, describedBy } = useDescribedBy(hint, error)
|
|
259
346
|
|
|
260
347
|
return (
|
|
261
348
|
<fieldset
|
|
262
349
|
className={cx(classes.group, className)}
|
|
263
350
|
disabled={disabled}
|
|
264
|
-
{
|
|
351
|
+
style={style === undefined ? glyphVars : { ...glyphVars, ...style }}
|
|
352
|
+
{...(section && { 'data-section': '' })}
|
|
353
|
+
{...(describedBy !== undefined && { 'aria-describedby': describedBy })}
|
|
265
354
|
>
|
|
266
355
|
<legend className={classes.legend}>
|
|
267
356
|
{label}
|
|
268
357
|
<RequiredMark required={required} />
|
|
269
358
|
</legend>
|
|
270
|
-
{hint !== undefined &&
|
|
359
|
+
{hint !== undefined && (
|
|
360
|
+
<span id={hintId} className={classes.hint}>
|
|
361
|
+
{hint}
|
|
362
|
+
</span>
|
|
363
|
+
)}
|
|
271
364
|
<div className={classes.groupControls} data-direction={direction}>
|
|
272
365
|
{children}
|
|
273
366
|
</div>
|
|
274
|
-
<FieldError error={error} />
|
|
367
|
+
<FieldError error={error} id={errorId} />
|
|
275
368
|
</fieldset>
|
|
276
369
|
)
|
|
277
370
|
}
|