basalt-ui 2.13.2 → 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 (143) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/MIGRATING.md +40 -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/create-router.d.ts +9 -4
  85. package/dist/provider/create-router.d.ts.map +1 -1
  86. package/dist/provider/create-router.js +1 -19
  87. package/dist/provider/error-fallback.module.css +4 -15
  88. package/dist/provider/error-fallback.module.css.d.ts +0 -1
  89. package/dist/provider/fallback.module.css +37 -0
  90. package/dist/provider/fallback.module.css.d.ts +11 -0
  91. package/dist/provider/index.d.ts +13 -1
  92. package/dist/provider/index.d.ts.map +1 -1
  93. package/dist/provider/index.js +10 -1
  94. package/dist/provider/route-defaults.d.ts +10 -0
  95. package/dist/provider/route-defaults.d.ts.map +1 -0
  96. package/dist/provider/route-defaults.js +25 -0
  97. package/dist/provider/route-defaults.module.css +39 -0
  98. package/dist/provider/route-defaults.module.css.d.ts +10 -0
  99. package/llms.txt +35 -14
  100. package/package.json +1 -1
  101. package/src/agent/chat/thread-feed-row.tsx +2 -2
  102. package/src/agent/chat/thread-message.tsx +2 -2
  103. package/src/agent/chat/thread-outcome-card.tsx +2 -2
  104. package/src/charts/DualPanel.tsx +1 -0
  105. package/src/charts/compile.ts +3 -2
  106. package/src/charts/cursor.ts +44 -27
  107. package/src/charts/legend.tsx +9 -6
  108. package/src/charts/panel.tsx +3 -0
  109. package/src/commands/notifications/center.tsx +2 -14
  110. package/src/controls/control-name.ts +33 -0
  111. package/src/controls/enum-filter.tsx +29 -27
  112. package/src/controls/filter-base.ts +31 -0
  113. package/src/controls/filter-pill.tsx +4 -0
  114. package/src/controls/filter-sheet.tsx +0 -56
  115. package/src/controls/glyphs.tsx +45 -2
  116. package/src/controls/index.ts +2 -1
  117. package/src/controls/multi-select-filter.tsx +67 -43
  118. package/src/controls/number-filter.tsx +47 -47
  119. package/src/controls/panel-row.tsx +7 -8
  120. package/src/controls/range-filter.tsx +54 -78
  121. package/src/controls/search-filter.tsx +107 -54
  122. package/src/controls/select-filter.tsx +2 -18
  123. package/src/controls/sync-button.tsx +7 -40
  124. package/src/controls/toggle-filter.tsx +9 -7
  125. package/src/controls/view-tabs.tsx +41 -21
  126. package/src/format/date.ts +189 -36
  127. package/src/format/index.ts +12 -11
  128. package/src/format/measure.ts +29 -18
  129. package/src/format/number.ts +76 -37
  130. package/src/format/shared.ts +116 -25
  131. package/src/provider/create-router.tsx +2 -36
  132. package/src/provider/error-fallback.module.css +4 -15
  133. package/src/provider/error-fallback.module.css.d.ts +0 -1
  134. package/src/provider/fallback.module.css +37 -0
  135. package/src/provider/fallback.module.css.d.ts +11 -0
  136. package/src/provider/index.tsx +25 -1
  137. package/src/provider/route-defaults.module.css +39 -0
  138. package/src/provider/route-defaults.module.css.d.ts +10 -0
  139. package/src/provider/route-defaults.tsx +39 -0
  140. package/dist/agent/chat/relative-time.d.ts +0 -27
  141. package/dist/agent/chat/relative-time.d.ts.map +0 -1
  142. package/dist/agent/chat/relative-time.js +0 -27
  143. package/src/agent/chat/relative-time.ts +0 -55
package/llms.txt CHANGED
@@ -1,4 +1,4 @@
1
- # basalt-ui v2.13.2
1
+ # basalt-ui v2.14.0
2
2
  # Opinionated framework for Mantine-based React apps — theme, app shell, TanStack Charts, toolchain presets
3
3
  #
4
4
  # Entry points: use the exact import specifier below; do not guess.
@@ -13,7 +13,7 @@
13
13
  # A subpath's `Install:` line is its required peers; `OptionalPeers:` are import()-only, install on use.
14
14
 
15
15
  Package: basalt-ui
16
- Version: 2.13.2
16
+ Version: 2.14.0
17
17
 
18
18
  ## basalt-ui
19
19
  Import: import { ... } from 'basalt-ui'
@@ -32,6 +32,8 @@ Signature: BasaltProvider(props: BasaltProviderProps): JSX.Element
32
32
  sizeClassHint?: "compact" | "medium" | "expanded"
33
33
  navCommandLabel?: (item: FlatNavItem) => string
34
34
  spotlight?: boolean
35
+ locale?: string
36
+ timeZone?: string
35
37
  router: BasaltRouter
36
38
  children: ReactNode
37
39
  Signature: BasaltShell(props: BasaltShellProps<G, T>): JSX.Element
@@ -516,13 +518,23 @@ OptionalPeers: vite-plugin-pwa@^1.3.0
516
518
  Import: import { ... } from 'basalt-ui/format'
517
519
  Description: integer/money/percent/durationClock/relativeTime/weekday/km/kcal — Intl-backed, Mantine-free, React-free formatting; the chart layer formats through the same implementation
518
520
  Layer: headless
521
+ Signature: bytes(value: Numeric, options: BytesOptions): string
522
+ Signature: compact(value: Numeric, options: CompactOptions): string
523
+ Signature: date(value: DateInput, options: DateOptions): string
524
+ Signature: dateTime(value: DateInput, options: DateOptions): string
525
+ Signature: defineFormat(next: FormatDefaults): void
526
+ locale?: string
527
+ timeZone?: string
528
+ Signature: delta(value: Numeric, options: DeltaOptions): string
529
+ Signature: duration(seconds: number | null | undefined, options: DurationOptions): string
519
530
  Signature: durationClock(seconds: number): string
520
- Signature: integer(value: number, options: LocaleOption): string
521
- Signature: kcal(value: number, options: KcalOptions): string
522
- Signature: km(meters: number, options: KmOptions): string
523
- Signature: money(value: number, options: FmtCurrencyOptions): string
524
- Signature: percent(value: number, options: FmtPercentOptions): string
525
- Signature: relativeTime(value: string | number | Date, options: RelativeTimeOptions): string
531
+ Signature: integer(value: Numeric, options: LocaleOption): string
532
+ Signature: kcal(value: Numeric, options: KcalOptions): string
533
+ Signature: km(meters: Numeric, options: KmOptions): string
534
+ Signature: money(value: Numeric, options: MoneyOptions): string
535
+ Signature: percent(value: Numeric, options: PercentOptions): string
536
+ Signature: relativeTime(value: DateInput, options: RelativeTimeOptions): string
537
+ Signature: time(value: DateInput, options: DateOptions): string
526
538
  Signature: weekday(value: string | number | Date, options: WeekdayOptions): string
527
539
 
528
540
  ## basalt-ui/forms
@@ -809,9 +821,11 @@ Signature: MultiSelectFilter(props: MultiSelectFilterProps<T>): ReactNode
809
821
  value?: never
810
822
  onChange?: never
811
823
  size?: never
812
- field: FieldHandle<MultiField<T>>
813
824
  label: string
814
825
  icon?: ReactNode
826
+ clearable?: boolean
827
+ disabled?: boolean
828
+ field: FieldHandle<MultiField<T>>
815
829
  noun?: string
816
830
  options?: readonly FilterOption[]
817
831
  counts?: Record<string, number>
@@ -822,21 +836,23 @@ Signature: NumberFilter(props: NumberFilterProps): ReactNode
822
836
  value?: never
823
837
  onChange?: never
824
838
  size?: never
825
- field: FieldHandle<NumberField>
826
839
  label: string
827
840
  icon?: ReactNode
828
- options?: readonly NumberFilterOption[]
829
- step?: number
830
841
  clearable?: boolean
842
+ disabled?: boolean
843
+ field: FieldHandle<NumberField>
844
+ options?: readonly FilterOption<number>[]
845
+ step?: number
831
846
  Signature: RangeFilter(props: RangeFilterProps<P, C>): ReactNode
832
847
  className?: string
833
848
  style?: CSSProperties
834
849
  value?: never
835
850
  onChange?: never
836
851
  size?: never
837
- field: FieldHandle<RangeField<P, C>>
838
852
  icon?: ReactNode
853
+ disabled?: boolean
839
854
  label?: string
855
+ field: FieldHandle<RangeField<P, C>>
840
856
  customPicker?: ComponentType<RangeCustomPickerProps>
841
857
  Signature: SearchFilter(props: SearchFilterProps): ReactNode
842
858
  className?: string
@@ -844,9 +860,11 @@ Signature: SearchFilter(props: SearchFilterProps): ReactNode
844
860
  value?: never
845
861
  onChange?: never
846
862
  size?: never
863
+ disabled?: boolean
847
864
  field: FieldHandle<StringField>
848
865
  placeholder?: string
849
866
  label?: string
867
+ clearable?: boolean
850
868
  Signature: SelectFilter(props: SelectFilterEnumProps<T>): ReactNode
851
869
  className?: string
852
870
  style?: CSSProperties
@@ -856,6 +874,7 @@ Signature: SelectFilter(props: SelectFilterEnumProps<T>): ReactNode
856
874
  label: string
857
875
  icon?: ReactNode
858
876
  clearable?: boolean
877
+ disabled?: boolean
859
878
  field: FieldHandle<EnumField<T>>
860
879
  options?: readonly FilterOption[]
861
880
  Signature: SyncButton(props: SyncButtonProps): ReactNode
@@ -873,15 +892,17 @@ Signature: ToggleFilter(props: ToggleFilterProps): ReactNode
873
892
  value?: never
874
893
  onChange?: never
875
894
  size?: never
876
- field: FieldHandle<BooleanField>
877
895
  label: string
878
896
  icon?: ReactNode
897
+ disabled?: boolean
898
+ field: FieldHandle<BooleanField>
879
899
  Signature: ViewTabs(props: ViewTabsProps<T>): ReactNode
880
900
  className?: string
881
901
  style?: CSSProperties
882
902
  value?: never
883
903
  onChange?: never
884
904
  size?: never
905
+ disabled?: boolean
885
906
  field: FieldHandle<EnumField<T>>
886
907
  options?: readonly ViewTabsOption<T>[]
887
908
  label?: string
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "basalt-ui",
3
- "version": "2.13.2",
3
+ "version": "2.14.0",
4
4
  "description": "Opinionated framework for Mantine-based React apps — theme, app shell, TanStack Charts, toolchain presets",
5
5
  "keywords": [
6
6
  "charts",
@@ -43,11 +43,11 @@ import { BasaltStickToBottom } from '../stick-to-bottom'
43
43
  import { cx } from '../../common/props'
44
44
  import type { BasaltProps, SlotStylesProps } from '../../common/props'
45
45
  import { assertRequiredProps } from '../../common/validate'
46
+ import { relativeTime } from '../../format'
46
47
  import { VX } from '../../tokens'
47
48
  import type { ComposerProps, ComposerSubmit } from './composer'
48
49
  import { Composer } from './composer'
49
50
  import type { MessageAffordances } from './message-affordances'
50
- import { formatRelativeTime } from './relative-time'
51
51
  import { ThreadTranscript } from './thread-message'
52
52
  import { resolveRowHeight } from './virtualize'
53
53
  import type { RowHeightProps, VirtualizeProps } from './virtualize'
@@ -309,7 +309,7 @@ export function ThreadFeedRow(props: ThreadFeedRowProps): JSX.Element {
309
309
  flexShrink: 0,
310
310
  }}
311
311
  >
312
- {formatRelativeTime(thread.updatedAt)}
312
+ {relativeTime(thread.updatedAt)}
313
313
  </Text>
314
314
  <ChevronGlyph expanded={expanded} />
315
315
  </Group>
@@ -53,10 +53,10 @@ import type { BasaltProps } from '../../common/props'
53
53
  import { assertRequiredProps } from '../../common/validate'
54
54
  import { Markdown } from '../../content/markdown'
55
55
  import { CopyAction } from '../../content/copy-action'
56
+ import { relativeTime } from '../../format'
56
57
  import { VX } from '../../tokens'
57
58
  import { DEFAULT_AFFORDANCES } from './message-affordances'
58
59
  import type { MessageAffordances } from './message-affordances'
59
- import { formatRelativeTime } from './relative-time'
60
60
  import { ToolChip } from './tool-chip'
61
61
  import { resolveVirtualize } from './virtualize'
62
62
  import type { VirtualizeOptions, VirtualizeProps } from './virtualize'
@@ -345,7 +345,7 @@ function MessageAffordanceRow({
345
345
  const timestampLabel =
346
346
  timestampMode === 'absolute'
347
347
  ? new Date(message.createdAt).toLocaleString()
348
- : formatRelativeTime(message.createdAt)
348
+ : relativeTime(message.createdAt)
349
349
 
350
350
  return (
351
351
  <Group
@@ -25,8 +25,8 @@ import type { AgentThread, ThreadStatus } from '../thread'
25
25
  import { assertRequiredProps } from '../../common/validate'
26
26
  import { cx } from '../../common/props'
27
27
  import type { BasaltProps } from '../../common/props'
28
+ import { relativeTime } from '../../format'
28
29
  import { alpha, VX } from '../../tokens'
29
- import { formatRelativeTime } from './relative-time'
30
30
 
31
31
  // ── Status badge — shown ONLY for states that need a glance (attention/error). ────
32
32
  // done/pending/streaming stay badge-free: a settled feed shouldn't be a wall of green chips —
@@ -113,7 +113,7 @@ function OutcomeBody({ thread }: { thread: AgentThread }): JSX.Element {
113
113
  <Text
114
114
  style={{ fontFamily: 'var(--basalt-font-mono)', fontSize: VX.text.micro, color: VX.faint }}
115
115
  >
116
- {formatRelativeTime(thread.updatedAt)}
116
+ {relativeTime(thread.updatedAt)}
117
117
  </Text>
118
118
  </Stack>
119
119
  )
@@ -321,6 +321,7 @@ export function DualPanel<T, X extends Date | number = Date | number>(
321
321
 
322
322
  return {
323
323
  keys: model.values,
324
+ extent: [lo - pad, hi + pad],
324
325
  top: topPane,
325
326
  bottom: barPane,
326
327
  topFraction,
@@ -23,7 +23,7 @@ import type {
23
23
  StoredChartSpec,
24
24
  } from '@tanstack/charts/types/core'
25
25
  import { SHORT_CHART_HEIGHT } from './box'
26
- import { fmtCompact } from '../format/number'
26
+ import { compact } from '../format/number'
27
27
  import { VX } from '../tokens'
28
28
  import type { ContainerClass } from '../tokens/size-classes'
29
29
  import { cursorBinding, followerOptions, quietWhileFollowing } from './cursor'
@@ -119,7 +119,7 @@ const labelsInside = (cls: ContainerClass, height: number): boolean =>
119
119
  cls === 'compact' && height > 0 && height < SHORT_CHART_HEIGHT
120
120
 
121
121
  export function defaultNumberFormat(v: number): string {
122
- return fmtCompact(v, { digits: Math.abs(v) >= 1000 ? 1 : 2 })
122
+ return compact(v, { digits: Math.abs(v) >= 1000 ? 1 : 2 })
123
123
  }
124
124
 
125
125
  const MONTHS = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
@@ -917,6 +917,7 @@ export function compileCartesian<T, X extends ChartX>(
917
917
  group: input.cursorGroup,
918
918
  chartId: input.chartId,
919
919
  keys: model.values,
920
+ extent: model.extent,
920
921
  mode: input.cursorResolution ?? 'nearest',
921
922
  pin: input.coarse === true,
922
923
  }),
@@ -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.