@xaui/native 0.9.1-alpha.39 → 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-GJSFKH4L.js → chunk-2XPG2243.js} +16 -16
- package/dist/{chunk-TGMVEHV7.cjs → chunk-3E7CDKFO.cjs} +61 -61
- package/dist/{chunk-37L7YGZV.cjs → chunk-5R26NM4M.cjs} +11 -34
- package/dist/chunk-5VKYNBNA.js +607 -0
- package/dist/{chunk-S4QUM4EE.cjs → chunk-6DOLGZVV.cjs} +4 -4
- package/dist/{chunk-LIUO6D3D.js → chunk-6UEZJRVI.js} +75 -75
- package/dist/chunk-734MFAX4.js +27 -0
- package/dist/{chunk-VZK3NLBH.cjs → chunk-7YF5NAHQ.cjs} +7 -7
- package/dist/{chunk-SIP5J7HU.cjs → chunk-ABAGZTXZ.cjs} +15 -15
- package/dist/{chunk-USF6EWYR.js → chunk-BRRXFOBY.js} +7 -7
- package/dist/{chunk-4KSKQD37.cjs → chunk-C5YLPCFC.cjs} +5 -5
- package/dist/{chunk-54CWXA34.cjs → chunk-DA3OKXHV.cjs} +59 -59
- package/dist/{chunk-HA6BFY3A.js → chunk-DD4276RF.js} +6 -6
- package/dist/{chunk-SACDOFGF.js → chunk-DG2I4PJG.js} +15 -15
- package/dist/{chunk-FBCWNXZC.js → chunk-DHGLGSH6.js} +58 -58
- package/dist/{chunk-MXGER5PI.js → chunk-DIBUQ46Y.js} +5 -5
- package/dist/{chunk-XAFP5JLK.js → chunk-EZEYMLO3.js} +13 -36
- package/dist/{chunk-7KLBTMXV.cjs → chunk-G7P3ERYF.cjs} +5 -5
- package/dist/{chunk-QZ24MZRX.js → chunk-GA6PBWNT.js} +1 -1
- package/dist/{chunk-HOI5425P.cjs → chunk-GFUZ3MUT.cjs} +6 -6
- package/dist/chunk-GTR5X65M.cjs +27 -0
- package/dist/{chunk-EYD4H4X6.js → chunk-KCMYU7WF.js} +1 -1
- package/dist/{chunk-JKP4TPIL.js → chunk-LRN3RNDO.js} +16 -16
- package/dist/{chunk-XNMZQSY5.js → chunk-N3KTZMPG.js} +5 -5
- package/dist/{chunk-7TOG4TVU.cjs → chunk-NWGLP6JX.cjs} +15 -15
- package/dist/{chunk-NCCRQK3P.cjs → chunk-R73XQK7X.cjs} +5 -5
- package/dist/{chunk-76XDVA24.cjs → chunk-RU7JCMWC.cjs} +6 -6
- package/dist/chunk-T5FV5F7A.cjs +607 -0
- package/dist/{chunk-3JXI2IHV.cjs → chunk-TJ74XVZN.cjs} +8 -8
- package/dist/{chunk-URA25DU4.cjs → chunk-UAWBAD4E.cjs} +5 -5
- package/dist/{chunk-6CO6FM67.js → chunk-UFTCTTKK.js} +15 -15
- package/dist/{chunk-DY3SUG5P.js → chunk-XFPQFCEK.js} +6 -6
- package/dist/{chunk-66FOASTP.cjs → chunk-XV735BSA.cjs} +6 -6
- package/dist/{chunk-TRETQZEW.js → chunk-YGYYJ3LQ.js} +5 -5
- package/dist/{chunk-R7BU4CPS.js → chunk-YVHT2UVW.js} +1 -1
- package/dist/{chunk-AAVCMCJ3.cjs → chunk-ZFOOJK37.cjs} +2 -2
- package/dist/components/accordion/index.cjs +5 -5
- package/dist/components/accordion/index.js +4 -4
- package/dist/components/alert/index.cjs +6 -6
- package/dist/components/alert/index.js +5 -5
- package/dist/components/avatar/index.cjs +4 -4
- package/dist/components/avatar/index.js +3 -3
- package/dist/components/badge/index.cjs +4 -4
- package/dist/components/badge/index.js +3 -3
- package/dist/components/button/index.cjs +5 -5
- package/dist/components/button/index.js +4 -4
- package/dist/components/card/index.cjs +5 -5
- package/dist/components/card/index.js +4 -4
- package/dist/components/checkbox/index.cjs +5 -5
- package/dist/components/checkbox/index.js +4 -4
- package/dist/components/chip/index.cjs +6 -6
- package/dist/components/chip/index.js +5 -5
- package/dist/components/divider/index.cjs +4 -4
- package/dist/components/divider/index.js +3 -3
- package/dist/components/field-group/index.cjs +5 -5
- package/dist/components/field-group/index.js +4 -4
- package/dist/components/input-otp/index.cjs +4 -4
- package/dist/components/input-otp/index.js +3 -3
- 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 +6 -5
- package/dist/components/popover/index.js +5 -4
- package/dist/components/radio/index.cjs +5 -5
- package/dist/components/radio/index.js +4 -4
- package/dist/components/select/index.cjs +5 -5
- package/dist/components/select/index.d.cts +1 -1
- package/dist/components/select/index.d.ts +1 -1
- package/dist/components/select/index.js +4 -4
- package/dist/components/spinner/index.cjs +1 -1
- package/dist/components/spinner/index.js +1 -1
- package/dist/components/switch/index.cjs +5 -5
- package/dist/components/switch/index.js +4 -4
- package/dist/components/text-area/index.cjs +5 -5
- package/dist/components/text-area/index.js +4 -4
- package/dist/components/text-field/index.cjs +4 -4
- package/dist/components/text-field/index.js +3 -3
- package/dist/components/typography/index.cjs +4 -4
- package/dist/components/typography/index.js +3 -3
- package/dist/index.cjs +61 -28
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +78 -45
- package/dist/system/index.cjs +7 -7
- package/dist/system/index.js +7 -7
- package/package.json +11 -1
- package/dist/{chunk-S2WNWMNT.js → chunk-2NRZKJG7.js} +4 -4
- package/dist/{chunk-26OGEFQI.js → chunk-4CUZZWFW.js} +3 -3
- package/dist/{chunk-KSUV74BE.cjs → chunk-6L2TS2R3.cjs} +3 -3
- package/dist/{chunk-SZLXPF3G.js → chunk-73RKQC5X.js} +3 -3
- package/dist/{chunk-BNFIFRQA.cjs → chunk-AMCSSOJT.cjs} +3 -3
- package/dist/{chunk-346QBNUD.js → chunk-H7DS4IO7.js} +4 -4
- package/dist/{chunk-RKCWYUGA.cjs → chunk-HDVVZG4S.cjs} +3 -3
- package/dist/{chunk-A7YB7YWX.cjs → chunk-J3MB4PI5.cjs} +3 -3
|
@@ -0,0 +1,607 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useAnchorRef
|
|
3
|
+
} from "./chunk-734MFAX4.js";
|
|
4
|
+
import {
|
|
5
|
+
useAnchoredPosition
|
|
6
|
+
} from "./chunk-2EGR4LWD.js";
|
|
7
|
+
import {
|
|
8
|
+
Portal
|
|
9
|
+
} from "./chunk-2PMXMKS5.js";
|
|
10
|
+
import {
|
|
11
|
+
anchoredEntering,
|
|
12
|
+
anchoredExiting,
|
|
13
|
+
overlayEntering,
|
|
14
|
+
overlayExiting
|
|
15
|
+
} from "./chunk-64MXEVT3.js";
|
|
16
|
+
import {
|
|
17
|
+
useMergedRef
|
|
18
|
+
} from "./chunk-NCTOTTVW.js";
|
|
19
|
+
import {
|
|
20
|
+
IconContext
|
|
21
|
+
} from "./chunk-FHUYHV6J.js";
|
|
22
|
+
import {
|
|
23
|
+
useControllableState
|
|
24
|
+
} from "./chunk-F6W3JQ7K.js";
|
|
25
|
+
import {
|
|
26
|
+
PressableFeedback
|
|
27
|
+
} from "./chunk-6UEZJRVI.js";
|
|
28
|
+
import {
|
|
29
|
+
usePressState
|
|
30
|
+
} from "./chunk-423RQBOX.js";
|
|
31
|
+
import {
|
|
32
|
+
createRecipe,
|
|
33
|
+
radiusAxis
|
|
34
|
+
} from "./chunk-4GTAZM2C.js";
|
|
35
|
+
import {
|
|
36
|
+
useXAUITheme
|
|
37
|
+
} from "./chunk-A3EGFI6T.js";
|
|
38
|
+
import {
|
|
39
|
+
createSlotContext
|
|
40
|
+
} from "./chunk-K72UDPVN.js";
|
|
41
|
+
import {
|
|
42
|
+
useStyleProps
|
|
43
|
+
} from "./chunk-M63GFNKV.js";
|
|
44
|
+
|
|
45
|
+
// src/components/menu/menu-content.tsx
|
|
46
|
+
import { forwardRef } from "react";
|
|
47
|
+
import Animated from "react-native-reanimated";
|
|
48
|
+
|
|
49
|
+
// src/components/menu/menu.recipe.ts
|
|
50
|
+
import { StyleSheet } from "react-native";
|
|
51
|
+
var SLOTS = [
|
|
52
|
+
"trigger",
|
|
53
|
+
"overlay",
|
|
54
|
+
"content",
|
|
55
|
+
"label",
|
|
56
|
+
"separator",
|
|
57
|
+
"group",
|
|
58
|
+
"item",
|
|
59
|
+
"itemTitle",
|
|
60
|
+
"itemDescription",
|
|
61
|
+
"itemIndicator"
|
|
62
|
+
];
|
|
63
|
+
var VARIANT_TOKENS = {
|
|
64
|
+
default: { fg: "overlayForeground" },
|
|
65
|
+
danger: { fg: "danger" }
|
|
66
|
+
};
|
|
67
|
+
function menuMeasure(fontSize) {
|
|
68
|
+
return fontSize * 15;
|
|
69
|
+
}
|
|
70
|
+
var PANEL_PADDING_HORIZONTAL = 1.5;
|
|
71
|
+
var PANEL_PADDING_VERTICAL = 3;
|
|
72
|
+
var ITEM_PADDING_HORIZONTAL = 2.5;
|
|
73
|
+
var ITEM_PADDING_VERTICAL = 2;
|
|
74
|
+
var ITEM_GAP = 2.5;
|
|
75
|
+
var LABEL_INSET = 3;
|
|
76
|
+
var INDICATOR = 5;
|
|
77
|
+
var HAIRLINE = StyleSheet.hairlineWidth;
|
|
78
|
+
var menuRecipe = createRecipe({
|
|
79
|
+
slots: SLOTS,
|
|
80
|
+
base: (theme) => ({
|
|
81
|
+
overlay: { position: "absolute", top: 0, bottom: 0, start: 0, end: 0 },
|
|
82
|
+
content: {
|
|
83
|
+
position: "absolute",
|
|
84
|
+
backgroundColor: theme.colors.overlay,
|
|
85
|
+
paddingHorizontal: theme.spacing(PANEL_PADDING_HORIZONTAL),
|
|
86
|
+
paddingVertical: theme.spacing(PANEL_PADDING_VERTICAL),
|
|
87
|
+
// Their `--radius-3xl` on a base of 8 is 24; our base is 12, so the same 24 is `2xl`.
|
|
88
|
+
borderRadius: theme.radius["2xl"],
|
|
89
|
+
borderCurve: "continuous",
|
|
90
|
+
...theme.shadows.overlay
|
|
91
|
+
},
|
|
92
|
+
label: {
|
|
93
|
+
fontFamily: theme.fontFamilies.body,
|
|
94
|
+
fontWeight: theme.fontWeights.medium,
|
|
95
|
+
fontSize: theme.fontSizes.sm,
|
|
96
|
+
lineHeight: theme.lineHeights.sm,
|
|
97
|
+
color: theme.colors.muted,
|
|
98
|
+
// Inset to the row's own text rather than to the panel: a heading that starts
|
|
99
|
+
// before the rows it heads reads as a heading for the panel.
|
|
100
|
+
marginStart: theme.spacing(LABEL_INSET),
|
|
101
|
+
paddingVertical: theme.spacing(1)
|
|
102
|
+
},
|
|
103
|
+
/**
|
|
104
|
+
* A rule between two runs of rows, placed by the caller rather than drawn between
|
|
105
|
+
* every pair. A menu of four related actions wants none; a menu whose last row is
|
|
106
|
+
* "Supprimer" wants exactly one, above it.
|
|
107
|
+
*
|
|
108
|
+
* It runs the panel's full inner width rather than lining up with the rows' text: a
|
|
109
|
+
* separator inset to the titles reads as belonging to the row under it, and this one
|
|
110
|
+
* belongs to neither.
|
|
111
|
+
*/
|
|
112
|
+
separator: {
|
|
113
|
+
height: HAIRLINE,
|
|
114
|
+
backgroundColor: theme.colors.separator,
|
|
115
|
+
marginVertical: theme.spacing(1),
|
|
116
|
+
marginHorizontal: -theme.spacing(PANEL_PADDING_HORIZONTAL)
|
|
117
|
+
},
|
|
118
|
+
group: { flexDirection: "column" },
|
|
119
|
+
item: {
|
|
120
|
+
flexDirection: "row",
|
|
121
|
+
alignItems: "center",
|
|
122
|
+
gap: theme.spacing(ITEM_GAP),
|
|
123
|
+
paddingHorizontal: theme.spacing(ITEM_PADDING_HORIZONTAL),
|
|
124
|
+
paddingVertical: theme.spacing(ITEM_PADDING_VERTICAL),
|
|
125
|
+
borderRadius: theme.radius.lg,
|
|
126
|
+
borderCurve: "continuous"
|
|
127
|
+
},
|
|
128
|
+
itemTitle: {
|
|
129
|
+
fontFamily: theme.fontFamilies.body,
|
|
130
|
+
fontWeight: theme.fontWeights.medium,
|
|
131
|
+
fontSize: theme.fontSizes.md,
|
|
132
|
+
lineHeight: theme.lineHeights.md,
|
|
133
|
+
// Grows into the row so an indicator stays pinned to the end, whatever the label's
|
|
134
|
+
// length — but from its **content** size rather than from zero.
|
|
135
|
+
//
|
|
136
|
+
// `flex: 1` is `flexBasis: 0`, and the panel is measured before it has a width: with
|
|
137
|
+
// a basis of zero and no definite width to grow into, the row's content size is
|
|
138
|
+
// nothing and the title collapses. The whole menu measured as a 70-point capsule
|
|
139
|
+
// with no text in it. HeroUI writes `flex: 1` here and gets away with it because
|
|
140
|
+
// their measuring pass hands the panel a definite width; ours asks the panel how
|
|
141
|
+
// wide it wants to be, which is a question a zero basis cannot answer.
|
|
142
|
+
flexGrow: 1,
|
|
143
|
+
flexShrink: 1,
|
|
144
|
+
flexBasis: "auto"
|
|
145
|
+
},
|
|
146
|
+
itemDescription: {
|
|
147
|
+
fontFamily: theme.fontFamilies.body,
|
|
148
|
+
fontSize: theme.fontSizes.sm,
|
|
149
|
+
lineHeight: theme.lineHeights.sm,
|
|
150
|
+
color: theme.colors.muted
|
|
151
|
+
},
|
|
152
|
+
itemIndicator: {
|
|
153
|
+
width: theme.spacing(INDICATOR),
|
|
154
|
+
height: theme.spacing(INDICATOR),
|
|
155
|
+
alignItems: "center",
|
|
156
|
+
justifyContent: "center"
|
|
157
|
+
}
|
|
158
|
+
}),
|
|
159
|
+
variantTokens: VARIANT_TOKENS,
|
|
160
|
+
/** The variant paints the row's text and nothing else. The panel is the theme's. */
|
|
161
|
+
paint: (_theme, colors) => ({
|
|
162
|
+
itemTitle: { color: colors.fg },
|
|
163
|
+
itemIndicator: { color: colors.fg }
|
|
164
|
+
}),
|
|
165
|
+
variants: { radius: radiusAxis("content") },
|
|
166
|
+
states: {
|
|
167
|
+
pressed: (theme) => ({
|
|
168
|
+
item: { backgroundColor: theme.colors.defaultSoftPressed }
|
|
169
|
+
}),
|
|
170
|
+
disabled: (theme) => ({ trigger: { opacity: theme.opacity.disabled } })
|
|
171
|
+
},
|
|
172
|
+
defaultVariants: { variant: "default" }
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
// src/components/menu/menu.context.ts
|
|
176
|
+
var [MenuProvider, useMenu] = createSlotContext("Menu");
|
|
177
|
+
var [MenuItemProvider, useMenuItem] = createSlotContext("Menu.Item");
|
|
178
|
+
|
|
179
|
+
// src/components/menu/menu-content.tsx
|
|
180
|
+
import { jsx } from "react/jsx-runtime";
|
|
181
|
+
var DEFAULT_OFFSET = 6;
|
|
182
|
+
var DEFAULT_INSETS = {
|
|
183
|
+
top: 12,
|
|
184
|
+
bottom: 12,
|
|
185
|
+
start: 12,
|
|
186
|
+
end: 12
|
|
187
|
+
};
|
|
188
|
+
var MenuContent = forwardRef(function MenuContent2({
|
|
189
|
+
children,
|
|
190
|
+
placement = "bottom",
|
|
191
|
+
align = "center",
|
|
192
|
+
width = "content-fit",
|
|
193
|
+
offset = DEFAULT_OFFSET,
|
|
194
|
+
alignOffset = 0,
|
|
195
|
+
avoidCollisions = true,
|
|
196
|
+
insets,
|
|
197
|
+
style,
|
|
198
|
+
onLayout,
|
|
199
|
+
...props
|
|
200
|
+
}, ref) {
|
|
201
|
+
const context = useMenu();
|
|
202
|
+
const { contentStyle, isOpen, anchor } = context;
|
|
203
|
+
const [styleProps, rest] = useStyleProps(props);
|
|
204
|
+
const theme = useXAUITheme();
|
|
205
|
+
const { position, onContentLayout, measuringStyle } = useAnchoredPosition({
|
|
206
|
+
anchor,
|
|
207
|
+
isOpen,
|
|
208
|
+
placement,
|
|
209
|
+
align,
|
|
210
|
+
width,
|
|
211
|
+
offset,
|
|
212
|
+
alignOffset,
|
|
213
|
+
avoidCollisions,
|
|
214
|
+
insets: { ...DEFAULT_INSETS, ...insets },
|
|
215
|
+
maxWidth: menuMeasure(theme.fontSizes.md),
|
|
216
|
+
onLayout
|
|
217
|
+
});
|
|
218
|
+
if (!isOpen || anchor === null) return null;
|
|
219
|
+
return /* @__PURE__ */ jsx(Portal, { children: /* @__PURE__ */ jsx(MenuProvider, { value: context, children: /* @__PURE__ */ jsx(
|
|
220
|
+
Animated.View,
|
|
221
|
+
{
|
|
222
|
+
ref,
|
|
223
|
+
entering: position ? anchoredEntering(position.placement) : void 0,
|
|
224
|
+
exiting: position ? anchoredExiting(position.placement) : void 0,
|
|
225
|
+
onLayout: onContentLayout,
|
|
226
|
+
...rest,
|
|
227
|
+
style: [
|
|
228
|
+
contentStyle,
|
|
229
|
+
position === null ? measuringStyle : {
|
|
230
|
+
top: position.top,
|
|
231
|
+
start: position.start,
|
|
232
|
+
width: position.width,
|
|
233
|
+
maxHeight: position.maxHeight
|
|
234
|
+
},
|
|
235
|
+
styleProps,
|
|
236
|
+
style
|
|
237
|
+
],
|
|
238
|
+
children
|
|
239
|
+
},
|
|
240
|
+
position?.placement ?? "measuring"
|
|
241
|
+
) }) });
|
|
242
|
+
});
|
|
243
|
+
MenuContent.displayName = "XAUI.Menu.Content";
|
|
244
|
+
|
|
245
|
+
// src/components/menu/menu-group.tsx
|
|
246
|
+
import { forwardRef as forwardRef2 } from "react";
|
|
247
|
+
import { View } from "react-native";
|
|
248
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
249
|
+
var MenuGroup = forwardRef2(function MenuGroup2({ children, accessibilityRole = "menu", style, ...props }, ref) {
|
|
250
|
+
const { groupStyle } = useMenu();
|
|
251
|
+
const [styleProps, rest] = useStyleProps(props);
|
|
252
|
+
return /* @__PURE__ */ jsx2(
|
|
253
|
+
View,
|
|
254
|
+
{
|
|
255
|
+
ref,
|
|
256
|
+
accessibilityRole,
|
|
257
|
+
...rest,
|
|
258
|
+
style: [groupStyle, styleProps, style],
|
|
259
|
+
children
|
|
260
|
+
}
|
|
261
|
+
);
|
|
262
|
+
});
|
|
263
|
+
MenuGroup.displayName = "XAUI.Menu.Group";
|
|
264
|
+
|
|
265
|
+
// src/components/menu/menu-item.tsx
|
|
266
|
+
import { forwardRef as forwardRef3, useCallback, useMemo } from "react";
|
|
267
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
268
|
+
var MenuItem = forwardRef3(function MenuItem2({
|
|
269
|
+
variant = "default",
|
|
270
|
+
children,
|
|
271
|
+
isDisabled = false,
|
|
272
|
+
closesOnPress = true,
|
|
273
|
+
asChild = false,
|
|
274
|
+
accessibilityRole = "menuitem",
|
|
275
|
+
accessibilityState,
|
|
276
|
+
style,
|
|
277
|
+
onPress,
|
|
278
|
+
onPressIn,
|
|
279
|
+
onPressOut,
|
|
280
|
+
...props
|
|
281
|
+
}, ref) {
|
|
282
|
+
const { itemStyle, itemPressedStyle, glyph, close } = useMenu();
|
|
283
|
+
const [styleProps, rest] = useStyleProps(props);
|
|
284
|
+
const [isPressed, press] = usePressState({ onPressIn, onPressOut });
|
|
285
|
+
const handlePress = useCallback(
|
|
286
|
+
(event) => {
|
|
287
|
+
onPress?.(event);
|
|
288
|
+
if (closesOnPress) close();
|
|
289
|
+
},
|
|
290
|
+
[close, closesOnPress, onPress]
|
|
291
|
+
);
|
|
292
|
+
const context = useMemo(
|
|
293
|
+
() => ({ variant, isPressed, isDisabled }),
|
|
294
|
+
[variant, isPressed, isDisabled]
|
|
295
|
+
);
|
|
296
|
+
return /* @__PURE__ */ jsx3(MenuItemProvider, { value: context, children: /* @__PURE__ */ jsx3(IconContext.Provider, { value: glyph[variant], children: /* @__PURE__ */ jsx3(
|
|
297
|
+
PressableFeedback,
|
|
298
|
+
{
|
|
299
|
+
ref,
|
|
300
|
+
isPressed,
|
|
301
|
+
isDisabled,
|
|
302
|
+
asChild,
|
|
303
|
+
accessibilityRole,
|
|
304
|
+
accessibilityState: { disabled: isDisabled, ...accessibilityState },
|
|
305
|
+
...rest,
|
|
306
|
+
style: [
|
|
307
|
+
itemStyle,
|
|
308
|
+
isPressed && itemPressedStyle,
|
|
309
|
+
styleProps,
|
|
310
|
+
typeof style === "function" ? style({ pressed: isPressed }) : style
|
|
311
|
+
],
|
|
312
|
+
onPress: handlePress,
|
|
313
|
+
onPressIn: press.onPressIn,
|
|
314
|
+
onPressOut: press.onPressOut,
|
|
315
|
+
children: typeof children === "function" ? children(context) : children
|
|
316
|
+
}
|
|
317
|
+
) }) });
|
|
318
|
+
});
|
|
319
|
+
MenuItem.displayName = "XAUI.Menu.Item";
|
|
320
|
+
|
|
321
|
+
// src/components/menu/menu-item-description.tsx
|
|
322
|
+
import { forwardRef as forwardRef4 } from "react";
|
|
323
|
+
import { Text } from "react-native";
|
|
324
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
325
|
+
var MenuItemDescription = forwardRef4(
|
|
326
|
+
function MenuItemDescription2({ children, style, ...props }, ref) {
|
|
327
|
+
const { itemDescriptionStyle } = useMenu();
|
|
328
|
+
const [styleProps, rest] = useStyleProps(props);
|
|
329
|
+
return /* @__PURE__ */ jsx4(Text, { ref, ...rest, style: [itemDescriptionStyle, styleProps, style], children });
|
|
330
|
+
}
|
|
331
|
+
);
|
|
332
|
+
MenuItemDescription.displayName = "XAUI.Menu.ItemDescription";
|
|
333
|
+
|
|
334
|
+
// src/components/menu/menu-item-indicator.tsx
|
|
335
|
+
import { forwardRef as forwardRef5 } from "react";
|
|
336
|
+
import { View as View2 } from "react-native";
|
|
337
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
338
|
+
var MenuItemIndicator = forwardRef5(
|
|
339
|
+
function MenuItemIndicator2({ children, style, ...props }, ref) {
|
|
340
|
+
const { itemIndicatorStyle } = useMenu();
|
|
341
|
+
const [styleProps, rest] = useStyleProps(props);
|
|
342
|
+
return /* @__PURE__ */ jsx5(View2, { ref, ...rest, style: [itemIndicatorStyle, styleProps, style], children });
|
|
343
|
+
}
|
|
344
|
+
);
|
|
345
|
+
MenuItemIndicator.displayName = "XAUI.Menu.ItemIndicator";
|
|
346
|
+
|
|
347
|
+
// src/components/menu/menu-item-title.tsx
|
|
348
|
+
import { forwardRef as forwardRef6 } from "react";
|
|
349
|
+
import { Text as Text2 } from "react-native";
|
|
350
|
+
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
351
|
+
var MenuItemTitle = forwardRef6(
|
|
352
|
+
function MenuItemTitle2({ children, numberOfLines = 1, style, ...props }, ref) {
|
|
353
|
+
const { itemTitleStyle } = useMenu();
|
|
354
|
+
const { variant } = useMenuItem();
|
|
355
|
+
const [styleProps, rest] = useStyleProps(props);
|
|
356
|
+
return /* @__PURE__ */ jsx6(
|
|
357
|
+
Text2,
|
|
358
|
+
{
|
|
359
|
+
ref,
|
|
360
|
+
numberOfLines,
|
|
361
|
+
...rest,
|
|
362
|
+
style: [itemTitleStyle[variant], styleProps, style],
|
|
363
|
+
children
|
|
364
|
+
}
|
|
365
|
+
);
|
|
366
|
+
}
|
|
367
|
+
);
|
|
368
|
+
MenuItemTitle.displayName = "XAUI.Menu.ItemTitle";
|
|
369
|
+
|
|
370
|
+
// src/components/menu/menu-label.tsx
|
|
371
|
+
import { forwardRef as forwardRef7 } from "react";
|
|
372
|
+
import { Text as Text3 } from "react-native";
|
|
373
|
+
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
374
|
+
var MenuLabel = forwardRef7(function MenuLabel2({ children, accessibilityRole = "header", style, ...props }, ref) {
|
|
375
|
+
const { labelStyle } = useMenu();
|
|
376
|
+
const [styleProps, rest] = useStyleProps(props);
|
|
377
|
+
return /* @__PURE__ */ jsx7(
|
|
378
|
+
Text3,
|
|
379
|
+
{
|
|
380
|
+
ref,
|
|
381
|
+
accessibilityRole,
|
|
382
|
+
...rest,
|
|
383
|
+
style: [labelStyle, styleProps, style],
|
|
384
|
+
children
|
|
385
|
+
}
|
|
386
|
+
);
|
|
387
|
+
});
|
|
388
|
+
MenuLabel.displayName = "XAUI.Menu.Label";
|
|
389
|
+
|
|
390
|
+
// src/components/menu/menu-separator.tsx
|
|
391
|
+
import { forwardRef as forwardRef8 } from "react";
|
|
392
|
+
import { View as View3 } from "react-native";
|
|
393
|
+
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
394
|
+
var MenuSeparator = forwardRef8(
|
|
395
|
+
function MenuSeparator2({ style, ...props }, ref) {
|
|
396
|
+
const { separatorStyle } = useMenu();
|
|
397
|
+
const [styleProps, rest] = useStyleProps(props);
|
|
398
|
+
return /* @__PURE__ */ jsx8(
|
|
399
|
+
View3,
|
|
400
|
+
{
|
|
401
|
+
ref,
|
|
402
|
+
accessibilityElementsHidden: true,
|
|
403
|
+
importantForAccessibility: "no-hide-descendants",
|
|
404
|
+
...rest,
|
|
405
|
+
style: [separatorStyle, styleProps, style]
|
|
406
|
+
}
|
|
407
|
+
);
|
|
408
|
+
}
|
|
409
|
+
);
|
|
410
|
+
MenuSeparator.displayName = "XAUI.Menu.Separator";
|
|
411
|
+
|
|
412
|
+
// src/components/menu/menu-overlay.tsx
|
|
413
|
+
import { forwardRef as forwardRef9 } from "react";
|
|
414
|
+
import { Pressable } from "react-native";
|
|
415
|
+
import Animated2 from "react-native-reanimated";
|
|
416
|
+
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
417
|
+
var AnimatedPressable = Animated2.createAnimatedComponent(Pressable);
|
|
418
|
+
var MenuOverlay = forwardRef9(function MenuOverlay2({ children, isDismissable = true, style, ...props }, ref) {
|
|
419
|
+
const context = useMenu();
|
|
420
|
+
const { overlayStyle, isOpen, close } = context;
|
|
421
|
+
const [styleProps, rest] = useStyleProps(props);
|
|
422
|
+
if (!isOpen) return null;
|
|
423
|
+
return /* @__PURE__ */ jsx9(Portal, { children: /* @__PURE__ */ jsx9(MenuProvider, { value: context, children: /* @__PURE__ */ jsx9(
|
|
424
|
+
AnimatedPressable,
|
|
425
|
+
{
|
|
426
|
+
ref,
|
|
427
|
+
entering: overlayEntering,
|
|
428
|
+
exiting: overlayExiting,
|
|
429
|
+
accessibilityRole: "none",
|
|
430
|
+
importantForAccessibility: "no",
|
|
431
|
+
onPress: isDismissable ? close : void 0,
|
|
432
|
+
...rest,
|
|
433
|
+
style: [overlayStyle, styleProps, style],
|
|
434
|
+
children
|
|
435
|
+
}
|
|
436
|
+
) }) });
|
|
437
|
+
});
|
|
438
|
+
MenuOverlay.displayName = "XAUI.Menu.Overlay";
|
|
439
|
+
|
|
440
|
+
// src/components/menu/menu-trigger.tsx
|
|
441
|
+
import { forwardRef as forwardRef10, useCallback as useCallback2 } from "react";
|
|
442
|
+
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
443
|
+
var MenuTrigger = forwardRef10(function MenuTrigger2({
|
|
444
|
+
children,
|
|
445
|
+
asChild = false,
|
|
446
|
+
accessibilityRole = "button",
|
|
447
|
+
accessibilityState,
|
|
448
|
+
style,
|
|
449
|
+
onLayout,
|
|
450
|
+
onPress,
|
|
451
|
+
onPressIn,
|
|
452
|
+
onPressOut,
|
|
453
|
+
...props
|
|
454
|
+
}, ref) {
|
|
455
|
+
const { triggerStyle, isOpen, isDisabled, toggle, setAnchor } = useMenu();
|
|
456
|
+
const [styleProps, rest] = useStyleProps(props);
|
|
457
|
+
const [isPressed, press] = usePressState({ onPressIn, onPressOut });
|
|
458
|
+
const anchor = useAnchorRef({ isOpen, onAnchor: setAnchor, onLayout });
|
|
459
|
+
const refs = useMergedRef(anchor.node, ref);
|
|
460
|
+
const handlePress = useCallback2(
|
|
461
|
+
(event) => {
|
|
462
|
+
onPress?.(event);
|
|
463
|
+
anchor.measure();
|
|
464
|
+
toggle();
|
|
465
|
+
},
|
|
466
|
+
[anchor, onPress, toggle]
|
|
467
|
+
);
|
|
468
|
+
return /* @__PURE__ */ jsx10(
|
|
469
|
+
PressableFeedback,
|
|
470
|
+
{
|
|
471
|
+
ref: refs,
|
|
472
|
+
isPressed,
|
|
473
|
+
isDisabled,
|
|
474
|
+
asChild,
|
|
475
|
+
accessibilityRole,
|
|
476
|
+
accessibilityState: {
|
|
477
|
+
disabled: isDisabled,
|
|
478
|
+
expanded: isOpen,
|
|
479
|
+
...accessibilityState
|
|
480
|
+
},
|
|
481
|
+
...rest,
|
|
482
|
+
onLayout: anchor.onLayout,
|
|
483
|
+
style: [
|
|
484
|
+
triggerStyle,
|
|
485
|
+
styleProps,
|
|
486
|
+
typeof style === "function" ? style({ pressed: isPressed }) : style
|
|
487
|
+
],
|
|
488
|
+
onPress: handlePress,
|
|
489
|
+
onPressIn: press.onPressIn,
|
|
490
|
+
onPressOut: press.onPressOut,
|
|
491
|
+
children
|
|
492
|
+
}
|
|
493
|
+
);
|
|
494
|
+
});
|
|
495
|
+
MenuTrigger.displayName = "XAUI.Menu.Trigger";
|
|
496
|
+
|
|
497
|
+
// src/components/menu/menu.tsx
|
|
498
|
+
import { useCallback as useCallback3, useMemo as useMemo2, useState } from "react";
|
|
499
|
+
import { StyleSheet as StyleSheet2 } from "react-native";
|
|
500
|
+
import { jsx as jsx11 } from "react/jsx-runtime";
|
|
501
|
+
var VARIANTS = ["default", "danger"];
|
|
502
|
+
function Menu({
|
|
503
|
+
children,
|
|
504
|
+
radius,
|
|
505
|
+
isOpen: controlledOpen,
|
|
506
|
+
defaultOpen = false,
|
|
507
|
+
onOpenChange,
|
|
508
|
+
isDisabled = false
|
|
509
|
+
}) {
|
|
510
|
+
const theme = useXAUITheme();
|
|
511
|
+
const [anchor, setAnchor] = useState(null);
|
|
512
|
+
const [isOpen, setOpen] = useControllableState({
|
|
513
|
+
value: controlledOpen,
|
|
514
|
+
defaultValue: defaultOpen,
|
|
515
|
+
onChange: onOpenChange
|
|
516
|
+
});
|
|
517
|
+
const selection = { radius };
|
|
518
|
+
const styles = menuRecipe.resolve({
|
|
519
|
+
theme,
|
|
520
|
+
selection,
|
|
521
|
+
states: { disabled: isDisabled }
|
|
522
|
+
});
|
|
523
|
+
const pressed = menuRecipe.resolve({ theme, selection, states: { pressed: true } });
|
|
524
|
+
const open = useCallback3(() => setOpen(true), [setOpen]);
|
|
525
|
+
const close = useCallback3(() => setOpen(false), [setOpen]);
|
|
526
|
+
const toggle = useCallback3(() => setOpen((current) => !current), [setOpen]);
|
|
527
|
+
const context = useMemo2(() => {
|
|
528
|
+
const byVariant = (read) => Object.fromEntries(VARIANTS.map((v) => [v, read(v)]));
|
|
529
|
+
const title = byVariant(
|
|
530
|
+
(variant) => menuRecipe.resolve({ theme, selection: { ...selection, variant } }).itemTitle
|
|
531
|
+
);
|
|
532
|
+
return {
|
|
533
|
+
triggerStyle: styles.trigger,
|
|
534
|
+
overlayStyle: styles.overlay,
|
|
535
|
+
contentStyle: styles.content,
|
|
536
|
+
labelStyle: styles.label,
|
|
537
|
+
separatorStyle: styles.separator,
|
|
538
|
+
groupStyle: styles.group,
|
|
539
|
+
itemStyle: styles.item,
|
|
540
|
+
itemPressedStyle: pressed.item,
|
|
541
|
+
itemTitleStyle: title,
|
|
542
|
+
itemDescriptionStyle: styles.itemDescription,
|
|
543
|
+
itemIndicatorStyle: styles.itemIndicator,
|
|
544
|
+
glyph: byVariant((variant) => {
|
|
545
|
+
const flat = StyleSheet2.flatten([title[variant]]);
|
|
546
|
+
return {
|
|
547
|
+
size: flat.fontSize,
|
|
548
|
+
// `ColorValue` also covers the platform's opaque colours, which `Icon` cannot
|
|
549
|
+
// hand to a third-party component expecting a string.
|
|
550
|
+
color: typeof flat.color === "string" ? flat.color : void 0
|
|
551
|
+
};
|
|
552
|
+
}),
|
|
553
|
+
isOpen,
|
|
554
|
+
isDisabled,
|
|
555
|
+
open,
|
|
556
|
+
close,
|
|
557
|
+
toggle,
|
|
558
|
+
anchor,
|
|
559
|
+
setAnchor
|
|
560
|
+
};
|
|
561
|
+
}, [
|
|
562
|
+
styles,
|
|
563
|
+
pressed,
|
|
564
|
+
theme,
|
|
565
|
+
radius,
|
|
566
|
+
isOpen,
|
|
567
|
+
isDisabled,
|
|
568
|
+
open,
|
|
569
|
+
close,
|
|
570
|
+
toggle,
|
|
571
|
+
anchor
|
|
572
|
+
]);
|
|
573
|
+
return /* @__PURE__ */ jsx11(MenuProvider, { value: context, children });
|
|
574
|
+
}
|
|
575
|
+
Menu.displayName = "XAUI.Menu.Root";
|
|
576
|
+
|
|
577
|
+
// src/components/menu/index.ts
|
|
578
|
+
var Menu2 = Object.assign(Menu, {
|
|
579
|
+
Trigger: MenuTrigger,
|
|
580
|
+
Overlay: MenuOverlay,
|
|
581
|
+
Content: MenuContent,
|
|
582
|
+
Label: MenuLabel,
|
|
583
|
+
Separator: MenuSeparator,
|
|
584
|
+
Group: MenuGroup,
|
|
585
|
+
Item: MenuItem,
|
|
586
|
+
ItemTitle: MenuItemTitle,
|
|
587
|
+
ItemDescription: MenuItemDescription,
|
|
588
|
+
ItemIndicator: MenuItemIndicator
|
|
589
|
+
});
|
|
590
|
+
|
|
591
|
+
export {
|
|
592
|
+
menuRecipe,
|
|
593
|
+
useMenu,
|
|
594
|
+
useMenuItem,
|
|
595
|
+
MenuContent,
|
|
596
|
+
MenuGroup,
|
|
597
|
+
MenuItem,
|
|
598
|
+
MenuItemDescription,
|
|
599
|
+
MenuItemIndicator,
|
|
600
|
+
MenuItemTitle,
|
|
601
|
+
MenuLabel,
|
|
602
|
+
MenuSeparator,
|
|
603
|
+
MenuOverlay,
|
|
604
|
+
MenuTrigger,
|
|
605
|
+
Menu,
|
|
606
|
+
Menu2
|
|
607
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
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
2
|
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var _chunkJ3MB4PI5cjs = require('./chunk-J3MB4PI5.cjs');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
var _chunk4KFKWBN5cjs = require('./chunk-4KFKWBN5.cjs');
|
|
@@ -36,7 +36,7 @@ var FieldGroupField = _react.forwardRef.call(void 0,
|
|
|
36
36
|
() => decoratorPadding(prefixWidth, suffixWidth),
|
|
37
37
|
[prefixWidth, suffixWidth]
|
|
38
38
|
);
|
|
39
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
39
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkJ3MB4PI5cjs.TextFieldField, { ref, ...props, style: [padding, style] });
|
|
40
40
|
}
|
|
41
41
|
);
|
|
42
42
|
FieldGroupField.displayName = "XAUI.FieldGroup.Field";
|
|
@@ -44,7 +44,7 @@ FieldGroupField.displayName = "XAUI.FieldGroup.Field";
|
|
|
44
44
|
// src/components/field-group/field-group-icon.tsx
|
|
45
45
|
|
|
46
46
|
function FieldGroupIcon({ size, color, ...rest }) {
|
|
47
|
-
const { icon } =
|
|
47
|
+
const { icon } = _chunkJ3MB4PI5cjs.useTextField.call(void 0, );
|
|
48
48
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk4KFKWBN5cjs.Icon, { size: _nullishCoalesce(size, () => ( icon.size)), color: _nullishCoalesce(color, () => ( icon.color)), ...rest });
|
|
49
49
|
}
|
|
50
50
|
FieldGroupIcon.displayName = "XAUI.FieldGroup.Icon";
|
|
@@ -58,7 +58,7 @@ var _reactnative = require('react-native');
|
|
|
58
58
|
|
|
59
59
|
var FieldGroupDecorator = _react.forwardRef.call(void 0,
|
|
60
60
|
function FieldGroupDecorator2({ side, children, isDecorative = false, onLayout, style, ...props }, ref) {
|
|
61
|
-
const { prefixStyle, suffixStyle, isDisabled } =
|
|
61
|
+
const { prefixStyle, suffixStyle, isDisabled } = _chunkJ3MB4PI5cjs.useTextField.call(void 0, );
|
|
62
62
|
const { setPrefixWidth, setSuffixWidth } = useFieldGroup();
|
|
63
63
|
const [styleProps, rest] = _chunkTK44VBIEcjs.useStyleProps.call(void 0, props);
|
|
64
64
|
const report = side === "prefix" ? setPrefixWidth : setSuffixWidth;
|