@xaui/native 0.9.1-alpha.4 → 0.9.1-alpha.40
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-2EGR4LWD.js +145 -0
- package/dist/chunk-2NRZKJG7.js +531 -0
- package/dist/chunk-2PMXMKS5.js +67 -0
- package/dist/chunk-2XPG2243.js +586 -0
- package/dist/chunk-36PRYGAM.js +13 -0
- package/dist/chunk-3E7CDKFO.cjs +696 -0
- package/dist/chunk-3GFRSZYR.js +54 -0
- package/dist/chunk-423RQBOX.js +21 -0
- package/dist/chunk-4CUZZWFW.js +92 -0
- package/dist/chunk-4GTAZM2C.js +174 -0
- package/dist/chunk-4KFKWBN5.cjs +89 -0
- package/dist/{chunk-3QBT3Q65.cjs → chunk-57SJ4LJF.cjs} +7 -2
- package/dist/chunk-5R26NM4M.cjs +402 -0
- package/dist/chunk-5VKYNBNA.js +607 -0
- package/dist/chunk-64MXEVT3.js +66 -0
- package/dist/chunk-6DOLGZVV.cjs +147 -0
- package/dist/chunk-6L2TS2R3.cjs +92 -0
- package/dist/chunk-6UEZJRVI.js +669 -0
- package/dist/chunk-734MFAX4.js +27 -0
- package/dist/chunk-73RKQC5X.js +104 -0
- package/dist/chunk-7DPL3ZDS.cjs +21 -0
- package/dist/chunk-7EIHHOHP.cjs +42 -0
- package/dist/chunk-7GHM4GKL.cjs +119 -0
- package/dist/chunk-7YF5NAHQ.cjs +74 -0
- package/dist/{chunk-X2K2FX3W.js → chunk-A3EGFI6T.js} +6 -1
- package/dist/chunk-ABAGZTXZ.cjs +736 -0
- package/dist/{chunk-AW63PTQ4.cjs → chunk-ACAPTWE3.cjs} +85 -81
- package/dist/chunk-AMCSSOJT.cjs +104 -0
- package/dist/chunk-BA2DBSAN.js +102 -0
- package/dist/chunk-BRRXFOBY.js +431 -0
- package/dist/chunk-C5YLPCFC.cjs +293 -0
- package/dist/chunk-DA3OKXHV.cjs +700 -0
- package/dist/chunk-DD4276RF.js +366 -0
- package/dist/chunk-DG2I4PJG.js +701 -0
- package/dist/chunk-DHGLGSH6.js +661 -0
- package/dist/chunk-DIBUQ46Y.js +346 -0
- package/dist/chunk-EGLLDKN6.js +9 -0
- package/dist/chunk-EJQCQPET.cjs +9 -0
- package/dist/chunk-EKS3W46M.cjs +66 -0
- package/dist/chunk-EZEYMLO3.js +402 -0
- package/dist/chunk-F6CQ6CBI.cjs +112 -0
- package/dist/chunk-F6W3JQ7K.js +42 -0
- package/dist/chunk-FHUYHV6J.js +89 -0
- package/dist/chunk-FNEUOBCV.cjs +174 -0
- package/dist/chunk-G7P3ERYF.cjs +478 -0
- package/dist/chunk-GA6PBWNT.js +147 -0
- package/dist/chunk-GFUZ3MUT.cjs +455 -0
- package/dist/chunk-GGW43Q37.cjs +1 -0
- package/dist/chunk-GTR5X65M.cjs +27 -0
- package/dist/chunk-H4E4HDEP.cjs +13 -0
- package/dist/chunk-H7DS4IO7.js +198 -0
- package/dist/chunk-HDVVZG4S.cjs +198 -0
- package/dist/chunk-IKJVLJKT.js +151 -0
- package/dist/chunk-J3MB4PI5.cjs +531 -0
- package/dist/chunk-K72UDPVN.js +119 -0
- package/dist/chunk-KCMYU7WF.js +86 -0
- package/dist/chunk-LRN3RNDO.js +940 -0
- package/dist/chunk-LTX6TB5I.js +124 -0
- package/dist/chunk-LUPCPLND.cjs +145 -0
- package/dist/chunk-M63GFNKV.js +194 -0
- package/dist/chunk-N3KTZMPG.js +293 -0
- package/dist/chunk-NCTOTTVW.js +13 -0
- package/dist/chunk-NWGLP6JX.cjs +410 -0
- package/dist/chunk-R73XQK7X.cjs +314 -0
- package/dist/chunk-RU7JCMWC.cjs +881 -0
- package/dist/chunk-SNIHUKDA.cjs +184 -0
- package/dist/chunk-T5FV5F7A.cjs +607 -0
- package/dist/chunk-TDTUAIFF.cjs +153 -0
- package/dist/chunk-TJ74XVZN.cjs +431 -0
- package/dist/chunk-TK44VBIE.cjs +194 -0
- package/dist/chunk-UAWBAD4E.cjs +346 -0
- package/dist/chunk-UFTCTTKK.js +381 -0
- package/dist/chunk-WDDXU3OH.cjs +67 -0
- package/dist/chunk-WFEMJCXO.cjs +13 -0
- package/dist/chunk-WHJTBTYM.js +0 -0
- package/dist/{chunk-2KXQATVL.js → chunk-WKCQ6VGW.js} +59 -55
- package/dist/chunk-XFPQFCEK.js +455 -0
- package/dist/chunk-XSQPVDFH.cjs +60 -0
- package/dist/chunk-XTC2SLFT.js +153 -0
- package/dist/chunk-XV735BSA.cjs +366 -0
- package/dist/chunk-XWNG2U4K.cjs +124 -0
- package/dist/chunk-YGYYJ3LQ.js +314 -0
- package/dist/chunk-YVHT2UVW.js +74 -0
- package/dist/chunk-ZFOOJK37.cjs +86 -0
- package/dist/close-button.type-BUYuoSt2.d.ts +36 -0
- package/dist/close-button.type-CHsgZ3wO.d.cts +36 -0
- package/dist/components/accordion/index.cjs +35 -0
- package/dist/components/accordion/index.d.cts +299 -0
- package/dist/components/accordion/index.d.ts +299 -0
- package/dist/components/accordion/index.js +35 -0
- package/dist/components/alert/index.cjs +20 -0
- package/dist/components/alert/index.d.cts +169 -0
- package/dist/components/alert/index.d.ts +169 -0
- package/dist/components/alert/index.js +20 -0
- package/dist/components/avatar/index.cjs +16 -0
- package/dist/components/avatar/index.d.cts +131 -0
- package/dist/components/avatar/index.d.ts +131 -0
- package/dist/components/avatar/index.js +16 -0
- package/dist/components/badge/index.cjs +15 -0
- package/dist/components/badge/index.d.cts +157 -0
- package/dist/components/badge/index.d.ts +157 -0
- package/dist/components/badge/index.js +15 -0
- package/dist/components/button/index.cjs +22 -0
- package/dist/components/button/index.d.cts +613 -0
- package/dist/components/button/index.d.ts +613 -0
- package/dist/components/button/index.js +22 -0
- package/dist/components/card/index.cjs +22 -0
- package/dist/components/card/index.d.cts +620 -0
- package/dist/components/card/index.d.ts +620 -0
- package/dist/components/card/index.js +22 -0
- package/dist/components/checkbox/index.cjs +26 -0
- package/dist/components/checkbox/index.d.cts +1136 -0
- package/dist/components/checkbox/index.d.ts +1136 -0
- package/dist/components/checkbox/index.js +26 -0
- package/dist/components/chip/index.cjs +20 -0
- package/dist/components/chip/index.d.cts +608 -0
- package/dist/components/chip/index.d.ts +608 -0
- package/dist/components/chip/index.js +20 -0
- package/dist/components/divider/index.cjs +13 -0
- package/dist/components/divider/index.d.cts +117 -0
- package/dist/components/divider/index.d.ts +117 -0
- package/dist/components/divider/index.js +13 -0
- package/dist/components/field-group/index.cjs +27 -0
- package/dist/components/field-group/index.d.cts +270 -0
- package/dist/components/field-group/index.d.ts +270 -0
- package/dist/components/field-group/index.js +27 -0
- package/dist/components/input-otp/index.cjs +29 -0
- package/dist/components/input-otp/index.d.cts +325 -0
- package/dist/components/input-otp/index.d.ts +325 -0
- package/dist/components/input-otp/index.js +29 -0
- package/dist/components/menu/index.cjs +49 -0
- package/dist/components/menu/index.d.cts +351 -0
- package/dist/components/menu/index.d.ts +351 -0
- package/dist/components/menu/index.js +49 -0
- package/dist/components/popover/index.cjs +38 -0
- package/dist/components/popover/index.d.cts +254 -0
- package/dist/components/popover/index.d.ts +254 -0
- package/dist/components/popover/index.js +38 -0
- package/dist/components/radio/index.cjs +26 -0
- package/dist/components/radio/index.d.cts +1102 -0
- package/dist/components/radio/index.d.ts +1102 -0
- package/dist/components/radio/index.js +26 -0
- package/dist/components/select/index.cjs +50 -0
- package/dist/components/select/index.d.cts +498 -0
- package/dist/components/select/index.d.ts +498 -0
- package/dist/components/select/index.js +50 -0
- package/dist/components/skeleton/index.cjs +11 -0
- package/dist/components/skeleton/index.d.cts +111 -0
- package/dist/components/skeleton/index.d.ts +111 -0
- package/dist/components/skeleton/index.js +11 -0
- package/dist/components/spinner/index.cjs +17 -0
- package/dist/components/spinner/index.d.cts +104 -0
- package/dist/components/spinner/index.d.ts +104 -0
- package/dist/components/spinner/index.js +17 -0
- package/dist/components/switch/index.cjs +27 -0
- package/dist/components/switch/index.d.cts +1154 -0
- package/dist/components/switch/index.d.ts +1154 -0
- package/dist/components/switch/index.js +27 -0
- package/dist/components/text-area/index.cjs +14 -0
- package/dist/components/text-area/index.d.cts +73 -0
- package/dist/components/text-area/index.d.ts +73 -0
- package/dist/components/text-area/index.js +14 -0
- package/dist/components/text-field/index.cjs +25 -0
- package/dist/components/text-field/index.d.cts +205 -0
- package/dist/components/text-field/index.d.ts +205 -0
- package/dist/components/text-field/index.js +25 -0
- package/dist/components/typography/index.cjs +15 -0
- package/dist/components/typography/index.d.cts +116 -0
- package/dist/components/typography/index.d.ts +116 -0
- package/dist/components/typography/index.js +15 -0
- package/dist/components/view/index.cjs +17 -0
- package/dist/components/view/index.d.cts +152 -0
- package/dist/components/view/index.d.ts +152 -0
- package/dist/components/view/index.js +17 -0
- package/dist/create-recipe-BdVd2ffi.d.ts +114 -0
- package/dist/create-recipe-dC7wMfnj.d.cts +114 -0
- package/dist/icon.type-Kml72iSz.d.ts +73 -0
- package/dist/icon.type-d_i9ma-i.d.cts +73 -0
- package/dist/index.cjs +400 -4
- package/dist/index.d.cts +118 -4
- package/dist/index.d.ts +118 -4
- package/dist/index.js +423 -27
- package/dist/placement-DHa0Rrh1.d.cts +38 -0
- package/dist/placement-DHa0Rrh1.d.ts +38 -0
- package/dist/pressable-feedback.type-BA2C9sSz.d.cts +127 -0
- package/dist/pressable-feedback.type-Bs4dQlGj.d.ts +127 -0
- package/dist/style-props.type-CfnoGEP7.d.cts +31 -0
- package/dist/style-props.type-CfnoGEP7.d.ts +31 -0
- package/dist/system/index.cjs +73 -4
- package/dist/system/index.d.cts +379 -193
- package/dist/system/index.d.ts +379 -193
- package/dist/system/index.js +87 -18
- package/dist/text-field.type-0l73acce.d.ts +167 -0
- package/dist/text-field.type-DBh06DU5.d.cts +167 -0
- package/dist/theme/index.cjs +5 -3
- package/dist/theme/index.d.cts +55 -24
- package/dist/theme/index.d.ts +55 -24
- package/dist/theme/index.js +4 -2
- package/dist/{theme.type-C9bFJKFm.d.cts → theme.type-C2gNHpEx.d.cts} +1 -1
- package/dist/{theme.type-C9bFJKFm.d.ts → theme.type-C2gNHpEx.d.ts} +1 -1
- package/package.json +254 -18
- package/dist/chunk-ECDWSSHJ.js +0 -688
- package/dist/chunk-IYFGO523.cjs +0 -688
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createRecipe,
|
|
3
|
+
radiusAxis
|
|
4
|
+
} from "./chunk-4GTAZM2C.js";
|
|
5
|
+
import {
|
|
6
|
+
useXAUITheme
|
|
7
|
+
} from "./chunk-A3EGFI6T.js";
|
|
8
|
+
import {
|
|
9
|
+
Slot,
|
|
10
|
+
childrenToString
|
|
11
|
+
} from "./chunk-K72UDPVN.js";
|
|
12
|
+
import {
|
|
13
|
+
useStyleProps
|
|
14
|
+
} from "./chunk-M63GFNKV.js";
|
|
15
|
+
|
|
16
|
+
// src/components/badge/badge.tsx
|
|
17
|
+
import { forwardRef, useMemo } from "react";
|
|
18
|
+
import { Text, View } from "react-native";
|
|
19
|
+
|
|
20
|
+
// src/components/badge/badge.recipe.ts
|
|
21
|
+
var SLOTS = ["root", "label"];
|
|
22
|
+
var VARIANT_TOKENS = {
|
|
23
|
+
primary: { bg: "accent", fg: "accentForeground" },
|
|
24
|
+
secondary: { bg: "accentSoft", fg: "accentSoftForeground" },
|
|
25
|
+
default: { bg: "default", fg: "defaultForeground" },
|
|
26
|
+
tertiary: { border: "border", fg: "foreground" },
|
|
27
|
+
ghost: { fg: "foreground" },
|
|
28
|
+
success: { bg: "success", fg: "successForeground" },
|
|
29
|
+
"success-soft": { bg: "successSoft", fg: "successSoftForeground" },
|
|
30
|
+
warning: { bg: "warning", fg: "warningForeground" },
|
|
31
|
+
"warning-soft": { bg: "warningSoft", fg: "warningSoftForeground" },
|
|
32
|
+
danger: { bg: "danger", fg: "dangerForeground" },
|
|
33
|
+
"danger-soft": { bg: "dangerSoft", fg: "dangerSoftForeground" }
|
|
34
|
+
};
|
|
35
|
+
function sizeAxis(step) {
|
|
36
|
+
return (theme) => {
|
|
37
|
+
const height = theme.spacing(step.height);
|
|
38
|
+
return {
|
|
39
|
+
root: {
|
|
40
|
+
height,
|
|
41
|
+
minWidth: height,
|
|
42
|
+
paddingHorizontal: theme.spacing(step.padding)
|
|
43
|
+
},
|
|
44
|
+
label: { fontSize: theme.fontSizes[step.label] }
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
function dotAxis(diameter) {
|
|
49
|
+
return (theme) => {
|
|
50
|
+
const size = theme.spacing(diameter);
|
|
51
|
+
return {
|
|
52
|
+
root: { height: size, width: size, minWidth: size, paddingHorizontal: 0 }
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
var BADGE_DEFAULT_SIZE = "md";
|
|
57
|
+
var SIZES = {
|
|
58
|
+
xs: { height: 4, padding: 1.25, label: "xs", dot: 1.5 },
|
|
59
|
+
sm: { height: 4.5, padding: 1.5, label: "xs", dot: 2 },
|
|
60
|
+
md: { height: 5, padding: 1.5, label: "xs", dot: 2.5 },
|
|
61
|
+
lg: { height: 6, padding: 2, label: "sm", dot: 3 }
|
|
62
|
+
};
|
|
63
|
+
function badgeOffset(theme, size, isDot) {
|
|
64
|
+
const step = SIZES[size];
|
|
65
|
+
return theme.spacing(isDot ? step.dot : step.height) / 2;
|
|
66
|
+
}
|
|
67
|
+
var badgeRecipe = createRecipe({
|
|
68
|
+
slots: SLOTS,
|
|
69
|
+
base: (theme) => ({
|
|
70
|
+
root: {
|
|
71
|
+
flexDirection: "row",
|
|
72
|
+
alignItems: "center",
|
|
73
|
+
justifyContent: "center",
|
|
74
|
+
borderWidth: 0,
|
|
75
|
+
// The capsule at every size, which is what makes a two-digit count read as one
|
|
76
|
+
// object. `radius` is still there for the square marker.
|
|
77
|
+
borderRadius: theme.radius.full,
|
|
78
|
+
// Squircle corners for when `radius` overrides the pill. Free on Android.
|
|
79
|
+
borderCurve: "continuous"
|
|
80
|
+
},
|
|
81
|
+
label: {
|
|
82
|
+
fontFamily: theme.fontFamilies.body,
|
|
83
|
+
fontWeight: theme.fontWeights.semibold,
|
|
84
|
+
// Android reserves leading above and below the glyphs, which in a 16pt box is the
|
|
85
|
+
// difference between a centred digit and one sitting low.
|
|
86
|
+
includeFontPadding: false,
|
|
87
|
+
// No `lineHeight`: the scale's leading is taller than the box at every size here,
|
|
88
|
+
// and the root centres the label anyway.
|
|
89
|
+
textAlign: "center"
|
|
90
|
+
}
|
|
91
|
+
}),
|
|
92
|
+
variantTokens: VARIANT_TOKENS,
|
|
93
|
+
/**
|
|
94
|
+
* Where the variant's colours land, for every variant at once. The border width follows
|
|
95
|
+
* the *presence* of the border role, so `ghost` needs no rule of its own.
|
|
96
|
+
*/
|
|
97
|
+
paint: (theme, colors) => ({
|
|
98
|
+
root: {
|
|
99
|
+
backgroundColor: colors.bg,
|
|
100
|
+
borderColor: colors.border,
|
|
101
|
+
borderWidth: colors.border ? theme.borderWidth.default : 0
|
|
102
|
+
},
|
|
103
|
+
label: { color: colors.fg }
|
|
104
|
+
}),
|
|
105
|
+
/** Declaration order is application order: `dot` overrides the box `size` set, and
|
|
106
|
+
* `radius` overrides the capsule from `base`. */
|
|
107
|
+
variants: {
|
|
108
|
+
size: {
|
|
109
|
+
xs: sizeAxis(SIZES.xs),
|
|
110
|
+
sm: sizeAxis(SIZES.sm),
|
|
111
|
+
md: sizeAxis(SIZES.md),
|
|
112
|
+
lg: sizeAxis(SIZES.lg)
|
|
113
|
+
},
|
|
114
|
+
/**
|
|
115
|
+
* The same four keys as `size`, and the root selects it with the resolved size when
|
|
116
|
+
* `isDot` is set and with nothing when it is not — an axis left unselected contributes
|
|
117
|
+
* nothing, which is exactly "this badge has a label". A `{ true, false }` axis would
|
|
118
|
+
* have needed a `false` branch with nothing to say, and a `size × isDot` compound
|
|
119
|
+
* would have been sixteen entries for four measurements.
|
|
120
|
+
*/
|
|
121
|
+
dot: {
|
|
122
|
+
xs: dotAxis(SIZES.xs.dot),
|
|
123
|
+
sm: dotAxis(SIZES.sm.dot),
|
|
124
|
+
md: dotAxis(SIZES.md.dot),
|
|
125
|
+
lg: dotAxis(SIZES.lg.dot)
|
|
126
|
+
},
|
|
127
|
+
radius: radiusAxis("root")
|
|
128
|
+
},
|
|
129
|
+
/**
|
|
130
|
+
* `danger`, where every other component in the library defaults to the first name in its
|
|
131
|
+
* ladder. A badge is overwhelmingly the count of something that wants attention — unread,
|
|
132
|
+
* failed, overdue — and a red one is what `<Badge>3</Badge>` means. The accent count is a
|
|
133
|
+
* `variant` away.
|
|
134
|
+
*/
|
|
135
|
+
defaultVariants: { variant: "danger", size: BADGE_DEFAULT_SIZE }
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
// src/components/badge/badge.utils.ts
|
|
139
|
+
function placementInsets(placement, offset) {
|
|
140
|
+
if (!placement) return void 0;
|
|
141
|
+
const vertical = placement.startsWith("top") ? { top: -offset } : { bottom: -offset };
|
|
142
|
+
const horizontal = placement.endsWith("start") ? { start: -offset } : { end: -offset };
|
|
143
|
+
return { position: "absolute", ...vertical, ...horizontal };
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// src/components/badge/badge.tsx
|
|
147
|
+
import { jsx } from "react/jsx-runtime";
|
|
148
|
+
var Badge = forwardRef(function Badge2({
|
|
149
|
+
children,
|
|
150
|
+
variant,
|
|
151
|
+
size,
|
|
152
|
+
radius,
|
|
153
|
+
color,
|
|
154
|
+
isDot = false,
|
|
155
|
+
placement,
|
|
156
|
+
asChild = false,
|
|
157
|
+
style,
|
|
158
|
+
...props
|
|
159
|
+
}, ref) {
|
|
160
|
+
const theme = useXAUITheme();
|
|
161
|
+
const [styleProps, rest] = useStyleProps(props);
|
|
162
|
+
const resolvedSize = size ?? BADGE_DEFAULT_SIZE;
|
|
163
|
+
const selection = {
|
|
164
|
+
variant,
|
|
165
|
+
size,
|
|
166
|
+
radius,
|
|
167
|
+
// An axis left unselected contributes nothing, which is exactly "this badge has a
|
|
168
|
+
// label" — no `false` branch with nothing to say.
|
|
169
|
+
dot: isDot ? resolvedSize : void 0
|
|
170
|
+
};
|
|
171
|
+
const styles = badgeRecipe.resolve({ theme, selection });
|
|
172
|
+
const tint = color ? badgeRecipe.tint({ theme, color, selection }) : void 0;
|
|
173
|
+
const insets = useMemo(
|
|
174
|
+
() => placementInsets(placement, badgeOffset(theme, resolvedSize, isDot)),
|
|
175
|
+
[placement, theme, resolvedSize, isDot]
|
|
176
|
+
);
|
|
177
|
+
const rootStyle = [styles.root, tint?.root, insets, styleProps, style];
|
|
178
|
+
const text = childrenToString(children);
|
|
179
|
+
const label = text !== null ? /* @__PURE__ */ jsx(Text, { style: [styles.label, tint?.label], numberOfLines: 1, children: text }) : children;
|
|
180
|
+
const content = isDot ? null : label;
|
|
181
|
+
const Root = asChild ? Slot : View;
|
|
182
|
+
return /* @__PURE__ */ jsx(
|
|
183
|
+
Root,
|
|
184
|
+
{
|
|
185
|
+
ref,
|
|
186
|
+
...rest,
|
|
187
|
+
style: rootStyle,
|
|
188
|
+
children: asChild ? children : content
|
|
189
|
+
}
|
|
190
|
+
);
|
|
191
|
+
});
|
|
192
|
+
Badge.displayName = "XAUI.Badge";
|
|
193
|
+
|
|
194
|
+
export {
|
|
195
|
+
badgeRecipe,
|
|
196
|
+
placementInsets,
|
|
197
|
+
Badge
|
|
198
|
+
};
|
|
@@ -0,0 +1,198 @@
|
|
|
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
|
+
|
|
4
|
+
var _chunkFNEUOBCVcjs = require('./chunk-FNEUOBCV.cjs');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
var _chunk57SJ4LJFcjs = require('./chunk-57SJ4LJF.cjs');
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
var _chunk7GHM4GKLcjs = require('./chunk-7GHM4GKL.cjs');
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
var _chunkTK44VBIEcjs = require('./chunk-TK44VBIE.cjs');
|
|
15
|
+
|
|
16
|
+
// src/components/badge/badge.tsx
|
|
17
|
+
var _react = require('react');
|
|
18
|
+
var _reactnative = require('react-native');
|
|
19
|
+
|
|
20
|
+
// src/components/badge/badge.recipe.ts
|
|
21
|
+
var SLOTS = ["root", "label"];
|
|
22
|
+
var VARIANT_TOKENS = {
|
|
23
|
+
primary: { bg: "accent", fg: "accentForeground" },
|
|
24
|
+
secondary: { bg: "accentSoft", fg: "accentSoftForeground" },
|
|
25
|
+
default: { bg: "default", fg: "defaultForeground" },
|
|
26
|
+
tertiary: { border: "border", fg: "foreground" },
|
|
27
|
+
ghost: { fg: "foreground" },
|
|
28
|
+
success: { bg: "success", fg: "successForeground" },
|
|
29
|
+
"success-soft": { bg: "successSoft", fg: "successSoftForeground" },
|
|
30
|
+
warning: { bg: "warning", fg: "warningForeground" },
|
|
31
|
+
"warning-soft": { bg: "warningSoft", fg: "warningSoftForeground" },
|
|
32
|
+
danger: { bg: "danger", fg: "dangerForeground" },
|
|
33
|
+
"danger-soft": { bg: "dangerSoft", fg: "dangerSoftForeground" }
|
|
34
|
+
};
|
|
35
|
+
function sizeAxis(step) {
|
|
36
|
+
return (theme) => {
|
|
37
|
+
const height = theme.spacing(step.height);
|
|
38
|
+
return {
|
|
39
|
+
root: {
|
|
40
|
+
height,
|
|
41
|
+
minWidth: height,
|
|
42
|
+
paddingHorizontal: theme.spacing(step.padding)
|
|
43
|
+
},
|
|
44
|
+
label: { fontSize: theme.fontSizes[step.label] }
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
function dotAxis(diameter) {
|
|
49
|
+
return (theme) => {
|
|
50
|
+
const size = theme.spacing(diameter);
|
|
51
|
+
return {
|
|
52
|
+
root: { height: size, width: size, minWidth: size, paddingHorizontal: 0 }
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
var BADGE_DEFAULT_SIZE = "md";
|
|
57
|
+
var SIZES = {
|
|
58
|
+
xs: { height: 4, padding: 1.25, label: "xs", dot: 1.5 },
|
|
59
|
+
sm: { height: 4.5, padding: 1.5, label: "xs", dot: 2 },
|
|
60
|
+
md: { height: 5, padding: 1.5, label: "xs", dot: 2.5 },
|
|
61
|
+
lg: { height: 6, padding: 2, label: "sm", dot: 3 }
|
|
62
|
+
};
|
|
63
|
+
function badgeOffset(theme, size, isDot) {
|
|
64
|
+
const step = SIZES[size];
|
|
65
|
+
return theme.spacing(isDot ? step.dot : step.height) / 2;
|
|
66
|
+
}
|
|
67
|
+
var badgeRecipe = _chunkFNEUOBCVcjs.createRecipe.call(void 0, {
|
|
68
|
+
slots: SLOTS,
|
|
69
|
+
base: (theme) => ({
|
|
70
|
+
root: {
|
|
71
|
+
flexDirection: "row",
|
|
72
|
+
alignItems: "center",
|
|
73
|
+
justifyContent: "center",
|
|
74
|
+
borderWidth: 0,
|
|
75
|
+
// The capsule at every size, which is what makes a two-digit count read as one
|
|
76
|
+
// object. `radius` is still there for the square marker.
|
|
77
|
+
borderRadius: theme.radius.full,
|
|
78
|
+
// Squircle corners for when `radius` overrides the pill. Free on Android.
|
|
79
|
+
borderCurve: "continuous"
|
|
80
|
+
},
|
|
81
|
+
label: {
|
|
82
|
+
fontFamily: theme.fontFamilies.body,
|
|
83
|
+
fontWeight: theme.fontWeights.semibold,
|
|
84
|
+
// Android reserves leading above and below the glyphs, which in a 16pt box is the
|
|
85
|
+
// difference between a centred digit and one sitting low.
|
|
86
|
+
includeFontPadding: false,
|
|
87
|
+
// No `lineHeight`: the scale's leading is taller than the box at every size here,
|
|
88
|
+
// and the root centres the label anyway.
|
|
89
|
+
textAlign: "center"
|
|
90
|
+
}
|
|
91
|
+
}),
|
|
92
|
+
variantTokens: VARIANT_TOKENS,
|
|
93
|
+
/**
|
|
94
|
+
* Where the variant's colours land, for every variant at once. The border width follows
|
|
95
|
+
* the *presence* of the border role, so `ghost` needs no rule of its own.
|
|
96
|
+
*/
|
|
97
|
+
paint: (theme, colors) => ({
|
|
98
|
+
root: {
|
|
99
|
+
backgroundColor: colors.bg,
|
|
100
|
+
borderColor: colors.border,
|
|
101
|
+
borderWidth: colors.border ? theme.borderWidth.default : 0
|
|
102
|
+
},
|
|
103
|
+
label: { color: colors.fg }
|
|
104
|
+
}),
|
|
105
|
+
/** Declaration order is application order: `dot` overrides the box `size` set, and
|
|
106
|
+
* `radius` overrides the capsule from `base`. */
|
|
107
|
+
variants: {
|
|
108
|
+
size: {
|
|
109
|
+
xs: sizeAxis(SIZES.xs),
|
|
110
|
+
sm: sizeAxis(SIZES.sm),
|
|
111
|
+
md: sizeAxis(SIZES.md),
|
|
112
|
+
lg: sizeAxis(SIZES.lg)
|
|
113
|
+
},
|
|
114
|
+
/**
|
|
115
|
+
* The same four keys as `size`, and the root selects it with the resolved size when
|
|
116
|
+
* `isDot` is set and with nothing when it is not — an axis left unselected contributes
|
|
117
|
+
* nothing, which is exactly "this badge has a label". A `{ true, false }` axis would
|
|
118
|
+
* have needed a `false` branch with nothing to say, and a `size × isDot` compound
|
|
119
|
+
* would have been sixteen entries for four measurements.
|
|
120
|
+
*/
|
|
121
|
+
dot: {
|
|
122
|
+
xs: dotAxis(SIZES.xs.dot),
|
|
123
|
+
sm: dotAxis(SIZES.sm.dot),
|
|
124
|
+
md: dotAxis(SIZES.md.dot),
|
|
125
|
+
lg: dotAxis(SIZES.lg.dot)
|
|
126
|
+
},
|
|
127
|
+
radius: _chunkFNEUOBCVcjs.radiusAxis.call(void 0, "root")
|
|
128
|
+
},
|
|
129
|
+
/**
|
|
130
|
+
* `danger`, where every other component in the library defaults to the first name in its
|
|
131
|
+
* ladder. A badge is overwhelmingly the count of something that wants attention — unread,
|
|
132
|
+
* failed, overdue — and a red one is what `<Badge>3</Badge>` means. The accent count is a
|
|
133
|
+
* `variant` away.
|
|
134
|
+
*/
|
|
135
|
+
defaultVariants: { variant: "danger", size: BADGE_DEFAULT_SIZE }
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
// src/components/badge/badge.utils.ts
|
|
139
|
+
function placementInsets(placement, offset) {
|
|
140
|
+
if (!placement) return void 0;
|
|
141
|
+
const vertical = placement.startsWith("top") ? { top: -offset } : { bottom: -offset };
|
|
142
|
+
const horizontal = placement.endsWith("start") ? { start: -offset } : { end: -offset };
|
|
143
|
+
return { position: "absolute", ...vertical, ...horizontal };
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// src/components/badge/badge.tsx
|
|
147
|
+
var _jsxruntime = require('react/jsx-runtime');
|
|
148
|
+
var Badge = _react.forwardRef.call(void 0, function Badge2({
|
|
149
|
+
children,
|
|
150
|
+
variant,
|
|
151
|
+
size,
|
|
152
|
+
radius,
|
|
153
|
+
color,
|
|
154
|
+
isDot = false,
|
|
155
|
+
placement,
|
|
156
|
+
asChild = false,
|
|
157
|
+
style,
|
|
158
|
+
...props
|
|
159
|
+
}, ref) {
|
|
160
|
+
const theme = _chunk57SJ4LJFcjs.useXAUITheme.call(void 0, );
|
|
161
|
+
const [styleProps, rest] = _chunkTK44VBIEcjs.useStyleProps.call(void 0, props);
|
|
162
|
+
const resolvedSize = _nullishCoalesce(size, () => ( BADGE_DEFAULT_SIZE));
|
|
163
|
+
const selection = {
|
|
164
|
+
variant,
|
|
165
|
+
size,
|
|
166
|
+
radius,
|
|
167
|
+
// An axis left unselected contributes nothing, which is exactly "this badge has a
|
|
168
|
+
// label" — no `false` branch with nothing to say.
|
|
169
|
+
dot: isDot ? resolvedSize : void 0
|
|
170
|
+
};
|
|
171
|
+
const styles = badgeRecipe.resolve({ theme, selection });
|
|
172
|
+
const tint = color ? badgeRecipe.tint({ theme, color, selection }) : void 0;
|
|
173
|
+
const insets = _react.useMemo.call(void 0,
|
|
174
|
+
() => placementInsets(placement, badgeOffset(theme, resolvedSize, isDot)),
|
|
175
|
+
[placement, theme, resolvedSize, isDot]
|
|
176
|
+
);
|
|
177
|
+
const rootStyle = [styles.root, _optionalChain([tint, 'optionalAccess', _ => _.root]), insets, styleProps, style];
|
|
178
|
+
const text = _chunk7GHM4GKLcjs.childrenToString.call(void 0, children);
|
|
179
|
+
const label = text !== null ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactnative.Text, { style: [styles.label, _optionalChain([tint, 'optionalAccess', _2 => _2.label])], numberOfLines: 1, children: text }) : children;
|
|
180
|
+
const content = isDot ? null : label;
|
|
181
|
+
const Root = asChild ? _chunk7GHM4GKLcjs.Slot : _reactnative.View;
|
|
182
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
183
|
+
Root,
|
|
184
|
+
{
|
|
185
|
+
ref,
|
|
186
|
+
...rest,
|
|
187
|
+
style: rootStyle,
|
|
188
|
+
children: asChild ? children : content
|
|
189
|
+
}
|
|
190
|
+
);
|
|
191
|
+
});
|
|
192
|
+
Badge.displayName = "XAUI.Badge";
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
exports.badgeRecipe = badgeRecipe; exports.placementInsets = placementInsets; exports.Badge = Badge;
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { createRecipe, radiusAxis } from "./chunk-4GTAZM2C.js";
|
|
2
|
+
import { useXAUITheme } from "./chunk-A3EGFI6T.js";
|
|
3
|
+
import { useStyleProps } from "./chunk-M63GFNKV.js";
|
|
4
|
+
|
|
5
|
+
// src/components/skeleton/skeleton.tsx
|
|
6
|
+
import { forwardRef, useEffect } from "react";
|
|
7
|
+
import { View } from "react-native";
|
|
8
|
+
import Animated, { Easing, cancelAnimation, useAnimatedStyle, useSharedValue, withRepeat, withTiming } from "react-native-reanimated";
|
|
9
|
+
|
|
10
|
+
// src/components/skeleton/skeleton.recipe.ts
|
|
11
|
+
var SLOTS = ["root"];
|
|
12
|
+
var VARIANT_TOKENS = {
|
|
13
|
+
default: {
|
|
14
|
+
bg: "default"
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
var skeletonRecipe = createRecipe({
|
|
18
|
+
slots: SLOTS,
|
|
19
|
+
base: () => ({
|
|
20
|
+
// Squircle corners, free on Android and what keeps a `full` radius from reading as a
|
|
21
|
+
// stadium at small sizes. Nothing else: a skeleton has no size of its own — see the
|
|
22
|
+
// component for why R14 is the whole sizing API here.
|
|
23
|
+
root: {
|
|
24
|
+
borderCurve: "continuous"
|
|
25
|
+
}
|
|
26
|
+
}),
|
|
27
|
+
variantTokens: VARIANT_TOKENS,
|
|
28
|
+
paint: (_theme, colors) => ({
|
|
29
|
+
root: {
|
|
30
|
+
backgroundColor: colors.bg
|
|
31
|
+
}
|
|
32
|
+
}),
|
|
33
|
+
variants: {
|
|
34
|
+
radius: radiusAxis("root")
|
|
35
|
+
},
|
|
36
|
+
/**
|
|
37
|
+
* `md` is the block, and `full` is what an avatar placeholder passes. There is no `size`
|
|
38
|
+
* default because there is no `size`: the caller gives the block its dimensions with
|
|
39
|
+
* R14's `width` and `height`, because only they know the shape of the thing that is
|
|
40
|
+
* missing.
|
|
41
|
+
*/
|
|
42
|
+
/**
|
|
43
|
+
* `variant` is named here and nowhere else: there is one, the caller cannot choose it,
|
|
44
|
+
* and the recipe still needs it selected for `paint` and the tint to resolve.
|
|
45
|
+
*/
|
|
46
|
+
defaultVariants: {
|
|
47
|
+
variant: "default",
|
|
48
|
+
radius: "md"
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
// src/components/skeleton/skeleton.tsx
|
|
53
|
+
import { Fragment, jsx } from "react/jsx-runtime";
|
|
54
|
+
var PULSE_DURATION = 1e3;
|
|
55
|
+
var PULSE_MIN_OPACITY = 0.5;
|
|
56
|
+
var Skeleton = forwardRef(function Skeleton2({
|
|
57
|
+
radius,
|
|
58
|
+
color,
|
|
59
|
+
isLoading = true,
|
|
60
|
+
animation = true,
|
|
61
|
+
children,
|
|
62
|
+
style,
|
|
63
|
+
...props
|
|
64
|
+
}, ref) {
|
|
65
|
+
const theme = useXAUITheme();
|
|
66
|
+
const [styleProps, rest] = useStyleProps(props);
|
|
67
|
+
const selection = {
|
|
68
|
+
radius
|
|
69
|
+
};
|
|
70
|
+
const styles = skeletonRecipe.resolve({
|
|
71
|
+
theme,
|
|
72
|
+
selection
|
|
73
|
+
});
|
|
74
|
+
const tint = color ? skeletonRecipe.tint({
|
|
75
|
+
theme,
|
|
76
|
+
color,
|
|
77
|
+
selection
|
|
78
|
+
}) : void 0;
|
|
79
|
+
if (!isLoading) return /* @__PURE__ */jsx(Fragment, {
|
|
80
|
+
children
|
|
81
|
+
});
|
|
82
|
+
const blockProps = {
|
|
83
|
+
// A block stands in for content that is not there. Announcing its absence is `busy`
|
|
84
|
+
// on whatever region is loading, not a stop on each rectangle. Both stay overridable
|
|
85
|
+
// (R9) for the caller whose skeleton really is the whole screen.
|
|
86
|
+
accessibilityElementsHidden: true,
|
|
87
|
+
importantForAccessibility: "no-hide-descendants",
|
|
88
|
+
...rest
|
|
89
|
+
};
|
|
90
|
+
const blockStyle = [styles.root, tint?.root, styleProps, style];
|
|
91
|
+
if (!animation) return /* @__PURE__ */jsx(View, {
|
|
92
|
+
ref,
|
|
93
|
+
...blockProps,
|
|
94
|
+
style: blockStyle
|
|
95
|
+
});
|
|
96
|
+
return /* @__PURE__ */jsx(PulsingBlock, {
|
|
97
|
+
ref,
|
|
98
|
+
...blockProps,
|
|
99
|
+
style: blockStyle
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
Skeleton.displayName = "XAUI.Skeleton";
|
|
103
|
+
const _worklet_948977267547_init_data = {
|
|
104
|
+
code: "function chunkIKJVLJKTJs1(){const{opacity}=this.__closure;return{opacity:opacity.value};}",
|
|
105
|
+
location: "/home/runner/work/xaui/xaui/packages/native/dist/chunk-IKJVLJKT.js",
|
|
106
|
+
sourceMap: "{\"version\":3,\"names\":[\"chunkIKJVLJKTJs1\",\"opacity\",\"__closure\",\"value\"],\"sources\":[\"/home/runner/work/xaui/xaui/packages/native/dist/chunk-IKJVLJKT.js\"],\"mappings\":\"AAyF2C,SAAAA,gBAAMA,CAAA,QAAAC,OAAA,OAAAC,SAAA,CAE3C,MAAO,CAAED,OAAO,CAAEA,OAAO,CAACE,KAAM,CAAC,CACnC\",\"ignoreList\":[]}"
|
|
107
|
+
};
|
|
108
|
+
var PulsingBlock = forwardRef(function PulsingBlock2({
|
|
109
|
+
style,
|
|
110
|
+
...props
|
|
111
|
+
}, ref) {
|
|
112
|
+
const opacity = useSharedValue(1);
|
|
113
|
+
useEffect(() => {
|
|
114
|
+
opacity.value = withRepeat(withTiming(PULSE_MIN_OPACITY, {
|
|
115
|
+
duration: PULSE_DURATION,
|
|
116
|
+
easing: Easing.inOut(Easing.ease)
|
|
117
|
+
}), -1,
|
|
118
|
+
// Reversed, so the block breathes rather than snapping back to full at each turn.
|
|
119
|
+
true);
|
|
120
|
+
return () => cancelAnimation(opacity);
|
|
121
|
+
}, [opacity]);
|
|
122
|
+
const animatedStyle = useAnimatedStyle(function chunkIKJVLJKTJs1Factory({
|
|
123
|
+
_worklet_948977267547_init_data,
|
|
124
|
+
opacity
|
|
125
|
+
}) {
|
|
126
|
+
const _e = [new global.Error(), -2, -27];
|
|
127
|
+
const chunkIKJVLJKTJs1 = function () {
|
|
128
|
+
return {
|
|
129
|
+
opacity: opacity.value
|
|
130
|
+
};
|
|
131
|
+
};
|
|
132
|
+
chunkIKJVLJKTJs1.__closure = {
|
|
133
|
+
opacity
|
|
134
|
+
};
|
|
135
|
+
chunkIKJVLJKTJs1.__workletHash = 948977267547;
|
|
136
|
+
chunkIKJVLJKTJs1.__pluginVersion = "0.7.4";
|
|
137
|
+
chunkIKJVLJKTJs1.__initData = _worklet_948977267547_init_data;
|
|
138
|
+
chunkIKJVLJKTJs1.__stackDetails = _e;
|
|
139
|
+
return chunkIKJVLJKTJs1;
|
|
140
|
+
}({
|
|
141
|
+
_worklet_948977267547_init_data,
|
|
142
|
+
opacity
|
|
143
|
+
}), [opacity]);
|
|
144
|
+
return /* @__PURE__ */jsx(Animated.View, {
|
|
145
|
+
ref,
|
|
146
|
+
...props,
|
|
147
|
+
style: [style, animatedStyle]
|
|
148
|
+
});
|
|
149
|
+
});
|
|
150
|
+
PulsingBlock.displayName = "XAUI.Skeleton.Block";
|
|
151
|
+
export { skeletonRecipe, Skeleton };
|