panelui-native 0.107.1 → 0.109.0
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/lib/module/components/avatar/index.js +7 -1
- package/lib/module/components/avatar/index.js.map +1 -1
- package/lib/module/components/badge/index.js +85 -4
- package/lib/module/components/badge/index.js.map +1 -1
- package/lib/module/components/button/index.js +12 -0
- package/lib/module/components/button/index.js.map +1 -1
- package/lib/module/components/button-group/index.js +3 -0
- package/lib/module/components/button-group/index.js.map +1 -1
- package/lib/module/components/checkbox/index.js +54 -4
- package/lib/module/components/checkbox/index.js.map +1 -1
- package/lib/module/components/chip/index.js +23 -1
- package/lib/module/components/chip/index.js.map +1 -1
- package/lib/module/components/input/index.js +14 -0
- package/lib/module/components/input/index.js.map +1 -1
- package/lib/module/components/map/index.js +157 -5
- package/lib/module/components/map/index.js.map +1 -1
- package/lib/module/components/map/map-insets.js +174 -0
- package/lib/module/components/map/map-insets.js.map +1 -0
- package/lib/module/components/radio-group/index.js +49 -3
- package/lib/module/components/radio-group/index.js.map +1 -1
- package/lib/module/components/select/index.js +54 -2
- package/lib/module/components/select/index.js.map +1 -1
- package/lib/module/components/switch/index.js +42 -3
- package/lib/module/components/switch/index.js.map +1 -1
- package/lib/module/components/tabs/index.js +147 -1
- package/lib/module/components/tabs/index.js.map +1 -1
- package/lib/module/components/textarea/index.js +18 -0
- package/lib/module/components/textarea/index.js.map +1 -1
- package/lib/module/components/toggle-button/index.js +34 -2
- package/lib/module/components/toggle-button/index.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/components/avatar/index.d.ts.map +1 -1
- package/lib/typescript/src/components/badge/index.d.ts +68 -0
- package/lib/typescript/src/components/badge/index.d.ts.map +1 -1
- package/lib/typescript/src/components/button/index.d.ts +12 -0
- package/lib/typescript/src/components/button/index.d.ts.map +1 -1
- package/lib/typescript/src/components/button-group/index.d.ts +9 -0
- package/lib/typescript/src/components/button-group/index.d.ts.map +1 -1
- package/lib/typescript/src/components/checkbox/index.d.ts +89 -0
- package/lib/typescript/src/components/checkbox/index.d.ts.map +1 -1
- package/lib/typescript/src/components/chip/index.d.ts +24 -0
- package/lib/typescript/src/components/chip/index.d.ts.map +1 -1
- package/lib/typescript/src/components/input/index.d.ts +30 -0
- package/lib/typescript/src/components/input/index.d.ts.map +1 -1
- package/lib/typescript/src/components/map/index.d.ts +67 -1
- package/lib/typescript/src/components/map/index.d.ts.map +1 -1
- package/lib/typescript/src/components/map/map-insets.d.ts +80 -0
- package/lib/typescript/src/components/map/map-insets.d.ts.map +1 -0
- package/lib/typescript/src/components/radio-group/index.d.ts +188 -1
- package/lib/typescript/src/components/radio-group/index.d.ts.map +1 -1
- package/lib/typescript/src/components/select/index.d.ts +9 -1
- package/lib/typescript/src/components/select/index.d.ts.map +1 -1
- package/lib/typescript/src/components/switch/index.d.ts +38 -0
- package/lib/typescript/src/components/switch/index.d.ts.map +1 -1
- package/lib/typescript/src/components/tabs/index.d.ts +10 -1
- package/lib/typescript/src/components/tabs/index.d.ts.map +1 -1
- package/lib/typescript/src/components/textarea/index.d.ts +18 -0
- package/lib/typescript/src/components/textarea/index.d.ts.map +1 -1
- package/lib/typescript/src/components/toggle-button/index.d.ts +24 -0
- package/lib/typescript/src/components/toggle-button/index.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +7 -7
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/components/avatar/index.tsx +7 -1
- package/src/components/badge/index.tsx +30 -4
- package/src/components/button/index.tsx +9 -2
- package/src/components/button-group/index.tsx +1 -0
- package/src/components/checkbox/index.tsx +47 -3
- package/src/components/chip/index.tsx +5 -1
- package/src/components/input/index.tsx +6 -0
- package/src/components/map/index.tsx +215 -5
- package/src/components/map/map-insets.ts +169 -0
- package/src/components/radio-group/index.tsx +56 -4
- package/src/components/select/index.tsx +50 -1
- package/src/components/switch/index.tsx +16 -4
- package/src/components/tabs/index.tsx +61 -0
- package/src/components/textarea/index.tsx +6 -0
- package/src/components/toggle-button/index.tsx +16 -1
- package/src/index.ts +8 -3
|
@@ -94,6 +94,33 @@ const selectVariants = tv({
|
|
|
94
94
|
groupLabel: 'px-3 pb-1 pt-2',
|
|
95
95
|
},
|
|
96
96
|
variants: {
|
|
97
|
+
/*
|
|
98
|
+
* The trigger only. The options are read in a sheet or a list of their
|
|
99
|
+
* own, at one size, however compact the field that opened them is.
|
|
100
|
+
*/
|
|
101
|
+
size: {
|
|
102
|
+
xs: {
|
|
103
|
+
trigger: 'gap-2 px-2.5 py-1.5',
|
|
104
|
+
triggerLabel: 'text-[13px]',
|
|
105
|
+
placeholder: 'text-[13px]',
|
|
106
|
+
},
|
|
107
|
+
sm: {
|
|
108
|
+
trigger: 'gap-2 px-3 py-2.5',
|
|
109
|
+
triggerLabel: 'text-sm',
|
|
110
|
+
placeholder: 'text-sm',
|
|
111
|
+
},
|
|
112
|
+
md: {},
|
|
113
|
+
lg: {
|
|
114
|
+
trigger: 'py-4',
|
|
115
|
+
triggerLabel: 'text-lg',
|
|
116
|
+
placeholder: 'text-lg',
|
|
117
|
+
},
|
|
118
|
+
xl: {
|
|
119
|
+
trigger: 'px-5 py-5',
|
|
120
|
+
triggerLabel: 'text-lg',
|
|
121
|
+
placeholder: 'text-lg',
|
|
122
|
+
},
|
|
123
|
+
},
|
|
97
124
|
selected: {
|
|
98
125
|
true: { item: 'bg-accent' },
|
|
99
126
|
},
|
|
@@ -111,11 +138,24 @@ const selectVariants = tv({
|
|
|
111
138
|
},
|
|
112
139
|
defaultVariants: {
|
|
113
140
|
presentation: 'sheet',
|
|
141
|
+
size: 'md',
|
|
114
142
|
},
|
|
115
143
|
});
|
|
116
144
|
|
|
117
145
|
export type SelectPresentation = 'sheet' | 'inline' | 'overlay';
|
|
118
146
|
|
|
147
|
+
/** How big the trigger is. */
|
|
148
|
+
export type SelectSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
149
|
+
|
|
150
|
+
/** The chevron keeps step with the label beside it. */
|
|
151
|
+
const CHEVRON_SIZE: Record<SelectSize, number> = { xs: 12, sm: 14, md: 16, lg: 18, xl: 20 };
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* What the `xs` trigger is short of a 44pt target, above and below. The
|
|
155
|
+
* trigger is as wide as its container, so there is nothing to add at the sides.
|
|
156
|
+
*/
|
|
157
|
+
const XS_TRIGGER_HIT_SLOP = { top: 7, bottom: 7 };
|
|
158
|
+
|
|
119
159
|
interface SelectContextValue {
|
|
120
160
|
value: string | undefined;
|
|
121
161
|
onSelect: (value: string) => void;
|
|
@@ -399,6 +439,12 @@ export interface SelectProps {
|
|
|
399
439
|
placeholder?: string;
|
|
400
440
|
/** Refuses the trigger and dims it. The options cannot be opened. */
|
|
401
441
|
disabled?: boolean;
|
|
442
|
+
/**
|
|
443
|
+
* How big the trigger is: its padding, its text and its chevron. The options
|
|
444
|
+
* it opens are not resized. Ignored in `native` mode, where the platform
|
|
445
|
+
* draws the picker. For the height of the sheet, see `sheetProps.size`.
|
|
446
|
+
*/
|
|
447
|
+
size?: SelectSize;
|
|
402
448
|
/** Extra classes for the trigger — the field you press to open the list. */
|
|
403
449
|
triggerClassName?: string;
|
|
404
450
|
/** Extra classes for the selected option's text on the trigger. */
|
|
@@ -490,6 +536,7 @@ function SelectRoot({
|
|
|
490
536
|
searchContainerClassName,
|
|
491
537
|
emptyClassName,
|
|
492
538
|
presentation = 'sheet',
|
|
539
|
+
size = 'md',
|
|
493
540
|
title,
|
|
494
541
|
sheetProps,
|
|
495
542
|
contentWidth = 'trigger',
|
|
@@ -604,7 +651,7 @@ function SelectRoot({
|
|
|
604
651
|
[value, onValueChange, close, query]
|
|
605
652
|
);
|
|
606
653
|
|
|
607
|
-
const slots = selectVariants({ disabled: !!disabled, presentation });
|
|
654
|
+
const slots = selectVariants({ disabled: !!disabled, presentation, size });
|
|
608
655
|
const chevronColor = useCSSVariable('--color-muted-foreground');
|
|
609
656
|
|
|
610
657
|
const chevronStyle = useAnimatedStyle(() => ({
|
|
@@ -646,6 +693,7 @@ function SelectRoot({
|
|
|
646
693
|
*/
|
|
647
694
|
accessibilityRole="combobox"
|
|
648
695
|
accessibilityState={{ disabled: !!disabled, expanded: open }}
|
|
696
|
+
hitSlop={size === 'xs' ? XS_TRIGGER_HIT_SLOP : undefined}
|
|
649
697
|
disabled={disabled}
|
|
650
698
|
onPress={toggle}
|
|
651
699
|
className={slots.trigger({ className: triggerClassName })}
|
|
@@ -657,6 +705,7 @@ function SelectRoot({
|
|
|
657
705
|
)}
|
|
658
706
|
<Animated.View style={chevronStyle}>
|
|
659
707
|
<ChevronDownIcon
|
|
708
|
+
size={CHEVRON_SIZE[size]}
|
|
660
709
|
color={typeof chevronColor === 'string' ? chevronColor : '#737373'}
|
|
661
710
|
/>
|
|
662
711
|
</Animated.View>
|
|
@@ -21,9 +21,15 @@ const switchVariants = tv({
|
|
|
21
21
|
thumb: 'rounded-full bg-white shadow-sm',
|
|
22
22
|
},
|
|
23
23
|
variants: {
|
|
24
|
+
// Each track is its thumb plus the 3pt of padding and 1pt of border on
|
|
25
|
+
// either side, and twice as wide as it is tall. `TRAVEL` below is what is
|
|
26
|
+
// left of that width once the thumb is in it.
|
|
24
27
|
size: {
|
|
28
|
+
xs: { track: 'h-5 w-8', thumb: 'h-3 w-3' },
|
|
25
29
|
sm: { track: 'h-6 w-10', thumb: 'h-4 w-4' },
|
|
26
30
|
md: { track: 'h-7 w-12', thumb: 'h-5 w-5' },
|
|
31
|
+
lg: { track: 'h-8 w-14', thumb: 'h-6 w-6' },
|
|
32
|
+
xl: { track: 'h-9 w-16', thumb: 'h-7 w-7' },
|
|
27
33
|
},
|
|
28
34
|
disabled: {
|
|
29
35
|
true: { track: 'opacity-50' },
|
|
@@ -34,19 +40,25 @@ const switchVariants = tv({
|
|
|
34
40
|
},
|
|
35
41
|
});
|
|
36
42
|
|
|
37
|
-
|
|
43
|
+
/** How big a switch is. */
|
|
44
|
+
export type SwitchSize = NonNullable<VariantProps<typeof switchVariants>['size']>;
|
|
45
|
+
|
|
46
|
+
const TRAVEL: Record<SwitchSize, number> = { xs: 12, sm: 16, md: 20, lg: 24, xl: 28 };
|
|
38
47
|
|
|
39
48
|
/**
|
|
40
49
|
* Room around each track so the target reaches 48dp on both axes.
|
|
41
50
|
*
|
|
42
51
|
* Slop rather than a bigger box, because a box is layout: a switch sized to
|
|
43
52
|
* its target would stand 48dp tall in every row it has ever been placed in,
|
|
44
|
-
* and the tracks are
|
|
45
|
-
* which is why the
|
|
53
|
+
* and the tracks are 20 to 36 tall. From `md` up the track is already 48 wide,
|
|
54
|
+
* which is why only the two smallest have horizontal figures.
|
|
46
55
|
*/
|
|
47
|
-
const SWITCH_HIT_SLOP: Record<
|
|
56
|
+
const SWITCH_HIT_SLOP: Record<SwitchSize, { top: number; bottom: number; left: number; right: number }> = {
|
|
57
|
+
xs: { top: 14, bottom: 14, left: 8, right: 8 },
|
|
48
58
|
sm: { top: 12, bottom: 12, left: 4, right: 4 },
|
|
49
59
|
md: { top: 10, bottom: 10, left: 0, right: 0 },
|
|
60
|
+
lg: { top: 8, bottom: 8, left: 0, right: 0 },
|
|
61
|
+
xl: { top: 6, bottom: 6, left: 0, right: 0 },
|
|
50
62
|
};
|
|
51
63
|
|
|
52
64
|
export interface SwitchProps
|
|
@@ -119,6 +119,21 @@ const MEASURE_WIDTH = 400;
|
|
|
119
119
|
|
|
120
120
|
export type TabsVariant = 'segmented' | 'underline' | 'pill' | 'expanding';
|
|
121
121
|
|
|
122
|
+
/** How big the triggers and their labels are. */
|
|
123
|
+
export type TabsSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Room above and below the two smallest sizes, so a row that is drawn 20 or 24
|
|
127
|
+
* points tall is still pressed like one that is 44.
|
|
128
|
+
*
|
|
129
|
+
* Vertical only. The triggers sit edge to edge in a row, and slop to the side
|
|
130
|
+
* would reach into the neighbouring tab and take its presses.
|
|
131
|
+
*/
|
|
132
|
+
const TRIGGER_HIT_SLOP: Partial<Record<TabsSize, { top: number; bottom: number }>> = {
|
|
133
|
+
xs: { top: 12, bottom: 12 },
|
|
134
|
+
sm: { top: 8, bottom: 8 },
|
|
135
|
+
};
|
|
136
|
+
|
|
122
137
|
/**
|
|
123
138
|
* How much of an inactive panel survives a switch away from it.
|
|
124
139
|
*
|
|
@@ -187,6 +202,21 @@ const tabsVariants = tv({
|
|
|
187
202
|
trigger: 'rounded-full bg-muted px-3.5 py-2.5',
|
|
188
203
|
},
|
|
189
204
|
},
|
|
205
|
+
/*
|
|
206
|
+
* The label's type size. `md` adds nothing, so it is whatever the label
|
|
207
|
+
* was drawn at before sizes existed.
|
|
208
|
+
*
|
|
209
|
+
* How tall a trigger is depends on the variant as well, since each draws
|
|
210
|
+
* its tab differently, so the padding per size is in the compound variants
|
|
211
|
+
* below rather than here.
|
|
212
|
+
*/
|
|
213
|
+
size: {
|
|
214
|
+
xs: { label: 'text-xs' },
|
|
215
|
+
sm: { label: 'text-[13px]' },
|
|
216
|
+
md: {},
|
|
217
|
+
lg: { label: 'text-base' },
|
|
218
|
+
xl: { label: 'text-lg' },
|
|
219
|
+
},
|
|
190
220
|
active: {
|
|
191
221
|
true: { label: 'text-foreground' },
|
|
192
222
|
false: { label: 'text-muted-foreground' },
|
|
@@ -207,9 +237,27 @@ const tabsVariants = tv({
|
|
|
207
237
|
// exists to avoid.
|
|
208
238
|
{ variant: 'expanding', class: { trigger: 'flex-none' } },
|
|
209
239
|
{ variant: 'expanding', active: true, class: { trigger: 'bg-surface-tertiary' } },
|
|
240
|
+
// Half a step of padding per size, either side of the variant's own.
|
|
241
|
+
{ variant: 'segmented', size: 'xs', class: { trigger: 'py-0.5' } },
|
|
242
|
+
{ variant: 'segmented', size: 'sm', class: { trigger: 'py-1' } },
|
|
243
|
+
{ variant: 'segmented', size: 'lg', class: { trigger: 'py-2' } },
|
|
244
|
+
{ variant: 'segmented', size: 'xl', class: { trigger: 'py-2.5' } },
|
|
245
|
+
{ variant: 'underline', size: 'xs', class: { trigger: 'py-1.5' } },
|
|
246
|
+
{ variant: 'underline', size: 'sm', class: { trigger: 'py-2' } },
|
|
247
|
+
{ variant: 'underline', size: 'lg', class: { trigger: 'py-3' } },
|
|
248
|
+
{ variant: 'underline', size: 'xl', class: { trigger: 'py-3.5' } },
|
|
249
|
+
{ variant: 'pill', size: 'xs', class: { trigger: 'py-1' } },
|
|
250
|
+
{ variant: 'pill', size: 'sm', class: { trigger: 'py-1.5' } },
|
|
251
|
+
{ variant: 'pill', size: 'lg', class: { trigger: 'py-2.5' } },
|
|
252
|
+
{ variant: 'pill', size: 'xl', class: { trigger: 'py-3' } },
|
|
253
|
+
{ variant: 'expanding', size: 'xs', class: { trigger: 'px-2.5 py-1.5' } },
|
|
254
|
+
{ variant: 'expanding', size: 'sm', class: { trigger: 'px-3 py-2' } },
|
|
255
|
+
{ variant: 'expanding', size: 'lg', class: { trigger: 'px-4 py-3' } },
|
|
256
|
+
{ variant: 'expanding', size: 'xl', class: { trigger: 'px-5 py-3.5' } },
|
|
210
257
|
],
|
|
211
258
|
defaultVariants: {
|
|
212
259
|
variant: 'segmented',
|
|
260
|
+
size: 'md',
|
|
213
261
|
scrollable: false,
|
|
214
262
|
},
|
|
215
263
|
});
|
|
@@ -225,6 +273,7 @@ interface TabsContextValue {
|
|
|
225
273
|
registerLayout: (value: string, layout: TabLayout) => void;
|
|
226
274
|
layouts: Record<string, TabLayout>;
|
|
227
275
|
variant: TabsVariant;
|
|
276
|
+
size: TabsSize;
|
|
228
277
|
keepMounted: TabsKeepMounted;
|
|
229
278
|
/**
|
|
230
279
|
* Whether the panels are in a strip rather than stacked in place.
|
|
@@ -280,6 +329,13 @@ export interface TabsProps extends ViewProps {
|
|
|
280
329
|
* every trigger an `icon` — a closed tab has nothing else.
|
|
281
330
|
*/
|
|
282
331
|
variant?: TabsVariant;
|
|
332
|
+
/**
|
|
333
|
+
* How big the triggers and their labels are. `xs` and `sm` are for a tab set
|
|
334
|
+
* inside something else, such as a card or a toolbar; `lg` and `xl` are for
|
|
335
|
+
* one that is the main navigation of a screen. Icons and badges you pass are
|
|
336
|
+
* not resized.
|
|
337
|
+
*/
|
|
338
|
+
size?: TabsSize;
|
|
283
339
|
/**
|
|
284
340
|
* Mount every panel up front instead of only the ones that have been
|
|
285
341
|
* reached, so a scroll position or a half-filled form is there from the
|
|
@@ -378,6 +434,7 @@ function TabsRoot({
|
|
|
378
434
|
onValueChange,
|
|
379
435
|
defaultValue,
|
|
380
436
|
variant = 'segmented',
|
|
437
|
+
size = 'md',
|
|
381
438
|
keepMounted = false,
|
|
382
439
|
swipeable = false,
|
|
383
440
|
animation,
|
|
@@ -427,6 +484,7 @@ function TabsRoot({
|
|
|
427
484
|
registerLayout,
|
|
428
485
|
layouts,
|
|
429
486
|
variant,
|
|
487
|
+
size,
|
|
430
488
|
keepMounted,
|
|
431
489
|
pager: paged,
|
|
432
490
|
animationDisabled,
|
|
@@ -437,6 +495,7 @@ function TabsRoot({
|
|
|
437
495
|
registerLayout,
|
|
438
496
|
layouts,
|
|
439
497
|
variant,
|
|
498
|
+
size,
|
|
440
499
|
keepMounted,
|
|
441
500
|
paged,
|
|
442
501
|
animationDisabled,
|
|
@@ -901,6 +960,7 @@ function TabsTrigger({
|
|
|
901
960
|
const active = context.value === value;
|
|
902
961
|
const slots = tabsVariants({
|
|
903
962
|
variant: context.variant,
|
|
963
|
+
size: context.size,
|
|
904
964
|
active,
|
|
905
965
|
disabled,
|
|
906
966
|
scrollable,
|
|
@@ -948,6 +1008,7 @@ function TabsTrigger({
|
|
|
948
1008
|
disabled={disabled}
|
|
949
1009
|
onPress={() => context.setValue(value)}
|
|
950
1010
|
onLayout={handleLayout}
|
|
1011
|
+
hitSlop={TRIGGER_HIT_SLOP[context.size]}
|
|
951
1012
|
className={cn(slots.trigger(), (icon || badge) && 'flex-row gap-1.5', className)}
|
|
952
1013
|
>
|
|
953
1014
|
{icon}
|
|
@@ -53,9 +53,11 @@ const FOCUS_DURATION = 150;
|
|
|
53
53
|
* them here as well is what lets `rows` and `size` compose.
|
|
54
54
|
*/
|
|
55
55
|
const METRICS = {
|
|
56
|
+
xs: { fontSize: 13, lineHeight: 18, padding: 8 },
|
|
56
57
|
sm: { fontSize: 14, lineHeight: 20, padding: 10 },
|
|
57
58
|
md: { fontSize: 16, lineHeight: 22, padding: 12 },
|
|
58
59
|
lg: { fontSize: 16, lineHeight: 24, padding: 14 },
|
|
60
|
+
xl: { fontSize: 18, lineHeight: 26, padding: 16 },
|
|
59
61
|
} as const;
|
|
60
62
|
|
|
61
63
|
const textareaVariants = tv({
|
|
@@ -82,10 +84,14 @@ const textareaVariants = tv({
|
|
|
82
84
|
outline: { field: 'bg-background' },
|
|
83
85
|
filled: { field: 'bg-muted' },
|
|
84
86
|
},
|
|
87
|
+
// The same horizontal padding and type size as Input at each step, so a
|
|
88
|
+
// one-line field and a multi-line one stacked in a form share an edge.
|
|
85
89
|
size: {
|
|
90
|
+
xs: { field: 'px-2.5 text-[13px]' },
|
|
86
91
|
sm: { field: 'px-3 text-[14px]' },
|
|
87
92
|
md: { field: 'px-3.5 text-[16px]' },
|
|
88
93
|
lg: { field: 'px-4 text-[16px]' },
|
|
94
|
+
xl: { field: 'px-5 text-[18px]' },
|
|
89
95
|
},
|
|
90
96
|
disabled: {
|
|
91
97
|
true: { field: 'opacity-[0.64]' },
|
|
@@ -58,10 +58,14 @@ const toggleVariants = tv({
|
|
|
58
58
|
/** Nothing at rest — for a dense toolbar where six fills would be noise. */
|
|
59
59
|
ghost: { root: 'bg-transparent' },
|
|
60
60
|
},
|
|
61
|
+
// The same five heights as Button, so a toggle and a button side by side
|
|
62
|
+
// in a toolbar are one row rather than two.
|
|
61
63
|
size: {
|
|
64
|
+
xs: { root: 'h-7 gap-1 rounded-md px-2', label: 'text-xs' },
|
|
62
65
|
sm: { root: 'h-9 gap-1.5 px-2.5', label: 'text-sm' },
|
|
63
66
|
md: { root: 'h-11 px-4', label: 'text-base' },
|
|
64
67
|
lg: { root: 'h-12 px-6', label: 'text-lg' },
|
|
68
|
+
xl: { root: 'h-14 px-8', label: 'text-lg' },
|
|
65
69
|
},
|
|
66
70
|
selected: {
|
|
67
71
|
true: { root: 'border-primary/24 bg-accent', label: 'text-accent-foreground' },
|
|
@@ -76,9 +80,11 @@ const toggleVariants = tv({
|
|
|
76
80
|
},
|
|
77
81
|
compoundVariants: [
|
|
78
82
|
// Square, and sized from the height so the icon sits in the middle.
|
|
83
|
+
{ iconOnly: true, size: 'xs', class: { root: 'w-7' } },
|
|
79
84
|
{ iconOnly: true, size: 'sm', class: { root: 'w-9' } },
|
|
80
85
|
{ iconOnly: true, size: 'md', class: { root: 'w-11' } },
|
|
81
86
|
{ iconOnly: true, size: 'lg', class: { root: 'w-12' } },
|
|
87
|
+
{ iconOnly: true, size: 'xl', class: { root: 'w-14' } },
|
|
82
88
|
],
|
|
83
89
|
defaultVariants: {
|
|
84
90
|
variant: 'default',
|
|
@@ -86,6 +92,9 @@ const toggleVariants = tv({
|
|
|
86
92
|
},
|
|
87
93
|
});
|
|
88
94
|
|
|
95
|
+
/** What `xs` is short of a 44pt target on each side. */
|
|
96
|
+
const XS_HIT_SLOP = 8;
|
|
97
|
+
|
|
89
98
|
type ToggleVariantProps = VariantProps<typeof toggleVariants>;
|
|
90
99
|
export type ToggleButtonSize = NonNullable<ToggleVariantProps['size']>;
|
|
91
100
|
export type ToggleButtonVariant = NonNullable<ToggleVariantProps['variant']>;
|
|
@@ -274,6 +283,7 @@ const ToggleButtonRoot = forwardRef<View, ToggleButtonProps>(
|
|
|
274
283
|
selectedClassName,
|
|
275
284
|
unselectedClassName,
|
|
276
285
|
onPress,
|
|
286
|
+
hitSlop,
|
|
277
287
|
...props
|
|
278
288
|
},
|
|
279
289
|
ref
|
|
@@ -291,9 +301,10 @@ const ToggleButtonRoot = forwardRef<View, ToggleButtonProps>(
|
|
|
291
301
|
const isDisabled = disabled || (group?.disabled ?? false);
|
|
292
302
|
const enableHaptics = haptics ?? group?.haptics ?? false;
|
|
293
303
|
|
|
304
|
+
const resolvedSize = size ?? group?.size;
|
|
294
305
|
const slots = toggleVariants({
|
|
295
306
|
variant: variant ?? group?.variant,
|
|
296
|
-
size:
|
|
307
|
+
size: resolvedSize,
|
|
297
308
|
selected,
|
|
298
309
|
iconOnly,
|
|
299
310
|
disabled: isDisabled,
|
|
@@ -342,6 +353,10 @@ const ToggleButtonRoot = forwardRef<View, ToggleButtonProps>(
|
|
|
342
353
|
aria-pressed={selected}
|
|
343
354
|
disabled={isDisabled}
|
|
344
355
|
onPress={handlePress}
|
|
356
|
+
// A 28pt toggle standing alone is given the rest of a 44pt target.
|
|
357
|
+
// Not inside a group, where the slop would reach into its
|
|
358
|
+
// neighbours and take their presses. A caller's own figure wins.
|
|
359
|
+
hitSlop={hitSlop ?? (!group && resolvedSize === 'xs' ? XS_HIT_SLOP : undefined)}
|
|
345
360
|
className={cn(
|
|
346
361
|
slots.root({ className }),
|
|
347
362
|
selected ? selectedClassName : unselectedClassName
|
package/src/index.ts
CHANGED
|
@@ -108,7 +108,7 @@ export {
|
|
|
108
108
|
type AnimatedBadgeSize,
|
|
109
109
|
type AnimatedBadgeStatus,
|
|
110
110
|
} from './components/animated-badge';
|
|
111
|
-
export { Badge, type BadgeProps } from './components/badge';
|
|
111
|
+
export { Badge, type BadgeProps, type BadgeSize } from './components/badge';
|
|
112
112
|
export {
|
|
113
113
|
BarChart,
|
|
114
114
|
useBarChart,
|
|
@@ -346,6 +346,8 @@ export {
|
|
|
346
346
|
type MapPopupProps,
|
|
347
347
|
type MapControlsProps,
|
|
348
348
|
type MapControlsPosition,
|
|
349
|
+
type MapOverlayProps,
|
|
350
|
+
type MapOverlayPosition,
|
|
349
351
|
type MapRouteProps,
|
|
350
352
|
type MapArcProps,
|
|
351
353
|
type MapGeoJSONProps,
|
|
@@ -380,6 +382,7 @@ export {
|
|
|
380
382
|
type SelectItemProps,
|
|
381
383
|
type SelectGroupProps,
|
|
382
384
|
type SelectPresentation,
|
|
385
|
+
type SelectSize,
|
|
383
386
|
type SelectSheetProps,
|
|
384
387
|
} from './components/select';
|
|
385
388
|
export {
|
|
@@ -417,6 +420,7 @@ export {
|
|
|
417
420
|
type TabsTriggerProps,
|
|
418
421
|
type TabsContentProps,
|
|
419
422
|
type TabsVariant,
|
|
423
|
+
type TabsSize,
|
|
420
424
|
type TabsKeepMounted,
|
|
421
425
|
type TabsAnimation,
|
|
422
426
|
} from './components/tabs';
|
|
@@ -462,7 +466,7 @@ export {
|
|
|
462
466
|
type DateRange,
|
|
463
467
|
} from './components/calendar';
|
|
464
468
|
export { Card, type CardProps } from './components/card';
|
|
465
|
-
export { Checkbox, type CheckboxProps } from './components/checkbox';
|
|
469
|
+
export { Checkbox, type CheckboxProps, type CheckboxSize } from './components/checkbox';
|
|
466
470
|
export {
|
|
467
471
|
Chip,
|
|
468
472
|
useChip,
|
|
@@ -1110,6 +1114,7 @@ export {
|
|
|
1110
1114
|
RadioGroup,
|
|
1111
1115
|
type RadioGroupProps,
|
|
1112
1116
|
type RadioGroupItemProps,
|
|
1117
|
+
type RadioSize,
|
|
1113
1118
|
} from './components/radio-group';
|
|
1114
1119
|
export {
|
|
1115
1120
|
Rating,
|
|
@@ -1408,7 +1413,7 @@ export {
|
|
|
1408
1413
|
type SwipeOpenSide,
|
|
1409
1414
|
type SwipeHandle,
|
|
1410
1415
|
} from './components/swipe';
|
|
1411
|
-
export { Switch, type SwitchProps } from './components/switch';
|
|
1416
|
+
export { Switch, type SwitchProps, type SwitchSize } from './components/switch';
|
|
1412
1417
|
export {
|
|
1413
1418
|
TimePicker,
|
|
1414
1419
|
type TimePickerProps,
|