@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,460 @@
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/color-picker/color-picker.tsx
13
+ import React, { useEffect, useState } from "react";
14
+ import { Pressable, ScrollView, Text, View } from "react-native";
15
+ import { withOpacity } from "@xaui/core";
16
+
17
+ // src/components/color-picker/color-picker.palette.ts
18
+ var defaultColorGroups = [
19
+ {
20
+ name: "Red",
21
+ colors: [
22
+ "#fef2f2",
23
+ "#fecaca",
24
+ "#f87171",
25
+ "#ef4444",
26
+ "#dc2626",
27
+ "#b91c1c",
28
+ "#991b1b",
29
+ "#7f1d1d"
30
+ ]
31
+ },
32
+ {
33
+ name: "Orange",
34
+ colors: [
35
+ "#fff7ed",
36
+ "#fed7aa",
37
+ "#fb923c",
38
+ "#f97316",
39
+ "#ea580c",
40
+ "#c2410c",
41
+ "#9a3412",
42
+ "#7c2d12"
43
+ ]
44
+ },
45
+ {
46
+ name: "Amber",
47
+ colors: [
48
+ "#fffbeb",
49
+ "#fde68a",
50
+ "#fbbf24",
51
+ "#f59e0b",
52
+ "#d97706",
53
+ "#b45309",
54
+ "#92400e",
55
+ "#78350f"
56
+ ]
57
+ },
58
+ {
59
+ name: "Yellow",
60
+ colors: [
61
+ "#fefce8",
62
+ "#fef08a",
63
+ "#facc15",
64
+ "#eab308",
65
+ "#ca8a04",
66
+ "#a16207",
67
+ "#854d0e",
68
+ "#713f12"
69
+ ]
70
+ },
71
+ {
72
+ name: "Lime",
73
+ colors: [
74
+ "#f7fee7",
75
+ "#d9f99d",
76
+ "#86efac",
77
+ "#4ade80",
78
+ "#22c55e",
79
+ "#16a34a",
80
+ "#15803d",
81
+ "#14532d"
82
+ ]
83
+ },
84
+ {
85
+ name: "Green",
86
+ colors: [
87
+ "#f0fdf4",
88
+ "#bbf7d0",
89
+ "#4ade80",
90
+ "#22c55e",
91
+ "#16a34a",
92
+ "#15803d",
93
+ "#166534",
94
+ "#14532d"
95
+ ]
96
+ },
97
+ {
98
+ name: "Teal",
99
+ colors: [
100
+ "#f0fdfa",
101
+ "#99f6e4",
102
+ "#2dd4bf",
103
+ "#14b8a6",
104
+ "#0d9488",
105
+ "#0f766e",
106
+ "#115e59",
107
+ "#134e4a"
108
+ ]
109
+ },
110
+ {
111
+ name: "Cyan",
112
+ colors: [
113
+ "#ecfeff",
114
+ "#a5f3fc",
115
+ "#22d3ee",
116
+ "#06b6d4",
117
+ "#0891b2",
118
+ "#0e7490",
119
+ "#155e75",
120
+ "#164e63"
121
+ ]
122
+ },
123
+ {
124
+ name: "Blue",
125
+ colors: [
126
+ "#eff6ff",
127
+ "#bfdbfe",
128
+ "#60a5fa",
129
+ "#3b82f6",
130
+ "#2563eb",
131
+ "#1d4ed8",
132
+ "#1e40af",
133
+ "#1e3a8a"
134
+ ]
135
+ },
136
+ {
137
+ name: "Indigo",
138
+ colors: [
139
+ "#eef2ff",
140
+ "#c7d2fe",
141
+ "#818cf8",
142
+ "#6366f1",
143
+ "#4f46e5",
144
+ "#4338ca",
145
+ "#3730a3",
146
+ "#312e81"
147
+ ]
148
+ },
149
+ {
150
+ name: "Violet",
151
+ colors: [
152
+ "#f5f3ff",
153
+ "#ddd6fe",
154
+ "#a78bfa",
155
+ "#8b5cf6",
156
+ "#7c3aed",
157
+ "#6d28d9",
158
+ "#5b21b6",
159
+ "#4c1d95"
160
+ ]
161
+ },
162
+ {
163
+ name: "Purple",
164
+ colors: [
165
+ "#faf5ff",
166
+ "#e9d5ff",
167
+ "#c084fc",
168
+ "#a855f7",
169
+ "#9333ea",
170
+ "#7e22ce",
171
+ "#6b21a8",
172
+ "#581c87"
173
+ ]
174
+ },
175
+ {
176
+ name: "Pink",
177
+ colors: [
178
+ "#fdf2f8",
179
+ "#fbcfe8",
180
+ "#f472b6",
181
+ "#ec4899",
182
+ "#db2777",
183
+ "#be185d",
184
+ "#9d174d",
185
+ "#831843"
186
+ ]
187
+ },
188
+ {
189
+ name: "Rose",
190
+ colors: [
191
+ "#fff1f2",
192
+ "#fecdd3",
193
+ "#fb7185",
194
+ "#f43f5e",
195
+ "#e11d48",
196
+ "#be123c",
197
+ "#9f1239",
198
+ "#881337"
199
+ ]
200
+ },
201
+ {
202
+ name: "Neutral",
203
+ colors: [
204
+ "#fafafa",
205
+ "#f5f5f5",
206
+ "#e5e5e5",
207
+ "#d4d4d4",
208
+ "#a3a3a3",
209
+ "#737373",
210
+ "#525252",
211
+ "#404040",
212
+ "#262626",
213
+ "#171717",
214
+ "#0a0a0a"
215
+ ]
216
+ }
217
+ ];
218
+
219
+ // src/components/color-picker/color-picker.style.ts
220
+ import { StyleSheet } from "react-native";
221
+ var styles = StyleSheet.create({
222
+ sheetContent: {
223
+ flex: 1,
224
+ paddingBottom: 24
225
+ },
226
+ header: {
227
+ paddingHorizontal: 20,
228
+ paddingTop: 4,
229
+ paddingBottom: 16,
230
+ flexDirection: "row",
231
+ alignItems: "center",
232
+ justifyContent: "space-between"
233
+ },
234
+ sheetTitle: {
235
+ fontSize: 16,
236
+ fontWeight: "600"
237
+ },
238
+ selectedPreview: {
239
+ flexDirection: "row",
240
+ alignItems: "center",
241
+ gap: 8
242
+ },
243
+ previewSwatch: {
244
+ width: 28,
245
+ height: 28,
246
+ borderRadius: 14,
247
+ borderWidth: 2
248
+ },
249
+ hexLabel: {
250
+ fontSize: 13,
251
+ fontWeight: "500",
252
+ letterSpacing: 0.5
253
+ },
254
+ groupContainer: {
255
+ marginBottom: 16,
256
+ paddingHorizontal: 20
257
+ },
258
+ groupName: {
259
+ fontSize: 13,
260
+ fontWeight: "500",
261
+ marginBottom: 8
262
+ },
263
+ swatchRow: {
264
+ flexDirection: "row",
265
+ flexWrap: "wrap",
266
+ gap: 8
267
+ },
268
+ triggerSwatch: {
269
+ width: 22,
270
+ height: 22,
271
+ borderRadius: 4,
272
+ borderWidth: 1
273
+ }
274
+ });
275
+
276
+ // src/components/color-picker/color-picker.tsx
277
+ var Swatch = ({
278
+ color,
279
+ size,
280
+ isSelected,
281
+ onSelect,
282
+ borderColor
283
+ }) => /* @__PURE__ */ React.createElement(
284
+ Pressable,
285
+ {
286
+ onPress: () => onSelect(color),
287
+ accessibilityRole: "button",
288
+ accessibilityLabel: color,
289
+ accessibilityState: { selected: isSelected },
290
+ style: [
291
+ {
292
+ width: size,
293
+ height: size,
294
+ borderRadius: 6,
295
+ backgroundColor: color,
296
+ borderWidth: isSelected ? 3 : 1,
297
+ borderColor: isSelected ? borderColor : withOpacity(borderColor, 0.15)
298
+ }
299
+ ]
300
+ }
301
+ );
302
+ var ColorGroupSection = ({
303
+ group,
304
+ selectedColor,
305
+ swatchSize,
306
+ themeMain,
307
+ foreground,
308
+ onSelect
309
+ }) => /* @__PURE__ */ React.createElement(View, { style: styles.groupContainer }, /* @__PURE__ */ React.createElement(Text, { style: [styles.groupName, { color: withOpacity(foreground, 0.6) }] }, group.name), /* @__PURE__ */ React.createElement(View, { style: styles.swatchRow }, group.colors.map((color) => /* @__PURE__ */ React.createElement(
310
+ Swatch,
311
+ {
312
+ key: color,
313
+ color,
314
+ size: swatchSize,
315
+ isSelected: color === selectedColor,
316
+ onSelect,
317
+ borderColor: color === selectedColor ? themeMain : foreground
318
+ }
319
+ ))));
320
+ var ColorPicker = ({
321
+ value,
322
+ placeholder = "Pick a color...",
323
+ label,
324
+ labelPlacement = "outside",
325
+ description,
326
+ errorMessage,
327
+ colorGroups = defaultColorGroups,
328
+ sheetTitle = "Pick a color",
329
+ themeColor = "primary",
330
+ variant = "flat",
331
+ size = "md",
332
+ radius = "md",
333
+ isOpened,
334
+ isDisabled = false,
335
+ isInvalid = false,
336
+ fullWidth = true,
337
+ sheetStyle,
338
+ swatchSize = 28,
339
+ onColorChange,
340
+ onOpenChange,
341
+ onClose
342
+ }) => {
343
+ const [isOpen, setIsOpen] = useState(isOpened ?? false);
344
+ const theme = useXUITheme();
345
+ const sheetBackground = theme.mode === "dark" ? theme.colors.background : "#ffffff";
346
+ useEffect(() => {
347
+ if (isOpened !== void 0) {
348
+ setIsOpen(isOpened);
349
+ }
350
+ }, [isOpened]);
351
+ const handleOpen = () => {
352
+ if (isDisabled) return;
353
+ setIsOpen(true);
354
+ onOpenChange?.(true);
355
+ };
356
+ const handleClose = () => {
357
+ setIsOpen(false);
358
+ onOpenChange?.(false);
359
+ onClose?.();
360
+ };
361
+ const handleSelect = (color) => {
362
+ onColorChange?.(color);
363
+ handleClose();
364
+ };
365
+ const triggerColor = value;
366
+ const foreground = theme.colors.foreground;
367
+ const themeMain = theme.colors[themeColor]?.main ?? foreground;
368
+ const triggerEndContent = /* @__PURE__ */ React.createElement(
369
+ View,
370
+ {
371
+ style: [
372
+ styles.triggerSwatch,
373
+ {
374
+ backgroundColor: triggerColor ?? "transparent",
375
+ borderColor: triggerColor ? withOpacity(foreground, 0.2) : withOpacity(foreground, 0.15),
376
+ borderStyle: triggerColor ? "solid" : "dashed"
377
+ }
378
+ ]
379
+ }
380
+ );
381
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
382
+ InputTrigger,
383
+ {
384
+ value: value ? "" : void 0,
385
+ placeholder,
386
+ label,
387
+ labelPlacement,
388
+ description,
389
+ errorMessage,
390
+ themeColor,
391
+ variant,
392
+ size,
393
+ radius,
394
+ isDisabled,
395
+ isInvalid,
396
+ fullWidth,
397
+ startContent: triggerEndContent,
398
+ endContent: value ? /* @__PURE__ */ React.createElement(
399
+ Text,
400
+ {
401
+ style: [
402
+ {
403
+ fontSize: 13,
404
+ fontWeight: "500",
405
+ letterSpacing: 0.5,
406
+ color: withOpacity(foreground, 0.6)
407
+ }
408
+ ]
409
+ },
410
+ value.toUpperCase()
411
+ ) : void 0,
412
+ onPress: handleOpen
413
+ }
414
+ ), /* @__PURE__ */ React.createElement(
415
+ BottomSheet,
416
+ {
417
+ isOpen,
418
+ snapPoints: [0.75],
419
+ themeColor,
420
+ onClose: handleClose,
421
+ style: { backgroundColor: sheetBackground, ...sheetStyle }
422
+ },
423
+ /* @__PURE__ */ React.createElement(View, { style: styles.sheetContent }, /* @__PURE__ */ React.createElement(View, { style: styles.header }, /* @__PURE__ */ React.createElement(Text, { style: [styles.sheetTitle, { color: foreground }] }, sheetTitle), value && /* @__PURE__ */ React.createElement(View, { style: styles.selectedPreview }, /* @__PURE__ */ React.createElement(
424
+ View,
425
+ {
426
+ style: [
427
+ styles.previewSwatch,
428
+ {
429
+ backgroundColor: value,
430
+ borderColor: withOpacity(foreground, 0.2)
431
+ }
432
+ ]
433
+ }
434
+ ), /* @__PURE__ */ React.createElement(
435
+ Text,
436
+ {
437
+ style: [
438
+ styles.hexLabel,
439
+ { color: withOpacity(foreground, 0.7) }
440
+ ]
441
+ },
442
+ value.toUpperCase()
443
+ ))), /* @__PURE__ */ React.createElement(ScrollView, { showsVerticalScrollIndicator: false }, colorGroups.map((group) => /* @__PURE__ */ React.createElement(
444
+ ColorGroupSection,
445
+ {
446
+ key: group.name,
447
+ group,
448
+ selectedColor: value,
449
+ swatchSize,
450
+ themeMain,
451
+ foreground,
452
+ onSelect: handleSelect
453
+ }
454
+ ))))
455
+ ));
456
+ };
457
+ export {
458
+ ColorPicker,
459
+ defaultColorGroups
460
+ };
@@ -0,0 +1,8 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+ var _chunk2ANGPYCPcjs = require('../chunk-2ANGPYCP.cjs');
4
+ require('../chunk-HSPTLUFA.cjs');
5
+ require('../chunk-OQ2BLOOG.cjs');
6
+
7
+
8
+ exports.InputTrigger = _chunk2ANGPYCPcjs.InputTrigger;
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ import { I as InputTriggerProps } from '../input-trigger.type-BL70fHE9.cjs';
3
+ export { e as InputTriggerCustomAppearance, a as InputTriggerEvents, d as InputTriggerLabelPlacement, c as InputTriggerSize, b as InputTriggerVariant } from '../input-trigger.type-BL70fHE9.cjs';
4
+ import 'react-native';
5
+ import '../index-DyU3sW3_.cjs';
6
+
7
+ declare const InputTrigger: React.FC<InputTriggerProps>;
8
+
9
+ export { InputTrigger, InputTriggerProps };
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ import { I as InputTriggerProps } from '../input-trigger.type-BODYStHk.js';
3
+ export { e as InputTriggerCustomAppearance, a as InputTriggerEvents, d as InputTriggerLabelPlacement, c as InputTriggerSize, b as InputTriggerVariant } from '../input-trigger.type-BODYStHk.js';
4
+ import 'react-native';
5
+ import '../index-DyU3sW3_.js';
6
+
7
+ declare const InputTrigger: React.FC<InputTriggerProps>;
8
+
9
+ export { InputTrigger, InputTriggerProps };
@@ -0,0 +1,8 @@
1
+ import {
2
+ InputTrigger
3
+ } from "../chunk-E4DOPNVW.js";
4
+ import "../chunk-DXXNBF5P.js";
5
+ import "../chunk-LTKYHG5V.js";
6
+ export {
7
+ InputTrigger
8
+ };
@@ -0,0 +1,97 @@
1
+ import { ReactNode } from 'react';
2
+ import { StyleProp, ViewStyle, TextStyle } from 'react-native';
3
+ import { T as ThemeColor, R as Radius } from './index-DyU3sW3_.cjs';
4
+
5
+ type InputTriggerVariant = 'flat' | 'faded' | 'bordered' | 'underlined';
6
+ type InputTriggerSize = 'sm' | 'md' | 'lg';
7
+ type InputTriggerLabelPlacement = 'outside' | 'inside';
8
+ type InputTriggerCustomAppearance = {
9
+ container?: StyleProp<ViewStyle>;
10
+ inputContainer?: StyleProp<ViewStyle>;
11
+ inputWrapper?: StyleProp<ViewStyle>;
12
+ label?: StyleProp<TextStyle>;
13
+ content?: StyleProp<TextStyle>;
14
+ helperText?: StyleProp<TextStyle>;
15
+ };
16
+ type InputTriggerProps = {
17
+ /**
18
+ * Value displayed inside the trigger (acts as placeholder when no value).
19
+ */
20
+ value?: ReactNode;
21
+ /**
22
+ * Placeholder text shown when no value is set.
23
+ */
24
+ placeholder?: string;
25
+ /**
26
+ * Label displayed above or inside the trigger.
27
+ */
28
+ label?: ReactNode;
29
+ /**
30
+ * Position of the label relative to the trigger.
31
+ * @default 'outside'
32
+ */
33
+ labelPlacement?: InputTriggerLabelPlacement;
34
+ /**
35
+ * Helper text displayed below the trigger.
36
+ */
37
+ description?: ReactNode;
38
+ /**
39
+ * Error message displayed when isInvalid is true.
40
+ */
41
+ errorMessage?: ReactNode;
42
+ /**
43
+ * Content rendered at the start of the trigger.
44
+ */
45
+ startContent?: ReactNode;
46
+ /**
47
+ * Content rendered at the end of the trigger.
48
+ */
49
+ endContent?: ReactNode;
50
+ /**
51
+ * Theme color for focus and active states.
52
+ * @default 'primary'
53
+ */
54
+ themeColor?: ThemeColor;
55
+ /**
56
+ * Visual style variant.
57
+ * @default 'flat'
58
+ */
59
+ variant?: InputTriggerVariant;
60
+ /**
61
+ * Size of the trigger.
62
+ * @default 'md'
63
+ */
64
+ size?: InputTriggerSize;
65
+ /**
66
+ * Border radius of the trigger.
67
+ * @default 'md'
68
+ */
69
+ radius?: Radius;
70
+ /**
71
+ * Whether the trigger is disabled.
72
+ * @default false
73
+ */
74
+ isDisabled?: boolean;
75
+ /**
76
+ * Whether the trigger is in an invalid state.
77
+ * @default false
78
+ */
79
+ isInvalid?: boolean;
80
+ /**
81
+ * Whether the component takes the full available width.
82
+ * @default true
83
+ */
84
+ fullWidth?: boolean;
85
+ /**
86
+ * Custom style overrides for trigger parts.
87
+ */
88
+ customAppearance?: InputTriggerCustomAppearance;
89
+ } & InputTriggerEvents;
90
+ type InputTriggerEvents = {
91
+ /**
92
+ * Called when the trigger is pressed.
93
+ */
94
+ onPress?: () => void;
95
+ };
96
+
97
+ export type { InputTriggerProps as I, InputTriggerEvents as a, InputTriggerVariant as b, InputTriggerSize as c, InputTriggerLabelPlacement as d, InputTriggerCustomAppearance as e };
@@ -0,0 +1,97 @@
1
+ import { ReactNode } from 'react';
2
+ import { StyleProp, ViewStyle, TextStyle } from 'react-native';
3
+ import { T as ThemeColor, R as Radius } from './index-DyU3sW3_.js';
4
+
5
+ type InputTriggerVariant = 'flat' | 'faded' | 'bordered' | 'underlined';
6
+ type InputTriggerSize = 'sm' | 'md' | 'lg';
7
+ type InputTriggerLabelPlacement = 'outside' | 'inside';
8
+ type InputTriggerCustomAppearance = {
9
+ container?: StyleProp<ViewStyle>;
10
+ inputContainer?: StyleProp<ViewStyle>;
11
+ inputWrapper?: StyleProp<ViewStyle>;
12
+ label?: StyleProp<TextStyle>;
13
+ content?: StyleProp<TextStyle>;
14
+ helperText?: StyleProp<TextStyle>;
15
+ };
16
+ type InputTriggerProps = {
17
+ /**
18
+ * Value displayed inside the trigger (acts as placeholder when no value).
19
+ */
20
+ value?: ReactNode;
21
+ /**
22
+ * Placeholder text shown when no value is set.
23
+ */
24
+ placeholder?: string;
25
+ /**
26
+ * Label displayed above or inside the trigger.
27
+ */
28
+ label?: ReactNode;
29
+ /**
30
+ * Position of the label relative to the trigger.
31
+ * @default 'outside'
32
+ */
33
+ labelPlacement?: InputTriggerLabelPlacement;
34
+ /**
35
+ * Helper text displayed below the trigger.
36
+ */
37
+ description?: ReactNode;
38
+ /**
39
+ * Error message displayed when isInvalid is true.
40
+ */
41
+ errorMessage?: ReactNode;
42
+ /**
43
+ * Content rendered at the start of the trigger.
44
+ */
45
+ startContent?: ReactNode;
46
+ /**
47
+ * Content rendered at the end of the trigger.
48
+ */
49
+ endContent?: ReactNode;
50
+ /**
51
+ * Theme color for focus and active states.
52
+ * @default 'primary'
53
+ */
54
+ themeColor?: ThemeColor;
55
+ /**
56
+ * Visual style variant.
57
+ * @default 'flat'
58
+ */
59
+ variant?: InputTriggerVariant;
60
+ /**
61
+ * Size of the trigger.
62
+ * @default 'md'
63
+ */
64
+ size?: InputTriggerSize;
65
+ /**
66
+ * Border radius of the trigger.
67
+ * @default 'md'
68
+ */
69
+ radius?: Radius;
70
+ /**
71
+ * Whether the trigger is disabled.
72
+ * @default false
73
+ */
74
+ isDisabled?: boolean;
75
+ /**
76
+ * Whether the trigger is in an invalid state.
77
+ * @default false
78
+ */
79
+ isInvalid?: boolean;
80
+ /**
81
+ * Whether the component takes the full available width.
82
+ * @default true
83
+ */
84
+ fullWidth?: boolean;
85
+ /**
86
+ * Custom style overrides for trigger parts.
87
+ */
88
+ customAppearance?: InputTriggerCustomAppearance;
89
+ } & InputTriggerEvents;
90
+ type InputTriggerEvents = {
91
+ /**
92
+ * Called when the trigger is pressed.
93
+ */
94
+ onPress?: () => void;
95
+ };
96
+
97
+ export type { InputTriggerProps as I, InputTriggerEvents as a, InputTriggerVariant as b, InputTriggerSize as c, InputTriggerLabelPlacement as d, InputTriggerCustomAppearance as e };