@xaui/native 0.0.32 → 0.0.33

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.
@@ -0,0 +1,250 @@
1
+ import {
2
+ InputTrigger
3
+ } from "../chunk-E4DOPNVW.js";
4
+ import {
5
+ BottomSheet
6
+ } from "../chunk-ED22WCCI.js";
7
+ import "../chunk-DXXNBF5P.js";
8
+ import {
9
+ useXUITheme
10
+ } from "../chunk-LTKYHG5V.js";
11
+
12
+ // src/components/picker/picker.tsx
13
+ import React, { useState } from "react";
14
+ import { Pressable, ScrollView, Text, View } from "react-native";
15
+ import { getSafeThemeColor, withOpacity } from "@xaui/core";
16
+
17
+ // src/components/picker/picker.style.ts
18
+ import { StyleSheet } from "react-native";
19
+ var styles = StyleSheet.create({
20
+ sheetContent: {
21
+ flex: 1,
22
+ paddingBottom: 24
23
+ },
24
+ sheetTitle: {
25
+ paddingHorizontal: 20,
26
+ paddingTop: 4,
27
+ paddingBottom: 12,
28
+ fontSize: 16,
29
+ fontWeight: "600"
30
+ },
31
+ optionItem: {
32
+ flexDirection: "row",
33
+ alignItems: "center",
34
+ paddingHorizontal: 20,
35
+ paddingVertical: 14,
36
+ gap: 12
37
+ },
38
+ optionItemDisabled: {
39
+ opacity: 0.4
40
+ },
41
+ optionLabel: {
42
+ flex: 1,
43
+ fontSize: 16
44
+ },
45
+ checkmark: {
46
+ width: 20,
47
+ height: 20,
48
+ borderRadius: 10,
49
+ alignItems: "center",
50
+ justifyContent: "center"
51
+ },
52
+ divider: {
53
+ height: StyleSheet.hairlineWidth,
54
+ marginHorizontal: 20
55
+ }
56
+ });
57
+
58
+ // src/components/picker/picker.tsx
59
+ var ChevronDownIcon = ({
60
+ color,
61
+ size
62
+ }) => /* @__PURE__ */ React.createElement(
63
+ View,
64
+ {
65
+ style: {
66
+ width: size,
67
+ height: size,
68
+ alignItems: "center",
69
+ justifyContent: "center"
70
+ }
71
+ },
72
+ /* @__PURE__ */ React.createElement(
73
+ View,
74
+ {
75
+ style: {
76
+ width: size * 0.5,
77
+ height: size * 0.5,
78
+ borderRightWidth: 2,
79
+ borderBottomWidth: 2,
80
+ borderColor: color,
81
+ transform: [{ rotate: "45deg" }],
82
+ marginTop: -(size * 0.15)
83
+ }
84
+ }
85
+ )
86
+ );
87
+ var CheckIcon = ({ color }) => /* @__PURE__ */ React.createElement(View, { style: { width: 20, height: 20, alignItems: "center", justifyContent: "center" } }, /* @__PURE__ */ React.createElement(
88
+ View,
89
+ {
90
+ style: {
91
+ width: 6,
92
+ height: 10,
93
+ borderRightWidth: 2,
94
+ borderBottomWidth: 2,
95
+ borderColor: color,
96
+ transform: [{ rotate: "45deg" }],
97
+ marginTop: -3
98
+ }
99
+ }
100
+ ));
101
+ var OptionItem = ({
102
+ option,
103
+ isSelected,
104
+ themeColor,
105
+ foreground,
106
+ onSelect
107
+ }) => {
108
+ const handlePress = () => {
109
+ if (!option.disabled) {
110
+ onSelect(option.value);
111
+ }
112
+ };
113
+ return /* @__PURE__ */ React.createElement(
114
+ Pressable,
115
+ {
116
+ onPress: handlePress,
117
+ style: [styles.optionItem, option.disabled && styles.optionItemDisabled],
118
+ disabled: option.disabled
119
+ },
120
+ /* @__PURE__ */ React.createElement(
121
+ Text,
122
+ {
123
+ style: [
124
+ styles.optionLabel,
125
+ { color: isSelected ? themeColor : foreground }
126
+ ]
127
+ },
128
+ option.label
129
+ ),
130
+ isSelected && /* @__PURE__ */ React.createElement(CheckIcon, { color: themeColor })
131
+ );
132
+ };
133
+ var Picker = ({
134
+ options,
135
+ value,
136
+ placeholder = "Select an option...",
137
+ label,
138
+ labelPlacement = "outside",
139
+ description,
140
+ errorMessage,
141
+ sheetTitle,
142
+ themeColor = "primary",
143
+ variant = "flat",
144
+ size = "md",
145
+ radius = "md",
146
+ isOpened,
147
+ isDisabled = false,
148
+ isInvalid = false,
149
+ fullWidth = true,
150
+ sheetStyle,
151
+ endContent,
152
+ onValueChange,
153
+ onOpenChange,
154
+ onClose
155
+ }) => {
156
+ const [internalIsOpen, setInternalIsOpen] = useState(false);
157
+ const isControlled = isOpened !== void 0;
158
+ const isOpen = isControlled ? Boolean(isOpened) : internalIsOpen;
159
+ const theme = useXUITheme();
160
+ const sheetBackground = theme.mode === "dark" ? theme.colors.background : "#ffffff";
161
+ const safeThemeColor = getSafeThemeColor(themeColor);
162
+ const colorScheme = theme.colors[safeThemeColor];
163
+ const selectedOption = options.find((opt) => opt.value === value);
164
+ const displayLabel = selectedOption?.label;
165
+ const setOpen = (nextOpen) => {
166
+ if (nextOpen && isDisabled) return;
167
+ if (!isControlled) {
168
+ setInternalIsOpen(nextOpen);
169
+ }
170
+ onOpenChange?.(nextOpen);
171
+ };
172
+ const handleOpen = () => {
173
+ setOpen(true);
174
+ };
175
+ const requestClose = () => {
176
+ setOpen(false);
177
+ };
178
+ const handleSheetClose = () => {
179
+ if (isOpen) {
180
+ setOpen(false);
181
+ }
182
+ onClose?.();
183
+ };
184
+ const handleSelect = (selectedValue) => {
185
+ onValueChange?.(selectedValue);
186
+ requestClose();
187
+ };
188
+ const chevronColor = withOpacity(theme.colors.foreground, 0.45);
189
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
190
+ InputTrigger,
191
+ {
192
+ value: displayLabel,
193
+ placeholder,
194
+ label,
195
+ labelPlacement,
196
+ description,
197
+ errorMessage,
198
+ themeColor,
199
+ variant,
200
+ size,
201
+ radius,
202
+ isDisabled,
203
+ isInvalid,
204
+ fullWidth,
205
+ endContent: endContent ?? /* @__PURE__ */ React.createElement(ChevronDownIcon, { color: chevronColor, size: 20 }),
206
+ onPress: handleOpen
207
+ }
208
+ ), /* @__PURE__ */ React.createElement(
209
+ BottomSheet,
210
+ {
211
+ isOpen,
212
+ snapPoints: [Math.min(0.35 + options.length * 0.065, 0.85)],
213
+ themeColor,
214
+ onClose: handleSheetClose,
215
+ style: { backgroundColor: sheetBackground, ...sheetStyle }
216
+ },
217
+ /* @__PURE__ */ React.createElement(View, { style: styles.sheetContent }, sheetTitle ? /* @__PURE__ */ React.createElement(
218
+ Text,
219
+ {
220
+ style: [styles.sheetTitle, { color: theme.colors.foreground }]
221
+ },
222
+ sheetTitle
223
+ ) : null, /* @__PURE__ */ React.createElement(ScrollView, null, options.map((option, index) => /* @__PURE__ */ React.createElement(View, { key: option.value }, /* @__PURE__ */ React.createElement(
224
+ OptionItem,
225
+ {
226
+ option,
227
+ isSelected: option.value === value,
228
+ themeColor: colorScheme.main,
229
+ foreground: theme.colors.foreground,
230
+ onSelect: handleSelect
231
+ }
232
+ ), index < options.length - 1 && /* @__PURE__ */ React.createElement(
233
+ View,
234
+ {
235
+ style: [
236
+ styles.divider,
237
+ {
238
+ backgroundColor: withOpacity(
239
+ theme.colors.foreground,
240
+ 0.06
241
+ )
242
+ }
243
+ ]
244
+ }
245
+ )))))
246
+ ));
247
+ };
248
+ export {
249
+ Picker
250
+ };
@@ -1,6 +1,7 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 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; }
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 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; }require('../chunk-EUQDGTST.cjs');
2
2
 
3
- var _chunkXFPPR2VBcjs = require('../chunk-XFPPR2VB.cjs');
3
+
4
+ var _chunkRVR42THGcjs = require('../chunk-RVR42THG.cjs');
4
5
  require('../chunk-HSPTLUFA.cjs');
5
6
 
6
7
 
@@ -716,7 +717,7 @@ var TimePickerDialog = ({
716
717
  _optionalChain([onCancel, 'optionalCall', _8 => _8()]);
717
718
  onClose();
718
719
  };
719
- return /* @__PURE__ */ _react2.default.createElement(_chunkXFPPR2VBcjs.BottomSheet, { isOpen, onClose, snapPoints: [0.7] }, /* @__PURE__ */ _react2.default.createElement(_reactnative.View, null, /* @__PURE__ */ _react2.default.createElement(
720
+ return /* @__PURE__ */ _react2.default.createElement(_chunkRVR42THGcjs.BottomSheet, { isOpen, onClose, snapPoints: [0.7] }, /* @__PURE__ */ _react2.default.createElement(_reactnative.View, null, /* @__PURE__ */ _react2.default.createElement(
720
721
  TimePicker,
721
722
  {
722
723
  value: tempValue,
@@ -1,6 +1,7 @@
1
+ import "../chunk-DECMUMCI.js";
1
2
  import {
2
3
  BottomSheet
3
- } from "../chunk-HC2SSHNU.js";
4
+ } from "../chunk-ED22WCCI.js";
4
5
  import "../chunk-DXXNBF5P.js";
5
6
  import {
6
7
  useXUITheme
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xaui/native",
3
- "version": "0.0.32",
3
+ "version": "0.0.33",
4
4
  "description": "Flutter-inspired React Native UI components with native animations powered by React Native Reanimated",
5
5
  "keywords": [
6
6
  "react-native",
@@ -232,6 +232,21 @@
232
232
  "import": "./dist/snackbar/index.js",
233
233
  "require": "./dist/snackbar/index.js"
234
234
  },
235
+ "./input-trigger": {
236
+ "types": "./dist/input-trigger/index.d.ts",
237
+ "import": "./dist/input-trigger/index.js",
238
+ "require": "./dist/input-trigger/index.js"
239
+ },
240
+ "./picker": {
241
+ "types": "./dist/picker/index.d.ts",
242
+ "import": "./dist/picker/index.js",
243
+ "require": "./dist/picker/index.js"
244
+ },
245
+ "./color-picker": {
246
+ "types": "./dist/color-picker/index.d.ts",
247
+ "import": "./dist/color-picker/index.js",
248
+ "require": "./dist/color-picker/index.js"
249
+ },
235
250
  "./snippet": {
236
251
  "types": "./dist/snippet/index.d.ts",
237
252
  "import": "./dist/snippet/index.js",
File without changes
File without changes