@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,10 @@
1
+ import { Path } from 'react-native-svg';
2
+ import { createSvgIcon } from './svg-icon';
3
+
4
+ // Tabler settings (MIT), tabler-icons 1.2.42 via Iconify; WCPOS v2's `settings` nav icon.
5
+ export const SettingsIcon = createSvgIcon('SettingsIcon', () => (
6
+ <>
7
+ <Path d="M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 0 0 2.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 0 0 1.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 0 0-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 0 0-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 0 0-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 0 0-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 0 0 1.066-2.573c-.94-1.543.826-3.31 2.37-2.37c1 .608 2.296.07 2.572-1.065" />
8
+ <Path d="M9 12a3 3 0 1 0 6 0a3 3 0 0 0-6 0" />
9
+ </>
10
+ ));
@@ -0,0 +1,10 @@
1
+ import { Path } from 'react-native-svg';
2
+ import { createSvgIcon } from './svg-icon';
3
+
4
+ // Lucide sticky-note (ISC)
5
+ export const StickyNoteIcon = createSvgIcon('StickyNoteIcon', () => (
6
+ <>
7
+ <Path d="M16 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V8Z" />
8
+ <Path d="M15 3v4a2 2 0 0 0 2 2h4" />
9
+ </>
10
+ ));
@@ -0,0 +1,4 @@
1
+ import { Circle, Path } from 'react-native-svg';
2
+ import { createSvgIcon } from './svg-icon';
3
+
4
+ export const UserIcon = createSvgIcon('UserIcon', () => (<><Circle cx={12} cy={8} r={5} /><Path d="M20 21a8 8 0 0 0-16 0" /></>));
@@ -0,0 +1,7 @@
1
+ import { Path } from 'react-native-svg';
2
+ import { createSvgIcon } from './svg-icon';
3
+
4
+ // Tabler users (MIT), tabler-icons 1.2.42 via Iconify; WCPOS v2's `customers` nav icon.
5
+ export const UsersIcon = createSvgIcon('UsersIcon', () => (
6
+ <Path d="M5 7a4 4 0 1 0 8 0a4 4 0 1 0-8 0M3 21v-2a4 4 0 0 1 4-4h4a4 4 0 0 1 4 4v2m1-17.87a4 4 0 0 1 0 7.75M21 21v-2a4 4 0 0 0-3-3.85" />
7
+ ));
@@ -0,0 +1,7 @@
1
+ import { Path } from 'react-native-svg';
2
+ import { createSvgIcon } from './svg-icon';
3
+
4
+ /** Four tiles: the grid view (v2 tabler view-grid). */
5
+ export const ViewGridIcon = createSvgIcon('ViewGridIcon', () => (
6
+ <Path d="M4 5a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v4a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1zm10 0a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v4a1 1 0 0 1-1 1h-4a1 1 0 0 1-1-1zM4 15a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v4a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1zm10 0a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v4a1 1 0 0 1-1 1h-4a1 1 0 0 1-1-1z" />
7
+ ));
@@ -0,0 +1,7 @@
1
+ import { Path } from 'react-native-svg';
2
+ import { createSvgIcon } from './svg-icon';
3
+
4
+ /** Two tiles with lines: the table view (v2 tabler view-list). */
5
+ export const ViewListIcon = createSvgIcon('ViewListIcon', () => (
6
+ <Path d="M13 5h8m-8 4h5m-5 6h8m-8 4h5M3 5a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v4a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1zm0 10a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v4a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1z" />
7
+ ));
package/src/ui/index.ts CHANGED
@@ -7,18 +7,40 @@ export { VStack, vstackVariants, type VStackProps } from './vstack';
7
7
  export { Icon, iconVariants, type IconProps } from './icon';
8
8
  export { createSvgIcon, type SvgIconProps } from './icon/svg-icon';
9
9
  export { SearchIcon } from './icon/search-icon';
10
+ export { UserIcon } from './icon/user-icon';
10
11
  export { ShoppingCartIcon } from './icon/shopping-cart-icon';
11
12
  export { XIcon } from './icon/x-icon';
12
13
  export { ScanIcon } from './icon/scan-icon';
13
14
  export { GripIcon } from './icon/grip-icon';
14
15
  export { ChevronDownIcon } from './icon/chevron-down-icon';
16
+ export { ChevronRightIcon } from './icon/chevron-right-icon';
17
+ export { PlusIcon } from './icon/plus-icon';
18
+ export { CashRegisterIcon } from './icon/cash-register-icon';
19
+ export { GiftIcon } from './icon/gift-icon';
20
+ export { ReceiptIcon } from './icon/receipt-icon';
21
+ export { PrinterIcon } from './icon/printer-icon';
22
+ export { DiscountIcon } from './icon/discount-icon';
23
+ export { UsersIcon } from './icon/users-icon';
24
+ export { ChartLineIcon } from './icon/chart-line-icon';
25
+ export { ActivityHeartbeatIcon } from './icon/activity-heartbeat-icon';
26
+ export { SettingsIcon } from './icon/settings-icon';
27
+ export { MessageQuestionIcon } from './icon/message-question-icon';
28
+ export { CheckIcon } from './icon/check-icon';
29
+ export { AlertTriangleIcon } from './icon/alert-triangle-icon';
30
+ export { AlertCircleIcon } from './icon/alert-circle-icon';
31
+ export { InfoCircleIcon } from './icon/info-circle-icon';
15
32
  export { Loader, loaderVariants, type LoaderProps } from './loader';
33
+ export { Skeleton, skeletonCount, SKELETON_MAX_ROWS, type SkeletonProps } from './skeleton';
16
34
  export { Badge, badgeVariants, badgeTextVariants, type BadgeProps } from './badge';
35
+ export { StatusBadge, statusDotVariants, type StatusBadgeProps } from './status-badge';
36
+ export { ToneDisc, type ToneDiscProps, type ToneDiscTone } from './tone-disc';
37
+ export { Notice, type NoticeProps, type NoticeAction } from './notice';
17
38
  export { Avatar, avatarVariants, avatarInitials, type AvatarProps } from './avatar';
18
39
 
19
40
  // Interactive
20
41
  export { Button, buttonVariants, buttonTextVariants, type ButtonProps } from './button';
21
42
  export { IconButton, iconButtonVariants, type IconButtonProps } from './icon-button';
43
+ export { ListRow, type ListRowProps, type ListRowSize } from './list-row';
22
44
 
23
45
  // Containers & Form
24
46
  export { Card, CardHeader, CardTitle, CardDescription, CardContent, CardFooter } from './card';
@@ -42,6 +64,7 @@ export {
42
64
  AlertDialogContent, AlertDialogHeader, AlertDialogFooter, AlertDialogTitle,
43
65
  AlertDialogDescription, AlertDialogAction, AlertDialogCancel,
44
66
  } from './alert-dialog';
67
+ export { ConfirmDialog, type ConfirmDialogProps } from './confirm-dialog';
45
68
 
46
69
  // Select
47
70
  export {
@@ -52,7 +75,7 @@ export {
52
75
  // Combobox
53
76
  export {
54
77
  Combobox, ComboboxTrigger, ComboboxInput, ComboboxContent,
55
- ComboboxItem, ComboboxEmpty,
78
+ ComboboxList, ComboboxItem, ComboboxEmpty,
56
79
  } from './combobox';
57
80
 
58
81
  // Dropdown Menu
@@ -0,0 +1,93 @@
1
+ import * as React from 'react';
2
+ import { Pressable, View, type PressableProps, type Role } from 'react-native';
3
+ import { cn, POINTER_FLOORS } from '@tallyui/theme';
4
+ import { currentRowMark } from '../../lib/current-row';
5
+ import { usePointer } from '../../scale/use-pointer';
6
+ import { useScale } from '../../scale/scale-provider';
7
+
8
+ type ListRowSize = 'default' | 'sm';
9
+
10
+ type ListRowProps = Omit<PressableProps, 'children' | 'role'> & {
11
+ /** Unset, a row with an action is a `button`; one without is no control at all. */
12
+ role?: Role;
13
+ /**
14
+ * Set on a list whose rows can be the current one (open orders, a short choice). `true`
15
+ * paints the row `bg-muted` with the primary bar on its left edge; `false` keeps the bar's
16
+ * room, so the rows' content lines up either way. Unset: a plain list, no bar.
17
+ */
18
+ selected?: boolean;
19
+ /** Before the body: an avatar, a thumb, a check. */
20
+ leading?: React.ReactNode;
21
+ /** After the body: an amount, a badge, a chevron. */
22
+ trailing?: React.ReactNode;
23
+ /** `default` (56) for a two-line data row; `sm` (44) for a one-line row or a dense list. */
24
+ size?: ListRowSize;
25
+ className?: string;
26
+ /** The body column's own layout (a `gap-1` between its lines). */
27
+ bodyClassName?: string;
28
+ children?: React.ReactNode;
29
+ };
30
+
31
+ /** Roles whose `selected` is announced as checked, not selected. */
32
+ const CHECKED_ROLES = new Set(['radio', 'checkbox', 'menuitemradio', 'menuitemcheckbox']);
33
+
34
+ /**
35
+ * WCPOS v2's ListRow: one flush row of a list, a hairline under it, `leading`, body and `trailing`.
36
+ * A later slice adds v2's shared pressable surface.
37
+ * TallyUI difference: `sm` is a `minHeight` style number (the `--spacing-row` token, floored at the pointer
38
+ * floor, as v2's own figure) rather than v2's `min-h-row` class, because `scale.css` is opt-in.
39
+ */
40
+ function ListRow({
41
+ role,
42
+ accessibilityRole,
43
+ selected,
44
+ leading,
45
+ trailing,
46
+ size,
47
+ className,
48
+ bodyClassName,
49
+ children,
50
+ disabled,
51
+ style,
52
+ ...props
53
+ }: ListRowProps) {
54
+ const pointer = usePointer();
55
+ const row = Math.max(useScale().variables['--spacing-row'], POINTER_FLOORS[pointer]);
56
+ const resolved = role ?? accessibilityRole ?? (props.onPress ? 'button' : undefined);
57
+ const checked = resolved !== undefined && CHECKED_ROLES.has(resolved);
58
+ const rowStyle: PressableProps['style'] =
59
+ size !== 'sm' ? style
60
+ : typeof style === 'function' ? (state) => [{ minHeight: row }, style(state)]
61
+ : [{ minHeight: row }, style];
62
+ return (
63
+ <Pressable
64
+ role={resolved as Role | undefined}
65
+ // A row without an action is no tab stop (react-native-web ignores `focusable`).
66
+ tabIndex={props.onPress || props.onLongPress || role || accessibilityRole ? undefined : -1}
67
+ // React Native maps both onto the state a native screen reader announces.
68
+ aria-selected={checked ? undefined : selected}
69
+ aria-checked={checked ? selected : undefined}
70
+ {...props}
71
+ style={rowStyle}
72
+ disabled={!!disabled}
73
+ className={cn(
74
+ 'border-border flex-row items-center gap-3 border-b px-3 py-2',
75
+ size === 'sm' ? undefined : 'min-h-14',
76
+ 'active:bg-accent',
77
+ pointer === 'fine' && 'web:hover:bg-accent',
78
+ disabled && 'opacity-45 web:pointer-events-none',
79
+ currentRowMark(selected),
80
+ // The bar's 2 comes out of the row's 12, so the content stays on the same line.
81
+ selected !== undefined && 'pl-2.5',
82
+ className,
83
+ )}
84
+ >
85
+ {leading}
86
+ <View className={cn('min-w-0 flex-1', bodyClassName)}>{children}</View>
87
+ {trailing}
88
+ </Pressable>
89
+ );
90
+ }
91
+
92
+ export { ListRow };
93
+ export type { ListRowProps, ListRowSize };
@@ -0,0 +1,65 @@
1
+ import * as React from 'react';
2
+ import { AccessibilityInfo, Platform, View } from 'react-native';
3
+ import { cn } from '@tallyui/theme';
4
+ import { Button } from '../button';
5
+ import { HStack } from '../hstack';
6
+ import { Text } from '../text';
7
+ import { VStack } from '../vstack';
8
+ import type { SvgIconProps } from '../icon/svg-icon';
9
+ import { AlertCircleIcon } from '../icon/alert-circle-icon';
10
+ import { AlertTriangleIcon } from '../icon/alert-triangle-icon';
11
+ import { InfoCircleIcon } from '../icon/info-circle-icon';
12
+
13
+ type NoticeAction = { label: string; onPress: () => void; testID?: string; primary?: boolean };
14
+ type NoticeProps = {
15
+ tone: 'bad' | 'warning' | 'info';
16
+ title: string;
17
+ children?: React.ReactNode;
18
+ actions?: readonly [NoticeAction] | readonly [NoticeAction, NoticeAction];
19
+ /** The tone's glyph by default; `null` draws none. */
20
+ icon?: React.ComponentType<SvgIconProps> | null;
21
+ /** `false` makes a plain group, not a live region, for a band that holds controls. */
22
+ live?: boolean;
23
+ testID?: string; className?: string;
24
+ };
25
+
26
+ // As WCPOS v2's TONE[tone].band and glyph; a `primary` action's label is inked in the accent.
27
+ const TONES = {
28
+ bad: { band: 'border-bad/45 bg-bad-bg', glyph: AlertCircleIcon },
29
+ warning: { band: 'border-warning/45 bg-warning-bg', glyph: AlertTriangleIcon },
30
+ info: { band: 'border-border bg-card', glyph: InfoCircleIcon },
31
+ } as const;
32
+
33
+ export function Notice({ tone, title, children, actions, icon, live = true, testID, className }: NoticeProps) {
34
+ // iOS has no live region, so a bad band speaks its title once on mount there (as v2).
35
+ const spoken = React.useRef(live && tone === 'bad' ? title : undefined);
36
+ React.useEffect(() => {
37
+ if (spoken.current && Platform.OS === 'ios') AccessibilityInfo.announceForAccessibility(spoken.current);
38
+ }, []);
39
+ const Glyph = icon ?? TONES[tone].glyph;
40
+ const id = (part: string) => (testID ? `${testID}-${part}` : undefined);
41
+ return (
42
+ <View
43
+ testID={testID}
44
+ role={!live ? 'group' : tone === 'bad' ? 'alert' : 'status'}
45
+ aria-live={!live ? undefined : tone === 'bad' ? 'assertive' : 'polite'}
46
+ className={cn('flex-row flex-wrap items-center gap-2 rounded-lg border px-3 py-2.5', TONES[tone].band, className)}
47
+ >
48
+ {icon !== null && <Glyph className="text-foreground" />}
49
+ <VStack className="min-w-0 flex-1 basis-48">
50
+ <Text testID={id('title')} className="text-foreground font-medium">{title}</Text>
51
+ {children}
52
+ </VStack>
53
+ {actions && (
54
+ <HStack className="flex-wrap gap-2">
55
+ {actions.map((action, index) => (
56
+ <Button key={index} variant="ghost" size="sm" className="h-auto min-h-9 py-1" testID={action.testID ?? id(`action-${index}`)} onPress={action.onPress}>
57
+ <Text className={cn('web:whitespace-normal', action.primary && 'text-primary')}>{action.label}</Text>
58
+ </Button>
59
+ ))}
60
+ </HStack>
61
+ )}
62
+ </View>
63
+ );
64
+ }
65
+ export type { NoticeProps, NoticeAction };
@@ -52,6 +52,8 @@ const SelectContent = React.forwardRef<
52
52
  <SelectPrimitive.Portal>
53
53
  <SelectPrimitive.Content
54
54
  ref={ref}
55
+ // v2's `min-w-32` floor (monorepo select/index.tsx:171-174); the primitive's
56
+ // Content raises it to the trigger's width with an inline minWidth.
55
57
  className={cn(
56
58
  'relative z-50 min-w-[8rem] overflow-hidden rounded-md border border-border bg-popover p-1 text-popover-foreground shadow-md',
57
59
  className,
@@ -0,0 +1,37 @@
1
+ import { View, type ViewProps } from 'react-native';
2
+ import { cn } from '@tallyui/theme';
3
+ import { useScale } from '../../scale/scale-provider';
4
+
5
+ export type SkeletonProps = ViewProps & { shape?: 'block' | 'line' | 'row' | 'tile' | 'chip'; className?: string };
6
+
7
+ const shapes = {
8
+ block: 'flex-1 w-full',
9
+ line: 'h-5',
10
+ row: 'w-full',
11
+ tile: 'w-full',
12
+ // A filter chip's own frame (v2 `Chip`: the control height, full radius).
13
+ chip: 'w-24 rounded-full',
14
+ };
15
+
16
+ // TallyUI difference: row/tile/chip heights are style numbers from the scale, not v2's h-row/h-tile/h-ctl
17
+ // classes, because scale.css is opt-in (as ListRow, ui/list-row/index.tsx).
18
+ const heights = { row: '--spacing-row', tile: '--spacing-tile', chip: '--spacing-ctl' } as const;
19
+
20
+ /** WCPOS v2's Skeleton: a still, muted placeholder in the shape of what is coming. No pulse, no animation. */
21
+ export function Skeleton({ shape = 'block', className, style, ...props }: SkeletonProps) {
22
+ const { variables } = useScale();
23
+ const height = shape in heights ? variables[heights[shape as keyof typeof heights]] : undefined;
24
+ return (
25
+ <View {...props} style={[height === undefined ? null : { height }, style]}
26
+ className={cn('bg-muted rounded-lg', shapes[shape], className)} aria-busy />
27
+ );
28
+ }
29
+
30
+ export const SKELETON_MAX_ROWS = 12;
31
+
32
+ /** How many skeleton rows fill `extent` at `rowHeight` each: at least 1, at most SKELETON_MAX_ROWS (v2). */
33
+ export function skeletonCount(extent: number, rowHeight: number): number {
34
+ if (!Number.isFinite(extent) || extent <= 0) return 1;
35
+ if (!Number.isFinite(rowHeight) || rowHeight <= 0) return 1;
36
+ return Math.min(SKELETON_MAX_ROWS, Math.max(1, Math.ceil(extent / rowHeight)));
37
+ }
@@ -0,0 +1,43 @@
1
+ import * as React from 'react';
2
+ import { View, type ViewProps } from 'react-native';
3
+ import { cn } from '@tallyui/theme';
4
+ import { cva, type VariantProps } from 'class-variance-authority';
5
+ import { Text, TextClassContext } from '../text';
6
+
7
+ const statusDotVariants = cva('shrink-0 rounded-full', {
8
+ variants: {
9
+ size: { default: 'size-2', caption: 'size-1.5' },
10
+ variant: {
11
+ default: 'bg-primary',
12
+ ok: 'bg-success',
13
+ warning: 'bg-warning',
14
+ bad: 'bg-destructive',
15
+ info: 'bg-info',
16
+ muted: 'bg-muted-foreground',
17
+ },
18
+ },
19
+ defaultVariants: { variant: 'default', size: 'default' },
20
+ });
21
+
22
+ type StatusBadgeProps = ViewProps & VariantProps<typeof statusDotVariants> & {
23
+ /** The word naming the state; it keeps the foreground colour. */
24
+ label: string;
25
+ };
26
+
27
+ // The dot carries the status colour and the word keeps the foreground, so a status never reads by
28
+ // colour alone (WCPOS v2 `status-badge`); `caption` is a row's state line and a log level.
29
+ function StatusBadge({ label, variant, size, className, ...props }: StatusBadgeProps) {
30
+ return (
31
+ <View className={cn('flex-row items-center gap-1.5', className)} {...props}>
32
+ <View aria-hidden className={statusDotVariants({ variant, size })} />
33
+ <TextClassContext.Provider value={undefined}>
34
+ <Text className={cn('shrink', size === 'caption' ? 'text-xs text-muted-foreground' : 'text-sm text-foreground')}>
35
+ {label}
36
+ </Text>
37
+ </TextClassContext.Provider>
38
+ </View>
39
+ );
40
+ }
41
+
42
+ export { StatusBadge, statusDotVariants };
43
+ export type { StatusBadgeProps };
@@ -21,7 +21,7 @@ const Switch = React.forwardRef<React.ComponentRef<typeof SwitchPrimitive.Root>,
21
21
  <SwitchPrimitive.Root
22
22
  ref={ref}
23
23
  className={cn(
24
- `web:peer inline-flex ${s.track} shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent web:transition-colors web:focus-visible:outline-none web:focus-visible:ring-2 web:focus-visible:ring-ring web:focus-visible:ring-offset-2 web:focus-visible:ring-offset-background`,
24
+ `web:peer inline-flex flex-row ${s.track} shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent web:transition-colors web:focus-visible:outline-none web:focus-visible:ring-2 web:focus-visible:ring-ring web:focus-visible:ring-offset-2 web:focus-visible:ring-offset-background`,
25
25
  props.checked ? 'bg-primary' : 'bg-border',
26
26
  props.disabled && 'web:cursor-not-allowed opacity-50',
27
27
  className,
@@ -1,6 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import { Tabs as TabsPrimitive, TextClassContext } from '@tallyui/primitives';
3
3
  import { cn } from '@tallyui/theme';
4
+ import { MinTargetBand } from '../../scale/min-target';
4
5
 
5
6
  const Tabs = TabsPrimitive.Root;
6
7
 
@@ -16,7 +17,7 @@ function TabsList({ className, ...props }: React.ComponentPropsWithoutRef<typeof
16
17
  const TabsTrigger = React.forwardRef<
17
18
  React.ComponentRef<typeof TabsPrimitive.Trigger>,
18
19
  React.ComponentPropsWithoutRef<typeof TabsPrimitive.Trigger>
19
- >(function TabsTrigger({ className, ...props }, ref) {
20
+ >(function TabsTrigger({ className, children, ...props }, ref) {
20
21
  const { value } = TabsPrimitive.useRootContext();
21
22
  const isActive = props.value === value;
22
23
 
@@ -35,7 +36,15 @@ const TabsTrigger = React.forwardRef<
35
36
  className,
36
37
  )}
37
38
  {...props}
38
- />
39
+ >
40
+ {/* The band rides along after the label; asChild's Slot takes one child, so it keeps its own. */}
41
+ {props.asChild ? children : (state) => (
42
+ <>
43
+ {typeof children === 'function' ? children(state) : children}
44
+ <MinTargetBand />
45
+ </>
46
+ )}
47
+ </TabsPrimitive.Trigger>
39
48
  </TextClassContext.Provider>
40
49
  );
41
50
  });
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import { ToggleGroup as ToggleGroupPrimitive, TextClassContext } from '@tallyui/primitives';
2
+ import { ToggleGroup as ToggleGroupPrimitive, toggleGroupUtils, TextClassContext } from '@tallyui/primitives';
3
3
  import { cn } from '@tallyui/theme';
4
4
  import { type VariantProps } from 'class-variance-authority';
5
5
  import { toggleVariants, toggleTextVariants } from '../toggle';
@@ -38,6 +38,7 @@ const ToggleGroupItem = React.forwardRef<
38
38
  ToggleGroupItemProps
39
39
  >(function ToggleGroupItem({ className, variant, size, ...props }, ref) {
40
40
  const context = React.useContext(ToggleGroupContext);
41
+ const pressed = toggleGroupUtils.getIsSelected(ToggleGroupPrimitive.useRootContext().value, props.value);
41
42
 
42
43
  return (
43
44
  <TextClassContext.Provider
@@ -53,6 +54,7 @@ const ToggleGroupItem = React.forwardRef<
53
54
  variant: variant || context.variant,
54
55
  size: size || context.size,
55
56
  }),
57
+ pressed && 'bg-accent text-accent-foreground',
56
58
  className,
57
59
  )}
58
60
  {...props}
@@ -0,0 +1,41 @@
1
+ import type * as React from 'react';
2
+ import { View } from 'react-native';
3
+ import { cn } from '@tallyui/theme';
4
+ import type { SvgIconProps } from '../icon/svg-icon';
5
+ import { CheckIcon } from '../icon/check-icon';
6
+ import { AlertTriangleIcon } from '../icon/alert-triangle-icon';
7
+ import { AlertCircleIcon } from '../icon/alert-circle-icon';
8
+ import { InfoCircleIcon } from '../icon/info-circle-icon';
9
+
10
+ type Tone = 'ok' | 'warning' | 'bad' | 'info' | 'muted';
11
+ type ToneDiscProps = {
12
+ tone: Tone;
13
+ /** Overrides the tone's glyph; any `createSvgIcon` glyph. */
14
+ icon?: React.ComponentType<SvgIconProps>;
15
+ size?: 'sm' | 'default' | 'lg';
16
+ testID?: string;
17
+ };
18
+
19
+ const TONES = {
20
+ ok: { disc: 'bg-ok-bg', text: 'text-ok', glyph: CheckIcon },
21
+ warning: { disc: 'bg-warning-bg', text: 'text-warning-text', glyph: AlertTriangleIcon },
22
+ bad: { disc: 'bg-bad-bg', text: 'text-bad', glyph: AlertCircleIcon },
23
+ info: { disc: 'bg-info/15', text: 'text-info', glyph: InfoCircleIcon },
24
+ muted: { disc: 'bg-muted', text: 'text-muted-foreground', glyph: InfoCircleIcon },
25
+ } as const;
26
+ const SIZES = { sm: { disc: 'size-11', glyph: 18 }, default: { disc: 'size-14', glyph: 28 }, lg: { disc: 'size-24', glyph: 36 } } as const;
27
+
28
+ // As WCPOS v2: the tone lives on the disc (its wash and its glyph).
29
+ // One scale: 44 beside a sheet's title, 56 a gate or finished setup, 96 the paid stamp.
30
+ export function ToneDisc({ tone: name, icon, size: sizeName = 'default', testID }: ToneDiscProps) {
31
+ const tone = TONES[name];
32
+ const size = SIZES[sizeName];
33
+ const Glyph = icon ?? tone.glyph;
34
+ return (
35
+ <View testID={testID} className={cn('items-center justify-center rounded-full', size.disc, tone.disc, tone.text)}>
36
+ <Glyph size={size.glyph} strokeWidth={1.5} />
37
+ </View>
38
+ );
39
+ }
40
+
41
+ export type { ToneDiscProps, Tone as ToneDiscTone };