@jobber/components 4.85.6-CJS-to-ESM.3 → 4.85.6-CJS-to-ESM.4

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 (82) hide show
  1. package/dist/Chips/InternalChipDismissible/index.cjs +3 -2
  2. package/dist/Chips/InternalChipDismissible/index.mjs +3 -2
  3. package/dist/Chips/index.cjs +4 -3
  4. package/dist/Chips/index.mjs +4 -3
  5. package/dist/{Chips-CWmwDShP.js → Chips-DKCvpzfp.js} +1 -1
  6. package/dist/{Chips-DqEZ8iEX.js → Chips-PXZl-nIG.js} +1 -1
  7. package/dist/Combobox/index.cjs +3 -2
  8. package/dist/Combobox/index.mjs +3 -2
  9. package/dist/{Combobox-BBsXbnmz.js → Combobox-CL1tRKd3.js} +1 -1
  10. package/dist/{Combobox-YIT4j2TF.js → Combobox-D44taKUg.js} +1 -1
  11. package/dist/ConfirmationModal/index.cjs +6 -3
  12. package/dist/ConfirmationModal/index.mjs +6 -3
  13. package/dist/{ConfirmationModal-BX-WMEkO.js → ConfirmationModal-Bg7ftIT2.js} +1 -1
  14. package/dist/{ConfirmationModal-KamMnKR1.js → ConfirmationModal-CrH9KKYd.js} +1 -1
  15. package/dist/Countdown/index.cjs +3 -2
  16. package/dist/Countdown/index.mjs +3 -2
  17. package/dist/Countdown-6Bkj7xkV.js +659 -0
  18. package/dist/Countdown-XLp-r4PS.js +657 -0
  19. package/dist/DataList/components/DataListFilters/components/DataListSort/index.cjs +4 -3
  20. package/dist/DataList/components/DataListFilters/components/DataListSort/index.mjs +4 -3
  21. package/dist/DataList/components/DataListFilters/index.cjs +5 -4
  22. package/dist/DataList/components/DataListFilters/index.mjs +5 -4
  23. package/dist/DataList/index.cjs +6 -5
  24. package/dist/DataList/index.mjs +6 -5
  25. package/dist/{DataList-_BDe70gJ.js → DataList-D67E3-Ka.js} +1 -1
  26. package/dist/{DataList-DPwZfKmO.js → DataList-DqrdT8B4.js} +1 -1
  27. package/dist/{DataListFilters-Cer-kvNp.js → DataListFilters-BjCiSdX2.js} +1 -1
  28. package/dist/{DataListFilters-BtkKOPc0.js → DataListFilters-C8PRbG6B.js} +1 -1
  29. package/dist/{DataListSort-B2WPMPA4.js → DataListSort-BPIPnVXL.js} +1 -1
  30. package/dist/{DataListSort-Bwwe-KI1.js → DataListSort-D1Ng8x7t.js} +1 -1
  31. package/dist/FeatureSwitch/index.cjs +6 -3
  32. package/dist/FeatureSwitch/index.mjs +6 -3
  33. package/dist/{FeatureSwitch-C66nDoAy.js → FeatureSwitch-C6OjQJWH.js} +1 -1
  34. package/dist/{FeatureSwitch-C1cXc0VS.js → FeatureSwitch-Dt8VXcE6.js} +1 -1
  35. package/dist/FormatFile/index.cjs +7 -4
  36. package/dist/FormatFile/index.mjs +7 -4
  37. package/dist/{FormatFile-BA27eKT-.js → FormatFile-BEsZX9CU.js} +1 -1
  38. package/dist/{FormatFile-BIVkB0MY.js → FormatFile-BhY6M5LN.js} +1 -1
  39. package/dist/Gallery/index.cjs +7 -5
  40. package/dist/Gallery/index.mjs +7 -5
  41. package/dist/{Gallery-OozTFjse.js → Gallery-BfEW11YL.js} +1 -1
  42. package/dist/{Gallery-DwACTTDQ.js → Gallery-kWVZNTYq.js} +1 -1
  43. package/dist/Grid/index.cjs +3 -2
  44. package/dist/Grid/index.mjs +3 -2
  45. package/dist/{Grid-C2MuTPpS.js → Grid-InsV4yVr.js} +1 -1
  46. package/dist/{Grid-MPbWi5rM.js → Grid-cuC0E5S-.js} +1 -1
  47. package/dist/InputAvatar/index.cjs +3 -2
  48. package/dist/InputAvatar/index.mjs +3 -2
  49. package/dist/{InputAvatar-BOUrq-0O.js → InputAvatar-B2dB8FZL.js} +1 -1
  50. package/dist/{InputAvatar-BsaMMOEu.js → InputAvatar-CuzV_xzx.js} +1 -1
  51. package/dist/InputFile/index.cjs +2 -1
  52. package/dist/InputFile/index.mjs +2 -1
  53. package/dist/{InputFile-D3TxxmjO.js → InputFile-TLVjerUe.js} +24 -1207
  54. package/dist/{InputFile-BTkuYVab.js → InputFile-cOKwdZIS.js} +1 -1184
  55. package/dist/{InternalChipDismissible-Btb0-4Ng.js → InternalChipDismissible-BuafNVqR.js} +1 -1
  56. package/dist/{InternalChipDismissible-DO0XSGT9.js → InternalChipDismissible-D9MobrPl.js} +1 -1
  57. package/dist/List/index.cjs +5 -3
  58. package/dist/List/index.mjs +5 -3
  59. package/dist/{List-DMvKP4KP.js → List-Cspxky2V.js} +1 -1
  60. package/dist/{List-BmI9aBh-.js → List-DJE2WMjK.js} +1 -1
  61. package/dist/Markdown/index.cjs +5 -2
  62. package/dist/Markdown/index.mjs +5 -2
  63. package/dist/Markdown-C-Kz7FGt.js +18983 -0
  64. package/dist/Markdown-D4Q_2pBV.js +18985 -0
  65. package/dist/Page/index.cjs +5 -3
  66. package/dist/Page/index.mjs +5 -3
  67. package/dist/{Page-B7b9jIoH.js → Page-CNNOg5qF.js} +1 -1
  68. package/dist/{Page-dfDVxvl3.js → Page-Dj0S56-I.js} +1 -1
  69. package/dist/index-B88K44gK.js +1186 -0
  70. package/dist/index-BoP83yS-.js +8 -0
  71. package/dist/index-CJnrkxgL.js +1189 -0
  72. package/dist/index-Jb6tGBiW.js +11 -0
  73. package/dist/index.cjs +21 -20
  74. package/dist/index.mjs +21 -20
  75. package/dist/{useAssert-CmHXXmL3.js → useAssert-DJjF2xRH.js} +1 -3
  76. package/dist/{useAssert-DswGyJhs.js → useAssert-Dj-7DdKE.js} +2 -4
  77. package/package.json +2 -2
  78. package/rollup.config.mjs +10 -11
  79. package/dist/Countdown-DQYi_QSJ.js +0 -63
  80. package/dist/Countdown-mTio5lCJ.js +0 -65
  81. package/dist/Markdown-B2B4q1R4.js +0 -57
  82. package/dist/Markdown-BqNLA1UK.js +0 -55
@@ -0,0 +1,659 @@
1
+ 'use strict';
2
+
3
+ var React = require('react');
4
+ var temporal = require('@std-proposal/temporal');
5
+ var index = require('./index-CJnrkxgL.js');
6
+
7
+ function _classCallCheck(instance, Constructor) {
8
+ if (!(instance instanceof Constructor)) {
9
+ throw new TypeError("Cannot call a class as a function");
10
+ }
11
+ }
12
+
13
+ function _defineProperties(target, props) {
14
+ for (var i = 0; i < props.length; i++) {
15
+ var descriptor = props[i];
16
+ descriptor.enumerable = descriptor.enumerable || false;
17
+ descriptor.configurable = true;
18
+ if ("value" in descriptor) descriptor.writable = true;
19
+ Object.defineProperty(target, descriptor.key, descriptor);
20
+ }
21
+ }
22
+
23
+ function _createClass(Constructor, protoProps, staticProps) {
24
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
25
+ if (staticProps) _defineProperties(Constructor, staticProps);
26
+ return Constructor;
27
+ }
28
+
29
+ function _inherits(subClass, superClass) {
30
+ if (typeof superClass !== "function" && superClass !== null) {
31
+ throw new TypeError("Super expression must either be null or a function");
32
+ }
33
+
34
+ subClass.prototype = Object.create(superClass && superClass.prototype, {
35
+ constructor: {
36
+ value: subClass,
37
+ writable: true,
38
+ configurable: true
39
+ }
40
+ });
41
+ if (superClass) _setPrototypeOf(subClass, superClass);
42
+ }
43
+
44
+ function _getPrototypeOf(o) {
45
+ _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
46
+ return o.__proto__ || Object.getPrototypeOf(o);
47
+ };
48
+ return _getPrototypeOf(o);
49
+ }
50
+
51
+ function _setPrototypeOf(o, p) {
52
+ _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
53
+ o.__proto__ = p;
54
+ return o;
55
+ };
56
+
57
+ return _setPrototypeOf(o, p);
58
+ }
59
+
60
+ function _isNativeReflectConstruct() {
61
+ if (typeof Reflect === "undefined" || !Reflect.construct) return false;
62
+ if (Reflect.construct.sham) return false;
63
+ if (typeof Proxy === "function") return true;
64
+
65
+ try {
66
+ Date.prototype.toString.call(Reflect.construct(Date, [], function () {}));
67
+ return true;
68
+ } catch (e) {
69
+ return false;
70
+ }
71
+ }
72
+
73
+ function _assertThisInitialized(self) {
74
+ if (self === void 0) {
75
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
76
+ }
77
+
78
+ return self;
79
+ }
80
+
81
+ function _possibleConstructorReturn(self, call) {
82
+ if (call && (typeof call === "object" || typeof call === "function")) {
83
+ return call;
84
+ }
85
+
86
+ return _assertThisInitialized(self);
87
+ }
88
+
89
+ function _createSuper(Derived) {
90
+ var hasNativeReflectConstruct = _isNativeReflectConstruct();
91
+
92
+ return function _createSuperInternal() {
93
+ var Super = _getPrototypeOf(Derived),
94
+ result;
95
+
96
+ if (hasNativeReflectConstruct) {
97
+ var NewTarget = _getPrototypeOf(this).constructor;
98
+
99
+ result = Reflect.construct(Super, arguments, NewTarget);
100
+ } else {
101
+ result = Super.apply(this, arguments);
102
+ }
103
+
104
+ return _possibleConstructorReturn(this, result);
105
+ };
106
+ }
107
+
108
+ function _toConsumableArray(arr) {
109
+ return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
110
+ }
111
+
112
+ function _arrayWithoutHoles(arr) {
113
+ if (Array.isArray(arr)) return _arrayLikeToArray(arr);
114
+ }
115
+
116
+ function _iterableToArray(iter) {
117
+ if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter);
118
+ }
119
+
120
+ function _unsupportedIterableToArray(o, minLen) {
121
+ if (!o) return;
122
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
123
+ var n = Object.prototype.toString.call(o).slice(8, -1);
124
+ if (n === "Object" && o.constructor) n = o.constructor.name;
125
+ if (n === "Map" || n === "Set") return Array.from(o);
126
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
127
+ }
128
+
129
+ function _arrayLikeToArray(arr, len) {
130
+ if (len == null || len > arr.length) len = arr.length;
131
+
132
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
133
+
134
+ return arr2;
135
+ }
136
+
137
+ function _nonIterableSpread() {
138
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
139
+ }
140
+
141
+ function zeroPad(value) {
142
+ var length = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2;
143
+ var strValue = String(value);
144
+ if (length === 0) return strValue;
145
+ var match = strValue.match(/(.*?)([0-9]+)(.*)/);
146
+ var prefix = match ? match[1] : '';
147
+ var suffix = match ? match[3] : '';
148
+ var strNo = match ? match[2] : strValue;
149
+ var paddedNo = strNo.length >= length ? strNo : (_toConsumableArray(Array(length)).map(function () {
150
+ return '0';
151
+ }).join('') + strNo).slice(length * -1);
152
+ return "".concat(prefix).concat(paddedNo).concat(suffix);
153
+ }
154
+ var timeDeltaFormatOptionsDefaults = {
155
+ daysInHours: false,
156
+ zeroPadTime: 2
157
+ };
158
+ function calcTimeDelta(date) {
159
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
160
+ var _options$now = options.now,
161
+ now = _options$now === void 0 ? Date.now : _options$now,
162
+ _options$precision = options.precision,
163
+ precision = _options$precision === void 0 ? 0 : _options$precision,
164
+ controlled = options.controlled,
165
+ _options$offsetTime = options.offsetTime,
166
+ offsetTime = _options$offsetTime === void 0 ? 0 : _options$offsetTime,
167
+ overtime = options.overtime;
168
+ var startTimestamp;
169
+
170
+ if (typeof date === 'string') {
171
+ startTimestamp = new Date(date).getTime();
172
+ } else if (date instanceof Date) {
173
+ startTimestamp = date.getTime();
174
+ } else {
175
+ startTimestamp = date;
176
+ }
177
+
178
+ if (!controlled) {
179
+ startTimestamp += offsetTime;
180
+ }
181
+
182
+ var timeLeft = controlled ? startTimestamp : startTimestamp - now();
183
+ var clampedPrecision = Math.min(20, Math.max(0, precision));
184
+ var total = Math.round(parseFloat(((overtime ? timeLeft : Math.max(0, timeLeft)) / 1000).toFixed(clampedPrecision)) * 1000);
185
+ var seconds = Math.abs(total) / 1000;
186
+ return {
187
+ total: total,
188
+ days: Math.floor(seconds / (3600 * 24)),
189
+ hours: Math.floor(seconds / 3600 % 24),
190
+ minutes: Math.floor(seconds / 60 % 60),
191
+ seconds: Math.floor(seconds % 60),
192
+ milliseconds: Number((seconds % 1 * 1000).toFixed()),
193
+ completed: total <= 0
194
+ };
195
+ }
196
+ function formatTimeDelta(timeDelta, options) {
197
+ var days = timeDelta.days,
198
+ hours = timeDelta.hours,
199
+ minutes = timeDelta.minutes,
200
+ seconds = timeDelta.seconds;
201
+
202
+ var _Object$assign = Object.assign(Object.assign({}, timeDeltaFormatOptionsDefaults), options),
203
+ daysInHours = _Object$assign.daysInHours,
204
+ zeroPadTime = _Object$assign.zeroPadTime,
205
+ _Object$assign$zeroPa = _Object$assign.zeroPadDays,
206
+ zeroPadDays = _Object$assign$zeroPa === void 0 ? zeroPadTime : _Object$assign$zeroPa;
207
+
208
+ var zeroPadTimeLength = Math.min(2, zeroPadTime);
209
+ var formattedHours = daysInHours ? zeroPad(hours + days * 24, zeroPadTime) : zeroPad(hours, zeroPadTimeLength);
210
+ return {
211
+ days: daysInHours ? '' : zeroPad(days, zeroPadDays),
212
+ hours: formattedHours,
213
+ minutes: zeroPad(minutes, zeroPadTimeLength),
214
+ seconds: zeroPad(seconds, zeroPadTimeLength)
215
+ };
216
+ }
217
+
218
+ var Countdown$1 = function (_React$Component) {
219
+ _inherits(Countdown, _React$Component);
220
+
221
+ var _super = _createSuper(Countdown);
222
+
223
+ function Countdown() {
224
+ var _this;
225
+
226
+ _classCallCheck(this, Countdown);
227
+
228
+ _this = _super.apply(this, arguments);
229
+ _this.state = {
230
+ count: _this.props.count || 3
231
+ };
232
+
233
+ _this.startCountdown = function () {
234
+ _this.interval = window.setInterval(function () {
235
+ var count = _this.state.count - 1;
236
+
237
+ if (count === 0) {
238
+ _this.stopCountdown();
239
+
240
+ _this.props.onComplete && _this.props.onComplete();
241
+ } else {
242
+ _this.setState(function (prevState) {
243
+ return {
244
+ count: prevState.count - 1
245
+ };
246
+ });
247
+ }
248
+ }, 1000);
249
+ };
250
+
251
+ _this.stopCountdown = function () {
252
+ clearInterval(_this.interval);
253
+ };
254
+
255
+ _this.addTime = function (seconds) {
256
+ _this.stopCountdown();
257
+
258
+ _this.setState(function (prevState) {
259
+ return {
260
+ count: prevState.count + seconds
261
+ };
262
+ }, _this.startCountdown);
263
+ };
264
+
265
+ return _this;
266
+ }
267
+
268
+ _createClass(Countdown, [{
269
+ key: "componentDidMount",
270
+ value: function componentDidMount() {
271
+ this.startCountdown();
272
+ }
273
+ }, {
274
+ key: "componentWillUnmount",
275
+ value: function componentWillUnmount() {
276
+ clearInterval(this.interval);
277
+ }
278
+ }, {
279
+ key: "render",
280
+ value: function render() {
281
+ return this.props.children ? React.cloneElement(this.props.children, {
282
+ count: this.state.count
283
+ }) : null;
284
+ }
285
+ }]);
286
+
287
+ return Countdown;
288
+ }(React.Component);
289
+ Countdown$1.propTypes = {
290
+ count: index.propTypesExports.number,
291
+ children: index.propTypesExports.element,
292
+ onComplete: index.propTypesExports.func
293
+ };
294
+
295
+ var Countdown$1$1 = function (_React$Component) {
296
+ _inherits(Countdown$1$1, _React$Component);
297
+
298
+ var _super = _createSuper(Countdown$1$1);
299
+
300
+ function Countdown$1$1(props) {
301
+ var _this;
302
+
303
+ _classCallCheck(this, Countdown$1$1);
304
+
305
+ _this = _super.call(this, props);
306
+ _this.mounted = false;
307
+ _this.initialTimestamp = _this.calcOffsetStartTimestamp();
308
+ _this.offsetStartTimestamp = _this.props.autoStart ? 0 : _this.initialTimestamp;
309
+ _this.offsetTime = 0;
310
+ _this.legacyMode = false;
311
+ _this.legacyCountdownRef = React.createRef();
312
+
313
+ _this.tick = function () {
314
+ var timeDelta = _this.calcTimeDelta();
315
+
316
+ var callback = timeDelta.completed && !_this.props.overtime ? undefined : _this.props.onTick;
317
+
318
+ _this.setTimeDeltaState(timeDelta, undefined, callback);
319
+ };
320
+
321
+ _this.start = function () {
322
+ if (_this.isStarted()) return;
323
+ var prevOffsetStartTimestamp = _this.offsetStartTimestamp;
324
+ _this.offsetStartTimestamp = 0;
325
+ _this.offsetTime += prevOffsetStartTimestamp ? _this.calcOffsetStartTimestamp() - prevOffsetStartTimestamp : 0;
326
+
327
+ var timeDelta = _this.calcTimeDelta();
328
+
329
+ _this.setTimeDeltaState(timeDelta, "STARTED", _this.props.onStart);
330
+
331
+ if (!_this.props.controlled && (!timeDelta.completed || _this.props.overtime)) {
332
+ _this.clearTimer();
333
+
334
+ _this.interval = window.setInterval(_this.tick, _this.props.intervalDelay);
335
+ }
336
+ };
337
+
338
+ _this.pause = function () {
339
+ if (_this.isPaused()) return;
340
+
341
+ _this.clearTimer();
342
+
343
+ _this.offsetStartTimestamp = _this.calcOffsetStartTimestamp();
344
+
345
+ _this.setTimeDeltaState(_this.state.timeDelta, "PAUSED", _this.props.onPause);
346
+ };
347
+
348
+ _this.stop = function () {
349
+ if (_this.isStopped()) return;
350
+
351
+ _this.clearTimer();
352
+
353
+ _this.offsetStartTimestamp = _this.calcOffsetStartTimestamp();
354
+ _this.offsetTime = _this.offsetStartTimestamp - _this.initialTimestamp;
355
+
356
+ _this.setTimeDeltaState(_this.calcTimeDelta(), "STOPPED", _this.props.onStop);
357
+ };
358
+
359
+ _this.isStarted = function () {
360
+ return _this.isStatus("STARTED");
361
+ };
362
+
363
+ _this.isPaused = function () {
364
+ return _this.isStatus("PAUSED");
365
+ };
366
+
367
+ _this.isStopped = function () {
368
+ return _this.isStatus("STOPPED");
369
+ };
370
+
371
+ _this.isCompleted = function () {
372
+ return _this.isStatus("COMPLETED");
373
+ };
374
+
375
+ if (props.date) {
376
+ var timeDelta = _this.calcTimeDelta();
377
+
378
+ _this.state = {
379
+ timeDelta: timeDelta,
380
+ status: timeDelta.completed ? "COMPLETED" : "STOPPED"
381
+ };
382
+ } else {
383
+ _this.legacyMode = true;
384
+ }
385
+
386
+ return _this;
387
+ }
388
+
389
+ _createClass(Countdown$1$1, [{
390
+ key: "componentDidMount",
391
+ value: function componentDidMount() {
392
+ if (this.legacyMode) {
393
+ return;
394
+ }
395
+
396
+ this.mounted = true;
397
+ if (this.props.onMount) this.props.onMount(this.calcTimeDelta());
398
+ if (this.props.autoStart) this.start();
399
+ }
400
+ }, {
401
+ key: "componentDidUpdate",
402
+ value: function componentDidUpdate(prevProps) {
403
+ if (this.legacyMode) {
404
+ return;
405
+ }
406
+
407
+ if (this.props.date !== prevProps.date) {
408
+ this.initialTimestamp = this.calcOffsetStartTimestamp();
409
+ this.offsetStartTimestamp = this.initialTimestamp;
410
+ this.offsetTime = 0;
411
+ this.setTimeDeltaState(this.calcTimeDelta());
412
+ }
413
+ }
414
+ }, {
415
+ key: "componentWillUnmount",
416
+ value: function componentWillUnmount() {
417
+ if (this.legacyMode) {
418
+ return;
419
+ }
420
+
421
+ this.mounted = false;
422
+ this.clearTimer();
423
+ }
424
+ }, {
425
+ key: "calcTimeDelta",
426
+ value: function calcTimeDelta$1() {
427
+ var _this$props = this.props,
428
+ date = _this$props.date,
429
+ now = _this$props.now,
430
+ precision = _this$props.precision,
431
+ controlled = _this$props.controlled,
432
+ overtime = _this$props.overtime;
433
+ return calcTimeDelta(date, {
434
+ now: now,
435
+ precision: precision,
436
+ controlled: controlled,
437
+ offsetTime: this.offsetTime,
438
+ overtime: overtime
439
+ });
440
+ }
441
+ }, {
442
+ key: "calcOffsetStartTimestamp",
443
+ value: function calcOffsetStartTimestamp() {
444
+ return Date.now();
445
+ }
446
+ }, {
447
+ key: "addTime",
448
+ value: function addTime(seconds) {
449
+ this.legacyCountdownRef.current.addTime(seconds);
450
+ }
451
+ }, {
452
+ key: "clearTimer",
453
+ value: function clearTimer() {
454
+ window.clearInterval(this.interval);
455
+ }
456
+ }, {
457
+ key: "isStatus",
458
+ value: function isStatus(status) {
459
+ return this.state.status === status;
460
+ }
461
+ }, {
462
+ key: "setTimeDeltaState",
463
+ value: function setTimeDeltaState(timeDelta, status, callback) {
464
+ var _this2 = this;
465
+
466
+ if (!this.mounted) return;
467
+ var completing = timeDelta.completed && !this.state.timeDelta.completed;
468
+ var completedOnStart = timeDelta.completed && status === "STARTED";
469
+
470
+ if (completing && !this.props.overtime) {
471
+ this.clearTimer();
472
+ }
473
+
474
+ var onDone = function onDone() {
475
+ if (callback) callback(_this2.state.timeDelta);
476
+
477
+ if (_this2.props.onComplete && (completing || completedOnStart)) {
478
+ _this2.props.onComplete(timeDelta, completedOnStart);
479
+ }
480
+ };
481
+
482
+ return this.setState(function (prevState) {
483
+ var newStatus = status || prevState.status;
484
+
485
+ if (timeDelta.completed && !_this2.props.overtime) {
486
+ newStatus = "COMPLETED";
487
+ } else if (!status && newStatus === "COMPLETED") {
488
+ newStatus = "STOPPED";
489
+ }
490
+
491
+ return {
492
+ timeDelta: timeDelta,
493
+ status: newStatus
494
+ };
495
+ }, onDone);
496
+ }
497
+ }, {
498
+ key: "getApi",
499
+ value: function getApi() {
500
+ return this.api = this.api || {
501
+ start: this.start,
502
+ pause: this.pause,
503
+ stop: this.stop,
504
+ isStarted: this.isStarted,
505
+ isPaused: this.isPaused,
506
+ isStopped: this.isStopped,
507
+ isCompleted: this.isCompleted
508
+ };
509
+ }
510
+ }, {
511
+ key: "getRenderProps",
512
+ value: function getRenderProps() {
513
+ var _this$props2 = this.props,
514
+ daysInHours = _this$props2.daysInHours,
515
+ zeroPadTime = _this$props2.zeroPadTime,
516
+ zeroPadDays = _this$props2.zeroPadDays;
517
+ var timeDelta = this.state.timeDelta;
518
+ return Object.assign(Object.assign({}, timeDelta), {
519
+ api: this.getApi(),
520
+ props: this.props,
521
+ formatted: formatTimeDelta(timeDelta, {
522
+ daysInHours: daysInHours,
523
+ zeroPadTime: zeroPadTime,
524
+ zeroPadDays: zeroPadDays
525
+ })
526
+ });
527
+ }
528
+ }, {
529
+ key: "render",
530
+ value: function render() {
531
+ if (this.legacyMode) {
532
+ var _this$props3 = this.props,
533
+ count = _this$props3.count,
534
+ _children = _this$props3.children,
535
+ onComplete = _this$props3.onComplete;
536
+ return React.createElement(Countdown$1, {
537
+ ref: this.legacyCountdownRef,
538
+ count: count,
539
+ onComplete: onComplete
540
+ }, _children);
541
+ }
542
+
543
+ var _this$props4 = this.props,
544
+ className = _this$props4.className,
545
+ overtime = _this$props4.overtime,
546
+ children = _this$props4.children,
547
+ renderer = _this$props4.renderer;
548
+ var renderProps = this.getRenderProps();
549
+
550
+ if (renderer) {
551
+ return renderer(renderProps);
552
+ }
553
+
554
+ if (children && this.state.timeDelta.completed && !overtime) {
555
+ return React.cloneElement(children, {
556
+ countdown: renderProps
557
+ });
558
+ }
559
+
560
+ var _renderProps$formatte = renderProps.formatted,
561
+ days = _renderProps$formatte.days,
562
+ hours = _renderProps$formatte.hours,
563
+ minutes = _renderProps$formatte.minutes,
564
+ seconds = _renderProps$formatte.seconds;
565
+ return React.createElement("span", {
566
+ className: className
567
+ }, renderProps.total < 0 ? '-' : '', days, days ? ':' : '', hours, ":", minutes, ":", seconds);
568
+ }
569
+ }]);
570
+
571
+ return Countdown$1$1;
572
+ }(React.Component);
573
+ Countdown$1$1.defaultProps = Object.assign(Object.assign({}, timeDeltaFormatOptionsDefaults), {
574
+ controlled: false,
575
+ intervalDelay: 1000,
576
+ precision: 0,
577
+ autoStart: true
578
+ });
579
+ Countdown$1$1.propTypes = {
580
+ date: index.propTypesExports.oneOfType([index.propTypesExports.instanceOf(Date), index.propTypesExports.string, index.propTypesExports.number]),
581
+ daysInHours: index.propTypesExports.bool,
582
+ zeroPadTime: index.propTypesExports.number,
583
+ zeroPadDays: index.propTypesExports.number,
584
+ controlled: index.propTypesExports.bool,
585
+ intervalDelay: index.propTypesExports.number,
586
+ precision: index.propTypesExports.number,
587
+ autoStart: index.propTypesExports.bool,
588
+ overtime: index.propTypesExports.bool,
589
+ className: index.propTypesExports.string,
590
+ children: index.propTypesExports.element,
591
+ renderer: index.propTypesExports.func,
592
+ now: index.propTypesExports.func,
593
+ onMount: index.propTypesExports.func,
594
+ onStart: index.propTypesExports.func,
595
+ onPause: index.propTypesExports.func,
596
+ onStop: index.propTypesExports.func,
597
+ onTick: index.propTypesExports.func,
598
+ onComplete: index.propTypesExports.func
599
+ };
600
+
601
+ function computeTimeUnit(remainder, unit) {
602
+ return parseInt(remainder, 10) !== 1 ? `${unit}s` : unit;
603
+ }
604
+
605
+ function Countdown({ date: inputDate, onComplete, showUnits, granularity = "dhms", }) {
606
+ const date = React.useMemo(() => {
607
+ let initDate;
608
+ if (inputDate instanceof temporal.CivilDate) {
609
+ initDate = new Date(inputDate.year, inputDate.month - 1, inputDate.day);
610
+ }
611
+ else {
612
+ initDate = new Date(inputDate);
613
+ }
614
+ return initDate;
615
+ }, [inputDate]);
616
+ return (React.createElement(Countdown$1$1, { date: date, zeroPadTime: 2, renderer: (props) => (React.createElement(RenderedCountdown, Object.assign({}, props, { granularity: granularity, showUnits: showUnits }))), onComplete: onComplete }));
617
+ }
618
+ function RenderedCountdown({ formatted, granularity = "dhms", showUnits, }) {
619
+ const { days, hours, minutes, seconds } = formatted;
620
+ return React.createElement(React.Fragment, null, buildTime());
621
+ function buildTime() {
622
+ const totalHours = 24 * Number(days) + Number(hours);
623
+ const totalMinutes = 60 * totalHours + Number(minutes);
624
+ const totalSeconds = 60 * totalMinutes + Number(seconds);
625
+ const times = {
626
+ d: { total: days, remainder: days, unit: computeTimeUnit(days, "day") },
627
+ h: {
628
+ total: totalHours,
629
+ remainder: hours,
630
+ unit: computeTimeUnit(hours, "hour"),
631
+ },
632
+ m: {
633
+ total: totalMinutes,
634
+ remainder: minutes,
635
+ unit: computeTimeUnit(minutes, "minute"),
636
+ },
637
+ s: {
638
+ total: totalSeconds,
639
+ remainder: seconds,
640
+ unit: computeTimeUnit(seconds, "second"),
641
+ },
642
+ };
643
+ return timeFormatter(times, granularity, showUnits);
644
+ }
645
+ }
646
+ function timeFormatter(times, granularity, showUnits) {
647
+ let substr = "";
648
+ granularity.split("").forEach((unit, i) => {
649
+ if (i == 0) {
650
+ substr += `${times[unit].total}${showUnits ? ` ${times[unit].unit}` : ""}`;
651
+ }
652
+ else {
653
+ substr += ` : ${times[unit].remainder}${showUnits ? ` ${times[unit].unit}` : ""}`;
654
+ }
655
+ });
656
+ return substr;
657
+ }
658
+
659
+ exports.Countdown = Countdown;