@tallyui/components 3.3.0 → 3.5.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
@@ -8,8 +8,8 @@ import { VariantProps } from 'class-variance-authority';
8
8
  import { SvgProps } from 'react-native-svg';
9
9
  import { Separator as Separator$1, Label as Label$1, Tabs as Tabs$1, Dialog as Dialog$1, AlertDialog as AlertDialog$1, Select as Select$1, Combobox as Combobox$1, DropdownMenu as DropdownMenu$1, ContextMenu as ContextMenu$1, Popover as Popover$1, Tooltip as Tooltip$1, HoverCard as HoverCard$1, Accordion as Accordion$1, Collapsible as Collapsible$1, Checkbox as Checkbox$1, Switch as Switch$1, RadioGroup as RadioGroup$1, Toggle as Toggle$1, ToggleGroup as ToggleGroup$1, Progress as Progress$1, Slider as Slider$1, Image } from '@tallyui/primitives';
10
10
  export { TextClassContext } from '@tallyui/primitives';
11
- import { Money, CustomerTraits, Customer, CustomerInput, ProductTraits, SyncNotice, StoreSettingsChoices, StoreSettingsChoice } from '@tallyui/core';
12
- import { useRegisterSession, MovementType, useSale, AppliedDiscount, Discount, CatalogueEntry, SentOrder, PosOrder, OutboxState, ParkedOrderSummary } from '@tallyui/pos';
11
+ import { CatalogueView, ProductSortValue, ProductSort, useRegisterSession, MovementType, useSale, AppliedDiscount, Discount, CatalogueEntry, CatalogueViewState, SentOrder, PosOrder, OutboxState, ParkedOrderSummary } from '@tallyui/pos';
12
+ import { ProductTraits, TraitContext, Money, CustomerTraits, Customer, CustomerInput, ProductCategory, SyncNotice, StoreSettingsChoices, StoreSettingsChoice } from '@tallyui/core';
13
13
 
14
14
  declare const textVariants: (props?: ({
15
15
  variant?: "link" | "default" | null | undefined;
@@ -501,6 +501,57 @@ interface ProductGridProps extends Omit<VStackProps, 'children'> {
501
501
  */
502
502
  declare function ProductGrid({ items, renderItem, numColumns, searchSlot, filterSlot, emptyState, showUnsellable, className, ...viewProps }: ProductGridProps): react_jsx_runtime.JSX.Element;
503
503
 
504
+ interface ViewToggleProps extends Omit<ViewProps, 'children'> {
505
+ value: CatalogueView;
506
+ onChange: (view: CatalogueView) => void;
507
+ /** Default { grid: 'Grid', table: 'Table' }. */
508
+ labels?: {
509
+ grid?: string;
510
+ table?: string;
511
+ };
512
+ className?: string;
513
+ }
514
+ declare function ViewToggle({ value, onChange, labels, className, ...viewProps }: ViewToggleProps): JSX.Element;
515
+
516
+ interface ProductTableColumn<Doc = any> {
517
+ /** Stable id; the default columns use PRODUCT_SORT_FIELDS. */
518
+ id: string;
519
+ /** Header label. */
520
+ header: string;
521
+ render: (doc: Doc) => ReactNode;
522
+ /** The value the header sort orders by; omit to make the column unsortable. */
523
+ sortValue?: (doc: Doc) => ProductSortValue;
524
+ /** Flex weight of the column; default 1. */
525
+ flex?: number;
526
+ }
527
+ interface ProductTableProps extends Omit<ViewProps, 'children'> {
528
+ items: any[];
529
+ /** Default: trait columns with a ConnectorProvider, else none. */
530
+ columns?: ProductTableColumn[];
531
+ /** Controlled sort when not undefined (null = no sort). */
532
+ sort?: ProductSort | null;
533
+ /** Initial sort when uncontrolled; default null. */
534
+ defaultSort?: ProductSort | null;
535
+ onSortChange?: (sort: ProductSort | null) => void;
536
+ /** Sort rows here (default true); false leaves ordering to the app. */
537
+ sortItems?: boolean;
538
+ onSelect?: (doc: any) => void;
539
+ searchSlot?: ReactNode;
540
+ filterSlot?: ReactNode;
541
+ emptyState?: ReactNode;
542
+ showUnsellable?: boolean;
543
+ /** Passed to the default price column's ProductPrice. */
544
+ currencySymbol?: string;
545
+ className?: string;
546
+ }
547
+ declare function defaultProductColumns(traits: ProductTraits, context?: TraitContext, options?: {
548
+ currencySymbol?: string;
549
+ }): ProductTableColumn[];
550
+ declare function useDefaultProductColumns(options?: {
551
+ currencySymbol?: string;
552
+ }): ProductTableColumn[];
553
+ declare function ProductTable({ items, columns, sort, defaultSort, onSortChange, sortItems, onSelect, searchSlot, filterSlot, emptyState, showUnsellable, currencySymbol, className, ...viewProps }: ProductTableProps): JSX.Element;
554
+
504
555
  interface ProductListProps extends Omit<ViewProps, 'children'> {
505
556
  items: any[];
506
557
  renderItem: (item: any, index: number) => ReactNode;
@@ -1216,9 +1267,13 @@ interface ConnectorStatusProps extends Omit<ViewProps, 'children'> {
1216
1267
  declare function ConnectorStatus({ name, status, lastSync, error, className, unsoldCount, unsoldStale, formatUnsold, ...viewProps }: ConnectorStatusProps): react_jsx_runtime.JSX.Element;
1217
1268
 
1218
1269
  /** `taxLabel` names each tax row; VAT isn't universal, so a platform passes its own (medusapos passes `VAT ${rate}%`). */
1219
- declare function Cart({ sale, taxLabel, canEditPrice, onPriceChange }: {
1270
+ declare function Cart({ sale, taxLabel, canEditPrice, onPriceChange, taxClasses }: {
1220
1271
  sale: ReturnType<typeof useSale>;
1221
1272
  taxLabel?: (ratePpm: number) => string;
1273
+ taxClasses?: ReadonlyArray<{
1274
+ id: string;
1275
+ label: string;
1276
+ }>;
1222
1277
  /** Shows a Price action on each line. Pass the till's own permission; the control isn't shown without it. */
1223
1278
  canEditPrice?: boolean;
1224
1279
  /** Called after a price is applied, for the app's audit log. The reason is kept only here. */
@@ -1280,8 +1335,31 @@ declare function PriceForm({ lineName, currency, currentMinor, onApply, onClose
1280
1335
  onClose: () => void;
1281
1336
  }): JSX.Element;
1282
1337
 
1338
+ interface ChargeFormProps {
1339
+ currency: string;
1340
+ lineTax?: {
1341
+ none: boolean;
1342
+ classes: boolean;
1343
+ };
1344
+ taxClasses?: ReadonlyArray<{
1345
+ id: string;
1346
+ label: string;
1347
+ }>;
1348
+ shippingTaxFromStore?: boolean;
1349
+ onApply: (charge: {
1350
+ kind: 'fee' | 'shipping' | 'custom';
1351
+ name: string;
1352
+ amountMinor: number;
1353
+ taxStatus?: 'none';
1354
+ taxClass?: string;
1355
+ }) => string | null;
1356
+ onClose: () => void;
1357
+ }
1358
+ /** `onApply` returns a refusal to show inline, or null once applied. */
1359
+ declare function ChargeForm({ currency, lineTax, taxClasses, shippingTaxFromStore, onApply, onClose }: ChargeFormProps): react_jsx_runtime.JSX.Element;
1360
+
1283
1361
  declare function formatStockSyncTime(time: Date, locale?: string, hour12?: boolean, now?: Date): string;
1284
- declare function Catalogue<Doc>({ products, traits, currency, onSelect, statusText, statusAccessory, lastSyncedAt, loading, pullError, lastStockCheckAt, hour12, minCodeLength }: {
1362
+ declare function Catalogue<Doc>({ products, traits, currency, onSelect, statusText, statusAccessory, lastSyncedAt, loading, pullError, lastStockCheckAt, hour12, minCodeLength, viewState, defaultViewState, loadViewState, saveViewState, onViewStateError, onStateChange, showViewToggle, items, onQueryChange, showCategoryNav, categories }: {
1285
1363
  products: Doc[];
1286
1364
  traits: ProductTraits<Doc>;
1287
1365
  currency: string;
@@ -1307,6 +1385,28 @@ declare function Catalogue<Doc>({ products, traits, currency, onSelect, statusTe
1307
1385
  * search instead of doing a code lookup. A scanner's timing threshold is the app's own concern,
1308
1386
  * in its unfocused wedge listener — not this prop's job. */
1309
1387
  minCodeLength?: number;
1388
+ /** Controlled view state; changes are reported through onStateChange. */
1389
+ viewState?: CatalogueViewState;
1390
+ /** Uncontrolled initial state, merged over DEFAULT_CATALOGUE_VIEW_STATE. */
1391
+ defaultViewState?: Partial<CatalogueViewState>;
1392
+ /** App-owned stored state, read once on mount in uncontrolled mode. */
1393
+ loadViewState?: () => unknown | Promise<unknown>;
1394
+ /** Saves cashier changes, never loads; uncontrolled only. */
1395
+ saveViewState?: (state: CatalogueViewState) => void | Promise<void>;
1396
+ /** Load/save errors; swallowed when omitted. */
1397
+ onViewStateError?: (error: unknown) => void;
1398
+ /** Loaded state or a cashier's next state (requested state when controlled). */
1399
+ onStateChange?: (state: CatalogueViewState) => void;
1400
+ /** Show the grid/table toggle in the header. Default false. */
1401
+ showViewToggle?: boolean;
1402
+ /** Show the category nav in the header. Default false. */
1403
+ showCategoryNav?: boolean;
1404
+ /** Replaces the categories derived from the listed products. */
1405
+ categories?: ProductCategory[];
1406
+ /** App-filtered, sorted list shown as given; products still drives scanning and variant choices. */
1407
+ items?: Doc[];
1408
+ /** Search text on every input change, for apps that filter items themselves. */
1409
+ onQueryChange?: (query: string) => void;
1310
1410
  }): react_jsx_runtime.JSX.Element;
1311
1411
 
1312
1412
  /** `store`/`taxLabel`/`topInset`/`formatDate` replace the app's Medusa settings, hard-coded VAT (default matches
@@ -1454,4 +1554,4 @@ interface StoreSettingsChoiceScreenProps extends Omit<ViewProps, 'children'> {
1454
1554
  */
1455
1555
  declare function StoreSettingsChoiceScreen({ choices, initial, onSubmit, countryName, locale, title, body, regionLabel, countryLabel, channelLabel, submitLabel, className, ...viewProps }: StoreSettingsChoiceScreenProps): react_jsx_runtime.JSX.Element;
1456
1556
 
1457
- export { APPROVAL_REQUIRED_TEXT, Accordion, AccordionContent, AccordionItem, AccordionTrigger, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, Avatar, type AvatarProps, Badge, type BadgeProps, Button, type ButtonProps, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Cart, type CartAction, CartBar, CartLine, CartLineActions, type CartLineActionsProps, type CartLineProps, CartNoteInput, type CartNoteInputProps, CartPanel, type CartPanelProps, CartTotal, type CartTotalProps, CashCountInput, type CashCountInputProps, CashTendered, type CashTenderedProps, Catalogue, type CategoryItem, CategoryNav, type CategoryNavProps, ChangeDisplay, type ChangeDisplayProps, Checkbox, CheckoutLayout, type CheckoutLayoutProps, type ChipItem, ClosureSheet, type ClosureSheetProps, Collapsible, CollapsibleContent, CollapsibleTrigger, Combobox, ComboboxContent, ComboboxEmpty, ComboboxInput, ComboboxItem, ComboboxTrigger, type ConnectionStatus, ConnectorStatus, type ConnectorStatusProps, ContextMenu, ContextMenuCheckboxItem, ContextMenuContent, ContextMenuGroup, ContextMenuItem, ContextMenuLabel, ContextMenuPortal, ContextMenuRadioGroup, ContextMenuRadioItem, ContextMenuSeparator, ContextMenuSub, ContextMenuSubContent, ContextMenuSubTrigger, ContextMenuTrigger, CustomerCard, type CustomerCardProps, CustomerForm, type CustomerFormProps, type CustomerFormValues, CustomerOrderHistory, type CustomerOrderHistoryProps, CustomerPicker, type CustomerPickerProps, CustomerSelect, type CustomerSelectProps, type Denomination, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DiscountBadge, type DiscountBadgeProps, DiscountChips, DiscountForm, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, FilterChip, FilterChipGroup, type FilterChipGroupProps, type FilterChipProps, HStack, type HStackProps, HoverCard, HoverCardContent, HoverCardTrigger, Icon, IconButton, type IconButtonProps, type IconProps, Input, InputField, InputRoot, type InputRootProps, InputSlot, Label, type LabelProps, LiveTabScreen, type LiveTabScreenProps, type LiveTabScreenState, Loader, type LoaderProps, MovementSheet, type MovementSheetProps, OpenRegisterCard, type OpenRegisterCardProps, OrderCard, type OrderCardProps, OrderDetail, type OrderDetailLineItem, type OrderDetailProps, OrderList, type OrderListProps, type OrderStatus, OrderStatusBadge, type OrderStatusBadgeProps, OrderSummary, OrderSummaryLine, type OrderSummaryLineProps, type OrderSummaryPayment, type OrderSummaryProps, OrdersList, POSLayout, type POSLayoutProps, ParkedSales, type ParkedSalesProps, type PaymentMethod, PaymentMethodCard, type PaymentMethodCardProps, PaymentSelector, type PaymentSelectorProps, Popover, PopoverContent, PopoverTrigger, PriceForm, ProductCard, type ProductCardProps, ProductGrid, type ProductGridProps, ProductImage, type ProductImageProps, ProductList, type ProductListProps, ProductPrice, type ProductPriceProps, ProductSku, type ProductSkuProps, ProductStockBadge, type ProductStockBadgeProps, ProductTitle, type ProductTitleProps, ProductVariantPicker, type ProductVariantPickerProps, Progress, type ProgressProps, QuantityStepper, type QuantityStepperProps, RadioGroup, RadioGroupItem, Receipt, type ReceiptItem, ReceiptPreview, type ReceiptPreviewProps, RegisterBar, type RegisterBarPill, type RegisterBarProps, RegisterColumn, type RegisterColumnProps, RegisterCount, type RegisterCountProps, RegisterOpenClose, type RegisterOpenCloseProps, RegisterPanel, type RegisterPanelProps, RegisterPicker, type RegisterPickerProps, type RegisterPickerRegister, RegisterSummary, type RegisterSummaryProps, SearchIcon, SearchInput, type SearchInputProps, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectSeparator, SelectTrigger, SelectValue, Separator, type SeparatorProps, SettingsGroup, type SettingsGroupProps, SettingsLayout, type SettingsLayoutProps, SettingsRow, type SettingsRowProps, Slider, type SliderProps, SplitTender, StoreSettingsChoiceScreen, type StoreSettingsChoiceScreenProps, type SvgIconProps, Switch, SyncStatus, Table, TableBody, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, Tender, Text, type TextProps, Textarea, type TextareaProps, Toast, ToastClose, ToastDescription, type ToastProps, ToastTitle, Toggle, ToggleGroup, ToggleGroupItem, type ToggleGroupItemProps, type ToggleGroupProps, type ToggleProps, Tooltip, TooltipContent, TooltipTrigger, type TransactionSummary, VStack, type VStackProps, type VariantOption, XIcon, avatarVariants, badgeTextVariants, badgeVariants, buttonTextVariants, buttonVariants, createSvgIcon, describeRegisterBarPill, discountLabel, formatStockSyncTime, hstackVariants, iconButtonVariants, iconVariants, injectPrintStyle, loaderVariants, orderReference, parseDiscount, parsePrice, textVariants, toastVariants, toggleTextVariants, toggleVariants, useInputContext, vstackVariants };
1557
+ export { APPROVAL_REQUIRED_TEXT, Accordion, AccordionContent, AccordionItem, AccordionTrigger, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, Avatar, type AvatarProps, Badge, type BadgeProps, Button, type ButtonProps, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Cart, type CartAction, CartBar, CartLine, CartLineActions, type CartLineActionsProps, type CartLineProps, CartNoteInput, type CartNoteInputProps, CartPanel, type CartPanelProps, CartTotal, type CartTotalProps, CashCountInput, type CashCountInputProps, CashTendered, type CashTenderedProps, Catalogue, type CategoryItem, CategoryNav, type CategoryNavProps, ChangeDisplay, type ChangeDisplayProps, ChargeForm, type ChargeFormProps, Checkbox, CheckoutLayout, type CheckoutLayoutProps, type ChipItem, ClosureSheet, type ClosureSheetProps, Collapsible, CollapsibleContent, CollapsibleTrigger, Combobox, ComboboxContent, ComboboxEmpty, ComboboxInput, ComboboxItem, ComboboxTrigger, type ConnectionStatus, ConnectorStatus, type ConnectorStatusProps, ContextMenu, ContextMenuCheckboxItem, ContextMenuContent, ContextMenuGroup, ContextMenuItem, ContextMenuLabel, ContextMenuPortal, ContextMenuRadioGroup, ContextMenuRadioItem, ContextMenuSeparator, ContextMenuSub, ContextMenuSubContent, ContextMenuSubTrigger, ContextMenuTrigger, CustomerCard, type CustomerCardProps, CustomerForm, type CustomerFormProps, type CustomerFormValues, CustomerOrderHistory, type CustomerOrderHistoryProps, CustomerPicker, type CustomerPickerProps, CustomerSelect, type CustomerSelectProps, type Denomination, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DiscountBadge, type DiscountBadgeProps, DiscountChips, DiscountForm, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, FilterChip, FilterChipGroup, type FilterChipGroupProps, type FilterChipProps, HStack, type HStackProps, HoverCard, HoverCardContent, HoverCardTrigger, Icon, IconButton, type IconButtonProps, type IconProps, Input, InputField, InputRoot, type InputRootProps, InputSlot, Label, type LabelProps, LiveTabScreen, type LiveTabScreenProps, type LiveTabScreenState, Loader, type LoaderProps, MovementSheet, type MovementSheetProps, OpenRegisterCard, type OpenRegisterCardProps, OrderCard, type OrderCardProps, OrderDetail, type OrderDetailLineItem, type OrderDetailProps, OrderList, type OrderListProps, type OrderStatus, OrderStatusBadge, type OrderStatusBadgeProps, OrderSummary, OrderSummaryLine, type OrderSummaryLineProps, type OrderSummaryPayment, type OrderSummaryProps, OrdersList, POSLayout, type POSLayoutProps, ParkedSales, type ParkedSalesProps, type PaymentMethod, PaymentMethodCard, type PaymentMethodCardProps, PaymentSelector, type PaymentSelectorProps, Popover, PopoverContent, PopoverTrigger, PriceForm, ProductCard, type ProductCardProps, ProductGrid, type ProductGridProps, ProductImage, type ProductImageProps, ProductList, type ProductListProps, ProductPrice, type ProductPriceProps, ProductSku, type ProductSkuProps, ProductStockBadge, type ProductStockBadgeProps, ProductTable, type ProductTableColumn, type ProductTableProps, ProductTitle, type ProductTitleProps, ProductVariantPicker, type ProductVariantPickerProps, Progress, type ProgressProps, QuantityStepper, type QuantityStepperProps, RadioGroup, RadioGroupItem, Receipt, type ReceiptItem, ReceiptPreview, type ReceiptPreviewProps, RegisterBar, type RegisterBarPill, type RegisterBarProps, RegisterColumn, type RegisterColumnProps, RegisterCount, type RegisterCountProps, RegisterOpenClose, type RegisterOpenCloseProps, RegisterPanel, type RegisterPanelProps, RegisterPicker, type RegisterPickerProps, type RegisterPickerRegister, RegisterSummary, type RegisterSummaryProps, SearchIcon, SearchInput, type SearchInputProps, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectSeparator, SelectTrigger, SelectValue, Separator, type SeparatorProps, SettingsGroup, type SettingsGroupProps, SettingsLayout, type SettingsLayoutProps, SettingsRow, type SettingsRowProps, Slider, type SliderProps, SplitTender, StoreSettingsChoiceScreen, type StoreSettingsChoiceScreenProps, type SvgIconProps, Switch, SyncStatus, Table, TableBody, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, Tender, Text, type TextProps, Textarea, type TextareaProps, Toast, ToastClose, ToastDescription, type ToastProps, ToastTitle, Toggle, ToggleGroup, ToggleGroupItem, type ToggleGroupItemProps, type ToggleGroupProps, type ToggleProps, Tooltip, TooltipContent, TooltipTrigger, type TransactionSummary, VStack, type VStackProps, type VariantOption, ViewToggle, type ViewToggleProps, XIcon, avatarVariants, badgeTextVariants, badgeVariants, buttonTextVariants, buttonVariants, createSvgIcon, defaultProductColumns, describeRegisterBarPill, discountLabel, formatStockSyncTime, hstackVariants, iconButtonVariants, iconVariants, injectPrintStyle, loaderVariants, orderReference, parseDiscount, parsePrice, textVariants, toastVariants, toggleTextVariants, toggleVariants, useDefaultProductColumns, useInputContext, vstackVariants };