@xaui/native 0.0.27 → 0.0.29
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/LICENSE +21 -0
- package/README.md +105 -228
- package/dist/alert/index.cjs +92 -166
- package/dist/alert/index.js +2 -1
- package/dist/app-bar/index.cjs +24 -98
- package/dist/app-bar/index.js +2 -1
- package/dist/autocomplete/index.cjs +192 -281
- package/dist/autocomplete/index.js +36 -48
- package/dist/avatar/index.cjs +59 -133
- package/dist/avatar/index.js +2 -1
- package/dist/badge/index.cjs +26 -99
- package/dist/badge/index.js +2 -1
- package/dist/bottom-sheet/index.cjs +5 -456
- package/dist/bottom-sheet/index.js +4 -363
- package/dist/bottom-tab-bar/index.cjs +93 -167
- package/dist/bottom-tab-bar/index.js +2 -2
- package/dist/button/index.cjs +73 -525
- package/dist/button/index.js +3 -2
- package/dist/card/index.cjs +76 -169
- package/dist/card/index.js +2 -2
- package/dist/carousel/index.cjs +68 -145
- package/dist/carousel/index.js +1 -1
- package/dist/chart/index.cjs +132 -173
- package/dist/checkbox/index.cjs +70 -143
- package/dist/checkbox/index.js +2 -1
- package/dist/chip/index.cjs +89 -164
- package/dist/chip/index.js +2 -1
- package/dist/chunk-BD72HIPR.cjs +75 -0
- package/dist/chunk-DHSTKO3K.cjs +19 -0
- package/dist/{chunk-CZFDZPAS.js → chunk-DXXNBF5P.js} +5 -0
- package/dist/{chunk-UI5L26KD.js → chunk-F7WH4DMG.js} +1 -1
- package/dist/chunk-GBHQCAKW.js +19 -0
- package/dist/chunk-HC2SSHNU.js +368 -0
- package/dist/chunk-HSPTLUFA.cjs +7 -0
- package/dist/chunk-JEGEPGVU.js +287 -0
- package/dist/chunk-KTLGDLCB.cjs +287 -0
- package/dist/{chunk-GHCVNQET.js → chunk-LTKYHG5V.js} +5 -12
- package/dist/{chunk-ULJSCNPE.js → chunk-LUBWRVI2.js} +1 -1
- package/dist/chunk-OQ2BLOOG.cjs +138 -0
- package/dist/chunk-QMYWIWSX.cjs +384 -0
- package/dist/chunk-XFPPR2VB.cjs +368 -0
- package/dist/core/index.cjs +22 -168
- package/dist/core/index.d.cts +1 -1
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.js +5 -3
- package/dist/datepicker/index.cjs +239 -320
- package/dist/datepicker/index.js +2 -1
- package/dist/divider/index.cjs +5 -145
- package/dist/divider/index.js +3 -2
- package/dist/drawer/index.cjs +39 -112
- package/dist/drawer/index.js +2 -1
- package/dist/expansion-panel/index.cjs +91 -230
- package/dist/expansion-panel/index.js +3 -2
- package/dist/fab/index.cjs +6 -722
- package/dist/fab/index.js +4 -3
- package/dist/fab-menu/index.cjs +81 -814
- package/dist/fab-menu/index.js +4 -3
- package/dist/feature-discovery/index.cjs +72 -139
- package/dist/feature-discovery/index.js +2 -2
- package/dist/index.cjs +1 -18
- package/dist/indicator/index.cjs +5 -445
- package/dist/indicator/index.js +3 -2
- package/dist/input/index.cjs +214 -282
- package/dist/input/index.js +2 -2
- package/dist/list/index.cjs +71 -146
- package/dist/list/index.js +2 -1
- package/dist/menu/index.cjs +71 -127
- package/dist/menu/index.d.cts +8 -0
- package/dist/menu/index.d.ts +8 -0
- package/dist/menu/index.js +15 -3
- package/dist/menubox/index.cjs +60 -132
- package/dist/menubox/index.js +2 -1
- package/dist/pager/index.cjs +42 -80
- package/dist/progress/index.cjs +43 -114
- package/dist/progress/index.js +2 -1
- package/dist/radio/index.cjs +82 -154
- package/dist/radio/index.js +2 -1
- package/dist/segment-button/index.cjs +60 -147
- package/dist/segment-button/index.js +2 -2
- package/dist/select/index.cjs +149 -224
- package/dist/select/index.js +10 -22
- package/dist/skeleton/index.cjs +23 -94
- package/dist/skeleton/index.js +2 -2
- package/dist/slider/index.cjs +77 -156
- package/dist/slider/index.js +2 -1
- package/dist/snackbar/index.cjs +420 -0
- package/dist/snackbar/index.d.cts +175 -0
- package/dist/snackbar/index.d.ts +175 -0
- package/dist/snackbar/index.js +420 -0
- package/dist/stepper/index.cjs +121 -195
- package/dist/stepper/index.js +2 -1
- package/dist/switch/index.cjs +48 -121
- package/dist/switch/index.js +2 -1
- package/dist/tabs/index.cjs +67 -151
- package/dist/tabs/index.js +2 -1
- package/dist/timepicker/index.cjs +135 -593
- package/dist/timepicker/index.js +24 -383
- package/dist/toolbar/index.cjs +59 -128
- package/dist/toolbar/index.js +2 -1
- package/dist/typography/index.cjs +37 -92
- package/dist/typography/index.d.cts +1 -1
- package/dist/typography/index.d.ts +1 -1
- package/dist/typography/index.js +20 -1
- package/dist/view/index.cjs +178 -223
- package/package.json +6 -1
- package/dist/chunk-3XSXTM3G.js +0 -661
- package/dist/chunk-4KSZLONZ.js +0 -79
- package/dist/chunk-I4V5Y5GD.js +0 -76
- package/dist/chunk-URBEEDFX.js +0 -79
package/dist/menu/index.cjs
CHANGED
|
@@ -1,93 +1,22 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
|
|
30
|
-
// src/components/menu/index.ts
|
|
31
|
-
var menu_exports = {};
|
|
32
|
-
__export(menu_exports, {
|
|
33
|
-
Menu: () => Menu,
|
|
34
|
-
MenuItem: () => MenuItem
|
|
35
|
-
});
|
|
36
|
-
module.exports = __toCommonJS(menu_exports);
|
|
37
|
-
|
|
38
|
-
// src/components/menu/menu.tsx
|
|
39
|
-
var import_react7 = __toESM(require("react"), 1);
|
|
40
|
-
var import_react_native6 = require("react-native");
|
|
41
|
-
|
|
42
|
-
// src/core/theme-context.tsx
|
|
43
|
-
var import_react4 = __toESM(require("react"), 1);
|
|
44
|
-
var import_react_native2 = require("react-native");
|
|
45
|
-
var import_theme = require("@xaui/core/theme");
|
|
46
|
-
var import_palette = require("@xaui/core/palette");
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 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; }require('../chunk-HSPTLUFA.cjs');
|
|
47
2
|
|
|
48
|
-
// src/core/portal/portal.tsx
|
|
49
|
-
var import_react2 = require("react");
|
|
50
3
|
|
|
51
|
-
|
|
52
|
-
var import_react = require("react");
|
|
53
|
-
var PortalContext = (0, import_react.createContext)(null);
|
|
4
|
+
var _chunkOQ2BLOOGcjs = require('../chunk-OQ2BLOOG.cjs');
|
|
54
5
|
|
|
55
|
-
// src/
|
|
56
|
-
var
|
|
57
|
-
var
|
|
58
|
-
var hostStyles = import_react_native.StyleSheet.create({
|
|
59
|
-
container: {
|
|
60
|
-
flex: 1
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
// src/core/theme-context.tsx
|
|
65
|
-
var XUIThemeContext = (0, import_react4.createContext)(null);
|
|
66
|
-
|
|
67
|
-
// src/core/theme-hooks.ts
|
|
68
|
-
var import_react5 = require("react");
|
|
69
|
-
var import_react_native3 = require("react-native");
|
|
70
|
-
function useXUITheme() {
|
|
71
|
-
const theme = (0, import_react5.useContext)(XUIThemeContext);
|
|
72
|
-
if (!theme) {
|
|
73
|
-
throw new Error("useXUITheme must be used within XUIProvider");
|
|
74
|
-
}
|
|
75
|
-
return theme;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// src/core/index.ts
|
|
79
|
-
var import_theme2 = require("@xaui/core/theme");
|
|
6
|
+
// src/components/menu/menu.tsx
|
|
7
|
+
var _react = require('react'); var _react2 = _interopRequireDefault(_react);
|
|
8
|
+
var _reactnative = require('react-native');
|
|
80
9
|
|
|
81
10
|
// src/components/menu/menu.style.ts
|
|
82
|
-
|
|
11
|
+
|
|
83
12
|
var SCREEN_INDENT = 8;
|
|
84
13
|
var MENU_GAP = 4;
|
|
85
|
-
var styles =
|
|
14
|
+
var styles = _reactnative.StyleSheet.create({
|
|
86
15
|
wrapper: {
|
|
87
16
|
position: "absolute"
|
|
88
17
|
},
|
|
89
18
|
overlay: {
|
|
90
|
-
...
|
|
19
|
+
..._reactnative.StyleSheet.absoluteFillObject
|
|
91
20
|
},
|
|
92
21
|
menuContainer: {
|
|
93
22
|
position: "absolute",
|
|
@@ -100,20 +29,24 @@ var MENU_SCREEN_INDENT = SCREEN_INDENT;
|
|
|
100
29
|
var MENU_TRIGGER_GAP = MENU_GAP;
|
|
101
30
|
|
|
102
31
|
// src/components/menu/menu.hook.ts
|
|
103
|
-
|
|
104
|
-
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
105
38
|
var useMenuTriggerMeasurements = (visible) => {
|
|
106
|
-
const triggerRef = (0,
|
|
107
|
-
const [triggerPosition, setTriggerPosition] = (0,
|
|
39
|
+
const triggerRef = _react.useRef.call(void 0, null);
|
|
40
|
+
const [triggerPosition, setTriggerPosition] = _react.useState.call(void 0,
|
|
108
41
|
null
|
|
109
42
|
);
|
|
110
|
-
(0,
|
|
43
|
+
_react.useEffect.call(void 0, () => {
|
|
111
44
|
if (!visible) {
|
|
112
45
|
setTriggerPosition(null);
|
|
113
46
|
return;
|
|
114
47
|
}
|
|
115
48
|
const measureTrigger = (attempt) => {
|
|
116
|
-
triggerRef.current
|
|
49
|
+
_optionalChain([triggerRef, 'access', _2 => _2.current, 'optionalAccess', _3 => _3.measure, 'call', _4 => _4((_, __, width, height, pageX, pageY) => {
|
|
117
50
|
if ((width <= 0 || height <= 0) && attempt < 5) {
|
|
118
51
|
globalThis.requestAnimationFrame(() => measureTrigger(attempt + 1));
|
|
119
52
|
return;
|
|
@@ -124,7 +57,7 @@ var useMenuTriggerMeasurements = (visible) => {
|
|
|
124
57
|
width: Math.max(0, width),
|
|
125
58
|
height: Math.max(0, height)
|
|
126
59
|
});
|
|
127
|
-
});
|
|
60
|
+
})]);
|
|
128
61
|
};
|
|
129
62
|
const frameId = globalThis.setTimeout(() => measureTrigger(0), 0);
|
|
130
63
|
return () => globalThis.clearTimeout(frameId);
|
|
@@ -132,14 +65,14 @@ var useMenuTriggerMeasurements = (visible) => {
|
|
|
132
65
|
return { triggerRef, triggerPosition };
|
|
133
66
|
};
|
|
134
67
|
var useMenuContentLayout = (visible) => {
|
|
135
|
-
const [contentSize, setContentSize] = (0,
|
|
136
|
-
const [isMeasured, setIsMeasured] = (0,
|
|
137
|
-
(0,
|
|
68
|
+
const [contentSize, setContentSize] = _react.useState.call(void 0, { width: 0, height: 0 });
|
|
69
|
+
const [isMeasured, setIsMeasured] = _react.useState.call(void 0, false);
|
|
70
|
+
_react.useEffect.call(void 0, () => {
|
|
138
71
|
if (!visible) {
|
|
139
72
|
setIsMeasured(false);
|
|
140
73
|
}
|
|
141
74
|
}, [visible]);
|
|
142
|
-
const handleContentLayout = (0,
|
|
75
|
+
const handleContentLayout = _react.useCallback.call(void 0, (event) => {
|
|
143
76
|
const { width, height } = event.nativeEvent.layout;
|
|
144
77
|
if (width > 0 && height > 0) {
|
|
145
78
|
setContentSize({ width, height });
|
|
@@ -149,10 +82,10 @@ var useMenuContentLayout = (visible) => {
|
|
|
149
82
|
return { contentSize, handleContentLayout, isMeasured };
|
|
150
83
|
};
|
|
151
84
|
var useMenuPosition = (triggerPosition, contentSize, position) => {
|
|
152
|
-
return (0,
|
|
85
|
+
return _react.useMemo.call(void 0, () => {
|
|
153
86
|
if (!triggerPosition) return { top: 0, left: 0 };
|
|
154
|
-
const screenWidth =
|
|
155
|
-
const screenHeight =
|
|
87
|
+
const screenWidth = _reactnative.Dimensions.get("window").width;
|
|
88
|
+
const screenHeight = _reactnative.Dimensions.get("window").height;
|
|
156
89
|
let top;
|
|
157
90
|
let left = triggerPosition.x;
|
|
158
91
|
const hasEnoughSpaceBelow = triggerPosition.y + triggerPosition.height + contentSize.height <= screenHeight - MENU_SCREEN_INDENT;
|
|
@@ -192,20 +125,20 @@ var useMenuPosition = (triggerPosition, contentSize, position) => {
|
|
|
192
125
|
}, [triggerPosition, contentSize, position]);
|
|
193
126
|
};
|
|
194
127
|
var useMenuAnimation = (visible) => {
|
|
195
|
-
const opacity = (0,
|
|
196
|
-
const scale = (0,
|
|
197
|
-
(0,
|
|
128
|
+
const opacity = _react.useRef.call(void 0, new _reactnative.Animated.Value(0)).current;
|
|
129
|
+
const scale = _react.useRef.call(void 0, new _reactnative.Animated.Value(0)).current;
|
|
130
|
+
_react.useEffect.call(void 0, () => {
|
|
198
131
|
if (!visible) return;
|
|
199
132
|
opacity.setValue(0);
|
|
200
133
|
scale.setValue(0);
|
|
201
|
-
|
|
202
|
-
|
|
134
|
+
_reactnative.Animated.parallel([
|
|
135
|
+
_reactnative.Animated.timing(opacity, {
|
|
203
136
|
toValue: 1,
|
|
204
137
|
duration: 200,
|
|
205
|
-
easing:
|
|
138
|
+
easing: _reactnative.Easing.bezier(0.4, 0, 0.2, 1),
|
|
206
139
|
useNativeDriver: true
|
|
207
140
|
}),
|
|
208
|
-
|
|
141
|
+
_reactnative.Animated.spring(scale, {
|
|
209
142
|
toValue: 1,
|
|
210
143
|
friction: 9,
|
|
211
144
|
tension: 100,
|
|
@@ -222,33 +155,45 @@ var Menu = ({
|
|
|
222
155
|
trigger,
|
|
223
156
|
position = "bottom",
|
|
224
157
|
onDismiss,
|
|
158
|
+
onItemPress,
|
|
225
159
|
children,
|
|
226
160
|
customAppearance,
|
|
227
161
|
maxHeight = 280
|
|
228
162
|
}) => {
|
|
229
|
-
const theme = useXUITheme();
|
|
163
|
+
const theme = _chunkOQ2BLOOGcjs.useXUITheme.call(void 0, );
|
|
230
164
|
const { triggerRef, triggerPosition } = useMenuTriggerMeasurements(visible);
|
|
231
165
|
const { contentSize, handleContentLayout, isMeasured } = useMenuContentLayout(visible);
|
|
232
166
|
const menuPosition = useMenuPosition(triggerPosition, contentSize, position);
|
|
233
167
|
const { opacity, scale } = useMenuAnimation(visible);
|
|
234
|
-
|
|
235
|
-
|
|
168
|
+
const handledChildren = _react2.default.Children.map(children, (child) => {
|
|
169
|
+
if (!_react2.default.isValidElement(child)) return child;
|
|
170
|
+
const { onPress, itemKey } = child.props;
|
|
171
|
+
if (!onPress && !itemKey) return child;
|
|
172
|
+
return _react2.default.cloneElement(child, {
|
|
173
|
+
onPress: (e) => {
|
|
174
|
+
_optionalChain([onPress, 'optionalCall', _5 => _5(e)]);
|
|
175
|
+
if (itemKey) _optionalChain([onItemPress, 'optionalCall', _6 => _6(itemKey)]);
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
});
|
|
179
|
+
return /* @__PURE__ */ _react2.default.createElement(_react2.default.Fragment, null, /* @__PURE__ */ _react2.default.createElement(_reactnative.View, { ref: triggerRef, collapsable: false }, trigger), /* @__PURE__ */ _react2.default.createElement(
|
|
180
|
+
_reactnative.Modal,
|
|
236
181
|
{
|
|
237
182
|
visible,
|
|
238
183
|
transparent: true,
|
|
239
184
|
animationType: "fade",
|
|
240
185
|
onRequestClose: onDismiss
|
|
241
186
|
},
|
|
242
|
-
/* @__PURE__ */
|
|
243
|
-
|
|
187
|
+
/* @__PURE__ */ _react2.default.createElement(
|
|
188
|
+
_reactnative.Pressable,
|
|
244
189
|
{
|
|
245
|
-
style: [styles.overlay, customAppearance
|
|
190
|
+
style: [styles.overlay, _optionalChain([customAppearance, 'optionalAccess', _7 => _7.overlay])],
|
|
246
191
|
onPress: onDismiss,
|
|
247
192
|
accessibilityRole: "button",
|
|
248
193
|
accessibilityLabel: "Close menu"
|
|
249
194
|
},
|
|
250
|
-
/* @__PURE__ */
|
|
251
|
-
|
|
195
|
+
/* @__PURE__ */ _react2.default.createElement(
|
|
196
|
+
_reactnative.Animated.View,
|
|
252
197
|
{
|
|
253
198
|
onLayout: handleContentLayout,
|
|
254
199
|
style: [
|
|
@@ -262,24 +207,24 @@ var Menu = ({
|
|
|
262
207
|
transform: [{ scale }],
|
|
263
208
|
...theme.shadows.md
|
|
264
209
|
},
|
|
265
|
-
customAppearance
|
|
210
|
+
_optionalChain([customAppearance, 'optionalAccess', _8 => _8.container])
|
|
266
211
|
]
|
|
267
212
|
},
|
|
268
|
-
/* @__PURE__ */
|
|
213
|
+
/* @__PURE__ */ _react2.default.createElement(_reactnative.Pressable, { onPress: (e) => e.stopPropagation() }, /* @__PURE__ */ _react2.default.createElement(_reactnative.View, { style: _optionalChain([customAppearance, 'optionalAccess', _9 => _9.content]) }, /* @__PURE__ */ _react2.default.createElement(_reactnative.ScrollView, { style: { maxHeight } }, handledChildren)))
|
|
269
214
|
)
|
|
270
215
|
)
|
|
271
216
|
));
|
|
272
217
|
};
|
|
273
218
|
|
|
274
219
|
// src/components/menu/menu-item.tsx
|
|
275
|
-
|
|
276
|
-
|
|
220
|
+
|
|
221
|
+
|
|
277
222
|
|
|
278
223
|
// src/components/menu/menu-item.style.ts
|
|
279
|
-
|
|
224
|
+
|
|
280
225
|
var MIN_WIDTH = 112;
|
|
281
226
|
var MAX_WIDTH = 280;
|
|
282
|
-
var styles2 =
|
|
227
|
+
var styles2 = _reactnative.StyleSheet.create({
|
|
283
228
|
container: {
|
|
284
229
|
minWidth: MIN_WIDTH,
|
|
285
230
|
maxWidth: MAX_WIDTH,
|
|
@@ -329,14 +274,14 @@ var MenuItem = ({
|
|
|
329
274
|
customAppearance,
|
|
330
275
|
accessibilityLabel
|
|
331
276
|
}) => {
|
|
332
|
-
const theme = useXUITheme();
|
|
277
|
+
const theme = _chunkOQ2BLOOGcjs.useXUITheme.call(void 0, );
|
|
333
278
|
const titleColor = isDisabled ? theme.colors.foreground + "50" : theme.colors.foreground;
|
|
334
279
|
const renderTitle = () => {
|
|
335
280
|
if (typeof title === "string" || typeof title === "number") {
|
|
336
|
-
return /* @__PURE__ */
|
|
337
|
-
|
|
281
|
+
return /* @__PURE__ */ _react2.default.createElement(
|
|
282
|
+
_reactnative.Text,
|
|
338
283
|
{
|
|
339
|
-
style: [styles2.titleText, { color: titleColor }, customAppearance
|
|
284
|
+
style: [styles2.titleText, { color: titleColor }, _optionalChain([customAppearance, 'optionalAccess', _10 => _10.title])],
|
|
340
285
|
numberOfLines: 1
|
|
341
286
|
},
|
|
342
287
|
title
|
|
@@ -344,8 +289,8 @@ var MenuItem = ({
|
|
|
344
289
|
}
|
|
345
290
|
return title;
|
|
346
291
|
};
|
|
347
|
-
return /* @__PURE__ */
|
|
348
|
-
|
|
292
|
+
return /* @__PURE__ */ _react2.default.createElement(
|
|
293
|
+
_reactnative.Pressable,
|
|
349
294
|
{
|
|
350
295
|
onPress: isDisabled ? void 0 : onPress,
|
|
351
296
|
disabled: isDisabled,
|
|
@@ -359,14 +304,13 @@ var MenuItem = ({
|
|
|
359
304
|
pressed && !isDisabled && {
|
|
360
305
|
backgroundColor: theme.colors.foreground + "10"
|
|
361
306
|
},
|
|
362
|
-
customAppearance
|
|
307
|
+
_optionalChain([customAppearance, 'optionalAccess', _11 => _11.container])
|
|
363
308
|
]
|
|
364
309
|
},
|
|
365
|
-
/* @__PURE__ */
|
|
310
|
+
/* @__PURE__ */ _react2.default.createElement(_reactnative.View, { style: [styles2.row, _optionalChain([customAppearance, 'optionalAccess', _12 => _12.content])] }, startContent && /* @__PURE__ */ _react2.default.createElement(_reactnative.View, { style: styles2.startContent }, startContent), /* @__PURE__ */ _react2.default.createElement(_reactnative.View, { style: styles2.content }, renderTitle()), endContent && /* @__PURE__ */ _react2.default.createElement(_reactnative.View, { style: styles2.endContent }, endContent))
|
|
366
311
|
);
|
|
367
312
|
};
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
});
|
|
313
|
+
|
|
314
|
+
|
|
315
|
+
|
|
316
|
+
exports.Menu = Menu; exports.MenuItem = MenuItem;
|
package/dist/menu/index.d.cts
CHANGED
|
@@ -34,6 +34,10 @@ type MenuProps = {
|
|
|
34
34
|
* Callback called when Menu is dismissed. The `visible` prop needs to be updated when this is called.
|
|
35
35
|
*/
|
|
36
36
|
onDismiss?: () => void;
|
|
37
|
+
/**
|
|
38
|
+
* Callback fired when a MenuItem with an `itemKey` is pressed.
|
|
39
|
+
*/
|
|
40
|
+
onItemPress?: (itemKey: string) => void;
|
|
37
41
|
/**
|
|
38
42
|
* Content of the Menu.
|
|
39
43
|
*/
|
|
@@ -66,6 +70,10 @@ type MenuItemCustomAppearance = {
|
|
|
66
70
|
title?: TextStyle;
|
|
67
71
|
};
|
|
68
72
|
type MenuItemProps = {
|
|
73
|
+
/**
|
|
74
|
+
* Optional key emitted via Menu `onItemPress`.
|
|
75
|
+
*/
|
|
76
|
+
itemKey?: string;
|
|
69
77
|
/**
|
|
70
78
|
* Title text for the MenuItem.
|
|
71
79
|
*/
|
package/dist/menu/index.d.ts
CHANGED
|
@@ -34,6 +34,10 @@ type MenuProps = {
|
|
|
34
34
|
* Callback called when Menu is dismissed. The `visible` prop needs to be updated when this is called.
|
|
35
35
|
*/
|
|
36
36
|
onDismiss?: () => void;
|
|
37
|
+
/**
|
|
38
|
+
* Callback fired when a MenuItem with an `itemKey` is pressed.
|
|
39
|
+
*/
|
|
40
|
+
onItemPress?: (itemKey: string) => void;
|
|
37
41
|
/**
|
|
38
42
|
* Content of the Menu.
|
|
39
43
|
*/
|
|
@@ -66,6 +70,10 @@ type MenuItemCustomAppearance = {
|
|
|
66
70
|
title?: TextStyle;
|
|
67
71
|
};
|
|
68
72
|
type MenuItemProps = {
|
|
73
|
+
/**
|
|
74
|
+
* Optional key emitted via Menu `onItemPress`.
|
|
75
|
+
*/
|
|
76
|
+
itemKey?: string;
|
|
69
77
|
/**
|
|
70
78
|
* Title text for the MenuItem.
|
|
71
79
|
*/
|
package/dist/menu/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import "../chunk-
|
|
1
|
+
import "../chunk-DXXNBF5P.js";
|
|
2
2
|
import {
|
|
3
3
|
useXUITheme
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-LTKYHG5V.js";
|
|
5
5
|
|
|
6
6
|
// src/components/menu/menu.tsx
|
|
7
7
|
import React from "react";
|
|
@@ -155,6 +155,7 @@ var Menu = ({
|
|
|
155
155
|
trigger,
|
|
156
156
|
position = "bottom",
|
|
157
157
|
onDismiss,
|
|
158
|
+
onItemPress,
|
|
158
159
|
children,
|
|
159
160
|
customAppearance,
|
|
160
161
|
maxHeight = 280
|
|
@@ -164,6 +165,17 @@ var Menu = ({
|
|
|
164
165
|
const { contentSize, handleContentLayout, isMeasured } = useMenuContentLayout(visible);
|
|
165
166
|
const menuPosition = useMenuPosition(triggerPosition, contentSize, position);
|
|
166
167
|
const { opacity, scale } = useMenuAnimation(visible);
|
|
168
|
+
const handledChildren = React.Children.map(children, (child) => {
|
|
169
|
+
if (!React.isValidElement(child)) return child;
|
|
170
|
+
const { onPress, itemKey } = child.props;
|
|
171
|
+
if (!onPress && !itemKey) return child;
|
|
172
|
+
return React.cloneElement(child, {
|
|
173
|
+
onPress: (e) => {
|
|
174
|
+
onPress?.(e);
|
|
175
|
+
if (itemKey) onItemPress?.(itemKey);
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
});
|
|
167
179
|
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(View, { ref: triggerRef, collapsable: false }, trigger), /* @__PURE__ */ React.createElement(
|
|
168
180
|
Modal,
|
|
169
181
|
{
|
|
@@ -198,7 +210,7 @@ var Menu = ({
|
|
|
198
210
|
customAppearance?.container
|
|
199
211
|
]
|
|
200
212
|
},
|
|
201
|
-
/* @__PURE__ */ React.createElement(Pressable, { onPress: (e) => e.stopPropagation() }, /* @__PURE__ */ React.createElement(View, { style: customAppearance?.content }, /* @__PURE__ */ React.createElement(ScrollView, { style: { maxHeight } },
|
|
213
|
+
/* @__PURE__ */ React.createElement(Pressable, { onPress: (e) => e.stopPropagation() }, /* @__PURE__ */ React.createElement(View, { style: customAppearance?.content }, /* @__PURE__ */ React.createElement(ScrollView, { style: { maxHeight } }, handledChildren)))
|
|
202
214
|
)
|
|
203
215
|
)
|
|
204
216
|
));
|