@saasquatch/mint-components 1.15.0-115 → 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.
Files changed (76) hide show
  1. package/dist/cjs/RewardExchangeListData-a787ce54.js +1144 -0
  2. package/dist/cjs/{ShadowViewAddon-74752e56.js → ShadowViewAddon-f1bd9b26.js} +1 -1
  3. package/dist/cjs/{copy-text-view-c13907f9.js → copy-text-view-44dfefc7.js} +5 -7
  4. package/dist/cjs/copy-text-view-f0313f78.js +121 -0
  5. package/dist/cjs/sqm-big-stat_43.cjs.entry.js +2 -2
  6. package/dist/cjs/sqm-coupon-code-view-a869384e.js +35 -0
  7. package/dist/cjs/sqm-coupon-code.cjs.entry.js +285 -0
  8. package/dist/cjs/sqm-pagination_3.cjs.entry.js +1 -1
  9. package/dist/cjs/sqm-referral-code.cjs.entry.js +177 -0
  10. package/dist/cjs/sqm-reward-exchange-list.cjs.entry.js +1018 -0
  11. package/dist/cjs/sqm-share-code.cjs.entry.js +147 -0
  12. package/dist/cjs/sqm-share-link.cjs.entry.js +102 -0
  13. package/dist/cjs/sqm-stencilbook.cjs.entry.js +3 -3
  14. package/dist/collection/components/sqm-share-link/ShareLink.stories.js +1 -1
  15. package/dist/collection/components/views/copy-text-view.js +5 -7
  16. package/dist/esm/RewardExchangeListData-11c043e3.js +1122 -0
  17. package/dist/esm/{ShadowViewAddon-ee0c8c4b.js → ShadowViewAddon-c0600f22.js} +1 -1
  18. package/dist/esm/copy-text-view-3129fb22.js +119 -0
  19. package/dist/esm/{copy-text-view-61bd1ac1.js → copy-text-view-a319c261.js} +5 -7
  20. package/dist/esm/sqm-big-stat_43.entry.js +2 -2
  21. package/dist/esm/sqm-coupon-code-view-af016712.js +33 -0
  22. package/dist/esm/sqm-coupon-code.entry.js +281 -0
  23. package/dist/esm/sqm-pagination_3.entry.js +1 -1
  24. package/dist/esm/sqm-referral-code.entry.js +173 -0
  25. package/dist/esm/sqm-reward-exchange-list.entry.js +1014 -0
  26. package/dist/esm/sqm-share-code.entry.js +143 -0
  27. package/dist/esm/sqm-share-link.entry.js +98 -0
  28. package/dist/esm/sqm-stencilbook.entry.js +3 -3
  29. package/dist/esm-es5/RewardExchangeListData-11c043e3.js +1 -0
  30. package/dist/esm-es5/{ShadowViewAddon-ee0c8c4b.js → ShadowViewAddon-c0600f22.js} +1 -1
  31. package/dist/esm-es5/copy-text-view-3129fb22.js +1 -0
  32. package/dist/esm-es5/copy-text-view-a319c261.js +1 -0
  33. package/dist/esm-es5/sqm-big-stat_43.entry.js +1 -1
  34. package/dist/esm-es5/sqm-coupon-code-view-af016712.js +1 -0
  35. package/dist/esm-es5/sqm-coupon-code.entry.js +1 -0
  36. package/dist/esm-es5/sqm-pagination_3.entry.js +1 -1
  37. package/dist/esm-es5/sqm-referral-code.entry.js +1 -0
  38. package/dist/esm-es5/sqm-reward-exchange-list.entry.js +1 -0
  39. package/dist/esm-es5/sqm-share-code.entry.js +1 -0
  40. package/dist/esm-es5/sqm-share-link.entry.js +1 -0
  41. package/dist/esm-es5/sqm-stencilbook.entry.js +1 -1
  42. package/dist/mint-components/RewardExchangeListData-11c043e3.js +1122 -0
  43. package/dist/mint-components/RewardExchangeListData-546ffbb9.system.js +1 -0
  44. package/dist/mint-components/copy-text-view-3129fb22.js +119 -0
  45. package/dist/mint-components/copy-text-view-33cac657.system.js +1 -0
  46. package/dist/mint-components/mint-components.esm.js +1 -1
  47. package/dist/mint-components/{p-2bf5998b.entry.js → p-1276830a.entry.js} +1 -1
  48. package/dist/mint-components/p-1de49f76.js +1 -0
  49. package/dist/mint-components/{p-94952e33.js → p-6b904749.js} +1 -1
  50. package/dist/mint-components/p-a89baf7b.system.js +1 -1
  51. package/dist/mint-components/{p-ba0c9f88.system.entry.js → p-aa77d858.system.entry.js} +1 -1
  52. package/dist/mint-components/{p-45736fa8.system.js → p-bdc86ee3.system.js} +1 -1
  53. package/dist/mint-components/{p-680894bd.system.entry.js → p-be770d69.system.entry.js} +1 -1
  54. package/dist/mint-components/{p-0bac31a6.entry.js → p-e34b460e.entry.js} +1 -1
  55. package/dist/mint-components/{p-4e3ec053.system.entry.js → p-ed69dc98.system.entry.js} +1 -1
  56. package/dist/mint-components/p-f4f57363.system.js +1 -0
  57. package/dist/mint-components/{p-dba96a48.entry.js → p-f9f67437.entry.js} +2 -2
  58. package/dist/mint-components/sqm-coupon-code-view-40fd8d8b.system.js +1 -0
  59. package/dist/mint-components/sqm-coupon-code-view-af016712.js +33 -0
  60. package/dist/mint-components/sqm-coupon-code.entry.js +281 -0
  61. package/dist/mint-components/sqm-coupon-code.system.entry.js +1 -0
  62. package/dist/mint-components/sqm-referral-code.entry.js +173 -0
  63. package/dist/mint-components/sqm-referral-code.system.entry.js +1 -0
  64. package/dist/mint-components/sqm-reward-exchange-list.entry.js +1014 -0
  65. package/dist/mint-components/sqm-reward-exchange-list.system.entry.js +1 -0
  66. package/dist/mint-components/sqm-share-code.entry.js +143 -0
  67. package/dist/mint-components/sqm-share-code.system.entry.js +1 -0
  68. package/dist/mint-components/sqm-share-link.entry.js +98 -0
  69. package/dist/mint-components/sqm-share-link.system.entry.js +1 -0
  70. package/dist/mint-components/sqm-stencilbook.entry.js +20330 -0
  71. package/dist/mint-components/sqm-stencilbook.system.entry.js +1 -0
  72. package/docs/docs.docx +0 -0
  73. package/package.json +1 -1
  74. package/dist/esm-es5/copy-text-view-61bd1ac1.js +0 -1
  75. package/dist/mint-components/p-c5ca5b5f.js +0 -1
  76. package/dist/mint-components/p-efeab858.system.js +0 -1
@@ -9,7 +9,7 @@ const utils = require('./utils-7cbd60cc.js');
9
9
  const JSS = require('./JSS-8503a151.js');
10
10
  const useReferralCodes = require('./useReferralCodes-11cdf43b.js');
11
11
  const mixins = require('./mixins-4761d472.js');
12
- const copyTextView = require('./copy-text-view-c13907f9.js');
12
+ const copyTextView = require('./copy-text-view-44dfefc7.js');
13
13
  const useChildElements = require('./useChildElements-966c9041.js');
14
14
  const luxon = require('./luxon-949beaf2.js');
15
15
  const sqmTextSpanView = require('./sqm-text-span-view-7a61ae4c.js');
@@ -36,15 +36,10 @@ function CopyTextView(props) {
36
36
  width: "100%",
37
37
  },
38
38
  "&::part(base)": {
39
- // Use ternary operators for optional props to avoid issues with "undefinedpx"
40
- "--sl-input-border-radius": props.borderRadius
41
- ? `${props.borderRadius}px`
42
- : "var(--sqm-input-border-radius)",
43
- "--sl-input-border-color": props.borderColor || "var(--sqm-border-color)",
44
- // These are now correct
39
+ "--sl-input-border-radius": `${props.borderRadius}px` || "var(--sqm-border-radius-normal)",
45
40
  "--sl-input-background-color": props.backgroundColor || "var(--sqm-portal-background)",
46
41
  "--sl-input-color": props.textColor || "var(--sqm-input-color)",
47
- // Other variables
42
+ "--sl-input-border-color": "var(--sqm-border-color)",
48
43
  "--sl-input-border-color-hover": "#999999",
49
44
  "--sl-input-border-color-focus": "#999999",
50
45
  "--sl-input-color-hover": "var(--sqm-input-color-hover)",
@@ -54,6 +49,9 @@ function CopyTextView(props) {
54
49
  "--sl-input-background-color-hover": "var(--sqm-portal-background)",
55
50
  cursor: "pointer",
56
51
  overflow: "visible",
52
+ borderRadius: `${props.borderRadius}px` || "var(--sqm-border-radius-normal)",
53
+ background: props.backgroundColor || "var(--sqm-portal-background)",
54
+ border: `var(--sqm-border-thickness) solid ${props.borderColor || "var(--sqm-input-border-color)"}`,
57
55
  },
58
56
  width: "100%",
59
57
  },
@@ -0,0 +1,121 @@
1
+ 'use strict';
2
+
3
+ const index = require('./index-ad175903.js');
4
+ const JSS = require('./JSS-518e9b4d.js');
5
+ const mixins = require('./mixins-f51b04f1.js');
6
+
7
+ const vanillaStyle = `
8
+ :host{
9
+ display: block;
10
+ width: 100%;
11
+ }
12
+ `;
13
+ const textAlignStyle = {
14
+ right: `
15
+ sl-input::part(input){
16
+ text-align: right;
17
+ }`,
18
+ center: `
19
+ sl-input::part(input){
20
+ text-align: center;
21
+ }`,
22
+ left: ``,
23
+ };
24
+ const disabledStyles = `
25
+ sl-input::part(input){
26
+ cursor: default;
27
+ }
28
+ `;
29
+ function CopyTextView(props) {
30
+ const { buttonStyle = "icon" } = props;
31
+ const style = {
32
+ HostBlock: mixins.HostBlock,
33
+ inputStyle: {
34
+ "&::part(input)": {
35
+ textOverflow: "ellipsis",
36
+ width: "100%",
37
+ },
38
+ "&::part(base)": {
39
+ "--sl-input-border-radius": `${props.borderRadius}px` || "var(--sqm-border-radius-normal)",
40
+ "--sl-input-background-color": props.backgroundColor || "var(--sqm-portal-background)",
41
+ "--sl-input-color": props.textColor || "var(--sqm-input-color)",
42
+ "--sl-input-border-color": "var(--sqm-border-color)",
43
+ "--sl-input-border-color-hover": "#999999",
44
+ "--sl-input-border-color-focus": "#999999",
45
+ "--sl-input-color-hover": "var(--sqm-input-color-hover)",
46
+ "--sl-input-color-focus": "var(--sqm-input-color-focus)",
47
+ "--sl-input-color-disabled": "var(--sqm-input-disabled-color)",
48
+ "--sl-input-background-color-focus": "var(--sqm-portal-background)",
49
+ "--sl-input-background-color-hover": "var(--sqm-portal-background)",
50
+ cursor: "pointer",
51
+ overflow: "visible",
52
+ borderRadius: `${props.borderRadius}px` || "var(--sqm-border-radius-normal)",
53
+ background: props.backgroundColor || "var(--sqm-portal-background)",
54
+ border: `var(--sqm-border-thickness) solid ${props.borderColor || "var(--sqm-input-border-color)"}`,
55
+ },
56
+ width: "100%",
57
+ },
58
+ icon: {
59
+ "&::part(base)": {
60
+ color: props.textColor || "var(--sqm-input-color)",
61
+ },
62
+ },
63
+ inputErrorStyle: {
64
+ "&::part(base)": {
65
+ border: "2px solid red",
66
+ },
67
+ },
68
+ ContainerDiv: {
69
+ display: "flex",
70
+ alignItems: "flex-start",
71
+ flexDirection: "column",
72
+ justifyContent: "center",
73
+ gap: "var(--sl-spacing-x-small)",
74
+ width: "100%",
75
+ },
76
+ containerStyle: {
77
+ display: "flex",
78
+ alignItems: "center",
79
+ gap: "var(--sl-spacing-x-small)",
80
+ width: "100%",
81
+ },
82
+ errorTextStyle: {
83
+ margin: "0",
84
+ color: "var(--sqm-danger-color-text)",
85
+ },
86
+ notificationTextStyle: {
87
+ margin: "0",
88
+ color: "inherit",
89
+ },
90
+ };
91
+ const sheet = JSS.createStyleSheet(style);
92
+ const styleString = sheet.toString();
93
+ const error = !props.loading && props.error;
94
+ const inputText = error ? props.inputPlaceholderText : props.copyString;
95
+ const disabled = error || props.loading || props.disabled;
96
+ const tooltipPlacement = props.buttonStyle === "button-below"
97
+ ? "bottom"
98
+ : props.buttonStyle === "button-outside"
99
+ ? "top"
100
+ : "top-end";
101
+ const copyButton = (index.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" ? (index.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 })) : (index.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"))));
102
+ return (index.h("div", { class: sheet.classes.ContainerDiv },
103
+ index.h("style", { type: "text/css" },
104
+ styleString,
105
+ vanillaStyle,
106
+ textAlignStyle[props.textAlign],
107
+ disabled && disabledStyles),
108
+ index.h("div", { class: sheet.classes.containerStyle, style: {
109
+ flexDirection: `${buttonStyle === "button-below" ? "column" : "row"}`,
110
+ } },
111
+ index.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 },
112
+ buttonStyle === "icon" && copyButton,
113
+ error && (index.h("p", { slot: "help-text", class: sheet.classes.errorTextStyle }, props.errorText))),
114
+ (buttonStyle === "button-outside" || buttonStyle === "button-below") &&
115
+ copyButton),
116
+ props.isCopied &&
117
+ props.showNotificationText &&
118
+ props.notificationText && (index.h("p", { part: "sqm-notification-text", class: sheet.classes.notificationTextStyle }, props.notificationText))));
119
+ }
120
+
121
+ exports.CopyTextView = CopyTextView;
@@ -12,7 +12,7 @@ const utils = require('./utils-7cbd60cc.js');
12
12
  const JSS = require('./JSS-8503a151.js');
13
13
  require('./useReferralCodes-11cdf43b.js');
14
14
  require('./mixins-4761d472.js');
15
- const copyTextView = require('./copy-text-view-c13907f9.js');
15
+ const copyTextView = require('./copy-text-view-44dfefc7.js');
16
16
  const reRender = require('./re-render-d516138a.js');
17
17
  const useChildElements = require('./useChildElements-966c9041.js');
18
18
  require('./luxon-949beaf2.js');
@@ -25,7 +25,7 @@ const sqmPortalLoginView = require('./sqm-portal-login-view-bb50304c.js');
25
25
  const usePortalLogin = require('./usePortalLogin-6aa864ef.js');
26
26
  const AsYouType = require('./AsYouType-6788393a.js');
27
27
  const utilities = require('./utilities-9a0c5e91.js');
28
- const ShadowViewAddon = require('./ShadowViewAddon-74752e56.js');
28
+ const ShadowViewAddon = require('./ShadowViewAddon-f1bd9b26.js');
29
29
  require('./sqm-portal-container-view-07e4343f.js');
30
30
  const parseStates = require('./parseStates-d1effc19.js');
31
31
  const usePayoutStatus = require('./usePayoutStatus-3b34dab1.js');
@@ -0,0 +1,35 @@
1
+ 'use strict';
2
+
3
+ const index = require('./index-ad175903.js');
4
+ const JSS = require('./JSS-518e9b4d.js');
5
+ const mixins = require('./mixins-f51b04f1.js');
6
+ const copyTextView = require('./copy-text-view-f0313f78.js');
7
+
8
+ function CouponCodeView(props) {
9
+ const error = !props.loading && props.error;
10
+ const style = {
11
+ HostBlock: mixins.HostBlock,
12
+ couponCodeLabel: {
13
+ margin: "var(--sl-spacing-x-small) 0",
14
+ color: props.textColor || "var(--sqm-text-subdued)",
15
+ fontSize: "var(--sl-font-size-small)",
16
+ },
17
+ };
18
+ const vanillaStyle = `
19
+ :host{
20
+ display: block;
21
+ width: 100%;
22
+ }
23
+ `;
24
+ const sheet = JSS.createStyleSheet(style);
25
+ const styleString = sheet.toString();
26
+ return (index.h("div", null,
27
+ index.h("style", { type: "text/css" },
28
+ styleString,
29
+ vanillaStyle),
30
+ index.h("p", { class: sheet.classes.couponCodeLabel, style: { textAlign: props.textAlign } }, props.couponCodeLabel),
31
+ error ? (index.h("sqm-form-message", { type: props.errorType, exportparts: "erroralert-icon" },
32
+ index.h("div", { part: "erroralert-text" }, props.errorText))) : (index.h(copyTextView.CopyTextView, Object.assign({}, props)))));
33
+ }
34
+
35
+ exports.CouponCodeView = CouponCodeView;
@@ -0,0 +1,285 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const index = require('./index-ad175903.js');
6
+ const domContextHooks_module = require('./dom-context-hooks.module-baf97805.js');
7
+ const index_module = require('./index.module-0ec494e5.js');
8
+ require('./jss-preset-default.esm-b48f0c33.js');
9
+ require('./JSS-518e9b4d.js');
10
+ require('./mixins-f51b04f1.js');
11
+ const utils = require('./utils-ebe923b6.js');
12
+ const cjs = require('./cjs-2bf512b9.js');
13
+ require('./copy-text-view-f0313f78.js');
14
+ const sqmCouponCodeView = require('./sqm-coupon-code-view-a869384e.js');
15
+
16
+ const FuelTankRewardsQuery = index_module.dist.gql `
17
+ query fuelTankRewardsQuery($programId: ID!) {
18
+ user: viewer {
19
+ ... on User {
20
+ instantAccessRewards(
21
+ filter: { type_eq: FUELTANK, programId_eq: $programId }
22
+ ) {
23
+ data {
24
+ fuelTankCode
25
+ fuelTankType
26
+ statuses
27
+ dateGiven
28
+ dateExpires
29
+ dateRedeemed
30
+ dateCancelled
31
+ dateScheduledFor
32
+ datePendingForUnhandledError
33
+ }
34
+ count
35
+ totalCount
36
+ }
37
+ }
38
+ }
39
+ }
40
+ `;
41
+ const WIDGET_ENGAGEMENT_EVENT = index_module.dist.gql `
42
+ mutation loadEvent($eventMeta: UserAnalyticsEvent!) {
43
+ createUserAnalyticsEvent(eventMeta: $eventMeta)
44
+ }
45
+ `;
46
+ function useCouponCode(props) {
47
+ var _a, _b, _c;
48
+ const user = index_module.J();
49
+ const programId = index_module.H();
50
+ const engagementMedium = index_module.B();
51
+ const [sendLoadEvent] = index_module.$e(WIDGET_ENGAGEMENT_EVENT);
52
+ const { data, loading, refetch, errors } = index_module.wn(FuelTankRewardsQuery, { programId }, !(user === null || user === void 0 ? void 0 : user.jwt));
53
+ const getStatus = (reward) => {
54
+ if (!reward || !reward.statuses)
55
+ return "ERROR";
56
+ const state = reward.statuses[reward.statuses.length - 1];
57
+ if (state === "PENDING" && reward.dateScheduledFor === null)
58
+ return "EMPTY_TANK";
59
+ return state;
60
+ };
61
+ 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];
62
+ const rewardStatus = getStatus(reward);
63
+ const dateAvailable = rewardStatus === "PENDING" && reward.dateScheduledFor
64
+ ? new Date(reward.dateScheduledFor).toLocaleDateString("default", {
65
+ day: "numeric",
66
+ month: "long",
67
+ year: "numeric",
68
+ })
69
+ : undefined;
70
+ const copyString = (reward === null || reward === void 0 ? void 0 : reward.fuelTankCode) || "...";
71
+ const [open, setOpen] = domContextHooks_module.useState(false);
72
+ function onClick() {
73
+ // Should well supported: https://developer.mozilla.org/en-US/docs/Web/API/Clipboard#browser_compatibility
74
+ // Only if called from a user-initiated event
75
+ navigator.clipboard.writeText(copyString);
76
+ setOpen(true);
77
+ setTimeout(() => setOpen(false), props.tooltiplifespan);
78
+ sendLoadEvent({
79
+ eventMeta: {
80
+ programId,
81
+ id: user === null || user === void 0 ? void 0 : user.id,
82
+ accountId: user === null || user === void 0 ? void 0 : user.accountId,
83
+ type: "USER_REFERRAL_PROGRAM_ENGAGEMENT_EVENT",
84
+ meta: {
85
+ engagementMedium,
86
+ shareMedium: "DIRECT",
87
+ },
88
+ },
89
+ });
90
+ }
91
+ const getRewardStatusText = (status) => {
92
+ switch (status) {
93
+ case "CANCELLED":
94
+ return props.cancelledErrorText;
95
+ case "EXPIRED":
96
+ return props.expiredErrorText;
97
+ case "EMPTY_TANK":
98
+ return props.fullfillmentErrorText;
99
+ case "PENDING":
100
+ return props.pendingErrorText.replace("{unpendDate}", dateAvailable);
101
+ case "REDEEMED":
102
+ return props.redeemedErrorText;
103
+ case "AVAILABLE":
104
+ return "";
105
+ default:
106
+ return props.genericErrorText;
107
+ }
108
+ };
109
+ const getRewardStatusErrorType = (status) => {
110
+ switch (status) {
111
+ case "EXPIRED":
112
+ case "EMPTY_TANK":
113
+ case "CANCELLED":
114
+ case "ERROR":
115
+ return "warning";
116
+ case "PENDING":
117
+ return "info";
118
+ case "REDEEMED":
119
+ return "success";
120
+ default:
121
+ return;
122
+ }
123
+ };
124
+ const errorText = getRewardStatusText(rewardStatus);
125
+ const errorType = getRewardStatusErrorType(rewardStatus);
126
+ const error = rewardStatus !== "AVAILABLE";
127
+ return {
128
+ ...props,
129
+ onClick,
130
+ open,
131
+ copyString,
132
+ error,
133
+ errorText,
134
+ dateAvailable,
135
+ loading,
136
+ errorType,
137
+ buttonType: props.buttonType || "primary",
138
+ };
139
+ }
140
+
141
+ const CouponCode = class {
142
+ constructor(hostRef) {
143
+ index.registerInstance(this, hostRef);
144
+ /**
145
+ * Shown inside a tooltip after someone has successfully copied the link to their clipboard.
146
+ *
147
+ * @uiName Tooltip text
148
+ */
149
+ this.tooltiptext = "Copied to Clipboard";
150
+ /**
151
+ * The number of milliseconds that the tooltip appears for
152
+ *
153
+ * @uiName Tooltip lifespan
154
+ */
155
+ this.tooltiplifespan = 1000;
156
+ /**
157
+ * @uiName Coupon code alignment
158
+ * @uiType string
159
+ * @uiEnum ["left", "center", "right"]
160
+ * @uiEnumNames ["Left", "Center", "Right"]
161
+ * @uiGroup Style
162
+ */
163
+ this.textAlign = "left";
164
+ /**
165
+ * @uiName Copy button label
166
+ */
167
+ this.copyButtonLabel = "Copy Coupon";
168
+ /**
169
+ * Set the copy button style and placement.
170
+ *
171
+ * @uiName Style
172
+ * @uiType string
173
+ * @uiEnum ["icon", "button-outside", "button-below"]
174
+ * @uiEnumNames ["Icon", "Button outside", "Button below"]
175
+ * @uiGroup Style
176
+ */
177
+ this.buttonStyle = "icon";
178
+ /**
179
+ * @uiName Coupon code label
180
+ */
181
+ this.couponCodeLabel = "Your coupon code:";
182
+ /**
183
+ * Display this message when the coupon code has been cancelled.
184
+ *
185
+ * @uiWidget textArea
186
+ * @uiName Cancelled code error message
187
+ * @uiGroup Coupon code error
188
+ */
189
+ this.cancelledErrorText = "This code has been cancelled. Please reach out to the Support team for help resolving this issue.";
190
+ /**
191
+ * Display this message when the coupon code has already been redeemed.
192
+ *
193
+ * @uiWidget textArea
194
+ * @uiName Redeemed code error message
195
+ * @uiGroup Coupon code error
196
+ */
197
+ this.redeemedErrorText = "Looks like you’ve already redeemed this code.";
198
+ /**
199
+ * Display this message when the coupon code has expired.
200
+ *
201
+ * @uiWidget textArea
202
+ * @uiName Expired code error message
203
+ * @uiGroup Coupon code error
204
+ */
205
+ this.expiredErrorText = "Looks like this code has expired. Please reach out to the Support team for help resolving this issue.";
206
+ /**
207
+ * Display this message when the code fails to load due to a fulfillment error.
208
+ *
209
+ * @uiWidget textArea
210
+ * @uiName Code fulfillment error message
211
+ * @uiGroup Coupon code error
212
+ */
213
+ this.fullfillmentErrorText = "We couldn't fetch your code. Please try again later or reach out to the Support team for help resolving this issue.";
214
+ /**
215
+ * Display this message when the coupon code not available yet. Use the ICU message, {unpendDate}, to show the date the code will be available.
216
+ *
217
+ * @uiWidget textArea
218
+ * @uiName Code pending error message
219
+ * @uiGroup Coupon code error
220
+ */
221
+ this.pendingErrorText = "Your code will be available on {unpendDate}. Mark your calendar and come back then to redeem your reward!";
222
+ /**
223
+ * Display this message when the code fails to load due to an unspecified error.
224
+ *
225
+ * @uiWidget textArea
226
+ * @uiName Code retrieval error message
227
+ * @uiGroup Coupon code error
228
+ */
229
+ this.genericErrorText = "We couldn't fetch your code. Please try again later or reach out to the Support team for help resolving this issue.";
230
+ /**
231
+ * Display this text when the coupon code can’t be retrieved.
232
+ *
233
+ * @uiName Coupon code placeholder
234
+ * @uiGroup Coupon code error
235
+ */
236
+ this.couponCodePlaceholder = "...";
237
+ /**
238
+ * The type of the button (primary or secondary) that will be used to copy the link.
239
+ * @uiName Button Type
240
+ * @uiType string
241
+ * @uiEnum ["primary", "secondary"]
242
+ * @uiEnumNames ["Primary", "Secondary"]
243
+ * @uiGroup Style
244
+ */
245
+ this.buttonType = "primary";
246
+ domContextHooks_module.h$1(this);
247
+ }
248
+ disconnectedCallback() { }
249
+ render() {
250
+ const thisProps = utils.getProps(this);
251
+ const props = index_module.isDemo()
252
+ ? useDemoCouponCode(thisProps)
253
+ : useCouponCode(thisProps);
254
+ return index.h(sqmCouponCodeView.CouponCodeView, Object.assign({}, props));
255
+ }
256
+ };
257
+ function useDemoCouponCode(props) {
258
+ const [open, setOpen] = domContextHooks_module.useState(false);
259
+ const copyString = "THANKSJANE125uv125";
260
+ return cjs.cjs({
261
+ copyString,
262
+ tooltiptext: props.tooltiptext,
263
+ textAlign: props.textAlign,
264
+ buttonStyle: props.buttonStyle,
265
+ copyButtonLabel: props.copyButtonLabel,
266
+ error: false,
267
+ couponCodePlaceholder: props.couponCodePlaceholder,
268
+ couponCodeLabel: props.couponCodeLabel,
269
+ borderColor: props.borderColor,
270
+ backgroundColor: props.backgroundColor,
271
+ textColor: props.textColor,
272
+ borderRadius: props.borderRadius,
273
+ buttonType: props.buttonType,
274
+ open,
275
+ onClick: () => {
276
+ // Should well supported: https://developer.mozilla.org/en-US/docs/Web/API/Clipboard#browser_compatibility
277
+ // Only if called from a user-initiated event
278
+ navigator.clipboard.writeText(copyString);
279
+ setOpen(true);
280
+ setTimeout(() => setOpen(false), props.tooltiplifespan);
281
+ },
282
+ }, props.demoData || {}, { arrayMerge: (_, a) => a });
283
+ }
284
+
285
+ exports.sqm_coupon_code = CouponCode;
@@ -11,7 +11,7 @@ const utils = require('./utils-7cbd60cc.js');
11
11
  const JSS = require('./JSS-8503a151.js');
12
12
  const useReferralCodes = require('./useReferralCodes-11cdf43b.js');
13
13
  require('./mixins-4761d472.js');
14
- const copyTextView = require('./copy-text-view-c13907f9.js');
14
+ const copyTextView = require('./copy-text-view-44dfefc7.js');
15
15
 
16
16
  const style = {
17
17
  Container: {
@@ -0,0 +1,177 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const index = require('./index-ad175903.js');
6
+ const domContextHooks_module = require('./dom-context-hooks.module-baf97805.js');
7
+ const index_module = require('./index.module-0ec494e5.js');
8
+ require('./jss-preset-default.esm-b48f0c33.js');
9
+ require('./JSS-518e9b4d.js');
10
+ require('./mixins-f51b04f1.js');
11
+ const utils = require('./utils-ebe923b6.js');
12
+ const cjs = require('./cjs-2bf512b9.js');
13
+ const useReferralCodes = require('./useReferralCodes-bb07449a.js');
14
+ const copyTextView = require('./copy-text-view-f0313f78.js');
15
+
16
+ const MessageLinkQuery = index_module.dist.gql `
17
+ query getReferralCode($programId: ID) {
18
+ user: viewer {
19
+ ... on User {
20
+ referralCode(programId: $programId)
21
+ }
22
+ }
23
+ }
24
+ `;
25
+ const WIDGET_ENGAGEMENT_EVENT = index_module.dist.gql `
26
+ mutation loadEvent($eventMeta: UserAnalyticsEvent!) {
27
+ createUserAnalyticsEvent(eventMeta: $eventMeta)
28
+ }
29
+ `;
30
+ function useReferralCode(props) {
31
+ var _a, _b;
32
+ const { programId = index_module.H() } = props;
33
+ const user = index_module.J();
34
+ const engagementMedium = index_module.B();
35
+ const contextData = index_module.Fn(useReferralCodes.REFERRAL_CODES_NAMESPACE);
36
+ const { data } = index_module.wn(MessageLinkQuery, { programId }, !(user === null || user === void 0 ? void 0 : user.jwt) || (contextData === null || contextData === void 0 ? void 0 : contextData.referralCode) !== undefined);
37
+ const [sendLoadEvent] = index_module.$e(WIDGET_ENGAGEMENT_EVENT);
38
+ const [setCopied] = index_module.$e(useReferralCodes.SET_CODE_COPIED);
39
+ 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 :
40
+ // Shown during loading
41
+ "...";
42
+ const [open, setOpen] = domContextHooks_module.useState(false);
43
+ async function onClick() {
44
+ if (contextData) {
45
+ await setCopied({ referralCode: contextData.referralCode });
46
+ contextData.refresh();
47
+ }
48
+ // Should well supported: https://developer.mozilla.org/en-US/docs/Web/API/Clipboard#browser_compatibility
49
+ // Only if called from a user-initiated event
50
+ navigator.clipboard.writeText(copyString);
51
+ setOpen(true);
52
+ setTimeout(() => setOpen(false), props.tooltiplifespan);
53
+ sendLoadEvent({
54
+ eventMeta: {
55
+ programId,
56
+ id: user === null || user === void 0 ? void 0 : user.id,
57
+ accountId: user === null || user === void 0 ? void 0 : user.accountId,
58
+ type: "USER_REFERRAL_PROGRAM_ENGAGEMENT_EVENT",
59
+ meta: {
60
+ engagementMedium,
61
+ shareMedium: "DIRECT",
62
+ },
63
+ },
64
+ });
65
+ }
66
+ return {
67
+ ...props,
68
+ onClick,
69
+ open,
70
+ copyString: copyString,
71
+ isCopied: contextData === null || contextData === void 0 ? void 0 : contextData.isCopied,
72
+ showNotificationText: props.showNotificationText && !!(contextData === null || contextData === void 0 ? void 0 : contextData.singleUse),
73
+ };
74
+ }
75
+
76
+ const ReferralCode = class {
77
+ constructor(hostRef) {
78
+ index.registerInstance(this, hostRef);
79
+ /**
80
+ * Shown inside a tooltip after someone has successfully copied the link to their clipboard
81
+ *
82
+ * @uiName Tooltip text
83
+ */
84
+ this.tooltiptext = "Copied to Clipboard";
85
+ /**
86
+ * Boolean used to show notification text below input
87
+ *
88
+ * @uiName Show notification text
89
+ */
90
+ this.showNotificationText = false;
91
+ /**
92
+ * Shown underneath single-use promo codes when the user has already copied the code
93
+ *
94
+ * @uiName Notification text
95
+ */
96
+ this.notificationText = "You've copied this code before";
97
+ /**
98
+ * The number of milliseconds that the tooltip appears for
99
+ *
100
+ * @uiName Tooltip lifespan
101
+ */
102
+ this.tooltiplifespan = 1000;
103
+ /**
104
+ * Change the text alignment
105
+ *
106
+ * @uiName Referral code alignment
107
+ * @uiType string
108
+ * @uiEnum ["left", "center", "right"]
109
+ * @uiEnumNames ["Left", "Center", "Right"]
110
+ * @uiGroup Style
111
+ */
112
+ this.textAlign = "left";
113
+ /**
114
+ * @uiName Copy button label
115
+ */
116
+ this.copyButtonLabel = "Copy Code";
117
+ /**
118
+ * Set the copy button style and placement
119
+ *
120
+ * @uiName Style
121
+ * @uiType string
122
+ * @uiEnum ["icon", "button-outside", "button-below"]
123
+ * @uiEnumNames ["Icon", "Button outside", "Button below"]
124
+ * @uiGroup Style
125
+ */
126
+ this.buttonStyle = "icon";
127
+ /**
128
+ * The type of the button that is used (primary or secondary).
129
+ * @uiName Button Type
130
+ * @uiType string
131
+ * @uiEnum ["primary", "secondary"]
132
+ * @uiEnumNames ["Primary", "Secondary"]
133
+ * @uiGroup Style
134
+ */
135
+ this.buttonType = "primary";
136
+ domContextHooks_module.h$1(this);
137
+ }
138
+ disconnectedCallback() { }
139
+ render() {
140
+ const thisProps = utils.getProps(this);
141
+ const props = index_module.isDemo()
142
+ ? useDemoReferralCode(thisProps)
143
+ : useReferralCode(thisProps);
144
+ return index.h(copyTextView.CopyTextView, Object.assign({}, props));
145
+ }
146
+ };
147
+ function useDemoReferralCode(props) {
148
+ const [open, setOpen] = domContextHooks_module.useState(false);
149
+ const copyString = "REFERRALCODE001";
150
+ return cjs.cjs({
151
+ copyString: copyString,
152
+ tooltiptext: props.tooltiptext,
153
+ textAlign: props.textAlign,
154
+ copyButtonLabel: props.copyButtonLabel,
155
+ buttonStyle: props.buttonStyle,
156
+ notificationText: props.notificationText,
157
+ showNotificationText: props.showNotificationText,
158
+ isCopied: props.showNotificationText,
159
+ borderColor: props.borderColor,
160
+ backgroundColor: props.backgroundColor,
161
+ textColor: props.textColor,
162
+ borderRadius: props.borderRadius,
163
+ buttonType: props.buttonType,
164
+ isUsed: false,
165
+ rewardStatus: "AVAILABLE",
166
+ open,
167
+ onClick: () => {
168
+ // Should well supported: https://developer.mozilla.org/en-US/docs/Web/API/Clipboard#browser_compatibility
169
+ // Only if called from a user-initiated event
170
+ navigator.clipboard.writeText(copyString);
171
+ setOpen(true);
172
+ setTimeout(() => setOpen(false), props.tooltiplifespan);
173
+ },
174
+ }, props.demoData || {}, { arrayMerge: (_, a) => a });
175
+ }
176
+
177
+ exports.sqm_referral_code = ReferralCode;