@xaui/native 0.9.1-alpha.0 → 0.9.1-alpha.2

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.
@@ -0,0 +1,174 @@
1
+ import { g as XAUITheme, X as XAUIColors } from '../theme.type-B3ODSLbB.js';
2
+ import { ViewStyle, TextStyle } from 'react-native';
3
+ import * as react from 'react';
4
+ import { ReactNode, Provider, Ref, RefCallback } from 'react';
5
+
6
+ /**
7
+ * A slot is a view or a text node, and a recipe writes one object per slot, so the two
8
+ * RN style shapes are merged rather than discriminated per slot.
9
+ */
10
+ type SlotStyle = ViewStyle & TextStyle;
11
+ type SlotStyles<Slot extends string> = Partial<Record<Slot, SlotStyle>>;
12
+ /** The roles a variant consumes. The variant names tokens; `paint` says where they land. */
13
+ type VariantRole = 'bg' | 'bgPressed' | 'fg' | 'border';
14
+ /** Token names per role — no colour value ever appears in a recipe. */
15
+ type VariantTokens = Partial<Record<VariantRole, keyof XAUIColors>>;
16
+ /** The same roles resolved: theme colours, or the slices of a raw `color`. */
17
+ type VariantColors = Partial<Record<VariantRole, string>>;
18
+ /**
19
+ * `disabled` is applied last of the three: a control that is both pressed and disabled
20
+ * has to read disabled.
21
+ */
22
+ type StateName = 'focused' | 'pressed' | 'disabled';
23
+ type States = Partial<Record<StateName, boolean>>;
24
+ /** Reads the theme and the variant's resolved colours; returns one style per slot. */
25
+ type StyleFn<Slot extends string> = (theme: XAUITheme, colors: VariantColors) => SlotStyles<Slot>;
26
+ /** Named axes of finite token values — `{ size: { sm: fn, md: fn } }`. */
27
+ type Axes<Slot extends string> = Record<string, Record<string, StyleFn<Slot>>>;
28
+ /** One value per axis, plus the variant. Missing keys fall back to `defaultVariants`. */
29
+ type Selection<Variant extends string, A extends Axes<string>> = {
30
+ variant?: Variant;
31
+ } & {
32
+ [Axis in keyof A]?: Extract<keyof A[Axis], string>;
33
+ };
34
+ type CompoundVariant<Slot extends string, Variant extends string, A extends Axes<Slot>> = {
35
+ when: Selection<Variant, A>;
36
+ style: StyleFn<Slot>;
37
+ };
38
+ type RecipeConfig<Slot extends string, Variant extends string, A extends Axes<Slot>> = {
39
+ /** Every slot the component publishes. Slots a recipe never styles resolve to `{}`. */
40
+ slots: readonly Slot[];
41
+ base?: StyleFn<Slot>;
42
+ variantTokens?: Record<Variant, VariantTokens>;
43
+ /** Where the variant's colours land — written once, and it holds for every variant. */
44
+ paint?: StyleFn<Slot>;
45
+ variants?: A;
46
+ compoundVariants?: ReadonlyArray<CompoundVariant<Slot, Variant, A>>;
47
+ states?: Partial<Record<StateName, StyleFn<Slot>>>;
48
+ defaultVariants?: Selection<Variant, A>;
49
+ };
50
+ /** Stable references: the same object for the same tokens, for the app's lifetime. */
51
+ type ResolvedStyles<Slot extends string> = Readonly<Record<Slot, SlotStyle>>;
52
+ /** A selection with `defaultVariants` already folded in, keyed by axis name. */
53
+ type ResolvedSelection = Readonly<Record<string, string | undefined>>;
54
+
55
+ type ResolveArgs<Variant extends string, A extends Axes<string>> = {
56
+ theme: XAUITheme;
57
+ selection?: Selection<Variant, A>;
58
+ states?: States;
59
+ };
60
+ type TintArgs<Variant extends string, A extends Axes<string>> = ResolveArgs<Variant, A> & {
61
+ color: string;
62
+ };
63
+ type Recipe<Slot extends string, Variant extends string, A extends Axes<Slot>> = {
64
+ readonly slots: readonly Slot[];
65
+ /** The cached pass: stable `StyleSheet` references, keyed by tokens alone. */
66
+ resolve(args: ResolveArgs<Variant, A>): ResolvedStyles<Slot>;
67
+ /**
68
+ * The tint pass: the same functions run again with `color`'s slices in place of the
69
+ * theme's tokens. Uncached and allocating, and only ever called when `color` is set.
70
+ */
71
+ tint(args: TintArgs<Variant, A>): SlotStyles<Slot>;
72
+ };
73
+ /**
74
+ * A component's style, declared once. Resolution splits in two because the two halves
75
+ * have different lifetimes: everything keyed by a finite token is cached forever, and
76
+ * an arbitrary `color` is recomputed per render — which is what keeps the cache bounded
77
+ * by the number of token combinations rather than by the palette users invent.
78
+ *
79
+ * const styles = buttonRecipe.resolve({ theme, selection: { variant, size }, states })
80
+ * const tint = color ? buttonRecipe.tint({ theme, color, selection, states }) : undefined
81
+ * <View style={[styles.root, tint?.root, style]} />
82
+ */
83
+ declare function createRecipe<Slot extends string, Variant extends string, const A extends Axes<Slot>>(config: RecipeConfig<Slot, Variant, A>): Recipe<Slot, Variant, A>;
84
+
85
+ /**
86
+ * R3: the string a root should wrap in its default text slot, or `null` when it should
87
+ * render its children as they are.
88
+ *
89
+ * The whole tree is stringified recursively rather than the first child inspected. That
90
+ * is what makes `<Button>{count} items</Button>` work — children there are the array
91
+ * `[3, ' items']`, and an `isValidElement` check on the first entry would call it an
92
+ * element-free tree only by accident, while a check for "is the first child a string"
93
+ * would miss it outright.
94
+ *
95
+ * `null` for an empty result as much as for a tree containing an element: in both cases
96
+ * there is nothing to wrap, and a root's fallback — render the children — is right for
97
+ * both. It also keeps `<Button>{false}</Button>` from mounting an empty text node.
98
+ */
99
+ declare function childrenToString(children: ReactNode): string | null;
100
+
101
+ /**
102
+ * A context a slot cannot read by accident. Every compound gets one, and it carries
103
+ * **resolved** values — style references the root already computed, not tokens for the
104
+ * slot to resolve again (R5).
105
+ *
106
+ * ```ts
107
+ * const [ButtonProvider, useButton] = createSlotContext<ButtonContext>('Button')
108
+ * ```
109
+ *
110
+ * The tuple is what lets each compound name its own hook, which R10 requires it to
111
+ * export. `name` gives both halves of the error, so there is one place to spell it.
112
+ */
113
+ declare function createSlotContext<T>(name: string): readonly [Provider<T | null>, () => T];
114
+
115
+ /** Anything React accepts as a ref, plus the absence of one. */
116
+ type PossibleRef<T> = Ref<T> | undefined;
117
+ /**
118
+ * The props `mergeProps` knows how to combine. Deliberately loose: it merges whatever a
119
+ * root hands to whatever child it was given, and neither side is knowable from here.
120
+ */
121
+ type MergeableProps = Record<string, unknown>;
122
+ type AsChildProps = {
123
+ /**
124
+ * Merge this component's props into its single child instead of rendering an element
125
+ * of its own — a navigation `Link` as a `Button`, a bespoke trigger as a `Select`.
126
+ */
127
+ asChild?: boolean;
128
+ };
129
+
130
+ /**
131
+ * Merges a root's own props into the child it renders through `asChild` (R12). Four
132
+ * rules, and the child wins wherever they do not apply — it is the more specific intent:
133
+ *
134
+ * - **Event handlers compose.** Both run, ours first: the component's own behaviour (the
135
+ * press state that drives its styles) happens before the child's side effect (the
136
+ * navigation). Replacing one with the other is the bug this exists to prevent.
137
+ * - **Styles stack**, ours under the child's, so the child can override.
138
+ * - **`ref`s merge** through `mergeRefs`. React 19 passes `ref` as an ordinary prop, so
139
+ * it arrives here rather than beside the props, and dropping it would sever the root's
140
+ * handle on the node.
141
+ * - **Everything else: the child's value wins**, and ours fills in what it left unset.
142
+ */
143
+ declare function mergeProps(ours: MergeableProps, theirs: MergeableProps): MergeableProps;
144
+
145
+ /**
146
+ * One callback that feeds several refs — what lets a root keep its own handle on a node
147
+ * while still honouring the ref its caller passed (R9), and what `asChild` needs to
148
+ * forward a ref into the child it merges into (R12).
149
+ *
150
+ * It returns nothing on purpose. React 19 reads a ref callback's return value as a
151
+ * cleanup function while React 18 ignores it, and this package supports both; letting
152
+ * a merged cleanup through would behave differently on each. React calls every ref with
153
+ * `null` on unmount anyway, which this forwards.
154
+ */
155
+ declare function mergeRefs<T>(...refs: Array<PossibleRef<T>>): RefCallback<T>;
156
+
157
+ type SlotProps = MergeableProps & {
158
+ children?: ReactNode;
159
+ };
160
+ /**
161
+ * The render branch behind `asChild` (R12). A root picks it instead of its own element:
162
+ *
163
+ * ```tsx
164
+ * const Root = asChild ? Slot : Pressable
165
+ * return <Root ref={ref} {...rootProps}>{children}</Root>
166
+ * ```
167
+ *
168
+ * One line per root, which is the point — forty-seven roots each hand-rolling a
169
+ * `cloneElement` and a ref merge would drift, and R12 has to hold uniformly from the
170
+ * first component or the ref signature of the whole core changes later.
171
+ */
172
+ declare const Slot: react.ForwardRefExoticComponent<Omit<SlotProps, "ref"> & react.RefAttributes<unknown>>;
173
+
174
+ export { type AsChildProps, type Axes, type CompoundVariant, type MergeableProps, type PossibleRef, type Recipe, type RecipeConfig, type ResolveArgs, type ResolvedSelection, type ResolvedStyles, type Selection, Slot, type SlotProps, type SlotStyle, type SlotStyles, type StateName, type States, type StyleFn, type TintArgs, type VariantColors, type VariantRole, type VariantTokens, childrenToString, createRecipe, createSlotContext, mergeProps, mergeRefs };
@@ -0,0 +1,17 @@
1
+ import {
2
+ Slot,
3
+ childrenToString,
4
+ createRecipe,
5
+ createSlotContext,
6
+ mergeProps,
7
+ mergeRefs
8
+ } from "../chunk-RCP3SD26.js";
9
+ import "../chunk-RBNCR5KB.js";
10
+ export {
11
+ Slot,
12
+ childrenToString,
13
+ createRecipe,
14
+ createSlotContext,
15
+ mergeProps,
16
+ mergeRefs
17
+ };
@@ -13,9 +13,10 @@
13
13
 
14
14
 
15
15
 
16
- var _chunkJDS6KGCMcjs = require('../chunk-JDS6KGCM.cjs');
16
+ var _chunkNHPQQQ7Pcjs = require('../chunk-NHPQQQ7P.cjs');
17
17
 
18
18
 
19
+ var _chunkM7P46XKIcjs = require('../chunk-M7P46XKI.cjs');
19
20
 
20
21
 
21
22
 
@@ -29,4 +30,7 @@ var _chunkJDS6KGCMcjs = require('../chunk-JDS6KGCM.cjs');
29
30
 
30
31
 
31
32
 
32
- exports.ThemeContext = _chunkJDS6KGCMcjs.ThemeContext; exports.XAUIProvider = _chunkJDS6KGCMcjs.XAUIProvider; exports.buildRadius = _chunkJDS6KGCMcjs.buildRadius; exports.buildShadows = _chunkJDS6KGCMcjs.buildShadows; exports.createTheme = _chunkJDS6KGCMcjs.createTheme; exports.defaultTheme = _chunkJDS6KGCMcjs.defaultTheme; exports.deriveColors = _chunkJDS6KGCMcjs.deriveColors; exports.palette = _chunkJDS6KGCMcjs.palette; exports.primitives = _chunkJDS6KGCMcjs.primitives; exports.sourceKeys = _chunkJDS6KGCMcjs.sourceKeys; exports.tokens = _chunkJDS6KGCMcjs.tokens; exports.useColorMode = _chunkJDS6KGCMcjs.useColorMode; exports.useThemeColor = _chunkJDS6KGCMcjs.useThemeColor; exports.useXAUITheme = _chunkJDS6KGCMcjs.useXAUITheme;
33
+
34
+
35
+
36
+ exports.ThemeContext = _chunkNHPQQQ7Pcjs.ThemeContext; exports.XAUIProvider = _chunkNHPQQQ7Pcjs.XAUIProvider; exports.buildRadius = _chunkNHPQQQ7Pcjs.buildRadius; exports.buildShadows = _chunkNHPQQQ7Pcjs.buildShadows; exports.createTheme = _chunkNHPQQQ7Pcjs.createTheme; exports.defaultTheme = _chunkNHPQQQ7Pcjs.defaultTheme; exports.deriveColors = _chunkNHPQQQ7Pcjs.deriveColors; exports.deriveTint = _chunkM7P46XKIcjs.deriveTint; exports.palette = _chunkNHPQQQ7Pcjs.palette; exports.primitives = _chunkNHPQQQ7Pcjs.primitives; exports.sourceKeys = _chunkNHPQQQ7Pcjs.sourceKeys; exports.tokens = _chunkNHPQQQ7Pcjs.tokens; exports.useColorMode = _chunkNHPQQQ7Pcjs.useColorMode; exports.useThemeColor = _chunkNHPQQQ7Pcjs.useThemeColor; exports.useXAUITheme = _chunkNHPQQQ7Pcjs.useXAUITheme;
@@ -1,157 +1,7 @@
1
1
  import * as react from 'react';
2
2
  import { ReactNode } from 'react';
3
-
4
- /** The source layer the only surface a consumer writes by hand, per mode. */
5
- type XAUISourceColors = {
6
- background: string;
7
- foreground: string;
8
- surface: string;
9
- surfaceForeground: string;
10
- surfaceSecondary: string;
11
- surfaceSecondaryForeground: string;
12
- surfaceTertiary: string;
13
- surfaceTertiaryForeground: string;
14
- overlay: string;
15
- overlayForeground: string;
16
- backdrop: string;
17
- muted: string;
18
- default: string;
19
- defaultForeground: string;
20
- accent: string;
21
- accentForeground: string;
22
- fieldBackground: string;
23
- fieldForeground: string;
24
- fieldPlaceholder: string;
25
- fieldBorder: string;
26
- success: string;
27
- successForeground: string;
28
- warning: string;
29
- warningForeground: string;
30
- danger: string;
31
- dangerForeground: string;
32
- segment: string;
33
- segmentForeground: string;
34
- border: string;
35
- separator: string;
36
- focus: string;
37
- link: string;
38
- };
39
- /** The derived layer — computed by `deriveColors`, never written by hand. */
40
- type XAUIDerivedColors = {
41
- accentPressed: string;
42
- successPressed: string;
43
- warningPressed: string;
44
- dangerPressed: string;
45
- defaultPressed: string;
46
- surfacePressed: string;
47
- defaultSoft: string;
48
- defaultSoftForeground: string;
49
- defaultSoftPressed: string;
50
- accentSoft: string;
51
- accentSoftForeground: string;
52
- accentSoftPressed: string;
53
- successSoft: string;
54
- successSoftForeground: string;
55
- successSoftPressed: string;
56
- warningSoft: string;
57
- warningSoftForeground: string;
58
- warningSoftPressed: string;
59
- dangerSoft: string;
60
- dangerSoftForeground: string;
61
- dangerSoftPressed: string;
62
- backgroundSecondary: string;
63
- backgroundTertiary: string;
64
- backgroundInverse: string;
65
- borderSecondary: string;
66
- borderTertiary: string;
67
- separatorSecondary: string;
68
- separatorTertiary: string;
69
- fieldPressed: string;
70
- fieldFocus: string;
71
- fieldBorderPressed: string;
72
- fieldBorderFocus: string;
73
- };
74
- /** Constant across both modes. */
75
- type XAUIPrimitiveColors = {
76
- white: string;
77
- black: string;
78
- snow: string;
79
- eclipse: string;
80
- };
81
- /** Everything a component reads, flattened. */
82
- type XAUIColors = XAUISourceColors & XAUIDerivedColors & XAUIPrimitiveColors;
83
- type ColorMode = 'light' | 'dark';
84
- type Size = 'xs' | 'sm' | 'md' | 'lg';
85
- type RadiusKey = 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl' | '3xl' | '4xl' | 'field' | 'full';
86
- type FontSizeKey = Size | 'xl' | '2xl' | '3xl' | '4xl';
87
- type FontWeightKey = 'regular' | 'medium' | 'semibold' | 'bold';
88
- type XAUIRadius = Record<RadiusKey, number>;
89
- type XAUIShadow = {
90
- shadowColor: string;
91
- shadowOffset: {
92
- width: number;
93
- height: number;
94
- };
95
- shadowOpacity: number;
96
- shadowRadius: number;
97
- elevation: number;
98
- };
99
- type XAUITheme = {
100
- id: string;
101
- mode: ColorMode;
102
- colors: XAUIColors;
103
- /** Base 4 — `spacing(3) === 12`. A function, so there is no "what do we call 12px". */
104
- spacing: (steps: number) => number;
105
- radius: XAUIRadius;
106
- borderWidth: {
107
- default: number;
108
- field: number;
109
- };
110
- fontSizes: Record<FontSizeKey, number>;
111
- lineHeights: Record<FontSizeKey, number>;
112
- fontWeights: Record<FontWeightKey, string>;
113
- fontFamilies: {
114
- body: string;
115
- heading: string;
116
- mono: string;
117
- };
118
- /** Semantic roles, not a scale: dark mode drops the surface shadow entirely. */
119
- shadows: {
120
- surface: XAUIShadow;
121
- overlay: XAUIShadow;
122
- field: XAUIShadow;
123
- };
124
- opacity: {
125
- disabled: number;
126
- };
127
- controlHeights: Record<Size, number>;
128
- };
129
- type XAUIThemeConfig = {
130
- colors?: {
131
- light?: Partial<XAUISourceColors & XAUIDerivedColors>;
132
- dark?: Partial<XAUISourceColors & XAUIDerivedColors>;
133
- };
134
- /** The single base the whole radius scale derives from. */
135
- radius?: number;
136
- spacingUnit?: number;
137
- borderWidth?: Partial<XAUITheme['borderWidth']>;
138
- fontSizes?: Partial<XAUITheme['fontSizes']>;
139
- lineHeights?: Partial<XAUITheme['lineHeights']>;
140
- fontWeights?: Partial<XAUITheme['fontWeights']>;
141
- fontFamilies?: Partial<XAUITheme['fontFamilies']>;
142
- /** Per role, and `shadowOffset` is replaced whole — a half-set offset is not a shadow. */
143
- shadows?: {
144
- [K in keyof XAUITheme['shadows']]?: Partial<XAUIShadow>;
145
- };
146
- opacity?: Partial<XAUITheme['opacity']>;
147
- controlHeights?: Partial<XAUITheme['controlHeights']>;
148
- };
149
- /** What `createTheme` returns: both modes, resolved, sharing one id. */
150
- type XAUIThemeSet = {
151
- id: string;
152
- light: XAUITheme;
153
- dark: XAUITheme;
154
- };
3
+ import { i as XAUIThemeSet, h as XAUIThemeConfig, f as XAUISourceColors, b as XAUIDerivedColors, g as XAUITheme, d as XAUIRadius, C as ColorMode, X as XAUIColors } from '../theme.type-B3ODSLbB.cjs';
4
+ export { F as FontSizeKey, a as FontWeightKey, R as RadiusKey, S as Size, c as XAUIPrimitiveColors, e as XAUIShadow } from '../theme.type-B3ODSLbB.cjs';
155
5
 
156
6
  /** `'system'` follows the device; the resolved value is never `'system'`. */
157
7
  type ColorModePreference = 'light' | 'dark' | 'system';
@@ -196,6 +46,26 @@ declare const defaultTheme: XAUIThemeSet;
196
46
  */
197
47
  declare function deriveColors(s: XAUISourceColors): XAUIDerivedColors;
198
48
 
49
+ /**
50
+ * A raw tint, expanded into the slices a variant consumes. One `color` gives the base;
51
+ * the other five come out of the same OKLab formulas as `deriveColors`, so a free tint
52
+ * behaves exactly like `accent` or `danger` — same ratios, same rendering — instead of
53
+ * following a parallel mechanic.
54
+ */
55
+ type XAUITint = {
56
+ base: string;
57
+ foreground: string;
58
+ soft: string;
59
+ softForeground: string;
60
+ pressed: string;
61
+ softPressed: string;
62
+ };
63
+ /**
64
+ * Memoized per tint *and* theme: sRGB → OKLab → sRGB is not free per render, and
65
+ * `softForeground` mixes with the theme's `foreground`, which differs between modes.
66
+ */
67
+ declare function deriveTint(tint: string, theme: XAUITheme): XAUITint;
68
+
199
69
  /**
200
70
  * The raw palette — Tailwind's scale, 22 families x 11 shades.
201
71
  *
@@ -666,4 +536,4 @@ declare function useColorMode(): ColorMode;
666
536
  declare function useThemeColor(token: keyof XAUIColors): string;
667
537
  declare function useThemeColor(tokens: Array<keyof XAUIColors>): string[];
668
538
 
669
- export { type ColorMode, type ColorModePreference, type FontSizeKey, type FontWeightKey, type PaletteFamily, type PaletteShade, type RadiusKey, type Size, ThemeContext, type XAUIColors, type XAUIDerivedColors, type XAUIPrimitiveColors, XAUIProvider, type XAUIProviderProps, type XAUIRadius, type XAUIShadow, type XAUISourceColors, type XAUITheme, type XAUIThemeConfig, type XAUIThemeSet, buildRadius, buildShadows, createTheme, defaultTheme, deriveColors, palette, primitives, sourceKeys, tokens, useColorMode, useThemeColor, useXAUITheme };
539
+ export { ColorMode, type ColorModePreference, type PaletteFamily, type PaletteShade, ThemeContext, XAUIColors, XAUIDerivedColors, XAUIProvider, type XAUIProviderProps, XAUIRadius, XAUISourceColors, XAUITheme, XAUIThemeConfig, XAUIThemeSet, type XAUITint, buildRadius, buildShadows, createTheme, defaultTheme, deriveColors, deriveTint, palette, primitives, sourceKeys, tokens, useColorMode, useThemeColor, useXAUITheme };
@@ -1,157 +1,7 @@
1
1
  import * as react from 'react';
2
2
  import { ReactNode } from 'react';
3
-
4
- /** The source layer the only surface a consumer writes by hand, per mode. */
5
- type XAUISourceColors = {
6
- background: string;
7
- foreground: string;
8
- surface: string;
9
- surfaceForeground: string;
10
- surfaceSecondary: string;
11
- surfaceSecondaryForeground: string;
12
- surfaceTertiary: string;
13
- surfaceTertiaryForeground: string;
14
- overlay: string;
15
- overlayForeground: string;
16
- backdrop: string;
17
- muted: string;
18
- default: string;
19
- defaultForeground: string;
20
- accent: string;
21
- accentForeground: string;
22
- fieldBackground: string;
23
- fieldForeground: string;
24
- fieldPlaceholder: string;
25
- fieldBorder: string;
26
- success: string;
27
- successForeground: string;
28
- warning: string;
29
- warningForeground: string;
30
- danger: string;
31
- dangerForeground: string;
32
- segment: string;
33
- segmentForeground: string;
34
- border: string;
35
- separator: string;
36
- focus: string;
37
- link: string;
38
- };
39
- /** The derived layer — computed by `deriveColors`, never written by hand. */
40
- type XAUIDerivedColors = {
41
- accentPressed: string;
42
- successPressed: string;
43
- warningPressed: string;
44
- dangerPressed: string;
45
- defaultPressed: string;
46
- surfacePressed: string;
47
- defaultSoft: string;
48
- defaultSoftForeground: string;
49
- defaultSoftPressed: string;
50
- accentSoft: string;
51
- accentSoftForeground: string;
52
- accentSoftPressed: string;
53
- successSoft: string;
54
- successSoftForeground: string;
55
- successSoftPressed: string;
56
- warningSoft: string;
57
- warningSoftForeground: string;
58
- warningSoftPressed: string;
59
- dangerSoft: string;
60
- dangerSoftForeground: string;
61
- dangerSoftPressed: string;
62
- backgroundSecondary: string;
63
- backgroundTertiary: string;
64
- backgroundInverse: string;
65
- borderSecondary: string;
66
- borderTertiary: string;
67
- separatorSecondary: string;
68
- separatorTertiary: string;
69
- fieldPressed: string;
70
- fieldFocus: string;
71
- fieldBorderPressed: string;
72
- fieldBorderFocus: string;
73
- };
74
- /** Constant across both modes. */
75
- type XAUIPrimitiveColors = {
76
- white: string;
77
- black: string;
78
- snow: string;
79
- eclipse: string;
80
- };
81
- /** Everything a component reads, flattened. */
82
- type XAUIColors = XAUISourceColors & XAUIDerivedColors & XAUIPrimitiveColors;
83
- type ColorMode = 'light' | 'dark';
84
- type Size = 'xs' | 'sm' | 'md' | 'lg';
85
- type RadiusKey = 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl' | '3xl' | '4xl' | 'field' | 'full';
86
- type FontSizeKey = Size | 'xl' | '2xl' | '3xl' | '4xl';
87
- type FontWeightKey = 'regular' | 'medium' | 'semibold' | 'bold';
88
- type XAUIRadius = Record<RadiusKey, number>;
89
- type XAUIShadow = {
90
- shadowColor: string;
91
- shadowOffset: {
92
- width: number;
93
- height: number;
94
- };
95
- shadowOpacity: number;
96
- shadowRadius: number;
97
- elevation: number;
98
- };
99
- type XAUITheme = {
100
- id: string;
101
- mode: ColorMode;
102
- colors: XAUIColors;
103
- /** Base 4 — `spacing(3) === 12`. A function, so there is no "what do we call 12px". */
104
- spacing: (steps: number) => number;
105
- radius: XAUIRadius;
106
- borderWidth: {
107
- default: number;
108
- field: number;
109
- };
110
- fontSizes: Record<FontSizeKey, number>;
111
- lineHeights: Record<FontSizeKey, number>;
112
- fontWeights: Record<FontWeightKey, string>;
113
- fontFamilies: {
114
- body: string;
115
- heading: string;
116
- mono: string;
117
- };
118
- /** Semantic roles, not a scale: dark mode drops the surface shadow entirely. */
119
- shadows: {
120
- surface: XAUIShadow;
121
- overlay: XAUIShadow;
122
- field: XAUIShadow;
123
- };
124
- opacity: {
125
- disabled: number;
126
- };
127
- controlHeights: Record<Size, number>;
128
- };
129
- type XAUIThemeConfig = {
130
- colors?: {
131
- light?: Partial<XAUISourceColors & XAUIDerivedColors>;
132
- dark?: Partial<XAUISourceColors & XAUIDerivedColors>;
133
- };
134
- /** The single base the whole radius scale derives from. */
135
- radius?: number;
136
- spacingUnit?: number;
137
- borderWidth?: Partial<XAUITheme['borderWidth']>;
138
- fontSizes?: Partial<XAUITheme['fontSizes']>;
139
- lineHeights?: Partial<XAUITheme['lineHeights']>;
140
- fontWeights?: Partial<XAUITheme['fontWeights']>;
141
- fontFamilies?: Partial<XAUITheme['fontFamilies']>;
142
- /** Per role, and `shadowOffset` is replaced whole — a half-set offset is not a shadow. */
143
- shadows?: {
144
- [K in keyof XAUITheme['shadows']]?: Partial<XAUIShadow>;
145
- };
146
- opacity?: Partial<XAUITheme['opacity']>;
147
- controlHeights?: Partial<XAUITheme['controlHeights']>;
148
- };
149
- /** What `createTheme` returns: both modes, resolved, sharing one id. */
150
- type XAUIThemeSet = {
151
- id: string;
152
- light: XAUITheme;
153
- dark: XAUITheme;
154
- };
3
+ import { i as XAUIThemeSet, h as XAUIThemeConfig, f as XAUISourceColors, b as XAUIDerivedColors, g as XAUITheme, d as XAUIRadius, C as ColorMode, X as XAUIColors } from '../theme.type-B3ODSLbB.js';
4
+ export { F as FontSizeKey, a as FontWeightKey, R as RadiusKey, S as Size, c as XAUIPrimitiveColors, e as XAUIShadow } from '../theme.type-B3ODSLbB.js';
155
5
 
156
6
  /** `'system'` follows the device; the resolved value is never `'system'`. */
157
7
  type ColorModePreference = 'light' | 'dark' | 'system';
@@ -196,6 +46,26 @@ declare const defaultTheme: XAUIThemeSet;
196
46
  */
197
47
  declare function deriveColors(s: XAUISourceColors): XAUIDerivedColors;
198
48
 
49
+ /**
50
+ * A raw tint, expanded into the slices a variant consumes. One `color` gives the base;
51
+ * the other five come out of the same OKLab formulas as `deriveColors`, so a free tint
52
+ * behaves exactly like `accent` or `danger` — same ratios, same rendering — instead of
53
+ * following a parallel mechanic.
54
+ */
55
+ type XAUITint = {
56
+ base: string;
57
+ foreground: string;
58
+ soft: string;
59
+ softForeground: string;
60
+ pressed: string;
61
+ softPressed: string;
62
+ };
63
+ /**
64
+ * Memoized per tint *and* theme: sRGB → OKLab → sRGB is not free per render, and
65
+ * `softForeground` mixes with the theme's `foreground`, which differs between modes.
66
+ */
67
+ declare function deriveTint(tint: string, theme: XAUITheme): XAUITint;
68
+
199
69
  /**
200
70
  * The raw palette — Tailwind's scale, 22 families x 11 shades.
201
71
  *
@@ -666,4 +536,4 @@ declare function useColorMode(): ColorMode;
666
536
  declare function useThemeColor(token: keyof XAUIColors): string;
667
537
  declare function useThemeColor(tokens: Array<keyof XAUIColors>): string[];
668
538
 
669
- export { type ColorMode, type ColorModePreference, type FontSizeKey, type FontWeightKey, type PaletteFamily, type PaletteShade, type RadiusKey, type Size, ThemeContext, type XAUIColors, type XAUIDerivedColors, type XAUIPrimitiveColors, XAUIProvider, type XAUIProviderProps, type XAUIRadius, type XAUIShadow, type XAUISourceColors, type XAUITheme, type XAUIThemeConfig, type XAUIThemeSet, buildRadius, buildShadows, createTheme, defaultTheme, deriveColors, palette, primitives, sourceKeys, tokens, useColorMode, useThemeColor, useXAUITheme };
539
+ export { ColorMode, type ColorModePreference, type PaletteFamily, type PaletteShade, ThemeContext, XAUIColors, XAUIDerivedColors, XAUIProvider, type XAUIProviderProps, XAUIRadius, XAUISourceColors, XAUITheme, XAUIThemeConfig, XAUIThemeSet, type XAUITint, buildRadius, buildShadows, createTheme, defaultTheme, deriveColors, deriveTint, palette, primitives, sourceKeys, tokens, useColorMode, useThemeColor, useXAUITheme };
@@ -13,7 +13,10 @@ import {
13
13
  useColorMode,
14
14
  useThemeColor,
15
15
  useXAUITheme
16
- } from "../chunk-T3ZI2PZ6.js";
16
+ } from "../chunk-PBVPOX7D.js";
17
+ import {
18
+ deriveTint
19
+ } from "../chunk-RBNCR5KB.js";
17
20
  export {
18
21
  ThemeContext,
19
22
  XAUIProvider,
@@ -22,6 +25,7 @@ export {
22
25
  createTheme,
23
26
  defaultTheme,
24
27
  deriveColors,
28
+ deriveTint,
25
29
  palette,
26
30
  primitives,
27
31
  sourceKeys,