@tallyui/components 3.20.1 → 4.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 (161) hide show
  1. package/dist/index.d.ts +1114 -90
  2. package/dist/index.js +8077 -3352
  3. package/package.json +10 -11
  4. package/src/cart/cart-charge-line.tsx +58 -0
  5. package/src/cart/cart-columns-form.tsx +98 -0
  6. package/src/cart/cart-columns.tsx +49 -18
  7. package/src/cart/cart-foot.tsx +7 -2
  8. package/src/cart/cart-line-strip.tsx +59 -0
  9. package/src/cart/cart-line.tsx +20 -8
  10. package/src/cart/cart-note-row.tsx +30 -0
  11. package/src/cart/cart-panel.tsx +9 -1
  12. package/src/cart/cart-row-motion.tsx +125 -0
  13. package/src/cart/cart-total.tsx +44 -15
  14. package/src/cart/index.ts +2 -1
  15. package/src/checkout/cash-tendered.tsx +8 -7
  16. package/src/checkout/change-display.tsx +2 -1
  17. package/src/checkout/index.ts +1 -1
  18. package/src/checkout/payment-selector.tsx +6 -2
  19. package/src/checkout/payment-types.test-d.ts +28 -0
  20. package/src/customer/address-editor.tsx +87 -0
  21. package/src/customer/address-fields.tsx +120 -0
  22. package/src/customer/customer-dropdown.tsx +200 -0
  23. package/src/customer/customer-editor.tsx +99 -0
  24. package/src/customer/customer-form.tsx +39 -5
  25. package/src/customer/customer-picker.tsx +38 -14
  26. package/src/customer/customers-list.tsx +83 -0
  27. package/src/customer/index.ts +5 -0
  28. package/src/filter/filter-pills.tsx +63 -0
  29. package/src/i18n/locales/en/components.json +85 -0
  30. package/src/index.ts +40 -2
  31. package/src/input/decimal-entry.ts +21 -0
  32. package/src/layout/checkout-layout.tsx +1 -1
  33. package/src/layout/live-tab-screen.tsx +1 -1
  34. package/src/layout/pos-layout.tsx +80 -4
  35. package/src/layout/settings-layout.tsx +1 -1
  36. package/src/layout/store-settings-choice-screen.tsx +1 -1
  37. package/src/lib/current-row.ts +13 -0
  38. package/src/lib/money-input.ts +16 -0
  39. package/src/lib/motion.ts +22 -0
  40. package/src/lib/use-reduced-motion.ts +20 -0
  41. package/src/order/index.ts +1 -1
  42. package/src/order/order-detail.tsx +123 -5
  43. package/src/order/order-filter-bar.tsx +7 -57
  44. package/src/order/order-status-badge.tsx +42 -19
  45. package/src/order/refund-form.tsx +7 -5
  46. package/src/product/camera-scan-button.tsx +2 -0
  47. package/src/product/category-nav.tsx +8 -0
  48. package/src/product/category-tile.tsx +65 -15
  49. package/src/product/in-cart-badge.tsx +55 -6
  50. package/src/product/index.ts +1 -0
  51. package/src/product/press-veil.tsx +7 -0
  52. package/src/product/product-card.tsx +5 -1
  53. package/src/product/product-grid.tsx +5 -0
  54. package/src/product/product-price.tsx +6 -3
  55. package/src/product/product-stock-badge.tsx +3 -2
  56. package/src/product/product-table.tsx +96 -8
  57. package/src/product/products-screen-columns.tsx +74 -0
  58. package/src/product/variant-tile.tsx +68 -0
  59. package/src/product/variation-picker.tsx +3 -3
  60. package/src/product/view-toggle.tsx +33 -4
  61. package/src/register/cashier-sheet.tsx +195 -0
  62. package/src/register/closure-sheet.tsx +54 -3
  63. package/src/register/handover-slip.tsx +2 -1
  64. package/src/register/index.ts +2 -1
  65. package/src/register/movement-sheet.tsx +66 -7
  66. package/src/register/open-register-card.tsx +11 -11
  67. package/src/register/register-bar.helpers.ts +17 -4
  68. package/src/register/register-bar.tsx +26 -5
  69. package/src/register/register-count.tsx +158 -24
  70. package/src/register/register-panel.tsx +16 -5
  71. package/src/register/register-side-sheet.tsx +32 -8
  72. package/src/register/switch-confirm.tsx +2 -2
  73. package/src/reports/card-panel.tsx +131 -0
  74. package/src/reports/cards.tsx +53 -36
  75. package/src/reports/hero.tsx +2 -1
  76. package/src/reports/index.ts +1 -0
  77. package/src/reports/sales-room.tsx +4 -2
  78. package/src/sale/breadcrumb.tsx +48 -0
  79. package/src/sale/cart-bar.tsx +2 -1
  80. package/src/sale/cart.tsx +127 -38
  81. package/src/sale/catalogue-settings-form.tsx +92 -0
  82. package/src/sale/catalogue.tsx +304 -42
  83. package/src/sale/category-browse.tsx +27 -0
  84. package/src/sale/charge-form.tsx +85 -21
  85. package/src/sale/customer-display-screen.tsx +22 -6
  86. package/src/sale/discount-form.tsx +132 -28
  87. package/src/sale/index.ts +6 -3
  88. package/src/sale/line-popover.tsx +72 -36
  89. package/src/sale/offered-methods.ts +16 -0
  90. package/src/sale/open-sale-tabs.tsx +58 -10
  91. package/src/sale/order-note-sheet.tsx +37 -0
  92. package/src/sale/order-reference.ts +3 -0
  93. package/src/sale/orders-list.tsx +76 -37
  94. package/src/sale/parked-sales.tsx +2 -1
  95. package/src/sale/price-form.tsx +7 -5
  96. package/src/sale/product-filter-bar.tsx +38 -5
  97. package/src/sale/receipt-sheet.tsx +243 -0
  98. package/src/sale/receipt.tsx +19 -9
  99. package/src/sale/sync-status.tsx +10 -0
  100. package/src/sale/tender-ledger.tsx +92 -0
  101. package/src/sale/tender-pane.tsx +159 -73
  102. package/src/sale/tender.tsx +10 -7
  103. package/src/sale/use-tender.ts +63 -0
  104. package/src/scale/min-target.tsx +36 -0
  105. package/src/settings/barcode-scanning-settings.tsx +164 -0
  106. package/src/settings/connector-status.tsx +1 -1
  107. package/src/settings/customer-display-settings.tsx +12 -25
  108. package/src/settings/index.ts +5 -0
  109. package/src/settings/printer-form.tsx +161 -0
  110. package/src/settings/printing-settings.tsx +268 -0
  111. package/src/settings/settings-group.tsx +2 -1
  112. package/src/settings/tax-calculation-settings.tsx +1 -1
  113. package/src/shell/added-to-cart-toast.tsx +61 -0
  114. package/src/shell/app-shell.tsx +5 -1
  115. package/src/shell/connectivity-toast.tsx +70 -0
  116. package/src/shell/index.ts +2 -0
  117. package/src/shell/nav-drawer.tsx +5 -2
  118. package/src/shell/nav-item.tsx +7 -4
  119. package/src/shell/nav-rail.tsx +9 -2
  120. package/src/ui/accordion/index.tsx +86 -8
  121. package/src/ui/alert-dialog/index.tsx +19 -5
  122. package/src/ui/combobox/index.tsx +21 -2
  123. package/src/ui/confirm-dialog/index.tsx +53 -0
  124. package/src/ui/dialog/index.tsx +68 -14
  125. package/src/ui/dialog/motion.ts +54 -0
  126. package/src/ui/icon/activity-heartbeat-icon.tsx +7 -0
  127. package/src/ui/icon/alert-circle-icon.tsx +5 -0
  128. package/src/ui/icon/alert-triangle-icon.tsx +7 -0
  129. package/src/ui/icon/banknote-icon.tsx +11 -0
  130. package/src/ui/icon/cash-register-icon.tsx +10 -0
  131. package/src/ui/icon/category-icon.tsx +7 -0
  132. package/src/ui/icon/chart-line-icon.tsx +5 -0
  133. package/src/ui/icon/check-icon.tsx +5 -0
  134. package/src/ui/icon/chevron-left-icon.tsx +4 -0
  135. package/src/ui/icon/chevron-right-icon.tsx +4 -0
  136. package/src/ui/icon/credit-card-icon.tsx +10 -0
  137. package/src/ui/icon/discount-icon.tsx +11 -0
  138. package/src/ui/icon/gift-icon.tsx +10 -0
  139. package/src/ui/icon/info-circle-icon.tsx +10 -0
  140. package/src/ui/icon/map-pin-icon.tsx +10 -0
  141. package/src/ui/icon/message-question-icon.tsx +7 -0
  142. package/src/ui/icon/pencil-icon.tsx +10 -0
  143. package/src/ui/icon/plus-icon.tsx +9 -0
  144. package/src/ui/icon/printer-icon.tsx +10 -0
  145. package/src/ui/icon/receipt-icon.tsx +7 -0
  146. package/src/ui/icon/settings-icon.tsx +10 -0
  147. package/src/ui/icon/sticky-note-icon.tsx +10 -0
  148. package/src/ui/icon/user-icon.tsx +4 -0
  149. package/src/ui/icon/users-icon.tsx +7 -0
  150. package/src/ui/icon/view-grid-icon.tsx +7 -0
  151. package/src/ui/icon/view-list-icon.tsx +7 -0
  152. package/src/ui/index.ts +24 -1
  153. package/src/ui/list-row/index.tsx +93 -0
  154. package/src/ui/notice/index.tsx +65 -0
  155. package/src/ui/select/index.tsx +2 -0
  156. package/src/ui/skeleton/index.tsx +37 -0
  157. package/src/ui/status-badge/index.tsx +43 -0
  158. package/src/ui/switch/index.tsx +1 -1
  159. package/src/ui/tabs/index.tsx +11 -2
  160. package/src/ui/toggle-group/index.tsx +3 -1
  161. package/src/ui/tone-disc/index.tsx +41 -0
@@ -0,0 +1,268 @@
1
+ /**
2
+ * Settings › Printing, the Printers section and template routing: ported from WCPOS v2
3
+ * `packages/core/src/screens/main/settings/printing/` (`index.tsx`, `printer-row.tsx`, `template-row.tsx`). Props only;
4
+ * the app passes the printers and wires every callback, and opens its own add/edit dialog from `onAdd` / `onEdit` and
5
+ * shows the result of `onTest`. The setup report and docs link are optional (`onCopySetupReport`, `onOpenHelp`);
6
+ * the app does the copying, the toast and opening the docs. Left out (a later row): the test-print toast.
7
+ */
8
+ import { useState, type JSX } from 'react';
9
+ import { View } from 'react-native';
10
+ import { Circle } from 'react-native-svg';
11
+ import type { ReceiptTemplate } from '@tallyui/core';
12
+ import { resolvePrinter, type PrinterProfile } from '@tallyui/pos';
13
+ import { cn } from '@tallyui/theme';
14
+ import { Button } from '../ui/button';
15
+ import { ConfirmDialog } from '../ui/confirm-dialog';
16
+ import {
17
+ DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger,
18
+ } from '../ui/dropdown-menu';
19
+ import { createSvgIcon } from '../ui/icon/svg-icon';
20
+ import { IconButton } from '../ui/icon-button';
21
+ import { Loader } from '../ui/loader';
22
+ import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '../ui/select';
23
+ import { Text } from '../ui/text';
24
+ import { SettingsGroup } from './settings-group';
25
+
26
+ type RoutedTemplate = Pick<ReceiptTemplate, 'id' | 'kind' | 'title' | 'engine' | 'paper'>;
27
+
28
+ export interface PrintingSettingsProps {
29
+ printers: readonly PrinterProfile[];
30
+ /** v2's isLoading: the section shows its title only. Default false. */
31
+ loading?: boolean;
32
+ /** Ids of printers whose test print is running; their Test Print button shows its loading state. */
33
+ testingIds?: ReadonlySet<string>;
34
+ onTest: (printer: PrinterProfile) => void;
35
+ onEdit: (printer: PrinterProfile) => void;
36
+ onSetDefault: (id: string) => void;
37
+ /** Called after the cashier confirms the delete dialog. */
38
+ onDelete: (id: string) => void;
39
+ onAdd: () => void;
40
+ /** The store's templates, in its order. When absent, no routing sections are drawn. */
41
+ templates?: readonly RoutedTemplate[];
42
+ /** Template id -> printer profile id: this device's overrides. Default `{}`. */
43
+ routing?: Readonly<Record<string, string>>;
44
+ /** A template's printer was chosen; `null` means Auto (clear the override). */
45
+ onRoutingChange?: (templateId: string, printerId: string | null) => void;
46
+ /** v2's "Copy setup report": adds that item, first in each printer row's menu, and makes the menu show for every row. The app builds
47
+ * and copies the report (clipboard or share sheet) and shows any toast; the component only calls this. */
48
+ onCopySetupReport?: (printer: PrinterProfile) => void;
49
+ /** v2's "Having trouble?" link under the printer list; pressing it calls this (the app opens its printer docs). Absent: no link. */
50
+ onOpenHelp?: () => void;
51
+ className?: string;
52
+ }
53
+
54
+ // Lucide ellipsis (ISC). TallyUI's settings rows have no row icon and there is no printer icon, so this is the only one.
55
+ const MoreIcon = createSvgIcon('MoreIcon', () => (
56
+ <>
57
+ <Circle cx="12" cy="12" r="1" />
58
+ <Circle cx="19" cy="12" r="1" />
59
+ <Circle cx="5" cy="12" r="1" />
60
+ </>
61
+ ));
62
+
63
+ const NO_TESTS: ReadonlySet<string> = new Set();
64
+
65
+ // v2's usesSystemPrintDialog also checks a `winspool` address (a Windows queue); TallyUI has no Windows queue lane,
66
+ // so every `system` printer is the Print Dialog.
67
+ const isPrintDialog = (printer: PrinterProfile) => printer.connectionType === 'system';
68
+
69
+ function connectionLabel(printer: PrinterProfile): string {
70
+ if (isPrintDialog(printer)) return 'Print Dialog · built-in';
71
+ const host = printer.address || '?';
72
+ const base = printer.port ? `${host}:${printer.port}` : host;
73
+ if (printer.vendor === 'epson') return `${base} · Epson`;
74
+ if (printer.vendor === 'star') return `${base} · Star`;
75
+ return base;
76
+ }
77
+
78
+ interface PrinterRowProps extends Pick<PrintingSettingsProps, 'onTest' | 'onEdit' | 'onSetDefault' | 'onCopySetupReport'> {
79
+ printer: PrinterProfile;
80
+ testing: boolean;
81
+ onDelete: (printer: PrinterProfile) => void;
82
+ }
83
+
84
+ function PrinterRow({ printer, testing, onTest, onEdit, onSetDefault, onDelete, onCopySetupReport }: PrinterRowProps): JSX.Element {
85
+ const { id, name, isDefault, isBuiltIn } = printer;
86
+ const canSetDefault = !isDefault && !isBuiltIn;
87
+ const canDelete = !isBuiltIn;
88
+ return (
89
+ <View testID={`printer-row-${id}`} className="gap-3 px-4 py-3 sm:flex-row sm:items-center">
90
+ <View className="flex-1 gap-0.5">
91
+ <View className="flex-row items-center gap-2">
92
+ <Text className="text-sm font-medium text-foreground">{name}</Text>
93
+ {isDefault && (
94
+ <Text testID={`printer-row-${id}-default`} className="rounded border border-border px-1.5 text-xs text-muted-foreground">
95
+ Default
96
+ </Text>
97
+ )}
98
+ </View>
99
+ <Text testID={`printer-row-${id}-connection`} className="text-xs text-muted-foreground">{connectionLabel(printer)}</Text>
100
+ </View>
101
+ <View className="flex-row items-center gap-2">
102
+ <Button testID={`printer-row-${id}-test`} variant="outline" size="sm" disabled={testing} aria-busy={testing} onPress={() => onTest(printer)}>
103
+ {testing ? <Loader size="sm" /> : null}
104
+ <Text>Test Print</Text>
105
+ </Button>
106
+ {!isBuiltIn && (
107
+ <Button testID={`printer-row-${id}-edit`} variant="outline" size="sm" onPress={() => onEdit(printer)}>
108
+ <Text>Edit</Text>
109
+ </Button>
110
+ )}
111
+ {/* Without onCopySetupReport a built-in printer's menu would be empty, so the menu shows only with an item. */}
112
+ {(canSetDefault || canDelete || onCopySetupReport) && (
113
+ <DropdownMenu>
114
+ <DropdownMenuTrigger asChild>
115
+ <IconButton testID={`printer-row-${id}-menu`} size="sm" accessibilityLabel="More actions">
116
+ <View className="text-foreground"><MoreIcon /></View>
117
+ </IconButton>
118
+ </DropdownMenuTrigger>
119
+ <DropdownMenuContent align="end">
120
+ {onCopySetupReport && (
121
+ <DropdownMenuItem testID={`printer-row-${id}-copy-report`} onPress={() => onCopySetupReport(printer)}>
122
+ <Text>Copy setup report</Text>
123
+ </DropdownMenuItem>
124
+ )}
125
+ {canSetDefault && (
126
+ <DropdownMenuItem testID={`printer-row-${id}-set-default`} onPress={() => onSetDefault(id)}>
127
+ <Text>Set Default</Text>
128
+ </DropdownMenuItem>
129
+ )}
130
+ {canDelete && (canSetDefault || onCopySetupReport) && <DropdownMenuSeparator />}
131
+ {canDelete && (
132
+ <DropdownMenuItem testID={`printer-row-${id}-delete`} onPress={() => onDelete(printer)}>
133
+ <Text className="text-destructive">Delete</Text>
134
+ </DropdownMenuItem>
135
+ )}
136
+ </DropdownMenuContent>
137
+ </DropdownMenu>
138
+ )}
139
+ </View>
140
+ </View>
141
+ );
142
+ }
143
+
144
+ // v2's AUTO_VALUE: the Select value that means "no override".
145
+ const AUTO = '__auto__';
146
+ const NO_ROUTING: Readonly<Record<string, string>> = {};
147
+ const SECTIONS = [
148
+ { kind: 'receipt', title: 'Receipt Templates' },
149
+ { kind: 'report', title: 'Report templates' },
150
+ { kind: 'closure', title: 'Closure templates' },
151
+ ] as const;
152
+
153
+ interface TemplateRowProps extends Pick<PrintingSettingsProps, 'printers' | 'onRoutingChange'> {
154
+ template: RoutedTemplate;
155
+ overrideId: string | undefined;
156
+ }
157
+
158
+ function TemplateRow({ template, printers, overrideId, onRoutingChange }: TemplateRowProps): JSX.Element {
159
+ const { id, title, engine, paper } = template;
160
+ const autoLabel = `Auto — ${resolvePrinter({ template, profiles: printers })?.name ?? 'Print Dialog'}`;
161
+ const override = overrideId ? printers.find((printer) => printer.id === overrideId) : undefined;
162
+ const missing = overrideId !== undefined && !override;
163
+ const selected = override
164
+ ? { value: override.id, label: override.name }
165
+ : missing ? { value: overrideId, label: 'Unavailable printer' } : { value: AUTO, label: autoLabel };
166
+ // v2 shows a bare "Thermal"; an unset paper is 80mm because resolvePrinter/templateColumns and renderReceiptHtml treat it so.
167
+ const typeLabel = engine === 'thermal' ? `Thermal ${paper ?? '80mm'}` : 'HTML';
168
+ return (
169
+ <View testID={`template-row-${id}`} className="gap-3 px-4 py-3 sm:flex-row sm:items-center">
170
+ <View className="flex-1 flex-row items-center gap-2">
171
+ <Text className="text-sm font-medium text-foreground">{title}</Text>
172
+ <Text testID={`template-row-${id}-type`} className="rounded border border-border px-1.5 text-xs text-muted-foreground">
173
+ {typeLabel}
174
+ </Text>
175
+ </View>
176
+ <Select value={selected}
177
+ onValueChange={(option) => { if (option) onRoutingChange?.(id, option.value === AUTO ? null : option.value); }}>
178
+ <SelectTrigger testID={`template-row-${id}-printer-select`} accessibilityLabel={`Printer for ${title}`} className="h-9 w-64">
179
+ <SelectValue placeholder={autoLabel} className="shrink text-sm text-foreground" numberOfLines={1} />
180
+ </SelectTrigger>
181
+ <SelectContent className="w-64">
182
+ <SelectItem value={AUTO} label={autoLabel}><Text className="text-sm">{autoLabel}</Text></SelectItem>
183
+ {missing && (
184
+ <SelectItem value={overrideId} label="Unavailable printer"><Text className="text-sm">Unavailable printer</Text></SelectItem>
185
+ )}
186
+ {printers.map((printer) => (
187
+ <SelectItem key={printer.id} value={printer.id} label={printer.name}><Text className="text-sm">{printer.name}</Text></SelectItem>
188
+ ))}
189
+ </SelectContent>
190
+ </Select>
191
+ </View>
192
+ );
193
+ }
194
+
195
+ export function PrintingSettings({
196
+ printers, loading = false, testingIds = NO_TESTS, onTest, onEdit, onSetDefault, onDelete, onAdd,
197
+ templates, routing = NO_ROUTING, onRoutingChange, onCopySetupReport, onOpenHelp, className,
198
+ }: PrintingSettingsProps): JSX.Element {
199
+ // The dialog is open while `pending` is set; `target` outlives it so the title keeps the name while it closes.
200
+ const [pending, setPending] = useState<PrinterProfile>();
201
+ const [target, setTarget] = useState<PrinterProfile>();
202
+ const hasHardware = printers.some((printer) => !isPrintDialog(printer));
203
+ const askDelete = (printer: PrinterProfile) => {
204
+ setTarget(printer);
205
+ setPending(printer);
206
+ };
207
+
208
+ return (
209
+ <View className={cn('gap-6', className)}>
210
+ <SettingsGroup title="Printers" description="Devices receipts can be sent to.">
211
+ {loading ? null : (
212
+ <>
213
+ {hasHardware ? printers.map((printer) => (
214
+ <PrinterRow
215
+ key={printer.id} printer={printer} testing={testingIds.has(printer.id)}
216
+ onTest={onTest} onEdit={onEdit} onSetDefault={onSetDefault} onDelete={askDelete}
217
+ onCopySetupReport={onCopySetupReport}
218
+ />
219
+ )) : (
220
+ <View testID="printers-empty-state" className="gap-1 px-4 py-6">
221
+ <Text className="text-center text-sm font-medium text-foreground">No printers configured</Text>
222
+ <Text className="text-center text-sm text-muted-foreground">
223
+ Add a printer to send receipts straight to your hardware. You can always use the Print Dialog without one.
224
+ </Text>
225
+ </View>
226
+ )}
227
+ <View className="p-4">
228
+ {/* Primary until a hardware printer exists, as in v2. */}
229
+ <Button testID="printing-add-printer-button" variant={hasHardware ? 'outline' : 'default'} size="sm" className="self-start" onPress={onAdd}>
230
+ <Text>Add Printer</Text>
231
+ </Button>
232
+ </View>
233
+ {onOpenHelp ? (
234
+ <View className="px-4 pb-4">
235
+ <Button testID="printing-having-trouble" variant="link" size="sm" role="link" className="h-11 self-start px-0"
236
+ onPress={onOpenHelp}>
237
+ <Text className="text-xs">Having trouble?</Text>
238
+ </Button>
239
+ </View>
240
+ ) : null}
241
+ </>
242
+ )}
243
+ </SettingsGroup>
244
+ {templates && !loading && SECTIONS.map(({ kind, title }) => {
245
+ const rows = templates.filter((template) => template.kind === kind);
246
+ return (
247
+ <SettingsGroup key={kind} title={title} description="Choose which printer each template prints to.">
248
+ {rows.length > 0 ? rows.map((template) => (
249
+ <TemplateRow key={template.id} template={template} printers={printers}
250
+ overrideId={routing[template.id]} onRoutingChange={onRoutingChange} />
251
+ )) : (
252
+ <Text testID={`templates-empty-${kind}`} className="px-4 py-3 text-sm text-muted-foreground">No active templates found.</Text>
253
+ )}
254
+ </SettingsGroup>
255
+ );
256
+ })}
257
+ {/* v2's description, shown only with routing: without `templates` no template is routed to a printer. */}
258
+ <ConfirmDialog
259
+ testID={`printer-row-${target?.id}-delete-dialog`}
260
+ cancelTestID={`printer-row-${target?.id}-delete-cancel`} confirmTestID={`printer-row-${target?.id}-delete-confirm`}
261
+ title={`Delete ${target?.name ?? ''}?`} confirmLabel="Delete"
262
+ description={templates ? 'Receipts routed to it print with Auto instead.' : undefined}
263
+ open={pending !== undefined} onOpenChange={(open) => { if (!open) setPending(undefined); }}
264
+ onConfirm={() => { if (pending) onDelete(pending.id); }}
265
+ />
266
+ </View>
267
+ );
268
+ }
@@ -17,7 +17,8 @@ export function SettingsGroup({ title, description, children, className, ...view
17
17
  <Text className="text-sm font-semibold text-foreground">{title}</Text>
18
18
  {description && <Text className="text-xs text-muted-foreground">{description}</Text>}
19
19
  </View>
20
- <View className="rounded-lg border border-border bg-card">{children}</View>
20
+ {/* A group with nothing in it, such as Printers while loading, shows its header and no empty card, as v2's section does. */}
21
+ {children != null && children !== false && <View className="rounded-lg border border-border bg-card">{children}</View>}
21
22
  </View>
22
23
  );
23
24
  }
@@ -31,7 +31,7 @@ const OPTIONS: { value: TaxBasedOn; label: string }[] = [
31
31
  { value: 'base', label: 'Shop base address' },
32
32
  ];
33
33
 
34
- /** The class name rule of @tallyui/pos `taxDerivation` (re-implemented here: components import only types from pos). */
34
+ /** The class name rule of @tallyui/pos `taxDerivation`, copied: pos keeps it private (`taxClassName` in tax/tax-derivation.ts). */
35
35
  function classLabel(slug: string): string {
36
36
  if (slug === '' || slug === 'standard') return 'Standard';
37
37
  const words = slug.replace(/-/g, ' ');
@@ -0,0 +1,61 @@
1
+ // Port of WCPOS v2's added-to-cart toast (MIT, WCPOS): packages/core/src/screens/main/pos/hooks/added-to-cart-toast.ts,
2
+ // with the top-centre placement of apps/main/app/_layout.tsx:84. It is one toast that updates in place and never
3
+ // stacks: in v2 #2370 a stack of add toasts covered the top product row and took the cashier's taps.
4
+ import { useEffect, useRef, useState } from 'react';
5
+ import { AccessibilityInfo, Platform, View } from 'react-native';
6
+ import { Toast, ToastClose, ToastTitle } from '../ui/toast';
7
+
8
+ // v2's ADDED_TO_CART_DURATION; each add restarts it.
9
+ const VISIBLE_MS = 4_000;
10
+
11
+ export interface AddedToCartEvent {
12
+ /** A new value for each add, e.g. a counter; the same key twice is one add. */
13
+ key: number | string;
14
+ /** The product's name; the first add names it. */
15
+ name?: string;
16
+ }
17
+
18
+ export interface AddedToCartToastProps {
19
+ /** The latest add, or null before any. The app sets it where it adds a line, unless the add is silent. */
20
+ added: AddedToCartEvent | null;
21
+ testID?: string;
22
+ }
23
+
24
+ export function AddedToCartToast({ added, testID = 'added-to-cart-toast' }: AddedToCartToastProps) {
25
+ const lastKey = useRef(added?.key);
26
+ const [toast, setToast] = useState<{ shown: boolean; count: number; name?: string }>({ shown: false, count: 0 });
27
+
28
+ useEffect(() => {
29
+ if (added == null || added.key === lastKey.current) return;
30
+ lastKey.current = added.key;
31
+ setToast((prev) => ({ shown: true, count: prev.count + 1, name: prev.count === 0 ? added.name : prev.name }));
32
+ }, [added]);
33
+
34
+ useEffect(() => {
35
+ if (!toast.shown) return;
36
+ const timer = setTimeout(() => setToast({ shown: false, count: 0 }), VISIBLE_MS);
37
+ return () => clearTimeout(timer);
38
+ }, [toast]);
39
+
40
+ // The count line only shows from 2, so a single add never reads "1 item".
41
+ const title = !toast.shown ? null
42
+ : toast.count > 1 ? `${toast.count} items added to cart`
43
+ : toast.name ? `${toast.name} added to cart` : 'Added to cart';
44
+
45
+ useEffect(() => {
46
+ if (title !== null && Platform.OS === 'ios') AccessibilityInfo.announceForAccessibility(title);
47
+ }, [title]);
48
+
49
+ if (title === null) return null;
50
+ return (
51
+ <View pointerEvents="box-none" className="absolute inset-x-0 top-4 z-50 items-center px-4">
52
+ <Toast testID={testID} accessibilityLiveRegion="polite" className="max-w-sm border-success">
53
+ <View aria-hidden className="absolute inset-0 bg-success/15" />
54
+ <View className="flex-1 gap-1">
55
+ <ToastTitle>{title}</ToastTitle>
56
+ </View>
57
+ <ToastClose accessibilityLabel="Close" onPress={() => setToast({ shown: false, count: 0 })} />
58
+ </Toast>
59
+ </View>
60
+ );
61
+ }
@@ -23,6 +23,8 @@ export interface AppShellProps {
23
23
  onNavigate: (id: string) => void;
24
24
  /** Drawn above the page (a `RegisterBar`); its menu button opens the drawer on phones. */
25
25
  registerBar?: React.ReactNode;
26
+ /** Drawn at the foot of the rail on wide windows and of the drawer on phones (a version line). */
27
+ navFooter?: React.ReactNode;
26
28
  children?: React.ReactNode;
27
29
  className?: string;
28
30
  testID?: string;
@@ -34,6 +36,7 @@ export function AppShell({
34
36
  activeId,
35
37
  onNavigate,
36
38
  registerBar,
39
+ navFooter,
37
40
  children,
38
41
  className,
39
42
  testID = 'app-shell',
@@ -54,7 +57,7 @@ export function AppShell({
54
57
  return (
55
58
  <ShellContext.Provider value={shell}>
56
59
  <View testID={testID} className={cn('flex-1 bg-background', !phone && 'flex-row', className)}>
57
- {!phone && <NavRail items={navItems} activeId={activeId} onNavigate={onNavigate} />}
60
+ {!phone && <NavRail items={navItems} activeId={activeId} onNavigate={onNavigate} footer={navFooter} />}
58
61
  {page}
59
62
  {phone && (
60
63
  <NavDrawer
@@ -63,6 +66,7 @@ export function AppShell({
63
66
  items={navItems}
64
67
  activeId={activeId}
65
68
  onNavigate={onNavigate}
69
+ footer={navFooter}
66
70
  />
67
71
  )}
68
72
  </View>
@@ -0,0 +1,70 @@
1
+ // Port of WCPOS v2's OnlineStatusLogger and its toast (MIT, WCPOS): the settle rule and the three titles from
2
+ // packages/core/src/screens/main/components/online-status/online-status-logger.tsx, the description kept from the
3
+ // code's action hint as in packages/core/src/contexts/merchant-toast.ts, the text of SYNC121's actionHint in
4
+ // packages/utils/src/logger/error-registry.json, and the top-centre placement of apps/main/app/_layout.tsx:84.
5
+ import { useEffect, useRef, useState } from 'react';
6
+ import { AccessibilityInfo, Platform, View } from 'react-native';
7
+ import type { ConnectivityState } from '@tallyui/core';
8
+ import { cn } from '@tallyui/theme';
9
+ import { Toast, ToastClose, ToastDescription, ToastTitle } from '../ui/toast';
10
+
11
+ // v2's CONNECTIVITY_SETTLE_MS: a verdict that reverts inside it is a flap, not an outage.
12
+ const SETTLE_MS = 5_000;
13
+ // How long the toast stays; TallyUI's choice, v2's Toaster passes no duration of its own.
14
+ const VISIBLE_MS = 4_000;
15
+ // v2 SYNC121's action hint, shown under both warnings.
16
+ const DESCRIPTION = 'Nothing to do — keep selling. Changes send automatically when the connection returns.';
17
+
18
+ const TEXT: Record<ConnectivityState, { title: string; description?: string; warning: boolean }> = {
19
+ offline: { title: 'Device went offline', description: DESCRIPTION, warning: true },
20
+ degraded: { title: 'Website is unreachable', description: DESCRIPTION, warning: true },
21
+ online: { title: 'Connection restored', warning: false },
22
+ };
23
+
24
+ export interface ConnectivityToastProps {
25
+ /** The till's connectivity verdict, e.g. a `@tallyui/database` connectivity tracker's `state`. */
26
+ state: ConnectivityState;
27
+ testID?: string;
28
+ }
29
+
30
+ export function ConnectivityToast({ state, testID = 'connectivity-toast' }: ConnectivityToastProps) {
31
+ const previous = useRef(state);
32
+ const lastShown = useRef(state);
33
+ const [shown, setShown] = useState<ConnectivityState | null>(null);
34
+
35
+ useEffect(() => {
36
+ if (state === previous.current) return;
37
+ previous.current = state;
38
+ const timer = setTimeout(() => {
39
+ if (state === lastShown.current) return;
40
+ lastShown.current = state;
41
+ setShown(state);
42
+ }, SETTLE_MS);
43
+ return () => clearTimeout(timer);
44
+ }, [state]);
45
+
46
+ useEffect(() => {
47
+ if (shown === null) return;
48
+ if (Platform.OS === 'ios') {
49
+ const { title, description } = TEXT[shown];
50
+ AccessibilityInfo.announceForAccessibility(description ? `${title} ${description}` : title);
51
+ }
52
+ const timer = setTimeout(() => setShown(null), VISIBLE_MS);
53
+ return () => clearTimeout(timer);
54
+ }, [shown]);
55
+
56
+ if (shown === null) return null;
57
+ const { title, description, warning } = TEXT[shown];
58
+ return (
59
+ <View pointerEvents="box-none" className="absolute inset-x-0 top-4 z-50 items-center px-4">
60
+ <Toast testID={testID} accessibilityLiveRegion="polite" className={cn('max-w-sm', warning ? 'border-warning' : 'border-success')}>
61
+ <View aria-hidden className={cn('absolute inset-0', warning ? 'bg-warning/15' : 'bg-success/15')} />
62
+ <View className="flex-1 gap-1">
63
+ <ToastTitle>{title}</ToastTitle>
64
+ {description ? <ToastDescription>{description}</ToastDescription> : null}
65
+ </View>
66
+ <ToastClose accessibilityLabel="Close" onPress={() => setShown(null)} />
67
+ </Toast>
68
+ </View>
69
+ );
70
+ }
@@ -2,3 +2,5 @@ export { AppShell, type AppShellProps } from './app-shell';
2
2
  export { NavRail, type NavRailProps } from './nav-rail';
3
3
  export { NavDrawer, type NavDrawerProps } from './nav-drawer';
4
4
  export type { ShellNavItem } from './nav-item';
5
+ export { ConnectivityToast, type ConnectivityToastProps } from './connectivity-toast';
6
+ export { AddedToCartToast, type AddedToCartToastProps, type AddedToCartEvent } from './added-to-cart-toast';
@@ -17,6 +17,8 @@ export interface NavDrawerProps {
17
17
  onNavigate: (id: string) => void;
18
18
  /** Drawn above the items (a store name or logo). */
19
19
  header?: React.ReactNode;
20
+ /** Drawn at the foot of the panel, under the items (a version line). */
21
+ footer?: React.ReactNode;
20
22
  testID?: string;
21
23
  }
22
24
 
@@ -61,7 +63,7 @@ function useFocusTrap(panel: React.RefObject<View | null>, active: boolean, onEs
61
63
  * The phone's navigation: a 200-wide panel that slides over the screen from the left, v2's
62
64
  * `drawerType: 'front'`, with a backdrop that closes it. Pressing the current page only closes it.
63
65
  */
64
- export function NavDrawer({ open, onOpenChange, items, activeId, onNavigate, header, testID = 'nav-drawer' }: NavDrawerProps) {
66
+ export function NavDrawer({ open, onOpenChange, items, activeId, onNavigate, header, footer, testID = 'nav-drawer' }: NavDrawerProps) {
65
67
  const [mounted, setMounted] = React.useState(open);
66
68
  const offset = React.useRef(new Animated.Value(open ? 0 : -DRAWER_WIDTH)).current;
67
69
  const panel = React.useRef<View>(null);
@@ -116,7 +118,7 @@ export function NavDrawer({ open, onOpenChange, items, activeId, onNavigate, hea
116
118
  aria-modal
117
119
  aria-label="Menu"
118
120
  testID={`${testID}-panel`}
119
- className="absolute bottom-0 left-0 top-0 border-r border-border bg-card shadow-lg"
121
+ className="absolute bottom-0 left-0 top-0 border-r border-sidebar-border bg-sidebar shadow-lg"
120
122
  style={{ width: DRAWER_WIDTH, transform: [{ translateX: offset }] }}
121
123
  >
122
124
  {header}
@@ -124,6 +126,7 @@ export function NavDrawer({ open, onOpenChange, items, activeId, onNavigate, hea
124
126
  <View>{top.map(renderItem)}</View>
125
127
  {bottom.length > 0 && <View className="mt-auto">{bottom.map(renderItem)}</View>}
126
128
  </View>
129
+ {footer != null && <View testID={`${testID}-footer`}>{footer}</View>}
127
130
  </Animated.View>
128
131
  </View>
129
132
  );
@@ -27,12 +27,15 @@ type NavButtonProps = Omit<PressableProps, 'children'> & {
27
27
  labelled?: boolean;
28
28
  };
29
29
 
30
- /** One nav entry: `h-12 rounded-lg` as v2's drawer size, lifted onto the primary tint when active. */
30
+ /**
31
+ * One nav entry: `h-12 rounded-lg` as v2's drawer size. On the sidebar wash the active square lifts
32
+ * to `rail-selected` with the selected ink.
33
+ */
31
34
  export const NavButton = React.forwardRef<View, NavButtonProps>(function NavButton(
32
35
  { item, active, labelled = false, className, ...props },
33
36
  ref,
34
37
  ) {
35
- const tint = active ? 'text-primary' : 'text-muted-foreground';
38
+ const tint = active ? 'text-rail-selected-foreground' : 'text-sidebar-foreground';
36
39
  return (
37
40
  <Pressable
38
41
  ref={ref}
@@ -43,7 +46,7 @@ export const NavButton = React.forwardRef<View, NavButtonProps>(function NavButt
43
46
  className={cn(
44
47
  'h-12 flex-row items-center rounded-lg web:transition-colors',
45
48
  labelled ? 'gap-3 px-3' : 'w-12 justify-center',
46
- active ? 'bg-primary/10' : 'web:hover:bg-accent active:bg-accent',
49
+ active ? 'bg-rail-selected' : 'web:hover:bg-rail-accent active:bg-rail-accent',
47
50
  'web:focus-visible:outline-none web:focus-visible:ring-2 web:focus-visible:ring-ring',
48
51
  typeof className === 'string' ? className : undefined,
49
52
  )}
@@ -61,7 +64,7 @@ export const NavButton = React.forwardRef<View, NavButtonProps>(function NavButt
61
64
  )}
62
65
  </View>
63
66
  {labelled && (
64
- <Text className={cn('flex-1 text-base', active ? 'font-semibold text-primary' : 'text-foreground')} numberOfLines={1}>
67
+ <Text className={cn('flex-1 text-base', active ? 'text-rail-selected-foreground' : 'text-sidebar-foreground')} numberOfLines={1}>
65
68
  {item.label}
66
69
  </Text>
67
70
  )}
@@ -10,6 +10,8 @@ export interface NavRailProps {
10
10
  items: ShellNavItem[];
11
11
  activeId?: string;
12
12
  onNavigate: (id: string) => void;
13
+ /** Drawn at the foot of the rail, under the bottom items (a version line). */
14
+ footer?: React.ReactNode;
13
15
  className?: string;
14
16
  testID?: string;
15
17
  }
@@ -19,7 +21,7 @@ export interface NavRailProps {
19
21
  * plus 2 units each side (64 at Regular), so it follows the scale step as v2's does. Icon-only:
20
22
  * the label shows to the right on hover or keyboard focus, v2's web tooltip.
21
23
  */
22
- export function NavRail({ items, activeId, onNavigate, className, testID = 'nav-rail' }: NavRailProps) {
24
+ export function NavRail({ items, activeId, onNavigate, footer, className, testID = 'nav-rail' }: NavRailProps) {
23
25
  const [hinted, setHinted] = React.useState<string | null>(null);
24
26
  const renderItem = (item: ShellNavItem) => (
25
27
  <View key={item.id} className="relative z-10">
@@ -49,10 +51,15 @@ export function NavRail({ items, activeId, onNavigate, className, testID = 'nav-
49
51
  role="navigation"
50
52
  aria-label="Main"
51
53
  testID={testID}
52
- className={cn('z-10 w-16 items-center border-r border-border bg-card py-2', className)}
54
+ className={cn('z-10 w-16 items-center border-r border-sidebar-border bg-sidebar py-2', className)}
53
55
  >
54
56
  <View className="gap-2">{top.map(renderItem)}</View>
55
57
  {bottom.length > 0 && <View className="mt-auto gap-2">{bottom.map(renderItem)}</View>}
58
+ {footer != null && (
59
+ <View testID={`${testID}-footer`} className={cn('items-center', bottom.length > 0 ? 'mt-2' : 'mt-auto')}>
60
+ {footer}
61
+ </View>
62
+ )}
56
63
  </View>
57
64
  );
58
65
  }