@tallyui/components 4.0.1 → 4.2.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 +49 -8
- package/dist/index.js +180 -37
- package/package.json +9 -9
- package/src/i18n/locales/en/components.json +1 -0
- package/src/index.ts +2 -2
- package/src/product/product-table.tsx +18 -7
- package/src/product/product-variant-picker.tsx +4 -0
- package/src/sale/cart.tsx +4 -2
- package/src/sale/catalogue.tsx +4 -3
- package/src/sale/charge-form.tsx +21 -3
- package/src/sale/held-leg.ts +6 -0
- package/src/sale/index.ts +2 -2
- package/src/sale/line-popover.tsx +2 -1
- package/src/sale/orders-list.tsx +62 -3
- package/src/sale/receipt-sheet.tsx +28 -8
- package/src/sale/since-text.ts +6 -3
- package/src/sale/sync-status.tsx +4 -0
- package/src/sale/tender-ledger.tsx +9 -3
- package/src/sale/tender-pane.tsx +4 -2
package/dist/index.js
CHANGED
|
@@ -2928,6 +2928,7 @@ function ProductTable({
|
|
|
2928
2928
|
isExpanded,
|
|
2929
2929
|
onToggleExpand,
|
|
2930
2930
|
renderExpanded,
|
|
2931
|
+
variationsButton = false,
|
|
2931
2932
|
loading = false,
|
|
2932
2933
|
className,
|
|
2933
2934
|
...viewProps
|
|
@@ -3003,7 +3004,8 @@ function ProductTable({
|
|
|
3003
3004
|
const key = String(item.id ?? index);
|
|
3004
3005
|
const variations = addButton && traits !== void 0 && traits.getVariantCount(item) > 1;
|
|
3005
3006
|
const count2 = addButton && !variations ? cartQuantity?.(item) ?? 0 : 0;
|
|
3006
|
-
const
|
|
3007
|
+
const variantCount = traits?.getVariantCount(item) ?? 0;
|
|
3008
|
+
const expandable = (thumbnail || variationsButton) && onToggleExpand !== void 0 && renderExpanded !== void 0 && variantCount > 1;
|
|
3007
3009
|
const expanded = expandable && (isExpanded?.(item) ?? false);
|
|
3008
3010
|
const row2 = /* @__PURE__ */ jsxs31(TableRow, { testID: onSelect ? void 0 : "product-row-" + key, children: [
|
|
3009
3011
|
thumbnail ? /* @__PURE__ */ jsx82(TableCell, { style: { width: thumb + CELL_PAD_X }, className: "flex-none px-3 py-1.5", children: expandable ? /* @__PURE__ */ jsx82(
|
|
@@ -3020,12 +3022,31 @@ function ProductTable({
|
|
|
3020
3022
|
children: /* @__PURE__ */ jsx82(ProductImage, { doc: item, size: thumb, showPlaceholder: true, className: "rounded-md" })
|
|
3021
3023
|
}
|
|
3022
3024
|
) : /* @__PURE__ */ jsx82(ProductImage, { doc: item, size: thumb, showPlaceholder: true, className: "rounded-md" }) }) : null,
|
|
3023
|
-
resolvedColumns.map((column) => /* @__PURE__ */
|
|
3025
|
+
resolvedColumns.map((column, cell) => /* @__PURE__ */ jsxs31(
|
|
3024
3026
|
TableCell,
|
|
3025
3027
|
{
|
|
3026
3028
|
style: { flex: column.flex ?? 1 },
|
|
3027
3029
|
className: cn53("px-3 py-1.5", column.align && ALIGN[column.align]),
|
|
3028
|
-
children:
|
|
3030
|
+
children: [
|
|
3031
|
+
column.render(item),
|
|
3032
|
+
cell === 0 && expandable && variationsButton ? /* @__PURE__ */ jsxs31(
|
|
3033
|
+
Pressable11,
|
|
3034
|
+
{
|
|
3035
|
+
accessibilityRole: "button",
|
|
3036
|
+
"aria-expanded": expanded,
|
|
3037
|
+
testID: "product-row-variations-" + key,
|
|
3038
|
+
className: "mt-0.5 self-start flex-row items-center gap-1",
|
|
3039
|
+
onPress: (event) => {
|
|
3040
|
+
event.stopPropagation?.();
|
|
3041
|
+
onToggleExpand(item);
|
|
3042
|
+
},
|
|
3043
|
+
children: [
|
|
3044
|
+
/* @__PURE__ */ jsx82(View30, { className: "text-muted-foreground", children: expanded ? /* @__PURE__ */ jsx82(ChevronDownIcon, { size: 14 }) : /* @__PURE__ */ jsx82(ChevronRightIcon, { size: 14 }) }),
|
|
3045
|
+
/* @__PURE__ */ jsx82(Text, { className: "text-xs text-muted-foreground", children: `${variantCount} variations` })
|
|
3046
|
+
]
|
|
3047
|
+
}
|
|
3048
|
+
) : null
|
|
3049
|
+
]
|
|
3029
3050
|
},
|
|
3030
3051
|
column.id
|
|
3031
3052
|
)),
|
|
@@ -3052,7 +3073,7 @@ function ProductTable({
|
|
|
3052
3073
|
View30,
|
|
3053
3074
|
{
|
|
3054
3075
|
testID: "product-row-expanded-" + key,
|
|
3055
|
-
style: { paddingLeft: thumb + CELL_PAD_X },
|
|
3076
|
+
style: { paddingLeft: thumbnail ? thumb + CELL_PAD_X : 0 },
|
|
3056
3077
|
className: "border-b border-border",
|
|
3057
3078
|
children: renderExpanded(item)
|
|
3058
3079
|
}
|
|
@@ -3250,10 +3271,12 @@ function ProductVariantPicker({
|
|
|
3250
3271
|
return /* @__PURE__ */ jsx86(
|
|
3251
3272
|
Pressable13,
|
|
3252
3273
|
{
|
|
3274
|
+
testID: `variant-option-${option.name}-${value}`,
|
|
3253
3275
|
onPress: () => handleSelect(option.name, value),
|
|
3254
3276
|
className: cn56(
|
|
3255
3277
|
"rounded-lg border px-3 py-1.5",
|
|
3256
|
-
active ? "border-primary bg-primary/10" : "border-border bg-card"
|
|
3278
|
+
active ? "border-primary bg-primary/10" : "border-border bg-card",
|
|
3279
|
+
option.dimmed?.includes(value) && "opacity-50"
|
|
3257
3280
|
),
|
|
3258
3281
|
children: /* @__PURE__ */ jsx86(
|
|
3259
3282
|
Text15,
|
|
@@ -3781,6 +3804,7 @@ var components_default = {
|
|
|
3781
3804
|
"pos_checkout.no_payments_yet": "No payments yet",
|
|
3782
3805
|
"pos_checkout.paid": "Paid",
|
|
3783
3806
|
"pos_checkout.paid_in_full": "Paid in full",
|
|
3807
|
+
"pos_checkout.paid_in_full_at": "Paid in full \xB7 {time}",
|
|
3784
3808
|
"pos_checkout.paid_of_total": "{paid} of {total} paid",
|
|
3785
3809
|
"pos_checkout.part_payment_left": "Part payment \xB7 {left} left after this",
|
|
3786
3810
|
"pos_checkout.pick_amount_due": "This payment is {amount} for the picked items",
|
|
@@ -9796,6 +9820,7 @@ import { normalizeMoneyText as normalizeMoneyText5, useCurrencySymbol as useCurr
|
|
|
9796
9820
|
import { Fragment as Fragment36, jsx as jsx169, jsxs as jsxs106 } from "react/jsx-runtime";
|
|
9797
9821
|
var NAME_LABEL_ID = "charge-form-name-label";
|
|
9798
9822
|
var AMOUNT_LABEL_ID4 = "charge-form-amount-label";
|
|
9823
|
+
var SKU_LABEL_ID = "charge-form-sku-label";
|
|
9799
9824
|
var button3 = "rounded-md border border-border px-3 py-2 min-h-11 items-center justify-center";
|
|
9800
9825
|
var DEFAULT_NAME = { fee: "Fee", shipping: "Shipping", custom: "Product" };
|
|
9801
9826
|
function ChargeForm({
|
|
@@ -9806,6 +9831,7 @@ function ChargeForm({
|
|
|
9806
9831
|
shippingNoTax,
|
|
9807
9832
|
kind: fixedKind,
|
|
9808
9833
|
initial,
|
|
9834
|
+
sku,
|
|
9809
9835
|
allowPercent,
|
|
9810
9836
|
pricesIncludeTax,
|
|
9811
9837
|
onApply,
|
|
@@ -9823,7 +9849,10 @@ function ChargeForm({
|
|
|
9823
9849
|
const [noTax, setNoTax] = useState48(initial?.taxStatus === "none");
|
|
9824
9850
|
const [includesTax, setIncludesTax] = useState48(initial?.amountIncludesTax ?? pricesIncludeTax ?? false);
|
|
9825
9851
|
const [taxClass, setTaxClass] = useState48(initial?.taxClass ?? "");
|
|
9852
|
+
const [skuText, setSkuText] = useState48(initial?.sku ?? "");
|
|
9853
|
+
const [skuOpen, setSkuOpen] = useState48(Boolean(initial?.sku));
|
|
9826
9854
|
const [error, setError] = useState48(null);
|
|
9855
|
+
const showSku = Boolean(sku) && kind === "custom";
|
|
9827
9856
|
const storeShipping = kind === "shipping" && shippingTaxFromStore;
|
|
9828
9857
|
const showNoTax = storeShipping ? shippingNoTax : lineTax?.none;
|
|
9829
9858
|
const showUnit = Boolean(allowPercent) && kind === "fee";
|
|
@@ -9841,7 +9870,8 @@ function ChargeForm({
|
|
|
9841
9870
|
taxStatus: showNoTax ? noTax ? "none" : void 0 : initial?.taxStatus === "none" ? "none" : void 0,
|
|
9842
9871
|
taxClass: !storeShipping && lineTax?.classes && taxClasses?.length ? taxClass || void 0 : initial?.taxClass,
|
|
9843
9872
|
...percentMode ? { percent: parsed } : !showUnit && initial?.percent !== void 0 ? { percent: initial.percent } : {},
|
|
9844
|
-
...percentMode ? {} : showIncludesTax ? includesTax !== pricesIncludeTax ? { amountIncludesTax: includesTax } : {} : initial?.amountIncludesTax !== void 0 ? { amountIncludesTax: initial.amountIncludesTax } : {}
|
|
9873
|
+
...percentMode ? {} : showIncludesTax ? includesTax !== pricesIncludeTax ? { amountIncludesTax: includesTax } : {} : initial?.amountIncludesTax !== void 0 ? { amountIncludesTax: initial.amountIncludesTax } : {},
|
|
9874
|
+
...showSku ? skuText.trim() ? { sku: skuText.trim() } : {} : initial?.sku ? { sku: initial.sku } : {}
|
|
9845
9875
|
});
|
|
9846
9876
|
setError(refused);
|
|
9847
9877
|
if (refused === null) onClose();
|
|
@@ -9936,6 +9966,29 @@ function ChargeForm({
|
|
|
9936
9966
|
},
|
|
9937
9967
|
option.id
|
|
9938
9968
|
)) }) : null }),
|
|
9969
|
+
showSku ? skuOpen ? /* @__PURE__ */ jsxs106(Fragment36, { children: [
|
|
9970
|
+
/* @__PURE__ */ jsx169(Label, { nativeID: SKU_LABEL_ID, children: t("common.sku") }),
|
|
9971
|
+
/* @__PURE__ */ jsx169(
|
|
9972
|
+
TextInput11,
|
|
9973
|
+
{
|
|
9974
|
+
testID: "charge-form-sku-input",
|
|
9975
|
+
accessibilityLabelledBy: SKU_LABEL_ID,
|
|
9976
|
+
accessibilityLabel: t("common.sku"),
|
|
9977
|
+
value: skuText,
|
|
9978
|
+
onChangeText: setSkuText,
|
|
9979
|
+
className: "min-w-0 rounded-md border border-border bg-background px-3 py-2 text-foreground"
|
|
9980
|
+
}
|
|
9981
|
+
)
|
|
9982
|
+
] }) : /* @__PURE__ */ jsx169(
|
|
9983
|
+
Pressable44,
|
|
9984
|
+
{
|
|
9985
|
+
testID: "charge-form-add-sku",
|
|
9986
|
+
accessibilityRole: "button",
|
|
9987
|
+
onPress: () => setSkuOpen(true),
|
|
9988
|
+
className: `${button3} bg-card self-start`,
|
|
9989
|
+
children: /* @__PURE__ */ jsx169(Text44, { className: "text-foreground", children: `+ ${t("common.sku")}` })
|
|
9990
|
+
}
|
|
9991
|
+
) : null,
|
|
9939
9992
|
error ? /* @__PURE__ */ jsx169(Text44, { accessibilityRole: "alert", className: "text-destructive", children: error }) : null,
|
|
9940
9993
|
/* @__PURE__ */ jsxs106(View102, { className: "flex-row gap-2", children: [
|
|
9941
9994
|
/* @__PURE__ */ jsx169(Pressable44, { accessibilityRole: "button", onPress: apply, className: `${button3} bg-primary`, children: /* @__PURE__ */ jsx169(Text44, { className: "font-semibold text-primary-foreground", children: t(initial ? "common.save" : "common.add_to_cart") }) }),
|
|
@@ -10053,6 +10106,7 @@ function LinePopover({
|
|
|
10053
10106
|
onEscapeKeyDown: () => {
|
|
10054
10107
|
discard.current = true;
|
|
10055
10108
|
},
|
|
10109
|
+
pointerEvents: open ? "auto" : "none",
|
|
10056
10110
|
children: /* @__PURE__ */ jsx170(
|
|
10057
10111
|
Animated9.View,
|
|
10058
10112
|
{
|
|
@@ -10192,6 +10246,11 @@ import { useFormatMoney as useFormatMoney20, wireMethodOf as wireMethodOf2 } fro
|
|
|
10192
10246
|
import { canVoidLeg, countsTowardPaid, legStatus } from "@tallyui/pos";
|
|
10193
10247
|
import { cn as cn112 } from "@tallyui/theme";
|
|
10194
10248
|
|
|
10249
|
+
// src/sale/held-leg.ts
|
|
10250
|
+
function heldTillLeg(order, leg) {
|
|
10251
|
+
return !!leg.locked || !!leg.reopened || !!order.afterClose?.payments.some((p) => p.id === leg.id);
|
|
10252
|
+
}
|
|
10253
|
+
|
|
10195
10254
|
// src/sale/offered-methods.ts
|
|
10196
10255
|
import { defaultPaymentMethods, wireMethodOf } from "@tallyui/core";
|
|
10197
10256
|
function offeredMethods(methods) {
|
|
@@ -10202,6 +10261,14 @@ function tenderOf(descriptor) {
|
|
|
10202
10261
|
return { method, ...descriptor.id !== method ? { methodId: descriptor.id } : {} };
|
|
10203
10262
|
}
|
|
10204
10263
|
|
|
10264
|
+
// src/sale/since-text.ts
|
|
10265
|
+
function shortTime(t) {
|
|
10266
|
+
return new Date(t).toLocaleTimeString(void 0, { hour: "numeric", minute: "2-digit" });
|
|
10267
|
+
}
|
|
10268
|
+
function sinceText(clock2) {
|
|
10269
|
+
return clock2.firstFailedAt === void 0 ? "about " + shortTime(clock2.since) : shortTime(clock2.firstFailedAt);
|
|
10270
|
+
}
|
|
10271
|
+
|
|
10205
10272
|
// src/sale/tender-ledger.tsx
|
|
10206
10273
|
import { Fragment as Fragment37, jsx as jsx172, jsxs as jsxs109 } from "react/jsx-runtime";
|
|
10207
10274
|
var STATUS_LABEL = {
|
|
@@ -10229,6 +10296,8 @@ function TenderLedger({ sale, methods, closing = false, confirmVoid = false }) {
|
|
|
10229
10296
|
const money = (minor) => formatMoney2({ amount: minor, currency: order.currency }) ?? "";
|
|
10230
10297
|
const balance = order.balanceDueMinor;
|
|
10231
10298
|
const settled = order.payments.some(countsTowardPaid);
|
|
10299
|
+
const paidAt = order.payments.filter(countsTowardPaid).at(-1)?.takenAt;
|
|
10300
|
+
const paidInFull = paidAt ? t("pos_checkout.paid_in_full_at", { time: shortTime(paidAt) }) : t("pos_checkout.paid_in_full");
|
|
10232
10301
|
const firstPending = order.payments.find((leg) => legStatus(leg) === "pending");
|
|
10233
10302
|
const askedLeg = order.payments.find((leg) => leg.id === asking);
|
|
10234
10303
|
const asked = askedLeg && descriptorOf(askedLeg);
|
|
@@ -10245,8 +10314,9 @@ function TenderLedger({ sale, methods, closing = false, confirmVoid = false }) {
|
|
|
10245
10314
|
/* @__PURE__ */ jsx172(Text46, { testID: `tender-leg-${leg.id}-status`, className: cn112("text-sm font-semibold", STATUS_TONE[status]), children: voided ? t("pos_checkout.cancelled") : t(STATUS_LABEL[status]) })
|
|
10246
10315
|
] }),
|
|
10247
10316
|
leg.reference ? /* @__PURE__ */ jsx172(Text46, { className: "text-sm text-muted-foreground", children: leg.reference }) : null,
|
|
10317
|
+
leg.takenAt ? /* @__PURE__ */ jsx172(Text46, { testID: `tender-leg-${leg.id}-time`, className: "text-sm text-muted-foreground", children: shortTime(leg.takenAt) }) : null,
|
|
10248
10318
|
leg === firstPending ? /* @__PURE__ */ jsx172(Text46, { className: "text-sm text-muted-foreground", children: t("pos_checkout.next_leg") }) : null,
|
|
10249
|
-
descriptor && canVoidLeg(leg, descriptor) ? /* @__PURE__ */ jsx172(
|
|
10319
|
+
descriptor && canVoidLeg(leg, descriptor) && !heldTillLeg(order, leg) ? /* @__PURE__ */ jsx172(
|
|
10250
10320
|
Pressable46,
|
|
10251
10321
|
{
|
|
10252
10322
|
testID: `tender-leg-${leg.id}-void`,
|
|
@@ -10259,7 +10329,7 @@ function TenderLedger({ sale, methods, closing = false, confirmVoid = false }) {
|
|
|
10259
10329
|
) : null
|
|
10260
10330
|
] }, leg.id);
|
|
10261
10331
|
}),
|
|
10262
|
-
!closing && balance === 0 && settled ? /* @__PURE__ */ jsx172(Text46, { className: "text-sm text-success", children:
|
|
10332
|
+
!closing && balance === 0 && settled ? /* @__PURE__ */ jsx172(Text46, { className: "text-sm text-success", children: paidInFull }) : null,
|
|
10263
10333
|
confirmVoid ? /* @__PURE__ */ jsx172(
|
|
10264
10334
|
ConfirmDialog,
|
|
10265
10335
|
{
|
|
@@ -10289,7 +10359,7 @@ function TenderLedger({ sale, methods, closing = false, confirmVoid = false }) {
|
|
|
10289
10359
|
/* @__PURE__ */ jsxs109(View104, { testID: "tender-ledger-totals", className: "gap-1.5", children: [
|
|
10290
10360
|
row2(t("common.total"), order.totalMinor),
|
|
10291
10361
|
row2(t("pos_checkout.paid"), order.paidMinor),
|
|
10292
|
-
/* @__PURE__ */ jsx172(View104, { testID: "tender-ledger-lead", className: "mt-1.5 flex-row justify-between border-t border-border pt-2", children: balance === 0 && settled ? /* @__PURE__ */ jsx172(Text46, { className: "font-semibold text-success", children:
|
|
10362
|
+
/* @__PURE__ */ jsx172(View104, { testID: "tender-ledger-lead", className: "mt-1.5 flex-row justify-between border-t border-border pt-2", children: balance === 0 && settled ? /* @__PURE__ */ jsx172(Text46, { className: "font-semibold text-success", children: paidInFull }) : /* @__PURE__ */ jsxs109(Fragment37, { children: [
|
|
10293
10363
|
/* @__PURE__ */ jsx172(Text46, { className: "font-semibold text-foreground", children: t("pos_checkout.remaining") }),
|
|
10294
10364
|
/* @__PURE__ */ jsx172(Text46, { testID: "tender-ledger-remaining", className: "font-semibold text-foreground", children: money(order.balanceDueMinor) })
|
|
10295
10365
|
] }) })
|
|
@@ -10884,7 +10954,7 @@ function TenderPane({ sale, state, dispatch, methods, ledger = true, back = true
|
|
|
10884
10954
|
const chips = givesChange ? quickTenderedAmounts2(dueMinor, QUICK_CASH_STEPS.map((step) => step * 10 ** minorUnitDigits11(order.currency))) : [];
|
|
10885
10955
|
const balanceChip = method !== null && !givesChange && state.entryMode !== "percent" ? dueMinor : null;
|
|
10886
10956
|
const [onlyLeg] = order.payments;
|
|
10887
|
-
const cardReference = order.payments.length === 1 && onlyLeg.method === "external" && legStatus2(onlyLeg) === "captured" && balance === 0;
|
|
10957
|
+
const cardReference = order.payments.length === 1 && onlyLeg.method === "external" && legStatus2(onlyLeg) === "captured" && balance === 0 && !heldTillLeg(order, onlyLeg);
|
|
10888
10958
|
const hint = partPick ? pickRefused || entry === target ? t("pos_checkout.pick_amount_due", { amount: money(target) }) : givesChange && entry > target ? t("pos_checkout.change_due", { amount: money(entry - target) }) : "" : pickRefused ? t("pos_checkout.pick_amount_due", { amount: money(figures.roundedDueMinor) }) : noChange ? t("pos_checkout.no_change_for_method", { amount: money(balance), method: method?.title }) : entryChange > 0 ? t("pos_checkout.change_due", { amount: money(entryChange) }) : figures.appliedMinor < balance && figures.entryMinor > 0 ? t("pos_checkout.part_payment_left", { left: money(left) }) : "";
|
|
10889
10959
|
const refused = tillLegsTheStoreRefuses(order);
|
|
10890
10960
|
const refusedMinor = order.payments.filter((leg) => refused.includes(leg.id)).reduce((total, leg) => total + leg.amountMinor, 0);
|
|
@@ -11052,7 +11122,7 @@ function TenderPane({ sale, state, dispatch, methods, ledger = true, back = true
|
|
|
11052
11122
|
] }) : null,
|
|
11053
11123
|
refused.length > 0 ? /* @__PURE__ */ jsxs114(Fragment41, { children: [
|
|
11054
11124
|
/* @__PURE__ */ jsx177(Text49, { testID: "tender-store-holds", className: "text-foreground", children: t("pos_checkout.store_holds_payment", { amount: money(refusedMinor) }) }),
|
|
11055
|
-
refused.map((id) => /* @__PURE__ */ jsx177(Pressable49, { testID: `tender-leg-${id}-remove`, accessibilityRole: "button", onPress: () => sale.removeTender(id), className: button5, children: /* @__PURE__ */ jsx177(Text49, { className: "text-center text-foreground", children: t("pos_checkout.remove_payment") }) }, id))
|
|
11125
|
+
refused.filter((id) => !order.payments.some((leg) => leg.id === id && heldTillLeg(order, leg))).map((id) => /* @__PURE__ */ jsx177(Pressable49, { testID: `tender-leg-${id}-remove`, accessibilityRole: "button", onPress: () => sale.removeTender(id), className: button5, children: /* @__PURE__ */ jsx177(Text49, { className: "text-center text-foreground", children: t("pos_checkout.remove_payment") }) }, id))
|
|
11056
11126
|
] }) : null,
|
|
11057
11127
|
/* @__PURE__ */ jsx177(
|
|
11058
11128
|
Pressable49,
|
|
@@ -11751,6 +11821,7 @@ function Catalogue({
|
|
|
11751
11821
|
return next;
|
|
11752
11822
|
}) : void 0,
|
|
11753
11823
|
renderExpanded: tableRow?.expand ? variantRows : void 0,
|
|
11824
|
+
variationsButton: tableRow?.variationsButton,
|
|
11754
11825
|
cartQuantity: (doc) => quantities.get(traits.getId(doc)) ?? 0
|
|
11755
11826
|
}
|
|
11756
11827
|
) : drillEntries.length > 0 ? /* @__PURE__ */ jsxs119(LevelWrap, { level: true, onBack: () => setDrillId(null), children: [
|
|
@@ -12147,11 +12218,17 @@ function PrinterValue({ printers, printerId, autoPrinterName, onPrinterChange })
|
|
|
12147
12218
|
] });
|
|
12148
12219
|
}
|
|
12149
12220
|
var EMAIL_PATTERN = /^[^\s@]+@[^\s@]+$/;
|
|
12150
|
-
|
|
12221
|
+
var SEND_FAILED = "Could not send the receipt.";
|
|
12222
|
+
function EmailSentLine({ queued }) {
|
|
12223
|
+
const t = useT();
|
|
12224
|
+
return /* @__PURE__ */ jsx186(Text, { testID: "receipt-email-sent", className: "py-2 text-sm text-foreground", children: t(queued ? "receipt.email_queued" : "receipt.email_sent") });
|
|
12225
|
+
}
|
|
12226
|
+
function ReceiptEmailForm({ email, onDone }) {
|
|
12151
12227
|
const [text, setText] = useState54(email.defaultAddress ?? "");
|
|
12152
12228
|
const [save, setSave] = useState54(false);
|
|
12153
12229
|
const [error, setError] = useState54(null);
|
|
12154
12230
|
const [sending, setSending] = useState54(false);
|
|
12231
|
+
const [sent, setSent] = useState54(null);
|
|
12155
12232
|
const send = async () => {
|
|
12156
12233
|
if (sending) return;
|
|
12157
12234
|
const address = text.trim();
|
|
@@ -12166,12 +12243,14 @@ function EmailForm({ email, onDone }) {
|
|
|
12166
12243
|
refusal = await result;
|
|
12167
12244
|
}
|
|
12168
12245
|
} catch (cause) {
|
|
12169
|
-
refusal = cause instanceof Error ? cause.message :
|
|
12246
|
+
refusal = cause instanceof Error ? cause.message : SEND_FAILED;
|
|
12170
12247
|
}
|
|
12171
12248
|
setSending(false);
|
|
12172
|
-
if (refusal
|
|
12173
|
-
|
|
12249
|
+
if (refusal !== null) return setError(refusal || SEND_FAILED);
|
|
12250
|
+
setSent(email.offline ? "queued" : "sent");
|
|
12251
|
+
onDone?.(Boolean(email.offline));
|
|
12174
12252
|
};
|
|
12253
|
+
if (sent) return /* @__PURE__ */ jsx186(EmailSentLine, { queued: sent === "queued" });
|
|
12175
12254
|
return /* @__PURE__ */ jsxs122(View114, { testID: "receipt-email-form", className: "gap-2 py-2", children: [
|
|
12176
12255
|
/* @__PURE__ */ jsx186(Text, { className: "text-sm font-medium text-foreground", children: "Email Address" }),
|
|
12177
12256
|
/* @__PURE__ */ jsx186(Input, { children: /* @__PURE__ */ jsx186(
|
|
@@ -12226,7 +12305,6 @@ function ReceiptSheet({
|
|
|
12226
12305
|
downloadingPdf = false,
|
|
12227
12306
|
children
|
|
12228
12307
|
}) {
|
|
12229
|
-
const t = useT();
|
|
12230
12308
|
const [sent, setSent] = useState54(null);
|
|
12231
12309
|
const [emailOpen, setEmailOpen] = useState54(false);
|
|
12232
12310
|
if (!open && (emailOpen || sent)) {
|
|
@@ -12244,11 +12322,11 @@ function ReceiptSheet({
|
|
|
12244
12322
|
/* @__PURE__ */ jsx186(SheetRow, { testID: "print-sheet-printer", label: "Printer", children: printers && printers.length > 0 ? /* @__PURE__ */ jsx186(PrinterValue, { printers, printerId, autoPrinterName, onPrinterChange }) : /* @__PURE__ */ jsx186(Text, { className: "text-sm text-foreground", children: printerLabel }) })
|
|
12245
12323
|
] }),
|
|
12246
12324
|
/* @__PURE__ */ jsx186(ScrollView22, { className: "flex-1", contentContainerClassName: "pb-2", children }),
|
|
12247
|
-
email && emailOpen ? /* @__PURE__ */ jsx186(
|
|
12325
|
+
email && emailOpen ? /* @__PURE__ */ jsx186(ReceiptEmailForm, { email, onDone: (queued) => {
|
|
12248
12326
|
setEmailOpen(false);
|
|
12249
12327
|
setSent(queued ? "queued" : "sent");
|
|
12250
12328
|
} }) : null,
|
|
12251
|
-
email && sent ? /* @__PURE__ */ jsx186(
|
|
12329
|
+
email && sent ? /* @__PURE__ */ jsx186(EmailSentLine, { queued: sent === "queued" }) : null,
|
|
12252
12330
|
/* @__PURE__ */ jsxs122(DialogFooter, { bordered: true, className: "gap-2", testID: "receipt-footer", children: [
|
|
12253
12331
|
/* @__PURE__ */ jsx186(DialogClose, { asChild: true, children: /* @__PURE__ */ jsx186(Button, { variant: "outline", testID: "receipt-close-button", children: /* @__PURE__ */ jsx186(Text, { children: "Close" }) }) }),
|
|
12254
12332
|
onEmailPress ? /* @__PURE__ */ jsx186(Button, { variant: "outline", testID: "receipt-email-button", onPress: onEmailPress, children: /* @__PURE__ */ jsx186(Text, { children: "Email Receipt" }) }) : null,
|
|
@@ -12286,14 +12364,6 @@ function ReceiptSheet({
|
|
|
12286
12364
|
// src/sale/sync-status.tsx
|
|
12287
12365
|
import { useEffect as useEffect23, useRef as useRef25, useState as useState55 } from "react";
|
|
12288
12366
|
import { AccessibilityInfo as AccessibilityInfo4, Platform as Platform21, Text as Text56, View as View115 } from "react-native";
|
|
12289
|
-
|
|
12290
|
-
// src/sale/since-text.ts
|
|
12291
|
-
function sinceText(clock2) {
|
|
12292
|
-
const time = (t) => new Date(t).toLocaleTimeString(void 0, { hour: "numeric", minute: "2-digit" });
|
|
12293
|
-
return clock2.firstFailedAt === void 0 ? "about " + time(clock2.since) : time(clock2.firstFailedAt);
|
|
12294
|
-
}
|
|
12295
|
-
|
|
12296
|
-
// src/sale/sync-status.tsx
|
|
12297
12367
|
import { Fragment as Fragment47, jsx as jsx187, jsxs as jsxs123 } from "react/jsx-runtime";
|
|
12298
12368
|
var PULL_NOTICE_TEXT = {
|
|
12299
12369
|
unauthorized: {
|
|
@@ -12334,6 +12404,7 @@ var REFUSED = (n, waiting) => n === 1 ? `1 sale needs attention${waiting} \xB7 T
|
|
|
12334
12404
|
var REFUSED_DETAIL = "Refused sales stay on this till under Needs attention, each with what to do next.";
|
|
12335
12405
|
var SALES_REFUSED = "The online store refused the last send. This till will try again with the next sale, or when the app is reopened.";
|
|
12336
12406
|
var TILL_UPDATES_REFUSED = "The online store refused the last send. This till will try again with the next till update, or when the app is reopened.";
|
|
12407
|
+
var STORE_VERSION_UNKNOWN = "The online store didn't say which POS plugin version it runs.";
|
|
12337
12408
|
var count = (n, noun) => `${n} ${noun}${n === 1 ? "" : "s"}`;
|
|
12338
12409
|
function useAnnounceOnIos(...texts) {
|
|
12339
12410
|
const announced = useRef25(texts);
|
|
@@ -12380,6 +12451,7 @@ function SyncStatus({ state, registerState, pluginName = "the POS plugin", pullN
|
|
|
12380
12451
|
] }) : null,
|
|
12381
12452
|
/* @__PURE__ */ jsx187(Text56, { accessibilityLabel: spoken, accessibilityLiveRegion: "polite", className: "px-4 py-2 text-xs text-muted-foreground", children: spoken }),
|
|
12382
12453
|
doing ? /* @__PURE__ */ jsx187(Text56, { className: "px-4 pb-2 text-xs text-muted-foreground", children: doing }) : null,
|
|
12454
|
+
doing && outbox.lastRetryReason === "store_version_unknown" ? /* @__PURE__ */ jsx187(Text56, { className: "px-4 pb-2 text-xs text-muted-foreground", children: STORE_VERSION_UNKNOWN }) : null,
|
|
12383
12455
|
refused ? /* @__PURE__ */ jsx187(Text56, { className: "px-4 pb-2 text-xs text-muted-foreground", children: REFUSED_DETAIL }) : null,
|
|
12384
12456
|
oneDetail && notice ? /* @__PURE__ */ jsx187(Text56, { className: "px-4 pb-2 text-xs text-muted-foreground", children: notice.detail }) : backendMissing ? /* @__PURE__ */ jsx187(Text56, { className: "px-4 pb-2 text-xs text-muted-foreground", children: BACKEND_MISSING_DETAIL.replace("{pluginName}", () => pluginName).replace("{lastTime}", () => upToDate ? " the last time it checked" : "") }) : null
|
|
12385
12457
|
] });
|
|
@@ -12389,7 +12461,7 @@ function SyncStatus({ state, registerState, pluginName = "the POS plugin", pullN
|
|
|
12389
12461
|
import { useEffect as useEffect24, useId as useId4, useRef as useRef26, useState as useState56 } from "react";
|
|
12390
12462
|
import { Pressable as Pressable55, ScrollView as ScrollView23, Text as Text57, View as View116 } from "react-native";
|
|
12391
12463
|
import { useFormatMoney as useFormatMoney25, knownWarnings } from "@tallyui/core";
|
|
12392
|
-
import { extrasNotSent, isRequeueableOrder, needsAttention, noteDelivery as noteDelivery2, refundDueOf, UPDATE_UNSENDABLE, UPDATE_UNSENDABLE_MESSAGE } from "@tallyui/pos";
|
|
12464
|
+
import { extrasNotSent, isRequeueableOrder, needsAttention, noteDelivery as noteDelivery2, refundDueOf, REOPENABLE_CODES, UPDATE_UNSENDABLE, UPDATE_UNSENDABLE_MESSAGE } from "@tallyui/pos";
|
|
12393
12465
|
import { Fragment as Fragment48, jsx as jsx188, jsxs as jsxs124 } from "react/jsx-runtime";
|
|
12394
12466
|
var STATUS_LABEL2 = { pending: "Waiting to sync", applied: "Synced", rejected: "Not accepted" };
|
|
12395
12467
|
var FIGURE_LABELS = /* @__PURE__ */ new Map([["subtotalMinor", "Subtotal"], ["taxMinor", "Tax"], ["discountMinor", "Discount"]]);
|
|
@@ -12405,7 +12477,9 @@ var REFUSAL_SENTENCES = /* @__PURE__ */ new Map([
|
|
|
12405
12477
|
["unknown_variant", "The online store refused this sale: that product variation no longer exists."],
|
|
12406
12478
|
["invalid_quantity", "The online store refused this sale: a quantity or a discount on it isn't allowed."],
|
|
12407
12479
|
["underpaid", "The online store refused this sale: the payments add up to less than the total."],
|
|
12408
|
-
["unsupported_currency", "The online store refused this sale: the store doesn't take this currency."]
|
|
12480
|
+
["unsupported_currency", "The online store refused this sale: the store doesn't take this currency."],
|
|
12481
|
+
["coupon_invalid", "The online store refused this sale: a coupon on it isn't valid now. Reopen it to sell it again."],
|
|
12482
|
+
["total_mismatch", "The online store refused this sale: its total didn't match the store's. Reopen it to sell it again."]
|
|
12409
12483
|
]);
|
|
12410
12484
|
var refusalSentence = (code) => REFUSAL_SENTENCES.get(code ?? "") ?? REFUSAL_SENTENCES.get("platform_error");
|
|
12411
12485
|
var REOPEN_AGAIN_SENTENCE = "This order was changed in the online store after it was reopened here, so your change wasn't sent. Reopen the order and make the change again.";
|
|
@@ -12432,11 +12506,34 @@ function OrderSyncNotices({ order, stuck, children }) {
|
|
|
12432
12506
|
knownWarnings(order.warnings).filter((warning) => warning.code !== "register_session_unknown").map((warning, index) => /* @__PURE__ */ jsx188(View116, { className: "border-l-4 border-warning pl-2", children: /* @__PURE__ */ jsx188(Text57, { className: "text-foreground", children: warning.code === "insufficient_stock" ? `${warning.quantity} sold without stock: ${order.lines.find((line) => line.variantId === warning.variantId)?.name}` : warning.code === "tax_rate_mismatch" ? `Tax at ${(warning.ratePpm / 1e4).toLocaleString(void 0, { maximumFractionDigits: 4 })}%: store ${formatMoney2({ amount: warning.serverMinor, currency: order.currency })} vs POS ${formatMoney2({ amount: warning.expectedMinor, currency: order.currency })}` : warning.code === "customer_ignored" ? `The online store didn't recognise the customer on this sale, so it was saved as a guest sale. Customer id: ${warning.customerId}.` : warning.code === "figures_mismatch" ? `The online store worked out different figures for this sale. ${warning.fields.map(({ field, tillMinor, serverMinor }) => `${FIGURE_LABELS.get(field) ?? field}: till ${formatMoney2({ amount: tillMinor, currency: order.currency })}, store ${formatMoney2({ amount: serverMinor, currency: order.currency })}.`).join(" ")}` : warning.code === "line_figures_mismatch" ? ((n) => `The online store worked out different figures for ${n === 1 ? "one line" : `${n} lines`} of this sale.`)(new Set(warning.lines.map((line) => line.lineId)).size) : warning.bridgeMinor !== void 0 ? `Store calculated ${formatMoney2({ amount: warning.serverMinor, currency: order.currency })}; a rounding line of ${warning.bridgeMinor > 0 ? "+" : ""}${formatMoney2({ amount: warning.bridgeMinor, currency: order.currency })} brought it to ${formatMoney2({ amount: warning.expectedMinor, currency: order.currency })}` : `Store total ${formatMoney2({ amount: warning.serverMinor, currency: order.currency })} vs POS ${formatMoney2({ amount: warning.expectedMinor, currency: order.currency })}` }) }, index))
|
|
12433
12507
|
] });
|
|
12434
12508
|
}
|
|
12435
|
-
function OrdersList({ orders, onRetry, formatDate = defaultFormatDate2, footer, stuck, history, onOpen }) {
|
|
12509
|
+
function OrdersList({ orders, onRetry, formatDate = defaultFormatDate2, footer, stuck, history, onOpen, onReopen, onResume }) {
|
|
12436
12510
|
const formatMoney2 = useFormatMoney25();
|
|
12437
12511
|
const hintId = useId4();
|
|
12438
12512
|
const retrying = useRef26(/* @__PURE__ */ new Set());
|
|
12439
12513
|
const [retryingIds, setRetryingIds] = useState56(/* @__PURE__ */ new Set());
|
|
12514
|
+
const reopening = useRef26(/* @__PURE__ */ new Set());
|
|
12515
|
+
const [reopens, setReopens] = useState56(/* @__PURE__ */ new Map());
|
|
12516
|
+
const setReopen = (id, state) => setReopens((current) => {
|
|
12517
|
+
const next = new Map(current);
|
|
12518
|
+
if (state) next.set(id, state);
|
|
12519
|
+
else next.delete(id);
|
|
12520
|
+
return next;
|
|
12521
|
+
});
|
|
12522
|
+
async function reopen(order, options) {
|
|
12523
|
+
if (!onReopen || reopening.current.has(order.id)) return;
|
|
12524
|
+
reopening.current.add(order.id);
|
|
12525
|
+
setReopen(order.id, { ...reopens.get(order.id), busy: true });
|
|
12526
|
+
try {
|
|
12527
|
+
await onReopen(order, options);
|
|
12528
|
+
setReopen(order.id);
|
|
12529
|
+
} catch (error) {
|
|
12530
|
+
const reason = error?.reason;
|
|
12531
|
+
const toCollectMinor = error?.toCollectMinor;
|
|
12532
|
+
setReopen(order.id, reason === "coupon_carry_inexact" && typeof toCollectMinor === "number" ? { toCollectMinor } : { failed: typeof reason === "string" ? reason : null });
|
|
12533
|
+
} finally {
|
|
12534
|
+
reopening.current.delete(order.id);
|
|
12535
|
+
}
|
|
12536
|
+
}
|
|
12440
12537
|
const [expanded, setExpanded] = useState56(/* @__PURE__ */ new Set());
|
|
12441
12538
|
useEffect24(() => {
|
|
12442
12539
|
for (const id of retrying.current) {
|
|
@@ -12485,6 +12582,9 @@ function OrdersList({ orders, onRetry, formatDate = defaultFormatDate2, footer,
|
|
|
12485
12582
|
const refundDueMinor = refundDueOf(order);
|
|
12486
12583
|
const key = `${section.title}:${order.id}`;
|
|
12487
12584
|
const isExpanded = expanded.has(key);
|
|
12585
|
+
const attention = section.title === "Needs attention";
|
|
12586
|
+
const reopenable = attention && !!onReopen && order.syncStatus === "rejected" && REOPENABLE_CODES.includes(order.error?.code ?? "") && order.storeOrderId === void 0 && order.reopenedAt === void 0;
|
|
12587
|
+
const reopenState = reopens.get(order.id);
|
|
12488
12588
|
return /* @__PURE__ */ jsxs124(View116, { className: "gap-1 rounded-md border border-border bg-card p-3", children: [
|
|
12489
12589
|
/* @__PURE__ */ jsx188(Text57, { id: `${hintId}-${sectionIndex}-${order.id}`, className: "hidden", children: "Shows the items and payments of this sale" }),
|
|
12490
12590
|
/* @__PURE__ */ jsxs124(
|
|
@@ -12531,15 +12631,56 @@ function OrdersList({ orders, onRetry, formatDate = defaultFormatDate2, footer,
|
|
|
12531
12631
|
refundDueMinor > 0 ? /* @__PURE__ */ jsx188(Text57, { testID: `order-refund-due-${order.id}`, className: "text-foreground", children: `Refund due ${formatMoney2({ amount: refundDueMinor, currency: order.currency })}` }) : null,
|
|
12532
12632
|
order.note ? /* @__PURE__ */ jsx188(Text57, { testID: `order-note-${order.id}`, className: "text-foreground", children: `Customer note: ${order.note}` }) : null
|
|
12533
12633
|
] }) : null,
|
|
12534
|
-
/* @__PURE__ */
|
|
12535
|
-
|
|
12536
|
-
|
|
12537
|
-
|
|
12538
|
-
if (await onRetry([order.id]) === 0) {
|
|
12539
|
-
retrying.current.delete(order.id);
|
|
12634
|
+
/* @__PURE__ */ jsxs124(OrderSyncNotices, { order, stuck, children: [
|
|
12635
|
+
section.title === "Needs attention" && isRequeueableOrder(order) ? /* @__PURE__ */ jsx188(Pressable55, { accessibilityRole: "button", disabled: retryingIds.has(order.id), onPress: async () => {
|
|
12636
|
+
if (retrying.current.has(order.id)) return;
|
|
12637
|
+
retrying.current.add(order.id);
|
|
12540
12638
|
setRetryingIds(new Set(retrying.current));
|
|
12541
|
-
|
|
12542
|
-
|
|
12639
|
+
if (await onRetry([order.id]) === 0) {
|
|
12640
|
+
retrying.current.delete(order.id);
|
|
12641
|
+
setRetryingIds(new Set(retrying.current));
|
|
12642
|
+
}
|
|
12643
|
+
}, className: "rounded-md bg-primary px-4 py-2", children: /* @__PURE__ */ jsx188(Text57, { className: "text-center font-semibold text-primary-foreground", children: "Retry" }) }) : null,
|
|
12644
|
+
attention && order.reopenedAt !== void 0 ? /* @__PURE__ */ jsxs124(Fragment48, { children: [
|
|
12645
|
+
/* @__PURE__ */ jsx188(Text57, { testID: `order-${order.id}-reopened`, className: "text-muted-foreground", children: "Reopened as a parked sale." }),
|
|
12646
|
+
onResume ? /* @__PURE__ */ jsx188(
|
|
12647
|
+
Pressable55,
|
|
12648
|
+
{
|
|
12649
|
+
accessibilityRole: "button",
|
|
12650
|
+
accessibilityLabel: `Resume order ${orderReference(order)}`,
|
|
12651
|
+
testID: `order-${order.id}-resume`,
|
|
12652
|
+
onPress: () => onResume(order),
|
|
12653
|
+
className: "rounded-md bg-primary px-4 py-2",
|
|
12654
|
+
children: /* @__PURE__ */ jsx188(Text57, { className: "text-center font-semibold text-primary-foreground", children: "Resume" })
|
|
12655
|
+
}
|
|
12656
|
+
) : null
|
|
12657
|
+
] }) : null,
|
|
12658
|
+
reopenable && reopenState?.failed !== void 0 ? /* @__PURE__ */ jsx188(Text57, { testID: `order-${order.id}-reopen-error`, className: "text-muted-foreground", children: reopenState.failed ? `This sale can't be reopened here (${reopenState.failed}).` : "This sale can't be reopened here." }) : reopenable ? /* @__PURE__ */ jsxs124(Fragment48, { children: [
|
|
12659
|
+
/* @__PURE__ */ jsx188(
|
|
12660
|
+
Pressable55,
|
|
12661
|
+
{
|
|
12662
|
+
accessibilityRole: "button",
|
|
12663
|
+
accessibilityLabel: `Reopen order ${orderReference(order)}`,
|
|
12664
|
+
testID: `order-${order.id}-reopen`,
|
|
12665
|
+
disabled: reopenState?.busy,
|
|
12666
|
+
onPress: () => reopen(order),
|
|
12667
|
+
className: "rounded-md bg-primary px-4 py-2",
|
|
12668
|
+
children: /* @__PURE__ */ jsx188(Text57, { className: "text-center font-semibold text-primary-foreground", children: "Reopen" })
|
|
12669
|
+
}
|
|
12670
|
+
),
|
|
12671
|
+
reopenState?.toCollectMinor !== void 0 ? /* @__PURE__ */ jsx188(
|
|
12672
|
+
Pressable55,
|
|
12673
|
+
{
|
|
12674
|
+
accessibilityRole: "button",
|
|
12675
|
+
testID: `order-${order.id}-reopen-without-coupon`,
|
|
12676
|
+
disabled: reopenState.busy,
|
|
12677
|
+
onPress: () => reopen(order, { withoutCoupons: true }),
|
|
12678
|
+
className: "rounded-md border border-border px-4 py-2",
|
|
12679
|
+
children: /* @__PURE__ */ jsx188(Text57, { className: "text-center font-semibold text-foreground", children: `Reopen without the coupon: ${formatMoney2({ amount: reopenState.toCollectMinor, currency: order.currency })} to collect` })
|
|
12680
|
+
}
|
|
12681
|
+
) : null
|
|
12682
|
+
] }) : null
|
|
12683
|
+
] })
|
|
12543
12684
|
] }, order.id);
|
|
12544
12685
|
})
|
|
12545
12686
|
] }, section.title)),
|
|
@@ -14219,6 +14360,7 @@ export {
|
|
|
14219
14360
|
ParkedSales,
|
|
14220
14361
|
PaymentMethodCard,
|
|
14221
14362
|
PaymentSelector,
|
|
14363
|
+
PickStepper,
|
|
14222
14364
|
PlusIcon,
|
|
14223
14365
|
Popover,
|
|
14224
14366
|
PopoverContent,
|
|
@@ -14243,6 +14385,7 @@ export {
|
|
|
14243
14385
|
RadioGroup,
|
|
14244
14386
|
RadioGroupItem,
|
|
14245
14387
|
Receipt,
|
|
14388
|
+
ReceiptEmailForm,
|
|
14246
14389
|
ReceiptIcon,
|
|
14247
14390
|
ReceiptPreview,
|
|
14248
14391
|
ReceiptSheet,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tallyui/components",
|
|
3
|
-
"version": "4.0
|
|
3
|
+
"version": "4.2.0",
|
|
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": "^4.0
|
|
32
|
-
"@tallyui/primitives": "^4.0
|
|
33
|
-
"@tallyui/theme": "^4.0
|
|
31
|
+
"@tallyui/core": "^4.2.0",
|
|
32
|
+
"@tallyui/primitives": "^4.2.0",
|
|
33
|
+
"@tallyui/theme": "^4.2.0",
|
|
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": "4.0
|
|
42
|
+
"@tallyui/pos": "4.2.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@tallyui/connector-medusa": "4.0
|
|
46
|
-
"@tallyui/connector-vendure": "4.0
|
|
47
|
-
"@tallyui/connector-woocommerce": "4.0
|
|
48
|
-
"@tallyui/mock-api": "4.0
|
|
45
|
+
"@tallyui/connector-medusa": "4.2.0",
|
|
46
|
+
"@tallyui/connector-vendure": "4.2.0",
|
|
47
|
+
"@tallyui/connector-woocommerce": "4.2.0",
|
|
48
|
+
"@tallyui/mock-api": "4.2.0",
|
|
49
49
|
"@types/react": ">=18",
|
|
50
50
|
"react": "^19.2.4",
|
|
51
51
|
"react-native-svg": "15.12.1",
|
|
@@ -77,6 +77,7 @@
|
|
|
77
77
|
"pos_checkout.no_payments_yet": "No payments yet",
|
|
78
78
|
"pos_checkout.paid": "Paid",
|
|
79
79
|
"pos_checkout.paid_in_full": "Paid in full",
|
|
80
|
+
"pos_checkout.paid_in_full_at": "Paid in full · {time}",
|
|
80
81
|
"pos_checkout.paid_of_total": "{paid} of {total} paid",
|
|
81
82
|
"pos_checkout.part_payment_left": "Part payment · {left} left after this",
|
|
82
83
|
"pos_checkout.pick_amount_due": "This payment is {amount} for the picked items",
|
package/src/index.ts
CHANGED
|
@@ -248,11 +248,11 @@ export { TaxBasedOn, type TaxBasedOnProps } from './tax';
|
|
|
248
248
|
|
|
249
249
|
// Sale components
|
|
250
250
|
export {
|
|
251
|
-
Cart, CartBar, Tender, SplitTender, TenderPane, type TenderPaneProps, DiscountForm, DiscountChips, parseDiscount, discountLabel,
|
|
251
|
+
Cart, PickStepper, CartBar, Tender, SplitTender, TenderPane, type TenderPaneProps, DiscountForm, DiscountChips, parseDiscount, discountLabel,
|
|
252
252
|
PriceForm, parsePrice, LinePopover, type LinePopoverProps,
|
|
253
253
|
ChargeForm, type ChargeFormProps,
|
|
254
254
|
OrderNoteSheet, type OrderNoteSheetProps,
|
|
255
|
-
Catalogue, CatalogueSettingsForm, type CatalogueSettingsFormProps, formatStockSyncTime, Receipt, ReceiptSheet, type ReceiptSheetProps, type ReceiptSheetEmail, type ReceiptSheetTemplate, injectPrintStyle, SyncStatus, syncStatusQuiet, OrdersList, OrderSyncNotices, type OrderSyncNoticesProps, type OrderHistoryRow, orderReference,
|
|
255
|
+
Catalogue, CatalogueSettingsForm, type CatalogueSettingsFormProps, formatStockSyncTime, Receipt, ReceiptSheet, ReceiptEmailForm, type ReceiptEmailFormProps, type ReceiptSheetProps, type ReceiptSheetEmail, type ReceiptSheetTemplate, injectPrintStyle, SyncStatus, syncStatusQuiet, OrdersList, OrderSyncNotices, type OrderSyncNoticesProps, type OrderHistoryRow, orderReference,
|
|
256
256
|
ParkedSales, type ParkedSalesProps, OpenSaleTabs, type OpenSaleTabsProps, CustomerDisplayScreen,
|
|
257
257
|
CustomerDisplayPairing, type CustomerDisplayPairingProps,
|
|
258
258
|
ProductFilterBar, DEFAULT_PRODUCT_FILTERS, PRODUCT_FILTER_CHIPS, type ProductFilterBarProps, type ProductFilterChip, type ProductFilters, type ProductTermFilter, type FilterOption,
|
|
@@ -4,7 +4,7 @@ import { useProductTraits, useTraitContext, useStockOverlaid, type ProductTraits
|
|
|
4
4
|
import { productSortValue, sortProducts, type ProductSort, type ProductSortValue } from '@tallyui/pos';
|
|
5
5
|
import { cn } from '@tallyui/theme';
|
|
6
6
|
import { Table, TableHeader, TableBody, TableRow, TableHead, TableCell, Text, VStack, IconButton, PlusIcon, ChevronRightIcon,
|
|
7
|
-
Skeleton, skeletonCount } from '../ui';
|
|
7
|
+
ChevronDownIcon, Skeleton, skeletonCount } from '../ui';
|
|
8
8
|
import { MinTargetBand } from '../scale/min-target';
|
|
9
9
|
import { usePointer } from '../scale/use-pointer';
|
|
10
10
|
import { ProductImage } from './product-image';
|
|
@@ -88,8 +88,12 @@ export interface ProductTableProps extends Omit<ViewProps, 'children'> {
|
|
|
88
88
|
/** With renderExpanded and showThumbnail, a product with more than one variant has its thumbnail toggle its
|
|
89
89
|
* expanded block: a button labelled "Show variations" with aria-expanded. A press calls this, never onSelect. */
|
|
90
90
|
onToggleExpand?: (doc: ProductTableRowDoc) => void;
|
|
91
|
-
/** The block drawn under an expanded row (e.g. its variant rows), indented by the thumbnail column. */
|
|
91
|
+
/** The block drawn under an expanded row (e.g. its variant rows), indented by the thumbnail column when it shows. */
|
|
92
92
|
renderExpanded?: (doc: ProductTableRowDoc) => ReactNode;
|
|
93
|
+
/** v2's "{count} variations" button under the first cell's content, with a chevron and aria-expanded, on a product
|
|
94
|
+
* with more than one variant. A press calls onToggleExpand, never onSelect; needs onToggleExpand and renderExpanded,
|
|
95
|
+
* and makes such rows expandable without showThumbnail. Default false. */
|
|
96
|
+
variationsButton?: boolean;
|
|
93
97
|
/** With no items, draw the header and skeleton rows instead of emptyState, as WCPOS v2's DataTableSkeleton. */
|
|
94
98
|
loading?: boolean;
|
|
95
99
|
className?: string;
|
|
@@ -121,7 +125,7 @@ export function useDefaultProductColumns(options?: { currencySymbol?: string }):
|
|
|
121
125
|
export function ProductTable({
|
|
122
126
|
items, columns, sort, defaultSort = null, onSortChange, sortItems = true, onSelect,
|
|
123
127
|
searchSlot, filterSlot, emptyState, showUnsellable = false, currencySymbol, showThumbnail = false,
|
|
124
|
-
showAddButton = false, cartQuantity, isExpanded, onToggleExpand, renderExpanded, loading = false, className, ...viewProps
|
|
128
|
+
showAddButton = false, cartQuantity, isExpanded, onToggleExpand, renderExpanded, variationsButton = false, loading = false, className, ...viewProps
|
|
125
129
|
}: ProductTableProps): JSX.Element {
|
|
126
130
|
// Without a ConnectorProvider, custom columns can render without traits.
|
|
127
131
|
let traits: ReturnType<typeof useProductTraits> | undefined;
|
|
@@ -190,7 +194,8 @@ export function ProductTable({
|
|
|
190
194
|
const key = String(item.id ?? index);
|
|
191
195
|
const variations = addButton && traits !== undefined && traits.getVariantCount(item) > 1;
|
|
192
196
|
const count = addButton && !variations ? cartQuantity?.(item) ?? 0 : 0;
|
|
193
|
-
const
|
|
197
|
+
const variantCount = traits?.getVariantCount(item) ?? 0;
|
|
198
|
+
const expandable = (thumbnail || variationsButton) && onToggleExpand !== undefined && renderExpanded !== undefined && variantCount > 1;
|
|
194
199
|
const expanded = expandable && (isExpanded?.(item) ?? false);
|
|
195
200
|
const row = (
|
|
196
201
|
<TableRow testID={onSelect ? undefined : 'product-row-' + key}>
|
|
@@ -199,9 +204,15 @@ export function ProductTable({
|
|
|
199
204
|
testID={'product-row-expand-' + key} onPress={(event) => { event.stopPropagation?.(); onToggleExpand!(item); }}>
|
|
200
205
|
<ProductImage doc={item} size={thumb} showPlaceholder className="rounded-md" /></Pressable> :
|
|
201
206
|
<ProductImage doc={item} size={thumb} showPlaceholder className="rounded-md" />}</TableCell> : null}
|
|
202
|
-
{resolvedColumns.map((column) => (
|
|
207
|
+
{resolvedColumns.map((column, cell) => (
|
|
203
208
|
<TableCell key={column.id} style={{ flex: column.flex ?? 1 }}
|
|
204
|
-
className={cn('px-3 py-1.5', column.align && ALIGN[column.align])}>{column.render(item)}
|
|
209
|
+
className={cn('px-3 py-1.5', column.align && ALIGN[column.align])}>{column.render(item)}
|
|
210
|
+
{cell === 0 && expandable && variationsButton ? <Pressable accessibilityRole="button" aria-expanded={expanded}
|
|
211
|
+
testID={'product-row-variations-' + key} className="mt-0.5 self-start flex-row items-center gap-1"
|
|
212
|
+
onPress={(event) => { event.stopPropagation?.(); onToggleExpand!(item); }}>
|
|
213
|
+
<View className="text-muted-foreground">{expanded ? <ChevronDownIcon size={14} /> : <ChevronRightIcon size={14} />}</View>
|
|
214
|
+
<Text className="text-xs text-muted-foreground">{`${variantCount} variations`}</Text>
|
|
215
|
+
</Pressable> : null}</TableCell>
|
|
205
216
|
))}
|
|
206
217
|
{addButton ? (
|
|
207
218
|
<TableCell style={{ width: ACTION_WIDTH }} className="flex-none items-center justify-center px-0 py-1.5">
|
|
@@ -222,7 +233,7 @@ export function ProductTable({
|
|
|
222
233
|
{row}
|
|
223
234
|
</Pressable>
|
|
224
235
|
) : row}
|
|
225
|
-
{expanded ? <View testID={'product-row-expanded-' + key} style={{ paddingLeft: thumb + CELL_PAD_X }}
|
|
236
|
+
{expanded ? <View testID={'product-row-expanded-' + key} style={{ paddingLeft: thumbnail ? thumb + CELL_PAD_X : 0 }}
|
|
226
237
|
className="border-b border-border">{renderExpanded!(item)}</View> : null}
|
|
227
238
|
</>;
|
|
228
239
|
}}
|