vlite3 1.4.2 → 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/CategoryManager/CategoryManager.vue2.js +1 -1
- package/components/CategoryMenu/CategoryMenuVariant1.vue.js +1 -1
- package/components/Clipboard.vue.d.ts +2 -2
- package/components/ColorPicker/ColorIro.vue3.js +2 -2
- package/components/ColorPicker/ColorPicker.vue.js +2 -2
- package/components/Dropdown/Dropdown.vue.js +2 -1
- package/components/Dropdown/DropdownMenu.vue.d.ts +2 -0
- package/components/Dropdown/DropdownMenu.vue.js +2 -2
- package/components/Dropdown/{DropdownMenu.vue3.js → DropdownMenu.vue2.js} +45 -43
- 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/components/Screen/ScreenFilter.vue.js +1 -1
- package/core/config.d.ts +128 -0
- package/package.json +2 -2
- package/style.css +1 -1
- package/types/config.type.d.ts +2 -0
- /package/components/ColorPicker/{ColorIro.vue.js → ColorIro.vue2.js} +0 -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';
|