@loja-integrada/admin-components 0.9.8 → 0.12.0

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.
@@ -210,6 +210,14 @@ var CreditCard = function CreditCard() {
210
210
  });
211
211
  };
212
212
 
213
+ var Download = function Download() {
214
+ return React.createElement("path", {
215
+ fillRule: "evenodd",
216
+ d: "M14.667 11.556v2.666c0 .246-.2.445-.445.445H1.778a.445.445 0 0 1-.445-.445v-2.666H0v2.666C0 15.204.796 16 1.778 16h12.444c.982 0 1.778-.796 1.778-1.778v-2.666h-1.333ZM3.109 7.607a.668.668 0 0 1 .893-.992l3.331 3V0h1.334v9.614l3.331-2.999a.668.668 0 0 1 .893.992l-4.445 4a.667.667 0 0 1-.892 0l-4.445-4Z",
217
+ clipRule: "evenodd"
218
+ });
219
+ };
220
+
213
221
  var Product = function Product() {
214
222
  return React.createElement("path", {
215
223
  fillRule: "evenodd",
@@ -242,6 +250,14 @@ var Eye = function Eye() {
242
250
  });
243
251
  };
244
252
 
253
+ var ExclamationCircle = function ExclamationCircle() {
254
+ return React.createElement("path", {
255
+ fillRule: "evenodd",
256
+ d: "M9 10.5A1.25 1.25 0 1 0 9 13a1.25 1.25 0 0 0 0-2.5Zm-.303-1h.605a.5.5 0 0 0 .497-.445l.328-2.945A1 1 0 0 0 9.132 5h-.266a1 1 0 0 0-.993 1.11L8.2 9.055a.5.5 0 0 0 .497.445Zm.303 7c-4.136 0-7.5-3.364-7.5-7.5S4.864 1.5 9 1.5s7.5 3.364 7.5 7.5-3.364 7.5-7.5 7.5ZM9 0a9 9 0 0 0-9 9 9 9 0 0 0 9 9 9 9 0 0 0 9-9 9 9 0 0 0-9-9Z",
257
+ clipRule: "evenodd"
258
+ });
259
+ };
260
+
245
261
  var ExclamationTriangle = function ExclamationTriangle() {
246
262
  return React.createElement("path", {
247
263
  fillRule: "evenodd",
@@ -342,6 +358,14 @@ var InfoCircle = function InfoCircle() {
342
358
  });
343
359
  };
344
360
 
361
+ var Link = function Link() {
362
+ return React.createElement("path", {
363
+ fillRule: "evenodd",
364
+ clipRule: "evenodd",
365
+ d: "M10.5645 7.44624c-.301-.301-.78701-.301-1.08701 0-.301.301-.301.787 0 1.088l.74501.747c.34.34.526.79196.526 1.27096-.001.482-.189.933-.53 1.271l-3.82701 3.811c-1.106 1.103-2.91 1.102-4.016 0-.54-.539-.838-1.256-.838-2.02 0-.765.298-1.482.838-2.022l2.038-2.03096c.3-.3.302-.786.002-1.088-.299-.301-.786-.301-1.087-.002l-2.038 2.03196c-.833.83-1.29 1.933-1.29 3.111 0 1.177.457 2.281 1.29 3.112.854.849 1.973 1.274 3.093 1.274 1.12-.001 2.24-.425 3.093-1.273l3.82701-3.812c.632-.63.982-1.468.983-2.361.001-.89096-.346-1.72996-.977-2.36196l-.745-.746Zm6.154.057-2.31 2.314c-.301.30096-.787.30096-1.088 0-.3-.301-.3-.788 0-1.089l2.311-2.313c1.111-1.112 1.111-2.922 0-4.033-1.121-1.122-2.926-1.122-4.038-.01l-3.83001 3.835c-.7.701-.7 1.84 0 2.54l.75.752c.301.3.301.78696 0 1.08796-.149.15-.345.225-.543.225-.197 0-.393-.075-.544-.225l-.75-.75196c-1.299-1.3-1.299-3.416 0-4.716l3.83001-3.835c1.71-1.712 4.493-1.712 6.203 0 1.719 1.722 1.719 4.508.009 6.219Z"
366
+ });
367
+ };
368
+
345
369
  var Loading = function Loading() {
346
370
  return React.createElement("path", {
347
371
  fillRule: "evenodd",
@@ -503,10 +527,12 @@ var icons = {
503
527
  close: Close,
504
528
  checkCircle: CheckCircle,
505
529
  creditcard: CreditCard,
530
+ download: Download,
506
531
  product: Product,
507
532
  edit: Edit,
508
533
  exchange: Exchange,
509
534
  eye: Eye,
535
+ exclamationCircle: ExclamationCircle,
510
536
  exclamationTriangle: ExclamationTriangle,
511
537
  externalLink: ExternalLink,
512
538
  home: Home,
@@ -519,6 +545,7 @@ var icons = {
519
545
  plusCircle: PlusCircle,
520
546
  print: Print,
521
547
  infoCircle: InfoCircle,
548
+ link: Link,
522
549
  loading: Loading,
523
550
  pix: Pix,
524
551
  search: Search,
@@ -956,9 +983,9 @@ var formatValuePatterns = {
956
983
  },
957
984
  onlyText: {
958
985
  mask: function mask(rawValue) {
959
- var onlyText = rawValue.replace(/[^a-zA-ZÀ-ú'~0-9\s]/g, '').split('');
986
+ var onlyText = rawValue.replace(/[^a-zA-ZÀ-ú'˜0-9\]/g, '').split('');
960
987
  return onlyText.map(function () {
961
- return /[a-zA-ZÀ-ú'~´`^0-9\s]/g;
988
+ return /[a-zA-ZÀ-ú'˜`´^0-9\]/g;
962
989
  });
963
990
  }
964
991
  },
@@ -1314,6 +1341,8 @@ var ToggleComponent = function ToggleComponent(_ref, ref) {
1314
1341
  isChecked = _React$useState[0],
1315
1342
  setIsChecked = _React$useState[1];
1316
1343
 
1344
+ var toggleStatusText = disabled ? 'disabled' : 'enabled';
1345
+ var toggleCheckText = isChecked ? 'checked' : 'unchecked';
1317
1346
  React.useEffect(function () {
1318
1347
  setIsChecked(!!checked);
1319
1348
  }, [checked]);
@@ -1324,9 +1353,31 @@ var ToggleComponent = function ToggleComponent(_ref, ref) {
1324
1353
  onChange && onChange(event);
1325
1354
  };
1326
1355
 
1356
+ var toggleClasses = {
1357
+ background: {
1358
+ checked: {
1359
+ enabled: 'bg-primary border-primary',
1360
+ disabled: 'bg-base-3 border-card-stroke'
1361
+ },
1362
+ unchecked: {
1363
+ enabled: 'bg-base-1 border-card-stroke',
1364
+ disabled: 'bg-base-3 border-card-stroke'
1365
+ }
1366
+ },
1367
+ circle: {
1368
+ checked: {
1369
+ enabled: 'translate-x-full ml-px bg-base-1',
1370
+ disabled: 'translate-x-full ml-px bg-base-1'
1371
+ },
1372
+ unchecked: {
1373
+ enabled: 'translate-x-0 bg-inverted-2',
1374
+ disabled: 'translate-x-0 bg-base-1'
1375
+ }
1376
+ }
1377
+ };
1327
1378
  var toggleContainerDisabledClasses = (disabled ? 'pointer-events-none' : '') + " relative";
1328
- var toggleBackgroundClasses = "block border border-card-stroke w-[53px] h-8 rounded-full\n " + (disabled ? ' bg-base-3' : ' bg-base-1') + " ";
1329
- var toggleCircleClasses = "transform " + (!isChecked ? 'translate-x-0 bg-inverted-2' : 'translate-x-full ml-px ' + (disabled ? 'bg-base-1' : 'bg-primary')) + " absolute left-[6px] top-[6px] w-5 h-5 rounded-full transition";
1379
+ var toggleBackgroundClasses = "block border w-[53px] h-8 rounded-full " + toggleClasses.background[toggleCheckText][toggleStatusText] + " transition";
1380
+ var toggleCircleClasses = "transform " + toggleClasses.circle[toggleCheckText][toggleStatusText] + " absolute left-[6px] top-[6px] w-5 h-5 rounded-full transition";
1330
1381
  var toggleLabelClasses = "ml-2 text-inverted-1 text-f6 tracking-4 label";
1331
1382
  return React.createElement("label", {
1332
1383
  htmlFor: inputId,
@@ -1349,8 +1400,8 @@ var ToggleComponent = function ToggleComponent(_ref, ref) {
1349
1400
  }, label));
1350
1401
  };
1351
1402
 
1352
- var ToggleWithFowardRef = /*#__PURE__*/React.forwardRef(ToggleComponent);
1353
- var Toggle = /*#__PURE__*/React.memo(ToggleWithFowardRef);
1403
+ var ToggleWithForwardRef = /*#__PURE__*/React.forwardRef(ToggleComponent);
1404
+ var Toggle = /*#__PURE__*/React.memo(ToggleWithForwardRef);
1354
1405
 
1355
1406
  var sizeClasses = {
1356
1407
  "default": 'h-12',
@@ -1439,7 +1490,7 @@ var CustomPlaceholder = function CustomPlaceholder(props) {
1439
1490
 
1440
1491
  var CustomSingleValue = function CustomSingleValue(props, variant) {
1441
1492
  return React.createElement(SingleValue, Object.assign({}, props, {
1442
- className: "text-f6 tracking-4 text-inverted-2 text-sm truncate " + variantValueClasses[variant]
1493
+ className: "text-f6 tracking-4 text-on-base text-sm truncate " + variantValueClasses[variant]
1443
1494
  }));
1444
1495
  };
1445
1496
 
@@ -1586,16 +1637,23 @@ var DropdownWithFowardRef = /*#__PURE__*/React.forwardRef(DropdownComponent);
1586
1637
  var Dropdown = /*#__PURE__*/React.memo(DropdownWithFowardRef);
1587
1638
 
1588
1639
  var CheckboxComponent = function CheckboxComponent(_ref, ref) {
1589
- var label = _ref.label,
1640
+ var _ref$className = _ref.className,
1641
+ className = _ref$className === void 0 ? '' : _ref$className,
1642
+ label = _ref.label,
1590
1643
  id = _ref.id,
1591
1644
  name = _ref.name,
1592
1645
  onChange = _ref.onChange,
1593
1646
  checked = _ref.checked,
1594
1647
  disabled = _ref.disabled,
1595
- indeterminate = _ref.indeterminate,
1648
+ _ref$indeterminate = _ref.indeterminate,
1649
+ indeterminate = _ref$indeterminate === void 0 ? false : _ref$indeterminate,
1596
1650
  _ref$boxAlign = _ref.boxAlign,
1597
1651
  boxAlign = _ref$boxAlign === void 0 ? 'center' : _ref$boxAlign,
1598
- props = _objectWithoutPropertiesLoose(_ref, ["label", "id", "name", "onChange", "checked", "disabled", "indeterminate", "boxAlign"]);
1652
+ helpText = _ref.helpText,
1653
+ _ref$hasError = _ref.hasError,
1654
+ hasError = _ref$hasError === void 0 ? false : _ref$hasError,
1655
+ errorMessage = _ref.errorMessage,
1656
+ props = _objectWithoutPropertiesLoose(_ref, ["className", "label", "id", "name", "onChange", "checked", "disabled", "indeterminate", "boxAlign", "helpText", "hasError", "errorMessage"]);
1599
1657
 
1600
1658
  var inputRef = React.useRef(null);
1601
1659
  var inputId = id || name;
@@ -1609,6 +1667,7 @@ var CheckboxComponent = function CheckboxComponent(_ref, ref) {
1609
1667
  setIsIndeterminate = _React$useState2[1];
1610
1668
 
1611
1669
  var isCenterBoxAlign = boxAlign === 'center';
1670
+ var hasErrorState = hasError || !!errorMessage;
1612
1671
  React.useEffect(function () {
1613
1672
  setIsChecked(!!checked);
1614
1673
  if (checked) setIsIndeterminate(false);
@@ -1628,7 +1687,7 @@ var CheckboxComponent = function CheckboxComponent(_ref, ref) {
1628
1687
 
1629
1688
  var checkboxIconClasses = "transition duration-200 ease-in-out " + (isChecked || isIndeterminate ? 'scale-100' : 'scale-0');
1630
1689
  var checkboxIconContainerClasses = "border border-card-stroke transition duration-200 ease-in-out\n " + (disabled ? 'bg-base-4' : isChecked || isIndeterminate ? 'bg-primary border-primary' : 'bg-base-1') + "\n " + (isCenterBoxAlign ? 'items-center' : '') + "\n rounded w-4 h-4 flex justify-center m-px\n ";
1631
- var checkboxLabelClasses = "ml-1 input-label text-f6 tracking-4 leading-6 " + (disabled ? 'text-inverted-2' : '');
1690
+ var checkboxLabelClasses = "ml-1 input-label text-f6 tracking-4 leading-6 " + (hasErrorState ? 'text-danger' : disabled ? 'text-inverted-2' : '');
1632
1691
  var alignOptions = {
1633
1692
  start: 'items-start',
1634
1693
  end: 'items-end',
@@ -1636,7 +1695,14 @@ var CheckboxComponent = function CheckboxComponent(_ref, ref) {
1636
1695
  baseline: 'items-baseline',
1637
1696
  stretch: 'items-stretch'
1638
1697
  };
1639
- return React.createElement("label", {
1698
+ var HelpTextComponent = React.createElement(InputHelpText, {
1699
+ helpText: errorMessage || helpText,
1700
+ hasError: hasErrorState,
1701
+ className: "mt-2"
1702
+ });
1703
+ return React.createElement("div", {
1704
+ className: "inline-block " + className
1705
+ }, React.createElement("label", {
1640
1706
  htmlFor: inputId,
1641
1707
  className: "inline-flex " + alignOptions[boxAlign] + " cursor-pointer"
1642
1708
  }, React.createElement("span", {
@@ -1670,7 +1736,7 @@ var CheckboxComponent = function CheckboxComponent(_ref, ref) {
1670
1736
  fill: "white"
1671
1737
  })))), React.createElement("span", {
1672
1738
  className: checkboxLabelClasses
1673
- }, label));
1739
+ }, label)), HelpTextComponent);
1674
1740
  };
1675
1741
 
1676
1742
  var CheckboxWithFowardRef = /*#__PURE__*/React.forwardRef(CheckboxComponent);
@@ -1859,7 +1925,7 @@ var TableComponent = function TableComponent(_ref2) {
1859
1925
  }));
1860
1926
  })), React.createElement("tbody", Object.assign({}, getTableBodyProps(), {
1861
1927
  className: "text-sm text-on-base"
1862
- }), isLoading ? React.createElement("tr", null, Array(columnsLength).fill(0).map(function (key) {
1928
+ }), isLoading ? React.createElement("tr", null, Array(columnsLength).fill(0).map(function (_, key) {
1863
1929
  return React.createElement("td", {
1864
1930
  key: key,
1865
1931
  className: "" + TdClasses
@@ -2395,19 +2461,34 @@ var TooltipComponent = function TooltipComponent(props) {
2395
2461
  computedProps.content = mounted ? props.content : '';
2396
2462
  }
2397
2463
 
2398
- return React.createElement(Tippy, Object.assign({}, computedProps, {
2464
+ return React.createElement(StyledTooltipComponent, Object.assign({}, computedProps, {
2399
2465
  appendTo: (props == null ? void 0 : props.appendTo) || 'parent',
2400
2466
  hideOnClick: (props == null ? void 0 : props.hideOnClick) || false,
2401
2467
  trigger: (props == null ? void 0 : props.trigger) || 'mouseenter',
2402
2468
  touch: (props == null ? void 0 : props.touch) || ['hold', 400],
2403
2469
  duration: (props == null ? void 0 : props.duration) || 150,
2404
2470
  placement: ((_window = window) == null ? void 0 : _window.innerWidth) < 1024 ? 'top' : (props == null ? void 0 : props.placement) || 'top',
2405
- interactive: (props == null ? void 0 : props.interactive) || false
2471
+ interactive: (props == null ? void 0 : props.interactive) || false,
2472
+ theme: (props == null ? void 0 : props.theme) || 'dark'
2406
2473
  }));
2407
2474
  };
2408
2475
 
2409
- var styledTooltipComponent = /*#__PURE__*/styled(TooltipComponent)(_templateObject || (_templateObject = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n --bg-color: #20221b;\n position: relative;\n background-color: var(--bg-color);\n color: #fff;\n border-radius: 3px;\n font-size: 12px;\n letter-spacing: -0.4px;\n line-height: 1.4;\n outline: 0;\n transition-property: transform, visibility, opacity;\n\n &[data-animation='fade'][data-state='hidden'] {\n opacity: 0;\n }\n\n [data-tippy-root] {\n max-width: calc(100vw - 10px);\n }\n\n &[data-placement^='top'] > .tippy-arrow {\n bottom: 0;\n }\n\n &[data-placement^='top'] > .tippy-arrow:before {\n bottom: -7px;\n left: 0;\n border-width: 8px 8px 0;\n border-top-color: initial;\n transform-origin: center top;\n }\n\n &[data-placement^='bottom'] > .tippy-arrow {\n top: 0;\n }\n\n &[data-placement^='bottom'] > .tippy-arrow:before {\n top: -7px;\n left: 0;\n border-width: 0 8px 8px;\n border-bottom-color: initial;\n transform-origin: center bottom;\n }\n\n &[data-placement^='left'] > .tippy-arrow {\n right: 0;\n }\n\n &[data-placement^='left'] > .tippy-arrow:before {\n border-width: 8px 0 8px 8px;\n border-left-color: initial;\n right: -7px;\n transform-origin: center left;\n }\n\n &[data-placement^='right'] > .tippy-arrow {\n left: 0;\n }\n\n &[data-placement^='right'] > .tippy-arrow:before {\n left: -7px;\n border-width: 8px 8px 8px 0;\n border-right-color: initial;\n transform-origin: center right;\n }\n\n &[data-inertia][data-state='visible'] {\n transition-timing-function: cubic-bezier(0.54, 1.5, 0.38, 1.11);\n }\n\n .tippy-arrow {\n width: 15px;\n height: 15px;\n color: var(--bg-color);\n }\n\n .tippy-arrow:before {\n content: '';\n position: absolute;\n border-color: transparent;\n border-style: solid;\n }\n\n .tippy-content {\n position: relative;\n padding: 12px 8px;\n z-index: 1;\n }\n"])));
2410
- var Tooltip = /*#__PURE__*/React.memo(styledTooltipComponent);
2476
+ var theme = {
2477
+ light: {
2478
+ background: '#fff',
2479
+ color: '#371E56'
2480
+ },
2481
+ dark: {
2482
+ background: '#371E56',
2483
+ color: '#fff'
2484
+ }
2485
+ };
2486
+ var StyledTooltipComponent = /*#__PURE__*/styled(Tippy)(_templateObject || (_templateObject = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n --bg-color: ", ";\n position: relative;\n background-color: var(--bg-color);\n color: ", ";\n border-radius: 3px;\n font-size: 12px;\n letter-spacing: -0.4px;\n line-height: 1.4;\n outline: 0;\n transition-property: transform, visibility, opacity;\n\n &[data-animation='fade'][data-state='hidden'] {\n opacity: 0;\n }\n\n [data-tippy-root] {\n max-width: calc(100vw - 10px);\n }\n\n &[data-placement^='top'] > .tippy-arrow {\n bottom: 0;\n }\n\n &[data-placement^='top'] > .tippy-arrow:before {\n bottom: -7px;\n left: 0;\n border-width: 8px 8px 0;\n border-top-color: initial;\n transform-origin: center top;\n }\n\n &[data-placement^='bottom'] > .tippy-arrow {\n top: 0;\n }\n\n &[data-placement^='bottom'] > .tippy-arrow:before {\n top: -7px;\n left: 0;\n border-width: 0 8px 8px;\n border-bottom-color: initial;\n transform-origin: center bottom;\n }\n\n &[data-placement^='left'] > .tippy-arrow {\n right: 0;\n }\n\n &[data-placement^='left'] > .tippy-arrow:before {\n border-width: 8px 0 8px 8px;\n border-left-color: initial;\n right: -7px;\n transform-origin: center left;\n }\n\n &[data-placement^='right'] > .tippy-arrow {\n left: 0;\n }\n\n &[data-placement^='right'] > .tippy-arrow:before {\n left: -7px;\n border-width: 8px 8px 8px 0;\n border-right-color: initial;\n transform-origin: center right;\n }\n\n &[data-inertia][data-state='visible'] {\n transition-timing-function: cubic-bezier(0.54, 1.5, 0.38, 1.11);\n }\n\n .tippy-arrow {\n width: 15px;\n height: 15px;\n color: var(--bg-color);\n }\n\n .tippy-arrow:before {\n content: '';\n position: absolute;\n border-color: transparent;\n border-style: solid;\n }\n\n .tippy-content {\n position: relative;\n padding: 12px 8px;\n z-index: 1;\n }\n"])), function (props) {
2487
+ return theme[props.theme].background;
2488
+ }, function (props) {
2489
+ return theme[props.theme].color;
2490
+ });
2491
+ var Tooltip = /*#__PURE__*/React.memo(TooltipComponent);
2411
2492
 
2412
2493
  var SharedContext = /*#__PURE__*/React.createContext({
2413
2494
  variant: 'default',