@tallyui/components 3.20.0 → 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
@@ -1,7 +1,14 @@
1
1
  import * as React from 'react';
2
- import { View } from 'react-native';
2
+ import { Animated, Platform, View } from 'react-native';
3
3
  import { Accordion as AccordionPrimitive, TextClassContext } from '@tallyui/primitives';
4
4
  import { cn } from '@tallyui/theme';
5
+ import { ChevronDownIcon } from '../icon/chevron-down-icon';
6
+ import { CROSSFADE, EASE, TIMING_EASE } from '../../lib/motion';
7
+ import { useReducedMotion } from '../../lib/use-reduced-motion';
8
+
9
+ // WCPOS v2 packages/components/src/accordion/index.tsx:65: the chevron turns over 250ms opening, 200ms closing.
10
+ const TURN_OPEN_MS = 250;
11
+ const TURN_CLOSE_MS = 200;
5
12
 
6
13
  const Accordion = AccordionPrimitive.Root;
7
14
 
@@ -15,12 +22,46 @@ const AccordionItem = React.forwardRef<
15
22
  });
16
23
  AccordionItem.displayName = 'AccordionItem';
17
24
 
25
+ /** v2's down chevron, turned 180deg (and dimmed to 0.8) while its item is open. */
26
+ function AccordionChevron() {
27
+ const { isExpanded } = AccordionPrimitive.useItemContext();
28
+ const reduced = useReducedMotion();
29
+ const turn = React.useRef(new Animated.Value(isExpanded ? 1 : 0)).current;
30
+ const shown = React.useRef(isExpanded);
31
+ React.useEffect(() => {
32
+ if (shown.current === isExpanded) return;
33
+ shown.current = isExpanded;
34
+ turn.stopAnimation();
35
+ if (reduced !== false) return turn.setValue(isExpanded ? 1 : 0);
36
+ Animated.timing(turn, { toValue: isExpanded ? 1 : 0, duration: isExpanded ? TURN_OPEN_MS : TURN_CLOSE_MS,
37
+ easing: TIMING_EASE, useNativeDriver: Platform.OS !== 'web' }).start();
38
+ }, [isExpanded, reduced, turn]);
39
+ React.useEffect(() => () => turn.stopAnimation(), [turn]);
40
+ const rotate = turn.interpolate({ inputRange: [0, 1], outputRange: ['0deg', '180deg'] });
41
+ const opacity = turn.interpolate({ inputRange: [0, 1], outputRange: [1, 0.8] });
42
+ return (
43
+ <Animated.View aria-hidden className="shrink-0 text-foreground" style={{ opacity, transform: [{ rotate }] }}>
44
+ <ChevronDownIcon size={18} strokeWidth={1.5} />
45
+ </Animated.View>
46
+ );
47
+ }
48
+
49
+ type AccordionTriggerProps = React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Trigger> & {
50
+ /** Which side of the label the chevron sits on, as in v2; defaults to the right. */
51
+ chevronPosition?: 'left' | 'right';
52
+ /** Classes for the outer AccordionPrimitive.Header wrapper, merged after `flex` (useful for flex sizing). */
53
+ headerClassName?: string;
54
+ };
55
+
18
56
  const AccordionTrigger = React.forwardRef<
19
57
  React.ComponentRef<typeof AccordionPrimitive.Trigger>,
20
- React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Trigger>
21
- >(function AccordionTrigger({ className, children, ...props }, ref) {
58
+ AccordionTriggerProps
59
+ >(function AccordionTrigger({ className, children, chevronPosition = 'right', headerClassName, ...props }, ref) {
60
+ // Under asChild the one slotted child draws its own content, as in SelectTrigger.
61
+ const draw = (label: React.ReactNode) =>
62
+ <>{chevronPosition === 'left' && <AccordionChevron />}{label}{chevronPosition === 'right' && <AccordionChevron />}</>;
22
63
  return (
23
- <AccordionPrimitive.Header className="flex">
64
+ <AccordionPrimitive.Header className={cn('flex', headerClassName)}>
24
65
  <TextClassContext.Provider value="text-sm font-medium">
25
66
  <AccordionPrimitive.Trigger
26
67
  ref={ref}
@@ -30,7 +71,7 @@ const AccordionTrigger = React.forwardRef<
30
71
  )}
31
72
  {...props}
32
73
  >
33
- {children}
74
+ {props.asChild ? children : typeof children === 'function' ? (state) => draw(children(state)) : draw(children)}
34
75
  </AccordionPrimitive.Trigger>
35
76
  </TextClassContext.Provider>
36
77
  </AccordionPrimitive.Header>
@@ -38,18 +79,55 @@ const AccordionTrigger = React.forwardRef<
38
79
  });
39
80
  AccordionTrigger.displayName = 'AccordionTrigger';
40
81
 
82
+ type Fold = 'idle' | 'opening' | 'closing';
83
+
41
84
  const AccordionContent = React.forwardRef<
42
85
  React.ComponentRef<typeof AccordionPrimitive.Content>,
43
86
  React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Content>
44
- >(function AccordionContent({ className, children, ...props }, ref) {
87
+ >(function AccordionContent({ className, children, forceMount, ...props }, ref) {
88
+ const { isExpanded } = AccordionPrimitive.useItemContext();
89
+ const still = useReducedMotion() !== false;
90
+ const height = React.useRef(new Animated.Value(0)).current;
91
+ const measured = React.useRef(0);
92
+ const waiting = React.useRef(false);
93
+ // Only a change of isExpanded after mount folds; `from` is the phase that change interrupted.
94
+ const [fold, setFold] = React.useState<{ open: boolean; phase: Fold; from: Fold }>(
95
+ { open: isExpanded, phase: 'idle', from: 'idle' });
96
+ if (fold.open !== isExpanded) {
97
+ const phase = forceMount || still ? 'idle' : isExpanded ? 'opening' : 'closing';
98
+ setFold({ open: isExpanded, phase, from: fold.phase });
99
+ }
100
+ const run = React.useCallback((toValue: number) => {
101
+ Animated.timing(height, { toValue, duration: CROSSFADE, easing: EASE, useNativeDriver: false })
102
+ .start(({ finished }) => finished && setFold((f) => ({ ...f, phase: 'idle' })));
103
+ }, [height]);
104
+ React.useLayoutEffect(() => {
105
+ if (fold.phase === 'idle') return;
106
+ height.stopAnimation();
107
+ waiting.current = false;
108
+ if (fold.phase === 'opening') {
109
+ // Reopened mid-close: still mounted and measured. Otherwise wait for the fresh content's layout.
110
+ if (fold.from === 'closing') run(measured.current);
111
+ else { height.setValue(0); waiting.current = true; }
112
+ } else if (measured.current <= 0) setFold((f) => ({ ...f, phase: 'idle' }));
113
+ else { if (fold.from === 'idle') height.setValue(measured.current); run(0); }
114
+ }, [fold, height, run]);
115
+ React.useEffect(() => () => height.stopAnimation(), [height]);
116
+ const onLayout = (h: number) => {
117
+ measured.current = h;
118
+ if (waiting.current) { waiting.current = false; if (h > 0) run(h); else setFold((f) => ({ ...f, phase: 'idle' })); }
119
+ };
45
120
  return (
46
121
  <TextClassContext.Provider value="text-sm">
47
122
  <AccordionPrimitive.Content
48
123
  ref={ref}
49
- className={cn('overflow-hidden text-sm web:transition-all', className)}
124
+ className="overflow-hidden text-sm web:transition-all"
125
+ forceMount={forceMount || fold.phase === 'closing' ? true : undefined}
50
126
  {...props}
51
127
  >
52
- <View className="pb-4 pt-0">{children}</View>
128
+ <Animated.View style={fold.phase === 'idle' ? undefined : { height, overflow: 'hidden' }}>
129
+ <View className={cn('pb-4 pt-0', className)} onLayout={(e) => onLayout(e.nativeEvent.layout.height)}>{children}</View>
130
+ </Animated.View>
53
131
  </AccordionPrimitive.Content>
54
132
  </TextClassContext.Provider>
55
133
  );
@@ -1,7 +1,8 @@
1
1
  import * as React from 'react';
2
- import { View } from 'react-native';
2
+ import { View, Animated, Platform } from 'react-native';
3
3
  import { AlertDialog as AlertDialogPrimitive, TextClassContext } from '@tallyui/primitives';
4
4
  import { cn } from '@tallyui/theme';
5
+ import { useOverlayMotion, DIALOG_MOTION } from '../dialog/motion';
5
6
 
6
7
  const AlertDialog = AlertDialogPrimitive.Root;
7
8
  const AlertDialogTrigger = AlertDialogPrimitive.Trigger;
@@ -25,18 +26,31 @@ const AlertDialogContent = React.forwardRef<
25
26
  React.ComponentRef<typeof AlertDialogPrimitive.Content>,
26
27
  React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Content>
27
28
  >(function AlertDialogContent({ className, children, ...props }, ref) {
29
+ const { open } = AlertDialogPrimitive.useRootContext();
30
+ const { mounted, scrim, panel } = useOverlayMotion(open, true, DIALOG_MOTION);
31
+ if (!mounted) return null;
32
+ const { style, ...propsWithoutStyle } = props;
33
+ // WCPOS v2 dialog-in / dialog-out.
28
34
  return (
29
- <AlertDialogPortal>
30
- <AlertDialogOverlay />
35
+ <AlertDialogPortal forceMount>
36
+ <Animated.View className="fixed inset-0 z-50" style={{ opacity: scrim }} pointerEvents={open ? 'auto' : 'none'}>
37
+ <AlertDialogOverlay forceMount className="absolute inset-0" />
38
+ </Animated.View>
31
39
  <AlertDialogPrimitive.Content
40
+ forceMount asChild
32
41
  ref={ref}
33
42
  className={cn(
34
43
  'fixed left-1/2 top-1/2 z-50 w-full max-w-lg -translate-x-1/2 -translate-y-1/2 gap-4 rounded-lg border border-border bg-background p-6 shadow-lg',
35
44
  className,
36
45
  )}
37
- {...props}
46
+ {...propsWithoutStyle}
38
47
  >
39
- {children}
48
+ <Animated.View
49
+ style={[style, { opacity: panel, transform: Platform.OS === 'web' ? [{ scale: panel.interpolate({ inputRange: [0, 1], outputRange: [0.95, 1] }) }] : undefined }]}
50
+ pointerEvents={open ? 'auto' : 'none'}
51
+ >
52
+ {children}
53
+ </Animated.View>
40
54
  </AlertDialogPrimitive.Content>
41
55
  </AlertDialogPortal>
42
56
  );
@@ -51,7 +51,9 @@ const ComboboxContent = React.forwardRef<
51
51
  <ComboboxPrimitive.Content
52
52
  ref={ref}
53
53
  className={cn(
54
- 'z-50 min-w-[8rem] overflow-hidden rounded-md border border-border bg-popover p-1 text-popover-foreground shadow-md',
54
+ // v2's list size (monorepo combobox.tsx `max-h-75 w-80`): 20rem wide, 18.75rem tall at
55
+ // most. The primitive's inline minWidth (the trigger's width) still wins over `w-80`.
56
+ 'z-50 max-h-75 w-80 overflow-hidden rounded-md border border-border bg-popover p-1 text-popover-foreground shadow-md',
55
57
  className,
56
58
  )}
57
59
  {...props}
@@ -64,6 +66,23 @@ const ComboboxContent = React.forwardRef<
64
66
  });
65
67
  ComboboxContent.displayName = 'ComboboxContent';
66
68
 
69
+ // v2's list (monorepo combobox.tsx ComboboxList): the part of Content that scrolls past the cap,
70
+ // so an Input placed above it in Content stays put. Not v2's flex-1 with basis 0: under a
71
+ // max-height alone that collapses a short list to 0 (Chromium, react-native-web). Grow 0,
72
+ // shrink 1 keeps a short list at its natural height and shrinks a long one to fit the cap.
73
+ const ComboboxList = React.forwardRef<
74
+ ScrollView,
75
+ React.ComponentPropsWithoutRef<typeof ScrollView>
76
+ >(function ComboboxList({ className, style, ...props }, ref) {
77
+ return (
78
+ // "handled": the first tap on an item, with the Input's keyboard up on native, selects it
79
+ // instead of only closing the keyboard.
80
+ <ScrollView ref={ref} keyboardShouldPersistTaps="handled" className={cn(className)}
81
+ style={[{ flexGrow: 0, flexShrink: 1 }, style]} {...props} />
82
+ );
83
+ });
84
+ ComboboxList.displayName = 'ComboboxList';
85
+
67
86
  const ComboboxItem = React.forwardRef<
68
87
  React.ComponentRef<typeof ComboboxPrimitive.Item>,
69
88
  React.ComponentPropsWithoutRef<typeof ComboboxPrimitive.Item>
@@ -94,5 +113,5 @@ const ComboboxEmpty = React.forwardRef<
94
113
  ComboboxEmpty.displayName = 'ComboboxEmpty';
95
114
 
96
115
  export {
97
- Combobox, ComboboxTrigger, ComboboxInput, ComboboxContent, ComboboxItem, ComboboxEmpty,
116
+ Combobox, ComboboxTrigger, ComboboxInput, ComboboxContent, ComboboxList, ComboboxItem, ComboboxEmpty,
98
117
  };
@@ -0,0 +1,53 @@
1
+ import type * as React from 'react';
2
+ import {
3
+ AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter,
4
+ AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger,
5
+ } from '../alert-dialog';
6
+ import { Button } from '../button';
7
+ import { Text } from '../text';
8
+
9
+ export interface ConfirmDialogProps {
10
+ title: string;
11
+ description?: string;
12
+ /** Default "Cancel". */
13
+ cancelLabel?: string;
14
+ confirmLabel: string;
15
+ /** Default 'destructive'. */
16
+ tone?: 'destructive' | 'default';
17
+ /** Called on the confirm button; the dialog then closes. */
18
+ onConfirm: () => void;
19
+ /** Cancel is `${testID}-cancel` and confirm `${testID}-confirm` unless `cancelTestID` / `confirmTestID` say otherwise. */
20
+ testID: string;
21
+ cancelTestID?: string;
22
+ confirmTestID?: string;
23
+ /** The element that opens the dialog, rendered with `AlertDialogTrigger asChild`. Leave it out when the caller controls `open`. */
24
+ trigger?: React.ReactElement;
25
+ open?: boolean;
26
+ onOpenChange?: (open: boolean) => void;
27
+ }
28
+
29
+ /** Inventory C9: the one confirm dialog in TallyUI. */
30
+ export function ConfirmDialog({
31
+ title, description, cancelLabel, confirmLabel, tone, onConfirm, testID, cancelTestID, confirmTestID,
32
+ trigger, open, onOpenChange,
33
+ }: ConfirmDialogProps): React.JSX.Element {
34
+ return (
35
+ <AlertDialog open={open} onOpenChange={onOpenChange}>
36
+ {trigger && <AlertDialogTrigger asChild>{trigger}</AlertDialogTrigger>}
37
+ <AlertDialogContent testID={testID}>
38
+ <AlertDialogHeader>
39
+ <AlertDialogTitle>{title}</AlertDialogTitle>
40
+ {description && <AlertDialogDescription>{description}</AlertDialogDescription>}
41
+ </AlertDialogHeader>
42
+ <AlertDialogFooter>
43
+ <AlertDialogCancel asChild>
44
+ <Button testID={cancelTestID ?? `${testID}-cancel`} variant="outline" className="min-h-11"><Text>{cancelLabel ?? 'Cancel'}</Text></Button>
45
+ </AlertDialogCancel>
46
+ <AlertDialogAction asChild>
47
+ <Button testID={confirmTestID ?? `${testID}-confirm`} variant={tone === 'default' ? 'default' : 'destructive'} className="min-h-11" onPress={onConfirm}><Text>{confirmLabel}</Text></Button>
48
+ </AlertDialogAction>
49
+ </AlertDialogFooter>
50
+ </AlertDialogContent>
51
+ </AlertDialog>
52
+ );
53
+ }
@@ -1,7 +1,10 @@
1
1
  import * as React from 'react';
2
- import { View, Text, Pressable } from 'react-native';
2
+ import { View, Text, Pressable, Animated, Dimensions, Platform } from 'react-native';
3
3
  import { Dialog as DialogPrimitive, TextClassContext } from '@tallyui/primitives';
4
4
  import { cn } from '@tallyui/theme';
5
+ import { useOverlayMotion, SHEET_MOTION, DIALOG_MOTION } from './motion';
6
+ import { IconButton } from '../icon-button';
7
+ import { XIcon } from '../icon/x-icon';
5
8
 
6
9
  const Dialog = DialogPrimitive.Root;
7
10
  const DialogTrigger = DialogPrimitive.Trigger;
@@ -22,25 +25,73 @@ const DialogOverlay = React.forwardRef<
22
25
  });
23
26
  DialogOverlay.displayName = 'DialogOverlay';
24
27
 
25
- /** Where the content sits: centred (the default), or a full-height sheet on the right edge, full width on a phone. */
28
+ /** Where the content sits: centred (the default), or a full-height sheet on the left or right edge, full width on a phone. */
26
29
  const SIDE_CLASS = {
27
30
  center: 'fixed left-1/2 top-1/2 z-50 w-full max-w-lg -translate-x-1/2 -translate-y-1/2 gap-4 rounded-lg border border-border bg-background p-6 shadow-lg',
31
+ left: 'fixed left-0 top-0 bottom-0 z-50 h-full w-full max-w-lg gap-4 rounded-none border-r border-border bg-background p-6 shadow-lg',
28
32
  right: 'fixed right-0 top-0 bottom-0 z-50 h-full w-full max-w-lg gap-4 rounded-none border-l border-border bg-background p-6 shadow-lg',
29
33
  } as const;
30
34
 
31
35
  const DialogContent = React.forwardRef<
32
36
  React.ComponentRef<typeof DialogPrimitive.Content>,
33
- React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content> & { side?: keyof typeof SIDE_CLASS }
34
- >(function DialogContent({ className, children, side = 'center', ...props }, ref) {
37
+ React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content> & {
38
+ side?: keyof typeof SIDE_CLASS;
39
+ /** v2's dialog chrome: a close X in the top-right corner; opt-in so existing dialogs are unchanged (desk ruling 18 Nov). */
40
+ showClose?: boolean;
41
+ /** v2's dialog chrome: the close X's accessible name; opt-in so existing dialogs are unchanged (desk ruling 18 Nov). */
42
+ closeLabel?: string;
43
+ }
44
+ >(function DialogContent({ className, children, side = 'center', showClose = false, closeLabel = 'Close', ...props }, ref) {
45
+ const { open } = DialogPrimitive.useRootContext();
46
+ const { mounted, scrim, panel } = useOverlayMotion(open, true, side === 'center' ? DIALOG_MOTION : SHEET_MOTION);
47
+ const [width, setWidth] = React.useState(() => Dimensions.get('window').width);
48
+ const close = showClose ? (
49
+ <View className="absolute right-1 top-1">
50
+ <DialogClose asChild>
51
+ <IconButton variant="ghost" size="sm" testID={props.testID ? `${props.testID}-close` : 'dialog-close'} accessibilityLabel={closeLabel}><XIcon size={18} /></IconButton>
52
+ </DialogClose>
53
+ </View>
54
+ ) : null;
55
+
56
+ // WCPOS v2 panel-in-left / panel-out-left and panel-in-right / panel-out-right.
57
+ if (side === 'left' || side === 'right') {
58
+ if (!mounted) return null;
59
+ const { style, ...propsWithoutStyle } = props;
60
+ return (
61
+ <DialogPortal forceMount>
62
+ <Animated.View className="fixed inset-0 z-50" style={{ opacity: scrim }} pointerEvents={open ? 'auto' : 'none'}>
63
+ <DialogOverlay forceMount className="absolute inset-0" />
64
+ </Animated.View>
65
+ <DialogPrimitive.Content forceMount asChild ref={ref} className={cn(SIDE_CLASS[side], className)} {...propsWithoutStyle}>
66
+ <Animated.View
67
+ style={[style, { transform: [{ translateX: panel.interpolate({ inputRange: [0, 1], outputRange: side === 'left' ? [-width, 0] : [width, 0] }) }] }]}
68
+ pointerEvents={open ? 'auto' : 'none'}
69
+ onLayout={(e) => { if (e.nativeEvent.layout.width) setWidth(e.nativeEvent.layout.width); }}
70
+ >
71
+ {children}
72
+ {close}
73
+ </Animated.View>
74
+ </DialogPrimitive.Content>
75
+ </DialogPortal>
76
+ );
77
+ }
78
+
79
+ if (!mounted) return null;
80
+ const { style, ...propsWithoutStyle } = props;
81
+ // WCPOS v2 dialog-in / dialog-out.
35
82
  return (
36
- <DialogPortal>
37
- <DialogOverlay />
38
- <DialogPrimitive.Content
39
- ref={ref}
40
- className={cn(SIDE_CLASS[side], className)}
41
- {...props}
42
- >
43
- {children}
83
+ <DialogPortal forceMount>
84
+ <Animated.View className="fixed inset-0 z-50" style={{ opacity: scrim }} pointerEvents={open ? 'auto' : 'none'}>
85
+ <DialogOverlay forceMount className="absolute inset-0" />
86
+ </Animated.View>
87
+ <DialogPrimitive.Content forceMount asChild ref={ref} className={cn(SIDE_CLASS.center, className)} {...propsWithoutStyle}>
88
+ <Animated.View
89
+ style={[style, { opacity: panel, transform: Platform.OS === 'web' ? [{ scale: panel.interpolate({ inputRange: [0, 1], outputRange: [0.95, 1] }) }] : undefined }]}
90
+ pointerEvents={open ? 'auto' : 'none'}
91
+ >
92
+ {children}
93
+ {close}
94
+ </Animated.View>
44
95
  </DialogPrimitive.Content>
45
96
  </DialogPortal>
46
97
  );
@@ -53,9 +104,12 @@ function DialogHeader({ className, ...props }: React.ComponentPropsWithoutRef<ty
53
104
  );
54
105
  }
55
106
 
56
- function DialogFooter({ className, ...props }: React.ComponentPropsWithoutRef<typeof View>) {
107
+ function DialogFooter({ className, bordered = false, ...props }: React.ComponentPropsWithoutRef<typeof View> & {
108
+ /** v2's dialog chrome: a top divider above the actions; opt-in so existing dialogs are unchanged (desk ruling 18 Nov). */
109
+ bordered?: boolean;
110
+ }) {
57
111
  return (
58
- <View className={cn('flex flex-col-reverse sm:flex-row sm:justify-end sm:gap-2', className)} {...props} />
112
+ <View className={cn('flex flex-col-reverse sm:flex-row sm:justify-end sm:gap-2', bordered && 'border-t border-border pt-4', className)} {...props} />
59
113
  );
60
114
  }
61
115
 
@@ -0,0 +1,54 @@
1
+ import { useEffect, useRef, useState } from 'react';
2
+ import { Animated, Platform } from 'react-native';
3
+ import { useReducedMotion } from '../../lib/use-reduced-motion';
4
+ import { EASE, EASE_EXIT, POPOVER_FADE } from '../../lib/motion';
5
+ export { EASE, EASE_EXIT };
6
+ export type OverlayMotion = {
7
+ enterMs: number; exitMs: number; scrimInMs: number; scrimOutMs: number; exitEasing: (value: number) => number;
8
+ };
9
+ // WCPOS v2 apps/main/global.css:174-181.
10
+ export const SHEET_MOTION: OverlayMotion = { enterMs: 250, exitMs: 200, scrimInMs: 150, scrimOutMs: 200, exitEasing: EASE_EXIT };
11
+ // WCPOS v2 apps/main/global.css:174-177.
12
+ export const DIALOG_MOTION: OverlayMotion = { enterMs: 150, exitMs: 150, scrimInMs: 150, scrimOutMs: 200, exitEasing: EASE };
13
+ // WCPOS v2 packages/components/src/lib/overlay/index.tsx:227-231 (anchored).
14
+ export const POPOVER_MOTION: OverlayMotion = { enterMs: POPOVER_FADE, exitMs: POPOVER_FADE, scrimInMs: POPOVER_FADE, scrimOutMs: POPOVER_FADE, exitEasing: EASE };
15
+
16
+ export function useOverlayMotion(open: boolean, enabled: boolean, motion: OverlayMotion): {
17
+ mounted: boolean; scrim: Animated.Value; panel: Animated.Value;
18
+ } {
19
+ const scrim = useRef(new Animated.Value(0)).current;
20
+ const panel = useRef(new Animated.Value(0)).current;
21
+ const [mounted, setMounted] = useState(open);
22
+ const reduced = useReducedMotion();
23
+ if (open && !mounted) setMounted(true);
24
+
25
+ useEffect(() => {
26
+ if (!enabled || reduced === null) return;
27
+ if (reduced) {
28
+ scrim.setValue(open ? 1 : 0);
29
+ panel.setValue(open ? 1 : 0);
30
+ return;
31
+ }
32
+ if (!mounted) return;
33
+ const animation = Animated.parallel([
34
+ Animated.timing(scrim, {
35
+ toValue: open ? 1 : 0,
36
+ duration: open ? motion.scrimInMs : motion.scrimOutMs,
37
+ easing: EASE,
38
+ useNativeDriver: Platform.OS !== 'web',
39
+ }),
40
+ Animated.timing(panel, {
41
+ toValue: open ? 1 : 0,
42
+ duration: open ? motion.enterMs : motion.exitMs,
43
+ easing: open ? EASE : motion.exitEasing,
44
+ useNativeDriver: Platform.OS !== 'web',
45
+ }),
46
+ ]);
47
+ animation.start(({ finished }) => {
48
+ if (finished && !open) setMounted(false);
49
+ });
50
+ return () => animation.stop();
51
+ }, [open, mounted, reduced, enabled, scrim, panel, motion]);
52
+
53
+ return { mounted: enabled && reduced === false ? mounted || open : open, scrim, panel };
54
+ }
@@ -0,0 +1,7 @@
1
+ import { Path } from 'react-native-svg';
2
+ import { createSvgIcon } from './svg-icon';
3
+
4
+ // Tabler activity-heartbeat (MIT), tabler-icons 1.2.42 via Iconify; WCPOS v2's `health` nav icon.
5
+ export const ActivityHeartbeatIcon = createSvgIcon('ActivityHeartbeatIcon', () => (
6
+ <Path d="M3 12h4.5L9 6l4 12l2-9l1.5 3H21" />
7
+ ));
@@ -0,0 +1,5 @@
1
+ import { Path } from 'react-native-svg';
2
+ import { createSvgIcon } from './svg-icon';
3
+
4
+ // Tabler alert-circle (MIT), as WCPOS v2's tabler `alert` glyph.
5
+ export const AlertCircleIcon = createSvgIcon('AlertCircleIcon', () => <Path d="M3 12a9 9 0 1 0 18 0 9 9 0 0 0-18 0m9-4v4m0 4h.01" />);
@@ -0,0 +1,7 @@
1
+ import { Path } from 'react-native-svg';
2
+ import { createSvgIcon } from './svg-icon';
3
+
4
+ // Tabler alert-triangle (MIT), as WCPOS v2's tabler `warning` glyph.
5
+ export const AlertTriangleIcon = createSvgIcon('AlertTriangleIcon', () => (
6
+ <Path d="M12 9v4m-1.637-9.409L2.257 17.125a1.914 1.914 0 0 0 1.636 2.871h16.214a1.914 1.914 0 0 0 1.636-2.87L13.637 3.59a1.914 1.914 0 0 0-3.274 0M12 16h.01" />
7
+ ));
@@ -0,0 +1,11 @@
1
+ import { Circle, Path, Rect } from 'react-native-svg';
2
+ import { createSvgIcon } from './svg-icon';
3
+
4
+ // Lucide's banknote icon (ISC licence).
5
+ export const BanknoteIcon = createSvgIcon('BanknoteIcon', () => (
6
+ <>
7
+ <Rect x={2} y={6} width={20} height={12} rx={2} />
8
+ <Circle cx={12} cy={12} r={2} />
9
+ <Path d="M6 12h.01M18 12h.01" />
10
+ </>
11
+ ));
@@ -0,0 +1,10 @@
1
+ import { Path } from 'react-native-svg';
2
+ import { createSvgIcon } from './svg-icon';
3
+
4
+ // Tabler cash-register (MIT), tabler-icons 1.2.42 via Iconify; WCPOS v2's `register` nav icon.
5
+ export const CashRegisterIcon = createSvgIcon('CashRegisterIcon', () => (
6
+ <>
7
+ <Path d="M21 15h-2.5a1.503 1.503 0 0 0-1.5 1.5a1.503 1.503 0 0 0 1.5 1.5h1a1.503 1.503 0 0 1 1.5 1.5a1.503 1.503 0 0 1-1.5 1.5H17m2 0v1m0-8v1m-6 6H6a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h2m12 3.12V9a2 2 0 0 0-2-2h-2" />
8
+ <Path d="M16 10V4a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v6m8 0H8m8 0h1m-9 0H7m1 4v.01M8 17v.01m4-3.02V14m0 3v.01" />
9
+ </>
10
+ ));
@@ -0,0 +1,7 @@
1
+ import { Path } from 'react-native-svg';
2
+ import { createSvgIcon } from './svg-icon';
3
+
4
+ // Tabler category (MIT), v2 `icon/components/tabler/category.tsx`: the folder mark on a category tile.
5
+ export const CategoryIcon = createSvgIcon('CategoryIcon', () => (
6
+ <Path d="M5 4h4l3 3h7a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2" />
7
+ ));
@@ -0,0 +1,5 @@
1
+ import { Path } from 'react-native-svg';
2
+ import { createSvgIcon } from './svg-icon';
3
+
4
+ // Tabler chart-line (MIT), tabler-icons 1.2.42 via Iconify; WCPOS v2's `reports` nav icon.
5
+ export const ChartLineIcon = createSvgIcon('ChartLineIcon', () => <Path d="M4 19h16M4 15l4-6l4 2l4-5l4 4" />);
@@ -0,0 +1,5 @@
1
+ import { Path } from 'react-native-svg';
2
+ import { createSvgIcon } from './svg-icon';
3
+
4
+ // Tabler check (MIT), as WCPOS v2's tabler `check` glyph.
5
+ export const CheckIcon = createSvgIcon('CheckIcon', () => <Path d="m5 12 5 5L20 7" />);
@@ -0,0 +1,4 @@
1
+ import { Polyline } from 'react-native-svg';
2
+ import { createSvgIcon } from './svg-icon';
3
+
4
+ export const ChevronLeftIcon = createSvgIcon('ChevronLeftIcon', () => <Polyline points="15 18 9 12 15 6" />);
@@ -0,0 +1,4 @@
1
+ import { Polyline } from 'react-native-svg';
2
+ import { createSvgIcon } from './svg-icon';
3
+
4
+ export const ChevronRightIcon = createSvgIcon('ChevronRightIcon', () => <Polyline points="9 18 15 12 9 6" />);
@@ -0,0 +1,10 @@
1
+ import { Line, Rect } from 'react-native-svg';
2
+ import { createSvgIcon } from './svg-icon';
3
+
4
+ // Lucide's credit-card icon (ISC licence).
5
+ export const CreditCardIcon = createSvgIcon('CreditCardIcon', () => (
6
+ <>
7
+ <Rect x={2} y={5} width={20} height={14} rx={2} />
8
+ <Line x1={2} y1={10} x2={22} y2={10} />
9
+ </>
10
+ ));
@@ -0,0 +1,11 @@
1
+ import { Path } from 'react-native-svg';
2
+ import { createSvgIcon } from './svg-icon';
3
+
4
+ // Tabler discount (MIT), tabler-icons 1.2.42 via Iconify; WCPOS v2's `discount` nav icon.
5
+ export const DiscountIcon = createSvgIcon('DiscountIcon', () => (
6
+ <>
7
+ <Path d="m9 15l6-6" />
8
+ <Path d="M9 9.5a.5.5 0 1 0 1 0a.5.5 0 1 0-1 0m5 5a.5.5 0 1 0 1 0a.5.5 0 1 0-1 0" fill="currentColor" />
9
+ <Path d="M3 12a9 9 0 1 0 18 0a9 9 0 1 0-18 0" />
10
+ </>
11
+ ));
@@ -0,0 +1,10 @@
1
+ import { Path } from 'react-native-svg';
2
+ import { createSvgIcon } from './svg-icon';
3
+
4
+ // Tabler gift (MIT), tabler-icons 1.2.42 via Iconify; WCPOS v2's `gift` nav icon.
5
+ export const GiftIcon = createSvgIcon('GiftIcon', () => (
6
+ <>
7
+ <Path d="M3 9a1 1 0 0 1 1-1h16a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1zm9-1v13" />
8
+ <Path d="M19 12v7a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2v-7m2.5-4a2.5 2.5 0 0 1 0-5A4.8 8 0 0 1 12 8a4.8 8 0 0 1 4.5-5a2.5 2.5 0 0 1 0 5" />
9
+ </>
10
+ ));
@@ -0,0 +1,10 @@
1
+ import { Path } from 'react-native-svg';
2
+ import { createSvgIcon } from './svg-icon';
3
+
4
+ // Tabler info-circle (MIT), as WCPOS v2's tabler `info` glyph.
5
+ export const InfoCircleIcon = createSvgIcon('InfoCircleIcon', () => (
6
+ <>
7
+ <Path d="M3 12a9 9 0 1 0 18 0 9 9 0 0 0-18 0m9-3h.01" />
8
+ <Path d="M11 12h1v4h1" />
9
+ </>
10
+ ));
@@ -0,0 +1,10 @@
1
+ import { Path } from 'react-native-svg';
2
+ import { createSvgIcon } from './svg-icon';
3
+
4
+ // Tabler map-pin (MIT): the glyph of WCPOS v2's `address` icon in its default (Tabler) set.
5
+ export const MapPinIcon = createSvgIcon('MapPinIcon', () => (
6
+ <>
7
+ <Path d="M9 11a3 3 0 1 0 6 0 3 3 0 0 0-6 0" />
8
+ <Path d="M17.657 16.657 13.414 20.9a2 2 0 0 1-2.827 0l-4.244-4.243a8 8 0 1 1 11.314 0" />
9
+ </>
10
+ ));
@@ -0,0 +1,7 @@
1
+ import { Path } from 'react-native-svg';
2
+ import { createSvgIcon } from './svg-icon';
3
+
4
+ // Tabler message-question (MIT), tabler-icons 1.2.42 via Iconify; WCPOS v2's `support` nav icon.
5
+ export const MessageQuestionIcon = createSvgIcon('MessageQuestionIcon', () => (
6
+ <Path d="M8 9h8m-8 4h6m0 5h-1l-5 3v-3H6a3 3 0 0 1-3-3V7a3 3 0 0 1 3-3h12a3 3 0 0 1 3 3v4.5M19 22v.01M19 19a2.003 2.003 0 0 0 .914-3.782a1.98 1.98 0 0 0-2.414.483" />
7
+ ));
@@ -0,0 +1,10 @@
1
+ import { Path } from 'react-native-svg';
2
+ import { createSvgIcon } from './svg-icon';
3
+
4
+ // Lucide pencil (ISC)
5
+ export const PencilIcon = createSvgIcon('PencilIcon', () => (
6
+ <>
7
+ <Path d="M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z" />
8
+ <Path d="m15 5 4 4" />
9
+ </>
10
+ ));
@@ -0,0 +1,9 @@
1
+ import { Line } from 'react-native-svg';
2
+ import { createSvgIcon } from './svg-icon';
3
+
4
+ export const PlusIcon = createSvgIcon('PlusIcon', () => (
5
+ <>
6
+ <Line x1={5} y1={12} x2={19} y2={12} />
7
+ <Line x1={12} y1={5} x2={12} y2={19} />
8
+ </>
9
+ ));
@@ -0,0 +1,10 @@
1
+ import { Path } from 'react-native-svg';
2
+ import { createSvgIcon } from './svg-icon';
3
+
4
+ // Tabler printer (MIT); WCPOS v2's `print` icon.
5
+ export const PrinterIcon = createSvgIcon('PrinterIcon', () => (
6
+ <>
7
+ <Path d="M17 17h2a2 2 0 0 0 2-2v-4a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v4a2 2 0 0 0 2 2h2m10-8V5a2 2 0 0 0-2-2H9a2 2 0 0 0-2 2v4" />
8
+ <Path d="M7 15a2 2 0 0 1 2-2h6a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2H9a2 2 0 0 1-2-2z" />
9
+ </>
10
+ ));
@@ -0,0 +1,7 @@
1
+ import { Path } from 'react-native-svg';
2
+ import { createSvgIcon } from './svg-icon';
3
+
4
+ // Tabler receipt (MIT), tabler-icons 1.2.42 via Iconify; WCPOS v2's `receipt` nav icon.
5
+ export const ReceiptIcon = createSvgIcon('ReceiptIcon', () => (
6
+ <Path d="M5 21V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16l-3-2l-2 2l-2-2l-2 2l-2-2zM9 7h6m-6 4h6m-2 4h2" />
7
+ ));