vlite3 1.4.3 → 1.4.4
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/components/AvatarUploader/AvatarUploader.vue.d.ts +2 -2
- package/components/Cart/Cart.vue.d.ts +27 -0
- package/components/Cart/CartCouponInput.vue.d.ts +32 -0
- package/components/Cart/CartEmptyState.vue.d.ts +17 -0
- package/components/Cart/CartLineItem.vue.d.ts +29 -0
- package/components/Cart/CartSummary.vue.d.ts +29 -0
- package/components/Cart/CartVariant1.vue.d.ts +42 -0
- package/components/Cart/CartVariant2.vue.d.ts +42 -0
- package/components/Cart/CartVariant3.vue.d.ts +41 -0
- package/components/Cart/CartVariant4.vue.d.ts +41 -0
- package/components/Cart/composables/useCartCalculation.d.ts +91 -0
- package/components/Cart/index.d.ts +7 -0
- package/components/Cart/types.d.ts +391 -0
- package/components/CategoryManager/CategoryManager.vue.d.ts +2 -2
- package/components/Clipboard.vue.d.ts +2 -2
- package/components/FilePicker/FilePicker.vue.d.ts +2 -2
- package/components/Form/FormField.vue.d.ts +1 -1
- package/components/OTPInput/OTPInput.vue.d.ts +1 -1
- package/components/Rating/Rating.vue.d.ts +1 -1
- package/core/config.d.ts +128 -0
- package/package.json +1 -1
- package/types/config.type.d.ts +2 -0
|
@@ -13,12 +13,12 @@ export interface Props {
|
|
|
13
13
|
className?: string;
|
|
14
14
|
}
|
|
15
15
|
declare const _default: import('vue').DefineComponent<Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
|
|
16
|
-
change: (value: FilePickerValue) => any;
|
|
17
16
|
error: (error: string) => any;
|
|
17
|
+
change: (value: FilePickerValue) => any;
|
|
18
18
|
"update:modelValue": (value: any) => any;
|
|
19
19
|
}, string, import('vue').PublicProps, Readonly<Props> & Readonly<{
|
|
20
|
-
onChange?: (value: FilePickerValue) => any;
|
|
21
20
|
onError?: (error: string) => any;
|
|
21
|
+
onChange?: (value: FilePickerValue) => any;
|
|
22
22
|
"onUpdate:modelValue"?: (value: any) => any;
|
|
23
23
|
}>, {
|
|
24
24
|
alt: string;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { CartProps, CartCoupon, CartTotals } from './types';
|
|
2
|
+
declare const _default: import('vue').DefineComponent<CartProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
|
|
3
|
+
clear: () => any;
|
|
4
|
+
remove: (itemId: string | number) => any;
|
|
5
|
+
continue: () => any;
|
|
6
|
+
"update:quantity": (itemId: string | number, quantity: number) => any;
|
|
7
|
+
"continue-shopping": () => any;
|
|
8
|
+
"apply-coupon": (code: string) => any;
|
|
9
|
+
"remove-coupon": () => any;
|
|
10
|
+
"coupon-change": (code: string) => any;
|
|
11
|
+
"update:coupon": (coupon: CartCoupon) => any;
|
|
12
|
+
"update:totals": (totals: CartTotals) => any;
|
|
13
|
+
}, string, import('vue').PublicProps, Readonly<CartProps> & Readonly<{
|
|
14
|
+
onClear?: () => any;
|
|
15
|
+
onRemove?: (itemId: string | number) => any;
|
|
16
|
+
onContinue?: () => any;
|
|
17
|
+
"onUpdate:quantity"?: (itemId: string | number, quantity: number) => any;
|
|
18
|
+
"onContinue-shopping"?: () => any;
|
|
19
|
+
"onApply-coupon"?: (code: string) => any;
|
|
20
|
+
"onRemove-coupon"?: () => any;
|
|
21
|
+
"onCoupon-change"?: (code: string) => any;
|
|
22
|
+
"onUpdate:coupon"?: (coupon: CartCoupon) => any;
|
|
23
|
+
"onUpdate:totals"?: (totals: CartTotals) => any;
|
|
24
|
+
}>, {
|
|
25
|
+
variant: import('./types').CartVariant;
|
|
26
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLDivElement>;
|
|
27
|
+
export default _default;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { CartCoupon, CartLabels } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Coupon field with all UX states modelled as a discriminated union.
|
|
4
|
+
*
|
|
5
|
+
* - idle → empty input, no validation feedback
|
|
6
|
+
* - applying → request in flight (spinner, input + button disabled)
|
|
7
|
+
* - applied → success state, shows remove action and discount summary
|
|
8
|
+
* - invalid → code not recognised (red border + helper text)
|
|
9
|
+
* - expired → coupon no longer valid (amber border + helper text)
|
|
10
|
+
* - error → generic API error, uses `coupon.message` for helper text
|
|
11
|
+
*
|
|
12
|
+
* The parent owns validation logic; the component only renders.
|
|
13
|
+
*/
|
|
14
|
+
type __VLS_Props = {
|
|
15
|
+
coupon?: CartCoupon;
|
|
16
|
+
labels: CartLabels;
|
|
17
|
+
compact?: boolean;
|
|
18
|
+
readonly?: boolean;
|
|
19
|
+
};
|
|
20
|
+
declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
|
|
21
|
+
remove: () => any;
|
|
22
|
+
apply: (code: string) => any;
|
|
23
|
+
change: (code: string) => any;
|
|
24
|
+
}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
25
|
+
onRemove?: () => any;
|
|
26
|
+
onApply?: (code: string) => any;
|
|
27
|
+
onChange?: (code: string) => any;
|
|
28
|
+
}>, {
|
|
29
|
+
compact: boolean;
|
|
30
|
+
readonly: boolean;
|
|
31
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLDivElement>;
|
|
32
|
+
export default _default;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { CartLabels } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Empty-cart state, rendered when items.length === 0 (and features.emptyState).
|
|
4
|
+
* Same look across all variants; the parent controls size via `compact`.
|
|
5
|
+
*/
|
|
6
|
+
type __VLS_Props = {
|
|
7
|
+
labels: CartLabels;
|
|
8
|
+
compact?: boolean;
|
|
9
|
+
};
|
|
10
|
+
declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
|
|
11
|
+
"continue-shopping": () => any;
|
|
12
|
+
}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
13
|
+
"onContinue-shopping"?: () => any;
|
|
14
|
+
}>, {
|
|
15
|
+
compact: boolean;
|
|
16
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLDivElement>;
|
|
17
|
+
export default _default;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { CartItem, CartFeatures, CartLabels } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Internal layout hints — passed by the variant parent to switch presentation.
|
|
4
|
+
* - 'drawer' : full image, name, sku, variant, qty stepper, price, remove
|
|
5
|
+
* - 'compact': no image, dense single-line per item (POS / register)
|
|
6
|
+
* - 'card' : image + name + variant stacked, controls in a row below
|
|
7
|
+
* - 'mini' : single line, name, qty, price; minimal controls
|
|
8
|
+
*/
|
|
9
|
+
type Layout = 'drawer' | 'compact' | 'card' | 'mini';
|
|
10
|
+
type __VLS_Props = {
|
|
11
|
+
item: CartItem;
|
|
12
|
+
features: CartFeatures;
|
|
13
|
+
labels: CartLabels;
|
|
14
|
+
compact?: boolean;
|
|
15
|
+
readonly?: boolean;
|
|
16
|
+
layout?: Layout;
|
|
17
|
+
};
|
|
18
|
+
declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
|
|
19
|
+
remove: (itemId: string | number) => any;
|
|
20
|
+
"update:quantity": (itemId: string | number, quantity: number) => any;
|
|
21
|
+
}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
22
|
+
onRemove?: (itemId: string | number) => any;
|
|
23
|
+
"onUpdate:quantity"?: (itemId: string | number, quantity: number) => any;
|
|
24
|
+
}>, {
|
|
25
|
+
compact: boolean;
|
|
26
|
+
readonly: boolean;
|
|
27
|
+
layout: Layout;
|
|
28
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
29
|
+
export default _default;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { CartTotals, CartFeatures, CartLabels, CartVariant, CartCoupon } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Subtotal / Discount / Estimated Tax / Shipping / Grand Total renderer.
|
|
4
|
+
* Used by Variant1, Variant2, Variant3. Variant4 inlines its own summary
|
|
5
|
+
* to preserve the mini-cart look.
|
|
6
|
+
*
|
|
7
|
+
* Driven entirely by `features` — every row is conditionally rendered, so
|
|
8
|
+
* the same component can produce a single-line POS total or a full
|
|
9
|
+
* e-commerce summary without branching at the call site.
|
|
10
|
+
*
|
|
11
|
+
* Accepts the applied `coupon` (optional) so it can render the discount
|
|
12
|
+
* row as "Discount · WELCOME10" + "−$25.00" / "−10%". Also renders the
|
|
13
|
+
* free-shipping progress hint ("Add $X more for free shipping") when the
|
|
14
|
+
* totals carry a `freeShippingProgress` payload.
|
|
15
|
+
*/
|
|
16
|
+
type __VLS_Props = {
|
|
17
|
+
totals: CartTotals;
|
|
18
|
+
features: CartFeatures;
|
|
19
|
+
labels: CartLabels;
|
|
20
|
+
compact?: boolean;
|
|
21
|
+
variant?: CartVariant;
|
|
22
|
+
/** Currently applied coupon (for the discount-row caption + pill) */
|
|
23
|
+
coupon?: CartCoupon;
|
|
24
|
+
};
|
|
25
|
+
declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
26
|
+
variant: CartVariant;
|
|
27
|
+
compact: boolean;
|
|
28
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLDivElement>;
|
|
29
|
+
export default _default;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { CartData, CartActions, CartFeatures, CartLabels, CartVariant } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Variant 1 — E-commerce Drawer / Slide-over Cart
|
|
4
|
+
*
|
|
5
|
+
* - Full-width drawer / panel layout
|
|
6
|
+
* - Header: title + item count + close
|
|
7
|
+
* - Scrollable line-items list
|
|
8
|
+
* - Sticky footer: coupon + summary + actions
|
|
9
|
+
* - Best for: site.com slide-over cart, mobile / tablet cart drawer
|
|
10
|
+
*/
|
|
11
|
+
type __VLS_Props = {
|
|
12
|
+
data: CartData;
|
|
13
|
+
actions: CartActions;
|
|
14
|
+
features: CartFeatures;
|
|
15
|
+
labels: CartLabels;
|
|
16
|
+
compact?: boolean;
|
|
17
|
+
variant?: CartVariant;
|
|
18
|
+
containerClass?: string | any[] | Record<string, boolean>;
|
|
19
|
+
};
|
|
20
|
+
declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
|
|
21
|
+
clear: () => any;
|
|
22
|
+
remove: (itemId: string | number) => any;
|
|
23
|
+
continue: () => any;
|
|
24
|
+
"update:quantity": (itemId: string | number, quantity: number) => any;
|
|
25
|
+
"continue-shopping": () => any;
|
|
26
|
+
"apply-coupon": (code: string) => any;
|
|
27
|
+
"remove-coupon": () => any;
|
|
28
|
+
"coupon-change": (code: string) => any;
|
|
29
|
+
}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
30
|
+
onClear?: () => any;
|
|
31
|
+
onRemove?: (itemId: string | number) => any;
|
|
32
|
+
onContinue?: () => any;
|
|
33
|
+
"onUpdate:quantity"?: (itemId: string | number, quantity: number) => any;
|
|
34
|
+
"onContinue-shopping"?: () => any;
|
|
35
|
+
"onApply-coupon"?: (code: string) => any;
|
|
36
|
+
"onRemove-coupon"?: () => any;
|
|
37
|
+
"onCoupon-change"?: (code: string) => any;
|
|
38
|
+
}>, {
|
|
39
|
+
variant: CartVariant;
|
|
40
|
+
compact: boolean;
|
|
41
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLDivElement>;
|
|
42
|
+
export default _default;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { CartData, CartActions, CartFeatures, CartLabels, CartVariant } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Variant 2 — POS / Register Cart
|
|
4
|
+
*
|
|
5
|
+
* - Dense, register-friendly layout
|
|
6
|
+
* - No thumbnails (faster scanning at the till)
|
|
7
|
+
* - Receipt-style dashed dividers
|
|
8
|
+
* - Inline coupon + summary, two compact side-by-side actions
|
|
9
|
+
* - Best for: in-store POS, kitchen tickets, fast-checkout flows
|
|
10
|
+
*/
|
|
11
|
+
type __VLS_Props = {
|
|
12
|
+
data: CartData;
|
|
13
|
+
actions: CartActions;
|
|
14
|
+
features: CartFeatures;
|
|
15
|
+
labels: CartLabels;
|
|
16
|
+
compact?: boolean;
|
|
17
|
+
variant?: CartVariant;
|
|
18
|
+
containerClass?: string | any[] | Record<string, boolean>;
|
|
19
|
+
};
|
|
20
|
+
declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
|
|
21
|
+
clear: () => any;
|
|
22
|
+
remove: (itemId: string | number) => any;
|
|
23
|
+
continue: () => any;
|
|
24
|
+
"update:quantity": (itemId: string | number, quantity: number) => any;
|
|
25
|
+
"continue-shopping": () => any;
|
|
26
|
+
"apply-coupon": (code: string) => any;
|
|
27
|
+
"remove-coupon": () => any;
|
|
28
|
+
"coupon-change": (code: string) => any;
|
|
29
|
+
}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
30
|
+
onClear?: () => any;
|
|
31
|
+
onRemove?: (itemId: string | number) => any;
|
|
32
|
+
onContinue?: () => any;
|
|
33
|
+
"onUpdate:quantity"?: (itemId: string | number, quantity: number) => any;
|
|
34
|
+
"onContinue-shopping"?: () => any;
|
|
35
|
+
"onApply-coupon"?: (code: string) => any;
|
|
36
|
+
"onRemove-coupon"?: () => any;
|
|
37
|
+
"onCoupon-change"?: (code: string) => any;
|
|
38
|
+
}>, {
|
|
39
|
+
variant: CartVariant;
|
|
40
|
+
compact: boolean;
|
|
41
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLDivElement>;
|
|
42
|
+
export default _default;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { CartData, CartActions, CartFeatures, CartLabels, CartVariant } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Variant 3 — Full Page Cart
|
|
4
|
+
*
|
|
5
|
+
* - Header (title + item count + clear)
|
|
6
|
+
* - Two-column body on lg+: items list (left) + sticky summary card (right)
|
|
7
|
+
* - Stacks on mobile
|
|
8
|
+
* - Best for: /cart route, e-commerce site, mobile-first responsive checkout
|
|
9
|
+
*/
|
|
10
|
+
type __VLS_Props = {
|
|
11
|
+
data: CartData;
|
|
12
|
+
actions: CartActions;
|
|
13
|
+
features: CartFeatures;
|
|
14
|
+
labels: CartLabels;
|
|
15
|
+
compact?: boolean;
|
|
16
|
+
variant?: CartVariant;
|
|
17
|
+
containerClass?: string | any[] | Record<string, boolean>;
|
|
18
|
+
};
|
|
19
|
+
declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
|
|
20
|
+
clear: () => any;
|
|
21
|
+
remove: (itemId: string | number) => any;
|
|
22
|
+
continue: () => any;
|
|
23
|
+
"update:quantity": (itemId: string | number, quantity: number) => any;
|
|
24
|
+
"continue-shopping": () => any;
|
|
25
|
+
"apply-coupon": (code: string) => any;
|
|
26
|
+
"remove-coupon": () => any;
|
|
27
|
+
"coupon-change": (code: string) => any;
|
|
28
|
+
}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
29
|
+
onClear?: () => any;
|
|
30
|
+
onRemove?: (itemId: string | number) => any;
|
|
31
|
+
onContinue?: () => any;
|
|
32
|
+
"onUpdate:quantity"?: (itemId: string | number, quantity: number) => any;
|
|
33
|
+
"onContinue-shopping"?: () => any;
|
|
34
|
+
"onApply-coupon"?: (code: string) => any;
|
|
35
|
+
"onRemove-coupon"?: () => any;
|
|
36
|
+
"onCoupon-change"?: (code: string) => any;
|
|
37
|
+
}>, {
|
|
38
|
+
variant: CartVariant;
|
|
39
|
+
compact: boolean;
|
|
40
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLDivElement>;
|
|
41
|
+
export default _default;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { CartData, CartActions, CartFeatures, CartLabels, CartVariant } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Variant 4 — Mini Cart / Summary
|
|
4
|
+
*
|
|
5
|
+
* - Compact, single-column "summary-first" layout
|
|
6
|
+
* - Tiny line items (no images, no qty stepper — name + qty + price)
|
|
7
|
+
* - Inline summary, single primary CTA
|
|
8
|
+
* - Best for: navbar dropdown, header mini-cart, side panel pre-checkout
|
|
9
|
+
*/
|
|
10
|
+
type __VLS_Props = {
|
|
11
|
+
data: CartData;
|
|
12
|
+
actions: CartActions;
|
|
13
|
+
features: CartFeatures;
|
|
14
|
+
labels: CartLabels;
|
|
15
|
+
compact?: boolean;
|
|
16
|
+
variant?: CartVariant;
|
|
17
|
+
containerClass?: string | any[] | Record<string, boolean>;
|
|
18
|
+
};
|
|
19
|
+
declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
|
|
20
|
+
clear: () => any;
|
|
21
|
+
remove: (itemId: string | number) => any;
|
|
22
|
+
continue: () => any;
|
|
23
|
+
"update:quantity": (itemId: string | number, quantity: number) => any;
|
|
24
|
+
"continue-shopping": () => any;
|
|
25
|
+
"apply-coupon": (code: string) => any;
|
|
26
|
+
"remove-coupon": () => any;
|
|
27
|
+
"coupon-change": (code: string) => any;
|
|
28
|
+
}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
29
|
+
onClear?: () => any;
|
|
30
|
+
onRemove?: (itemId: string | number) => any;
|
|
31
|
+
onContinue?: () => any;
|
|
32
|
+
"onUpdate:quantity"?: (itemId: string | number, quantity: number) => any;
|
|
33
|
+
"onContinue-shopping"?: () => any;
|
|
34
|
+
"onApply-coupon"?: (code: string) => any;
|
|
35
|
+
"onRemove-coupon"?: () => any;
|
|
36
|
+
"onCoupon-change"?: (code: string) => any;
|
|
37
|
+
}>, {
|
|
38
|
+
variant: CartVariant;
|
|
39
|
+
compact: boolean;
|
|
40
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLDivElement>;
|
|
41
|
+
export default _default;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { CartItem, CartTotals, CartTaxConfig, CartShippingConfig, CartCoupon } from '../types';
|
|
2
|
+
/** Sum of (price × quantity) for items that are taxable (or all, if item.taxable is undefined). */
|
|
3
|
+
export declare function sumLineTotals(items: CartItem[], onlyTaxable?: boolean): number;
|
|
4
|
+
/** Sum of (originalPrice × quantity) − (price × quantity) across all items. */
|
|
5
|
+
export declare function sumSavings(items: CartItem[]): number;
|
|
6
|
+
export declare function sumItemCount(items: CartItem[]): number;
|
|
7
|
+
/**
|
|
8
|
+
* Compute the discount amount a coupon would apply to a given subtotal.
|
|
9
|
+
* Returns 0 if the coupon doesn't qualify (expired / min-spend not met / etc).
|
|
10
|
+
*/
|
|
11
|
+
export declare function computeCouponDiscount(coupon: CartCoupon | null | undefined, subtotal: number, currency?: string): number;
|
|
12
|
+
export interface TaxBreakdownLine {
|
|
13
|
+
/** Human label, e.g. "Sales Tax" or "VAT (20%)" */
|
|
14
|
+
label: string;
|
|
15
|
+
/** Computed tax amount */
|
|
16
|
+
amount: number;
|
|
17
|
+
/** Rate used (in percent), when applicable */
|
|
18
|
+
rate?: number;
|
|
19
|
+
}
|
|
20
|
+
export interface TaxResult {
|
|
21
|
+
/** Total tax across all breakdown lines */
|
|
22
|
+
total: number;
|
|
23
|
+
/** Per-line breakdown (single line for `rate`/`flat`, no lines for `exempt`) */
|
|
24
|
+
breakdown: TaxBreakdownLine[];
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Compute tax on a given taxable subtotal using a `CartTaxConfig`.
|
|
28
|
+
* - `mode: 'rate'` → percent-based tax (e.g. 8.75% sales tax)
|
|
29
|
+
* - `mode: 'flat'` → fixed tax amount regardless of cart value
|
|
30
|
+
* - `mode: 'exempt'` → no tax
|
|
31
|
+
* - `mode: 'inclusive'`→ tax is already inside the price (display only)
|
|
32
|
+
*/
|
|
33
|
+
export declare function computeTax(taxableSubtotal: number, tax: CartTaxConfig | undefined, roundToCents?: number): TaxResult;
|
|
34
|
+
export interface ShippingResult {
|
|
35
|
+
/** Final shipping cost the customer pays */
|
|
36
|
+
cost: number;
|
|
37
|
+
/** True when the cost is 0 because the user crossed a free-shipping threshold */
|
|
38
|
+
isFree: boolean;
|
|
39
|
+
/** Human-readable reason, e.g. "Free over $50" or "Standard" */
|
|
40
|
+
label: string;
|
|
41
|
+
/** For UI: "Add $X more for free shipping" — null when already free / no rule */
|
|
42
|
+
freeShippingProgress: {
|
|
43
|
+
/** Amount left to spend to unlock free shipping (0 when already unlocked) */
|
|
44
|
+
remaining: number;
|
|
45
|
+
/** The threshold itself */
|
|
46
|
+
threshold: number;
|
|
47
|
+
} | null;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Compute shipping cost using a `CartShippingConfig`.
|
|
51
|
+
* - `mode: 'flat'` → fixed cost
|
|
52
|
+
* - `mode: 'free'` → always free
|
|
53
|
+
* - `mode: 'freeOver'` → free when subtotal ≥ cost-free threshold
|
|
54
|
+
* - `mode: 'tiered'` → lookup table; first row whose `minSubtotal ≤ subtotal` wins
|
|
55
|
+
* - `mode: 'function'` → caller-provided (subtotal, items) => cost
|
|
56
|
+
* - `mode: 'pickup'` → no shipping (in-store pickup)
|
|
57
|
+
*/
|
|
58
|
+
export declare function computeShipping(subtotal: number, shipping: CartShippingConfig | undefined, items: CartItem[]): ShippingResult;
|
|
59
|
+
export interface CalculateInput {
|
|
60
|
+
items: CartItem[];
|
|
61
|
+
tax?: CartTaxConfig;
|
|
62
|
+
shipping?: CartShippingConfig;
|
|
63
|
+
/** The applied coupon (with optional `definition` for internal math) */
|
|
64
|
+
coupon?: CartCoupon | null;
|
|
65
|
+
/** Override rounding precision (default 2) */
|
|
66
|
+
roundToCents?: number;
|
|
67
|
+
/** Currency code — propagated to the result */
|
|
68
|
+
currency?: string;
|
|
69
|
+
}
|
|
70
|
+
export interface CalculateOutput {
|
|
71
|
+
/** The full `CartTotals` object the cart renders */
|
|
72
|
+
totals: CartTotals;
|
|
73
|
+
/** Per-line tax breakdown (empty array for `exempt` / no tax) */
|
|
74
|
+
taxBreakdown: TaxBreakdownLine[];
|
|
75
|
+
/** Free-shipping progress hint for the UI ("Add $X more…") */
|
|
76
|
+
freeShippingProgress: ShippingResult['freeShippingProgress'];
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* The single entry point used by the Cart. Pure: same input → same output.
|
|
80
|
+
*
|
|
81
|
+
* items = [{ price: 100, quantity: 2 }, { price: 50, quantity: 1, taxable: false }]
|
|
82
|
+
* tax = { mode: 'rate', rate: 8.75 }
|
|
83
|
+
* shipping = { mode: 'freeOver', cost: 9.99, freeOver: 50 }
|
|
84
|
+
* coupon = { code: 'WELCOME10', state: 'applied', definition: { type: 'percentage', value: 10, minSubtotal: 100 } }
|
|
85
|
+
*
|
|
86
|
+
* → { subtotal: 250, discount: 25, taxableSubtotal: 200, estimatedTax: 17.50,
|
|
87
|
+
* shipping: 0, grandTotal: 242.50, itemCount: 3, ... }
|
|
88
|
+
*/
|
|
89
|
+
export declare function calculateCartTotals(input: CalculateInput): CalculateOutput;
|
|
90
|
+
/** Convenience helper for the most common case: just items + configs. */
|
|
91
|
+
export declare function useCartCalculation(input: () => CalculateInput): CalculateOutput;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { default as Cart } from './Cart.vue';
|
|
2
|
+
export { default as CartLineItem } from './CartLineItem.vue';
|
|
3
|
+
export { default as CartSummary } from './CartSummary.vue';
|
|
4
|
+
export { default as CartCouponInput } from './CartCouponInput.vue';
|
|
5
|
+
export { default as CartEmptyState } from './CartEmptyState.vue';
|
|
6
|
+
export * from './composables/useCartCalculation';
|
|
7
|
+
export * from './types';
|
|
@@ -0,0 +1,391 @@
|
|
|
1
|
+
export type CartVariant = 'Variant1' | 'Variant2' | 'Variant3' | 'Variant4';
|
|
2
|
+
/** How the cart should be sized within its parent */
|
|
3
|
+
export type CartSize = 'sm' | 'md' | 'lg';
|
|
4
|
+
/**
|
|
5
|
+
* Tax configuration. The cart applies this automatically when `data.totals`
|
|
6
|
+
* is not provided. Supports the most common real-world scenarios:
|
|
7
|
+
*
|
|
8
|
+
* - **`rate`** — percent-based tax on the post-discount subtotal
|
|
9
|
+
* (e.g. 8.75% US sales tax, 19% German VAT)
|
|
10
|
+
* - **`flat`** — fixed tax amount (e.g. "$5 service fee")
|
|
11
|
+
* - **`exempt`** — no tax at all (digital goods, B2B resale, etc.)
|
|
12
|
+
* - **`inclusive`**— tax already baked into the displayed price (EU VAT)
|
|
13
|
+
*/
|
|
14
|
+
export interface CartTaxConfig {
|
|
15
|
+
mode: 'rate' | 'flat' | 'exempt' | 'inclusive';
|
|
16
|
+
/** Percent rate when `mode === 'rate' | 'inclusive'` (e.g. 8.75) */
|
|
17
|
+
rate?: number;
|
|
18
|
+
/** Fixed amount when `mode === 'flat'` */
|
|
19
|
+
amount?: number;
|
|
20
|
+
/** Override the default label (e.g. "GST" instead of "Tax (10%)") */
|
|
21
|
+
label?: string;
|
|
22
|
+
/** Currency this tax applies to (defaults to the cart currency) */
|
|
23
|
+
currency?: string;
|
|
24
|
+
/**
|
|
25
|
+
* What base to apply tax on. Default: 'afterDiscount' (most common).
|
|
26
|
+
* - `subtotal` — full subtotal before any coupon
|
|
27
|
+
* - `afterDiscount` — subtotal minus coupon discount
|
|
28
|
+
* - `original` — alias for `subtotal`
|
|
29
|
+
*/
|
|
30
|
+
applyTo?: 'subtotal' | 'afterDiscount' | 'original';
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Shipping configuration. Plug-and-play with the most common e-commerce /
|
|
34
|
+
* POS patterns. Use `mode: 'function'` for fully custom logic.
|
|
35
|
+
*/
|
|
36
|
+
export interface CartShippingConfig {
|
|
37
|
+
mode: 'flat' | 'free' | 'freeOver' | 'tiered' | 'function' | 'pickup';
|
|
38
|
+
/** Default shipping cost (for `flat` / `freeOver`) */
|
|
39
|
+
cost?: number;
|
|
40
|
+
/** Free-shipping threshold (for `freeOver`) */
|
|
41
|
+
freeOver?: number;
|
|
42
|
+
/** Tiered shipping table (for `tiered`) */
|
|
43
|
+
tiers?: Array<{
|
|
44
|
+
/** Min subtotal for this tier to apply */
|
|
45
|
+
minSubtotal: number;
|
|
46
|
+
/** Shipping cost for this tier (0 = free) */
|
|
47
|
+
cost: number;
|
|
48
|
+
/** Optional label override for this tier */
|
|
49
|
+
label?: string;
|
|
50
|
+
}>;
|
|
51
|
+
/** Custom calculation (for `function`) */
|
|
52
|
+
calculate?: (subtotal: number, items: CartItem[]) => {
|
|
53
|
+
cost: number;
|
|
54
|
+
isFree?: boolean;
|
|
55
|
+
label?: string;
|
|
56
|
+
};
|
|
57
|
+
/** Default label for the shipping line */
|
|
58
|
+
label?: string;
|
|
59
|
+
/** Currency this shipping cost is in */
|
|
60
|
+
currency?: string;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* A coupon's business rules. Pass an array of these as `data.coupons` and
|
|
64
|
+
* the cart will validate user-typed codes against this list internally —
|
|
65
|
+
* you don't need any custom code in your component to handle fixed/percent
|
|
66
|
+
* discounts, min-spend, expiry, or max-cap.
|
|
67
|
+
*
|
|
68
|
+
* If you need server-side validation (rate-limited, single-use, fraud),
|
|
69
|
+
* use `validateCoupon` on `CartProps` instead — the cart will await it
|
|
70
|
+
* and drive the `applying` / `applied` / `invalid` UX for you.
|
|
71
|
+
*/
|
|
72
|
+
export interface CartCouponDefinition {
|
|
73
|
+
/** Coupon code (case-insensitive match by default) */
|
|
74
|
+
code: string;
|
|
75
|
+
/** 'percentage' (% off subtotal) or 'fixed' (flat amount off) */
|
|
76
|
+
type: 'percentage' | 'fixed';
|
|
77
|
+
/** Discount value — percent (0-100) for 'percentage', currency for 'fixed' */
|
|
78
|
+
value: number;
|
|
79
|
+
/** Human-readable description, e.g. "10% off your first order" */
|
|
80
|
+
description?: string;
|
|
81
|
+
/** Min cart subtotal required to apply */
|
|
82
|
+
minSubtotal?: number;
|
|
83
|
+
/** Cap on the discount amount (mostly for `type: 'percentage'`) */
|
|
84
|
+
maxDiscount?: number;
|
|
85
|
+
/** ISO 8601 / Date — coupon expiry */
|
|
86
|
+
expiresAt?: string | Date;
|
|
87
|
+
/** ISO 4217 currency code (coupon only applies to matching currency) */
|
|
88
|
+
currency?: string;
|
|
89
|
+
/**
|
|
90
|
+
* For stacking: how many times this coupon can be applied (1 by default).
|
|
91
|
+
* Single-use coupons set this to 1.
|
|
92
|
+
*/
|
|
93
|
+
usageLimit?: number;
|
|
94
|
+
/** Optional minimum item count required */
|
|
95
|
+
minItems?: number;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Drives the coupon input's visual state and helper message.
|
|
99
|
+
*
|
|
100
|
+
* - `idle` → empty input, no validation feedback
|
|
101
|
+
* - `applying` → request in flight (shows spinner, disables input)
|
|
102
|
+
* - `applied` → success state (green check, shows "Remove" action)
|
|
103
|
+
* - `invalid` → code does not exist (red border + helper text)
|
|
104
|
+
* - `expired` → coupon no longer valid (amber border + helper text)
|
|
105
|
+
* - `error` → generic error (e.g. min spend not met) — message from API
|
|
106
|
+
*/
|
|
107
|
+
export type CartCouponState = 'idle' | 'applying' | 'applied' | 'invalid' | 'expired' | 'error';
|
|
108
|
+
export interface CartTrustSignal {
|
|
109
|
+
/** Iconify name, e.g. "lucide:truck" */
|
|
110
|
+
icon: string;
|
|
111
|
+
/** Text to display */
|
|
112
|
+
text: string;
|
|
113
|
+
}
|
|
114
|
+
export interface CartItem {
|
|
115
|
+
/** Unique identifier for the line item */
|
|
116
|
+
id: string | number;
|
|
117
|
+
/** Product / service name (required) */
|
|
118
|
+
name: string;
|
|
119
|
+
/** Optional secondary description */
|
|
120
|
+
description?: string;
|
|
121
|
+
/** URL to the product thumbnail */
|
|
122
|
+
thumbnail?: string;
|
|
123
|
+
/** SKU / barcode string */
|
|
124
|
+
sku?: string;
|
|
125
|
+
/** Variant label (size, color, etc.) */
|
|
126
|
+
variant?: string;
|
|
127
|
+
/** Unit price */
|
|
128
|
+
price: number;
|
|
129
|
+
/** Quantity in cart */
|
|
130
|
+
quantity: number;
|
|
131
|
+
/** Optional strike-through original price (for sale items) */
|
|
132
|
+
originalPrice?: number;
|
|
133
|
+
/** Hard cap on the qty stepper (e.g. stock) */
|
|
134
|
+
maxQuantity?: number;
|
|
135
|
+
/** Mark out-of-stock items (renders disabled state) */
|
|
136
|
+
inStock?: boolean;
|
|
137
|
+
/** Whether this line should be taxed */
|
|
138
|
+
taxable?: boolean;
|
|
139
|
+
/** Free-form metadata — passed through to custom renderers via slots */
|
|
140
|
+
metadata?: Record<string, any>;
|
|
141
|
+
}
|
|
142
|
+
export interface CartCoupon {
|
|
143
|
+
/** The coupon code as typed by the user */
|
|
144
|
+
code: string;
|
|
145
|
+
/** Human-readable description, e.g. "10% off your order" */
|
|
146
|
+
description?: string;
|
|
147
|
+
/** Current state of the coupon in the UX (see CartCouponState) */
|
|
148
|
+
state?: CartCouponState;
|
|
149
|
+
/** Discount amount (positive number) applied to the cart */
|
|
150
|
+
discountAmount?: number;
|
|
151
|
+
/**
|
|
152
|
+
* Free-form message from the validation API.
|
|
153
|
+
* Shown in the helper-text area when state is 'invalid' | 'expired' | 'error'.
|
|
154
|
+
*/
|
|
155
|
+
message?: string;
|
|
156
|
+
/** ISO 8601 / Date — used to render the "Expires in 2d" pill */
|
|
157
|
+
expiresAt?: string | Date;
|
|
158
|
+
/**
|
|
159
|
+
* The full coupon definition. When provided, the cart will recompute
|
|
160
|
+
* `discountAmount` automatically as items change. Without it, the
|
|
161
|
+
* cart trusts whatever `discountAmount` you pass in.
|
|
162
|
+
*/
|
|
163
|
+
definition?: CartCouponDefinition;
|
|
164
|
+
}
|
|
165
|
+
export interface CartTotals {
|
|
166
|
+
/** Sum of all line items before any discount/tax/shipping */
|
|
167
|
+
subtotal: number;
|
|
168
|
+
/** Total discount applied to the order (positive number) */
|
|
169
|
+
discount?: number;
|
|
170
|
+
/** Estimated tax — labelled exactly as the user asked: "Estimated Tax" */
|
|
171
|
+
estimatedTax?: number;
|
|
172
|
+
/** Tax rate in percent (e.g. 8.625) — used to render "Tax (8.625%)" */
|
|
173
|
+
taxRate?: number;
|
|
174
|
+
/** Shipping cost */
|
|
175
|
+
shipping?: number;
|
|
176
|
+
/** Final amount to charge (after discount + tax + shipping) */
|
|
177
|
+
grandTotal: number;
|
|
178
|
+
/** Number of items — used to render the "Items (4)" line in the summary */
|
|
179
|
+
itemCount?: number;
|
|
180
|
+
/** Total saved vs. original prices — rendered as a savings pill */
|
|
181
|
+
totalSavings?: number;
|
|
182
|
+
/** ISO 4217 currency code (defaults to the global Price config) */
|
|
183
|
+
currency?: string;
|
|
184
|
+
/** Subtotal of taxable items only (used internally; safe to ignore) */
|
|
185
|
+
taxableSubtotal?: number;
|
|
186
|
+
/**
|
|
187
|
+
* Free-shipping progress hint. When the user is below the free-shipping
|
|
188
|
+
* threshold, the cart renders "Add $X more for free shipping".
|
|
189
|
+
*/
|
|
190
|
+
freeShippingProgress?: {
|
|
191
|
+
/** Amount left to spend to unlock free shipping */
|
|
192
|
+
remaining: number;
|
|
193
|
+
/** The free-shipping threshold itself */
|
|
194
|
+
threshold: number;
|
|
195
|
+
} | null;
|
|
196
|
+
/** Per-line tax breakdown — drives the summary if you want multi-rate tax */
|
|
197
|
+
taxBreakdown?: Array<{
|
|
198
|
+
label: string;
|
|
199
|
+
amount: number;
|
|
200
|
+
rate?: number;
|
|
201
|
+
}>;
|
|
202
|
+
}
|
|
203
|
+
export interface CartActions {
|
|
204
|
+
/** Label for the primary action, e.g. "Continue to Checkout" */
|
|
205
|
+
continueLabel?: string;
|
|
206
|
+
/** Label for the secondary action, e.g. "Continue Shopping" */
|
|
207
|
+
continueShoppingLabel?: string;
|
|
208
|
+
/** Show / hide the primary action button */
|
|
209
|
+
showContinue?: boolean;
|
|
210
|
+
/** Show / hide the secondary action button */
|
|
211
|
+
showContinueShopping?: boolean;
|
|
212
|
+
/** Disable the primary action (e.g. when cart is empty) */
|
|
213
|
+
continueDisabled?: boolean;
|
|
214
|
+
/** Disable the secondary action */
|
|
215
|
+
continueShoppingDisabled?: boolean;
|
|
216
|
+
/** Optional icon for the primary action (Iconify name) */
|
|
217
|
+
continueIcon?: string;
|
|
218
|
+
/** Optional icon for the secondary action (Iconify name) */
|
|
219
|
+
continueShoppingIcon?: string;
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Every optional block of the cart can be turned on or off independently.
|
|
223
|
+
* This is what makes the same component usable across e-commerce and POS.
|
|
224
|
+
*
|
|
225
|
+
* Defaults are documented per field — they are designed to satisfy the
|
|
226
|
+
* "out-of-the-box e-commerce cart" use case. POS scenarios explicitly
|
|
227
|
+
* disable thumbnails and description.
|
|
228
|
+
*/
|
|
229
|
+
export interface CartFeatures {
|
|
230
|
+
/** Allow +/- quantity stepper (disabled in readonly) */
|
|
231
|
+
editableQuantity?: boolean;
|
|
232
|
+
/** Allow removing individual items */
|
|
233
|
+
removable?: boolean;
|
|
234
|
+
/** Show the "Clear cart" action */
|
|
235
|
+
clearable?: boolean;
|
|
236
|
+
/** Show the coupon input */
|
|
237
|
+
coupon?: boolean;
|
|
238
|
+
/** Show the Subtotal row */
|
|
239
|
+
subtotal?: boolean;
|
|
240
|
+
/** Show the Discount row */
|
|
241
|
+
discount?: boolean;
|
|
242
|
+
/** Show the Estimated Tax row */
|
|
243
|
+
estimatedTax?: boolean;
|
|
244
|
+
/** Show the Shipping row */
|
|
245
|
+
shipping?: boolean;
|
|
246
|
+
/** Show the Total Savings row */
|
|
247
|
+
totalSavings?: boolean;
|
|
248
|
+
/** Show the primary "Continue" action */
|
|
249
|
+
continue?: boolean;
|
|
250
|
+
/** Show the secondary "Continue shopping" action */
|
|
251
|
+
continueShopping?: boolean;
|
|
252
|
+
/** Show item thumbnails (false in POS compact) */
|
|
253
|
+
thumbnails?: boolean;
|
|
254
|
+
/** Show the secondary description line under the name */
|
|
255
|
+
description?: boolean;
|
|
256
|
+
/** Show the SKU line under the name */
|
|
257
|
+
sku?: boolean;
|
|
258
|
+
/** Show the variant label (size, color) */
|
|
259
|
+
itemVariant?: boolean;
|
|
260
|
+
/** Render an Empty state when there are no items */
|
|
261
|
+
emptyState?: boolean;
|
|
262
|
+
/** Show trust signals (if provided in data) */
|
|
263
|
+
trustSignals?: boolean;
|
|
264
|
+
}
|
|
265
|
+
export interface CartData {
|
|
266
|
+
/** Cart title (e.g. "Your Cart", "Order #1287", "Basket") */
|
|
267
|
+
title?: string;
|
|
268
|
+
/** Optional subtitle / context line */
|
|
269
|
+
subtitle?: string;
|
|
270
|
+
/** Brand / store name */
|
|
271
|
+
brandName?: string;
|
|
272
|
+
/** Brand / store logo URL */
|
|
273
|
+
brandLogo?: string;
|
|
274
|
+
/** Line items in the cart */
|
|
275
|
+
items: CartItem[];
|
|
276
|
+
/**
|
|
277
|
+
* Totals breakdown. OPTIONAL — if you don't pass it, the cart computes
|
|
278
|
+
* it automatically from `items + tax + shipping + coupon`. If you do
|
|
279
|
+
* pass it (e.g. server-computed or pre-aggregated), the cart uses it
|
|
280
|
+
* verbatim and skips its own math.
|
|
281
|
+
*/
|
|
282
|
+
totals?: CartTotals;
|
|
283
|
+
/** Currently applied coupon, if any */
|
|
284
|
+
coupon?: CartCoupon;
|
|
285
|
+
/**
|
|
286
|
+
* Tax configuration. Used by the built-in calculator when `totals`
|
|
287
|
+
* is not provided. Ignored when `totals` is provided.
|
|
288
|
+
*/
|
|
289
|
+
tax?: CartTaxConfig;
|
|
290
|
+
/**
|
|
291
|
+
* Shipping configuration. Used by the built-in calculator when `totals`
|
|
292
|
+
* is not provided. Ignored when `totals` is provided.
|
|
293
|
+
*/
|
|
294
|
+
shipping?: CartShippingConfig;
|
|
295
|
+
/**
|
|
296
|
+
* Catalog of valid coupons. When provided, the cart will validate
|
|
297
|
+
* user-typed codes against this list internally — no `apply-coupon`
|
|
298
|
+
* event handler needed. Use this for static coupon lists; for
|
|
299
|
+
* server-validated coupons, use the `validateCoupon` prop instead.
|
|
300
|
+
*/
|
|
301
|
+
coupons?: CartCouponDefinition[];
|
|
302
|
+
/**
|
|
303
|
+
* Default currency for the cart. Used by the calculation engine when
|
|
304
|
+
* `totals` is not provided. Falls back to the global Price config.
|
|
305
|
+
*/
|
|
306
|
+
currency?: string;
|
|
307
|
+
/** Mark the entire cart read-only (no qty edits, no remove, no coupon change) */
|
|
308
|
+
readonly?: boolean;
|
|
309
|
+
/** Reduce padding/typography (mirrors Invoice `compact` flag) */
|
|
310
|
+
compact?: boolean;
|
|
311
|
+
/** Manually toggle the empty state (overrides `items.length === 0`) */
|
|
312
|
+
empty?: boolean;
|
|
313
|
+
/** Optional trust signals (e.g. "Free shipping over $50", "30-day returns"). */
|
|
314
|
+
trustSignals?: CartTrustSignal[];
|
|
315
|
+
/** Custom CSS class for the root container */
|
|
316
|
+
containerClass?: string | any[] | Record<string, boolean>;
|
|
317
|
+
}
|
|
318
|
+
export interface CartLabels {
|
|
319
|
+
/** Replaces the default "Cart" / "Your Cart" heading */
|
|
320
|
+
cart?: string;
|
|
321
|
+
/** Replaces the default "Your cart is empty" heading in the empty state */
|
|
322
|
+
emptyTitle?: string;
|
|
323
|
+
/** Replaces the default empty-state description */
|
|
324
|
+
emptyDescription?: string;
|
|
325
|
+
/** Replaces the default "Start shopping" CTA in the empty state */
|
|
326
|
+
emptyAction?: string;
|
|
327
|
+
/** Replaces the default "Subtotal" label */
|
|
328
|
+
subtotal?: string;
|
|
329
|
+
/** Replaces the default "Discount" label */
|
|
330
|
+
discount?: string;
|
|
331
|
+
/** Replaces the default "Estimated Tax" label */
|
|
332
|
+
estimatedTax?: string;
|
|
333
|
+
/** Replaces the default "Shipping" label */
|
|
334
|
+
shipping?: string;
|
|
335
|
+
/** Replaces the default "Grand Total" label */
|
|
336
|
+
grandTotal?: string;
|
|
337
|
+
/** Replaces the default "Total Savings" label */
|
|
338
|
+
totalSavings?: string;
|
|
339
|
+
/** Replaces the default "Coupon" input label */
|
|
340
|
+
coupon?: string;
|
|
341
|
+
/** Replaces the default coupon input placeholder */
|
|
342
|
+
couponPlaceholder?: string;
|
|
343
|
+
/** Replaces the default "Apply" button text */
|
|
344
|
+
applyCoupon?: string;
|
|
345
|
+
/** Replaces the default "Remove coupon" aria-label on the applied-coupon × button */
|
|
346
|
+
removeCoupon?: string;
|
|
347
|
+
/** Replaces the default "Quantity" label */
|
|
348
|
+
quantity?: string;
|
|
349
|
+
/** Replaces the default "Remove" item button */
|
|
350
|
+
remove?: string;
|
|
351
|
+
/** Replaces the default "Continue to checkout" button */
|
|
352
|
+
continue?: string;
|
|
353
|
+
/** Replaces the default "Continue shopping" button */
|
|
354
|
+
continueShopping?: string;
|
|
355
|
+
/** Replaces the default "Clear cart" action */
|
|
356
|
+
clearCart?: string;
|
|
357
|
+
/** Replaces the default "Items" prefix in summary (e.g. "Items (3)") */
|
|
358
|
+
itemCount?: string;
|
|
359
|
+
}
|
|
360
|
+
export interface CartProps {
|
|
361
|
+
/** The complete cart data object (required) */
|
|
362
|
+
data: CartData;
|
|
363
|
+
/** Visual layout variant */
|
|
364
|
+
variant?: CartVariant;
|
|
365
|
+
/** Action button configuration */
|
|
366
|
+
actions?: CartActions;
|
|
367
|
+
/** Per-feature on/off toggles */
|
|
368
|
+
features?: CartFeatures;
|
|
369
|
+
/** Custom text label overrides */
|
|
370
|
+
labels?: CartLabels;
|
|
371
|
+
/** Custom CSS class for the root container */
|
|
372
|
+
containerClass?: string | any[] | Record<string, boolean>;
|
|
373
|
+
/**
|
|
374
|
+
* Async server-side coupon validator. Receives the code the user typed
|
|
375
|
+
* and the current subtotal; resolves with a `CartCouponDefinition`
|
|
376
|
+
* (or null to reject). When provided, this takes precedence over
|
|
377
|
+
* `data.coupons` for the apply flow.
|
|
378
|
+
*
|
|
379
|
+
* The cart automatically drives the `applying` / `applied` / `invalid`
|
|
380
|
+
* / `expired` / `error` UX around this call.
|
|
381
|
+
*/
|
|
382
|
+
validateCoupon?: (code: string, context: {
|
|
383
|
+
subtotal: number;
|
|
384
|
+
currency?: string;
|
|
385
|
+
items: CartItem[];
|
|
386
|
+
}) => Promise<CartCouponDefinition | {
|
|
387
|
+
code: string;
|
|
388
|
+
message: string;
|
|
389
|
+
state?: 'invalid' | 'expired' | 'error';
|
|
390
|
+
} | null>;
|
|
391
|
+
}
|
|
@@ -37,11 +37,11 @@ declare const __VLS_component: import('vue').DefineComponent<CategoryManagerProp
|
|
|
37
37
|
}>, {
|
|
38
38
|
size: "sm" | "md" | "lg";
|
|
39
39
|
loading: boolean;
|
|
40
|
+
emptyTitle: string;
|
|
41
|
+
emptyDescription: string;
|
|
40
42
|
readonly: boolean;
|
|
41
43
|
modelValue: CategoryItem[];
|
|
42
44
|
rawData: RawCategoryItem[];
|
|
43
|
-
emptyTitle: string;
|
|
44
|
-
emptyDescription: string;
|
|
45
45
|
defaultExpanded: (string | number)[];
|
|
46
46
|
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, HTMLDivElement>;
|
|
47
47
|
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
|
|
@@ -27,11 +27,11 @@ declare function __VLS_template(): {
|
|
|
27
27
|
};
|
|
28
28
|
type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
|
|
29
29
|
declare const __VLS_component: import('vue').DefineComponent<ClipboardProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
|
|
30
|
-
copy: (text: string) => any;
|
|
31
30
|
error: (err: Error) => any;
|
|
31
|
+
copy: (text: string) => any;
|
|
32
32
|
}, string, import('vue').PublicProps, Readonly<ClipboardProps> & Readonly<{
|
|
33
|
-
onCopy?: (text: string) => any;
|
|
34
33
|
onError?: (err: Error) => any;
|
|
34
|
+
onCopy?: (text: string) => any;
|
|
35
35
|
}>, {
|
|
36
36
|
variant: ButtonVariant;
|
|
37
37
|
size: ButtonSize;
|
|
@@ -41,12 +41,12 @@ declare function __VLS_template(): {
|
|
|
41
41
|
};
|
|
42
42
|
type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
|
|
43
43
|
declare const __VLS_component: import('vue').DefineComponent<Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
|
|
44
|
-
change: (value: FilePickerValue | FilePickerValue[]) => any;
|
|
45
44
|
error: (error: string) => any;
|
|
45
|
+
change: (value: FilePickerValue | FilePickerValue[]) => any;
|
|
46
46
|
"update:modelValue": (value: FilePickerValue | FilePickerValue[]) => any;
|
|
47
47
|
}, string, import('vue').PublicProps, Readonly<Props> & Readonly<{
|
|
48
|
-
onChange?: (value: FilePickerValue | FilePickerValue[]) => any;
|
|
49
48
|
onError?: (error: string) => any;
|
|
49
|
+
onChange?: (value: FilePickerValue | FilePickerValue[]) => any;
|
|
50
50
|
"onUpdate:modelValue"?: (value: FilePickerValue | FilePickerValue[]) => any;
|
|
51
51
|
}>, {
|
|
52
52
|
variant: "dropzone" | "input";
|
|
@@ -31,8 +31,8 @@ declare const _default: import('vue').DefineComponent<Props, {}, {}, {}, {}, imp
|
|
|
31
31
|
size: InputSize;
|
|
32
32
|
rounded: InputRounded;
|
|
33
33
|
loading: boolean;
|
|
34
|
-
readonly: boolean;
|
|
35
34
|
error: string;
|
|
35
|
+
readonly: boolean;
|
|
36
36
|
disabled: boolean;
|
|
37
37
|
isUpdate: boolean;
|
|
38
38
|
floatingActive: boolean;
|
|
@@ -37,8 +37,8 @@ declare const _default: import('vue').DefineComponent<Props, {}, {}, {}, {}, imp
|
|
|
37
37
|
mask: boolean;
|
|
38
38
|
variant: "solid" | "outline" | "ghost";
|
|
39
39
|
size: "sm" | "md" | "lg";
|
|
40
|
-
placeholder: string;
|
|
41
40
|
error: boolean;
|
|
41
|
+
placeholder: string;
|
|
42
42
|
disabled: boolean;
|
|
43
43
|
modelValue: string;
|
|
44
44
|
autofocus: boolean;
|
|
@@ -23,6 +23,7 @@ declare const __VLS_component: import('vue').DefineComponent<RatingProps, {}, {}
|
|
|
23
23
|
icon: string | string[];
|
|
24
24
|
size: "sm" | "md" | "lg" | "xl";
|
|
25
25
|
solid: boolean;
|
|
26
|
+
clearable: boolean;
|
|
26
27
|
readonly: boolean;
|
|
27
28
|
disabled: boolean;
|
|
28
29
|
modelValue: number;
|
|
@@ -32,7 +33,6 @@ declare const __VLS_component: import('vue').DefineComponent<RatingProps, {}, {}
|
|
|
32
33
|
activeIcon: string | string[];
|
|
33
34
|
activeColor: string;
|
|
34
35
|
inactiveColor: string;
|
|
35
|
-
clearable: boolean;
|
|
36
36
|
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, HTMLDivElement>;
|
|
37
37
|
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
|
|
38
38
|
export default _default;
|
package/core/config.d.ts
CHANGED
|
@@ -113,6 +113,70 @@ export declare const configState: {
|
|
|
113
113
|
};
|
|
114
114
|
containerClass?: string | any[] | Record<string, boolean>;
|
|
115
115
|
};
|
|
116
|
+
cart?: {
|
|
117
|
+
variant?: import('../components/Cart').CartVariant;
|
|
118
|
+
labels?: {
|
|
119
|
+
cart?: string;
|
|
120
|
+
emptyTitle?: string;
|
|
121
|
+
emptyDescription?: string;
|
|
122
|
+
emptyAction?: string;
|
|
123
|
+
subtotal?: string;
|
|
124
|
+
discount?: string;
|
|
125
|
+
estimatedTax?: string;
|
|
126
|
+
shipping?: string;
|
|
127
|
+
grandTotal?: string;
|
|
128
|
+
totalSavings?: string;
|
|
129
|
+
coupon?: string;
|
|
130
|
+
couponPlaceholder?: string;
|
|
131
|
+
applyCoupon?: string;
|
|
132
|
+
removeCoupon?: string;
|
|
133
|
+
quantity?: string;
|
|
134
|
+
remove?: string;
|
|
135
|
+
continue?: string;
|
|
136
|
+
continueShopping?: string;
|
|
137
|
+
clearCart?: string;
|
|
138
|
+
itemCount?: string;
|
|
139
|
+
};
|
|
140
|
+
containerClass?: string | any[] | Record<string, boolean>;
|
|
141
|
+
actions?: {
|
|
142
|
+
continueLabel?: string;
|
|
143
|
+
continueShoppingLabel?: string;
|
|
144
|
+
showContinue?: boolean;
|
|
145
|
+
showContinueShopping?: boolean;
|
|
146
|
+
continueDisabled?: boolean;
|
|
147
|
+
continueShoppingDisabled?: boolean;
|
|
148
|
+
continueIcon?: string;
|
|
149
|
+
continueShoppingIcon?: string;
|
|
150
|
+
};
|
|
151
|
+
features?: {
|
|
152
|
+
editableQuantity?: boolean;
|
|
153
|
+
removable?: boolean;
|
|
154
|
+
clearable?: boolean;
|
|
155
|
+
coupon?: boolean;
|
|
156
|
+
subtotal?: boolean;
|
|
157
|
+
discount?: boolean;
|
|
158
|
+
estimatedTax?: boolean;
|
|
159
|
+
shipping?: boolean;
|
|
160
|
+
totalSavings?: boolean;
|
|
161
|
+
continue?: boolean;
|
|
162
|
+
continueShopping?: boolean;
|
|
163
|
+
thumbnails?: boolean;
|
|
164
|
+
description?: boolean;
|
|
165
|
+
sku?: boolean;
|
|
166
|
+
itemVariant?: boolean;
|
|
167
|
+
emptyState?: boolean;
|
|
168
|
+
trustSignals?: boolean;
|
|
169
|
+
};
|
|
170
|
+
validateCoupon?: (code: string, context: {
|
|
171
|
+
subtotal: number;
|
|
172
|
+
currency?: string;
|
|
173
|
+
items: import('../components/Cart').CartItem[];
|
|
174
|
+
}) => Promise<import('../components/Cart').CartCouponDefinition | {
|
|
175
|
+
code: string;
|
|
176
|
+
message: string;
|
|
177
|
+
state?: "invalid" | "expired" | "error";
|
|
178
|
+
} | null>;
|
|
179
|
+
};
|
|
116
180
|
};
|
|
117
181
|
};
|
|
118
182
|
/**
|
|
@@ -228,5 +292,69 @@ export declare function useVLiteConfig(): {
|
|
|
228
292
|
};
|
|
229
293
|
containerClass?: string | any[] | Record<string, boolean>;
|
|
230
294
|
};
|
|
295
|
+
cart?: {
|
|
296
|
+
variant?: import('../components/Cart').CartVariant;
|
|
297
|
+
labels?: {
|
|
298
|
+
cart?: string;
|
|
299
|
+
emptyTitle?: string;
|
|
300
|
+
emptyDescription?: string;
|
|
301
|
+
emptyAction?: string;
|
|
302
|
+
subtotal?: string;
|
|
303
|
+
discount?: string;
|
|
304
|
+
estimatedTax?: string;
|
|
305
|
+
shipping?: string;
|
|
306
|
+
grandTotal?: string;
|
|
307
|
+
totalSavings?: string;
|
|
308
|
+
coupon?: string;
|
|
309
|
+
couponPlaceholder?: string;
|
|
310
|
+
applyCoupon?: string;
|
|
311
|
+
removeCoupon?: string;
|
|
312
|
+
quantity?: string;
|
|
313
|
+
remove?: string;
|
|
314
|
+
continue?: string;
|
|
315
|
+
continueShopping?: string;
|
|
316
|
+
clearCart?: string;
|
|
317
|
+
itemCount?: string;
|
|
318
|
+
};
|
|
319
|
+
containerClass?: string | any[] | Record<string, boolean>;
|
|
320
|
+
actions?: {
|
|
321
|
+
continueLabel?: string;
|
|
322
|
+
continueShoppingLabel?: string;
|
|
323
|
+
showContinue?: boolean;
|
|
324
|
+
showContinueShopping?: boolean;
|
|
325
|
+
continueDisabled?: boolean;
|
|
326
|
+
continueShoppingDisabled?: boolean;
|
|
327
|
+
continueIcon?: string;
|
|
328
|
+
continueShoppingIcon?: string;
|
|
329
|
+
};
|
|
330
|
+
features?: {
|
|
331
|
+
editableQuantity?: boolean;
|
|
332
|
+
removable?: boolean;
|
|
333
|
+
clearable?: boolean;
|
|
334
|
+
coupon?: boolean;
|
|
335
|
+
subtotal?: boolean;
|
|
336
|
+
discount?: boolean;
|
|
337
|
+
estimatedTax?: boolean;
|
|
338
|
+
shipping?: boolean;
|
|
339
|
+
totalSavings?: boolean;
|
|
340
|
+
continue?: boolean;
|
|
341
|
+
continueShopping?: boolean;
|
|
342
|
+
thumbnails?: boolean;
|
|
343
|
+
description?: boolean;
|
|
344
|
+
sku?: boolean;
|
|
345
|
+
itemVariant?: boolean;
|
|
346
|
+
emptyState?: boolean;
|
|
347
|
+
trustSignals?: boolean;
|
|
348
|
+
};
|
|
349
|
+
validateCoupon?: (code: string, context: {
|
|
350
|
+
subtotal: number;
|
|
351
|
+
currency?: string;
|
|
352
|
+
items: import('../components/Cart').CartItem[];
|
|
353
|
+
}) => Promise<import('../components/Cart').CartCouponDefinition | {
|
|
354
|
+
code: string;
|
|
355
|
+
message: string;
|
|
356
|
+
state?: "invalid" | "expired" | "error";
|
|
357
|
+
} | null>;
|
|
358
|
+
};
|
|
231
359
|
};
|
|
232
360
|
};
|
package/package.json
CHANGED
package/types/config.type.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { AttachmentsListProps } from '../components/AttachmentsList/types';
|
|
|
5
5
|
import { ListProps } from './list.type';
|
|
6
6
|
import { InvoiceProps } from '../components/Invoice/types';
|
|
7
7
|
import { FooterProps } from '../components/Footer/types';
|
|
8
|
+
import { CartProps } from '../components/Cart/types';
|
|
8
9
|
/**
|
|
9
10
|
* Interface for the file upload handler function.
|
|
10
11
|
* This allows users to replace the default upload logic with their own API.
|
|
@@ -104,5 +105,6 @@ export interface VLiteConfig {
|
|
|
104
105
|
list?: Omit<ListProps, 'fields' | 'data'>;
|
|
105
106
|
invoice?: Omit<InvoiceProps, 'data'>;
|
|
106
107
|
footer?: Omit<FooterProps, 'data'>;
|
|
108
|
+
cart?: Omit<CartProps, 'data'>;
|
|
107
109
|
};
|
|
108
110
|
}
|