@veevarts/design-system 1.12.0-alpha.1 → 1.12.0-alpha.2
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.cjs +11 -11
- package/dist/index.js +6051 -5553
- package/dist/patterns/Summary/Summary.d.ts +4 -0
- package/dist/patterns/Summary/components/ActionBar.d.ts +17 -0
- package/dist/patterns/Summary/components/CartButton.d.ts +11 -0
- package/dist/patterns/Summary/components/CollapseHeader.d.ts +19 -0
- package/dist/patterns/Summary/components/GrandTotalRow.d.ts +11 -0
- package/dist/patterns/Summary/components/ItemRow.d.ts +9 -0
- package/dist/patterns/Summary/components/PrimaryCta.d.ts +11 -0
- package/dist/patterns/Summary/components/ServiceFeeRow.d.ts +8 -0
- package/dist/patterns/Summary/components/SummaryBody.d.ts +15 -0
- package/dist/patterns/Summary/components/TotalsLineRow.d.ts +8 -0
- package/dist/patterns/Summary/drag.d.ts +55 -0
- package/dist/patterns/Summary/fmt.d.ts +2 -0
- package/dist/patterns/Summary/index.d.ts +7 -0
- package/dist/patterns/Summary/types.d.ts +147 -0
- package/dist/patterns/index.d.ts +2 -0
- package/package.json +1 -1
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { SummaryClassNames, SummaryPrimaryAction, SummaryProps } from '../types';
|
|
3
|
+
export interface ActionBarProps {
|
|
4
|
+
open: boolean;
|
|
5
|
+
/** Open progress 0→1; drives the cross-fade opacity. */
|
|
6
|
+
progress: number;
|
|
7
|
+
/** True while a drag is in progress (disables the eased transition). */
|
|
8
|
+
dragging: boolean;
|
|
9
|
+
primaryAction?: SummaryPrimaryAction;
|
|
10
|
+
isLoading: boolean;
|
|
11
|
+
cart?: SummaryProps['cart'];
|
|
12
|
+
cartAriaLabel: string;
|
|
13
|
+
/** Expand the summary — the closed-bar cart button opens it on click. */
|
|
14
|
+
onToggleOpen?: () => void;
|
|
15
|
+
classNames: SummaryClassNames;
|
|
16
|
+
}
|
|
17
|
+
export declare const ActionBar: React.FC<ActionBarProps>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { SummaryProps } from '../types';
|
|
3
|
+
export interface CartButtonProps {
|
|
4
|
+
cart: NonNullable<SummaryProps['cart']>;
|
|
5
|
+
ariaLabel: string;
|
|
6
|
+
/** Click handler — wired by the action bar to open the summary (and still
|
|
7
|
+
* fire the consumer's `cart.onPress` if provided). */
|
|
8
|
+
onPress: () => void;
|
|
9
|
+
className?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare const CartButton: React.FC<CartButtonProps>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { Money, SummaryClassNames } from '../types';
|
|
3
|
+
export interface CollapseHeaderProps {
|
|
4
|
+
title: React.ReactNode;
|
|
5
|
+
total: {
|
|
6
|
+
label?: React.ReactNode;
|
|
7
|
+
amount: Money;
|
|
8
|
+
};
|
|
9
|
+
locale: string;
|
|
10
|
+
open: boolean;
|
|
11
|
+
/** Open progress 0→1; drives the cross-fade opacity. */
|
|
12
|
+
progress: number;
|
|
13
|
+
/** True while a drag is in progress (disables the eased transition). */
|
|
14
|
+
dragging: boolean;
|
|
15
|
+
toggleAriaLabel: string;
|
|
16
|
+
onToggleOpen?: () => void;
|
|
17
|
+
classNames: SummaryClassNames;
|
|
18
|
+
}
|
|
19
|
+
export declare const CollapseHeader: React.FC<CollapseHeaderProps>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { Money } from '../types';
|
|
3
|
+
export interface GrandTotalRowProps {
|
|
4
|
+
total: {
|
|
5
|
+
label?: React.ReactNode;
|
|
6
|
+
amount: Money;
|
|
7
|
+
};
|
|
8
|
+
locale: string;
|
|
9
|
+
className?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare const GrandTotalRow: React.FC<GrandTotalRowProps>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { SummaryLineItem } from '../types';
|
|
3
|
+
export interface ItemRowProps {
|
|
4
|
+
item: SummaryLineItem;
|
|
5
|
+
locale: string;
|
|
6
|
+
onRemove?: (id: string) => void;
|
|
7
|
+
removeAriaLabel: string;
|
|
8
|
+
}
|
|
9
|
+
export declare const ItemRow: React.FC<ItemRowProps>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { SummaryProps } from '../types';
|
|
3
|
+
export interface PrimaryCtaProps {
|
|
4
|
+
action: NonNullable<SummaryProps['primaryAction']>;
|
|
5
|
+
disabledByLoading: boolean;
|
|
6
|
+
className?: string;
|
|
7
|
+
/** Disambiguates the two cross-fade CTA layers. Default `summary-cta` (the
|
|
8
|
+
* open / desktop instance); the closed compact layer passes `summary-cta-compact`. */
|
|
9
|
+
testId?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare const PrimaryCta: React.FC<PrimaryCtaProps>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { SummaryServiceFee } from '../types';
|
|
3
|
+
export interface ServiceFeeRowProps {
|
|
4
|
+
fee: SummaryServiceFee;
|
|
5
|
+
locale: string;
|
|
6
|
+
className?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare const ServiceFeeRow: React.FC<ServiceFeeRowProps>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { SummaryClassNames, SummaryLineItem, SummaryServiceFee, SummaryTotalRow } from '../types';
|
|
3
|
+
export interface SummaryBodyProps {
|
|
4
|
+
pricesInLabel: React.ReactNode;
|
|
5
|
+
currency?: React.ReactNode;
|
|
6
|
+
items?: SummaryLineItem[];
|
|
7
|
+
serviceFee?: SummaryServiceFee;
|
|
8
|
+
rows?: SummaryTotalRow[];
|
|
9
|
+
locale: string;
|
|
10
|
+
onRemoveItem?: (id: string) => void;
|
|
11
|
+
removeAriaLabel: string;
|
|
12
|
+
emptyState?: React.ReactNode;
|
|
13
|
+
classNames: SummaryClassNames;
|
|
14
|
+
}
|
|
15
|
+
export declare const SummaryBody: React.FC<SummaryBodyProps>;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Drag/reveal gesture helpers for the collapsible `<Summary>`.
|
|
3
|
+
*
|
|
4
|
+
* Kept in their own module (not in `Summary.tsx`) so the component file only
|
|
5
|
+
* exports a component — the Design-System fast-refresh convention — and so the
|
|
6
|
+
* gesture math is pure and fully unit-tested (framer's drag `info` never fires
|
|
7
|
+
* under the test mock).
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Minimum vertical drag distance (px) past which a collapsible summary toggles.
|
|
11
|
+
* Exported so the gesture threshold is testable and tunable.
|
|
12
|
+
*/
|
|
13
|
+
export declare const DRAG_TOGGLE_THRESHOLD = 60;
|
|
14
|
+
/**
|
|
15
|
+
* Pure decision for the drag-to-toggle gesture: drag **up** (negative offset)
|
|
16
|
+
* while closed opens; drag **down** (positive offset) while open closes. A drag
|
|
17
|
+
* shorter than `threshold`, or in the wrong direction for the current state,
|
|
18
|
+
* does nothing.
|
|
19
|
+
*/
|
|
20
|
+
export declare const shouldToggleOnDrag: (offsetY: number, open: boolean, threshold?: number) => boolean;
|
|
21
|
+
/** Clamp a proposed reveal height into `[0, fullHeight]`. */
|
|
22
|
+
export declare const clampRevealHeight: (proposed: number, fullHeight: number) => number;
|
|
23
|
+
/**
|
|
24
|
+
* Live reveal height while dragging: dragging **up** (negative `offsetY`) grows
|
|
25
|
+
* the panel from its `baseHeight`; dragging **down** shrinks it. Clamped to the
|
|
26
|
+
* panel's natural `fullHeight` so it tracks the finger 1:1 without overshooting.
|
|
27
|
+
*/
|
|
28
|
+
export declare const revealHeightFromDrag: (baseHeight: number, offsetY: number, fullHeight: number) => number;
|
|
29
|
+
/**
|
|
30
|
+
* Resolve the reveal panel's current height. While dragging (`dragHeight` set)
|
|
31
|
+
* the finger drives it; otherwise it rests fully open (`fullHeight`) or fully
|
|
32
|
+
* collapsed (`0`).
|
|
33
|
+
*/
|
|
34
|
+
export declare const currentRevealHeight: (dragHeight: number | null, open: boolean, fullHeight: number) => number;
|
|
35
|
+
/**
|
|
36
|
+
* The reveal panel animates its height smoothly at rest, but tracks the finger
|
|
37
|
+
* with no transition while dragging (so the drag feels 1:1, not laggy).
|
|
38
|
+
*/
|
|
39
|
+
export declare const revealTransitionClass: (dragging: boolean) => string;
|
|
40
|
+
export interface DragInfo {
|
|
41
|
+
offset?: {
|
|
42
|
+
y?: number;
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
export interface DragHandlerDeps {
|
|
46
|
+
open: boolean;
|
|
47
|
+
fullHeight: number;
|
|
48
|
+
setDragHeight: (height: number | null) => void;
|
|
49
|
+
onToggleOpen?: () => void;
|
|
50
|
+
}
|
|
51
|
+
export interface DragHandlers {
|
|
52
|
+
onDrag: (event: unknown, info?: DragInfo) => void;
|
|
53
|
+
onDragEnd: (event: unknown, info?: DragInfo) => void;
|
|
54
|
+
}
|
|
55
|
+
export declare const createDragHandlers: (deps: DragHandlerDeps) => DragHandlers;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Summary Pattern — pure-UI order summary (Figma node 12127-11831):
|
|
3
|
+
* header, flexible line items, service-fee toggle, totals, collapsible
|
|
4
|
+
* Total + CTA, and a compact mobile bottom-bar.
|
|
5
|
+
*/
|
|
6
|
+
export { Summary } from './Summary';
|
|
7
|
+
export type { SummaryProps, SummaryLineItem, SummaryServiceFee, SummaryTotalRow, SummaryPrimaryAction, SummaryLabels, Money, } from './types';
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { Money } from '../../utils/money';
|
|
3
|
+
export type { Money } from '../../utils/money';
|
|
4
|
+
/**
|
|
5
|
+
* A single, flexible line item. The four Figma "types" (Ticket, Event,
|
|
6
|
+
* Membership, Donation) are compositions of this one shape — not rigid
|
|
7
|
+
* variants — honouring "grouping, but flexible".
|
|
8
|
+
*/
|
|
9
|
+
export interface SummaryLineItem {
|
|
10
|
+
/** Stable id (keys, remove handler, and `data-testid`). */
|
|
11
|
+
id: string;
|
|
12
|
+
/** Display name (Ticket / Event title / Membership / Donation). */
|
|
13
|
+
name: ReactNode;
|
|
14
|
+
/** Quantity; renders a `{qty} x` prefix (Ticket / Adult / Children). */
|
|
15
|
+
quantity?: number;
|
|
16
|
+
/** Right-aligned price. Omit on an Event header that only groups children. */
|
|
17
|
+
amount?: Money;
|
|
18
|
+
/** Render the name in a heavier weight (Event / Membership / Donation titles). */
|
|
19
|
+
emphasis?: boolean;
|
|
20
|
+
/** Leading icon node (e.g. `lucide:ticket` for Event, `lucide:star` for Membership). */
|
|
21
|
+
leadingIcon?: ReactNode;
|
|
22
|
+
/** Calendar row, e.g. "March 26th, 2026 - 9:45 am - 09:45 pm" (Event). */
|
|
23
|
+
dateLabel?: ReactNode;
|
|
24
|
+
/** Date-range row joined by an arrow (Membership), e.g. Jan 26, 2026 → Jan 26, 2027. */
|
|
25
|
+
dateRange?: {
|
|
26
|
+
from: ReactNode;
|
|
27
|
+
to: ReactNode;
|
|
28
|
+
};
|
|
29
|
+
/** Nested rows, indented (Event's Adult / Children). */
|
|
30
|
+
children?: SummaryLineItem[];
|
|
31
|
+
}
|
|
32
|
+
/** The "Pay Service fee" radio-toggle row. */
|
|
33
|
+
export interface SummaryServiceFee {
|
|
34
|
+
label: ReactNode;
|
|
35
|
+
amount: Money;
|
|
36
|
+
/** Selected (filled radio) state. */
|
|
37
|
+
isSelected?: boolean;
|
|
38
|
+
/** Fires when the row/radio is toggled. */
|
|
39
|
+
onToggle?: () => void;
|
|
40
|
+
}
|
|
41
|
+
/** A plain totals row (Subtotal, Taxes). */
|
|
42
|
+
export interface SummaryTotalRow {
|
|
43
|
+
/** Stable key for `data-testid` (e.g. 'subtotal', 'taxes'). */
|
|
44
|
+
key: string;
|
|
45
|
+
label: ReactNode;
|
|
46
|
+
amount: Money;
|
|
47
|
+
}
|
|
48
|
+
/** The primary call-to-action (orange pill + arrow). */
|
|
49
|
+
export interface SummaryPrimaryAction {
|
|
50
|
+
label: ReactNode;
|
|
51
|
+
onPress: () => void;
|
|
52
|
+
isLoading?: boolean;
|
|
53
|
+
isDisabled?: boolean;
|
|
54
|
+
}
|
|
55
|
+
/** Overridable copy. */
|
|
56
|
+
export interface SummaryLabels {
|
|
57
|
+
/** Aria label for the per-item remove control. Default "Remove item". */
|
|
58
|
+
removeAriaLabel?: string;
|
|
59
|
+
/** Aria label for the collapse/expand press target. Default "Toggle summary". */
|
|
60
|
+
toggleAriaLabel?: string;
|
|
61
|
+
/** Aria label for the mobile cart button. Default "View cart". */
|
|
62
|
+
cartAriaLabel?: string;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Per-slot class overrides — the Design-System `classNames` convention (HeroUI
|
|
66
|
+
* `SlotsToClasses`). Each key targets one visual region and is merged AFTER the
|
|
67
|
+
* component's own classes via `cn`, so any Tailwind utility you pass wins. The
|
|
68
|
+
* root also accepts the plain `className`.
|
|
69
|
+
*/
|
|
70
|
+
export interface SummaryClassNames {
|
|
71
|
+
/** Root `<section>` (applied alongside `className`). */
|
|
72
|
+
base?: string;
|
|
73
|
+
/** Header row (title + `×`). */
|
|
74
|
+
header?: string;
|
|
75
|
+
/** Title text. */
|
|
76
|
+
title?: string;
|
|
77
|
+
/** The header collapse/close (`×`) control. */
|
|
78
|
+
closeButton?: string;
|
|
79
|
+
/** "Prices are in / currency" row. */
|
|
80
|
+
prices?: string;
|
|
81
|
+
/** Line-items container. */
|
|
82
|
+
items?: string;
|
|
83
|
+
/** Service-fee row. */
|
|
84
|
+
serviceFee?: string;
|
|
85
|
+
/** Totals-rows container (Subtotal / Taxes). */
|
|
86
|
+
totalsRows?: string;
|
|
87
|
+
/** The Total row. */
|
|
88
|
+
total?: string;
|
|
89
|
+
/** Primary CTA button. */
|
|
90
|
+
cta?: string;
|
|
91
|
+
/** Mobile compact bottom-bar. */
|
|
92
|
+
mobileBar?: string;
|
|
93
|
+
/** Mobile cart button. */
|
|
94
|
+
cart?: string;
|
|
95
|
+
}
|
|
96
|
+
export interface SummaryProps {
|
|
97
|
+
/** Header title. Default "Summary". */
|
|
98
|
+
title?: ReactNode;
|
|
99
|
+
/** Left text of the prices row. Default "Prices are in". */
|
|
100
|
+
pricesInLabel?: ReactNode;
|
|
101
|
+
/** Right text of the prices row (currency code), e.g. "USD". */
|
|
102
|
+
currency?: ReactNode;
|
|
103
|
+
/** BCP-47 locale for money formatting. Default 'en-US'. */
|
|
104
|
+
locale?: string;
|
|
105
|
+
/** Flexible line items (flat or grouped via `children`). */
|
|
106
|
+
items?: SummaryLineItem[];
|
|
107
|
+
/** Optional "Pay Service fee" radio-toggle row. */
|
|
108
|
+
serviceFee?: SummaryServiceFee;
|
|
109
|
+
/** Plain totals rows rendered above the Total (Subtotal, Taxes). */
|
|
110
|
+
rows?: SummaryTotalRow[];
|
|
111
|
+
/** The emphasized Total row (label default "Total"). */
|
|
112
|
+
total: {
|
|
113
|
+
label?: ReactNode;
|
|
114
|
+
amount: Money;
|
|
115
|
+
};
|
|
116
|
+
/**
|
|
117
|
+
* Whether the summary can collapse — the header shows a `×` and the whole
|
|
118
|
+
* header toggles Open/Closed. Defaults to `variant === 'mobile'` (mobile
|
|
119
|
+
* collapses, desktop does not). Pass explicitly to override the automatic
|
|
120
|
+
* behaviour.
|
|
121
|
+
*/
|
|
122
|
+
collapsible?: boolean;
|
|
123
|
+
/** Controlled open/closed state (default open). */
|
|
124
|
+
isOpen?: boolean;
|
|
125
|
+
/** Fires when the header (open) — or the closed bar's Total (closed) — is activated to toggle. */
|
|
126
|
+
onToggleOpen?: () => void;
|
|
127
|
+
/** The primary CTA. */
|
|
128
|
+
primaryAction?: SummaryPrimaryAction;
|
|
129
|
+
/** When provided, item rows show a red trash remove control. */
|
|
130
|
+
onRemoveItem?: (id: string) => void;
|
|
131
|
+
/** Layout: full card ('main') or compact bottom-bar ('mobile'). Default 'main'. */
|
|
132
|
+
variant?: 'main' | 'mobile';
|
|
133
|
+
/** Mobile bottom-bar cart button + badge count. */
|
|
134
|
+
cart?: {
|
|
135
|
+
count?: number;
|
|
136
|
+
onPress?: () => void;
|
|
137
|
+
};
|
|
138
|
+
/** Disables the CTA and signals recalculation. */
|
|
139
|
+
isLoading?: boolean;
|
|
140
|
+
/** Rendered when there are no items. */
|
|
141
|
+
emptyState?: ReactNode;
|
|
142
|
+
labels?: SummaryLabels;
|
|
143
|
+
'data-testid'?: string;
|
|
144
|
+
className?: string;
|
|
145
|
+
/** Per-slot class overrides (Design-System `classNames` convention). */
|
|
146
|
+
classNames?: SummaryClassNames;
|
|
147
|
+
}
|
package/dist/patterns/index.d.ts
CHANGED
|
@@ -57,3 +57,5 @@ export { PaymentSubAmountInput } from './PaymentSubAmountInput';
|
|
|
57
57
|
export type { PaymentSubAmountInputProps } from './PaymentSubAmountInput';
|
|
58
58
|
export { ConfirmDialog } from './ConfirmDialog';
|
|
59
59
|
export type { ConfirmDialogProps } from './ConfirmDialog';
|
|
60
|
+
export { Summary } from './Summary';
|
|
61
|
+
export type { SummaryProps, SummaryLineItem, SummaryServiceFee, SummaryTotalRow, SummaryPrimaryAction, SummaryLabels, } from './Summary';
|