@tecsinapse/react-web-kit 1.18.2 → 1.18.5

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/CHANGELOG.md CHANGED
@@ -3,6 +3,39 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [1.18.5](https://github.com/tecsinapse/design-system/compare/@tecsinapse/react-web-kit@1.18.4...@tecsinapse/react-web-kit@1.18.5) (2022-08-08)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * update peerdep ([cb4ec62](https://github.com/tecsinapse/design-system/commit/cb4ec62ab2532ad7d7e38328d23bdde2581a470e))
12
+
13
+
14
+
15
+
16
+
17
+ ## [1.18.4](https://github.com/tecsinapse/design-system/compare/@tecsinapse/react-web-kit@1.18.3...@tecsinapse/react-web-kit@1.18.4) (2022-08-08)
18
+
19
+
20
+ ### Features
21
+
22
+ * added text in Footer DataGrid inform quantity items rendered of total items. ([#179497](https://github.com/tecsinapse/design-system/issues/179497)) ([0ba47c6](https://github.com/tecsinapse/design-system/commit/0ba47c66da0173418e56fcdcfa1ee5e5e9d966e3))
23
+
24
+
25
+
26
+
27
+
28
+ ## [1.18.3](https://github.com/tecsinapse/design-system/compare/@tecsinapse/react-web-kit@1.18.2...@tecsinapse/react-web-kit@1.18.3) (2022-08-03)
29
+
30
+
31
+ ### Features
32
+
33
+ * added prop exportComponent in Footer Data Grid. ([c4b63de](https://github.com/tecsinapse/design-system/commit/c4b63deeb5853e538c55a035f2312eef06efef48))
34
+
35
+
36
+
37
+
38
+
6
39
  ## [1.18.2](https://github.com/tecsinapse/design-system/compare/@tecsinapse/react-web-kit@1.18.1...@tecsinapse/react-web-kit@1.18.2) (2022-08-02)
7
40
 
8
41
 
@@ -23,6 +23,7 @@ export interface DataGridProps<Data> extends React.HTMLAttributes<HTMLDivElement
23
23
  loading?: boolean;
24
24
  skeletonComponent?: React.ReactNode;
25
25
  emptyPlaceholder?: React.ReactNode;
26
+ exportComponent?: React.ReactNode;
26
27
  }
27
- declare const DataGrid: <Data extends unknown>({ headers, data, rowKeyExtractor, toolbarTitle, toolbarFooter, toolbarRightIcons, selectable, selectedRows, onSelectedRows, pagination, rowsPerPage, onRowsPerPageChange, rowsPerPageOptions: _rowsPerPageOptions, rowsPerPageLabel: _rowsPerPageLabel, exportLabel, exportFunction, rowsCount, page, onPageChange, loading, skeletonComponent, emptyPlaceholder, ...rest }: DataGridProps<Data>) => JSX.Element;
28
+ declare const DataGrid: <Data extends unknown>({ headers, data, rowKeyExtractor, toolbarTitle, toolbarFooter, toolbarRightIcons, selectable, selectedRows, onSelectedRows, pagination, rowsPerPage, onRowsPerPageChange, rowsPerPageOptions: _rowsPerPageOptions, rowsPerPageLabel: _rowsPerPageLabel, exportLabel, exportFunction, rowsCount, page, onPageChange, loading, skeletonComponent, emptyPlaceholder, exportComponent, ...rest }: DataGridProps<Data>) => JSX.Element;
28
29
  export default DataGrid;
@@ -44,6 +44,7 @@ const DataGrid = ({
44
44
  loading = false,
45
45
  skeletonComponent,
46
46
  emptyPlaceholder,
47
+ exportComponent,
47
48
  ...rest
48
49
  }) => {
49
50
  if (selectable && (!selectedRows || !onSelectedRows)) {
@@ -113,7 +114,8 @@ const DataGrid = ({
113
114
  rowsCount: rowsCount ?? data.length,
114
115
  page: page,
115
116
  onPageChange: onPageChange,
116
- pagination: pagination
117
+ pagination: pagination,
118
+ exportComponent: exportComponent
117
119
  })));
118
120
  };
119
121
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/components/organisms/DataGrid/DataGrid.tsx"],"names":["DataGrid","headers","data","rowKeyExtractor","toolbarTitle","toolbarFooter","toolbarRightIcons","selectable","selectedRows","onSelectedRows","pagination","rowsPerPage","onRowsPerPageChange","rowsPerPageOptions","_rowsPerPageOptions","rowsPerPageLabel","_rowsPerPageLabel","exportLabel","exportFunction","rowsCount","page","onPageChange","loading","skeletonComponent","emptyPlaceholder","rest","Error","React","useCallback","value","useMemo","handleSelect","current","checked","prevState","idx","findIndex","el","length","map","item","some","sel","Array","keys","padding","width","Number"],"mappings":";;;;;;;AAAA;;AACA;;AAQA;;AACA;;AAEA;;AACA;;AACA;;;;AA2CA,MAAMA,QAAQ,GAAG,CAAuB;AACtCC,EAAAA,OADsC;AAEtCC,EAAAA,IAFsC;AAGtCC,EAAAA,eAHsC;AAItCC,EAAAA,YAJsC;AAKtCC,EAAAA,aALsC;AAMtCC,EAAAA,iBANsC;AAOtCC,EAAAA,UAAU,GAAG,KAPyB;AAQtCC,EAAAA,YAAY,GAAG,EARuB;AAStCC,EAAAA,cATsC;AAUtCC,EAAAA,UAAU,GAAG,KAVyB;AAWtCC,EAAAA,WAAW,GAAG,EAXwB;AAYtCC,EAAAA,mBAZsC;AAatCC,EAAAA,kBAAkB,EAAEC,mBAbkB;AActCC,EAAAA,gBAAgB,EAAEC,iBAdoB;AAetCC,EAAAA,WAAW,GAAG,UAfwB;AAgBtCC,EAAAA,cAhBsC;AAiBtCC,EAAAA,SAjBsC;AAkBtCC,EAAAA,IAAI,GAAG,CAlB+B;AAmBtCC,EAAAA,YAnBsC;AAoBtCC,EAAAA,OAAO,GAAG,KApB4B;AAqBtCC,EAAAA,iBArBsC;AAsBtCC,EAAAA,gBAtBsC;AAuBtC,KAAGC;AAvBmC,CAAvB,KAwBuB;AACtC,MAAIlB,UAAU,KAAK,CAACC,YAAD,IAAiB,CAACC,cAAvB,CAAd,EAAsD;AACpD,UAAM,IAAIiB,KAAJ,CACJ,iFADI,CAAN;AAGD;;AAED,QAAMX,gBAAgB,GAAGY,eAAMC,WAAN,CACvBC,KAAK,IACHb,iBAAiB,GACbA,iBAAiB,CAACa,KAAD,CADJ,GAEZ,sBAAqBA,KAAM,QAJX,EAKvB,CAACb,iBAAD,CALuB,CAAzB;;AAOA,QAAMH,kBAAkB,GAAGc,eAAMG,OAAN,CACzB,MAAMhB,mBAAmB,IAAI,CAAC,EAAD,EA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,WAFf;AAGE,IAAA,gBAAgB,EAAEF,gBAHpB;AAIE,IAAA,WAAW,EAAEJ,WAJf;AAKE,IAAA,mBAAmB,EAAEC,mBALvB;AAME,IAAA,kBAAkB,EAAEC,kBANtB;AAOE,IAAA,SAAS,EAAEM,SAAS,IAAIjB,IAAI,CAACoC,MAP/B;AAQE,IAAA,IAAI,EAAElB,IARR;AASE,IAAA,YAAY,EAAEC,YAThB;AAUE,IAAA,UAAU,EAAEX;AAVd,IAxDJ,CANF,CADF;AA+ED,CA3ID;;eA6IeV,Q","sourcesContent":["import React from 'react';\nimport {\n Table,\n TableToolbar,\n TableContainer,\n Tr,\n Td,\n TBody,\n} from '../../atoms/Table';\nimport { Header } from './Header';\nimport { Row } from './Row';\nimport { HeadersType } from './types';\nimport { Footer } from './Footer';\nimport { Skeleton } from '../../atoms/Skeleton';\nimport { getData, removeElement } from './utils';\n\nexport interface DataGridProps<Data>\n extends React.HTMLAttributes<HTMLDivElement> {\n headers: HeadersType<Data>[];\n data: Data[];\n /** Unique identifier for row data */\n rowKeyExtractor: (data: Data) => string;\n toolbarRightIcons?: React.ReactNode;\n toolbarFooter?: React.ReactNode;\n toolbarTitle: string;\n /** Enable rows selection */\n selectable?: boolean;\n /** Selected items */\n selectedRows?: Data[];\n /** Selection handler */\n onSelectedRows?: (data: Data[] | ((prevState: Data[]) => Data[])) => void;\n /** Shows pagination controls */\n pagination?: boolean;\n /** Results per page */\n rowsPerPage?: number;\n /** Results per page handler */\n onRowsPerPageChange?: (value: number) => void;\n rowsPerPageOptions?: number[];\n rowsPerPageLabel?: (value: number) => string;\n /** Export button label */\n exportLabel?: string;\n exportFunction?: () => void;\n /** Total data elements. Only specify this property if your data is server-side */\n rowsCount?: number;\n /** Current page. Always start in 0 */\n page?: number;\n /** Current page handler */\n onPageChange?: (page: number) => void;\n /** Loading state. The amount of skeleton rows is based on current rowsPerPage */\n loading?: boolean;\n /** Custom skeleton component for better visual */\n skeletonComponent?: React.ReactNode;\n /** Empty state placeholder */\n emptyPlaceholder?: React.ReactNode;\n}\n\n/** Note: Consider memoizing functions for a better performance */\nconst DataGrid = <Data extends unknown>({\n headers,\n data,\n rowKeyExtractor,\n toolbarTitle,\n toolbarFooter,\n toolbarRightIcons,\n selectable = false,\n selectedRows = [],\n onSelectedRows,\n pagination = false,\n rowsPerPage = 10,\n onRowsPerPageChange,\n rowsPerPageOptions: _rowsPerPageOptions,\n rowsPerPageLabel: _rowsPerPageLabel,\n exportLabel = 'Exportar',\n exportFunction,\n rowsCount,\n page = 0,\n onPageChange,\n loading = false,\n skeletonComponent,\n emptyPlaceholder,\n ...rest\n}: DataGridProps<Data>): JSX.Element => {\n if (selectable && (!selectedRows || !onSelectedRows)) {\n throw new Error(\n '[DataGrid] You should specify selection handlers (selectedRows, onSelectedRows)'\n );\n }\n\n const rowsPerPageLabel = React.useCallback(\n value =>\n _rowsPerPageLabel\n ? _rowsPerPageLabel(value)\n : `Exibir por página: ${value} itens`,\n [_rowsPerPageLabel]\n );\n const rowsPerPageOptions = React.useMemo(\n () => _rowsPerPageOptions ?? [10, 25, 50],\n [_rowsPerPageOptions]\n );\n\n const handleSelect = React.useCallback(\n (current, checked) => {\n if (checked) {\n onSelectedRows?.(prevState => [...prevState, current]);\n return;\n }\n\n onSelectedRows?.(prevState => {\n const idx = prevState.findIndex(\n el => rowKeyExtractor(el) === rowKeyExtractor(current)\n );\n return [...removeElement(prevState, idx)];\n });\n },\n [onSelectedRows, rowKeyExtractor]\n );\n\n return (\n <TableContainer {...rest}>\n <TableToolbar\n title={toolbarTitle}\n rightIcons={toolbarRightIcons}\n footer={toolbarFooter}\n />\n <Table>\n <Header\n selectable={selectable}\n headers={headers}\n data={data}\n rowsCount={rowsCount ?? data.length}\n rowKeyExtractor={rowKeyExtractor}\n selectedRows={selectedRows}\n onSelected={onSelectedRows}\n />\n\n {!loading ? (\n <TBody>\n {data.length > 0 ? (\n getData(\n data,\n rowsCount,\n page,\n rowsPerPage,\n pagination\n ).map(item => (\n <Row\n key={rowKeyExtractor(item)}\n rowKeyExtractor={rowKeyExtractor}\n handleSelect={handleSelect}\n selectable={selectable}\n headers={headers}\n data={item}\n checked={selectedRows?.some(\n sel => rowKeyExtractor(sel) === rowKeyExtractor(item)\n )}\n />\n ))\n ) : (\n <tr>\n <td colSpan={99}>{emptyPlaceholder}</td>\n </tr>\n )}\n </TBody>\n ) : (\n <TBody>\n {[...Array(rowsPerPage).keys()].map(idx => (\n <Tr key={`skeleton-${idx}`}>\n <Td colSpan={99} style={{ padding: 0 }}>\n {skeletonComponent ?? (\n <Skeleton height={55} radius=\"mili\" animation=\"wave\">\n <div style={{ width: '100%' }} />\n </Skeleton>\n )}\n </Td>\n </Tr>\n ))}\n </TBody>\n )}\n\n {(Number(rowsCount) > 0 || data.length > 0) && (\n <Footer\n exportFunction={exportFunction}\n exportLabel={exportLabel}\n rowsPerPageLabel={rowsPerPageLabel}\n rowsPerPage={rowsPerPage}\n onRowsPerPageChange={onRowsPerPageChange}\n rowsPerPageOptions={rowsPerPageOptions}\n rowsCount={rowsCount ?? data.length}\n page={page}\n onPageChange={onPageChange}\n pagination={pagination}\n />\n )}\n </Table>\n </TableContainer>\n );\n};\n\nexport default DataGrid;\n"],"file":"DataGrid.js"}
1
+ {"version":3,"sources":["../../../../src/components/organisms/DataGrid/DataGrid.tsx"],"names":["DataGrid","headers","data","rowKeyExtractor","toolbarTitle","toolbarFooter","toolbarRightIcons","selectable","selectedRows","onSelectedRows","pagination","rowsPerPage","onRowsPerPageChange","rowsPerPageOptions","_rowsPerPageOptions","rowsPerPageLabel","_rowsPerPageLabel","exportLabel","exportFunction","rowsCount","page","onPageChange","loading","skeletonComponent","emptyPlaceholder","exportComponent","rest","Error","React","useCallback","value","useMemo","handleSelect","current","checked","prevState","idx","findIndex","el","length","map","item","some","sel","Array","keys","padding","width","Number"],"mappings":";;;;;;;AAAA;;AACA;;AAQA;;AACA;;AAEA;;AACA;;AACA;;;;AA6CA,MAAMA,QAAQ,GAAG,C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AS,EAAEM,SAAS,IAAIjB,IAAI,CAACqC,MAP/B;AAQE,IAAA,IAAI,EAAEnB,IARR;AASE,IAAA,YAAY,EAAEC,YAThB;AAUE,IAAA,UAAU,EAAEX,UAVd;AAWE,IAAA,eAAe,EAAEe;AAXnB,IAxDJ,CANF,CADF;AAgFD,CA7ID;;eA+IezB,Q","sourcesContent":["import React from 'react';\nimport {\n Table,\n TableToolbar,\n TableContainer,\n Tr,\n Td,\n TBody,\n} from '../../atoms/Table';\nimport { Header } from './Header';\nimport { Row } from './Row';\nimport { HeadersType } from './types';\nimport { Footer } from './Footer';\nimport { Skeleton } from '../../atoms/Skeleton';\nimport { getData, removeElement } from './utils';\n\nexport interface DataGridProps<Data>\n extends React.HTMLAttributes<HTMLDivElement> {\n headers: HeadersType<Data>[];\n data: Data[];\n /** Unique identifier for row data */\n rowKeyExtractor: (data: Data) => string;\n toolbarRightIcons?: React.ReactNode;\n toolbarFooter?: React.ReactNode;\n toolbarTitle: string;\n /** Enable rows selection */\n selectable?: boolean;\n /** Selected items */\n selectedRows?: Data[];\n /** Selection handler */\n onSelectedRows?: (data: Data[] | ((prevState: Data[]) => Data[])) => void;\n /** Shows pagination controls */\n pagination?: boolean;\n /** Results per page */\n rowsPerPage?: number;\n /** Results per page handler */\n onRowsPerPageChange?: (value: number) => void;\n rowsPerPageOptions?: number[];\n rowsPerPageLabel?: (value: number) => string;\n /** Export button label */\n exportLabel?: string;\n exportFunction?: () => void;\n /** Total data elements. Only specify this property if your data is server-side */\n rowsCount?: number;\n /** Current page. Always start in 0 */\n page?: number;\n /** Current page handler */\n onPageChange?: (page: number) => void;\n /** Loading state. The amount of skeleton rows is based on current rowsPerPage */\n loading?: boolean;\n /** Custom skeleton component for better visual */\n skeletonComponent?: React.ReactNode;\n /** Empty state placeholder */\n emptyPlaceholder?: React.ReactNode;\n /** Export component, use if default button with label is not ideal. This prop, not receive \"exportLabel\" and \"exportFunction\" */\n exportComponent?: React.ReactNode;\n}\n\n/** Note: Consider memoizing functions for a better performance */\nconst DataGrid = <Data extends unknown>({\n headers,\n data,\n rowKeyExtractor,\n toolbarTitle,\n toolbarFooter,\n toolbarRightIcons,\n selectable = false,\n selectedRows = [],\n onSelectedRows,\n pagination = false,\n rowsPerPage = 10,\n onRowsPerPageChange,\n rowsPerPageOptions: _rowsPerPageOptions,\n rowsPerPageLabel: _rowsPerPageLabel,\n exportLabel = 'Exportar',\n exportFunction,\n rowsCount,\n page = 0,\n onPageChange,\n loading = false,\n skeletonComponent,\n emptyPlaceholder,\n exportComponent,\n ...rest\n}: DataGridProps<Data>): JSX.Element => {\n if (selectable && (!selectedRows || !onSelectedRows)) {\n throw new Error(\n '[DataGrid] You should specify selection handlers (selectedRows, onSelectedRows)'\n );\n }\n\n const rowsPerPageLabel = React.useCallback(\n value =>\n _rowsPerPageLabel\n ? _rowsPerPageLabel(value)\n : `Exibir por página: ${value} itens`,\n [_rowsPerPageLabel]\n );\n const rowsPerPageOptions = React.useMemo(\n () => _rowsPerPageOptions ?? [10, 25, 50],\n [_rowsPerPageOptions]\n );\n\n const handleSelect = React.useCallback(\n (current, checked) => {\n if (checked) {\n onSelectedRows?.(prevState => [...prevState, current]);\n return;\n }\n\n onSelectedRows?.(prevState => {\n const idx = prevState.findIndex(\n el => rowKeyExtractor(el) === rowKeyExtractor(current)\n );\n return [...removeElement(prevState, idx)];\n });\n },\n [onSelectedRows, rowKeyExtractor]\n );\n\n return (\n <TableContainer {...rest}>\n <TableToolbar\n title={toolbarTitle}\n rightIcons={toolbarRightIcons}\n footer={toolbarFooter}\n />\n <Table>\n <Header\n selectable={selectable}\n headers={headers}\n data={data}\n rowsCount={rowsCount ?? data.length}\n rowKeyExtractor={rowKeyExtractor}\n selectedRows={selectedRows}\n onSelected={onSelectedRows}\n />\n\n {!loading ? (\n <TBody>\n {data.length > 0 ? (\n getData(\n data,\n rowsCount,\n page,\n rowsPerPage,\n pagination\n ).map(item => (\n <Row\n key={rowKeyExtractor(item)}\n rowKeyExtractor={rowKeyExtractor}\n handleSelect={handleSelect}\n selectable={selectable}\n headers={headers}\n data={item}\n checked={selectedRows?.some(\n sel => rowKeyExtractor(sel) === rowKeyExtractor(item)\n )}\n />\n ))\n ) : (\n <tr>\n <td colSpan={99}>{emptyPlaceholder}</td>\n </tr>\n )}\n </TBody>\n ) : (\n <TBody>\n {[...Array(rowsPerPage).keys()].map(idx => (\n <Tr key={`skeleton-${idx}`}>\n <Td colSpan={99} style={{ padding: 0 }}>\n {skeletonComponent ?? (\n <Skeleton height={55} radius=\"mili\" animation=\"wave\">\n <div style={{ width: '100%' }} />\n </Skeleton>\n )}\n </Td>\n </Tr>\n ))}\n </TBody>\n )}\n\n {(Number(rowsCount) > 0 || data.length > 0) && (\n <Footer\n exportFunction={exportFunction}\n exportLabel={exportLabel}\n rowsPerPageLabel={rowsPerPageLabel}\n rowsPerPage={rowsPerPage}\n onRowsPerPageChange={onRowsPerPageChange}\n rowsPerPageOptions={rowsPerPageOptions}\n rowsCount={rowsCount ?? data.length}\n page={page}\n onPageChange={onPageChange}\n pagination={pagination}\n exportComponent={exportComponent}\n />\n )}\n </Table>\n </TableContainer>\n );\n};\n\nexport default DataGrid;\n"],"file":"DataGrid.js"}
@@ -10,6 +10,7 @@ interface DataGridFooterProps {
10
10
  page: number;
11
11
  onPageChange?: (page: number) => void;
12
12
  pagination: boolean;
13
+ exportComponent?: React.ReactNode;
13
14
  }
14
15
  declare const _default: React.NamedExoticComponent<DataGridFooterProps>;
15
16
  export default _default;
@@ -25,7 +25,8 @@ const Footer = ({
25
25
  rowsCount,
26
26
  page,
27
27
  onPageChange,
28
- pagination
28
+ pagination,
29
+ exportComponent
29
30
  }) => {
30
31
  if (pagination && (!onPageChange || !onRowsPerPageChange)) {
31
32
  throw new Error('[DataGrid] You should specify pagination handlers (onPageChange, onRowsPerPageChange)');
@@ -66,6 +67,7 @@ const Footer = ({
66
67
  onPageChange === null || onPageChange === void 0 ? void 0 : onPageChange(0);
67
68
  }, [onPageChange, onRowsPerPageChange]);
68
69
 
70
+ const quantityRowsRendered = rowsPerPage > rowsCount ? rowsCount : rowsPerPage;
69
71
  return _react.default.createElement(_Table.TFoot, null, _react.default.createElement(_Table.Tr, null, _react.default.createElement(_styled.TdFooterStyled, {
70
72
  colSpan: 99
71
73
  }, _react.default.createElement(_styled.FooterContainer, null, _react.default.createElement(_styled.FooterContainerStart, null, pagination && _react.default.createElement(_styled.SelectContainer, null, _react.default.createElement(_reactWebKit.Select, {
@@ -76,13 +78,16 @@ const Footer = ({
76
78
  keyExtractor: value => String(value),
77
79
  labelExtractor: rowsPerPageLabel,
78
80
  anchor: "top"
79
- })), exportFunction && _react.default.createElement(_styled.HoveredText, null, _react.default.createElement(_reactWebKit.Button, {
81
+ })), exportComponent && !exportFunction && _react.default.createElement(_react.default.Fragment, null, exportComponent), exportFunction && _react.default.createElement(_styled.HoveredText, null, _react.default.createElement(_reactWebKit.Button, {
80
82
  variant: "outlined",
81
83
  onPress: () => exportFunction()
82
84
  }, _react.default.createElement(_reactWebKit.Text, {
83
85
  fontColor: "orange",
84
86
  fontWeight: "bold"
85
- }, exportLabel)))), pagination && _react.default.createElement(_styled.FooterContainerEnd, null, _react.default.createElement(_styled.NavigationButton, {
87
+ }, exportLabel)))), pagination && _react.default.createElement(_react.default.Fragment, null, _react.default.createElement(_styled.TextPagination, {
88
+ fontWeight: 'bold',
89
+ fontColor: 'medium'
90
+ }, `Exibindo ${quantityRowsRendered} de ${rowsCount} registros`), _react.default.createElement(_styled.FooterContainerEnd, null, _react.default.createElement(_styled.NavigationButton, {
86
91
  onPress: () => onPageChange === null || onPageChange === void 0 ? void 0 : onPageChange(page - 1),
87
92
  disabled: page === 0
88
93
  }, _react.default.createElement(_reactWebKit.Icon, {
@@ -104,7 +109,7 @@ const Footer = ({
104
109
  name: 'chevron-right',
105
110
  type: 'material-community',
106
111
  fontColor: 'light'
107
- })))))));
112
+ }))))))));
108
113
  };
109
114
 
110
115
  var _default = _react.default.memo(Footer);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/components/organisms/DataGrid/Footer/Footer.tsx"],"names":["Footer","rowsPerPage","onRowsPerPageChange","rowsPerPageOptions","rowsPerPageLabel","exportFunction","exportLabel","rowsCount","page","onPageChange","pagination","Error","getPaginationSlice","totalPages","Math","ceil","start","end","handleRowsPerPage","React","useCallback","value","String","Array","keys","slice","map","memo"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;;;AA0BA,MAAMA,MAAqC,GAAG,CAAC;AAC7CC,EAAAA,WAD6C;AAE7CC,EAAAA,mBAF6C;AAG7CC,EAAAA,kBAH6C;AAI7CC,EAAAA,gBAJ6C;AAK7CC,EAAAA,cAL6C;AAM7CC,EAAAA,WAN6C;AAO7CC,EAAAA,SAP6C;AAQ7CC,EAAAA,IAR6C;AAS7CC,EAAAA,YAT6C;AAU7CC,EAAAA;AAV6C,CAAD,KAWxC;AACJ,MAAIA,UAAU,KAAK,CAACD,YAAD,IAAiB,CAACP,mBAAvB,CAAd,EAA2D;AACzD,UAAM,IAAIS,KAAJ,CACJ,uFADI,CAAN;AAGD;;AAED,QAAMC,kBAAkB,GAAG,MAAsC;AAC/D,UAAMC,UAAU,GAAGC,IAAI,CAACC,IAAL,CAAUR,SAAS,GAAGN,WAAtB,CAAnB;;AACA,QAAIY,UAAU,GAAG,CAAjB,EAAoB;AAClB,aAAO;AAAEG,QAAAA,KAAK,EAAE,CAAT;AAAYC,QAAAA,GAAG,EAAEJ;AAAjB,OAAP;AACD;;AACD,QAAIL,IAAI,KAAK,CAAb,EAAgB;AACd,aAAO;AAAEQ,QAAAA,KAAK,EAAER,IAAT;AAAeS,QAAAA,GAAG,EAAET,IAAI,GAAG;AAA3B,OAAP;AACD;;AACD,QAAIA,IAAI,KAAKK,UAAU,GAAG,CAA1B,EAA6B;AAC3B,aAAO;AAAEG,QAAAA,KAAK,EAAER,IAAI,GAAG,CAAhB;AAAmBS,QAAAA,GAAG,EAAET,IAAI,GAAG;AAA/B,OAAP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ent":["import React from 'react';\nimport { Button, Icon, Select, Text } from '@tecsinapse/react-web-kit';\nimport { TFoot, Tr } from '../../../atoms/Table';\nimport {\n FooterContainer,\n FooterContainerEnd,\n FooterContainerStart,\n HoveredText,\n NavigationButton,\n PageButton,\n PagesContainer,\n SelectContainer,\n TdFooterStyled,\n} from './styled';\n\ninterface DataGridFooterProps {\n rowsPerPage: number;\n onRowsPerPageChange?: (value: number) => void;\n rowsPerPageOptions: number[];\n rowsPerPageLabel: (value: number) => string;\n exportLabel?: string;\n exportFunction?: () => void;\n /** Total data elements */\n rowsCount: number;\n page: number;\n onPageChange?: (page: number) => void;\n pagination: boolean;\n}\n\nconst Footer: React.FC<DataGridFooterProps> = ({\n rowsPerPage,\n onRowsPerPageChange,\n rowsPerPageOptions,\n rowsPerPageLabel,\n exportFunction,\n exportLabel,\n rowsCount,\n page,\n onPageChange,\n pagination,\n}) => {\n if (pagination && (!onPageChange || !onRowsPerPageChange)) {\n throw new Error(\n '[DataGrid] You should specify pagination handlers (onPageChange, onRowsPerPageChange)'\n );\n }\n\n const getPaginationSlice = (): { start: number; end: number } => {\n const totalPages = Math.ceil(rowsCount / rowsPerPage);\n if (totalPages < 4) {\n return { start: 0, end: totalPages };\n }\n if (page === 0) {\n return { start: page, end: page + 3 };\n }\n if (page === totalPages - 1) {\n return { start: page - 2, end: page + 1 };\n }\n return { start: page - 1, end: page + 2 };\n };\n\n const handleRowsPerPage = React.useCallback(\n value => {\n onRowsPerPageChange?.(value as number);\n onPageChange?.(0);\n },\n [onPageChange, onRowsPerPageChange]\n );\n\n return (\n <TFoot>\n <Tr>\n <TdFooterStyled colSpan={99}>\n <FooterContainer>\n <FooterContainerStart>\n {pagination && (\n <SelectContainer>\n <Select\n options={rowsPerPageOptions}\n onSelect={handleRowsPerPage}\n value={rowsPerPage}\n type={'single'}\n keyExtractor={value => String(value)}\n labelExtractor={rowsPerPageLabel}\n anchor=\"top\"\n />\n </SelectContainer>\n )}\n {exportFunction && (\n <HoveredText>\n <Button variant=\"outlined\" onPress={() => exportFunction()}>\n <Text fontColor=\"orange\" fontWeight=\"bold\">\n {exportLabel}\n </Text>\n </Button>\n </HoveredText>\n )}\n </FooterContainerStart>\n {pagination && (\n <FooterContainerEnd>\n <NavigationButton\n onPress={() => onPageChange?.(page - 1)}\n disabled={page === 0}\n >\n <Icon\n name={'chevron-left'}\n type={'material-community'}\n fontColor={'light'}\n />\n </NavigationButton>\n <PagesContainer>\n {[...Array(Math.ceil(rowsCount / rowsPerPage)).keys()]\n .slice(getPaginationSlice().start, getPaginationSlice().end)\n .map(value => (\n <HoveredText key={`page-${value}`}>\n <PageButton\n variant={page === value ? 'outlined' : 'text'}\n onPress={() => onPageChange?.(value)}\n >\n <Text fontColor=\"medium\" fontWeight=\"bold\">\n {value + 1}\n </Text>\n </PageButton>\n </HoveredText>\n ))}\n </PagesContainer>\n <NavigationButton\n onPress={() => onPageChange?.(page + 1)}\n disabled={page === Math.ceil(rowsCount / rowsPerPage) - 1}\n >\n <Icon\n name={'chevron-right'}\n type={'material-community'}\n fontColor={'light'}\n />\n </NavigationButton>\n </FooterContainerEnd>\n )}\n </FooterContainer>\n </TdFooterStyled>\n </Tr>\n </TFoot>\n );\n};\n\nexport default React.memo(Footer);\n"],"file":"Footer.js"}
1
+ {"version":3,"sources":["../../../../../src/components/organisms/DataGrid/Footer/Footer.tsx"],"names":["Footer","rowsPerPage","onRowsPerPageChange","rowsPerPageOptions","rowsPerPageLabel","exportFunction","exportLabel","rowsCount","page","onPageChange","pagination","exportComponent","Error","getPaginationSlice","totalPages","Math","ceil","start","end","handleRowsPerPage","React","useCallback","value","quantityRowsRendered","String","Array","keys","slice","map","memo"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;;;AA4BA,MAAMA,MAAqC,GAAG,CAAC;AAC7CC,EAAAA,WAD6C;AAE7CC,EAAAA,mBAF6C;AAG7CC,EAAAA,kBAH6C;AAI7CC,EAAAA,gBAJ6C;AAK7CC,EAAAA,cAL6C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,IAAI,EAAE,oBAFR;AAGE,IAAA,SAAS,EAAE;AAHb,IAJF,CADF,EAWE,6BAAC,sBAAD,QACG,CAAC,GAAGiB,KAAK,CAACV,IAAI,CAACC,IAAL,CAAUT,SAAS,GAAGN,WAAtB,CAAD,CAAL,CAA0CyB,IAA1C,EAAJ,EACEC,KADF,CAEGd,kBAAkB,GAAGI,KAFxB,EAGGJ,kBAAkB,GAAGK,GAHxB,EAKEU,GALF,CAKMN,KAAK,IACR,6BAAC,mBAAD;AAAa,IAAA,GAAG,EAAG,QAAOA,KAAM;AAAhC,KACE,6BAAC,kBAAD;AACE,IAAA,OAAO,EAAEd,IAAI,KAAKc,KAAT,GAAiB,UAAjB,GAA8B,MADzC;AAEE,IAAA,OAAO,EAAE,MAAMb,YAAN,aAAMA,YAAN,uBAAMA,YAAY,CAAGa,KAAH;AAF7B,KAIE,6BAAC,iBAAD;AAAM,IAAA,SAAS,EAAC,QAAhB;AAAyB,IAAA,UAAU,EAAC;AAApC,KACGA,KAAK,GAAG,CADX,CAJF,CADF,CANH,CADH,CAXF,EA8BE,6BAAC,wBAAD;AACE,IAAA,OAAO,EAAE,MAAMb,YAAN,aAAMA,YAAN,uBAAMA,YAAY,CAAGD,IAAI,GAAG,CAAV,CAD7B;AAEE,IAAA,QAAQ,EAAEA,IAAI,KAAKO,IAAI,CAACC,IAAL,CAAUT,SAAS,GAAGN,WAAtB,IAAqC;AAF1D,KAIE,6BAAC,iBAAD;AACE,IAAA,IAAI,EAAE,eADR;AAEE,IAAA,IAAI,EAAE,oBAFR;AAGE,IAAA,SAAS,EAAE;AAHb,IAJF,CA9BF,CALF,CA3BJ,CADF,CADF,CADF,CADF;AAoFD,CAhID;;eAkIemB,eAAMS,IAAN,CAAW7B,MAAX,C","sourcesContent":["import React from 'react';\nimport { Button, Icon, Select, Text } from '@tecsinapse/react-web-kit';\nimport { TFoot, Tr } from '../../../atoms/Table';\nimport {\n FooterContainer,\n FooterContainerEnd,\n FooterContainerStart,\n HoveredText,\n NavigationButton,\n PageButton,\n PagesContainer,\n SelectContainer,\n TdFooterStyled,\n TextPagination,\n} from './styled';\n\ninterface DataGridFooterProps {\n rowsPerPage: number;\n onRowsPerPageChange?: (value: number) => void;\n rowsPerPageOptions: number[];\n rowsPerPageLabel: (value: number) => string;\n exportLabel?: string;\n exportFunction?: () => void;\n /** Total data elements */\n rowsCount: number;\n page: number;\n onPageChange?: (page: number) => void;\n pagination: boolean;\n exportComponent?: React.ReactNode;\n}\n\nconst Footer: React.FC<DataGridFooterProps> = ({\n rowsPerPage,\n onRowsPerPageChange,\n rowsPerPageOptions,\n rowsPerPageLabel,\n exportFunction,\n exportLabel,\n rowsCount,\n page,\n onPageChange,\n pagination,\n exportComponent,\n}) => {\n if (pagination && (!onPageChange || !onRowsPerPageChange)) {\n throw new Error(\n '[DataGrid] You should specify pagination handlers (onPageChange, onRowsPerPageChange)'\n );\n }\n\n const getPaginationSlice = (): { start: number; end: number } => {\n const totalPages = Math.ceil(rowsCount / rowsPerPage);\n if (totalPages < 4) {\n return { start: 0, end: totalPages };\n }\n if (page === 0) {\n return { start: page, end: page + 3 };\n }\n if (page === totalPages - 1) {\n return { start: page - 2, end: page + 1 };\n }\n return { start: page - 1, end: page + 2 };\n };\n\n const handleRowsPerPage = React.useCallback(\n value => {\n onRowsPerPageChange?.(value as number);\n onPageChange?.(0);\n },\n [onPageChange, onRowsPerPageChange]\n );\n\n const quantityRowsRendered =\n rowsPerPage > rowsCount ? rowsCount : rowsPerPage;\n\n return (\n <TFoot>\n <Tr>\n <TdFooterStyled colSpan={99}>\n <FooterContainer>\n <FooterContainerStart>\n {pagination && (\n <SelectContainer>\n <Select\n options={rowsPerPageOptions}\n onSelect={handleRowsPerPage}\n value={rowsPerPage}\n type={'single'}\n keyExtractor={value => String(value)}\n labelExtractor={rowsPerPageLabel}\n anchor=\"top\"\n />\n </SelectContainer>\n )}\n {exportComponent && !exportFunction && <>{exportComponent}</>}\n {exportFunction && (\n <HoveredText>\n <Button variant=\"outlined\" onPress={() => exportFunction()}>\n <Text fontColor=\"orange\" fontWeight=\"bold\">\n {exportLabel}\n </Text>\n </Button>\n </HoveredText>\n )}\n </FooterContainerStart>\n {pagination && (\n <>\n <TextPagination\n fontWeight={'bold'}\n fontColor={'medium'}\n >{`Exibindo ${quantityRowsRendered} de ${rowsCount} registros`}</TextPagination>\n <FooterContainerEnd>\n <NavigationButton\n onPress={() => onPageChange?.(page - 1)}\n disabled={page === 0}\n >\n <Icon\n name={'chevron-left'}\n type={'material-community'}\n fontColor={'light'}\n />\n </NavigationButton>\n <PagesContainer>\n {[...Array(Math.ceil(rowsCount / rowsPerPage)).keys()]\n .slice(\n getPaginationSlice().start,\n getPaginationSlice().end\n )\n .map(value => (\n <HoveredText key={`page-${value}`}>\n <PageButton\n variant={page === value ? 'outlined' : 'text'}\n onPress={() => onPageChange?.(value)}\n >\n <Text fontColor=\"medium\" fontWeight=\"bold\">\n {value + 1}\n </Text>\n </PageButton>\n </HoveredText>\n ))}\n </PagesContainer>\n <NavigationButton\n onPress={() => onPageChange?.(page + 1)}\n disabled={page === Math.ceil(rowsCount / rowsPerPage) - 1}\n >\n <Icon\n name={'chevron-right'}\n type={'material-community'}\n fontColor={'light'}\n />\n </NavigationButton>\n </FooterContainerEnd>\n </>\n )}\n </FooterContainer>\n </TdFooterStyled>\n </Tr>\n </TFoot>\n );\n};\n\nexport default React.memo(Footer);\n"],"file":"Footer.js"}
@@ -33,3 +33,6 @@ export declare const NavigationButton: import("@emotion/native").StyledComponent
33
33
  export declare const PageButton: import("@emotion/native").StyledComponent<any, {}, {}>;
34
34
  export declare const PagesContainer: import("@emotion/styled").StyledComponent<any, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
35
35
  export declare const HoveredText: import("@emotion/styled").StyledComponent<any, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
36
+ export declare const TextPagination: import("@emotion/native").StyledComponent<any, {}, {
37
+ ref?: import("react").Ref<any> | undefined;
38
+ }>;
@@ -3,12 +3,14 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.HoveredText = exports.PagesContainer = exports.PageButton = exports.NavigationButton = exports.SelectContainer = exports.FooterContainerEnd = exports.FooterContainerStart = exports.FooterContainer = exports.FlexContainer = exports.TdFooterStyled = void 0;
6
+ exports.TextPagination = exports.HoveredText = exports.PagesContainer = exports.PageButton = exports.NavigationButton = exports.SelectContainer = exports.FooterContainerEnd = exports.FooterContainerStart = exports.FooterContainer = exports.FlexContainer = exports.TdFooterStyled = void 0;
7
7
 
8
8
  var _styled = _interopRequireDefault(require("@emotion/styled"));
9
9
 
10
10
  var _native = _interopRequireDefault(require("@emotion/native"));
11
11
 
12
+ var _reactWebKit = require("@tecsinapse/react-web-kit");
13
+
12
14
  var _Table = require("../../../atoms/Table");
13
15
 
14
16
  var _Button = require("../../../atoms/Button");
@@ -90,4 +92,14 @@ const HoveredText = (0, _styled.default)('div')`
90
92
  }
91
93
  `;
92
94
  exports.HoveredText = HoveredText;
95
+ const TextPagination = (0, _native.default)(_reactWebKit.Text)`
96
+ padding-right: ${({
97
+ theme
98
+ }) => theme.spacing.deca};
99
+ padding-left: ${({
100
+ theme
101
+ }) => theme.spacing.deca};
102
+
103
+ `;
104
+ exports.TextPagination = TextPagination;
93
105
  //# sourceMappingURL=styled.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/components/organisms/DataGrid/Footer/styled.ts"],"names":["TdFooterStyled","Td","theme","spacing","centi","FlexContainer","FooterContainer","FooterContainerStart","FooterContainerEnd","SelectContainer","deca","NavigationButton","Button","borderRadius","mili","PageButton","micro","PagesContainer","HoveredText","font","color","light"],"mappings":";;;;;;;AAAA;;AACA;;AAEA;;AACA;;;;AAEO,MAAMA,cAAc,GAAG,qBAAOC,SAAP,CAAgC;AAC9D,aAAa,CAAC;AAAEC,EAAAA;AAAF,CAAD,KA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qBAAO,KAAP,CAAmC;AACjE;AACA;AACA,CAHO;;AAKA,MAAMC,WAAW,GAAG,qBAAO,KAAP,CAAmC;AAC9D;AACA;AACA,aAAa,CAAC;AAAEhB,EAAAA;AAAF,CAAD,KAAeA,KAAK,CAACiB,IAAN,CAAWC,KAAX,CAAiBC,KAAM;AACnD;AACA,CALO","sourcesContent":["import styled from '@emotion/styled';\nimport { default as nativeStyled } from '@emotion/native';\nimport { StyleProps } from '@tecsinapse/react-core';\nimport { Td } from '../../../atoms/Table';\nimport { Button } from '../../../atoms/Button';\n\nexport const TdFooterStyled = styled(Td)<Partial<StyleProps>>`\n padding: ${({ theme }) => theme.spacing.centi} 0 0 0;\n`;\n\nexport const FlexContainer = styled('div')`\n display: flex;\n flex-grow: 1;\n`;\n\nexport const FooterContainer = styled(FlexContainer)`\n justify-content: space-between;\n align-items: center;\n`;\n\nexport const FooterContainerStart = styled(FlexContainer)`\n justify-content: flex-start;\n`;\n\nexport const FooterContainerEnd = styled(FlexContainer)`\n justify-content: flex-end;\n`;\n\nexport const SelectContainer = styled('div')<Partial<StyleProps>>`\n margin-right: ${({ theme }) => theme.spacing.deca};\n`;\n\nexport const NavigationButton = nativeStyled(Button)<Partial<StyleProps>>` \n border-radius: ${({ theme }) => theme.borderRadius.mili};\n height: 44px;\n justify-content: center;\n padding: ${({ theme }) => theme.spacing.centi};\n width: 44px; \n`;\n\n// Se o botão estiver ativo, renderizar outlined, caso contrario o botão é text\nexport const PageButton = nativeStyled(NavigationButton)<Partial<StyleProps>>`\n padding-right: ${({ theme }) => theme.spacing.deca};\n padding-left: ${({ theme }) => theme.spacing.deca};\n border-radius: ${({ theme }) => theme.borderRadius.mili};\n justify-content: center;\n margin-left: ${({ theme }) => theme.spacing.micro};\n margin-right: ${({ theme }) => theme.spacing.micro};\n`;\n\nexport const PagesContainer = styled('div')<Partial<StyleProps>>`\n margin: 0 20px;\n display: flex;\n`;\n\nexport const HoveredText = styled('div')<Partial<StyleProps>>`\n user-select: none;\n &:hover * {\n color: ${({ theme }) => theme.font.color.light};\n }\n`;\n"],"file":"styled.js"}
1
+ {"version":3,"sources":["../../../../../src/components/organisms/DataGrid/Footer/styled.ts"],"names":["TdFooterStyled","Td","theme","spacing","centi","FlexContainer","FooterContainer","FooterContainerStart","FooterContainerEnd","SelectContainer","deca","NavigationButton","Button","borderRadius","mili","PageButton","micro","PagesContainer","HoveredText","font","color","light","TextPagination","Text"],"mappings":";;;;;;;AAAA;;AACA;;AAEA;;AACA;;AACA;;;;AAEO,MAAMA,cAAc,GAAG,qBAAOC,SAAP,CAAgC;AAC9D,aAAa,CAAC;AAAEC,EAAAA;AAAF,CAAD,KAAeA,KAAK,CAACC,OAAN,CAAcC,KAAM;AAChD,CAFO;;AAIA,MAAMC,aAAa,GAAG,qBAAO,KAAP,CAAc;AAC3C;AACA;AACA,CAHO;;AAKA,MAAMC,eAAe,GAAG,qBAAOD,aAAP,CAAsB;AACrD;AACA;AACA,CAHO;;AAKA,MAAME,oBAAoB,GAAG,qBAAOF,aAAP,CAAsB;AAC1D;AACA,CAFO;;AAIA,MAAMG,kBAAkB,GAAG,qBAAOH,aAAP,CAAsB;AACxD;AACA,CAFO;;AAIA,MAAMI,eAAe,GAAG,qBAAO,KAAP,CAAmC;AAClE,kBAAkB,CAAC;AAAEP,EAAAA;AAAF,CAAD,KAAeA,KAAK,CAACC,OAAN,CAAcO,IAAK;AACpD,CAFO;;AAIA,MAAMC,gBAAgB,GAAG,qBAAaC,cAAb,CAA0C;AAC1E,qBAAqB,CAAC;AAAEV,EAAAA;AAAF,CAAD,KAAeA,KAAK,CAACW,YAAN,CAAmBC,IAAK;AAC5D;AACA;AACA,eAAe,CAAC;AAAEZ,EAAAA;AAAF,CAAD,KAAeA,KAAK,CAACC,OAAN,CAAcC,KAAM;AAClD;AACA,CANO;;AASA,MAAMW,UAAU,GAAG,qBAAaJ,gBAAb,CAAoD;AAC9E,qBAAqB,CAAC;AAAET,EAAAA;AAAF,CAAD,KAAeA,KAAK,CAACC,OAAN,CAAcO,IAAK;AACvD,oBAAoB,CAAC;AAAER,EAAAA;AAAF,CAAD,KAAeA,KAAK,CAACC,OAAN,CAAcO,IAAK;AACtD,qBAAqB,CAAC;AAAER,EAAAA;AAAF,CAAD,KAAeA,KAAK,CAACW,YAAN,CAAmBC,IAAK;AAC5D;AACA,mBAAmB,CAAC;AAAEZ,EAAAA;AAAF,CAAD,KAAeA,KAAK,CAACC,OAAN,CAAca,KAAM;AACtD,oBAAoB,CAAC;AAAEd,EAAAA;AAAF,CAAD,KAAeA,KAAK,CAACC,OAAN,CAAca,KAAM;AACvD,CAPO;;AASA,MAAMC,cAAc,GAAG,qBAAO,KAAP,CAAmC;AACjE;AACA;AACA,CAHO;;AAKA,MAAMC,WAAW,GAAG,qBAAO,KAAP,CAAmC;AAC9D;AACA;AACA,aAAa,CAAC;AAAEhB,EAAAA;AAAF,CAAD,KAAeA,KAAK,CAACiB,IAAN,CAAWC,KAAX,CAAiBC,KAAM;AACnD;AACA,CALO;;AAOA,MAAMC,cAAc,GAAG,qBAAaC,iBAAb,CAAwC;AACtE,mBAAmB,CAAC;AAAErB,EAAAA;AAAF,CAAD,KAAeA,KAAK,CAACC,OAAN,CAAcO,IAAK;AACrD,kBAAkB,CAAC;AAAER,EAAAA;AAAF,CAAD,KAAeA,KAAK,CAACC,OAAN,CAAcO,IAAK;AACpD;AACA,CAJO","sourcesContent":["import styled from '@emotion/styled';\nimport { default as nativeStyled } from '@emotion/native';\nimport { StyleProps } from '@tecsinapse/react-core';\nimport { Text } from '@tecsinapse/react-web-kit';\nimport { Td } from '../../../atoms/Table';\nimport { Button } from '../../../atoms/Button';\n\nexport const TdFooterStyled = styled(Td)<Partial<StyleProps>>`\n padding: ${({ theme }) => theme.spacing.centi} 0 0 0;\n`;\n\nexport const FlexContainer = styled('div')`\n display: flex;\n flex-grow: 1;\n`;\n\nexport const FooterContainer = styled(FlexContainer)`\n justify-content: space-between;\n align-items: center;\n`;\n\nexport const FooterContainerStart = styled(FlexContainer)`\n justify-content: flex-start;\n`;\n\nexport const FooterContainerEnd = styled(FlexContainer)`\n justify-content: flex-end;\n`;\n\nexport const SelectContainer = styled('div')<Partial<StyleProps>>`\n margin-right: ${({ theme }) => theme.spacing.deca};\n`;\n\nexport const NavigationButton = nativeStyled(Button)<Partial<StyleProps>>` \n border-radius: ${({ theme }) => theme.borderRadius.mili};\n height: 44px;\n justify-content: center;\n padding: ${({ theme }) => theme.spacing.centi};\n width: 44px; \n`;\n\n// Se o botão estiver ativo, renderizar outlined, caso contrario o botão é text\nexport const PageButton = nativeStyled(NavigationButton)<Partial<StyleProps>>`\n padding-right: ${({ theme }) => theme.spacing.deca};\n padding-left: ${({ theme }) => theme.spacing.deca};\n border-radius: ${({ theme }) => theme.borderRadius.mili};\n justify-content: center;\n margin-left: ${({ theme }) => theme.spacing.micro};\n margin-right: ${({ theme }) => theme.spacing.micro};\n`;\n\nexport const PagesContainer = styled('div')<Partial<StyleProps>>`\n margin: 0 20px;\n display: flex;\n`;\n\nexport const HoveredText = styled('div')<Partial<StyleProps>>`\n user-select: none;\n &:hover * {\n color: ${({ theme }) => theme.font.color.light};\n }\n`;\n\nexport const TextPagination = nativeStyled(Text)<Partial<StyleProps>>`\n padding-right: ${({ theme }) => theme.spacing.deca};\n padding-left: ${({ theme }) => theme.spacing.deca};\n\n`;\n"],"file":"styled.js"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tecsinapse/react-web-kit",
3
3
  "description": "TecSinapse React components",
4
- "version": "1.18.2",
4
+ "version": "1.18.5",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "license": "MIT",
@@ -17,7 +17,7 @@
17
17
  "@emotion/native": "^11.0.0",
18
18
  "@emotion/react": "^11.4.1",
19
19
  "@emotion/styled": "^11.3.0",
20
- "@tecsinapse/react-core": "^1.17.2",
20
+ "@tecsinapse/react-core": "^1.17.3",
21
21
  "@types/react-native": "^0.64.4",
22
22
  "react-native-vector-icons": "^9.2.0",
23
23
  "react-transition-group": "^4.4.2"
@@ -34,7 +34,7 @@
34
34
  "peerDependencies": {
35
35
  "react": "^16.8.0 || ^17.0.0 || ^18.0.0",
36
36
  "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0",
37
- "react-native-web": "^0.17.1"
37
+ "react-native-web": "^0.17.1 || ^0.18.0"
38
38
  },
39
- "gitHead": "077c192810529eb555031e7e35ef90477f8f830d"
39
+ "gitHead": "14c13e63e11837acd58c8076570979669aec154c"
40
40
  }
@@ -52,6 +52,8 @@ export interface DataGridProps<Data>
52
52
  skeletonComponent?: React.ReactNode;
53
53
  /** Empty state placeholder */
54
54
  emptyPlaceholder?: React.ReactNode;
55
+ /** Export component, use if default button with label is not ideal. This prop, not receive "exportLabel" and "exportFunction" */
56
+ exportComponent?: React.ReactNode;
55
57
  }
56
58
 
57
59
  /** Note: Consider memoizing functions for a better performance */
@@ -78,6 +80,7 @@ const DataGrid = <Data extends unknown>({
78
80
  loading = false,
79
81
  skeletonComponent,
80
82
  emptyPlaceholder,
83
+ exportComponent,
81
84
  ...rest
82
85
  }: DataGridProps<Data>): JSX.Element => {
83
86
  if (selectable && (!selectedRows || !onSelectedRows)) {
@@ -189,6 +192,7 @@ const DataGrid = <Data extends unknown>({
189
192
  page={page}
190
193
  onPageChange={onPageChange}
191
194
  pagination={pagination}
195
+ exportComponent={exportComponent}
192
196
  />
193
197
  )}
194
198
  </Table>
@@ -11,6 +11,7 @@ import {
11
11
  PagesContainer,
12
12
  SelectContainer,
13
13
  TdFooterStyled,
14
+ TextPagination,
14
15
  } from './styled';
15
16
 
16
17
  interface DataGridFooterProps {
@@ -25,6 +26,7 @@ interface DataGridFooterProps {
25
26
  page: number;
26
27
  onPageChange?: (page: number) => void;
27
28
  pagination: boolean;
29
+ exportComponent?: React.ReactNode;
28
30
  }
29
31
 
30
32
  const Footer: React.FC<DataGridFooterProps> = ({
@@ -38,6 +40,7 @@ const Footer: React.FC<DataGridFooterProps> = ({
38
40
  page,
39
41
  onPageChange,
40
42
  pagination,
43
+ exportComponent,
41
44
  }) => {
42
45
  if (pagination && (!onPageChange || !onRowsPerPageChange)) {
43
46
  throw new Error(
@@ -67,6 +70,9 @@ const Footer: React.FC<DataGridFooterProps> = ({
67
70
  [onPageChange, onRowsPerPageChange]
68
71
  );
69
72
 
73
+ const quantityRowsRendered =
74
+ rowsPerPage > rowsCount ? rowsCount : rowsPerPage;
75
+
70
76
  return (
71
77
  <TFoot>
72
78
  <Tr>
@@ -86,6 +92,7 @@ const Footer: React.FC<DataGridFooterProps> = ({
86
92
  />
87
93
  </SelectContainer>
88
94
  )}
95
+ {exportComponent && !exportFunction && <>{exportComponent}</>}
89
96
  {exportFunction && (
90
97
  <HoveredText>
91
98
  <Button variant="outlined" onPress={() => exportFunction()}>
@@ -97,44 +104,53 @@ const Footer: React.FC<DataGridFooterProps> = ({
97
104
  )}
98
105
  </FooterContainerStart>
99
106
  {pagination && (
100
- <FooterContainerEnd>
101
- <NavigationButton
102
- onPress={() => onPageChange?.(page - 1)}
103
- disabled={page === 0}
104
- >
105
- <Icon
106
- name={'chevron-left'}
107
- type={'material-community'}
108
- fontColor={'light'}
109
- />
110
- </NavigationButton>
111
- <PagesContainer>
112
- {[...Array(Math.ceil(rowsCount / rowsPerPage)).keys()]
113
- .slice(getPaginationSlice().start, getPaginationSlice().end)
114
- .map(value => (
115
- <HoveredText key={`page-${value}`}>
116
- <PageButton
117
- variant={page === value ? 'outlined' : 'text'}
118
- onPress={() => onPageChange?.(value)}
119
- >
120
- <Text fontColor="medium" fontWeight="bold">
121
- {value + 1}
122
- </Text>
123
- </PageButton>
124
- </HoveredText>
125
- ))}
126
- </PagesContainer>
127
- <NavigationButton
128
- onPress={() => onPageChange?.(page + 1)}
129
- disabled={page === Math.ceil(rowsCount / rowsPerPage) - 1}
130
- >
131
- <Icon
132
- name={'chevron-right'}
133
- type={'material-community'}
134
- fontColor={'light'}
135
- />
136
- </NavigationButton>
137
- </FooterContainerEnd>
107
+ <>
108
+ <TextPagination
109
+ fontWeight={'bold'}
110
+ fontColor={'medium'}
111
+ >{`Exibindo ${quantityRowsRendered} de ${rowsCount} registros`}</TextPagination>
112
+ <FooterContainerEnd>
113
+ <NavigationButton
114
+ onPress={() => onPageChange?.(page - 1)}
115
+ disabled={page === 0}
116
+ >
117
+ <Icon
118
+ name={'chevron-left'}
119
+ type={'material-community'}
120
+ fontColor={'light'}
121
+ />
122
+ </NavigationButton>
123
+ <PagesContainer>
124
+ {[...Array(Math.ceil(rowsCount / rowsPerPage)).keys()]
125
+ .slice(
126
+ getPaginationSlice().start,
127
+ getPaginationSlice().end
128
+ )
129
+ .map(value => (
130
+ <HoveredText key={`page-${value}`}>
131
+ <PageButton
132
+ variant={page === value ? 'outlined' : 'text'}
133
+ onPress={() => onPageChange?.(value)}
134
+ >
135
+ <Text fontColor="medium" fontWeight="bold">
136
+ {value + 1}
137
+ </Text>
138
+ </PageButton>
139
+ </HoveredText>
140
+ ))}
141
+ </PagesContainer>
142
+ <NavigationButton
143
+ onPress={() => onPageChange?.(page + 1)}
144
+ disabled={page === Math.ceil(rowsCount / rowsPerPage) - 1}
145
+ >
146
+ <Icon
147
+ name={'chevron-right'}
148
+ type={'material-community'}
149
+ fontColor={'light'}
150
+ />
151
+ </NavigationButton>
152
+ </FooterContainerEnd>
153
+ </>
138
154
  )}
139
155
  </FooterContainer>
140
156
  </TdFooterStyled>
@@ -1,6 +1,7 @@
1
1
  import styled from '@emotion/styled';
2
2
  import { default as nativeStyled } from '@emotion/native';
3
3
  import { StyleProps } from '@tecsinapse/react-core';
4
+ import { Text } from '@tecsinapse/react-web-kit';
4
5
  import { Td } from '../../../atoms/Table';
5
6
  import { Button } from '../../../atoms/Button';
6
7
 
@@ -59,3 +60,9 @@ export const HoveredText = styled('div')<Partial<StyleProps>>`
59
60
  color: ${({ theme }) => theme.font.color.light};
60
61
  }
61
62
  `;
63
+
64
+ export const TextPagination = nativeStyled(Text)<Partial<StyleProps>>`
65
+ padding-right: ${({ theme }) => theme.spacing.deca};
66
+ padding-left: ${({ theme }) => theme.spacing.deca};
67
+
68
+ `;