@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,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
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// src/system/anchored/anchored-motion.ts
|
|
2
|
+
import { Easing, Keyframe } from "react-native-reanimated";
|
|
3
|
+
var ENTER_MS = 200;
|
|
4
|
+
var EXIT_MS = 150;
|
|
5
|
+
var TRAVEL = 8;
|
|
6
|
+
function anchoredEntering(placement) {
|
|
7
|
+
const [x, y] = travel(placement);
|
|
8
|
+
return new Keyframe({
|
|
9
|
+
0: {
|
|
10
|
+
opacity: 0,
|
|
11
|
+
transform: [{ translateX: x }, { translateY: y }, { scale: 0.95 }]
|
|
12
|
+
},
|
|
13
|
+
100: {
|
|
14
|
+
opacity: 1,
|
|
15
|
+
transform: [{ translateX: 0 }, { translateY: 0 }, { scale: 1 }],
|
|
16
|
+
easing: Easing.out(Easing.cubic)
|
|
17
|
+
}
|
|
18
|
+
}).duration(ENTER_MS);
|
|
19
|
+
}
|
|
20
|
+
function anchoredExiting(placement) {
|
|
21
|
+
const [x, y] = travel(placement);
|
|
22
|
+
return new Keyframe({
|
|
23
|
+
0: {
|
|
24
|
+
opacity: 1,
|
|
25
|
+
transform: [{ translateX: 0 }, { translateY: 0 }, { scale: 1 }]
|
|
26
|
+
},
|
|
27
|
+
100: {
|
|
28
|
+
opacity: 0,
|
|
29
|
+
transform: [{ translateX: x }, { translateY: y }, { scale: 0.95 }],
|
|
30
|
+
easing: Easing.in(Easing.cubic)
|
|
31
|
+
}
|
|
32
|
+
}).duration(EXIT_MS);
|
|
33
|
+
}
|
|
34
|
+
function travel(placement) {
|
|
35
|
+
switch (placement) {
|
|
36
|
+
case "bottom":
|
|
37
|
+
return [0, -TRAVEL];
|
|
38
|
+
case "top":
|
|
39
|
+
return [0, TRAVEL];
|
|
40
|
+
case "end":
|
|
41
|
+
return [-TRAVEL, 0];
|
|
42
|
+
case "start":
|
|
43
|
+
return [TRAVEL, 0];
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
var overlayEntering = new Keyframe({
|
|
47
|
+
0: { opacity: 0 },
|
|
48
|
+
100: { opacity: 1 }
|
|
49
|
+
}).duration(ENTER_MS);
|
|
50
|
+
var overlayExiting = new Keyframe({
|
|
51
|
+
0: { opacity: 1 },
|
|
52
|
+
100: { opacity: 0 }
|
|
53
|
+
}).duration(EXIT_MS);
|
|
54
|
+
|
|
55
|
+
// src/system/anchored/indicator-spring.ts
|
|
56
|
+
var INDICATOR_SPRING = { damping: 140, stiffness: 1e3, mass: 4 };
|
|
57
|
+
var INDICATOR_ROTATION = [0, -180];
|
|
58
|
+
|
|
59
|
+
export {
|
|
60
|
+
anchoredEntering,
|
|
61
|
+
anchoredExiting,
|
|
62
|
+
overlayEntering,
|
|
63
|
+
overlayExiting,
|
|
64
|
+
INDICATOR_SPRING,
|
|
65
|
+
INDICATOR_ROTATION
|
|
66
|
+
};
|