@haus-storefront-react/discounts 0.0.15
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/CHANGELOG.md +1 -0
- package/README.md +243 -0
- package/browser-ponyfill-BWNJl_vW.js +2 -0
- package/browser-ponyfill-CnvJuRn8.mjs +341 -0
- package/index-0w2MTo8y.js +114 -0
- package/index-CJQ4SQIa.mjs +7832 -0
- package/index.d.ts +4 -0
- package/index.js +1 -0
- package/index.mjs +6 -0
- package/lib/active-discounts.d.ts +48 -0
- package/lib/coupon-code.d.ts +62 -0
- package/lib/use-active-discounts.d.ts +10 -0
- package/lib/use-coupon-code.d.ts +9 -0
- package/package.json +20 -0
package/index.d.ts
ADDED
package/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./index-0w2MTo8y.js");exports.ActiveDiscounts=o.ActiveDiscounts;exports.CouponCode=o.CouponCode;exports.useCouponCode=o.useCouponCode;
|
package/index.mjs
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Scope, WebButtonProps, WebDivProps } from '@haus-storefront-react/common-utils';
|
|
2
|
+
import { UseActiveDiscountsReturn } from './use-active-discounts';
|
|
3
|
+
import { AsChildProps, ChildrenProps } from '@haus-storefront-react/shared-types';
|
|
4
|
+
type ScopedProps<P> = P & {
|
|
5
|
+
__scopeActiveDiscounts?: Scope;
|
|
6
|
+
};
|
|
7
|
+
type ActiveDiscountsContextValue = UseActiveDiscountsReturn & {
|
|
8
|
+
currentDiscount?: UseActiveDiscountsReturn['discounts'][0];
|
|
9
|
+
};
|
|
10
|
+
interface ActiveDiscountsRootProps {
|
|
11
|
+
children?: (props: ActiveDiscountsContextValue) => React.ReactNode;
|
|
12
|
+
}
|
|
13
|
+
interface ActiveDiscountsListProps extends Omit<WebDivProps, 'children'>, AsChildProps<ChildrenProps<{
|
|
14
|
+
discounts: UseActiveDiscountsReturn['discounts'];
|
|
15
|
+
}>> {
|
|
16
|
+
__scopeActiveDiscounts?: Scope;
|
|
17
|
+
}
|
|
18
|
+
interface ActiveDiscountsItemProps extends Omit<WebDivProps, 'children'>, AsChildProps<ChildrenProps<{
|
|
19
|
+
discount: UseActiveDiscountsReturn['discounts'][0];
|
|
20
|
+
}>> {
|
|
21
|
+
discount: UseActiveDiscountsReturn['discounts'][0];
|
|
22
|
+
__scopeActiveDiscounts?: Scope;
|
|
23
|
+
}
|
|
24
|
+
interface ActiveDiscountsRemoveButtonProps extends AsChildProps, WebButtonProps {
|
|
25
|
+
__scopeActiveDiscounts?: Scope;
|
|
26
|
+
}
|
|
27
|
+
declare const ActiveDiscounts: {
|
|
28
|
+
({ children, __scopeActiveDiscounts, }: ScopedProps<ActiveDiscountsRootProps>): import("react/jsx-runtime").JSX.Element;
|
|
29
|
+
displayName: string;
|
|
30
|
+
} & {
|
|
31
|
+
Root: {
|
|
32
|
+
({ children, __scopeActiveDiscounts, }: ScopedProps<ActiveDiscountsRootProps>): import("react/jsx-runtime").JSX.Element;
|
|
33
|
+
displayName: string;
|
|
34
|
+
};
|
|
35
|
+
List: {
|
|
36
|
+
({ asChild, children, __scopeActiveDiscounts, ...props }: ScopedProps<ActiveDiscountsListProps>): import("react/jsx-runtime").JSX.Element | null;
|
|
37
|
+
displayName: string;
|
|
38
|
+
};
|
|
39
|
+
Item: {
|
|
40
|
+
({ asChild, discount, children, __scopeActiveDiscounts, ...props }: ScopedProps<ActiveDiscountsItemProps>): import("react/jsx-runtime").JSX.Element;
|
|
41
|
+
displayName: string;
|
|
42
|
+
};
|
|
43
|
+
RemoveButton: {
|
|
44
|
+
({ asChild, children, __scopeActiveDiscounts, ...props }: ActiveDiscountsRemoveButtonProps): import("react/jsx-runtime").JSX.Element | null;
|
|
45
|
+
displayName: string;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
export { ActiveDiscounts };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { Scope, WebButtonProps, WebDivProps, WebInputProps } from '@haus-storefront-react/common-utils';
|
|
2
|
+
import { useCouponCode } from './use-coupon-code';
|
|
3
|
+
import { AsChildProps, ChildrenProps } from '@haus-storefront-react/shared-types';
|
|
4
|
+
type ScopedProps<P> = P & {
|
|
5
|
+
__scopeCouponCode?: Scope;
|
|
6
|
+
};
|
|
7
|
+
type CouponCodeContextValue = ReturnType<typeof useCouponCode>;
|
|
8
|
+
interface CouponCodeRootProps {
|
|
9
|
+
children?: ChildrenProps<CouponCodeContextValue>;
|
|
10
|
+
}
|
|
11
|
+
interface CouponCodeInputProps extends AsChildProps, WebInputProps {
|
|
12
|
+
__scopeCouponCode?: Scope;
|
|
13
|
+
}
|
|
14
|
+
interface CouponCodeApplyButtonProps extends AsChildProps<ChildrenProps<{
|
|
15
|
+
isLoading: boolean;
|
|
16
|
+
error: Error | null;
|
|
17
|
+
}>>, Omit<WebButtonProps, 'children'> {
|
|
18
|
+
__scopeCouponCode?: Scope;
|
|
19
|
+
}
|
|
20
|
+
interface CouponCodeRemoveButtonProps extends AsChildProps, WebButtonProps {
|
|
21
|
+
couponCode: string;
|
|
22
|
+
__scopeCouponCode?: Scope;
|
|
23
|
+
}
|
|
24
|
+
interface CouponCodeErrorProps extends AsChildProps, WebDivProps {
|
|
25
|
+
__scopeCouponCode?: Scope;
|
|
26
|
+
}
|
|
27
|
+
interface CouponCodeDisplayProps extends AsChildProps<ChildrenProps<{
|
|
28
|
+
couponCode: string;
|
|
29
|
+
discount?: string;
|
|
30
|
+
}>>, Omit<WebDivProps, 'children'> {
|
|
31
|
+
couponCode: string;
|
|
32
|
+
discount?: string;
|
|
33
|
+
__scopeCouponCode?: Scope;
|
|
34
|
+
}
|
|
35
|
+
export declare const CouponCode: {
|
|
36
|
+
Root: {
|
|
37
|
+
({ children, __scopeCouponCode }: ScopedProps<CouponCodeRootProps>): import("react/jsx-runtime").JSX.Element;
|
|
38
|
+
displayName: string;
|
|
39
|
+
};
|
|
40
|
+
Input: {
|
|
41
|
+
({ asChild, __scopeCouponCode, ...props }: CouponCodeInputProps): import("react/jsx-runtime").JSX.Element;
|
|
42
|
+
displayName: string;
|
|
43
|
+
};
|
|
44
|
+
ApplyButton: {
|
|
45
|
+
({ asChild, children, __scopeCouponCode, ...props }: CouponCodeApplyButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
46
|
+
displayName: string;
|
|
47
|
+
};
|
|
48
|
+
RemoveButton: {
|
|
49
|
+
({ asChild, couponCode, __scopeCouponCode, ...props }: CouponCodeRemoveButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
50
|
+
displayName: string;
|
|
51
|
+
};
|
|
52
|
+
Error: {
|
|
53
|
+
({ asChild, children, __scopeCouponCode, ...props }: CouponCodeErrorProps): import("react/jsx-runtime").JSX.Element | null;
|
|
54
|
+
displayName: string;
|
|
55
|
+
};
|
|
56
|
+
Display: {
|
|
57
|
+
({ asChild, couponCode, discount, children, __scopeCouponCode, ...props }: CouponCodeDisplayProps): import("react/jsx-runtime").JSX.Element;
|
|
58
|
+
displayName: string;
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
export { useCouponCode } from './use-coupon-code';
|
|
62
|
+
export type { UseCouponCodeReturn } from './use-coupon-code';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Promotion, Discount, CurrencyCode } from '@haus-storefront-react/shared-types';
|
|
2
|
+
export interface DiscountWithPromotion extends Discount {
|
|
3
|
+
promotion?: Promotion;
|
|
4
|
+
currencyCode: CurrencyCode;
|
|
5
|
+
}
|
|
6
|
+
export interface UseActiveDiscountsReturn {
|
|
7
|
+
discounts: DiscountWithPromotion[];
|
|
8
|
+
removeCouponCode: (couponCode: string) => Promise<void>;
|
|
9
|
+
}
|
|
10
|
+
export declare const useActiveDiscounts: () => UseActiveDiscountsReturn;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface UseCouponCodeReturn {
|
|
2
|
+
code: string;
|
|
3
|
+
isLoading: boolean;
|
|
4
|
+
error: Error | null;
|
|
5
|
+
setCode: (code: string) => void;
|
|
6
|
+
applyCouponCode: (code: string) => Promise<void>;
|
|
7
|
+
removeCouponCode: (code: string) => Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
export declare const useCouponCode: () => UseCouponCodeReturn;
|
package/package.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@haus-storefront-react/discounts",
|
|
3
|
+
"version": "0.0.15",
|
|
4
|
+
"main": "./index.js",
|
|
5
|
+
"types": "./index.d.ts",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./index.d.ts",
|
|
9
|
+
"import": "./index.mjs",
|
|
10
|
+
"require": "./index.js"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"@haus-storefront-react/common-ui": "0.0.15",
|
|
15
|
+
"@haus-storefront-react/common-utils": "0.0.15",
|
|
16
|
+
"@haus-storefront-react/core": "0.0.15",
|
|
17
|
+
"@haus-storefront-react/hooks": "0.0.15",
|
|
18
|
+
"@haus-storefront-react/shared-types": "0.0.15"
|
|
19
|
+
}
|
|
20
|
+
}
|