@thecb/components 3.5.13 → 3.5.14

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/index.cjs.js CHANGED
@@ -275,47 +275,21 @@ function __spreadArrays() {
275
275
  return r;
276
276
  }
277
277
 
278
- /*! *****************************************************************************
279
- Copyright (c) Microsoft Corporation. All rights reserved.
280
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use
281
- this file except in compliance with the License. You may obtain a copy of the
282
- License at http://www.apache.org/licenses/LICENSE-2.0
283
-
284
- THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
285
- KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
286
- WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
287
- MERCHANTABLITY OR NON-INFRINGEMENT.
288
-
289
- See the Apache Version 2.0 License for specific language governing permissions
290
- and limitations under the License.
291
- ***************************************************************************** */
292
-
293
- var __assign$1 = function() {
294
- __assign$1 = Object.assign || function __assign(t) {
295
- for (var s, i = 1, n = arguments.length; i < n; i++) {
296
- s = arguments[i];
297
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
298
- }
299
- return t;
300
- };
301
- return __assign$1.apply(this, arguments);
302
- };
303
-
304
278
  var clamp = function (min, max) { return function (v) {
305
279
  return Math.max(Math.min(v, max), min);
306
280
  }; };
307
281
  var sanitize = function (v) { return (v % 1 ? Number(v.toFixed(5)) : v); };
308
282
  var floatRegex = /(-)?(\d[\d\.]*)/g;
309
- var colorRegex = /(#[0-9a-f]{6}|#[0-9a-f]{3}|#(?:[0-9a-f]{2}){2,4}|(rgb|hsl)a?\((-?\d+%?[,\s]+){2,3}\s*[\d\.]+%?\))/gi;
310
- var singleColorRegex = /^(#[0-9a-f]{3}|#(?:[0-9a-f]{2}){2,4}|(rgb|hsl)a?\((-?\d+%?[,\s]+){2,3}\s*[\d\.]+%?\))$/i;
283
+ var colorRegex = /(#[0-9a-f]{6}|#[0-9a-f]{3}|#(?:[0-9a-f]{2}){2,4}|(rgb|hsl)a?\((-?[\d\.]+%?[,\s]+){2,3}\s*\/*\s*[\d\.]+%?\))/gi;
284
+ var singleColorRegex = /^(#[0-9a-f]{3}|#(?:[0-9a-f]{2}){2,4}|(rgb|hsl)a?\((-?[\d\.]+%?[,\s]+){2,3}\s*\/*\s*[\d\.]+%?\))$/i;
311
285
 
312
286
  var number = {
313
287
  test: function (v) { return typeof v === 'number'; },
314
288
  parse: parseFloat,
315
289
  transform: function (v) { return v; }
316
290
  };
317
- var alpha = __assign$1(__assign$1({}, number), { transform: clamp(0, 1) });
318
- var scale = __assign$1(__assign$1({}, number), { default: 1 });
291
+ var alpha = __assign(__assign({}, number), { transform: clamp(0, 1) });
292
+ var scale = __assign(__assign({}, number), { default: 1 });
319
293
 
320
294
  var createUnitType = function (unit) { return ({
321
295
  test: function (v) {
@@ -329,7 +303,7 @@ var percent = createUnitType('%');
329
303
  var px = createUnitType('px');
330
304
  var vh = createUnitType('vh');
331
305
  var vw = createUnitType('vw');
332
- var progressPercentage = __assign$1(__assign$1({}, percent), { parse: function (v) { return percent.parse(v) / 100; }, transform: function (v) { return percent.transform(v * 100); } });
306
+ var progressPercentage = __assign(__assign({}, percent), { parse: function (v) { return percent.parse(v) / 100; }, transform: function (v) { return percent.transform(v * 100); } });
333
307
 
334
308
  var getValueFromFunctionString = function (value) {
335
309
  return value.substring(value.indexOf('(') + 1, value.lastIndexOf(')'));
@@ -337,12 +311,17 @@ var getValueFromFunctionString = function (value) {
337
311
  var clampRgbUnit = clamp(0, 255);
338
312
  var isRgba = function (v) { return v.red !== undefined; };
339
313
  var isHsla = function (v) { return v.hue !== undefined; };
314
+ function getValuesAsArray(value) {
315
+ return getValueFromFunctionString(value)
316
+ .replace(/(,|\/)/g, ' ')
317
+ .split(/ \s*/);
318
+ }
340
319
  var splitColorValues = function (terms) {
341
320
  return function (v) {
342
321
  if (typeof v !== 'string')
343
322
  return v;
344
323
  var values = {};
345
- var valuesArray = getValueFromFunctionString(v).split(/,\s*/);
324
+ var valuesArray = getValuesAsArray(v);
346
325
  for (var i = 0; i < 4; i++) {
347
326
  values[terms[i]] =
348
327
  valuesArray[i] !== undefined ? parseFloat(valuesArray[i]) : 1;
@@ -351,14 +330,14 @@ var splitColorValues = function (terms) {
351
330
  };
352
331
  };
353
332
  var rgbaTemplate = function (_a) {
354
- var red = _a.red, green = _a.green, blue = _a.blue, _b = _a.alpha, alpha$$1 = _b === void 0 ? 1 : _b;
355
- return "rgba(" + red + ", " + green + ", " + blue + ", " + alpha$$1 + ")";
333
+ var red = _a.red, green = _a.green, blue = _a.blue, _b = _a.alpha, alpha = _b === void 0 ? 1 : _b;
334
+ return "rgba(" + red + ", " + green + ", " + blue + ", " + alpha + ")";
356
335
  };
357
336
  var hslaTemplate = function (_a) {
358
- var hue = _a.hue, saturation = _a.saturation, lightness = _a.lightness, _b = _a.alpha, alpha$$1 = _b === void 0 ? 1 : _b;
359
- return "hsla(" + hue + ", " + saturation + ", " + lightness + ", " + alpha$$1 + ")";
337
+ var hue = _a.hue, saturation = _a.saturation, lightness = _a.lightness, _b = _a.alpha, alpha = _b === void 0 ? 1 : _b;
338
+ return "hsla(" + hue + ", " + saturation + ", " + lightness + ", " + alpha + ")";
360
339
  };
361
- var rgbUnit = __assign$1(__assign$1({}, number), { transform: function (v) { return Math.round(clampRgbUnit(v)); } });
340
+ var rgbUnit = __assign(__assign({}, number), { transform: function (v) { return Math.round(clampRgbUnit(v)); } });
362
341
  function isColorString(color, colorType) {
363
342
  return color.startsWith(colorType) && singleColorRegex.test(color);
364
343
  }
@@ -366,12 +345,12 @@ var rgba = {
366
345
  test: function (v) { return (typeof v === 'string' ? isColorString(v, 'rgb') : isRgba(v)); },
367
346
  parse: splitColorValues(['red', 'green', 'blue', 'alpha']),
368
347
  transform: function (_a) {
369
- var red = _a.red, green = _a.green, blue = _a.blue, _b = _a.alpha, alpha$$1 = _b === void 0 ? 1 : _b;
348
+ var red = _a.red, green = _a.green, blue = _a.blue, _b = _a.alpha, alpha$1 = _b === void 0 ? 1 : _b;
370
349
  return rgbaTemplate({
371
350
  red: rgbUnit.transform(red),
372
351
  green: rgbUnit.transform(green),
373
352
  blue: rgbUnit.transform(blue),
374
- alpha: sanitize(alpha.transform(alpha$$1))
353
+ alpha: sanitize(alpha.transform(alpha$1))
375
354
  });
376
355
  }
377
356
  };
@@ -379,16 +358,16 @@ var hsla = {
379
358
  test: function (v) { return (typeof v === 'string' ? isColorString(v, 'hsl') : isHsla(v)); },
380
359
  parse: splitColorValues(['hue', 'saturation', 'lightness', 'alpha']),
381
360
  transform: function (_a) {
382
- var hue = _a.hue, saturation = _a.saturation, lightness = _a.lightness, _b = _a.alpha, alpha$$1 = _b === void 0 ? 1 : _b;
361
+ var hue = _a.hue, saturation = _a.saturation, lightness = _a.lightness, _b = _a.alpha, alpha$1 = _b === void 0 ? 1 : _b;
383
362
  return hslaTemplate({
384
363
  hue: Math.round(hue),
385
364
  saturation: percent.transform(sanitize(saturation)),
386
365
  lightness: percent.transform(sanitize(lightness)),
387
- alpha: sanitize(alpha.transform(alpha$$1))
366
+ alpha: sanitize(alpha.transform(alpha$1))
388
367
  });
389
368
  }
390
369
  };
391
- var hex = __assign$1(__assign$1({}, rgba), { test: function (v) { return typeof v === 'string' && isColorString(v, '#'); }, parse: function (v) {
370
+ var hex = __assign(__assign({}, rgba), { test: function (v) { return typeof v === 'string' && isColorString(v, '#'); }, parse: function (v) {
392
371
  var r = '';
393
372
  var g = '';
394
373
  var b = '';
@@ -522,140 +501,134 @@ if (process.env.NODE_ENV !== 'production') {
522
501
  };
523
502
  }
524
503
 
525
- var prevTime = 0;
526
- var onNextFrame = typeof window !== 'undefined' && window.requestAnimationFrame !== undefined
527
- ? function (callback) { return window.requestAnimationFrame(callback); }
528
- : function (callback) {
529
- var timestamp = Date.now();
530
- var timeToCall = Math.max(0, 16.7 - (timestamp - prevTime));
531
- prevTime = timestamp + timeToCall;
532
- setTimeout(function () { return callback(prevTime); }, timeToCall);
504
+ var prevTime = 0;
505
+ var onNextFrame = typeof window !== 'undefined' && window.requestAnimationFrame !== undefined ? function (callback) {
506
+ return window.requestAnimationFrame(callback);
507
+ } : function (callback) {
508
+ var timestamp = Date.now();
509
+ var timeToCall = Math.max(0, 16.7 - (timestamp - prevTime));
510
+ prevTime = timestamp + timeToCall;
511
+ setTimeout(function () {
512
+ return callback(prevTime);
513
+ }, timeToCall);
514
+ };
515
+
516
+ var createStep = function (setRunNextFrame) {
517
+ var processToRun = [];
518
+ var processToRunNextFrame = [];
519
+ var numThisFrame = 0;
520
+ var isProcessing = false;
521
+ var i = 0;
522
+ var cancelled = new WeakSet();
523
+ var toKeepAlive = new WeakSet();
524
+ var renderStep = {
525
+ cancel: function (process) {
526
+ var indexOfCallback = processToRunNextFrame.indexOf(process);
527
+ cancelled.add(process);
528
+ if (indexOfCallback !== -1) {
529
+ processToRunNextFrame.splice(indexOfCallback, 1);
530
+ }
531
+ },
532
+ process: function (frame) {
533
+ var _a;
534
+ isProcessing = true;
535
+ _a = [processToRunNextFrame, processToRun], processToRun = _a[0], processToRunNextFrame = _a[1];
536
+ processToRunNextFrame.length = 0;
537
+ numThisFrame = processToRun.length;
538
+ if (numThisFrame) {
539
+ var process_1;
540
+ for (i = 0; i < numThisFrame; i++) {
541
+ process_1 = processToRun[i];
542
+ process_1(frame);
543
+ if (toKeepAlive.has(process_1) === true && !cancelled.has(process_1)) {
544
+ renderStep.schedule(process_1);
545
+ setRunNextFrame(true);
546
+ }
547
+ }
548
+ }
549
+ isProcessing = false;
550
+ },
551
+ schedule: function (process, keepAlive, immediate) {
552
+ if (keepAlive === void 0) {
553
+ keepAlive = false;
554
+ }
555
+ if (immediate === void 0) {
556
+ immediate = false;
557
+ }
558
+ invariant(typeof process === "function", "Argument must be a function");
559
+ var addToCurrentBuffer = immediate && isProcessing;
560
+ var buffer = addToCurrentBuffer ? processToRun : processToRunNextFrame;
561
+ cancelled.delete(process);
562
+ if (keepAlive) toKeepAlive.add(process);
563
+ if (buffer.indexOf(process) === -1) {
564
+ buffer.push(process);
565
+ if (addToCurrentBuffer) numThisFrame = processToRun.length;
566
+ }
567
+ }
533
568
  };
569
+ return renderStep;
570
+ };
534
571
 
535
- var createStep = (function (setRunNextFrame) {
536
- var processToRun = [];
537
- var processToRunNextFrame = [];
538
- var numThisFrame = 0;
539
- var isProcessing = false;
540
- var i = 0;
541
- var cancelled = new WeakSet();
542
- var toKeepAlive = new WeakSet();
543
- var renderStep = {
544
- cancel: function (process) {
545
- var indexOfCallback = processToRunNextFrame.indexOf(process);
546
- cancelled.add(process);
547
- if (indexOfCallback !== -1) {
548
- processToRunNextFrame.splice(indexOfCallback, 1);
549
- }
550
- },
551
- process: function (frame) {
552
- var _a;
553
- isProcessing = true;
554
- _a = [
555
- processToRunNextFrame,
556
- processToRun
557
- ], processToRun = _a[0], processToRunNextFrame = _a[1];
558
- processToRunNextFrame.length = 0;
559
- numThisFrame = processToRun.length;
560
- if (numThisFrame) {
561
- var process_1;
562
- for (i = 0; i < numThisFrame; i++) {
563
- process_1 = processToRun[i];
564
- process_1(frame);
565
- if (toKeepAlive.has(process_1) === true && !cancelled.has(process_1)) {
566
- renderStep.schedule(process_1);
567
- setRunNextFrame(true);
568
- }
569
- }
570
- }
571
- isProcessing = false;
572
- },
573
- schedule: function (process, keepAlive, immediate) {
574
- if (keepAlive === void 0) { keepAlive = false; }
575
- if (immediate === void 0) { immediate = false; }
576
- invariant(typeof process === 'function', 'Argument must be a function');
577
- var addToCurrentBuffer = immediate && isProcessing;
578
- var buffer = addToCurrentBuffer ? processToRun : processToRunNextFrame;
579
- cancelled.delete(process);
580
- if (keepAlive)
581
- toKeepAlive.add(process);
582
- if (buffer.indexOf(process) === -1) {
583
- buffer.push(process);
584
- if (addToCurrentBuffer)
585
- numThisFrame = processToRun.length;
586
- }
587
- }
588
- };
589
- return renderStep;
590
- });
591
-
592
- var StepId;
593
- (function (StepId) {
594
- StepId["Read"] = "read";
595
- StepId["Update"] = "update";
596
- StepId["Render"] = "render";
597
- StepId["PostRender"] = "postRender";
598
- StepId["FixedUpdate"] = "fixedUpdate";
599
- })(StepId || (StepId = {}));
600
-
601
- var maxElapsed = 40;
602
- var defaultElapsed = (1 / 60) * 1000;
603
- var useDefaultElapsed = true;
604
- var willRunNextFrame = false;
605
- var isProcessing = false;
606
- var frame = {
607
- delta: 0,
608
- timestamp: 0
609
- };
610
- var stepsOrder = [
611
- StepId.Read,
612
- StepId.Update,
613
- StepId.Render,
614
- StepId.PostRender
615
- ];
616
- var setWillRunNextFrame = function (willRun) { return (willRunNextFrame = willRun); };
617
- var _a = stepsOrder.reduce(function (acc, key) {
618
- var step = createStep(setWillRunNextFrame);
619
- acc.sync[key] = function (process, keepAlive, immediate) {
620
- if (keepAlive === void 0) { keepAlive = false; }
621
- if (immediate === void 0) { immediate = false; }
622
- if (!willRunNextFrame)
623
- startLoop();
624
- step.schedule(process, keepAlive, immediate);
625
- return process;
626
- };
627
- acc.cancelSync[key] = function (process) { return step.cancel(process); };
628
- acc.steps[key] = step;
629
- return acc;
630
- }, {
631
- steps: {},
632
- sync: {},
633
- cancelSync: {}
634
- }), steps = _a.steps, sync = _a.sync, cancelSync = _a.cancelSync;
635
- var processStep = function (stepId) { return steps[stepId].process(frame); };
636
- var processFrame = function (timestamp) {
637
- willRunNextFrame = false;
638
- frame.delta = useDefaultElapsed
639
- ? defaultElapsed
640
- : Math.max(Math.min(timestamp - frame.timestamp, maxElapsed), 1);
641
- if (!useDefaultElapsed)
642
- defaultElapsed = frame.delta;
643
- frame.timestamp = timestamp;
644
- isProcessing = true;
645
- stepsOrder.forEach(processStep);
646
- isProcessing = false;
647
- if (willRunNextFrame) {
648
- useDefaultElapsed = false;
649
- onNextFrame(processFrame);
650
- }
651
- };
652
- var startLoop = function () {
653
- willRunNextFrame = true;
654
- useDefaultElapsed = true;
655
- if (!isProcessing)
656
- onNextFrame(processFrame);
657
- };
658
- var getFrameData = function () { return frame; };
572
+ var maxElapsed = 40;
573
+ var defaultElapsed = 1 / 60 * 1000;
574
+ var useDefaultElapsed = true;
575
+ var willRunNextFrame = false;
576
+ var isProcessing = false;
577
+ var frame = {
578
+ delta: 0,
579
+ timestamp: 0
580
+ };
581
+ var stepsOrder = ["read", "update", "preRender", "render", "postRender"];
582
+ var setWillRunNextFrame = function (willRun) {
583
+ return willRunNextFrame = willRun;
584
+ };
585
+ var steps = /*#__PURE__*/stepsOrder.reduce(function (acc, key) {
586
+ acc[key] = createStep(setWillRunNextFrame);
587
+ return acc;
588
+ }, {});
589
+ var sync = /*#__PURE__*/stepsOrder.reduce(function (acc, key) {
590
+ var step = steps[key];
591
+ acc[key] = function (process, keepAlive, immediate) {
592
+ if (keepAlive === void 0) {
593
+ keepAlive = false;
594
+ }
595
+ if (immediate === void 0) {
596
+ immediate = false;
597
+ }
598
+ if (!willRunNextFrame) startLoop();
599
+ step.schedule(process, keepAlive, immediate);
600
+ return process;
601
+ };
602
+ return acc;
603
+ }, {});
604
+ var cancelSync = /*#__PURE__*/stepsOrder.reduce(function (acc, key) {
605
+ acc[key] = steps[key].cancel;
606
+ return acc;
607
+ }, {});
608
+ var processStep = function (stepId) {
609
+ return steps[stepId].process(frame);
610
+ };
611
+ var processFrame = function (timestamp) {
612
+ willRunNextFrame = false;
613
+ frame.delta = useDefaultElapsed ? defaultElapsed : Math.max(Math.min(timestamp - frame.timestamp, maxElapsed), 1);
614
+ if (!useDefaultElapsed) defaultElapsed = frame.delta;
615
+ frame.timestamp = timestamp;
616
+ isProcessing = true;
617
+ stepsOrder.forEach(processStep);
618
+ isProcessing = false;
619
+ if (willRunNextFrame) {
620
+ useDefaultElapsed = false;
621
+ onNextFrame(processFrame);
622
+ }
623
+ };
624
+ var startLoop = function () {
625
+ willRunNextFrame = true;
626
+ useDefaultElapsed = true;
627
+ if (!isProcessing) onNextFrame(processFrame);
628
+ };
629
+ var getFrameData = function () {
630
+ return frame;
631
+ };
659
632
 
660
633
  var DEFAULT_OVERSHOOT_STRENGTH = 1.525;
661
634
  var reversed = function (easing) {
@@ -930,15 +903,15 @@ See the Apache Version 2.0 License for specific language governing permissions
930
903
  and limitations under the License.
931
904
  ***************************************************************************** */
932
905
 
933
- var __assign$2 = function() {
934
- __assign$2 = Object.assign || function __assign(t) {
906
+ var __assign$1 = function() {
907
+ __assign$1 = Object.assign || function __assign(t) {
935
908
  for (var s, i = 1, n = arguments.length; i < n; i++) {
936
909
  s = arguments[i];
937
910
  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
938
911
  }
939
912
  return t;
940
913
  };
941
- return __assign$2.apply(this, arguments);
914
+ return __assign$1.apply(this, arguments);
942
915
  };
943
916
 
944
917
  var mixLinearColor = function (from, to, v) {
@@ -961,7 +934,7 @@ var mixColor = (function (from, to) {
961
934
  invariant(fromColorType.transform === toColorType.transform, 'Both colors must be hex/RGBA, OR both must be HSLA.');
962
935
  var fromColor = fromColorType.parse(from);
963
936
  var toColor = toColorType.parse(to);
964
- var blended = __assign$2({}, fromColor);
937
+ var blended = __assign$1({}, fromColor);
965
938
  var mixFunc = fromColorType === hsla ? mix : mixLinearColor;
966
939
  return function (v) {
967
940
  for (var key in blended) {
@@ -1006,7 +979,7 @@ var mixArray = function (from, to) {
1006
979
  };
1007
980
  };
1008
981
  var mixObject = function (origin, target) {
1009
- var output = __assign$2({}, origin, target);
982
+ var output = __assign$1({}, origin, target);
1010
983
  var blendValue = {};
1011
984
  for (var key in output) {
1012
985
  if (origin[key] !== undefined && target[key] !== undefined) {
@@ -3396,15 +3369,15 @@ See the Apache Version 2.0 License for specific language governing permissions
3396
3369
  and limitations under the License.
3397
3370
  ***************************************************************************** */
3398
3371
 
3399
- var __assign$3 = function () {
3400
- __assign$3 = Object.assign || function __assign(t) {
3372
+ var __assign$2 = function () {
3373
+ __assign$2 = Object.assign || function __assign(t) {
3401
3374
  for (var s, i = 1, n = arguments.length; i < n; i++) {
3402
3375
  s = arguments[i];
3403
3376
  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
3404
3377
  }
3405
3378
  return t;
3406
3379
  };
3407
- return __assign$3.apply(this, arguments);
3380
+ return __assign$2.apply(this, arguments);
3408
3381
  };
3409
3382
 
3410
3383
  function __rest$1(s, e) {
@@ -3524,12 +3497,12 @@ var intelligentTransition = {
3524
3497
  opacity: linearTween,
3525
3498
  default: tween
3526
3499
  };
3527
- var dragAction = /*#__PURE__*/__assign$3( /*#__PURE__*/__assign$3({}, intelligentTransition), { x: /*#__PURE__*/createPointer(pointerX, 'left', 'right', BoundingBoxDimension.width), y: /*#__PURE__*/createPointer(pointerY, 'top', 'bottom', BoundingBoxDimension.height) });
3500
+ var dragAction = /*#__PURE__*/__assign$2( /*#__PURE__*/__assign$2({}, intelligentTransition), { x: /*#__PURE__*/createPointer(pointerX, 'left', 'right', BoundingBoxDimension.width), y: /*#__PURE__*/createPointer(pointerY, 'top', 'bottom', BoundingBoxDimension.height) });
3528
3501
  var justAxis = function (_a) {
3529
3502
  var from = _a.from;
3530
3503
  return just(from);
3531
3504
  };
3532
- var intelligentDragEnd = /*#__PURE__*/__assign$3( /*#__PURE__*/__assign$3({}, intelligentTransition), { x: justAxis, y: justAxis });
3505
+ var intelligentDragEnd = /*#__PURE__*/__assign$2( /*#__PURE__*/__assign$2({}, intelligentTransition), { x: justAxis, y: justAxis });
3533
3506
  var defaultTransitions = /*#__PURE__*/new Map([['default', intelligentTransition], ['drag', dragAction], ['dragEnd', intelligentDragEnd]]);
3534
3507
 
3535
3508
  var animationLookup = {
@@ -3624,7 +3597,7 @@ var getAction = function (v, _a, _b) {
3624
3597
  velocity: velocity,
3625
3598
  ease: ease
3626
3599
  } : { ease: ease };
3627
- return animationLookup[type](__assign$3(__assign$3({}, baseProps), def));
3600
+ return animationLookup[type](__assign$2(__assign$2({}, baseProps), def));
3628
3601
  };
3629
3602
  var isAction = function (action$$1) {
3630
3603
  return typeof action$$1.start !== 'undefined';
@@ -4003,7 +3976,7 @@ var convertPositionalUnits = function (state, nextPose) {
4003
3976
  changedPositionalKeys.push(key);
4004
3977
  if (!applyAtEndHasBeenCopied) {
4005
3978
  applyAtEndHasBeenCopied = true;
4006
- nextPose.applyAtEnd = nextPose.applyAtEnd ? __assign$3({}, nextPose.applyAtEnd) : {};
3979
+ nextPose.applyAtEnd = nextPose.applyAtEnd ? __assign$2({}, nextPose.applyAtEnd) : {};
4007
3980
  }
4008
3981
  nextPose.applyAtEnd[key] = nextPose.applyAtEnd[key] || nextPose[key];
4009
3982
  setValue(state, key, to);
@@ -4060,7 +4033,7 @@ var createPoseConfig = function (element, _a) {
4060
4033
  pressable = _a.pressable,
4061
4034
  dragBounds = _a.dragBounds,
4062
4035
  config = __rest$1(_a, ["onDragStart", "onDragEnd", "onPressStart", "onPressEnd", "draggable", "hoverable", "focusable", "pressable", "dragBounds"]);
4063
- var poseConfig = __assign$3(__assign$3({ flip: {} }, config), { props: __assign$3(__assign$3({}, config.props), { onDragStart: onDragStart,
4036
+ var poseConfig = __assign$2(__assign$2({ flip: {} }, config), { props: __assign$2(__assign$2({}, config.props), { onDragStart: onDragStart,
4064
4037
  onDragEnd: onDragEnd,
4065
4038
  onPressStart: onPressStart,
4066
4039
  onPressEnd: onPressEnd,
@@ -4074,8 +4047,8 @@ var createPoseConfig = function (element, _a) {
4074
4047
  var _b = dragPoses(draggable),
4075
4048
  drag = _b.drag,
4076
4049
  dragEnd = _b.dragEnd;
4077
- poseConfig.drag = __assign$3(__assign$3({}, drag), poseConfig.drag);
4078
- poseConfig.dragEnd = __assign$3(__assign$3({}, dragEnd), poseConfig.dragEnd);
4050
+ poseConfig.drag = __assign$2(__assign$2({}, drag), poseConfig.drag);
4051
+ poseConfig.dragEnd = __assign$2(__assign$2({}, dragEnd), poseConfig.dragEnd);
4079
4052
  }
4080
4053
  return poseConfig;
4081
4054
  };
@@ -4121,7 +4094,7 @@ var domPose = /*#__PURE__*/pose({
4121
4094
  var props = _a.props,
4122
4095
  activeActions = _a.activeActions;
4123
4096
  var measure = props.dimensions.measure;
4124
- var poserApi = __assign$3(__assign$3({}, api), { addChild: function (element, childConfig) {
4097
+ var poserApi = __assign$2(__assign$2({}, api), { addChild: function (element, childConfig) {
4125
4098
  return api._addChild(createPoseConfig(element, childConfig), domPose);
4126
4099
  }, measure: measure, flip: function (op) {
4127
4100
  if (op) {
@@ -4191,7 +4164,7 @@ var pickAssign = function (shouldPick, sources) {
4191
4164
  }, {});
4192
4165
  };
4193
4166
 
4194
- var _a$1 = React.createContext({}), PoseParentConsumer = _a$1.Consumer, PoseParentProvider = _a$1.Provider;
4167
+ var _a = React.createContext({}), PoseParentConsumer = _a.Consumer, PoseParentProvider = _a.Provider;
4195
4168
  var calcPopFromFlowStyle = function (el) {
4196
4169
  var offsetTop = el.offsetTop, offsetLeft = el.offsetLeft, offsetWidth = el.offsetWidth, offsetHeight = el.offsetHeight;
4197
4170
  return {
@@ -11083,7 +11056,7 @@ function useForceUpdate() {
11083
11056
 
11084
11057
  var SyncLayoutContext = React.createContext(null);
11085
11058
 
11086
- var _a$2;
11059
+ var _a$1;
11087
11060
  var StepName;
11088
11061
  (function (StepName) {
11089
11062
  StepName["Prepare"] = "prepare";
@@ -11121,12 +11094,12 @@ var createUseSyncEffect = function (stepName) { return function (callback) {
11121
11094
  jobsNeedProcessing = true;
11122
11095
  jobs[stepName].push(callback);
11123
11096
  }; };
11124
- var layoutSync = (_a$2 = {},
11125
- _a$2[StepName.Prepare] = createUseSyncEffect(StepName.Prepare),
11126
- _a$2[StepName.Read] = createUseSyncEffect(StepName.Read),
11127
- _a$2[StepName.Render] = createUseSyncEffect(StepName.Render),
11128
- _a$2.flush = flushAllJobs,
11129
- _a$2);
11097
+ var layoutSync = (_a$1 = {},
11098
+ _a$1[StepName.Prepare] = createUseSyncEffect(StepName.Prepare),
11099
+ _a$1[StepName.Read] = createUseSyncEffect(StepName.Read),
11100
+ _a$1[StepName.Render] = createUseSyncEffect(StepName.Render),
11101
+ _a$1.flush = flushAllJobs,
11102
+ _a$1);
11130
11103
 
11131
11104
  function isHTMLElement$1(element) {
11132
11105
  return element instanceof HTMLElement;
@@ -14239,24 +14212,19 @@ var fallbackValues$4 = {
14239
14212
  var Alert = function Alert(_ref) {
14240
14213
  var heading = _ref.heading,
14241
14214
  text = _ref.text,
14215
+ textOverride = _ref.textOverride,
14242
14216
  variant = _ref.variant,
14243
14217
  children = _ref.children,
14244
14218
  height = _ref.height,
14245
14219
  onLinkClick = _ref.onLinkClick,
14220
+ _ref$padding = _ref.padding,
14221
+ padding = _ref$padding === void 0 ? "0.5rem" : _ref$padding,
14246
14222
  _ref$showQuitLink = _ref.showQuitLink,
14247
14223
  showQuitLink = _ref$showQuitLink === void 0 ? true : _ref$showQuitLink,
14224
+ maxContentWidth = _ref.maxContentWidth,
14248
14225
  themeValues = _ref.themeValues;
14249
14226
  var Icon = AlertIcons[variant];
14250
- return /*#__PURE__*/React__default.createElement(Box, {
14251
- padding: "0.5rem",
14252
- width: "100%",
14253
- minHeight: "100px",
14254
- height: height ? height : "auto",
14255
- background: themeValues.background,
14256
- borderRadius: "4px",
14257
- borderColor: themeValues.border,
14258
- borderSize: "1px"
14259
- }, /*#__PURE__*/React__default.createElement(Sidebar, {
14227
+ var content = /*#__PURE__*/React__default.createElement(Sidebar, {
14260
14228
  width: "24px",
14261
14229
  childGap: "0rem"
14262
14230
  }, /*#__PURE__*/React__default.createElement(Box, {
@@ -14276,11 +14244,11 @@ var Alert = function Alert(_ref) {
14276
14244
  width: "24px",
14277
14245
  childGap: "0rem"
14278
14246
  }, /*#__PURE__*/React__default.createElement(Box, {
14279
- padding: "1rem"
14247
+ padding: "".concat(padding, " 1rem")
14280
14248
  }, /*#__PURE__*/React__default.createElement(Cluster, {
14281
14249
  justify: "flex-start",
14282
14250
  align: "center"
14283
- }, /*#__PURE__*/React__default.createElement(Stack, {
14251
+ }, textOverride ? textOverride : /*#__PURE__*/React__default.createElement(Stack, {
14284
14252
  fullHeight: true,
14285
14253
  childGap: "0.25rem"
14286
14254
  }, /*#__PURE__*/React__default.createElement(Text$1, {
@@ -14297,7 +14265,19 @@ var Alert = function Alert(_ref) {
14297
14265
  padding: "0",
14298
14266
  minHeight: "100%",
14299
14267
  onClick: onLinkClick
14300
- }, /*#__PURE__*/React__default.createElement(IconQuit, null)))))));
14268
+ }, /*#__PURE__*/React__default.createElement(IconQuit, null))))));
14269
+ return /*#__PURE__*/React__default.createElement(Box, {
14270
+ padding: padding,
14271
+ width: "100%",
14272
+ minHeight: height && parseInt(height) < 100 ? height : "100px",
14273
+ height: height ? height : "auto",
14274
+ background: themeValues.background,
14275
+ borderRadius: "4px",
14276
+ borderColor: themeValues.border,
14277
+ borderSize: "1px"
14278
+ }, maxContentWidth ? /*#__PURE__*/React__default.createElement(Center, {
14279
+ maxWidth: maxContentWidth
14280
+ }, content) : content);
14301
14281
  };
14302
14282
 
14303
14283
  var Alert$1 = themeComponent(Alert, "Alert", fallbackValues$4, "info");
@@ -18077,13 +18057,13 @@ var DisplayCard = function DisplayCard(_ref) {
18077
18057
  variant: "smallGhost",
18078
18058
  dataQa: buttonText,
18079
18059
  extraStyles: "min-width: 0;"
18080
- }) : /*#__PURE__*/React__default.createElement(ButtonWithAction, {
18060
+ }) : buttonAction ? /*#__PURE__*/React__default.createElement(ButtonWithAction, {
18081
18061
  text: buttonText,
18082
18062
  action: buttonAction,
18083
18063
  variant: "smallGhost",
18084
18064
  dataQa: buttonText,
18085
18065
  extraStyles: "min-width: 0;"
18086
- }))))));
18066
+ }) : /*#__PURE__*/React__default.createElement(React.Fragment, null))))));
18087
18067
  };
18088
18068
 
18089
18069
  var src = createCommonjsModule(function (module, exports) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thecb/components",
3
- "version": "3.5.13",
3
+ "version": "3.5.14",
4
4
  "description": "Common lib for CityBase react components",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",
@@ -1,6 +1,6 @@
1
1
  import React from "react";
2
2
  import { AlertIcons, IconQuit } from "../../../deprecated/icons";
3
- import { Box, Cluster, Stack, Cover, Sidebar } from "../layouts";
3
+ import { Box, Center, Cluster, Stack, Cover, Sidebar } from "../layouts";
4
4
  import Text from "../text";
5
5
  import { fallbackValues } from "./Alert.theme";
6
6
  import { themeComponent } from "../../../util/themeUtils";
@@ -8,37 +8,34 @@ import { themeComponent } from "../../../util/themeUtils";
8
8
  const Alert = ({
9
9
  heading,
10
10
  text,
11
+ textOverride,
11
12
  variant,
12
13
  children,
13
14
  height,
14
15
  onLinkClick,
16
+ padding = "0.5rem",
15
17
  showQuitLink = true,
18
+ maxContentWidth,
16
19
  themeValues
17
20
  }) => {
18
21
  const Icon = AlertIcons[variant];
19
- return (
20
- <Box
21
- padding="0.5rem"
22
- width="100%"
23
- minHeight="100px"
24
- height={height ? height : "auto"}
25
- background={themeValues.background}
26
- borderRadius="4px"
27
- borderColor={themeValues.border}
28
- borderSize="1px"
29
- >
30
- <Sidebar width="24px" childGap="0rem">
31
- <Box padding="0 0 0 1rem" minHeight="100%">
32
- <Cover minHeight="100%" singleChild>
33
- <Box padding="0" width="1.5rem" minHeight="1.5rem">
34
- <Icon />
35
- </Box>
36
- </Cover>
37
- </Box>
38
- <Box padding="0">
39
- <Sidebar onRight width="24px" childGap="0rem">
40
- <Box padding="1rem">
41
- <Cluster justify="flex-start" align="center">
22
+
23
+ const content = (
24
+ <Sidebar width="24px" childGap="0rem">
25
+ <Box padding="0 0 0 1rem" minHeight="100%">
26
+ <Cover minHeight="100%" singleChild>
27
+ <Box padding="0" width="1.5rem" minHeight="1.5rem">
28
+ <Icon />
29
+ </Box>
30
+ </Cover>
31
+ </Box>
32
+ <Box padding="0">
33
+ <Sidebar onRight width="24px" childGap="0rem">
34
+ <Box padding={`${padding} 1rem`}>
35
+ <Cluster justify="flex-start" align="center">
36
+ {textOverride ? (
37
+ textOverride
38
+ ) : (
42
39
  <Stack fullHeight childGap="0.25rem">
43
40
  <Text variant="p" color={themeValues.text} weight="600">
44
41
  {heading}
@@ -48,18 +45,37 @@ const Alert = ({
48
45
  </Text>
49
46
  {children}
50
47
  </Stack>
51
- </Cluster>
52
- </Box>
53
- <Cluster justify="flex-end" align="flex-start">
54
- {showQuitLink && (
55
- <Box padding="0" minHeight="100%" onClick={onLinkClick}>
56
- <IconQuit />
57
- </Box>
58
48
  )}
59
49
  </Cluster>
60
- </Sidebar>
61
- </Box>
62
- </Sidebar>
50
+ </Box>
51
+ <Cluster justify="flex-end" align="flex-start">
52
+ {showQuitLink && (
53
+ <Box padding="0" minHeight="100%" onClick={onLinkClick}>
54
+ <IconQuit />
55
+ </Box>
56
+ )}
57
+ </Cluster>
58
+ </Sidebar>
59
+ </Box>
60
+ </Sidebar>
61
+ );
62
+
63
+ return (
64
+ <Box
65
+ padding={padding}
66
+ width="100%"
67
+ minHeight={height && parseInt(height) < 100 ? height : "100px"}
68
+ height={height ? height : "auto"}
69
+ background={themeValues.background}
70
+ borderRadius="4px"
71
+ borderColor={themeValues.border}
72
+ borderSize="1px"
73
+ >
74
+ {maxContentWidth ? (
75
+ <Center maxWidth={maxContentWidth}>{content}</Center>
76
+ ) : (
77
+ content
78
+ )}
63
79
  </Box>
64
80
  );
65
81
  };
@@ -1,4 +1,4 @@
1
- import React from "react";
1
+ import React, { Fragment } from "react";
2
2
  import Stack from "../layouts/Stack";
3
3
  import Box from "../layouts/Box";
4
4
  import Text from "../text";
@@ -48,7 +48,7 @@ const DisplayCard = ({
48
48
  dataQa={buttonText}
49
49
  extraStyles={`min-width: 0;`}
50
50
  />
51
- ) : (
51
+ ) : buttonAction ? (
52
52
  <ButtonWithAction
53
53
  text={buttonText}
54
54
  action={buttonAction}
@@ -56,6 +56,8 @@ const DisplayCard = ({
56
56
  dataQa={buttonText}
57
57
  extraStyles={`min-width: 0;`}
58
58
  />
59
+ ) : (
60
+ <Fragment />
59
61
  )}
60
62
  </Cluster>
61
63
  </Box>
package/.tool-versions DELETED
@@ -1 +0,0 @@
1
- nodejs 10.15.3