@tallyui/components 5.2.0 → 5.3.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.
package/dist/index.d.ts CHANGED
@@ -1186,6 +1186,9 @@ interface CartLineProps extends Omit<HStackProps, 'children'> {
1186
1186
  picking?: boolean;
1187
1187
  locale?: string;
1188
1188
  className?: string;
1189
+ /** The line strip's press target (`CartLineStrip`): wraps the Total cell's content, or with Total hidden the last visible
1190
+ * cell's that holds no button of its own (not Quantity, nor Price while `priceSlot` is set). */
1191
+ wrapTotal?: (content: ReactNode) => ReactNode;
1189
1192
  }
1190
1193
  /**
1191
1194
  * A single cart line in the columns of CartColumnHeads: quantity, the name with its attributes, the unit price
@@ -1195,7 +1198,7 @@ interface CartLineProps extends Omit<HStackProps, 'children'> {
1195
1198
  * <CartLine name="Coffee" quantity={2} unitPrice={unitPrice} lineTotal={lineTotal} />
1196
1199
  * ```
1197
1200
  */
1198
- declare function CartLine({ name, attributes, quantity, unitPrice, regularUnitPrice, lineTotal, showPrice, quantitySlot, priceSlot, columns, sku, imageUrl, onSplit, picking, locale, className, ...props }: CartLineProps): react_jsx_runtime.JSX.Element;
1201
+ declare function CartLine({ name, attributes, quantity, unitPrice, regularUnitPrice, lineTotal, showPrice, quantitySlot, priceSlot, columns, sku, imageUrl, onSplit, picking, locale, className, wrapTotal, ...props }: CartLineProps): react_jsx_runtime.JSX.Element;
1199
1202
 
1200
1203
  interface CartColumnsFormProps extends Omit<ViewProps, 'children'> {
1201
1204
  /** The saved columns (default `{}`, today's look). */
package/dist/index.js CHANGED
@@ -3718,6 +3718,7 @@ function CameraScannerPanel({
3718
3718
  }
3719
3719
 
3720
3720
  // src/cart/cart-line.tsx
3721
+ import { Children as Children2, cloneElement as cloneElement2 } from "react";
3721
3722
  import { Pressable as Pressable16, View as View41 } from "react-native";
3722
3723
  import { useFormatMoney as useFormatMoney2 } from "@tallyui/core";
3723
3724
  import { Image as Image4 } from "@tallyui/primitives";
@@ -3991,6 +3992,7 @@ function CartLine({
3991
3992
  picking = false,
3992
3993
  locale,
3993
3994
  className,
3995
+ wrapTotal,
3994
3996
  ...props
3995
3997
  }) {
3996
3998
  const formatMoney2 = useFormatMoney2();
@@ -3998,6 +4000,8 @@ function CartLine({
3998
4000
  const options = Object.entries(attributes ?? {}).map(([key, value]) => `${key}: ${value}`).join(" \xB7 ");
3999
4001
  const sameCurrency = regularUnitPrice?.currency === unitPrice.currency;
4000
4002
  const regular = (columns?.price?.onSale ?? true) && regularUnitPrice && sameCurrency && regularUnitPrice.amount > unitPrice.amount ? formatMoney2(regularUnitPrice, locale) ?? "\u2014" : null;
4003
+ const slots = cartColumnSlots(columns, { showPrice });
4004
+ const target = slots.includes("total") ? "total" : slots.filter((id) => id !== "quantity" && !(id === "price" && priceSlot)).pop();
4001
4005
  const cells = {
4002
4006
  fill: /* @__PURE__ */ jsx96(View41, { className: "flex-1" }, "fill"),
4003
4007
  quantity: /* @__PURE__ */ jsxs40(View41, { className: (picking ? CART_PICKING_QUANTITY : CART_COLUMNS.quantity).cell, children: [
@@ -4046,7 +4050,7 @@ function CartLine({
4046
4050
  regularPrice: /* @__PURE__ */ jsx96(View41, { className: CART_COLUMNS.regularPrice.cell, children: /* @__PURE__ */ jsx96(Text, { testID: "cart-line-regular-price", className: "text-right text-sm tabular-nums text-muted-foreground", children: formatMoney2(regularUnitPrice && sameCurrency ? regularUnitPrice : unitPrice, locale) ?? "\u2014" }) }, "regularPrice"),
4047
4051
  total: /* @__PURE__ */ jsx96(View41, { className: CART_COLUMNS.total.cell, children: /* @__PURE__ */ jsx96(Text, { className: "text-right text-sm font-semibold tabular-nums", children: formatMoney2(lineTotal, locale) ?? "\u2014" }) }, "total")
4048
4052
  };
4049
- return /* @__PURE__ */ jsx96(HStack, { space: "none", className: cn60("py-2.5", className), ...props, children: cartColumnSlots(columns, { showPrice }).map((id) => cells[id]) });
4053
+ return /* @__PURE__ */ jsx96(HStack, { space: "none", className: cn60("py-2.5", className), ...props, children: slots.map((id) => wrapTotal && id === target ? cloneElement2(cells[id], {}, wrapTotal(Children2.toArray(cells[id].props.children))) : cells[id]) });
4050
4054
  }
4051
4055
 
4052
4056
  // src/cart/cart-columns-form.tsx
@@ -9539,8 +9543,24 @@ function CartChargeLine({ name, price, total, showPrice = true, columns, locale,
9539
9543
 
9540
9544
  // src/cart/cart-line-strip.tsx
9541
9545
  import { useRef as useRef20, useState as useState46 } from "react";
9542
- import { Animated as Animated8, Platform as Platform17, Pressable as Pressable42, View as View101 } from "react-native";
9546
+ import { Animated as Animated8, PanResponder, Platform as Platform17, Pressable as Pressable42, View as View101 } from "react-native";
9547
+
9548
+ // src/cart/line-strip-geometry.ts
9549
+ var REMOVE_SHARE = 0.6;
9550
+ var REMOVE_BAND = 56;
9551
+ var REMOVE_FLICK = 800;
9552
+ function removePoint(rowWidth, stripWidth) {
9553
+ return Math.max(stripWidth + REMOVE_BAND, Math.round(rowWidth * REMOVE_SHARE));
9554
+ }
9555
+ function releaseOutcome({ revealed, velocityX, rowWidth, stripWidth }) {
9556
+ if (revealed >= removePoint(rowWidth, stripWidth)) return "remove";
9557
+ if (velocityX <= -REMOVE_FLICK && revealed > stripWidth) return "remove";
9558
+ return revealed > stripWidth / 2 ? "open" : "home";
9559
+ }
9560
+
9561
+ // src/cart/cart-line-strip.tsx
9543
9562
  import { jsx as jsx168, jsxs as jsxs105 } from "react/jsx-runtime";
9563
+ var STILL_MS = 50;
9544
9564
  function CartLineStrip({ name, onEdit, onRemove, children }) {
9545
9565
  const reduced = useReducedMotion() !== false;
9546
9566
  const offset = useRef20(new Animated8.Value(0)).current;
@@ -9579,6 +9599,33 @@ function CartLineStrip({ name, onEdit, onRemove, children }) {
9579
9599
  settle(false);
9580
9600
  });
9581
9601
  };
9602
+ const drag = useRef20({ row: 0, strip: 0, base: 0, claimed: 0, settle, leave });
9603
+ Object.assign(drag.current, { row: rowWidth ?? 0, strip: stripWidth, settle, leave });
9604
+ const clamp = (x) => Math.min(0, Math.max(-drag.current.row, x));
9605
+ const pan = useRef20(PanResponder.create({
9606
+ onMoveShouldSetPanResponder: (_, { dx, dy }) => !leaving.current && drag.current.row > 0 && Math.abs(dx) > 8 && Math.abs(dx) > Math.abs(dy) && (drag.current.claimed = dx, true),
9607
+ onPanResponderGrant: () => {
9608
+ const { claimed } = drag.current;
9609
+ drag.current.base = (opened.current ? -drag.current.strip : 0) + claimed;
9610
+ drag.current.claimed = 0;
9611
+ offset.stopAnimation((value) => {
9612
+ drag.current.base = value + claimed;
9613
+ });
9614
+ },
9615
+ onPanResponderMove: (_, { dx }) => offset.setValue(clamp(drag.current.base + dx)),
9616
+ onPanResponderRelease: (event, { dx, vx, _accountsForMovesUpTo }) => {
9617
+ drag.current.claimed = 0;
9618
+ const { row: row2, strip, base } = drag.current;
9619
+ const still = event.touchHistory.mostRecentTimeStamp - _accountsForMovesUpTo > STILL_MS;
9620
+ const outcome = releaseOutcome({ revealed: -clamp(base + dx), velocityX: still ? 0 : vx * 1e3, rowWidth: row2, stripWidth: strip });
9621
+ if (outcome === "remove") drag.current.leave();
9622
+ else drag.current.settle(outcome === "open");
9623
+ },
9624
+ onPanResponderTerminate: () => {
9625
+ drag.current.claimed = 0;
9626
+ drag.current.settle(opened.current);
9627
+ }
9628
+ })).current;
9582
9629
  const peek = (on) => {
9583
9630
  if (opened.current || leaving.current || reduced) return;
9584
9631
  if (on) Animated8.spring(offset, { ...PEEK_SPRING, toValue: -PEEK, useNativeDriver: Platform17.OS !== "web" }).start();
@@ -9615,7 +9662,7 @@ function CartLineStrip({ name, onEdit, onRemove, children }) {
9615
9662
  importantForAccessibility: open ? "auto" : "no-hide-descendants",
9616
9663
  "aria-hidden": !open,
9617
9664
  children: /* @__PURE__ */ jsxs105(View101, { testID: "cart-line-strip-actions", className: "flex-row items-stretch", onLayout: (event) => setStripWidth(event.nativeEvent.layout.width), children: [
9618
- /* @__PURE__ */ jsx168(
9665
+ onEdit ? /* @__PURE__ */ jsx168(
9619
9666
  Button,
9620
9667
  {
9621
9668
  variant: "default",
@@ -9629,7 +9676,7 @@ function CartLineStrip({ name, onEdit, onRemove, children }) {
9629
9676
  },
9630
9677
  children: /* @__PURE__ */ jsx168(Text, { children: "Edit" })
9631
9678
  }
9632
- ),
9679
+ ) : null,
9633
9680
  /* @__PURE__ */ jsx168(
9634
9681
  Button,
9635
9682
  {
@@ -9644,7 +9691,7 @@ function CartLineStrip({ name, onEdit, onRemove, children }) {
9644
9691
  ] })
9645
9692
  }
9646
9693
  ),
9647
- /* @__PURE__ */ jsx168(Animated8.View, { className: "bg-background", style: { transform: [{ translateX: shown2 }] }, children: children(wrapTotal) })
9694
+ /* @__PURE__ */ jsx168(Animated8.View, { ...pan.panHandlers, className: "bg-background", style: { transform: [{ translateX: shown2 }] }, children: children(wrapTotal) })
9648
9695
  ] });
9649
9696
  }
9650
9697
 
@@ -10542,7 +10589,7 @@ function Cart({
10542
10589
  const [priceError, setPriceError] = useState51(null);
10543
10590
  const [openForm, setForm] = useState51(null);
10544
10591
  const form = picker ? null : openForm;
10545
- const ChargeStrip = picker ? ReadOnlyStrip : CartLineStrip;
10592
+ const Strip = picker ? ReadOnlyStrip : CartLineStrip;
10546
10593
  const chargesOffered = (sale.capabilities?.orderCreate ?? 0) >= 5;
10547
10594
  const shippingNoTax = (sale.capabilities?.orderCreate ?? 0) >= 6;
10548
10595
  const showOrderDiscount = !picker && order.lineItems.length > 0 && (orderActions || orderDiscountChips && order.discounts.length > 0);
@@ -10569,10 +10616,14 @@ function Cart({
10569
10616
  if (refused === null) setPriceError((now) => now?.lineId === line.id ? null : now);
10570
10617
  return refused;
10571
10618
  };
10619
+ const removeLine = (id) => {
10620
+ sale.remove(id);
10621
+ return sale.removal("line", id) ? "refused" : null;
10622
+ };
10572
10623
  const unpaid = (line) => line.quantity - (picker?.paid[line.id] ?? 0);
10573
10624
  const pickable = (line) => Number.isInteger(line.quantity) && line.quantity > 0 && display(line.id).amountMinor >= 0 && unpaid(line) > 0;
10574
10625
  const renderItem = (line) => /* @__PURE__ */ jsxs111(Fragment38, { children: [
10575
- /* @__PURE__ */ jsx174(
10626
+ /* @__PURE__ */ jsx174(Strip, { name: line.name, onRemove: () => removeLine(line.id), children: (wrapTotal) => /* @__PURE__ */ jsx174(
10576
10627
  CartLine,
10577
10628
  {
10578
10629
  name: line.name,
@@ -10631,9 +10682,10 @@ function Cart({
10631
10682
  commit: lineCommit,
10632
10683
  onCloseRefused: (message) => setPriceError({ lineId: line.id, message })
10633
10684
  }
10634
- ) : void 0
10685
+ ) : void 0,
10686
+ wrapTotal
10635
10687
  }
10636
- ),
10688
+ ) }),
10637
10689
  splitError?.lineId === line.id ? /* @__PURE__ */ jsx174(
10638
10690
  Text47,
10639
10691
  {
@@ -10736,7 +10788,7 @@ function Cart({
10736
10788
  identity: order.id,
10737
10789
  renderItem: (charge, index) => /* @__PURE__ */ jsxs111(View106, { testID: `cart-${kind === "fees" ? "fee" : "shipping"}-${index}`, children: [
10738
10790
  /* @__PURE__ */ jsx174(
10739
- ChargeStrip,
10791
+ Strip,
10740
10792
  {
10741
10793
  name: charge.name,
10742
10794
  onEdit: () => setForm({ type: "edit-charge", kind, id: charge.id }),
@@ -12769,7 +12821,7 @@ function SyncStatus({ state, registerState, pluginName = "the POS plugin", pullN
12769
12821
  // src/sale/orders-list.tsx
12770
12822
  import { useEffect as useEffect24, useId as useId4, useRef as useRef26, useState as useState57 } from "react";
12771
12823
  import { Pressable as Pressable56, ScrollView as ScrollView23, Text as Text58, View as View118 } from "react-native";
12772
- import { useFormatMoney as useFormatMoney26, knownWarnings } from "@tallyui/core";
12824
+ import { useFormatMoney as useFormatMoney26, useOptionalConnector as useOptionalConnector2, knownWarnings } from "@tallyui/core";
12773
12825
  import { canCancelOnStore, canPayRestOnStore, canReverseOnStore, extrasNotSent, isRequeueableOrder, needsAdminReasonOf as needsAdminReasonOf2, needsAttention, noteDelivery as noteDelivery2, refundDueOf, REOPENABLE_CODES, settledOnStore, storeOrderLeft, TILL_SESSION_CLOSED, tillPayments, unrecordedLegs, UPDATE_UNSENDABLE, UPDATE_UNSENDABLE_MESSAGE } from "@tallyui/pos";
12774
12826
  import { Fragment as Fragment48, jsx as jsx190, jsxs as jsxs126 } from "react/jsx-runtime";
12775
12827
  var STATUS_LABEL2 = { pending: "Waiting to sync", applied: "Synced", rejected: "Not accepted" };
@@ -12865,6 +12917,7 @@ function OrderSyncNotices({ order, stuck, children }) {
12865
12917
  }
12866
12918
  function OrdersList({ orders, onRetry, formatDate = defaultFormatDate2, footer, stuck, history, onOpen, onReopen, onResume, onCancelOnStore, onPayRestOnStore, onReverseOnStore, openSessionId }) {
12867
12919
  const formatMoney2 = useFormatMoney26();
12920
+ const discountsAreTaxedRows = useOptionalConnector2()?.discountsAreTaxedRows === true;
12868
12921
  const hintId = useId4();
12869
12922
  const retrying = useRef26(/* @__PURE__ */ new Set());
12870
12923
  const [retryingIds, setRetryingIds] = useState57(/* @__PURE__ */ new Set());
@@ -12974,7 +13027,7 @@ function OrdersList({ orders, onRetry, formatDate = defaultFormatDate2, footer,
12974
13027
  return bTime - aTime;
12975
13028
  });
12976
13029
  return /* @__PURE__ */ jsxs126(ScrollView23, { className: "flex-1 bg-background p-4", children: [
12977
- [{ title: "Needs attention", orders: needsAttention(orders, { stuckCommandIds: stuck?.commandIds }) }, { title: "Recent", orders: recent }].filter((section) => section.title === "Recent" || section.orders.length > 0).map((section, sectionIndex) => /* @__PURE__ */ jsxs126(View118, { className: "mb-6 gap-3", children: [
13030
+ [{ title: "Needs attention", orders: needsAttention(orders, { stuckCommandIds: stuck?.commandIds, discountsAreTaxedRows }) }, { title: "Recent", orders: recent }].filter((section) => section.title === "Recent" || section.orders.length > 0).map((section, sectionIndex) => /* @__PURE__ */ jsxs126(View118, { className: "mb-6 gap-3", children: [
12978
13031
  /* @__PURE__ */ jsx190(Text58, { accessibilityRole: "header", className: "text-xl font-semibold text-foreground", children: section.title }),
12979
13032
  section.title === "Recent" && orders.length === 0 && shown2.length === 0 ? /* @__PURE__ */ jsx190(Text58, { testID: "orders-empty", className: "text-muted-foreground", children: "No sales yet. Completed sales appear here." }) : null,
12980
13033
  section.orders.map((order) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tallyui/components",
3
- "version": "5.2.0",
3
+ "version": "5.3.0",
4
4
  "type": "module",
5
5
  "description": "Universal POS UI components for Tally UI",
6
6
  "main": "./dist/index.js",
@@ -29,9 +29,9 @@
29
29
  "directory": "packages/components"
30
30
  },
31
31
  "peerDependencies": {
32
- "@tallyui/core": "^5.2.0",
33
- "@tallyui/primitives": "^5.2.0",
34
- "@tallyui/theme": "^5.2.0",
32
+ "@tallyui/core": "^5.3.0",
33
+ "@tallyui/primitives": "^5.3.0",
34
+ "@tallyui/theme": "^5.3.0",
35
35
  "react": ">=18",
36
36
  "react-native": ">=0.74",
37
37
  "react-native-svg": ">=15"
@@ -40,13 +40,13 @@
40
40
  "class-variance-authority": "^0.7.1",
41
41
  "i18next": "^26.7.1",
42
42
  "react-i18next": "^17.1.12",
43
- "@tallyui/pos": "5.2.0"
43
+ "@tallyui/pos": "5.3.0"
44
44
  },
45
45
  "devDependencies": {
46
- "@tallyui/connector-medusa": "5.2.0",
47
- "@tallyui/connector-vendure": "5.2.0",
48
- "@tallyui/connector-woocommerce": "5.2.0",
49
- "@tallyui/mock-api": "5.2.0",
46
+ "@tallyui/connector-medusa": "5.3.0",
47
+ "@tallyui/connector-vendure": "5.3.0",
48
+ "@tallyui/connector-woocommerce": "5.3.0",
49
+ "@tallyui/mock-api": "5.3.0",
50
50
  "@types/react": ">=18",
51
51
  "react": "^19.2.4",
52
52
  "react-native-svg": "15.12.1",
@@ -1,14 +1,17 @@
1
- // Ported from WCPOS v2 packages/core/src/screens/main/pos/cart/cells/line-strip.tsx (press to open, Remove flies the row off; the Total peeks on hover; no swipe yet) and cells/edit-cart-item-button.tsx; MIT, WCPOS.
1
+ // Ported from WCPOS v2 packages/core/src/screens/main/pos/cart/cells/line-strip.tsx (press to open, Remove flies the row off; the Total peeks on hover; drag to open or fling off by v2's release rule (line-strip.geometry.ts); no remove-point haptic or Edit swallow) and cells/edit-cart-item-button.tsx; MIT, WCPOS.
2
2
  import { useRef, useState, type JSX, type ReactNode } from 'react';
3
- import { Animated, Platform, Pressable, View } from 'react-native';
3
+ import { Animated, PanResponder, Platform, Pressable, View } from 'react-native';
4
4
  import { Button, Text } from '../ui';
5
5
  import { ARM, EASE_EXIT, PANEL_SLIDE_OUT, PEEK, PEEK_SPRING } from '../lib/motion';
6
6
  import { useReducedMotion } from '../lib/use-reduced-motion';
7
+ import { releaseOutcome } from './line-strip-geometry';
8
+ // A release this long after the last move is not a flick: PanResponder's vx is the last move's speed and survives a pause (react-native-web PanResponder index.js:234-235).
9
+ const STILL_MS = 50;
7
10
 
8
- /** A cart row with v2's hidden strip under it: pressing the row's Total slides the row left onto a solid Edit and Remove. */
11
+ /** A cart row with v2's hidden strip under it: pressing the row's Total slides the row left onto a solid Remove, with Edit beside it when `onEdit` is given. */
9
12
  export function CartLineStrip({ name, onEdit, onRemove, children }: {
10
13
  name: string;
11
- onEdit: () => void;
14
+ onEdit?: () => void;
12
15
  // A returned string is a refusal, and the row comes back.
13
16
  onRemove: () => string | null | void;
14
17
  children: (wrapTotal: (content: ReactNode) => ReactNode) => ReactNode;
@@ -42,6 +45,35 @@ export function CartLineStrip({ name, onEdit, onRemove, children }: {
42
45
  settle(false);
43
46
  });
44
47
  };
48
+ // The pan handlers are created once: they read the widths, the drag's base and the latest settle and leave through this ref.
49
+ const drag = useRef({ row: 0, strip: 0, base: 0, claimed: 0, settle, leave });
50
+ Object.assign(drag.current, { row: rowWidth ?? 0, strip: stripWidth, settle, leave });
51
+ const clamp = (x: number) => Math.min(0, Math.max(-drag.current.row, x));
52
+ const pan = useRef(PanResponder.create({
53
+ onMoveShouldSetPanResponder: (_, { dx, dy }) => !leaving.current && drag.current.row > 0
54
+ && Math.abs(dx) > 8 && Math.abs(dx) > Math.abs(dy) && (drag.current.claimed = dx, true),
55
+ onPanResponderGrant: () => {
56
+ const { claimed } = drag.current;
57
+ // PanResponder zeroes dx at grant (react-native Libraries/Interaction/PanResponder.js onResponderGrant; react-native-web vendor PanResponder index.js:330), so the claimed distance joins the base.
58
+ drag.current.base = (opened.current ? -drag.current.strip : 0) + claimed;
59
+ drag.current.claimed = 0;
60
+ // The row's real place: the callback is synchronous on the JS driver (web). On the native driver it can land after the first moves, so a row
61
+ // grabbed mid-spring can jump once by the distance between the spring's target and its real place; the immediate base above is where it starts until then.
62
+ offset.stopAnimation((value) => { drag.current.base = value + claimed; });
63
+ },
64
+ onPanResponderMove: (_, { dx }) => offset.setValue(clamp(drag.current.base + dx)),
65
+ onPanResponderRelease: (event, { dx, vx, _accountsForMovesUpTo }) => {
66
+ drag.current.claimed = 0;
67
+ const { row, strip, base } = drag.current;
68
+ // gestureState.vx is px per ms, dx over DOM timeStamp ms (react-native-web dist/vendor/react-native/PanResponder/index.js:235); v2's rule takes px/s.
69
+ // react-native's GestureResponderEvent type leaves out touchHistory, which PanResponder itself reads (react-native-web PanResponder index.js:306).
70
+ const still = (event as unknown as { touchHistory: { mostRecentTimeStamp: number } }).touchHistory.mostRecentTimeStamp - _accountsForMovesUpTo > STILL_MS;
71
+ const outcome = releaseOutcome({ revealed: -clamp(base + dx), velocityX: still ? 0 : vx * 1000, rowWidth: row, stripWidth: strip });
72
+ if (outcome === 'remove') drag.current.leave();
73
+ else drag.current.settle(outcome === 'open');
74
+ },
75
+ onPanResponderTerminate: () => { drag.current.claimed = 0; drag.current.settle(opened.current); },
76
+ })).current;
45
77
  // v2's peek: only a closed, staying row, and only with reduced motion known to be off.
46
78
  const peek = (on: boolean) => {
47
79
  if (opened.current || leaving.current || reduced) return;
@@ -61,12 +93,12 @@ export function CartLineStrip({ name, onEdit, onRemove, children }: {
61
93
  style={rowWidth === undefined ? undefined : { width: rowWidth }} pointerEvents={open ? 'auto' : 'none'}
62
94
  accessibilityElementsHidden={!open} importantForAccessibility={open ? 'auto' : 'no-hide-descendants'} aria-hidden={!open}>
63
95
  <View testID="cart-line-strip-actions" className="flex-row items-stretch" onLayout={(event) => setStripWidth(event.nativeEvent.layout.width)}>
64
- <Button variant="default" testID="cart-line-edit" accessibilityLabel={`Edit ${name}`} className={block}
65
- onPress={() => { if (leaving.current) return; settle(false); onEdit(); }}><Text>Edit</Text></Button>
96
+ {onEdit ? <Button variant="default" testID="cart-line-edit" accessibilityLabel={`Edit ${name}`} className={block}
97
+ onPress={() => { if (leaving.current) return; settle(false); onEdit(); }}><Text>Edit</Text></Button> : null}
66
98
  <Button variant="destructive" testID="cart-line-remove" accessibilityLabel={`Remove ${name}`} className={block}
67
99
  onPress={leave}><Text>Remove</Text></Button>
68
100
  </View>
69
101
  </View>
70
- <Animated.View className="bg-background" style={{ transform: [{ translateX: shown }] }}>{children(wrapTotal)}</Animated.View>
102
+ <Animated.View {...pan.panHandlers} className="bg-background" style={{ transform: [{ translateX: shown }] }}>{children(wrapTotal)}</Animated.View>
71
103
  </View>;
72
104
  }
@@ -1,4 +1,4 @@
1
- import type { ReactNode } from 'react';
1
+ import { Children, cloneElement, type ReactElement, type ReactNode } from 'react';
2
2
  import { Pressable, View } from 'react-native';
3
3
  import { useFormatMoney, type Money } from '@tallyui/core';
4
4
  import { Image } from '@tallyui/primitives';
@@ -35,6 +35,9 @@ export interface CartLineProps extends Omit<HStackProps, 'children'> {
35
35
  picking?: boolean;
36
36
  locale?: string;
37
37
  className?: string;
38
+ /** The line strip's press target (`CartLineStrip`): wraps the Total cell's content, or with Total hidden the last visible
39
+ * cell's that holds no button of its own (not Quantity, nor Price while `priceSlot` is set). */
40
+ wrapTotal?: (content: ReactNode) => ReactNode;
38
41
  }
39
42
 
40
43
  // Name and attributes: WCPOS v2 packages/core/src/screens/main/pos/cart/cells/product-name.tsx; price:
@@ -48,14 +51,16 @@ export interface CartLineProps extends Omit<HStackProps, 'children'> {
48
51
  * ```
49
52
  */
50
53
  export function CartLine({ name, attributes, quantity, unitPrice, regularUnitPrice, lineTotal, showPrice = true, quantitySlot, priceSlot,
51
- columns, sku, imageUrl, onSplit, picking = false, locale, className, ...props }: CartLineProps) {
54
+ columns, sku, imageUrl, onSplit, picking = false, locale, className, wrapTotal, ...props }: CartLineProps) {
52
55
  const formatMoney = useFormatMoney();
53
56
  const t = useT();
54
57
  const options = Object.entries(attributes ?? {}).map(([key, value]) => `${key}: ${value}`).join(' · ');
55
58
  const sameCurrency = regularUnitPrice?.currency === unitPrice.currency;
56
59
  const regular = (columns?.price?.onSale ?? true) && regularUnitPrice && sameCurrency && regularUnitPrice.amount > unitPrice.amount
57
60
  ? formatMoney(regularUnitPrice, locale) ?? '—' : null;
58
- const cells: Record<ReturnType<typeof cartColumnSlots>[number], ReactNode> = {
61
+ const slots = cartColumnSlots(columns, { showPrice });
62
+ const target = slots.includes('total') ? 'total' : slots.filter((id) => id !== 'quantity' && !(id === 'price' && priceSlot)).pop();
63
+ const cells: Record<(typeof slots)[number], ReactElement<{ children?: ReactNode }>> = {
59
64
  fill: <View key="fill" className="flex-1" />,
60
65
  quantity: <View key="quantity" className={(picking ? CART_PICKING_QUANTITY : CART_COLUMNS.quantity).cell}>
61
66
  {quantitySlot ?? <Text className="text-sm tabular-nums">{quantity}</Text>}
@@ -90,7 +95,7 @@ export function CartLine({ name, attributes, quantity, unitPrice, regularUnitPri
90
95
  };
91
96
  return (
92
97
  <HStack space="none" className={cn('py-2.5', className)} {...props}>
93
- {cartColumnSlots(columns, { showPrice }).map((id) => cells[id])}
98
+ {slots.map((id) => wrapTotal && id === target ? cloneElement(cells[id], {}, wrapTotal(Children.toArray(cells[id].props.children))) : cells[id])}
94
99
  </HStack>
95
100
  );
96
101
  }
@@ -0,0 +1,28 @@
1
+ // Ported from WCPOS v2 packages/core/src/screens/main/pos/cart/cells/line-strip.geometry.ts (the release rule only); MIT, WCPOS.
2
+
3
+ /**
4
+ * The remove point as a share of the row. Material and Wear commit at a half; our strip
5
+ * already covers 42–47 % of a register column, so a half would leave almost no band between
6
+ * "open" and "remove".
7
+ */
8
+ export const REMOVE_SHARE = 0.6;
9
+ /** The band is never narrower than this past the open strip, whatever the row width. */
10
+ export const REMOVE_BAND = 56;
11
+ /** A flick this fast (px/s, leftwards) past the open strip removes without reaching the line. */
12
+ export const REMOVE_FLICK = 800;
13
+
14
+ /** How far the row has to travel before letting go removes it. */
15
+ export function removePoint(rowWidth: number, stripWidth: number): number {
16
+ return Math.max(stripWidth + REMOVE_BAND, Math.round(rowWidth * REMOVE_SHARE));
17
+ }
18
+
19
+ export type Release = 'remove' | 'open' | 'home';
20
+
21
+ /** `revealed` is how far left the row sits (a positive number), `velocityX` the gesture's, leftwards negative. */
22
+ export function releaseOutcome({ revealed, velocityX, rowWidth, stripWidth }: {
23
+ revealed: number; velocityX: number; rowWidth: number; stripWidth: number;
24
+ }): Release {
25
+ if (revealed >= removePoint(rowWidth, stripWidth)) return 'remove';
26
+ if (velocityX <= -REMOVE_FLICK && revealed > stripWidth) return 'remove';
27
+ return revealed > stripWidth / 2 ? 'open' : 'home';
28
+ }
package/src/sale/cart.tsx CHANGED
@@ -119,7 +119,7 @@ export function Cart({ sale, taxLabel = (ratePpm: number) => `Tax ${ratePpm / 10
119
119
  | { type: 'edit-charge'; kind: 'fees' | 'shipping'; id: string } | null>(null);
120
120
  // The picker's bill is read-only: no form shows, nor any control that opens one.
121
121
  const form = picker ? null : openForm;
122
- const ChargeStrip = picker ? ReadOnlyStrip : CartLineStrip;
122
+ const Strip = picker ? ReadOnlyStrip : CartLineStrip;
123
123
  const chargesOffered = (sale.capabilities?.orderCreate ?? 0) >= 5;
124
124
  // #1115: front desk 2026-11-20, a Woo store at order.create 6+ takes a No tax shipping line (stock 2.0.4 proof F2).
125
125
  const shippingNoTax = (sale.capabilities?.orderCreate ?? 0) >= 6;
@@ -143,11 +143,16 @@ export function Cart({ sale, taxLabel = (ratePpm: number) => `Tax ${ratePpm / 10
143
143
  if (refused === null) setPriceError((now) => (now?.lineId === line.id ? null : now));
144
144
  return refused;
145
145
  };
146
+ // sale.remove returns nothing, so a refused remove (editRefusal, which sets sale.error) is read back from the builder, and the strip brings the row back.
147
+ const removeLine = (id: string) => {
148
+ sale.remove(id);
149
+ return sale.removal('line', id) ? 'refused' : null;
150
+ };
146
151
  const unpaid = (line: typeof order.lineItems[number]) => line.quantity - (picker?.paid[line.id] ?? 0);
147
152
  const pickable = (line: typeof order.lineItems[number]) => Number.isInteger(line.quantity) && line.quantity > 0
148
153
  && display(line.id).amountMinor >= 0 && unpaid(line) > 0;
149
154
  const renderItem = (line: typeof order.lineItems[number]) => <>
150
- <CartLine name={line.name} attributes={line.attributes} quantity={line.quantity} unitPrice={money(line.unitPriceMinor)}
155
+ <Strip name={line.name} onRemove={() => removeLine(line.id)}>{(wrapTotal) => <CartLine name={line.name} attributes={line.attributes} quantity={line.quantity} unitPrice={money(line.unitPriceMinor)}
151
156
  regularUnitPrice={line.regularUnitPriceMinor === undefined ? undefined : money(line.regularUnitPriceMinor)}
152
157
  lineTotal={money(display(line.id).amountMinor)} showPrice={showPrice}
153
158
  columns={columns} sku={line.sku} imageUrl={line.imageUrl} onSplit={picker ? undefined : () => split(line.id)} picking={picker !== undefined}
@@ -162,7 +167,8 @@ export function Cart({ sale, taxLabel = (ratePpm: number) => `Tax ${ratePpm / 10
162
167
  priceSlot={pricePopover && !picker ? <LinePopover kind="price" lineName={line.name} currency={order.currency} value={line.unitPriceMinor}
163
168
  regularValue={line.regularUnitPriceMinor} actions={[{ id: 'discount', label: 'Discount', onPress: () => setForm({ type: 'discount', lineId: line.id }) }]}
164
169
  quickDiscounts={quickDiscounts} textClassName="text-right text-muted-foreground" onApply={(amount) => applyPrice(line, amount)}
165
- commit={lineCommit} onCloseRefused={(message) => setPriceError({ lineId: line.id, message })} /> : undefined} />
170
+ commit={lineCommit} onCloseRefused={(message) => setPriceError({ lineId: line.id, message })} /> : undefined} wrapTotal={wrapTotal} />}
171
+ </Strip>
166
172
  {splitError?.lineId === line.id ? <Text accessibilityRole="alert" testID="cart-line-split-error"
167
173
  className="px-3 text-sm text-destructive">{splitError.message}</Text> : null}
168
174
  {priceError?.lineId === line.id ? <Text accessibilityRole="alert" testID="cart-line-price-error"
@@ -201,12 +207,12 @@ export function Cart({ sale, taxLabel = (ratePpm: number) => `Tax ${ratePpm / 10
201
207
  {(['fees', 'shipping'] as const).map((kind) => <MotionRows key={kind} items={order[kind] ?? []} keyOf={(charge) => charge.id}
202
208
  pulseKey={() => 0} identity={order.id} renderItem={(charge, index) =>
203
209
  <View testID={`cart-${kind === 'fees' ? 'fee' : 'shipping'}-${index}`}>
204
- <ChargeStrip name={charge.name} onEdit={() => setForm({ type: 'edit-charge', kind, id: charge.id })}
210
+ <Strip name={charge.name} onEdit={() => setForm({ type: 'edit-charge', kind, id: charge.id })}
205
211
  onRemove={() => kind === 'fees' ? sale.removeFee(charge.id) : sale.removeShipping(charge.id)}>
206
212
  {(wrapTotal) => <CartChargeLine name={charge.name} price={money(charge.amountMinor)} percent={charge.percent}
207
213
  total={money(order.display[kind]!.find((row) => row.id === charge.id)!.amountMinor)}
208
214
  showPrice={showPrice} columns={columns} picking={picker !== undefined} testID="cart-charge-line" wrapTotal={wrapTotal} />}
209
- </ChargeStrip>
215
+ </Strip>
210
216
  {form?.type === 'edit-charge' && form.kind === kind && form.id === charge.id ? <ChargeForm key={charge.id}
211
217
  kind={kind === 'fees' ? 'fee' : 'shipping'} initial={charge} currency={order.currency} lineTax={sale.capabilities?.lineTax}
212
218
  allowPercent pricesIncludeTax={chargeTaxSwitch ? order.pricesIncludeTax : undefined}
@@ -260,7 +266,7 @@ export function Cart({ sale, taxLabel = (ratePpm: number) => `Tax ${ratePpm / 10
260
266
  </View>;
261
267
  }
262
268
 
263
- /** A fee or shipping row on the picker's read-only bill: the row alone, no Edit or Remove strip. */
269
+ /** A product, fee or shipping row on the picker's read-only bill: the row alone, no Edit or Remove strip. */
264
270
  const ReadOnlyStrip = ({ children }: Parameters<typeof CartLineStrip>[0]) => <>{children((content) => content)}</>;
265
271
 
266
272
  /** WCPOS v2's `− n of unpaid +` stepper (tender/unit-stepper.tsx), the one Cart's `picker` draws in each pickable line's
@@ -1,6 +1,6 @@
1
1
  import { useEffect, useId, useRef, useState, type ReactNode } from 'react';
2
2
  import { Pressable, ScrollView, Text, View } from 'react-native';
3
- import { useFormatMoney, knownWarnings, type SettleOutcome } from '@tallyui/core';
3
+ import { useFormatMoney, useOptionalConnector, knownWarnings, type SettleOutcome } from '@tallyui/core';
4
4
  import { canCancelOnStore, canPayRestOnStore, canReverseOnStore, extrasNotSent, isRequeueableOrder, needsAdminReasonOf, needsAttention, noteDelivery, refundDueOf, REOPENABLE_CODES, settledOnStore, storeOrderLeft, TILL_SESSION_CLOSED, tillPayments, unrecordedLegs, UPDATE_UNSENDABLE, UPDATE_UNSENDABLE_MESSAGE, type OutboxState, type PosOrder } from '@tallyui/pos';
5
5
  import { META_NOT_SENT, NOTE_NOT_SENT, orderReference, TAX_IDS_NOT_SENT } from './order-reference';
6
6
  import { sinceText } from './since-text';
@@ -208,6 +208,7 @@ export function OrdersList({ orders, onRetry, formatDate = defaultFormatDate, fo
208
208
  onReverseOnStore?: (order: PosOrder) => Promise<SettleOutcome | { kind: 'not_offered' }>;
209
209
  }) {
210
210
  const formatMoney = useFormatMoney();
211
+ const discountsAreTaxedRows = useOptionalConnector()?.discountsAreTaxedRows === true;
211
212
  const hintId = useId();
212
213
  const retrying = useRef(new Set<string>());
213
214
  const [retryingIds, setRetryingIds] = useState(new Set<string>());
@@ -316,7 +317,7 @@ export function OrdersList({ orders, onRetry, formatDate = defaultFormatDate, fo
316
317
  return bTime - aTime;
317
318
  });
318
319
  return <ScrollView className="flex-1 bg-background p-4">
319
- {[{ title: 'Needs attention', orders: needsAttention(orders, { stuckCommandIds: stuck?.commandIds }) }, { title: 'Recent', orders: recent }].filter((section) => section.title === 'Recent' || section.orders.length > 0).map((section, sectionIndex) => (
320
+ {[{ title: 'Needs attention', orders: needsAttention(orders, { stuckCommandIds: stuck?.commandIds, discountsAreTaxedRows }) }, { title: 'Recent', orders: recent }].filter((section) => section.title === 'Recent' || section.orders.length > 0).map((section, sectionIndex) => (
320
321
  <View key={section.title} className="mb-6 gap-3">
321
322
  <Text accessibilityRole="header" className="text-xl font-semibold text-foreground">{section.title}</Text>
322
323
  {section.title === 'Recent' && orders.length === 0 && shown.length === 0 ? <Text testID="orders-empty" className="text-muted-foreground">No sales yet. Completed sales appear here.</Text> : null}