@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.
Files changed (75) hide show
  1. package/dist/cjs/RewardExchangeListData-a787ce54.js +1144 -0
  2. package/dist/cjs/{ShadowViewAddon-c468a0a7.js → ShadowViewAddon-f1bd9b26.js} +1 -1
  3. package/dist/cjs/{copy-text-view-b9a8fbb1.js → copy-text-view-44dfefc7.js} +1 -1
  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 +2 -2
  14. package/dist/collection/components/views/copy-text-view.js +1 -1
  15. package/dist/esm/RewardExchangeListData-11c043e3.js +1122 -0
  16. package/dist/esm/{ShadowViewAddon-518e026d.js → ShadowViewAddon-c0600f22.js} +1 -1
  17. package/dist/esm/copy-text-view-3129fb22.js +119 -0
  18. package/dist/esm/{copy-text-view-b219d166.js → copy-text-view-a319c261.js} +1 -1
  19. package/dist/esm/sqm-big-stat_43.entry.js +2 -2
  20. package/dist/esm/sqm-coupon-code-view-af016712.js +33 -0
  21. package/dist/esm/sqm-coupon-code.entry.js +281 -0
  22. package/dist/esm/sqm-pagination_3.entry.js +1 -1
  23. package/dist/esm/sqm-referral-code.entry.js +173 -0
  24. package/dist/esm/sqm-reward-exchange-list.entry.js +1014 -0
  25. package/dist/esm/sqm-share-code.entry.js +143 -0
  26. package/dist/esm/sqm-share-link.entry.js +98 -0
  27. package/dist/esm/sqm-stencilbook.entry.js +2 -2
  28. package/dist/esm-es5/RewardExchangeListData-11c043e3.js +1 -0
  29. package/dist/esm-es5/{ShadowViewAddon-518e026d.js → ShadowViewAddon-c0600f22.js} +1 -1
  30. package/dist/esm-es5/copy-text-view-3129fb22.js +1 -0
  31. package/dist/esm-es5/copy-text-view-a319c261.js +1 -0
  32. package/dist/esm-es5/sqm-big-stat_43.entry.js +1 -1
  33. package/dist/esm-es5/sqm-coupon-code-view-af016712.js +1 -0
  34. package/dist/esm-es5/sqm-coupon-code.entry.js +1 -0
  35. package/dist/esm-es5/sqm-pagination_3.entry.js +1 -1
  36. package/dist/esm-es5/sqm-referral-code.entry.js +1 -0
  37. package/dist/esm-es5/sqm-reward-exchange-list.entry.js +1 -0
  38. package/dist/esm-es5/sqm-share-code.entry.js +1 -0
  39. package/dist/esm-es5/sqm-share-link.entry.js +1 -0
  40. package/dist/esm-es5/sqm-stencilbook.entry.js +1 -1
  41. package/dist/mint-components/RewardExchangeListData-11c043e3.js +1122 -0
  42. package/dist/mint-components/RewardExchangeListData-546ffbb9.system.js +1 -0
  43. package/dist/mint-components/copy-text-view-3129fb22.js +119 -0
  44. package/dist/mint-components/copy-text-view-33cac657.system.js +1 -0
  45. package/dist/mint-components/mint-components.esm.js +1 -1
  46. package/dist/mint-components/{p-5cbcff66.entry.js → p-1276830a.entry.js} +1 -1
  47. package/dist/mint-components/p-1de49f76.js +1 -0
  48. package/dist/mint-components/{p-761a02d5.js → p-6b904749.js} +1 -1
  49. package/dist/mint-components/p-a89baf7b.system.js +1 -1
  50. package/dist/mint-components/{p-8432d8c2.system.entry.js → p-aa77d858.system.entry.js} +1 -1
  51. package/dist/mint-components/{p-b8ddc820.system.js → p-bdc86ee3.system.js} +1 -1
  52. package/dist/mint-components/{p-b5fe3d2c.system.entry.js → p-be770d69.system.entry.js} +1 -1
  53. package/dist/mint-components/{p-5aeb80dc.entry.js → p-e34b460e.entry.js} +1 -1
  54. package/dist/mint-components/{p-db14cf82.system.entry.js → p-ed69dc98.system.entry.js} +1 -1
  55. package/dist/mint-components/p-f4f57363.system.js +1 -0
  56. package/dist/mint-components/{p-53eaaebf.entry.js → p-f9f67437.entry.js} +1 -1
  57. package/dist/mint-components/sqm-coupon-code-view-40fd8d8b.system.js +1 -0
  58. package/dist/mint-components/sqm-coupon-code-view-af016712.js +33 -0
  59. package/dist/mint-components/sqm-coupon-code.entry.js +281 -0
  60. package/dist/mint-components/sqm-coupon-code.system.entry.js +1 -0
  61. package/dist/mint-components/sqm-referral-code.entry.js +173 -0
  62. package/dist/mint-components/sqm-referral-code.system.entry.js +1 -0
  63. package/dist/mint-components/sqm-reward-exchange-list.entry.js +1014 -0
  64. package/dist/mint-components/sqm-reward-exchange-list.system.entry.js +1 -0
  65. package/dist/mint-components/sqm-share-code.entry.js +143 -0
  66. package/dist/mint-components/sqm-share-code.system.entry.js +1 -0
  67. package/dist/mint-components/sqm-share-link.entry.js +98 -0
  68. package/dist/mint-components/sqm-share-link.system.entry.js +1 -0
  69. package/dist/mint-components/sqm-stencilbook.entry.js +20330 -0
  70. package/dist/mint-components/sqm-stencilbook.system.entry.js +1 -0
  71. package/docs/docs.docx +0 -0
  72. package/package.json +1 -1
  73. package/dist/esm-es5/copy-text-view-b219d166.js +0 -1
  74. package/dist/mint-components/p-25e70b59.js +0 -1
  75. package/dist/mint-components/p-a4bbb947.system.js +0 -1
@@ -0,0 +1 @@
1
+ System.register(["./index-bfed5e90.system.js","./JSS-840a8fea.system.js","./mixins-8c4521b7.system.js","./copy-text-view-33cac657.system.js"],(function(e){"use strict";var t,s,r,n;return{setters:[function(e){t=e.h},function(e){s=e.c},function(e){r=e.H},function(e){n=e.C}],execute:function(){e("C",o);function o(e){var o=!e.loading&&e.error;var a={HostBlock:r,couponCodeLabel:{margin:"var(--sl-spacing-x-small) 0",color:e.textColor||"var(--sqm-text-subdued)",fontSize:"var(--sl-font-size-small)"}};var i="\n :host{\n display: block; \n width: 100%;\n }\n";var c=s(a);var l=c.toString();return t("div",null,t("style",{type:"text/css"},l,i),t("p",{class:c.classes.couponCodeLabel,style:{textAlign:e.textAlign}},e.couponCodeLabel),o?t("sqm-form-message",{type:e.errorType,exportparts:"erroralert-icon"},t("div",{part:"erroralert-text"},e.errorText)):t(n,Object.assign({},e)))}}}}));
@@ -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 };
@@ -0,0 +1 @@
1
+ var __makeTemplateObject=this&&this.__makeTemplateObject||function(e,t){if(Object.defineProperty){Object.defineProperty(e,"raw",{value:t})}else{e.raw=t}return e};var __assign=this&&this.__assign||function(){__assign=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++){t=arguments[n];for(var o in t)if(Object.prototype.hasOwnProperty.call(t,o))e[o]=t[o]}return e};return __assign.apply(this,arguments)};System.register(["./index-bfed5e90.system.js","./dom-context-hooks.module-7cdc0e68.system.js","./index.module-3ae23e6a.system.js","./jss-preset-default.esm-62a04d6d.system.js","./JSS-840a8fea.system.js","./mixins-8c4521b7.system.js","./utils-e473b250.system.js","./cjs-f0ef8d23.system.js","./copy-text-view-33cac657.system.js","./sqm-coupon-code-view-40fd8d8b.system.js"],(function(e){"use strict";var t,n,r,o,a,i,s,u,d,l,c,p,f,v;return{setters:[function(e){t=e.r;n=e.h},function(e){r=e.i;o=e.o},function(e){a=e.d;i=e.J;s=e.H;u=e.B;d=e.$;l=e.w;c=e.i},function(){},function(){},function(){},function(e){p=e.g},function(e){f=e.c},function(){},function(e){v=e.C}],execute:function(){var h=a.gql(__makeTemplateObject(["\n query fuelTankRewardsQuery($programId: ID!) {\n user: viewer {\n ... on User {\n instantAccessRewards(\n filter: { type_eq: FUELTANK, programId_eq: $programId }\n ) {\n data {\n fuelTankCode\n fuelTankType\n statuses\n dateGiven\n dateExpires\n dateRedeemed\n dateCancelled\n dateScheduledFor\n datePendingForUnhandledError\n }\n count\n totalCount\n }\n }\n }\n }\n"],["\n query fuelTankRewardsQuery($programId: ID!) {\n user: viewer {\n ... on User {\n instantAccessRewards(\n filter: { type_eq: FUELTANK, programId_eq: $programId }\n ) {\n data {\n fuelTankCode\n fuelTankType\n statuses\n dateGiven\n dateExpires\n dateRedeemed\n dateCancelled\n dateScheduledFor\n datePendingForUnhandledError\n }\n count\n totalCount\n }\n }\n }\n }\n"]));var m=a.gql(__makeTemplateObject(["\n mutation loadEvent($eventMeta: UserAnalyticsEvent!) {\n createUserAnalyticsEvent(eventMeta: $eventMeta)\n }\n"],["\n mutation loadEvent($eventMeta: UserAnalyticsEvent!) {\n createUserAnalyticsEvent(eventMeta: $eventMeta)\n }\n"]));function E(e){var t,n,o;var a=i();var c=s();var p=u();var f=d(m)[0];var v=l(h,{programId:c},!(a===null||a===void 0?void 0:a.jwt)),E=v.data,y=v.loading,g=v.refetch,T=v.errors;var b=function(e){if(!e||!e.statuses)return"ERROR";var t=e.statuses[e.statuses.length-1];if(t==="PENDING"&&e.dateScheduledFor===null)return"EMPTY_TANK";return t};var x=(o=(n=(t=E===null||E===void 0?void 0:E.user)===null||t===void 0?void 0:t.instantAccessRewards)===null||n===void 0?void 0:n.data)===null||o===void 0?void 0:o[0];var _=b(x);var C=_==="PENDING"&&x.dateScheduledFor?new Date(x.dateScheduledFor).toLocaleDateString("default",{day:"numeric",month:"long",year:"numeric"}):undefined;var A=(x===null||x===void 0?void 0:x.fuelTankCode)||"...";var R=r(false),k=R[0],j=R[1];function w(){navigator.clipboard.writeText(A);j(true);setTimeout((function(){return j(false)}),e.tooltiplifespan);f({eventMeta:{programId:c,id:a===null||a===void 0?void 0:a.id,accountId:a===null||a===void 0?void 0:a.accountId,type:"USER_REFERRAL_PROGRAM_ENGAGEMENT_EVENT",meta:{engagementMedium:p,shareMedium:"DIRECT"}}})}var P=function(t){switch(t){case"CANCELLED":return e.cancelledErrorText;case"EXPIRED":return e.expiredErrorText;case"EMPTY_TANK":return e.fullfillmentErrorText;case"PENDING":return e.pendingErrorText.replace("{unpendDate}",C);case"REDEEMED":return e.redeemedErrorText;case"AVAILABLE":return"";default:return e.genericErrorText}};var I=function(e){switch(e){case"EXPIRED":case"EMPTY_TANK":case"CANCELLED":case"ERROR":return"warning";case"PENDING":return"info";case"REDEEMED":return"success";default:return}};var D=P(_);var L=I(_);var N=_!=="AVAILABLE";return __assign(__assign({},e),{onClick:w,open:k,copyString:A,error:N,errorText:D,dateAvailable:C,loading:y,errorType:L,buttonType:e.buttonType||"primary"})}var y=e("sqm_coupon_code",function(){function e(e){t(this,e);this.tooltiptext="Copied to Clipboard";this.tooltiplifespan=1e3;this.textAlign="left";this.copyButtonLabel="Copy Coupon";this.buttonStyle="icon";this.couponCodeLabel="Your coupon code:";this.cancelledErrorText="This code has been cancelled. Please reach out to the Support team for help resolving this issue.";this.redeemedErrorText="Looks like you’ve already redeemed this code.";this.expiredErrorText="Looks like this code has expired. Please reach out to the Support team for help resolving this issue.";this.fullfillmentErrorText="We couldn't fetch your code. Please try again later or reach out to the Support team for help resolving this issue.";this.pendingErrorText="Your code will be available on {unpendDate}. Mark your calendar and come back then to redeem your reward!";this.genericErrorText="We couldn't fetch your code. Please try again later or reach out to the Support team for help resolving this issue.";this.couponCodePlaceholder="...";this.buttonType="primary";o(this)}e.prototype.disconnectedCallback=function(){};e.prototype.render=function(){var e=p(this);var t=c()?g(e):E(e);return n(v,Object.assign({},t))};return e}());function g(e){var t=r(false),n=t[0],o=t[1];var a="THANKSJANE125uv125";return f({copyString:a,tooltiptext:e.tooltiptext,textAlign:e.textAlign,buttonStyle:e.buttonStyle,copyButtonLabel:e.copyButtonLabel,error:false,couponCodePlaceholder:e.couponCodePlaceholder,couponCodeLabel:e.couponCodeLabel,borderColor:e.borderColor,backgroundColor:e.backgroundColor,textColor:e.textColor,borderRadius:e.borderRadius,buttonType:e.buttonType,open:n,onClick:function(){navigator.clipboard.writeText(a);o(true);setTimeout((function(){return o(false)}),e.tooltiplifespan)}},e.demoData||{},{arrayMerge:function(e,t){return t}})}}}}));
@@ -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 };
@@ -0,0 +1 @@
1
+ var __makeTemplateObject=this&&this.__makeTemplateObject||function(e,t){if(Object.defineProperty){Object.defineProperty(e,"raw",{value:t})}else{e.raw=t}return e};var __assign=this&&this.__assign||function(){__assign=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++){t=arguments[n];for(var o in t)if(Object.prototype.hasOwnProperty.call(t,o))e[o]=t[o]}return e};return __assign.apply(this,arguments)};var __awaiter=this&&this.__awaiter||function(e,t,n,r){function o(e){return e instanceof n?e:new n((function(t){t(e)}))}return new(n||(n=Promise))((function(n,i){function a(e){try{l(r.next(e))}catch(e){i(e)}}function s(e){try{l(r["throw"](e))}catch(e){i(e)}}function l(e){e.done?n(e.value):o(e.value).then(a,s)}l((r=r.apply(e,t||[])).next())}))};var __generator=this&&this.__generator||function(e,t){var n={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},r,o,i,a;return a={next:s(0),throw:s(1),return:s(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function s(e){return function(t){return l([e,t])}}function l(a){if(r)throw new TypeError("Generator is already executing.");while(n)try{if(r=1,o&&(i=a[0]&2?o["return"]:a[0]?o["throw"]||((i=o["return"])&&i.call(o),0):o.next)&&!(i=i.call(o,a[1])).done)return i;if(o=0,i)a=[a[0]&2,i.value];switch(a[0]){case 0:case 1:i=a;break;case 4:n.label++;return{value:a[1],done:false};case 5:n.label++;o=a[1];a=[0];continue;case 7:a=n.ops.pop();n.trys.pop();continue;default:if(!(i=n.trys,i=i.length>0&&i[i.length-1])&&(a[0]===6||a[0]===2)){n=0;continue}if(a[0]===3&&(!i||a[1]>i[0]&&a[1]<i[3])){n.label=a[1];break}if(a[0]===6&&n.label<i[1]){n.label=i[1];i=a;break}if(i&&n.label<i[2]){n.label=i[2];n.ops.push(a);break}if(i[2])n.ops.pop();n.trys.pop();continue}a=t.call(e,n)}catch(e){a=[6,e];o=0}finally{r=i=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:true}}};System.register(["./index-bfed5e90.system.js","./dom-context-hooks.module-7cdc0e68.system.js","./index.module-3ae23e6a.system.js","./jss-preset-default.esm-62a04d6d.system.js","./JSS-840a8fea.system.js","./mixins-8c4521b7.system.js","./utils-e473b250.system.js","./cjs-f0ef8d23.system.js","./useReferralCodes-c5a6014c.system.js","./copy-text-view-33cac657.system.js"],(function(e){"use strict";var t,n,r,o,i,a,s,l,u,c,f,d,p,v,y,h,b;return{setters:[function(e){t=e.r;n=e.h},function(e){r=e.i;o=e.o},function(e){i=e.d;a=e.H;s=e.J;l=e.B;u=e.F;c=e.w;f=e.$;d=e.i},function(){},function(){},function(){},function(e){p=e.g},function(e){v=e.c},function(e){y=e.R;h=e.S},function(e){b=e.C}],execute:function(){var m=i.gql(__makeTemplateObject(["\n query getReferralCode($programId: ID) {\n user: viewer {\n ... on User {\n referralCode(programId: $programId)\n }\n }\n }\n"],["\n query getReferralCode($programId: ID) {\n user: viewer {\n ... on User {\n referralCode(programId: $programId)\n }\n }\n }\n"]));var g=i.gql(__makeTemplateObject(["\n mutation loadEvent($eventMeta: UserAnalyticsEvent!) {\n createUserAnalyticsEvent(eventMeta: $eventMeta)\n }\n"],["\n mutation loadEvent($eventMeta: UserAnalyticsEvent!) {\n createUserAnalyticsEvent(eventMeta: $eventMeta)\n }\n"]));function _(e){var t,n;var o=e.programId,i=o===void 0?a():o;var d=s();var p=l();var v=u(y);var b=c(m,{programId:i},!(d===null||d===void 0?void 0:d.jwt)||(v===null||v===void 0?void 0:v.referralCode)!==undefined).data;var _=f(g)[0];var w=f(h)[0];var x=(n=(v===null||v===void 0?void 0:v.referralCode)||((t=b===null||b===void 0?void 0:b.user)===null||t===void 0?void 0:t.referralCode))!==null&&n!==void 0?n:"...";var C=r(false),T=C[0],j=C[1];function E(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){switch(t.label){case 0:if(!v)return[3,2];return[4,w({referralCode:v.referralCode})];case 1:t.sent();v.refresh();t.label=2;case 2:navigator.clipboard.writeText(x);j(true);setTimeout((function(){return j(false)}),e.tooltiplifespan);_({eventMeta:{programId:i,id:d===null||d===void 0?void 0:d.id,accountId:d===null||d===void 0?void 0:d.accountId,type:"USER_REFERRAL_PROGRAM_ENGAGEMENT_EVENT",meta:{engagementMedium:p,shareMedium:"DIRECT"}}});return[2]}}))}))}return __assign(__assign({},e),{onClick:E,open:T,copyString:x,isCopied:v===null||v===void 0?void 0:v.isCopied,showNotificationText:e.showNotificationText&&!!(v===null||v===void 0?void 0:v.singleUse)})}var w=e("sqm_referral_code",function(){function e(e){t(this,e);this.tooltiptext="Copied to Clipboard";this.showNotificationText=false;this.notificationText="You've copied this code before";this.tooltiplifespan=1e3;this.textAlign="left";this.copyButtonLabel="Copy Code";this.buttonStyle="icon";this.buttonType="primary";o(this)}e.prototype.disconnectedCallback=function(){};e.prototype.render=function(){var e=p(this);var t=d()?x(e):_(e);return n(b,Object.assign({},t))};return e}());function x(e){var t=r(false),n=t[0],o=t[1];var i="REFERRALCODE001";return v({copyString:i,tooltiptext:e.tooltiptext,textAlign:e.textAlign,copyButtonLabel:e.copyButtonLabel,buttonStyle:e.buttonStyle,notificationText:e.notificationText,showNotificationText:e.showNotificationText,isCopied:e.showNotificationText,borderColor:e.borderColor,backgroundColor:e.backgroundColor,textColor:e.textColor,borderRadius:e.borderRadius,buttonType:e.buttonType,isUsed:false,rewardStatus:"AVAILABLE",open:n,onClick:function(){navigator.clipboard.writeText(i);o(true);setTimeout((function(){return o(false)}),e.tooltiplifespan)}},e.demoData||{},{arrayMerge:function(e,t){return t}})}}}}));