@loja-integrada/admin-components 0.9.4 → 0.9.8

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.
@@ -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
@@ -3,5 +3,5 @@ export declare const Checkbox: React.MemoExoticComponent<React.ForwardRefExoticC
3
3
  export interface CheckboxProps extends React.InputHTMLAttributes<HTMLInputElement> {
4
4
  label?: string | React.ReactNode;
5
5
  indeterminate?: boolean;
6
- boxAlign?: 'center' | 'baseline';
6
+ boxAlign?: 'start' | 'end' | 'center' | 'baseline' | 'stretch';
7
7
  }
@@ -581,7 +581,8 @@ var listOfStylesHover = {
581
581
  info: "hover:bg-secondary-bold",
582
582
  warning: "hover:bg-warning-dark",
583
583
  danger: "hover:bg-danger-dark",
584
- outline: "hover:bg-primary-light"
584
+ outline: "hover:bg-primary-light",
585
+ onlyText: "hover:bg-base-2"
585
586
  };
586
587
  var listOfStylesActive = {
587
588
  primary: "active:bg-primary-bold",
@@ -589,13 +590,15 @@ var listOfStylesActive = {
589
590
  tertiary: "active:bg-tertiary-bold",
590
591
  warning: "active:bg-warning-bold",
591
592
  danger: "hover:bg-danger-bold",
592
- outline: "active:shadow-inner active:bg-base-1"
593
+ outline: "active:shadow-inner active:bg-base-1",
594
+ onlyText: "active:bg-base-1"
593
595
  };
594
596
  var listOfStylesFocus = {
595
597
  primary: "focus:ring-1 focus:ring-primary-dark focus:ring-opacity-50",
596
598
  secondary: "focus:ring focus:ring-focus",
597
599
  danger: "focus:ring-1 focus:ring-danger-dark",
598
- outline: "focus:ring-2 focus:ring-focus focus:ring-offset-1"
600
+ outline: "focus:ring-2 focus:ring-focus focus:ring-offset-1",
601
+ onlyText: "focus:bg-base-1"
599
602
  };
600
603
  var listOfStyles = {
601
604
  primary: "bg-primary text-base-1 " + listOfStylesHover['primary'] + " " + listOfStylesActive['primary'] + " " + listOfStylesFocus['primary'],
@@ -604,7 +607,8 @@ var listOfStyles = {
604
607
  info: "bg-secondary-dark text-base-1 " + listOfStylesHover['info'],
605
608
  warning: "bg-warning text-on-base " + listOfStylesHover['warning'] + " " + listOfStylesActive['warning'],
606
609
  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']
610
+ outline: "bg-transparent text-inverted-2 border border-inverted-2 " + listOfStylesHover['outline'] + " " + listOfStylesActive['outline'] + " " + listOfStylesFocus['outline'],
611
+ onlyText: "bg-transparent border-transparent text-inverted-2 px-0 " + listOfStylesHover['onlyText'] + " " + listOfStylesActive['onlyText'] + " " + listOfStylesFocus['onlyText']
608
612
  };
609
613
  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
614
  var listOfStylesDisabled = {
@@ -614,7 +618,8 @@ var listOfStylesDisabled = {
614
618
  info: defaultDisabledStyle,
615
619
  warning: defaultDisabledStyle,
616
620
  danger: defaultDisabledStyle,
617
- outline: defaultDisabledStyle
621
+ outline: defaultDisabledStyle,
622
+ onlyText: "bg-transparent text-on-base-3 shadow-none ring-0 border-0"
618
623
  };
619
624
  var listOfSizes = {
620
625
  small: "text-f7 h-8",
@@ -687,7 +692,7 @@ var LoadingPlaceholderComponent = function LoadingPlaceholderComponent(_ref) {
687
692
  return React__default.createElement("div", {
688
693
  className: "animate-pulse flex " + className
689
694
  }, React__default.createElement("div", {
690
- className: "h-4 bg-inverted-2 bg-opacity-20 rounded w-80 max-w-full"
695
+ className: "h-4 bg-inverted-2 bg-opacity-20 rounded w-full max-w-full"
691
696
  }));
692
697
  };
693
698
 
@@ -1632,9 +1637,16 @@ var CheckboxComponent = function CheckboxComponent(_ref, ref) {
1632
1637
  var checkboxIconClasses = "transition duration-200 ease-in-out " + (isChecked || isIndeterminate ? 'scale-100' : 'scale-0');
1633
1638
  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
1639
  var checkboxLabelClasses = "ml-1 input-label text-f6 tracking-4 leading-6 " + (disabled ? 'text-inverted-2' : '');
1640
+ var alignOptions = {
1641
+ start: 'items-start',
1642
+ end: 'items-end',
1643
+ center: 'items-center',
1644
+ baseline: 'items-baseline',
1645
+ stretch: 'items-stretch'
1646
+ };
1635
1647
  return React__default.createElement("label", {
1636
1648
  htmlFor: inputId,
1637
- className: "inline-flex items-" + boxAlign + " cursor-pointer"
1649
+ className: "inline-flex " + alignOptions[boxAlign] + " cursor-pointer"
1638
1650
  }, React__default.createElement("span", {
1639
1651
  className: "rounded z-50 flex items-center justify-center focus-within:ring-2 ring-focus"
1640
1652
  }, React__default.createElement("input", Object.assign({
@@ -1705,7 +1717,8 @@ var TableComponent = function TableComponent(_ref2) {
1705
1717
  onChange = _ref2.onChange,
1706
1718
  selectedData = _ref2.selectedData,
1707
1719
  _ref2$disabledRows = _ref2.disabledRows,
1708
- disabledRows = _ref2$disabledRows === void 0 ? [] : _ref2$disabledRows;
1720
+ disabledRows = _ref2$disabledRows === void 0 ? [] : _ref2$disabledRows,
1721
+ id = _ref2.id;
1709
1722
  var rowsPropsMemoized = React__default.useMemo(function () {
1710
1723
  return rowsProps;
1711
1724
  }, [rowsProps]);
@@ -1808,9 +1821,13 @@ var TableComponent = function TableComponent(_ref2) {
1808
1821
  var columnsLength = React__default.useMemo(function () {
1809
1822
  return selectable ? columns.length + 1 : columns.length;
1810
1823
  }, [columns, selectable]);
1824
+ var tableId = React__default.useMemo(function () {
1825
+ return id ? "" + id.charAt(0).toUpperCase() + id.slice(1) : '';
1826
+ }, [id]);
1811
1827
  return React__default.createElement("div", {
1812
1828
  className: "max-w-full overflow-x-auto"
1813
1829
  }, React__default.createElement("table", Object.assign({}, getTableProps(), {
1830
+ id: id,
1814
1831
  className: "w-full bg-base-1 rounded border-separate border border-card-stroke",
1815
1832
  cellSpacing: "0"
1816
1833
  }), React__default.createElement("thead", {
@@ -1833,7 +1850,8 @@ var TableComponent = function TableComponent(_ref2) {
1833
1850
  },
1834
1851
  checked: isHeaderSelectChecked,
1835
1852
  indeterminate: isHeaderSelectedIndeterminate,
1836
- disabled: isHeaderSelectDisabled
1853
+ disabled: isHeaderSelectDisabled,
1854
+ id: "checkboxSelectAllRows" + tableId
1837
1855
  })), headerGroup.headers.map(function (column) {
1838
1856
  var _column$getHeaderProp = column.getHeaderProps(),
1839
1857
  key = _column$getHeaderProp.key,
@@ -1849,10 +1867,12 @@ var TableComponent = function TableComponent(_ref2) {
1849
1867
  }));
1850
1868
  })), React__default.createElement("tbody", Object.assign({}, getTableBodyProps(), {
1851
1869
  className: "text-sm text-on-base"
1852
- }), isLoading ? React__default.createElement("tr", null, React__default.createElement("td", {
1853
- colSpan: columnsLength || 1,
1854
- className: "" + TdClasses
1855
- }, React__default.createElement(TdWrapper, null, React__default.createElement(LoadingPlaceholder, null)))) : !rows || !rows.length ? React__default.createElement("tr", null, React__default.createElement("td", {
1870
+ }), isLoading ? React__default.createElement("tr", null, Array(columnsLength).fill(0).map(function (key) {
1871
+ return React__default.createElement("td", {
1872
+ key: key,
1873
+ className: "" + TdClasses
1874
+ }, React__default.createElement(TdWrapper, null, React__default.createElement(LoadingPlaceholder, null)));
1875
+ })) : !rows || !rows.length ? React__default.createElement("tr", null, React__default.createElement("td", {
1856
1876
  colSpan: columnsLength || 1,
1857
1877
  className: "" + TdClasses
1858
1878
  }, React__default.createElement(TdWrapper, null, React__default.createElement("div", {
@@ -1877,7 +1897,8 @@ var TableComponent = function TableComponent(_ref2) {
1877
1897
  return handleSelectRow(index, e);
1878
1898
  },
1879
1899
  checked: isRowChecked,
1880
- disabled: isRowDisabled
1900
+ disabled: isRowDisabled,
1901
+ id: "checkboxRow" + index + tableId
1881
1902
  })), row.cells.map(function (cell) {
1882
1903
  var _cell$getCellProps = cell.getCellProps(),
1883
1904
  key = _cell$getCellProps.key,
@@ -1904,19 +1925,24 @@ var activeStyles = function activeStyles(active) {
1904
1925
 
1905
1926
 
1906
1927
  var boldFixStyle = "before:content-[attr(data-title)] before:block before:font-semibold before:h-0 before:overflow-hidden before:visibility-hidden";
1928
+ var disabledStyle = 'text-inverted-2 cursor-not-allowed';
1907
1929
  var TabsItem = function TabsItem(_ref) {
1908
1930
  var id = _ref.id,
1909
1931
  title = _ref.title,
1910
1932
  _ref$active = _ref.active,
1911
1933
  active = _ref$active === void 0 ? false : _ref$active,
1934
+ _ref$disabled = _ref.disabled,
1935
+ disabled = _ref$disabled === void 0 ? false : _ref$disabled,
1912
1936
  onChange = _ref.onChange;
1913
1937
  return React__default.createElement("button", {
1914
- 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",
1938
+ id: "btnTab" + id,
1939
+ 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 : ''),
1915
1940
  onClick: function onClick() {
1916
1941
  return onChange(id);
1917
- }
1942
+ },
1943
+ disabled: disabled
1918
1944
  }, React__default.createElement("span", {
1919
- className: "block text-f6 text-sm py-4 border-b-4 break-words group-hover:font-semibold " + activeStyles(active) + " " + boldFixStyle,
1945
+ className: "block tracking-4 text-f6 text-sm py-4 border-b-4 break-words " + (disabled ? '' : 'group-hover:font-semibold') + " " + activeStyles(active) + " " + boldFixStyle,
1920
1946
  "data-title": title
1921
1947
  }, title));
1922
1948
  };
@@ -2107,6 +2133,8 @@ var ModalComponent = function ModalComponent(_ref) {
2107
2133
  }, React__default.createElement("span", {
2108
2134
  className: "min-w-0 text-inverted-2 text-xs font-semibold uppercase break-words " + (headerTitle ? 'pb-3' : '')
2109
2135
  }, headerTitle), React__default.createElement("button", {
2136
+ type: "button",
2137
+ id: "btnCloseModal",
2110
2138
  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",
2111
2139
  onClick: handleRequestCloseFunc
2112
2140
  }, headerClose !== false && React__default.createElement("span", {
@@ -2825,6 +2853,7 @@ var PaginationInfoComponent = function PaginationInfoComponent(_ref) {
2825
2853
  }, React__default.createElement("div", {
2826
2854
  className: "flex items-center mr-5 text-inverted-2 tracking-4 text-f6"
2827
2855
  }, itemsLengthOptions ? React__default.createElement(Select, {
2856
+ id: "selectItemsPerPage",
2828
2857
  options: itemsLengthOptions,
2829
2858
  withoutStyle: true,
2830
2859
  "aria-label": "Itens por p\xE1gina",
@@ -2894,6 +2923,7 @@ var PaginationNavComponent = function PaginationNavComponent(_ref) {
2894
2923
  }, React__default.createElement("div", {
2895
2924
  className: "text-inverted-2 text-f6 tracking-4"
2896
2925
  }, React__default.createElement("span", {
2926
+ id: "btnPaginationActualPage",
2897
2927
  className: "pagination-nav-current text-primary font-semibold",
2898
2928
  ref: inputEl,
2899
2929
  contentEditable: true,
@@ -2903,6 +2933,7 @@ var PaginationNavComponent = function PaginationNavComponent(_ref) {
2903
2933
  onCut: onPreventDefault,
2904
2934
  onPaste: onPreventDefault
2905
2935
  }, currentPage), ' ', "/", ' ', React__default.createElement("button", {
2936
+ id: "btnPaginationLastPage",
2906
2937
  className: "pagination-nav-total focus:outline-none",
2907
2938
  onClick: function onClick() {
2908
2939
  if (currentPage !== maxTotalPages) handleChange(maxTotalPages);
@@ -2910,7 +2941,8 @@ var PaginationNavComponent = function PaginationNavComponent(_ref) {
2910
2941
  }, maxTotalPages)), React__default.createElement("div", {
2911
2942
  className: "text-inverted-2 ml-5 flex items-center"
2912
2943
  }, React__default.createElement("button", {
2913
- className: "pagination-nav-previous mr-3 duration-200 focus:outline-none " + (hasPrev ? 'hover:text-inverted-1' : ''),
2944
+ id: "btnPaginationPrev",
2945
+ className: "pagination-nav-previous mr-3 duration-200 outline-none " + (hasPrev ? 'hover:text-inverted-1' : ''),
2914
2946
  "aria-label": "Ir para p\xE1gina anterior",
2915
2947
  onClick: function onClick() {
2916
2948
  if (hasPrev) handleChange(currentPage - 1);
@@ -2920,7 +2952,8 @@ var PaginationNavComponent = function PaginationNavComponent(_ref) {
2920
2952
  block: true,
2921
2953
  size: 4
2922
2954
  })), React__default.createElement("button", {
2923
- className: "pagination-nav-next duration-200 focus:outline-none " + (hasNext ? 'hover:text-inverted-1' : ''),
2955
+ id: "btnPaginationNext",
2956
+ className: "pagination-nav-next duration-200 outline-none " + (hasNext ? 'hover:text-inverted-1' : ''),
2924
2957
  "aria-label": "Ir para pr\xF3xima p\xE1gina",
2925
2958
  onClick: function onClick() {
2926
2959
  if (hasNext) handleChange(currentPage + 1);