@xaui/native 0.0.31 → 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.
Files changed (42) hide show
  1. package/README.md +4 -0
  2. package/dist/app-bar/index.cjs +4 -1
  3. package/dist/app-bar/index.js +4 -1
  4. package/dist/bottom-sheet/index.cjs +4 -3
  5. package/dist/bottom-sheet/index.js +2 -1
  6. package/dist/chunk-2ANGPYCP.cjs +308 -0
  7. package/dist/chunk-DECMUMCI.js +0 -0
  8. package/dist/chunk-E4DOPNVW.js +308 -0
  9. package/dist/chunk-EUQDGTST.cjs +1 -0
  10. package/dist/color-picker/index.cjs +460 -0
  11. package/dist/color-picker/index.d.cts +124 -0
  12. package/dist/color-picker/index.d.ts +124 -0
  13. package/dist/color-picker/index.js +460 -0
  14. package/dist/dialog/index.cjs +381 -0
  15. package/dist/dialog/index.d.cts +151 -0
  16. package/dist/dialog/index.d.ts +151 -0
  17. package/dist/dialog/index.js +381 -0
  18. package/dist/index-DyU3sW3_.d.cts +4 -0
  19. package/dist/index-DyU3sW3_.d.ts +4 -0
  20. package/dist/input-trigger/index.cjs +8 -0
  21. package/dist/input-trigger/index.d.cts +9 -0
  22. package/dist/input-trigger/index.d.ts +9 -0
  23. package/dist/input-trigger/index.js +8 -0
  24. package/dist/input-trigger.type-BL70fHE9.d.cts +97 -0
  25. package/dist/input-trigger.type-BODYStHk.d.ts +97 -0
  26. package/dist/picker/index.cjs +250 -0
  27. package/dist/picker/index.d.cts +121 -0
  28. package/dist/picker/index.d.ts +121 -0
  29. package/dist/picker/index.js +250 -0
  30. package/dist/snackbar/index.d.cts +1 -2
  31. package/dist/snackbar/index.d.ts +1 -2
  32. package/dist/snippet/index.cjs +282 -0
  33. package/dist/snippet/index.d.cts +90 -0
  34. package/dist/snippet/index.d.ts +90 -0
  35. package/dist/snippet/index.js +282 -0
  36. package/dist/timepicker/index.cjs +4 -3
  37. package/dist/timepicker/index.js +2 -1
  38. package/dist/toolbar/index.cjs +24 -17
  39. package/dist/toolbar/index.js +25 -18
  40. package/package.json +26 -1
  41. /package/dist/{chunk-HC2SSHNU.js → chunk-ED22WCCI.js} +0 -0
  42. /package/dist/{chunk-XFPPR2VB.cjs → chunk-RVR42THG.cjs} +0 -0
@@ -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
+ };