@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.
- package/dist/cjs/RewardExchangeListData-a787ce54.js +1144 -0
- package/dist/cjs/{ShadowViewAddon-74752e56.js → ShadowViewAddon-f1bd9b26.js} +1 -1
- package/dist/cjs/{copy-text-view-c13907f9.js → copy-text-view-44dfefc7.js} +5 -7
- 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 +3 -3
- package/dist/collection/components/sqm-share-link/ShareLink.stories.js +1 -1
- package/dist/collection/components/views/copy-text-view.js +5 -7
- package/dist/esm/RewardExchangeListData-11c043e3.js +1122 -0
- package/dist/esm/{ShadowViewAddon-ee0c8c4b.js → ShadowViewAddon-c0600f22.js} +1 -1
- package/dist/esm/copy-text-view-3129fb22.js +119 -0
- package/dist/esm/{copy-text-view-61bd1ac1.js → copy-text-view-a319c261.js} +5 -7
- 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 +3 -3
- package/dist/esm-es5/RewardExchangeListData-11c043e3.js +1 -0
- package/dist/esm-es5/{ShadowViewAddon-ee0c8c4b.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-2bf5998b.entry.js → p-1276830a.entry.js} +1 -1
- package/dist/mint-components/p-1de49f76.js +1 -0
- package/dist/mint-components/{p-94952e33.js → p-6b904749.js} +1 -1
- package/dist/mint-components/p-a89baf7b.system.js +1 -1
- package/dist/mint-components/{p-ba0c9f88.system.entry.js → p-aa77d858.system.entry.js} +1 -1
- package/dist/mint-components/{p-45736fa8.system.js → p-bdc86ee3.system.js} +1 -1
- package/dist/mint-components/{p-680894bd.system.entry.js → p-be770d69.system.entry.js} +1 -1
- package/dist/mint-components/{p-0bac31a6.entry.js → p-e34b460e.entry.js} +1 -1
- package/dist/mint-components/{p-4e3ec053.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-dba96a48.entry.js → p-f9f67437.entry.js} +2 -2
- 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-61bd1ac1.js +0 -1
- package/dist/mint-components/p-c5ca5b5f.js +0 -1
- package/dist/mint-components/p-efeab858.system.js +0 -1
|
@@ -0,0 +1,1014 @@
|
|
|
1
|
+
import { r as registerInstance, h as h$1, i as Host } from './index-bfb7f924.js';
|
|
2
|
+
import './global-c7169457.js';
|
|
3
|
+
import { u as useReducer, i as useState, j as useEffect, k as useRef, o as h } from './dom-context-hooks.module-01c1b885.js';
|
|
4
|
+
import { d as dist, J, $ as $e, w as wn, o as Qe, i as isDemo } from './index.module-83586215.js';
|
|
5
|
+
import './GoogleFonts-e3a7f82a.js';
|
|
6
|
+
import './jss-preset-default.esm-c36417f8.js';
|
|
7
|
+
import './JSS-8c381d8b.js';
|
|
8
|
+
import './mixins-acc245cc.js';
|
|
9
|
+
import { g as getProps } from './utils-93e14db3.js';
|
|
10
|
+
import { c as cjs } from './cjs-e829b75b.js';
|
|
11
|
+
import './copy-text-view-3129fb22.js';
|
|
12
|
+
import { p as demoRewardExchange, R as RewardExchangeView } from './RewardExchangeListData-11c043e3.js';
|
|
13
|
+
import { p as parseStates } from './parseStates-ed75e224.js';
|
|
14
|
+
|
|
15
|
+
// canvas-confetti v1.4.0 built on 2021-03-10T12:32:33.488Z
|
|
16
|
+
var module = {};
|
|
17
|
+
|
|
18
|
+
// source content
|
|
19
|
+
(function main(global, module, isWorker, workerSize) {
|
|
20
|
+
var canUseWorker = !!(
|
|
21
|
+
global.Worker &&
|
|
22
|
+
global.Blob &&
|
|
23
|
+
global.Promise &&
|
|
24
|
+
global.OffscreenCanvas &&
|
|
25
|
+
global.OffscreenCanvasRenderingContext2D &&
|
|
26
|
+
global.HTMLCanvasElement &&
|
|
27
|
+
global.HTMLCanvasElement.prototype.transferControlToOffscreen &&
|
|
28
|
+
global.URL &&
|
|
29
|
+
global.URL.createObjectURL);
|
|
30
|
+
|
|
31
|
+
function noop() {}
|
|
32
|
+
|
|
33
|
+
// create a promise if it exists, otherwise, just
|
|
34
|
+
// call the function directly
|
|
35
|
+
function promise(func) {
|
|
36
|
+
var ModulePromise = module.exports.Promise;
|
|
37
|
+
var Prom = ModulePromise !== void 0 ? ModulePromise : global.Promise;
|
|
38
|
+
|
|
39
|
+
if (typeof Prom === 'function') {
|
|
40
|
+
return new Prom(func);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
func(noop, noop);
|
|
44
|
+
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
var raf = (function () {
|
|
49
|
+
var TIME = Math.floor(1000 / 60);
|
|
50
|
+
var frame, cancel;
|
|
51
|
+
var frames = {};
|
|
52
|
+
var lastFrameTime = 0;
|
|
53
|
+
|
|
54
|
+
if (typeof requestAnimationFrame === 'function' && typeof cancelAnimationFrame === 'function') {
|
|
55
|
+
frame = function (cb) {
|
|
56
|
+
var id = Math.random();
|
|
57
|
+
|
|
58
|
+
frames[id] = requestAnimationFrame(function onFrame(time) {
|
|
59
|
+
if (lastFrameTime === time || lastFrameTime + TIME - 1 < time) {
|
|
60
|
+
lastFrameTime = time;
|
|
61
|
+
delete frames[id];
|
|
62
|
+
|
|
63
|
+
cb();
|
|
64
|
+
} else {
|
|
65
|
+
frames[id] = requestAnimationFrame(onFrame);
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
return id;
|
|
70
|
+
};
|
|
71
|
+
cancel = function (id) {
|
|
72
|
+
if (frames[id]) {
|
|
73
|
+
cancelAnimationFrame(frames[id]);
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
} else {
|
|
77
|
+
frame = function (cb) {
|
|
78
|
+
return setTimeout(cb, TIME);
|
|
79
|
+
};
|
|
80
|
+
cancel = function (timer) {
|
|
81
|
+
return clearTimeout(timer);
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return { frame: frame, cancel: cancel };
|
|
86
|
+
}());
|
|
87
|
+
|
|
88
|
+
var getWorker = (function () {
|
|
89
|
+
var worker;
|
|
90
|
+
var prom;
|
|
91
|
+
var resolves = {};
|
|
92
|
+
|
|
93
|
+
function decorate(worker) {
|
|
94
|
+
function execute(options, callback) {
|
|
95
|
+
worker.postMessage({ options: options || {}, callback: callback });
|
|
96
|
+
}
|
|
97
|
+
worker.init = function initWorker(canvas) {
|
|
98
|
+
var offscreen = canvas.transferControlToOffscreen();
|
|
99
|
+
worker.postMessage({ canvas: offscreen }, [offscreen]);
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
worker.fire = function fireWorker(options, size, done) {
|
|
103
|
+
if (prom) {
|
|
104
|
+
execute(options, null);
|
|
105
|
+
return prom;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
var id = Math.random().toString(36).slice(2);
|
|
109
|
+
|
|
110
|
+
prom = promise(function (resolve) {
|
|
111
|
+
function workerDone(msg) {
|
|
112
|
+
if (msg.data.callback !== id) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
delete resolves[id];
|
|
117
|
+
worker.removeEventListener('message', workerDone);
|
|
118
|
+
|
|
119
|
+
prom = null;
|
|
120
|
+
done();
|
|
121
|
+
resolve();
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
worker.addEventListener('message', workerDone);
|
|
125
|
+
execute(options, id);
|
|
126
|
+
|
|
127
|
+
resolves[id] = workerDone.bind(null, { data: { callback: id }});
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
return prom;
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
worker.reset = function resetWorker() {
|
|
134
|
+
worker.postMessage({ reset: true });
|
|
135
|
+
|
|
136
|
+
for (var id in resolves) {
|
|
137
|
+
resolves[id]();
|
|
138
|
+
delete resolves[id];
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
return function () {
|
|
144
|
+
if (worker) {
|
|
145
|
+
return worker;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
if (!isWorker && canUseWorker) {
|
|
149
|
+
var code = [
|
|
150
|
+
'var CONFETTI, SIZE = {}, module = {};',
|
|
151
|
+
'(' + main.toString() + ')(this, module, true, SIZE);',
|
|
152
|
+
'onmessage = function(msg) {',
|
|
153
|
+
' if (msg.data.options) {',
|
|
154
|
+
' CONFETTI(msg.data.options).then(function () {',
|
|
155
|
+
' if (msg.data.callback) {',
|
|
156
|
+
' postMessage({ callback: msg.data.callback });',
|
|
157
|
+
' }',
|
|
158
|
+
' });',
|
|
159
|
+
' } else if (msg.data.reset) {',
|
|
160
|
+
' CONFETTI.reset();',
|
|
161
|
+
' } else if (msg.data.resize) {',
|
|
162
|
+
' SIZE.width = msg.data.resize.width;',
|
|
163
|
+
' SIZE.height = msg.data.resize.height;',
|
|
164
|
+
' } else if (msg.data.canvas) {',
|
|
165
|
+
' SIZE.width = msg.data.canvas.width;',
|
|
166
|
+
' SIZE.height = msg.data.canvas.height;',
|
|
167
|
+
' CONFETTI = module.exports.create(msg.data.canvas);',
|
|
168
|
+
' }',
|
|
169
|
+
'}',
|
|
170
|
+
].join('\n');
|
|
171
|
+
try {
|
|
172
|
+
worker = new Worker(URL.createObjectURL(new Blob([code])));
|
|
173
|
+
} catch (e) {
|
|
174
|
+
// eslint-disable-next-line no-console
|
|
175
|
+
typeof console !== undefined && typeof console.warn === 'function' ? console.warn('🎊 Could not load worker', e) : null;
|
|
176
|
+
|
|
177
|
+
return null;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
decorate(worker);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
return worker;
|
|
184
|
+
};
|
|
185
|
+
})();
|
|
186
|
+
|
|
187
|
+
var defaults = {
|
|
188
|
+
particleCount: 50,
|
|
189
|
+
angle: 90,
|
|
190
|
+
spread: 45,
|
|
191
|
+
startVelocity: 45,
|
|
192
|
+
decay: 0.9,
|
|
193
|
+
gravity: 1,
|
|
194
|
+
drift: 0,
|
|
195
|
+
ticks: 200,
|
|
196
|
+
x: 0.5,
|
|
197
|
+
y: 0.5,
|
|
198
|
+
shapes: ['square', 'circle'],
|
|
199
|
+
zIndex: 100,
|
|
200
|
+
colors: [
|
|
201
|
+
'#26ccff',
|
|
202
|
+
'#a25afd',
|
|
203
|
+
'#ff5e7e',
|
|
204
|
+
'#88ff5a',
|
|
205
|
+
'#fcff42',
|
|
206
|
+
'#ffa62d',
|
|
207
|
+
'#ff36ff'
|
|
208
|
+
],
|
|
209
|
+
// probably should be true, but back-compat
|
|
210
|
+
disableForReducedMotion: false,
|
|
211
|
+
scalar: 1
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
function convert(val, transform) {
|
|
215
|
+
return transform ? transform(val) : val;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
function isOk(val) {
|
|
219
|
+
return !(val === null || val === undefined);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
function prop(options, name, transform) {
|
|
223
|
+
return convert(
|
|
224
|
+
options && isOk(options[name]) ? options[name] : defaults[name],
|
|
225
|
+
transform
|
|
226
|
+
);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
function onlyPositiveInt(number){
|
|
230
|
+
return number < 0 ? 0 : Math.floor(number);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
function randomInt(min, max) {
|
|
234
|
+
// [min, max)
|
|
235
|
+
return Math.floor(Math.random() * (max - min)) + min;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
function toDecimal(str) {
|
|
239
|
+
return parseInt(str, 16);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
function colorsToRgb(colors) {
|
|
243
|
+
return colors.map(hexToRgb);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
function hexToRgb(str) {
|
|
247
|
+
var val = String(str).replace(/[^0-9a-f]/gi, '');
|
|
248
|
+
|
|
249
|
+
if (val.length < 6) {
|
|
250
|
+
val = val[0]+val[0]+val[1]+val[1]+val[2]+val[2];
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
return {
|
|
254
|
+
r: toDecimal(val.substring(0,2)),
|
|
255
|
+
g: toDecimal(val.substring(2,4)),
|
|
256
|
+
b: toDecimal(val.substring(4,6))
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
function getOrigin(options) {
|
|
261
|
+
var origin = prop(options, 'origin', Object);
|
|
262
|
+
origin.x = prop(origin, 'x', Number);
|
|
263
|
+
origin.y = prop(origin, 'y', Number);
|
|
264
|
+
|
|
265
|
+
return origin;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
function setCanvasWindowSize(canvas) {
|
|
269
|
+
canvas.width = document.documentElement.clientWidth;
|
|
270
|
+
canvas.height = document.documentElement.clientHeight;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
function setCanvasRectSize(canvas) {
|
|
274
|
+
var rect = canvas.getBoundingClientRect();
|
|
275
|
+
canvas.width = rect.width;
|
|
276
|
+
canvas.height = rect.height;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
function getCanvas(zIndex) {
|
|
280
|
+
var canvas = document.createElement('canvas');
|
|
281
|
+
|
|
282
|
+
canvas.style.position = 'fixed';
|
|
283
|
+
canvas.style.top = '0px';
|
|
284
|
+
canvas.style.left = '0px';
|
|
285
|
+
canvas.style.pointerEvents = 'none';
|
|
286
|
+
canvas.style.zIndex = zIndex;
|
|
287
|
+
|
|
288
|
+
return canvas;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
function ellipse(context, x, y, radiusX, radiusY, rotation, startAngle, endAngle, antiClockwise) {
|
|
292
|
+
context.save();
|
|
293
|
+
context.translate(x, y);
|
|
294
|
+
context.rotate(rotation);
|
|
295
|
+
context.scale(radiusX, radiusY);
|
|
296
|
+
context.arc(0, 0, 1, startAngle, endAngle, antiClockwise);
|
|
297
|
+
context.restore();
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
function randomPhysics(opts) {
|
|
301
|
+
var radAngle = opts.angle * (Math.PI / 180);
|
|
302
|
+
var radSpread = opts.spread * (Math.PI / 180);
|
|
303
|
+
|
|
304
|
+
return {
|
|
305
|
+
x: opts.x,
|
|
306
|
+
y: opts.y,
|
|
307
|
+
wobble: Math.random() * 10,
|
|
308
|
+
velocity: (opts.startVelocity * 0.5) + (Math.random() * opts.startVelocity),
|
|
309
|
+
angle2D: -radAngle + ((0.5 * radSpread) - (Math.random() * radSpread)),
|
|
310
|
+
tiltAngle: Math.random() * Math.PI,
|
|
311
|
+
color: opts.color,
|
|
312
|
+
shape: opts.shape,
|
|
313
|
+
tick: 0,
|
|
314
|
+
totalTicks: opts.ticks,
|
|
315
|
+
decay: opts.decay,
|
|
316
|
+
drift: opts.drift,
|
|
317
|
+
random: Math.random() + 5,
|
|
318
|
+
tiltSin: 0,
|
|
319
|
+
tiltCos: 0,
|
|
320
|
+
wobbleX: 0,
|
|
321
|
+
wobbleY: 0,
|
|
322
|
+
gravity: opts.gravity * 3,
|
|
323
|
+
ovalScalar: 0.6,
|
|
324
|
+
scalar: opts.scalar
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
function updateFetti(context, fetti) {
|
|
329
|
+
fetti.x += Math.cos(fetti.angle2D) * fetti.velocity + fetti.drift;
|
|
330
|
+
fetti.y += Math.sin(fetti.angle2D) * fetti.velocity + fetti.gravity;
|
|
331
|
+
fetti.wobble += 0.1;
|
|
332
|
+
fetti.velocity *= fetti.decay;
|
|
333
|
+
fetti.tiltAngle += 0.1;
|
|
334
|
+
fetti.tiltSin = Math.sin(fetti.tiltAngle);
|
|
335
|
+
fetti.tiltCos = Math.cos(fetti.tiltAngle);
|
|
336
|
+
fetti.random = Math.random() + 5;
|
|
337
|
+
fetti.wobbleX = fetti.x + ((10 * fetti.scalar) * Math.cos(fetti.wobble));
|
|
338
|
+
fetti.wobbleY = fetti.y + ((10 * fetti.scalar) * Math.sin(fetti.wobble));
|
|
339
|
+
|
|
340
|
+
var progress = (fetti.tick++) / fetti.totalTicks;
|
|
341
|
+
|
|
342
|
+
var x1 = fetti.x + (fetti.random * fetti.tiltCos);
|
|
343
|
+
var y1 = fetti.y + (fetti.random * fetti.tiltSin);
|
|
344
|
+
var x2 = fetti.wobbleX + (fetti.random * fetti.tiltCos);
|
|
345
|
+
var y2 = fetti.wobbleY + (fetti.random * fetti.tiltSin);
|
|
346
|
+
|
|
347
|
+
context.fillStyle = 'rgba(' + fetti.color.r + ', ' + fetti.color.g + ', ' + fetti.color.b + ', ' + (1 - progress) + ')';
|
|
348
|
+
context.beginPath();
|
|
349
|
+
|
|
350
|
+
if (fetti.shape === 'circle') {
|
|
351
|
+
context.ellipse ?
|
|
352
|
+
context.ellipse(fetti.x, fetti.y, Math.abs(x2 - x1) * fetti.ovalScalar, Math.abs(y2 - y1) * fetti.ovalScalar, Math.PI / 10 * fetti.wobble, 0, 2 * Math.PI) :
|
|
353
|
+
ellipse(context, fetti.x, fetti.y, Math.abs(x2 - x1) * fetti.ovalScalar, Math.abs(y2 - y1) * fetti.ovalScalar, Math.PI / 10 * fetti.wobble, 0, 2 * Math.PI);
|
|
354
|
+
} else {
|
|
355
|
+
context.moveTo(Math.floor(fetti.x), Math.floor(fetti.y));
|
|
356
|
+
context.lineTo(Math.floor(fetti.wobbleX), Math.floor(y1));
|
|
357
|
+
context.lineTo(Math.floor(x2), Math.floor(y2));
|
|
358
|
+
context.lineTo(Math.floor(x1), Math.floor(fetti.wobbleY));
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
context.closePath();
|
|
362
|
+
context.fill();
|
|
363
|
+
|
|
364
|
+
return fetti.tick < fetti.totalTicks;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
function animate(canvas, fettis, resizer, size, done) {
|
|
368
|
+
var animatingFettis = fettis.slice();
|
|
369
|
+
var context = canvas.getContext('2d');
|
|
370
|
+
var animationFrame;
|
|
371
|
+
var destroy;
|
|
372
|
+
|
|
373
|
+
var prom = promise(function (resolve) {
|
|
374
|
+
function onDone() {
|
|
375
|
+
animationFrame = destroy = null;
|
|
376
|
+
|
|
377
|
+
context.clearRect(0, 0, size.width, size.height);
|
|
378
|
+
|
|
379
|
+
done();
|
|
380
|
+
resolve();
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
function update() {
|
|
384
|
+
if (isWorker && !(size.width === workerSize.width && size.height === workerSize.height)) {
|
|
385
|
+
size.width = canvas.width = workerSize.width;
|
|
386
|
+
size.height = canvas.height = workerSize.height;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
if (!size.width && !size.height) {
|
|
390
|
+
resizer(canvas);
|
|
391
|
+
size.width = canvas.width;
|
|
392
|
+
size.height = canvas.height;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
context.clearRect(0, 0, size.width, size.height);
|
|
396
|
+
|
|
397
|
+
animatingFettis = animatingFettis.filter(function (fetti) {
|
|
398
|
+
return updateFetti(context, fetti);
|
|
399
|
+
});
|
|
400
|
+
|
|
401
|
+
if (animatingFettis.length) {
|
|
402
|
+
animationFrame = raf.frame(update);
|
|
403
|
+
} else {
|
|
404
|
+
onDone();
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
animationFrame = raf.frame(update);
|
|
409
|
+
destroy = onDone;
|
|
410
|
+
});
|
|
411
|
+
|
|
412
|
+
return {
|
|
413
|
+
addFettis: function (fettis) {
|
|
414
|
+
animatingFettis = animatingFettis.concat(fettis);
|
|
415
|
+
|
|
416
|
+
return prom;
|
|
417
|
+
},
|
|
418
|
+
canvas: canvas,
|
|
419
|
+
promise: prom,
|
|
420
|
+
reset: function () {
|
|
421
|
+
if (animationFrame) {
|
|
422
|
+
raf.cancel(animationFrame);
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
if (destroy) {
|
|
426
|
+
destroy();
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
};
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
function confettiCannon(canvas, globalOpts) {
|
|
433
|
+
var isLibCanvas = !canvas;
|
|
434
|
+
var allowResize = !!prop(globalOpts || {}, 'resize');
|
|
435
|
+
var globalDisableForReducedMotion = prop(globalOpts, 'disableForReducedMotion', Boolean);
|
|
436
|
+
var shouldUseWorker = canUseWorker && !!prop(globalOpts || {}, 'useWorker');
|
|
437
|
+
var worker = shouldUseWorker ? getWorker() : null;
|
|
438
|
+
var resizer = isLibCanvas ? setCanvasWindowSize : setCanvasRectSize;
|
|
439
|
+
var initialized = (canvas && worker) ? !!canvas.__confetti_initialized : false;
|
|
440
|
+
var preferLessMotion = typeof matchMedia === 'function' && matchMedia('(prefers-reduced-motion)').matches;
|
|
441
|
+
var animationObj;
|
|
442
|
+
|
|
443
|
+
function fireLocal(options, size, done) {
|
|
444
|
+
var particleCount = prop(options, 'particleCount', onlyPositiveInt);
|
|
445
|
+
var angle = prop(options, 'angle', Number);
|
|
446
|
+
var spread = prop(options, 'spread', Number);
|
|
447
|
+
var startVelocity = prop(options, 'startVelocity', Number);
|
|
448
|
+
var decay = prop(options, 'decay', Number);
|
|
449
|
+
var gravity = prop(options, 'gravity', Number);
|
|
450
|
+
var drift = prop(options, 'drift', Number);
|
|
451
|
+
var colors = prop(options, 'colors', colorsToRgb);
|
|
452
|
+
var ticks = prop(options, 'ticks', Number);
|
|
453
|
+
var shapes = prop(options, 'shapes');
|
|
454
|
+
var scalar = prop(options, 'scalar');
|
|
455
|
+
var origin = getOrigin(options);
|
|
456
|
+
|
|
457
|
+
var temp = particleCount;
|
|
458
|
+
var fettis = [];
|
|
459
|
+
|
|
460
|
+
var startX = canvas.width * origin.x;
|
|
461
|
+
var startY = canvas.height * origin.y;
|
|
462
|
+
|
|
463
|
+
while (temp--) {
|
|
464
|
+
fettis.push(
|
|
465
|
+
randomPhysics({
|
|
466
|
+
x: startX,
|
|
467
|
+
y: startY,
|
|
468
|
+
angle: angle,
|
|
469
|
+
spread: spread,
|
|
470
|
+
startVelocity: startVelocity,
|
|
471
|
+
color: colors[temp % colors.length],
|
|
472
|
+
shape: shapes[randomInt(0, shapes.length)],
|
|
473
|
+
ticks: ticks,
|
|
474
|
+
decay: decay,
|
|
475
|
+
gravity: gravity,
|
|
476
|
+
drift: drift,
|
|
477
|
+
scalar: scalar
|
|
478
|
+
})
|
|
479
|
+
);
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
// if we have a previous canvas already animating,
|
|
483
|
+
// add to it
|
|
484
|
+
if (animationObj) {
|
|
485
|
+
return animationObj.addFettis(fettis);
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
animationObj = animate(canvas, fettis, resizer, size , done);
|
|
489
|
+
|
|
490
|
+
return animationObj.promise;
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
function fire(options) {
|
|
494
|
+
var disableForReducedMotion = globalDisableForReducedMotion || prop(options, 'disableForReducedMotion', Boolean);
|
|
495
|
+
var zIndex = prop(options, 'zIndex', Number);
|
|
496
|
+
|
|
497
|
+
if (disableForReducedMotion && preferLessMotion) {
|
|
498
|
+
return promise(function (resolve) {
|
|
499
|
+
resolve();
|
|
500
|
+
});
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
if (isLibCanvas && animationObj) {
|
|
504
|
+
// use existing canvas from in-progress animation
|
|
505
|
+
canvas = animationObj.canvas;
|
|
506
|
+
} else if (isLibCanvas && !canvas) {
|
|
507
|
+
// create and initialize a new canvas
|
|
508
|
+
canvas = getCanvas(zIndex);
|
|
509
|
+
document.body.appendChild(canvas);
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
if (allowResize && !initialized) {
|
|
513
|
+
// initialize the size of a user-supplied canvas
|
|
514
|
+
resizer(canvas);
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
var size = {
|
|
518
|
+
width: canvas.width,
|
|
519
|
+
height: canvas.height
|
|
520
|
+
};
|
|
521
|
+
|
|
522
|
+
if (worker && !initialized) {
|
|
523
|
+
worker.init(canvas);
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
initialized = true;
|
|
527
|
+
|
|
528
|
+
if (worker) {
|
|
529
|
+
canvas.__confetti_initialized = true;
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
function onResize() {
|
|
533
|
+
if (worker) {
|
|
534
|
+
// TODO this really shouldn't be immediate, because it is expensive
|
|
535
|
+
var obj = {
|
|
536
|
+
getBoundingClientRect: function () {
|
|
537
|
+
if (!isLibCanvas) {
|
|
538
|
+
return canvas.getBoundingClientRect();
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
};
|
|
542
|
+
|
|
543
|
+
resizer(obj);
|
|
544
|
+
|
|
545
|
+
worker.postMessage({
|
|
546
|
+
resize: {
|
|
547
|
+
width: obj.width,
|
|
548
|
+
height: obj.height
|
|
549
|
+
}
|
|
550
|
+
});
|
|
551
|
+
return;
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
// don't actually query the size here, since this
|
|
555
|
+
// can execute frequently and rapidly
|
|
556
|
+
size.width = size.height = null;
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
function done() {
|
|
560
|
+
animationObj = null;
|
|
561
|
+
|
|
562
|
+
if (allowResize) {
|
|
563
|
+
global.removeEventListener('resize', onResize);
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
if (isLibCanvas && canvas) {
|
|
567
|
+
document.body.removeChild(canvas);
|
|
568
|
+
canvas = null;
|
|
569
|
+
initialized = false;
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
if (allowResize) {
|
|
574
|
+
global.addEventListener('resize', onResize, false);
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
if (worker) {
|
|
578
|
+
return worker.fire(options, size, done);
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
return fireLocal(options, size, done);
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
fire.reset = function () {
|
|
585
|
+
if (worker) {
|
|
586
|
+
worker.reset();
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
if (animationObj) {
|
|
590
|
+
animationObj.reset();
|
|
591
|
+
}
|
|
592
|
+
};
|
|
593
|
+
|
|
594
|
+
return fire;
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
module.exports = confettiCannon(null, { useWorker: true, resize: true });
|
|
598
|
+
module.exports.create = confettiCannon;
|
|
599
|
+
}((function () {
|
|
600
|
+
if (typeof window !== 'undefined') {
|
|
601
|
+
return window;
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
if (typeof self !== 'undefined') {
|
|
605
|
+
return self;
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
return this || {};
|
|
609
|
+
})(), module, false));
|
|
610
|
+
|
|
611
|
+
// end source content
|
|
612
|
+
|
|
613
|
+
const confetti = module.exports;
|
|
614
|
+
var create = module.exports.create;
|
|
615
|
+
|
|
616
|
+
const GET_EXCHANGE_LIST = dist.gql `
|
|
617
|
+
query getExchangeList {
|
|
618
|
+
viewer {
|
|
619
|
+
... on User {
|
|
620
|
+
visibleRewardExchangeItems(limit: 20, offset: 0) {
|
|
621
|
+
data {
|
|
622
|
+
key
|
|
623
|
+
name
|
|
624
|
+
description
|
|
625
|
+
imageUrl
|
|
626
|
+
available
|
|
627
|
+
unavailableReasonCode
|
|
628
|
+
ruleType
|
|
629
|
+
sourceUnit
|
|
630
|
+
sourceValue
|
|
631
|
+
prettySourceValue
|
|
632
|
+
sourceMinValue
|
|
633
|
+
prettySourceMinValue
|
|
634
|
+
sourceMaxValue
|
|
635
|
+
prettySourceMaxValue
|
|
636
|
+
destinationMinValue
|
|
637
|
+
prettyDestinationMinValue
|
|
638
|
+
destinationMaxValue
|
|
639
|
+
prettyDestinationMaxValue
|
|
640
|
+
globalRewardKey
|
|
641
|
+
destinationUnit
|
|
642
|
+
steps {
|
|
643
|
+
sourceValue
|
|
644
|
+
prettySourceValue
|
|
645
|
+
destinationValue
|
|
646
|
+
prettyDestinationValue
|
|
647
|
+
available
|
|
648
|
+
globalRewardKey
|
|
649
|
+
unavailableReasonCode
|
|
650
|
+
rewardInput
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
totalCount
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
`;
|
|
659
|
+
const EXCHANGE = dist.gql `
|
|
660
|
+
mutation exchange($exchangeRewardInput: ExchangeRewardInput!) {
|
|
661
|
+
exchangeReward(exchangeRewardInput: $exchangeRewardInput) {
|
|
662
|
+
reward {
|
|
663
|
+
id
|
|
664
|
+
fuelTankCode
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
`;
|
|
669
|
+
function useRewardExchangeList(props) {
|
|
670
|
+
var _a, _b, _c, _d, _e;
|
|
671
|
+
const [exchangeState, setExchangeState] = useReducer((state, next) => ({
|
|
672
|
+
...state,
|
|
673
|
+
...next,
|
|
674
|
+
}), {
|
|
675
|
+
selectedItem: undefined,
|
|
676
|
+
selectedStep: undefined,
|
|
677
|
+
redeemStage: "chooseReward",
|
|
678
|
+
amount: 0,
|
|
679
|
+
exchangeError: false,
|
|
680
|
+
});
|
|
681
|
+
const [open, setOpen] = useState(false);
|
|
682
|
+
const { selectedItem, selectedStep, redeemStage, amount, exchangeError } = exchangeState;
|
|
683
|
+
const user = J();
|
|
684
|
+
const [exchange, { data: exchangeResponse, loading: exchangeLoading, errors },] = $e(EXCHANGE);
|
|
685
|
+
const { data, loading, refetch, errors: queryError, } = wn(GET_EXCHANGE_LIST, {}, !(user === null || user === void 0 ? void 0 : user.jwt));
|
|
686
|
+
useEffect(() => {
|
|
687
|
+
var _a, _b;
|
|
688
|
+
if ((_b = (_a = exchangeResponse === null || exchangeResponse === void 0 ? void 0 : exchangeResponse.exchangeReward) === null || _a === void 0 ? void 0 : _a.reward) === null || _b === void 0 ? void 0 : _b.id) {
|
|
689
|
+
setExchangeState({ redeemStage: "success", exchangeError: false });
|
|
690
|
+
}
|
|
691
|
+
if (!!errors) {
|
|
692
|
+
setExchangeState({ exchangeError: true });
|
|
693
|
+
}
|
|
694
|
+
}, [exchangeResponse, errors]);
|
|
695
|
+
const canvasRef = useRef();
|
|
696
|
+
useEffect(() => {
|
|
697
|
+
if (!canvasRef.current)
|
|
698
|
+
return;
|
|
699
|
+
const canvas = canvasRef.current;
|
|
700
|
+
canvas.confetti =
|
|
701
|
+
canvas.confetti || confetti.create(canvas, { resize: true });
|
|
702
|
+
canvas.confetti();
|
|
703
|
+
}, [canvasRef.current]);
|
|
704
|
+
const { refresh } = Qe();
|
|
705
|
+
async function exchangeReward() {
|
|
706
|
+
if (!selectedItem)
|
|
707
|
+
return;
|
|
708
|
+
let exchangeVariables = {
|
|
709
|
+
accountId: user === null || user === void 0 ? void 0 : user.accountId,
|
|
710
|
+
userId: user.id,
|
|
711
|
+
};
|
|
712
|
+
switch (selectedItem.ruleType) {
|
|
713
|
+
case "FIXED_GLOBAL_REWARD":
|
|
714
|
+
exchangeVariables = {
|
|
715
|
+
...exchangeVariables,
|
|
716
|
+
redeemCreditInput: {
|
|
717
|
+
amount: selectedItem.sourceValue,
|
|
718
|
+
unit: selectedItem.sourceUnit,
|
|
719
|
+
},
|
|
720
|
+
globalRewardKey: selectedItem.globalRewardKey,
|
|
721
|
+
};
|
|
722
|
+
break;
|
|
723
|
+
case "STEPPED_FIXED_GLOBAL_REWARD":
|
|
724
|
+
exchangeVariables = {
|
|
725
|
+
...exchangeVariables,
|
|
726
|
+
redeemCreditInput: {
|
|
727
|
+
amount: selectedStep.sourceValue,
|
|
728
|
+
unit: selectedItem.sourceUnit,
|
|
729
|
+
},
|
|
730
|
+
globalRewardKey: selectedStep.globalRewardKey,
|
|
731
|
+
};
|
|
732
|
+
break;
|
|
733
|
+
case "VARIABLE_GLOBAL_REWARD":
|
|
734
|
+
exchangeVariables = {
|
|
735
|
+
...exchangeVariables,
|
|
736
|
+
redeemCreditInput: {
|
|
737
|
+
amount: amount,
|
|
738
|
+
unit: selectedItem.sourceUnit,
|
|
739
|
+
},
|
|
740
|
+
globalRewardKey: selectedItem.globalRewardKey,
|
|
741
|
+
rewardInput: selectedStep.rewardInput,
|
|
742
|
+
};
|
|
743
|
+
break;
|
|
744
|
+
case "VARIABLE_CREDIT_REWARD":
|
|
745
|
+
exchangeVariables = {
|
|
746
|
+
...exchangeVariables,
|
|
747
|
+
redeemCreditInput: {
|
|
748
|
+
amount: amount,
|
|
749
|
+
unit: selectedItem.sourceUnit,
|
|
750
|
+
},
|
|
751
|
+
rewardInput: {
|
|
752
|
+
type: "CREDIT",
|
|
753
|
+
unit: selectedItem.destinationUnit,
|
|
754
|
+
assignedCredit: selectedStep.destinationValue,
|
|
755
|
+
},
|
|
756
|
+
};
|
|
757
|
+
break;
|
|
758
|
+
default:
|
|
759
|
+
exchangeVariables = {
|
|
760
|
+
...exchangeVariables,
|
|
761
|
+
...selectedStep.rewardInput,
|
|
762
|
+
};
|
|
763
|
+
}
|
|
764
|
+
await exchange({ exchangeRewardInput: exchangeVariables });
|
|
765
|
+
refresh();
|
|
766
|
+
}
|
|
767
|
+
const resetState = (refresh) => {
|
|
768
|
+
refresh && refetch();
|
|
769
|
+
setExchangeState({
|
|
770
|
+
amount: 0,
|
|
771
|
+
selectedStep: undefined,
|
|
772
|
+
selectedItem: undefined,
|
|
773
|
+
exchangeError: false,
|
|
774
|
+
redeemStage: "chooseReward",
|
|
775
|
+
});
|
|
776
|
+
};
|
|
777
|
+
function setStage(stage) {
|
|
778
|
+
setExchangeState({ redeemStage: stage });
|
|
779
|
+
}
|
|
780
|
+
function copyFuelTankCode() {
|
|
781
|
+
var _a, _b;
|
|
782
|
+
navigator.clipboard.writeText((_b = (_a = exchangeResponse === null || exchangeResponse === void 0 ? void 0 : exchangeResponse.exchangeReward) === null || _a === void 0 ? void 0 : _a.reward) === null || _b === void 0 ? void 0 : _b.fuelTankCode);
|
|
783
|
+
setOpen(true);
|
|
784
|
+
setTimeout(() => setOpen(false), 1000);
|
|
785
|
+
}
|
|
786
|
+
return {
|
|
787
|
+
states: {
|
|
788
|
+
content: {
|
|
789
|
+
text: props,
|
|
790
|
+
},
|
|
791
|
+
selectedItem,
|
|
792
|
+
redeemStage,
|
|
793
|
+
amount,
|
|
794
|
+
selectedStep,
|
|
795
|
+
exchangeError,
|
|
796
|
+
queryError: !!queryError,
|
|
797
|
+
loading: loading || exchangeLoading,
|
|
798
|
+
open,
|
|
799
|
+
noExchangeOptions: ((_a = data === null || data === void 0 ? void 0 : data.viewer) === null || _a === void 0 ? void 0 : _a.visibleRewardExchangeItems.totalCount) === 0,
|
|
800
|
+
},
|
|
801
|
+
data: {
|
|
802
|
+
exchangeList: (_c = (_b = data === null || data === void 0 ? void 0 : data.viewer) === null || _b === void 0 ? void 0 : _b.visibleRewardExchangeItems) === null || _c === void 0 ? void 0 : _c.data,
|
|
803
|
+
fuelTankCode: (_e = (_d = exchangeResponse === null || exchangeResponse === void 0 ? void 0 : exchangeResponse.exchangeReward) === null || _d === void 0 ? void 0 : _d.reward) === null || _e === void 0 ? void 0 : _e.fuelTankCode,
|
|
804
|
+
},
|
|
805
|
+
callbacks: {
|
|
806
|
+
exchangeReward,
|
|
807
|
+
setExchangeState,
|
|
808
|
+
setStage,
|
|
809
|
+
resetState,
|
|
810
|
+
copyFuelTankCode,
|
|
811
|
+
},
|
|
812
|
+
refs: {
|
|
813
|
+
canvasRef,
|
|
814
|
+
},
|
|
815
|
+
};
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
const SqmRewardExchangeList = class {
|
|
819
|
+
constructor(hostRef) {
|
|
820
|
+
registerInstance(this, hostRef);
|
|
821
|
+
this.ignored = true;
|
|
822
|
+
/**
|
|
823
|
+
* Error message shown when reward is not available
|
|
824
|
+
*
|
|
825
|
+
* @uiName Not available error
|
|
826
|
+
* @uiWidget textArea
|
|
827
|
+
*/
|
|
828
|
+
this.notAvailableError = "{unavailableReasonCode, select, US_TAX {US Tax limit} INSUFFICIENT_REDEEMABLE_CREDIT {{sourceValue} required} AVAILABILITY_PREDICATE {Not available} other {{unavailableReasonCode}} }";
|
|
829
|
+
/**
|
|
830
|
+
* @uiName Choose reward progress title
|
|
831
|
+
*/
|
|
832
|
+
this.chooseRewardTitle = "Rewards";
|
|
833
|
+
/**
|
|
834
|
+
* @uiName Choose amount progress title
|
|
835
|
+
*/
|
|
836
|
+
this.chooseAmountTitle = "Select";
|
|
837
|
+
/**
|
|
838
|
+
* @uiName Confirmation progress title
|
|
839
|
+
*/
|
|
840
|
+
this.confirmationTitle = "Confirm";
|
|
841
|
+
/**
|
|
842
|
+
* @uiName Reward title text
|
|
843
|
+
*/
|
|
844
|
+
this.rewardTitle = "Choose a reward";
|
|
845
|
+
/**
|
|
846
|
+
* @uiName Cancel button text
|
|
847
|
+
*/
|
|
848
|
+
this.cancelText = "Cancel";
|
|
849
|
+
/**
|
|
850
|
+
* @uiName Back button text
|
|
851
|
+
*/
|
|
852
|
+
this.backText = "Back";
|
|
853
|
+
/**
|
|
854
|
+
* @uiName Continue button text
|
|
855
|
+
*/
|
|
856
|
+
this.continueText = "Continue";
|
|
857
|
+
/**
|
|
858
|
+
* Displayed on the reward selection page.
|
|
859
|
+
* @uiName Continue to confirmation button text
|
|
860
|
+
*/
|
|
861
|
+
this.continueToConfirmationText = "Continue to confirmation";
|
|
862
|
+
/**
|
|
863
|
+
* @uiName Redeem button text
|
|
864
|
+
*/
|
|
865
|
+
this.redeemText = "Redeem";
|
|
866
|
+
/**
|
|
867
|
+
* Displayed as the header for the confirmation page.
|
|
868
|
+
*
|
|
869
|
+
* @uiName Confirmation title text
|
|
870
|
+
*/
|
|
871
|
+
this.redeemTitle = "Confirm and redeem";
|
|
872
|
+
/**
|
|
873
|
+
* Displayed on the success screen when a user successfully exchanges for a reward.
|
|
874
|
+
*
|
|
875
|
+
* @uiName Redemption success message
|
|
876
|
+
* @uiWidget textArea
|
|
877
|
+
*/
|
|
878
|
+
this.redemptionSuccessText = "Redeemed {sourceValue} for {destinationValue}";
|
|
879
|
+
/**
|
|
880
|
+
* Displayed on the reward exchange cards.
|
|
881
|
+
*
|
|
882
|
+
* @uiName Reward exchange amount text
|
|
883
|
+
* @uiWidget textArea
|
|
884
|
+
*/
|
|
885
|
+
this.sourceAmountMessage = "{ruleType, select, FIXED_GLOBAL_REWARD {{sourceValue}} other {{sourceMinValue} to {sourceMaxValue}}}";
|
|
886
|
+
/**
|
|
887
|
+
* Shown when a user copies a fuel tank code
|
|
888
|
+
*
|
|
889
|
+
* @uiName Tooltip text
|
|
890
|
+
*/
|
|
891
|
+
this.tooltipText = "Copied";
|
|
892
|
+
/**
|
|
893
|
+
* @uiName Done text
|
|
894
|
+
*/
|
|
895
|
+
this.doneText = "Done";
|
|
896
|
+
/**
|
|
897
|
+
* @uiName Select amount text
|
|
898
|
+
* @uiWidget textArea
|
|
899
|
+
*/
|
|
900
|
+
this.selectText = "Select amount to receive";
|
|
901
|
+
/**
|
|
902
|
+
* Shown if an error occurs when loading the reward exchange.
|
|
903
|
+
*
|
|
904
|
+
* @uiName Reward list error message
|
|
905
|
+
* @uiWidget textArea
|
|
906
|
+
*/
|
|
907
|
+
this.queryError = "Unable to load reward exchange list. Please try again";
|
|
908
|
+
/**
|
|
909
|
+
* Shown if an error occurs during the reward exchange.
|
|
910
|
+
*
|
|
911
|
+
* @uiName Redemption error message
|
|
912
|
+
* @uiWidget textArea
|
|
913
|
+
*/
|
|
914
|
+
this.redemptionError = "An error occured trying to redeem this reward. Please try again";
|
|
915
|
+
/**
|
|
916
|
+
* @uiName Not enough error message
|
|
917
|
+
* @uiWidget textArea
|
|
918
|
+
*/
|
|
919
|
+
this.notEnoughError = "Not enough {sourceUnit} to redeem for this reward";
|
|
920
|
+
/**
|
|
921
|
+
* @uiName Reward redeemed text
|
|
922
|
+
*/
|
|
923
|
+
this.rewardRedeemedText = "Reward redeemed";
|
|
924
|
+
/**
|
|
925
|
+
* @uiName Promo code text
|
|
926
|
+
*/
|
|
927
|
+
this.promoCode = "Promo Code";
|
|
928
|
+
/**
|
|
929
|
+
* Set the number of placeholder cards to be shown in loading state.
|
|
930
|
+
*
|
|
931
|
+
* @uiName Loading cards
|
|
932
|
+
*/
|
|
933
|
+
this.skeletonCardNum = 8;
|
|
934
|
+
/**
|
|
935
|
+
* Shown in the confirmation state.
|
|
936
|
+
*
|
|
937
|
+
* @uiName Reward row title
|
|
938
|
+
*/
|
|
939
|
+
this.rewardNameTitle = "Reward";
|
|
940
|
+
/**
|
|
941
|
+
* Shown in the confirmation state.
|
|
942
|
+
*
|
|
943
|
+
* @uiName Reward amount row title
|
|
944
|
+
*/
|
|
945
|
+
this.rewardAmountTitle = "Reward Amount";
|
|
946
|
+
/**
|
|
947
|
+
* Shown in the confirmation state.
|
|
948
|
+
*
|
|
949
|
+
* @uiName Cost row title
|
|
950
|
+
*/
|
|
951
|
+
this.costTitle = "Cost to Redeem";
|
|
952
|
+
/**
|
|
953
|
+
* @componentState { "title": "Choose reward", "props": { "redeemStage": "chooseReward" }, "dependencies": ["sqm-reward-exchange-list"] }
|
|
954
|
+
* @componentState { "title": "Reward details", "props": { "redeemStage": "chooseAmount" }, "dependencies": ["sqm-reward-exchange-list"] }
|
|
955
|
+
* @componentState { "title": "Confirm exchange", "props": { "redeemStage": "confirmation" }, "dependencies": ["sqm-reward-exchange-list"] }
|
|
956
|
+
* @componentState { "title": "Exchange successful", "props": { "redeemStage": "success" }, "dependencies": ["sqm-reward-exchange-list"] }
|
|
957
|
+
*/
|
|
958
|
+
this.stateController = "{}";
|
|
959
|
+
h(this);
|
|
960
|
+
}
|
|
961
|
+
disconnectedCallback() { }
|
|
962
|
+
render() {
|
|
963
|
+
const props = {
|
|
964
|
+
...getProps(this),
|
|
965
|
+
empty: h$1(EmptySlot, null),
|
|
966
|
+
};
|
|
967
|
+
const { states, data, callbacks, refs } = isDemo()
|
|
968
|
+
? useRewardExchangeListDemo(props)
|
|
969
|
+
: useRewardExchangeList(props);
|
|
970
|
+
return (h$1(Host, { style: { display: "contents" } }, h$1(RewardExchangeView, { states: states, data: data, callbacks: callbacks, refs: refs })));
|
|
971
|
+
}
|
|
972
|
+
static get assetsDirs() { return ["assets"]; }
|
|
973
|
+
};
|
|
974
|
+
function EmptySlot() {
|
|
975
|
+
return (h$1("slot", { name: "empty" }, h$1("sqm-empty", { emptyStateImage: "https://res.cloudinary.com/saasquatch/image/upload/v1644360953/squatch-assets/empty_exchange2.png", emptyStateHeader: "Redeem rewards", emptyStateText: "Use your points to redeem rewards once they become available" })));
|
|
976
|
+
}
|
|
977
|
+
function useRewardExchangeListDemo(props) {
|
|
978
|
+
const states = parseStates(props.stateController);
|
|
979
|
+
const formatted = Object.keys(states).reduce((prev, key) => key === "reward-exchange-list"
|
|
980
|
+
? { ...prev, ...states[key] }
|
|
981
|
+
: { ...prev, [`${key}_stateController`]: states[key] }, {});
|
|
982
|
+
return cjs({
|
|
983
|
+
states: {
|
|
984
|
+
content: {
|
|
985
|
+
text: props,
|
|
986
|
+
},
|
|
987
|
+
redeemStage: "chooseReward",
|
|
988
|
+
amount: 0,
|
|
989
|
+
selectedStep: undefined,
|
|
990
|
+
selectedItem: undefined,
|
|
991
|
+
open: false,
|
|
992
|
+
exchangeError: false,
|
|
993
|
+
queryError: false,
|
|
994
|
+
loading: false,
|
|
995
|
+
noExchangeOptions: false,
|
|
996
|
+
},
|
|
997
|
+
data: {
|
|
998
|
+
// shareCode: "SHARECODE123",
|
|
999
|
+
exchangeList: demoRewardExchange.data.exchangeList,
|
|
1000
|
+
},
|
|
1001
|
+
callbacks: {
|
|
1002
|
+
exchangeReward: () => { },
|
|
1003
|
+
setExchangeState: (_) => { },
|
|
1004
|
+
setStage: (_) => { },
|
|
1005
|
+
resetState: () => { },
|
|
1006
|
+
copyFuelTankCode: () => { },
|
|
1007
|
+
},
|
|
1008
|
+
refs: {
|
|
1009
|
+
canvasRef: {},
|
|
1010
|
+
},
|
|
1011
|
+
}, props.demoData || formatted || {}, { arrayMerge: (_, a) => a });
|
|
1012
|
+
}
|
|
1013
|
+
|
|
1014
|
+
export { SqmRewardExchangeList as sqm_reward_exchange_list };
|