basalt-ui 2.13.3 → 2.14.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 (123) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/MIGRATING.md +36 -12
  3. package/dist/agent/chat/thread-feed-row.d.ts.map +1 -1
  4. package/dist/agent/chat/thread-feed-row.js +2 -2
  5. package/dist/agent/chat/thread-message.d.ts.map +1 -1
  6. package/dist/agent/chat/thread-message.js +2 -2
  7. package/dist/agent/chat/thread-outcome-card.js +2 -2
  8. package/dist/charts/DualPanel.d.ts.map +1 -1
  9. package/dist/charts/DualPanel.js +1 -0
  10. package/dist/charts/compile.d.ts.map +1 -1
  11. package/dist/charts/compile.js +3 -2
  12. package/dist/charts/cursor.d.ts +10 -6
  13. package/dist/charts/cursor.d.ts.map +1 -1
  14. package/dist/charts/cursor.js +20 -13
  15. package/dist/charts/legend.d.ts +5 -4
  16. package/dist/charts/legend.d.ts.map +1 -1
  17. package/dist/charts/legend.js +3 -3
  18. package/dist/charts/panel.d.ts +2 -0
  19. package/dist/charts/panel.d.ts.map +1 -1
  20. package/dist/charts/panel.js +1 -0
  21. package/dist/commands/notifications/center.d.ts.map +1 -1
  22. package/dist/commands/notifications/center.js +2 -11
  23. package/dist/controls/control-name.d.ts +27 -0
  24. package/dist/controls/control-name.d.ts.map +1 -0
  25. package/dist/controls/control-name.js +11 -0
  26. package/dist/controls/enum-filter.d.ts +3 -6
  27. package/dist/controls/enum-filter.d.ts.map +1 -1
  28. package/dist/controls/enum-filter.js +8 -4
  29. package/dist/controls/filter-base.d.ts +30 -0
  30. package/dist/controls/filter-base.d.ts.map +1 -0
  31. package/dist/controls/filter-base.js +0 -0
  32. package/dist/controls/filter-pill.d.ts +3 -1
  33. package/dist/controls/filter-pill.d.ts.map +1 -1
  34. package/dist/controls/filter-pill.js +2 -0
  35. package/dist/controls/filter-sheet.d.ts +0 -32
  36. package/dist/controls/filter-sheet.d.ts.map +1 -1
  37. package/dist/controls/filter-sheet.js +1 -28
  38. package/dist/controls/glyphs.d.ts +12 -0
  39. package/dist/controls/glyphs.d.ts.map +1 -1
  40. package/dist/controls/glyphs.js +23 -2
  41. package/dist/controls/index.d.ts +2 -1
  42. package/dist/controls/index.d.ts.map +1 -1
  43. package/dist/controls/multi-select-filter.d.ts +8 -3
  44. package/dist/controls/multi-select-filter.d.ts.map +1 -1
  45. package/dist/controls/multi-select-filter.js +27 -10
  46. package/dist/controls/number-filter.d.ts +3 -12
  47. package/dist/controls/number-filter.d.ts.map +1 -1
  48. package/dist/controls/number-filter.js +17 -6
  49. package/dist/controls/panel-row.d.ts +5 -8
  50. package/dist/controls/panel-row.d.ts.map +1 -1
  51. package/dist/controls/panel-row.js +3 -0
  52. package/dist/controls/range-filter.d.ts +14 -14
  53. package/dist/controls/range-filter.d.ts.map +1 -1
  54. package/dist/controls/range-filter.js +18 -41
  55. package/dist/controls/search-filter.d.ts +5 -2
  56. package/dist/controls/search-filter.d.ts.map +1 -1
  57. package/dist/controls/search-filter.js +74 -40
  58. package/dist/controls/select-filter.d.ts +2 -15
  59. package/dist/controls/select-filter.d.ts.map +1 -1
  60. package/dist/controls/sync-button.d.ts +0 -6
  61. package/dist/controls/sync-button.d.ts.map +1 -1
  62. package/dist/controls/sync-button.js +6 -36
  63. package/dist/controls/toggle-filter.d.ts +2 -2
  64. package/dist/controls/toggle-filter.d.ts.map +1 -1
  65. package/dist/controls/toggle-filter.js +3 -2
  66. package/dist/controls/view-tabs.d.ts +3 -4
  67. package/dist/controls/view-tabs.d.ts.map +1 -1
  68. package/dist/controls/view-tabs.js +24 -5
  69. package/dist/format/date.d.ts +43 -10
  70. package/dist/format/date.d.ts.map +1 -1
  71. package/dist/format/date.js +109 -18
  72. package/dist/format/index.d.ts +12 -11
  73. package/dist/format/index.d.ts.map +1 -1
  74. package/dist/format/index.js +11 -2
  75. package/dist/format/measure.d.ts +9 -9
  76. package/dist/format/measure.d.ts.map +1 -1
  77. package/dist/format/measure.js +19 -8
  78. package/dist/format/number.d.ts +35 -27
  79. package/dist/format/number.d.ts.map +1 -1
  80. package/dist/format/number.js +41 -20
  81. package/dist/format/shared.d.ts +38 -7
  82. package/dist/format/shared.d.ts.map +1 -1
  83. package/dist/format/shared.js +61 -13
  84. package/dist/provider/index.d.ts +13 -1
  85. package/dist/provider/index.d.ts.map +1 -1
  86. package/dist/provider/index.js +8 -0
  87. package/llms.txt +35 -14
  88. package/package.json +1 -1
  89. package/src/agent/chat/thread-feed-row.tsx +2 -2
  90. package/src/agent/chat/thread-message.tsx +2 -2
  91. package/src/agent/chat/thread-outcome-card.tsx +2 -2
  92. package/src/charts/DualPanel.tsx +1 -0
  93. package/src/charts/compile.ts +3 -2
  94. package/src/charts/cursor.ts +44 -27
  95. package/src/charts/legend.tsx +9 -6
  96. package/src/charts/panel.tsx +3 -0
  97. package/src/commands/notifications/center.tsx +2 -14
  98. package/src/controls/control-name.ts +33 -0
  99. package/src/controls/enum-filter.tsx +29 -27
  100. package/src/controls/filter-base.ts +31 -0
  101. package/src/controls/filter-pill.tsx +4 -0
  102. package/src/controls/filter-sheet.tsx +0 -56
  103. package/src/controls/glyphs.tsx +45 -2
  104. package/src/controls/index.ts +2 -1
  105. package/src/controls/multi-select-filter.tsx +67 -43
  106. package/src/controls/number-filter.tsx +47 -47
  107. package/src/controls/panel-row.tsx +7 -8
  108. package/src/controls/range-filter.tsx +54 -78
  109. package/src/controls/search-filter.tsx +107 -54
  110. package/src/controls/select-filter.tsx +2 -18
  111. package/src/controls/sync-button.tsx +7 -40
  112. package/src/controls/toggle-filter.tsx +9 -7
  113. package/src/controls/view-tabs.tsx +41 -21
  114. package/src/format/date.ts +189 -36
  115. package/src/format/index.ts +12 -11
  116. package/src/format/measure.ts +29 -18
  117. package/src/format/number.ts +76 -37
  118. package/src/format/shared.ts +116 -25
  119. package/src/provider/index.tsx +23 -0
  120. package/dist/agent/chat/relative-time.d.ts +0 -27
  121. package/dist/agent/chat/relative-time.d.ts.map +0 -1
  122. package/dist/agent/chat/relative-time.js +0 -27
  123. package/src/agent/chat/relative-time.ts +0 -55
@@ -128,33 +128,47 @@ export function isForeign(group: string | undefined, chartId: string): boolean {
128
128
  const valueX = (state: CursorState): ChartValue | undefined =>
129
129
  state?.anchor === 'value' ? state.value.x : undefined
130
130
 
131
- /** Snaps a foreign x value onto this chart's own x values; `null` = no snap (exact). */
131
+ /**
132
+ * Snaps a foreign x value onto this chart's own x values; `null` = no snap (a string x). A value
133
+ * outside the rendered x extent (`extent`; a caller with none gets the keys' own) resolves to
134
+ * `undefined`: the chart claims no datum at an x it does not cover, so it draws neither crosshair
135
+ * nor dots. The edges are inside. Only keys inside the extent are candidates, so a snap never lands
136
+ * on a datum the chart does not render; with none inside, a snapping mode resolves to `undefined`.
137
+ */
132
138
  function snapper(
133
139
  keys: readonly ChartX[],
134
140
  mode: CursorResolution,
141
+ extent?: readonly [number, number],
135
142
  ): ((x: ChartValue) => ChartValue | undefined) | null {
136
143
  const first = keys[0]
137
- if (first === undefined || typeof first === 'string') return null
138
- const isDate = first instanceof Date
144
+ if (typeof first === 'string') return null
139
145
  const ts = keys
140
146
  .map((k) => (k instanceof Date ? k.getTime() : (k as number)))
141
147
  .toSorted((a, b) => a - b)
148
+ const [lo, hi] = extent ?? [ts[0], ts.at(-1)]
149
+ if (lo === undefined || hi === undefined) return null
150
+ const inside = ts.filter((k) => k >= lo && k <= hi)
151
+ // No keys to read the x type from (an extent-only chart): either type is compared by its time.
152
+ const isDate = first === undefined ? undefined : first instanceof Date
142
153
  return (x) => {
143
154
  // Charts whose x value types differ never sync (the 1.x `DomainKind` partition).
144
- if (isDate !== x instanceof Date) return undefined
145
- if (!isDate && typeof x !== 'number') return undefined
155
+ if (isDate !== undefined && isDate !== x instanceof Date) return undefined
156
+ if (!(x instanceof Date) && typeof x !== 'number') return undefined
157
+ const t = x instanceof Date ? x.getTime() : x
158
+ if (t < lo || t > hi) return undefined
146
159
  if (mode === 'exact') return x
147
- const t = x instanceof Date ? x.getTime() : (x as number)
148
- let i = ts.findLastIndex((k) => k <= t)
160
+ const last = inside.length - 1
161
+ if (last < 0) return undefined
162
+ let i = inside.findLastIndex((k) => k <= t)
149
163
  if (
150
164
  mode === 'nearest' &&
151
- i < ts.length - 1 &&
152
- (i < 0 || (ts[i + 1] as number) - t < t - (ts[i] as number))
165
+ i < last &&
166
+ (i < 0 || (inside[i + 1] as number) - t < t - (inside[i] as number))
153
167
  )
154
168
  i += 1
155
- const snapped = ts[Math.max(i, 0)] as number
169
+ const snapped = inside[Math.max(i, 0)] as number
156
170
  if (snapped === t) return x
157
- return isDate ? new Date(snapped) : snapped
171
+ return x instanceof Date ? new Date(snapped) : snapped
158
172
  }
159
173
  }
160
174
 
@@ -201,6 +215,15 @@ function snappedState(state: NonNullable<CursorState>, x: ChartValue | undefined
201
215
  return { ...state, value: { ...state.value, x } }
202
216
  }
203
217
 
218
+ export type CursorViewOptions = {
219
+ group: string | undefined
220
+ chartId: string
221
+ keys: readonly ChartX[]
222
+ mode: CursorResolution
223
+ /** The x extent the chart renders (`xDomain`, else the data's); default: the keys' own. */
224
+ extent?: readonly [number, number] | undefined
225
+ }
226
+
204
227
  /**
205
228
  * Each chart's view of its group's controller. Two jobs:
206
229
  * - stamp what this chart publishes with its id (ownership, above);
@@ -212,13 +235,9 @@ function snappedState(state: NonNullable<CursorState>, x: ChartValue | undefined
212
235
  * is dropped a microtask after its last subscription ends, or after its creation if nothing
213
236
  * subscribed by then.
214
237
  */
215
- export function chartCursorView(
216
- group: string | undefined,
217
- chartId: string,
218
- keys: readonly ChartX[],
219
- mode: CursorResolution,
220
- ): ChartCursorController {
221
- const config: Snap = { snap: snapper(keys, mode), memo: new WeakMap() }
238
+ export function chartCursorView(opts: CursorViewOptions): ChartCursorController {
239
+ const { group, chartId } = opts
240
+ const config: Snap = { snap: snapper(opts.keys, opts.mode, opts.extent), memo: new WeakMap() }
222
241
  if (isServer()) return makeView(group, chartId, () => config)
223
242
  const id = `${group ?? 'default'}\u0000${chartId}`
224
243
  const existing = views.get(id)
@@ -310,17 +329,15 @@ export const quietWhileFollowing: ChartTooltipExtension = {
310
329
  },
311
330
  }
312
331
 
313
- export function cursorBinding(opts: {
314
- group: string | undefined
315
- chartId: string
316
- keys: readonly ChartX[]
317
- mode: CursorResolution
318
- /** Activation pins and unpins the cursor — on for a coarse pointer (§ 9.6: tap to pin). */
319
- pin: boolean
320
- }): ChartCursorBinding {
332
+ export function cursorBinding(
333
+ opts: CursorViewOptions & {
334
+ /** Activation pins and unpins the cursor — on for a coarse pointer (§ 9.6: tap to pin). */
335
+ pin: boolean
336
+ },
337
+ ): ChartCursorBinding {
321
338
  return {
322
339
  use: cursorHost,
323
- controller: chartCursorView(opts.group, opts.chartId, opts.keys, opts.mode),
340
+ controller: chartCursorView(opts),
324
341
  mode: 'focus',
325
342
  match: 'x',
326
343
  pin: opts.pin,
@@ -21,10 +21,12 @@ export type LegendMode = 'dots' | 'chips' | 'auto'
21
21
  const ROLE_ORDER = ['series', 'overlay', 'reference'] as const
22
22
 
23
23
  /**
24
- * Dots sit wider apart than chips: a dot is 8px, and two 44px coarse-pointer hit areas centred on
25
- * 8px hosts only stop overlapping once the pitch clears 44 (44 − 8 − 2, plus headroom).
24
+ * The pitch between dots-mode entries: 8px under the old 38, to pay for the 14px line key so the
25
+ * four-entry legend still fits one row at 390px. `--vx-hit-gap` caps each coarse-pointer hit area
26
+ * at the entry plus 2px and this gap (`styles.css`), so neighbours never overlap; the trade is that
27
+ * a dots-mode hit target is 8 + 2 + 30 = 40px, not 44.
26
28
  */
27
- const DOTS_GAP = 38
29
+ const DOTS_GAP = 30
28
30
 
29
31
  /** The entries a series list derives, in display order (by role when `groups`). */
30
32
  export function legendEntries<T>(
@@ -107,13 +109,14 @@ const swatchFill = (s: SwatchStyle): string =>
107
109
  s.colorNegative ? `linear-gradient(90deg, ${s.color} 50%, ${s.colorNegative} 50%)` : s.color
108
110
 
109
111
  /**
110
- * A line series' key: a short stroke with its dash, compact below 480px and wide from 480px. A
112
+ * A line series' key: a stroke with its dash, compact below 480px and wide from 480px. Both are at
113
+ * least 14px with two or more clear dashes: a shorter key reads as two dots. A
111
114
  * dashed swatch has BUTT caps: a round cap grows each dash by half the stroke width per end and
112
115
  * would close the gap.
113
116
  */
114
117
  export const LINE_SWATCH = {
115
- compact: { width: 8, dash: '2.5 2' },
116
- wide: { width: 12, dash: '4 3' },
118
+ compact: { width: 14, dash: '4 3' },
119
+ wide: { width: 16, dash: '4 3' },
117
120
  } as const
118
121
 
119
122
  function LineSwatch({ s, compact }: { s: SwatchStyle; compact: boolean }): ReactElement {
@@ -51,6 +51,8 @@ export type PaneBuilder = (ctx: PaneContext) => {
51
51
  export type PanelPlan<T> = {
52
52
  /** Every x value the cursor can land on, for snapping a foreign cursor. */
53
53
  keys: readonly ChartX[]
54
+ /** The x extent the shared scale renders; absent, the keys' own. */
55
+ extent?: readonly [number, number] | undefined
54
56
  top: PaneBuilder
55
57
  bottom: PaneBuilder
56
58
  /** The top pane's share of the grid, 0..1. */
@@ -215,6 +217,7 @@ function panelDefinition<T, X extends ChartX>(
215
217
  group: cursorGroup,
216
218
  chartId,
217
219
  keys: plan.keys,
220
+ extent: plan.extent,
218
221
  mode: cursorResolution,
219
222
  pin: ctx.coarse,
220
223
  }),
@@ -29,24 +29,12 @@ import {
29
29
  } from '@mantine/core'
30
30
  import type { BasaltProps } from '../../common/props'
31
31
  import { cx } from '../../common/props'
32
+ import { relativeTime } from '../../format'
32
33
  import { VX } from '../../tokens'
33
34
  import { resolveAction } from './define-notifications'
34
35
  import { useNotificationHistory } from './store'
35
36
  import type { NotificationHistoryItem, NotificationIntent } from './store'
36
37
 
37
- // ── Relative time ─────────────────────────────────────────────────────────────
38
-
39
- function relativeTime(createdAt: number): string {
40
- const seconds = Math.floor((Date.now() - createdAt) / 1000)
41
- if (seconds < 60) return 'just now'
42
- const minutes = Math.floor(seconds / 60)
43
- if (minutes < 60) return `${minutes}m ago`
44
- const hours = Math.floor(minutes / 60)
45
- if (hours < 24) return `${hours}h ago`
46
- const days = Math.floor(hours / 24)
47
- return `${days}d ago`
48
- }
49
-
50
38
  // ── Intent → Mantine color (drives the action Button's own `light`-variant tint) ──────────────
51
39
 
52
40
  const INTENT_COLOR: Record<NotificationIntent, string> = {
@@ -136,7 +124,7 @@ function NotificationItem({
136
124
  </Text>
137
125
  <Group gap="xs" align="center" mt={2} wrap="nowrap">
138
126
  <Text ff="monospace" c="var(--vx-faint)" style={{ fontSize: VX.text.micro }}>
139
- {relativeTime(item.createdAt)}
127
+ {relativeTime(item.createdAt, { style: 'short' })}
140
128
  </Text>
141
129
  {resolved !== undefined && (
142
130
  <Button variant="light" color={color} size="compact-xs" onClick={handleAction}>
@@ -0,0 +1,33 @@
1
+ import { useId } from 'react'
2
+
3
+ /**
4
+ * Names a control that has no VISIBLE Mantine `label`, and does it differently per surface — which
5
+ * is the whole reason this is one helper instead of an `aria-label` sprinkled per call site.
6
+ *
7
+ * In the SHEET and the PANEL the visible `PanelRow` heading is right there, so the control points
8
+ * at it (`aria-labelledby`) and the heading stops being decoration. In the PILL surface there is no
9
+ * visible name to point at — the pill text is the VALUE (`EUR`, `30d`, `3 channels`) — so the
10
+ * control carries the filter's own name instead. Either way the announced name is what is being
11
+ * filtered, not what it currently holds.
12
+ *
13
+ * The id is generated by the CONTROL, not by `PanelRow`, because the control renders its own
14
+ * `PanelRow`: an id published downward through context could never reach the sibling that needs it.
15
+ *
16
+ * @example
17
+ * const { labelId, nameProps } = useControlName(label, inSheet || inPanel)
18
+ * <Radio.Group {...nameProps} …/>
19
+ * // and, in the sheet/panel branch: <PanelRow label={label} labelId={labelId}>…</PanelRow>
20
+ */
21
+ export function useControlName(
22
+ label: string,
23
+ named: boolean,
24
+ ): {
25
+ labelId: string
26
+ nameProps: { 'aria-labelledby': string } | { 'aria-label': string }
27
+ } {
28
+ const labelId = useId()
29
+ return {
30
+ labelId,
31
+ nameProps: named ? { 'aria-labelledby': labelId } : { 'aria-label': label },
32
+ }
33
+ }
@@ -32,10 +32,10 @@ import type { BasaltProps } from '../common/props'
32
32
  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
+ import type { FilterBase, FilterOption } from './filter-base'
35
36
  import { FilterClearButton, FilterPill } from './filter-pill'
36
- import { useControlName } from './filter-sheet'
37
+ import { useControlName } from './control-name'
37
38
  import { PanelChoice, PanelRow } from './panel-row'
38
- import type { FilterOption } from './select-filter'
39
39
 
40
40
  /**
41
41
  * The slice of a `FieldHandle` this body actually binds to, generic over the VALUE rather than over
@@ -53,34 +53,33 @@ export type ChoiceHandle<T extends string> = {
53
53
  clear(): void
54
54
  }
55
55
 
56
- export type EnumFilterProps<T extends string> = BasaltProps & {
57
- readonly field: ChoiceHandle<T>
58
- readonly label: string
59
- readonly icon?: ReactNode
60
- /** Adds a `Clear` action that clears the field — the same `field.clear()` `Reset all` calls. */
61
- readonly clearable?: boolean
62
- /**
63
- * Overrides `field.options` at render — a runtime catalogue whose labels carry live data, or the
64
- * only row source a `StringField` has. `| undefined` explicitly: an internal component is spread
65
- * into, and `exactOptionalPropertyTypes` rejects a possibly-undefined member on a bare optional.
66
- */
67
- readonly options?: readonly FilterOption[] | undefined
68
- /** Pill text for a value no rendered option matches, ahead of `label` — the name `.labels()` gave
69
- * an unset state that is deliberately not a row (`NumberFilter`'s preset form). */
70
- readonly unmatchedLabel?: string | undefined
71
- /**
72
- * Mono pill label — forwarded to `FilterPill.numeric`. Set by `NumberFilter`, whose values ARE
73
- * numbers (`1` / `2` / `7`), and by nothing else: the same law `[data-numeric]` applies to a
74
- * numeric SegmentedControl label. A word-valued filter never sets it.
75
- */
76
- readonly numeric?: boolean | undefined
77
- }
56
+ export type EnumFilterProps<T extends string> = BasaltProps &
57
+ FilterBase & {
58
+ readonly field: ChoiceHandle<T>
59
+ readonly label: string
60
+ /**
61
+ * Overrides `field.options` at render — a runtime catalogue whose labels carry live data, or the
62
+ * only row source a `StringField` has. `| undefined` explicitly: an internal component is spread
63
+ * into, and `exactOptionalPropertyTypes` rejects a possibly-undefined member on a bare optional.
64
+ */
65
+ readonly options?: readonly FilterOption[] | undefined
66
+ /** Pill text for a value no rendered option matches, ahead of `label` — the name `.labels()` gave
67
+ * an unset state that is deliberately not a row (`NumberFilter`'s preset form). */
68
+ readonly unmatchedLabel?: string | undefined
69
+ /**
70
+ * Mono pill label — forwarded to `FilterPill.numeric`. Set by `NumberFilter`, whose values ARE
71
+ * numbers (`1` / `2` / `7`), and by nothing else: the same law `[data-numeric]` applies to a
72
+ * numeric SegmentedControl label. A word-valued filter never sets it.
73
+ */
74
+ readonly numeric?: boolean | undefined
75
+ }
78
76
 
79
77
  export function EnumFilter<T extends string>({
80
78
  field,
81
79
  label,
82
80
  icon,
83
81
  clearable,
82
+ disabled,
84
83
  numeric,
85
84
  options: optionsProp,
86
85
  unmatchedLabel,
@@ -90,9 +89,10 @@ export function EnumFilter<T extends string>({
90
89
  const [value, setValue] = field.use()
91
90
  const surface = useFilterSurface()
92
91
  const isDefault = field.isDefault(value)
93
- useFilterRegistration(!isDefault, () => {
92
+ const clearFilter = (): void => {
94
93
  field.clear()
95
- })
94
+ }
95
+ useFilterRegistration(!isDefault, clearFilter)
96
96
 
97
97
  // The prop wins whole, never merged: a catalogue that has dropped a value must be able to drop
98
98
  // its row, which a merge with `field.options` would silently put back.
@@ -123,6 +123,7 @@ export function EnumFilter<T extends string>({
123
123
  value={value}
124
124
  options={options}
125
125
  {...(numeric === true && { numeric: true })}
126
+ {...(disabled === true && { disabled: true })}
126
127
  onChange={(next) => {
127
128
  // Rendered from `options` — the cast restores what the codec already guarantees.
128
129
  setValue(next as T)
@@ -161,7 +162,7 @@ export function EnumFilter<T extends string>({
161
162
  />
162
163
  ))}
163
164
  </Stack>
164
- {clearable === true && !isDefault && <FilterClearButton onClear={() => field.clear()} />}
165
+ {clearable === true && !isDefault && <FilterClearButton onClear={clearFilter} />}
165
166
  </Radio.Group>
166
167
  )
167
168
 
@@ -170,6 +171,7 @@ export function EnumFilter<T extends string>({
170
171
  label={selected?.label ?? unmatchedLabel ?? label}
171
172
  active={!isDefault}
172
173
  {...(numeric === true && { numeric: true })}
174
+ {...(disabled === true && { disabled: true })}
173
175
  {...(icon !== undefined && { icon })}
174
176
  {...(className !== undefined && { className })}
175
177
  {...(style !== undefined && { style })}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * The prop and option shapes every filter shares (`docs/CONTROLS-SPEC.md` §3). INTERNAL — the
3
+ * filters re-state their own props from these, so a new member lands on the whole family at once.
4
+ */
5
+ import type { ReactNode } from 'react'
6
+
7
+ /**
8
+ * What every filter takes besides its `field`. A filter picks the members that mean something to it
9
+ * (`Omit<FilterBase, 'clearable'>` for a toggle) and tightens `label` to required where no sensible
10
+ * default exists — a store field declares no name of its own, only its VALUES' labels.
11
+ */
12
+ export type FilterBase = {
13
+ /** The popover/sheet heading and the accessible name — never the pill text, which reads the VALUE. */
14
+ readonly label?: string
15
+ /** Leading pill icon. */
16
+ readonly icon?: ReactNode
17
+ /** Adds a `Clear` action that clears the field — the same `field.clear()` `Reset all` calls. */
18
+ readonly clearable?: boolean
19
+ /** Renders the control inert: a pill that will not open, a row that will not edit. */
20
+ readonly disabled?: boolean
21
+ }
22
+
23
+ /**
24
+ * One row of any option list. `disabled` renders the row and refuses the selection — a live
25
+ * catalogue cannot leave an archived value out, because rows already pointing at it still label it.
26
+ */
27
+ export type FilterOption<V extends string | number = string> = {
28
+ readonly value: V
29
+ readonly label: string
30
+ readonly disabled?: boolean
31
+ }
@@ -41,6 +41,8 @@ export type FilterPillProps = BasaltProps & {
41
41
  * where `aria-expanded` (which Mantine's `Popover.Target` supplies) is the correct state.
42
42
  */
43
43
  readonly pressed?: boolean
44
+ /** Inert: the pill cannot be pressed, so its popover never opens. */
45
+ readonly disabled?: boolean
44
46
  /** Set by `FilterSet` on its own fold/sheet pills; a filter never passes either of these. */
45
47
  readonly hideGlyph?: boolean
46
48
  /** `data-shown` — the CSS hook that reveals the `+N` fold pill once folding is needed. */
@@ -56,6 +58,7 @@ export function FilterPill({
56
58
  onClick,
57
59
  ariaLabel,
58
60
  pressed,
61
+ disabled,
59
62
  className,
60
63
  style,
61
64
  hideGlyph,
@@ -79,6 +82,7 @@ export function FilterPill({
79
82
  {...(ariaLabel !== undefined && { 'aria-label': ariaLabel })}
80
83
  {...(pressed !== undefined && children === undefined && { 'aria-pressed': pressed })}
81
84
  {...(shown === true && { 'data-shown': true })}
85
+ {...(disabled === true && { disabled: true })}
82
86
  {...(icon !== undefined && {
83
87
  // `IconSlot` owns the 16px box and the optical centring; `.pillIcon` adds only the pill's
84
88
  // muted-then-ink colour law. A consumer's glyph can no longer set this row's height.
@@ -18,7 +18,6 @@
18
18
  * hand would own a second, unregistered filter home (C1).
19
19
  */
20
20
  import { Button, Drawer } from '@mantine/core'
21
- import { useId } from 'react'
22
21
  import type { ReactNode } from 'react'
23
22
  import type { BasaltProps } from '../common/props'
24
23
  import classes from './controls.module.css'
@@ -78,58 +77,3 @@ export function FilterSheet({
78
77
  </Drawer>
79
78
  )
80
79
  }
81
-
82
- /**
83
- * The selected-row mark — 16px, drawn at the row's trailing edge (`docs/CONTROLS-SPEC.md` §2.1).
84
- * Exported from the MODULE, not from `./index.ts`: the panel surface's facet list draws the same
85
- * mark at the same edge, and two hand-drawn checks would drift.
86
- */
87
- export function CheckGlyph(): ReactNode {
88
- return (
89
- <svg
90
- width={16}
91
- height={16}
92
- viewBox="0 0 24 24"
93
- fill="none"
94
- stroke="currentColor"
95
- strokeWidth={2.25}
96
- strokeLinecap="round"
97
- strokeLinejoin="round"
98
- aria-hidden
99
- >
100
- <path d="M5 12.5l5 5l9 -11" />
101
- </svg>
102
- )
103
- }
104
-
105
- /**
106
- * Names a control that has no VISIBLE Mantine `label`, and does it differently per surface — which
107
- * is the whole reason this is one helper instead of an `aria-label` sprinkled per call site.
108
- *
109
- * In the SHEET and the PANEL the visible `PanelRow` heading is right there, so the control points
110
- * at it (`aria-labelledby`) and the heading stops being decoration. In the PILL surface there is no
111
- * visible name to point at — the pill text is the VALUE (`EUR`, `30d`, `3 channels`) — so the
112
- * control carries the filter's own name instead. Either way the announced name is what is being
113
- * filtered, not what it currently holds.
114
- *
115
- * The id is generated by the CONTROL, not by `PanelRow`, because the control renders its own
116
- * `PanelRow`: an id published downward through context could never reach the sibling that needs it.
117
- *
118
- * @example
119
- * const { labelId, nameProps } = useControlName(label, inSheet || inPanel)
120
- * <Radio.Group {...nameProps} …/>
121
- * // and, in the sheet/panel branch: <PanelRow label={label} labelId={labelId}>…</PanelRow>
122
- */
123
- export function useControlName(
124
- label: string,
125
- named: boolean,
126
- ): {
127
- labelId: string
128
- nameProps: { 'aria-labelledby': string } | { 'aria-label': string }
129
- } {
130
- const labelId = useId()
131
- return {
132
- labelId,
133
- nameProps: named ? { 'aria-labelledby': labelId } : { 'aria-label': label },
134
- }
135
- }
@@ -17,7 +17,17 @@ import type { ReactNode } from 'react'
17
17
  const ICON_SIZE = 16
18
18
  const AFFORDANCE_SIZE = 14
19
19
 
20
- function Stroke({ size = ICON_SIZE, children }: { size?: number; children: ReactNode }): ReactNode {
20
+ function Stroke({
21
+ size = ICON_SIZE,
22
+ strokeWidth = 1.75,
23
+ className,
24
+ children,
25
+ }: {
26
+ size?: number
27
+ strokeWidth?: number
28
+ className?: string | undefined
29
+ children: ReactNode
30
+ }): ReactNode {
21
31
  return (
22
32
  <svg
23
33
  width={size}
@@ -25,7 +35,8 @@ function Stroke({ size = ICON_SIZE, children }: { size?: number; children: React
25
35
  viewBox="0 0 24 24"
26
36
  fill="none"
27
37
  stroke="currentColor"
28
- strokeWidth={1.75}
38
+ strokeWidth={strokeWidth}
39
+ {...(className !== undefined && { className })}
29
40
  strokeLinecap="round"
30
41
  strokeLinejoin="round"
31
42
  aria-hidden
@@ -69,3 +80,35 @@ export function UpDownGlyph(): ReactNode {
69
80
  </Stroke>
70
81
  )
71
82
  }
83
+
84
+ /**
85
+ * The selected-row mark — 16px, drawn at the row's trailing edge (`docs/CONTROLS-SPEC.md` §2.1).
86
+ * Shared by the facet list and any other row that marks a selection at its trailing edge, so two
87
+ * hand-drawn checks cannot drift.
88
+ */
89
+ export function CheckGlyph(): ReactNode {
90
+ return (
91
+ <Stroke strokeWidth={2.25}>
92
+ <path d="M5 12.5l5 5l9 -11" />
93
+ </Stroke>
94
+ )
95
+ }
96
+
97
+ /** `SearchFilter`'s leading icon. */
98
+ export function SearchGlyph(): ReactNode {
99
+ return (
100
+ <Stroke strokeWidth={2}>
101
+ <circle cx="11" cy="11" r="7" />
102
+ <path d="M21 21l-4.35 -4.35" />
103
+ </Stroke>
104
+ )
105
+ }
106
+
107
+ /** `SyncButton`'s icon; the caller owns the spin class, which lives in its own stylesheet. */
108
+ export function RefreshGlyph({ className }: { className?: string | undefined }): ReactNode {
109
+ return (
110
+ <Stroke strokeWidth={2} className={className}>
111
+ <path d="M20 11a8 8 0 1 0-2.34 5.66M20 5v6h-6" />
112
+ </Stroke>
113
+ )
114
+ }
@@ -10,11 +10,12 @@ export { SyncButton } from './sync-button'
10
10
  // `FilterPill`, `FilterSheet` and the `EnumFilter` body are deliberately NOT here: reaching for
11
11
  // them is hand-rolling a filter (`basalt/hand-rolled-filter`).
12
12
  export { FilterSet } from './filter-set'
13
- export { RangeFilter } from './range-filter'
13
+ export { RangeFilter, type RangeCustomPickerProps } from './range-filter'
14
14
  export { SelectFilter } from './select-filter'
15
15
  export { MultiSelectFilter } from './multi-select-filter'
16
16
  export { NumberFilter } from './number-filter'
17
17
  export { SearchFilter } from './search-filter'
18
18
  export { ToggleFilter } from './toggle-filter'
19
19
  export { ViewTabs } from './view-tabs'
20
+ export type { FilterOption } from './filter-base'
20
21
  export { FormRow, FormGroup } from './form-layout'