@loja-integrada/admin-components 0.9.7 → 0.11.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`.
@@ -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;
18
+ /**
19
+ * Item align
20
+ * @default 'center'
21
+ * */
6
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 ExclamationCircle: () => JSX.Element;
@@ -0,0 +1,2 @@
1
+ /// <reference types="react" />
2
+ export declare const Link: () => JSX.Element;
@@ -21,10 +21,12 @@ 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;
27
28
  eye: () => JSX.Element;
29
+ exclamationCircle: () => JSX.Element;
28
30
  exclamationTriangle: () => JSX.Element;
29
31
  externalLink: () => JSX.Element;
30
32
  home: () => JSX.Element;
@@ -37,6 +39,7 @@ export declare const icons: {
37
39
  plusCircle: () => JSX.Element;
38
40
  print: () => JSX.Element;
39
41
  infoCircle: () => JSX.Element;
42
+ link: () => JSX.Element;
40
43
  loading: () => JSX.Element;
41
44
  pix: () => JSX.Element;
42
45
  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",
@@ -250,6 +258,14 @@ var Eye = function Eye() {
250
258
  });
251
259
  };
252
260
 
261
+ var ExclamationCircle = function ExclamationCircle() {
262
+ return React__default.createElement("path", {
263
+ fillRule: "evenodd",
264
+ 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",
265
+ clipRule: "evenodd"
266
+ });
267
+ };
268
+
253
269
  var ExclamationTriangle = function ExclamationTriangle() {
254
270
  return React__default.createElement("path", {
255
271
  fillRule: "evenodd",
@@ -350,6 +366,14 @@ var InfoCircle = function InfoCircle() {
350
366
  });
351
367
  };
352
368
 
369
+ var Link = function Link() {
370
+ return React__default.createElement("path", {
371
+ fillRule: "evenodd",
372
+ clipRule: "evenodd",
373
+ 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"
374
+ });
375
+ };
376
+
353
377
  var Loading = function Loading() {
354
378
  return React__default.createElement("path", {
355
379
  fillRule: "evenodd",
@@ -511,10 +535,12 @@ var icons = {
511
535
  close: Close,
512
536
  checkCircle: CheckCircle,
513
537
  creditcard: CreditCard,
538
+ download: Download,
514
539
  product: Product,
515
540
  edit: Edit,
516
541
  exchange: Exchange,
517
542
  eye: Eye,
543
+ exclamationCircle: ExclamationCircle,
518
544
  exclamationTriangle: ExclamationTriangle,
519
545
  externalLink: ExternalLink,
520
546
  home: Home,
@@ -527,6 +553,7 @@ var icons = {
527
553
  plusCircle: PlusCircle,
528
554
  print: Print,
529
555
  infoCircle: InfoCircle,
556
+ link: Link,
530
557
  loading: Loading,
531
558
  pix: Pix,
532
559
  search: Search,
@@ -1594,16 +1621,23 @@ var DropdownWithFowardRef = /*#__PURE__*/React__default.forwardRef(DropdownCompo
1594
1621
  var Dropdown = /*#__PURE__*/React__default.memo(DropdownWithFowardRef);
1595
1622
 
1596
1623
  var CheckboxComponent = function CheckboxComponent(_ref, ref) {
1597
- var label = _ref.label,
1624
+ var _ref$className = _ref.className,
1625
+ className = _ref$className === void 0 ? '' : _ref$className,
1626
+ label = _ref.label,
1598
1627
  id = _ref.id,
1599
1628
  name = _ref.name,
1600
1629
  onChange = _ref.onChange,
1601
1630
  checked = _ref.checked,
1602
1631
  disabled = _ref.disabled,
1603
- indeterminate = _ref.indeterminate,
1632
+ _ref$indeterminate = _ref.indeterminate,
1633
+ indeterminate = _ref$indeterminate === void 0 ? false : _ref$indeterminate,
1604
1634
  _ref$boxAlign = _ref.boxAlign,
1605
1635
  boxAlign = _ref$boxAlign === void 0 ? 'center' : _ref$boxAlign,
1606
- props = _objectWithoutPropertiesLoose(_ref, ["label", "id", "name", "onChange", "checked", "disabled", "indeterminate", "boxAlign"]);
1636
+ helpText = _ref.helpText,
1637
+ _ref$hasError = _ref.hasError,
1638
+ hasError = _ref$hasError === void 0 ? false : _ref$hasError,
1639
+ errorMessage = _ref.errorMessage,
1640
+ props = _objectWithoutPropertiesLoose(_ref, ["className", "label", "id", "name", "onChange", "checked", "disabled", "indeterminate", "boxAlign", "helpText", "hasError", "errorMessage"]);
1607
1641
 
1608
1642
  var inputRef = React__default.useRef(null);
1609
1643
  var inputId = id || name;
@@ -1617,6 +1651,7 @@ var CheckboxComponent = function CheckboxComponent(_ref, ref) {
1617
1651
  setIsIndeterminate = _React$useState2[1];
1618
1652
 
1619
1653
  var isCenterBoxAlign = boxAlign === 'center';
1654
+ var hasErrorState = hasError || !!errorMessage;
1620
1655
  React__default.useEffect(function () {
1621
1656
  setIsChecked(!!checked);
1622
1657
  if (checked) setIsIndeterminate(false);
@@ -1636,7 +1671,7 @@ var CheckboxComponent = function CheckboxComponent(_ref, ref) {
1636
1671
 
1637
1672
  var checkboxIconClasses = "transition duration-200 ease-in-out " + (isChecked || isIndeterminate ? 'scale-100' : 'scale-0');
1638
1673
  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 ";
1639
- var checkboxLabelClasses = "ml-1 input-label text-f6 tracking-4 leading-6 " + (disabled ? 'text-inverted-2' : '');
1674
+ var checkboxLabelClasses = "ml-1 input-label text-f6 tracking-4 leading-6 " + (hasErrorState ? 'text-danger' : disabled ? 'text-inverted-2' : '');
1640
1675
  var alignOptions = {
1641
1676
  start: 'items-start',
1642
1677
  end: 'items-end',
@@ -1644,7 +1679,14 @@ var CheckboxComponent = function CheckboxComponent(_ref, ref) {
1644
1679
  baseline: 'items-baseline',
1645
1680
  stretch: 'items-stretch'
1646
1681
  };
1647
- return React__default.createElement("label", {
1682
+ var HelpTextComponent = React__default.createElement(InputHelpText, {
1683
+ helpText: errorMessage || helpText,
1684
+ hasError: hasErrorState,
1685
+ className: "mt-2"
1686
+ });
1687
+ return React__default.createElement("div", {
1688
+ className: "inline-block " + className
1689
+ }, React__default.createElement("label", {
1648
1690
  htmlFor: inputId,
1649
1691
  className: "inline-flex " + alignOptions[boxAlign] + " cursor-pointer"
1650
1692
  }, React__default.createElement("span", {
@@ -1678,7 +1720,7 @@ var CheckboxComponent = function CheckboxComponent(_ref, ref) {
1678
1720
  fill: "white"
1679
1721
  })))), React__default.createElement("span", {
1680
1722
  className: checkboxLabelClasses
1681
- }, label));
1723
+ }, label)), HelpTextComponent);
1682
1724
  };
1683
1725
 
1684
1726
  var CheckboxWithFowardRef = /*#__PURE__*/React__default.forwardRef(CheckboxComponent);
@@ -1717,7 +1759,8 @@ var TableComponent = function TableComponent(_ref2) {
1717
1759
  onChange = _ref2.onChange,
1718
1760
  selectedData = _ref2.selectedData,
1719
1761
  _ref2$disabledRows = _ref2.disabledRows,
1720
- disabledRows = _ref2$disabledRows === void 0 ? [] : _ref2$disabledRows;
1762
+ disabledRows = _ref2$disabledRows === void 0 ? [] : _ref2$disabledRows,
1763
+ id = _ref2.id;
1721
1764
  var rowsPropsMemoized = React__default.useMemo(function () {
1722
1765
  return rowsProps;
1723
1766
  }, [rowsProps]);
@@ -1820,9 +1863,13 @@ var TableComponent = function TableComponent(_ref2) {
1820
1863
  var columnsLength = React__default.useMemo(function () {
1821
1864
  return selectable ? columns.length + 1 : columns.length;
1822
1865
  }, [columns, selectable]);
1866
+ var tableId = React__default.useMemo(function () {
1867
+ return id ? "" + id.charAt(0).toUpperCase() + id.slice(1) : '';
1868
+ }, [id]);
1823
1869
  return React__default.createElement("div", {
1824
1870
  className: "max-w-full overflow-x-auto"
1825
1871
  }, React__default.createElement("table", Object.assign({}, getTableProps(), {
1872
+ id: id,
1826
1873
  className: "w-full bg-base-1 rounded border-separate border border-card-stroke",
1827
1874
  cellSpacing: "0"
1828
1875
  }), React__default.createElement("thead", {
@@ -1845,7 +1892,8 @@ var TableComponent = function TableComponent(_ref2) {
1845
1892
  },
1846
1893
  checked: isHeaderSelectChecked,
1847
1894
  indeterminate: isHeaderSelectedIndeterminate,
1848
- disabled: isHeaderSelectDisabled
1895
+ disabled: isHeaderSelectDisabled,
1896
+ id: "checkboxSelectAllRows" + tableId
1849
1897
  })), headerGroup.headers.map(function (column) {
1850
1898
  var _column$getHeaderProp = column.getHeaderProps(),
1851
1899
  key = _column$getHeaderProp.key,
@@ -1861,7 +1909,7 @@ var TableComponent = function TableComponent(_ref2) {
1861
1909
  }));
1862
1910
  })), React__default.createElement("tbody", Object.assign({}, getTableBodyProps(), {
1863
1911
  className: "text-sm text-on-base"
1864
- }), isLoading ? React__default.createElement("tr", null, Array(columnsLength).fill(0).map(function (key) {
1912
+ }), isLoading ? React__default.createElement("tr", null, Array(columnsLength).fill(0).map(function (_, key) {
1865
1913
  return React__default.createElement("td", {
1866
1914
  key: key,
1867
1915
  className: "" + TdClasses
@@ -1891,7 +1939,8 @@ var TableComponent = function TableComponent(_ref2) {
1891
1939
  return handleSelectRow(index, e);
1892
1940
  },
1893
1941
  checked: isRowChecked,
1894
- disabled: isRowDisabled
1942
+ disabled: isRowDisabled,
1943
+ id: "checkboxRow" + index + tableId
1895
1944
  })), row.cells.map(function (cell) {
1896
1945
  var _cell$getCellProps = cell.getCellProps(),
1897
1946
  key = _cell$getCellProps.key,
@@ -2126,6 +2175,8 @@ var ModalComponent = function ModalComponent(_ref) {
2126
2175
  }, React__default.createElement("span", {
2127
2176
  className: "min-w-0 text-inverted-2 text-xs font-semibold uppercase break-words " + (headerTitle ? 'pb-3' : '')
2128
2177
  }, headerTitle), React__default.createElement("button", {
2178
+ type: "button",
2179
+ id: "btnCloseModal",
2129
2180
  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",
2130
2181
  onClick: handleRequestCloseFunc
2131
2182
  }, headerClose !== false && React__default.createElement("span", {