@bigbinary/neeto-molecules 3.16.19 → 3.16.21

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.
@@ -1,56 +1,652 @@
1
1
  import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
2
- import { useMemo, useRef, useState, useEffect } from 'react';
2
+ import React__default, { useState, useLayoutEffect, useEffect, useMemo, useRef } from 'react';
3
3
  import classnames from 'classnames';
4
4
  import { capitalize, findIndexBy, noop } from '@bigbinary/neeto-cist';
5
5
  import Stepper from '@bigbinary/neetoui/Stepper';
6
6
  import _defineProperty from '@babel/runtime/helpers/defineProperty';
7
7
  import { globalProps } from '@bigbinary/neeto-commons-frontend/initializers';
8
- import withT from '@bigbinary/neeto-commons-frontend/react-utils/withT';
9
8
  import Button from '@bigbinary/neetoui/Button';
10
9
  import Typography from '@bigbinary/neetoui/Typography';
11
- import { jsxs, jsx } from 'react/jsx-runtime';
12
- import { n } from './inject-css-DmrvuTKK.js';
10
+ import { jsx, jsxs } from 'react/jsx-runtime';
11
+ import { useTranslation, Trans } from 'react-i18next';
13
12
  import { t } from 'i18next';
14
13
  import useBreakpoints from '@bigbinary/neeto-commons-frontend/react-utils/useBreakpoints';
15
14
  import RightArrow from '@bigbinary/neeto-icons/RightArrow';
16
- import { useTranslation, Trans } from 'react-i18next';
15
+ import { n } from './inject-css-DmrvuTKK.js';
16
+ import withT from '@bigbinary/neeto-commons-frontend/react-utils/withT';
17
17
 
18
- function ownKeys$1(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
19
- function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$1(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$1(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
20
- var CompletedScreen = withT(function (_ref) {
21
- var t = _ref.t,
22
- completeButtonProps = _ref.completeButtonProps;
23
- return /*#__PURE__*/jsxs("div", {
24
- className: "neeto-molecules-onboarding__wrapper",
25
- "data-testid": "onboarding-congratulations-wrapper",
26
- children: [/*#__PURE__*/jsxs("div", {
27
- className: "mx-auto mb-6 w-full max-w-2xl space-y-2 px-6 pt-16",
28
- children: [/*#__PURE__*/jsx(Typography, {
29
- className: "text-center",
30
- "data-cy": "onboarding-congratulations-emoji",
31
- style: "h1",
32
- children: "\uD83C\uDF89"
33
- }), /*#__PURE__*/jsxs(Typography, {
34
- className: "text-center",
35
- "data-cy": "onboarding-congratulations-title",
36
- "data-testid": "onboarding-congratulations-title",
37
- style: "h1",
38
- children: [/*#__PURE__*/jsx("span", {
39
- className: "neeto-ui-text-success-500",
40
- children: t("neetoMolecules.onboarding.congratulations")
41
- }), /*#__PURE__*/jsx("br", {}), t("neetoMolecules.onboarding.readyToUse", {
42
- appName: capitalize(globalProps.appName)
43
- })]
44
- })]
45
- }), /*#__PURE__*/jsx(Button, _objectSpread$1({
46
- "data-cy": "onboarding-congratulations-button",
47
- "data-testid": "onboarding-congratulations-button",
48
- label: t("neetoMolecules.onboarding.helpScreen.startUsingButton", {
49
- appName: globalProps.appName
50
- })
51
- }, completeButtonProps))]
52
- });
53
- });
18
+ // t: current time, b: beginning value, _c: final value, d: total duration
19
+ var tweenFunctions = {
20
+ linear: function(t, b, _c, d) {
21
+ var c = _c - b;
22
+ return c * t / d + b;
23
+ },
24
+ easeInQuad: function(t, b, _c, d) {
25
+ var c = _c - b;
26
+ return c * (t /= d) * t + b;
27
+ },
28
+ easeOutQuad: function(t, b, _c, d) {
29
+ var c = _c - b;
30
+ return -c * (t /= d) * (t - 2) + b;
31
+ },
32
+ easeInOutQuad: function(t, b, _c, d) {
33
+ var c = _c - b;
34
+ if ((t /= d / 2) < 1) {
35
+ return c / 2 * t * t + b;
36
+ } else {
37
+ return -c / 2 * ((--t) * (t - 2) - 1) + b;
38
+ }
39
+ },
40
+ easeInCubic: function(t, b, _c, d) {
41
+ var c = _c - b;
42
+ return c * (t /= d) * t * t + b;
43
+ },
44
+ easeOutCubic: function(t, b, _c, d) {
45
+ var c = _c - b;
46
+ return c * ((t = t / d - 1) * t * t + 1) + b;
47
+ },
48
+ easeInOutCubic: function(t, b, _c, d) {
49
+ var c = _c - b;
50
+ if ((t /= d / 2) < 1) {
51
+ return c / 2 * t * t * t + b;
52
+ } else {
53
+ return c / 2 * ((t -= 2) * t * t + 2) + b;
54
+ }
55
+ },
56
+ easeInQuart: function(t, b, _c, d) {
57
+ var c = _c - b;
58
+ return c * (t /= d) * t * t * t + b;
59
+ },
60
+ easeOutQuart: function(t, b, _c, d) {
61
+ var c = _c - b;
62
+ return -c * ((t = t / d - 1) * t * t * t - 1) + b;
63
+ },
64
+ easeInOutQuart: function(t, b, _c, d) {
65
+ var c = _c - b;
66
+ if ((t /= d / 2) < 1) {
67
+ return c / 2 * t * t * t * t + b;
68
+ } else {
69
+ return -c / 2 * ((t -= 2) * t * t * t - 2) + b;
70
+ }
71
+ },
72
+ easeInQuint: function(t, b, _c, d) {
73
+ var c = _c - b;
74
+ return c * (t /= d) * t * t * t * t + b;
75
+ },
76
+ easeOutQuint: function(t, b, _c, d) {
77
+ var c = _c - b;
78
+ return c * ((t = t / d - 1) * t * t * t * t + 1) + b;
79
+ },
80
+ easeInOutQuint: function(t, b, _c, d) {
81
+ var c = _c - b;
82
+ if ((t /= d / 2) < 1) {
83
+ return c / 2 * t * t * t * t * t + b;
84
+ } else {
85
+ return c / 2 * ((t -= 2) * t * t * t * t + 2) + b;
86
+ }
87
+ },
88
+ easeInSine: function(t, b, _c, d) {
89
+ var c = _c - b;
90
+ return -c * Math.cos(t / d * (Math.PI / 2)) + c + b;
91
+ },
92
+ easeOutSine: function(t, b, _c, d) {
93
+ var c = _c - b;
94
+ return c * Math.sin(t / d * (Math.PI / 2)) + b;
95
+ },
96
+ easeInOutSine: function(t, b, _c, d) {
97
+ var c = _c - b;
98
+ return -c / 2 * (Math.cos(Math.PI * t / d) - 1) + b;
99
+ },
100
+ easeInExpo: function(t, b, _c, d) {
101
+ var c = _c - b;
102
+ return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;
103
+ },
104
+ easeOutExpo: function(t, b, _c, d) {
105
+ var c = _c - b;
106
+ return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
107
+ },
108
+ easeInOutExpo: function(t, b, _c, d) {
109
+ var c = _c - b;
110
+ if (t === 0) {
111
+ return b;
112
+ }
113
+ if (t === d) {
114
+ return b + c;
115
+ }
116
+ if ((t /= d / 2) < 1) {
117
+ return c / 2 * Math.pow(2, 10 * (t - 1)) + b;
118
+ } else {
119
+ return c / 2 * (-Math.pow(2, -10 * --t) + 2) + b;
120
+ }
121
+ },
122
+ easeInCirc: function(t, b, _c, d) {
123
+ var c = _c - b;
124
+ return -c * (Math.sqrt(1 - (t /= d) * t) - 1) + b;
125
+ },
126
+ easeOutCirc: function(t, b, _c, d) {
127
+ var c = _c - b;
128
+ return c * Math.sqrt(1 - (t = t / d - 1) * t) + b;
129
+ },
130
+ easeInOutCirc: function(t, b, _c, d) {
131
+ var c = _c - b;
132
+ if ((t /= d / 2) < 1) {
133
+ return -c / 2 * (Math.sqrt(1 - t * t) - 1) + b;
134
+ } else {
135
+ return c / 2 * (Math.sqrt(1 - (t -= 2) * t) + 1) + b;
136
+ }
137
+ },
138
+ easeInElastic: function(t, b, _c, d) {
139
+ var c = _c - b;
140
+ var a, p, s;
141
+ s = 1.70158;
142
+ p = 0;
143
+ a = c;
144
+ if (t === 0) {
145
+ return b;
146
+ } else if ((t /= d) === 1) {
147
+ return b + c;
148
+ }
149
+ if (!p) {
150
+ p = d * 0.3;
151
+ }
152
+ if (a < Math.abs(c)) {
153
+ a = c;
154
+ s = p / 4;
155
+ } else {
156
+ s = p / (2 * Math.PI) * Math.asin(c / a);
157
+ }
158
+ return -(a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p)) + b;
159
+ },
160
+ easeOutElastic: function(t, b, _c, d) {
161
+ var c = _c - b;
162
+ var a, p, s;
163
+ s = 1.70158;
164
+ p = 0;
165
+ a = c;
166
+ if (t === 0) {
167
+ return b;
168
+ } else if ((t /= d) === 1) {
169
+ return b + c;
170
+ }
171
+ if (!p) {
172
+ p = d * 0.3;
173
+ }
174
+ if (a < Math.abs(c)) {
175
+ a = c;
176
+ s = p / 4;
177
+ } else {
178
+ s = p / (2 * Math.PI) * Math.asin(c / a);
179
+ }
180
+ return a * Math.pow(2, -10 * t) * Math.sin((t * d - s) * (2 * Math.PI) / p) + c + b;
181
+ },
182
+ easeInOutElastic: function(t, b, _c, d) {
183
+ var c = _c - b;
184
+ var a, p, s;
185
+ s = 1.70158;
186
+ p = 0;
187
+ a = c;
188
+ if (t === 0) {
189
+ return b;
190
+ } else if ((t /= d / 2) === 2) {
191
+ return b + c;
192
+ }
193
+ if (!p) {
194
+ p = d * (0.3 * 1.5);
195
+ }
196
+ if (a < Math.abs(c)) {
197
+ a = c;
198
+ s = p / 4;
199
+ } else {
200
+ s = p / (2 * Math.PI) * Math.asin(c / a);
201
+ }
202
+ if (t < 1) {
203
+ return -0.5 * (a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p)) + b;
204
+ } else {
205
+ return a * Math.pow(2, -10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p) * 0.5 + c + b;
206
+ }
207
+ },
208
+ easeInBack: function(t, b, _c, d, s) {
209
+ var c = _c - b;
210
+ if (s === void 0) {
211
+ s = 1.70158;
212
+ }
213
+ return c * (t /= d) * t * ((s + 1) * t - s) + b;
214
+ },
215
+ easeOutBack: function(t, b, _c, d, s) {
216
+ var c = _c - b;
217
+ if (s === void 0) {
218
+ s = 1.70158;
219
+ }
220
+ return c * ((t = t / d - 1) * t * ((s + 1) * t + s) + 1) + b;
221
+ },
222
+ easeInOutBack: function(t, b, _c, d, s) {
223
+ var c = _c - b;
224
+ if (s === void 0) {
225
+ s = 1.70158;
226
+ }
227
+ if ((t /= d / 2) < 1) {
228
+ return c / 2 * (t * t * (((s *= 1.525) + 1) * t - s)) + b;
229
+ } else {
230
+ return c / 2 * ((t -= 2) * t * (((s *= 1.525) + 1) * t + s) + 2) + b;
231
+ }
232
+ },
233
+ easeInBounce: function(t, b, _c, d) {
234
+ var c = _c - b;
235
+ var v;
236
+ v = tweenFunctions.easeOutBounce(d - t, 0, c, d);
237
+ return c - v + b;
238
+ },
239
+ easeOutBounce: function(t, b, _c, d) {
240
+ var c = _c - b;
241
+ if ((t /= d) < 1 / 2.75) {
242
+ return c * (7.5625 * t * t) + b;
243
+ } else if (t < 2 / 2.75) {
244
+ return c * (7.5625 * (t -= 1.5 / 2.75) * t + 0.75) + b;
245
+ } else if (t < 2.5 / 2.75) {
246
+ return c * (7.5625 * (t -= 2.25 / 2.75) * t + 0.9375) + b;
247
+ } else {
248
+ return c * (7.5625 * (t -= 2.625 / 2.75) * t + 0.984375) + b;
249
+ }
250
+ },
251
+ easeInOutBounce: function(t, b, _c, d) {
252
+ var c = _c - b;
253
+ var v;
254
+ if (t < d / 2) {
255
+ v = tweenFunctions.easeInBounce(t * 2, 0, c, d);
256
+ return v * 0.5 + b;
257
+ } else {
258
+ v = tweenFunctions.easeOutBounce(t * 2 - d, 0, c, d);
259
+ return v * 0.5 + c * 0.5 + b;
260
+ }
261
+ }
262
+ };
263
+
264
+ var tweenFunctions_1 = tweenFunctions;
265
+
266
+ function degreesToRads(degrees) {
267
+ return (degrees * Math.PI) / 180;
268
+ }
269
+ function randomRange(min, max) {
270
+ return min + Math.random() * (max - min);
271
+ }
272
+ function randomInt(min, max) {
273
+ return Math.floor(min + Math.random() * (max - min + 1));
274
+ }
275
+
276
+ var ParticleShape;
277
+ (function (ParticleShape) {
278
+ ParticleShape[ParticleShape["Circle"] = 0] = "Circle";
279
+ ParticleShape[ParticleShape["Square"] = 1] = "Square";
280
+ ParticleShape[ParticleShape["Strip"] = 2] = "Strip";
281
+ })(ParticleShape || (ParticleShape = {}));
282
+ var RotationDirection;
283
+ (function (RotationDirection) {
284
+ RotationDirection[RotationDirection["Positive"] = 1] = "Positive";
285
+ RotationDirection[RotationDirection["Negative"] = -1] = "Negative";
286
+ })(RotationDirection || (RotationDirection = {}));
287
+ const DEFAULT_FRAME_TIME = 1000 / 60;
288
+ class Particle {
289
+ constructor(context, getOptions, x, y) {
290
+ this.getOptions = getOptions;
291
+ const { colors, initialVelocityX, initialVelocityY } = this.getOptions();
292
+ this.context = context;
293
+ this.x = x;
294
+ this.y = y;
295
+ this.w = randomRange(5, 20);
296
+ this.h = randomRange(5, 20);
297
+ this.radius = randomRange(5, 10);
298
+ this.vx =
299
+ typeof initialVelocityX === 'number'
300
+ ? randomRange(-initialVelocityX, initialVelocityX)
301
+ : randomRange(initialVelocityX.min, initialVelocityX.max);
302
+ this.vy =
303
+ typeof initialVelocityY === 'number'
304
+ ? randomRange(-initialVelocityY, 0)
305
+ : randomRange(initialVelocityY.min, initialVelocityY.max);
306
+ this.shape = randomInt(0, 2);
307
+ this.angle = degreesToRads(randomRange(0, 360));
308
+ this.angularSpin = randomRange(-0.2, 0.2);
309
+ this.color = colors[Math.floor(Math.random() * colors.length)];
310
+ this.rotateY = randomRange(0, 1);
311
+ this.rotationDirection = randomRange(0, 1)
312
+ ? RotationDirection.Positive
313
+ : RotationDirection.Negative;
314
+ }
315
+ update(elapsed) {
316
+ const { gravity, wind, friction, opacity, drawShape } = this.getOptions();
317
+ const frameTimeMultiplier = elapsed / DEFAULT_FRAME_TIME;
318
+ this.x += this.vx * frameTimeMultiplier;
319
+ this.y += this.vy * frameTimeMultiplier;
320
+ this.vy += gravity * frameTimeMultiplier;
321
+ this.vx += wind * frameTimeMultiplier;
322
+ this.vx *= friction ** frameTimeMultiplier;
323
+ this.vy *= friction ** frameTimeMultiplier;
324
+ if (this.rotateY >= 1 &&
325
+ this.rotationDirection === RotationDirection.Positive) {
326
+ this.rotationDirection = RotationDirection.Negative;
327
+ }
328
+ else if (this.rotateY <= -1 &&
329
+ this.rotationDirection === RotationDirection.Negative) {
330
+ this.rotationDirection = RotationDirection.Positive;
331
+ }
332
+ const rotateDelta = 0.1 * this.rotationDirection * frameTimeMultiplier;
333
+ this.rotateY += rotateDelta;
334
+ this.angle += this.angularSpin;
335
+ this.context.save();
336
+ this.context.translate(this.x, this.y);
337
+ this.context.rotate(this.angle);
338
+ this.context.scale(1, this.rotateY);
339
+ this.context.rotate(this.angle);
340
+ this.context.beginPath();
341
+ this.context.fillStyle = this.color;
342
+ this.context.strokeStyle = this.color;
343
+ this.context.globalAlpha = opacity;
344
+ this.context.lineCap = 'round';
345
+ this.context.lineWidth = 2;
346
+ if (drawShape && typeof drawShape === 'function') {
347
+ drawShape.call(this, this.context);
348
+ }
349
+ else {
350
+ switch (this.shape) {
351
+ case ParticleShape.Circle: {
352
+ this.context.beginPath();
353
+ this.context.arc(0, 0, this.radius, 0, 2 * Math.PI);
354
+ this.context.fill();
355
+ break;
356
+ }
357
+ case ParticleShape.Square: {
358
+ this.context.fillRect(-this.w / 2, -this.h / 2, this.w, this.h);
359
+ break;
360
+ }
361
+ case ParticleShape.Strip: {
362
+ this.context.fillRect(-this.w / 6, -this.h / 2, this.w / 3, this.h);
363
+ break;
364
+ }
365
+ }
366
+ }
367
+ this.context.closePath();
368
+ this.context.restore();
369
+ }
370
+ }
371
+
372
+ class ParticleGenerator {
373
+ constructor(canvas, getOptions) {
374
+ this.x = 0;
375
+ this.y = 0;
376
+ this.w = 0;
377
+ this.h = 0;
378
+ this.lastNumberOfPieces = 0;
379
+ this.tweenProgress = 0;
380
+ this.tweenFrom = 0;
381
+ this.particles = [];
382
+ this.particlesGenerated = 0;
383
+ this.removeParticleAt = (i) => {
384
+ this.particles.splice(i, 1);
385
+ };
386
+ this.getParticle = () => {
387
+ const newParticleX = randomRange(this.x, this.w + this.x);
388
+ const newParticleY = randomRange(this.y, this.h + this.y);
389
+ return new Particle(this.context, this.getOptions, newParticleX, newParticleY);
390
+ };
391
+ this.animate = (elapsed) => {
392
+ const { canvas, context, particlesGenerated, lastNumberOfPieces } = this;
393
+ const { run, recycle, numberOfPieces, debug, tweenFunction, tweenDuration, } = this.getOptions();
394
+ if (!run) {
395
+ return false;
396
+ }
397
+ const nP = this.particles.length;
398
+ const activeCount = recycle ? nP : particlesGenerated;
399
+ // Initial population
400
+ if (activeCount < numberOfPieces) {
401
+ // Use the numberOfPieces prop as a key to reset the easing timing
402
+ if (lastNumberOfPieces !== numberOfPieces) {
403
+ this.tweenProgress = 0;
404
+ this.tweenFrom = activeCount;
405
+ this.lastNumberOfPieces = numberOfPieces;
406
+ }
407
+ // Clamp tweenProgress between 0 and tweenDuration
408
+ this.tweenProgress = Math.min(tweenDuration, Math.max(0, this.tweenProgress + elapsed));
409
+ const tweenedVal = tweenFunction(this.tweenProgress, this.tweenFrom, numberOfPieces, tweenDuration);
410
+ const numToAdd = Math.round(tweenedVal - activeCount);
411
+ for (let i = 0; i < numToAdd; i++) {
412
+ this.particles.push(this.getParticle());
413
+ }
414
+ this.particlesGenerated += numToAdd;
415
+ }
416
+ if (debug) {
417
+ // Draw debug text
418
+ context.font = '12px sans-serif';
419
+ context.fillStyle = '#333';
420
+ context.textAlign = 'right';
421
+ context.fillText(`Particles: ${nP}`, canvas.width - 10, canvas.height - 20);
422
+ }
423
+ // Maintain the population, iterating backwards to prevent issues when removing particles
424
+ for (let i = this.particles.length - 1; i >= 0; i--) {
425
+ const p = this.particles[i];
426
+ // Update each particle's position
427
+ p.update(elapsed);
428
+ // Prune the off-canvas particles
429
+ if (p.y > canvas.height ||
430
+ p.y < -100 ||
431
+ p.x > canvas.width + 100 ||
432
+ p.x < -100) {
433
+ if (recycle && activeCount <= numberOfPieces) {
434
+ // Replace the particle with a brand new one
435
+ this.particles[i] = this.getParticle();
436
+ }
437
+ else {
438
+ this.removeParticleAt(i);
439
+ }
440
+ }
441
+ }
442
+ return nP > 0 || activeCount < numberOfPieces;
443
+ };
444
+ this.canvas = canvas;
445
+ const ctx = this.canvas.getContext('2d');
446
+ if (!ctx) {
447
+ throw new Error('Could not get canvas context');
448
+ }
449
+ this.context = ctx;
450
+ this.getOptions = getOptions;
451
+ }
452
+ }
453
+
454
+ const confettiDefaults = {
455
+ width: typeof window !== 'undefined' ? window.innerWidth : 300,
456
+ height: typeof window !== 'undefined' ? window.innerHeight : 200,
457
+ numberOfPieces: 200,
458
+ friction: 0.99,
459
+ wind: 0,
460
+ gravity: 0.1,
461
+ initialVelocityX: 4,
462
+ initialVelocityY: 10,
463
+ colors: [
464
+ '#f44336',
465
+ '#e91e63',
466
+ '#9c27b0',
467
+ '#673ab7',
468
+ '#3f51b5',
469
+ '#2196f3',
470
+ '#03a9f4',
471
+ '#00bcd4',
472
+ '#009688',
473
+ '#4CAF50',
474
+ '#8BC34A',
475
+ '#CDDC39',
476
+ '#FFEB3B',
477
+ '#FFC107',
478
+ '#FF9800',
479
+ '#FF5722',
480
+ '#795548',
481
+ ],
482
+ opacity: 1.0,
483
+ debug: false,
484
+ tweenFunction: tweenFunctions_1.easeInOutQuad,
485
+ tweenDuration: 5000,
486
+ recycle: true,
487
+ run: true,
488
+ };
489
+ class Confetti {
490
+ constructor(canvas, opts) {
491
+ this.lastFrameTime = 0;
492
+ this.setOptionsWithDefaults = (opts) => {
493
+ const computedConfettiDefaults = {
494
+ confettiSource: {
495
+ x: 0,
496
+ y: 0,
497
+ w: this.canvas.width,
498
+ h: 0,
499
+ },
500
+ };
501
+ this._options = {
502
+ ...computedConfettiDefaults,
503
+ ...confettiDefaults,
504
+ ...opts,
505
+ };
506
+ Object.assign(this, opts.confettiSource);
507
+ };
508
+ this.update = (timestamp = 0) => {
509
+ const { options: { run, onConfettiComplete, frameRate }, canvas, context, } = this;
510
+ // Cap elapsed time to 50ms to prevent large time steps
511
+ const elapsed = Math.min(timestamp - this.lastFrameTime, 50);
512
+ // Throttle the frame rate if set
513
+ if (frameRate && elapsed < 1000 / frameRate) {
514
+ this.rafId = requestAnimationFrame(this.update);
515
+ return;
516
+ }
517
+ this.lastFrameTime = timestamp - (frameRate ? elapsed % frameRate : 0);
518
+ if (run) {
519
+ context.fillStyle = 'white';
520
+ context.clearRect(0, 0, canvas.width, canvas.height);
521
+ }
522
+ if (this.generator.animate(elapsed)) {
523
+ this.rafId = requestAnimationFrame(this.update);
524
+ }
525
+ else {
526
+ if (onConfettiComplete &&
527
+ typeof onConfettiComplete === 'function' &&
528
+ this.generator.particlesGenerated > 0) {
529
+ onConfettiComplete.call(this, this);
530
+ }
531
+ this._options.run = false;
532
+ }
533
+ };
534
+ this.reset = () => {
535
+ if (this.generator && this.generator.particlesGenerated > 0) {
536
+ this.generator.particlesGenerated = 0;
537
+ this.generator.particles = [];
538
+ this.generator.lastNumberOfPieces = 0;
539
+ }
540
+ };
541
+ this.stop = () => {
542
+ this.options = { run: false };
543
+ if (this.rafId) {
544
+ cancelAnimationFrame(this.rafId);
545
+ this.rafId = undefined;
546
+ }
547
+ };
548
+ this.canvas = canvas;
549
+ const ctx = this.canvas.getContext('2d');
550
+ if (!ctx) {
551
+ throw new Error('Could not get canvas context');
552
+ }
553
+ this.context = ctx;
554
+ this.generator = new ParticleGenerator(this.canvas, () => this.options);
555
+ this.options = opts;
556
+ this.update();
557
+ }
558
+ get options() {
559
+ return this._options;
560
+ }
561
+ set options(opts) {
562
+ const lastRunState = this._options?.run;
563
+ const lastRecycleState = this._options?.recycle;
564
+ this.setOptionsWithDefaults(opts);
565
+ if (this.generator) {
566
+ Object.assign(this.generator, this.options.confettiSource);
567
+ if (typeof opts.recycle === 'boolean' &&
568
+ opts.recycle &&
569
+ lastRecycleState === false) {
570
+ this.generator.lastNumberOfPieces = this.generator.particles.length;
571
+ }
572
+ }
573
+ if (typeof opts.run === 'boolean' && opts.run && lastRunState === false) {
574
+ this.update();
575
+ }
576
+ }
577
+ }
578
+
579
+ const ref = React__default.createRef();
580
+ class ReactConfettiInternal extends React__default.Component {
581
+ constructor(props) {
582
+ super(props);
583
+ this.canvas = React__default.createRef();
584
+ this.canvas = props.canvasRef || ref;
585
+ }
586
+ componentDidMount() {
587
+ if (this.canvas.current) {
588
+ const opts = extractCanvasProps(this.props)[0];
589
+ this.confetti = new Confetti(this.canvas.current, opts);
590
+ }
591
+ }
592
+ componentDidUpdate() {
593
+ const confettiOptions = extractCanvasProps(this.props)[0];
594
+ if (this.confetti) {
595
+ this.confetti.options = confettiOptions;
596
+ }
597
+ }
598
+ componentWillUnmount() {
599
+ if (this.confetti) {
600
+ this.confetti.stop();
601
+ }
602
+ this.confetti = undefined;
603
+ }
604
+ render() {
605
+ const [confettiOptions, passedProps] = extractCanvasProps(this.props);
606
+ const canvasStyles = {
607
+ zIndex: 2,
608
+ position: 'absolute',
609
+ pointerEvents: 'none',
610
+ top: 0,
611
+ left: 0,
612
+ bottom: 0,
613
+ right: 0,
614
+ ...passedProps.style,
615
+ };
616
+ return (jsx("canvas", { width: confettiOptions.width, height: confettiOptions.height, ref: this.canvas, ...passedProps, style: canvasStyles }));
617
+ }
618
+ }
619
+ ReactConfettiInternal.defaultProps = {
620
+ ...confettiDefaults,
621
+ };
622
+ ReactConfettiInternal.displayName = 'ReactConfetti';
623
+ function extractCanvasProps(props) {
624
+ const confettiOptions = {};
625
+ const refs = {};
626
+ const rest = {};
627
+ const confettiOptionKeys = [
628
+ ...Object.keys(confettiDefaults),
629
+ 'confettiSource',
630
+ 'drawShape',
631
+ 'onConfettiComplete',
632
+ 'frameRate',
633
+ ];
634
+ const refProps = ['canvasRef'];
635
+ for (const prop in props) {
636
+ const val = props[prop];
637
+ if (confettiOptionKeys.includes(prop)) {
638
+ confettiOptions[prop] = val;
639
+ }
640
+ else if (refProps.includes(prop)) {
641
+ refProps[prop] = val;
642
+ }
643
+ else {
644
+ rest[prop] = val;
645
+ }
646
+ }
647
+ return [confettiOptions, rest, refs];
648
+ }
649
+ const ReactConfetti = React__default.forwardRef((props, ref) => jsx(ReactConfettiInternal, { canvasRef: ref, ...props }));
54
650
 
55
651
  var GENERAL_ONBOARDING_STEPS = {
56
652
  WELCOME: "welcome",
@@ -58,9 +654,6 @@ var GENERAL_ONBOARDING_STEPS = {
58
654
  FINISH: "finish"
59
655
  };
60
656
 
61
- var css = ".neeto-molecules-onboarding__wrapper{align-items:center;display:flex;flex-direction:column;flex-grow:1;height:100vh;overflow-y:auto;padding:0;width:100%}.neeto-molecules-onboarding__container{display:flex;flex-direction:column;height:100vh;overflow-y:auto;position:relative;width:100%}.neeto-molecules-onboarding__stepper-wrapper{background-color:rgb(var(--neeto-ui-white));border-bottom:1px solid rgb(var(--neeto-ui-gray-200));display:flex;flex-shrink:0;padding:.5rem 1rem;width:100%}@media (min-width:1024px){.neeto-molecules-onboarding__stepper-wrapper{justify-content:center}}.neeto-molecules-onboarding__content{flex-grow:1;min-height:0;overflow-y:auto;width:100%}.neeto-molecules-onboarding__content--forward{animation:slideInRight .4s ease backwards}.neeto-molecules-onboarding__content--backward{animation:slideInLeft .4s ease backwards}@keyframes slideInRight{0%{opacity:0;transform:translateX(100%)}to{opacity:1;transform:translateX(0)}}@keyframes slideInLeft{0%{opacity:0;transform:translateX(-100%)}to{opacity:1;transform:translateX(0)}}";
62
- n(css,{});
63
-
64
657
  var HelpScreen = function HelpScreen(_ref) {
65
658
  var setCurrentStep = _ref.setCurrentStep,
66
659
  helpScreenClassName = _ref.helpScreenClassName;
@@ -109,8 +702,8 @@ var HelpScreen = function HelpScreen(_ref) {
109
702
  });
110
703
  };
111
704
 
112
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
113
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
705
+ function ownKeys$1(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
706
+ function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$1(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$1(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
114
707
  var createSteps = function createSteps(onboardingSteps, setCurrentStep, currentStep, helpScreenClassName) {
115
708
  var helpStep = {
116
709
  key: GENERAL_ONBOARDING_STEPS.HELP,
@@ -122,11 +715,101 @@ var createSteps = function createSteps(onboardingSteps, setCurrentStep, currentS
122
715
  })
123
716
  };
124
717
  return onboardingSteps.concat(helpStep).map(function (step, idx) {
125
- return _objectSpread(_objectSpread({}, step), {}, {
718
+ return _objectSpread$1(_objectSpread$1({}, step), {}, {
126
719
  id: idx + 1
127
720
  });
128
721
  });
129
722
  };
723
+ var getWindowDimensions = function getWindowDimensions() {
724
+ return typeof window !== "undefined" ? {
725
+ width: window.innerWidth,
726
+ height: window.innerHeight
727
+ } : {
728
+ width: 100,
729
+ height: 100
730
+ };
731
+ };
732
+
733
+ var useWindowDimensions = function useWindowDimensions() {
734
+ var _useState = useState({
735
+ width: 100,
736
+ height: 100
737
+ }),
738
+ _useState2 = _slicedToArray(_useState, 2),
739
+ windowDimensions = _useState2[0],
740
+ setWindowDimensions = _useState2[1];
741
+ useLayoutEffect(function () {
742
+ setWindowDimensions(getWindowDimensions());
743
+ function handleResize() {
744
+ setWindowDimensions(getWindowDimensions());
745
+ }
746
+ window.addEventListener("resize", handleResize);
747
+ return function () {
748
+ return window.removeEventListener("resize", handleResize);
749
+ };
750
+ }, []);
751
+ return windowDimensions;
752
+ };
753
+
754
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
755
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
756
+ var CompletedScreen = function CompletedScreen(_ref) {
757
+ var completeButtonProps = _ref.completeButtonProps;
758
+ var _useTranslation = useTranslation(),
759
+ t = _useTranslation.t;
760
+ var _useState = useState(true),
761
+ _useState2 = _slicedToArray(_useState, 2),
762
+ dropConfetti = _useState2[0],
763
+ setDropConfetti = _useState2[1];
764
+ var _useWindowDimensions = useWindowDimensions(),
765
+ height = _useWindowDimensions.height,
766
+ width = _useWindowDimensions.width;
767
+ useEffect(function () {
768
+ var timer = setTimeout(function () {
769
+ return setDropConfetti(false);
770
+ }, 10000);
771
+ return function () {
772
+ return clearTimeout(timer);
773
+ };
774
+ }, []);
775
+ return /*#__PURE__*/jsxs("div", {
776
+ className: "neeto-molecules-onboarding__wrapper",
777
+ "data-testid": "onboarding-congratulations-wrapper",
778
+ children: [/*#__PURE__*/jsx(ReactConfetti, {
779
+ height: height,
780
+ width: width,
781
+ recycle: dropConfetti
782
+ }), /*#__PURE__*/jsxs("div", {
783
+ className: "mx-auto mb-6 w-full max-w-2xl space-y-2 px-6 pt-16",
784
+ children: [/*#__PURE__*/jsx(Typography, {
785
+ className: "text-center",
786
+ "data-cy": "onboarding-congratulations-emoji",
787
+ style: "h1",
788
+ children: "\uD83C\uDF89"
789
+ }), /*#__PURE__*/jsxs(Typography, {
790
+ className: "text-center",
791
+ "data-cy": "onboarding-congratulations-title",
792
+ "data-testid": "onboarding-congratulations-title",
793
+ style: "h1",
794
+ children: [/*#__PURE__*/jsx("span", {
795
+ className: "neeto-ui-text-success-500",
796
+ children: t("neetoMolecules.onboarding.congratulations")
797
+ }), /*#__PURE__*/jsx("br", {}), t("neetoMolecules.onboarding.readyToUse", {
798
+ appName: capitalize(globalProps.appName)
799
+ })]
800
+ })]
801
+ }), /*#__PURE__*/jsx(Button, _objectSpread({
802
+ "data-cy": "onboarding-congratulations-button",
803
+ "data-testid": "onboarding-congratulations-button",
804
+ label: t("neetoMolecules.onboarding.helpScreen.startUsingButton", {
805
+ appName: globalProps.appName
806
+ })
807
+ }, completeButtonProps))]
808
+ });
809
+ };
810
+
811
+ var css = ".neeto-molecules-onboarding__wrapper{align-items:center;display:flex;flex-direction:column;flex-grow:1;height:100vh;overflow-y:auto;padding:0;width:100%}.neeto-molecules-onboarding__container{display:flex;flex-direction:column;height:100vh;overflow-y:auto;position:relative;width:100%}.neeto-molecules-onboarding__stepper-wrapper{background-color:rgb(var(--neeto-ui-white));border-bottom:1px solid rgb(var(--neeto-ui-gray-200));display:flex;flex-shrink:0;padding:.5rem 1rem;width:100%}@media (min-width:1024px){.neeto-molecules-onboarding__stepper-wrapper{justify-content:center}}.neeto-molecules-onboarding__content{flex-grow:1;min-height:0;overflow-y:auto;width:100%}.neeto-molecules-onboarding__content--forward{animation:slideInRight .4s ease backwards}.neeto-molecules-onboarding__content--backward{animation:slideInLeft .4s ease backwards}@keyframes slideInRight{0%{opacity:0;transform:translateX(100%)}to{opacity:1;transform:translateX(0)}}@keyframes slideInLeft{0%{opacity:0;transform:translateX(-100%)}to{opacity:1;transform:translateX(0)}}";
812
+ n(css,{});
130
813
 
131
814
  var WelcomeScreen = withT(function (_ref) {
132
815
  var t = _ref.t,