@tallyui/components 3.10.0 → 3.11.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
@@ -589,6 +589,8 @@ declare function ProductVariantPicker({ options, selected, onSelect, className,
589
589
 
590
590
  interface CartLineProps extends Omit<HStackProps, 'children'> {
591
591
  name: string;
592
+ /** The variant's chosen options, one "Name: Value" row each under the name. */
593
+ attributes?: Record<string, string>;
592
594
  quantity: number;
593
595
  unitPrice: Money;
594
596
  lineTotal: Money;
@@ -602,7 +604,7 @@ interface CartLineProps extends Omit<HStackProps, 'children'> {
602
604
  * <CartLine name="Coffee" quantity={2} unitPrice={unitPrice} lineTotal={lineTotal} />
603
605
  * ```
604
606
  */
605
- declare function CartLine({ name, quantity, unitPrice, lineTotal, locale, className, ...props }: CartLineProps): react_jsx_runtime.JSX.Element;
607
+ declare function CartLine({ name, attributes, quantity, unitPrice, lineTotal, locale, className, ...props }: CartLineProps): react_jsx_runtime.JSX.Element;
606
608
 
607
609
  interface CartTotalProps extends Omit<VStackProps, 'children'> {
608
610
  subtotal: Money;
@@ -616,6 +618,8 @@ interface CartTotalProps extends Omit<VStackProps, 'children'> {
616
618
  taxInclusive?: boolean;
617
619
  locale?: string;
618
620
  className?: string;
621
+ /** Rows rendered directly under Subtotal, e.g. a platform's coupon chips. */
622
+ afterSubtotal?: ReactNode;
619
623
  }
620
624
  /**
621
625
  * Displays a cart summary: subtotal, optional discount, optional tax, and total, in the receipt's order.
@@ -624,7 +628,7 @@ interface CartTotalProps extends Omit<VStackProps, 'children'> {
624
628
  * <CartTotal subtotal={subtotal} discount={discount} taxLines={taxLines} total={total} />
625
629
  * ```
626
630
  */
627
- declare function CartTotal({ subtotal, taxLines, discount, total, taxInclusive, locale, className, ...props }: CartTotalProps): react_jsx_runtime.JSX.Element;
631
+ declare function CartTotal({ subtotal, taxLines, discount, total, taxInclusive, locale, className, afterSubtotal, ...props }: CartTotalProps): react_jsx_runtime.JSX.Element;
628
632
 
629
633
  interface CartPanelProps<T> extends Omit<VStackProps, 'children'> {
630
634
  /** Cart line items to render */
@@ -1271,7 +1275,7 @@ interface ConnectorStatusProps extends Omit<ViewProps, 'children'> {
1271
1275
  declare function ConnectorStatus({ name, status, lastSync, error, className, unsoldCount, unsoldStale, formatUnsold, ...viewProps }: ConnectorStatusProps): react_jsx_runtime.JSX.Element;
1272
1276
 
1273
1277
  /** `taxLabel` names each tax row; VAT isn't universal, so a platform passes its own (medusapos passes `VAT ${rate}%`). */
1274
- declare function Cart({ sale, taxLabel, canEditPrice, onPriceChange, taxClasses }: {
1278
+ declare function Cart({ sale, taxLabel, canEditPrice, onPriceChange, taxClasses, afterSubtotal }: {
1275
1279
  sale: ReturnType<typeof useSale>;
1276
1280
  taxLabel?: (ratePpm: number) => string;
1277
1281
  taxClasses?: ReadonlyArray<{
@@ -1287,6 +1291,8 @@ declare function Cart({ sale, taxLabel, canEditPrice, onPriceChange, taxClasses
1287
1291
  toMinor: number;
1288
1292
  reason?: string;
1289
1293
  }) => void;
1294
+ /** Rows under the totals' Subtotal, e.g. the platform's coupon chips (passed to CartTotal). */
1295
+ afterSubtotal?: ReactNode;
1290
1296
  }): react_jsx_runtime.JSX.Element;
1291
1297
 
1292
1298
  /** Phone mode's cart summary (medusapos ADR 0009): the whole bar is one button; the total is the cart's own Total row. */
package/dist/index.js CHANGED
@@ -2126,10 +2126,11 @@ function ProductVariantPicker({
2126
2126
  import { formatMoney as formatMoney2 } from "@tallyui/core";
2127
2127
  import { cn as cn48 } from "@tallyui/theme";
2128
2128
  import { jsx as jsx51, jsxs as jsxs13 } from "react/jsx-runtime";
2129
- function CartLine({ name, quantity, unitPrice, lineTotal, locale, className, ...props }) {
2129
+ function CartLine({ name, attributes, quantity, unitPrice, lineTotal, locale, className, ...props }) {
2130
2130
  return /* @__PURE__ */ jsxs13(HStack, { className: cn48("px-3 py-2.5", className), ...props, children: [
2131
2131
  /* @__PURE__ */ jsxs13(VStack, { space: "none", className: "flex-1 gap-0.5", children: [
2132
2132
  /* @__PURE__ */ jsx51(Text, { className: "text-sm font-medium", numberOfLines: 1, children: name }),
2133
+ Object.entries(attributes ?? {}).map(([key, value]) => /* @__PURE__ */ jsx51(Text, { className: "text-xs text-muted-foreground", children: `${key}: ${value}` }, key)),
2133
2134
  /* @__PURE__ */ jsx51(Text, { className: "text-xs text-muted-foreground", children: `${formatMoney2(unitPrice, locale) ?? "\u2014"} \xD7 ${quantity}` })
2134
2135
  ] }),
2135
2136
  /* @__PURE__ */ jsx51(Text, { className: "text-sm font-semibold", children: formatMoney2(lineTotal, locale) ?? "\u2014" })
@@ -2148,6 +2149,7 @@ function CartTotal({
2148
2149
  taxInclusive,
2149
2150
  locale,
2150
2151
  className,
2152
+ afterSubtotal,
2151
2153
  ...props
2152
2154
  }) {
2153
2155
  return /* @__PURE__ */ jsxs14(VStack, { space: "none", className: cn49("gap-1.5 px-3 py-3", className), ...props, children: [
@@ -2155,6 +2157,7 @@ function CartTotal({
2155
2157
  /* @__PURE__ */ jsx52(Text, { className: "text-sm text-muted-foreground", children: "Subtotal" }),
2156
2158
  /* @__PURE__ */ jsx52(Text, { className: "text-sm", children: formatMoney3(subtotal, locale) ?? "\u2014" })
2157
2159
  ] }),
2160
+ afterSubtotal,
2158
2161
  discount && discount.amount > 0 && /* @__PURE__ */ jsxs14(HStack, { space: "none", className: "justify-between", children: [
2159
2162
  /* @__PURE__ */ jsx52(Text, { className: "text-sm text-muted-foreground", children: "Discount" }),
2160
2163
  /* @__PURE__ */ jsxs14(Text, { className: "text-sm", children: [
@@ -4375,7 +4378,7 @@ function ChargeForm({ currency, lineTax, taxClasses, shippingTaxFromStore, onApp
4375
4378
 
4376
4379
  // src/sale/cart.tsx
4377
4380
  import { Fragment as Fragment6, jsx as jsx93, jsxs as jsxs51 } from "react/jsx-runtime";
4378
- function Cart({ sale, taxLabel = (ratePpm) => `Tax ${ratePpm / 1e4}%`, canEditPrice = false, onPriceChange, taxClasses }) {
4381
+ function Cart({ sale, taxLabel = (ratePpm) => `Tax ${ratePpm / 1e4}%`, canEditPrice = false, onPriceChange, taxClasses, afterSubtotal }) {
4379
4382
  const { order } = sale;
4380
4383
  const money = (amount) => ({ amount, currency: order.currency });
4381
4384
  const { totals } = buildReceiptData(order, { storeName: "" });
@@ -4403,6 +4406,7 @@ function Cart({ sale, taxLabel = (ratePpm) => `Tax ${ratePpm / 1e4}%`, canEditPr
4403
4406
  CartLine,
4404
4407
  {
4405
4408
  name: line.name,
4409
+ attributes: line.attributes,
4406
4410
  quantity: line.quantity,
4407
4411
  unitPrice: money(line.unitPriceMinor),
4408
4412
  lineTotal: money(display(line.id).amountMinor)
@@ -4535,7 +4539,8 @@ function Cart({ sale, taxLabel = (ratePpm) => `Tax ${ratePpm / 1e4}%`, canEditPr
4535
4539
  discount: money(totals.discountMinor),
4536
4540
  total: money(totals.totalMinor),
4537
4541
  taxLines: taxRows,
4538
- taxInclusive: totals.taxInclusive
4542
+ taxInclusive: totals.taxInclusive,
4543
+ afterSubtotal
4539
4544
  }
4540
4545
  ),
4541
4546
  sale.error ? /* @__PURE__ */ jsx93(Text36, { accessibilityRole: "alert", className: "text-destructive", children: sale.error }) : null,
@@ -5070,6 +5075,7 @@ function Receipt({
5070
5075
  ] }),
5071
5076
  receipt.lineItems.map((line, index) => /* @__PURE__ */ jsxs56(View63, { children: [
5072
5077
  /* @__PURE__ */ jsx98(Text41, { className: "text-foreground", children: line.name }),
5078
+ Object.entries(line.attributes ?? {}).map(([name, value]) => /* @__PURE__ */ jsx98(Text41, { className: "text-muted-foreground", children: `${name}: ${value}` }, name)),
5073
5079
  row(`${line.quantity} \xD7 ${money(line.unitPriceMinor)}`, money(line.displayAmountMinor)),
5074
5080
  line.displayDiscounts.map((discount, i) => /* @__PURE__ */ jsx98(View63, { className: "pl-4", children: row(`${discountLabel(
5075
5081
  order.lineItems[index].discounts[i],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tallyui/components",
3
- "version": "3.10.0",
3
+ "version": "3.11.0",
4
4
  "type": "module",
5
5
  "description": "Universal POS UI components for Tally UI",
6
6
  "main": "./dist/index.js",
@@ -28,22 +28,22 @@
28
28
  "directory": "packages/components"
29
29
  },
30
30
  "peerDependencies": {
31
- "@tallyui/core": "^3.10.0",
32
- "@tallyui/primitives": "^3.10.0",
33
- "@tallyui/theme": "^3.10.0",
31
+ "@tallyui/core": "^3.11.0",
32
+ "@tallyui/primitives": "^3.11.0",
33
+ "@tallyui/theme": "^3.11.0",
34
34
  "react": ">=18",
35
35
  "react-native": ">=0.74",
36
36
  "react-native-svg": ">=15"
37
37
  },
38
38
  "dependencies": {
39
39
  "class-variance-authority": "^0.7.1",
40
- "@tallyui/pos": "3.10.0"
40
+ "@tallyui/pos": "3.11.0"
41
41
  },
42
42
  "devDependencies": {
43
- "@tallyui/connector-medusa": "3.10.0",
44
- "@tallyui/connector-vendure": "3.10.0",
45
- "@tallyui/connector-woocommerce": "3.10.0",
46
- "@tallyui/mock-api": "3.10.0",
43
+ "@tallyui/connector-medusa": "3.11.0",
44
+ "@tallyui/connector-vendure": "3.11.0",
45
+ "@tallyui/connector-woocommerce": "3.11.0",
46
+ "@tallyui/mock-api": "3.11.0",
47
47
  "@types/react": ">=18",
48
48
  "react": "^19.2.4",
49
49
  "react-native-svg": "15.12.1",
@@ -4,6 +4,8 @@ import { Text, HStack, VStack, type HStackProps } from '../ui';
4
4
 
5
5
  export interface CartLineProps extends Omit<HStackProps, 'children'> {
6
6
  name: string;
7
+ /** The variant's chosen options, one "Name: Value" row each under the name. */
8
+ attributes?: Record<string, string>;
7
9
  quantity: number;
8
10
  unitPrice: Money;
9
11
  lineTotal: Money;
@@ -18,11 +20,14 @@ export interface CartLineProps extends Omit<HStackProps, 'children'> {
18
20
  * <CartLine name="Coffee" quantity={2} unitPrice={unitPrice} lineTotal={lineTotal} />
19
21
  * ```
20
22
  */
21
- export function CartLine({ name, quantity, unitPrice, lineTotal, locale, className, ...props }: CartLineProps) {
23
+ export function CartLine({ name, attributes, quantity, unitPrice, lineTotal, locale, className, ...props }: CartLineProps) {
22
24
  return (
23
25
  <HStack className={cn('px-3 py-2.5', className)} {...props}>
24
26
  <VStack space="none" className="flex-1 gap-0.5">
25
27
  <Text className="text-sm font-medium" numberOfLines={1}>{name}</Text>
28
+ {Object.entries(attributes ?? {}).map(([key, value]) => (
29
+ <Text key={key} className="text-xs text-muted-foreground">{`${key}: ${value}`}</Text>
30
+ ))}
26
31
  <Text className="text-xs text-muted-foreground">
27
32
  {`${formatMoney(unitPrice, locale) ?? '—'} × ${quantity}`}
28
33
  </Text>
@@ -1,3 +1,4 @@
1
+ import type { ReactNode } from 'react';
1
2
  import { formatMoney, type Money } from '@tallyui/core';
2
3
  import { cn } from '@tallyui/theme';
3
4
  import { Text, HStack, VStack, type VStackProps } from '../ui';
@@ -11,6 +12,8 @@ export interface CartTotalProps extends Omit<VStackProps, 'children'> {
11
12
  taxInclusive?: boolean;
12
13
  locale?: string;
13
14
  className?: string;
15
+ /** Rows rendered directly under Subtotal, e.g. a platform's coupon chips. */
16
+ afterSubtotal?: ReactNode;
14
17
  }
15
18
 
16
19
  /**
@@ -28,6 +31,7 @@ export function CartTotal({
28
31
  taxInclusive,
29
32
  locale,
30
33
  className,
34
+ afterSubtotal,
31
35
  ...props
32
36
  }: CartTotalProps) {
33
37
  return (
@@ -37,6 +41,8 @@ export function CartTotal({
37
41
  <Text className="text-sm">{formatMoney(subtotal, locale) ?? '—'}</Text>
38
42
  </HStack>
39
43
 
44
+ {afterSubtotal}
45
+
40
46
  {discount && discount.amount > 0 && (
41
47
  <HStack space="none" className="justify-between">
42
48
  <Text className="text-sm text-muted-foreground">Discount</Text>
package/src/sale/cart.tsx CHANGED
@@ -1,4 +1,4 @@
1
- import { useState } from 'react';
1
+ import { useState, type ReactNode } from 'react';
2
2
  import { Pressable, Text, View } from 'react-native';
3
3
  import { formatMoney } from '@tallyui/core';
4
4
  import { buildReceiptData } from '@tallyui/pos';
@@ -9,13 +9,15 @@ import { PriceForm } from './price-form';
9
9
  import { ChargeForm } from './charge-form';
10
10
 
11
11
  /** `taxLabel` names each tax row; VAT isn't universal, so a platform passes its own (medusapos passes `VAT ${rate}%`). */
12
- export function Cart({ sale, taxLabel = (ratePpm: number) => `Tax ${ratePpm / 10000}%`, canEditPrice = false, onPriceChange, taxClasses }:
12
+ export function Cart({ sale, taxLabel = (ratePpm: number) => `Tax ${ratePpm / 10000}%`, canEditPrice = false, onPriceChange, taxClasses, afterSubtotal }:
13
13
  { sale: ReturnType<typeof useSale>; taxLabel?: (ratePpm: number) => string;
14
14
  taxClasses?: ReadonlyArray<{ id: string; label: string }>;
15
15
  /** Shows a Price action on each line. Pass the till's own permission; the control isn't shown without it. */
16
16
  canEditPrice?: boolean;
17
17
  /** Called after a price is applied, for the app's audit log. The reason is kept only here. */
18
18
  onPriceChange?: (change: { lineId: string; fromMinor: number; toMinor: number; reason?: string }) => void;
19
+ /** Rows under the totals' Subtotal, e.g. the platform's coupon chips (passed to CartTotal). */
20
+ afterSubtotal?: ReactNode;
19
21
  }) {
20
22
  const { order } = sale;
21
23
  const money = (amount: number) => ({ amount, currency: order.currency });
@@ -39,7 +41,7 @@ export function Cart({ sale, taxLabel = (ratePpm: number) => `Tax ${ratePpm / 10
39
41
  { id: 'discount', label: 'Discount', color: 'text-primary', onPress: () => setForm({ type: 'discount', lineId: line.id }) },
40
42
  ...(canEditPrice ? [{ id: 'price', label: 'Price', color: 'text-primary', onPress: () => setForm({ type: 'price', lineId: line.id }) }] : []),
41
43
  ]}>
42
- <CartLine name={line.name} quantity={line.quantity} unitPrice={money(line.unitPriceMinor)}
44
+ <CartLine name={line.name} attributes={line.attributes} quantity={line.quantity} unitPrice={money(line.unitPriceMinor)}
43
45
  lineTotal={money(display(line.id).amountMinor)} />
44
46
  </CartLineActions>
45
47
  <DiscountChips discounts={line.discounts} amounts={display(line.id).discounts} currency={order.currency} onRemove={sale.removeDiscount} />
@@ -95,7 +97,7 @@ export function Cart({ sale, taxLabel = (ratePpm: number) => `Tax ${ratePpm / 10
95
97
  footer={<View testID="cart-footer" className="gap-3 pb-4">
96
98
  {/* Exclusive: subtotal − discount + tax = total. Inclusive: subtotal − discount = total, the tax "incl.", not added. */}
97
99
  <CartTotal subtotal={money(totals.subtotalMinor)} discount={money(totals.discountMinor)} total={money(totals.totalMinor)}
98
- taxLines={taxRows} taxInclusive={totals.taxInclusive} />
100
+ taxLines={taxRows} taxInclusive={totals.taxInclusive} afterSubtotal={afterSubtotal} />
99
101
  {sale.error ? <Text accessibilityRole="alert" className="text-destructive">{sale.error}</Text> : null}
100
102
  <View className="flex-row gap-3">
101
103
  <Pressable accessibilityRole="button" disabled={!order.lineItems.length} onPress={() => sale.startTender('cash')} className={pay}>
@@ -48,6 +48,7 @@ export function Receipt({ order, posOrder, store, cashier, registerId, registerN
48
48
  {receipt.header.customer && <Text className="text-muted-foreground">Customer: {receipt.header.customer}</Text>}
49
49
  {receipt.lineItems.map((line, index) => <View key={index}>
50
50
  <Text className="text-foreground">{line.name}</Text>
51
+ {Object.entries(line.attributes ?? {}).map(([name, value]) => <Text key={name} className="text-muted-foreground">{`${name}: ${value}`}</Text>)}
51
52
  {/* Before any discount, then the line's own discounts as sub-rows (TallyUI ADR-063); they add up to the subtotal. */}
52
53
  {row(`${line.quantity} × ${money(line.unitPriceMinor)}`, money(line.displayAmountMinor))}
53
54
  {line.displayDiscounts.map((discount, i) => <View key={i} className="pl-4">{row(`${discountLabel(