@xaui/native 0.0.12 → 0.0.13
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/README.md +8 -1
- package/dist/accordion/index.cjs +7 -2
- package/dist/accordion/index.js +7 -2
- package/dist/alert/index.cjs +25 -188
- package/dist/alert/index.js +1 -2
- package/dist/autocomplete/index.cjs +106 -403
- package/dist/autocomplete/index.js +1 -3
- package/dist/button/index.cjs +126 -4
- package/dist/button/index.d.cts +63 -1
- package/dist/button/index.d.ts +63 -1
- package/dist/button/index.js +117 -3
- package/dist/checkbox/index.cjs +5 -1
- package/dist/checkbox/index.js +5 -1
- package/dist/{chunk-OFYJYQ2M.js → chunk-2T6FKPJW.js} +1 -3
- package/dist/{chunk-LM23DOX3.js → chunk-7OFTYKK4.js} +13 -33
- package/dist/{chunk-63LRW4QD.js → chunk-MKHBEJLO.js} +8 -1
- package/dist/{chunk-RL47NQAU.js → chunk-NMZUPH3R.js} +7 -12
- package/dist/datepicker/index.cjs +115 -836
- package/dist/datepicker/index.js +1 -3
- package/dist/index.cjs +362 -1170
- package/dist/index.js +4 -6
- package/dist/indicator/index.cjs +8 -1
- package/dist/indicator/index.js +1 -1
- package/dist/menu/index.cjs +371 -0
- package/dist/menu/index.d.cts +107 -0
- package/dist/menu/index.d.ts +107 -0
- package/dist/menu/index.js +304 -0
- package/dist/select/index.cjs +40 -16
- package/dist/select/index.js +40 -16
- package/dist/view/index.cjs +12 -7
- package/dist/view/index.js +12 -7
- package/package.json +7 -6
- package/dist/chunk-CKGZOJVV.js +0 -815
- package/dist/chunk-SIXET7TJ.js +0 -172
- package/dist/icon/index.cjs +0 -1054
- package/dist/icon/index.d.cts +0 -42
- package/dist/icon/index.d.ts +0 -42
- package/dist/icon/index.js +0 -21
package/dist/index.js
CHANGED
|
@@ -7,17 +7,15 @@ import {
|
|
|
7
7
|
} from "./chunk-XJKA22BK.js";
|
|
8
8
|
import {
|
|
9
9
|
Alert
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-2T6FKPJW.js";
|
|
11
11
|
import {
|
|
12
12
|
Autocomplete,
|
|
13
13
|
AutocompleteItem
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-NMZUPH3R.js";
|
|
15
15
|
import "./chunk-GBHQCAKW.js";
|
|
16
16
|
import {
|
|
17
17
|
DatePicker
|
|
18
|
-
} from "./chunk-
|
|
19
|
-
import "./chunk-CKGZOJVV.js";
|
|
20
|
-
import "./chunk-SIXET7TJ.js";
|
|
18
|
+
} from "./chunk-7OFTYKK4.js";
|
|
21
19
|
import {
|
|
22
20
|
Typography
|
|
23
21
|
} from "./chunk-ZYTBRHLJ.js";
|
|
@@ -26,7 +24,7 @@ import {
|
|
|
26
24
|
} from "./chunk-GNJIET26.js";
|
|
27
25
|
import {
|
|
28
26
|
ActivityIndicator
|
|
29
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-MKHBEJLO.js";
|
|
30
28
|
import "./chunk-NBRASCX4.js";
|
|
31
29
|
export {
|
|
32
30
|
ActivityIndicator,
|
package/dist/indicator/index.cjs
CHANGED
|
@@ -215,7 +215,14 @@ var CircularActivityIndicator = ({
|
|
|
215
215
|
borderWidth: strokeWidth,
|
|
216
216
|
borderRadius: size / 2
|
|
217
217
|
};
|
|
218
|
-
return /* @__PURE__ */ import_react6.default.createElement(import_react_native5.Animated.View, { key: index, style: [styles.layer] }, /* @__PURE__ */ import_react6.default.createElement(import_react_native5.Animated.View, { style: layerStyle }, /* @__PURE__ */ import_react6.default.createElement(
|
|
218
|
+
return /* @__PURE__ */ import_react6.default.createElement(import_react_native5.Animated.View, { key: index, style: [styles.layer] }, /* @__PURE__ */ import_react6.default.createElement(import_react_native5.Animated.View, { style: layerStyle }, /* @__PURE__ */ import_react6.default.createElement(
|
|
219
|
+
import_react_native5.Animated.View,
|
|
220
|
+
{
|
|
221
|
+
style: [containerStyle, offsetStyle],
|
|
222
|
+
collapsable: false
|
|
223
|
+
},
|
|
224
|
+
/* @__PURE__ */ import_react6.default.createElement(import_react_native5.Animated.View, { style: viewportStyle }, /* @__PURE__ */ import_react6.default.createElement(import_react_native5.Animated.View, { style: containerStyle, collapsable: false }, /* @__PURE__ */ import_react6.default.createElement(import_react_native5.Animated.View, { style: lineStyle })))
|
|
225
|
+
)));
|
|
219
226
|
})
|
|
220
227
|
));
|
|
221
228
|
};
|
package/dist/indicator/index.js
CHANGED
|
@@ -0,0 +1,371 @@
|
|
|
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");
|
|
47
|
+
|
|
48
|
+
// src/core/portal/portal.tsx
|
|
49
|
+
var import_react2 = require("react");
|
|
50
|
+
|
|
51
|
+
// src/core/portal/portal-context.ts
|
|
52
|
+
var import_react = require("react");
|
|
53
|
+
var PortalContext = (0, import_react.createContext)(null);
|
|
54
|
+
|
|
55
|
+
// src/core/portal/portal-host.tsx
|
|
56
|
+
var import_react3 = __toESM(require("react"), 1);
|
|
57
|
+
var import_react_native = require("react-native");
|
|
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");
|
|
80
|
+
|
|
81
|
+
// src/components/menu/menu.style.ts
|
|
82
|
+
var import_react_native4 = require("react-native");
|
|
83
|
+
var SCREEN_INDENT = 8;
|
|
84
|
+
var MENU_GAP = 4;
|
|
85
|
+
var styles = import_react_native4.StyleSheet.create({
|
|
86
|
+
wrapper: {
|
|
87
|
+
position: "absolute"
|
|
88
|
+
},
|
|
89
|
+
overlay: {
|
|
90
|
+
...import_react_native4.StyleSheet.absoluteFillObject
|
|
91
|
+
},
|
|
92
|
+
menuContainer: {
|
|
93
|
+
position: "absolute",
|
|
94
|
+
paddingVertical: 8,
|
|
95
|
+
minWidth: 200,
|
|
96
|
+
maxWidth: 320
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
var MENU_SCREEN_INDENT = SCREEN_INDENT;
|
|
100
|
+
var MENU_TRIGGER_GAP = MENU_GAP;
|
|
101
|
+
|
|
102
|
+
// src/components/menu/menu.hook.ts
|
|
103
|
+
var import_react6 = require("react");
|
|
104
|
+
var import_react_native5 = require("react-native");
|
|
105
|
+
var useMenuTriggerMeasurements = (visible) => {
|
|
106
|
+
const triggerRef = (0, import_react6.useRef)(null);
|
|
107
|
+
const [triggerPosition, setTriggerPosition] = (0, import_react6.useState)(null);
|
|
108
|
+
(0, import_react6.useEffect)(() => {
|
|
109
|
+
if (!visible) {
|
|
110
|
+
setTriggerPosition(null);
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
const measureTrigger = (attempt) => {
|
|
114
|
+
triggerRef.current?.measure((_, __, width, height, pageX, pageY) => {
|
|
115
|
+
if ((width <= 0 || height <= 0) && attempt < 5) {
|
|
116
|
+
globalThis.requestAnimationFrame(() => measureTrigger(attempt + 1));
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
setTriggerPosition({
|
|
120
|
+
x: pageX,
|
|
121
|
+
y: pageY,
|
|
122
|
+
width: Math.max(0, width),
|
|
123
|
+
height: Math.max(0, height)
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
};
|
|
127
|
+
const frameId = globalThis.setTimeout(() => measureTrigger(0), 0);
|
|
128
|
+
return () => globalThis.clearTimeout(frameId);
|
|
129
|
+
}, [visible]);
|
|
130
|
+
return { triggerRef, triggerPosition };
|
|
131
|
+
};
|
|
132
|
+
var useMenuContentLayout = (visible) => {
|
|
133
|
+
const [contentSize, setContentSize] = (0, import_react6.useState)({ width: 0, height: 0 });
|
|
134
|
+
const [isMeasured, setIsMeasured] = (0, import_react6.useState)(false);
|
|
135
|
+
(0, import_react6.useEffect)(() => {
|
|
136
|
+
if (!visible) {
|
|
137
|
+
setIsMeasured(false);
|
|
138
|
+
}
|
|
139
|
+
}, [visible]);
|
|
140
|
+
const handleContentLayout = (0, import_react6.useCallback)((event) => {
|
|
141
|
+
const { width, height } = event.nativeEvent.layout;
|
|
142
|
+
if (width > 0 && height > 0) {
|
|
143
|
+
setContentSize({ width, height });
|
|
144
|
+
setIsMeasured(true);
|
|
145
|
+
}
|
|
146
|
+
}, []);
|
|
147
|
+
return { contentSize, handleContentLayout, isMeasured };
|
|
148
|
+
};
|
|
149
|
+
var useMenuPosition = (triggerPosition, contentSize, position) => {
|
|
150
|
+
return (0, import_react6.useMemo)(() => {
|
|
151
|
+
if (!triggerPosition) return { top: 0, left: 0 };
|
|
152
|
+
const screenWidth = import_react_native5.Dimensions.get("window").width;
|
|
153
|
+
const screenHeight = import_react_native5.Dimensions.get("window").height;
|
|
154
|
+
let top;
|
|
155
|
+
let left = triggerPosition.x;
|
|
156
|
+
const hasEnoughSpaceBelow = triggerPosition.y + triggerPosition.height + contentSize.height <= screenHeight - MENU_SCREEN_INDENT;
|
|
157
|
+
const hasEnoughSpaceAbove = triggerPosition.y - contentSize.height >= MENU_SCREEN_INDENT;
|
|
158
|
+
if (position === "bottom") {
|
|
159
|
+
if (hasEnoughSpaceBelow) {
|
|
160
|
+
top = triggerPosition.y + triggerPosition.height + MENU_TRIGGER_GAP;
|
|
161
|
+
} else if (hasEnoughSpaceAbove) {
|
|
162
|
+
top = triggerPosition.y - contentSize.height - MENU_TRIGGER_GAP;
|
|
163
|
+
} else {
|
|
164
|
+
top = triggerPosition.y + triggerPosition.height + MENU_TRIGGER_GAP;
|
|
165
|
+
}
|
|
166
|
+
} else {
|
|
167
|
+
if (hasEnoughSpaceAbove) {
|
|
168
|
+
top = triggerPosition.y - contentSize.height - MENU_TRIGGER_GAP;
|
|
169
|
+
} else if (hasEnoughSpaceBelow) {
|
|
170
|
+
top = triggerPosition.y + triggerPosition.height + MENU_TRIGGER_GAP;
|
|
171
|
+
} else {
|
|
172
|
+
top = triggerPosition.y - contentSize.height - MENU_TRIGGER_GAP;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
if (contentSize.width > 0 && left + contentSize.width > screenWidth - MENU_SCREEN_INDENT) {
|
|
176
|
+
left = Math.max(
|
|
177
|
+
MENU_SCREEN_INDENT,
|
|
178
|
+
triggerPosition.x + triggerPosition.width - contentSize.width
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
if (left < MENU_SCREEN_INDENT) {
|
|
182
|
+
left = MENU_SCREEN_INDENT;
|
|
183
|
+
}
|
|
184
|
+
const maxTop = Math.max(MENU_SCREEN_INDENT, screenHeight - MENU_SCREEN_INDENT - contentSize.height);
|
|
185
|
+
const clampedTop = Math.min(maxTop, Math.max(MENU_SCREEN_INDENT, top));
|
|
186
|
+
return { top: clampedTop, left };
|
|
187
|
+
}, [triggerPosition, contentSize, position]);
|
|
188
|
+
};
|
|
189
|
+
var useMenuAnimation = (visible) => {
|
|
190
|
+
const opacity = (0, import_react6.useRef)(new import_react_native5.Animated.Value(0)).current;
|
|
191
|
+
const scale = (0, import_react6.useRef)(new import_react_native5.Animated.Value(0)).current;
|
|
192
|
+
(0, import_react6.useEffect)(() => {
|
|
193
|
+
if (!visible) return;
|
|
194
|
+
opacity.setValue(0);
|
|
195
|
+
scale.setValue(0);
|
|
196
|
+
import_react_native5.Animated.parallel([
|
|
197
|
+
import_react_native5.Animated.timing(opacity, {
|
|
198
|
+
toValue: 1,
|
|
199
|
+
duration: 200,
|
|
200
|
+
easing: import_react_native5.Easing.bezier(0.4, 0, 0.2, 1),
|
|
201
|
+
useNativeDriver: true
|
|
202
|
+
}),
|
|
203
|
+
import_react_native5.Animated.spring(scale, {
|
|
204
|
+
toValue: 1,
|
|
205
|
+
friction: 9,
|
|
206
|
+
tension: 100,
|
|
207
|
+
useNativeDriver: true
|
|
208
|
+
})
|
|
209
|
+
]).start();
|
|
210
|
+
}, [visible, opacity, scale]);
|
|
211
|
+
return { opacity, scale };
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
// src/components/menu/menu.tsx
|
|
215
|
+
var Menu = ({
|
|
216
|
+
visible,
|
|
217
|
+
trigger,
|
|
218
|
+
position = "bottom",
|
|
219
|
+
onDismiss,
|
|
220
|
+
children,
|
|
221
|
+
customAppearance,
|
|
222
|
+
maxHeight = 280
|
|
223
|
+
}) => {
|
|
224
|
+
const theme = useXUITheme();
|
|
225
|
+
const { triggerRef, triggerPosition } = useMenuTriggerMeasurements(visible);
|
|
226
|
+
const { contentSize, handleContentLayout, isMeasured } = useMenuContentLayout(visible);
|
|
227
|
+
const menuPosition = useMenuPosition(triggerPosition, contentSize, position);
|
|
228
|
+
const { opacity, scale } = useMenuAnimation(visible);
|
|
229
|
+
return /* @__PURE__ */ import_react7.default.createElement(import_react7.default.Fragment, null, /* @__PURE__ */ import_react7.default.createElement(import_react_native6.View, { ref: triggerRef, collapsable: false }, trigger), /* @__PURE__ */ import_react7.default.createElement(
|
|
230
|
+
import_react_native6.Modal,
|
|
231
|
+
{
|
|
232
|
+
visible,
|
|
233
|
+
transparent: true,
|
|
234
|
+
animationType: "fade",
|
|
235
|
+
onRequestClose: onDismiss
|
|
236
|
+
},
|
|
237
|
+
/* @__PURE__ */ import_react7.default.createElement(
|
|
238
|
+
import_react_native6.Pressable,
|
|
239
|
+
{
|
|
240
|
+
style: [styles.overlay, customAppearance?.overlay],
|
|
241
|
+
onPress: onDismiss,
|
|
242
|
+
accessibilityRole: "button",
|
|
243
|
+
accessibilityLabel: "Close menu"
|
|
244
|
+
},
|
|
245
|
+
/* @__PURE__ */ import_react7.default.createElement(
|
|
246
|
+
import_react_native6.Animated.View,
|
|
247
|
+
{
|
|
248
|
+
onLayout: handleContentLayout,
|
|
249
|
+
style: [
|
|
250
|
+
styles.menuContainer,
|
|
251
|
+
{
|
|
252
|
+
top: isMeasured ? menuPosition.top : -9999,
|
|
253
|
+
left: isMeasured ? menuPosition.left : -9999,
|
|
254
|
+
backgroundColor: theme.colors.background,
|
|
255
|
+
borderRadius: theme.borderRadius.md,
|
|
256
|
+
opacity: isMeasured ? opacity : 0,
|
|
257
|
+
transform: [{ scale }],
|
|
258
|
+
...theme.shadows.md
|
|
259
|
+
},
|
|
260
|
+
customAppearance?.container
|
|
261
|
+
]
|
|
262
|
+
},
|
|
263
|
+
/* @__PURE__ */ import_react7.default.createElement(import_react_native6.Pressable, { onPress: (e) => e.stopPropagation() }, /* @__PURE__ */ import_react7.default.createElement(import_react_native6.View, { style: customAppearance?.content }, /* @__PURE__ */ import_react7.default.createElement(import_react_native6.ScrollView, { style: { maxHeight } }, children)))
|
|
264
|
+
)
|
|
265
|
+
)
|
|
266
|
+
));
|
|
267
|
+
};
|
|
268
|
+
|
|
269
|
+
// src/components/menu/menu-item.tsx
|
|
270
|
+
var import_react8 = __toESM(require("react"), 1);
|
|
271
|
+
var import_react_native8 = require("react-native");
|
|
272
|
+
|
|
273
|
+
// src/components/menu/menu-item.style.ts
|
|
274
|
+
var import_react_native7 = require("react-native");
|
|
275
|
+
var MIN_WIDTH = 112;
|
|
276
|
+
var MAX_WIDTH = 280;
|
|
277
|
+
var styles2 = import_react_native7.StyleSheet.create({
|
|
278
|
+
container: {
|
|
279
|
+
minWidth: MIN_WIDTH,
|
|
280
|
+
maxWidth: MAX_WIDTH,
|
|
281
|
+
height: 48,
|
|
282
|
+
justifyContent: "center",
|
|
283
|
+
paddingHorizontal: 12
|
|
284
|
+
},
|
|
285
|
+
denseContainer: {
|
|
286
|
+
height: 32
|
|
287
|
+
},
|
|
288
|
+
row: {
|
|
289
|
+
flexDirection: "row",
|
|
290
|
+
alignItems: "center"
|
|
291
|
+
},
|
|
292
|
+
content: {
|
|
293
|
+
flex: 1,
|
|
294
|
+
justifyContent: "center"
|
|
295
|
+
},
|
|
296
|
+
titleText: {
|
|
297
|
+
fontSize: 16
|
|
298
|
+
},
|
|
299
|
+
startContent: {
|
|
300
|
+
width: 24,
|
|
301
|
+
marginRight: 12,
|
|
302
|
+
alignItems: "center",
|
|
303
|
+
justifyContent: "center"
|
|
304
|
+
},
|
|
305
|
+
endContent: {
|
|
306
|
+
width: 24,
|
|
307
|
+
marginLeft: 12,
|
|
308
|
+
alignItems: "center",
|
|
309
|
+
justifyContent: "center"
|
|
310
|
+
},
|
|
311
|
+
disabled: {
|
|
312
|
+
opacity: 0.5
|
|
313
|
+
}
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
// src/components/menu/menu-item.tsx
|
|
317
|
+
var MenuItem = ({
|
|
318
|
+
title,
|
|
319
|
+
startContent,
|
|
320
|
+
endContent,
|
|
321
|
+
isDisabled = false,
|
|
322
|
+
dense = false,
|
|
323
|
+
onPress,
|
|
324
|
+
customAppearance,
|
|
325
|
+
accessibilityLabel
|
|
326
|
+
}) => {
|
|
327
|
+
const theme = useXUITheme();
|
|
328
|
+
const titleColor = isDisabled ? theme.colors.foreground + "50" : theme.colors.foreground;
|
|
329
|
+
const renderTitle = () => {
|
|
330
|
+
if (typeof title === "string" || typeof title === "number") {
|
|
331
|
+
return /* @__PURE__ */ import_react8.default.createElement(
|
|
332
|
+
import_react_native8.Text,
|
|
333
|
+
{
|
|
334
|
+
style: [
|
|
335
|
+
styles2.titleText,
|
|
336
|
+
{ color: titleColor },
|
|
337
|
+
customAppearance?.title
|
|
338
|
+
],
|
|
339
|
+
numberOfLines: 1
|
|
340
|
+
},
|
|
341
|
+
title
|
|
342
|
+
);
|
|
343
|
+
}
|
|
344
|
+
return title;
|
|
345
|
+
};
|
|
346
|
+
return /* @__PURE__ */ import_react8.default.createElement(
|
|
347
|
+
import_react_native8.Pressable,
|
|
348
|
+
{
|
|
349
|
+
onPress: isDisabled ? void 0 : onPress,
|
|
350
|
+
disabled: isDisabled,
|
|
351
|
+
accessibilityRole: "menuitem",
|
|
352
|
+
accessibilityLabel,
|
|
353
|
+
accessibilityState: { disabled: isDisabled },
|
|
354
|
+
style: ({ pressed }) => [
|
|
355
|
+
styles2.container,
|
|
356
|
+
dense && styles2.denseContainer,
|
|
357
|
+
isDisabled && styles2.disabled,
|
|
358
|
+
pressed && !isDisabled && {
|
|
359
|
+
backgroundColor: theme.colors.foreground + "10"
|
|
360
|
+
},
|
|
361
|
+
customAppearance?.container
|
|
362
|
+
]
|
|
363
|
+
},
|
|
364
|
+
/* @__PURE__ */ import_react8.default.createElement(import_react_native8.View, { style: [styles2.row, customAppearance?.content] }, startContent && /* @__PURE__ */ import_react8.default.createElement(import_react_native8.View, { style: styles2.startContent }, startContent), /* @__PURE__ */ import_react8.default.createElement(import_react_native8.View, { style: styles2.content }, renderTitle()), endContent && /* @__PURE__ */ import_react8.default.createElement(import_react_native8.View, { style: styles2.endContent }, endContent))
|
|
365
|
+
);
|
|
366
|
+
};
|
|
367
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
368
|
+
0 && (module.exports = {
|
|
369
|
+
Menu,
|
|
370
|
+
MenuItem
|
|
371
|
+
});
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
import { ViewStyle, GestureResponderEvent, TextStyle } from 'react-native';
|
|
3
|
+
|
|
4
|
+
type MenuPosition = 'top' | 'bottom';
|
|
5
|
+
type MenuCustomAppearance = {
|
|
6
|
+
/**
|
|
7
|
+
* Custom styles for the overlay container
|
|
8
|
+
*/
|
|
9
|
+
overlay?: ViewStyle;
|
|
10
|
+
/**
|
|
11
|
+
* Custom styles for the menu container
|
|
12
|
+
*/
|
|
13
|
+
container?: ViewStyle;
|
|
14
|
+
/**
|
|
15
|
+
* Custom styles for the menu content
|
|
16
|
+
*/
|
|
17
|
+
content?: ViewStyle;
|
|
18
|
+
};
|
|
19
|
+
type MenuProps = {
|
|
20
|
+
/**
|
|
21
|
+
* Whether the Menu is currently visible.
|
|
22
|
+
*/
|
|
23
|
+
visible: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* The trigger element to open the menu from. This is the component that will trigger the menu display.
|
|
26
|
+
*/
|
|
27
|
+
trigger: ReactNode;
|
|
28
|
+
/**
|
|
29
|
+
* Whether the menu should open at the top of the trigger or at its bottom.
|
|
30
|
+
* @default 'bottom'
|
|
31
|
+
*/
|
|
32
|
+
position?: MenuPosition;
|
|
33
|
+
/**
|
|
34
|
+
* Callback called when Menu is dismissed. The `visible` prop needs to be updated when this is called.
|
|
35
|
+
*/
|
|
36
|
+
onDismiss?: () => void;
|
|
37
|
+
/**
|
|
38
|
+
* Content of the Menu.
|
|
39
|
+
*/
|
|
40
|
+
children: ReactNode;
|
|
41
|
+
/**
|
|
42
|
+
* Custom appearance styles for menu parts
|
|
43
|
+
*/
|
|
44
|
+
customAppearance?: MenuCustomAppearance;
|
|
45
|
+
/**
|
|
46
|
+
* Maximum height of the scrollable menu content
|
|
47
|
+
* @default 280
|
|
48
|
+
*/
|
|
49
|
+
maxHeight?: number;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
declare const Menu: React.FC<MenuProps>;
|
|
53
|
+
|
|
54
|
+
type MenuItemCustomAppearance = {
|
|
55
|
+
/**
|
|
56
|
+
* Custom styles for the item container
|
|
57
|
+
*/
|
|
58
|
+
container?: ViewStyle;
|
|
59
|
+
/**
|
|
60
|
+
* Custom styles for the item content
|
|
61
|
+
*/
|
|
62
|
+
content?: ViewStyle;
|
|
63
|
+
/**
|
|
64
|
+
* Custom styles for the title text
|
|
65
|
+
*/
|
|
66
|
+
title?: TextStyle;
|
|
67
|
+
};
|
|
68
|
+
type MenuItemProps = {
|
|
69
|
+
/**
|
|
70
|
+
* Title text for the MenuItem.
|
|
71
|
+
*/
|
|
72
|
+
title: ReactNode;
|
|
73
|
+
/**
|
|
74
|
+
* Content to display at the start of the item.
|
|
75
|
+
*/
|
|
76
|
+
startContent?: ReactNode;
|
|
77
|
+
/**
|
|
78
|
+
* Content to display at the end of the item.
|
|
79
|
+
*/
|
|
80
|
+
endContent?: ReactNode;
|
|
81
|
+
/**
|
|
82
|
+
* Whether the item is disabled. A disabled item is greyed out and onPress is not called on touch.
|
|
83
|
+
* @default false
|
|
84
|
+
*/
|
|
85
|
+
isDisabled?: boolean;
|
|
86
|
+
/**
|
|
87
|
+
* Sets min height with densed layout.
|
|
88
|
+
* @default false
|
|
89
|
+
*/
|
|
90
|
+
dense?: boolean;
|
|
91
|
+
/**
|
|
92
|
+
* Function to execute on press.
|
|
93
|
+
*/
|
|
94
|
+
onPress?: (e: GestureResponderEvent) => void;
|
|
95
|
+
/**
|
|
96
|
+
* Custom appearance styles for item parts
|
|
97
|
+
*/
|
|
98
|
+
customAppearance?: MenuItemCustomAppearance;
|
|
99
|
+
/**
|
|
100
|
+
* Accessibility label for the item. This is read by the screen reader when the user taps the component.
|
|
101
|
+
*/
|
|
102
|
+
accessibilityLabel?: string;
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
declare const MenuItem: React.FC<MenuItemProps>;
|
|
106
|
+
|
|
107
|
+
export { Menu, type MenuCustomAppearance, MenuItem, type MenuItemCustomAppearance, type MenuItemProps, type MenuPosition, type MenuProps };
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
import { ViewStyle, GestureResponderEvent, TextStyle } from 'react-native';
|
|
3
|
+
|
|
4
|
+
type MenuPosition = 'top' | 'bottom';
|
|
5
|
+
type MenuCustomAppearance = {
|
|
6
|
+
/**
|
|
7
|
+
* Custom styles for the overlay container
|
|
8
|
+
*/
|
|
9
|
+
overlay?: ViewStyle;
|
|
10
|
+
/**
|
|
11
|
+
* Custom styles for the menu container
|
|
12
|
+
*/
|
|
13
|
+
container?: ViewStyle;
|
|
14
|
+
/**
|
|
15
|
+
* Custom styles for the menu content
|
|
16
|
+
*/
|
|
17
|
+
content?: ViewStyle;
|
|
18
|
+
};
|
|
19
|
+
type MenuProps = {
|
|
20
|
+
/**
|
|
21
|
+
* Whether the Menu is currently visible.
|
|
22
|
+
*/
|
|
23
|
+
visible: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* The trigger element to open the menu from. This is the component that will trigger the menu display.
|
|
26
|
+
*/
|
|
27
|
+
trigger: ReactNode;
|
|
28
|
+
/**
|
|
29
|
+
* Whether the menu should open at the top of the trigger or at its bottom.
|
|
30
|
+
* @default 'bottom'
|
|
31
|
+
*/
|
|
32
|
+
position?: MenuPosition;
|
|
33
|
+
/**
|
|
34
|
+
* Callback called when Menu is dismissed. The `visible` prop needs to be updated when this is called.
|
|
35
|
+
*/
|
|
36
|
+
onDismiss?: () => void;
|
|
37
|
+
/**
|
|
38
|
+
* Content of the Menu.
|
|
39
|
+
*/
|
|
40
|
+
children: ReactNode;
|
|
41
|
+
/**
|
|
42
|
+
* Custom appearance styles for menu parts
|
|
43
|
+
*/
|
|
44
|
+
customAppearance?: MenuCustomAppearance;
|
|
45
|
+
/**
|
|
46
|
+
* Maximum height of the scrollable menu content
|
|
47
|
+
* @default 280
|
|
48
|
+
*/
|
|
49
|
+
maxHeight?: number;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
declare const Menu: React.FC<MenuProps>;
|
|
53
|
+
|
|
54
|
+
type MenuItemCustomAppearance = {
|
|
55
|
+
/**
|
|
56
|
+
* Custom styles for the item container
|
|
57
|
+
*/
|
|
58
|
+
container?: ViewStyle;
|
|
59
|
+
/**
|
|
60
|
+
* Custom styles for the item content
|
|
61
|
+
*/
|
|
62
|
+
content?: ViewStyle;
|
|
63
|
+
/**
|
|
64
|
+
* Custom styles for the title text
|
|
65
|
+
*/
|
|
66
|
+
title?: TextStyle;
|
|
67
|
+
};
|
|
68
|
+
type MenuItemProps = {
|
|
69
|
+
/**
|
|
70
|
+
* Title text for the MenuItem.
|
|
71
|
+
*/
|
|
72
|
+
title: ReactNode;
|
|
73
|
+
/**
|
|
74
|
+
* Content to display at the start of the item.
|
|
75
|
+
*/
|
|
76
|
+
startContent?: ReactNode;
|
|
77
|
+
/**
|
|
78
|
+
* Content to display at the end of the item.
|
|
79
|
+
*/
|
|
80
|
+
endContent?: ReactNode;
|
|
81
|
+
/**
|
|
82
|
+
* Whether the item is disabled. A disabled item is greyed out and onPress is not called on touch.
|
|
83
|
+
* @default false
|
|
84
|
+
*/
|
|
85
|
+
isDisabled?: boolean;
|
|
86
|
+
/**
|
|
87
|
+
* Sets min height with densed layout.
|
|
88
|
+
* @default false
|
|
89
|
+
*/
|
|
90
|
+
dense?: boolean;
|
|
91
|
+
/**
|
|
92
|
+
* Function to execute on press.
|
|
93
|
+
*/
|
|
94
|
+
onPress?: (e: GestureResponderEvent) => void;
|
|
95
|
+
/**
|
|
96
|
+
* Custom appearance styles for item parts
|
|
97
|
+
*/
|
|
98
|
+
customAppearance?: MenuItemCustomAppearance;
|
|
99
|
+
/**
|
|
100
|
+
* Accessibility label for the item. This is read by the screen reader when the user taps the component.
|
|
101
|
+
*/
|
|
102
|
+
accessibilityLabel?: string;
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
declare const MenuItem: React.FC<MenuItemProps>;
|
|
106
|
+
|
|
107
|
+
export { Menu, type MenuCustomAppearance, MenuItem, type MenuItemCustomAppearance, type MenuItemProps, type MenuPosition, type MenuProps };
|