@startlibs/components 1.0.0-alpha-7w → 1.0.0-alpha-7x

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 (3) hide show
  1. package/lib/index.js +155 -234
  2. package/package.json +2 -2
  3. package/src/index.js +30 -0
package/lib/index.js CHANGED
@@ -27,11 +27,9 @@ var _objectSpread = _interopDefault(require('@babel/runtime/helpers/objectSpread
27
27
  var _uniqueId = _interopDefault(require('lodash/fp/uniqueId'));
28
28
  var _max = _interopDefault(require('lodash/fp/max'));
29
29
  var _identity = _interopDefault(require('lodash/fp/identity'));
30
- var _ = _interopDefault(require('lodash/fp'));
31
- var _toConsumableArray = _interopDefault(require('@babel/runtime/helpers/toConsumableArray'));
32
- var _typeof = _interopDefault(require('@babel/runtime/helpers/typeof'));
33
- var emotion = require('emotion');
34
30
  var _isString = _interopDefault(require('lodash/fp/isString'));
31
+ var _toConsumableArray = _interopDefault(require('@babel/runtime/helpers/toConsumableArray'));
32
+ var _isObject = _interopDefault(require('lodash/fp/isObject'));
35
33
  var _defineProperty = _interopDefault(require('@babel/runtime/helpers/defineProperty'));
36
34
  var _assertThisInitialized = _interopDefault(require('@babel/runtime/helpers/assertThisInitialized'));
37
35
  var _set = _interopDefault(require('lodash/fp/set'));
@@ -42,6 +40,7 @@ var reactHotLoader = require('react-hot-loader');
42
40
  var _isFunction = _interopDefault(require('lodash/fp/isFunction'));
43
41
  var reactIs = require('react-is');
44
42
  var mitt = _interopDefault(require('mitt'));
43
+ var _typeof = _interopDefault(require('@babel/runtime/helpers/typeof'));
45
44
  var _without = _interopDefault(require('lodash/fp/without'));
46
45
 
47
46
  var IconComponent =
@@ -146,7 +145,7 @@ function _templateObject3() {
146
145
  }
147
146
 
148
147
  function _templateObject2() {
149
- var data = _taggedTemplateLiteral(["\n ", "\n "]);
148
+ var data = _taggedTemplateLiteral(["\n ", "\n ", "\n ", "\n "]);
150
149
 
151
150
  _templateObject2 = function _templateObject2() {
152
151
  return data;
@@ -229,12 +228,14 @@ var Button = styled__default(React__default.forwardRef(function (_ref, ref) {
229
228
  })).withConfig({
230
229
  displayName: "Button",
231
230
  componentId: "qe54pl-1"
232
- })(["vertical-align:top;border:0;font-size:12px;border-radius:", ";background:", ";color:white;min-width:8rem;font-weight:500;display:inline-block;line-height:16px;text-align:center;padding:10px 1.25rem;outline:none;cursor:pointer;position:relative;text-decoration:none;user-select:none;:hover{background:", ";}:active{background:", ";}", " + .styled-button{margin-left:1rem;}", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", ""], function (props) {
231
+ })(["vertical-align:top;border:0;font-size:12px;border-radius:", ";background:", ";color:white;min-width:8rem;font-weight:500;display:inline-block;line-height:16px;text-align:center;padding:10px 1.25rem;outline:none;cursor:pointer;position:relative;text-decoration:none;user-select:none;flex-shrink:0;:hover{background:", ";}:active{background:", ";}", " ", " + .styled-button{margin-left:1rem;}", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", ""], function (props) {
233
232
  return props.rounded ? '100px' : '6px';
234
233
  }, utils.getColor, function (props) {
235
234
  return polished.darken(0.05, utils.getColor(props, true));
236
235
  }, function (props) {
237
236
  return polished.darken(0.08, utils.getColor(props, true));
237
+ }, function (props) {
238
+ return props.nowrap && "\n white-space: nowrap;\n ";
238
239
  }, function (props) {
239
240
  return !props.noFocus && !props.isLoading && styled.css([":focus{", "}", ""], focus, function (props) {
240
241
  return props.focused && focus;
@@ -264,7 +265,11 @@ var Button = styled__default(React__default.forwardRef(function (_ref, ref) {
264
265
  }, function (props) {
265
266
  return props.isLoading && styled.css(["color:transparent !important;pointer-events:none;", "{visibility:hidden;}"], Icon);
266
267
  }, utils.media.mobile(_templateObject2(), function (props) {
267
- return !props.small && styled.css(["padding:13px 1.5rem;font-size:13px;"]);
268
+ return !props.small && !props.onlyIcon && styled.css(["padding:13px 1.5rem;font-size:13px;"]);
269
+ }, function (props) {
270
+ return !props.small && props.onlyIcon && styled.css(["min-width:3.5rem;min-height:3.5rem;"]);
271
+ }, function (props) {
272
+ return props.withDropdown && styled.css(["padding-right:2.5rem;", "{right:14px;}"], DropdownIcon);
268
273
  }), utils.media.max(359)(_templateObject3(), function (props) {
269
274
  return !props.small && !props.onlyIcon && !props.onlyDropdown && styled.css(["min-width:0;"]);
270
275
  }), function (props) {
@@ -322,6 +327,10 @@ function (_React$Component) {
322
327
  value: function componentDidCatch(e, info) {
323
328
  var error = e && e.stack;
324
329
 
330
+ if (e === null || e === void 0 ? void 0 : e.notFound) {
331
+ return;
332
+ }
333
+
325
334
  try {
326
335
  if (!e || !e.stack) {
327
336
  JSON.stringify(e);
@@ -378,190 +387,10 @@ function (_React$Component) {
378
387
  return ErrorBoundary;
379
388
  }(React__default.Component); // StartlibsProvider.registerInternal('ErrorBoundary',ErrorBoundary)
380
389
 
381
- var scrollWidth = function () {
382
- if (!window.document) return 0;
383
- var html = document.documentElement;
384
- var oldOverflow = html.style.overflowY;
385
- html.style.overflowY = 'scroll';
386
- var width = window.innerWidth - html.clientWidth;
387
- html.style.overflowY = oldOverflow;
388
- return width;
389
- }();
390
-
391
- var callIfFunction = function callIfFunction(prop) {
392
- for (var _len6 = arguments.length, args = new Array(_len6 > 1 ? _len6 - 1 : 0), _key6 = 1; _key6 < _len6; _key6++) {
393
- args[_key6 - 1] = arguments[_key6];
394
- }
395
-
396
- return typeof prop === "function" ? prop.apply(void 0, args) : prop;
397
- };
398
- var ifUndefined = function ifUndefined(v) {
399
- for (var _len10 = arguments.length, or = new Array(_len10 > 1 ? _len10 - 1 : 0), _key10 = 1; _key10 < _len10; _key10++) {
400
- or[_key10 - 1] = arguments[_key10];
401
- }
402
-
403
- return v !== undefined ? v : or.length === 1 ? or[0] : ifUndefined.apply(void 0, [or[0]].concat(_toConsumableArray(or.slice(1))));
404
- };
405
- function isMobile() {
406
- var check = false;
407
-
408
- if (typeof navigator === 'undefined') {
409
- return false;
410
- }
411
-
412
- (function (a) {
413
- if (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series([46])0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br([ev])w|bumb|bw-([nu])|c55\/|capi|ccwa|cdm-|cell|chtm|cldc|cmd-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc-s|devi|dica|dmob|do([cp])o|ds(12|-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly([-_])|g1 u|g560|gene|gf-5|g-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd-([mpt])|hei-|hi(pt|ta)|hp( i|ip)|hs-c|ht(c([- _agpst])|tp)|hu(aw|tc)|i-(20|go|ma)|i230|iac([ -/])|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja([tv])a|jbro|jemu|jigs|kddi|keji|kgt([ /])|klon|kpt |kwc-|kyo([ck])|le(no|xi)|lg( g|\/([klu])|50|54|-[a-w])|libw|lynx|m1-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t([- ov])|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30([02])|n50([025])|n7(0([01])|10)|ne(([cm])-|on|tf|wf|wg|wt)|nok([6i])|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan([adt])|pdxg|pg(13|-([1-8]|c))|phil|pire|pl(ay|uc)|pn-2|po(ck|rt|se)|prox|psio|pt-g|qa-a|qc(07|12|21|32|60|-[2-7]|i-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h-|oo|p-)|sdk\/|se(c([-01])|47|mc|nd|ri)|sgh-|shar|sie([-m])|sk-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h-|v-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl-|tdg-|tel(i|m)|tim-|t-mo|to(pl|sh)|ts(70|m-|m3|m5)|tx-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c([- ])|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas-|your|zeto|zte-/i.test(a.substr(0, 4))) check = true;
414
- })(navigator.userAgent || navigator.vendor || window['opera']);
415
-
416
- return check;
417
- }
418
- var normalizeTouch = function normalizeTouch(fn, endFn) {
419
- return function (e) {
420
- var touch = e.touches[0];
421
-
422
- if (e.touches.length > 1 && e.type !== 'touchend') {
423
- callIfFunction(endFn, e, touch);
424
- } else {
425
- callIfFunction(fn, e, touch);
426
- }
427
- };
428
- };
429
- var normalizeMouse = function normalizeMouse(fn, endFn) {
430
- return function (e) {
431
- if (e.buttons > 1 && e.type !== 'mouseup') {
432
- callIfFunction(endFn, e, e);
433
- } else {
434
- callIfFunction(fn, e, e);
435
- }
436
- };
437
- };
438
- var normalizePress = function normalizePress(fn, endFn) {
439
- return function (e) {
440
- if (e.touches) {
441
- normalizeTouch(fn, endFn)(e);
442
- } else {
443
- normalizeMouse(fn, endFn)(e);
444
- }
445
- };
446
- };
447
-
448
390
  function _templateObject$1() {
449
- var data = _taggedTemplateLiteral(["\n ", ""]);
450
-
451
- _templateObject$1 = function _templateObject() {
452
- return data;
453
- };
454
-
455
- return data;
456
- }
457
- var media = function media() {
458
- for (var _len = arguments.length, sizePairs = new Array(_len), _key = 0; _key < _len; _key++) {
459
- sizePairs[_key] = arguments[_key];
460
- }
461
-
462
- return function () {
463
- return styled.css(["@media ", "{", "}"], sizePairs.map(function (_ref4) {
464
- var _ref5 = _slicedToArray(_ref4, 2),
465
- size = _ref5[0],
466
- type = _ref5[1];
467
-
468
- return "(".concat(type, ": ").concat(size + scrollWidth, "px)");
469
- }).join(' and '), styled.css.apply(void 0, arguments));
470
- };
471
- };
472
- media.mobile = media([600, 'max-width']);
473
-
474
- media.between = function (min, max) {
475
- return media([min, 'min-width'], [max, 'max-width']);
476
- };
477
-
478
- media.max = function (n) {
479
- return media([n, 'max-width']);
480
- };
481
-
482
- media.min = function (n) {
483
- return media([n, 'min-width']);
484
- };
485
-
486
- media.desktop = media([601, 'min-width']);
487
-
488
- var getFrameOffset = function getFrameOffset(i, total) {
489
- return Math.round(i * 100 / (total - 1));
490
- };
491
-
492
- var oneWayAnimation = function oneWayAnimation() {
493
- for (var _len2 = arguments.length, frames = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
494
- frames[_key2] = arguments[_key2];
495
- }
496
-
497
- return emotion.keyframes(_templateObject$1(), frames.map(function (frame, i) {
498
- return !frame ? '' : "".concat(getFrameOffset(i, frames.length), "% {\n ").concat(frame, "\n }");
499
- }));
500
- };
501
- var twoWayAnimation = function twoWayAnimation() {
502
- for (var _len3 = arguments.length, frames = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
503
- frames[_key3] = arguments[_key3];
504
- }
505
-
506
- return [frames, _.reverse(frames)].map(function (frames) {
507
- return oneWayAnimation.apply(void 0, _toConsumableArray(frames));
508
- });
509
- };
510
- var identityTranslateFrames = oneWayAnimation('transform: translateY(0);', 'transform: translateY(0);');
511
- var identityOpacityFrames = oneWayAnimation('opacity: 1;', 'opacity:1;');
512
-
513
- var disableSelect = function disableSelect(e) {
514
- e.preventDefault();
515
- };
516
-
517
- var createPressEvent = function createPressEvent(onStart) {
518
- return normalizePress(function (startEvent, info) {
519
- var onEnd = onStart(startEvent, info);
520
- var finish = normalizePress(function (e, info) {
521
- callIfFunction(onEnd, e, info);
522
- window.removeEventListener('selectstart', disableSelect);
523
- window.removeEventListener('touchend', finish);
524
- window.removeEventListener('mouseup', finish);
525
- });
526
- window.addEventListener('selectstart', disableSelect);
527
-
528
- if (startEvent.touches) {
529
- window.addEventListener('touchend', finish);
530
- } else {
531
- window.addEventListener("mouseup", finish);
532
- }
533
- });
534
- };
535
- var createPressAndMoveEvent = function createPressAndMoveEvent(onStart) {
536
- return createPressEvent(function (startEvent, info) {
537
- var _concat3 = [].concat(onStart(startEvent, info)),
538
- _concat4 = _slicedToArray(_concat3, 2),
539
- onMove = _concat4[0],
540
- onEnd = _concat4[1];
541
-
542
- var finish = normalizePress(function (e, info) {
543
- callIfFunction(onEnd, e, info);
544
- window.removeEventListener('touchmove', move);
545
- window.removeEventListener('mousemove', move);
546
- });
547
- var move = normalizePress(onMove, finish);
548
-
549
- if (startEvent.touches) {
550
- window.addEventListener('touchmove', move, {
551
- passive: false
552
- });
553
- } else {
554
- window.addEventListener("mousemove", move);
555
- }
556
-
557
- return finish;
558
- });
559
- };
560
-
561
- function _templateObject$2() {
562
391
  var data = _taggedTemplateLiteral(["test"]);
563
392
 
564
- _templateObject$2 = function _templateObject() {
393
+ _templateObject$1 = function _templateObject() {
565
394
  return data;
566
395
  };
567
396
 
@@ -682,7 +511,7 @@ var defaultSwitchAnimation = utils.oneWayAnimation("opacity: 1;", "opacity: 0;",
682
511
  var SHORT_ANIMATIONS = {
683
512
  fadeIn: defaultEnterAnimation
684
513
  };
685
- var b = styled.createGlobalStyle(_templateObject$2());
514
+ var b = styled.createGlobalStyle(_templateObject$1());
686
515
 
687
516
  var applyDefault = function applyDefault(k) {
688
517
  return SHORT_ANIMATIONS[k] || k;
@@ -1322,8 +1151,8 @@ var _willUseFlip = willUseFlip(),
1322
1151
  var useFlipAnimation = function useFlipAnimation(ref, onEnterOrBoth) {
1323
1152
  var onLeaveOrIgnore = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
1324
1153
  var config = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
1325
- var onEnter = ifUndefined(onEnterOrBoth && onEnterOrBoth.onEnter, onEnterOrBoth);
1326
- var onLeave = ifUndefined(onEnterOrBoth && onEnterOrBoth.onLeave, onLeaveOrIgnore);
1154
+ var onEnter = utils.ifUndefined(onEnterOrBoth && onEnterOrBoth.onEnter, onEnterOrBoth);
1155
+ var onLeave = utils.ifUndefined(onEnterOrBoth && onEnterOrBoth.onLeave, onLeaveOrIgnore);
1327
1156
  useFlipEnter(ref, onEnter, config);
1328
1157
  useFlipLeave(ref, onLeave === true ? onEnter : onLeave, _objectSpread({}, config, {
1329
1158
  reverse: onLeave === true
@@ -1340,10 +1169,10 @@ function _templateObject2$1() {
1340
1169
  return data;
1341
1170
  }
1342
1171
 
1343
- function _templateObject$3() {
1172
+ function _templateObject$2() {
1344
1173
  var data = _taggedTemplateLiteral(["\n padding: ", ";\n "]);
1345
1174
 
1346
- _templateObject$3 = function _templateObject() {
1175
+ _templateObject$2 = function _templateObject() {
1347
1176
  return data;
1348
1177
  };
1349
1178
 
@@ -1368,7 +1197,7 @@ var DialogCenter = styled__default.div.withConfig({
1368
1197
  componentId: "wendlg-2"
1369
1198
  })(["@supports (position:sticky){will-change:transform,opacity;&.JS-wc-off{will-change:auto;}}display:-webkit-box;display:-ms-flexbox;display:flex;overflow-y:", ";overflow-x:hidden;position:fixed;top:0;bottom:0;left:0;right:0;align-items:center;", " ", ""], function (props) {
1370
1199
  return props.withScroll ? "scroll" : "hidden";
1371
- }, utils.media.desktop(_templateObject$3(), function (props) {
1200
+ }, utils.media.desktop(_templateObject$2(), function (props) {
1372
1201
  return props.fullscreen ? '1rem' : '3rem 0.5rem;';
1373
1202
  }), utils.media.mobile(_templateObject2$1(), function (props) {
1374
1203
  return props.fullscreenOnMobile ? '0' : '0.5rem';
@@ -1789,10 +1618,10 @@ function _templateObject2$2() {
1789
1618
  return data;
1790
1619
  }
1791
1620
 
1792
- function _templateObject$4() {
1621
+ function _templateObject$3() {
1793
1622
  var data = _taggedTemplateLiteral(["\n display: flex;\n flex-wrap: nowrap;\n margin-left: -", "rem;\n margin-right: -", "rem;\n margin-top: -", "rem;\n > * {\n flex-basis: 0;\n flex-grow: 1;\n margin-left: ", "rem;\n margin-right: ", "rem;\n margin-top: ", "rem;\n }\n "]);
1794
1623
 
1795
- _templateObject$4 = function _templateObject() {
1624
+ _templateObject$3 = function _templateObject() {
1796
1625
  return data;
1797
1626
  };
1798
1627
 
@@ -1818,7 +1647,7 @@ var SplitColumnsContainer = styled__default.div.withConfig({
1818
1647
  displayName: "SplitColumnsContainer",
1819
1648
  componentId: "sc-1h4sw88-0"
1820
1649
  })(["margin-bottom:", "rem;", " ", ""], getMarginFromFieldChild, function (props) {
1821
- return styled.css(["", ""], utils.media.min(props.viewportMinWidth || 0)(_templateObject$4(), function (props) {
1650
+ return styled.css(["", ""], utils.media.min(props.viewportMinWidth || 0)(_templateObject$3(), function (props) {
1822
1651
  return utils.getMargin(splitColumnMargins)(props) / 2;
1823
1652
  }, function (props) {
1824
1653
  return utils.getMargin(splitColumnMargins)(props) / 2;
@@ -2013,10 +1842,10 @@ function _templateObject2$3() {
2013
1842
  return data;
2014
1843
  }
2015
1844
 
2016
- function _templateObject$5() {
1845
+ function _templateObject$4() {
2017
1846
  var data = _taggedTemplateLiteral(["\n top: 0\n "]);
2018
1847
 
2019
- _templateObject$5 = function _templateObject() {
1848
+ _templateObject$4 = function _templateObject() {
2020
1849
  return data;
2021
1850
  };
2022
1851
 
@@ -2025,7 +1854,7 @@ function _templateObject$5() {
2025
1854
  var DialogIcon = styled__default(Icon).withConfig({
2026
1855
  displayName: "Dialog__DialogIcon",
2027
1856
  componentId: "gai4ey-0"
2028
- })(["font-size:60px;width:8rem;text-align:center;color:#d2d2d2;right:0;top:1rem;position:absolute;", ""], utils.media.desktop(_templateObject$5()));
1857
+ })(["font-size:60px;width:8rem;text-align:center;color:#d2d2d2;right:0;top:1rem;position:absolute;", ""], utils.media.desktop(_templateObject$4()));
2029
1858
  var CloseIcon = styled__default(Icon).attrs(_assign({
2030
1859
  icon: 'x'
2031
1860
  })).withConfig({
@@ -2075,6 +1904,7 @@ var DialogAlwaysVisibleDiv = styled__default.div.withConfig({
2075
1904
  var Dialog = styled__default(React__default.forwardRef(function (_ref, outerRef) {
2076
1905
  var className = _ref.className,
2077
1906
  skipWrap = _ref.skipWrap,
1907
+ skipCloseIcon = _ref.skipCloseIcon,
2078
1908
  isLoading = _ref.isLoading,
2079
1909
  footer = _ref.footer,
2080
1910
  Content = _ref.Content,
@@ -2085,12 +1915,12 @@ var Dialog = styled__default(React__default.forwardRef(function (_ref, outerRef)
2085
1915
  auxiliarActions = _ref.auxiliarActions,
2086
1916
  _ref$container = _ref.container,
2087
1917
  container = _ref$container === void 0 ? true : _ref$container,
2088
- props = _objectWithoutProperties(_ref, ["className", "skipWrap", "isLoading", "footer", "Content", "children", "title", "illustration", "icon", "auxiliarActions", "container"]);
1918
+ props = _objectWithoutProperties(_ref, ["className", "skipWrap", "skipCloseIcon", "isLoading", "footer", "Content", "children", "title", "illustration", "icon", "auxiliarActions", "container"]);
2089
1919
 
2090
1920
  var ref = core.useEnsureRef(outerRef);
2091
1921
 
2092
1922
  var alwaysVisible = function alwaysVisible(confirmCloseDialog) {
2093
- return React__default.createElement(React__default.Fragment, null, props.closeDialog && React__default.createElement(CloseIcon, {
1923
+ return React__default.createElement(React__default.Fragment, null, props.closeDialog && !skipCloseIcon && React__default.createElement(CloseIcon, {
2094
1924
  className: "JS-dialog-close",
2095
1925
  onClick: confirmCloseDialog
2096
1926
  }), title && React__default.createElement(DialogTitle, null, utils.callIfFunction(title)));
@@ -2190,6 +2020,78 @@ var DialogError = function DialogError(_ref6) {
2190
2020
  });
2191
2021
  };
2192
2022
 
2023
+ var useDialog = function useDialog(dialog) {
2024
+ var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
2025
+ var toggleCallback = arguments.length > 2 ? arguments[2] : undefined;
2026
+ var toggle = core.useToggle(false, toggleCallback);
2027
+ core.useFill("Dialog", toggle.isOpen !== false && dialog(toggle.close), [toggle.isOpen].concat(_toConsumableArray(args)));
2028
+ return toggle.open;
2029
+ };
2030
+ var useDialogWithToggle = function useDialogWithToggle(dialog) {
2031
+ var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
2032
+ var toggle = core.useToggle();
2033
+ core.useFill("Dialog", toggle.isOpen !== false && dialog(toggle), [toggle.isOpen].concat(_toConsumableArray(args)));
2034
+ return toggle;
2035
+ };
2036
+
2037
+ var WarningDialog = styled__default(function (_ref) {
2038
+ var content = _ref.content,
2039
+ closeDialog = _ref.closeDialog,
2040
+ className = _ref.className,
2041
+ _ref$icon = _ref.icon,
2042
+ icon = _ref$icon === void 0 ? "warning" : _ref$icon,
2043
+ _ref$confirmLabel = _ref.confirmLabel,
2044
+ confirmLabel = _ref$confirmLabel === void 0 ? "Entendi" : _ref$confirmLabel;
2045
+ return React__default.createElement(Dialog, {
2046
+ className: className
2047
+ }, React__default.createElement(MainIcon, {
2048
+ icon: icon
2049
+ }), React__default.createElement("p", null, content), React__default.createElement(Button, {
2050
+ highlight: true,
2051
+ onClick: closeDialog
2052
+ }, confirmLabel));
2053
+ }).withConfig({
2054
+ displayName: "WarningDialog",
2055
+ componentId: "sc-1jw779e-0"
2056
+ })(["text-align:center;max-width:36rem;padding:2.5rem;p{font-size:16px;font-weight:500;max-width:27rem;margin:0 auto 2rem;}"]);
2057
+ var MainIcon = styled__default(Icon).withConfig({
2058
+ displayName: "WarningDialog__MainIcon",
2059
+ componentId: "sc-1jw779e-1"
2060
+ })(["color:", ";font-size:46px;display:block;margin-bottom:1.25rem;"], function (props) {
2061
+ return props.icon === 'warning' ? utils.getColor('alert') : utils.getColor('main');
2062
+ });
2063
+ var useWarningDialog = function useWarningDialog() {
2064
+ return useDialogWithToggle(function (toggle) {
2065
+ return React__default.createElement(WarningDialog, _extends({}, toggle.isOpen, {
2066
+ closeDialog: toggle.close
2067
+ }));
2068
+ });
2069
+ };
2070
+
2071
+ var _willUseSharedState = core.willUseSharedState(),
2072
+ _willUseSharedState2 = _slicedToArray(_willUseSharedState, 3),
2073
+ useRenderDefaultWarningDialog = _willUseSharedState2[0],
2074
+ _setWarningDialog = _willUseSharedState2[2];
2075
+
2076
+ var setWarningDialog = function setWarningDialog(props) {
2077
+ return _setWarningDialog(React__default.createElement(WarningDialog, _extends({}, props, {
2078
+ closeDialog: function closeDialog() {
2079
+ return _setWarningDialog(null);
2080
+ }
2081
+ })));
2082
+ };
2083
+ var DefaultWarningDialog = function DefaultWarningDialog() {
2084
+ var _useRenderDefaultWarn = useRenderDefaultWarningDialog(),
2085
+ _useRenderDefaultWarn2 = _slicedToArray(_useRenderDefaultWarn, 1),
2086
+ warningDialog = _useRenderDefaultWarn2[0];
2087
+
2088
+ if (warningDialog) {
2089
+ return warningDialog;
2090
+ }
2091
+
2092
+ return null;
2093
+ };
2094
+
2193
2095
  var NotificationContainer = styled__default.div.withConfig({
2194
2096
  displayName: "Notifications__NotificationContainer",
2195
2097
  componentId: "naxsn6-0"
@@ -2197,13 +2099,15 @@ var NotificationContainer = styled__default.div.withConfig({
2197
2099
  var Notification = styled__default.div.withConfig({
2198
2100
  displayName: "Notifications__Notification",
2199
2101
  componentId: "naxsn6-1"
2200
- })(["padding:1rem 3.5rem 1rem 1rem;border-radius:5px;color:white;text-align:left;line-height:20px;background:", ";box-shadow:0 2px 0px 0px rgba(0,0,0,0.25);min-width:12rem;min-height:44px;display:inline-block;position:relative;top:1rem;", "{color:white;display:inline-block;background-color:rgba(0,0,0,0.2);font-size:14px;width:20px;height:20px;text-align:center;line-height:20px;border-radius:50%;cursor:pointer;position:absolute;top:1rem;right:1rem;&:hover{background-color:rgba(0,0,0,0.3);}}"], utils.getColor('success'), Icon);
2102
+ })(["padding:1rem 3.5rem 1rem 1rem;border-radius:5px;color:white;text-align:left;line-height:20px;background:", ";box-shadow:0 2px 0px 0px rgba(0,0,0,0.25);min-width:12rem;min-height:44px;display:inline-block;position:relative;top:1rem;", "{color:white;display:inline-block;background-color:rgba(0,0,0,0.2);font-size:14px;width:20px;height:20px;text-align:center;line-height:20px;border-radius:50%;cursor:pointer;position:absolute;top:1rem;right:1rem;&:hover{background-color:rgba(0,0,0,0.3);}}"], function (props) {
2103
+ return utils.getColor(props.type)(props);
2104
+ }, Icon);
2201
2105
 
2202
- var _willUseSharedState = core.willUseSharedState(),
2203
- _willUseSharedState2 = _slicedToArray(_willUseSharedState, 3),
2204
- useNotification = _willUseSharedState2[0],
2205
- useNotificationRef = _willUseSharedState2[1],
2206
- setNotification = _willUseSharedState2[2];
2106
+ var _willUseSharedState$1 = core.willUseSharedState(),
2107
+ _willUseSharedState2$1 = _slicedToArray(_willUseSharedState$1, 3),
2108
+ useNotification = _willUseSharedState2$1[0],
2109
+ useNotificationRef = _willUseSharedState2$1[1],
2110
+ setNotification = _willUseSharedState2$1[2];
2207
2111
  var willSetNotification = function willSetNotification(str) {
2208
2112
  return function () {
2209
2113
  return setNotification(str);
@@ -2215,15 +2119,24 @@ var Notifications = function Notifications() {
2215
2119
 
2216
2120
  var _useNotification = useNotification(),
2217
2121
  _useNotification2 = _slicedToArray(_useNotification, 2),
2218
- notification = _useNotification2[0],
2122
+ rawNotification = _useNotification2[0],
2219
2123
  setNotification = _useNotification2[1];
2220
2124
 
2125
+ var _ref = _isObject(rawNotification) ? rawNotification : {
2126
+ type: "success",
2127
+ msg: rawNotification
2128
+ },
2129
+ msg = _ref.msg,
2130
+ type = _ref.type,
2131
+ _ref$timeout = _ref.timeout,
2132
+ timeout = _ref$timeout === void 0 ? 5000 : _ref$timeout;
2133
+
2221
2134
  React.useEffect(function () {
2222
- if (notification) {
2135
+ if (msg) {
2223
2136
  toggle.open();
2224
- setTimeout(toggle.willCloseAfter(5000), 100);
2137
+ setTimeout(toggle.willCloseAfter(timeout), 100);
2225
2138
  }
2226
- }, [notification]);
2139
+ }, [msg]);
2227
2140
  React.useEffect(function () {
2228
2141
  if (!toggle.isOpen) {
2229
2142
  setNotification(null);
@@ -2231,7 +2144,9 @@ var Notifications = function Notifications() {
2231
2144
  }, [toggle.isOpen]);
2232
2145
  return toggle.isOpen && React__default.createElement(core.Fill, {
2233
2146
  name: "Notifications"
2234
- }, React__default.createElement(FlipNotification, null, notification, React__default.createElement(Icon, {
2147
+ }, React__default.createElement(FlipNotification, {
2148
+ type: type
2149
+ }, utils.callIfFunction(msg, toggle.close), React__default.createElement(Icon, {
2235
2150
  icon: "x",
2236
2151
  onClick: toggle.close
2237
2152
  })));
@@ -2666,11 +2581,11 @@ function (_React$Component) {
2666
2581
  var rectAnimation = getClientRectAnimation(oldSnap.parent, newSnap.parent, {
2667
2582
  skipTransform: true
2668
2583
  });
2669
- var endEffect = callIfFunction(effect, newSnap.parent.domNode, {
2584
+ var endEffect = utils.callIfFunction(effect, newSnap.parent.domNode, {
2670
2585
  newSnap: newSnap,
2671
2586
  oldSnap: oldSnap
2672
2587
  });
2673
- callIfFunction(onStartAnimation);
2588
+ utils.callIfFunction(onStartAnimation);
2674
2589
  morph(newSnap.parent.domNode, formatAnimation(rectAnimation, timing), endEffect || onEndAnimation);
2675
2590
  };
2676
2591
 
@@ -3991,10 +3906,10 @@ function _templateObject2$4() {
3991
3906
  return data;
3992
3907
  }
3993
3908
 
3994
- function _templateObject$6() {
3909
+ function _templateObject$5() {
3995
3910
  var data = _taggedTemplateLiteral(["\n font-size: 14px;\n & > * {\n padding-top: 15px;\n padding-bottom: 15px;\n }\n ", ", .icon {\n font-size: 25px;\n }\n "]);
3996
3911
 
3997
- _templateObject$6 = function _templateObject() {
3912
+ _templateObject$5 = function _templateObject() {
3998
3913
  return data;
3999
3914
  };
4000
3915
 
@@ -4009,7 +3924,7 @@ var popupAnimation = utils.animationTiming('0.2s ease-out');
4009
3924
  var ListItem = styled__default.li.withConfig({
4010
3925
  displayName: "ContextMenu__ListItem",
4011
3926
  componentId: "sc-13y1vvt-0"
4012
- })(["position:relative;font-size:12px;& > *{padding:11px 1.5rem 11px 3.5rem;display:block;}", ",.icon{font-size:23px;position:absolute;padding-left:0.25rem;left:0;top:50%;transform:translateY(-50%);width:3.5rem;text-align:center;}", " & > a{color:inherit;font-weight:inherit;text-decoration:inherit;}& > a,& > label{cursor:pointer;}", " ", " input[type=\"radio\"]{display:none;}", " ", " ", " ", ""], Icon, utils.media.mobile(_templateObject$6(), Icon), utils.ifProp('hover', styled.css(["& > a,& > label{background:", ";color:", ";color:", ";}"], function (props) {
3927
+ })(["position:relative;font-size:13px;& > *{padding:11px 1.5rem 11px 3.5rem;display:block;}", ",.icon{font-size:23px;position:absolute;padding-left:0.25rem;left:0;top:50%;transform:translateY(-50%);width:3.5rem;text-align:center;}", " & > a{color:inherit;font-weight:inherit;text-decoration:inherit;}& > a,& > label{cursor:pointer;}", " ", " input[type=\"radio\"]{display:none;}", " ", " ", " ", ""], Icon, utils.media.mobile(_templateObject$5(), Icon), utils.ifProp('hover', styled.css(["& > a,& > label{background:", ";color:", ";color:", ";}"], function (props) {
4013
3928
  return polished.lighten(0.53, utils.getColor("main")(props));
4014
3929
  }, utils.getColor('main'), function (props) {
4015
3930
  return polished.darken(0.03, utils.getColor("main")(props));
@@ -4245,7 +4160,7 @@ var Li = function Li(_ref) {
4245
4160
  };
4246
4161
  }, []);
4247
4162
  React.useEffect(function () {
4248
- if (children && !isMobile()) {
4163
+ if (children && !utils.isMobile()) {
4249
4164
  if (hover) {
4250
4165
  if (!subMenu.isOpen || subMenu.closing || !subPrevented.get()) {
4251
4166
  subMenu.open();
@@ -4333,9 +4248,9 @@ var _willUseLayers$1 = core.willUseLayers(),
4333
4248
 
4334
4249
  var contextMenuLayersQuantity = contextMenuLayersSize;
4335
4250
 
4336
- var _willUseSharedState$1 = core.willUseSharedState(),
4337
- _willUseSharedState2$1 = _slicedToArray(_willUseSharedState$1, 1),
4338
- useContextMenuSharedState = _willUseSharedState2$1[0];
4251
+ var _willUseSharedState$2 = core.willUseSharedState(),
4252
+ _willUseSharedState2$2 = _slicedToArray(_willUseSharedState$2, 1),
4253
+ useContextMenuSharedState = _willUseSharedState2$2[0];
4339
4254
 
4340
4255
  var ContextMenuComponent = React.forwardRef(function (_ref2, unesuredRef) {
4341
4256
  var children = _ref2.children,
@@ -4452,7 +4367,7 @@ var ContextMenuComponent = React.forwardRef(function (_ref2, unesuredRef) {
4452
4367
  });
4453
4368
  };
4454
4369
 
4455
- var touchStart = createPressAndMoveEvent(function (e, prevPos) {
4370
+ var touchStart = utils.createPressAndMoveEvent(function (e, prevPos) {
4456
4371
  // e.preventDefault()
4457
4372
  e.stopPropagation();
4458
4373
  e.target.dispatchEvent(new MouseEvent('mousemove', {
@@ -4896,7 +4811,7 @@ var BlockContainer$2 = styled__default.div.withConfig({
4896
4811
  componentId: "htfwpl-0"
4897
4812
  })(["position:relative;"]);
4898
4813
 
4899
- var _twoWayAnimation$4 = twoWayAnimation('opacity: 0;', 'opacity: 0;', 'opacity: 1;'),
4814
+ var _twoWayAnimation$4 = utils.twoWayAnimation('opacity: 0;', 'opacity: 0;', 'opacity: 1;'),
4900
4815
  _twoWayAnimation2$4 = _slicedToArray(_twoWayAnimation$4, 2),
4901
4816
  fadeIn$3 = _twoWayAnimation2$4[0],
4902
4817
  relativeFadeout = _twoWayAnimation2$4[1];
@@ -4941,7 +4856,7 @@ var SwitchContainer = function SwitchContainer(_ref2) {
4941
4856
  return React__default.createElement(BlockContainer$2, {
4942
4857
  ref: contentRef,
4943
4858
  className: className
4944
- }, callIfFunction(children));
4859
+ }, utils.callIfFunction(children));
4945
4860
  };
4946
4861
 
4947
4862
  var TOP_TRIGGER = function TOP_TRIGGER(posInfo, refInfo) {
@@ -5070,14 +4985,14 @@ var willUseIsSticky = function willUseIsSticky() {
5070
4985
 
5071
4986
  if (value !== undefined) {
5072
4987
  setIsSticky(value);
5073
- callIfFunction(onChange, value);
4988
+ utils.callIfFunction(onChange, value);
5074
4989
  setSharedIsSticky(value);
5075
4990
  }
5076
4991
  }
5077
4992
  });
5078
4993
  React.useEffect(function () {
5079
4994
  setIsSticky(false);
5080
- getObserver(callIfFunction(root)).observe(ensuredRef.current);
4995
+ getObserver(utils.callIfFunction(root)).observe(ensuredRef.current);
5081
4996
  activeObserved = activeObserved.concat(ensuredRef.current);
5082
4997
  return function () {
5083
4998
  // observer.unobserve(ref.current)
@@ -5152,10 +5067,10 @@ var Image = React.forwardRef(function (_ref, ref) {
5152
5067
  }));
5153
5068
  });
5154
5069
 
5155
- function _templateObject$7() {
5156
- var data = _taggedTemplateLiteral(["\n @supports (position: sticky) {\n top: 0;\n margin: -0.75rem;\n }\n "]);
5070
+ function _templateObject$6() {
5071
+ var data = _taggedTemplateLiteral(["\n @supports (position: sticky) {\n top: 0;\n margin-right: -0.75rem;\n }\n "]);
5157
5072
 
5158
- _templateObject$7 = function _templateObject() {
5073
+ _templateObject$6 = function _templateObject() {
5159
5074
  return data;
5160
5075
  };
5161
5076
 
@@ -5164,7 +5079,7 @@ function _templateObject$7() {
5164
5079
  var DialogWithImageHeader = styled__default(Dialog).withConfig({
5165
5080
  displayName: "DialogWithImageHeader",
5166
5081
  componentId: "sc-1f1ry4g-0"
5167
- })(["max-width:51rem;", "{background:", ";text-shadow:none;color:rgba(120,120,120,1);font-size:20px;box-shadow:rgba(0,0,0,0.2) 0px 1px 3px 0px,rgba(0,0,0,0.05) 0px 0px 0px 1px;width:36px;height:36px;line-height:36px;transition:0.1s ease-out;:hover{background-color:rgb(230,230,230);}:active{background-color:rgb(220,220,220);transition:0s ease-out;}@supports (position:sticky){position:sticky;top:-2.5rem;right:0rem;float:right;margin:-1.25rem;}", "}"], CloseIcon, utils.getColor('gray240'), utils.media.mobile(_templateObject$7()));
5082
+ })(["max-width:51rem;", "{background:", ";text-shadow:none;color:rgba(120,120,120,1);font-size:20px;box-shadow:rgba(0,0,0,0.2) 0px 1px 3px 0px,rgba(0,0,0,0.05) 0px 0px 0px 1px;width:36px;height:36px;line-height:36px;transition:0.1s ease-out;:hover{background-color:rgb(230,230,230);}:active{background-color:rgb(220,220,220);transition:0s ease-out;}@supports (position:sticky){position:sticky;top:-2.5rem;right:0rem;float:right;margin-right:-1.25rem;margin-top:0.75rem;}", "}"], CloseIcon, utils.getColor('gray240'), utils.media.mobile(_templateObject$6()));
5168
5083
 
5169
5084
  function _templateObject2$5() {
5170
5085
  var data = _taggedTemplateLiteral(["\n min-height: 100%;\n overflow: hidden;\n "]);
@@ -5176,10 +5091,10 @@ function _templateObject2$5() {
5176
5091
  return data;
5177
5092
  }
5178
5093
 
5179
- function _templateObject$8() {
5094
+ function _templateObject$7() {
5180
5095
  var data = _taggedTemplateLiteral(["\n display:block;\n position:fixed;\n top:0;\n left:0;\n bottom:0;\n z-index:1000;\n transition: 0.25s transform ease-out;\n background-color: ", ";\n box-shadow: -5px 0 20px 5px rgba(0,0,0,0.4);\n border-radius: 0;\n ", "\n "]);
5181
5096
 
5182
- _templateObject$8 = function _templateObject() {
5097
+ _templateObject$7 = function _templateObject() {
5183
5098
  return data;
5184
5099
  };
5185
5100
 
@@ -5190,7 +5105,7 @@ var SideMenu = styled__default.div.withConfig({
5190
5105
  componentId: "suvg9r-0"
5191
5106
  })(["background-color:", ";border-top-left-radius:10px;border-bottom-left-radius:10px;width:19rem;flex-shrink:0;padding:1.25rem 0;", " ", ""], utils.getColor('gray240'), function (props) {
5192
5107
  return !props.visibleOnDesktop && 'display:none;';
5193
- }, utils.media.mobile(_templateObject$8(), utils.getColor('gray240'), function (props) {
5108
+ }, utils.media.mobile(_templateObject$7(), utils.getColor('gray240'), function (props) {
5194
5109
  return !props.isOpen && "\n transform: translateX(-100%);\n box-shadow: none;\n ";
5195
5110
  }));
5196
5111
  var DialogTabMenu = styled__default.ul.withConfig({
@@ -5329,6 +5244,7 @@ exports.ContextMenu = ContextMenu;
5329
5244
  exports.ContextMenuComponent = ContextMenuComponent;
5330
5245
  exports.DefaultArrow = DefaultArrow;
5331
5246
  exports.DefaultConfirmDialog = DefaultConfirmDialog;
5247
+ exports.DefaultWarningDialog = DefaultWarningDialog;
5332
5248
  exports.Dialog = Dialog;
5333
5249
  exports.DialogContainer = DialogContainer;
5334
5250
  exports.DialogContent = DialogContent;
@@ -5376,6 +5292,7 @@ exports.StickyContainer = StickyContainer;
5376
5292
  exports.SwitchDiv = SwitchDiv;
5377
5293
  exports.Tooltip = Tooltip;
5378
5294
  exports.TransitionDiv = TransitionDiv;
5295
+ exports.WarningDialog = WarningDialog;
5379
5296
  exports.addPositioningBound = addPositioningBound;
5380
5297
  exports.contextMenuLayersQuantity = contextMenuLayersQuantity;
5381
5298
  exports.defaultAnimationMaker = defaultAnimationMaker;
@@ -5390,8 +5307,11 @@ exports.morph = morph;
5390
5307
  exports.preventDialogPop = preventDialogPop;
5391
5308
  exports.removeWindowScroll = removeWindowScroll;
5392
5309
  exports.setNotification = setNotification;
5310
+ exports.setWarningDialog = setWarningDialog;
5393
5311
  exports.toPosition = toPosition;
5312
+ exports.useDialog = useDialog;
5394
5313
  exports.useDialogLayers = useDialogLayers;
5314
+ exports.useDialogWithToggle = useDialogWithToggle;
5395
5315
  exports.useFlip = useFlip;
5396
5316
  exports.useFlipAnimation = useFlipAnimation;
5397
5317
  exports.useFlipEnter = useFlipEnter;
@@ -5399,6 +5319,7 @@ exports.useFlipLeave = useFlipLeave;
5399
5319
  exports.useNotification = useNotification;
5400
5320
  exports.useNotificationRef = useNotificationRef;
5401
5321
  exports.usePositioning = usePositioning;
5322
+ exports.useWarningDialog = useWarningDialog;
5402
5323
  exports.waitForPop = waitForPop;
5403
5324
  exports.willSetNotification = willSetNotification;
5404
5325
  exports.willUseFlip = willUseFlip;
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@startlibs/components",
3
- "version": "1.0.0-alpha-7w",
3
+ "version": "1.0.0-alpha-7x",
4
4
  "description": "Startlibs Components",
5
- "main": "lib/index.js",
5
+ "main": "src/index.js",
6
6
  "sideEffects": false,
7
7
  "source": true,
8
8
  "peerDependencies": {
package/src/index.js ADDED
@@ -0,0 +1,30 @@
1
+ export * from './Button'
2
+ export * from './Dialog'
3
+ export * from './useDialogWithToggle'
4
+ export * from './WarningDialog'
5
+ export * from './Notifications'
6
+ export * from './containers/usePositioning'
7
+ export * from './containers/Reposition'
8
+ export * from './containers/DialogContainer'
9
+ export * from './Draggable'
10
+ export * from './Icon'
11
+ export * from './Tooltip'
12
+ export * from './Loading'
13
+ export * from './SplitColumnsContainer'
14
+ export * from './ContextMenu'
15
+ export * from './ErrorBoundary'
16
+ export * from './Popup'
17
+ export * from './PageLoader'
18
+ export * from './FillLastLineResizer'
19
+ export * from './Flip'
20
+ export * from './FlipList'
21
+ export * from './TransitionDiv'
22
+ export * from './LoadingDiv'
23
+ export * from './SwitchDiv'
24
+ export * from './willUseIsSticky'
25
+ export * from './FormatDate'
26
+ export * from './Image'
27
+ export * from './alt/dialogs/DialogWithImageHeader'
28
+ export * from './alt/dialogs/DialogWithSidebar'
29
+ export * from './alt/dialogs/MobileBubbleDialog'
30
+ export * from './Link'