basalt-ui 2.6.1 → 2.7.1

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 (48) hide show
  1. package/AGENTS.md +15 -15
  2. package/CHANGELOG.md +26 -0
  3. package/MIGRATING.md +47 -12
  4. package/agent/rules/basalt-batteries.md +3 -3
  5. package/agent/rules/basalt-controls.md +3 -3
  6. package/agent/skills/basalt-app/SKILL.md +44 -0
  7. package/configs/oxlint-plugin.js +48 -0
  8. package/configs/oxlint-plugin.test.ts +82 -0
  9. package/dist/charts/DualPanel.d.ts +1 -1
  10. package/dist/charts/DualPanel.d.ts.map +1 -1
  11. package/dist/charts/DualPanel.js +2 -1
  12. package/dist/charts/legend.d.ts +9 -1
  13. package/dist/charts/legend.d.ts.map +1 -1
  14. package/dist/charts/legend.js +3 -2
  15. package/dist/commands/define-overlays.d.ts +5 -0
  16. package/dist/commands/define-overlays.d.ts.map +1 -1
  17. package/dist/commands/define-overlays.js +2 -0
  18. package/dist/commands/index.d.ts +4 -0
  19. package/dist/commands/index.d.ts.map +1 -1
  20. package/dist/commands/notifications/define-notifications.d.ts +3 -0
  21. package/dist/commands/notifications/define-notifications.d.ts.map +1 -1
  22. package/dist/controls/form-layout.d.ts +15 -6
  23. package/dist/controls/form-layout.d.ts.map +1 -1
  24. package/dist/forms/field.d.ts +42 -2
  25. package/dist/forms/field.d.ts.map +1 -1
  26. package/dist/forms/field.js +2 -2
  27. package/dist/forms/index.d.ts +4 -5
  28. package/dist/forms/index.d.ts.map +1 -1
  29. package/dist/surfaces.d.ts +2 -2
  30. package/dist/surfaces.js +2 -2
  31. package/dist/table/data-table.d.ts +37 -0
  32. package/dist/table/data-table.d.ts.map +1 -1
  33. package/dist/table/data-table.js +100 -17
  34. package/dist/table/index.d.ts +1 -0
  35. package/dist/table/index.d.ts.map +1 -1
  36. package/llms.txt +238 -5
  37. package/package.json +1 -1
  38. package/src/charts/DualPanel.tsx +5 -3
  39. package/src/charts/legend.tsx +16 -5
  40. package/src/commands/define-overlays.ts +5 -0
  41. package/src/commands/index.ts +4 -0
  42. package/src/commands/notifications/define-notifications.ts +3 -0
  43. package/src/controls/form-layout.tsx +15 -6
  44. package/src/forms/field.ts +78 -3
  45. package/src/forms/index.ts +4 -5
  46. package/src/surfaces.ts +2 -2
  47. package/src/table/data-table.tsx +175 -17
  48. package/src/table/index.ts +2 -0
package/llms.txt CHANGED
@@ -1,4 +1,4 @@
1
- # basalt-ui v2.6.1
1
+ # basalt-ui v2.7.1
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.6.1
16
+ Version: 2.7.1
17
17
 
18
18
  ## basalt-ui
19
19
  Import: import { ... } from 'basalt-ui'
@@ -54,16 +54,206 @@ Description: CartesianChart (the TanStack Charts rung), the Lines and Bars kinds
54
54
  Layer: headless
55
55
  Rule: basalt-charts
56
56
  Signature: BandStrip(props: BandStripProps<T, X>): ReactElement<unknown, string | JSXElementConstructor<any>>
57
+ className?: string
58
+ style?: CSSProperties
59
+ ariaLabel: string
60
+ data: readonly T[]
61
+ x: (d: T) => X
62
+ xTicks?: number | readonly X[]
63
+ formatX?: ((x: X) => string)
64
+ legend?: false | ChartLegendConfig
65
+ height?: number | ResponsiveChartHeight
66
+ state?: ChartState
67
+ cursorGroup?: string
68
+ cursorResolution?: CursorResolution
69
+ tooltip?: false | ChartTooltipConfig<T, X>
70
+ states: readonly BandStripSeries<T>[]
71
+ getBand: (d: T) => BandSpan
72
+ fold?: BandFold<T>
57
73
  Signature: Bars(props: BarsProps<T, X>): ReactElement<unknown, string | JSXElementConstructor<any>>
74
+ className?: string
75
+ style?: CSSProperties
76
+ ariaLabel: string
77
+ data: readonly T[]
78
+ x: (d: T) => X
79
+ y?: AxisConfig<T>
80
+ y2?: AxisConfig<T>
81
+ xTicks?: number | readonly X[]
82
+ formatX?: ((x: X) => string)
83
+ zones?: readonly ZoneSpec[]
84
+ xZones?: readonly XZoneSpec<X>[]
85
+ refLines?: readonly RefLine[]
86
+ legend?: false | ChartLegendConfig
87
+ height?: number | ResponsiveChartHeight
88
+ state?: ChartState
89
+ cursorGroup?: string
90
+ cursorResolution?: CursorResolution
91
+ tooltip?: false | ChartTooltipConfig<T, X>
92
+ bars: readonly BarsBar<T>[]
93
+ lines?: readonly BarsLine<T>[]
94
+ layout?: "stacked" | "grouped" | "normalized"
95
+ barOpacity?: ((d: T, key: string) => number)
58
96
  Signature: CartesianChart(props: CartesianChartProps<T, X>): ReactElement<unknown, string | JSXElementConstructor<any>>
97
+ className?: string
98
+ style?: CSSProperties
99
+ ariaLabel: string
100
+ data: readonly T[]
101
+ x: (d: T) => X
102
+ series: readonly ChartSeries<T>[]
103
+ marks: (plot: PlotContext<T, X>) => ChartMarks
104
+ y?: AxisConfig<T>
105
+ y2?: AxisConfig<T>
106
+ xTicks?: number | readonly X[]
107
+ formatX?: ((x: X) => string)
108
+ zones?: readonly ZoneSpec[]
109
+ xZones?: readonly XZoneSpec<X>[]
110
+ refLines?: readonly RefLine[]
111
+ legend?: false | ChartLegendConfig
112
+ height?: number | ResponsiveChartHeight
113
+ state?: ChartState
114
+ cursorGroup?: string
115
+ cursorResolution?: CursorResolution
116
+ tooltip?: false | ChartTooltipConfig<T, X>
59
117
  Signature: ChartCard(props: ChartCardProps): ReactElement<unknown, string | JSXElementConstructor<any>>
118
+ className?: string
119
+ style?: CSSProperties
120
+ classNames?: Partial<Record<ChartCardSlot, string>>
121
+ title?: string
122
+ icon?: ReactNode
123
+ subtitle?: string
124
+ info?: string
125
+ value?: string
126
+ delta?: number
127
+ deltaPeriod?: string
128
+ deltaPolarity?: DeltaPolarity
129
+ count?: number
130
+ actions?: ReactNode
131
+ state?: ChartState
132
+ placeholderHeight?: number | ResponsiveChartHeight
133
+ stateAction?: ReactNode
134
+ children?: ReactNode
60
135
  Signature: Donut(props: DonutProps<K>): ReactElement<unknown, string | JSXElementConstructor<any>>
136
+ className?: string
137
+ style?: CSSProperties
138
+ ariaLabel: string
139
+ data: readonly DonutDatum<K>[]
140
+ colorForKey: (key: K) => string
141
+ formatValue: (v: number) => string
142
+ seriesLabel?: ((key: K) => string)
143
+ centerLabel?: string
144
+ centerSubLabel?: string
145
+ height?: number | ResponsiveChartHeight
146
+ state?: ChartState
61
147
  Signature: DualPanel(props: DualPanelProps<T, X>): ReactElement<unknown, string | JSXElementConstructor<any>>
148
+ className?: string
149
+ style?: CSSProperties
150
+ ariaLabel: string
151
+ data: readonly T[]
152
+ x: (d: T) => X
153
+ formatX?: ((x: X) => string)
154
+ legend?: false | ChartLegendConfig
155
+ height?: number | ResponsiveChartHeight
156
+ state?: ChartState
157
+ cursorGroup?: string
158
+ cursorResolution?: CursorResolution
159
+ tooltip?: false | ChartTooltipConfig<T, X>
160
+ series: readonly DualPanelLine<T>[]
161
+ top?: { domain?: readonly [number, number] | "auto" | undefined; …
162
+ fillBetween?: { from: string; to: string; fill: string; aboveFill?: strin…
163
+ bar: DualPanelBar<T>
164
+ topFraction?: number
62
165
  Signature: Heatmap(props: HeatmapProps<T>): ReactElement<unknown, string | JSXElementConstructor<any>>
166
+ className?: string
167
+ style?: CSSProperties
168
+ ariaLabel: string
169
+ data: readonly T[]
170
+ getRow: (d: T) => string
171
+ getCol: (d: T) => string
172
+ getValue: (d: T) => number | null
173
+ rows?: readonly string[]
174
+ cols?: readonly string[]
175
+ color?: string
176
+ domain?: readonly [number, number]
177
+ formatValue?: ((v: number) => string)
178
+ formatRow?: ((row: string) => string)
179
+ formatCol?: ((col: string) => string)
180
+ legend?: false | { label?: string | undefined; }
181
+ tooltip?: false | { rows?: ((d: T) => readonly ChartTooltipRow[]) | u…
182
+ height?: number | ResponsiveChartHeight
183
+ matchHeight?: boolean
184
+ state?: ChartState
63
185
  Signature: Lines(props: LinesProps<T, X>): ReactElement<unknown, string | JSXElementConstructor<any>>
186
+ className?: string
187
+ style?: CSSProperties
188
+ ariaLabel: string
189
+ data: readonly T[]
190
+ x: (d: T) => X
191
+ series: readonly ChartSeries<T>[]
192
+ y?: AxisConfig<T>
193
+ y2?: AxisConfig<T>
194
+ xTicks?: number | readonly X[]
195
+ formatX?: ((x: X) => string)
196
+ zones?: readonly ZoneSpec[]
197
+ xZones?: readonly XZoneSpec<X>[]
198
+ refLines?: readonly RefLine[]
199
+ legend?: false | ChartLegendConfig
200
+ height?: number | ResponsiveChartHeight
201
+ state?: ChartState
202
+ cursorGroup?: string
203
+ cursorResolution?: CursorResolution
204
+ tooltip?: false | ChartTooltipConfig<T, X>
205
+ thresholds?: [X] extends [string] ? never : readonly Threshold[]
64
206
  Signature: MirroredBars(props: MirroredBarsProps<T, X>): ReactElement<unknown, string | JSXElementConstructor<any>>
207
+ className?: string
208
+ style?: CSSProperties
209
+ ariaLabel: string
210
+ data: readonly T[]
211
+ x: (d: T) => X
212
+ formatX?: ((x: X) => string)
213
+ legend?: false | ChartLegendConfig
214
+ height?: number | ResponsiveChartHeight
215
+ state?: ChartState
216
+ cursorGroup?: string
217
+ tooltip?: false | ChartTooltipConfig<T, X>
218
+ series: readonly MirroredBarsSeries<T>[]
219
+ up: MirroredBarPane
220
+ down: MirroredBarPane
221
+ upFraction?: number
222
+ getAbsentFraction?: ((d: T) => number)
223
+ getBarOpacity?: ((d: T) => number)
224
+ fold?: { minBandPx?: number | undefined; merge: (group: T[]) => T;…
225
+ cursorResolution?: CursorResolution
65
226
  Signature: Sparkline(props: SparklineProps): ReactElement<unknown, string | JSXElementConstructor<any>>
227
+ className?: string
228
+ style?: CSSProperties
229
+ ariaLabel: string
230
+ data: readonly number[]
231
+ height: number
232
+ width?: number
233
+ mark?: "line" | "bar"
234
+ color?: string
235
+ emphasizeLast?: boolean
236
+ emphasisColor?: string
237
+ state?: ChartState
66
238
  Signature: StackedArea(props: StackedAreaProps<T, X>): ReactElement<unknown, string | JSXElementConstructor<any>>
239
+ className?: string
240
+ style?: CSSProperties
241
+ ariaLabel: string
242
+ data: readonly T[]
243
+ x: (d: T) => X
244
+ xTicks?: number | readonly X[]
245
+ formatX?: ((x: X) => string)
246
+ zones?: readonly ZoneSpec[]
247
+ xZones?: readonly XZoneSpec<X>[]
248
+ refLines?: readonly RefLine[]
249
+ legend?: false | ChartLegendConfig
250
+ height?: number | ResponsiveChartHeight
251
+ state?: ChartState
252
+ cursorGroup?: string
253
+ cursorResolution?: CursorResolution
254
+ tooltip?: false | ChartTooltipConfig<T, X>
255
+ series: readonly StackedAreaBand<T>[]
256
+ y?: Omit<AxisConfig<T>, "scale">
67
257
  Signature: chartCursor(group: string): ChartCursorController<ChartValue, ChartValue>
68
258
  Signature: chartCurve(name: CurveName): ChartCurve
69
259
  Install: bun add @tanstack/charts@1.1.0 d3-scale@4.0.2
@@ -113,13 +303,15 @@ Description: Mantine form layer: useBasaltForm + inputProps/fieldKey (two calls
113
303
  Layer: mantine-coupled
114
304
  Rule: basalt-batteries
115
305
  Signature: fieldKey(form: UseFormReturnType<Values>, path: Path): string
116
- Signature: inputProps(form: UseFormReturnType<Values>, path: Path): GetInputPropsReturnType
306
+ Signature: inputProps(form: UseFormReturnType<Values>, path: Path): InputProps
117
307
  Signature: useBasaltForm(opts: UseBasaltFormOptions<Values>): UseFormReturnType<Values>
308
+ mode?: "controlled" | "uncontrolled"
309
+ schema?: StandardSchemaV1<unknown, Values>
118
310
  Install: bun add @mantine/form@^9.7.0
119
311
 
120
312
  ## basalt-ui/commands
121
313
  Import: import { ... } from 'basalt-ui/commands'
122
- Description: defineCommands (typed command bus), defineOverlays/overlays, setColorScheme, toggleSidebar, ShortcutsHelp, defineNotifications/emit/NotificationBell (folded in from ./notifications); BasaltProvider mounts Spotlight, Modals and Notifications
314
+ Description: defineCommands (typed command bus), defineOverlays/overlays (a form dialog is a registered overlay opened with overlays.open), setColorScheme, toggleSidebar, ShortcutsHelp, defineNotifications/emit/NotificationBell (emit only accepts kinds registered in defineNotifications; folded in from ./notifications); BasaltProvider mounts Spotlight, Modals and Notifications
123
315
  Layer: mantine-coupled
124
316
  Rule: basalt-batteries
125
317
  Signature: NotificationBell(props: NotificationBellProps): JSX.Element
@@ -139,6 +331,47 @@ Description: BasaltDataTable and createColumnHelper: a data table over TanStack
139
331
  Layer: mantine-coupled
140
332
  Rule: basalt-batteries
141
333
  Signature: BasaltDataTable(props: BasaltDataTableProps<T>): JSX.Element
334
+ className?: string
335
+ style?: CSSProperties
336
+ classNames?: Partial<Record<BasaltDataTableSlot, string>>
337
+ title?: string
338
+ icon?: ReactNode
339
+ subtitle?: string
340
+ data: T[]
341
+ columns: BasaltColumnDef<T>[]
342
+ enableSorting?: boolean
343
+ manualSorting?: boolean
344
+ striped?: boolean | "odd" | "even"
345
+ highlightOnHover?: boolean
346
+ emptyState?: ReactNode
347
+ isLoading?: boolean
348
+ query?: QueryStateLike<unknown>
349
+ skeletonRows?: number
350
+ initialSorting?: SortingState
351
+ onSortingChange?: (sorting: SortingState) => void
352
+ enableGlobalFilter?: boolean
353
+ globalFilterPlaceholder?: string
354
+ searchIcon?: ReactNode
355
+ initialGlobalFilter?: string
356
+ onGlobalFilterChange?: (value: string) => void
357
+ facets?: DataTableFacet<T>[]
358
+ onColumnFiltersChange?: (filters: ColumnFiltersState) => void
359
+ manualFiltering?: boolean
360
+ actions?: SlotActions
361
+ onRowActivate?: (row: T) => void
362
+ renderCard?: (row: T) => ReactNode
363
+ enableRowSelection?: boolean
364
+ rowSelection?: RowSelectionState
365
+ onRowSelectionChange?: (selection: RowSelectionState) => void
366
+ getRowId?: (row: T, index: number) => string
367
+ bulkActions?: (rows: T[]) => BarAction[]
368
+ rowActions?: DataTableRowAction<T>[]
369
+ rowLabel?: (row: T) => string
370
+ enablePagination?: boolean
371
+ pageSizeOptions?: number[]
372
+ initialPagination?: PaginationState
373
+ onPaginationChange?: (pagination: PaginationState) => void
374
+ … +13 more
142
375
  Signature: createColumnHelper(): ColumnHelper<{ rowSortingFeature: TableFeature; columnFilteringFeatur…
143
376
  Install: bun add @tanstack/react-table@9.2.8
144
377
 
@@ -176,7 +409,7 @@ OptionalPeers: shiki@^4.5.0, @shikijs/langs@^4.5.0, @shikijs/themes@^4.5.0, beau
176
409
 
177
410
  ## basalt-ui/controls
178
411
  Import: import { ... } from 'basalt-ui/controls'
179
- Description: The control tier (docs/CONTROLS-SPEC.md §3): FilterSet (nowrap row + measured +N fold + the mobile Filters (n) sheet), RangeFilter/CompareFilter/SelectFilter/MultiSelectFilter/NumberFilter/SearchFilter/ToggleFilter (each bound to a FieldHandle — no value/onChange/size, law C2/C5; NumberFilter is the field.number lane, a radio list over `options` or a stepper without), ViewTabs, the action/sync family (ActionGroup, OverflowMenu, SyncButton, BarAction/GlobalAction), and the form layout FormSection/FormRow/FormGroup/FormActions (moved here from ./forms in 1.36.0 — FormRow is law C1’s form row and needs no @mantine/form). THREE surfaces, picked by the home and never by a prop (useFilterSurface): pill in a PageBar row, sheet in the mobile Filters (n) drawer, panel in a PageAside body — where every control renders an inspector/facet ROW instead of a chip (docs/ASIDE-SPEC.md §3). PanelRow is that row primitive (label above, hint, mono readout, an `end` control on the label line) and SliderControl is the one bound control with no pill form at all; the counts/max props on MultiSelectFilter render the Foundry facet list there. Every control owns its own desktop/mobile swap in CSS (C9) and renders size="ctl" internally. Resolves and renders with NO @mantine/dates installed — the custom date picker is injected through RangeFilter.customPicker from ./controls-dates.
412
+ Description: The control tier (docs/CONTROLS-SPEC.md §3). Exports: `FilterSet` (nowrap row + measured +N fold + the mobile Filters (n) sheet), `RangeFilter`/`SelectFilter`/`MultiSelectFilter`/`NumberFilter`/`SearchFilter`/`ToggleFilter` (each bound to a FieldHandle — no value/onChange/size, law C2/C5; `NumberFilter` is the field.number lane, a radio list over `options` or a stepper without), `ViewTabs`, `SyncButton` with the `BarAction`/`GlobalAction` types, and the form layout `FormRow`/`FormGroup` (moved here from ./forms in 1.36.0 — `FormRow` is law C1’s form row and needs no @mantine/form). THREE surfaces, picked by the home and never by a prop: pill in a PageBar row, sheet in the mobile Filters (n) drawer, panel in a PageAside body — where every control renders an inspector/facet ROW instead of a chip (docs/ASIDE-SPEC.md §3); the counts/max props on `MultiSelectFilter` render the Foundry facet list there. Every control owns its own desktop/mobile swap in CSS (C9) and renders size="ctl" internally. Resolves and renders with NO @mantine/dates installed — the custom date picker is injected through RangeFilter.customPicker from ./controls-dates.
180
413
  Layer: mantine-coupled
181
414
  Rule: basalt-controls
182
415
  Signature: FilterSet(props: FilterSetProps): ReactNode
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "basalt-ui",
3
- "version": "2.6.1",
3
+ "version": "2.7.1",
4
4
  "description": "Opinionated framework for Mantine-based React apps — theme, app shell, TanStack Charts, toolchain presets",
5
5
  "keywords": [
6
6
  "charts",
@@ -18,6 +18,7 @@ import { defaultFormatX, defaultNumberFormat, engineRow, seriesRow, visibleSerie
18
18
  import { barMark, emphasis, lineMark, markersOf, thinFill } from './marks'
19
19
  import { PanelRung, chartHeightOf, paneX, paneY, rowsOf } from './panel'
20
20
  import type { PaneBuilder, PanelInput, PanelPlan } from './panel'
21
+ import type { SignedSeries } from './legend'
21
22
  import { xScaleFor } from './scales'
22
23
  import { rowX } from './types'
23
24
  import type { CartesianChartProps, ChartSeries, PlotContext, PlotRow } from './types'
@@ -57,7 +58,7 @@ export type DualPanelLine<T> = Pick<
57
58
  export type DualPanelBar<T> = {
58
59
  label: string
59
60
  getValue: (d: T) => number | null
60
- /** The fill above zero, and the legend swatch. */
61
+ /** The fill above zero; the legend swatch splits positive | negative (one entry, one toggle). */
61
62
  positive: string
62
63
  /** The fill below zero. */
63
64
  negative: string
@@ -149,15 +150,16 @@ export function DualPanel<T, X extends Date | number = Date | number>(
149
150
  () => series.map((s) => ({ ...s, mark: 'line' as const })),
150
151
  [series],
151
152
  )
152
- const barSeries = useMemo<ChartSeries<T>>(
153
+ const barSeries = useMemo<SignedSeries<T>>(
153
154
  () => ({
154
155
  key: BAR_KEY,
155
156
  label: bar.label,
156
157
  color: bar.positive,
158
+ colorNegative: bar.negative,
157
159
  mark: 'bar',
158
160
  getValue: bar.getValue,
159
161
  }),
160
- [bar.label, bar.positive, bar.getValue],
162
+ [bar.label, bar.positive, bar.negative, bar.getValue],
161
163
  )
162
164
  const all = useMemo(() => [...lines, barSeries], [lines, barSeries])
163
165
  const topFormat = top?.format ?? defaultNumberFormat
@@ -69,11 +69,22 @@ const buttonStyle: CSSProperties = {
69
69
  }
70
70
  const noteStyle: CSSProperties = { color: VX.axis }
71
71
 
72
+ /**
73
+ * A legend entry that may be a sign-coloured bar: `colorNegative` is the below-zero colour and the
74
+ * swatch splits `color` | `colorNegative`. Only `DualPanel`'s bar sets it; the entry stays one
75
+ * toggle, so the sign halves hide together.
76
+ */
77
+ export type SignedSeries<T> = ChartSeries<T> & { colorNegative?: string | undefined }
78
+
72
79
  type SwatchStyle = Pick<
73
- ChartSeries<never>,
74
- 'color' | 'mark' | 'dash' | 'strokeOpacity' | 'fillOpacity'
80
+ SignedSeries<never>,
81
+ 'color' | 'colorNegative' | 'mark' | 'dash' | 'strokeOpacity' | 'fillOpacity'
75
82
  >
76
83
 
84
+ /** A swatch fill: the series colour, or a hard-stop split for a sign-coloured bar. */
85
+ const swatchFill = (s: SwatchStyle): string =>
86
+ s.colorNegative ? `linear-gradient(90deg, ${s.color} 50%, ${s.colorNegative} 50%)` : s.color
87
+
77
88
  function Swatch({ s, mode }: { s: SwatchStyle; mode: LegendMode }): ReactElement {
78
89
  if (mode === 'auto')
79
90
  return (
@@ -92,7 +103,7 @@ function Swatch({ s, mode }: { s: SwatchStyle; mode: LegendMode }): ReactElement
92
103
  height: 8,
93
104
  // theme-allow raw-surface — a legend dot is a circle, not a surface corner
94
105
  borderRadius: '50%',
95
- background: s.color,
106
+ background: swatchFill(s),
96
107
  opacity: s.fillOpacity ?? 1,
97
108
  flex: 'none',
98
109
  }}
@@ -123,7 +134,7 @@ function Swatch({ s, mode }: { s: SwatchStyle; mode: LegendMode }): ReactElement
123
134
  height: 10,
124
135
  // theme-allow raw-surface — swatch geometry, not a surface corner
125
136
  borderRadius: 2,
126
- background: s.color,
137
+ background: swatchFill(s),
127
138
  opacity: s.fillOpacity ?? 1,
128
139
  flex: 'none',
129
140
  }}
@@ -132,7 +143,7 @@ function Swatch({ s, mode }: { s: SwatchStyle; mode: LegendMode }): ReactElement
132
143
  }
133
144
 
134
145
  export type ChartLegendProps<T> = {
135
- series: readonly ChartSeries<T>[]
146
+ series: readonly SignedSeries<T>[]
136
147
  hidden: ReadonlySet<string>
137
148
  mode: LegendMode
138
149
  groups: boolean
@@ -5,6 +5,9 @@
5
5
  * `overlays` imperative controller — unknown keys are tsc errors. The type slot gives the
6
6
  * compile-time key union; the module-level stash gives the runtime values.
7
7
  *
8
+ * A form dialog is an entry whose `render` returns the form; open it from a row action with
9
+ * `overlays.open('id', props)` and put its component in a `*-modal.tsx`.
10
+ *
8
11
  * Uses @mantine/modals under the hood. ModalsProvider must be mounted (BasaltProvider does this).
9
12
  *
10
13
  * @example
@@ -338,6 +341,8 @@ export const overlays = {
338
341
  * Open a registered overlay by key. Resolves the Overlay spec from the runtime stash and calls
339
342
  * modals.open() with the rendered body. The props type is inferred from the registered overlay.
340
343
  *
344
+ * Needs the key registered first: `defineOverlays` plus the `BasaltRegister` `overlays` augmentation.
345
+ *
341
346
  * `overlays.open('nonexistent', …)` is a tsc error when BasaltRegister.overlays is augmented.
342
347
  * Un-augmented: OverlayKey = never → effectively uncallable.
343
348
  *
@@ -1,6 +1,10 @@
1
1
  /**
2
2
  * ./commands — the command bus, overlay controller, shortcuts help and the notification registry.
3
3
  *
4
+ * Two seams need registering first: `emit(kind)` only accepts kinds registered in `defineNotifications`,
5
+ * and a form dialog is a `defineOverlays` entry opened with `overlays.open('id', props)`; both
6
+ * register their keys through the `declare module 'basalt-ui'` augmentation (see each factory).
7
+ *
4
8
  * `BasaltProvider` mounts modals, Spotlight, hotkeys and notifications; this barrel is only what
5
9
  * an app declares and calls.
6
10
  *
@@ -2,6 +2,9 @@
2
2
  * defineNotifications — const-generic factory for typed notification kind registries.
3
3
  * Mirrors the defineSeries pattern from ./tokens (const-generic, identity passthrough).
4
4
  *
5
+ * `emit` only accepts kinds registered here first: call `defineNotifications` and augment
6
+ * `BasaltRegister.notifications` before emitting.
7
+ *
5
8
  * Consumer augments BasaltRegister.notifications with the spec map type, then uses the typed
6
9
  * `emit` helper which resolves the registered kind at compile-time. An unknown kind is a tsc error.
7
10
  *
@@ -137,9 +137,10 @@ export type FormRowProps = BasaltProps &
137
137
  hint?: string
138
138
  /**
139
139
  * The field's error, rendered under the control. Falsy renders nothing. For a Mantine input
140
- * wired through `inputProps(form, path)`, Mantine's own `Input.Wrapper` already renders
141
- * `form.errors[path]` — passing it here too would render it twice. Reserve this prop for
142
- * children that render no error of their own: a raw input, a custom control.
140
+ * wired through `inputProps(form, path)`, Mantine's own `Input.Wrapper` already renders the
141
+ * field error — passing it here too would render it twice. Reserve this prop for children that
142
+ * render no error of their own (a raw input, a custom control) and read it typed:
143
+ * `error={inputProps(form, path).error}`.
143
144
  */
144
145
  error?: ReactNode
145
146
  /** Marks the field required: an accent `*` for sighted readers, `(required)` for assistive tech. */
@@ -172,7 +173,7 @@ export type FormRowProps = BasaltProps &
172
173
  *
173
174
  * @example
174
175
  * // A raw control renders no error of its own — pass it explicitly.
175
- * <FormRow label="Email" required error={form.errors['email']}>
176
+ * <FormRow label="Email" required error={inputProps(form, 'email').error}>
176
177
  * <input value={form.values.email} onChange={(e) => form.setFieldValue('email', e.target.value)} />
177
178
  * </FormRow>
178
179
  */
@@ -239,8 +240,16 @@ export type FormGroupProps = BasaltProps & {
239
240
  *
240
241
  * @example
241
242
  * <FormGroup label="Notify me about" direction="row">
242
- * <Checkbox key={fieldKey(form, 'onDeploy')} {...inputProps(form, 'onDeploy')} label="Deploys" />
243
- * <Checkbox key={fieldKey(form, 'onError')} {...inputProps(form, 'onError')} label="Errors" />
243
+ * <Checkbox
244
+ * key={fieldKey(form, 'onDeploy')}
245
+ * {...inputProps(form, 'onDeploy', { type: 'checkbox' })}
246
+ * label="Deploys"
247
+ * />
248
+ * <Switch
249
+ * key={fieldKey(form, 'onError')}
250
+ * {...inputProps(form, 'onError', { type: 'checkbox' })}
251
+ * label="Errors"
252
+ * />
244
253
  * </FormGroup>
245
254
  */
246
255
  export function FormGroup(props: FormGroupProps) {
@@ -15,7 +15,56 @@
15
15
  * which was the whole reason for the rename in the first place. Write
16
16
  * `key={fieldKey(form, path)} {...inputProps(form, path)}`.
17
17
  */
18
- import type { LooseKeys, UseFormReturnType } from '@mantine/form'
18
+ import type { GetInputPropsReturnType, LooseKeys, UseFormReturnType } from '@mantine/form'
19
+ import type { ReactNode } from 'react'
20
+
21
+ /**
22
+ * What `inputProps` returns: Mantine's shape with `error` typed (`any` upstream). `error` is always
23
+ * present — Mantine sets the key on every call, `undefined` on a clean field — so it is `ReactNode`,
24
+ * not optional. It is the one typed way to read a field error: `form.errors` is an index signature
25
+ * (dot access is TS4111), and a raw control inside `FormRow` takes
26
+ * `<FormRow error={inputProps(form, path).error}>`. A Mantine input spread with `inputProps` already
27
+ * renders it; passing it to `FormRow` as well renders it twice.
28
+ */
29
+ export type InputProps = Omit<GetInputPropsReturnType, 'error'> & { error: ReactNode }
30
+
31
+ type Digit = '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9'
32
+
33
+ type AllDigits<S extends string> = S extends `${Digit}${infer Rest}`
34
+ ? Rest extends ''
35
+ ? true
36
+ : AllDigits<Rest>
37
+ : false
38
+
39
+ /** A canonical array index: digits only, no sign, no decimal point, no exponent, no leading zero. */
40
+ type IsIndex<S extends string> = S extends '0'
41
+ ? true
42
+ : S extends `0${string}`
43
+ ? false
44
+ : AllDigits<S>
45
+
46
+ /** One path segment applied to a value; `never` when the segment does not exist there. */
47
+ type Child<T, K extends string> =
48
+ NonNullable<T> extends infer N
49
+ ? N extends readonly (infer V)[]
50
+ ? IsIndex<K> extends true
51
+ ? V
52
+ : never
53
+ : K extends keyof N
54
+ ? N[K]
55
+ : never
56
+ : never
57
+
58
+ type ValueAt<T, P extends string> = P extends `${infer Head}.${infer Rest}`
59
+ ? ValueAt<Child<T, Head>, Rest>
60
+ : Child<T, P>
61
+
62
+ /** `Path` if the value at that dot path is a (possibly optional/nullable) boolean, else `never`. */
63
+ type BooleanAt<Values, Path extends string> = [ValueAt<Values, Path>] extends [never]
64
+ ? never
65
+ : [NonNullable<ValueAt<Values, Path>>] extends [boolean]
66
+ ? Path
67
+ : never
19
68
 
20
69
  // ── inputProps ────────────────────────────────────────────────────────────────
21
70
 
@@ -37,8 +86,34 @@ import type { LooseKeys, UseFormReturnType } from '@mantine/form'
37
86
  export function inputProps<Values extends Record<string, unknown>, Path extends LooseKeys<Values>>(
38
87
  form: UseFormReturnType<Values>,
39
88
  path: Path,
40
- ): ReturnType<UseFormReturnType<Values>['getInputProps']> {
41
- return form.getInputProps(path)
89
+ ): InputProps
90
+ /**
91
+ * The boolean overload: `{ type: 'checkbox' }` binds a boolean field to Mantine `Checkbox` and
92
+ * `Switch`. It returns `onChange` plus `defaultChecked` in `useBasaltForm`'s default `uncontrolled`
93
+ * mode, or `checked` under `mode: 'controlled'` (Mantine decides; there is no `value`).
94
+ *
95
+ * Only a path whose value is a boolean (optional/nullable included) type-checks; a string path is a
96
+ * type error, not a silently wrong binding. Two limits of that check:
97
+ * - The path must be a literal. A `string`-typed path is rejected here (use a literal, or the
98
+ * one-argument form), so the path argument does not autocomplete.
99
+ * - On a union parent, a key present on several members is accepted only when every member types it
100
+ * as boolean; array segments must be canonical indices (`flags.0`, never `flags.1.5` or `flags.01`).
101
+ *
102
+ * @example
103
+ * <Switch key={fieldKey(form, 'active')} {...inputProps(form, 'active', { type: 'checkbox' })} />
104
+ */
105
+ export function inputProps<Values extends Record<string, unknown>, Path extends string>(
106
+ form: UseFormReturnType<Values>,
107
+ path: BooleanAt<Values, Path>,
108
+ options: { type: 'checkbox' },
109
+ ): InputProps
110
+ export function inputProps<Values extends Record<string, unknown>>(
111
+ form: UseFormReturnType<Values>,
112
+ path: string,
113
+ options?: { type: 'checkbox' },
114
+ ): InputProps {
115
+ // Mantine types `error` optional but sets the key on every call (`withError` defaults to true).
116
+ return form.getInputProps(path, options) as InputProps
42
117
  }
43
118
 
44
119
  /**
@@ -6,14 +6,13 @@
6
6
  * `basalt-ui`. Same reason `./charts` and `./tokens` stay off the root barrel, one optional peer
7
7
  * over. Import everything below from `basalt-ui/forms`.
8
8
  *
9
- * Four pieces: the form (`useBasaltForm` + `inputProps`/`fieldKey`), the submit lifecycle
10
- * (`useFormSubmit` + `FormStateProvider`), the list field (`useFieldArray`) and the draft
11
- * (`useFormDraft`). The layout (`FormSection` / `FormRow` / `FormGroup` / `FormActions`) lives in
12
- * `basalt-ui/controls` (it needs no `@mantine/form`); `useForm`/`schemaResolver` come from
13
- * `@mantine/form` directly. Both stopped being re-exported here in 1.39.0.
9
+ * One piece: the form (`useBasaltForm` + `inputProps`/`fieldKey`). The layout (FormRow /
10
+ * FormGroup) lives in `basalt-ui/controls` (it needs no `@mantine/form`); the form hook and
11
+ * schema resolvers come from `@mantine/form` directly.
14
12
  *
15
13
  * Optional peer: @mantine/form ^9.3.0 — install with: bun add @mantine/form
16
14
  */
17
15
 
18
16
  export { useBasaltForm } from './create-form'
19
17
  export { inputProps, fieldKey } from './field'
18
+ export type { InputProps } from './field'
package/src/surfaces.ts CHANGED
@@ -409,7 +409,7 @@ export const SURFACES = {
409
409
  guardKinds: [],
410
410
  pluginRules: [],
411
411
  description:
412
- 'defineCommands (typed command bus), defineOverlays/overlays, setColorScheme, toggleSidebar, ShortcutsHelp, defineNotifications/emit/NotificationBell (folded in from ./notifications); BasaltProvider mounts Spotlight, Modals and Notifications',
412
+ 'defineCommands (typed command bus), defineOverlays/overlays (a form dialog is a registered overlay opened with overlays.open), setColorScheme, toggleSidebar, ShortcutsHelp, defineNotifications/emit/NotificationBell (emit only accepts kinds registered in defineNotifications; folded in from ./notifications); BasaltProvider mounts Spotlight, Modals and Notifications',
413
413
  optionalPeers: ['@tanstack/react-hotkeys'],
414
414
  forbiddenImports: [],
415
415
  },
@@ -502,7 +502,7 @@ export const SURFACES = {
502
502
  'C12 — one shape for refresh/sync (SyncButton); only the alias table sees a renamed copy',
503
503
  ],
504
504
  description:
505
- 'The control tier (docs/CONTROLS-SPEC.md §3): FilterSet (nowrap row + measured +N fold + the mobile Filters (n) sheet), RangeFilter/CompareFilter/SelectFilter/MultiSelectFilter/NumberFilter/SearchFilter/ToggleFilter (each bound to a FieldHandle — no value/onChange/size, law C2/C5; NumberFilter is the field.number lane, a radio list over `options` or a stepper without), ViewTabs, the action/sync family (ActionGroup, OverflowMenu, SyncButton, BarAction/GlobalAction), and the form layout FormSection/FormRow/FormGroup/FormActions (moved here from ./forms in 1.36.0 — FormRow is law C1’s form row and needs no @mantine/form). THREE surfaces, picked by the home and never by a prop (useFilterSurface): pill in a PageBar row, sheet in the mobile Filters (n) drawer, panel in a PageAside body — where every control renders an inspector/facet ROW instead of a chip (docs/ASIDE-SPEC.md §3). PanelRow is that row primitive (label above, hint, mono readout, an `end` control on the label line) and SliderControl is the one bound control with no pill form at all; the counts/max props on MultiSelectFilter render the Foundry facet list there. Every control owns its own desktop/mobile swap in CSS (C9) and renders size="ctl" internally. Resolves and renders with NO @mantine/dates installed — the custom date picker is injected through RangeFilter.customPicker from ./controls-dates.',
505
+ 'The control tier (docs/CONTROLS-SPEC.md §3). Exports: `FilterSet` (nowrap row + measured +N fold + the mobile Filters (n) sheet), `RangeFilter`/`SelectFilter`/`MultiSelectFilter`/`NumberFilter`/`SearchFilter`/`ToggleFilter` (each bound to a FieldHandle — no value/onChange/size, law C2/C5; `NumberFilter` is the field.number lane, a radio list over `options` or a stepper without), `ViewTabs`, `SyncButton` with the `BarAction`/`GlobalAction` types, and the form layout `FormRow`/`FormGroup` (moved here from ./forms in 1.36.0 — `FormRow` is law C1’s form row and needs no @mantine/form). THREE surfaces, picked by the home and never by a prop: pill in a PageBar row, sheet in the mobile Filters (n) drawer, panel in a PageAside body — where every control renders an inspector/facet ROW instead of a chip (docs/ASIDE-SPEC.md §3); the counts/max props on `MultiSelectFilter` render the Foundry facet list there. Every control owns its own desktop/mobile swap in CSS (C9) and renders size="ctl" internally. Resolves and renders with NO @mantine/dates installed — the custom date picker is injected through RangeFilter.customPicker from ./controls-dates.',
506
506
  optionalPeers: [],
507
507
  // `@mantine/dates` is an optional peer basaltViteConfig pre-bundles the whole @mantine scope
508
508
  // for — a consumer without the peer (linewatch) must never resolve it through this surface.