@loja-integrada/admin-components 0.9.6 → 0.10.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.
package/README.md CHANGED
@@ -3,6 +3,18 @@
3
3
  Components for Loja Integrada admin.
4
4
  [https://lojaintegrada.github.io/admin-components/](https://lojaintegrada.github.io/admin-components/)
5
5
 
6
+ ## Usage
7
+
8
+ ```bash
9
+ yarn add @loja-integrada/admin-components
10
+ ```
11
+
12
+ ```js
13
+ import { Button } from '@loja-integrada/admin-components'
14
+
15
+ <Button></Button>
16
+ ```
17
+
6
18
  ## Comamnds
7
19
 
8
20
  ### Storybook
@@ -45,14 +57,6 @@ Deploy to GitHub Pages is automatic after deploy to NPM
45
57
  This project works with both Jest or Cypress Components.
46
58
  Use `.spec.` for Cypress and `.test.` for Jest
47
59
 
48
- ## Usage
49
-
50
- ```js
51
- import { Button } from '@loja-integrada/admin-components'
52
-
53
- <Button></Button>
54
- ```
55
-
56
60
  ### Bundle analysis
57
61
 
58
62
  Calculates the real cost of your library using [size-limit](https://github.com/ai/size-limit) with `yarn size` and visulize it with `yarn analyze`.
@@ -15,7 +15,7 @@ export interface ButtonProps extends ButtonAnchorProps {
15
15
  /** Button variant
16
16
  * @default primary
17
17
  * */
18
- variant?: 'primary' | 'secondary' | 'tertiary' | 'info' | 'warning' | 'danger' | 'outline';
18
+ variant?: 'primary' | 'secondary' | 'tertiary' | 'info' | 'warning' | 'danger' | 'outline' | 'onlyText';
19
19
  /**
20
20
  * Button is loading
21
21
  * */
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { Row } from 'react-table';
3
- export declare const Table: React.MemoExoticComponent<({ columns: columnsProps, rows: rowsProps, selectable, isLoading, emptyText, onChange, selectedData, disabledRows, }: TableProps) => JSX.Element>;
3
+ export declare const Table: React.MemoExoticComponent<({ columns: columnsProps, rows: rowsProps, selectable, isLoading, emptyText, onChange, selectedData, disabledRows, id, }: TableProps) => JSX.Element>;
4
4
  declare type CellWrapperProp = React.ComponentClass<any> | React.FunctionComponent<any>;
5
5
  declare type TextAlignProp = 'left' | 'right' | 'center';
6
6
  declare type TableRowProp = {
@@ -72,5 +72,10 @@ export interface TableProps {
72
72
  * @default []
73
73
  */
74
74
  disabledRows?: number[];
75
+ /**
76
+ * Id of the table.
77
+ * @default undefined
78
+ */
79
+ id?: string;
75
80
  }
76
81
  export {};
@@ -1,7 +1,27 @@
1
1
  import React from 'react';
2
+ import { InputHelpTextProps } from '../InputHelpText';
2
3
  export declare const Checkbox: React.MemoExoticComponent<React.ForwardRefExoticComponent<CheckboxProps & React.RefAttributes<HTMLInputElement>>>;
3
- export interface CheckboxProps extends React.InputHTMLAttributes<HTMLInputElement> {
4
+ export interface CheckboxProps extends InputHelpTextProps, React.InputHTMLAttributes<HTMLInputElement> {
5
+ /**
6
+ * Custom class name
7
+ * */
8
+ className?: string;
9
+ /**
10
+ * Text label of the checkbox
11
+ * */
4
12
  label?: string | React.ReactNode;
13
+ /**
14
+ * Checkbox box isn't selected nwither unselected
15
+ * @default false
16
+ * */
5
17
  indeterminate?: boolean;
6
- boxAlign?: 'center' | 'baseline';
18
+ /**
19
+ * Item align
20
+ * @default 'center'
21
+ * */
22
+ boxAlign?: 'start' | 'end' | 'center' | 'baseline' | 'stretch';
23
+ /**
24
+ * Error message to display
25
+ * */
26
+ errorMessage?: string;
7
27
  }
@@ -5,6 +5,7 @@ export default _default;
5
5
  export declare const Default: Story<CheckboxProps>;
6
6
  export declare const Indeterminate: Story<CheckboxProps>;
7
7
  export declare const Disabled: Story<CheckboxProps>;
8
+ export declare const Error: Story<CheckboxProps>;
8
9
  export declare const DisabledChecked: Story<CheckboxProps>;
9
10
  export declare const DisabledIndeterminate: Story<CheckboxProps>;
10
11
  export declare const WithOnChange: Story<CheckboxProps>;
@@ -25,12 +25,12 @@ export interface InputProps extends InputLabelProps, InputHelpTextProps, Omit<Re
25
25
  sufix?: React.ReactNode | string | null;
26
26
  /**
27
27
  * Set visibility of input prefix border
28
- * @default 'true'
28
+ * @default true
29
29
  * */
30
30
  prefixBorder?: boolean;
31
31
  /**
32
32
  * Set visibility of input sufix border
33
- * @default 'true'
33
+ * @default true
34
34
  * */
35
35
  sufixBorder?: boolean;
36
36
  }
@@ -0,0 +1,2 @@
1
+ /// <reference types="react" />
2
+ export declare const Download: () => JSX.Element;
@@ -0,0 +1,2 @@
1
+ /// <reference types="react" />
2
+ export declare const Link: () => JSX.Element;
@@ -21,6 +21,7 @@ export declare const icons: {
21
21
  close: () => JSX.Element;
22
22
  checkCircle: () => JSX.Element;
23
23
  creditcard: () => JSX.Element;
24
+ download: () => JSX.Element;
24
25
  product: () => JSX.Element;
25
26
  edit: () => JSX.Element;
26
27
  exchange: () => JSX.Element;
@@ -37,6 +38,7 @@ export declare const icons: {
37
38
  plusCircle: () => JSX.Element;
38
39
  print: () => JSX.Element;
39
40
  infoCircle: () => JSX.Element;
41
+ link: () => JSX.Element;
40
42
  loading: () => JSX.Element;
41
43
  pix: () => JSX.Element;
42
44
  search: () => JSX.Element;
@@ -218,6 +218,14 @@ var CreditCard = function CreditCard() {
218
218
  });
219
219
  };
220
220
 
221
+ var Download = function Download() {
222
+ return React__default.createElement("path", {
223
+ fillRule: "evenodd",
224
+ 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",
225
+ clipRule: "evenodd"
226
+ });
227
+ };
228
+
221
229
  var Product = function Product() {
222
230
  return React__default.createElement("path", {
223
231
  fillRule: "evenodd",
@@ -350,6 +358,14 @@ var InfoCircle = function InfoCircle() {
350
358
  });
351
359
  };
352
360
 
361
+ var Link = function Link() {
362
+ return React__default.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
+
353
369
  var Loading = function Loading() {
354
370
  return React__default.createElement("path", {
355
371
  fillRule: "evenodd",
@@ -511,6 +527,7 @@ var icons = {
511
527
  close: Close,
512
528
  checkCircle: CheckCircle,
513
529
  creditcard: CreditCard,
530
+ download: Download,
514
531
  product: Product,
515
532
  edit: Edit,
516
533
  exchange: Exchange,
@@ -527,6 +544,7 @@ var icons = {
527
544
  plusCircle: PlusCircle,
528
545
  print: Print,
529
546
  infoCircle: InfoCircle,
547
+ link: Link,
530
548
  loading: Loading,
531
549
  pix: Pix,
532
550
  search: Search,
@@ -581,7 +599,8 @@ var listOfStylesHover = {
581
599
  info: "hover:bg-secondary-bold",
582
600
  warning: "hover:bg-warning-dark",
583
601
  danger: "hover:bg-danger-dark",
584
- outline: "hover:bg-primary-light"
602
+ outline: "hover:bg-primary-light",
603
+ onlyText: "hover:bg-base-2"
585
604
  };
586
605
  var listOfStylesActive = {
587
606
  primary: "active:bg-primary-bold",
@@ -589,13 +608,15 @@ var listOfStylesActive = {
589
608
  tertiary: "active:bg-tertiary-bold",
590
609
  warning: "active:bg-warning-bold",
591
610
  danger: "hover:bg-danger-bold",
592
- outline: "active:shadow-inner active:bg-base-1"
611
+ outline: "active:shadow-inner active:bg-base-1",
612
+ onlyText: "active:bg-base-1"
593
613
  };
594
614
  var listOfStylesFocus = {
595
615
  primary: "focus:ring-1 focus:ring-primary-dark focus:ring-opacity-50",
596
616
  secondary: "focus:ring focus:ring-focus",
597
617
  danger: "focus:ring-1 focus:ring-danger-dark",
598
- outline: "focus:ring-2 focus:ring-focus focus:ring-offset-1"
618
+ outline: "focus:ring-2 focus:ring-focus focus:ring-offset-1",
619
+ onlyText: "focus:bg-base-1"
599
620
  };
600
621
  var listOfStyles = {
601
622
  primary: "bg-primary text-base-1 " + listOfStylesHover['primary'] + " " + listOfStylesActive['primary'] + " " + listOfStylesFocus['primary'],
@@ -604,7 +625,8 @@ var listOfStyles = {
604
625
  info: "bg-secondary-dark text-base-1 " + listOfStylesHover['info'],
605
626
  warning: "bg-warning text-on-base " + listOfStylesHover['warning'] + " " + listOfStylesActive['warning'],
606
627
  danger: "bg-danger text-base-1 " + listOfStylesHover['danger'] + " " + listOfStylesActive['danger'] + " " + listOfStylesFocus['danger'],
607
- outline: "bg-transparent text-inverted-2 border border-inverted-2 " + listOfStylesHover['outline'] + " " + listOfStylesActive['outline'] + " " + listOfStylesFocus['outline']
628
+ outline: "bg-transparent text-inverted-2 border border-inverted-2 " + listOfStylesHover['outline'] + " " + listOfStylesActive['outline'] + " " + listOfStylesFocus['outline'],
629
+ onlyText: "bg-transparent border-transparent text-inverted-2 px-0 " + listOfStylesHover['onlyText'] + " " + listOfStylesActive['onlyText'] + " " + listOfStylesFocus['onlyText']
608
630
  };
609
631
  var defaultDisabledStyle = "bg-base-3 cursor-default text-on-base-2 shadow-none ring-0 border-0 hover:bg-base-3 hover:text-on-base-2 ";
610
632
  var listOfStylesDisabled = {
@@ -614,7 +636,8 @@ var listOfStylesDisabled = {
614
636
  info: defaultDisabledStyle,
615
637
  warning: defaultDisabledStyle,
616
638
  danger: defaultDisabledStyle,
617
- outline: defaultDisabledStyle
639
+ outline: defaultDisabledStyle,
640
+ onlyText: "bg-transparent text-on-base-3 shadow-none ring-0 border-0"
618
641
  };
619
642
  var listOfSizes = {
620
643
  small: "text-f7 h-8",
@@ -1589,16 +1612,23 @@ var DropdownWithFowardRef = /*#__PURE__*/React__default.forwardRef(DropdownCompo
1589
1612
  var Dropdown = /*#__PURE__*/React__default.memo(DropdownWithFowardRef);
1590
1613
 
1591
1614
  var CheckboxComponent = function CheckboxComponent(_ref, ref) {
1592
- var label = _ref.label,
1615
+ var _ref$className = _ref.className,
1616
+ className = _ref$className === void 0 ? '' : _ref$className,
1617
+ label = _ref.label,
1593
1618
  id = _ref.id,
1594
1619
  name = _ref.name,
1595
1620
  onChange = _ref.onChange,
1596
1621
  checked = _ref.checked,
1597
1622
  disabled = _ref.disabled,
1598
- indeterminate = _ref.indeterminate,
1623
+ _ref$indeterminate = _ref.indeterminate,
1624
+ indeterminate = _ref$indeterminate === void 0 ? false : _ref$indeterminate,
1599
1625
  _ref$boxAlign = _ref.boxAlign,
1600
1626
  boxAlign = _ref$boxAlign === void 0 ? 'center' : _ref$boxAlign,
1601
- props = _objectWithoutPropertiesLoose(_ref, ["label", "id", "name", "onChange", "checked", "disabled", "indeterminate", "boxAlign"]);
1627
+ helpText = _ref.helpText,
1628
+ _ref$hasError = _ref.hasError,
1629
+ hasError = _ref$hasError === void 0 ? false : _ref$hasError,
1630
+ errorMessage = _ref.errorMessage,
1631
+ props = _objectWithoutPropertiesLoose(_ref, ["className", "label", "id", "name", "onChange", "checked", "disabled", "indeterminate", "boxAlign", "helpText", "hasError", "errorMessage"]);
1602
1632
 
1603
1633
  var inputRef = React__default.useRef(null);
1604
1634
  var inputId = id || name;
@@ -1612,6 +1642,7 @@ var CheckboxComponent = function CheckboxComponent(_ref, ref) {
1612
1642
  setIsIndeterminate = _React$useState2[1];
1613
1643
 
1614
1644
  var isCenterBoxAlign = boxAlign === 'center';
1645
+ var hasErrorState = hasError || !!errorMessage;
1615
1646
  React__default.useEffect(function () {
1616
1647
  setIsChecked(!!checked);
1617
1648
  if (checked) setIsIndeterminate(false);
@@ -1631,10 +1662,24 @@ var CheckboxComponent = function CheckboxComponent(_ref, ref) {
1631
1662
 
1632
1663
  var checkboxIconClasses = "transition duration-200 ease-in-out " + (isChecked || isIndeterminate ? 'scale-100' : 'scale-0');
1633
1664
  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 ";
1634
- var checkboxLabelClasses = "ml-1 input-label text-f6 tracking-4 leading-6 " + (disabled ? 'text-inverted-2' : '');
1635
- return React__default.createElement("label", {
1665
+ var checkboxLabelClasses = "ml-1 input-label text-f6 tracking-4 leading-6 " + (hasErrorState ? 'text-danger' : disabled ? 'text-inverted-2' : '');
1666
+ var alignOptions = {
1667
+ start: 'items-start',
1668
+ end: 'items-end',
1669
+ center: 'items-center',
1670
+ baseline: 'items-baseline',
1671
+ stretch: 'items-stretch'
1672
+ };
1673
+ var HelpTextComponent = React__default.createElement(InputHelpText, {
1674
+ helpText: errorMessage || helpText,
1675
+ hasError: hasErrorState,
1676
+ className: "mt-2"
1677
+ });
1678
+ return React__default.createElement("div", {
1679
+ className: "inline-block " + className
1680
+ }, React__default.createElement("label", {
1636
1681
  htmlFor: inputId,
1637
- className: "inline-flex items-" + boxAlign + " cursor-pointer"
1682
+ className: "inline-flex " + alignOptions[boxAlign] + " cursor-pointer"
1638
1683
  }, React__default.createElement("span", {
1639
1684
  className: "rounded z-50 flex items-center justify-center focus-within:ring-2 ring-focus"
1640
1685
  }, React__default.createElement("input", Object.assign({
@@ -1666,7 +1711,7 @@ var CheckboxComponent = function CheckboxComponent(_ref, ref) {
1666
1711
  fill: "white"
1667
1712
  })))), React__default.createElement("span", {
1668
1713
  className: checkboxLabelClasses
1669
- }, label));
1714
+ }, label)), HelpTextComponent);
1670
1715
  };
1671
1716
 
1672
1717
  var CheckboxWithFowardRef = /*#__PURE__*/React__default.forwardRef(CheckboxComponent);
@@ -1705,7 +1750,8 @@ var TableComponent = function TableComponent(_ref2) {
1705
1750
  onChange = _ref2.onChange,
1706
1751
  selectedData = _ref2.selectedData,
1707
1752
  _ref2$disabledRows = _ref2.disabledRows,
1708
- disabledRows = _ref2$disabledRows === void 0 ? [] : _ref2$disabledRows;
1753
+ disabledRows = _ref2$disabledRows === void 0 ? [] : _ref2$disabledRows,
1754
+ id = _ref2.id;
1709
1755
  var rowsPropsMemoized = React__default.useMemo(function () {
1710
1756
  return rowsProps;
1711
1757
  }, [rowsProps]);
@@ -1808,9 +1854,13 @@ var TableComponent = function TableComponent(_ref2) {
1808
1854
  var columnsLength = React__default.useMemo(function () {
1809
1855
  return selectable ? columns.length + 1 : columns.length;
1810
1856
  }, [columns, selectable]);
1857
+ var tableId = React__default.useMemo(function () {
1858
+ return id ? "" + id.charAt(0).toUpperCase() + id.slice(1) : '';
1859
+ }, [id]);
1811
1860
  return React__default.createElement("div", {
1812
1861
  className: "max-w-full overflow-x-auto"
1813
1862
  }, React__default.createElement("table", Object.assign({}, getTableProps(), {
1863
+ id: id,
1814
1864
  className: "w-full bg-base-1 rounded border-separate border border-card-stroke",
1815
1865
  cellSpacing: "0"
1816
1866
  }), React__default.createElement("thead", {
@@ -1833,7 +1883,8 @@ var TableComponent = function TableComponent(_ref2) {
1833
1883
  },
1834
1884
  checked: isHeaderSelectChecked,
1835
1885
  indeterminate: isHeaderSelectedIndeterminate,
1836
- disabled: isHeaderSelectDisabled
1886
+ disabled: isHeaderSelectDisabled,
1887
+ id: "checkboxSelectAllRows" + tableId
1837
1888
  })), headerGroup.headers.map(function (column) {
1838
1889
  var _column$getHeaderProp = column.getHeaderProps(),
1839
1890
  key = _column$getHeaderProp.key,
@@ -1849,7 +1900,7 @@ var TableComponent = function TableComponent(_ref2) {
1849
1900
  }));
1850
1901
  })), React__default.createElement("tbody", Object.assign({}, getTableBodyProps(), {
1851
1902
  className: "text-sm text-on-base"
1852
- }), isLoading ? React__default.createElement("tr", null, Array(columnsLength).fill(0).map(function (key) {
1903
+ }), isLoading ? React__default.createElement("tr", null, Array(columnsLength).fill(0).map(function (_, key) {
1853
1904
  return React__default.createElement("td", {
1854
1905
  key: key,
1855
1906
  className: "" + TdClasses
@@ -1879,7 +1930,8 @@ var TableComponent = function TableComponent(_ref2) {
1879
1930
  return handleSelectRow(index, e);
1880
1931
  },
1881
1932
  checked: isRowChecked,
1882
- disabled: isRowDisabled
1933
+ disabled: isRowDisabled,
1934
+ id: "checkboxRow" + index + tableId
1883
1935
  })), row.cells.map(function (cell) {
1884
1936
  var _cell$getCellProps = cell.getCellProps(),
1885
1937
  key = _cell$getCellProps.key,
@@ -2114,6 +2166,8 @@ var ModalComponent = function ModalComponent(_ref) {
2114
2166
  }, React__default.createElement("span", {
2115
2167
  className: "min-w-0 text-inverted-2 text-xs font-semibold uppercase break-words " + (headerTitle ? 'pb-3' : '')
2116
2168
  }, headerTitle), React__default.createElement("button", {
2169
+ type: "button",
2170
+ id: "btnCloseModal",
2117
2171
  className: (preventClose ? 'hidden' : 'flex') + " items-center p-2 pb-1 -mr-2 -mt-3 text-sm font-semibold text-inverted-2 hover:text-inverted-1",
2118
2172
  onClick: handleRequestCloseFunc
2119
2173
  }, headerClose !== false && React__default.createElement("span", {