@loja-integrada/admin-components 0.9.5 → 0.9.9

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 {};
@@ -3,3 +3,4 @@ import { TabsProps } from './Tabs';
3
3
  declare const _default: Meta<import("@storybook/react").Args>;
4
4
  export default _default;
5
5
  export declare const Default: Story<TabsProps>;
6
+ export declare const WithTabDisabled: Story<TabsProps>;
@@ -10,5 +10,5 @@ interface TabsItemProps extends TabsItemInterface {
10
10
  */
11
11
  onChange: (arg0: string) => void;
12
12
  }
13
- export declare const TabsItem: ({ id, title, active, onChange, }: TabsItemProps) => JSX.Element;
13
+ export declare const TabsItem: ({ id, title, active, disabled, onChange, }: TabsItemProps) => JSX.Element;
14
14
  export {};
@@ -7,6 +7,10 @@ export interface TabsItemInterface {
7
7
  * Item visible title
8
8
  */
9
9
  title: string;
10
+ /**
11
+ * Disabled a specific tab
12
+ */
13
+ disabled?: boolean;
10
14
  /**
11
15
  * Item content
12
16
  * @deprecated Not implemented
@@ -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 Link: () => JSX.Element;
@@ -37,6 +37,7 @@ export declare const icons: {
37
37
  plusCircle: () => JSX.Element;
38
38
  print: () => JSX.Element;
39
39
  infoCircle: () => JSX.Element;
40
+ link: () => JSX.Element;
40
41
  loading: () => JSX.Element;
41
42
  pix: () => JSX.Element;
42
43
  search: () => JSX.Element;
@@ -350,6 +350,14 @@ var InfoCircle = function InfoCircle() {
350
350
  });
351
351
  };
352
352
 
353
+ var Link = function Link() {
354
+ return React__default.createElement("path", {
355
+ fillRule: "evenodd",
356
+ clipRule: "evenodd",
357
+ 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"
358
+ });
359
+ };
360
+
353
361
  var Loading = function Loading() {
354
362
  return React__default.createElement("path", {
355
363
  fillRule: "evenodd",
@@ -527,6 +535,7 @@ var icons = {
527
535
  plusCircle: PlusCircle,
528
536
  print: Print,
529
537
  infoCircle: InfoCircle,
538
+ link: Link,
530
539
  loading: Loading,
531
540
  pix: Pix,
532
541
  search: Search,
@@ -581,7 +590,8 @@ var listOfStylesHover = {
581
590
  info: "hover:bg-secondary-bold",
582
591
  warning: "hover:bg-warning-dark",
583
592
  danger: "hover:bg-danger-dark",
584
- outline: "hover:bg-primary-light"
593
+ outline: "hover:bg-primary-light",
594
+ onlyText: "hover:bg-base-2"
585
595
  };
586
596
  var listOfStylesActive = {
587
597
  primary: "active:bg-primary-bold",
@@ -589,13 +599,15 @@ var listOfStylesActive = {
589
599
  tertiary: "active:bg-tertiary-bold",
590
600
  warning: "active:bg-warning-bold",
591
601
  danger: "hover:bg-danger-bold",
592
- outline: "active:shadow-inner active:bg-base-1"
602
+ outline: "active:shadow-inner active:bg-base-1",
603
+ onlyText: "active:bg-base-1"
593
604
  };
594
605
  var listOfStylesFocus = {
595
606
  primary: "focus:ring-1 focus:ring-primary-dark focus:ring-opacity-50",
596
607
  secondary: "focus:ring focus:ring-focus",
597
608
  danger: "focus:ring-1 focus:ring-danger-dark",
598
- outline: "focus:ring-2 focus:ring-focus focus:ring-offset-1"
609
+ outline: "focus:ring-2 focus:ring-focus focus:ring-offset-1",
610
+ onlyText: "focus:bg-base-1"
599
611
  };
600
612
  var listOfStyles = {
601
613
  primary: "bg-primary text-base-1 " + listOfStylesHover['primary'] + " " + listOfStylesActive['primary'] + " " + listOfStylesFocus['primary'],
@@ -604,7 +616,8 @@ var listOfStyles = {
604
616
  info: "bg-secondary-dark text-base-1 " + listOfStylesHover['info'],
605
617
  warning: "bg-warning text-on-base " + listOfStylesHover['warning'] + " " + listOfStylesActive['warning'],
606
618
  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']
619
+ outline: "bg-transparent text-inverted-2 border border-inverted-2 " + listOfStylesHover['outline'] + " " + listOfStylesActive['outline'] + " " + listOfStylesFocus['outline'],
620
+ onlyText: "bg-transparent border-transparent text-inverted-2 px-0 " + listOfStylesHover['onlyText'] + " " + listOfStylesActive['onlyText'] + " " + listOfStylesFocus['onlyText']
608
621
  };
609
622
  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
623
  var listOfStylesDisabled = {
@@ -614,7 +627,8 @@ var listOfStylesDisabled = {
614
627
  info: defaultDisabledStyle,
615
628
  warning: defaultDisabledStyle,
616
629
  danger: defaultDisabledStyle,
617
- outline: defaultDisabledStyle
630
+ outline: defaultDisabledStyle,
631
+ onlyText: "bg-transparent text-on-base-3 shadow-none ring-0 border-0"
618
632
  };
619
633
  var listOfSizes = {
620
634
  small: "text-f7 h-8",
@@ -1589,16 +1603,23 @@ var DropdownWithFowardRef = /*#__PURE__*/React__default.forwardRef(DropdownCompo
1589
1603
  var Dropdown = /*#__PURE__*/React__default.memo(DropdownWithFowardRef);
1590
1604
 
1591
1605
  var CheckboxComponent = function CheckboxComponent(_ref, ref) {
1592
- var label = _ref.label,
1606
+ var _ref$className = _ref.className,
1607
+ className = _ref$className === void 0 ? '' : _ref$className,
1608
+ label = _ref.label,
1593
1609
  id = _ref.id,
1594
1610
  name = _ref.name,
1595
1611
  onChange = _ref.onChange,
1596
1612
  checked = _ref.checked,
1597
1613
  disabled = _ref.disabled,
1598
- indeterminate = _ref.indeterminate,
1614
+ _ref$indeterminate = _ref.indeterminate,
1615
+ indeterminate = _ref$indeterminate === void 0 ? false : _ref$indeterminate,
1599
1616
  _ref$boxAlign = _ref.boxAlign,
1600
1617
  boxAlign = _ref$boxAlign === void 0 ? 'center' : _ref$boxAlign,
1601
- props = _objectWithoutPropertiesLoose(_ref, ["label", "id", "name", "onChange", "checked", "disabled", "indeterminate", "boxAlign"]);
1618
+ helpText = _ref.helpText,
1619
+ _ref$hasError = _ref.hasError,
1620
+ hasError = _ref$hasError === void 0 ? false : _ref$hasError,
1621
+ errorMessage = _ref.errorMessage,
1622
+ props = _objectWithoutPropertiesLoose(_ref, ["className", "label", "id", "name", "onChange", "checked", "disabled", "indeterminate", "boxAlign", "helpText", "hasError", "errorMessage"]);
1602
1623
 
1603
1624
  var inputRef = React__default.useRef(null);
1604
1625
  var inputId = id || name;
@@ -1612,6 +1633,7 @@ var CheckboxComponent = function CheckboxComponent(_ref, ref) {
1612
1633
  setIsIndeterminate = _React$useState2[1];
1613
1634
 
1614
1635
  var isCenterBoxAlign = boxAlign === 'center';
1636
+ var hasErrorState = hasError || !!errorMessage;
1615
1637
  React__default.useEffect(function () {
1616
1638
  setIsChecked(!!checked);
1617
1639
  if (checked) setIsIndeterminate(false);
@@ -1631,10 +1653,24 @@ var CheckboxComponent = function CheckboxComponent(_ref, ref) {
1631
1653
 
1632
1654
  var checkboxIconClasses = "transition duration-200 ease-in-out " + (isChecked || isIndeterminate ? 'scale-100' : 'scale-0');
1633
1655
  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", {
1656
+ var checkboxLabelClasses = "ml-1 input-label text-f6 tracking-4 leading-6 " + (hasErrorState ? 'text-danger' : disabled ? 'text-inverted-2' : '');
1657
+ var alignOptions = {
1658
+ start: 'items-start',
1659
+ end: 'items-end',
1660
+ center: 'items-center',
1661
+ baseline: 'items-baseline',
1662
+ stretch: 'items-stretch'
1663
+ };
1664
+ var HelpTextComponent = React__default.createElement(InputHelpText, {
1665
+ helpText: errorMessage || helpText,
1666
+ hasError: hasErrorState,
1667
+ className: "mt-2"
1668
+ });
1669
+ return React__default.createElement("div", {
1670
+ className: "inline-block " + className
1671
+ }, React__default.createElement("label", {
1636
1672
  htmlFor: inputId,
1637
- className: "inline-flex items-" + boxAlign + " cursor-pointer"
1673
+ className: "inline-flex " + alignOptions[boxAlign] + " cursor-pointer"
1638
1674
  }, React__default.createElement("span", {
1639
1675
  className: "rounded z-50 flex items-center justify-center focus-within:ring-2 ring-focus"
1640
1676
  }, React__default.createElement("input", Object.assign({
@@ -1666,7 +1702,7 @@ var CheckboxComponent = function CheckboxComponent(_ref, ref) {
1666
1702
  fill: "white"
1667
1703
  })))), React__default.createElement("span", {
1668
1704
  className: checkboxLabelClasses
1669
- }, label));
1705
+ }, label)), HelpTextComponent);
1670
1706
  };
1671
1707
 
1672
1708
  var CheckboxWithFowardRef = /*#__PURE__*/React__default.forwardRef(CheckboxComponent);
@@ -1705,7 +1741,8 @@ var TableComponent = function TableComponent(_ref2) {
1705
1741
  onChange = _ref2.onChange,
1706
1742
  selectedData = _ref2.selectedData,
1707
1743
  _ref2$disabledRows = _ref2.disabledRows,
1708
- disabledRows = _ref2$disabledRows === void 0 ? [] : _ref2$disabledRows;
1744
+ disabledRows = _ref2$disabledRows === void 0 ? [] : _ref2$disabledRows,
1745
+ id = _ref2.id;
1709
1746
  var rowsPropsMemoized = React__default.useMemo(function () {
1710
1747
  return rowsProps;
1711
1748
  }, [rowsProps]);
@@ -1808,9 +1845,13 @@ var TableComponent = function TableComponent(_ref2) {
1808
1845
  var columnsLength = React__default.useMemo(function () {
1809
1846
  return selectable ? columns.length + 1 : columns.length;
1810
1847
  }, [columns, selectable]);
1848
+ var tableId = React__default.useMemo(function () {
1849
+ return id ? "" + id.charAt(0).toUpperCase() + id.slice(1) : '';
1850
+ }, [id]);
1811
1851
  return React__default.createElement("div", {
1812
1852
  className: "max-w-full overflow-x-auto"
1813
1853
  }, React__default.createElement("table", Object.assign({}, getTableProps(), {
1854
+ id: id,
1814
1855
  className: "w-full bg-base-1 rounded border-separate border border-card-stroke",
1815
1856
  cellSpacing: "0"
1816
1857
  }), React__default.createElement("thead", {
@@ -1833,7 +1874,8 @@ var TableComponent = function TableComponent(_ref2) {
1833
1874
  },
1834
1875
  checked: isHeaderSelectChecked,
1835
1876
  indeterminate: isHeaderSelectedIndeterminate,
1836
- disabled: isHeaderSelectDisabled
1877
+ disabled: isHeaderSelectDisabled,
1878
+ id: "checkboxSelectAllRows" + tableId
1837
1879
  })), headerGroup.headers.map(function (column) {
1838
1880
  var _column$getHeaderProp = column.getHeaderProps(),
1839
1881
  key = _column$getHeaderProp.key,
@@ -1849,7 +1891,7 @@ var TableComponent = function TableComponent(_ref2) {
1849
1891
  }));
1850
1892
  })), React__default.createElement("tbody", Object.assign({}, getTableBodyProps(), {
1851
1893
  className: "text-sm text-on-base"
1852
- }), isLoading ? React__default.createElement("tr", null, Array(columnsLength).fill(0).map(function (key) {
1894
+ }), isLoading ? React__default.createElement("tr", null, Array(columnsLength).fill(0).map(function (_, key) {
1853
1895
  return React__default.createElement("td", {
1854
1896
  key: key,
1855
1897
  className: "" + TdClasses
@@ -1879,7 +1921,8 @@ var TableComponent = function TableComponent(_ref2) {
1879
1921
  return handleSelectRow(index, e);
1880
1922
  },
1881
1923
  checked: isRowChecked,
1882
- disabled: isRowDisabled
1924
+ disabled: isRowDisabled,
1925
+ id: "checkboxRow" + index + tableId
1883
1926
  })), row.cells.map(function (cell) {
1884
1927
  var _cell$getCellProps = cell.getCellProps(),
1885
1928
  key = _cell$getCellProps.key,
@@ -1906,20 +1949,24 @@ var activeStyles = function activeStyles(active) {
1906
1949
 
1907
1950
 
1908
1951
  var boldFixStyle = "before:content-[attr(data-title)] before:block before:font-semibold before:h-0 before:overflow-hidden before:visibility-hidden";
1952
+ var disabledStyle = 'text-inverted-2 cursor-not-allowed';
1909
1953
  var TabsItem = function TabsItem(_ref) {
1910
1954
  var id = _ref.id,
1911
1955
  title = _ref.title,
1912
1956
  _ref$active = _ref.active,
1913
1957
  active = _ref$active === void 0 ? false : _ref$active,
1958
+ _ref$disabled = _ref.disabled,
1959
+ disabled = _ref$disabled === void 0 ? false : _ref$disabled,
1914
1960
  onChange = _ref.onChange;
1915
1961
  return React__default.createElement("button", {
1916
1962
  id: "btnTab" + id,
1917
- className: "tabs-item " + (active ? 'tabs-item-active' : '') + " group min-w-0 flex-shrink-0 overflow-x-hidden px-2 last:-mr-2 first:-ml-2",
1963
+ className: "tabs-item " + (active ? 'tabs-item-active' : '') + " group min-w-0 flex-shrink-0 overflow-x-hidden px-2 last:-mr-2 first:-ml-2 " + (disabled ? disabledStyle : ''),
1918
1964
  onClick: function onClick() {
1919
1965
  return onChange(id);
1920
- }
1966
+ },
1967
+ disabled: disabled
1921
1968
  }, React__default.createElement("span", {
1922
- className: "block text-f6 tracking-4 text-sm py-4 border-b-4 break-words group-hover:font-semibold " + activeStyles(active) + " " + boldFixStyle,
1969
+ className: "block tracking-4 text-f6 text-sm py-4 border-b-4 break-words " + (disabled ? '' : 'group-hover:font-semibold') + " " + activeStyles(active) + " " + boldFixStyle,
1923
1970
  "data-title": title
1924
1971
  }, title));
1925
1972
  };
@@ -2110,6 +2157,8 @@ var ModalComponent = function ModalComponent(_ref) {
2110
2157
  }, React__default.createElement("span", {
2111
2158
  className: "min-w-0 text-inverted-2 text-xs font-semibold uppercase break-words " + (headerTitle ? 'pb-3' : '')
2112
2159
  }, headerTitle), React__default.createElement("button", {
2160
+ type: "button",
2161
+ id: "btnCloseModal",
2113
2162
  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",
2114
2163
  onClick: handleRequestCloseFunc
2115
2164
  }, headerClose !== false && React__default.createElement("span", {