@tallyui/components 4.1.0 → 5.0.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.
Files changed (40) hide show
  1. package/dist/index.d.ts +133 -50
  2. package/dist/index.js +2134 -1722
  3. package/package.json +10 -9
  4. package/src/cart/cart-columns-form.tsx +1 -1
  5. package/src/cart/cart-line-strip.tsx +17 -4
  6. package/src/customer/customer-dropdown.tsx +6 -2
  7. package/src/customer/customer-editor.tsx +2 -2
  8. package/src/customer/customer-picker.tsx +15 -12
  9. package/src/i18n/locales/en/components.json +23 -2
  10. package/src/index.ts +4 -2
  11. package/src/layout/settings-layout.tsx +16 -4
  12. package/src/lib/motion.ts +6 -0
  13. package/src/order/index.ts +1 -0
  14. package/src/order/refund-form.tsx +16 -3
  15. package/src/order/refund-needs-admin-notice.tsx +29 -0
  16. package/src/product/product-table.tsx +18 -7
  17. package/src/product/product-variant-picker.tsx +4 -0
  18. package/src/register/register-count.tsx +1 -1
  19. package/src/reports/card-panel.tsx +3 -1
  20. package/src/reports/cards.tsx +1 -0
  21. package/src/sale/cancel-payment-view.tsx +102 -0
  22. package/src/sale/cart.tsx +12 -8
  23. package/src/sale/catalogue-settings-form.tsx +2 -2
  24. package/src/sale/catalogue.tsx +57 -12
  25. package/src/sale/charge-form.tsx +21 -3
  26. package/src/sale/customer-display-screen.tsx +2 -1
  27. package/src/sale/index.ts +2 -2
  28. package/src/sale/open-sale-tabs.tsx +23 -3
  29. package/src/sale/orders-list.tsx +10 -3
  30. package/src/sale/receipt-sheet.tsx +28 -8
  31. package/src/sale/receipt.tsx +1 -0
  32. package/src/sale/sale-error-text.ts +10 -0
  33. package/src/sale/since-text.ts +6 -3
  34. package/src/sale/sync-status.tsx +10 -1
  35. package/src/sale/tender-ledger.tsx +54 -11
  36. package/src/sale/tender-pane.tsx +106 -38
  37. package/src/sale/tender.tsx +7 -5
  38. package/src/sale/void-in-flight.ts +19 -0
  39. package/src/ui/tabs/index.tsx +1 -1
  40. package/src/checkout/payment-types.test-d.ts +0 -28
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tallyui/components",
3
- "version": "4.1.0",
3
+ "version": "5.0.0",
4
4
  "type": "module",
5
5
  "description": "Universal POS UI components for Tally UI",
6
6
  "main": "./dist/index.js",
@@ -19,6 +19,7 @@
19
19
  "src",
20
20
  "!src/**/*.test.ts",
21
21
  "!src/**/*.test.tsx",
22
+ "!src/**/*.test-d.ts",
22
23
  "!src/**/__tests__/**"
23
24
  ],
24
25
  "license": "MIT",
@@ -28,9 +29,9 @@
28
29
  "directory": "packages/components"
29
30
  },
30
31
  "peerDependencies": {
31
- "@tallyui/core": "^4.1.0",
32
- "@tallyui/primitives": "^4.1.0",
33
- "@tallyui/theme": "^4.1.0",
32
+ "@tallyui/core": "^5.0.0",
33
+ "@tallyui/primitives": "^5.0.0",
34
+ "@tallyui/theme": "^5.0.0",
34
35
  "react": ">=18",
35
36
  "react-native": ">=0.74",
36
37
  "react-native-svg": ">=15"
@@ -39,13 +40,13 @@
39
40
  "class-variance-authority": "^0.7.1",
40
41
  "i18next": "^26.7.1",
41
42
  "react-i18next": "^17.1.12",
42
- "@tallyui/pos": "4.1.0"
43
+ "@tallyui/pos": "5.0.0"
43
44
  },
44
45
  "devDependencies": {
45
- "@tallyui/connector-medusa": "4.1.0",
46
- "@tallyui/connector-vendure": "4.1.0",
47
- "@tallyui/connector-woocommerce": "4.1.0",
48
- "@tallyui/mock-api": "4.1.0",
46
+ "@tallyui/connector-medusa": "5.0.0",
47
+ "@tallyui/connector-vendure": "5.0.0",
48
+ "@tallyui/connector-woocommerce": "5.0.0",
49
+ "@tallyui/mock-api": "5.0.0",
49
50
  "@types/react": ">=18",
50
51
  "react": "^19.2.4",
51
52
  "react-native-svg": "15.12.1",
@@ -55,7 +55,7 @@ export function CartColumnsForm({ value = {}, onChange, showReset = false, class
55
55
  };
56
56
  return (
57
57
  <View className={cn('gap-1', className)} {...viewProps}>
58
- <Text role="heading" className="pb-1 text-base font-semibold">{t('common.columns')}</Text>
58
+ <Text role="heading" aria-level={4} className="pb-1 text-base font-semibold">{t('common.columns')}</Text>
59
59
  {order.map((id, at) => {
60
60
  const label = t(LABELS[id]);
61
61
  const show = value[id]?.show ?? CART_COLUMN_DEFAULT_SHOWN[id];
@@ -1,8 +1,8 @@
1
- // Ported from WCPOS v2 packages/core/src/screens/main/pos/cart/cells/line-strip.tsx (press to open, Remove flies the row off; no swipe or hover yet) and cells/edit-cart-item-button.tsx; MIT, WCPOS.
1
+ // Ported from WCPOS v2 packages/core/src/screens/main/pos/cart/cells/line-strip.tsx (press to open, Remove flies the row off; the Total peeks on hover; no swipe yet) and cells/edit-cart-item-button.tsx; MIT, WCPOS.
2
2
  import { useRef, useState, type JSX, type ReactNode } from 'react';
3
3
  import { Animated, Platform, Pressable, View } from 'react-native';
4
4
  import { Button, Text } from '../ui';
5
- import { ARM, EASE_EXIT, PANEL_SLIDE_OUT } from '../lib/motion';
5
+ import { ARM, EASE_EXIT, PANEL_SLIDE_OUT, PEEK, PEEK_SPRING } from '../lib/motion';
6
6
  import { useReducedMotion } from '../lib/use-reduced-motion';
7
7
 
8
8
  /** A cart row with v2's hidden strip under it: pressing the row's Total slides the row left onto a solid Edit and Remove. */
@@ -18,11 +18,14 @@ export function CartLineStrip({ name, onEdit, onRemove, children }: {
18
18
  // The row is flying off or its removal is committing: nothing else may move it.
19
19
  const leaving = useRef(false);
20
20
  const [open, setOpen] = useState(false);
21
+ // `open` at event time: react-native-web binds a Pressable's hover-out listener at hover-in and keeps that closure (modules/useHover).
22
+ const opened = useRef(false);
21
23
  const [rowWidth, setRowWidth] = useState<number>();
22
24
  const [stripWidth, setStripWidth] = useState(0);
23
25
  const settle = (next: boolean) => {
24
26
  if (leaving.current) return;
25
27
  setOpen(next);
28
+ opened.current = next;
26
29
  const target = next ? -stripWidth : 0;
27
30
  if (reduced) offset.setValue(target);
28
31
  else Animated.spring(offset, { toValue: target, overshootClamping: true, useNativeDriver: Platform.OS !== 'web' }).start();
@@ -39,9 +42,19 @@ export function CartLineStrip({ name, onEdit, onRemove, children }: {
39
42
  settle(false);
40
43
  });
41
44
  };
45
+ // v2's peek: only a closed, staying row, and only with reduced motion known to be off.
46
+ const peek = (on: boolean) => {
47
+ if (opened.current || leaving.current || reduced) return;
48
+ if (on) Animated.spring(offset, { ...PEEK_SPRING, toValue: -PEEK, useNativeDriver: Platform.OS !== 'web' }).start();
49
+ else settle(false);
50
+ };
51
+ // A peek retargeted mid-close keeps the spring's velocity (SpringAnimation.start), so the bounce could swing past 0 and bare the strip's red at the left: never right of rest.
52
+ const shown = useRef(offset.interpolate({ inputRange: [-1, 0], outputRange: [-1, 0], extrapolateRight: 'clamp' })).current;
42
53
  const wrapTotal = (content: ReactNode) => <Pressable testID="cart-line-total" accessibilityRole="button"
43
54
  accessibilityLabel={`Edit total of ${name}`} accessibilityState={{ expanded: open }} className="justify-center"
44
- onPress={() => settle(!open)}>{content}</Pressable>;
55
+ onPress={() => settle(!open)} onHoverIn={() => peek(true)} onHoverOut={() => peek(false)}>{content}
56
+ {/* v2's HOVER_REACH: past the bounce, so the Total never slides out from under a resting pointer; closed only, or it would take Edit's presses. */}
57
+ {open ? null : <View className="absolute inset-y-0 left-0" style={{ right: -PEEK * 2 }} />}</Pressable>;
45
58
  const block = 'h-auto min-w-16 rounded-none px-5';
46
59
  return <View testID="cart-line-row" className="relative overflow-hidden" onLayout={(event) => setRowWidth(event.nativeEvent.layout.width)}>
47
60
  <View testID="cart-line-strip" className="absolute inset-y-0 right-0 flex-row items-stretch justify-end bg-destructive"
@@ -54,6 +67,6 @@ export function CartLineStrip({ name, onEdit, onRemove, children }: {
54
67
  onPress={leave}><Text>Remove</Text></Button>
55
68
  </View>
56
69
  </View>
57
- <Animated.View className="bg-background" style={{ transform: [{ translateX: offset }] }}>{children(wrapTotal)}</Animated.View>
70
+ <Animated.View className="bg-background" style={{ transform: [{ translateX: shown }] }}>{children(wrapTotal)}</Animated.View>
58
71
  </View>;
59
72
  }
@@ -5,6 +5,7 @@ import { Platform, Pressable, ScrollView, StyleSheet, Text, View, type NativeScr
5
5
  import { CustomerServiceError, type Customer } from '@tallyui/core';
6
6
  import { Popover } from '@tallyui/primitives';
7
7
  import { cn } from '@tallyui/theme';
8
+ import { useT } from '../i18n';
8
9
  import { Avatar, avatarInitials, Input, UserIcon } from '../ui';
9
10
  import { MapPinIcon } from '../ui/icon/map-pin-icon';
10
11
  import { customerErrorText } from './customer-picker';
@@ -56,6 +57,9 @@ export function CustomerDropdown({ search, browse, selected, onSelect, onError,
56
57
  const canBrowse = browse !== undefined;
57
58
  const onErrorRef = useRef(onError);
58
59
  onErrorRef.current = onError;
60
+ const t = useT();
61
+ const tRef = useRef(t);
62
+ tRef.current = t;
59
63
  const chip = useRef<View>(null);
60
64
  const name = selected?.name ?? 'Guest';
61
65
  // The shown rows' paging: their generation (any newer first page makes older pages stale), query, last page loaded
@@ -80,7 +84,7 @@ export function CustomerDropdown({ search, browse, selected, onSelect, onError,
80
84
  p.done = results.length < PAGE_SIZE;
81
85
  } catch (error) {
82
86
  if (stale()) return;
83
- setError(customerErrorText(error));
87
+ setError(customerErrorText(error, tRef.current));
84
88
  if (!(error instanceof CustomerServiceError)) onErrorRef.current?.(error);
85
89
  }
86
90
  }, blank ? 0 : debounceMs);
@@ -106,7 +110,7 @@ export function CustomerDropdown({ search, browse, selected, onSelect, onError,
106
110
  if (!fresh.length) p.done = true;
107
111
  } catch (error) {
108
112
  if (paging.current.gen !== p.gen) return;
109
- setError(customerErrorText(error));
113
+ setError(customerErrorText(error, tRef.current));
110
114
  if (!(error instanceof CustomerServiceError)) onErrorRef.current?.(error);
111
115
  } finally { p.busy = false; }
112
116
  };
@@ -53,7 +53,7 @@ export function CustomerEditor({ customer, create, update, onSaved, onCancel, on
53
53
  if (disabled) return;
54
54
  const trimmed: CustomerEditValues = { ...values, firstName: values.firstName.trim(), lastName: values.lastName.trim(),
55
55
  email: values.email.trim(), phone: values.phone.trim(), company: values.company?.trim() };
56
- const error = customerEmailError(trimmed.email);
56
+ const error = customerEmailError(trimmed.email, t);
57
57
  if (error) return setEmailError(error);
58
58
  let call: Promise<Customer> | undefined;
59
59
  if (!customer) call = create?.(toCustomerInput(trimmed));
@@ -69,7 +69,7 @@ export function CustomerEditor({ customer, create, update, onSaved, onCancel, on
69
69
  const result = await call;
70
70
  if (mounted.current) onSaved(result);
71
71
  } catch (failure) {
72
- if (mounted.current) setSaveError(customerErrorText(failure));
72
+ if (mounted.current) setSaveError(customerErrorText(failure, t));
73
73
  } finally {
74
74
  if (mounted.current) setSaving(false);
75
75
  }
@@ -6,6 +6,8 @@ import { CustomerCard } from './customer-card';
6
6
  import { CustomerSelect } from './customer-select';
7
7
  import { GuestGlyph } from './customer-dropdown';
8
8
  import { CustomerForm, type CustomerFormValues } from './customer-form';
9
+ import type { TFunction } from 'i18next';
10
+ import { useT } from '../i18n';
9
11
 
10
12
  export interface CustomerPickerProps {
11
13
  /** The connector's searchCustomers, bound to its context by the app. */
@@ -34,23 +36,24 @@ const EMAIL_MAX = 254;
34
36
  /** A simple shape, not RFC 5322: one `@`, a non-empty local part, a domain with text either side of a dot, no whitespace or NUL. */
35
37
  const EMAIL_SHAPE = /^[^\s@\u0000]+@[^\s@\u0000]+\.[^\s@\u0000]+$/u;
36
38
 
37
- /** The cashier's text for an email the store's shape check would refuse, else undefined (CustomerPicker's and CustomerEditor's). */
38
- export function customerEmailError(email: string): string | undefined {
39
- return email.length > EMAIL_MAX || !EMAIL_SHAPE.test(email) ? `Enter a valid email address (up to ${EMAIL_MAX} characters)` : undefined;
39
+ /** The cashier's text, read from the `customers.invalid_email` catalogue key, for an email the store's shape check would refuse, else undefined (CustomerPicker's and CustomerEditor's). */
40
+ export function customerEmailError(email: string, t: TFunction): string | undefined {
41
+ return email.length > EMAIL_MAX || !EMAIL_SHAPE.test(email) ? t('customers.invalid_email', { max: EMAIL_MAX }) : undefined;
40
42
  }
41
43
 
42
- /** The cashier's text for a customer search or create error (CustomerPicker's and CustomerDropdown's). */
43
- export function customerErrorText(error: unknown): string {
44
+ /** The cashier's text for a customer search or create error, read from the `customers.error_*` catalogue keys; an `invalid` error keeps the store's own reason (CustomerPicker's, CustomerEditor's and CustomerDropdown's). */
45
+ export function customerErrorText(error: unknown, t: TFunction): string {
44
46
  if (error instanceof CustomerServiceError) {
45
- return error.code === 'network' ? "Couldn't reach the store. Try again."
46
- : error.code === 'server' ? "The store couldn't do that. Try again." : error.message;
47
+ return error.code === 'network' ? t('customers.error_network')
48
+ : error.code === 'server' ? t('customers.error_server') : error.message;
47
49
  }
48
- return error instanceof ConnectorUnauthorizedError && error.code === 'unauthorized' ? 'Sign in again to continue.'
49
- : error instanceof ConnectorUnauthorizedError && error.code === 'forbidden' ? "Your account isn't allowed to do this on this store. Ask the store owner."
50
- : 'Something went wrong. Try again.';
50
+ return error instanceof ConnectorUnauthorizedError && error.code === 'unauthorized' ? t('customers.error_unauthorized')
51
+ : error instanceof ConnectorUnauthorizedError && error.code === 'forbidden' ? t('customers.error_forbidden')
52
+ : t('customers.error_unknown');
51
53
  }
52
54
 
53
55
  export function CustomerPicker({ search, create, selected, onSelect, onError, online, debounceMs = 250, className, testID = 'customer-picker-search', showAvatar = false, withGuest = false }: CustomerPickerProps) {
56
+ const t = useT();
54
57
  const [query, setQuery] = useState('');
55
58
  const [customers, setCustomers] = useState<Customer[]>([]);
56
59
  const [error, setError] = useState<string | null>(null);
@@ -65,7 +68,7 @@ export function CustomerPicker({ search, create, selected, onSelect, onError, on
65
68
  useEffect(() => { mounted.current = true; return () => { mounted.current = false; }; }, []);
66
69
 
67
70
  function handleError(error: unknown) {
68
- setError(customerErrorText(error));
71
+ setError(customerErrorText(error, t));
69
72
  if (!(error instanceof CustomerServiceError)) onError?.(error);
70
73
  }
71
74
 
@@ -89,7 +92,7 @@ export function CustomerPicker({ search, create, selected, onSelect, onError, on
89
92
  const email = values.email.trim();
90
93
  if (!online || !create || creating || !email) return;
91
94
  // The till sends this email in order.create, whose shape check refuses one over 254 characters: refuse it here instead.
92
- const emailError = customerEmailError(email);
95
+ const emailError = customerEmailError(email, t);
93
96
  if (emailError) return setError(emailError);
94
97
  setCreating(true);
95
98
  setError(null);
@@ -43,6 +43,12 @@
43
43
  "customer_display.refund_due": "Refund due",
44
44
  "customers.add_customer": "Add Customer",
45
45
  "customers.clear_search": "Clear search",
46
+ "customers.error_forbidden": "Your account isn't allowed to do this on this store. Ask the store owner.",
47
+ "customers.error_network": "Couldn't reach the store. Try again.",
48
+ "customers.error_server": "The store couldn't do that. Try again.",
49
+ "customers.error_unauthorized": "Sign in again to continue.",
50
+ "customers.error_unknown": "Something went wrong. Try again.",
51
+ "customers.invalid_email": "Enter a valid email address (up to {max} characters)",
46
52
  "customers.no_customers_yet": "No customers yet",
47
53
  "customers.no_customers_yet_description": "Customers you add, and anyone who buys from you, will appear here.",
48
54
  "customers.nothing_matches_search": "No customers match your search",
@@ -61,6 +67,7 @@
61
67
  "pos_cart.use_different_address": "Use a different address",
62
68
  "pos_checkout.after_this_payment": "After this payment · {amount}",
63
69
  "pos_checkout.amount_each": "{amount} each",
70
+ "pos_checkout.cancel_and_void": "Cancel and void",
64
71
  "pos_checkout.cancel_payment": "Cancel payment",
65
72
  "pos_checkout.cancel_payment_question": "Cancel this payment?",
66
73
  "pos_checkout.cancelled": "Cancelled",
@@ -69,6 +76,7 @@
69
76
  "pos_checkout.exact_amount": "Exact {amount}",
70
77
  "pos_checkout.full_balance": "Full balance {amount}",
71
78
  "pos_checkout.full_balance_label": "Full balance",
79
+ "pos_checkout.keep_taking_payment": "Keep taking payment",
72
80
  "pos_checkout.n_of_units": "{n} of {total}",
73
81
  "pos_checkout.n_of_ways": "{n} of {ways}",
74
82
  "pos_checkout.n_ways": "{ways} ways",
@@ -77,17 +85,20 @@
77
85
  "pos_checkout.no_payments_yet": "No payments yet",
78
86
  "pos_checkout.paid": "Paid",
79
87
  "pos_checkout.paid_in_full": "Paid in full",
88
+ "pos_checkout.paid_in_full_at": "Paid in full · {time}",
80
89
  "pos_checkout.paid_of_total": "{paid} of {total} paid",
81
90
  "pos_checkout.part_payment_left": "Part payment · {left} left after this",
82
91
  "pos_checkout.pick_amount_due": "This payment is {amount} for the picked items",
92
+ "pos_checkout.pick_rounds_to_nothing": "Cash cannot pay for these items: they round to nothing. Take them by another method.",
83
93
  "pos_checkout.payments_tab": "Payments",
84
94
  "pos_checkout.pick_fewer": "One fewer {name}",
85
95
  "pos_checkout.pick_more": "One more {name}",
86
96
  "pos_checkout.refund_due": "Refund due {amount}",
97
+ "pos_checkout.refund_on_method": "Refund {amount} on {title} from the order",
87
98
  "pos_checkout.remaining": "Remaining",
88
- "pos_checkout.remove_payment": "Remove payment",
89
99
  "pos_checkout.return_cash": "Return {amount} cash to the customer",
90
100
  "pos_checkout.rounded_from": "Rounded from {amount}",
101
+ "pos_checkout.rounding": "Rounding",
91
102
  "pos_checkout.split": "Split",
92
103
  "pos_checkout.split_the_rest": "Split the rest",
93
104
  "pos_checkout.status_authorized": "Authorized",
@@ -95,11 +106,21 @@
95
106
  "pos_checkout.status_failed": "Failed",
96
107
  "pos_checkout.status_pending": "Pending",
97
108
  "pos_checkout.status_voided": "Voided",
98
- "pos_checkout.store_holds_payment": "The store already holds this sale's payment. Remove the {amount} taken here to finish.",
109
+ "pos_checkout.store_holds_park": "The store already holds this sale's payment. The {amount} taken here can only be refunded from the order, so this sale can only be parked.",
110
+ "pos_checkout.store_holds_payment": "The store already holds this sale's payment. Cancel the {amount} taken here to finish.",
99
111
  "pos_checkout.take_amount_in": "Take {amount} in {method}",
100
112
  "pos_checkout.tendered": "Tendered",
101
113
  "pos_checkout.this_payment": "This payment",
102
114
  "pos_checkout.to_pay": "To pay",
115
+ "pos_checkout.void_later_cash_first": "Void the later cash payment first.",
116
+ "pos_checkout.cash_not_payable": "Cash cannot pay that exactly. Take {below} or {above}.",
117
+ "pos_checkout.cash_not_payable_above": "Cash cannot pay that exactly. Take {above}.",
118
+ "pos_checkout.cash_not_payable_typed": "Cash cannot pay that amount: take a whole number of the smallest cash step.",
119
+ "pos_checkout.cash_waits_for_payment": "Cash cannot pay that amount while another payment is in progress: finish that payment first.",
120
+ "pos_checkout.cash_pick_limit": "Too many rounded cash payments on this sale: take the rest as one payment.",
121
+ "pos_checkout.cash_settle_limit": "Too many rounded cash payments on this sale: take the rest by another method.",
122
+ "pos_checkout.cash_settle_limit_void": "Too many rounded cash payments on this sale: void the {amount} cash payment, then take the rest again.",
123
+ "pos_checkout.cash_settle_limit_park": "Too many rounded cash payments on this sale, and the {amount} cash payment cannot be voided here, so this sale can only be parked.",
103
124
  "pos_checkout.void_on_method": "Void {amount} on {title}",
104
125
  "receipt.email_queued": "Receipt email queued",
105
126
  "receipt.email_sent": "Email sent",
package/src/index.ts CHANGED
@@ -172,6 +172,8 @@ export {
172
172
  type RefundFormValue,
173
173
  RefundModal,
174
174
  type RefundModalProps,
175
+ RefundNeedsAdminNotice,
176
+ type RefundNeedsAdminNoticeProps,
175
177
  OrderFilterBar,
176
178
  type OrderFilterBarProps,
177
179
  type OrderFilterOption,
@@ -248,11 +250,11 @@ export { TaxBasedOn, type TaxBasedOnProps } from './tax';
248
250
 
249
251
  // Sale components
250
252
  export {
251
- Cart, CartBar, Tender, SplitTender, TenderPane, type TenderPaneProps, DiscountForm, DiscountChips, parseDiscount, discountLabel,
253
+ Cart, PickStepper, CartBar, Tender, SplitTender, TenderPane, type TenderPaneProps, DiscountForm, DiscountChips, parseDiscount, discountLabel,
252
254
  PriceForm, parsePrice, LinePopover, type LinePopoverProps,
253
255
  ChargeForm, type ChargeFormProps,
254
256
  OrderNoteSheet, type OrderNoteSheetProps,
255
- Catalogue, CatalogueSettingsForm, type CatalogueSettingsFormProps, formatStockSyncTime, Receipt, ReceiptSheet, type ReceiptSheetProps, type ReceiptSheetEmail, type ReceiptSheetTemplate, injectPrintStyle, SyncStatus, syncStatusQuiet, OrdersList, OrderSyncNotices, type OrderSyncNoticesProps, type OrderHistoryRow, orderReference,
257
+ Catalogue, CatalogueSettingsForm, type CatalogueSettingsFormProps, formatStockSyncTime, Receipt, ReceiptSheet, ReceiptEmailForm, type ReceiptEmailFormProps, type ReceiptSheetProps, type ReceiptSheetEmail, type ReceiptSheetTemplate, injectPrintStyle, SyncStatus, syncStatusQuiet, OrdersList, OrderSyncNotices, type OrderSyncNoticesProps, type OrderHistoryRow, orderReference,
256
258
  ParkedSales, type ParkedSalesProps, OpenSaleTabs, type OpenSaleTabsProps, CustomerDisplayScreen,
257
259
  CustomerDisplayPairing, type CustomerDisplayPairingProps,
258
260
  ProductFilterBar, DEFAULT_PRODUCT_FILTERS, PRODUCT_FILTER_CHIPS, type ProductFilterBarProps, type ProductFilterChip, type ProductFilters, type ProductTermFilter, type FilterOption,
@@ -4,12 +4,16 @@ import { Pressable, Text, View, useWindowDimensions, type ViewProps } from 'reac
4
4
  import { cn } from '@tallyui/theme';
5
5
 
6
6
  export interface SettingsLayoutProps extends Omit<ViewProps, 'children'> {
7
- navSlot: ReactNode;
7
+ /** A function receives closeNav; call it from an item's onPress so a pick shows that section's content on a narrow screen. */
8
+ navSlot: ReactNode | ((nav: { closeNav: () => void }) => ReactNode);
8
9
  contentSlot: ReactNode;
9
10
  headerSlot?: ReactNode;
10
11
  layout?: 'split' | 'stacked';
11
12
  breakpoint?: number;
12
13
  className?: string;
14
+ /** Controls the stacked menu; absent means the layout keeps its own state. */
15
+ navOpen?: boolean;
16
+ onNavOpenChange?: (open: boolean) => void;
13
17
  }
14
18
 
15
19
  export function SettingsLayout({
@@ -19,11 +23,19 @@ export function SettingsLayout({
19
23
  layout: layoutProp,
20
24
  breakpoint = 768,
21
25
  className,
26
+ navOpen,
27
+ onNavOpenChange,
22
28
  ...viewProps
23
29
  }: SettingsLayoutProps) {
24
30
  const { width } = useWindowDimensions();
25
31
  const layout = layoutProp ?? (width >= breakpoint ? 'split' : 'stacked');
26
- const [showNav, setShowNav] = useState(false);
32
+ const [innerOpen, setInnerOpen] = useState(false);
33
+ const showNav = navOpen ?? innerOpen;
34
+ const setShowNav = (open: boolean) => {
35
+ if (navOpen === undefined) setInnerOpen(open);
36
+ onNavOpenChange?.(open);
37
+ };
38
+ const renderNav = (closeNav: () => void) => (typeof navSlot === 'function' ? navSlot({ closeNav }) : navSlot);
27
39
 
28
40
  return (
29
41
  <View className={cn('flex-1 bg-background', className)} {...viewProps}>
@@ -31,14 +43,14 @@ export function SettingsLayout({
31
43
 
32
44
  {layout === 'split' ? (
33
45
  <View className="flex-1 flex-row">
34
- <View className="w-64 border-r border-border">{navSlot}</View>
46
+ <View className="w-64 border-r border-border">{renderNav(() => {})}</View>
35
47
  <View className="flex-1">{contentSlot}</View>
36
48
  </View>
37
49
  ) : (
38
50
  <View className="flex-1">
39
51
  {showNav ? (
40
52
  <View className="flex-1">
41
- {navSlot}
53
+ {renderNav(() => setShowNav(false))}
42
54
  <Pressable onPress={() => setShowNav(false)} className="border-t border-border p-3">
43
55
  <Text className="text-center text-sm font-medium text-primary">Done</Text>
44
56
  </Pressable>
package/src/lib/motion.ts CHANGED
@@ -20,3 +20,9 @@ export const EASE = Easing.bezier(...EASE_POINTS);
20
20
  export const CROSSFADE = 200;
21
21
  // Reanimated 4.7.1 withTiming's default easing (src/animation/timing.ts:91), which v2's accordion chevron uses.
22
22
  export const TIMING_EASE = Easing.inOut(Easing.quad);
23
+ export const PLUS_WIDTH = 48; // WCPOS v2 packages/core/src/screens/main/pos/cart/tab-window.ts:3.
24
+ export const NEW_TAB_WIDTH = 112; // WCPOS v2 packages/core/src/screens/main/pos/cart/tab-window.ts:5: the + cell unfolded into "+ New".
25
+ // WCPOS v2 packages/core/src/screens/main/pos/cart/cells/line-strip.tsx:49 (PEEK): how far a hovered row's Total peeks.
26
+ export const PEEK = 16;
27
+ // WCPOS v2 packages/core/src/screens/main/pos/cart/cells/line-strip.tsx:54 (PEEK_SPRING): the peek's underdamped bounce.
28
+ export const PEEK_SPRING = { mass: 1, stiffness: 380, damping: 12 };
@@ -4,4 +4,5 @@ export { OrderList, type OrderListProps } from './order-list';
4
4
  export { OrderDetail, type OrderDetailProps, type OrderDetailLineItem, type OrderDetailTaxLine } 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 { RefundNeedsAdminNotice, type RefundNeedsAdminNoticeProps } from './refund-needs-admin-notice';
7
8
  export { OrderFilterBar, type OrderFilterBarProps, type OrderFilterOption, type PaymentMethodKind } from './order-filter-bar';
@@ -29,6 +29,10 @@ export interface RefundFormProps {
29
29
  refundedMinor?: number;
30
30
  /** Shipping still refundable, with tax; 0 or absent hides the shipping field. */
31
31
  refundableShippingMinor?: number;
32
+ /** The order's cash rounding, signed (ADR-094): the sum of its entries, or a WooCommerce order's Rounding fee. The refund that takes every line's whole remaining quantity returns it through adjustmentMinor; default 0. */
33
+ cashRoundingMinor?: number;
34
+ /** The cash method's rounding increment (PaymentRounding.incrementMinor). A cash refund that is not a multiple of it shows a one-line notice; the refund itself is not rounded. */
35
+ cashIncrementMinor?: number;
32
36
  /** The sale's payment method; omit for a cash sale, which always refunds in cash. */
33
37
  originalMethod?: { title: string; available: boolean };
34
38
  /** Each line's restock starting value; default true. */
@@ -53,7 +57,7 @@ function parseAmount(text: string, currency: string, signed = false, format?: Mo
53
57
  /** Ports WCPOS v2 form.tsx, monorepo main 5ac185b0e; the till never prices lines itself (priceRefund). */
54
58
  export function RefundForm({
55
59
  lines, refunds, currency, orderReference, orderTotalMinor, refundedMinor = 0,
56
- refundableShippingMinor = 0, originalMethod, defaultRestock = true, online = true,
60
+ refundableShippingMinor = 0, cashRoundingMinor = 0, cashIncrementMinor, originalMethod, defaultRestock = true, online = true,
57
61
  error, onConfirm, onCancel,
58
62
  }: RefundFormProps): JSX.Element {
59
63
  const formatMoney = useFormatMoney();
@@ -76,11 +80,14 @@ export function RefundForm({
76
80
  restock: restock[orderLineId] ?? defaultRestock,
77
81
  })).filter(({ quantity }) => quantity > 0);
78
82
  const priced = priceRefund(lines, refunds, request);
83
+ const emptiesLines = priced.lines.length > 0 && available.every(({ orderLineId, refundableQuantity }) => (request.find((line) => line.orderLineId === orderLineId)?.quantity ?? 0) === refundableQuantity);
84
+ const roundingShareMinor = emptiesLines ? cashRoundingMinor : 0;
79
85
  const shippingMinor = refundableShippingMinor > 0 ? parseAmount(shippingText, currency, false, format) : 0;
80
86
  const adjustmentMinor = parseAmount(adjustmentText, currency, true, format);
81
87
  const totalMinor = typeof shippingMinor === 'number' && typeof adjustmentMinor === 'number'
82
- ? priced.totalMinor + shippingMinor + adjustmentMinor : undefined;
88
+ ? priced.totalMinor + shippingMinor + adjustmentMinor + roundingShareMinor : undefined;
83
89
  const destination = originalMethod?.available ? (picked ?? 'original_method') : 'cash';
90
+ const cashStep = destination === 'cash' && Number.isInteger(cashIncrementMinor) && cashIncrementMinor! > 1 && typeof totalMinor === 'number' && totalMinor > 0 && totalMinor % cashIncrementMinor! !== 0;
84
91
  const invalid = typeof shippingMinor === 'string' ? shippingMinor
85
92
  : typeof adjustmentMinor === 'string' ? adjustmentMinor
86
93
  : shippingMinor > refundableShippingMinor ? `Shipping can be at most ${fmt(refundableShippingMinor)}.`
@@ -98,7 +105,7 @@ export function RefundForm({
98
105
  const value: RefundFormValue = {
99
106
  lines: priced.lines,
100
107
  shippingMinor: shippingMinor as number,
101
- adjustmentMinor: adjustmentMinor as number,
108
+ adjustmentMinor: (adjustmentMinor as number) + roundingShareMinor,
102
109
  totalMinor: totalMinor!,
103
110
  destination,
104
111
  reason: reason.trim(),
@@ -178,10 +185,16 @@ export function RefundForm({
178
185
  Original payment method refunds are unavailable for this order.
179
186
  </Text>}
180
187
  </View>}
188
+ {roundingShareMinor !== 0 && <View className="flex-row justify-between gap-2">
189
+ <Text>Rounding</Text><Text testID="refund-rounding">{fmt(roundingShareMinor)}</Text>
190
+ </View>}
181
191
  <View className="flex-row justify-between gap-2">
182
192
  <Text className="font-semibold">Refund Total</Text>
183
193
  <Text testID="refund-total" className="font-semibold">{fmt(totalMinor ?? 0)}</Text>
184
194
  </View>
195
+ {cashStep && <Text testID="refund-cash-step" className="text-muted-foreground">
196
+ {`Cash cannot pay ${fmt(totalMinor)} exactly. The smallest cash step is ${fmt(cashIncrementMinor!)}.`}
197
+ </Text>}
185
198
  </ScrollView>
186
199
  {online === false && <Text testID="refund-offline-reason" className="text-muted-foreground">Refunds need a connection</Text>}
187
200
  {invalid && online !== false && <Text testID="refund-invalid" className="text-muted-foreground">{invalid}</Text>}
@@ -0,0 +1,29 @@
1
+ import type { JSX } from 'react';
2
+ import { View } from 'react-native';
3
+ import { NEEDS_ADMIN_MESSAGE_MAX } from '@tallyui/core';
4
+ import { refundNeedsAdminLine } from '@tallyui/pos';
5
+ import { Button } from '../ui/button';
6
+ import { Text } from '../ui/text';
7
+
8
+ export type RefundNeedsAdminNoticeProps = {
9
+ /** The server's needs_admin reason: the outcome's `reason`, or a pending record's `error.data.reason`. */
10
+ reason: string;
11
+ /** The server's message: shown under the lead line as plain text, cut to NEEDS_ADMIN_MESSAGE_MAX. */
12
+ message?: string;
13
+ /** Resends the same refund envelope (same id); omit to hide the button. */
14
+ onCheckAgain?: () => void;
15
+ };
16
+
17
+ export function RefundNeedsAdminNotice({ reason, message, onCheckAgain }: RefundNeedsAdminNoticeProps): JSX.Element {
18
+ return <View>
19
+ <Text testID="refund-needs-admin-line" accessibilityLiveRegion="polite" className="text-destructive">
20
+ {refundNeedsAdminLine(reason)}
21
+ </Text>
22
+ {message ? <Text testID="refund-needs-admin-message" className="text-muted-foreground">
23
+ {message.slice(0, NEEDS_ADMIN_MESSAGE_MAX)}
24
+ </Text> : null}
25
+ {onCheckAgain ? <Button testID="refund-needs-admin-check-again" onPress={onCheckAgain}>
26
+ <Text>Check again</Text>
27
+ </Button> : null}
28
+ </View>;
29
+ }
@@ -4,7 +4,7 @@ import { useProductTraits, useTraitContext, useStockOverlaid, type ProductTraits
4
4
  import { productSortValue, sortProducts, type ProductSort, type ProductSortValue } from '@tallyui/pos';
5
5
  import { cn } from '@tallyui/theme';
6
6
  import { Table, TableHeader, TableBody, TableRow, TableHead, TableCell, Text, VStack, IconButton, PlusIcon, ChevronRightIcon,
7
- Skeleton, skeletonCount } from '../ui';
7
+ ChevronDownIcon, Skeleton, skeletonCount } from '../ui';
8
8
  import { MinTargetBand } from '../scale/min-target';
9
9
  import { usePointer } from '../scale/use-pointer';
10
10
  import { ProductImage } from './product-image';
@@ -88,8 +88,12 @@ export interface ProductTableProps extends Omit<ViewProps, 'children'> {
88
88
  /** With renderExpanded and showThumbnail, a product with more than one variant has its thumbnail toggle its
89
89
  * expanded block: a button labelled "Show variations" with aria-expanded. A press calls this, never onSelect. */
90
90
  onToggleExpand?: (doc: ProductTableRowDoc) => void;
91
- /** The block drawn under an expanded row (e.g. its variant rows), indented by the thumbnail column. */
91
+ /** The block drawn under an expanded row (e.g. its variant rows), indented by the thumbnail column when it shows. */
92
92
  renderExpanded?: (doc: ProductTableRowDoc) => ReactNode;
93
+ /** v2's "{count} variations" button under the first cell's content, with a chevron and aria-expanded, on a product
94
+ * with more than one variant. A press calls onToggleExpand, never onSelect; needs onToggleExpand and renderExpanded,
95
+ * and makes such rows expandable without showThumbnail. Default false. */
96
+ variationsButton?: boolean;
93
97
  /** With no items, draw the header and skeleton rows instead of emptyState, as WCPOS v2's DataTableSkeleton. */
94
98
  loading?: boolean;
95
99
  className?: string;
@@ -121,7 +125,7 @@ export function useDefaultProductColumns(options?: { currencySymbol?: string }):
121
125
  export function ProductTable({
122
126
  items, columns, sort, defaultSort = null, onSortChange, sortItems = true, onSelect,
123
127
  searchSlot, filterSlot, emptyState, showUnsellable = false, currencySymbol, showThumbnail = false,
124
- showAddButton = false, cartQuantity, isExpanded, onToggleExpand, renderExpanded, loading = false, className, ...viewProps
128
+ showAddButton = false, cartQuantity, isExpanded, onToggleExpand, renderExpanded, variationsButton = false, loading = false, className, ...viewProps
125
129
  }: ProductTableProps): JSX.Element {
126
130
  // Without a ConnectorProvider, custom columns can render without traits.
127
131
  let traits: ReturnType<typeof useProductTraits> | undefined;
@@ -190,7 +194,8 @@ export function ProductTable({
190
194
  const key = String(item.id ?? index);
191
195
  const variations = addButton && traits !== undefined && traits.getVariantCount(item) > 1;
192
196
  const count = addButton && !variations ? cartQuantity?.(item) ?? 0 : 0;
193
- const expandable = thumbnail && onToggleExpand !== undefined && renderExpanded !== undefined && traits!.getVariantCount(item) > 1;
197
+ const variantCount = traits?.getVariantCount(item) ?? 0;
198
+ const expandable = (thumbnail || variationsButton) && onToggleExpand !== undefined && renderExpanded !== undefined && variantCount > 1;
194
199
  const expanded = expandable && (isExpanded?.(item) ?? false);
195
200
  const row = (
196
201
  <TableRow testID={onSelect ? undefined : 'product-row-' + key}>
@@ -199,9 +204,15 @@ export function ProductTable({
199
204
  testID={'product-row-expand-' + key} onPress={(event) => { event.stopPropagation?.(); onToggleExpand!(item); }}>
200
205
  <ProductImage doc={item} size={thumb} showPlaceholder className="rounded-md" /></Pressable> :
201
206
  <ProductImage doc={item} size={thumb} showPlaceholder className="rounded-md" />}</TableCell> : null}
202
- {resolvedColumns.map((column) => (
207
+ {resolvedColumns.map((column, cell) => (
203
208
  <TableCell key={column.id} style={{ flex: column.flex ?? 1 }}
204
- className={cn('px-3 py-1.5', column.align && ALIGN[column.align])}>{column.render(item)}</TableCell>
209
+ className={cn('px-3 py-1.5', column.align && ALIGN[column.align])}>{column.render(item)}
210
+ {cell === 0 && expandable && variationsButton ? <Pressable accessibilityRole="button" aria-expanded={expanded}
211
+ testID={'product-row-variations-' + key} className="mt-0.5 self-start flex-row items-center gap-1"
212
+ onPress={(event) => { event.stopPropagation?.(); onToggleExpand!(item); }}>
213
+ <View className="text-muted-foreground">{expanded ? <ChevronDownIcon size={14} /> : <ChevronRightIcon size={14} />}</View>
214
+ <Text className="text-xs text-muted-foreground">{`${variantCount} variations`}</Text>
215
+ </Pressable> : null}</TableCell>
205
216
  ))}
206
217
  {addButton ? (
207
218
  <TableCell style={{ width: ACTION_WIDTH }} className="flex-none items-center justify-center px-0 py-1.5">
@@ -222,7 +233,7 @@ export function ProductTable({
222
233
  {row}
223
234
  </Pressable>
224
235
  ) : row}
225
- {expanded ? <View testID={'product-row-expanded-' + key} style={{ paddingLeft: thumb + CELL_PAD_X }}
236
+ {expanded ? <View testID={'product-row-expanded-' + key} style={{ paddingLeft: thumbnail ? thumb + CELL_PAD_X : 0 }}
226
237
  className="border-b border-border">{renderExpanded!(item)}</View> : null}
227
238
  </>;
228
239
  }}
@@ -5,6 +5,8 @@ import { cn } from '@tallyui/theme';
5
5
  export interface VariantOption {
6
6
  name: string;
7
7
  values: string[];
8
+ /** Values in this group that no variant takes with the other current picks; drawn dimmed, still pressable. */
9
+ dimmed?: string[];
8
10
  }
9
11
 
10
12
  export interface ProductVariantPickerProps extends Omit<ViewProps, 'children'> {
@@ -36,10 +38,12 @@ export function ProductVariantPicker({
36
38
  return (
37
39
  <Pressable
38
40
  key={value}
41
+ testID={`variant-option-${option.name}-${value}`}
39
42
  onPress={() => handleSelect(option.name, value)}
40
43
  className={cn(
41
44
  'rounded-lg border px-3 py-1.5',
42
45
  active ? 'border-primary bg-primary/10' : 'border-border bg-card',
46
+ option.dimmed?.includes(value) && 'opacity-50',
43
47
  )}
44
48
  >
45
49
  <Text
@@ -144,7 +144,7 @@ async function saving(call: () => Promise<unknown>) {
144
144
  await call();
145
145
  } catch (e) {
146
146
  // The hook's own refusals keep their text (by name: components import no class from pos, ADR-064).
147
- const own = e instanceof Error && (e.name === 'RegisterApprovalRequiredError' || e.name === 'RegisterTenderInProgressError');
147
+ const own = e instanceof Error && (e.name === 'RegisterApprovalRequiredError' || e.name === 'RegisterTenderInProgressError' || e.name === 'RegisterSaleSavingError');
148
148
  throw own ? e : new StoreCallFailed(e);
149
149
  }
150
150
  }
@@ -62,8 +62,10 @@ function panelCells(card: SalesPanelId, figures: SalesFigures, money: (minor: nu
62
62
  };
63
63
  case 'taxes': return {
64
64
  head: ['Rate', 'Net', 'Tax', 'Gross'],
65
- rows: figures.taxes.map((row) => [taxLabel(row), row.netMinor === null ? UNKNOWN : money(row.netMinor), money(row.taxMinor),
65
+ rows: [...figures.taxes.map((row) => [taxLabel(row), row.netMinor === null ? UNKNOWN : money(row.netMinor), money(row.taxMinor),
66
66
  row.netMinor === null ? UNKNOWN : money(row.netMinor + row.taxMinor)]),
67
+ // Rounding is in gross, in no rate's net or tax: each column sums to its total.
68
+ ...(totals.roundingMinor !== 0 ? [['Rounding', '', '', money(totals.roundingMinor)]] : [])],
67
69
  total: ['Total', money(totals.netMinor), money(totals.taxMinor), money(totals.grossMinor)],
68
70
  };
69
71
  }
@@ -194,6 +194,7 @@ export function SalesCards({ figures, currency, onOpenCard, hide }: SalesCardsPr
194
194
  <StatGrid stats={[
195
195
  { label: 'Net', value: money(totals.netMinor) },
196
196
  { label: 'Tax', value: money(totals.taxMinor) },
197
+ ...(totals.roundingMinor !== 0 ? [{ label: 'Rounding', value: money(totals.roundingMinor) }] : []),
197
198
  { label: 'Gross', value: money(totals.grossMinor) },
198
199
  ]} />
199
200
  </>