@vellira-ui/react-native 2.25.1 → 2.26.1
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 +21 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +675 -273
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -66,7 +66,6 @@ function useThemeStyles(createStyles25) {
|
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
// src/components/Dropdown/Content/DropdownContent.styles.ts
|
|
69
|
-
import { overlay } from "@vellira-ui/tokens";
|
|
70
69
|
import { StyleSheet } from "react-native";
|
|
71
70
|
var createStyles = (theme) => StyleSheet.create({
|
|
72
71
|
modalRoot: {
|
|
@@ -75,7 +74,7 @@ var createStyles = (theme) => StyleSheet.create({
|
|
|
75
74
|
},
|
|
76
75
|
backdrop: {
|
|
77
76
|
...StyleSheet.absoluteFill,
|
|
78
|
-
backgroundColor: overlay.backdrop
|
|
77
|
+
backgroundColor: theme.semantic.overlay.backdrop
|
|
79
78
|
},
|
|
80
79
|
menu: {
|
|
81
80
|
maxHeight: "50%",
|
|
@@ -85,7 +84,15 @@ var createStyles = (theme) => StyleSheet.create({
|
|
|
85
84
|
borderColor: theme.components.dropdown.content.border,
|
|
86
85
|
borderTopLeftRadius: theme.tokens.radius.lg,
|
|
87
86
|
borderTopRightRadius: theme.tokens.radius.lg,
|
|
88
|
-
borderWidth: 1
|
|
87
|
+
borderWidth: 1,
|
|
88
|
+
shadowColor: "#000000",
|
|
89
|
+
shadowOffset: {
|
|
90
|
+
width: 0,
|
|
91
|
+
height: -4
|
|
92
|
+
},
|
|
93
|
+
shadowOpacity: 0.24,
|
|
94
|
+
shadowRadius: 16,
|
|
95
|
+
elevation: 12
|
|
89
96
|
}
|
|
90
97
|
});
|
|
91
98
|
|
|
@@ -94,7 +101,9 @@ import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
|
94
101
|
function DropdownContent({
|
|
95
102
|
isOpen,
|
|
96
103
|
children,
|
|
97
|
-
onClose
|
|
104
|
+
onClose,
|
|
105
|
+
contentStyle,
|
|
106
|
+
accessibilityLabel
|
|
98
107
|
}) {
|
|
99
108
|
const styles = useThemeStyles(createStyles);
|
|
100
109
|
return /* @__PURE__ */ jsx2(
|
|
@@ -114,7 +123,15 @@ function DropdownContent({
|
|
|
114
123
|
onPress: onClose
|
|
115
124
|
}
|
|
116
125
|
),
|
|
117
|
-
/* @__PURE__ */ jsx2(
|
|
126
|
+
/* @__PURE__ */ jsx2(
|
|
127
|
+
View,
|
|
128
|
+
{
|
|
129
|
+
accessibilityRole: "menu",
|
|
130
|
+
accessibilityLabel,
|
|
131
|
+
style: [styles.menu, contentStyle],
|
|
132
|
+
children
|
|
133
|
+
}
|
|
134
|
+
)
|
|
118
135
|
] })
|
|
119
136
|
}
|
|
120
137
|
);
|
|
@@ -122,7 +139,8 @@ function DropdownContent({
|
|
|
122
139
|
DropdownContent.displayName = "DropdownContent";
|
|
123
140
|
|
|
124
141
|
// src/components/Dropdown/Dropdown.tsx
|
|
125
|
-
import {
|
|
142
|
+
import { useCallback, useMemo as useMemo3 } from "react";
|
|
143
|
+
import { useDropdown } from "@vellira-ui/core";
|
|
126
144
|
import { View as View4 } from "react-native";
|
|
127
145
|
|
|
128
146
|
// src/components/Dropdown/Group/DropdownGroup.tsx
|
|
@@ -146,11 +164,12 @@ var createStyles2 = (theme) => StyleSheet2.create({
|
|
|
146
164
|
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
147
165
|
function DropdownGroup({ label }) {
|
|
148
166
|
const styles = useThemeStyles(createStyles2);
|
|
149
|
-
return /* @__PURE__ */ jsx3(Text, { style: styles.groupLabel, children: label });
|
|
167
|
+
return /* @__PURE__ */ jsx3(Text, { accessibilityRole: "header", style: styles.groupLabel, children: label });
|
|
150
168
|
}
|
|
151
169
|
DropdownGroup.displayName = "DropdownGroup";
|
|
152
170
|
|
|
153
171
|
// src/components/Dropdown/Item/DropdownItem.tsx
|
|
172
|
+
import { cloneElement, isValidElement } from "react";
|
|
154
173
|
import { Pressable as Pressable2, Text as Text2 } from "react-native";
|
|
155
174
|
|
|
156
175
|
// src/components/Dropdown/Item/DropdownItem.styles.ts
|
|
@@ -167,13 +186,16 @@ var createStyles3 = (theme) => StyleSheet3.create({
|
|
|
167
186
|
borderRadius: theme.tokens.radius.sm
|
|
168
187
|
},
|
|
169
188
|
itemPressed: {
|
|
170
|
-
backgroundColor: theme.components.dropdown.item.
|
|
189
|
+
backgroundColor: theme.components.dropdown.item.pressed.bg
|
|
171
190
|
},
|
|
172
191
|
itemDisabled: {
|
|
173
192
|
backgroundColor: theme.components.dropdown.item.disabled.bg
|
|
174
193
|
},
|
|
194
|
+
itemDanger: {
|
|
195
|
+
backgroundColor: theme.components.dropdown.item.danger.default.bg
|
|
196
|
+
},
|
|
175
197
|
itemDangerPressed: {
|
|
176
|
-
backgroundColor: theme.components.dropdown.item.danger.
|
|
198
|
+
backgroundColor: theme.components.dropdown.item.danger.active.bg
|
|
177
199
|
},
|
|
178
200
|
itemText: {
|
|
179
201
|
flex: 1,
|
|
@@ -181,18 +203,24 @@ var createStyles3 = (theme) => StyleSheet3.create({
|
|
|
181
203
|
color: theme.components.dropdown.item.default.fg,
|
|
182
204
|
fontFamily: theme.tokens.typography.family.regular,
|
|
183
205
|
fontSize: theme.tokens.typography.size.md,
|
|
184
|
-
lineHeight:
|
|
206
|
+
lineHeight: theme.tokens.typography.lineHeight.md
|
|
207
|
+
},
|
|
208
|
+
itemTextPressed: {
|
|
209
|
+
color: theme.components.dropdown.item.pressed.fg
|
|
185
210
|
},
|
|
186
211
|
itemTextDisabled: {
|
|
187
212
|
color: theme.components.dropdown.item.disabled.fg
|
|
188
213
|
},
|
|
189
|
-
|
|
214
|
+
itemTextDanger: {
|
|
190
215
|
color: theme.components.dropdown.item.danger.default.fg
|
|
216
|
+
},
|
|
217
|
+
itemTextDangerPressed: {
|
|
218
|
+
color: theme.components.dropdown.item.danger.active.fg
|
|
191
219
|
}
|
|
192
220
|
});
|
|
193
221
|
|
|
194
222
|
// src/components/Dropdown/Item/DropdownItem.tsx
|
|
195
|
-
import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
223
|
+
import { Fragment, jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
196
224
|
function DropdownItem({
|
|
197
225
|
label,
|
|
198
226
|
value,
|
|
@@ -204,13 +232,39 @@ function DropdownItem({
|
|
|
204
232
|
textStyle,
|
|
205
233
|
onSelect
|
|
206
234
|
}) {
|
|
235
|
+
const { theme } = useTheme();
|
|
207
236
|
const styles = useThemeStyles(createStyles3);
|
|
208
|
-
|
|
237
|
+
const renderColoredNode = (node, color) => {
|
|
238
|
+
if (!isValidElement(node)) return node;
|
|
239
|
+
return cloneElement(node, { color });
|
|
240
|
+
};
|
|
241
|
+
const getContentColor = (pressed) => {
|
|
242
|
+
if (disabled) {
|
|
243
|
+
return theme.components.dropdown.item.disabled.fg;
|
|
244
|
+
}
|
|
245
|
+
if (danger) {
|
|
246
|
+
return pressed ? theme.components.dropdown.item.danger.active.fg : theme.components.dropdown.item.danger.default.fg;
|
|
247
|
+
}
|
|
248
|
+
return pressed ? theme.components.dropdown.item.pressed.fg : theme.components.dropdown.item.default.fg;
|
|
249
|
+
};
|
|
250
|
+
const getBackgroundColor = (pressed) => {
|
|
251
|
+
if (disabled) {
|
|
252
|
+
return theme.components.dropdown.item.disabled.bg;
|
|
253
|
+
}
|
|
254
|
+
if (danger) {
|
|
255
|
+
return pressed ? theme.components.dropdown.item.danger.active.bg : theme.components.dropdown.item.danger.default.bg;
|
|
256
|
+
}
|
|
257
|
+
return pressed ? theme.components.dropdown.item.pressed.bg : theme.components.dropdown.item.default.bg;
|
|
258
|
+
};
|
|
259
|
+
const accessibilityLabel = typeof label === "string" ? label : value;
|
|
260
|
+
const numberOfLines = textWrap === "wrap" ? void 0 : 1;
|
|
261
|
+
const ellipsizeMode = textWrap === "truncate" ? "tail" : "clip";
|
|
262
|
+
return /* @__PURE__ */ jsx4(
|
|
209
263
|
Pressable2,
|
|
210
264
|
{
|
|
211
265
|
disabled,
|
|
212
266
|
accessibilityRole: "menuitem",
|
|
213
|
-
accessibilityLabel
|
|
267
|
+
accessibilityLabel,
|
|
214
268
|
accessibilityState: { disabled },
|
|
215
269
|
onPress: () => {
|
|
216
270
|
if (disabled) return;
|
|
@@ -218,27 +272,26 @@ function DropdownItem({
|
|
|
218
272
|
},
|
|
219
273
|
style: ({ pressed }) => [
|
|
220
274
|
styles.item,
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
275
|
+
{
|
|
276
|
+
backgroundColor: getBackgroundColor(pressed)
|
|
277
|
+
},
|
|
224
278
|
itemStyle
|
|
225
279
|
],
|
|
226
|
-
children:
|
|
227
|
-
|
|
228
|
-
/* @__PURE__ */
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
]
|
|
280
|
+
children: ({ pressed }) => {
|
|
281
|
+
const contentColor = getContentColor(pressed);
|
|
282
|
+
return /* @__PURE__ */ jsxs2(Fragment, { children: [
|
|
283
|
+
icon ? renderColoredNode(icon, contentColor) : null,
|
|
284
|
+
/* @__PURE__ */ jsx4(
|
|
285
|
+
Text2,
|
|
286
|
+
{
|
|
287
|
+
numberOfLines,
|
|
288
|
+
ellipsizeMode,
|
|
289
|
+
style: [styles.itemText, { color: contentColor }, textStyle],
|
|
290
|
+
children: label
|
|
291
|
+
}
|
|
292
|
+
)
|
|
293
|
+
] });
|
|
294
|
+
}
|
|
242
295
|
}
|
|
243
296
|
);
|
|
244
297
|
}
|
|
@@ -266,8 +319,8 @@ DropdownSeparator.displayName = "DropdownSeparator";
|
|
|
266
319
|
|
|
267
320
|
// src/components/Dropdown/Trigger/DropdownTrigger.tsx
|
|
268
321
|
import {
|
|
269
|
-
cloneElement,
|
|
270
|
-
isValidElement,
|
|
322
|
+
cloneElement as cloneElement2,
|
|
323
|
+
isValidElement as isValidElement2,
|
|
271
324
|
useEffect,
|
|
272
325
|
useRef,
|
|
273
326
|
useState
|
|
@@ -279,41 +332,88 @@ import { Animated, Pressable as Pressable3, Text as Text3, View as View3 } from
|
|
|
279
332
|
import { StyleSheet as StyleSheet5 } from "react-native";
|
|
280
333
|
var createStyles5 = (theme) => StyleSheet5.create({
|
|
281
334
|
trigger: {
|
|
282
|
-
minWidth: 32,
|
|
283
|
-
minHeight: 32,
|
|
284
335
|
alignItems: "center",
|
|
285
|
-
justifyContent: "
|
|
336
|
+
justifyContent: "center",
|
|
286
337
|
flexDirection: "row",
|
|
287
338
|
gap: theme.tokens.spacing[2],
|
|
288
|
-
padding: theme.tokens.spacing[2],
|
|
289
339
|
backgroundColor: theme.components.dropdown.trigger.default.bg,
|
|
290
340
|
borderColor: theme.components.dropdown.trigger.default.border,
|
|
291
341
|
borderRadius: theme.tokens.radius.lg,
|
|
292
342
|
borderWidth: 2
|
|
293
343
|
},
|
|
344
|
+
sm: {
|
|
345
|
+
minWidth: 36,
|
|
346
|
+
minHeight: 36,
|
|
347
|
+
paddingHorizontal: theme.tokens.spacing[3],
|
|
348
|
+
paddingVertical: theme.tokens.spacing[2]
|
|
349
|
+
},
|
|
350
|
+
md: {
|
|
351
|
+
minWidth: 44,
|
|
352
|
+
minHeight: 44,
|
|
353
|
+
paddingHorizontal: theme.tokens.spacing[4],
|
|
354
|
+
paddingVertical: theme.tokens.spacing[3]
|
|
355
|
+
},
|
|
356
|
+
lg: {
|
|
357
|
+
minWidth: 52,
|
|
358
|
+
minHeight: 52,
|
|
359
|
+
paddingHorizontal: theme.tokens.spacing[5],
|
|
360
|
+
paddingVertical: theme.tokens.spacing[4]
|
|
361
|
+
},
|
|
294
362
|
iconOnly: {
|
|
295
|
-
width: 42,
|
|
296
|
-
height: 42,
|
|
297
|
-
padding: theme.tokens.spacing[2],
|
|
298
363
|
borderRadius: theme.tokens.radius.full
|
|
299
364
|
},
|
|
365
|
+
smIconOnly: {
|
|
366
|
+
width: 36,
|
|
367
|
+
height: 36,
|
|
368
|
+
minWidth: 36,
|
|
369
|
+
minHeight: 36,
|
|
370
|
+
padding: 0
|
|
371
|
+
},
|
|
372
|
+
mdIconOnly: {
|
|
373
|
+
width: 44,
|
|
374
|
+
height: 44,
|
|
375
|
+
minWidth: 44,
|
|
376
|
+
minHeight: 44,
|
|
377
|
+
padding: 0
|
|
378
|
+
},
|
|
379
|
+
lgIconOnly: {
|
|
380
|
+
width: 52,
|
|
381
|
+
height: 52,
|
|
382
|
+
minWidth: 52,
|
|
383
|
+
minHeight: 52,
|
|
384
|
+
padding: 0
|
|
385
|
+
},
|
|
386
|
+
triggerPressed: {
|
|
387
|
+
backgroundColor: theme.components.dropdown.trigger.hover.bg,
|
|
388
|
+
borderColor: theme.components.dropdown.trigger.hover.border
|
|
389
|
+
},
|
|
300
390
|
triggerDisabled: {
|
|
301
391
|
backgroundColor: theme.components.dropdown.trigger.disabled.bg,
|
|
302
392
|
borderColor: theme.components.dropdown.trigger.disabled.border,
|
|
303
393
|
borderStyle: "dashed"
|
|
304
394
|
},
|
|
305
|
-
triggerPressed: {
|
|
306
|
-
backgroundColor: theme.components.dropdown.trigger.hover.bg
|
|
307
|
-
},
|
|
308
395
|
triggerText: {
|
|
309
396
|
color: theme.components.dropdown.trigger.default.fg,
|
|
310
|
-
fontFamily: theme.tokens.typography.family.regular
|
|
311
|
-
|
|
312
|
-
|
|
397
|
+
fontFamily: theme.tokens.typography.family.regular
|
|
398
|
+
},
|
|
399
|
+
triggerTextPressed: {
|
|
400
|
+
color: theme.components.dropdown.trigger.hover.fg
|
|
313
401
|
},
|
|
314
402
|
triggerTextDisabled: {
|
|
315
403
|
color: theme.components.dropdown.trigger.disabled.fg
|
|
316
404
|
},
|
|
405
|
+
textSm: {
|
|
406
|
+
fontSize: theme.tokens.typography.size.sm,
|
|
407
|
+
lineHeight: theme.tokens.typography.lineHeight.sm
|
|
408
|
+
},
|
|
409
|
+
textMd: {
|
|
410
|
+
fontSize: theme.tokens.typography.size.md,
|
|
411
|
+
lineHeight: theme.tokens.typography.lineHeight.md
|
|
412
|
+
},
|
|
413
|
+
textLg: {
|
|
414
|
+
fontSize: theme.tokens.typography.size.lg,
|
|
415
|
+
lineHeight: theme.tokens.typography.lineHeight.lg
|
|
416
|
+
},
|
|
317
417
|
icon: {
|
|
318
418
|
alignItems: "center",
|
|
319
419
|
justifyContent: "center"
|
|
@@ -334,13 +434,26 @@ function DropdownTrigger({
|
|
|
334
434
|
icon,
|
|
335
435
|
arrowIcon,
|
|
336
436
|
showArrow = true,
|
|
437
|
+
size = "md",
|
|
337
438
|
disabled = false,
|
|
338
439
|
isOpen,
|
|
339
440
|
triggerStyle,
|
|
441
|
+
accessibilityLabel,
|
|
442
|
+
accessibilityHint,
|
|
340
443
|
onPress
|
|
341
444
|
}) {
|
|
342
445
|
const { theme } = useTheme();
|
|
343
446
|
const styles = useThemeStyles(createStyles5);
|
|
447
|
+
const textSizeStyle = {
|
|
448
|
+
sm: styles.textSm,
|
|
449
|
+
md: styles.textMd,
|
|
450
|
+
lg: styles.textLg
|
|
451
|
+
}[size];
|
|
452
|
+
const iconOnlySizeStyle = {
|
|
453
|
+
sm: styles.smIconOnly,
|
|
454
|
+
md: styles.mdIconOnly,
|
|
455
|
+
lg: styles.lgIconOnly
|
|
456
|
+
}[size];
|
|
344
457
|
const hasIcon = Boolean(icon);
|
|
345
458
|
const isIconOnly = !trigger && hasIcon && !showArrow;
|
|
346
459
|
const [isPressed, setIsPressed] = useState(false);
|
|
@@ -364,6 +477,7 @@ function DropdownTrigger({
|
|
|
364
477
|
numberOfLines: 1,
|
|
365
478
|
style: [
|
|
366
479
|
styles.triggerText,
|
|
480
|
+
textSizeStyle,
|
|
367
481
|
{ color },
|
|
368
482
|
disabled && styles.triggerTextDisabled
|
|
369
483
|
],
|
|
@@ -371,8 +485,8 @@ function DropdownTrigger({
|
|
|
371
485
|
}
|
|
372
486
|
);
|
|
373
487
|
}
|
|
374
|
-
if (!
|
|
375
|
-
return
|
|
488
|
+
if (!isValidElement2(node)) return node;
|
|
489
|
+
return cloneElement2(node, { color });
|
|
376
490
|
};
|
|
377
491
|
const contentColor = disabled ? theme.components.dropdown.trigger.disabled.fg : isPressed ? theme.components.dropdown.trigger.hover.fg : theme.components.dropdown.trigger.default.fg;
|
|
378
492
|
const arrow = arrowIcon ? renderColoredNode(arrowIcon, contentColor) : /* @__PURE__ */ jsx6(ChevronDown, { width: 16, height: 16, color: contentColor });
|
|
@@ -382,16 +496,19 @@ function DropdownTrigger({
|
|
|
382
496
|
{
|
|
383
497
|
disabled,
|
|
384
498
|
accessibilityRole: "button",
|
|
385
|
-
accessibilityLabel: label,
|
|
499
|
+
accessibilityLabel: accessibilityLabel ?? (typeof label === "string" ? label : void 0),
|
|
500
|
+
accessibilityHint,
|
|
386
501
|
accessibilityState: { expanded: isOpen, disabled },
|
|
387
502
|
onPress,
|
|
388
503
|
onPressIn: () => setIsPressed(true),
|
|
389
504
|
onPressOut: () => setIsPressed(false),
|
|
390
505
|
style: [
|
|
391
506
|
styles.trigger,
|
|
507
|
+
styles[size],
|
|
508
|
+
isIconOnly && styles.iconOnly,
|
|
509
|
+
isIconOnly && iconOnlySizeStyle,
|
|
392
510
|
isPressed && !disabled && styles.triggerPressed,
|
|
393
511
|
disabled && styles.triggerDisabled,
|
|
394
|
-
isIconOnly && styles.iconOnly,
|
|
395
512
|
triggerStyle
|
|
396
513
|
],
|
|
397
514
|
children: [
|
|
@@ -402,6 +519,7 @@ function DropdownTrigger({
|
|
|
402
519
|
numberOfLines: 1,
|
|
403
520
|
style: [
|
|
404
521
|
styles.triggerText,
|
|
522
|
+
textSizeStyle,
|
|
405
523
|
{ color: contentColor },
|
|
406
524
|
disabled && styles.triggerTextDisabled
|
|
407
525
|
],
|
|
@@ -430,6 +548,7 @@ var createStyles6 = () => StyleSheet6.create({
|
|
|
430
548
|
});
|
|
431
549
|
|
|
432
550
|
// src/components/Dropdown/types.ts
|
|
551
|
+
var isMenuItem = (item) => item.type === void 0 || item.type === "item";
|
|
433
552
|
var isGroup = (item) => item.type === "group";
|
|
434
553
|
var isSeparator = (item) => item.type === "separator";
|
|
435
554
|
|
|
@@ -443,19 +562,48 @@ function Dropdown({
|
|
|
443
562
|
showArrow = true,
|
|
444
563
|
items,
|
|
445
564
|
onSelect,
|
|
565
|
+
open,
|
|
566
|
+
defaultOpen = false,
|
|
567
|
+
onOpenChange,
|
|
446
568
|
disabled = false,
|
|
569
|
+
size = "md",
|
|
447
570
|
style,
|
|
448
571
|
triggerStyle,
|
|
572
|
+
contentStyle,
|
|
449
573
|
itemStyle,
|
|
450
|
-
textStyle
|
|
574
|
+
textStyle,
|
|
575
|
+
accessibilityLabel,
|
|
576
|
+
accessibilityHint
|
|
451
577
|
}) {
|
|
452
578
|
const styles = useThemeStyles(createStyles6);
|
|
453
|
-
const
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
579
|
+
const menuAccessibilityLabel = useMemo3(() => {
|
|
580
|
+
if (accessibilityLabel) return accessibilityLabel;
|
|
581
|
+
return typeof label === "string" ? label : "Menu";
|
|
582
|
+
}, [accessibilityLabel, label]);
|
|
583
|
+
const navigableItems = useMemo3(
|
|
584
|
+
() => items.filter((item) => isMenuItem(item)),
|
|
585
|
+
[items]
|
|
586
|
+
);
|
|
587
|
+
const { isOpen, closeDropdown, toggleDropdown } = useDropdown({
|
|
588
|
+
items: navigableItems,
|
|
589
|
+
open,
|
|
590
|
+
defaultOpen,
|
|
591
|
+
disabled,
|
|
592
|
+
onOpenChange,
|
|
593
|
+
onSelect,
|
|
594
|
+
getItemValue: (item) => item.value,
|
|
595
|
+
getItemText: (item) => typeof item.label === "string" ? item.label : item.value
|
|
596
|
+
});
|
|
597
|
+
const handleSelect = useCallback(
|
|
598
|
+
(value) => {
|
|
599
|
+
onSelect?.(value);
|
|
600
|
+
closeDropdown();
|
|
601
|
+
},
|
|
602
|
+
[closeDropdown, onSelect]
|
|
603
|
+
);
|
|
604
|
+
const handleTriggerPress = useCallback(() => {
|
|
605
|
+
toggleDropdown();
|
|
606
|
+
}, [toggleDropdown]);
|
|
459
607
|
return /* @__PURE__ */ jsxs4(View4, { style: [styles.root, style], children: [
|
|
460
608
|
/* @__PURE__ */ jsx7(
|
|
461
609
|
DropdownTrigger,
|
|
@@ -467,48 +615,60 @@ function Dropdown({
|
|
|
467
615
|
showArrow,
|
|
468
616
|
disabled,
|
|
469
617
|
isOpen,
|
|
618
|
+
size,
|
|
470
619
|
triggerStyle,
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
}
|
|
620
|
+
accessibilityLabel,
|
|
621
|
+
accessibilityHint,
|
|
622
|
+
onPress: handleTriggerPress
|
|
475
623
|
}
|
|
476
624
|
),
|
|
477
|
-
/* @__PURE__ */ jsx7(
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
625
|
+
/* @__PURE__ */ jsx7(
|
|
626
|
+
DropdownContent,
|
|
627
|
+
{
|
|
628
|
+
isOpen,
|
|
629
|
+
onClose: closeDropdown,
|
|
630
|
+
contentStyle,
|
|
631
|
+
accessibilityLabel: menuAccessibilityLabel,
|
|
632
|
+
children: items.map((item, index) => {
|
|
633
|
+
if (isGroup(item)) {
|
|
634
|
+
return /* @__PURE__ */ jsx7(
|
|
635
|
+
DropdownGroup,
|
|
636
|
+
{
|
|
637
|
+
label: item.label
|
|
638
|
+
},
|
|
639
|
+
`group-${item.label}-${index}`
|
|
640
|
+
);
|
|
641
|
+
}
|
|
642
|
+
if (isSeparator(item)) {
|
|
643
|
+
return /* @__PURE__ */ jsx7(DropdownSeparator, {}, `separator-${index}`);
|
|
644
|
+
}
|
|
645
|
+
if (!isMenuItem(item)) {
|
|
646
|
+
return null;
|
|
647
|
+
}
|
|
648
|
+
return /* @__PURE__ */ jsx7(
|
|
649
|
+
DropdownItem,
|
|
650
|
+
{
|
|
651
|
+
label: item.label,
|
|
652
|
+
value: item.value,
|
|
653
|
+
icon: item.icon,
|
|
654
|
+
danger: item.danger,
|
|
655
|
+
disabled: item.disabled,
|
|
656
|
+
textWrap: item.textWrap,
|
|
657
|
+
itemStyle,
|
|
658
|
+
textStyle,
|
|
659
|
+
onSelect: handleSelect
|
|
660
|
+
},
|
|
661
|
+
`${item.value}-${index}`
|
|
662
|
+
);
|
|
663
|
+
})
|
|
489
664
|
}
|
|
490
|
-
|
|
491
|
-
DropdownItem,
|
|
492
|
-
{
|
|
493
|
-
label: item.label,
|
|
494
|
-
value: item.value,
|
|
495
|
-
icon: item.icon,
|
|
496
|
-
danger: item.danger,
|
|
497
|
-
disabled: item.disabled,
|
|
498
|
-
textWrap: item.textWrap,
|
|
499
|
-
itemStyle,
|
|
500
|
-
textStyle,
|
|
501
|
-
onSelect: handleSelect
|
|
502
|
-
},
|
|
503
|
-
item.value
|
|
504
|
-
);
|
|
505
|
-
}) })
|
|
665
|
+
)
|
|
506
666
|
] });
|
|
507
667
|
}
|
|
508
668
|
Dropdown.displayName = "Dropdown";
|
|
509
669
|
|
|
510
670
|
// src/components/Modal/Body/ModalBody.tsx
|
|
511
|
-
import { Children, cloneElement as
|
|
671
|
+
import { Children, cloneElement as cloneElement3, isValidElement as isValidElement3 } from "react";
|
|
512
672
|
import { Text as Text4, View as View5 } from "react-native";
|
|
513
673
|
|
|
514
674
|
// src/components/Modal/Body/ModalBody.styles.ts
|
|
@@ -522,12 +682,18 @@ var createStyles7 = (theme) => StyleSheet7.create({
|
|
|
522
682
|
fontFamily: theme.tokens.typography.family.regular,
|
|
523
683
|
fontSize: theme.tokens.typography.size.md,
|
|
524
684
|
lineHeight: theme.tokens.typography.lineHeight.md
|
|
685
|
+
},
|
|
686
|
+
description: {
|
|
687
|
+
color: theme.components.modal.description.fg,
|
|
688
|
+
fontFamily: theme.tokens.typography.family.regular,
|
|
689
|
+
fontSize: theme.tokens.typography.size.sm,
|
|
690
|
+
lineHeight: theme.tokens.typography.lineHeight.sm
|
|
525
691
|
}
|
|
526
692
|
});
|
|
527
693
|
|
|
528
694
|
// src/components/Modal/Body/ModalBody.tsx
|
|
529
695
|
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
530
|
-
var isTextElement = (child) =>
|
|
696
|
+
var isTextElement = (child) => isValidElement3(child) && child.type === Text4;
|
|
531
697
|
var renderBodyChildren = (children, textStyle) => Children.map(children, (child) => {
|
|
532
698
|
if (typeof child === "string" || typeof child === "number") {
|
|
533
699
|
return /* @__PURE__ */ jsx8(Text4, { style: textStyle, children: child });
|
|
@@ -535,7 +701,7 @@ var renderBodyChildren = (children, textStyle) => Children.map(children, (child)
|
|
|
535
701
|
if (!isTextElement(child)) {
|
|
536
702
|
return child;
|
|
537
703
|
}
|
|
538
|
-
return
|
|
704
|
+
return cloneElement3(child, {
|
|
539
705
|
style: [textStyle, child.props.style]
|
|
540
706
|
});
|
|
541
707
|
});
|
|
@@ -552,15 +718,15 @@ import { View as View6 } from "react-native";
|
|
|
552
718
|
import { StyleSheet as StyleSheet8 } from "react-native";
|
|
553
719
|
var createStyles8 = (theme) => StyleSheet8.create({
|
|
554
720
|
content: {
|
|
555
|
-
|
|
721
|
+
width: "100%",
|
|
556
722
|
maxWidth: 600,
|
|
557
723
|
maxHeight: "90%",
|
|
558
724
|
padding: theme.tokens.spacing[4],
|
|
725
|
+
gap: theme.tokens.spacing[4],
|
|
559
726
|
backgroundColor: theme.components.modal.content.bg,
|
|
560
727
|
borderColor: theme.components.modal.content.border,
|
|
561
728
|
borderRadius: theme.tokens.radius.lg,
|
|
562
729
|
borderWidth: 1,
|
|
563
|
-
gap: theme.tokens.spacing[4],
|
|
564
730
|
shadowColor: theme.tokens.shadows.lg.color,
|
|
565
731
|
shadowOffset: {
|
|
566
732
|
width: theme.tokens.shadows.lg.x,
|
|
@@ -627,23 +793,28 @@ var createStyles10 = (theme) => StyleSheet10.create({
|
|
|
627
793
|
flexDirection: "row",
|
|
628
794
|
gap: theme.tokens.spacing[3],
|
|
629
795
|
justifyContent: "space-between",
|
|
630
|
-
paddingBottom: theme.tokens.spacing[4]
|
|
631
|
-
backgroundColor: theme.components.modal.content.bg
|
|
796
|
+
paddingBottom: theme.tokens.spacing[4]
|
|
632
797
|
},
|
|
633
798
|
title: {
|
|
634
|
-
color: theme.components.modal.title.fg,
|
|
635
799
|
flex: 1,
|
|
800
|
+
color: theme.components.modal.title.fg,
|
|
636
801
|
fontFamily: theme.tokens.typography.family.semibold,
|
|
637
802
|
fontSize: theme.tokens.typography.size.lg,
|
|
638
803
|
lineHeight: theme.tokens.typography.lineHeight.md
|
|
639
804
|
},
|
|
640
805
|
closeButton: {
|
|
641
|
-
|
|
642
|
-
backgroundColor: theme.components.modal.closeButton.default.bg,
|
|
643
|
-
borderRadius: theme.tokens.radius.full,
|
|
806
|
+
width: 32,
|
|
644
807
|
height: 32,
|
|
808
|
+
alignItems: "center",
|
|
645
809
|
justifyContent: "center",
|
|
646
|
-
|
|
810
|
+
backgroundColor: theme.components.modal.closeButton.default.bg,
|
|
811
|
+
borderRadius: theme.tokens.radius.full
|
|
812
|
+
},
|
|
813
|
+
closeButtonPressed: {
|
|
814
|
+
backgroundColor: theme.components.modal.closeButton.hover.bg
|
|
815
|
+
},
|
|
816
|
+
closeButtonDisabled: {
|
|
817
|
+
backgroundColor: theme.components.modal.closeButton.disabled.bg
|
|
647
818
|
}
|
|
648
819
|
});
|
|
649
820
|
|
|
@@ -666,19 +837,19 @@ var ModalHeader = ({
|
|
|
666
837
|
accessibilityLabel: "Close modal",
|
|
667
838
|
onPress: onClose,
|
|
668
839
|
style: styles.closeButton,
|
|
669
|
-
children:
|
|
670
|
-
|
|
671
|
-
{
|
|
672
|
-
|
|
673
|
-
color: theme.components.modal.closeButton.default.fg
|
|
674
|
-
}
|
|
675
|
-
)
|
|
840
|
+
children: ({ pressed }) => {
|
|
841
|
+
const closeIconColor = pressed ? theme.components.modal.closeButton.hover.fg : theme.components.modal.closeButton.default.fg;
|
|
842
|
+
return /* @__PURE__ */ jsx11(Close, { size: 16, color: closeIconColor });
|
|
843
|
+
}
|
|
676
844
|
}
|
|
677
845
|
)
|
|
678
846
|
] });
|
|
679
847
|
};
|
|
680
848
|
ModalHeader.displayName = "ModalHeader";
|
|
681
849
|
|
|
850
|
+
// src/components/Modal/Modal.tsx
|
|
851
|
+
import { useModal } from "@vellira-ui/core";
|
|
852
|
+
|
|
682
853
|
// src/components/Modal/ModalOverlay.tsx
|
|
683
854
|
import { Modal as RNModal, Pressable as Pressable5, View as View9 } from "react-native";
|
|
684
855
|
|
|
@@ -741,12 +912,17 @@ var ModalRoot = ({
|
|
|
741
912
|
overlayStyle,
|
|
742
913
|
contentStyle
|
|
743
914
|
}) => {
|
|
744
|
-
|
|
915
|
+
const modal = useModal({
|
|
916
|
+
isOpen,
|
|
917
|
+
onClose,
|
|
918
|
+
closeOnBackdrop
|
|
919
|
+
});
|
|
920
|
+
return /* @__PURE__ */ jsx13(ModalContext_default.Provider, { value: { onClose: modal.onClose }, children: /* @__PURE__ */ jsx13(
|
|
745
921
|
ModalOverlay,
|
|
746
922
|
{
|
|
747
|
-
isOpen,
|
|
748
|
-
onClose,
|
|
749
|
-
closeOnBackdrop,
|
|
923
|
+
isOpen: modal.isOpen,
|
|
924
|
+
onClose: modal.onClose,
|
|
925
|
+
closeOnBackdrop: modal.closeOnBackdrop,
|
|
750
926
|
overlayStyle,
|
|
751
927
|
children: /* @__PURE__ */ jsx13(ModalContent, { style: contentStyle, children })
|
|
752
928
|
}
|
|
@@ -818,6 +994,9 @@ var createStyles12 = (theme) => StyleSheet12.create({
|
|
|
818
994
|
fontFamily: theme.tokens.typography.family.regular,
|
|
819
995
|
fontSize: theme.tokens.typography.size.sm,
|
|
820
996
|
lineHeight: theme.tokens.typography.lineHeight.sm
|
|
997
|
+
},
|
|
998
|
+
helperTextDisabled: {
|
|
999
|
+
color: theme.components.formField.disabled.helperTextFg
|
|
821
1000
|
}
|
|
822
1001
|
});
|
|
823
1002
|
|
|
@@ -890,7 +1069,11 @@ function FormField({
|
|
|
890
1069
|
Text6,
|
|
891
1070
|
{
|
|
892
1071
|
accessibilityLiveRegion: "polite",
|
|
893
|
-
style: [
|
|
1072
|
+
style: [
|
|
1073
|
+
styles.error,
|
|
1074
|
+
disabled && styles.helperTextDisabled,
|
|
1075
|
+
errorStyle
|
|
1076
|
+
],
|
|
894
1077
|
children: error
|
|
895
1078
|
}
|
|
896
1079
|
) : /* @__PURE__ */ jsx14(View10, { accessibilityLiveRegion: "polite", children: error }))
|
|
@@ -1013,9 +1196,9 @@ var RadioGroup = forwardRef(
|
|
|
1013
1196
|
RadioGroup.displayName = "RadioGroup";
|
|
1014
1197
|
|
|
1015
1198
|
// src/components/Select/Select.tsx
|
|
1016
|
-
import { useEffect as useEffect2, useState as
|
|
1199
|
+
import { useEffect as useEffect2, useState as useState2 } from "react";
|
|
1017
1200
|
import { Picker } from "@react-native-picker/picker";
|
|
1018
|
-
import {
|
|
1201
|
+
import { useSelect } from "@vellira-ui/core";
|
|
1019
1202
|
import { Modal as Modal3, Pressable as Pressable7, Text as Text8, View as View13 } from "react-native";
|
|
1020
1203
|
|
|
1021
1204
|
// src/components/Select/SelectTrigger/SelectTrigger.tsx
|
|
@@ -1066,11 +1249,27 @@ var createStyles14 = (theme) => StyleSheet14.create({
|
|
|
1066
1249
|
lineHeight: theme.tokens.typography.lineHeight.lg
|
|
1067
1250
|
},
|
|
1068
1251
|
triggerOpen: {
|
|
1069
|
-
|
|
1252
|
+
backgroundColor: theme.components.select.trigger.focus.bg,
|
|
1253
|
+
borderColor: theme.components.select.trigger.focus.border,
|
|
1254
|
+
borderWidth: 2
|
|
1070
1255
|
},
|
|
1071
1256
|
triggerError: {
|
|
1072
1257
|
borderColor: theme.components.select.trigger.error.border
|
|
1073
1258
|
},
|
|
1259
|
+
triggerErrorOpen: {
|
|
1260
|
+
borderColor: theme.components.select.trigger.error.border,
|
|
1261
|
+
shadowColor: theme.components.select.trigger.error.ring,
|
|
1262
|
+
shadowOffset: {
|
|
1263
|
+
width: 0,
|
|
1264
|
+
height: 0
|
|
1265
|
+
},
|
|
1266
|
+
shadowOpacity: 0.2,
|
|
1267
|
+
shadowRadius: 6,
|
|
1268
|
+
elevation: 1
|
|
1269
|
+
},
|
|
1270
|
+
textOpen: {
|
|
1271
|
+
color: theme.components.select.trigger.focus.fg
|
|
1272
|
+
},
|
|
1074
1273
|
triggerDisabled: {
|
|
1075
1274
|
backgroundColor: theme.components.select.trigger.disabled.bg,
|
|
1076
1275
|
borderColor: theme.components.select.trigger.disabled.border
|
|
@@ -1121,7 +1320,7 @@ function SelectTrigger({
|
|
|
1121
1320
|
sm: styles.textSm,
|
|
1122
1321
|
md: styles.textMd,
|
|
1123
1322
|
lg: styles.textLg
|
|
1124
|
-
}
|
|
1323
|
+
};
|
|
1125
1324
|
const resolvedAccessibilityHint = accessibilityHint ?? (hasError ? "Invalid selection. Opens a picker" : required ? "Required. Opens a picker" : "Opens a picker");
|
|
1126
1325
|
return /* @__PURE__ */ jsxs8(
|
|
1127
1326
|
Pressable6,
|
|
@@ -1150,8 +1349,9 @@ function SelectTrigger({
|
|
|
1150
1349
|
numberOfLines: 1,
|
|
1151
1350
|
style: [
|
|
1152
1351
|
styles.text,
|
|
1153
|
-
textSizeStyle,
|
|
1352
|
+
textSizeStyle[size],
|
|
1154
1353
|
isPlaceholder && styles.placeholder,
|
|
1354
|
+
isOpen && styles.textOpen,
|
|
1155
1355
|
disabled && styles.textDisabled,
|
|
1156
1356
|
textStyle
|
|
1157
1357
|
],
|
|
@@ -1181,7 +1381,6 @@ function SelectTrigger({
|
|
|
1181
1381
|
SelectTrigger.displayName = "SelectTrigger";
|
|
1182
1382
|
|
|
1183
1383
|
// src/components/Select/Select.styles.ts
|
|
1184
|
-
import { overlay as overlay2 } from "@vellira-ui/tokens";
|
|
1185
1384
|
import { StyleSheet as StyleSheet15 } from "react-native";
|
|
1186
1385
|
var createStyles15 = (theme) => StyleSheet15.create({
|
|
1187
1386
|
modalRoot: {
|
|
@@ -1190,23 +1389,31 @@ var createStyles15 = (theme) => StyleSheet15.create({
|
|
|
1190
1389
|
},
|
|
1191
1390
|
backdrop: {
|
|
1192
1391
|
...StyleSheet15.absoluteFill,
|
|
1193
|
-
backgroundColor:
|
|
1392
|
+
backgroundColor: theme.semantic.overlay.backdrop
|
|
1194
1393
|
},
|
|
1195
1394
|
sheet: {
|
|
1196
1395
|
maxHeight: "50%",
|
|
1396
|
+
overflow: "hidden",
|
|
1197
1397
|
backgroundColor: theme.components.select.dropdown.bg,
|
|
1198
1398
|
borderColor: theme.components.select.dropdown.border,
|
|
1199
1399
|
borderTopLeftRadius: theme.tokens.radius.lg,
|
|
1200
1400
|
borderTopRightRadius: theme.tokens.radius.lg,
|
|
1201
1401
|
borderWidth: 1,
|
|
1202
1402
|
borderBottomWidth: 0,
|
|
1203
|
-
|
|
1403
|
+
shadowColor: theme.tokens.shadows.lg.color,
|
|
1404
|
+
shadowOffset: {
|
|
1405
|
+
width: theme.tokens.shadows.lg.x,
|
|
1406
|
+
height: -theme.tokens.shadows.lg.y
|
|
1407
|
+
},
|
|
1408
|
+
shadowOpacity: theme.tokens.shadows.lg.opacity,
|
|
1409
|
+
shadowRadius: theme.tokens.shadows.lg.blur,
|
|
1410
|
+
elevation: theme.tokens.shadows.lg.elevation
|
|
1204
1411
|
},
|
|
1205
1412
|
toolbar: {
|
|
1206
1413
|
minHeight: 48,
|
|
1414
|
+
flexDirection: "row",
|
|
1207
1415
|
alignItems: "center",
|
|
1208
1416
|
justifyContent: "space-between",
|
|
1209
|
-
flexDirection: "row",
|
|
1210
1417
|
paddingHorizontal: theme.tokens.spacing[4],
|
|
1211
1418
|
borderBottomColor: theme.components.select.dropdown.border,
|
|
1212
1419
|
borderBottomWidth: 1
|
|
@@ -1233,7 +1440,7 @@ var createStyles15 = (theme) => StyleSheet15.create({
|
|
|
1233
1440
|
lineHeight: theme.tokens.typography.lineHeight.md
|
|
1234
1441
|
},
|
|
1235
1442
|
doneText: {
|
|
1236
|
-
color: theme.
|
|
1443
|
+
color: theme.semantic.text.interactive,
|
|
1237
1444
|
fontFamily: theme.tokens.typography.family.medium,
|
|
1238
1445
|
fontSize: theme.tokens.typography.size.md,
|
|
1239
1446
|
lineHeight: theme.tokens.typography.lineHeight.md
|
|
@@ -1266,14 +1473,14 @@ function Select({
|
|
|
1266
1473
|
}) {
|
|
1267
1474
|
const { theme } = useTheme();
|
|
1268
1475
|
const styles = useThemeStyles(createStyles15);
|
|
1269
|
-
const
|
|
1270
|
-
const [selectedValue, setSelectedValue] = useControllableState3({
|
|
1476
|
+
const { selectedValue, setSelectedValue, selectedOption, isOpen, setIsOpen } = useSelect({
|
|
1271
1477
|
value,
|
|
1272
|
-
defaultValue
|
|
1273
|
-
onChange
|
|
1478
|
+
defaultValue,
|
|
1479
|
+
onChange,
|
|
1480
|
+
options,
|
|
1481
|
+
disabled
|
|
1274
1482
|
});
|
|
1275
|
-
const [draftValue, setDraftValue] =
|
|
1276
|
-
const selectedOption = options.find((o) => o.value === selectedValue);
|
|
1483
|
+
const [draftValue, setDraftValue] = useState2(selectedValue);
|
|
1277
1484
|
const hasError = !!error;
|
|
1278
1485
|
useEffect2(() => {
|
|
1279
1486
|
if (isOpen) {
|
|
@@ -1457,13 +1664,17 @@ var createStyles16 = (theme) => StyleSheet16.create({
|
|
|
1457
1664
|
},
|
|
1458
1665
|
listPills: {
|
|
1459
1666
|
backgroundColor: theme.components.tabs.pills.default.bg,
|
|
1460
|
-
|
|
1667
|
+
borderRadius: theme.tokens.radius.lg
|
|
1461
1668
|
},
|
|
1462
1669
|
listVertical: {
|
|
1463
|
-
alignSelf: "flex-start",
|
|
1464
1670
|
flexDirection: "column",
|
|
1671
|
+
alignSelf: "flex-start",
|
|
1672
|
+
width: 140,
|
|
1673
|
+
minWidth: 140,
|
|
1674
|
+
maxWidth: 140,
|
|
1675
|
+
flexGrow: 0,
|
|
1676
|
+
flexShrink: 0,
|
|
1465
1677
|
gap: theme.tokens.spacing[1],
|
|
1466
|
-
marginRight: theme.tokens.spacing[4],
|
|
1467
1678
|
marginBottom: 0
|
|
1468
1679
|
}
|
|
1469
1680
|
});
|
|
@@ -1496,9 +1707,27 @@ import { View as View15 } from "react-native";
|
|
|
1496
1707
|
import { StyleSheet as StyleSheet17 } from "react-native";
|
|
1497
1708
|
var createStyles17 = (theme) => StyleSheet17.create({
|
|
1498
1709
|
panel: {
|
|
1499
|
-
|
|
1710
|
+
width: "100%",
|
|
1500
1711
|
minWidth: 0,
|
|
1712
|
+
alignSelf: "stretch",
|
|
1501
1713
|
padding: theme.tokens.spacing[4]
|
|
1714
|
+
},
|
|
1715
|
+
panelVertical: {
|
|
1716
|
+
flex: 1,
|
|
1717
|
+
flexBasis: 0,
|
|
1718
|
+
flexShrink: 1,
|
|
1719
|
+
minWidth: 0,
|
|
1720
|
+
alignSelf: "stretch"
|
|
1721
|
+
},
|
|
1722
|
+
panelHidden: {
|
|
1723
|
+
display: "none"
|
|
1724
|
+
},
|
|
1725
|
+
text: {
|
|
1726
|
+
flexShrink: 1,
|
|
1727
|
+
color: theme.components.tabs.panel.fg,
|
|
1728
|
+
fontFamily: theme.tokens.typography.family.regular,
|
|
1729
|
+
fontSize: theme.tokens.typography.size.md,
|
|
1730
|
+
lineHeight: theme.tokens.typography.lineHeight.md
|
|
1502
1731
|
}
|
|
1503
1732
|
});
|
|
1504
1733
|
|
|
@@ -1506,14 +1735,24 @@ var createStyles17 = (theme) => StyleSheet17.create({
|
|
|
1506
1735
|
import { jsx as jsx19 } from "react/jsx-runtime";
|
|
1507
1736
|
var TabsPanel = ({ index, children, style }) => {
|
|
1508
1737
|
const styles = useThemeStyles(createStyles17);
|
|
1509
|
-
const { activeIndex } = useTabs();
|
|
1738
|
+
const { activeIndex, orientation } = useTabs();
|
|
1510
1739
|
if (activeIndex !== index) return null;
|
|
1511
|
-
return /* @__PURE__ */ jsx19(
|
|
1740
|
+
return /* @__PURE__ */ jsx19(
|
|
1741
|
+
View15,
|
|
1742
|
+
{
|
|
1743
|
+
style: [
|
|
1744
|
+
styles.panel,
|
|
1745
|
+
orientation === "vertical" && styles.panelVertical,
|
|
1746
|
+
style
|
|
1747
|
+
],
|
|
1748
|
+
children
|
|
1749
|
+
}
|
|
1750
|
+
);
|
|
1512
1751
|
};
|
|
1513
1752
|
TabsPanel.displayName = "TabsPanel";
|
|
1514
1753
|
|
|
1515
1754
|
// src/components/Tabs/Tab/Tab.tsx
|
|
1516
|
-
import { cloneElement as
|
|
1755
|
+
import { cloneElement as cloneElement4, isValidElement as isValidElement4 } from "react";
|
|
1517
1756
|
import { Pressable as Pressable8, Text as Text9, View as View16 } from "react-native";
|
|
1518
1757
|
|
|
1519
1758
|
// src/components/Tabs/Tab/Tab.styles.ts
|
|
@@ -1521,40 +1760,78 @@ import { StyleSheet as StyleSheet18 } from "react-native";
|
|
|
1521
1760
|
var fontWeight2 = (value) => value;
|
|
1522
1761
|
var createStyles18 = (theme) => StyleSheet18.create({
|
|
1523
1762
|
tab: {
|
|
1763
|
+
minHeight: 40,
|
|
1524
1764
|
alignItems: "center",
|
|
1525
1765
|
flexDirection: "row",
|
|
1526
1766
|
gap: theme.tokens.spacing[2],
|
|
1527
1767
|
justifyContent: "center",
|
|
1528
1768
|
paddingHorizontal: theme.tokens.spacing[4],
|
|
1529
1769
|
paddingVertical: theme.tokens.spacing[2],
|
|
1530
|
-
backgroundColor: theme.components.tabs.trigger.default.bg
|
|
1531
|
-
borderWidth: 0
|
|
1770
|
+
backgroundColor: theme.components.tabs.trigger.default.bg
|
|
1532
1771
|
},
|
|
1533
1772
|
tabVertical: {
|
|
1534
|
-
|
|
1773
|
+
position: "relative",
|
|
1535
1774
|
width: "100%",
|
|
1775
|
+
minHeight: 40,
|
|
1776
|
+
flexGrow: 0,
|
|
1777
|
+
flexShrink: 0,
|
|
1536
1778
|
justifyContent: "flex-start"
|
|
1537
1779
|
},
|
|
1538
|
-
|
|
1780
|
+
horizontalIndicator: {
|
|
1781
|
+
position: "absolute",
|
|
1782
|
+
right: 0,
|
|
1783
|
+
bottom: 0,
|
|
1784
|
+
left: 0,
|
|
1785
|
+
height: 3,
|
|
1786
|
+
backgroundColor: "transparent"
|
|
1787
|
+
},
|
|
1788
|
+
horizontalIndicatorActive: {
|
|
1789
|
+
backgroundColor: theme.components.tabs.indicator.active.bg
|
|
1790
|
+
},
|
|
1791
|
+
verticalIndicator: {
|
|
1792
|
+
position: "absolute",
|
|
1793
|
+
top: 0,
|
|
1794
|
+
bottom: 0,
|
|
1795
|
+
left: 0,
|
|
1796
|
+
width: 3,
|
|
1797
|
+
backgroundColor: "transparent"
|
|
1798
|
+
},
|
|
1799
|
+
verticalIndicatorActive: {
|
|
1800
|
+
backgroundColor: theme.components.tabs.indicator.active.bg
|
|
1801
|
+
},
|
|
1802
|
+
verticalIndicatorPressed: {
|
|
1803
|
+
backgroundColor: theme.components.tabs.indicator.hover.bg
|
|
1804
|
+
},
|
|
1805
|
+
tabHovered: {
|
|
1806
|
+
backgroundColor: theme.components.tabs.trigger.hover.bg
|
|
1807
|
+
},
|
|
1808
|
+
tabPressed: {
|
|
1539
1809
|
backgroundColor: theme.components.tabs.trigger.active.bg
|
|
1540
1810
|
},
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
borderBottomWidth: 3,
|
|
1544
|
-
borderRadius: 0
|
|
1811
|
+
tabFocused: {
|
|
1812
|
+
borderColor: theme.semantic.focus.ring.color
|
|
1545
1813
|
},
|
|
1546
|
-
|
|
1547
|
-
|
|
1814
|
+
tabDefaultActive: {
|
|
1815
|
+
backgroundColor: theme.components.tabs.trigger.active.bg
|
|
1548
1816
|
},
|
|
1549
1817
|
tabDisabled: {
|
|
1550
1818
|
backgroundColor: theme.components.tabs.trigger.disabled.bg
|
|
1551
1819
|
},
|
|
1552
1820
|
tabText: {
|
|
1821
|
+
flexShrink: 0,
|
|
1822
|
+
textAlign: "center",
|
|
1823
|
+
lineHeight: theme.tokens.typography.lineHeight.md,
|
|
1553
1824
|
color: theme.components.tabs.trigger.default.fg,
|
|
1554
1825
|
fontFamily: theme.tokens.typography.family.regular,
|
|
1555
1826
|
fontSize: theme.tokens.typography.size.md,
|
|
1556
1827
|
fontWeight: fontWeight2(theme.tokens.typography.weight.regular)
|
|
1557
1828
|
},
|
|
1829
|
+
tabTextHover: {
|
|
1830
|
+
color: theme.components.tabs.trigger.hover.fg
|
|
1831
|
+
},
|
|
1832
|
+
tabTextPressed: {
|
|
1833
|
+
color: theme.components.tabs.trigger.active.fg
|
|
1834
|
+
},
|
|
1558
1835
|
tabTextDisabled: {
|
|
1559
1836
|
color: theme.components.tabs.trigger.disabled.fg
|
|
1560
1837
|
},
|
|
@@ -1564,17 +1841,32 @@ var createStyles18 = (theme) => StyleSheet18.create({
|
|
|
1564
1841
|
tabTextPillsActive: {
|
|
1565
1842
|
color: theme.components.tabs.pills.active.fg
|
|
1566
1843
|
},
|
|
1844
|
+
tabPills: {
|
|
1845
|
+
minHeight: 36,
|
|
1846
|
+
paddingHorizontal: theme.tokens.spacing[3],
|
|
1847
|
+
paddingVertical: theme.tokens.spacing[1],
|
|
1848
|
+
borderRadius: theme.tokens.radius.md
|
|
1849
|
+
},
|
|
1567
1850
|
tabPillsActive: {
|
|
1568
1851
|
backgroundColor: theme.components.tabs.pills.active.bg,
|
|
1569
1852
|
borderRadius: theme.tokens.radius.md
|
|
1570
1853
|
},
|
|
1571
|
-
|
|
1572
|
-
backgroundColor: theme.components.tabs.
|
|
1854
|
+
tabPillsHover: {
|
|
1855
|
+
backgroundColor: theme.components.tabs.pills.hover.bg
|
|
1856
|
+
},
|
|
1857
|
+
tabPillsPressed: {
|
|
1858
|
+
backgroundColor: theme.components.tabs.pills.active.bg
|
|
1573
1859
|
},
|
|
1574
1860
|
tabIcon: {
|
|
1575
1861
|
alignItems: "center",
|
|
1576
1862
|
justifyContent: "center"
|
|
1577
1863
|
},
|
|
1864
|
+
tabIconHover: {
|
|
1865
|
+
color: theme.components.tabs.trigger.hover.fg
|
|
1866
|
+
},
|
|
1867
|
+
tabIconPressed: {
|
|
1868
|
+
color: theme.components.tabs.trigger.active.fg
|
|
1869
|
+
},
|
|
1578
1870
|
tabIconActive: {
|
|
1579
1871
|
color: theme.components.tabs.trigger.active.fg
|
|
1580
1872
|
},
|
|
@@ -1584,7 +1876,7 @@ var createStyles18 = (theme) => StyleSheet18.create({
|
|
|
1584
1876
|
});
|
|
1585
1877
|
|
|
1586
1878
|
// src/components/Tabs/Tab/Tab.tsx
|
|
1587
|
-
import { jsx as jsx20, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
1879
|
+
import { Fragment as Fragment2, jsx as jsx20, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
1588
1880
|
var Tab = ({
|
|
1589
1881
|
index,
|
|
1590
1882
|
children,
|
|
@@ -1600,32 +1892,60 @@ var Tab = ({
|
|
|
1600
1892
|
const isPills = appearance === "pills";
|
|
1601
1893
|
const isUnderline = appearance === "underline";
|
|
1602
1894
|
const isDefault = appearance === "default";
|
|
1895
|
+
const isVertical = orientation === "vertical";
|
|
1603
1896
|
const iconColor = isPills && isActive ? theme.components.tabs.pills.active.fg : isActive ? theme.components.tabs.trigger.active.fg : theme.components.tabs.trigger.default.fg;
|
|
1604
|
-
const renderedIcon =
|
|
1897
|
+
const renderedIcon = isValidElement4(icon) ? cloneElement4(icon, {
|
|
1605
1898
|
color: iconColor
|
|
1606
1899
|
}) : icon;
|
|
1607
|
-
return /* @__PURE__ */
|
|
1900
|
+
return /* @__PURE__ */ jsx20(
|
|
1608
1901
|
Pressable8,
|
|
1609
1902
|
{
|
|
1610
1903
|
disabled,
|
|
1611
1904
|
accessibilityRole: "tab",
|
|
1612
1905
|
accessibilityState: { selected: isActive, disabled },
|
|
1613
|
-
onPress: () =>
|
|
1614
|
-
|
|
1906
|
+
onPress: () => {
|
|
1907
|
+
if (!disabled && !isActive) {
|
|
1908
|
+
setActiveIndex(index);
|
|
1909
|
+
}
|
|
1910
|
+
},
|
|
1911
|
+
style: ({ pressed }) => [
|
|
1615
1912
|
styles.tab,
|
|
1616
|
-
|
|
1913
|
+
isVertical && styles.tabVertical,
|
|
1914
|
+
isPills && styles.tabPills,
|
|
1617
1915
|
isPills && isActive && styles.tabPillsActive,
|
|
1618
|
-
|
|
1619
|
-
isUnderline && isActive && styles.tabUnderlineActive,
|
|
1916
|
+
pressed && !disabled && styles.tabPressed,
|
|
1620
1917
|
isDefault && isActive && styles.tabDefaultActive,
|
|
1621
1918
|
disabled && styles.tabDisabled,
|
|
1622
1919
|
style
|
|
1623
1920
|
],
|
|
1624
|
-
children: [
|
|
1921
|
+
children: ({ pressed }) => /* @__PURE__ */ jsxs10(Fragment2, { children: [
|
|
1922
|
+
isUnderline && !isVertical && /* @__PURE__ */ jsx20(
|
|
1923
|
+
View16,
|
|
1924
|
+
{
|
|
1925
|
+
pointerEvents: "none",
|
|
1926
|
+
style: [
|
|
1927
|
+
styles.horizontalIndicator,
|
|
1928
|
+
isActive && styles.horizontalIndicatorActive
|
|
1929
|
+
]
|
|
1930
|
+
}
|
|
1931
|
+
),
|
|
1932
|
+
isUnderline && isVertical && /* @__PURE__ */ jsx20(
|
|
1933
|
+
View16,
|
|
1934
|
+
{
|
|
1935
|
+
pointerEvents: "none",
|
|
1936
|
+
style: [
|
|
1937
|
+
styles.verticalIndicator,
|
|
1938
|
+
isActive && styles.verticalIndicatorActive,
|
|
1939
|
+
pressed && !isActive && !disabled && styles.verticalIndicatorPressed
|
|
1940
|
+
]
|
|
1941
|
+
}
|
|
1942
|
+
),
|
|
1625
1943
|
icon != null && /* @__PURE__ */ jsx20(View16, { style: styles.tabIcon, children: renderedIcon }),
|
|
1626
1944
|
children != null && /* @__PURE__ */ jsx20(
|
|
1627
1945
|
Text9,
|
|
1628
1946
|
{
|
|
1947
|
+
numberOfLines: 2,
|
|
1948
|
+
ellipsizeMode: "tail",
|
|
1629
1949
|
style: [
|
|
1630
1950
|
styles.tabText,
|
|
1631
1951
|
isPills && isActive && styles.tabTextPillsActive,
|
|
@@ -1636,41 +1956,30 @@ var Tab = ({
|
|
|
1636
1956
|
children
|
|
1637
1957
|
}
|
|
1638
1958
|
)
|
|
1639
|
-
]
|
|
1959
|
+
] })
|
|
1640
1960
|
}
|
|
1641
1961
|
);
|
|
1642
1962
|
};
|
|
1643
1963
|
Tab.displayName = "Tab";
|
|
1644
1964
|
|
|
1645
1965
|
// src/components/Tabs/Tabs.tsx
|
|
1646
|
-
import {
|
|
1966
|
+
import { useMemo as useMemo4 } from "react";
|
|
1967
|
+
import { useTabs as useTabs2 } from "@vellira-ui/core";
|
|
1647
1968
|
import { View as View17 } from "react-native";
|
|
1648
1969
|
|
|
1649
1970
|
// src/components/Tabs/Tabs.styles.ts
|
|
1650
1971
|
import { StyleSheet as StyleSheet19 } from "react-native";
|
|
1651
1972
|
var createStyles19 = (theme) => StyleSheet19.create({
|
|
1652
1973
|
root: {
|
|
1653
|
-
width: "100%"
|
|
1974
|
+
width: "100%",
|
|
1975
|
+
minWidth: 0
|
|
1654
1976
|
},
|
|
1655
1977
|
rootVertical: {
|
|
1656
1978
|
flexDirection: "row",
|
|
1657
1979
|
alignItems: "flex-start",
|
|
1658
|
-
gap: theme.tokens.spacing[6]
|
|
1659
|
-
},
|
|
1660
|
-
listVertical: {
|
|
1661
|
-
flexDirection: "column",
|
|
1662
|
-
width: 140,
|
|
1663
|
-
flexShrink: 0
|
|
1664
|
-
},
|
|
1665
|
-
tabVertical: {
|
|
1666
|
-
flex: 0,
|
|
1667
1980
|
width: "100%",
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
panel: {
|
|
1671
|
-
flex: 1,
|
|
1672
|
-
flexShrink: 1,
|
|
1673
|
-
minWidth: 0
|
|
1981
|
+
minWidth: 0,
|
|
1982
|
+
gap: theme.tokens.spacing[6]
|
|
1674
1983
|
}
|
|
1675
1984
|
});
|
|
1676
1985
|
|
|
@@ -1686,19 +1995,13 @@ var TabsRoot = ({
|
|
|
1686
1995
|
style
|
|
1687
1996
|
}) => {
|
|
1688
1997
|
const styles = useThemeStyles(createStyles19);
|
|
1689
|
-
const
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
}
|
|
1697
|
-
onChange?.(nextIndex);
|
|
1698
|
-
},
|
|
1699
|
-
[isControlled, onChange]
|
|
1700
|
-
);
|
|
1701
|
-
const value = useMemo3(
|
|
1998
|
+
const { activeIndex, setActiveIndex } = useTabs2({
|
|
1999
|
+
activeIndex: controlledActiveIndex,
|
|
2000
|
+
defaultActiveIndex,
|
|
2001
|
+
onChange,
|
|
2002
|
+
orientation
|
|
2003
|
+
});
|
|
2004
|
+
const value = useMemo4(
|
|
1702
2005
|
() => ({ activeIndex, appearance, orientation, setActiveIndex }),
|
|
1703
2006
|
[activeIndex, appearance, orientation, setActiveIndex]
|
|
1704
2007
|
);
|
|
@@ -1724,15 +2027,15 @@ var Tabs = Object.assign(TabsRoot, {
|
|
|
1724
2027
|
});
|
|
1725
2028
|
|
|
1726
2029
|
// src/components/Tooltip/Tooltip.tsx
|
|
1727
|
-
import { useEffect as useEffect3, useRef as useRef3, useState as
|
|
2030
|
+
import { useEffect as useEffect3, useRef as useRef3, useState as useState4 } from "react";
|
|
1728
2031
|
import { Modal as Modal4, Pressable as Pressable9, Text as Text10, View as View18 } from "react-native";
|
|
1729
2032
|
|
|
1730
2033
|
// src/hooks/useNativeFloatingPosition.ts
|
|
1731
|
-
import { useCallback as useCallback2, useRef as useRef2, useState as
|
|
2034
|
+
import { useCallback as useCallback2, useRef as useRef2, useState as useState3 } from "react";
|
|
1732
2035
|
import { Dimensions } from "react-native";
|
|
1733
2036
|
var safePadding = 12;
|
|
1734
2037
|
function useNativeFloatingPosition(placement = "top", offset = 8) {
|
|
1735
|
-
const [position, setPosition] =
|
|
2038
|
+
const [position, setPosition] = useState3({ top: 0, left: 0 });
|
|
1736
2039
|
const floatingSizeRef = useRef2({
|
|
1737
2040
|
width: 0,
|
|
1738
2041
|
height: 0
|
|
@@ -1805,26 +2108,28 @@ var createStyles20 = (theme) => StyleSheet20.create({
|
|
|
1805
2108
|
bubble: {
|
|
1806
2109
|
position: "absolute",
|
|
1807
2110
|
zIndex: 1e3,
|
|
2111
|
+
maxWidth: 280,
|
|
2112
|
+
paddingHorizontal: theme.tokens.spacing[3],
|
|
2113
|
+
paddingVertical: theme.tokens.spacing[2],
|
|
1808
2114
|
backgroundColor: theme.components.tooltip.content.bg,
|
|
1809
2115
|
borderColor: theme.components.tooltip.content.border,
|
|
1810
2116
|
borderRadius: theme.tokens.radius.sm,
|
|
1811
2117
|
borderWidth: 1,
|
|
1812
|
-
|
|
1813
|
-
paddingVertical: theme.tokens.spacing[2],
|
|
1814
|
-
shadowColor: theme.tokens.shadows.sm.color,
|
|
2118
|
+
shadowColor: theme.tokens.shadows.md.color,
|
|
1815
2119
|
shadowOffset: {
|
|
1816
|
-
width: theme.tokens.shadows.
|
|
1817
|
-
height: theme.tokens.shadows.
|
|
2120
|
+
width: theme.tokens.shadows.md.x,
|
|
2121
|
+
height: theme.tokens.shadows.md.y
|
|
1818
2122
|
},
|
|
1819
|
-
shadowOpacity: theme.tokens.shadows.
|
|
1820
|
-
shadowRadius: theme.tokens.shadows.
|
|
1821
|
-
elevation: theme.tokens.shadows.
|
|
2123
|
+
shadowOpacity: theme.tokens.shadows.md.opacity,
|
|
2124
|
+
shadowRadius: theme.tokens.shadows.md.blur,
|
|
2125
|
+
elevation: theme.tokens.shadows.md.elevation
|
|
1822
2126
|
},
|
|
1823
2127
|
text: {
|
|
2128
|
+
flexShrink: 1,
|
|
1824
2129
|
color: theme.components.tooltip.content.fg,
|
|
1825
2130
|
fontFamily: theme.tokens.typography.family.regular,
|
|
1826
2131
|
fontSize: theme.tokens.typography.size.sm,
|
|
1827
|
-
lineHeight:
|
|
2132
|
+
lineHeight: theme.tokens.typography.lineHeight.sm,
|
|
1828
2133
|
textAlign: "center"
|
|
1829
2134
|
}
|
|
1830
2135
|
});
|
|
@@ -1843,7 +2148,7 @@ function Tooltip({
|
|
|
1843
2148
|
textStyle
|
|
1844
2149
|
}) {
|
|
1845
2150
|
const styles = useThemeStyles(createStyles20);
|
|
1846
|
-
const [visible, setVisible] =
|
|
2151
|
+
const [visible, setVisible] = useState4(false);
|
|
1847
2152
|
const triggerRef = useRef3(null);
|
|
1848
2153
|
const closeTimerRef = useRef3(null);
|
|
1849
2154
|
const { position, updatePosition, onFloatingLayout } = useNativeFloatingPosition(placement, 8);
|
|
@@ -1901,7 +2206,7 @@ function Tooltip({
|
|
|
1901
2206
|
Tooltip.displayName = "Tooltip";
|
|
1902
2207
|
|
|
1903
2208
|
// src/primitives/Button/Button.tsx
|
|
1904
|
-
import { cloneElement as
|
|
2209
|
+
import { cloneElement as cloneElement5, useState as useState5 } from "react";
|
|
1905
2210
|
import { ActivityIndicator, Pressable as Pressable10, Text as Text11 } from "react-native";
|
|
1906
2211
|
|
|
1907
2212
|
// src/utils/devWarning.ts
|
|
@@ -1942,14 +2247,15 @@ var createStyles21 = (theme) => StyleSheet21.create({
|
|
|
1942
2247
|
borderColor: theme.components.button.disabled.border
|
|
1943
2248
|
},
|
|
1944
2249
|
focused: {
|
|
1945
|
-
borderColor: theme.semantic.focus.ring,
|
|
1946
|
-
shadowColor: theme.semantic.focus.ring,
|
|
2250
|
+
borderColor: theme.semantic.focus.ring.color,
|
|
2251
|
+
shadowColor: theme.semantic.focus.ring.color,
|
|
1947
2252
|
shadowOffset: {
|
|
1948
2253
|
width: 0,
|
|
1949
2254
|
height: 0
|
|
1950
2255
|
},
|
|
1951
|
-
shadowOpacity: 0.
|
|
1952
|
-
shadowRadius:
|
|
2256
|
+
shadowOpacity: 0.18,
|
|
2257
|
+
shadowRadius: 8,
|
|
2258
|
+
elevation: 2
|
|
1953
2259
|
},
|
|
1954
2260
|
pressed: {
|
|
1955
2261
|
transform: [{ scale: 0.98 }]
|
|
@@ -1957,7 +2263,7 @@ var createStyles21 = (theme) => StyleSheet21.create({
|
|
|
1957
2263
|
});
|
|
1958
2264
|
|
|
1959
2265
|
// src/primitives/Button/Button.tsx
|
|
1960
|
-
import { Fragment, jsx as jsx23, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
2266
|
+
import { Fragment as Fragment3, jsx as jsx23, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
1961
2267
|
var sizeMap = {
|
|
1962
2268
|
sm: {
|
|
1963
2269
|
px: 12,
|
|
@@ -2009,8 +2315,8 @@ function Button({
|
|
|
2009
2315
|
const styles = useThemeStyles(createStyles21);
|
|
2010
2316
|
const config = sizeMap[size];
|
|
2011
2317
|
const variantTheme = theme.components.button[color][variant];
|
|
2012
|
-
const [isHovered, setIsHovered] =
|
|
2013
|
-
const [isFocused, setIsFocused] =
|
|
2318
|
+
const [isHovered, setIsHovered] = useState5(false);
|
|
2319
|
+
const [isFocused, setIsFocused] = useState5(false);
|
|
2014
2320
|
const isDisabled = disabled || loading;
|
|
2015
2321
|
const iconOnly = iconOnlyProp || !children && Boolean(leftIcon || rightIcon);
|
|
2016
2322
|
const content = loading && loadingText ? loadingText : children;
|
|
@@ -2035,7 +2341,7 @@ function Button({
|
|
|
2035
2341
|
setIsHovered(false);
|
|
2036
2342
|
onHoverOut?.(event);
|
|
2037
2343
|
};
|
|
2038
|
-
const renderIcon = (icon, iconColor) =>
|
|
2344
|
+
const renderIcon = (icon, iconColor) => cloneElement5(icon, {
|
|
2039
2345
|
color: iconColor,
|
|
2040
2346
|
size: resolvedIconSize
|
|
2041
2347
|
});
|
|
@@ -2076,7 +2382,7 @@ function Button({
|
|
|
2076
2382
|
children: ({ pressed }) => {
|
|
2077
2383
|
const interactionTheme = getInteractionTheme(pressed);
|
|
2078
2384
|
const contentColor = interactionTheme.fg;
|
|
2079
|
-
return /* @__PURE__ */ jsxs12(
|
|
2385
|
+
return /* @__PURE__ */ jsxs12(Fragment3, { children: [
|
|
2080
2386
|
loading && /* @__PURE__ */ jsx23(ActivityIndicator, { size: "small", color: contentColor }),
|
|
2081
2387
|
!loading && leftIcon && renderIcon(leftIcon, contentColor),
|
|
2082
2388
|
content && !iconOnly && /* @__PURE__ */ jsx23(
|
|
@@ -2101,8 +2407,8 @@ function Button({
|
|
|
2101
2407
|
}
|
|
2102
2408
|
|
|
2103
2409
|
// src/primitives/Checkbox/Checkbox.tsx
|
|
2104
|
-
import { forwardRef as forwardRef2 } from "react";
|
|
2105
|
-
import { useControllableState as
|
|
2410
|
+
import { forwardRef as forwardRef2, useEffect as useEffect4 } from "react";
|
|
2411
|
+
import { useControllableState as useControllableState3 } from "@vellira-ui/core";
|
|
2106
2412
|
import { Check } from "@vellira-ui/icons";
|
|
2107
2413
|
import { Pressable as Pressable11, Text as Text12, View as View19 } from "react-native";
|
|
2108
2414
|
|
|
@@ -2153,6 +2459,14 @@ var createStyles22 = (theme) => StyleSheet22.create({
|
|
|
2153
2459
|
backgroundColor: theme.components.checkbox.checked.default.bg,
|
|
2154
2460
|
borderColor: theme.components.checkbox.checked.default.border
|
|
2155
2461
|
},
|
|
2462
|
+
boxCheckedHover: {
|
|
2463
|
+
backgroundColor: theme.components.checkbox.checked.hover.bg,
|
|
2464
|
+
borderColor: theme.components.checkbox.checked.hover.border
|
|
2465
|
+
},
|
|
2466
|
+
boxCheckedPressed: {
|
|
2467
|
+
backgroundColor: theme.components.checkbox.checked.pressed.bg,
|
|
2468
|
+
borderColor: theme.components.checkbox.checked.pressed.border
|
|
2469
|
+
},
|
|
2156
2470
|
boxDisabled: {
|
|
2157
2471
|
backgroundColor: theme.components.checkbox.disabled.bg,
|
|
2158
2472
|
borderColor: theme.components.checkbox.disabled.border
|
|
@@ -2160,17 +2474,41 @@ var createStyles22 = (theme) => StyleSheet22.create({
|
|
|
2160
2474
|
boxError: {
|
|
2161
2475
|
borderColor: theme.components.checkbox.error.border
|
|
2162
2476
|
},
|
|
2477
|
+
checkmark: {
|
|
2478
|
+
color: theme.components.checkbox.checked.default.fg
|
|
2479
|
+
},
|
|
2480
|
+
checkmarkHover: {
|
|
2481
|
+
color: theme.components.checkbox.checked.hover.fg
|
|
2482
|
+
},
|
|
2483
|
+
checkmarkPressed: {
|
|
2484
|
+
color: theme.components.checkbox.checked.pressed.fg
|
|
2485
|
+
},
|
|
2163
2486
|
indeterminateMark: {
|
|
2164
2487
|
width: "60%",
|
|
2165
2488
|
height: 2,
|
|
2166
2489
|
backgroundColor: theme.components.checkbox.checked.default.fg,
|
|
2167
2490
|
borderRadius: theme.tokens.radius.full
|
|
2168
2491
|
},
|
|
2492
|
+
indeterminateMarkHover: {
|
|
2493
|
+
backgroundColor: theme.components.checkbox.checked.hover.fg
|
|
2494
|
+
},
|
|
2495
|
+
indeterminateMarkPressed: {
|
|
2496
|
+
backgroundColor: theme.components.checkbox.checked.pressed.fg
|
|
2497
|
+
},
|
|
2169
2498
|
label: {
|
|
2170
2499
|
flexShrink: 1,
|
|
2171
2500
|
fontFamily: theme.tokens.typography.family.regular,
|
|
2172
2501
|
color: theme.components.checkbox.default.fg
|
|
2173
2502
|
},
|
|
2503
|
+
labelChecked: {
|
|
2504
|
+
color: theme.components.checkbox.checked.default.labelFg
|
|
2505
|
+
},
|
|
2506
|
+
labelCheckedHover: {
|
|
2507
|
+
color: theme.components.checkbox.checked.hover.labelFg
|
|
2508
|
+
},
|
|
2509
|
+
labelCheckedPressed: {
|
|
2510
|
+
color: theme.components.checkbox.checked.pressed.labelFg
|
|
2511
|
+
},
|
|
2174
2512
|
labelSm: {
|
|
2175
2513
|
fontSize: theme.tokens.typography.size.sm,
|
|
2176
2514
|
lineHeight: theme.tokens.typography.lineHeight.sm
|
|
@@ -2216,7 +2554,7 @@ var createStyles22 = (theme) => StyleSheet22.create({
|
|
|
2216
2554
|
});
|
|
2217
2555
|
|
|
2218
2556
|
// src/primitives/Checkbox/Checkbox.tsx
|
|
2219
|
-
import { jsx as jsx24, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
2557
|
+
import { Fragment as Fragment4, jsx as jsx24, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
2220
2558
|
var iconSizeBySize = {
|
|
2221
2559
|
sm: 10,
|
|
2222
2560
|
md: 12,
|
|
@@ -2257,7 +2595,7 @@ var Checkbox = forwardRef2(
|
|
|
2257
2595
|
lg: styles.errorTextLg
|
|
2258
2596
|
};
|
|
2259
2597
|
const hasError = Boolean(error);
|
|
2260
|
-
const [isChecked, setIsChecked] =
|
|
2598
|
+
const [isChecked, setIsChecked] = useControllableState3({
|
|
2261
2599
|
value: checked,
|
|
2262
2600
|
defaultValue: defaultChecked,
|
|
2263
2601
|
onChange: onCheckedChange
|
|
@@ -2269,13 +2607,14 @@ var Checkbox = forwardRef2(
|
|
|
2269
2607
|
const resolvedAccessibilityLabel = accessibilityLabel ?? label;
|
|
2270
2608
|
const resolvedAccessibilityHint = [accessibilityHint, description, error].filter(Boolean).join(" ");
|
|
2271
2609
|
const accessibilityChecked = indeterminate ? "mixed" : isChecked;
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2610
|
+
useEffect4(() => {
|
|
2611
|
+
devWarning(
|
|
2612
|
+
Boolean(resolvedAccessibilityLabel),
|
|
2613
|
+
"Checkbox: an accessible label must be provided through label or accessibilityLabel."
|
|
2614
|
+
);
|
|
2615
|
+
}, [resolvedAccessibilityLabel]);
|
|
2277
2616
|
return /* @__PURE__ */ jsxs13(View19, { style: styles.container, children: [
|
|
2278
|
-
/* @__PURE__ */
|
|
2617
|
+
/* @__PURE__ */ jsx24(
|
|
2279
2618
|
Pressable11,
|
|
2280
2619
|
{
|
|
2281
2620
|
...PressableProps,
|
|
@@ -2295,35 +2634,50 @@ var Checkbox = forwardRef2(
|
|
|
2295
2634
|
disabled && styles.disabled,
|
|
2296
2635
|
style
|
|
2297
2636
|
],
|
|
2298
|
-
children:
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2637
|
+
children: ({ pressed }) => {
|
|
2638
|
+
const isSelected = isChecked || indeterminate;
|
|
2639
|
+
const checkColor = disabled ? theme.components.checkbox.disabled.fg : pressed && isSelected ? theme.components.checkbox.checked.pressed.fg : theme.components.checkbox.checked.default.fg;
|
|
2640
|
+
return /* @__PURE__ */ jsxs13(Fragment4, { children: [
|
|
2641
|
+
/* @__PURE__ */ jsx24(
|
|
2642
|
+
View19,
|
|
2643
|
+
{
|
|
2644
|
+
style: [
|
|
2645
|
+
styles.box,
|
|
2646
|
+
boxSizeStyle[size],
|
|
2647
|
+
isSelected && styles.boxChecked,
|
|
2648
|
+
isSelected && pressed && styles.boxCheckedPressed,
|
|
2649
|
+
hasError && styles.boxError,
|
|
2650
|
+
disabled && styles.boxDisabled
|
|
2651
|
+
],
|
|
2652
|
+
children: indeterminate ? /* @__PURE__ */ jsx24(
|
|
2653
|
+
View19,
|
|
2654
|
+
{
|
|
2655
|
+
style: [
|
|
2656
|
+
styles.indeterminateMark,
|
|
2657
|
+
pressed && styles.indeterminateMarkPressed
|
|
2658
|
+
]
|
|
2659
|
+
}
|
|
2660
|
+
) : isChecked && /* @__PURE__ */ jsx24(Check, { size: iconSizeBySize[size], color: checkColor })
|
|
2661
|
+
}
|
|
2662
|
+
),
|
|
2663
|
+
label && /* @__PURE__ */ jsxs13(
|
|
2664
|
+
Text12,
|
|
2665
|
+
{
|
|
2666
|
+
style: [
|
|
2667
|
+
styles.label,
|
|
2668
|
+
labelSizeStyle[size],
|
|
2669
|
+
isSelected && styles.labelChecked,
|
|
2670
|
+
isSelected && pressed && styles.labelCheckedPressed,
|
|
2671
|
+
disabled && styles.labelDisabled
|
|
2672
|
+
],
|
|
2673
|
+
children: [
|
|
2674
|
+
label,
|
|
2675
|
+
required && /* @__PURE__ */ jsx24(Text12, { style: styles.requiredMark, children: " *" })
|
|
2676
|
+
]
|
|
2677
|
+
}
|
|
2678
|
+
)
|
|
2679
|
+
] });
|
|
2680
|
+
}
|
|
2327
2681
|
}
|
|
2328
2682
|
),
|
|
2329
2683
|
description && /* @__PURE__ */ jsx24(
|
|
@@ -2344,13 +2698,14 @@ var Checkbox = forwardRef2(
|
|
|
2344
2698
|
Checkbox.displayName = "Checkbox";
|
|
2345
2699
|
|
|
2346
2700
|
// src/primitives/Input/Input.tsx
|
|
2347
|
-
import { cloneElement as
|
|
2701
|
+
import { cloneElement as cloneElement6, forwardRef as forwardRef3, useState as useState6 } from "react";
|
|
2348
2702
|
import { Pressable as Pressable12, Text as Text13, TextInput, View as View20 } from "react-native";
|
|
2349
2703
|
|
|
2350
2704
|
// src/primitives/Input/Input.styles.ts
|
|
2351
2705
|
import { StyleSheet as StyleSheet23 } from "react-native";
|
|
2352
2706
|
var getPlaceholderTextColor = (theme) => theme.components.input.default.placeholder;
|
|
2353
2707
|
var getDisabledPlaceholderTextColor = (theme) => theme.components.input.disabled.placeholder;
|
|
2708
|
+
var resolveRingColor = (ring) => typeof ring === "string" ? ring : ring.color;
|
|
2354
2709
|
var createStyles23 = (theme) => StyleSheet23.create({
|
|
2355
2710
|
inputWrapper: {
|
|
2356
2711
|
position: "relative",
|
|
@@ -2406,15 +2761,18 @@ var createStyles23 = (theme) => StyleSheet23.create({
|
|
|
2406
2761
|
width: 20,
|
|
2407
2762
|
height: 20,
|
|
2408
2763
|
marginTop: -10,
|
|
2409
|
-
borderRadius:
|
|
2764
|
+
borderRadius: theme.tokens.radius.full,
|
|
2410
2765
|
alignItems: "center",
|
|
2411
2766
|
justifyContent: "center"
|
|
2412
2767
|
},
|
|
2413
2768
|
clearButtonText: {
|
|
2414
|
-
color: theme.components.input.
|
|
2769
|
+
color: theme.components.input.clearButton.fg,
|
|
2415
2770
|
fontSize: 16,
|
|
2416
2771
|
lineHeight: 20
|
|
2417
2772
|
},
|
|
2773
|
+
clearButtonPressed: {
|
|
2774
|
+
backgroundColor: theme.components.input.clearButton.pressedBg
|
|
2775
|
+
},
|
|
2418
2776
|
sm: {
|
|
2419
2777
|
minHeight: 36,
|
|
2420
2778
|
paddingHorizontal: theme.tokens.spacing[3],
|
|
@@ -2433,17 +2791,47 @@ var createStyles23 = (theme) => StyleSheet23.create({
|
|
|
2433
2791
|
paddingVertical: theme.tokens.spacing[4],
|
|
2434
2792
|
fontSize: theme.tokens.typography.size.lg
|
|
2435
2793
|
},
|
|
2436
|
-
error: {
|
|
2437
|
-
borderColor: theme.components.input.error.border
|
|
2438
|
-
},
|
|
2439
2794
|
focused: {
|
|
2440
2795
|
color: theme.components.input.focus.fg,
|
|
2441
2796
|
backgroundColor: theme.components.input.focus.bg,
|
|
2442
|
-
borderColor: theme.components.input.focus.border
|
|
2797
|
+
borderColor: theme.components.input.focus.border,
|
|
2798
|
+
shadowColor: resolveRingColor(theme.components.input.focus.ring),
|
|
2799
|
+
shadowOffset: {
|
|
2800
|
+
width: 0,
|
|
2801
|
+
height: 0
|
|
2802
|
+
},
|
|
2803
|
+
shadowOpacity: 0.18,
|
|
2804
|
+
shadowRadius: 6,
|
|
2805
|
+
elevation: 1
|
|
2443
2806
|
},
|
|
2444
|
-
|
|
2807
|
+
error: {
|
|
2445
2808
|
borderColor: theme.components.input.error.border
|
|
2446
2809
|
},
|
|
2810
|
+
errorFocused: {
|
|
2811
|
+
borderColor: theme.components.input.error.border,
|
|
2812
|
+
shadowColor: resolveRingColor(theme.components.input.error.ring),
|
|
2813
|
+
shadowOffset: {
|
|
2814
|
+
width: 0,
|
|
2815
|
+
height: 0
|
|
2816
|
+
},
|
|
2817
|
+
shadowOpacity: 0.2,
|
|
2818
|
+
shadowRadius: 6,
|
|
2819
|
+
elevation: 1
|
|
2820
|
+
},
|
|
2821
|
+
success: {
|
|
2822
|
+
borderColor: theme.components.input.success.border
|
|
2823
|
+
},
|
|
2824
|
+
successFocused: {
|
|
2825
|
+
borderColor: theme.components.input.success.border,
|
|
2826
|
+
shadowColor: resolveRingColor(theme.components.input.success.ring),
|
|
2827
|
+
shadowOffset: {
|
|
2828
|
+
width: 0,
|
|
2829
|
+
height: 0
|
|
2830
|
+
},
|
|
2831
|
+
shadowOpacity: 0.18,
|
|
2832
|
+
shadowRadius: 6,
|
|
2833
|
+
elevation: 1
|
|
2834
|
+
},
|
|
2447
2835
|
readOnly: {
|
|
2448
2836
|
color: theme.components.input.readOnly.fg,
|
|
2449
2837
|
borderColor: theme.components.input.readOnly.border,
|
|
@@ -2526,8 +2914,8 @@ var Input = forwardRef3(
|
|
|
2526
2914
|
}, ref) => {
|
|
2527
2915
|
const { theme } = useTheme();
|
|
2528
2916
|
const styles = useThemeStyles(createStyles23);
|
|
2529
|
-
const [isFocused, setIsFocused] =
|
|
2530
|
-
const [uncontrolledValue, setUncontrolledValue] =
|
|
2917
|
+
const [isFocused, setIsFocused] = useState6(false);
|
|
2918
|
+
const [uncontrolledValue, setUncontrolledValue] = useState6(
|
|
2531
2919
|
defaultValue ?? ""
|
|
2532
2920
|
);
|
|
2533
2921
|
const isControlled = value !== void 0;
|
|
@@ -2578,7 +2966,7 @@ var Input = forwardRef3(
|
|
|
2578
2966
|
style: styles.leftIcon,
|
|
2579
2967
|
accessibilityElementsHidden: true,
|
|
2580
2968
|
importantForAccessibility: "no",
|
|
2581
|
-
children:
|
|
2969
|
+
children: cloneElement6(leftIcon, {
|
|
2582
2970
|
color: leftIconColor,
|
|
2583
2971
|
size: resolvedIconSize
|
|
2584
2972
|
})
|
|
@@ -2628,7 +3016,7 @@ var Input = forwardRef3(
|
|
|
2628
3016
|
hitSlop: 8,
|
|
2629
3017
|
onPress: handleClear,
|
|
2630
3018
|
style: styles.clearButton,
|
|
2631
|
-
children: clearIcon ?
|
|
3019
|
+
children: clearIcon ? cloneElement6(clearIcon, {
|
|
2632
3020
|
color: clearIconColor,
|
|
2633
3021
|
size: resolvedIconSize
|
|
2634
3022
|
}) : /* @__PURE__ */ jsx25(
|
|
@@ -2646,7 +3034,7 @@ var Input = forwardRef3(
|
|
|
2646
3034
|
style: styles.rightIcon,
|
|
2647
3035
|
accessibilityElementsHidden: true,
|
|
2648
3036
|
importantForAccessibility: "no",
|
|
2649
|
-
children:
|
|
3037
|
+
children: cloneElement6(rightIcon, {
|
|
2650
3038
|
color: rightIconColor,
|
|
2651
3039
|
size: resolvedIconSize
|
|
2652
3040
|
})
|
|
@@ -2660,8 +3048,8 @@ var Input = forwardRef3(
|
|
|
2660
3048
|
Input.displayName = "Input";
|
|
2661
3049
|
|
|
2662
3050
|
// src/primitives/Radio/Radio.tsx
|
|
2663
|
-
import { forwardRef as forwardRef4, useEffect as
|
|
2664
|
-
import { useControllableState as
|
|
3051
|
+
import { forwardRef as forwardRef4, useEffect as useEffect5 } from "react";
|
|
3052
|
+
import { useControllableState as useControllableState4 } from "@vellira-ui/core";
|
|
2665
3053
|
import {
|
|
2666
3054
|
Pressable as Pressable13,
|
|
2667
3055
|
Text as Text14,
|
|
@@ -2697,7 +3085,11 @@ var createStyles24 = (theme) => StyleSheet24.create({
|
|
|
2697
3085
|
},
|
|
2698
3086
|
controlChecked: {
|
|
2699
3087
|
borderColor: theme.components.radio.checked.default.border,
|
|
2700
|
-
backgroundColor: theme.components.radio.default.bg
|
|
3088
|
+
backgroundColor: theme.components.radio.checked.default.bg
|
|
3089
|
+
},
|
|
3090
|
+
controlCheckedPressed: {
|
|
3091
|
+
borderColor: theme.components.radio.checked.pressed.border,
|
|
3092
|
+
backgroundColor: theme.components.radio.checked.pressed.bg
|
|
2701
3093
|
},
|
|
2702
3094
|
controlInvalid: {
|
|
2703
3095
|
borderColor: theme.components.radio.invalid.border
|
|
@@ -2706,12 +3098,19 @@ var createStyles24 = (theme) => StyleSheet24.create({
|
|
|
2706
3098
|
borderColor: theme.components.radio.disabled.border,
|
|
2707
3099
|
backgroundColor: theme.components.radio.disabled.bg
|
|
2708
3100
|
},
|
|
3101
|
+
controlCheckedDisabled: {
|
|
3102
|
+
borderColor: theme.components.radio.checked.disabled.border,
|
|
3103
|
+
backgroundColor: theme.components.radio.checked.disabled.bg
|
|
3104
|
+
},
|
|
2709
3105
|
indicator: {
|
|
2710
3106
|
borderRadius: theme.tokens.radius.full,
|
|
2711
|
-
backgroundColor: theme.components.radio.checked.default.
|
|
3107
|
+
backgroundColor: theme.components.radio.checked.default.fg
|
|
3108
|
+
},
|
|
3109
|
+
indicatorPressed: {
|
|
3110
|
+
backgroundColor: theme.components.radio.checked.pressed.fg
|
|
2712
3111
|
},
|
|
2713
3112
|
indicatorDisabled: {
|
|
2714
|
-
backgroundColor: theme.components.radio.checked.disabled.
|
|
3113
|
+
backgroundColor: theme.components.radio.checked.disabled.fg
|
|
2715
3114
|
},
|
|
2716
3115
|
content: {
|
|
2717
3116
|
flexShrink: 1,
|
|
@@ -2722,7 +3121,10 @@ var createStyles24 = (theme) => StyleSheet24.create({
|
|
|
2722
3121
|
fontFamily: theme.tokens.typography.family.regular
|
|
2723
3122
|
},
|
|
2724
3123
|
labelChecked: {
|
|
2725
|
-
color: theme.components.radio.checked.default.
|
|
3124
|
+
color: theme.components.radio.checked.default.labelFg
|
|
3125
|
+
},
|
|
3126
|
+
labelCheckedPressed: {
|
|
3127
|
+
color: theme.components.radio.checked.pressed.labelFg
|
|
2726
3128
|
},
|
|
2727
3129
|
labelInvalid: {
|
|
2728
3130
|
color: theme.components.radio.invalid.fg
|
|
@@ -2777,7 +3179,7 @@ var Radio = forwardRef4(
|
|
|
2777
3179
|
const styles = createStyles24(theme);
|
|
2778
3180
|
const group = useRadioGroupContext();
|
|
2779
3181
|
const isInsideGroup = group !== null;
|
|
2780
|
-
const [standaloneChecked, setStandaloneChecked] =
|
|
3182
|
+
const [standaloneChecked, setStandaloneChecked] = useControllableState4({
|
|
2781
3183
|
value: checked,
|
|
2782
3184
|
defaultValue: defaultChecked,
|
|
2783
3185
|
onChange: onCheckedChange
|
|
@@ -2811,7 +3213,7 @@ var Radio = forwardRef4(
|
|
|
2811
3213
|
};
|
|
2812
3214
|
const typographySize = typographySizeByRadioSize[resolvedSize];
|
|
2813
3215
|
const controlMarginTop = (typographySize.labelLineHeight - controlSize) / 2;
|
|
2814
|
-
|
|
3216
|
+
useEffect5(() => {
|
|
2815
3217
|
if (typeof __DEV__ !== "undefined" && __DEV__ && !label && !accessibilityLabel) {
|
|
2816
3218
|
console.warn(
|
|
2817
3219
|
"Radio requires either a visible label or accessibilityLabel."
|