@xaui/native 0.9.1-alpha.2 → 0.9.1-alpha.4
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/dist/{chunk-PBVPOX7D.js → chunk-2KXQATVL.js} +3 -27
- package/dist/{chunk-M7P46XKI.cjs → chunk-3QBT3Q65.cjs} +27 -2
- package/dist/{chunk-NHPQQQ7P.cjs → chunk-AW63PTQ4.cjs} +33 -57
- package/dist/chunk-ECDWSSHJ.js +688 -0
- package/dist/chunk-IYFGO523.cjs +688 -0
- package/dist/{chunk-RBNCR5KB.js → chunk-X2K2FX3W.js} +25 -0
- package/dist/index.cjs +32 -4
- package/dist/index.d.cts +4 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.js +36 -8
- package/dist/system/index.cjs +31 -3
- package/dist/system/index.d.cts +224 -3
- package/dist/system/index.d.ts +224 -3
- package/dist/system/index.js +32 -4
- package/dist/theme/index.cjs +3 -3
- package/dist/theme/index.d.cts +3 -2
- package/dist/theme/index.d.ts +3 -2
- package/dist/theme/index.js +6 -6
- package/dist/{theme.type-B3ODSLbB.d.cts → theme.type-C9bFJKFm.d.cts} +7 -1
- package/dist/{theme.type-B3ODSLbB.d.ts → theme.type-C9bFJKFm.d.ts} +7 -1
- package/package.json +1 -1
- package/dist/chunk-B755PRVJ.cjs +0 -274
- package/dist/chunk-RCP3SD26.js +0 -274
package/dist/system/index.d.ts
CHANGED
|
@@ -1,7 +1,228 @@
|
|
|
1
|
-
import { g as XAUITheme, X as XAUIColors } from '../theme.type-B3ODSLbB.js';
|
|
2
|
-
import { ViewStyle, TextStyle } from 'react-native';
|
|
3
1
|
import * as react from 'react';
|
|
4
2
|
import { ReactNode, Provider, Ref, RefCallback } from 'react';
|
|
3
|
+
import * as react_native from 'react-native';
|
|
4
|
+
import { PressableProps, StyleProp, ViewStyle, TextStyle } from 'react-native';
|
|
5
|
+
import { SharedValue } from 'react-native-reanimated';
|
|
6
|
+
import { g as XAUITheme, X as XAUIColors } from '../theme.type-C9bFJKFm.js';
|
|
7
|
+
|
|
8
|
+
type PortalProps = {
|
|
9
|
+
children: ReactNode;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Renders its children into the nearest `PortalHost` instead of where it sits. What
|
|
13
|
+
* `Dialog`, `Sheet`, `Drawer` and `Snackbar` are built on: an overlay has to escape the
|
|
14
|
+
* clipping and stacking of whatever container happened to hold the trigger.
|
|
15
|
+
*
|
|
16
|
+
* Both halves run in layout effects rather than effects, which is deliberate: the content
|
|
17
|
+
* lands in the same commit as the trigger's, so an overlay neither shows one frame late
|
|
18
|
+
* nor survives one frame past the unmount that closed it. The unpublish sits in its own
|
|
19
|
+
* effect so that it does not depend on `children` — a re-publish then keeps the portal's
|
|
20
|
+
* place in the host's order instead of dropping it and re-adding it at the end.
|
|
21
|
+
*/
|
|
22
|
+
declare function Portal({ children }: PortalProps): null;
|
|
23
|
+
declare namespace Portal {
|
|
24
|
+
var displayName: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
type PortalMethods = {
|
|
28
|
+
addPortal: (key: string, element: ReactNode) => void;
|
|
29
|
+
removePortal: (key: string) => void;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* `null` outside a host, and `Portal` treats that as "render nothing" rather than
|
|
33
|
+
* throwing: an app that forgot `PortalHost` should lose its overlays, not crash on the
|
|
34
|
+
* first `Dialog`.
|
|
35
|
+
*/
|
|
36
|
+
declare const PortalContext: react.Context<PortalMethods | null>;
|
|
37
|
+
|
|
38
|
+
type PortalHostProps = {
|
|
39
|
+
children: ReactNode;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Where every `Portal` in the tree below renders. Mounted once, at the root of the app,
|
|
43
|
+
* above navigation — an overlay that renders inside a screen is clipped by it.
|
|
44
|
+
*/
|
|
45
|
+
declare function PortalHost({ children }: PortalHostProps): react.JSX.Element;
|
|
46
|
+
declare namespace PortalHost {
|
|
47
|
+
var displayName: string;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* What the root does under the finger. `scale-highlight` and `scale-ripple` mount their
|
|
52
|
+
* overlay themselves; `scale` mounts none, which is what a root picks when it renders its
|
|
53
|
+
* own `<PressableFeedback.Highlight>` to style it (R1: no prop reaches into another
|
|
54
|
+
* component's insides).
|
|
55
|
+
*/
|
|
56
|
+
type FeedbackVariant = 'scale-highlight' | 'scale-ripple' | 'scale' | 'none';
|
|
57
|
+
type AnimationConfig = {
|
|
58
|
+
scale?: boolean;
|
|
59
|
+
highlight?: boolean;
|
|
60
|
+
ripple?: boolean;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* `false` and `'disabled'` turn this component's animations off. `'disable-all'` turns
|
|
64
|
+
* them off for its descendants too — a long list kills every row's worklets with one
|
|
65
|
+
* prop instead of threading it down. An object switches them off one at a time.
|
|
66
|
+
*/
|
|
67
|
+
type AnimationProp = boolean | 'disabled' | 'disable-all' | AnimationConfig;
|
|
68
|
+
/** `animation` once normalised — what the components actually read. */
|
|
69
|
+
type ResolvedAnimation = {
|
|
70
|
+
scale: boolean;
|
|
71
|
+
highlight: boolean;
|
|
72
|
+
ripple: boolean;
|
|
73
|
+
/** True when every sub-animation is off: the branch that mounts no worklet at all. */
|
|
74
|
+
none: boolean;
|
|
75
|
+
/** Propagated to descendants through context. */
|
|
76
|
+
disableAll: boolean;
|
|
77
|
+
};
|
|
78
|
+
type PressableFeedbackProps = Omit<PressableProps, 'style' | 'children' | 'disabled'> & {
|
|
79
|
+
/** Controlled: the root owns the state, because its recipe resolves on it (R5). */
|
|
80
|
+
isPressed?: boolean;
|
|
81
|
+
/** R8: `disabled` is not part of the public vocabulary, `isX` is. */
|
|
82
|
+
isDisabled?: boolean;
|
|
83
|
+
/**
|
|
84
|
+
* Merge into the single child instead of rendering a pressable (R12) — **keeping the
|
|
85
|
+
* feedback**. Swapping this component out for a bare `Slot` would silently drop the
|
|
86
|
+
* touch feedback of every `asChild` control.
|
|
87
|
+
*/
|
|
88
|
+
asChild?: boolean;
|
|
89
|
+
feedbackVariant?: FeedbackVariant;
|
|
90
|
+
animation?: AnimationProp;
|
|
91
|
+
style?: StyleProp<ViewStyle>;
|
|
92
|
+
/**
|
|
93
|
+
* `Pressable`'s function form is dropped on purpose. It exists to hand the press state
|
|
94
|
+
* to children; here the root above already owns that state and this publishes it
|
|
95
|
+
* through context, so the function form would be a second, quieter source of truth.
|
|
96
|
+
*/
|
|
97
|
+
children?: ReactNode;
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* A slot's own animation, overriding the blanket one on the root. `false` switches that
|
|
101
|
+
* slot off; the object tunes it. Deliberately two knobs rather than a full timing
|
|
102
|
+
* surface — anything past this is a different animation, and that is a component's job,
|
|
103
|
+
* not a prop's.
|
|
104
|
+
*/
|
|
105
|
+
type SlotAnimation = boolean | {
|
|
106
|
+
/** Milliseconds. Falls back to the shared press timing. */
|
|
107
|
+
duration?: number;
|
|
108
|
+
/** How far the overlay goes at full press, 0 to 1. */
|
|
109
|
+
opacity?: number;
|
|
110
|
+
};
|
|
111
|
+
type FeedbackContext = {
|
|
112
|
+
isPressed: boolean;
|
|
113
|
+
animation: ResolvedAnimation;
|
|
114
|
+
/** Absent on the static branch, where nothing animates and no worklet is mounted. */
|
|
115
|
+
progress?: SharedValue<number>;
|
|
116
|
+
/**
|
|
117
|
+
* Bumped on every press-in. The ripple starts from this rather than from a `useEffect`
|
|
118
|
+
* on `isPressed`: a one-shot driven by a boolean depends on React re-rendering between
|
|
119
|
+
* the two touch events, and starting it from the event that carries the coordinates is
|
|
120
|
+
* both simpler and impossible to miss.
|
|
121
|
+
*/
|
|
122
|
+
pressCount?: SharedValue<number>;
|
|
123
|
+
/** Where the finger landed, and how big the root is — the ripple needs both. */
|
|
124
|
+
origin?: SharedValue<{
|
|
125
|
+
x: number;
|
|
126
|
+
y: number;
|
|
127
|
+
}>;
|
|
128
|
+
size?: SharedValue<{
|
|
129
|
+
width: number;
|
|
130
|
+
height: number;
|
|
131
|
+
}>;
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
type PressableFeedbackHighlightProps = {
|
|
135
|
+
style?: StyleProp<ViewStyle>;
|
|
136
|
+
/** Overrides the blanket `animation` on the root, for this overlay only. */
|
|
137
|
+
animation?: SlotAnimation;
|
|
138
|
+
};
|
|
139
|
+
/**
|
|
140
|
+
* The press wash: one flat overlay fading in under the finger.
|
|
141
|
+
*
|
|
142
|
+
* It is a **neutral** wash, not the variant's pressed colour. A component picks one or
|
|
143
|
+
* the other — this overlay, or a `pressed` state in its recipe swapping `bg` for
|
|
144
|
+
* `bgPressed` — never both, or a pressed button darkens twice.
|
|
145
|
+
*/
|
|
146
|
+
declare function PressableFeedbackHighlight({ style, animation: override, }: PressableFeedbackHighlightProps): react.JSX.Element;
|
|
147
|
+
declare namespace PressableFeedbackHighlight {
|
|
148
|
+
var displayName: string;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
type PressableFeedbackRippleProps = {
|
|
152
|
+
style?: StyleProp<ViewStyle>;
|
|
153
|
+
/** Overrides the blanket `animation` on the root, for this overlay only. */
|
|
154
|
+
animation?: SlotAnimation;
|
|
155
|
+
};
|
|
156
|
+
/**
|
|
157
|
+
* A circle washing outwards from where the finger landed.
|
|
158
|
+
*
|
|
159
|
+
* It is a **one-shot, independent of how long the press lasts**: the wave runs its course
|
|
160
|
+
* and ends, the way a ripple in water does. Tying it to the press would leave a disc
|
|
161
|
+
* parked on the control for as long as a finger rests there.
|
|
162
|
+
*
|
|
163
|
+
* It needs the root to clip — `PressableFeedback` sets `overflow: 'hidden'` when it
|
|
164
|
+
* mounts one — and it renders nothing on the static branch: a ripple that cannot expand
|
|
165
|
+
* is a coloured disc sitting on the control, which reads as a defect rather than as
|
|
166
|
+
* reduced motion.
|
|
167
|
+
*/
|
|
168
|
+
declare function PressableFeedbackRipple({ style, animation: override, }: PressableFeedbackRippleProps): react.JSX.Element | null;
|
|
169
|
+
declare namespace PressableFeedbackRipple {
|
|
170
|
+
var displayName: string;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
declare const useFeedback: () => FeedbackContext;
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* The values the v0 tree shipped with (`Animated.spring` to `0.975`, `bounciness: 0`,
|
|
177
|
+
* over roughly 100ms). Kept identical on purpose: the touch feedback is the part of a
|
|
178
|
+
* library users feel rather than read, and changing its timing in a rewrite would be a
|
|
179
|
+
* regression nobody asked for. `bounciness: 0` is why a duration replaces the spring —
|
|
180
|
+
* a spring with no bounce is a curve.
|
|
181
|
+
*/
|
|
182
|
+
declare const PRESS_SCALE = 0.975;
|
|
183
|
+
declare const PRESS_DURATION = 100;
|
|
184
|
+
declare const RELEASE_DURATION = 150;
|
|
185
|
+
/** How far the wash and the ripple go at full press. */
|
|
186
|
+
declare const HIGHLIGHT_OPACITY = 0.08;
|
|
187
|
+
declare const RIPPLE_OPACITY = 0.12;
|
|
188
|
+
declare const RIPPLE_DURATION = 350;
|
|
189
|
+
/**
|
|
190
|
+
* The circle's radius as a multiple of the control's diagonal. Above 1 it covers from
|
|
191
|
+
* any point on the control, so where the finger landed never enters the calculation.
|
|
192
|
+
*/
|
|
193
|
+
declare const RIPPLE_COVERAGE = 1.25;
|
|
194
|
+
/**
|
|
195
|
+
* One shape out of four accepted ones, so the components read a record instead of
|
|
196
|
+
* re-deciding what `'disable-all'` meant.
|
|
197
|
+
*
|
|
198
|
+
* `inheritedDisableAll` comes from an ancestor that asked for it, and it wins: a list
|
|
199
|
+
* that switched its rows' animations off cannot be overridden by a row.
|
|
200
|
+
*/
|
|
201
|
+
declare function resolveAnimation(animation: AnimationProp | undefined, inheritedDisableAll?: boolean): ResolvedAnimation;
|
|
202
|
+
type ResolvedSlotAnimation = {
|
|
203
|
+
enabled: boolean;
|
|
204
|
+
duration: number;
|
|
205
|
+
opacity: number;
|
|
206
|
+
};
|
|
207
|
+
/**
|
|
208
|
+
* A slot's own `animation` over the root's blanket one, with the root winning when it
|
|
209
|
+
* switched everything off — `animation="disable-all"` on an ancestor cannot be undone by
|
|
210
|
+
* an overlay that asks nicely.
|
|
211
|
+
*/
|
|
212
|
+
declare function resolveSlotAnimation(override: SlotAnimation | undefined, enabledByRoot: boolean, defaultOpacity: number, defaultDuration?: number): ResolvedSlotAnimation;
|
|
213
|
+
|
|
214
|
+
declare const PressableFeedback: react.ForwardRefExoticComponent<Omit<react_native.PressableProps, "children" | "style" | "disabled"> & {
|
|
215
|
+
isPressed?: boolean;
|
|
216
|
+
isDisabled?: boolean;
|
|
217
|
+
asChild?: boolean;
|
|
218
|
+
feedbackVariant?: FeedbackVariant;
|
|
219
|
+
animation?: AnimationProp;
|
|
220
|
+
style?: react_native.StyleProp<react_native.ViewStyle>;
|
|
221
|
+
children?: react.ReactNode;
|
|
222
|
+
} & react.RefAttributes<react_native.View>> & {
|
|
223
|
+
Highlight: typeof PressableFeedbackHighlight;
|
|
224
|
+
Ripple: typeof PressableFeedbackRipple;
|
|
225
|
+
};
|
|
5
226
|
|
|
6
227
|
/**
|
|
7
228
|
* A slot is a view or a text node, and a recipe writes one object per slot, so the two
|
|
@@ -171,4 +392,4 @@ type SlotProps = MergeableProps & {
|
|
|
171
392
|
*/
|
|
172
393
|
declare const Slot: react.ForwardRefExoticComponent<Omit<SlotProps, "ref"> & react.RefAttributes<unknown>>;
|
|
173
394
|
|
|
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 };
|
|
395
|
+
export { type AnimationConfig, type AnimationProp, type AsChildProps, type Axes, type CompoundVariant, type FeedbackContext, type FeedbackVariant, HIGHLIGHT_OPACITY, type MergeableProps, PRESS_DURATION, PRESS_SCALE, Portal, PortalContext, PortalHost, type PortalHostProps, type PortalMethods, type PortalProps, type PossibleRef, PressableFeedback, type PressableFeedbackHighlightProps, type PressableFeedbackProps, type PressableFeedbackRippleProps, RELEASE_DURATION, RIPPLE_COVERAGE, RIPPLE_DURATION, RIPPLE_OPACITY, type Recipe, type RecipeConfig, type ResolveArgs, type ResolvedAnimation, type ResolvedSelection, type ResolvedStyles, type Selection, Slot, type SlotAnimation, 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, resolveAnimation, resolveSlotAnimation, useFeedback };
|
package/dist/system/index.js
CHANGED
|
@@ -1,17 +1,45 @@
|
|
|
1
1
|
import {
|
|
2
|
+
HIGHLIGHT_OPACITY,
|
|
3
|
+
PRESS_DURATION,
|
|
4
|
+
PRESS_SCALE,
|
|
5
|
+
Portal,
|
|
6
|
+
PortalContext,
|
|
7
|
+
PortalHost,
|
|
8
|
+
PressableFeedback,
|
|
9
|
+
RELEASE_DURATION,
|
|
10
|
+
RIPPLE_COVERAGE,
|
|
11
|
+
RIPPLE_DURATION,
|
|
12
|
+
RIPPLE_OPACITY,
|
|
2
13
|
Slot,
|
|
3
14
|
childrenToString,
|
|
4
15
|
createRecipe,
|
|
5
16
|
createSlotContext,
|
|
6
17
|
mergeProps,
|
|
7
|
-
mergeRefs
|
|
8
|
-
|
|
9
|
-
|
|
18
|
+
mergeRefs,
|
|
19
|
+
resolveAnimation,
|
|
20
|
+
resolveSlotAnimation,
|
|
21
|
+
useFeedback
|
|
22
|
+
} from "../chunk-ECDWSSHJ.js";
|
|
23
|
+
import "../chunk-X2K2FX3W.js";
|
|
10
24
|
export {
|
|
25
|
+
HIGHLIGHT_OPACITY,
|
|
26
|
+
PRESS_DURATION,
|
|
27
|
+
PRESS_SCALE,
|
|
28
|
+
Portal,
|
|
29
|
+
PortalContext,
|
|
30
|
+
PortalHost,
|
|
31
|
+
PressableFeedback,
|
|
32
|
+
RELEASE_DURATION,
|
|
33
|
+
RIPPLE_COVERAGE,
|
|
34
|
+
RIPPLE_DURATION,
|
|
35
|
+
RIPPLE_OPACITY,
|
|
11
36
|
Slot,
|
|
12
37
|
childrenToString,
|
|
13
38
|
createRecipe,
|
|
14
39
|
createSlotContext,
|
|
15
40
|
mergeProps,
|
|
16
|
-
mergeRefs
|
|
41
|
+
mergeRefs,
|
|
42
|
+
resolveAnimation,
|
|
43
|
+
resolveSlotAnimation,
|
|
44
|
+
useFeedback
|
|
17
45
|
};
|
package/dist/theme/index.cjs
CHANGED
|
@@ -9,14 +9,14 @@
|
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
12
|
+
var _chunkAW63PTQ4cjs = require('../chunk-AW63PTQ4.cjs');
|
|
12
13
|
|
|
13
14
|
|
|
14
15
|
|
|
15
16
|
|
|
16
|
-
var _chunkNHPQQQ7Pcjs = require('../chunk-NHPQQQ7P.cjs');
|
|
17
17
|
|
|
18
18
|
|
|
19
|
-
var
|
|
19
|
+
var _chunk3QBT3Q65cjs = require('../chunk-3QBT3Q65.cjs');
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
|
|
@@ -33,4 +33,4 @@ var _chunkM7P46XKIcjs = require('../chunk-M7P46XKI.cjs');
|
|
|
33
33
|
|
|
34
34
|
|
|
35
35
|
|
|
36
|
-
exports.ThemeContext =
|
|
36
|
+
exports.ThemeContext = _chunk3QBT3Q65cjs.ThemeContext; exports.XAUIProvider = _chunkAW63PTQ4cjs.XAUIProvider; exports.buildRadius = _chunkAW63PTQ4cjs.buildRadius; exports.buildShadows = _chunkAW63PTQ4cjs.buildShadows; exports.createTheme = _chunkAW63PTQ4cjs.createTheme; exports.defaultTheme = _chunkAW63PTQ4cjs.defaultTheme; exports.deriveColors = _chunkAW63PTQ4cjs.deriveColors; exports.deriveTint = _chunk3QBT3Q65cjs.deriveTint; exports.palette = _chunkAW63PTQ4cjs.palette; exports.primitives = _chunkAW63PTQ4cjs.primitives; exports.sourceKeys = _chunkAW63PTQ4cjs.sourceKeys; exports.tokens = _chunkAW63PTQ4cjs.tokens; exports.useColorMode = _chunk3QBT3Q65cjs.useColorMode; exports.useThemeColor = _chunk3QBT3Q65cjs.useThemeColor; exports.useXAUITheme = _chunk3QBT3Q65cjs.useXAUITheme;
|
package/dist/theme/index.d.cts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
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-
|
|
4
|
-
export { F as FontSizeKey, a as FontWeightKey, R as RadiusKey, S as Size, c as XAUIPrimitiveColors, e as XAUIShadow } from '../theme.type-
|
|
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-C9bFJKFm.cjs';
|
|
4
|
+
export { F as FontSizeKey, a as FontWeightKey, R as RadiusKey, S as Size, c as XAUIPrimitiveColors, e as XAUIShadow } from '../theme.type-C9bFJKFm.cjs';
|
|
5
|
+
import 'react-native';
|
|
5
6
|
|
|
6
7
|
/** `'system'` follows the device; the resolved value is never `'system'`. */
|
|
7
8
|
type ColorModePreference = 'light' | 'dark' | 'system';
|
package/dist/theme/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
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-
|
|
4
|
-
export { F as FontSizeKey, a as FontWeightKey, R as RadiusKey, S as Size, c as XAUIPrimitiveColors, e as XAUIShadow } from '../theme.type-
|
|
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-C9bFJKFm.js';
|
|
4
|
+
export { F as FontSizeKey, a as FontWeightKey, R as RadiusKey, S as Size, c as XAUIPrimitiveColors, e as XAUIShadow } from '../theme.type-C9bFJKFm.js';
|
|
5
|
+
import 'react-native';
|
|
5
6
|
|
|
6
7
|
/** `'system'` follows the device; the resolved value is never `'system'`. */
|
|
7
8
|
type ColorModePreference = 'light' | 'dark' | 'system';
|
package/dist/theme/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import {
|
|
2
|
-
ThemeContext,
|
|
3
2
|
XAUIProvider,
|
|
4
3
|
buildRadius,
|
|
5
4
|
buildShadows,
|
|
@@ -9,14 +8,15 @@ import {
|
|
|
9
8
|
palette,
|
|
10
9
|
primitives,
|
|
11
10
|
sourceKeys,
|
|
12
|
-
tokens
|
|
11
|
+
tokens
|
|
12
|
+
} from "../chunk-2KXQATVL.js";
|
|
13
|
+
import {
|
|
14
|
+
ThemeContext,
|
|
15
|
+
deriveTint,
|
|
13
16
|
useColorMode,
|
|
14
17
|
useThemeColor,
|
|
15
18
|
useXAUITheme
|
|
16
|
-
} from "../chunk-
|
|
17
|
-
import {
|
|
18
|
-
deriveTint
|
|
19
|
-
} from "../chunk-RBNCR5KB.js";
|
|
19
|
+
} from "../chunk-X2K2FX3W.js";
|
|
20
20
|
export {
|
|
21
21
|
ThemeContext,
|
|
22
22
|
XAUIProvider,
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { TextStyle } from 'react-native';
|
|
2
|
+
|
|
1
3
|
/** The source layer — the only surface a consumer writes by hand, per mode. */
|
|
2
4
|
type XAUISourceColors = {
|
|
3
5
|
background: string;
|
|
@@ -106,7 +108,11 @@ type XAUITheme = {
|
|
|
106
108
|
};
|
|
107
109
|
fontSizes: Record<FontSizeKey, number>;
|
|
108
110
|
lineHeights: Record<FontSizeKey, number>;
|
|
109
|
-
|
|
111
|
+
/**
|
|
112
|
+
* Typed as RN's own `fontWeight` rather than `string`: a `string` does not assign to
|
|
113
|
+
* it, so every component reading `t.fontWeights.medium` would have needed a cast.
|
|
114
|
+
*/
|
|
115
|
+
fontWeights: Record<FontWeightKey, TextStyle['fontWeight']>;
|
|
110
116
|
fontFamilies: {
|
|
111
117
|
body: string;
|
|
112
118
|
heading: string;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { TextStyle } from 'react-native';
|
|
2
|
+
|
|
1
3
|
/** The source layer — the only surface a consumer writes by hand, per mode. */
|
|
2
4
|
type XAUISourceColors = {
|
|
3
5
|
background: string;
|
|
@@ -106,7 +108,11 @@ type XAUITheme = {
|
|
|
106
108
|
};
|
|
107
109
|
fontSizes: Record<FontSizeKey, number>;
|
|
108
110
|
lineHeights: Record<FontSizeKey, number>;
|
|
109
|
-
|
|
111
|
+
/**
|
|
112
|
+
* Typed as RN's own `fontWeight` rather than `string`: a `string` does not assign to
|
|
113
|
+
* it, so every component reading `t.fontWeights.medium` would have needed a cast.
|
|
114
|
+
*/
|
|
115
|
+
fontWeights: Record<FontWeightKey, TextStyle['fontWeight']>;
|
|
110
116
|
fontFamilies: {
|
|
111
117
|
body: string;
|
|
112
118
|
heading: string;
|
package/package.json
CHANGED
package/dist/chunk-B755PRVJ.cjs
DELETED
|
@@ -1,274 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
|
-
|
|
3
|
-
var _chunkM7P46XKIcjs = require('./chunk-M7P46XKI.cjs');
|
|
4
|
-
|
|
5
|
-
// src/system/recipe/resolve-tint.ts
|
|
6
|
-
var TINT_SLICE_BY_SUFFIX = [
|
|
7
|
-
[/SoftForeground$/, "softForeground"],
|
|
8
|
-
[/SoftPressed$/, "softPressed"],
|
|
9
|
-
[/Soft$/, "soft"],
|
|
10
|
-
[/Foreground$/, "foreground"],
|
|
11
|
-
[/Pressed$/, "pressed"]
|
|
12
|
-
];
|
|
13
|
-
function tintSliceFor(token) {
|
|
14
|
-
for (const [suffix, slice] of TINT_SLICE_BY_SUFFIX) {
|
|
15
|
-
if (suffix.test(token)) return slice;
|
|
16
|
-
}
|
|
17
|
-
return "base";
|
|
18
|
-
}
|
|
19
|
-
function resolveTint(tokens, color, theme) {
|
|
20
|
-
const tint = _chunkM7P46XKIcjs.deriveTint.call(void 0, color, theme);
|
|
21
|
-
const colors = {};
|
|
22
|
-
for (const [role, token] of Object.entries(_nullishCoalesce(tokens, () => ( {})))) {
|
|
23
|
-
colors[role] = tint[tintSliceFor(token)];
|
|
24
|
-
}
|
|
25
|
-
return colors;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// src/system/recipe/style-cache.ts
|
|
29
|
-
var _reactnative = require('react-native');
|
|
30
|
-
|
|
31
|
-
// src/system/recipe/variant-map.ts
|
|
32
|
-
var STATE_ORDER = ["focused", "pressed", "disabled"];
|
|
33
|
-
function resolveSelection(defaultVariants, selection) {
|
|
34
|
-
const resolved = { ...defaultVariants };
|
|
35
|
-
for (const [axis, value] of Object.entries(_nullishCoalesce(selection, () => ( {})))) {
|
|
36
|
-
if (value !== void 0) resolved[axis] = value;
|
|
37
|
-
}
|
|
38
|
-
return resolved;
|
|
39
|
-
}
|
|
40
|
-
function resolveVariantColors(tokens, theme) {
|
|
41
|
-
const colors = {};
|
|
42
|
-
for (const [role, token] of entriesOf(tokens)) {
|
|
43
|
-
const value = theme.colors[token];
|
|
44
|
-
if (value === void 0) {
|
|
45
|
-
throw new Error(
|
|
46
|
-
`XAUI: the recipe names "${token}" for its "${role}" role, but the theme has no such colour token. Check the spelling against XAUIColors.`
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
colors[role] = value;
|
|
50
|
-
}
|
|
51
|
-
return colors;
|
|
52
|
-
}
|
|
53
|
-
function activeStateFns(states, active) {
|
|
54
|
-
const fns = [];
|
|
55
|
-
for (const state of STATE_ORDER) {
|
|
56
|
-
const fn = active[state] ? _optionalChain([states, 'optionalAccess', _ => _[state]]) : void 0;
|
|
57
|
-
if (fn) fns.push(fn);
|
|
58
|
-
}
|
|
59
|
-
return fns;
|
|
60
|
-
}
|
|
61
|
-
function collectStyleFns(config, selection, states) {
|
|
62
|
-
const fns = [];
|
|
63
|
-
if (config.base) fns.push(config.base);
|
|
64
|
-
if (config.paint) fns.push(config.paint);
|
|
65
|
-
for (const [axis, values] of Object.entries(_nullishCoalesce(config.variants, () => ( {})))) {
|
|
66
|
-
const value = selection[axis];
|
|
67
|
-
const fn = value === void 0 ? void 0 : values[value];
|
|
68
|
-
if (fn) fns.push(fn);
|
|
69
|
-
}
|
|
70
|
-
for (const compound of _nullishCoalesce(config.compoundVariants, () => ( []))) {
|
|
71
|
-
if (appliesTo(compound.when, selection)) fns.push(compound.style);
|
|
72
|
-
}
|
|
73
|
-
return [...fns, ...activeStateFns(config.states, states)];
|
|
74
|
-
}
|
|
75
|
-
function appliesTo(when, selection) {
|
|
76
|
-
return Object.entries(when).every(([axis, value]) => selection[axis] === value);
|
|
77
|
-
}
|
|
78
|
-
function entriesOf(tokens) {
|
|
79
|
-
return Object.entries(_nullishCoalesce(tokens, () => ( {})));
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
// src/system/recipe/style-cache.ts
|
|
83
|
-
function createStyleCache(slots) {
|
|
84
|
-
const entries = /* @__PURE__ */ new Map();
|
|
85
|
-
return {
|
|
86
|
-
read(key, build) {
|
|
87
|
-
const hit = entries.get(key);
|
|
88
|
-
if (hit) return hit;
|
|
89
|
-
const built = build();
|
|
90
|
-
const complete = {};
|
|
91
|
-
for (const slot of slots) complete[slot] = _nullishCoalesce(built[slot], () => ( {}));
|
|
92
|
-
const created = _reactnative.StyleSheet.create(complete);
|
|
93
|
-
entries.set(key, created);
|
|
94
|
-
return created;
|
|
95
|
-
},
|
|
96
|
-
get size() {
|
|
97
|
-
return entries.size;
|
|
98
|
-
},
|
|
99
|
-
clear() {
|
|
100
|
-
entries.clear();
|
|
101
|
-
}
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
function cacheKey(theme, selection, states) {
|
|
105
|
-
const axes = Object.keys(selection).sort().map((axis) => `${axis}:${_nullishCoalesce(selection[axis], () => ( "-"))}`).join("|");
|
|
106
|
-
const active = STATE_ORDER.filter((state) => states[state]).join(",");
|
|
107
|
-
return `${theme.id}|${theme.mode}|${axes}|${active}`;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
// src/system/recipe/create-recipe.ts
|
|
111
|
-
function createRecipe(config) {
|
|
112
|
-
const cache = createStyleCache(config.slots);
|
|
113
|
-
const tokensFor = (variant) => variant === void 0 ? void 0 : _optionalChain([config, 'access', _2 => _2.variantTokens, 'optionalAccess', _3 => _3[variant]]);
|
|
114
|
-
return {
|
|
115
|
-
slots: config.slots,
|
|
116
|
-
resolve({ theme, selection, states = {} }) {
|
|
117
|
-
const resolved = resolveSelection(config.defaultVariants, selection);
|
|
118
|
-
return cache.read(cacheKey(theme, resolved, states), () => {
|
|
119
|
-
const colors = resolveVariantColors(tokensFor(resolved.variant), theme);
|
|
120
|
-
return apply(collectStyleFns(config, resolved, states), theme, colors);
|
|
121
|
-
});
|
|
122
|
-
},
|
|
123
|
-
tint({ theme, color, selection, states = {} }) {
|
|
124
|
-
if (!config.paint) return {};
|
|
125
|
-
const resolved = resolveSelection(config.defaultVariants, selection);
|
|
126
|
-
const tokens = tokensFor(resolved.variant);
|
|
127
|
-
if (!tokens) return {};
|
|
128
|
-
const colors = resolveTint(tokens, color, theme);
|
|
129
|
-
const fns = [config.paint, ...activeStateFns(config.states, states)];
|
|
130
|
-
return apply(fns, theme, colors);
|
|
131
|
-
}
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
function apply(fns, theme, colors) {
|
|
135
|
-
const merged = {};
|
|
136
|
-
for (const fn of fns) {
|
|
137
|
-
const produced = fn(theme, colors);
|
|
138
|
-
for (const slot of Object.keys(produced)) {
|
|
139
|
-
const style = produced[slot];
|
|
140
|
-
if (!style) continue;
|
|
141
|
-
const previous = merged[slot];
|
|
142
|
-
merged[slot] = previous ? { ...previous, ...style } : style;
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
return merged;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
// src/system/slot/children-to-string.ts
|
|
149
|
-
var _react = require('react');
|
|
150
|
-
function childrenToString(children) {
|
|
151
|
-
const text = stringify(children);
|
|
152
|
-
return text === null || text === "" ? null : text;
|
|
153
|
-
}
|
|
154
|
-
function stringify(node) {
|
|
155
|
-
if (node === null || node === void 0 || typeof node === "boolean") return "";
|
|
156
|
-
if (typeof node === "string") return node;
|
|
157
|
-
if (typeof node === "number") return String(node);
|
|
158
|
-
if (_react.isValidElement.call(void 0, node)) return null;
|
|
159
|
-
if (Array.isArray(node)) {
|
|
160
|
-
let text = "";
|
|
161
|
-
for (const child of node) {
|
|
162
|
-
const part = stringify(child);
|
|
163
|
-
if (part === null) return null;
|
|
164
|
-
text += part;
|
|
165
|
-
}
|
|
166
|
-
return text;
|
|
167
|
-
}
|
|
168
|
-
return null;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
// src/system/slot/create-slot-context.ts
|
|
172
|
-
|
|
173
|
-
function createSlotContext(name) {
|
|
174
|
-
const Context = _react.createContext.call(void 0, null);
|
|
175
|
-
Context.displayName = `XAUI.${name}.Context`;
|
|
176
|
-
function useSlotContext() {
|
|
177
|
-
const value = _react.useContext.call(void 0, Context);
|
|
178
|
-
if (value === null) {
|
|
179
|
-
const error = new Error(
|
|
180
|
-
`XAUI: use${name} must be called inside <${name}>. A slot reads the values its root resolved, so it can only be rendered as a child of one.`
|
|
181
|
-
);
|
|
182
|
-
_optionalChain([Error, 'access', _4 => _4.captureStackTrace, 'optionalCall', _5 => _5(
|
|
183
|
-
error,
|
|
184
|
-
useSlotContext
|
|
185
|
-
)]);
|
|
186
|
-
throw error;
|
|
187
|
-
}
|
|
188
|
-
return value;
|
|
189
|
-
}
|
|
190
|
-
return [Context.Provider, useSlotContext];
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
// src/system/slot/merge-refs.ts
|
|
194
|
-
function mergeRefs(...refs) {
|
|
195
|
-
return (value) => {
|
|
196
|
-
for (const ref of refs) {
|
|
197
|
-
if (typeof ref === "function") ref(value);
|
|
198
|
-
else if (ref) ref.current = value;
|
|
199
|
-
}
|
|
200
|
-
};
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
// src/system/slot/merge-props.ts
|
|
204
|
-
var EVENT_HANDLER = /^on[A-Z]/;
|
|
205
|
-
function mergeProps(ours, theirs) {
|
|
206
|
-
const merged = { ...ours };
|
|
207
|
-
for (const key of Object.keys(theirs)) {
|
|
208
|
-
const ourValue = ours[key];
|
|
209
|
-
const theirValue = theirs[key];
|
|
210
|
-
if (EVENT_HANDLER.test(key)) {
|
|
211
|
-
merged[key] = composeHandlers(ourValue, theirValue);
|
|
212
|
-
} else if (key === "style") {
|
|
213
|
-
merged[key] = mergeStyles(ourValue, theirValue);
|
|
214
|
-
} else if (key === "ref") {
|
|
215
|
-
merged[key] = mergeRefs(
|
|
216
|
-
ourValue,
|
|
217
|
-
theirValue
|
|
218
|
-
);
|
|
219
|
-
} else {
|
|
220
|
-
merged[key] = theirValue;
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
return merged;
|
|
224
|
-
}
|
|
225
|
-
function composeHandlers(ours, theirs) {
|
|
226
|
-
if (typeof ours !== "function") return theirs;
|
|
227
|
-
if (typeof theirs !== "function") return ours;
|
|
228
|
-
return (...args) => {
|
|
229
|
-
;
|
|
230
|
-
ours(...args);
|
|
231
|
-
return theirs(...args);
|
|
232
|
-
};
|
|
233
|
-
}
|
|
234
|
-
function mergeStyles(ours, theirs) {
|
|
235
|
-
if (typeof ours === "function" || typeof theirs === "function") {
|
|
236
|
-
return (state) => [
|
|
237
|
-
resolveStyle(ours, state),
|
|
238
|
-
resolveStyle(theirs, state)
|
|
239
|
-
];
|
|
240
|
-
}
|
|
241
|
-
return [ours, theirs];
|
|
242
|
-
}
|
|
243
|
-
function resolveStyle(style, state) {
|
|
244
|
-
return typeof style === "function" ? style(state) : style;
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
// src/system/slot/slot.tsx
|
|
248
|
-
|
|
249
|
-
var Slot = _react.forwardRef.call(void 0, function Slot2({ children, ...ours }, ref) {
|
|
250
|
-
if (!_react.isValidElement.call(void 0, children)) {
|
|
251
|
-
throw new Error(
|
|
252
|
-
"XAUI: asChild expects exactly one React element as its child, and merges the component's props into it. Text, a fragment, several children or none give it nothing to merge into \u2014 drop `asChild` to render the component itself."
|
|
253
|
-
);
|
|
254
|
-
}
|
|
255
|
-
const child = children;
|
|
256
|
-
const merged = mergeProps(ours, child.props);
|
|
257
|
-
merged.ref = mergeRefs(ref, refOf(child));
|
|
258
|
-
return _react.cloneElement.call(void 0, child, merged);
|
|
259
|
-
});
|
|
260
|
-
Slot.displayName = "XAUI.Slot";
|
|
261
|
-
function refOf(element) {
|
|
262
|
-
const fromProps = element.props.ref;
|
|
263
|
-
const fromElement = element.ref;
|
|
264
|
-
return _nullishCoalesce(fromProps, () => ( fromElement));
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
exports.createRecipe = createRecipe; exports.childrenToString = childrenToString; exports.createSlotContext = createSlotContext; exports.mergeRefs = mergeRefs; exports.mergeProps = mergeProps; exports.Slot = Slot;
|