@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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tallyui/components",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.20.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Universal POS UI components for Tally UI",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -28,9 +28,9 @@
|
|
|
28
28
|
"directory": "packages/components"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
|
-
"@tallyui/core": "^3.
|
|
32
|
-
"@tallyui/primitives": "^3.
|
|
33
|
-
"@tallyui/theme": "^3.
|
|
31
|
+
"@tallyui/core": "^3.20.0",
|
|
32
|
+
"@tallyui/primitives": "^3.20.0",
|
|
33
|
+
"@tallyui/theme": "^3.20.0",
|
|
34
34
|
"react": ">=18",
|
|
35
35
|
"react-native": ">=0.74",
|
|
36
36
|
"react-native-svg": ">=15"
|
|
@@ -39,13 +39,13 @@
|
|
|
39
39
|
"class-variance-authority": "^0.7.1",
|
|
40
40
|
"i18next": "^26.7.1",
|
|
41
41
|
"react-i18next": "^17.1.12",
|
|
42
|
-
"@tallyui/pos": "3.
|
|
42
|
+
"@tallyui/pos": "3.20.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@tallyui/connector-medusa": "3.
|
|
46
|
-
"@tallyui/connector-vendure": "3.
|
|
47
|
-
"@tallyui/connector-woocommerce": "3.
|
|
48
|
-
"@tallyui/mock-api": "3.
|
|
45
|
+
"@tallyui/connector-medusa": "3.20.0",
|
|
46
|
+
"@tallyui/connector-vendure": "3.20.0",
|
|
47
|
+
"@tallyui/connector-woocommerce": "3.20.0",
|
|
48
|
+
"@tallyui/mock-api": "3.20.0",
|
|
49
49
|
"@types/react": ">=18",
|
|
50
50
|
"react": "^19.2.4",
|
|
51
51
|
"react-native-svg": "15.12.1",
|
|
@@ -12,7 +12,9 @@ import { Text } from '../ui';
|
|
|
12
12
|
*/
|
|
13
13
|
export const CART_COLUMNS = {
|
|
14
14
|
quantity: { head: 'w-12 flex-none items-center pr-2 pl-3', cell: 'w-12 flex-none items-center pr-2 pl-3' },
|
|
15
|
+
image: { head: 'w-14 flex-none items-center justify-center pl-3', cell: 'w-14 flex-none items-center justify-center pl-3' },
|
|
15
16
|
name: { head: 'min-w-0 flex-1 px-3', cell: 'min-w-0 flex-1 px-3' },
|
|
17
|
+
sku: { head: 'w-24 flex-none px-2', cell: 'w-24 flex-none px-2' },
|
|
16
18
|
price: { head: 'w-18 flex-none items-end px-2', cell: 'w-18 flex-none items-end px-2' },
|
|
17
19
|
total: { head: 'w-20 flex-none items-end pr-3 pl-2', cell: 'min-w-20 flex-none items-end pr-3 pl-2' },
|
|
18
20
|
};
|
|
@@ -29,11 +31,47 @@ export function cartShowsPrice({ cartWidth, windowWidth, windowHeight }:
|
|
|
29
31
|
return (cartWidth ?? Infinity) >= PRICE_COLUMN_MIN_WIDTH && windowWidth >= WIDE_MIN_WIDTH && windowHeight >= WIDE_MIN_HEIGHT;
|
|
30
32
|
}
|
|
31
33
|
|
|
32
|
-
|
|
34
|
+
/**
|
|
35
|
+
* v2's Cart Settings › Columns: each column's `show` switch and display options. Every field is optional; the
|
|
36
|
+
* defaults are today's look and v2's: Qty, Item, Price and Total show; Image, SKU, `quantity.split` and `name.sku` are off.
|
|
37
|
+
*/
|
|
38
|
+
export interface CartColumnSettings {
|
|
39
|
+
/** `split`: a Split link under a quantity above 1. */
|
|
40
|
+
quantity?: { show?: boolean; split?: boolean };
|
|
41
|
+
/** The line's image, in its own column with no head label. */
|
|
42
|
+
image?: { show?: boolean };
|
|
43
|
+
/** `sku`: the SKU on a line under the name. */
|
|
44
|
+
name?: { show?: boolean; sku?: boolean };
|
|
45
|
+
sku?: { show?: boolean };
|
|
46
|
+
/** Still folds on a narrow cart or a phone (`showPrice`). */
|
|
47
|
+
price?: { show?: boolean };
|
|
48
|
+
total?: { show?: boolean };
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export type CartColumnId = 'quantity' | 'image' | 'name' | 'sku' | 'price' | 'total';
|
|
52
|
+
const DEFAULT_SHOWN: Record<CartColumnId, boolean> = { quantity: true, image: false, name: true, sku: false, price: true, total: true };
|
|
53
|
+
|
|
54
|
+
/** The visible columns, in their fixed order; the heads and every line use it, so they cannot disagree. */
|
|
55
|
+
export function cartColumnIds(columns: CartColumnSettings = {}, { showPrice = true }: { showPrice?: boolean } = {}): CartColumnId[] {
|
|
56
|
+
return (Object.keys(DEFAULT_SHOWN) as CartColumnId[])
|
|
57
|
+
.filter((id) => (columns[id]?.show ?? DEFAULT_SHOWN[id]) && (id !== 'price' || showPrice));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** cartColumnIds with a `fill` in Item's place when it is hidden, so the amount columns stay right-aligned. */
|
|
61
|
+
export function cartColumnSlots(...args: Parameters<typeof cartColumnIds>): (CartColumnId | 'fill')[] {
|
|
62
|
+
const ids = cartColumnIds(...args);
|
|
63
|
+
if (ids.includes('name')) return ids;
|
|
64
|
+
const at = ids.filter((id) => id === 'quantity' || id === 'image').length;
|
|
65
|
+
return [...ids.slice(0, at), 'fill', ...ids.slice(at)];
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const HEADS: Record<CartColumnId, string> = { quantity: 'Qty', image: '', name: 'Item', sku: 'SKU', price: 'Price', total: 'Total' };
|
|
33
69
|
|
|
34
70
|
export interface CartColumnHeadsProps extends Omit<ViewProps, 'children'> {
|
|
35
71
|
/** Show the Price head (default true); pass the same value as each CartLine's `showPrice`. */
|
|
36
72
|
showPrice?: boolean;
|
|
73
|
+
/** Which columns show (v2's Cart Settings › Columns); pass the same value as each CartLine's `columns`. */
|
|
74
|
+
columns?: CartColumnSettings;
|
|
37
75
|
className?: string;
|
|
38
76
|
}
|
|
39
77
|
|
|
@@ -44,12 +82,12 @@ export interface CartColumnHeadsProps extends Omit<ViewProps, 'children'> {
|
|
|
44
82
|
* <CartColumnHeads showPrice={showPrice} />
|
|
45
83
|
* ```
|
|
46
84
|
*/
|
|
47
|
-
export function CartColumnHeads({ showPrice = true, className, ...props }: CartColumnHeadsProps): JSX.Element {
|
|
85
|
+
export function CartColumnHeads({ showPrice = true, columns, className, ...props }: CartColumnHeadsProps): JSX.Element {
|
|
48
86
|
return (
|
|
49
87
|
<View role="row" className={cn('flex-row border-b border-border', className)} {...props}>
|
|
50
|
-
{
|
|
88
|
+
{cartColumnSlots(columns, { showPrice }).map((id) => id === 'fill' ? <View key={id} className="flex-1" /> : (
|
|
51
89
|
<View key={id} role="columnheader" className={cn('h-9 justify-center', CART_COLUMNS[id].head)}>
|
|
52
|
-
<Text className="text-xs font-medium uppercase tracking-wide text-muted-foreground" numberOfLines={1}>{
|
|
90
|
+
{HEADS[id] ? <Text className="text-xs font-medium uppercase tracking-wide text-muted-foreground" numberOfLines={1}>{HEADS[id]}</Text> : null}
|
|
53
91
|
</View>
|
|
54
92
|
))}
|
|
55
93
|
</View>
|
package/src/cart/cart-foot.tsx
CHANGED
|
@@ -68,12 +68,12 @@ export function CartFoot({ total, onCheckout, actions = [], disabled = false, lo
|
|
|
68
68
|
{actions.length > 0 ? (
|
|
69
69
|
<Pressable ref={trigger} accessibilityRole="button" accessibilityLabel={MENU_LABEL} aria-haspopup="menu"
|
|
70
70
|
aria-expanded={open} testID="cart-foot-more" onPress={() => setOpen((value) => !value)}
|
|
71
|
-
className="
|
|
71
|
+
className="h-11 w-11 self-center items-center justify-center rounded-md border border-border bg-card">
|
|
72
72
|
<Text className="text-lg text-foreground">⋮</Text>
|
|
73
73
|
</Pressable>
|
|
74
74
|
) : null}
|
|
75
75
|
<Pressable accessibilityRole="button" testID="cart-checkout" disabled={disabled} onPress={onCheckout}
|
|
76
|
-
className={cn('min-h-
|
|
76
|
+
className={cn('min-h-14 flex-1 justify-center rounded-md bg-primary px-4 py-3', disabled && 'opacity-50')}>
|
|
77
77
|
<Text className="text-center font-semibold text-primary-foreground">{`Checkout ${formatMoney(total, locale) ?? '—'}`}</Text>
|
|
78
78
|
</Pressable>
|
|
79
79
|
</View>
|
package/src/cart/cart-line.tsx
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
|
-
import { View } from 'react-native';
|
|
2
|
+
import { Pressable, View } from 'react-native';
|
|
3
3
|
import { formatMoney, type Money } from '@tallyui/core';
|
|
4
|
+
import { Image } from '@tallyui/primitives';
|
|
4
5
|
import { cn } from '@tallyui/theme';
|
|
5
6
|
import { Text, HStack, type HStackProps } from '../ui';
|
|
6
|
-
import { CART_COLUMNS } from './cart-columns';
|
|
7
|
+
import { CART_COLUMNS, cartColumnSlots, type CartColumnSettings } from './cart-columns';
|
|
7
8
|
|
|
8
9
|
export interface CartLineProps extends Omit<HStackProps, 'children'> {
|
|
9
10
|
name: string;
|
|
@@ -20,6 +21,14 @@ export interface CartLineProps extends Omit<HStackProps, 'children'> {
|
|
|
20
21
|
quantitySlot?: ReactNode;
|
|
21
22
|
/** Replaces the unit price's text (the struck regular price stays above it). */
|
|
22
23
|
priceSlot?: ReactNode;
|
|
24
|
+
/** Which columns show, as CartColumnHeads' `columns` (v2's Cart Settings › Columns); the default is the look above. */
|
|
25
|
+
columns?: CartColumnSettings;
|
|
26
|
+
/** The SKU, in the SKU column and, with `columns.name.sku`, under the name. */
|
|
27
|
+
sku?: string;
|
|
28
|
+
/** The image in the Image column; without it the cell stays empty at its width. */
|
|
29
|
+
imageUrl?: string;
|
|
30
|
+
/** With `columns.quantity.split` and a quantity above 1, a Split link under the quantity calls this. */
|
|
31
|
+
onSplit?: () => void;
|
|
23
32
|
locale?: string;
|
|
24
33
|
className?: string;
|
|
25
34
|
}
|
|
@@ -34,27 +43,42 @@ export interface CartLineProps extends Omit<HStackProps, 'children'> {
|
|
|
34
43
|
* <CartLine name="Coffee" quantity={2} unitPrice={unitPrice} lineTotal={lineTotal} />
|
|
35
44
|
* ```
|
|
36
45
|
*/
|
|
37
|
-
export function CartLine({ name, attributes, quantity, unitPrice, regularUnitPrice, lineTotal, showPrice = true, quantitySlot, priceSlot,
|
|
46
|
+
export function CartLine({ name, attributes, quantity, unitPrice, regularUnitPrice, lineTotal, showPrice = true, quantitySlot, priceSlot,
|
|
47
|
+
columns, sku, imageUrl, onSplit, locale, className, ...props }: CartLineProps) {
|
|
38
48
|
const options = Object.entries(attributes ?? {}).map(([key, value]) => `${key}: ${value}`).join(' · ');
|
|
39
49
|
const regular = regularUnitPrice && regularUnitPrice.currency === unitPrice.currency && regularUnitPrice.amount > unitPrice.amount
|
|
40
50
|
? formatMoney(regularUnitPrice, locale) ?? '—' : null;
|
|
51
|
+
const cells: Record<ReturnType<typeof cartColumnSlots>[number], ReactNode> = {
|
|
52
|
+
fill: <View key="fill" className="flex-1" />,
|
|
53
|
+
quantity: <View key="quantity" className={CART_COLUMNS.quantity.cell}>
|
|
54
|
+
{quantitySlot ?? <Text className="text-sm tabular-nums">{quantity}</Text>}
|
|
55
|
+
{columns?.quantity?.split && quantity > 1 && onSplit ? <Pressable accessibilityRole="button" accessibilityLabel={`Split ${name}`}
|
|
56
|
+
testID="cart-line-split" onPress={onSplit} className="min-h-11 justify-center"><Text className="text-xs text-primary">Split</Text></Pressable> : null}
|
|
57
|
+
</View>,
|
|
58
|
+
image: <View key="image" className={CART_COLUMNS.image.cell}>
|
|
59
|
+
{imageUrl ? <Image.Root testID="cart-line-image" source={{ uri: imageUrl }} alt="" contentFit="cover" className="rounded-md"
|
|
60
|
+
style={{ width: 40, height: 40 }} /> : null}
|
|
61
|
+
</View>,
|
|
62
|
+
name: <View key="name" className={CART_COLUMNS.name.cell}>
|
|
63
|
+
<Text className="text-sm font-medium" numberOfLines={2}>{name}</Text>
|
|
64
|
+
{options ? <Text className="text-xs text-muted-foreground" numberOfLines={2}>{options}</Text> : null}
|
|
65
|
+
{columns?.name?.sku && sku ? <Text testID="cart-line-sku" className="text-sm text-muted-foreground">{sku}</Text> : null}
|
|
66
|
+
</View>,
|
|
67
|
+
sku: <View key="sku" className={CART_COLUMNS.sku.cell}>
|
|
68
|
+
{sku ? <Text className="text-sm text-muted-foreground" numberOfLines={1}>{sku}</Text> : null}
|
|
69
|
+
</View>,
|
|
70
|
+
price: <View key="price" className={CART_COLUMNS.price.cell}>
|
|
71
|
+
{regular ? <Text accessibilityLabel={`Regular price ${regular}`} style={{ textDecorationLine: 'line-through' }}
|
|
72
|
+
className="text-right text-sm tabular-nums text-muted-foreground line-through">{regular}</Text> : null}
|
|
73
|
+
{priceSlot ?? <Text className="text-right text-sm tabular-nums text-muted-foreground">{formatMoney(unitPrice, locale) ?? '—'}</Text>}
|
|
74
|
+
</View>,
|
|
75
|
+
total: <View key="total" className={CART_COLUMNS.total.cell}>
|
|
76
|
+
<Text className="text-right text-sm font-semibold tabular-nums">{formatMoney(lineTotal, locale) ?? '—'}</Text>
|
|
77
|
+
</View>,
|
|
78
|
+
};
|
|
41
79
|
return (
|
|
42
80
|
<HStack space="none" className={cn('py-2.5', className)} {...props}>
|
|
43
|
-
|
|
44
|
-
{quantitySlot ?? <Text className="text-sm tabular-nums">{quantity}</Text>}
|
|
45
|
-
</View>
|
|
46
|
-
<View className={CART_COLUMNS.name.cell}>
|
|
47
|
-
<Text className="text-sm font-medium" numberOfLines={2}>{name}</Text>
|
|
48
|
-
{options ? <Text className="text-xs text-muted-foreground" numberOfLines={2}>{options}</Text> : null}
|
|
49
|
-
</View>
|
|
50
|
-
{showPrice ? <View className={CART_COLUMNS.price.cell}>
|
|
51
|
-
{regular ? <Text accessibilityLabel={`Regular price ${regular}`} style={{ textDecorationLine: 'line-through' }}
|
|
52
|
-
className="text-right text-sm tabular-nums text-muted-foreground line-through">{regular}</Text> : null}
|
|
53
|
-
{priceSlot ?? <Text className="text-right text-sm tabular-nums text-muted-foreground">{formatMoney(unitPrice, locale) ?? '—'}</Text>}
|
|
54
|
-
</View> : null}
|
|
55
|
-
<View className={CART_COLUMNS.total.cell}>
|
|
56
|
-
<Text className="text-right text-sm font-semibold tabular-nums">{formatMoney(lineTotal, locale) ?? '—'}</Text>
|
|
57
|
-
</View>
|
|
81
|
+
{cartColumnSlots(columns, { showPrice }).map((id) => cells[id])}
|
|
58
82
|
</HStack>
|
|
59
83
|
);
|
|
60
84
|
}
|
|
@@ -6,6 +6,12 @@ import { cn } from '@tallyui/theme';
|
|
|
6
6
|
export interface CartNoteInputProps extends Omit<ViewProps, 'children'> {
|
|
7
7
|
value: string;
|
|
8
8
|
onChangeText: (text: string) => void;
|
|
9
|
+
/**
|
|
10
|
+
* The note's name, shown by the collapsed link, the input's placeholder and
|
|
11
|
+
* its accessibility label. WooCommerce sends the note as `customer_note`, so
|
|
12
|
+
* the customer sees it.
|
|
13
|
+
*/
|
|
14
|
+
label?: string;
|
|
9
15
|
placeholder?: string;
|
|
10
16
|
className?: string;
|
|
11
17
|
}
|
|
@@ -13,7 +19,8 @@ export interface CartNoteInputProps extends Omit<ViewProps, 'children'> {
|
|
|
13
19
|
export function CartNoteInput({
|
|
14
20
|
value,
|
|
15
21
|
onChangeText,
|
|
16
|
-
|
|
22
|
+
label = 'Customer note',
|
|
23
|
+
placeholder = label,
|
|
17
24
|
className,
|
|
18
25
|
...viewProps
|
|
19
26
|
}: CartNoteInputProps) {
|
|
@@ -26,7 +33,7 @@ export function CartNoteInput({
|
|
|
26
33
|
className={cn('flex-row items-center gap-1.5 px-3 py-2', className)}
|
|
27
34
|
{...viewProps}
|
|
28
35
|
>
|
|
29
|
-
<Text className="text-xs text-primary">Add
|
|
36
|
+
<Text className="text-xs text-primary">{`Add ${label.toLowerCase()}`}</Text>
|
|
30
37
|
</Pressable>
|
|
31
38
|
);
|
|
32
39
|
}
|
|
@@ -37,6 +44,7 @@ export function CartNoteInput({
|
|
|
37
44
|
value={value}
|
|
38
45
|
onChangeText={onChangeText}
|
|
39
46
|
placeholder={placeholder}
|
|
47
|
+
accessibilityLabel={label}
|
|
40
48
|
placeholderTextColorClassName="accent-muted-foreground"
|
|
41
49
|
multiline
|
|
42
50
|
className="min-h-[3rem] rounded-lg border border-border bg-card px-3 py-2 text-sm text-foreground"
|
package/src/cart/cart-panel.tsx
CHANGED
|
@@ -16,6 +16,8 @@ export interface CartPanelProps<T> extends Omit<VStackProps, 'children'> {
|
|
|
16
16
|
afterItems?: ReactNode;
|
|
17
17
|
/** Footer slot (e.g. totals, checkout button) */
|
|
18
18
|
footer?: ReactNode;
|
|
19
|
+
/** Classes for the footer's wrapper (default `border-t border-border px-3 py-2`). */
|
|
20
|
+
footerClassName?: string;
|
|
19
21
|
/** Content shown when items is empty */
|
|
20
22
|
emptyState?: ReactNode;
|
|
21
23
|
className?: string;
|
|
@@ -51,6 +53,7 @@ export function CartPanel<T>({
|
|
|
51
53
|
header,
|
|
52
54
|
afterItems,
|
|
53
55
|
footer,
|
|
56
|
+
footerClassName,
|
|
54
57
|
emptyState,
|
|
55
58
|
className,
|
|
56
59
|
...props
|
|
@@ -72,7 +75,7 @@ export function CartPanel<T>({
|
|
|
72
75
|
{afterItems}
|
|
73
76
|
</ScrollView>
|
|
74
77
|
|
|
75
|
-
{footer && <View className=
|
|
78
|
+
{footer && <View className={cn('border-t border-border px-3 py-2', footerClassName)}>{footer}</View>}
|
|
76
79
|
</VStack>
|
|
77
80
|
);
|
|
78
81
|
}
|
package/src/cart/cart-total.tsx
CHANGED
|
@@ -14,10 +14,12 @@ export interface CartTotalProps extends Omit<VStackProps, 'children'> {
|
|
|
14
14
|
className?: string;
|
|
15
15
|
/** Rows rendered directly under Subtotal, e.g. a platform's coupon chips. */
|
|
16
16
|
afterSubtotal?: ReactNode;
|
|
17
|
+
/** Draws the Total row. Pass `false` when the total shows elsewhere, e.g. v2's Checkout button. Default `true`. */
|
|
18
|
+
showTotal?: boolean;
|
|
17
19
|
}
|
|
18
20
|
|
|
19
21
|
/**
|
|
20
|
-
* Displays a cart summary: subtotal, optional discount, optional tax, and
|
|
22
|
+
* Displays a cart summary: subtotal, optional discount, optional tax, and an optional Total row, in the receipt's order.
|
|
21
23
|
*
|
|
22
24
|
* ```tsx
|
|
23
25
|
* <CartTotal subtotal={subtotal} discount={discount} taxLines={taxLines} total={total} />
|
|
@@ -32,6 +34,7 @@ export function CartTotal({
|
|
|
32
34
|
locale,
|
|
33
35
|
className,
|
|
34
36
|
afterSubtotal,
|
|
37
|
+
showTotal = true,
|
|
35
38
|
...props
|
|
36
39
|
}: CartTotalProps) {
|
|
37
40
|
return (
|
|
@@ -57,10 +60,10 @@ export function CartTotal({
|
|
|
57
60
|
</HStack>
|
|
58
61
|
))}
|
|
59
62
|
|
|
60
|
-
<HStack space="none" className="mt-1.5 justify-between border-t border-border pt-2">
|
|
61
|
-
<Text className="font-
|
|
62
|
-
<Text className="font-
|
|
63
|
-
</HStack>
|
|
63
|
+
{showTotal && <HStack space="none" className="mt-1.5 justify-between border-t border-border pt-2">
|
|
64
|
+
<Text className="font-semibold">Total</Text>
|
|
65
|
+
<Text className="font-semibold">{formatMoney(total, locale) ?? '—'}</Text>
|
|
66
|
+
</HStack>}
|
|
64
67
|
</VStack>
|
|
65
68
|
);
|
|
66
69
|
}
|
package/src/cart/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { CartLine, type CartLineProps } from './cart-line';
|
|
2
|
-
export { CartColumnHeads, type CartColumnHeadsProps } from './cart-columns';
|
|
2
|
+
export { CartColumnHeads, cartColumnIds, type CartColumnHeadsProps, type CartColumnSettings } from './cart-columns';
|
|
3
3
|
export { CartTotal, type CartTotalProps } from './cart-total';
|
|
4
4
|
export { CartPanel, type CartPanelProps } from './cart-panel';
|
|
5
5
|
export { DiscountBadge, type DiscountBadgeProps } from './discount-badge';
|
|
@@ -3,7 +3,7 @@ import { Pressable, ScrollView, View } from 'react-native';
|
|
|
3
3
|
import { Select } from '@tallyui/primitives';
|
|
4
4
|
import { useCustomerTraits, type CustomerTraits } from '@tallyui/core';
|
|
5
5
|
import { cn } from '@tallyui/theme';
|
|
6
|
-
import { VStack, type VStackProps } from '../ui';
|
|
6
|
+
import { Avatar, avatarInitials, HStack, VStack, type VStackProps } from '../ui';
|
|
7
7
|
import { SearchInput } from '../input/search-input';
|
|
8
8
|
import { CustomerCard } from './customer-card';
|
|
9
9
|
|
|
@@ -21,6 +21,10 @@ export interface CustomerSelectProps<Doc = any> extends Omit<VStackProps, 'child
|
|
|
21
21
|
placeholder?: string;
|
|
22
22
|
/** Renders the search input; pass false when the parent renders its own (as CustomerPicker does) */
|
|
23
23
|
showSearch?: boolean;
|
|
24
|
+
/** Draws an initials avatar before each row and the selected summary, the way v2's cart dropdown does */
|
|
25
|
+
showAvatar?: boolean;
|
|
26
|
+
/** The avatar's tone; defaults to `'primary'`, v2's look (light initials on a solid primary circle) */
|
|
27
|
+
avatarTone?: 'muted' | 'primary';
|
|
24
28
|
className?: string;
|
|
25
29
|
}
|
|
26
30
|
|
|
@@ -59,12 +63,26 @@ function CustomerSelectView<Doc>({
|
|
|
59
63
|
onSearch,
|
|
60
64
|
placeholder = 'Search customers...',
|
|
61
65
|
showSearch = true,
|
|
66
|
+
showAvatar = false,
|
|
67
|
+
avatarTone = 'primary',
|
|
62
68
|
className,
|
|
63
69
|
traits,
|
|
64
70
|
...props
|
|
65
71
|
}: CustomerSelectProps<Doc>) {
|
|
66
72
|
const [search, setSearch] = useState('');
|
|
67
73
|
|
|
74
|
+
// The avatar is decorative: the row's accessibility label already carries the name and email.
|
|
75
|
+
function card(doc: Doc) {
|
|
76
|
+
const customerCard = <CustomerCard doc={doc} traits={traits} />;
|
|
77
|
+
if (!showAvatar) return customerCard;
|
|
78
|
+
return (
|
|
79
|
+
<HStack space="sm">
|
|
80
|
+
<Avatar aria-hidden size="sm" tone={avatarTone} fallback={avatarInitials(traits?.getName(doc) ?? '')} />
|
|
81
|
+
{customerCard}
|
|
82
|
+
</HStack>
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
|
|
68
86
|
// Map selected customer to Select primitive's Option format
|
|
69
87
|
const selectedOption = selected && traits
|
|
70
88
|
? { value: traits.getId(selected), label: traits.getName(selected) }
|
|
@@ -103,7 +121,7 @@ function CustomerSelectView<Doc>({
|
|
|
103
121
|
{selected && traits && (
|
|
104
122
|
<Select.Trigger asChild>
|
|
105
123
|
<View className="rounded-lg border border-primary bg-primary/5 px-3 py-2">
|
|
106
|
-
|
|
124
|
+
{card(selected)}
|
|
107
125
|
</View>
|
|
108
126
|
</Select.Trigger>
|
|
109
127
|
)}
|
|
@@ -123,7 +141,7 @@ function CustomerSelectView<Doc>({
|
|
|
123
141
|
asChild
|
|
124
142
|
>
|
|
125
143
|
<Pressable accessibilityLabel={email ? `${label}, ${email}` : label} className="border-b border-border px-3 py-2">
|
|
126
|
-
|
|
144
|
+
{card(customer)}
|
|
127
145
|
</Pressable>
|
|
128
146
|
</Select.Item>
|
|
129
147
|
);
|
package/src/index.ts
CHANGED
|
@@ -44,6 +44,18 @@ export {
|
|
|
44
44
|
type InCartBadgeProps,
|
|
45
45
|
CategoryTile,
|
|
46
46
|
type CategoryTileProps,
|
|
47
|
+
VariationPicker,
|
|
48
|
+
type VariationPickerProps,
|
|
49
|
+
CameraScanButton,
|
|
50
|
+
type CameraScanButtonProps,
|
|
51
|
+
CameraScannerPanel,
|
|
52
|
+
FLASH_DURATION_MS,
|
|
53
|
+
SCANNER_MIN_HEIGHT,
|
|
54
|
+
SCANNER_MAX_HEIGHT,
|
|
55
|
+
SCANNER_DEFAULT_HEIGHT,
|
|
56
|
+
type CameraScannerPanelProps,
|
|
57
|
+
ScannerViewfinder,
|
|
58
|
+
type ViewfinderProps,
|
|
47
59
|
} from './product';
|
|
48
60
|
|
|
49
61
|
// Cart components
|
|
@@ -63,6 +75,8 @@ export {
|
|
|
63
75
|
type CartAction,
|
|
64
76
|
CartColumnHeads,
|
|
65
77
|
type CartColumnHeadsProps,
|
|
78
|
+
cartColumnIds,
|
|
79
|
+
type CartColumnSettings,
|
|
66
80
|
CartFoot,
|
|
67
81
|
type CartFootProps,
|
|
68
82
|
type CartFootAction,
|
|
@@ -138,6 +152,10 @@ export {
|
|
|
138
152
|
type RefundFormValue,
|
|
139
153
|
RefundModal,
|
|
140
154
|
type RefundModalProps,
|
|
155
|
+
OrderFilterBar,
|
|
156
|
+
type OrderFilterBarProps,
|
|
157
|
+
type OrderFilterOption,
|
|
158
|
+
type PaymentMethodKind,
|
|
141
159
|
} from './order';
|
|
142
160
|
|
|
143
161
|
// Register components
|
|
@@ -187,8 +205,15 @@ export {
|
|
|
187
205
|
type ConnectionStatus,
|
|
188
206
|
DisplaySettings,
|
|
189
207
|
type DisplaySettingsProps,
|
|
208
|
+
TaxCalculationSettings,
|
|
209
|
+
type TaxCalculationSettingsProps,
|
|
210
|
+
CustomerDisplaySettings,
|
|
211
|
+
type CustomerDisplaySettingsProps,
|
|
190
212
|
} from './settings';
|
|
191
213
|
|
|
214
|
+
// Tax components
|
|
215
|
+
export { TaxBasedOn, type TaxBasedOnProps } from './tax';
|
|
216
|
+
|
|
192
217
|
// Sale components
|
|
193
218
|
export {
|
|
194
219
|
Cart, CartBar, Tender, SplitTender, TenderPane, type TenderPaneProps, DiscountForm, DiscountChips, parseDiscount, discountLabel,
|
|
@@ -196,6 +221,7 @@ export {
|
|
|
196
221
|
ChargeForm, type ChargeFormProps,
|
|
197
222
|
Catalogue, formatStockSyncTime, Receipt, injectPrintStyle, SyncStatus, OrdersList, type OrderHistoryRow, orderReference,
|
|
198
223
|
ParkedSales, type ParkedSalesProps, OpenSaleTabs, type OpenSaleTabsProps, CustomerDisplayScreen,
|
|
224
|
+
CustomerDisplayPairing, type CustomerDisplayPairingProps,
|
|
199
225
|
ProductFilterBar, DEFAULT_PRODUCT_FILTERS, PRODUCT_FILTER_CHIPS, type ProductFilterBarProps, type ProductFilterChip, type ProductFilters,
|
|
200
226
|
} from './sale';
|
|
201
227
|
|
|
@@ -223,6 +249,7 @@ export {
|
|
|
223
249
|
export {
|
|
224
250
|
SalesRoom, type SalesRoomProps, SalesHero, type SalesHeroProps, SalesCards, type SalesCardsProps, type SalesCardId,
|
|
225
251
|
SalesFiltersBar, type SalesFiltersBarProps, type SalesFilters, type SalesOption,
|
|
252
|
+
DateRangeMenu, type DateRangeMenuProps,
|
|
226
253
|
} from './reports';
|
|
227
254
|
|
|
228
255
|
// Fonts
|
|
@@ -16,7 +16,7 @@ export function SearchInput({ value, onChangeText, className, placeholder = 'Sea
|
|
|
16
16
|
|
|
17
17
|
return (
|
|
18
18
|
<HStack space="sm" className={cn(
|
|
19
|
-
'rounded-lg border bg-card px-3
|
|
19
|
+
'h-11 items-center rounded-lg border bg-card px-3',
|
|
20
20
|
focused ? 'border-ring' : 'border-border',
|
|
21
21
|
className,
|
|
22
22
|
)}>
|
package/src/order/index.ts
CHANGED
|
@@ -4,3 +4,4 @@ export { OrderList, type OrderListProps } from './order-list';
|
|
|
4
4
|
export { OrderDetail, type OrderDetailProps, type OrderDetailLineItem } from './order-detail';
|
|
5
5
|
export { RefundForm, type RefundFormProps, type RefundFormValue } from './refund-form';
|
|
6
6
|
export { RefundModal, type RefundModalProps } from './refund-modal';
|
|
7
|
+
export { OrderFilterBar, type OrderFilterBarProps, type OrderFilterOption, type PaymentMethodKind } from './order-filter-bar';
|