@xaui/native 0.9.1-alpha.32 → 0.9.1-alpha.34
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-DUQUCOUY.cjs +198 -0
- package/dist/chunk-I66VMLHE.cjs +410 -0
- package/dist/chunk-LZK77LFX.js +198 -0
- package/dist/chunk-ZA6RT3XQ.js +381 -0
- package/dist/components/alert/index.cjs +1 -1
- package/dist/components/alert/index.js +1 -1
- package/dist/components/avatar/index.cjs +17 -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 +17 -0
- package/dist/components/badge/index.cjs +16 -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 +16 -0
- package/dist/components/button/index.cjs +3 -3
- package/dist/components/button/index.js +2 -2
- package/dist/components/chip/index.cjs +3 -3
- package/dist/components/chip/index.js +2 -2
- package/dist/index.cjs +40 -24
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +56 -40
- package/dist/system/index.cjs +4 -4
- package/dist/system/index.js +5 -5
- package/package.json +21 -1
- package/dist/{chunk-Y2B4XM3Y.js → chunk-2IWL6R3D.js} +3 -3
- package/dist/{chunk-4MPSXDAB.cjs → chunk-DBXFFJTC.cjs} +3 -3
- package/dist/{chunk-4YJLNYUS.js → chunk-M2BGCN77.js} +3 -3
- package/dist/{chunk-ETSYP3NH.cjs → chunk-QY4MN7X3.cjs} +3 -3
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Slot,
|
|
3
|
+
childrenToString
|
|
4
|
+
} from "./chunk-YXPYOOHU.js";
|
|
5
|
+
import {
|
|
6
|
+
createRecipe,
|
|
7
|
+
radiusAxis
|
|
8
|
+
} from "./chunk-4GTAZM2C.js";
|
|
9
|
+
import {
|
|
10
|
+
useStyleProps
|
|
11
|
+
} from "./chunk-MEYCZS32.js";
|
|
12
|
+
import {
|
|
13
|
+
useXAUITheme
|
|
14
|
+
} from "./chunk-A3EGFI6T.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,381 @@
|
|
|
1
|
+
import { IconContext } from "./chunk-WJPQARJ5.js";
|
|
2
|
+
import { Slot, childrenToString, createSlotContext } from "./chunk-YXPYOOHU.js";
|
|
3
|
+
import { createRecipe, radiusAxis } from "./chunk-4GTAZM2C.js";
|
|
4
|
+
import { useStyleProps } from "./chunk-MEYCZS32.js";
|
|
5
|
+
import { useXAUITheme } from "./chunk-A3EGFI6T.js";
|
|
6
|
+
|
|
7
|
+
// src/components/avatar/avatar-fallback.tsx
|
|
8
|
+
import { forwardRef as forwardRef2 } from "react";
|
|
9
|
+
import { View } from "react-native";
|
|
10
|
+
|
|
11
|
+
// src/components/avatar/avatar-initials.tsx
|
|
12
|
+
import { forwardRef } from "react";
|
|
13
|
+
import { Text } from "react-native";
|
|
14
|
+
|
|
15
|
+
// src/components/avatar/avatar.context.ts
|
|
16
|
+
var [AvatarProvider, useAvatar] = createSlotContext("Avatar");
|
|
17
|
+
|
|
18
|
+
// src/components/avatar/avatar-initials.tsx
|
|
19
|
+
import { jsx } from "react/jsx-runtime";
|
|
20
|
+
var AvatarInitials = forwardRef(function AvatarInitials2({
|
|
21
|
+
children,
|
|
22
|
+
style,
|
|
23
|
+
...props
|
|
24
|
+
}, ref) {
|
|
25
|
+
const {
|
|
26
|
+
initialsStyle
|
|
27
|
+
} = useAvatar();
|
|
28
|
+
const [styleProps, rest] = useStyleProps(props);
|
|
29
|
+
return /* @__PURE__ */jsx(Text, {
|
|
30
|
+
ref,
|
|
31
|
+
accessibilityElementsHidden: true,
|
|
32
|
+
importantForAccessibility: "no",
|
|
33
|
+
numberOfLines: 1,
|
|
34
|
+
...rest,
|
|
35
|
+
style: [initialsStyle, styleProps, style],
|
|
36
|
+
children
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
AvatarInitials.displayName = "XAUI.Avatar.Initials";
|
|
40
|
+
|
|
41
|
+
// src/components/avatar/avatar-fallback.tsx
|
|
42
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
43
|
+
var AvatarFallback = forwardRef2(function AvatarFallback2({
|
|
44
|
+
children,
|
|
45
|
+
style,
|
|
46
|
+
...props
|
|
47
|
+
}, ref) {
|
|
48
|
+
const {
|
|
49
|
+
fallbackStyle,
|
|
50
|
+
icon
|
|
51
|
+
} = useAvatar();
|
|
52
|
+
const [styleProps, rest] = useStyleProps(props);
|
|
53
|
+
const text = childrenToString(children);
|
|
54
|
+
const content = text !== null ? /* @__PURE__ */jsx2(AvatarInitials, {
|
|
55
|
+
children: text
|
|
56
|
+
}) : children;
|
|
57
|
+
return /* @__PURE__ */jsx2(View, {
|
|
58
|
+
ref,
|
|
59
|
+
style: [fallbackStyle, styleProps, style],
|
|
60
|
+
...rest,
|
|
61
|
+
children: /* @__PURE__ */jsx2(IconContext.Provider, {
|
|
62
|
+
value: icon,
|
|
63
|
+
children: content
|
|
64
|
+
})
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
AvatarFallback.displayName = "XAUI.Avatar.Fallback";
|
|
68
|
+
|
|
69
|
+
// src/components/avatar/avatar-image.tsx
|
|
70
|
+
import { forwardRef as forwardRef3, useCallback } from "react";
|
|
71
|
+
import { Image } from "react-native";
|
|
72
|
+
import Animated, { useAnimatedStyle, useSharedValue, withTiming } from "react-native-reanimated";
|
|
73
|
+
|
|
74
|
+
// src/components/avatar/avatar.style.ts
|
|
75
|
+
import { StyleSheet } from "react-native";
|
|
76
|
+
var avatarSheet = StyleSheet.create({
|
|
77
|
+
image: {
|
|
78
|
+
position: "absolute",
|
|
79
|
+
top: 0,
|
|
80
|
+
bottom: 0,
|
|
81
|
+
start: 0,
|
|
82
|
+
end: 0
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
// src/components/avatar/avatar-image.tsx
|
|
87
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
88
|
+
var FADE_DURATION = 200;
|
|
89
|
+
var AvatarImage = forwardRef3(function AvatarImage2({
|
|
90
|
+
animation = true,
|
|
91
|
+
style,
|
|
92
|
+
...props
|
|
93
|
+
}, ref) {
|
|
94
|
+
const [styleProps, rest] = useStyleProps(props);
|
|
95
|
+
const frameStyle = [avatarSheet.image, styleProps, style];
|
|
96
|
+
if (!animation) return /* @__PURE__ */jsx3(Image, {
|
|
97
|
+
ref,
|
|
98
|
+
...rest,
|
|
99
|
+
style: frameStyle
|
|
100
|
+
});
|
|
101
|
+
return /* @__PURE__ */jsx3(FadingImage, {
|
|
102
|
+
ref,
|
|
103
|
+
...rest,
|
|
104
|
+
style: frameStyle
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
AvatarImage.displayName = "XAUI.Avatar.Image";
|
|
108
|
+
const _worklet_9106607863565_init_data = {
|
|
109
|
+
code: "function chunkZA6RT3XQJs1(){const{opacity}=this.__closure;return{opacity:opacity.value};}",
|
|
110
|
+
location: "/home/runner/work/xaui/xaui/packages/native/dist/chunk-ZA6RT3XQ.js",
|
|
111
|
+
sourceMap: "{\"version\":3,\"names\":[\"chunkZA6RT3XQJs1\",\"opacity\",\"__closure\",\"value\"],\"sources\":[\"/home/runner/work/xaui/xaui/packages/native/dist/chunk-ZA6RT3XQ.js\"],\"mappings\":\"AAoG2C,SAAAA,gBAAMA,CAAA,QAAAC,OAAA,OAAAC,SAAA,CAE3C,MAAO,CAAED,OAAO,CAAEA,OAAO,CAACE,KAAM,CAAC,CACnC\",\"ignoreList\":[]}"
|
|
112
|
+
};
|
|
113
|
+
var FadingImage = forwardRef3(function FadingImage2({
|
|
114
|
+
onLoad,
|
|
115
|
+
style,
|
|
116
|
+
...props
|
|
117
|
+
}, ref) {
|
|
118
|
+
const opacity = useSharedValue(0);
|
|
119
|
+
const handleLoad = useCallback(event => {
|
|
120
|
+
opacity.value = withTiming(1, {
|
|
121
|
+
duration: FADE_DURATION
|
|
122
|
+
});
|
|
123
|
+
onLoad?.(event);
|
|
124
|
+
}, [opacity, onLoad]);
|
|
125
|
+
const animatedStyle = useAnimatedStyle(function chunkZA6RT3XQJs1Factory({
|
|
126
|
+
_worklet_9106607863565_init_data,
|
|
127
|
+
opacity
|
|
128
|
+
}) {
|
|
129
|
+
const _e = [new global.Error(), -2, -27];
|
|
130
|
+
const chunkZA6RT3XQJs1 = function () {
|
|
131
|
+
return {
|
|
132
|
+
opacity: opacity.value
|
|
133
|
+
};
|
|
134
|
+
};
|
|
135
|
+
chunkZA6RT3XQJs1.__closure = {
|
|
136
|
+
opacity
|
|
137
|
+
};
|
|
138
|
+
chunkZA6RT3XQJs1.__workletHash = 9106607863565;
|
|
139
|
+
chunkZA6RT3XQJs1.__pluginVersion = "0.7.4";
|
|
140
|
+
chunkZA6RT3XQJs1.__initData = _worklet_9106607863565_init_data;
|
|
141
|
+
chunkZA6RT3XQJs1.__stackDetails = _e;
|
|
142
|
+
return chunkZA6RT3XQJs1;
|
|
143
|
+
}({
|
|
144
|
+
_worklet_9106607863565_init_data,
|
|
145
|
+
opacity
|
|
146
|
+
}), [opacity]);
|
|
147
|
+
return /* @__PURE__ */jsx3(Animated.Image, {
|
|
148
|
+
ref,
|
|
149
|
+
...props,
|
|
150
|
+
onLoad: handleLoad,
|
|
151
|
+
style: [style, animatedStyle]
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
// src/components/avatar/avatar.tsx
|
|
156
|
+
import { forwardRef as forwardRef4, useMemo } from "react";
|
|
157
|
+
import { StyleSheet as StyleSheet2, View as View2 } from "react-native";
|
|
158
|
+
|
|
159
|
+
// src/components/avatar/avatar.recipe.ts
|
|
160
|
+
var SLOTS = ["root", "fallback", "initials", "icon"];
|
|
161
|
+
var VARIANT_TOKENS = {
|
|
162
|
+
primary: {
|
|
163
|
+
bg: "accent",
|
|
164
|
+
fg: "accentForeground"
|
|
165
|
+
},
|
|
166
|
+
secondary: {
|
|
167
|
+
bg: "accentSoft",
|
|
168
|
+
fg: "accentSoftForeground"
|
|
169
|
+
},
|
|
170
|
+
default: {
|
|
171
|
+
bg: "default",
|
|
172
|
+
fg: "defaultForeground"
|
|
173
|
+
},
|
|
174
|
+
tertiary: {
|
|
175
|
+
border: "border",
|
|
176
|
+
fg: "foreground"
|
|
177
|
+
},
|
|
178
|
+
ghost: {
|
|
179
|
+
fg: "foreground"
|
|
180
|
+
},
|
|
181
|
+
success: {
|
|
182
|
+
bg: "success",
|
|
183
|
+
fg: "successForeground"
|
|
184
|
+
},
|
|
185
|
+
"success-soft": {
|
|
186
|
+
bg: "successSoft",
|
|
187
|
+
fg: "successSoftForeground"
|
|
188
|
+
},
|
|
189
|
+
warning: {
|
|
190
|
+
bg: "warning",
|
|
191
|
+
fg: "warningForeground"
|
|
192
|
+
},
|
|
193
|
+
"warning-soft": {
|
|
194
|
+
bg: "warningSoft",
|
|
195
|
+
fg: "warningSoftForeground"
|
|
196
|
+
},
|
|
197
|
+
danger: {
|
|
198
|
+
bg: "danger",
|
|
199
|
+
fg: "dangerForeground"
|
|
200
|
+
},
|
|
201
|
+
"danger-soft": {
|
|
202
|
+
bg: "dangerSoft",
|
|
203
|
+
fg: "dangerSoftForeground"
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
function sizeAxis(step) {
|
|
207
|
+
return theme => {
|
|
208
|
+
const diameter = theme.spacing(step.diameter);
|
|
209
|
+
return {
|
|
210
|
+
root: {
|
|
211
|
+
width: diameter,
|
|
212
|
+
height: diameter
|
|
213
|
+
},
|
|
214
|
+
initials: {
|
|
215
|
+
fontSize: theme.fontSizes[step.initials],
|
|
216
|
+
lineHeight: theme.lineHeights[step.initials]
|
|
217
|
+
},
|
|
218
|
+
icon: {
|
|
219
|
+
fontSize: theme.fontSizes[step.glyph]
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
var SIZES = {
|
|
225
|
+
xs: {
|
|
226
|
+
diameter: 8,
|
|
227
|
+
initials: "xs",
|
|
228
|
+
glyph: "xs"
|
|
229
|
+
},
|
|
230
|
+
sm: {
|
|
231
|
+
diameter: 10,
|
|
232
|
+
initials: "xs",
|
|
233
|
+
glyph: "sm"
|
|
234
|
+
},
|
|
235
|
+
md: {
|
|
236
|
+
diameter: 12,
|
|
237
|
+
initials: "sm",
|
|
238
|
+
glyph: "md"
|
|
239
|
+
},
|
|
240
|
+
lg: {
|
|
241
|
+
diameter: 16,
|
|
242
|
+
initials: "md",
|
|
243
|
+
glyph: "xl"
|
|
244
|
+
}
|
|
245
|
+
};
|
|
246
|
+
var avatarRecipe = createRecipe({
|
|
247
|
+
slots: SLOTS,
|
|
248
|
+
base: theme => ({
|
|
249
|
+
root: {
|
|
250
|
+
alignItems: "center",
|
|
251
|
+
justifyContent: "center",
|
|
252
|
+
// The clip is what makes a square photo round, so unlike on the `Chip` it is not
|
|
253
|
+
// optional here: without it the image is a rectangle sitting over a circle.
|
|
254
|
+
overflow: "hidden",
|
|
255
|
+
// Squircle corners for when `radius` overrides the circle. Free on Android.
|
|
256
|
+
borderCurve: "continuous",
|
|
257
|
+
borderWidth: 0
|
|
258
|
+
},
|
|
259
|
+
fallback: {
|
|
260
|
+
width: "100%",
|
|
261
|
+
height: "100%",
|
|
262
|
+
alignItems: "center",
|
|
263
|
+
justifyContent: "center"
|
|
264
|
+
},
|
|
265
|
+
initials: {
|
|
266
|
+
fontFamily: theme.fontFamilies.body,
|
|
267
|
+
fontWeight: theme.fontWeights.medium,
|
|
268
|
+
// Two letters in a circle sit off-centre by the descender otherwise.
|
|
269
|
+
textAlign: "center"
|
|
270
|
+
}
|
|
271
|
+
}),
|
|
272
|
+
variantTokens: VARIANT_TOKENS,
|
|
273
|
+
/**
|
|
274
|
+
* Where the variant's colours land, for every variant at once. The border width follows
|
|
275
|
+
* the *presence* of the border role, so `ghost` needs no rule of its own to say it has
|
|
276
|
+
* no edge.
|
|
277
|
+
*
|
|
278
|
+
* The image takes no colour: it is a photograph, and tinting one is what `Icon`'s
|
|
279
|
+
* `source` form is for.
|
|
280
|
+
*/
|
|
281
|
+
paint: (theme, colors) => ({
|
|
282
|
+
root: {
|
|
283
|
+
backgroundColor: colors.bg,
|
|
284
|
+
borderColor: colors.border,
|
|
285
|
+
borderWidth: colors.border ? theme.borderWidth.default : 0
|
|
286
|
+
},
|
|
287
|
+
initials: {
|
|
288
|
+
color: colors.fg
|
|
289
|
+
},
|
|
290
|
+
icon: {
|
|
291
|
+
color: colors.fg
|
|
292
|
+
}
|
|
293
|
+
}),
|
|
294
|
+
/** Declaration order is application order: `radius` overrides the circle `base` set. */
|
|
295
|
+
variants: {
|
|
296
|
+
size: {
|
|
297
|
+
xs: sizeAxis(SIZES.xs),
|
|
298
|
+
sm: sizeAxis(SIZES.sm),
|
|
299
|
+
md: sizeAxis(SIZES.md),
|
|
300
|
+
lg: sizeAxis(SIZES.lg)
|
|
301
|
+
},
|
|
302
|
+
radius: radiusAxis("root")
|
|
303
|
+
},
|
|
304
|
+
/**
|
|
305
|
+
* A circle at every size, where HeroUI fixes one large radius for all three — which
|
|
306
|
+
* makes their small avatars round and their large ones squircles. `full` says the shape
|
|
307
|
+
* the name means once, and `radius` is still there for the logo that wants a square.
|
|
308
|
+
*/
|
|
309
|
+
defaultVariants: {
|
|
310
|
+
variant: "default",
|
|
311
|
+
size: "md",
|
|
312
|
+
radius: "full"
|
|
313
|
+
}
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
// src/components/avatar/avatar.tsx
|
|
317
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
318
|
+
var AvatarRoot = forwardRef4(function Avatar({
|
|
319
|
+
children,
|
|
320
|
+
variant,
|
|
321
|
+
size,
|
|
322
|
+
radius,
|
|
323
|
+
color,
|
|
324
|
+
asChild = false,
|
|
325
|
+
style,
|
|
326
|
+
...props
|
|
327
|
+
}, ref) {
|
|
328
|
+
const theme = useXAUITheme();
|
|
329
|
+
const [styleProps, rest] = useStyleProps(props);
|
|
330
|
+
const selection = {
|
|
331
|
+
variant,
|
|
332
|
+
size,
|
|
333
|
+
radius
|
|
334
|
+
};
|
|
335
|
+
const styles = avatarRecipe.resolve({
|
|
336
|
+
theme,
|
|
337
|
+
selection
|
|
338
|
+
});
|
|
339
|
+
const tint = color ? avatarRecipe.tint({
|
|
340
|
+
theme,
|
|
341
|
+
color,
|
|
342
|
+
selection
|
|
343
|
+
}) : void 0;
|
|
344
|
+
const context = useMemo(() => {
|
|
345
|
+
const icon = StyleSheet2.flatten([styles.icon, tint?.icon]);
|
|
346
|
+
return {
|
|
347
|
+
fallbackStyle: styles.fallback,
|
|
348
|
+
initialsStyle: tint ? [styles.initials, tint.initials] : styles.initials,
|
|
349
|
+
icon: {
|
|
350
|
+
size: icon.fontSize,
|
|
351
|
+
// `ColorValue` also covers the platform's opaque colours, which `Icon` cannot
|
|
352
|
+
// hand to a third-party component expecting a string.
|
|
353
|
+
color: typeof icon.color === "string" ? icon.color : void 0
|
|
354
|
+
}
|
|
355
|
+
};
|
|
356
|
+
}, [styles, tint]);
|
|
357
|
+
const rootStyle = [styles.root, tint?.root, styleProps, style];
|
|
358
|
+
const text = childrenToString(children);
|
|
359
|
+
const content = text !== null ? /* @__PURE__ */jsx4(AvatarFallback, {
|
|
360
|
+
children: text
|
|
361
|
+
}) : children;
|
|
362
|
+
const Root = asChild ? Slot : View2;
|
|
363
|
+
return /* @__PURE__ */jsx4(AvatarProvider, {
|
|
364
|
+
value: context,
|
|
365
|
+
children: /* @__PURE__ */jsx4(Root, {
|
|
366
|
+
ref,
|
|
367
|
+
...rest,
|
|
368
|
+
style: rootStyle,
|
|
369
|
+
children: asChild ? children : content
|
|
370
|
+
})
|
|
371
|
+
});
|
|
372
|
+
});
|
|
373
|
+
AvatarRoot.displayName = "XAUI.Avatar.Root";
|
|
374
|
+
|
|
375
|
+
// src/components/avatar/index.ts
|
|
376
|
+
var Avatar2 = Object.assign(AvatarRoot, {
|
|
377
|
+
Image: AvatarImage,
|
|
378
|
+
Fallback: AvatarFallback,
|
|
379
|
+
Initials: AvatarInitials
|
|
380
|
+
});
|
|
381
|
+
export { useAvatar, avatarRecipe, Avatar2 as Avatar };
|
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
|
|
5
5
|
var _chunkK7LLERKTcjs = require('../../chunk-K7LLERKT.cjs');
|
|
6
6
|
require('../../chunk-CYS6U374.cjs');
|
|
7
|
+
require('../../chunk-PCWT2YBE.cjs');
|
|
7
8
|
require('../../chunk-6M7RUU7V.cjs');
|
|
8
9
|
require('../../chunk-7DPL3ZDS.cjs');
|
|
9
10
|
require('../../chunk-EJQCQPET.cjs');
|
|
10
|
-
require('../../chunk-PCWT2YBE.cjs');
|
|
11
11
|
require('../../chunk-54FJOKAN.cjs');
|
|
12
12
|
require('../../chunk-H4E4HDEP.cjs');
|
|
13
13
|
require('../../chunk-FNEUOBCV.cjs');
|
|
@@ -4,10 +4,10 @@ import {
|
|
|
4
4
|
useAlert
|
|
5
5
|
} from "../../chunk-AYOVBZAX.js";
|
|
6
6
|
import "../../chunk-U3RDU3HU.js";
|
|
7
|
+
import "../../chunk-WJPQARJ5.js";
|
|
7
8
|
import "../../chunk-XNNJM5DQ.js";
|
|
8
9
|
import "../../chunk-423RQBOX.js";
|
|
9
10
|
import "../../chunk-EGLLDKN6.js";
|
|
10
|
-
import "../../chunk-WJPQARJ5.js";
|
|
11
11
|
import "../../chunk-YXPYOOHU.js";
|
|
12
12
|
import "../../chunk-36PRYGAM.js";
|
|
13
13
|
import "../../chunk-4GTAZM2C.js";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
var _chunkI66VMLHEcjs = require('../../chunk-I66VMLHE.cjs');
|
|
6
|
+
require('../../chunk-PCWT2YBE.cjs');
|
|
7
|
+
require('../../chunk-54FJOKAN.cjs');
|
|
8
|
+
require('../../chunk-H4E4HDEP.cjs');
|
|
9
|
+
require('../../chunk-FNEUOBCV.cjs');
|
|
10
|
+
require('../../chunk-I6ZB3FZI.cjs');
|
|
11
|
+
require('../../chunk-57SJ4LJF.cjs');
|
|
12
|
+
require('../../chunk-MC7SY2QH.cjs');
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
exports.Avatar = _chunkI66VMLHEcjs.Avatar; exports.avatarRecipe = _chunkI66VMLHEcjs.avatarRecipe; exports.useAvatar = _chunkI66VMLHEcjs.useAvatar;
|