@saasquatch/mint-components 1.15.0-116 → 1.15.0-117
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/cjs/RewardExchangeListData-a787ce54.js +1144 -0
- package/dist/cjs/{ShadowViewAddon-c468a0a7.js → ShadowViewAddon-f1bd9b26.js} +1 -1
- package/dist/cjs/{copy-text-view-b9a8fbb1.js → copy-text-view-44dfefc7.js} +1 -1
- package/dist/cjs/copy-text-view-f0313f78.js +121 -0
- package/dist/cjs/sqm-big-stat_43.cjs.entry.js +2 -2
- package/dist/cjs/sqm-coupon-code-view-a869384e.js +35 -0
- package/dist/cjs/sqm-coupon-code.cjs.entry.js +285 -0
- package/dist/cjs/sqm-pagination_3.cjs.entry.js +1 -1
- package/dist/cjs/sqm-referral-code.cjs.entry.js +177 -0
- package/dist/cjs/sqm-reward-exchange-list.cjs.entry.js +1018 -0
- package/dist/cjs/sqm-share-code.cjs.entry.js +147 -0
- package/dist/cjs/sqm-share-link.cjs.entry.js +102 -0
- package/dist/cjs/sqm-stencilbook.cjs.entry.js +2 -2
- package/dist/collection/components/views/copy-text-view.js +1 -1
- package/dist/esm/RewardExchangeListData-11c043e3.js +1122 -0
- package/dist/esm/{ShadowViewAddon-518e026d.js → ShadowViewAddon-c0600f22.js} +1 -1
- package/dist/esm/copy-text-view-3129fb22.js +119 -0
- package/dist/esm/{copy-text-view-b219d166.js → copy-text-view-a319c261.js} +1 -1
- package/dist/esm/sqm-big-stat_43.entry.js +2 -2
- package/dist/esm/sqm-coupon-code-view-af016712.js +33 -0
- package/dist/esm/sqm-coupon-code.entry.js +281 -0
- package/dist/esm/sqm-pagination_3.entry.js +1 -1
- package/dist/esm/sqm-referral-code.entry.js +173 -0
- package/dist/esm/sqm-reward-exchange-list.entry.js +1014 -0
- package/dist/esm/sqm-share-code.entry.js +143 -0
- package/dist/esm/sqm-share-link.entry.js +98 -0
- package/dist/esm/sqm-stencilbook.entry.js +2 -2
- package/dist/esm-es5/RewardExchangeListData-11c043e3.js +1 -0
- package/dist/esm-es5/{ShadowViewAddon-518e026d.js → ShadowViewAddon-c0600f22.js} +1 -1
- package/dist/esm-es5/copy-text-view-3129fb22.js +1 -0
- package/dist/esm-es5/copy-text-view-a319c261.js +1 -0
- package/dist/esm-es5/sqm-big-stat_43.entry.js +1 -1
- package/dist/esm-es5/sqm-coupon-code-view-af016712.js +1 -0
- package/dist/esm-es5/sqm-coupon-code.entry.js +1 -0
- package/dist/esm-es5/sqm-pagination_3.entry.js +1 -1
- package/dist/esm-es5/sqm-referral-code.entry.js +1 -0
- package/dist/esm-es5/sqm-reward-exchange-list.entry.js +1 -0
- package/dist/esm-es5/sqm-share-code.entry.js +1 -0
- package/dist/esm-es5/sqm-share-link.entry.js +1 -0
- package/dist/esm-es5/sqm-stencilbook.entry.js +1 -1
- package/dist/mint-components/RewardExchangeListData-11c043e3.js +1122 -0
- package/dist/mint-components/RewardExchangeListData-546ffbb9.system.js +1 -0
- package/dist/mint-components/copy-text-view-3129fb22.js +119 -0
- package/dist/mint-components/copy-text-view-33cac657.system.js +1 -0
- package/dist/mint-components/mint-components.esm.js +1 -1
- package/dist/mint-components/{p-5cbcff66.entry.js → p-1276830a.entry.js} +1 -1
- package/dist/mint-components/p-1de49f76.js +1 -0
- package/dist/mint-components/{p-761a02d5.js → p-6b904749.js} +1 -1
- package/dist/mint-components/p-a89baf7b.system.js +1 -1
- package/dist/mint-components/{p-8432d8c2.system.entry.js → p-aa77d858.system.entry.js} +1 -1
- package/dist/mint-components/{p-b8ddc820.system.js → p-bdc86ee3.system.js} +1 -1
- package/dist/mint-components/{p-b5fe3d2c.system.entry.js → p-be770d69.system.entry.js} +1 -1
- package/dist/mint-components/{p-5aeb80dc.entry.js → p-e34b460e.entry.js} +1 -1
- package/dist/mint-components/{p-db14cf82.system.entry.js → p-ed69dc98.system.entry.js} +1 -1
- package/dist/mint-components/p-f4f57363.system.js +1 -0
- package/dist/mint-components/{p-53eaaebf.entry.js → p-f9f67437.entry.js} +1 -1
- package/dist/mint-components/sqm-coupon-code-view-40fd8d8b.system.js +1 -0
- package/dist/mint-components/sqm-coupon-code-view-af016712.js +33 -0
- package/dist/mint-components/sqm-coupon-code.entry.js +281 -0
- package/dist/mint-components/sqm-coupon-code.system.entry.js +1 -0
- package/dist/mint-components/sqm-referral-code.entry.js +173 -0
- package/dist/mint-components/sqm-referral-code.system.entry.js +1 -0
- package/dist/mint-components/sqm-reward-exchange-list.entry.js +1014 -0
- package/dist/mint-components/sqm-reward-exchange-list.system.entry.js +1 -0
- package/dist/mint-components/sqm-share-code.entry.js +143 -0
- package/dist/mint-components/sqm-share-code.system.entry.js +1 -0
- package/dist/mint-components/sqm-share-link.entry.js +98 -0
- package/dist/mint-components/sqm-share-link.system.entry.js +1 -0
- package/dist/mint-components/sqm-stencilbook.entry.js +20330 -0
- package/dist/mint-components/sqm-stencilbook.system.entry.js +1 -0
- package/docs/docs.docx +0 -0
- package/package.json +1 -1
- package/dist/esm-es5/copy-text-view-b219d166.js +0 -1
- package/dist/mint-components/p-25e70b59.js +0 -1
- package/dist/mint-components/p-a4bbb947.system.js +0 -1
|
@@ -7,7 +7,7 @@ import { l as luxonLocale } from './utils-03188de2.js';
|
|
|
7
7
|
import { c as createStyleSheet, j as jss, a as create } from './JSS-67b5cff8.js';
|
|
8
8
|
import { a as REFERRAL_CODES_NAMESPACE, S as SET_CODE_COPIED } from './useReferralCodes-311e6d72.js';
|
|
9
9
|
import { H as HostBlock, A as AuthWrapper, a as AuthColumn, b as AuthButtonsContainer, E as ErrorStyles } from './mixins-f750863a.js';
|
|
10
|
-
import { C as CopyTextView } from './copy-text-view-
|
|
10
|
+
import { C as CopyTextView } from './copy-text-view-a319c261.js';
|
|
11
11
|
import { u as useChildElements } from './useChildElements-4e70ac0e.js';
|
|
12
12
|
import { l as luxon } from './luxon-bbf75a9d.js';
|
|
13
13
|
import { T as TextSpanView } from './sqm-text-span-view-4c17b8c9.js';
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { h } from './index-bfb7f924.js';
|
|
2
|
+
import { c as createStyleSheet } from './JSS-8c381d8b.js';
|
|
3
|
+
import { H as HostBlock } from './mixins-acc245cc.js';
|
|
4
|
+
|
|
5
|
+
const vanillaStyle = `
|
|
6
|
+
:host{
|
|
7
|
+
display: block;
|
|
8
|
+
width: 100%;
|
|
9
|
+
}
|
|
10
|
+
`;
|
|
11
|
+
const textAlignStyle = {
|
|
12
|
+
right: `
|
|
13
|
+
sl-input::part(input){
|
|
14
|
+
text-align: right;
|
|
15
|
+
}`,
|
|
16
|
+
center: `
|
|
17
|
+
sl-input::part(input){
|
|
18
|
+
text-align: center;
|
|
19
|
+
}`,
|
|
20
|
+
left: ``,
|
|
21
|
+
};
|
|
22
|
+
const disabledStyles = `
|
|
23
|
+
sl-input::part(input){
|
|
24
|
+
cursor: default;
|
|
25
|
+
}
|
|
26
|
+
`;
|
|
27
|
+
function CopyTextView(props) {
|
|
28
|
+
const { buttonStyle = "icon" } = props;
|
|
29
|
+
const style = {
|
|
30
|
+
HostBlock: HostBlock,
|
|
31
|
+
inputStyle: {
|
|
32
|
+
"&::part(input)": {
|
|
33
|
+
textOverflow: "ellipsis",
|
|
34
|
+
width: "100%",
|
|
35
|
+
},
|
|
36
|
+
"&::part(base)": {
|
|
37
|
+
"--sl-input-border-radius": `${props.borderRadius}px` || "var(--sqm-border-radius-normal)",
|
|
38
|
+
"--sl-input-background-color": props.backgroundColor || "var(--sqm-portal-background)",
|
|
39
|
+
"--sl-input-color": props.textColor || "var(--sqm-input-color)",
|
|
40
|
+
"--sl-input-border-color": "var(--sqm-border-color)",
|
|
41
|
+
"--sl-input-border-color-hover": "#999999",
|
|
42
|
+
"--sl-input-border-color-focus": "#999999",
|
|
43
|
+
"--sl-input-color-hover": "var(--sqm-input-color-hover)",
|
|
44
|
+
"--sl-input-color-focus": "var(--sqm-input-color-focus)",
|
|
45
|
+
"--sl-input-color-disabled": "var(--sqm-input-disabled-color)",
|
|
46
|
+
"--sl-input-background-color-focus": "var(--sqm-portal-background)",
|
|
47
|
+
"--sl-input-background-color-hover": "var(--sqm-portal-background)",
|
|
48
|
+
cursor: "pointer",
|
|
49
|
+
overflow: "visible",
|
|
50
|
+
borderRadius: `${props.borderRadius}px` || "var(--sqm-border-radius-normal)",
|
|
51
|
+
background: props.backgroundColor || "var(--sqm-portal-background)",
|
|
52
|
+
border: `var(--sqm-border-thickness) solid ${props.borderColor || "var(--sqm-input-border-color)"}`,
|
|
53
|
+
},
|
|
54
|
+
width: "100%",
|
|
55
|
+
},
|
|
56
|
+
icon: {
|
|
57
|
+
"&::part(base)": {
|
|
58
|
+
color: props.textColor || "var(--sqm-input-color)",
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
inputErrorStyle: {
|
|
62
|
+
"&::part(base)": {
|
|
63
|
+
border: "2px solid red",
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
ContainerDiv: {
|
|
67
|
+
display: "flex",
|
|
68
|
+
alignItems: "flex-start",
|
|
69
|
+
flexDirection: "column",
|
|
70
|
+
justifyContent: "center",
|
|
71
|
+
gap: "var(--sl-spacing-x-small)",
|
|
72
|
+
width: "100%",
|
|
73
|
+
},
|
|
74
|
+
containerStyle: {
|
|
75
|
+
display: "flex",
|
|
76
|
+
alignItems: "center",
|
|
77
|
+
gap: "var(--sl-spacing-x-small)",
|
|
78
|
+
width: "100%",
|
|
79
|
+
},
|
|
80
|
+
errorTextStyle: {
|
|
81
|
+
margin: "0",
|
|
82
|
+
color: "var(--sqm-danger-color-text)",
|
|
83
|
+
},
|
|
84
|
+
notificationTextStyle: {
|
|
85
|
+
margin: "0",
|
|
86
|
+
color: "inherit",
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
const sheet = createStyleSheet(style);
|
|
90
|
+
const styleString = sheet.toString();
|
|
91
|
+
const error = !props.loading && props.error;
|
|
92
|
+
const inputText = error ? props.inputPlaceholderText : props.copyString;
|
|
93
|
+
const disabled = error || props.loading || props.disabled;
|
|
94
|
+
const tooltipPlacement = props.buttonStyle === "button-below"
|
|
95
|
+
? "bottom"
|
|
96
|
+
: props.buttonStyle === "button-outside"
|
|
97
|
+
? "top"
|
|
98
|
+
: "top-end";
|
|
99
|
+
const copyButton = (h("sl-tooltip", { trigger: "manual", content: props.tooltiptext, placement: tooltipPlacement, disabled: props.disabled, open: props.open, skidding: props.buttonStyle === "icon" ? -5 : 0, slot: "suffix" }, buttonStyle === "icon" ? (h("sl-icon-button", { class: sheet.classes.icon, exportparts: "base: icon-button-base", onClick: () => { var _a; return (_a = props.onClick) === null || _a === void 0 ? void 0 : _a.call(props); }, name: "files", disabled: disabled })) : (h("sl-button", { exportparts: `base: ${props.buttonType || "primary"}button-base`, onClick: () => { var _a; return (_a = props.onClick) === null || _a === void 0 ? void 0 : _a.call(props); }, size: "medium", style: { width: `${buttonStyle === "button-below" && "100%"}` }, disabled: disabled, type: "primary" }, props.copyButtonLabel || "Copy"))));
|
|
100
|
+
return (h("div", { class: sheet.classes.ContainerDiv },
|
|
101
|
+
h("style", { type: "text/css" },
|
|
102
|
+
styleString,
|
|
103
|
+
vanillaStyle,
|
|
104
|
+
textAlignStyle[props.textAlign],
|
|
105
|
+
disabled && disabledStyles),
|
|
106
|
+
h("div", { class: sheet.classes.containerStyle, style: {
|
|
107
|
+
flexDirection: `${buttonStyle === "button-below" ? "column" : "row"}`,
|
|
108
|
+
} },
|
|
109
|
+
h("sl-input", { class: `${sheet.classes.inputStyle} ${error ? sheet.classes.inputErrorStyle : ""}`, exportparts: "base: input-base, input: input-field", value: props.loading ? "Loading..." : inputText, readonly: true, disabled: disabled },
|
|
110
|
+
buttonStyle === "icon" && copyButton,
|
|
111
|
+
error && (h("p", { slot: "help-text", class: sheet.classes.errorTextStyle }, props.errorText))),
|
|
112
|
+
(buttonStyle === "button-outside" || buttonStyle === "button-below") &&
|
|
113
|
+
copyButton),
|
|
114
|
+
props.isCopied &&
|
|
115
|
+
props.showNotificationText &&
|
|
116
|
+
props.notificationText && (h("p", { part: "sqm-notification-text", class: sheet.classes.notificationTextStyle }, props.notificationText))));
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export { CopyTextView as C };
|
|
@@ -49,7 +49,7 @@ function CopyTextView(props) {
|
|
|
49
49
|
overflow: "visible",
|
|
50
50
|
borderRadius: `${props.borderRadius}px` || "var(--sqm-border-radius-normal)",
|
|
51
51
|
background: props.backgroundColor || "var(--sqm-portal-background)",
|
|
52
|
-
border: `var(--sqm-border-thickness) solid ${props.borderColor || "--sqm-input-border-color"}`,
|
|
52
|
+
border: `var(--sqm-border-thickness) solid ${props.borderColor || "var(--sqm-input-border-color)"}`,
|
|
53
53
|
},
|
|
54
54
|
width: "100%",
|
|
55
55
|
},
|
|
@@ -8,7 +8,7 @@ import { g as getProps, a as getMissingProps } from './utils-03188de2.js';
|
|
|
8
8
|
import { c as createStyleSheet } from './JSS-67b5cff8.js';
|
|
9
9
|
import './useReferralCodes-311e6d72.js';
|
|
10
10
|
import './mixins-f750863a.js';
|
|
11
|
-
import { C as CopyTextView } from './copy-text-view-
|
|
11
|
+
import { C as CopyTextView } from './copy-text-view-a319c261.js';
|
|
12
12
|
import { a as useRequestRerender } from './re-render-9c90767d.js';
|
|
13
13
|
import { u as useChildElements } from './useChildElements-4e70ac0e.js';
|
|
14
14
|
import './luxon-bbf75a9d.js';
|
|
@@ -21,7 +21,7 @@ import { P as PortalLoginView } from './sqm-portal-login-view-7670cd86.js';
|
|
|
21
21
|
import { u as usePortalLogin } from './usePortalLogin-d0720c81.js';
|
|
22
22
|
import { A as AsYouType } from './AsYouType-46f67d0d.js';
|
|
23
23
|
import { i as isEmpty } from './utilities-ad9c2893.js';
|
|
24
|
-
import { u as useDemoBigStat, Q as useBigStat, B as BigStatView, C as CardFeedView, c as CheckboxFieldView, e as CouponCodeView, D as DropdownFieldView, E as EditProfileView, H as HeroView, I as InputFieldView, U as withShadowView, L as LeaderboardView, N as NameFieldsView, f as ChangeMarktingView, P as PortalChangePasswordView, g as PortalFooterView, h as PortalFrameView, d as PortalRegisterView, R as ReferralIframeView, i as RewardExchangeView, V as demoRewardExchange, G as useShareButton, a as ShareButtonView, J as useShareLink, S as StatContainerView, T as TaskCardView } from './ShadowViewAddon-
|
|
24
|
+
import { u as useDemoBigStat, Q as useBigStat, B as BigStatView, C as CardFeedView, c as CheckboxFieldView, e as CouponCodeView, D as DropdownFieldView, E as EditProfileView, H as HeroView, I as InputFieldView, U as withShadowView, L as LeaderboardView, N as NameFieldsView, f as ChangeMarktingView, P as PortalChangePasswordView, g as PortalFooterView, h as PortalFrameView, d as PortalRegisterView, R as ReferralIframeView, i as RewardExchangeView, V as demoRewardExchange, G as useShareButton, a as ShareButtonView, J as useShareLink, S as StatContainerView, T as TaskCardView } from './ShadowViewAddon-c0600f22.js';
|
|
25
25
|
import './sqm-portal-container-view-176e92e3.js';
|
|
26
26
|
import { p as parseStates } from './parseStates-ed75e224.js';
|
|
27
27
|
import { u as usePayoutStatus } from './usePayoutStatus-7eeec61b.js';
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { h } from './index-bfb7f924.js';
|
|
2
|
+
import { c as createStyleSheet } from './JSS-8c381d8b.js';
|
|
3
|
+
import { H as HostBlock } from './mixins-acc245cc.js';
|
|
4
|
+
import { C as CopyTextView } from './copy-text-view-3129fb22.js';
|
|
5
|
+
|
|
6
|
+
function CouponCodeView(props) {
|
|
7
|
+
const error = !props.loading && props.error;
|
|
8
|
+
const style = {
|
|
9
|
+
HostBlock: HostBlock,
|
|
10
|
+
couponCodeLabel: {
|
|
11
|
+
margin: "var(--sl-spacing-x-small) 0",
|
|
12
|
+
color: props.textColor || "var(--sqm-text-subdued)",
|
|
13
|
+
fontSize: "var(--sl-font-size-small)",
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
const vanillaStyle = `
|
|
17
|
+
:host{
|
|
18
|
+
display: block;
|
|
19
|
+
width: 100%;
|
|
20
|
+
}
|
|
21
|
+
`;
|
|
22
|
+
const sheet = createStyleSheet(style);
|
|
23
|
+
const styleString = sheet.toString();
|
|
24
|
+
return (h("div", null,
|
|
25
|
+
h("style", { type: "text/css" },
|
|
26
|
+
styleString,
|
|
27
|
+
vanillaStyle),
|
|
28
|
+
h("p", { class: sheet.classes.couponCodeLabel, style: { textAlign: props.textAlign } }, props.couponCodeLabel),
|
|
29
|
+
error ? (h("sqm-form-message", { type: props.errorType, exportparts: "erroralert-icon" },
|
|
30
|
+
h("div", { part: "erroralert-text" }, props.errorText))) : (h(CopyTextView, Object.assign({}, props)))));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export { CouponCodeView as C };
|
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
import { r as registerInstance, h as h$1 } from './index-bfb7f924.js';
|
|
2
|
+
import { i as useState, o as h } from './dom-context-hooks.module-01c1b885.js';
|
|
3
|
+
import { d as dist, J, H, B, $ as $e, w as wn, i as isDemo } from './index.module-83586215.js';
|
|
4
|
+
import './jss-preset-default.esm-c36417f8.js';
|
|
5
|
+
import './JSS-8c381d8b.js';
|
|
6
|
+
import './mixins-acc245cc.js';
|
|
7
|
+
import { g as getProps } from './utils-93e14db3.js';
|
|
8
|
+
import { c as cjs } from './cjs-e829b75b.js';
|
|
9
|
+
import './copy-text-view-3129fb22.js';
|
|
10
|
+
import { C as CouponCodeView } from './sqm-coupon-code-view-af016712.js';
|
|
11
|
+
|
|
12
|
+
const FuelTankRewardsQuery = dist.gql `
|
|
13
|
+
query fuelTankRewardsQuery($programId: ID!) {
|
|
14
|
+
user: viewer {
|
|
15
|
+
... on User {
|
|
16
|
+
instantAccessRewards(
|
|
17
|
+
filter: { type_eq: FUELTANK, programId_eq: $programId }
|
|
18
|
+
) {
|
|
19
|
+
data {
|
|
20
|
+
fuelTankCode
|
|
21
|
+
fuelTankType
|
|
22
|
+
statuses
|
|
23
|
+
dateGiven
|
|
24
|
+
dateExpires
|
|
25
|
+
dateRedeemed
|
|
26
|
+
dateCancelled
|
|
27
|
+
dateScheduledFor
|
|
28
|
+
datePendingForUnhandledError
|
|
29
|
+
}
|
|
30
|
+
count
|
|
31
|
+
totalCount
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
`;
|
|
37
|
+
const WIDGET_ENGAGEMENT_EVENT = dist.gql `
|
|
38
|
+
mutation loadEvent($eventMeta: UserAnalyticsEvent!) {
|
|
39
|
+
createUserAnalyticsEvent(eventMeta: $eventMeta)
|
|
40
|
+
}
|
|
41
|
+
`;
|
|
42
|
+
function useCouponCode(props) {
|
|
43
|
+
var _a, _b, _c;
|
|
44
|
+
const user = J();
|
|
45
|
+
const programId = H();
|
|
46
|
+
const engagementMedium = B();
|
|
47
|
+
const [sendLoadEvent] = $e(WIDGET_ENGAGEMENT_EVENT);
|
|
48
|
+
const { data, loading, refetch, errors } = wn(FuelTankRewardsQuery, { programId }, !(user === null || user === void 0 ? void 0 : user.jwt));
|
|
49
|
+
const getStatus = (reward) => {
|
|
50
|
+
if (!reward || !reward.statuses)
|
|
51
|
+
return "ERROR";
|
|
52
|
+
const state = reward.statuses[reward.statuses.length - 1];
|
|
53
|
+
if (state === "PENDING" && reward.dateScheduledFor === null)
|
|
54
|
+
return "EMPTY_TANK";
|
|
55
|
+
return state;
|
|
56
|
+
};
|
|
57
|
+
const reward = (_c = (_b = (_a = data === null || data === void 0 ? void 0 : data.user) === null || _a === void 0 ? void 0 : _a.instantAccessRewards) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c[0];
|
|
58
|
+
const rewardStatus = getStatus(reward);
|
|
59
|
+
const dateAvailable = rewardStatus === "PENDING" && reward.dateScheduledFor
|
|
60
|
+
? new Date(reward.dateScheduledFor).toLocaleDateString("default", {
|
|
61
|
+
day: "numeric",
|
|
62
|
+
month: "long",
|
|
63
|
+
year: "numeric",
|
|
64
|
+
})
|
|
65
|
+
: undefined;
|
|
66
|
+
const copyString = (reward === null || reward === void 0 ? void 0 : reward.fuelTankCode) || "...";
|
|
67
|
+
const [open, setOpen] = useState(false);
|
|
68
|
+
function onClick() {
|
|
69
|
+
// Should well supported: https://developer.mozilla.org/en-US/docs/Web/API/Clipboard#browser_compatibility
|
|
70
|
+
// Only if called from a user-initiated event
|
|
71
|
+
navigator.clipboard.writeText(copyString);
|
|
72
|
+
setOpen(true);
|
|
73
|
+
setTimeout(() => setOpen(false), props.tooltiplifespan);
|
|
74
|
+
sendLoadEvent({
|
|
75
|
+
eventMeta: {
|
|
76
|
+
programId,
|
|
77
|
+
id: user === null || user === void 0 ? void 0 : user.id,
|
|
78
|
+
accountId: user === null || user === void 0 ? void 0 : user.accountId,
|
|
79
|
+
type: "USER_REFERRAL_PROGRAM_ENGAGEMENT_EVENT",
|
|
80
|
+
meta: {
|
|
81
|
+
engagementMedium,
|
|
82
|
+
shareMedium: "DIRECT",
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
const getRewardStatusText = (status) => {
|
|
88
|
+
switch (status) {
|
|
89
|
+
case "CANCELLED":
|
|
90
|
+
return props.cancelledErrorText;
|
|
91
|
+
case "EXPIRED":
|
|
92
|
+
return props.expiredErrorText;
|
|
93
|
+
case "EMPTY_TANK":
|
|
94
|
+
return props.fullfillmentErrorText;
|
|
95
|
+
case "PENDING":
|
|
96
|
+
return props.pendingErrorText.replace("{unpendDate}", dateAvailable);
|
|
97
|
+
case "REDEEMED":
|
|
98
|
+
return props.redeemedErrorText;
|
|
99
|
+
case "AVAILABLE":
|
|
100
|
+
return "";
|
|
101
|
+
default:
|
|
102
|
+
return props.genericErrorText;
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
const getRewardStatusErrorType = (status) => {
|
|
106
|
+
switch (status) {
|
|
107
|
+
case "EXPIRED":
|
|
108
|
+
case "EMPTY_TANK":
|
|
109
|
+
case "CANCELLED":
|
|
110
|
+
case "ERROR":
|
|
111
|
+
return "warning";
|
|
112
|
+
case "PENDING":
|
|
113
|
+
return "info";
|
|
114
|
+
case "REDEEMED":
|
|
115
|
+
return "success";
|
|
116
|
+
default:
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
const errorText = getRewardStatusText(rewardStatus);
|
|
121
|
+
const errorType = getRewardStatusErrorType(rewardStatus);
|
|
122
|
+
const error = rewardStatus !== "AVAILABLE";
|
|
123
|
+
return {
|
|
124
|
+
...props,
|
|
125
|
+
onClick,
|
|
126
|
+
open,
|
|
127
|
+
copyString,
|
|
128
|
+
error,
|
|
129
|
+
errorText,
|
|
130
|
+
dateAvailable,
|
|
131
|
+
loading,
|
|
132
|
+
errorType,
|
|
133
|
+
buttonType: props.buttonType || "primary",
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const CouponCode = class {
|
|
138
|
+
constructor(hostRef) {
|
|
139
|
+
registerInstance(this, hostRef);
|
|
140
|
+
/**
|
|
141
|
+
* Shown inside a tooltip after someone has successfully copied the link to their clipboard.
|
|
142
|
+
*
|
|
143
|
+
* @uiName Tooltip text
|
|
144
|
+
*/
|
|
145
|
+
this.tooltiptext = "Copied to Clipboard";
|
|
146
|
+
/**
|
|
147
|
+
* The number of milliseconds that the tooltip appears for
|
|
148
|
+
*
|
|
149
|
+
* @uiName Tooltip lifespan
|
|
150
|
+
*/
|
|
151
|
+
this.tooltiplifespan = 1000;
|
|
152
|
+
/**
|
|
153
|
+
* @uiName Coupon code alignment
|
|
154
|
+
* @uiType string
|
|
155
|
+
* @uiEnum ["left", "center", "right"]
|
|
156
|
+
* @uiEnumNames ["Left", "Center", "Right"]
|
|
157
|
+
* @uiGroup Style
|
|
158
|
+
*/
|
|
159
|
+
this.textAlign = "left";
|
|
160
|
+
/**
|
|
161
|
+
* @uiName Copy button label
|
|
162
|
+
*/
|
|
163
|
+
this.copyButtonLabel = "Copy Coupon";
|
|
164
|
+
/**
|
|
165
|
+
* Set the copy button style and placement.
|
|
166
|
+
*
|
|
167
|
+
* @uiName Style
|
|
168
|
+
* @uiType string
|
|
169
|
+
* @uiEnum ["icon", "button-outside", "button-below"]
|
|
170
|
+
* @uiEnumNames ["Icon", "Button outside", "Button below"]
|
|
171
|
+
* @uiGroup Style
|
|
172
|
+
*/
|
|
173
|
+
this.buttonStyle = "icon";
|
|
174
|
+
/**
|
|
175
|
+
* @uiName Coupon code label
|
|
176
|
+
*/
|
|
177
|
+
this.couponCodeLabel = "Your coupon code:";
|
|
178
|
+
/**
|
|
179
|
+
* Display this message when the coupon code has been cancelled.
|
|
180
|
+
*
|
|
181
|
+
* @uiWidget textArea
|
|
182
|
+
* @uiName Cancelled code error message
|
|
183
|
+
* @uiGroup Coupon code error
|
|
184
|
+
*/
|
|
185
|
+
this.cancelledErrorText = "This code has been cancelled. Please reach out to the Support team for help resolving this issue.";
|
|
186
|
+
/**
|
|
187
|
+
* Display this message when the coupon code has already been redeemed.
|
|
188
|
+
*
|
|
189
|
+
* @uiWidget textArea
|
|
190
|
+
* @uiName Redeemed code error message
|
|
191
|
+
* @uiGroup Coupon code error
|
|
192
|
+
*/
|
|
193
|
+
this.redeemedErrorText = "Looks like you’ve already redeemed this code.";
|
|
194
|
+
/**
|
|
195
|
+
* Display this message when the coupon code has expired.
|
|
196
|
+
*
|
|
197
|
+
* @uiWidget textArea
|
|
198
|
+
* @uiName Expired code error message
|
|
199
|
+
* @uiGroup Coupon code error
|
|
200
|
+
*/
|
|
201
|
+
this.expiredErrorText = "Looks like this code has expired. Please reach out to the Support team for help resolving this issue.";
|
|
202
|
+
/**
|
|
203
|
+
* Display this message when the code fails to load due to a fulfillment error.
|
|
204
|
+
*
|
|
205
|
+
* @uiWidget textArea
|
|
206
|
+
* @uiName Code fulfillment error message
|
|
207
|
+
* @uiGroup Coupon code error
|
|
208
|
+
*/
|
|
209
|
+
this.fullfillmentErrorText = "We couldn't fetch your code. Please try again later or reach out to the Support team for help resolving this issue.";
|
|
210
|
+
/**
|
|
211
|
+
* Display this message when the coupon code not available yet. Use the ICU message, {unpendDate}, to show the date the code will be available.
|
|
212
|
+
*
|
|
213
|
+
* @uiWidget textArea
|
|
214
|
+
* @uiName Code pending error message
|
|
215
|
+
* @uiGroup Coupon code error
|
|
216
|
+
*/
|
|
217
|
+
this.pendingErrorText = "Your code will be available on {unpendDate}. Mark your calendar and come back then to redeem your reward!";
|
|
218
|
+
/**
|
|
219
|
+
* Display this message when the code fails to load due to an unspecified error.
|
|
220
|
+
*
|
|
221
|
+
* @uiWidget textArea
|
|
222
|
+
* @uiName Code retrieval error message
|
|
223
|
+
* @uiGroup Coupon code error
|
|
224
|
+
*/
|
|
225
|
+
this.genericErrorText = "We couldn't fetch your code. Please try again later or reach out to the Support team for help resolving this issue.";
|
|
226
|
+
/**
|
|
227
|
+
* Display this text when the coupon code can’t be retrieved.
|
|
228
|
+
*
|
|
229
|
+
* @uiName Coupon code placeholder
|
|
230
|
+
* @uiGroup Coupon code error
|
|
231
|
+
*/
|
|
232
|
+
this.couponCodePlaceholder = "...";
|
|
233
|
+
/**
|
|
234
|
+
* The type of the button (primary or secondary) that will be used to copy the link.
|
|
235
|
+
* @uiName Button Type
|
|
236
|
+
* @uiType string
|
|
237
|
+
* @uiEnum ["primary", "secondary"]
|
|
238
|
+
* @uiEnumNames ["Primary", "Secondary"]
|
|
239
|
+
* @uiGroup Style
|
|
240
|
+
*/
|
|
241
|
+
this.buttonType = "primary";
|
|
242
|
+
h(this);
|
|
243
|
+
}
|
|
244
|
+
disconnectedCallback() { }
|
|
245
|
+
render() {
|
|
246
|
+
const thisProps = getProps(this);
|
|
247
|
+
const props = isDemo()
|
|
248
|
+
? useDemoCouponCode(thisProps)
|
|
249
|
+
: useCouponCode(thisProps);
|
|
250
|
+
return h$1(CouponCodeView, Object.assign({}, props));
|
|
251
|
+
}
|
|
252
|
+
};
|
|
253
|
+
function useDemoCouponCode(props) {
|
|
254
|
+
const [open, setOpen] = useState(false);
|
|
255
|
+
const copyString = "THANKSJANE125uv125";
|
|
256
|
+
return cjs({
|
|
257
|
+
copyString,
|
|
258
|
+
tooltiptext: props.tooltiptext,
|
|
259
|
+
textAlign: props.textAlign,
|
|
260
|
+
buttonStyle: props.buttonStyle,
|
|
261
|
+
copyButtonLabel: props.copyButtonLabel,
|
|
262
|
+
error: false,
|
|
263
|
+
couponCodePlaceholder: props.couponCodePlaceholder,
|
|
264
|
+
couponCodeLabel: props.couponCodeLabel,
|
|
265
|
+
borderColor: props.borderColor,
|
|
266
|
+
backgroundColor: props.backgroundColor,
|
|
267
|
+
textColor: props.textColor,
|
|
268
|
+
borderRadius: props.borderRadius,
|
|
269
|
+
buttonType: props.buttonType,
|
|
270
|
+
open,
|
|
271
|
+
onClick: () => {
|
|
272
|
+
// Should well supported: https://developer.mozilla.org/en-US/docs/Web/API/Clipboard#browser_compatibility
|
|
273
|
+
// Only if called from a user-initiated event
|
|
274
|
+
navigator.clipboard.writeText(copyString);
|
|
275
|
+
setOpen(true);
|
|
276
|
+
setTimeout(() => setOpen(false), props.tooltiplifespan);
|
|
277
|
+
},
|
|
278
|
+
}, props.demoData || {}, { arrayMerge: (_, a) => a });
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
export { CouponCode as sqm_coupon_code };
|
|
@@ -7,7 +7,7 @@ import { g as getProps } from './utils-03188de2.js';
|
|
|
7
7
|
import { c as createStyleSheet } from './JSS-67b5cff8.js';
|
|
8
8
|
import { R as REFERRAL_CODES_PAGINATION_CONTEXT, a as REFERRAL_CODES_NAMESPACE, S as SET_CODE_COPIED, u as useReferralCodes } from './useReferralCodes-311e6d72.js';
|
|
9
9
|
import './mixins-f750863a.js';
|
|
10
|
-
import { C as CopyTextView } from './copy-text-view-
|
|
10
|
+
import { C as CopyTextView } from './copy-text-view-a319c261.js';
|
|
11
11
|
|
|
12
12
|
const style = {
|
|
13
13
|
Container: {
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { r as registerInstance, h as h$1 } from './index-bfb7f924.js';
|
|
2
|
+
import { i as useState, o as h } from './dom-context-hooks.module-01c1b885.js';
|
|
3
|
+
import { d as dist, H, J, B, F as Fn, w as wn, $ as $e, i as isDemo } from './index.module-83586215.js';
|
|
4
|
+
import './jss-preset-default.esm-c36417f8.js';
|
|
5
|
+
import './JSS-8c381d8b.js';
|
|
6
|
+
import './mixins-acc245cc.js';
|
|
7
|
+
import { g as getProps } from './utils-93e14db3.js';
|
|
8
|
+
import { c as cjs } from './cjs-e829b75b.js';
|
|
9
|
+
import { R as REFERRAL_CODES_NAMESPACE, S as SET_CODE_COPIED } from './useReferralCodes-ec892d5c.js';
|
|
10
|
+
import { C as CopyTextView } from './copy-text-view-3129fb22.js';
|
|
11
|
+
|
|
12
|
+
const MessageLinkQuery = dist.gql `
|
|
13
|
+
query getReferralCode($programId: ID) {
|
|
14
|
+
user: viewer {
|
|
15
|
+
... on User {
|
|
16
|
+
referralCode(programId: $programId)
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
`;
|
|
21
|
+
const WIDGET_ENGAGEMENT_EVENT = dist.gql `
|
|
22
|
+
mutation loadEvent($eventMeta: UserAnalyticsEvent!) {
|
|
23
|
+
createUserAnalyticsEvent(eventMeta: $eventMeta)
|
|
24
|
+
}
|
|
25
|
+
`;
|
|
26
|
+
function useReferralCode(props) {
|
|
27
|
+
var _a, _b;
|
|
28
|
+
const { programId = H() } = props;
|
|
29
|
+
const user = J();
|
|
30
|
+
const engagementMedium = B();
|
|
31
|
+
const contextData = Fn(REFERRAL_CODES_NAMESPACE);
|
|
32
|
+
const { data } = wn(MessageLinkQuery, { programId }, !(user === null || user === void 0 ? void 0 : user.jwt) || (contextData === null || contextData === void 0 ? void 0 : contextData.referralCode) !== undefined);
|
|
33
|
+
const [sendLoadEvent] = $e(WIDGET_ENGAGEMENT_EVENT);
|
|
34
|
+
const [setCopied] = $e(SET_CODE_COPIED);
|
|
35
|
+
const copyString = (_b = ((contextData === null || contextData === void 0 ? void 0 : contextData.referralCode) || ((_a = data === null || data === void 0 ? void 0 : data.user) === null || _a === void 0 ? void 0 : _a.referralCode))) !== null && _b !== void 0 ? _b :
|
|
36
|
+
// Shown during loading
|
|
37
|
+
"...";
|
|
38
|
+
const [open, setOpen] = useState(false);
|
|
39
|
+
async function onClick() {
|
|
40
|
+
if (contextData) {
|
|
41
|
+
await setCopied({ referralCode: contextData.referralCode });
|
|
42
|
+
contextData.refresh();
|
|
43
|
+
}
|
|
44
|
+
// Should well supported: https://developer.mozilla.org/en-US/docs/Web/API/Clipboard#browser_compatibility
|
|
45
|
+
// Only if called from a user-initiated event
|
|
46
|
+
navigator.clipboard.writeText(copyString);
|
|
47
|
+
setOpen(true);
|
|
48
|
+
setTimeout(() => setOpen(false), props.tooltiplifespan);
|
|
49
|
+
sendLoadEvent({
|
|
50
|
+
eventMeta: {
|
|
51
|
+
programId,
|
|
52
|
+
id: user === null || user === void 0 ? void 0 : user.id,
|
|
53
|
+
accountId: user === null || user === void 0 ? void 0 : user.accountId,
|
|
54
|
+
type: "USER_REFERRAL_PROGRAM_ENGAGEMENT_EVENT",
|
|
55
|
+
meta: {
|
|
56
|
+
engagementMedium,
|
|
57
|
+
shareMedium: "DIRECT",
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
return {
|
|
63
|
+
...props,
|
|
64
|
+
onClick,
|
|
65
|
+
open,
|
|
66
|
+
copyString: copyString,
|
|
67
|
+
isCopied: contextData === null || contextData === void 0 ? void 0 : contextData.isCopied,
|
|
68
|
+
showNotificationText: props.showNotificationText && !!(contextData === null || contextData === void 0 ? void 0 : contextData.singleUse),
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const ReferralCode = class {
|
|
73
|
+
constructor(hostRef) {
|
|
74
|
+
registerInstance(this, hostRef);
|
|
75
|
+
/**
|
|
76
|
+
* Shown inside a tooltip after someone has successfully copied the link to their clipboard
|
|
77
|
+
*
|
|
78
|
+
* @uiName Tooltip text
|
|
79
|
+
*/
|
|
80
|
+
this.tooltiptext = "Copied to Clipboard";
|
|
81
|
+
/**
|
|
82
|
+
* Boolean used to show notification text below input
|
|
83
|
+
*
|
|
84
|
+
* @uiName Show notification text
|
|
85
|
+
*/
|
|
86
|
+
this.showNotificationText = false;
|
|
87
|
+
/**
|
|
88
|
+
* Shown underneath single-use promo codes when the user has already copied the code
|
|
89
|
+
*
|
|
90
|
+
* @uiName Notification text
|
|
91
|
+
*/
|
|
92
|
+
this.notificationText = "You've copied this code before";
|
|
93
|
+
/**
|
|
94
|
+
* The number of milliseconds that the tooltip appears for
|
|
95
|
+
*
|
|
96
|
+
* @uiName Tooltip lifespan
|
|
97
|
+
*/
|
|
98
|
+
this.tooltiplifespan = 1000;
|
|
99
|
+
/**
|
|
100
|
+
* Change the text alignment
|
|
101
|
+
*
|
|
102
|
+
* @uiName Referral code alignment
|
|
103
|
+
* @uiType string
|
|
104
|
+
* @uiEnum ["left", "center", "right"]
|
|
105
|
+
* @uiEnumNames ["Left", "Center", "Right"]
|
|
106
|
+
* @uiGroup Style
|
|
107
|
+
*/
|
|
108
|
+
this.textAlign = "left";
|
|
109
|
+
/**
|
|
110
|
+
* @uiName Copy button label
|
|
111
|
+
*/
|
|
112
|
+
this.copyButtonLabel = "Copy Code";
|
|
113
|
+
/**
|
|
114
|
+
* Set the copy button style and placement
|
|
115
|
+
*
|
|
116
|
+
* @uiName Style
|
|
117
|
+
* @uiType string
|
|
118
|
+
* @uiEnum ["icon", "button-outside", "button-below"]
|
|
119
|
+
* @uiEnumNames ["Icon", "Button outside", "Button below"]
|
|
120
|
+
* @uiGroup Style
|
|
121
|
+
*/
|
|
122
|
+
this.buttonStyle = "icon";
|
|
123
|
+
/**
|
|
124
|
+
* The type of the button that is used (primary or secondary).
|
|
125
|
+
* @uiName Button Type
|
|
126
|
+
* @uiType string
|
|
127
|
+
* @uiEnum ["primary", "secondary"]
|
|
128
|
+
* @uiEnumNames ["Primary", "Secondary"]
|
|
129
|
+
* @uiGroup Style
|
|
130
|
+
*/
|
|
131
|
+
this.buttonType = "primary";
|
|
132
|
+
h(this);
|
|
133
|
+
}
|
|
134
|
+
disconnectedCallback() { }
|
|
135
|
+
render() {
|
|
136
|
+
const thisProps = getProps(this);
|
|
137
|
+
const props = isDemo()
|
|
138
|
+
? useDemoReferralCode(thisProps)
|
|
139
|
+
: useReferralCode(thisProps);
|
|
140
|
+
return h$1(CopyTextView, Object.assign({}, props));
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
function useDemoReferralCode(props) {
|
|
144
|
+
const [open, setOpen] = useState(false);
|
|
145
|
+
const copyString = "REFERRALCODE001";
|
|
146
|
+
return cjs({
|
|
147
|
+
copyString: copyString,
|
|
148
|
+
tooltiptext: props.tooltiptext,
|
|
149
|
+
textAlign: props.textAlign,
|
|
150
|
+
copyButtonLabel: props.copyButtonLabel,
|
|
151
|
+
buttonStyle: props.buttonStyle,
|
|
152
|
+
notificationText: props.notificationText,
|
|
153
|
+
showNotificationText: props.showNotificationText,
|
|
154
|
+
isCopied: props.showNotificationText,
|
|
155
|
+
borderColor: props.borderColor,
|
|
156
|
+
backgroundColor: props.backgroundColor,
|
|
157
|
+
textColor: props.textColor,
|
|
158
|
+
borderRadius: props.borderRadius,
|
|
159
|
+
buttonType: props.buttonType,
|
|
160
|
+
isUsed: false,
|
|
161
|
+
rewardStatus: "AVAILABLE",
|
|
162
|
+
open,
|
|
163
|
+
onClick: () => {
|
|
164
|
+
// Should well supported: https://developer.mozilla.org/en-US/docs/Web/API/Clipboard#browser_compatibility
|
|
165
|
+
// Only if called from a user-initiated event
|
|
166
|
+
navigator.clipboard.writeText(copyString);
|
|
167
|
+
setOpen(true);
|
|
168
|
+
setTimeout(() => setOpen(false), props.tooltiplifespan);
|
|
169
|
+
},
|
|
170
|
+
}, props.demoData || {}, { arrayMerge: (_, a) => a });
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export { ReferralCode as sqm_referral_code };
|