@tallyui/components 1.0.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.
Files changed (47) hide show
  1. package/dist/index.d.ts +364 -0
  2. package/dist/index.js +451 -0
  3. package/package.json +35 -0
  4. package/src/__tests__/cart-line.test.tsx +53 -0
  5. package/src/__tests__/cart-panel.test.tsx +55 -0
  6. package/src/__tests__/cart-total.test.tsx +60 -0
  7. package/src/__tests__/customer-card.test.tsx +47 -0
  8. package/src/__tests__/customer-select.test.tsx +33 -0
  9. package/src/__tests__/filter-chip.test.tsx +40 -0
  10. package/src/__tests__/helpers.ts +111 -0
  11. package/src/__tests__/order-summary-line.test.tsx +18 -0
  12. package/src/__tests__/order-summary.test.tsx +32 -0
  13. package/src/__tests__/payment-method-card.test.tsx +24 -0
  14. package/src/__tests__/payment-selector.test.tsx +23 -0
  15. package/src/__tests__/product-card.test.tsx +31 -0
  16. package/src/__tests__/product-grid.test.tsx +37 -0
  17. package/src/__tests__/product-image.test.tsx +54 -0
  18. package/src/__tests__/product-price.test.tsx +68 -0
  19. package/src/__tests__/product-sku.test.tsx +47 -0
  20. package/src/__tests__/product-stock-badge.test.tsx +58 -0
  21. package/src/__tests__/product-title.test.tsx +38 -0
  22. package/src/__tests__/search-input.test.tsx +22 -0
  23. package/src/cart/cart-line.tsx +49 -0
  24. package/src/cart/cart-panel.tsx +65 -0
  25. package/src/cart/cart-total.tsx +64 -0
  26. package/src/cart/index.ts +3 -0
  27. package/src/checkout/index.ts +4 -0
  28. package/src/checkout/order-summary-line.tsx +23 -0
  29. package/src/checkout/order-summary.tsx +77 -0
  30. package/src/checkout/payment-method-card.tsx +36 -0
  31. package/src/checkout/payment-selector.tsx +55 -0
  32. package/src/customer/customer-card.tsx +26 -0
  33. package/src/customer/customer-select.tsx +72 -0
  34. package/src/customer/index.ts +2 -0
  35. package/src/index.ts +61 -0
  36. package/src/input/filter-chip.tsx +58 -0
  37. package/src/input/index.ts +2 -0
  38. package/src/input/search-input.tsx +26 -0
  39. package/src/product/index.ts +7 -0
  40. package/src/product/product-card.tsx +28 -0
  41. package/src/product/product-grid.tsx +66 -0
  42. package/src/product/product-image.tsx +41 -0
  43. package/src/product/product-price.tsx +53 -0
  44. package/src/product/product-sku.tsx +33 -0
  45. package/src/product/product-stock-badge.tsx +73 -0
  46. package/src/product/product-title.tsx +30 -0
  47. package/src/uniwind-env.d.ts +31 -0
@@ -0,0 +1,364 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { TextProps, ImageProps, StyleProp, ImageStyle, ViewProps, TextInputProps } from 'react-native';
3
+ import { ReactNode } from 'react';
4
+
5
+ interface ProductTitleProps extends Omit<TextProps, 'children'> {
6
+ /** The raw RxDB product document (connector-specific shape) */
7
+ doc: any;
8
+ className?: string;
9
+ }
10
+ /**
11
+ * Displays a product's name.
12
+ *
13
+ * Works with any connector — it uses the active connector's product traits
14
+ * to extract the name from the document, regardless of whether the underlying
15
+ * field is called `name` (WooCommerce) or `title` (Medusa).
16
+ *
17
+ * ```tsx
18
+ * <ProductTitle doc={productDocument} className="text-lg font-bold" />
19
+ * ```
20
+ */
21
+ declare function ProductTitle({ doc, className, ...textProps }: ProductTitleProps): react_jsx_runtime.JSX.Element;
22
+
23
+ interface ProductPriceProps extends Omit<TextProps, 'children'> {
24
+ /** The raw RxDB product document (connector-specific shape) */
25
+ doc: any;
26
+ /** Currency symbol to prepend (defaults to '$') */
27
+ currencySymbol?: string;
28
+ className?: string;
29
+ }
30
+ /**
31
+ * Displays a product's price.
32
+ *
33
+ * Works with any connector — extracts price via traits regardless
34
+ * of whether it's a string field (WooCommerce) or derived from
35
+ * variant pricing (Medusa).
36
+ *
37
+ * ```tsx
38
+ * <ProductPrice doc={productDocument} currencySymbol="$" />
39
+ * ```
40
+ */
41
+ declare function ProductPrice({ doc, currencySymbol, className, ...textProps }: ProductPriceProps): react_jsx_runtime.JSX.Element;
42
+
43
+ interface ProductImageProps extends Omit<ImageProps, 'source'> {
44
+ /** The raw RxDB product document */
45
+ doc: any;
46
+ /** Image dimensions */
47
+ size?: number;
48
+ /** Style overrides (for dynamic sizing) */
49
+ style?: StyleProp<ImageStyle>;
50
+ className?: string;
51
+ }
52
+ /**
53
+ * Displays a product's primary image.
54
+ *
55
+ * Falls back to null if no image is available.
56
+ *
57
+ * ```tsx
58
+ * <ProductImage doc={productDocument} size={80} className="rounded-lg" />
59
+ * ```
60
+ */
61
+ declare function ProductImage({ doc, size, style, className, ...imageProps }: ProductImageProps): react_jsx_runtime.JSX.Element | null;
62
+
63
+ interface ProductSkuProps extends Omit<TextProps, 'children'> {
64
+ /** The raw RxDB product document (connector-specific shape) */
65
+ doc: any;
66
+ /** Text to show when SKU is missing (defaults to '—') */
67
+ fallback?: string;
68
+ className?: string;
69
+ }
70
+ /**
71
+ * Displays a product's SKU.
72
+ *
73
+ * Reads the SKU from whatever field the active connector stores it in —
74
+ * `doc.sku` for WooCommerce, `doc.variants[0].sku` for Medusa, etc.
75
+ *
76
+ * ```tsx
77
+ * <ProductSku doc={productDocument} />
78
+ * ```
79
+ */
80
+ declare function ProductSku({ doc, fallback, className, ...textProps }: ProductSkuProps): react_jsx_runtime.JSX.Element;
81
+
82
+ interface ProductStockBadgeProps extends Omit<ViewProps, 'children'> {
83
+ /** The raw RxDB product document (connector-specific shape) */
84
+ doc: any;
85
+ /** Whether to show the quantity alongside the status */
86
+ showQuantity?: boolean;
87
+ className?: string;
88
+ }
89
+ /**
90
+ * Displays a visual stock status badge for a product.
91
+ *
92
+ * Shows a colored label (In Stock / Out of Stock / On Backorder)
93
+ * with an optional quantity count.
94
+ *
95
+ * ```tsx
96
+ * <ProductStockBadge doc={productDocument} showQuantity />
97
+ * ```
98
+ */
99
+ declare function ProductStockBadge({ doc, showQuantity, className, ...viewProps }: ProductStockBadgeProps): react_jsx_runtime.JSX.Element;
100
+
101
+ interface ProductCardProps extends Omit<ViewProps, 'children'> {
102
+ doc: any;
103
+ onPress?: () => void;
104
+ imageSize?: number;
105
+ currencySymbol?: string;
106
+ className?: string;
107
+ }
108
+ declare function ProductCard({ doc, onPress, imageSize, currencySymbol, className, ...viewProps }: ProductCardProps): react_jsx_runtime.JSX.Element;
109
+
110
+ interface ProductGridProps extends Omit<ViewProps, 'children'> {
111
+ /** Array of product documents to render */
112
+ items: any[];
113
+ /** Render function for each product */
114
+ renderItem: (item: any, index: number) => ReactNode;
115
+ /** Number of columns in the grid (defaults to 2) */
116
+ numColumns?: number;
117
+ /** Search input slot rendered above the grid */
118
+ searchSlot?: ReactNode;
119
+ /** Filter slot rendered between search and grid */
120
+ filterSlot?: ReactNode;
121
+ /** Content shown when items is empty */
122
+ emptyState?: ReactNode;
123
+ className?: string;
124
+ }
125
+ /**
126
+ * A scrollable product grid with optional search and filter slots.
127
+ *
128
+ * Uses ScrollView + flexWrap for cross-platform grid layout rather than
129
+ * FlatList numColumns, which keeps things predictable in both native and web.
130
+ *
131
+ * ```tsx
132
+ * <ProductGrid
133
+ * items={products}
134
+ * renderItem={(doc) => <ProductCard doc={doc} />}
135
+ * searchSlot={<SearchInput value={q} onChangeText={setQ} />}
136
+ * numColumns={3}
137
+ * />
138
+ * ```
139
+ */
140
+ declare function ProductGrid({ items, renderItem, numColumns, searchSlot, filterSlot, emptyState, className, ...viewProps }: ProductGridProps): react_jsx_runtime.JSX.Element;
141
+
142
+ interface CartLineItem {
143
+ /** The raw product document (connector-specific shape) */
144
+ doc: any;
145
+ /** Quantity in cart */
146
+ quantity: number;
147
+ }
148
+ interface CartLineProps extends Omit<ViewProps, 'children'> {
149
+ /** The cart line item */
150
+ item: CartLineItem;
151
+ /** Currency symbol (defaults to '$') */
152
+ currencySymbol?: string;
153
+ className?: string;
154
+ }
155
+ /**
156
+ * Displays a single cart line item: product name, quantity, and line total.
157
+ *
158
+ * ```tsx
159
+ * <CartLine item={{ doc: productDocument, quantity: 2 }} />
160
+ * ```
161
+ */
162
+ declare function CartLine({ item, currencySymbol, className, ...viewProps }: CartLineProps): react_jsx_runtime.JSX.Element;
163
+
164
+ interface CartTotalProps extends Omit<ViewProps, 'children'> {
165
+ /** All cart line items */
166
+ items: CartLineItem[];
167
+ /** Currency symbol (defaults to '$') */
168
+ currencySymbol?: string;
169
+ /** Tax rate as a decimal (e.g. 0.1 for 10%). Defaults to 0. */
170
+ taxRate?: number;
171
+ /** Label for the tax line (defaults to 'Tax') */
172
+ taxLabel?: string;
173
+ className?: string;
174
+ }
175
+ /**
176
+ * Displays a cart summary with subtotal, optional tax, and total.
177
+ *
178
+ * ```tsx
179
+ * <CartTotal items={cartItems} taxRate={0.1} />
180
+ * ```
181
+ */
182
+ declare function CartTotal({ items, currencySymbol, taxRate, taxLabel, className, ...viewProps }: CartTotalProps): react_jsx_runtime.JSX.Element;
183
+
184
+ interface CartPanelProps extends Omit<ViewProps, 'children'> {
185
+ /** Cart line items to render */
186
+ items: CartLineItem[];
187
+ /** Render function for each cart line */
188
+ renderItem: (item: CartLineItem, index: number) => ReactNode;
189
+ /** Header slot (e.g. customer info) */
190
+ header?: ReactNode;
191
+ /** Footer slot (e.g. totals, checkout button) */
192
+ footer?: ReactNode;
193
+ /** Content shown when items is empty */
194
+ emptyState?: ReactNode;
195
+ className?: string;
196
+ }
197
+ /**
198
+ * A scrollable cart panel with header/footer slots.
199
+ *
200
+ * Composes CartLine (or custom renderItem) into a scrollable list
201
+ * with optional header, footer, and empty state.
202
+ *
203
+ * ```tsx
204
+ * <CartPanel
205
+ * items={cartItems}
206
+ * renderItem={(item) => <CartLine item={item} />}
207
+ * header={<CustomerCard doc={customer} />}
208
+ * footer={<CartTotal items={cartItems} />}
209
+ * />
210
+ * ```
211
+ */
212
+ declare function CartPanel({ items, renderItem, header, footer, emptyState, className, ...viewProps }: CartPanelProps): react_jsx_runtime.JSX.Element;
213
+
214
+ interface SearchInputProps extends Omit<TextInputProps, 'value' | 'onChangeText'> {
215
+ value: string;
216
+ onChangeText: (text: string) => void;
217
+ className?: string;
218
+ }
219
+ declare function SearchInput({ value, onChangeText, className, placeholder, ...props }: SearchInputProps): react_jsx_runtime.JSX.Element;
220
+
221
+ interface FilterChipProps {
222
+ label: string;
223
+ active: boolean;
224
+ onPress: () => void;
225
+ className?: string;
226
+ }
227
+ declare function FilterChip({ label, active, onPress, className }: FilterChipProps): react_jsx_runtime.JSX.Element;
228
+ interface ChipItem {
229
+ label: string;
230
+ active: boolean;
231
+ }
232
+ interface FilterChipGroupProps extends Omit<ViewProps, 'children'> {
233
+ chips: ChipItem[];
234
+ onChipPress: (index: number) => void;
235
+ className?: string;
236
+ }
237
+ declare function FilterChipGroup({ chips, onChipPress, className, ...viewProps }: FilterChipGroupProps): react_jsx_runtime.JSX.Element;
238
+
239
+ interface CustomerCardProps extends Omit<ViewProps, 'children'> {
240
+ doc: any;
241
+ className?: string;
242
+ }
243
+ declare function CustomerCard({ doc, className, ...viewProps }: CustomerCardProps): react_jsx_runtime.JSX.Element | null;
244
+
245
+ interface CustomerSelectProps extends Omit<ViewProps, 'children'> {
246
+ /** Customer documents to display as options */
247
+ customers: any[];
248
+ /** Currently selected customer (if any) */
249
+ selected?: any;
250
+ /** Called when a customer is selected */
251
+ onSelect: (customer: any) => void;
252
+ /** Called when the search text changes */
253
+ onSearch: (query: string) => void;
254
+ /** Placeholder text for the search input */
255
+ placeholder?: string;
256
+ className?: string;
257
+ }
258
+ /**
259
+ * A customer picker that displays a list of customer cards.
260
+ *
261
+ * When a customer is selected, their name is shown as a summary.
262
+ * The parent is responsible for filtering — this component just
263
+ * calls onSearch with the query text and renders whatever customers
264
+ * are passed in.
265
+ *
266
+ * ```tsx
267
+ * <CustomerSelect
268
+ * customers={filteredCustomers}
269
+ * selected={selectedCustomer}
270
+ * onSelect={setSelectedCustomer}
271
+ * onSearch={setSearchQuery}
272
+ * />
273
+ * ```
274
+ */
275
+ declare function CustomerSelect({ customers, selected, onSelect, onSearch, placeholder, className, ...viewProps }: CustomerSelectProps): react_jsx_runtime.JSX.Element;
276
+
277
+ interface PaymentMethodCardProps extends Omit<ViewProps, 'children'> {
278
+ label: string;
279
+ selected: boolean;
280
+ onPress: () => void;
281
+ icon?: ReactNode;
282
+ className?: string;
283
+ }
284
+ declare function PaymentMethodCard({ label, selected, onPress, icon, className, ...viewProps }: PaymentMethodCardProps): react_jsx_runtime.JSX.Element;
285
+
286
+ interface OrderSummaryLineProps extends Omit<ViewProps, 'children'> {
287
+ label: string;
288
+ amount: string;
289
+ bold?: boolean;
290
+ className?: string;
291
+ }
292
+ declare function OrderSummaryLine({ label, amount, bold, className, ...viewProps }: OrderSummaryLineProps): react_jsx_runtime.JSX.Element;
293
+
294
+ interface PaymentMethod {
295
+ id: string;
296
+ label: string;
297
+ icon?: ReactNode;
298
+ }
299
+ interface PaymentSelectorProps extends Omit<ViewProps, 'children'> {
300
+ /** Available payment methods */
301
+ methods: PaymentMethod[];
302
+ /** ID of the currently selected method */
303
+ selected: string;
304
+ /** Called when a method is selected */
305
+ onSelect: (id: string) => void;
306
+ className?: string;
307
+ }
308
+ /**
309
+ * A list of payment method cards where one can be selected at a time.
310
+ *
311
+ * Wraps PaymentMethodCard for each method and manages the selected state.
312
+ *
313
+ * ```tsx
314
+ * <PaymentSelector
315
+ * methods={[{ id: 'cash', label: 'Cash' }, { id: 'card', label: 'Credit Card' }]}
316
+ * selected={selectedMethod}
317
+ * onSelect={setSelectedMethod}
318
+ * />
319
+ * ```
320
+ */
321
+ declare function PaymentSelector({ methods, selected, onSelect, className, ...viewProps }: PaymentSelectorProps): react_jsx_runtime.JSX.Element;
322
+
323
+ interface OrderSummaryPayment {
324
+ label: string;
325
+ amount: string;
326
+ }
327
+ interface OrderSummaryProps extends Omit<ViewProps, 'children'> {
328
+ /** Formatted subtotal string (e.g. "$1199.98") */
329
+ subtotal: string;
330
+ /** Formatted tax amount (optional) */
331
+ tax?: string;
332
+ /** Label for the tax line (defaults to "Tax") */
333
+ taxLabel?: string;
334
+ /** Formatted total string */
335
+ total: string;
336
+ /** Payment lines to display (e.g. cash tendered, change due) */
337
+ payments?: OrderSummaryPayment[];
338
+ /** Header slot (e.g. customer info, order number) */
339
+ header?: ReactNode;
340
+ /** Footer slot (e.g. action buttons) */
341
+ footer?: ReactNode;
342
+ className?: string;
343
+ }
344
+ /**
345
+ * Displays an order summary with subtotal, tax, total, and optional
346
+ * payment breakdown.
347
+ *
348
+ * Uses OrderSummaryLine internally for each row. Accepts header and
349
+ * footer slots for additional context like customer info or action buttons.
350
+ *
351
+ * ```tsx
352
+ * <OrderSummary
353
+ * subtotal="$1199.98"
354
+ * tax="$120.00"
355
+ * taxLabel="GST"
356
+ * total="$1319.98"
357
+ * payments={[{ label: 'Cash', amount: '$1400.00' }, { label: 'Change', amount: '$80.02' }]}
358
+ * header={<CustomerCard doc={customer} />}
359
+ * />
360
+ * ```
361
+ */
362
+ declare function OrderSummary({ subtotal, tax, taxLabel, total, payments, header, footer, className, ...viewProps }: OrderSummaryProps): react_jsx_runtime.JSX.Element;
363
+
364
+ export { CartLine, type CartLineItem, type CartLineProps, CartPanel, type CartPanelProps, CartTotal, type CartTotalProps, type ChipItem, CustomerCard, type CustomerCardProps, CustomerSelect, type CustomerSelectProps, FilterChip, FilterChipGroup, type FilterChipGroupProps, type FilterChipProps, OrderSummary, OrderSummaryLine, type OrderSummaryLineProps, type OrderSummaryPayment, type OrderSummaryProps, type PaymentMethod, PaymentMethodCard, type PaymentMethodCardProps, PaymentSelector, type PaymentSelectorProps, ProductCard, type ProductCardProps, ProductGrid, type ProductGridProps, ProductImage, type ProductImageProps, ProductPrice, type ProductPriceProps, ProductSku, type ProductSkuProps, ProductStockBadge, type ProductStockBadgeProps, ProductTitle, type ProductTitleProps, SearchInput, type SearchInputProps };