@tallyui/components 3.18.0 → 3.20.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/dist/index.d.ts +473 -37
- package/dist/index.js +3656 -1905
- package/package.json +9 -9
- package/src/cart/cart-columns.tsx +42 -4
- package/src/cart/cart-foot.tsx +2 -2
- package/src/cart/cart-line.tsx +42 -18
- package/src/cart/cart-note-input.tsx +10 -2
- package/src/cart/cart-panel.tsx +4 -1
- package/src/cart/cart-total.tsx +8 -5
- package/src/cart/index.ts +1 -1
- package/src/customer/customer-select.tsx +21 -3
- package/src/index.ts +27 -0
- package/src/input/search-input.tsx +1 -1
- package/src/order/index.ts +1 -0
- package/src/order/order-filter-bar.tsx +247 -0
- package/src/product/camera-scan-button.tsx +28 -0
- package/src/product/camera-scanner-panel.tsx +156 -0
- package/src/product/index.ts +5 -0
- package/src/product/product-table.tsx +14 -4
- package/src/product/scanner-viewfinder.tsx +76 -0
- package/src/product/variation-picker.tsx +128 -0
- package/src/register/register-bar.tsx +2 -6
- package/src/register/register-panel.tsx +47 -24
- package/src/register/register-side-sheet.tsx +175 -0
- package/src/reports/date-range-menu.tsx +109 -0
- package/src/reports/filters-bar.tsx +11 -21
- package/src/reports/hero.tsx +8 -4
- package/src/reports/index.ts +1 -0
- package/src/sale/cart.tsx +49 -10
- package/src/sale/catalogue.tsx +98 -21
- package/src/sale/charge-form.tsx +12 -6
- package/src/sale/customer-display-pairing.tsx +111 -0
- package/src/sale/index.ts +1 -0
- package/src/sale/line-popover.tsx +17 -1
- package/src/sale/order-reference.ts +1 -1
- package/src/sale/orders-list.tsx +1 -1
- package/src/settings/customer-display-settings.tsx +163 -0
- package/src/settings/index.ts +2 -0
- package/src/settings/tax-calculation-settings.tsx +97 -0
- package/src/shell/nav-drawer.tsx +1 -1
- package/src/tax/index.ts +1 -0
- package/src/tax/tax-based-on.tsx +196 -0
- package/src/ui/alert-dialog/index.tsx +1 -1
- package/src/ui/avatar/index.tsx +22 -4
- package/src/ui/button/index.tsx +1 -1
- package/src/ui/calendar/index.tsx +119 -0
- package/src/ui/calendar/month-grid.ts +40 -0
- package/src/ui/combobox/index.tsx +1 -1
- package/src/ui/dialog/index.tsx +21 -9
- package/src/ui/icon/chevron-down-icon.tsx +4 -0
- package/src/ui/icon/grip-icon.tsx +10 -0
- package/src/ui/icon/scan-icon.tsx +13 -0
- package/src/ui/icon/shopping-cart-icon.tsx +10 -0
- package/src/ui/icon-button/index.tsx +1 -1
- package/src/ui/index.ts +11 -1
- package/src/ui/input/index.tsx +1 -1
- package/src/ui/select/index.tsx +22 -4
- package/src/ui/slider/index.tsx +2 -2
- package/src/ui/switch/index.tsx +19 -8
- package/src/ui/textarea/index.tsx +1 -1
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A month calendar with single and range selection, `min`/`max` bounds and a week start. WCPOS v2
|
|
3
|
+
* wraps react-native-calendars (`components/src/calendar/calendar-impl.tsx`); this is a plain grid
|
|
4
|
+
* of Pressables with theme token classes instead, so it adds no dependency. Days are store days.
|
|
5
|
+
*/
|
|
6
|
+
import { useMemo, useState, type JSX } from 'react';
|
|
7
|
+
import { Pressable, Text, View } from 'react-native';
|
|
8
|
+
import type { DayRange, StoreDay } from '@tallyui/pos';
|
|
9
|
+
import { cn } from '@tallyui/theme';
|
|
10
|
+
import { addMonths, monthGrid, monthOf, pressRangeDay, type Month, type WeekDay } from './month-grid';
|
|
11
|
+
|
|
12
|
+
interface CalendarBaseProps {
|
|
13
|
+
min?: StoreDay;
|
|
14
|
+
max?: StoreDay;
|
|
15
|
+
/** Default 1 (Monday), as v2 hard-codes. */
|
|
16
|
+
weekStartsOn?: WeekDay;
|
|
17
|
+
/** The month shown first; defaults to the month of the value's start, else of `today`. */
|
|
18
|
+
initialMonth?: Month;
|
|
19
|
+
/** Today as a store day, for the today mark and the default month; the caller works it out in store time. */
|
|
20
|
+
today: StoreDay;
|
|
21
|
+
/** BCP 47 tag for the month and weekday names via Intl, default 'en-GB'. */
|
|
22
|
+
locale?: string;
|
|
23
|
+
testID?: string;
|
|
24
|
+
className?: string;
|
|
25
|
+
}
|
|
26
|
+
export type CalendarProps =
|
|
27
|
+
| (CalendarBaseProps & { mode: 'single'; value: StoreDay | null; onChange: (day: StoreDay) => void })
|
|
28
|
+
| (CalendarBaseProps & { mode: 'range'; value: DayRange | null; onChange: (range: DayRange) => void });
|
|
29
|
+
|
|
30
|
+
const utc = (day: StoreDay) => new Date(`${day}T00:00:00Z`);
|
|
31
|
+
// 1 January 2023 was a Sunday, so day `i` of that week is weekday `i`.
|
|
32
|
+
const weekdayDate = (weekday: number) => new Date(Date.UTC(2023, 0, 1 + weekday));
|
|
33
|
+
const rangeKey = (range: DayRange | null) => (range ? `${range.from}/${range.to}` : '');
|
|
34
|
+
|
|
35
|
+
export function Calendar(props: CalendarProps): JSX.Element {
|
|
36
|
+
const { min, max, weekStartsOn = 1, today, locale = 'en-GB', testID = 'calendar', className } = props;
|
|
37
|
+
const start = props.mode === 'single' ? props.value : props.value?.from ?? null;
|
|
38
|
+
const [month, setMonth] = useState<Month>(props.initialMonth ?? monthOf(start ?? today));
|
|
39
|
+
// The first tap of a range still being picked, and the one-day range it reported.
|
|
40
|
+
const [pick, setPick] = useState<{ anchor: StoreDay; reported: string } | null>(null);
|
|
41
|
+
const valueKey = props.mode === 'range' ? rangeKey(props.value) : '';
|
|
42
|
+
const [seen, setSeen] = useState(valueKey);
|
|
43
|
+
if (seen !== valueKey) {
|
|
44
|
+
setSeen(valueKey);
|
|
45
|
+
if (pick && pick.reported !== valueKey) setPick(null);
|
|
46
|
+
}
|
|
47
|
+
const format = useMemo(() => ({
|
|
48
|
+
title: new Intl.DateTimeFormat(locale, { month: 'long', year: 'numeric', timeZone: 'UTC' }),
|
|
49
|
+
weekday: new Intl.DateTimeFormat(locale, { weekday: 'short', timeZone: 'UTC' }),
|
|
50
|
+
full: new Intl.DateTimeFormat(locale, { weekday: 'long', day: 'numeric', month: 'long', year: 'numeric', timeZone: 'UTC' }),
|
|
51
|
+
}), [locale]);
|
|
52
|
+
|
|
53
|
+
const outside = (day: StoreDay) => (min !== undefined && day < min) || (max !== undefined && day > max);
|
|
54
|
+
const prevDisabled = min !== undefined && addMonths(month, -1) < monthOf(min);
|
|
55
|
+
const nextDisabled = max !== undefined && addMonths(month, 1) > monthOf(max);
|
|
56
|
+
const press = (day: StoreDay) => {
|
|
57
|
+
if (outside(day)) return;
|
|
58
|
+
if (props.mode === 'single') return props.onChange(day);
|
|
59
|
+
const next = pressRangeDay(pick?.anchor ?? null, day);
|
|
60
|
+
setPick(next.anchor ? { anchor: next.anchor, reported: rangeKey(next.range) } : null);
|
|
61
|
+
props.onChange(next.range);
|
|
62
|
+
};
|
|
63
|
+
const look = (day: StoreDay): 'end' | 'inside' | null => {
|
|
64
|
+
if (props.mode === 'single') return props.value === day ? 'end' : null;
|
|
65
|
+
const range = props.value;
|
|
66
|
+
if (!range) return null;
|
|
67
|
+
if (day === range.from || day === range.to) return 'end';
|
|
68
|
+
return day > range.from && day < range.to ? 'inside' : null;
|
|
69
|
+
};
|
|
70
|
+
const arrow = (id: 'prev' | 'next', disabled: boolean, glyph: string, label: string) => (
|
|
71
|
+
<Pressable testID={`${testID}-${id}`} accessibilityRole="button" accessibilityLabel={label}
|
|
72
|
+
accessibilityState={{ disabled }} aria-disabled={disabled} disabled={disabled}
|
|
73
|
+
onPress={() => { if (!disabled) setMonth(addMonths(month, id === 'prev' ? -1 : 1)); }}
|
|
74
|
+
className={cn('h-9 w-9 items-center justify-center rounded-md active:bg-accent', disabled && 'opacity-40')}>
|
|
75
|
+
<Text className="text-xl text-primary">{glyph}</Text>
|
|
76
|
+
</Pressable>
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
return (
|
|
80
|
+
<View testID={testID} className={cn('gap-1', className)}>
|
|
81
|
+
<View className="flex-row items-center justify-between">
|
|
82
|
+
{arrow('prev', prevDisabled, '‹', 'Previous month')}
|
|
83
|
+
<Text testID={`${testID}-title`} className="text-base font-medium text-foreground">{format.title.format(utc(`${month}-01`))}</Text>
|
|
84
|
+
{arrow('next', nextDisabled, '›', 'Next month')}
|
|
85
|
+
</View>
|
|
86
|
+
<View testID={`${testID}-weekdays`} className="flex-row">
|
|
87
|
+
{Array.from({ length: 7 }, (_, i) => (
|
|
88
|
+
<Text key={i} className="flex-1 text-center text-xs font-medium text-muted-foreground">
|
|
89
|
+
{format.weekday.format(weekdayDate((weekStartsOn + i) % 7))}
|
|
90
|
+
</Text>
|
|
91
|
+
))}
|
|
92
|
+
</View>
|
|
93
|
+
{monthGrid(month, weekStartsOn).map((week) => (
|
|
94
|
+
<View key={week[0].day} className="flex-row">
|
|
95
|
+
{week.map(({ day, inMonth }) => {
|
|
96
|
+
const disabled = outside(day);
|
|
97
|
+
const state = look(day);
|
|
98
|
+
const selected = state !== null;
|
|
99
|
+
return (
|
|
100
|
+
<Pressable key={day} testID={`${testID}-day-${day}`} accessibilityRole="button"
|
|
101
|
+
accessibilityLabel={format.full.format(utc(day))} accessibilityState={{ selected, disabled }}
|
|
102
|
+
aria-selected={selected} aria-disabled={disabled} disabled={disabled} onPress={() => press(day)}
|
|
103
|
+
className={cn('aspect-square min-h-9 min-w-9 flex-1 items-center justify-center rounded-md',
|
|
104
|
+
state === 'end' && 'bg-primary', state === 'inside' && 'bg-primary/15')}>
|
|
105
|
+
<Text className={cn('text-sm',
|
|
106
|
+
state === 'end' ? 'text-primary-foreground'
|
|
107
|
+
: disabled ? 'text-border'
|
|
108
|
+
: day === today ? 'font-medium text-primary'
|
|
109
|
+
: inMonth ? 'text-foreground' : 'text-muted-foreground')}>
|
|
110
|
+
{Number(day.slice(8))}
|
|
111
|
+
</Text>
|
|
112
|
+
</Pressable>
|
|
113
|
+
);
|
|
114
|
+
})}
|
|
115
|
+
</View>
|
|
116
|
+
))}
|
|
117
|
+
</View>
|
|
118
|
+
);
|
|
119
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The calendar's date math, on store days (`yyyy-MM-dd`) and months (`yyyy-MM`). Everything is UTC
|
|
3
|
+
* day arithmetic, as pos `presetRange` does, so no `Date` is ever read in the device zone.
|
|
4
|
+
*/
|
|
5
|
+
import type { DayRange, StoreDay } from '@tallyui/pos';
|
|
6
|
+
|
|
7
|
+
export type Month = string;
|
|
8
|
+
/** 0 = Sunday, as `Date.getUTCDay`. */
|
|
9
|
+
export type WeekDay = 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
10
|
+
export interface GridDay { day: StoreDay; inMonth: boolean }
|
|
11
|
+
|
|
12
|
+
const DAY_MS = 86_400_000;
|
|
13
|
+
const iso = (at: number): StoreDay => new Date(at).toISOString().slice(0, 10);
|
|
14
|
+
|
|
15
|
+
export const monthOf = (day: StoreDay): Month => day.slice(0, 7);
|
|
16
|
+
|
|
17
|
+
export function addMonths(month: Month, n: number): Month {
|
|
18
|
+
const [year, m] = month.split('-').map(Number);
|
|
19
|
+
return iso(Date.UTC(year, m - 1 + n, 1)).slice(0, 7);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const compareDays = (a: StoreDay, b: StoreDay): number => (a < b ? -1 : a > b ? 1 : 0);
|
|
23
|
+
|
|
24
|
+
/** The weeks of `month`, each 7 days from `weekStartsOn`; leading and trailing days belong to the neighbouring months. */
|
|
25
|
+
export function monthGrid(month: Month, weekStartsOn: WeekDay): GridDay[][] {
|
|
26
|
+
const [year, m] = month.split('-').map(Number);
|
|
27
|
+
const first = Date.UTC(year, m - 1, 1);
|
|
28
|
+
const lead = (new Date(first).getUTCDay() - weekStartsOn + 7) % 7;
|
|
29
|
+
const length = new Date(Date.UTC(year, m, 0)).getUTCDate();
|
|
30
|
+
return Array.from({ length: Math.ceil((lead + length) / 7) }, (_, row) => Array.from({ length: 7 }, (_, col) => {
|
|
31
|
+
const day = iso(first + (row * 7 + col - lead) * DAY_MS);
|
|
32
|
+
return { day, inMonth: monthOf(day) === month };
|
|
33
|
+
}));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** v2's two-tap rule. `anchor` is the first tap of a range still being picked, or null. */
|
|
37
|
+
export function pressRangeDay(anchor: StoreDay | null, day: StoreDay): { range: DayRange; anchor: StoreDay | null } {
|
|
38
|
+
if (anchor === null) return { range: { from: day, to: day }, anchor: day };
|
|
39
|
+
return { range: compareDays(day, anchor) < 0 ? { from: day, to: anchor } : { from: anchor, to: day }, anchor: null };
|
|
40
|
+
}
|
|
@@ -13,7 +13,7 @@ const ComboboxTrigger = React.forwardRef<
|
|
|
13
13
|
<ComboboxPrimitive.Trigger
|
|
14
14
|
ref={ref}
|
|
15
15
|
className={cn(
|
|
16
|
-
'flex h-10 w-full flex-row items-center justify-between rounded-md border border-input bg-
|
|
16
|
+
'flex h-10 w-full flex-row items-center justify-between rounded-md border border-input bg-card px-3 py-2 text-sm web:ring-offset-background web:focus:outline-none web:focus:ring-2 web:focus:ring-ring web:focus:ring-offset-2',
|
|
17
17
|
className,
|
|
18
18
|
)}
|
|
19
19
|
{...props}
|
package/src/ui/dialog/index.tsx
CHANGED
|
@@ -15,26 +15,29 @@ const DialogOverlay = React.forwardRef<
|
|
|
15
15
|
return (
|
|
16
16
|
<DialogPrimitive.Overlay
|
|
17
17
|
ref={ref}
|
|
18
|
-
className={cn('fixed inset-0 z-50 bg-
|
|
18
|
+
className={cn('fixed inset-0 z-50 bg-scrim', className)}
|
|
19
19
|
{...props}
|
|
20
20
|
/>
|
|
21
21
|
);
|
|
22
22
|
});
|
|
23
23
|
DialogOverlay.displayName = 'DialogOverlay';
|
|
24
24
|
|
|
25
|
+
/** Where the content sits: centred (the default), or a full-height sheet on the right edge, full width on a phone. */
|
|
26
|
+
const SIDE_CLASS = {
|
|
27
|
+
center: 'fixed left-1/2 top-1/2 z-50 w-full max-w-lg -translate-x-1/2 -translate-y-1/2 gap-4 rounded-lg border border-border bg-background p-6 shadow-lg',
|
|
28
|
+
right: 'fixed right-0 top-0 bottom-0 z-50 h-full w-full max-w-lg gap-4 rounded-none border-l border-border bg-background p-6 shadow-lg',
|
|
29
|
+
} as const;
|
|
30
|
+
|
|
25
31
|
const DialogContent = React.forwardRef<
|
|
26
32
|
React.ComponentRef<typeof DialogPrimitive.Content>,
|
|
27
|
-
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content>
|
|
28
|
-
>(function DialogContent({ className, children, ...props }, ref) {
|
|
33
|
+
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content> & { side?: keyof typeof SIDE_CLASS }
|
|
34
|
+
>(function DialogContent({ className, children, side = 'center', ...props }, ref) {
|
|
29
35
|
return (
|
|
30
36
|
<DialogPortal>
|
|
31
37
|
<DialogOverlay />
|
|
32
38
|
<DialogPrimitive.Content
|
|
33
39
|
ref={ref}
|
|
34
|
-
className={cn(
|
|
35
|
-
'fixed left-1/2 top-1/2 z-50 w-full max-w-lg -translate-x-1/2 -translate-y-1/2 gap-4 rounded-lg border border-border bg-background p-6 shadow-lg',
|
|
36
|
-
className,
|
|
37
|
-
)}
|
|
40
|
+
className={cn(SIDE_CLASS[side], className)}
|
|
38
41
|
{...props}
|
|
39
42
|
>
|
|
40
43
|
{children}
|
|
@@ -56,13 +59,22 @@ function DialogFooter({ className, ...props }: React.ComponentPropsWithoutRef<ty
|
|
|
56
59
|
);
|
|
57
60
|
}
|
|
58
61
|
|
|
62
|
+
const TITLE_CLASS = 'text-lg font-semibold leading-none text-foreground';
|
|
63
|
+
|
|
64
|
+
/** tailwind-merge drops `leading-none` when a caller passes a text size; put it back unless the caller set a leading. */
|
|
65
|
+
function titleClass(className?: string) {
|
|
66
|
+
const merged = cn(TITLE_CLASS, className);
|
|
67
|
+
return /\bleading-/.test(merged) ? merged : `${merged} leading-none`;
|
|
68
|
+
}
|
|
69
|
+
|
|
59
70
|
const DialogTitle = React.forwardRef<
|
|
60
71
|
React.ComponentRef<typeof DialogPrimitive.Title>,
|
|
61
72
|
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>
|
|
62
73
|
>(function DialogTitle({ className, ...props }, ref) {
|
|
74
|
+
const merged = titleClass(className);
|
|
63
75
|
return (
|
|
64
|
-
<TextClassContext.Provider value=
|
|
65
|
-
<DialogPrimitive.Title ref={ref} className={
|
|
76
|
+
<TextClassContext.Provider value={merged}>
|
|
77
|
+
<DialogPrimitive.Title ref={ref} className={merged} {...props} />
|
|
66
78
|
</TextClassContext.Provider>
|
|
67
79
|
);
|
|
68
80
|
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Line } from 'react-native-svg';
|
|
2
|
+
import { createSvgIcon } from './svg-icon';
|
|
3
|
+
|
|
4
|
+
/** A horizontal grip of two lines. */
|
|
5
|
+
export const GripIcon = createSvgIcon('GripIcon', () => (
|
|
6
|
+
<>
|
|
7
|
+
<Line x1={5} y1={10} x2={19} y2={10} />
|
|
8
|
+
<Line x1={5} y1={14} x2={19} y2={14} />
|
|
9
|
+
</>
|
|
10
|
+
));
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Line, Path } from 'react-native-svg';
|
|
2
|
+
import { createSvgIcon } from './svg-icon';
|
|
3
|
+
|
|
4
|
+
/** A scan frame (four corners) with a centre line. */
|
|
5
|
+
export const ScanIcon = createSvgIcon('ScanIcon', () => (
|
|
6
|
+
<>
|
|
7
|
+
<Path d="M3 7V5a2 2 0 0 1 2-2h2" />
|
|
8
|
+
<Path d="M17 3h2a2 2 0 0 1 2 2v2" />
|
|
9
|
+
<Path d="M21 17v2a2 2 0 0 1-2 2h-2" />
|
|
10
|
+
<Path d="M7 21H5a2 2 0 0 1-2-2v-2" />
|
|
11
|
+
<Line x1={7} y1={12} x2={17} y2={12} />
|
|
12
|
+
</>
|
|
13
|
+
));
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Circle, Path } from 'react-native-svg';
|
|
2
|
+
import { createSvgIcon } from './svg-icon';
|
|
3
|
+
|
|
4
|
+
export const ShoppingCartIcon = createSvgIcon('ShoppingCartIcon', () => (
|
|
5
|
+
<>
|
|
6
|
+
<Circle cx={9} cy={20} r={1.5} />
|
|
7
|
+
<Circle cx={18} cy={20} r={1.5} />
|
|
8
|
+
<Path d="M2 3h3l2.5 12h11.5l2-8H6.2" />
|
|
9
|
+
</>
|
|
10
|
+
));
|
|
@@ -11,7 +11,7 @@ const iconButtonVariants = cva(
|
|
|
11
11
|
variant: {
|
|
12
12
|
default: 'bg-primary active:opacity-90',
|
|
13
13
|
destructive: 'bg-destructive active:opacity-90',
|
|
14
|
-
outline: 'border border-input bg-
|
|
14
|
+
outline: 'border border-input bg-card active:bg-accent',
|
|
15
15
|
secondary: 'bg-secondary active:opacity-80',
|
|
16
16
|
ghost: 'active:bg-accent',
|
|
17
17
|
},
|
package/src/ui/index.ts
CHANGED
|
@@ -7,10 +7,14 @@ export { VStack, vstackVariants, type VStackProps } from './vstack';
|
|
|
7
7
|
export { Icon, iconVariants, type IconProps } from './icon';
|
|
8
8
|
export { createSvgIcon, type SvgIconProps } from './icon/svg-icon';
|
|
9
9
|
export { SearchIcon } from './icon/search-icon';
|
|
10
|
+
export { ShoppingCartIcon } from './icon/shopping-cart-icon';
|
|
10
11
|
export { XIcon } from './icon/x-icon';
|
|
12
|
+
export { ScanIcon } from './icon/scan-icon';
|
|
13
|
+
export { GripIcon } from './icon/grip-icon';
|
|
14
|
+
export { ChevronDownIcon } from './icon/chevron-down-icon';
|
|
11
15
|
export { Loader, loaderVariants, type LoaderProps } from './loader';
|
|
12
16
|
export { Badge, badgeVariants, badgeTextVariants, type BadgeProps } from './badge';
|
|
13
|
-
export { Avatar, avatarVariants, type AvatarProps } from './avatar';
|
|
17
|
+
export { Avatar, avatarVariants, avatarInitials, type AvatarProps } from './avatar';
|
|
14
18
|
|
|
15
19
|
// Interactive
|
|
16
20
|
export { Button, buttonVariants, buttonTextVariants, type ButtonProps } from './button';
|
|
@@ -72,6 +76,12 @@ export {
|
|
|
72
76
|
// Popover
|
|
73
77
|
export { Popover, PopoverTrigger, PopoverContent } from './popover';
|
|
74
78
|
|
|
79
|
+
// Calendar
|
|
80
|
+
export { Calendar, type CalendarProps } from './calendar';
|
|
81
|
+
export {
|
|
82
|
+
monthGrid, monthOf, addMonths, compareDays, pressRangeDay, type Month, type WeekDay, type GridDay,
|
|
83
|
+
} from './calendar/month-grid';
|
|
84
|
+
|
|
75
85
|
// Tooltip
|
|
76
86
|
export { Tooltip, TooltipTrigger, TooltipContent } from './tooltip';
|
|
77
87
|
|
package/src/ui/input/index.tsx
CHANGED
|
@@ -30,7 +30,7 @@ const InputRoot = React.forwardRef<View, InputRootProps>(
|
|
|
30
30
|
<View
|
|
31
31
|
ref={ref}
|
|
32
32
|
className={cn(
|
|
33
|
-
'flex h-10 flex-row items-center rounded-md border border-input bg-
|
|
33
|
+
'flex h-10 flex-row items-center rounded-md border border-input bg-card px-3',
|
|
34
34
|
focused && 'ring-2 ring-ring ring-offset-2',
|
|
35
35
|
disabled && 'opacity-50',
|
|
36
36
|
className,
|
package/src/ui/select/index.tsx
CHANGED
|
@@ -2,25 +2,43 @@ import * as React from 'react';
|
|
|
2
2
|
import { View } from 'react-native';
|
|
3
3
|
import { Select as SelectPrimitive } from '@tallyui/primitives';
|
|
4
4
|
import { cn } from '@tallyui/theme';
|
|
5
|
+
import { ChevronDownIcon } from '../icon/chevron-down-icon';
|
|
5
6
|
|
|
6
7
|
const Select = SelectPrimitive.Root;
|
|
7
8
|
const SelectGroup = SelectPrimitive.Group;
|
|
8
9
|
const SelectValue = SelectPrimitive.Value;
|
|
9
10
|
|
|
11
|
+
type SelectTriggerProps = React.ComponentPropsWithoutRef<typeof SelectPrimitive.Trigger> & {
|
|
12
|
+
/**
|
|
13
|
+
* Draws a down chevron at the right, the v2 way. Pass `false` when the children draw their
|
|
14
|
+
* own, or for a trigger that needs none. Skipped under `asChild`, whose one child owns the content.
|
|
15
|
+
*/
|
|
16
|
+
chevron?: boolean;
|
|
17
|
+
};
|
|
18
|
+
|
|
10
19
|
const SelectTrigger = React.forwardRef<
|
|
11
20
|
React.ComponentRef<typeof SelectPrimitive.Trigger>,
|
|
12
|
-
|
|
13
|
-
>(function SelectTrigger({ className, children, ...props }, ref) {
|
|
21
|
+
SelectTriggerProps
|
|
22
|
+
>(function SelectTrigger({ className, children, chevron = true, ...props }, ref) {
|
|
14
23
|
return (
|
|
15
24
|
<SelectPrimitive.Trigger
|
|
16
25
|
ref={ref}
|
|
17
26
|
className={cn(
|
|
18
|
-
'flex h-10 w-full flex-row items-center justify-between rounded-md border border-input bg-
|
|
27
|
+
'flex h-10 w-full flex-row items-center justify-between rounded-md border border-input bg-card px-3 py-2 text-sm text-foreground web:ring-offset-background web:focus:outline-none web:focus:ring-2 web:focus:ring-ring web:focus:ring-offset-2',
|
|
19
28
|
className,
|
|
20
29
|
)}
|
|
21
30
|
{...props}
|
|
22
31
|
>
|
|
23
|
-
{
|
|
32
|
+
{chevron && !props.asChild ? (
|
|
33
|
+
<>
|
|
34
|
+
{children}
|
|
35
|
+
<View aria-hidden className="ml-2 shrink-0 opacity-50">
|
|
36
|
+
<ChevronDownIcon size={16} />
|
|
37
|
+
</View>
|
|
38
|
+
</>
|
|
39
|
+
) : (
|
|
40
|
+
children
|
|
41
|
+
)}
|
|
24
42
|
</SelectPrimitive.Trigger>
|
|
25
43
|
);
|
|
26
44
|
});
|
package/src/ui/slider/index.tsx
CHANGED
|
@@ -19,10 +19,10 @@ const Slider = React.forwardRef<
|
|
|
19
19
|
)}
|
|
20
20
|
{...props}
|
|
21
21
|
>
|
|
22
|
-
<SliderPrimitive.Track className="relative h-2 w-full grow overflow-hidden rounded-full bg-
|
|
22
|
+
<SliderPrimitive.Track className="relative h-2 w-full grow overflow-hidden rounded-full bg-muted">
|
|
23
23
|
<SliderPrimitive.Range className="absolute h-full bg-primary" />
|
|
24
24
|
</SliderPrimitive.Track>
|
|
25
|
-
<SliderPrimitive.Thumb className="absolute top-0 -ml-2.5 block h-5 w-5 rounded-full border-2 border-primary bg-
|
|
25
|
+
<SliderPrimitive.Thumb className="absolute top-0 -ml-2.5 block h-5 w-5 rounded-full border-2 border-primary bg-card web:ring-offset-background web:transition-colors web:focus-visible:outline-none web:focus-visible:ring-2 web:focus-visible:ring-ring web:focus-visible:ring-offset-2" />
|
|
26
26
|
</SliderPrimitive.Root>
|
|
27
27
|
);
|
|
28
28
|
});
|
package/src/ui/switch/index.tsx
CHANGED
|
@@ -2,16 +2,27 @@ import * as React from 'react';
|
|
|
2
2
|
import { Switch as SwitchPrimitive } from '@tallyui/primitives';
|
|
3
3
|
import { cn } from '@tallyui/theme';
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
// Track, thumb and checked travel per size. Both keep border-2, so travel = inner width - thumb.
|
|
6
|
+
const sizes = {
|
|
7
|
+
default: { track: 'h-6 w-11', thumb: 'h-5 w-5', on: 'translate-x-5' },
|
|
8
|
+
sm: { track: 'h-5 w-9', thumb: 'h-4 w-4', on: 'translate-x-4' },
|
|
9
|
+
} as const;
|
|
10
|
+
|
|
11
|
+
type SwitchProps = React.ComponentPropsWithoutRef<typeof SwitchPrimitive.Root> & {
|
|
12
|
+
size?: keyof typeof sizes;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const Switch = React.forwardRef<React.ComponentRef<typeof SwitchPrimitive.Root>, SwitchProps>(function Switch(
|
|
16
|
+
{ className, size = 'default', ...props },
|
|
17
|
+
ref,
|
|
18
|
+
) {
|
|
19
|
+
const s = sizes[size];
|
|
9
20
|
return (
|
|
10
21
|
<SwitchPrimitive.Root
|
|
11
22
|
ref={ref}
|
|
12
23
|
className={cn(
|
|
13
|
-
|
|
14
|
-
props.checked ? 'bg-primary' : 'bg-
|
|
24
|
+
`web:peer inline-flex ${s.track} shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent web:transition-colors web:focus-visible:outline-none web:focus-visible:ring-2 web:focus-visible:ring-ring web:focus-visible:ring-offset-2 web:focus-visible:ring-offset-background`,
|
|
25
|
+
props.checked ? 'bg-primary' : 'bg-border',
|
|
15
26
|
props.disabled && 'web:cursor-not-allowed opacity-50',
|
|
16
27
|
className,
|
|
17
28
|
)}
|
|
@@ -19,8 +30,8 @@ const Switch = React.forwardRef<
|
|
|
19
30
|
>
|
|
20
31
|
<SwitchPrimitive.Thumb
|
|
21
32
|
className={cn(
|
|
22
|
-
|
|
23
|
-
props.checked ?
|
|
33
|
+
`pointer-events-none block ${s.thumb} rounded-full bg-background shadow-lg ring-0 web:transition-transform`,
|
|
34
|
+
props.checked ? s.on : 'translate-x-0',
|
|
24
35
|
)}
|
|
25
36
|
/>
|
|
26
37
|
</SwitchPrimitive.Root>
|
|
@@ -14,7 +14,7 @@ const Textarea = React.forwardRef<TextInput, TextareaProps>(
|
|
|
14
14
|
multiline
|
|
15
15
|
textAlignVertical="top"
|
|
16
16
|
className={cn(
|
|
17
|
-
'min-h-[80px] w-full rounded-md border border-input bg-
|
|
17
|
+
'min-h-[80px] w-full rounded-md border border-input bg-card px-3 py-2 text-sm text-foreground placeholder:text-muted-foreground web:outline-none web:focus-visible:ring-2 web:focus-visible:ring-ring web:focus-visible:ring-offset-2',
|
|
18
18
|
className,
|
|
19
19
|
)}
|
|
20
20
|
{...props}
|