basalt-ui 2.12.0 → 2.13.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.
- package/CHANGELOG.md +35 -0
- package/MIGRATING.md +50 -12
- package/agent/rules/basalt-state.md +1 -1
- package/agent/skills/basalt-app/SKILL.md +1 -1
- package/agent/templates/main.tpl +1 -0
- package/dist/cli/basalt-install.d.ts +10 -0
- package/dist/cli/basalt-install.d.ts.map +1 -0
- package/dist/cli/basalt-install.js +0 -0
- package/dist/cli/check-theme.js +1 -1
- package/dist/cli/doctor-upgrade.d.ts +3 -3
- package/dist/cli/doctor-upgrade.d.ts.map +1 -1
- package/dist/cli/doctor-upgrade.js +28 -44
- package/dist/cli/doctor.js +3 -3
- package/dist/cli/index.d.ts +4 -28
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +10 -49
- package/dist/cli/provider-tags.d.ts +12 -0
- package/dist/cli/provider-tags.d.ts.map +1 -0
- package/dist/cli/provider-tags.js +28 -0
- package/dist/cli/render-imports.d.ts +24 -0
- package/dist/cli/render-imports.d.ts.map +1 -0
- package/dist/cli/render-imports.js +74 -0
- package/dist/cli/router-wiring.d.ts +12 -0
- package/dist/cli/router-wiring.d.ts.map +1 -1
- package/dist/cli/router-wiring.js +18 -0
- package/dist/cli/source-text.d.ts +7 -0
- package/dist/cli/source-text.d.ts.map +1 -1
- package/dist/cli/source-text.js +34 -0
- package/dist/cli/sync.d.ts.map +1 -1
- package/dist/cli/sync.js +18 -13
- package/dist/guard/fonts-hint.d.ts +3 -0
- package/dist/guard/fonts-hint.d.ts.map +1 -0
- package/dist/guard/fonts-hint.js +4 -0
- package/dist/guard/index.d.ts +1 -1
- package/dist/guard/index.d.ts.map +1 -1
- package/dist/guard/index.js +2 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/provider/create-router.d.ts +57 -10
- package/dist/provider/create-router.d.ts.map +1 -1
- package/dist/provider/create-router.js +28 -17
- package/dist/provider/index.d.ts +2 -2
- package/dist/provider/index.d.ts.map +1 -1
- package/dist/provider/index.js +23 -7
- package/dist/query-client.d.ts +2 -62
- package/dist/query-client.d.ts.map +1 -1
- package/dist/query-client.js +13 -18
- package/dist/router-tanstack/nav.d.ts +5 -0
- package/dist/router-tanstack/nav.d.ts.map +1 -1
- package/dist/router-tanstack/search-store-warnings.d.ts +33 -0
- package/dist/router-tanstack/search-store-warnings.d.ts.map +1 -0
- package/dist/router-tanstack/search-store-warnings.js +77 -0
- package/dist/router-tanstack/search-store.d.ts +2 -5
- package/dist/router-tanstack/search-store.d.ts.map +1 -1
- package/dist/router-tanstack/search-store.js +111 -110
- package/dist/router-tanstack/use-nav.d.ts +4 -2
- package/dist/router-tanstack/use-nav.d.ts.map +1 -1
- package/dist/router-tanstack/use-nav.js +55 -18
- package/dist/shell/app-breadcrumbs.d.ts +1 -3
- package/dist/shell/app-breadcrumbs.d.ts.map +1 -1
- package/dist/shell/app-breadcrumbs.js +1 -6
- package/dist/shell/index.d.ts +14 -5
- package/dist/shell/index.d.ts.map +1 -1
- package/dist/shell/index.js +6 -29
- package/dist/shell/nav-types.d.ts +7 -0
- package/dist/shell/nav-types.d.ts.map +1 -1
- package/dist/shell/page-aside.d.ts +4 -2
- package/dist/shell/page-aside.d.ts.map +1 -1
- package/dist/shell/page-aside.js +41 -23
- package/dist/shell/page-bar.d.ts +1 -1
- package/dist/shell/page-bar.d.ts.map +1 -1
- package/dist/shell/page-bar.js +39 -33
- package/dist/telemetry.d.ts +31 -2
- package/dist/telemetry.d.ts.map +1 -1
- package/dist/telemetry.js +32 -12
- package/dist/theme/ctl-theme.d.ts.map +1 -1
- package/dist/theme/ctl-theme.js +17 -30
- package/dist/theme/extend.d.ts +18 -0
- package/dist/theme/extend.d.ts.map +1 -0
- package/dist/theme/extend.js +6 -0
- package/dist/theme/index.d.ts.map +1 -1
- package/dist/theme/index.js +44 -84
- package/dist/unwrap.d.ts +29 -0
- package/dist/unwrap.d.ts.map +1 -0
- package/dist/unwrap.js +18 -0
- package/llms.txt +9 -5
- package/package.json +1 -1
- package/src/cli/basalt-install.ts +9 -0
- package/src/cli/check-theme.ts +1 -1
- package/src/cli/doctor-upgrade.ts +40 -61
- package/src/cli/doctor.ts +3 -3
- package/src/cli/index.ts +14 -71
- package/src/cli/provider-tags.ts +38 -0
- package/src/cli/render-imports.ts +104 -0
- package/src/cli/router-wiring.ts +23 -0
- package/src/cli/source-text.ts +39 -0
- package/src/cli/sync.ts +27 -21
- package/src/guard/fonts-hint.ts +2 -0
- package/src/guard/index.ts +2 -2
- package/src/index.ts +4 -2
- package/src/provider/create-router.tsx +103 -39
- package/src/provider/index.tsx +27 -9
- package/src/query-client.ts +20 -78
- package/src/router-tanstack/nav.ts +5 -0
- package/src/router-tanstack/search-store-warnings.ts +120 -0
- package/src/router-tanstack/search-store.ts +200 -206
- package/src/router-tanstack/use-nav.ts +116 -76
- package/src/shell/app-breadcrumbs.tsx +1 -12
- package/src/shell/index.tsx +22 -55
- package/src/shell/nav-types.ts +8 -0
- package/src/shell/page-aside.tsx +59 -26
- package/src/shell/page-bar.tsx +63 -59
- package/src/telemetry.ts +71 -13
- package/src/theme/__snapshots__/plain-theme.test.ts.snap +2354 -0
- package/src/theme/ctl-theme.tsx +20 -19
- package/src/theme/extend.ts +18 -0
- package/src/theme/index.ts +50 -49
- package/src/unwrap.ts +44 -0
package/src/theme/ctl-theme.tsx
CHANGED
|
@@ -30,13 +30,14 @@
|
|
|
30
30
|
* tier"), and it is stated here because it is the kind of thing that otherwise gets rediscovered as
|
|
31
31
|
* a bug. A consumer wanting a `lg` radio group puts it in a BODY, which no `CtlSlot` wraps.
|
|
32
32
|
*/
|
|
33
|
-
import {
|
|
33
|
+
import { Box, MantineThemeProvider } from '@mantine/core'
|
|
34
|
+
import type {
|
|
34
35
|
ActionIcon,
|
|
35
|
-
Box,
|
|
36
36
|
Button,
|
|
37
37
|
Checkbox,
|
|
38
38
|
Input,
|
|
39
|
-
|
|
39
|
+
MantineSize,
|
|
40
|
+
MantineThemeOverride,
|
|
40
41
|
MultiSelect,
|
|
41
42
|
NativeSelect,
|
|
42
43
|
Radio,
|
|
@@ -45,8 +46,8 @@ import {
|
|
|
45
46
|
Switch,
|
|
46
47
|
TextInput,
|
|
47
48
|
} from '@mantine/core'
|
|
48
|
-
import type { MantineSize, MantineThemeOverride } from '@mantine/core'
|
|
49
49
|
import type { ReactNode } from 'react'
|
|
50
|
+
import { ext } from './extend'
|
|
50
51
|
|
|
51
52
|
// Mantine's typed prop bags reject `data-*` literals; a spread carries the hit-area attribute in.
|
|
52
53
|
// Lives here (not `./index`, which imports THIS module) rather than the reverse, so `./index`'s own
|
|
@@ -59,17 +60,17 @@ export const HIT_ATTR: Record<string, true> = { 'data-basalt-hit': true }
|
|
|
59
60
|
* by `PageBar`/`Section`/the sidebar blocks) can reach the SAME tier without re-declaring it. */
|
|
60
61
|
export const CTL_THEME: MantineThemeOverride = {
|
|
61
62
|
components: {
|
|
62
|
-
Button: Button
|
|
63
|
-
ActionIcon: ActionIcon
|
|
64
|
-
Input: Input
|
|
65
|
-
TextInput: TextInput
|
|
66
|
-
Select: Select
|
|
67
|
-
MultiSelect: MultiSelect
|
|
68
|
-
SegmentedControl: SegmentedControl
|
|
69
|
-
NativeSelect: NativeSelect
|
|
63
|
+
Button: ext<typeof Button>({ defaultProps: { size: 'ctl' } }),
|
|
64
|
+
ActionIcon: ext<typeof ActionIcon>({ defaultProps: { size: 'ctl' } }),
|
|
65
|
+
Input: ext<typeof Input>({ defaultProps: { size: 'ctl' } }),
|
|
66
|
+
TextInput: ext<typeof TextInput>({ defaultProps: { size: 'ctl' } }),
|
|
67
|
+
Select: ext<typeof Select>({ defaultProps: { size: 'ctl' } }),
|
|
68
|
+
MultiSelect: ext<typeof MultiSelect>({ defaultProps: { size: 'ctl' } }),
|
|
69
|
+
SegmentedControl: ext<typeof SegmentedControl>({ defaultProps: { size: 'ctl' } }),
|
|
70
|
+
NativeSelect: ext<typeof NativeSelect>({ defaultProps: { size: 'ctl' } }),
|
|
70
71
|
// The theme keys are the component names Mantine's own `useProps` looks up — `RadioGroup`, not
|
|
71
72
|
// `Radio.Group` (`RadioGroup.mjs`: `useProps("RadioGroup", …)`).
|
|
72
|
-
Radio: Radio
|
|
73
|
+
Radio: ext<typeof Radio>({
|
|
73
74
|
defaultProps: { size: 'ctl', attributes: { label: HIT_ATTR } },
|
|
74
75
|
}),
|
|
75
76
|
// Mantine types `RadioGroup.size` as a CLOSED `MantineSize`, while `Radio`, `Checkbox`,
|
|
@@ -78,15 +79,15 @@ export const CTL_THEME: MantineThemeOverride = {
|
|
|
78
79
|
// upstream inconsistency, not a statement that `RadioGroup` cannot take a custom tier. At
|
|
79
80
|
// runtime `getSize` interpolates the string identically for all six. The cast restores what
|
|
80
81
|
// every sibling type already allows; it widens nothing.
|
|
81
|
-
RadioGroup: Radio.Group
|
|
82
|
-
Checkbox: Checkbox
|
|
82
|
+
RadioGroup: ext<typeof Radio.Group>({ defaultProps: { size: 'ctl' as MantineSize } }),
|
|
83
|
+
Checkbox: ext<typeof Checkbox>({
|
|
83
84
|
defaultProps: { size: 'ctl', attributes: { label: HIT_ATTR } },
|
|
84
85
|
}),
|
|
85
|
-
CheckboxGroup: Checkbox.Group
|
|
86
|
-
Switch: Switch
|
|
86
|
+
CheckboxGroup: ext<typeof Checkbox.Group>({ defaultProps: { size: 'ctl' } }),
|
|
87
|
+
Switch: ext<typeof Switch>({
|
|
87
88
|
defaultProps: { size: 'ctl', attributes: { track: HIT_ATTR } },
|
|
88
89
|
}),
|
|
89
|
-
SwitchGroup: Switch.Group
|
|
90
|
+
SwitchGroup: ext<typeof Switch.Group>({ defaultProps: { size: 'ctl' } }),
|
|
90
91
|
},
|
|
91
92
|
}
|
|
92
93
|
|
|
@@ -120,7 +121,7 @@ export const CTL_THEME: MantineThemeOverride = {
|
|
|
120
121
|
*/
|
|
121
122
|
const WIDGET_THEME: MantineThemeOverride = {
|
|
122
123
|
components: {
|
|
123
|
-
ActionIcon: ActionIcon
|
|
124
|
+
ActionIcon: ext<typeof ActionIcon>({ defaultProps: { size: 'icon' } }),
|
|
124
125
|
},
|
|
125
126
|
}
|
|
126
127
|
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { MantineThemeComponent } from '@mantine/core'
|
|
2
|
+
|
|
3
|
+
/** The input type of a Mantine component's `.extend()`: `defaultProps` / `classNames` / `styles` /
|
|
4
|
+
* `vars` typed against THAT component, taken from the component type alone. */
|
|
5
|
+
type ExtendInput<C> = C extends { extend: (input: infer I) => unknown } ? I : never
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Typed identity standing in for `Component.extend({...})`. Mantine's `extend` is `identity` at
|
|
9
|
+
* runtime (it exists for typing), but calling it is a VALUE use of the component, which drags the
|
|
10
|
+
* whole component module into every bundle that imports the theme. Pass the component as a type
|
|
11
|
+
* argument (`ext<typeof Card>({...})`, imported with `import type`) and the same compile-time
|
|
12
|
+
* checking applies with nothing emitted.
|
|
13
|
+
*/
|
|
14
|
+
export function ext<C extends { extend: (input: never) => unknown }>(
|
|
15
|
+
input: ExtendInput<C>,
|
|
16
|
+
): MantineThemeComponent {
|
|
17
|
+
return input as MantineThemeComponent
|
|
18
|
+
}
|
package/src/theme/index.ts
CHANGED
|
@@ -16,6 +16,13 @@
|
|
|
16
16
|
* layer emits, so there is no hand-duplicated hex to drift.
|
|
17
17
|
*/
|
|
18
18
|
import {
|
|
19
|
+
createTheme,
|
|
20
|
+
defaultVariantColorsResolver,
|
|
21
|
+
getPrimaryShade,
|
|
22
|
+
mergeThemeOverrides,
|
|
23
|
+
rem,
|
|
24
|
+
} from '@mantine/core'
|
|
25
|
+
import type {
|
|
19
26
|
Accordion,
|
|
20
27
|
ActionIcon,
|
|
21
28
|
Alert,
|
|
@@ -29,15 +36,11 @@ import {
|
|
|
29
36
|
Chip,
|
|
30
37
|
Code,
|
|
31
38
|
Combobox,
|
|
32
|
-
createTheme,
|
|
33
|
-
defaultVariantColorsResolver,
|
|
34
39
|
Drawer,
|
|
35
|
-
getPrimaryShade,
|
|
36
40
|
Indicator,
|
|
37
41
|
Input,
|
|
38
42
|
Kbd,
|
|
39
43
|
Menu,
|
|
40
|
-
mergeThemeOverrides,
|
|
41
44
|
Modal,
|
|
42
45
|
NavLink,
|
|
43
46
|
Notification,
|
|
@@ -51,7 +54,6 @@ import {
|
|
|
51
54
|
Progress,
|
|
52
55
|
Radio,
|
|
53
56
|
RadioCard,
|
|
54
|
-
rem,
|
|
55
57
|
Select,
|
|
56
58
|
SegmentedControl,
|
|
57
59
|
Stepper,
|
|
@@ -62,8 +64,6 @@ import {
|
|
|
62
64
|
TextInput,
|
|
63
65
|
Timeline,
|
|
64
66
|
Tooltip,
|
|
65
|
-
} from '@mantine/core'
|
|
66
|
-
import type {
|
|
67
67
|
CSSVariablesResolver,
|
|
68
68
|
MantineColorsTuple,
|
|
69
69
|
MantineTheme,
|
|
@@ -90,6 +90,7 @@ import navLinkClasses from './nav-link.module.css'
|
|
|
90
90
|
import segmentedControlClasses from './segmented-control.module.css'
|
|
91
91
|
import timelineClasses from './timeline.module.css'
|
|
92
92
|
import { HIT_ATTR } from './ctl-theme'
|
|
93
|
+
import { ext } from './extend'
|
|
93
94
|
|
|
94
95
|
/**
|
|
95
96
|
* The `fonts` option's resolved shape — defined in `../tokens/core` (`BasaltFontsConfig`, paired
|
|
@@ -540,7 +541,7 @@ function buildTheme(data: PaletteData, options: BuildThemeOptions = {}): Mantine
|
|
|
540
541
|
// • radius → `--vx-radius-card` (7px).
|
|
541
542
|
// This is the single source the user's "strict surface across components" demands; the
|
|
542
543
|
// `raw-surface` guard then stops consumers re-overriding any of it inline.
|
|
543
|
-
Card: Card
|
|
544
|
+
Card: ext<typeof Card>({
|
|
544
545
|
styles: {
|
|
545
546
|
root: {
|
|
546
547
|
backgroundColor: 'var(--vx-surface-panel)',
|
|
@@ -549,7 +550,7 @@ function buildTheme(data: PaletteData, options: BuildThemeOptions = {}): Mantine
|
|
|
549
550
|
},
|
|
550
551
|
},
|
|
551
552
|
}),
|
|
552
|
-
Paper: Paper
|
|
553
|
+
Paper: ext<typeof Paper>({
|
|
553
554
|
styles: {
|
|
554
555
|
root: {
|
|
555
556
|
backgroundColor: 'var(--vx-surface-panel)',
|
|
@@ -561,12 +562,12 @@ function buildTheme(data: PaletteData, options: BuildThemeOptions = {}): Mantine
|
|
|
561
562
|
// Mantine's default Badge radius is a full 1000px pill; the spec's delta/status badges sit at
|
|
562
563
|
// radius 6 (docs/DESIGN-SPEC.md §4/§5). Count badges (radius 5) are a distinct, smaller-radius
|
|
563
564
|
// usage left to the call site (`radius={5}` prop) since Badge has no state to key off here.
|
|
564
|
-
Badge: Badge
|
|
565
|
+
Badge: ext<typeof Badge>({ defaultProps: { radius: radius.ctrl } }),
|
|
565
566
|
// Alert renders its title in the body font by default; bring it onto the head-font idiom
|
|
566
567
|
// (docs/DESIGN-SPEC.md §5) like every other titled surface. Radius/padding/color tint are
|
|
567
568
|
// already on-system (defaultRadius 'md' control tier + the variant color resolver), so only
|
|
568
569
|
// the title font is overridden.
|
|
569
|
-
Alert: Alert
|
|
570
|
+
Alert: ext<typeof Alert>({
|
|
570
571
|
styles: {
|
|
571
572
|
title: {
|
|
572
573
|
fontFamily: 'var(--basalt-font-head)',
|
|
@@ -584,7 +585,7 @@ function buildTheme(data: PaletteData, options: BuildThemeOptions = {}): Mantine
|
|
|
584
585
|
// Cast: `AppShellCssVariables` declares only `--app-shell-transition-duration` /
|
|
585
586
|
// `-timing-function`, yet Mantine's OWN AppShell.css sets `--app-shell-border-color` on the
|
|
586
587
|
// same root.
|
|
587
|
-
AppShell: AppShell
|
|
588
|
+
AppShell: ext<typeof AppShell>({
|
|
588
589
|
vars: () =>
|
|
589
590
|
({ root: { '--app-shell-border-color': 'var(--vx-divider)' } }) as unknown as {
|
|
590
591
|
root: Record<
|
|
@@ -608,7 +609,7 @@ function buildTheme(data: PaletteData, options: BuildThemeOptions = {}): Mantine
|
|
|
608
609
|
// set at ink-6% by higher-specificity `:not([data-active])` rules in `nav-link.module.css` /
|
|
609
610
|
// `app-sidebar.module.css` — so it exists to keep the active row responding to the pointer
|
|
610
611
|
// now that its rest state sits in the same tint family as an inactive hover.
|
|
611
|
-
NavLink: NavLink
|
|
612
|
+
NavLink: ext<typeof NavLink>({
|
|
612
613
|
vars: () => ({
|
|
613
614
|
root: {
|
|
614
615
|
'--nl-bg': 'color-mix(in srgb, var(--vx-ink) 9%, transparent)',
|
|
@@ -655,7 +656,7 @@ function buildTheme(data: PaletteData, options: BuildThemeOptions = {}): Mantine
|
|
|
655
656
|
// legal home for the shadow's ring. Theming the base `Input` covers
|
|
656
657
|
// TextInput/NumberInput/PasswordInput/Select/Textarea, which all render it internally (only
|
|
657
658
|
// `size` needs per-component defaults, since each resolves its own).
|
|
658
|
-
Input: Input
|
|
659
|
+
Input: ext<typeof Input>({
|
|
659
660
|
defaultProps: { size: 'md' },
|
|
660
661
|
// Density coupling: Input's OWN `varsResolver` sets `--input-height` to
|
|
661
662
|
// `getSize(props.size, 'input-height')` (`@mantine/core/esm/components/Input/Input.mjs`),
|
|
@@ -689,20 +690,20 @@ function buildTheme(data: PaletteData, options: BuildThemeOptions = {}): Mantine
|
|
|
689
690
|
}),
|
|
690
691
|
classNames: { wrapper: controlsClasses.inputWrapper, input: controlsClasses.input },
|
|
691
692
|
}),
|
|
692
|
-
TextInput: TextInput
|
|
693
|
+
TextInput: ext<typeof TextInput>({ defaultProps: { size: 'md' } }),
|
|
693
694
|
// The stepper chevrons sit ~15px apart, so neither can own a 44px overlay; the coarse
|
|
694
695
|
// `.input` min-height floor (theme/controls.module.css) is the touch floor.
|
|
695
|
-
NumberInput: NumberInput
|
|
696
|
-
PasswordInput: PasswordInput
|
|
697
|
-
Select: Select
|
|
698
|
-
Textarea: Textarea
|
|
696
|
+
NumberInput: ext<typeof NumberInput>({ defaultProps: { size: 'md' } }),
|
|
697
|
+
PasswordInput: ext<typeof PasswordInput>({ defaultProps: { size: 'md' } }),
|
|
698
|
+
Select: ext<typeof Select>({ defaultProps: { size: 'md' } }),
|
|
699
|
+
Textarea: ext<typeof Textarea>({ defaultProps: { size: 'md' } }),
|
|
699
700
|
// PillsInput (MultiSelect/TagsInput's outer field) renders `InputBase` internally but under
|
|
700
701
|
// its OWN `__staticSelector: 'PillsInput'`, so it never reads `theme.components.Input` — the
|
|
701
702
|
// field idiom above never reached it. `PillsInput.classes === InputBase.classes`, so the SAME
|
|
702
703
|
// part names apply here; reusing both control classes picks up the exact `[data-variant]` rules
|
|
703
704
|
// in controls.module.css for free, no new CSS needed. Both slots are required — `wrapper` alone
|
|
704
705
|
// would land the vars but leave the field flat, since the depth lives on `input`.
|
|
705
|
-
PillsInput: PillsInput
|
|
706
|
+
PillsInput: ext<typeof PillsInput>({
|
|
706
707
|
classNames: { wrapper: controlsClasses.inputWrapper, input: controlsClasses.input },
|
|
707
708
|
}),
|
|
708
709
|
// Button / ActionIcon: depth for EVERY variant that owns a box (docs/DESIGN-SPEC.md §5's
|
|
@@ -730,7 +731,7 @@ function buildTheme(data: PaletteData, options: BuildThemeOptions = {}): Mantine
|
|
|
730
731
|
// anchor's doc in `tokens/palette.ts`), so the two can never drift. Scoped to `size === 'md'`,
|
|
731
732
|
// same rationale as Input's override: `undefined` leaves an explicitly different size (e.g.
|
|
732
733
|
// `size="xs"`) on Mantine's own static height.
|
|
733
|
-
Button: Button
|
|
734
|
+
Button: ext<typeof Button>({
|
|
734
735
|
classNames: { root: controlsClasses.buttonRoot },
|
|
735
736
|
vars: (_theme, props) => ({
|
|
736
737
|
root: {
|
|
@@ -741,7 +742,7 @@ function buildTheme(data: PaletteData, options: BuildThemeOptions = {}): Mantine
|
|
|
741
742
|
},
|
|
742
743
|
}),
|
|
743
744
|
}),
|
|
744
|
-
ActionIcon: ActionIcon
|
|
745
|
+
ActionIcon: ext<typeof ActionIcon>({
|
|
745
746
|
classNames: { root: controlsClasses.actionIconRoot },
|
|
746
747
|
vars: (_theme, props) => ({
|
|
747
748
|
root: {
|
|
@@ -764,10 +765,10 @@ function buildTheme(data: PaletteData, options: BuildThemeOptions = {}): Mantine
|
|
|
764
765
|
// Neither component sets a background of its own, so panel bg is added alongside the shadow —
|
|
765
766
|
// the same panel-bg + depth + no-border triad as Card/Paper — on `shadow-raised`, the shared
|
|
766
767
|
// CONTROL depth, not Card/Paper's `shadow-card`: a selection card is something you click.
|
|
767
|
-
CheckboxCard: CheckboxCard
|
|
768
|
+
CheckboxCard: ext<typeof CheckboxCard>({
|
|
768
769
|
classNames: { card: controlsClasses.checkboxCardRoot },
|
|
769
770
|
}),
|
|
770
|
-
RadioCard: RadioCard
|
|
771
|
+
RadioCard: ext<typeof RadioCard>({
|
|
771
772
|
classNames: { card: controlsClasses.radioCardRoot },
|
|
772
773
|
}),
|
|
773
774
|
// Chip: unlike Button/Input, Chip has no literal `variant="default"` — its OWN default (no
|
|
@@ -777,7 +778,7 @@ function buildTheme(data: PaletteData, options: BuildThemeOptions = {}): Mantine
|
|
|
777
778
|
// no shadow) — borderless but flat, the same symptom as CheckboxCard/RadioCard above. The class
|
|
778
779
|
// is wired conditionally (function-form `classNames`, same pattern as the `vars` on-color
|
|
779
780
|
// re-points below) so it NEVER reaches a consumer-chosen `light`/`outline` Chip.
|
|
780
|
-
Chip: Chip
|
|
781
|
+
Chip: ext<typeof Chip>({
|
|
781
782
|
classNames: (_theme, props) =>
|
|
782
783
|
(props.variant ?? 'filled') === 'filled' ? { label: controlsClasses.chipLabel } : {},
|
|
783
784
|
}),
|
|
@@ -813,7 +814,7 @@ function buildTheme(data: PaletteData, options: BuildThemeOptions = {}): Mantine
|
|
|
813
814
|
// `tokens/palette.ts`), and `radius.card`/`RADIUS_STEP.tight` two lines below already track the
|
|
814
815
|
// RADIUS knob together, so the inset between them must stay fixed at exactly 2 regardless of
|
|
815
816
|
// density.
|
|
816
|
-
SegmentedControl: SegmentedControl
|
|
817
|
+
SegmentedControl: ext<typeof SegmentedControl>({
|
|
817
818
|
defaultProps: { radius: radius.card },
|
|
818
819
|
classNames: {
|
|
819
820
|
label: segmentedControlClasses.label,
|
|
@@ -891,7 +892,7 @@ function buildTheme(data: PaletteData, options: BuildThemeOptions = {}): Mantine
|
|
|
891
892
|
}),
|
|
892
893
|
}),
|
|
893
894
|
// Track = ink-8%; leader/section fill colors are a per-usage `color` prop (left to consumers).
|
|
894
|
-
Progress: Progress
|
|
895
|
+
Progress: ext<typeof Progress>({
|
|
895
896
|
// `size` is a NUMBER, not a `var()` string — same rem()-comma-trap reasoning as Timeline's
|
|
896
897
|
// `bulletSize`/`lineWidth` below, so it reads the resolved `spacing.step.progressBarSize`
|
|
897
898
|
// (density-tracking) rather than a hand-typed literal.
|
|
@@ -910,7 +911,7 @@ function buildTheme(data: PaletteData, options: BuildThemeOptions = {}): Mantine
|
|
|
910
911
|
// live in `timeline.module.css` instead. `TimelineItem` renders through the PARENT Timeline's
|
|
911
912
|
// style context (`ctx.getStyles`), so `item`/`itemBullet`/`itemTitle`/`itemContent` are all
|
|
912
913
|
// themed from this ONE extend — no separate `TimelineItem` override needed.
|
|
913
|
-
Timeline: Timeline
|
|
914
|
+
Timeline: ext<typeof Timeline>({
|
|
914
915
|
// NUMBERS, not `var()` strings: `bulletSize`/`lineWidth` land through Timeline's own
|
|
915
916
|
// `rem()` conversion (`@mantine/core/esm/core/utils/units-converters/rem.mjs` splits on `,`
|
|
916
917
|
// and ` ` before checking numerics), which passes a bare `var(--x)` through intact but
|
|
@@ -945,7 +946,7 @@ function buildTheme(data: PaletteData, options: BuildThemeOptions = {}): Mantine
|
|
|
945
946
|
|
|
946
947
|
// Tooltip is a standalone floating primitive (not Popover-based) — themed directly. Its arrow
|
|
947
948
|
// ships border-less (`border: 0`), so the same edge is applied inline to keep the ring closed.
|
|
948
|
-
Tooltip: Tooltip
|
|
949
|
+
Tooltip: ext<typeof Tooltip>({
|
|
949
950
|
defaultProps: { radius: radius.floating },
|
|
950
951
|
styles: {
|
|
951
952
|
tooltip: {
|
|
@@ -959,7 +960,7 @@ function buildTheme(data: PaletteData, options: BuildThemeOptions = {}): Mantine
|
|
|
959
960
|
}),
|
|
960
961
|
// Popover is the shared floating primitive underneath Menu (Menu renders `<Popover>`
|
|
961
962
|
// internally with no `radius`/`shadow` of its own), so theming it here covers both.
|
|
962
|
-
Popover: Popover
|
|
963
|
+
Popover: ext<typeof Popover>({
|
|
963
964
|
defaultProps: { radius: radius.floating },
|
|
964
965
|
styles: {
|
|
965
966
|
dropdown: {
|
|
@@ -973,7 +974,7 @@ function buildTheme(data: PaletteData, options: BuildThemeOptions = {}): Mantine
|
|
|
973
974
|
// stripped from `styles` objects, and Menu's internal Popover does NOT consume
|
|
974
975
|
// `components.Popover.styles`, so the dropdown surface is repeated here). Menu.Label = the
|
|
975
976
|
// mono micro-label idiom; dividers use the layout-divider token.
|
|
976
|
-
Menu: Menu
|
|
977
|
+
Menu: ext<typeof Menu>({
|
|
977
978
|
classNames: { item: floatingClasses.menuItem },
|
|
978
979
|
styles: {
|
|
979
980
|
dropdown: {
|
|
@@ -999,7 +1000,7 @@ function buildTheme(data: PaletteData, options: BuildThemeOptions = {}): Mantine
|
|
|
999
1000
|
}),
|
|
1000
1001
|
// Combobox is the floating primitive underneath Select/Autocomplete/MultiSelect — like Menu,
|
|
1001
1002
|
// it doesn't consume `components.Popover.styles`, so the overlay dropdown idiom is repeated.
|
|
1002
|
-
Combobox: Combobox
|
|
1003
|
+
Combobox: ext<typeof Combobox>({
|
|
1003
1004
|
styles: {
|
|
1004
1005
|
dropdown: {
|
|
1005
1006
|
backgroundColor: 'var(--vx-surface-overlay)',
|
|
@@ -1016,7 +1017,7 @@ function buildTheme(data: PaletteData, options: BuildThemeOptions = {}): Mantine
|
|
|
1016
1017
|
// background moves back to opaque, matching the content box it sits above rather than the page
|
|
1017
1018
|
// behind it. Title = head font; close button = the ghost idiom (floating.module.css). Below the
|
|
1018
1019
|
// `medium` size class the Modal is a bottom sheet (floating.module.css `sheet*`).
|
|
1019
|
-
Modal: Modal
|
|
1020
|
+
Modal: ext<typeof Modal>({
|
|
1020
1021
|
defaultProps: { radius: radius.floating, closeButtonProps: { ...HIT_ATTR } },
|
|
1021
1022
|
classNames: {
|
|
1022
1023
|
close: floatingClasses.closeButton,
|
|
@@ -1037,7 +1038,7 @@ function buildTheme(data: PaletteData, options: BuildThemeOptions = {}): Mantine
|
|
|
1037
1038
|
},
|
|
1038
1039
|
},
|
|
1039
1040
|
}),
|
|
1040
|
-
Drawer: Drawer
|
|
1041
|
+
Drawer: ext<typeof Drawer>({
|
|
1041
1042
|
classNames: { close: floatingClasses.closeButton },
|
|
1042
1043
|
styles: {
|
|
1043
1044
|
content: {
|
|
@@ -1056,7 +1057,7 @@ function buildTheme(data: PaletteData, options: BuildThemeOptions = {}): Mantine
|
|
|
1056
1057
|
// count-badge bg: ink 6–8%") — mono, ink-7% bg, radius 5.
|
|
1057
1058
|
// Flat mono chip (mock's ⌘K badge) — Mantine's default Kbd draws a 3px "keyboard key" bottom
|
|
1058
1059
|
// border that reads as a heavy off-system rule, so the border goes entirely.
|
|
1059
|
-
Kbd: Kbd
|
|
1060
|
+
Kbd: ext<typeof Kbd>({
|
|
1060
1061
|
styles: {
|
|
1061
1062
|
root: {
|
|
1062
1063
|
backgroundColor: 'color-mix(in srgb, var(--vx-ink) 7%, transparent)',
|
|
@@ -1066,7 +1067,7 @@ function buildTheme(data: PaletteData, options: BuildThemeOptions = {}): Mantine
|
|
|
1066
1067
|
},
|
|
1067
1068
|
},
|
|
1068
1069
|
}),
|
|
1069
|
-
Code: Code
|
|
1070
|
+
Code: ext<typeof Code>({
|
|
1070
1071
|
styles: {
|
|
1071
1072
|
root: {
|
|
1072
1073
|
backgroundColor: 'color-mix(in srgb, var(--vx-ink) 7%, transparent)',
|
|
@@ -1083,7 +1084,7 @@ function buildTheme(data: PaletteData, options: BuildThemeOptions = {}): Mantine
|
|
|
1083
1084
|
// rows) is not expressible by it at all. `height` on a table cell behaves as a MINIMUM, so a
|
|
1084
1085
|
// wrapping cell still grows; `verticalSpacing` keeps working on top of it for a consumer that
|
|
1085
1086
|
// wants a denser or looser table than the tier.
|
|
1086
|
-
Table: Table
|
|
1087
|
+
Table: ext<typeof Table>({
|
|
1087
1088
|
classNames: { table: controlsClasses.tableRoot },
|
|
1088
1089
|
styles: {
|
|
1089
1090
|
th: {
|
|
@@ -1104,7 +1105,7 @@ function buildTheme(data: PaletteData, options: BuildThemeOptions = {}): Mantine
|
|
|
1104
1105
|
// `track` is the Switch's <label>, so the invisible `--vx-hit` overlay (`data-basalt-hit`)
|
|
1105
1106
|
// still toggles it. Checkbox/Radio boxes are bare <input>s under a plain <div> — an overlay
|
|
1106
1107
|
// there would swallow clicks, so only their `label` (a real <label>) carries it.
|
|
1107
|
-
Switch: Switch
|
|
1108
|
+
Switch: ext<typeof Switch>({
|
|
1108
1109
|
defaultProps: {
|
|
1109
1110
|
withThumbIndicator: false,
|
|
1110
1111
|
attributes: { track: HIT_ATTR },
|
|
@@ -1114,7 +1115,7 @@ function buildTheme(data: PaletteData, options: BuildThemeOptions = {}): Mantine
|
|
|
1114
1115
|
// control chrome — it reads the divider token instead of the heavy gray-3/dark-4 line
|
|
1115
1116
|
// (controls.module.css; custom properties are stripped from `styles` objects). The active tab
|
|
1116
1117
|
// underline keeps `--tabs-color` (accent) untouched.
|
|
1117
|
-
Tabs: Tabs
|
|
1118
|
+
Tabs: ext<typeof Tabs>({
|
|
1118
1119
|
classNames: { root: controlsClasses.tabsRoot },
|
|
1119
1120
|
// The on-color re-point (see below). Cast: Mantine's `TabsCssVariables` type declares only
|
|
1120
1121
|
// `--tabs-color` / `--tabs-radius`, yet Tabs' OWN varsResolver writes `--tabs-text-color` —
|
|
@@ -1132,7 +1133,7 @@ function buildTheme(data: PaletteData, options: BuildThemeOptions = {}): Mantine
|
|
|
1132
1133
|
// foreground var. Theme `vars` merge AFTER a component's own `varsResolver` (Mantine
|
|
1133
1134
|
// `useStyles`), so re-pointing that var here wins on every render path. Without this, a dark-mode
|
|
1134
1135
|
// Checkbox/Radio paints a white checkmark on the light accent fill — invisible.
|
|
1135
|
-
Checkbox: Checkbox
|
|
1136
|
+
Checkbox: ext<typeof Checkbox>({
|
|
1136
1137
|
defaultProps: { attributes: { label: HIT_ATTR } },
|
|
1137
1138
|
vars: (theme, props) => ({
|
|
1138
1139
|
root: {
|
|
@@ -1143,7 +1144,7 @@ function buildTheme(data: PaletteData, options: BuildThemeOptions = {}): Mantine
|
|
|
1143
1144
|
},
|
|
1144
1145
|
}),
|
|
1145
1146
|
}),
|
|
1146
|
-
Radio: Radio
|
|
1147
|
+
Radio: ext<typeof Radio>({
|
|
1147
1148
|
defaultProps: { attributes: { label: HIT_ATTR } },
|
|
1148
1149
|
vars: (theme, props) => ({
|
|
1149
1150
|
root: {
|
|
@@ -1152,7 +1153,7 @@ function buildTheme(data: PaletteData, options: BuildThemeOptions = {}): Mantine
|
|
|
1152
1153
|
},
|
|
1153
1154
|
}),
|
|
1154
1155
|
}),
|
|
1155
|
-
Pagination: Pagination
|
|
1156
|
+
Pagination: ext<typeof Pagination>({
|
|
1156
1157
|
vars: (theme, props) => ({
|
|
1157
1158
|
root: { '--pagination-active-color': onColorFor(theme, props) },
|
|
1158
1159
|
}),
|
|
@@ -1160,28 +1161,28 @@ function buildTheme(data: PaletteData, options: BuildThemeOptions = {}): Mantine
|
|
|
1160
1161
|
// `Pagination`'s own controls (prev/next/page buttons) resolve `PaginationControl`'s
|
|
1161
1162
|
// defaultProps independently of the parent — `data-basalt-hit` here is what closes the
|
|
1162
1163
|
// gap Switch/Checkbox/Radio already close at their own theme entries.
|
|
1163
|
-
PaginationControl: PaginationControl
|
|
1164
|
+
PaginationControl: ext<typeof PaginationControl>({
|
|
1164
1165
|
defaultProps: { ...HIT_ATTR },
|
|
1165
1166
|
}),
|
|
1166
|
-
Stepper: Stepper
|
|
1167
|
+
Stepper: ext<typeof Stepper>({
|
|
1167
1168
|
vars: (theme, props) => ({ root: { '--stepper-icon-color': onColorFor(theme, props) } }),
|
|
1168
1169
|
}),
|
|
1169
|
-
Indicator: Indicator
|
|
1170
|
+
Indicator: ext<typeof Indicator>({
|
|
1170
1171
|
vars: (theme, props) => ({ root: { '--indicator-text-color': onColorFor(theme, props) } }),
|
|
1171
1172
|
}),
|
|
1172
1173
|
// Accordion (default variant): hairline separators between items only — the color retune AND
|
|
1173
1174
|
// the last item's outer border-bottom drop both live in controls.module.css.
|
|
1174
|
-
Accordion: Accordion
|
|
1175
|
+
Accordion: ext<typeof Accordion>({ classNames: { item: controlsClasses.accordionItem } }),
|
|
1175
1176
|
// Parents faint, separator line-colored — the current-page treatment (head font, weight) is a
|
|
1176
1177
|
// shell-level concern (AppBreadcrumbs), not this generic Mantine primitive.
|
|
1177
|
-
Breadcrumbs: Breadcrumbs
|
|
1178
|
+
Breadcrumbs: ext<typeof Breadcrumbs>({
|
|
1178
1179
|
styles: {
|
|
1179
1180
|
breadcrumb: { color: 'var(--vx-faint)' },
|
|
1180
1181
|
separator: { color: 'var(--vx-surface-border)' },
|
|
1181
1182
|
},
|
|
1182
1183
|
}),
|
|
1183
1184
|
// Card idiom — same panel + shadow-card as every other surface.
|
|
1184
|
-
Notification: Notification
|
|
1185
|
+
Notification: ext<typeof Notification>({
|
|
1185
1186
|
defaultProps: { radius: radius.floating },
|
|
1186
1187
|
styles: {
|
|
1187
1188
|
root: {
|
|
@@ -1484,7 +1485,7 @@ function buildCssVariablesResolver(data: PaletteData): CSSVariablesResolver {
|
|
|
1484
1485
|
// Links: Mantine reads the accent FILL shade (4.38:1 on the light page, under WCAG AA); the hover
|
|
1485
1486
|
// accent is the next step darker and clears 4.5:1 on every light text surface.
|
|
1486
1487
|
'--mantine-color-anchor': 'var(--vx-accent-hover)',
|
|
1487
|
-
// `--app-shell-border-color` is set by `components.AppShell
|
|
1488
|
+
// `--app-shell-border-color` is set by `components.AppShell` `vars` above — this
|
|
1488
1489
|
// entry was dead (an element-level declaration always beats an inherited `:root` value).
|
|
1489
1490
|
// THE strict-surface lever. Mantine components do NOT chain border/surface colors through
|
|
1490
1491
|
// `--mantine-color-default-*`; each hardcodes a RAW ramp step (`--mantine-color-gray-{2,3,4}`
|
package/src/unwrap.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `unwrap` — the transport-agnostic `{ data, error }` envelope (Eden Treaty, a raw fetch wrapper)
|
|
3
|
+
* to data. Throws the `error` branch (any value that is not `null`/`undefined`) and, when there is
|
|
4
|
+
* no error, on `null`/`undefined` data: a 204 or a silent transport failure must not resolve.
|
|
5
|
+
*
|
|
6
|
+
* One generic signature with a conditional return, so a bare `.then(unwrap)` callback keeps its
|
|
7
|
+
* type (an overload pair resolves to `unknown` there). Pinned by `unwrap.type-guard.test.ts`.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* queryFn: () => unwrap(api.users.get({ query: params }))
|
|
11
|
+
* const rows = unwrap(await api.users.get())
|
|
12
|
+
* const rows2 = await api.users.get().then(unwrap)
|
|
13
|
+
*/
|
|
14
|
+
export function unwrap<R extends Envelope | PromiseLike<Envelope>>(response: R): UnwrapResult<R> {
|
|
15
|
+
// `Promise.resolve` adopts any thenable, so the result is a real Promise.
|
|
16
|
+
const result = isThenable(response)
|
|
17
|
+
? Promise.resolve(response).then(unwrapEnvelope)
|
|
18
|
+
: unwrapEnvelope(response)
|
|
19
|
+
return result as UnwrapResult<R>
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function isThenable(value: Envelope | PromiseLike<Envelope>): value is PromiseLike<Envelope> {
|
|
23
|
+
return typeof (value as { then?: unknown }).then === 'function'
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
type Envelope<TData = unknown> = { data: TData | null | undefined; error: unknown }
|
|
27
|
+
|
|
28
|
+
/** A `Promise<TData>` for a promised envelope, `TData` for a resolved one; `NonNullable` is applied
|
|
29
|
+
* to the inferred `data` so it distributes over Eden's union of envelope shapes. */
|
|
30
|
+
type UnwrapResult<R> =
|
|
31
|
+
R extends PromiseLike<{ data: infer TData; error: unknown }>
|
|
32
|
+
? Promise<NonNullable<TData>>
|
|
33
|
+
: R extends { data: infer TData; error: unknown }
|
|
34
|
+
? NonNullable<TData>
|
|
35
|
+
: never
|
|
36
|
+
|
|
37
|
+
function unwrapEnvelope<TData>({ data, error }: Envelope<TData>): TData {
|
|
38
|
+
if (error !== null && error !== undefined) throw error
|
|
39
|
+
if (data === null || data === undefined)
|
|
40
|
+
throw new Error(
|
|
41
|
+
'unwrap: null/undefined data with no error — check for a 204 response or a transport failure',
|
|
42
|
+
)
|
|
43
|
+
return data
|
|
44
|
+
}
|