@tallyui/components 3.19.0 → 3.20.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +14 -4
- package/dist/index.js +37 -20
- package/package.json +9 -9
- package/src/cart/cart-foot.tsx +2 -2
- package/src/cart/cart-panel.tsx +4 -1
- package/src/cart/cart-total.tsx +8 -5
- package/src/input/search-input.tsx +1 -1
- package/src/product/product-table.tsx +14 -4
- package/src/sale/cart.tsx +7 -4
- package/src/shell/nav-drawer.tsx +1 -1
- package/src/ui/alert-dialog/index.tsx +1 -1
- package/src/ui/dialog/index.tsx +1 -1
- package/src/ui/slider/index.tsx +2 -2
- package/src/ui/switch/index.tsx +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -657,6 +657,10 @@ interface ProductTableColumn<Doc = any> {
|
|
|
657
657
|
id: string;
|
|
658
658
|
/** Header label. */
|
|
659
659
|
header: string;
|
|
660
|
+
/** Places the head and the cells' content; default left (WCPOS v2 column-style). */
|
|
661
|
+
align?: 'left' | 'center' | 'right';
|
|
662
|
+
/** Draws no head label; `header` stays the head's accessible name (v2's image column). */
|
|
663
|
+
hideHeader?: boolean;
|
|
660
664
|
render: (doc: Doc) => ReactNode;
|
|
661
665
|
/** The value the header sort orders by; omit to make the column unsortable. */
|
|
662
666
|
sortValue?: (doc: Doc) => ProductSortValue;
|
|
@@ -931,15 +935,17 @@ interface CartTotalProps extends Omit<VStackProps, 'children'> {
|
|
|
931
935
|
className?: string;
|
|
932
936
|
/** Rows rendered directly under Subtotal, e.g. a platform's coupon chips. */
|
|
933
937
|
afterSubtotal?: ReactNode;
|
|
938
|
+
/** Draws the Total row. Pass `false` when the total shows elsewhere, e.g. v2's Checkout button. Default `true`. */
|
|
939
|
+
showTotal?: boolean;
|
|
934
940
|
}
|
|
935
941
|
/**
|
|
936
|
-
* Displays a cart summary: subtotal, optional discount, optional tax, and
|
|
942
|
+
* Displays a cart summary: subtotal, optional discount, optional tax, and an optional Total row, in the receipt's order.
|
|
937
943
|
*
|
|
938
944
|
* ```tsx
|
|
939
945
|
* <CartTotal subtotal={subtotal} discount={discount} taxLines={taxLines} total={total} />
|
|
940
946
|
* ```
|
|
941
947
|
*/
|
|
942
|
-
declare function CartTotal({ subtotal, taxLines, discount, total, taxInclusive, locale, className, afterSubtotal, ...props }: CartTotalProps): react_jsx_runtime.JSX.Element;
|
|
948
|
+
declare function CartTotal({ subtotal, taxLines, discount, total, taxInclusive, locale, className, afterSubtotal, showTotal, ...props }: CartTotalProps): react_jsx_runtime.JSX.Element;
|
|
943
949
|
|
|
944
950
|
interface CartPanelProps<T> extends Omit<VStackProps, 'children'> {
|
|
945
951
|
/** Cart line items to render */
|
|
@@ -954,11 +960,13 @@ interface CartPanelProps<T> extends Omit<VStackProps, 'children'> {
|
|
|
954
960
|
afterItems?: ReactNode;
|
|
955
961
|
/** Footer slot (e.g. totals, checkout button) */
|
|
956
962
|
footer?: ReactNode;
|
|
963
|
+
/** Classes for the footer's wrapper (default `border-t border-border px-3 py-2`). */
|
|
964
|
+
footerClassName?: string;
|
|
957
965
|
/** Content shown when items is empty */
|
|
958
966
|
emptyState?: ReactNode;
|
|
959
967
|
className?: string;
|
|
960
968
|
}
|
|
961
|
-
declare function CartPanel<T>({ items, renderItem, keyExtractor, header, afterItems, footer, emptyState, className, ...props }: CartPanelProps<T>): JSX.Element;
|
|
969
|
+
declare function CartPanel<T>({ items, renderItem, keyExtractor, header, afterItems, footer, footerClassName, emptyState, className, ...props }: CartPanelProps<T>): JSX.Element;
|
|
962
970
|
|
|
963
971
|
interface DiscountBadgeProps extends Omit<ViewProps, 'children'> {
|
|
964
972
|
label: string;
|
|
@@ -1873,7 +1881,7 @@ interface TaxBasedOnProps {
|
|
|
1873
1881
|
declare function TaxBasedOn({ derivation, onChangeSetting, onViewAllRates, countryName, className }: TaxBasedOnProps): react_jsx_runtime.JSX.Element;
|
|
1874
1882
|
|
|
1875
1883
|
/** `taxLabel` names each tax row; VAT isn't universal, so a platform passes its own (medusapos passes `VAT ${rate}%`). */
|
|
1876
|
-
declare function Cart({ sale, taxLabel, canEditPrice, onPriceChange, quickDiscounts, taxClasses, afterSubtotal, couponDiscountMinor, orderActions, checkout, lineEditor, columns, emptyIcon, emptyText }: {
|
|
1884
|
+
declare function Cart({ sale, taxLabel, canEditPrice, onPriceChange, quickDiscounts, taxClasses, afterSubtotal, showTotal, couponDiscountMinor, orderActions, checkout, lineEditor, columns, emptyIcon, emptyText }: {
|
|
1877
1885
|
sale: ReturnType<typeof useSale>;
|
|
1878
1886
|
taxLabel?: (ratePpm: number) => string;
|
|
1879
1887
|
taxClasses?: ReadonlyArray<{
|
|
@@ -1893,6 +1901,8 @@ declare function Cart({ sale, taxLabel, canEditPrice, onPriceChange, quickDiscou
|
|
|
1893
1901
|
quickDiscounts?: readonly number[];
|
|
1894
1902
|
/** Rows under the totals' Subtotal, e.g. the platform's coupon chips (passed to CartTotal). */
|
|
1895
1903
|
afterSubtotal?: ReactNode;
|
|
1904
|
+
/** Draws the totals' Total row. Pass `false` for v2's cart, where the total is on the Checkout button (`checkout`). Default `true`. */
|
|
1905
|
+
showTotal?: boolean;
|
|
1896
1906
|
/** The coupon amount the app itemises in `afterSubtotal` (e.g. Σ `order.display.coupons`), in integer minor units of
|
|
1897
1907
|
* the order's currency, in the display mode. When given, the Discount row shows the other discounts only (the
|
|
1898
1908
|
* totals' discount minus this) and is hidden when they come to 0. Absent: the Discount row is the whole discount. */
|
package/dist/index.js
CHANGED
|
@@ -794,7 +794,7 @@ var DialogOverlay = React17.forwardRef(function DialogOverlay2({ className, ...p
|
|
|
794
794
|
DialogPrimitive.Overlay,
|
|
795
795
|
{
|
|
796
796
|
ref,
|
|
797
|
-
className: cn16("fixed inset-0 z-50 bg-
|
|
797
|
+
className: cn16("fixed inset-0 z-50 bg-scrim", className),
|
|
798
798
|
...props
|
|
799
799
|
}
|
|
800
800
|
);
|
|
@@ -854,7 +854,7 @@ var AlertDialogOverlay = React18.forwardRef(function AlertDialogOverlay2({ class
|
|
|
854
854
|
AlertDialogPrimitive.Overlay,
|
|
855
855
|
{
|
|
856
856
|
ref,
|
|
857
|
-
className: cn17("fixed inset-0 z-50 bg-
|
|
857
|
+
className: cn17("fixed inset-0 z-50 bg-scrim", className),
|
|
858
858
|
...props
|
|
859
859
|
}
|
|
860
860
|
);
|
|
@@ -1556,7 +1556,7 @@ var Switch = React29.forwardRef(function Switch2({ className, size = "default",
|
|
|
1556
1556
|
ref,
|
|
1557
1557
|
className: cn29(
|
|
1558
1558
|
`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`,
|
|
1559
|
-
props.checked ? "bg-primary" : "bg-
|
|
1559
|
+
props.checked ? "bg-primary" : "bg-border",
|
|
1560
1560
|
props.disabled && "web:cursor-not-allowed opacity-50",
|
|
1561
1561
|
className
|
|
1562
1562
|
),
|
|
@@ -1751,8 +1751,8 @@ var Slider = React34.forwardRef(function Slider2({ className, ...props }, ref) {
|
|
|
1751
1751
|
),
|
|
1752
1752
|
...props,
|
|
1753
1753
|
children: [
|
|
1754
|
-
/* @__PURE__ */ jsx42(SliderPrimitive.Track, { className: "relative h-2 w-full grow overflow-hidden rounded-full bg-
|
|
1755
|
-
/* @__PURE__ */ jsx42(SliderPrimitive.Thumb, { className: "absolute top-0 -ml-2.5 block h-5 w-5 rounded-full border-2 border-primary bg-
|
|
1754
|
+
/* @__PURE__ */ jsx42(SliderPrimitive.Track, { className: "relative h-2 w-full grow overflow-hidden rounded-full bg-muted", children: /* @__PURE__ */ jsx42(SliderPrimitive.Range, { className: "absolute h-full bg-primary" }) }),
|
|
1755
|
+
/* @__PURE__ */ jsx42(SliderPrimitive.Thumb, { className: "absolute top-0 -ml-2.5 block h-5 w-5 rounded-full border-2 border-primary bg-card web:ring-offset-background web:transition-colors web:focus-visible:outline-none web:focus-visible:ring-2 web:focus-visible:ring-ring web:focus-visible:ring-offset-2" })
|
|
1756
1756
|
]
|
|
1757
1757
|
}
|
|
1758
1758
|
);
|
|
@@ -2212,12 +2212,13 @@ import { jsx as jsx54, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
|
2212
2212
|
var INITIAL_ROWS2 = 8;
|
|
2213
2213
|
var BATCH_ROWS2 = 8;
|
|
2214
2214
|
var WINDOW_SIZE2 = 5;
|
|
2215
|
+
var ALIGN = { left: "items-start", center: "items-center", right: "items-end" };
|
|
2215
2216
|
function defaultProductColumns(traits, context, options) {
|
|
2216
2217
|
const columns = [
|
|
2217
2218
|
{ id: "name", header: "Name", flex: 3, render: (doc) => /* @__PURE__ */ jsx54(ProductTitle, { doc, numberOfLines: 2 }) },
|
|
2218
2219
|
{ id: "sku", header: "SKU", flex: 1, render: (doc) => /* @__PURE__ */ jsx54(ProductSku, { doc }) },
|
|
2219
2220
|
{ id: "barcode", header: "Barcode", flex: 1, render: (doc) => /* @__PURE__ */ jsx54(Text, { children: traits.getBarcode(doc) ?? "\u2014" }) },
|
|
2220
|
-
{ id: "price", header: "Price", flex: 1, render: (doc) => /* @__PURE__ */ jsx54(ProductPrice, { doc, currencySymbol: options?.currencySymbol }) },
|
|
2221
|
+
{ id: "price", header: "Price", flex: 1, align: "right", render: (doc) => /* @__PURE__ */ jsx54(ProductPrice, { doc, currencySymbol: options?.currencySymbol }) },
|
|
2221
2222
|
{ id: "stock", header: "Stock", flex: 1, render: (doc) => /* @__PURE__ */ jsx54(ProductStockBadge, { doc, showQuantity: true, showAsOf: false }) },
|
|
2222
2223
|
{ id: "category", header: "Category", flex: 2, render: (doc) => /* @__PURE__ */ jsx54(Text, { children: traits.getCategoryNames(doc).join(", ") || "\u2014" }) }
|
|
2223
2224
|
];
|
|
@@ -2278,6 +2279,8 @@ function ProductTable({
|
|
|
2278
2279
|
TableHead,
|
|
2279
2280
|
{
|
|
2280
2281
|
style: { flex: column.flex ?? 1 },
|
|
2282
|
+
className: cn45("h-9 justify-center px-3 py-0", column.align && ALIGN[column.align]),
|
|
2283
|
+
"aria-label": column.hideHeader ? column.header : void 0,
|
|
2281
2284
|
...column.sortValue ? { "aria-sort": activeSort?.field === column.id ? activeSort.dir === "asc" ? "ascending" : "descending" : "none" } : {},
|
|
2282
2285
|
children: column.sortValue ? /* @__PURE__ */ jsx54(
|
|
2283
2286
|
Pressable10,
|
|
@@ -2286,12 +2289,12 @@ function ProductTable({
|
|
|
2286
2289
|
accessibilityLabel: "Sort by " + column.header,
|
|
2287
2290
|
testID: "product-table-sort-" + column.id,
|
|
2288
2291
|
onPress: () => changeSort(column.id),
|
|
2289
|
-
children: /* @__PURE__ */ jsxs15(Text, { children: [
|
|
2290
|
-
column.header,
|
|
2292
|
+
children: /* @__PURE__ */ jsxs15(Text, { numberOfLines: 1, children: [
|
|
2293
|
+
column.hideHeader ? "" : column.header,
|
|
2291
2294
|
activeSort?.field === column.id ? activeSort.dir === "asc" ? " \u25B2" : " \u25BC" : ""
|
|
2292
2295
|
] })
|
|
2293
2296
|
}
|
|
2294
|
-
) : /* @__PURE__ */ jsx54(Text, { children: column.header })
|
|
2297
|
+
) : /* @__PURE__ */ jsx54(Text, { numberOfLines: 1, children: column.hideHeader ? "" : column.header })
|
|
2295
2298
|
},
|
|
2296
2299
|
column.id
|
|
2297
2300
|
)) }) }),
|
|
@@ -2305,7 +2308,15 @@ function ProductTable({
|
|
|
2305
2308
|
windowSize: WINDOW_SIZE2,
|
|
2306
2309
|
renderItem: ({ item, index }) => {
|
|
2307
2310
|
const key = String(item.id ?? index);
|
|
2308
|
-
const row = /* @__PURE__ */ jsx54(TableRow, { testID: onSelect ? void 0 : "product-row-" + key, children: resolvedColumns.map((column) => /* @__PURE__ */ jsx54(
|
|
2311
|
+
const row = /* @__PURE__ */ jsx54(TableRow, { testID: onSelect ? void 0 : "product-row-" + key, children: resolvedColumns.map((column) => /* @__PURE__ */ jsx54(
|
|
2312
|
+
TableCell,
|
|
2313
|
+
{
|
|
2314
|
+
style: { flex: column.flex ?? 1 },
|
|
2315
|
+
className: cn45("px-3 py-1.5", column.align && ALIGN[column.align]),
|
|
2316
|
+
children: column.render(item)
|
|
2317
|
+
},
|
|
2318
|
+
column.id
|
|
2319
|
+
)) });
|
|
2309
2320
|
return onSelect ? /* @__PURE__ */ jsx54(Pressable10, { accessibilityRole: "button", testID: "product-row-" + key, onPress: () => onSelect(item), children: row }) : row;
|
|
2310
2321
|
}
|
|
2311
2322
|
}
|
|
@@ -2952,6 +2963,7 @@ function CartTotal({
|
|
|
2952
2963
|
locale,
|
|
2953
2964
|
className,
|
|
2954
2965
|
afterSubtotal,
|
|
2966
|
+
showTotal = true,
|
|
2955
2967
|
...props
|
|
2956
2968
|
}) {
|
|
2957
2969
|
return /* @__PURE__ */ jsxs23(VStack, { space: "none", className: cn54("gap-1.5 px-3 py-3", className), ...props, children: [
|
|
@@ -2971,9 +2983,9 @@ function CartTotal({
|
|
|
2971
2983
|
/* @__PURE__ */ jsx66(Text, { className: "text-sm text-muted-foreground", children: taxInclusive ? `incl. ${line.label}` : line.label }),
|
|
2972
2984
|
/* @__PURE__ */ jsx66(Text, { className: "text-sm", children: formatMoney3(line.amount, locale) ?? "\u2014" })
|
|
2973
2985
|
] }, index)),
|
|
2974
|
-
/* @__PURE__ */ jsxs23(HStack, { space: "none", className: "mt-1.5 justify-between border-t border-border pt-2", children: [
|
|
2975
|
-
/* @__PURE__ */ jsx66(Text, { className: "font-
|
|
2976
|
-
/* @__PURE__ */ jsx66(Text, { className: "font-
|
|
2986
|
+
showTotal && /* @__PURE__ */ jsxs23(HStack, { space: "none", className: "mt-1.5 justify-between border-t border-border pt-2", children: [
|
|
2987
|
+
/* @__PURE__ */ jsx66(Text, { className: "font-semibold", children: "Total" }),
|
|
2988
|
+
/* @__PURE__ */ jsx66(Text, { className: "font-semibold", children: formatMoney3(total, locale) ?? "\u2014" })
|
|
2977
2989
|
] })
|
|
2978
2990
|
] });
|
|
2979
2991
|
}
|
|
@@ -2993,6 +3005,7 @@ function CartPanel({
|
|
|
2993
3005
|
header,
|
|
2994
3006
|
afterItems,
|
|
2995
3007
|
footer,
|
|
3008
|
+
footerClassName,
|
|
2996
3009
|
emptyState,
|
|
2997
3010
|
className,
|
|
2998
3011
|
...props
|
|
@@ -3004,7 +3017,7 @@ function CartPanel({
|
|
|
3004
3017
|
hasItems ? items.map((item, index) => /* @__PURE__ */ jsx67(View35, { children: renderItem(item, index) }, keyExtractor ? keyExtractor(item, index) : defaultKey(item, index))) : emptyState ?? null,
|
|
3005
3018
|
afterItems
|
|
3006
3019
|
] }),
|
|
3007
|
-
footer && /* @__PURE__ */ jsx67(View35, { className: "border-t border-border px-3 py-2", children: footer })
|
|
3020
|
+
footer && /* @__PURE__ */ jsx67(View35, { className: cn55("border-t border-border px-3 py-2", footerClassName), children: footer })
|
|
3008
3021
|
] });
|
|
3009
3022
|
}
|
|
3010
3023
|
|
|
@@ -3141,7 +3154,7 @@ function CartFoot({ total, onCheckout, actions = [], disabled = false, locale, c
|
|
|
3141
3154
|
"aria-expanded": open,
|
|
3142
3155
|
testID: "cart-foot-more",
|
|
3143
3156
|
onPress: () => setOpen((value) => !value),
|
|
3144
|
-
className: "
|
|
3157
|
+
className: "h-11 w-11 self-center items-center justify-center rounded-md border border-border bg-card",
|
|
3145
3158
|
children: /* @__PURE__ */ jsx71(Text20, { className: "text-lg text-foreground", children: "\u22EE" })
|
|
3146
3159
|
}
|
|
3147
3160
|
) : null,
|
|
@@ -3152,7 +3165,7 @@ function CartFoot({ total, onCheckout, actions = [], disabled = false, locale, c
|
|
|
3152
3165
|
testID: "cart-checkout",
|
|
3153
3166
|
disabled,
|
|
3154
3167
|
onPress: onCheckout,
|
|
3155
|
-
className: cn59("min-h-
|
|
3168
|
+
className: cn59("min-h-14 flex-1 justify-center rounded-md bg-primary px-4 py-3", disabled && "opacity-50"),
|
|
3156
3169
|
children: /* @__PURE__ */ jsx71(Text20, { className: "text-center font-semibold text-primary-foreground", children: `Checkout ${formatMoney4(total, locale) ?? "\u2014"}` })
|
|
3157
3170
|
}
|
|
3158
3171
|
)
|
|
@@ -3170,7 +3183,7 @@ function SearchInput({ value, onChangeText, className, placeholder = "Search..."
|
|
|
3170
3183
|
const labelId = useId();
|
|
3171
3184
|
const [focused, setFocused] = useState10(false);
|
|
3172
3185
|
return /* @__PURE__ */ jsxs27(HStack, { space: "sm", className: cn60(
|
|
3173
|
-
"rounded-lg border bg-card px-3
|
|
3186
|
+
"h-11 items-center rounded-lg border bg-card px-3",
|
|
3174
3187
|
focused ? "border-ring" : "border-border",
|
|
3175
3188
|
className
|
|
3176
3189
|
), children: [
|
|
@@ -6847,6 +6860,7 @@ function Cart({
|
|
|
6847
6860
|
quickDiscounts,
|
|
6848
6861
|
taxClasses,
|
|
6849
6862
|
afterSubtotal,
|
|
6863
|
+
showTotal = true,
|
|
6850
6864
|
couponDiscountMinor,
|
|
6851
6865
|
orderActions = true,
|
|
6852
6866
|
checkout,
|
|
@@ -7007,6 +7021,7 @@ function Cart({
|
|
|
7007
7021
|
{
|
|
7008
7022
|
items: order.lineItems,
|
|
7009
7023
|
renderItem,
|
|
7024
|
+
footerClassName: "px-2 py-2",
|
|
7010
7025
|
emptyState: empty ? /* @__PURE__ */ jsxs74(View83, { testID: "cart-empty", className: "flex-1 items-center justify-center gap-3 px-3 py-6", children: [
|
|
7011
7026
|
emptyIcon === null ? null : /* @__PURE__ */ jsx122(
|
|
7012
7027
|
View83,
|
|
@@ -7082,16 +7097,18 @@ function Cart({
|
|
|
7082
7097
|
) : null
|
|
7083
7098
|
] }) : null
|
|
7084
7099
|
] }),
|
|
7085
|
-
footer: empty ? void 0 : /* @__PURE__ */ jsxs74(View83, { testID: "cart-footer", className: "gap-
|
|
7100
|
+
footer: empty ? void 0 : /* @__PURE__ */ jsxs74(View83, { testID: "cart-footer", className: "gap-2", children: [
|
|
7086
7101
|
/* @__PURE__ */ jsx122(
|
|
7087
7102
|
CartTotal,
|
|
7088
7103
|
{
|
|
7104
|
+
className: "px-0 py-0",
|
|
7089
7105
|
subtotal: money(totals.subtotalMinor),
|
|
7090
7106
|
total: money(totals.totalMinor),
|
|
7091
7107
|
discount: money(couponDiscountMinor === void 0 ? totals.discountMinor : Math.max(0, totals.discountMinor - couponDiscountMinor)),
|
|
7092
7108
|
taxLines: taxRows,
|
|
7093
7109
|
taxInclusive: totals.taxInclusive,
|
|
7094
|
-
afterSubtotal
|
|
7110
|
+
afterSubtotal,
|
|
7111
|
+
showTotal
|
|
7095
7112
|
}
|
|
7096
7113
|
),
|
|
7097
7114
|
sale.error ? /* @__PURE__ */ jsx122(Text44, { accessibilityRole: "alert", className: "text-destructive", children: sale.error }) : null,
|
|
@@ -8918,7 +8935,7 @@ function NavDrawer({ open, onOpenChange, items, activeId, onNavigate, header, te
|
|
|
8918
8935
|
{
|
|
8919
8936
|
testID: `${testID}-backdrop`,
|
|
8920
8937
|
accessibilityLabel: "Close menu",
|
|
8921
|
-
className: "flex-1 bg-
|
|
8938
|
+
className: "flex-1 bg-scrim",
|
|
8922
8939
|
onPress: close
|
|
8923
8940
|
}
|
|
8924
8941
|
)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tallyui/components",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.20.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Universal POS UI components for Tally UI",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -28,9 +28,9 @@
|
|
|
28
28
|
"directory": "packages/components"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
|
-
"@tallyui/core": "^3.
|
|
32
|
-
"@tallyui/primitives": "^3.
|
|
33
|
-
"@tallyui/theme": "^3.
|
|
31
|
+
"@tallyui/core": "^3.20.1",
|
|
32
|
+
"@tallyui/primitives": "^3.20.1",
|
|
33
|
+
"@tallyui/theme": "^3.20.1",
|
|
34
34
|
"react": ">=18",
|
|
35
35
|
"react-native": ">=0.74",
|
|
36
36
|
"react-native-svg": ">=15"
|
|
@@ -39,13 +39,13 @@
|
|
|
39
39
|
"class-variance-authority": "^0.7.1",
|
|
40
40
|
"i18next": "^26.7.1",
|
|
41
41
|
"react-i18next": "^17.1.12",
|
|
42
|
-
"@tallyui/pos": "3.
|
|
42
|
+
"@tallyui/pos": "3.20.1"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@tallyui/connector-medusa": "3.
|
|
46
|
-
"@tallyui/connector-vendure": "3.
|
|
47
|
-
"@tallyui/connector-woocommerce": "3.
|
|
48
|
-
"@tallyui/mock-api": "3.
|
|
45
|
+
"@tallyui/connector-medusa": "3.20.1",
|
|
46
|
+
"@tallyui/connector-vendure": "3.20.1",
|
|
47
|
+
"@tallyui/connector-woocommerce": "3.20.1",
|
|
48
|
+
"@tallyui/mock-api": "3.20.1",
|
|
49
49
|
"@types/react": ">=18",
|
|
50
50
|
"react": "^19.2.4",
|
|
51
51
|
"react-native-svg": "15.12.1",
|
package/src/cart/cart-foot.tsx
CHANGED
|
@@ -68,12 +68,12 @@ export function CartFoot({ total, onCheckout, actions = [], disabled = false, lo
|
|
|
68
68
|
{actions.length > 0 ? (
|
|
69
69
|
<Pressable ref={trigger} accessibilityRole="button" accessibilityLabel={MENU_LABEL} aria-haspopup="menu"
|
|
70
70
|
aria-expanded={open} testID="cart-foot-more" onPress={() => setOpen((value) => !value)}
|
|
71
|
-
className="
|
|
71
|
+
className="h-11 w-11 self-center items-center justify-center rounded-md border border-border bg-card">
|
|
72
72
|
<Text className="text-lg text-foreground">⋮</Text>
|
|
73
73
|
</Pressable>
|
|
74
74
|
) : null}
|
|
75
75
|
<Pressable accessibilityRole="button" testID="cart-checkout" disabled={disabled} onPress={onCheckout}
|
|
76
|
-
className={cn('min-h-
|
|
76
|
+
className={cn('min-h-14 flex-1 justify-center rounded-md bg-primary px-4 py-3', disabled && 'opacity-50')}>
|
|
77
77
|
<Text className="text-center font-semibold text-primary-foreground">{`Checkout ${formatMoney(total, locale) ?? '—'}`}</Text>
|
|
78
78
|
</Pressable>
|
|
79
79
|
</View>
|
package/src/cart/cart-panel.tsx
CHANGED
|
@@ -16,6 +16,8 @@ export interface CartPanelProps<T> extends Omit<VStackProps, 'children'> {
|
|
|
16
16
|
afterItems?: ReactNode;
|
|
17
17
|
/** Footer slot (e.g. totals, checkout button) */
|
|
18
18
|
footer?: ReactNode;
|
|
19
|
+
/** Classes for the footer's wrapper (default `border-t border-border px-3 py-2`). */
|
|
20
|
+
footerClassName?: string;
|
|
19
21
|
/** Content shown when items is empty */
|
|
20
22
|
emptyState?: ReactNode;
|
|
21
23
|
className?: string;
|
|
@@ -51,6 +53,7 @@ export function CartPanel<T>({
|
|
|
51
53
|
header,
|
|
52
54
|
afterItems,
|
|
53
55
|
footer,
|
|
56
|
+
footerClassName,
|
|
54
57
|
emptyState,
|
|
55
58
|
className,
|
|
56
59
|
...props
|
|
@@ -72,7 +75,7 @@ export function CartPanel<T>({
|
|
|
72
75
|
{afterItems}
|
|
73
76
|
</ScrollView>
|
|
74
77
|
|
|
75
|
-
{footer && <View className=
|
|
78
|
+
{footer && <View className={cn('border-t border-border px-3 py-2', footerClassName)}>{footer}</View>}
|
|
76
79
|
</VStack>
|
|
77
80
|
);
|
|
78
81
|
}
|
package/src/cart/cart-total.tsx
CHANGED
|
@@ -14,10 +14,12 @@ export interface CartTotalProps extends Omit<VStackProps, 'children'> {
|
|
|
14
14
|
className?: string;
|
|
15
15
|
/** Rows rendered directly under Subtotal, e.g. a platform's coupon chips. */
|
|
16
16
|
afterSubtotal?: ReactNode;
|
|
17
|
+
/** Draws the Total row. Pass `false` when the total shows elsewhere, e.g. v2's Checkout button. Default `true`. */
|
|
18
|
+
showTotal?: boolean;
|
|
17
19
|
}
|
|
18
20
|
|
|
19
21
|
/**
|
|
20
|
-
* Displays a cart summary: subtotal, optional discount, optional tax, and
|
|
22
|
+
* Displays a cart summary: subtotal, optional discount, optional tax, and an optional Total row, in the receipt's order.
|
|
21
23
|
*
|
|
22
24
|
* ```tsx
|
|
23
25
|
* <CartTotal subtotal={subtotal} discount={discount} taxLines={taxLines} total={total} />
|
|
@@ -32,6 +34,7 @@ export function CartTotal({
|
|
|
32
34
|
locale,
|
|
33
35
|
className,
|
|
34
36
|
afterSubtotal,
|
|
37
|
+
showTotal = true,
|
|
35
38
|
...props
|
|
36
39
|
}: CartTotalProps) {
|
|
37
40
|
return (
|
|
@@ -57,10 +60,10 @@ export function CartTotal({
|
|
|
57
60
|
</HStack>
|
|
58
61
|
))}
|
|
59
62
|
|
|
60
|
-
<HStack space="none" className="mt-1.5 justify-between border-t border-border pt-2">
|
|
61
|
-
<Text className="font-
|
|
62
|
-
<Text className="font-
|
|
63
|
-
</HStack>
|
|
63
|
+
{showTotal && <HStack space="none" className="mt-1.5 justify-between border-t border-border pt-2">
|
|
64
|
+
<Text className="font-semibold">Total</Text>
|
|
65
|
+
<Text className="font-semibold">{formatMoney(total, locale) ?? '—'}</Text>
|
|
66
|
+
</HStack>}
|
|
64
67
|
</VStack>
|
|
65
68
|
);
|
|
66
69
|
}
|
|
@@ -16,7 +16,7 @@ export function SearchInput({ value, onChangeText, className, placeholder = 'Sea
|
|
|
16
16
|
|
|
17
17
|
return (
|
|
18
18
|
<HStack space="sm" className={cn(
|
|
19
|
-
'rounded-lg border bg-card px-3
|
|
19
|
+
'h-11 items-center rounded-lg border bg-card px-3',
|
|
20
20
|
focused ? 'border-ring' : 'border-border',
|
|
21
21
|
className,
|
|
22
22
|
)}>
|
|
@@ -16,11 +16,18 @@ const BATCH_ROWS = 8;
|
|
|
16
16
|
// Keep nearby rows mounted without rendering the whole 2,000-product catalogue.
|
|
17
17
|
const WINDOW_SIZE = 5;
|
|
18
18
|
|
|
19
|
+
// Place column content horizontally inside column-direction Views.
|
|
20
|
+
const ALIGN = { left: 'items-start', center: 'items-center', right: 'items-end' } as const;
|
|
21
|
+
|
|
19
22
|
export interface ProductTableColumn<Doc = any> {
|
|
20
23
|
/** Stable id; the default columns use PRODUCT_SORT_FIELDS. */
|
|
21
24
|
id: string;
|
|
22
25
|
/** Header label. */
|
|
23
26
|
header: string;
|
|
27
|
+
/** Places the head and the cells' content; default left (WCPOS v2 column-style). */
|
|
28
|
+
align?: 'left' | 'center' | 'right';
|
|
29
|
+
/** Draws no head label; `header` stays the head's accessible name (v2's image column). */
|
|
30
|
+
hideHeader?: boolean;
|
|
24
31
|
render: (doc: Doc) => ReactNode;
|
|
25
32
|
/** The value the header sort orders by; omit to make the column unsortable. */
|
|
26
33
|
sortValue?: (doc: Doc) => ProductSortValue;
|
|
@@ -56,7 +63,7 @@ export function defaultProductColumns(
|
|
|
56
63
|
{ id: 'name', header: 'Name', flex: 3, render: (doc) => <ProductTitle doc={doc} numberOfLines={2} /> },
|
|
57
64
|
{ id: 'sku', header: 'SKU', flex: 1, render: (doc) => <ProductSku doc={doc} /> },
|
|
58
65
|
{ id: 'barcode', header: 'Barcode', flex: 1, render: (doc) => <Text>{traits.getBarcode(doc) ?? '—'}</Text> },
|
|
59
|
-
{ id: 'price', header: 'Price', flex: 1, render: (doc) => <ProductPrice doc={doc} currencySymbol={options?.currencySymbol} /> },
|
|
66
|
+
{ id: 'price', header: 'Price', flex: 1, align: 'right', render: (doc) => <ProductPrice doc={doc} currencySymbol={options?.currencySymbol} /> },
|
|
60
67
|
{ id: 'stock', header: 'Stock', flex: 1, render: (doc) => <ProductStockBadge doc={doc} showQuantity showAsOf={false} /> },
|
|
61
68
|
{ id: 'category', header: 'Category', flex: 2, render: (doc) => <Text>{traits.getCategoryNames(doc).join(', ') || '—'}</Text> },
|
|
62
69
|
];
|
|
@@ -110,14 +117,16 @@ export function ProductTable({
|
|
|
110
117
|
<TableRow>
|
|
111
118
|
{resolvedColumns.map((column) => (
|
|
112
119
|
<TableHead key={column.id} style={{ flex: column.flex ?? 1 }}
|
|
120
|
+
className={cn('h-9 justify-center px-3 py-0', column.align && ALIGN[column.align])}
|
|
121
|
+
aria-label={column.hideHeader ? column.header : undefined}
|
|
113
122
|
{...(column.sortValue ? { 'aria-sort': activeSort?.field === column.id
|
|
114
123
|
? (activeSort.dir === 'asc' ? 'ascending' : 'descending') : 'none' } : {})}>
|
|
115
124
|
{column.sortValue ? (
|
|
116
125
|
<Pressable accessibilityRole="button" accessibilityLabel={'Sort by ' + column.header}
|
|
117
126
|
testID={'product-table-sort-' + column.id} onPress={() => changeSort(column.id)}>
|
|
118
|
-
<Text>{column.header}{activeSort?.field === column.id ? (activeSort.dir === 'asc' ? ' ▲' : ' ▼') : ''}</Text>
|
|
127
|
+
<Text numberOfLines={1}>{column.hideHeader ? '' : column.header}{activeSort?.field === column.id ? (activeSort.dir === 'asc' ? ' ▲' : ' ▼') : ''}</Text>
|
|
119
128
|
</Pressable>
|
|
120
|
-
) : <Text>{column.header}</Text>}
|
|
129
|
+
) : <Text numberOfLines={1}>{column.hideHeader ? '' : column.header}</Text>}
|
|
121
130
|
</TableHead>
|
|
122
131
|
))}
|
|
123
132
|
</TableRow>
|
|
@@ -134,7 +143,8 @@ export function ProductTable({
|
|
|
134
143
|
const row = (
|
|
135
144
|
<TableRow testID={onSelect ? undefined : 'product-row-' + key}>
|
|
136
145
|
{resolvedColumns.map((column) => (
|
|
137
|
-
<TableCell key={column.id} style={{ flex: column.flex ?? 1 }}
|
|
146
|
+
<TableCell key={column.id} style={{ flex: column.flex ?? 1 }}
|
|
147
|
+
className={cn('px-3 py-1.5', column.align && ALIGN[column.align])}>{column.render(item)}</TableCell>
|
|
138
148
|
))}
|
|
139
149
|
</TableRow>
|
|
140
150
|
);
|
package/src/sale/cart.tsx
CHANGED
|
@@ -13,7 +13,7 @@ import { LinePopover } from './line-popover';
|
|
|
13
13
|
import { ShoppingCartIcon } from '../ui';
|
|
14
14
|
|
|
15
15
|
/** `taxLabel` names each tax row; VAT isn't universal, so a platform passes its own (medusapos passes `VAT ${rate}%`). */
|
|
16
|
-
export function Cart({ sale, taxLabel = (ratePpm: number) => `Tax ${ratePpm / 10000}%`, canEditPrice = false, onPriceChange, quickDiscounts, taxClasses, afterSubtotal, couponDiscountMinor, orderActions = true, checkout, lineEditor = 'inline',
|
|
16
|
+
export function Cart({ sale, taxLabel = (ratePpm: number) => `Tax ${ratePpm / 10000}%`, canEditPrice = false, onPriceChange, quickDiscounts, taxClasses, afterSubtotal, showTotal = true, couponDiscountMinor, orderActions = true, checkout, lineEditor = 'inline',
|
|
17
17
|
columns,
|
|
18
18
|
emptyIcon = <ShoppingCartIcon size={48} />, emptyText = 'Tap a product to start a sale' }:
|
|
19
19
|
{ sale: ReturnType<typeof useSale>; taxLabel?: (ratePpm: number) => string;
|
|
@@ -26,6 +26,8 @@ export function Cart({ sale, taxLabel = (ratePpm: number) => `Tax ${ratePpm / 10
|
|
|
26
26
|
quickDiscounts?: readonly number[];
|
|
27
27
|
/** Rows under the totals' Subtotal, e.g. the platform's coupon chips (passed to CartTotal). */
|
|
28
28
|
afterSubtotal?: ReactNode;
|
|
29
|
+
/** Draws the totals' Total row. Pass `false` for v2's cart, where the total is on the Checkout button (`checkout`). Default `true`. */
|
|
30
|
+
showTotal?: boolean;
|
|
29
31
|
/** The coupon amount the app itemises in `afterSubtotal` (e.g. Σ `order.display.coupons`), in integer minor units of
|
|
30
32
|
* the order's currency, in the display mode. When given, the Discount row shows the other discounts only (the
|
|
31
33
|
* totals' discount minus this) and is hidden when they come to 0. Absent: the Discount row is the whole discount. */
|
|
@@ -128,6 +130,7 @@ export function Cart({ sale, taxLabel = (ratePpm: number) => `Tax ${ratePpm / 10
|
|
|
128
130
|
return <View dataSet={{ print: 'hide' }} className="flex-1 min-h-0" onLayout={(event) => setCartWidth(event.nativeEvent.layout.width)}>
|
|
129
131
|
{empty ? null : <CartColumnHeads showPrice={showPrice} columns={columns} />}
|
|
130
132
|
<CartPanel items={order.lineItems} renderItem={renderItem}
|
|
133
|
+
footerClassName="px-2 py-2"
|
|
131
134
|
emptyState={empty ? <View testID="cart-empty" className="flex-1 items-center justify-center gap-3 px-3 py-6">
|
|
132
135
|
{emptyIcon === null ? null : <View aria-hidden accessibilityElementsHidden importantForAccessibility="no-hide-descendants"
|
|
133
136
|
className="text-muted-foreground">{emptyIcon}</View>}
|
|
@@ -164,11 +167,11 @@ export function Cart({ sale, taxLabel = (ratePpm: number) => `Tax ${ratePpm / 10
|
|
|
164
167
|
className="self-start rounded-md border border-border bg-card px-4 py-2 min-h-11 justify-center">
|
|
165
168
|
<Text className="text-foreground">Add charge</Text></Pressable> : null}
|
|
166
169
|
</View> : null}</>}
|
|
167
|
-
footer={empty ? undefined : <View testID="cart-footer" className="gap-
|
|
170
|
+
footer={empty ? undefined : <View testID="cart-footer" className="gap-2">
|
|
168
171
|
{/* Exclusive: subtotal − discount + tax = total. Inclusive: subtotal − discount = total, the tax "incl.", not added. */}
|
|
169
|
-
<CartTotal subtotal={money(totals.subtotalMinor)} total={money(totals.totalMinor)}
|
|
172
|
+
<CartTotal className="px-0 py-0" subtotal={money(totals.subtotalMinor)} total={money(totals.totalMinor)}
|
|
170
173
|
discount={money(couponDiscountMinor === undefined ? totals.discountMinor : Math.max(0, totals.discountMinor - couponDiscountMinor))}
|
|
171
|
-
taxLines={taxRows} taxInclusive={totals.taxInclusive} afterSubtotal={afterSubtotal} />
|
|
174
|
+
taxLines={taxRows} taxInclusive={totals.taxInclusive} afterSubtotal={afterSubtotal} showTotal={showTotal} />
|
|
172
175
|
{sale.error ? <Text accessibilityRole="alert" className="text-destructive">{sale.error}</Text> : null}
|
|
173
176
|
{checkout ? <CartFoot total={money(totals.totalMinor)} onCheckout={checkout.onCheckout} actions={checkout.actions}
|
|
174
177
|
disabled={!order.lineItems.length} /> : <View className="flex-row gap-3">
|
package/src/shell/nav-drawer.tsx
CHANGED
|
@@ -106,7 +106,7 @@ export function NavDrawer({ open, onOpenChange, items, activeId, onNavigate, hea
|
|
|
106
106
|
<Pressable
|
|
107
107
|
testID={`${testID}-backdrop`}
|
|
108
108
|
accessibilityLabel="Close menu"
|
|
109
|
-
className="flex-1 bg-
|
|
109
|
+
className="flex-1 bg-scrim"
|
|
110
110
|
onPress={close}
|
|
111
111
|
/>
|
|
112
112
|
</Animated.View>
|
package/src/ui/dialog/index.tsx
CHANGED
package/src/ui/slider/index.tsx
CHANGED
|
@@ -19,10 +19,10 @@ const Slider = React.forwardRef<
|
|
|
19
19
|
)}
|
|
20
20
|
{...props}
|
|
21
21
|
>
|
|
22
|
-
<SliderPrimitive.Track className="relative h-2 w-full grow overflow-hidden rounded-full bg-
|
|
22
|
+
<SliderPrimitive.Track className="relative h-2 w-full grow overflow-hidden rounded-full bg-muted">
|
|
23
23
|
<SliderPrimitive.Range className="absolute h-full bg-primary" />
|
|
24
24
|
</SliderPrimitive.Track>
|
|
25
|
-
<SliderPrimitive.Thumb className="absolute top-0 -ml-2.5 block h-5 w-5 rounded-full border-2 border-primary bg-
|
|
25
|
+
<SliderPrimitive.Thumb className="absolute top-0 -ml-2.5 block h-5 w-5 rounded-full border-2 border-primary bg-card web:ring-offset-background web:transition-colors web:focus-visible:outline-none web:focus-visible:ring-2 web:focus-visible:ring-ring web:focus-visible:ring-offset-2" />
|
|
26
26
|
</SliderPrimitive.Root>
|
|
27
27
|
);
|
|
28
28
|
});
|
package/src/ui/switch/index.tsx
CHANGED
|
@@ -22,7 +22,7 @@ const Switch = React.forwardRef<React.ComponentRef<typeof SwitchPrimitive.Root>,
|
|
|
22
22
|
ref={ref}
|
|
23
23
|
className={cn(
|
|
24
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`,
|
|
25
|
-
props.checked ? 'bg-primary' : 'bg-
|
|
25
|
+
props.checked ? 'bg-primary' : 'bg-border',
|
|
26
26
|
props.disabled && 'web:cursor-not-allowed opacity-50',
|
|
27
27
|
className,
|
|
28
28
|
)}
|