@redsift/design-system-legacy 6.0.0-alpha.9 → 6.1.0-alpha.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.
Files changed (206) hide show
  1. package/CONTRIBUTING.md +382 -0
  2. package/index.js +5708 -0
  3. package/index.js.map +1 -0
  4. package/package.json +7 -23
  5. package/esm/_internal/Alert.js +0 -10
  6. package/esm/_internal/Alert.js.map +0 -1
  7. package/esm/_internal/Alert2.js +0 -59
  8. package/esm/_internal/Alert2.js.map +0 -1
  9. package/esm/_internal/Button.js +0 -5
  10. package/esm/_internal/Button.js.map +0 -1
  11. package/esm/_internal/Button2.js +0 -56
  12. package/esm/_internal/Button2.js.map +0 -1
  13. package/esm/_internal/Card.js +0 -6
  14. package/esm/_internal/Card.js.map +0 -1
  15. package/esm/_internal/Card2.js +0 -33
  16. package/esm/_internal/Card2.js.map +0 -1
  17. package/esm/_internal/CardHeader.js +0 -7
  18. package/esm/_internal/CardHeader.js.map +0 -1
  19. package/esm/_internal/CardHeader2.js +0 -35
  20. package/esm/_internal/CardHeader2.js.map +0 -1
  21. package/esm/_internal/Checkbox.js +0 -7
  22. package/esm/_internal/Checkbox.js.map +0 -1
  23. package/esm/_internal/Checkbox2.js +0 -53
  24. package/esm/_internal/Checkbox2.js.map +0 -1
  25. package/esm/_internal/CheckboxTree.js +0 -8
  26. package/esm/_internal/CheckboxTree.js.map +0 -1
  27. package/esm/_internal/CheckboxTree2.js +0 -185
  28. package/esm/_internal/CheckboxTree2.js.map +0 -1
  29. package/esm/_internal/IconContainer.js +0 -6
  30. package/esm/_internal/IconContainer.js.map +0 -1
  31. package/esm/_internal/IconContainer2.js +0 -37
  32. package/esm/_internal/IconContainer2.js.map +0 -1
  33. package/esm/_internal/Input.js +0 -7
  34. package/esm/_internal/Input.js.map +0 -1
  35. package/esm/_internal/Input2.js +0 -185
  36. package/esm/_internal/Input2.js.map +0 -1
  37. package/esm/_internal/Pagination.js +0 -10
  38. package/esm/_internal/Pagination.js.map +0 -1
  39. package/esm/_internal/Pagination2.js +0 -82
  40. package/esm/_internal/Pagination2.js.map +0 -1
  41. package/esm/_internal/Radio.js +0 -7
  42. package/esm/_internal/Radio.js.map +0 -1
  43. package/esm/_internal/Radio2.js +0 -51
  44. package/esm/_internal/Radio2.js.map +0 -1
  45. package/esm/_internal/Select.js +0 -9
  46. package/esm/_internal/Select.js.map +0 -1
  47. package/esm/_internal/Select2.js +0 -458
  48. package/esm/_internal/Select2.js.map +0 -1
  49. package/esm/_internal/Switch.js +0 -7
  50. package/esm/_internal/Switch.js.map +0 -1
  51. package/esm/_internal/Switch2.js +0 -55
  52. package/esm/_internal/Switch2.js.map +0 -1
  53. package/esm/_internal/Table.js +0 -27
  54. package/esm/_internal/Table.js.map +0 -1
  55. package/esm/_internal/Table2.js +0 -1252
  56. package/esm/_internal/Table2.js.map +0 -1
  57. package/esm/_internal/Tabs.js +0 -7
  58. package/esm/_internal/Tabs.js.map +0 -1
  59. package/esm/_internal/Tabs2.js +0 -121
  60. package/esm/_internal/Tabs2.js.map +0 -1
  61. package/esm/_internal/Typography.js +0 -6
  62. package/esm/_internal/Typography.js.map +0 -1
  63. package/esm/_internal/Typography2.js +0 -75
  64. package/esm/_internal/Typography2.js.map +0 -1
  65. package/esm/_internal/_rollupPluginBabelHelpers.js +0 -108
  66. package/esm/_internal/_rollupPluginBabelHelpers.js.map +0 -1
  67. package/esm/_internal/icons/ActionsIcon.js +0 -20
  68. package/esm/_internal/icons/ActionsIcon.js.map +0 -1
  69. package/esm/_internal/icons/AddIcon.js +0 -16
  70. package/esm/_internal/icons/AddIcon.js.map +0 -1
  71. package/esm/_internal/icons/Arrow.js +0 -36
  72. package/esm/_internal/icons/Arrow.js.map +0 -1
  73. package/esm/_internal/icons/ArrowDown.js +0 -17
  74. package/esm/_internal/icons/ArrowDown.js.map +0 -1
  75. package/esm/_internal/icons/ArrowIcon.js +0 -29
  76. package/esm/_internal/icons/ArrowIcon.js.map +0 -1
  77. package/esm/_internal/icons/ArrowUp.js +0 -16
  78. package/esm/_internal/icons/ArrowUp.js.map +0 -1
  79. package/esm/_internal/icons/BarchartHorizontal.js +0 -26
  80. package/esm/_internal/icons/BarchartHorizontal.js.map +0 -1
  81. package/esm/_internal/icons/BellIcon.js +0 -27
  82. package/esm/_internal/icons/BellIcon.js.map +0 -1
  83. package/esm/_internal/icons/BimiSetupIcon.js +0 -21
  84. package/esm/_internal/icons/BimiSetupIcon.js.map +0 -1
  85. package/esm/_internal/icons/Chevron.js +0 -40
  86. package/esm/_internal/icons/Chevron.js.map +0 -1
  87. package/esm/_internal/icons/ChevronLeft.js +0 -16
  88. package/esm/_internal/icons/ChevronLeft.js.map +0 -1
  89. package/esm/_internal/icons/ChevronRight.js +0 -16
  90. package/esm/_internal/icons/ChevronRight.js.map +0 -1
  91. package/esm/_internal/icons/ClearIcon.js +0 -16
  92. package/esm/_internal/icons/ClearIcon.js.map +0 -1
  93. package/esm/_internal/icons/Cloud.js +0 -28
  94. package/esm/_internal/icons/Cloud.js.map +0 -1
  95. package/esm/_internal/icons/Cross.js +0 -26
  96. package/esm/_internal/icons/Cross.js.map +0 -1
  97. package/esm/_internal/icons/DeleteIcon.js +0 -24
  98. package/esm/_internal/icons/DeleteIcon.js.map +0 -1
  99. package/esm/_internal/icons/DynamicDmarcIcon.js +0 -36
  100. package/esm/_internal/icons/DynamicDmarcIcon.js.map +0 -1
  101. package/esm/_internal/icons/EditOutline.js +0 -16
  102. package/esm/_internal/icons/EditOutline.js.map +0 -1
  103. package/esm/_internal/icons/Email.js +0 -55
  104. package/esm/_internal/icons/Email.js.map +0 -1
  105. package/esm/_internal/icons/EmailSourcesIcon.js +0 -29
  106. package/esm/_internal/icons/EmailSourcesIcon.js.map +0 -1
  107. package/esm/_internal/icons/ExpandLayoutIcon.js +0 -35
  108. package/esm/_internal/icons/ExpandLayoutIcon.js.map +0 -1
  109. package/esm/_internal/icons/ExportIcon.js +0 -12
  110. package/esm/_internal/icons/ExportIcon.js.map +0 -1
  111. package/esm/_internal/icons/Eye.js +0 -35
  112. package/esm/_internal/icons/Eye.js.map +0 -1
  113. package/esm/_internal/icons/Facebook.js +0 -32
  114. package/esm/_internal/icons/Facebook.js.map +0 -1
  115. package/esm/_internal/icons/FilterList.js +0 -16
  116. package/esm/_internal/icons/FilterList.js.map +0 -1
  117. package/esm/_internal/icons/FindOutHowIcon.js +0 -41
  118. package/esm/_internal/icons/FindOutHowIcon.js.map +0 -1
  119. package/esm/_internal/icons/FlatArrow.js +0 -34
  120. package/esm/_internal/icons/FlatArrow.js.map +0 -1
  121. package/esm/_internal/icons/ForwardArrowIcon.js +0 -53
  122. package/esm/_internal/icons/ForwardArrowIcon.js.map +0 -1
  123. package/esm/_internal/icons/Github.js +0 -33
  124. package/esm/_internal/icons/Github.js.map +0 -1
  125. package/esm/_internal/icons/Globe.js +0 -61
  126. package/esm/_internal/icons/Globe.js.map +0 -1
  127. package/esm/_internal/icons/Hand.js +0 -25
  128. package/esm/_internal/icons/Hand.js.map +0 -1
  129. package/esm/_internal/icons/InfinityLoop.js +0 -22
  130. package/esm/_internal/icons/InfinityLoop.js.map +0 -1
  131. package/esm/_internal/icons/InfinityLoopBreak.js +0 -31
  132. package/esm/_internal/icons/InfinityLoopBreak.js.map +0 -1
  133. package/esm/_internal/icons/IngrainIcon.js +0 -39
  134. package/esm/_internal/icons/IngrainIcon.js.map +0 -1
  135. package/esm/_internal/icons/LanguageIcon.js +0 -37
  136. package/esm/_internal/icons/LanguageIcon.js.map +0 -1
  137. package/esm/_internal/icons/Linkedin.js +0 -29
  138. package/esm/_internal/icons/Linkedin.js.map +0 -1
  139. package/esm/_internal/icons/LocationPin.js +0 -31
  140. package/esm/_internal/icons/LocationPin.js.map +0 -1
  141. package/esm/_internal/icons/MicrosoftShield.js +0 -40
  142. package/esm/_internal/icons/MicrosoftShield.js.map +0 -1
  143. package/esm/_internal/icons/News.js +0 -44
  144. package/esm/_internal/icons/News.js.map +0 -1
  145. package/esm/_internal/icons/Nodes.js +0 -27
  146. package/esm/_internal/icons/Nodes.js.map +0 -1
  147. package/esm/_internal/icons/OnDmarcIcon.js +0 -34
  148. package/esm/_internal/icons/OnDmarcIcon.js.map +0 -1
  149. package/esm/_internal/icons/OnDmarcLogo.js +0 -52
  150. package/esm/_internal/icons/OnDmarcLogo.js.map +0 -1
  151. package/esm/_internal/icons/OnDomainIcon.js +0 -32
  152. package/esm/_internal/icons/OnDomainIcon.js.map +0 -1
  153. package/esm/_internal/icons/OnInboxIcon.js +0 -48
  154. package/esm/_internal/icons/OnInboxIcon.js.map +0 -1
  155. package/esm/_internal/icons/OnInboxLogo.js +0 -68
  156. package/esm/_internal/icons/OnInboxLogo.js.map +0 -1
  157. package/esm/_internal/icons/OnInboxManagerIcon.js +0 -49
  158. package/esm/_internal/icons/OnInboxManagerIcon.js.map +0 -1
  159. package/esm/_internal/icons/OpenInNewTabIcon.js +0 -23
  160. package/esm/_internal/icons/OpenInNewTabIcon.js.map +0 -1
  161. package/esm/_internal/icons/Padlock.js +0 -33
  162. package/esm/_internal/icons/Padlock.js.map +0 -1
  163. package/esm/_internal/icons/PlusIcon.js +0 -18
  164. package/esm/_internal/icons/PlusIcon.js.map +0 -1
  165. package/esm/_internal/icons/Question.js +0 -24
  166. package/esm/_internal/icons/Question.js.map +0 -1
  167. package/esm/_internal/icons/Recruiting.js +0 -23
  168. package/esm/_internal/icons/Recruiting.js.map +0 -1
  169. package/esm/_internal/icons/ReportsIcon.js +0 -21
  170. package/esm/_internal/icons/ReportsIcon.js.map +0 -1
  171. package/esm/_internal/icons/SearchIcon.js +0 -16
  172. package/esm/_internal/icons/SearchIcon.js.map +0 -1
  173. package/esm/_internal/icons/Shield.js +0 -22
  174. package/esm/_internal/icons/Shield.js.map +0 -1
  175. package/esm/_internal/icons/ShieldPassIcon.js +0 -19
  176. package/esm/_internal/icons/ShieldPassIcon.js.map +0 -1
  177. package/esm/_internal/icons/ShieldSolid.js +0 -31
  178. package/esm/_internal/icons/ShieldSolid.js.map +0 -1
  179. package/esm/_internal/icons/ShieldWarningIcon.js +0 -34
  180. package/esm/_internal/icons/ShieldWarningIcon.js.map +0 -1
  181. package/esm/_internal/icons/ShieldWarningInvertedIcon.js +0 -29
  182. package/esm/_internal/icons/ShieldWarningInvertedIcon.js.map +0 -1
  183. package/esm/_internal/icons/Spinner.js +0 -75
  184. package/esm/_internal/icons/Spinner.js.map +0 -1
  185. package/esm/_internal/icons/Team.js +0 -81
  186. package/esm/_internal/icons/Team.js.map +0 -1
  187. package/esm/_internal/icons/ThreeDotsIcon.js +0 -19
  188. package/esm/_internal/icons/ThreeDotsIcon.js.map +0 -1
  189. package/esm/_internal/icons/Thumb.js +0 -22
  190. package/esm/_internal/icons/Thumb.js.map +0 -1
  191. package/esm/_internal/icons/Traffic.js +0 -28
  192. package/esm/_internal/icons/Traffic.js.map +0 -1
  193. package/esm/_internal/icons/Twitter.js +0 -37
  194. package/esm/_internal/icons/Twitter.js.map +0 -1
  195. package/esm/_internal/icons/Upload.js +0 -25
  196. package/esm/_internal/icons/Upload.js.map +0 -1
  197. package/esm/_internal/icons/VerticalDots.js +0 -40
  198. package/esm/_internal/icons/VerticalDots.js.map +0 -1
  199. package/esm/_internal/icons/Warning.js +0 -36
  200. package/esm/_internal/icons/Warning.js.map +0 -1
  201. package/esm/_internal/icons/WarningTriangle.js +0 -39
  202. package/esm/_internal/icons/WarningTriangle.js.map +0 -1
  203. package/esm/_internal/icons/Youtube.js +0 -29
  204. package/esm/_internal/icons/Youtube.js.map +0 -1
  205. package/esm/index.js +0 -132
  206. package/esm/index.js.map +0 -1
@@ -1,1252 +0,0 @@
1
- import { _ as _taggedTemplateLiteral, c as _objectWithoutProperties, a as _extends, b as _objectSpread2 } from './_rollupPluginBabelHelpers.js';
2
- import React, { useState, useEffect, forwardRef, Fragment, useMemo, createRef } from 'react';
3
- import { useTable, useFilters, useSortBy, useExpanded, usePagination } from 'react-table';
4
- import styled, { css } from 'styled-components';
5
- import SimpleBarReact from 'simplebar-react';
6
- import { ArrowDown } from './icons/ArrowDown.js';
7
- import { ArrowUp } from './icons/ArrowUp.js';
8
- import { I as Input } from './Input2.js';
9
- import { ChevronRight } from './icons/ChevronRight.js';
10
- import { B as Button } from './Button2.js';
11
- import { EditOutline } from './icons/EditOutline.js';
12
- import { DeleteIcon } from './icons/DeleteIcon.js';
13
- import { ArrowIcon } from './icons/ArrowIcon.js';
14
- import { ClearIcon } from './icons/ClearIcon.js';
15
- import { T as Typography } from './Typography2.js';
16
- import { matchSorter } from 'match-sorter';
17
- import { CSVLink } from 'react-csv';
18
- import { ExportIcon } from './icons/ExportIcon.js';
19
- import { FilterList } from './icons/FilterList.js';
20
- import { SearchIcon } from './icons/SearchIcon.js';
21
- import { P as Pagination } from './Pagination2.js';
22
- import { Cross } from './icons/Cross.js';
23
- import { C as Checkbox } from './Checkbox2.js';
24
-
25
- const useIsMobile = () => {
26
- const [state, setState] = useState(false);
27
- useEffect(() => {
28
- const check = window.matchMedia("(max-width: 767px)");
29
-
30
- const checkIsMobile = () => {
31
- if (state !== check.matches) {
32
- setState(check.matches);
33
- }
34
- };
35
-
36
- check.addListener(checkIsMobile);
37
- checkIsMobile();
38
- return () => {
39
- check.removeListener(checkIsMobile);
40
- };
41
- }, []);
42
- return {
43
- isMobile: state
44
- };
45
- }; // Use: Place this with your other hooks:
46
- // const { isMobile } = useIsMobile();
47
-
48
- const DEBOUNCE_TIME = 100;
49
- const useDebouncedValue = function (value) {
50
- let delay = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEBOUNCE_TIME;
51
- const [debouncedValue, setDebouncedValue] = useState(value);
52
- useEffect(() => {
53
- const handler = setTimeout(() => {
54
- setDebouncedValue(value);
55
- }, delay);
56
- return () => {
57
- clearTimeout(handler);
58
- };
59
- }, [value]);
60
- return [debouncedValue];
61
- };
62
-
63
- const _excluded$3 = ["icon", "label", "disabled", "flatIcon", "outlined", "color"],
64
- _excluded2 = ["children"],
65
- _excluded3 = ["children"],
66
- _excluded4 = ["children", "header"],
67
- _excluded5 = ["children", "ellipsisOverflow"];
68
-
69
- var _templateObject$2, _templateObject2$1, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15, _templateObject16, _templateObject17, _templateObject18, _templateObject19, _templateObject20, _templateObject21, _templateObject22, _templateObject23, _templateObject24, _templateObject25, _templateObject26;
70
- // - for valid DOM nesting with custom scrollbar (simplebar), we need to use divs unfortunately
71
- // - aria roles used as recommended here:
72
- // https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/Table_Role
73
- // https://github.com/redsift/design-system/commit/8d1d84c2c74d76cbb0996e39b28974f5b8c871c1
74
-
75
- const StyledSimpleBar = styled(SimpleBarReact)(_templateObject$2 || (_templateObject$2 = _taggedTemplateLiteral(["\n overflow-y: hidden;\n .simplebar-track.simplebar-horizontal {\n height: 8px;\n bottom: 0;\n background: rgba(0, 0, 0, 0.125);\n ", "\n }\n .simplebar-track.simplebar-horizontal .simplebar-scrollbar {\n height: 8px;\n top: 0;\n }\n .simplebar-scrollbar,\n .simplebar-scrollbar:before,\n .simplebar-track.simplebar-horizontal {\n border-radius: 4px;\n }\n .simplebar-track.simplebar-horizontal .simplebar-scrollbar:before {\n background: rgba(0, 0, 0, 0.25);\n border-radius: 4px;\n left: 0;\n }\n .simplebar-content:after {\n content: none;\n }\n ", ";\n"])), _ref => {
76
- let {
77
- xoverflow
78
- } = _ref;
79
- return xoverflow && "left: ".concat(xoverflow + 2, "px;");
80
- }, _ref2 => {
81
- let {
82
- xoverflow,
83
- placeholderHeight
84
- } = _ref2;
85
- return xoverflow && "\n .simplebar-track.simplebar-vertical {\n display: none;\n visibility: hidden;\n }\n .simplebar-content {\n box-sizing: border-box;\n }\n .simplebar-placeholder {\n height: ".concat(placeholderHeight, "px !important;\n }\n .simplebar-scrollbar:before {\n top: 0;\n bottom: 0;\n }\n ");
86
- });
87
- const TableContent = /*#__PURE__*/forwardRef((_ref3, ref) => {
88
- let {
89
- children,
90
- xOverflow,
91
- placeholderHeight
92
- } = _ref3;
93
- return xOverflow ? /*#__PURE__*/React.createElement(StyledSimpleBar, {
94
- autoHide: false,
95
- forceVisible: "x",
96
- ref: ref,
97
- xoverflow: xOverflow,
98
- placeholderHeight: placeholderHeight
99
- }, children) : /*#__PURE__*/React.createElement(Fragment, null, children);
100
- });
101
- const ExpandIcon = styled(ChevronRight)(_templateObject2$1 || (_templateObject2$1 = _taggedTemplateLiteral(["\n vertical-align: middle;\n transform: ", ";\n"])), _ref4 => {
102
- let {
103
- expanded
104
- } = _ref4;
105
- return expanded ? "rotate(90deg)" : "unset";
106
- });
107
- const Container = styled.div(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n display: flex;\n flex-direction: column;\n"])));
108
- const sortIconStyles = css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n height: 18px;\n width: 18px;\n position: relative;\n top: 5px;\n"])));
109
- const SortDownIcon = styled(ArrowDown)(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n ", ";\n"])), sortIconStyles);
110
- const SortUpIcon = styled(ArrowUp)(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n ", ";\n"])), sortIconStyles);
111
- const CenteredActionButton = styled(Button)(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n display: flex;\n align-items: center;\n height: 40px;\n white-space: nowrap;\n ", "\n\n ", "\n ", "\n ", "\n"])), props => props.useMobileLayout ? "\n flex: 1;\n justify-content: center;\n * + && {\n span {\n display: none;\n }\n svg {\n margin-right: 0;\n }\n }\n " : "", props => props.hoverColor ? "&:hover { background-color: ".concat(props.hoverColor, "; }") : "", props => props.activeColor ? "&:active { background-color: ".concat(props.activeColor, "; }") : "", props => props.unPadded ? "" : "\n padding: 8px 16px;\n svg {\n margin-right: 14px;\n }\n && + && {\n margin-left: 8px;\n }\n ");
112
-
113
- const ActionIcon = _ref5 => {
114
- let {
115
- icon: Icon,
116
- label,
117
- disabled,
118
- flatIcon = true,
119
- outlined = false,
120
- color
121
- } = _ref5,
122
- rest = _objectWithoutProperties(_ref5, _excluded$3);
123
-
124
- const iconColor = flatIcon || outlined ? color : "#FFF";
125
- return /*#__PURE__*/React.createElement(CenteredActionButton, _extends({
126
- disabled: disabled,
127
- flatIcon: flatIcon,
128
- outlined: outlined,
129
- color: color
130
- }, rest), /*#__PURE__*/React.createElement(Icon, {
131
- disabled: disabled,
132
- color: iconColor,
133
- fill: iconColor
134
- }), /*#__PURE__*/React.createElement("span", null, label));
135
- };
136
-
137
- const Search = styled(Input)(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n width: ", ";\n max-width: 100%;\n margin-left: 0;\n"])), props => props.expand ? "100%" : "360px");
138
- const Header = styled.header(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["\n display: flex;\n justify-content: space-between;\n align-items: center;\n margin-bottom: 20px;\n flex-wrap: wrap;\n"])));
139
- const HeaderPrimaryContent = styled.div(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["\n flex: 1 1 360px;\n"])));
140
- const ActionBar = styled.div(_templateObject11 || (_templateObject11 = _taggedTemplateLiteral(["\n display: flex;\n flex-grow: 1;\n justify-content: flex-end;\n ", "\n\n ", " {\n flex: 1;\n }\n"])), props => props.spaced ? "margin-left: 32px;" : "", Button);
141
- const TableElement = styled.div(_templateObject12 || (_templateObject12 = _taggedTemplateLiteral(["\n display: block;\n border-radius: 4px;\n width: 100%;\n word-wrap: break-word;\n overflow-wrap: break-word;\n overflow: hidden;\n border-style: solid;\n border-color: rgba(0, 0, 0, 0.12);\n border-width: ", ";\n ", ";\n"])), _ref6 => {
142
- let {
143
- bordered
144
- } = _ref6;
145
- return bordered ? "1px 1px 0px 1px" : "0px";
146
- }, _ref7 => {
147
- let {
148
- xOverflow
149
- } = _ref7;
150
- return xOverflow && "overflow-x: scroll; overflow-y: hidden";
151
- });
152
-
153
- const StyledTable = _ref8 => {
154
- let {
155
- children
156
- } = _ref8,
157
- props = _objectWithoutProperties(_ref8, _excluded2);
158
-
159
- return /*#__PURE__*/React.createElement(TableElement, _extends({}, props, {
160
- role: "table"
161
- }), children);
162
- };
163
-
164
- const TableHeaderSection = styled.div(_templateObject13 || (_templateObject13 = _taggedTemplateLiteral(["\n ", "\n"])), _ref9 => {
165
- let {
166
- xOverflow
167
- } = _ref9;
168
- return xOverflow ? "width: auto; display: table;" : "display: flex;";
169
- }); // last cell style for xOverflow only
170
- // - last column has width: 100% and max-width: 100%
171
-
172
- const ThTdStyles = css(_templateObject14 || (_templateObject14 = _taggedTemplateLiteral(["\n display: flex;\n align-items: center;\n box-sizing: border-box;\n color: rgba(0, 0, 0, 0.87);\n font-family: Raleway, sans-serif;\n font-size: 0.875rem;\n line-height: 1.375rem;\n letter-spacing: 0.0071428571em;\n margin: 0;\n padding: ", ";\n\n ", "\n ", ";\n width: 100px;\n min-width: 100px;\n ", ";\n ", "\n ", "\n ", "\n"])), _ref10 => {
173
- let {
174
- noPadding
175
- } = _ref10;
176
- return noPadding ? "0px" : "10px";
177
- }, _ref11 => {
178
- let {
179
- stickyCell,
180
- xOverflowBg
181
- } = _ref11;
182
- return stickyCell && "\n box-shadow: 4px 4px 6px -4px rgba(0, 0, 0, 0.4);\n background: ".concat(xOverflowBg ? xOverflowBg : "white", ";\n position: sticky;\n left: 0;\n z-index: 1;\n ");
183
- }, _ref12 => {
184
- let {
185
- stickyCellNext
186
- } = _ref12;
187
- return stickyCellNext && "padding-left: 20px";
188
- }, _ref13 => {
189
- let {
190
- enableFlex,
191
- size
192
- } = _ref13;
193
- return enableFlex && "flex: ".concat(size || 100, "px");
194
- }, _ref14 => {
195
- let {
196
- size
197
- } = _ref14;
198
- return size && "\n width: ".concat(parseInt(size) ? "".concat(size, "px") : size, ";\n min-width: ").concat(parseInt(size) ? "".concat(size, "px") : size, ";\n max-width: ").concat(parseInt(size) ? "".concat(size, "px") : size, ";\n ");
199
- }, _ref15 => {
200
- let {
201
- lastCell
202
- } = _ref15;
203
- return lastCell && "\n width: 100%;\n min-width: 100px;\n max-width: 100%;\n ";
204
- }, _ref16 => {
205
- let {
206
- xOverflow
207
- } = _ref16;
208
- return xOverflow && "word-wrap: break-word;";
209
- });
210
- const TableHeaderTh = styled.div(_templateObject15 || (_templateObject15 = _taggedTemplateLiteral(["\n ", ";\n font-weight: 600;\n text-align: left;\n flex-direction: column;\n justify-content: ", ";\n align-items: flex-start;\n border-bottom: solid 1px rgba(0, 0, 0, 0.42);\n ", "\n .sort-icon {\n transition: opacity 0.2s ease;\n opacity: ", ";\n }\n\n &:hover {\n .sort-icon {\n opacity: ", ";\n }\n }\n"])), ThTdStyles, _ref17 => {
211
- let {
212
- justifyStart
213
- } = _ref17;
214
- return justifyStart ? "flex-start" : "center";
215
- }, _ref18 => {
216
- let {
217
- checkbox
218
- } = _ref18;
219
- return checkbox && "\n margin: 0px;\n padding: 0px 20px;\n ";
220
- }, _ref19 => {
221
- let {
222
- sortIconVisible
223
- } = _ref19;
224
- return sortIconVisible ? "1" : "0";
225
- }, _ref20 => {
226
- let {
227
- sortIconVisible
228
- } = _ref20;
229
- return sortIconVisible ? "1" : "0.3";
230
- });
231
-
232
- const TableHeaderCell = _ref21 => {
233
- let {
234
- children
235
- } = _ref21,
236
- props = _objectWithoutProperties(_ref21, _excluded3);
237
-
238
- return /*#__PURE__*/React.createElement(TableHeaderTh, _extends({}, props, {
239
- role: "columnheader"
240
- }), children);
241
- };
242
-
243
- const rowStyles = css(_templateObject16 || (_templateObject16 = _taggedTemplateLiteral(["\n display: flex;\n height: auto;\n min-height: 55px;\n width: 100%;\n border-style: solid;\n border-color: rgba(0, 0, 0, 0.12);\n border-width: ", ";\n ", ";\n"])), _ref22 => {
244
- let {
245
- isFooter,
246
- bordered
247
- } = _ref22;
248
- return isFooter ? "2px 1px 1px 1px" : bordered ? "0px 1px 1px 1px" : "0px 0px 1px 0px";
249
- }, _ref23 => {
250
- let {
251
- rowSpacing
252
- } = _ref23;
253
- return rowSpacing && "\n border: 1px solid #D8D9D9;\n border-radius: 4px;\n box-sizing: border-box;\n margin-top: ".concat(Number.isInteger(rowSpacing) ? "".concat(rowSpacing, "px") : "10px", ";\n");
254
- });
255
- const leftBorder = css(_templateObject17 || (_templateObject17 = _taggedTemplateLiteral(["\n div:not(:first-child) {\n border-left: solid 1px rgba(0, 0, 0, 0.12);\n }\n"])));
256
- const HeaderRow = styled.div(_templateObject18 || (_templateObject18 = _taggedTemplateLiteral(["\n ", ";\n ", ";\n ", "\n"])), rowStyles, _ref24 => {
257
- let {
258
- bordered
259
- } = _ref24;
260
- return bordered && leftBorder;
261
- }, _ref25 => {
262
- let {
263
- xOverflow
264
- } = _ref25;
265
- return xOverflow && " border: 0;";
266
- });
267
- const BodyRow = styled.div(_templateObject19 || (_templateObject19 = _taggedTemplateLiteral(["\n ", ";\n ", ";\n background-color: ", ";\n &:hover {\n background-color: ", ";\n }\n"])), rowStyles, _ref26 => {
268
- let {
269
- bordered
270
- } = _ref26;
271
- return bordered && leftBorder;
272
- }, _ref27 => {
273
- let {
274
- rowColor,
275
- selected,
276
- selectHighlight
277
- } = _ref27;
278
- return rowColor || selected && selectHighlight || "unset";
279
- }, _ref28 => {
280
- let {
281
- isFooter,
282
- isEmpty,
283
- rowColor,
284
- selected,
285
- selectHighlight
286
- } = _ref28;
287
- return rowColor ? rowColor : selected && selectHighlight ? selectHighlight : isFooter || isEmpty ? "unset" : "rgba(0, 0, 0, 0.04)";
288
- });
289
-
290
- const Row = _ref29 => {
291
- let {
292
- children,
293
- header
294
- } = _ref29,
295
- props = _objectWithoutProperties(_ref29, _excluded4);
296
-
297
- if (!header) {
298
- return /*#__PURE__*/React.createElement(BodyRow, _extends({}, props, {
299
- role: "row"
300
- }), children);
301
- }
302
-
303
- return /*#__PURE__*/React.createElement(HeaderRow, _extends({}, props, {
304
- role: "row"
305
- }), children);
306
- };
307
-
308
- const TableBody = styled.div(_templateObject20 || (_templateObject20 = _taggedTemplateLiteral(["\n ", "\n ", "\n"])), _ref30 => {
309
- let {
310
- xOverflow
311
- } = _ref30;
312
- return !xOverflow && "\n display: flex;\n flex-direction: column;\n ";
313
- }, _ref31 => {
314
- let {
315
- xOverflow
316
- } = _ref31;
317
- return xOverflow && "display: table;";
318
- });
319
- const CellElement = styled.div(_templateObject21 || (_templateObject21 = _taggedTemplateLiteral(["\n ", ";\n border-bottom-color: rgba(0, 0, 0, 0.42);\n border-bottom-color: ", ";\n text-align: ", ";\n justify-content: ", ";\n ", "\n ", "\n"])), ThTdStyles, _ref32 => {
320
- let {
321
- rowSpacing
322
- } = _ref32;
323
- return rowSpacing ? "transparent" : "rgba(0, 0, 0, 0.42)";
324
- }, _ref33 => {
325
- let {
326
- isNumber
327
- } = _ref33;
328
- return isNumber ? "right" : "left";
329
- }, _ref34 => {
330
- let {
331
- isNumber
332
- } = _ref34;
333
- return isNumber ? "flex-end" : "flex-start";
334
- }, _ref35 => {
335
- let {
336
- checkbox
337
- } = _ref35;
338
- return checkbox && "\n margin: 0px;\n padding: 0px 20px;\n ";
339
- }, _ref36 => {
340
- let {
341
- onClick
342
- } = _ref36;
343
- return onClick && "cursor: pointer;";
344
- });
345
- const CellElementEllipsis = styled.div(_templateObject22 || (_templateObject22 = _taggedTemplateLiteral(["\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n"])));
346
-
347
- const Cell = _ref37 => {
348
- let {
349
- children,
350
- ellipsisOverflow
351
- } = _ref37,
352
- props = _objectWithoutProperties(_ref37, _excluded5);
353
-
354
- return /*#__PURE__*/React.createElement(CellElement, _extends({}, props, {
355
- role: "cell"
356
- }), ellipsisOverflow ? /*#__PURE__*/React.createElement(CellElementEllipsis, null, children) : children);
357
- };
358
-
359
- const SortCell = styled(Cell)(_templateObject23 || (_templateObject23 = _taggedTemplateLiteral(["\n flex: 1;\n flex-direction: column;\n padding: 0px !important;\n width: 25px;\n height: unset;\n"])));
360
- const DeleteConfirmButton = styled.button(_templateObject24 || (_templateObject24 = _taggedTemplateLiteral(["\n font-family: Raleway, sans-serif;\n font-weight: 700;\n color: ", ";\n border: none;\n font-size: 0.8125rem;\n background-color: transparent;\n cursor: pointer;\n user-select: none;\n text-decoration: none;\n outline: 0;\n"])), _ref38 => {
361
- let {
362
- confirm
363
- } = _ref38;
364
- return confirm ? "#d1462f" : "";
365
- });
366
- const GreyButton = styled.button(_templateObject25 || (_templateObject25 = _taggedTemplateLiteral(["\n display: flex;\n flex-grow: 1;\n align-items: center;\n border: 0;\n padding: ", ";\n background: #f7f7f7;\n border: 1px solid #c0c0c2;\n ", ";\n ", ";\n transition: 0.2s;\n svg {\n transform: ", ";\n }\n svg > path {\n stroke: #c0c0c2;\n transition: 0.2s;\n }\n cursor: pointer;\n &:hover,\n &:focus,\n &:active {\n background: #e2e6ea;\n svg > path {\n stroke: #333;\n }\n outline: none;\n }\n"])), _ref39 => {
367
- let {
368
- rowSpacing,
369
- action
370
- } = _ref39;
371
- return rowSpacing && action ? "10px 5px" : "10px 4px";
372
- }, _ref40 => {
373
- let {
374
- rowSpacing,
375
- action
376
- } = _ref40;
377
- return rowSpacing && action === "increment" && "\n border-top-left-radius: 4px;\n margin-left: -1px;\n margin-top: -1px;\n ";
378
- }, _ref41 => {
379
- let {
380
- rowSpacing,
381
- action
382
- } = _ref41;
383
- return rowSpacing && action === "decrement" && "\n border-bottom-left-radius: 4px;\n margin-left: -1px;\n margin-bottom: -1px;\n ";
384
- }, _ref42 => {
385
- let {
386
- action
387
- } = _ref42;
388
- return action === "increment" ? "rotate(-90deg)" : "rotate(90deg)";
389
- });
390
- const AddComponentContainer = styled.div(_templateObject26 || (_templateObject26 = _taggedTemplateLiteral(["\n border: 1px solid #ebedf4;\n border-radius: 5px;\n background-color: #fafbff;\n padding: 16px 20px;\n"])));
391
-
392
- var _templateObject$1, _templateObject2;
393
-
394
- const _excluded$2 = ["title"];
395
-
396
- const BlankRows = _ref => {
397
- let {
398
- onDelete,
399
- showDeleteColumn,
400
- onSelectionChange,
401
- staticPageSize,
402
- noPagination,
403
- headerGroups,
404
- rowSubComponent,
405
- editRowEnabled,
406
- bordered,
407
- rows,
408
- page
409
- } = _ref;
410
- const brows = staticPageSize && staticPageSize - (noPagination ? rows.length : page.length) > 0 ? [...Array(staticPageSize - (noPagination ? rows.length : page.length)).keys()] : (noPagination ? rows.length : page.length) < 1 ? ["0"] : [];
411
- return /*#__PURE__*/React.createElement(Fragment, null, brows.map(id => {
412
- return /*#__PURE__*/React.createElement(Row, {
413
- bordered: bordered,
414
- key: "emptyrow-".concat(id),
415
- isEmpty: true
416
- }, onSelectionChange && /*#__PURE__*/React.createElement(Cell, null), headerGroups[headerGroups.length - 1].headers.map((header, idx) => {
417
- return /*#__PURE__*/React.createElement(Cell, {
418
- key: "emptycell-".concat(idx)
419
- });
420
- }), editRowEnabled || onDelete && showDeleteColumn ? /*#__PURE__*/React.createElement(Cell, {
421
- size: editRowEnabled && onDelete && showDeleteColumn ? 90 : 80
422
- }) : null, rowSubComponent && !editRowEnabled && /*#__PURE__*/React.createElement(Cell, {
423
- size: 50
424
- }));
425
- }));
426
- };
427
-
428
- const ClearSearchButton = _ref2 => {
429
- let {
430
- title,
431
- handleClearSearch
432
- } = _ref2;
433
- return /*#__PURE__*/React.createElement(Button, {
434
- "aria-label": title,
435
- onClick: handleClearSearch,
436
- flatIcon: true
437
- }, /*#__PURE__*/React.createElement(ClearIcon, {
438
- alt: title
439
- }));
440
- };
441
-
442
- const EditButton = _ref3 => {
443
- let {
444
- title
445
- } = _ref3,
446
- props = _objectWithoutProperties(_ref3, _excluded$2);
447
-
448
- let onClick = props.onClick;
449
-
450
- if (props.customOnEdit) {
451
- onClick = () => {
452
- props.customOnEdit(props.row);
453
- };
454
- }
455
-
456
- return /*#__PURE__*/React.createElement(ActionIcon, _extends({
457
- title: title,
458
- "aria-label": title,
459
- icon: EditOutline,
460
- unPadded: true
461
- }, props, {
462
- onClick: onClick
463
- }));
464
- };
465
-
466
- const ButtonsRowContainer = _ref4 => {
467
- let {
468
- size = 80,
469
- children
470
- } = _ref4;
471
- return /*#__PURE__*/React.createElement(Cell, {
472
- size: size
473
- }, children);
474
- };
475
-
476
- const ActionButtons = _ref5 => {
477
- let {
478
- row,
479
- disabled,
480
- onDelete,
481
- editButtonProps,
482
- customOnEdit,
483
- locales
484
- } = _ref5;
485
- const [confirm, setConfirm] = useState(false);
486
-
487
- const handleOnDelete = row => {
488
- if (!("_id" in row.original)) {
489
- return;
490
- }
491
-
492
- const {
493
- _id
494
- } = row.original;
495
- onDelete([_id]);
496
- setConfirm(false);
497
- };
498
-
499
- const ConfirmButtons = () => {
500
- return /*#__PURE__*/React.createElement("div", {
501
- style: {
502
- display: "flex",
503
- flexDirection: "column",
504
- justifyContent: "center",
505
- alignItems: "center"
506
- }
507
- }, /*#__PURE__*/React.createElement(DeleteConfirmButton, {
508
- confirm: true,
509
- onClick: () => handleOnDelete(row)
510
- }, locales["remove"] || "Remove"), /*#__PURE__*/React.createElement(DeleteConfirmButton, {
511
- flat: true,
512
- onClick: () => setConfirm(false)
513
- }, locales["cancel"] || "Cancel"));
514
- };
515
-
516
- if (confirm) {
517
- return /*#__PURE__*/React.createElement(ConfirmButtons, null);
518
- }
519
-
520
- if (editButtonProps) {
521
- return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(EditButton, _extends({
522
- row: row,
523
- customOnEdit: customOnEdit
524
- }, editButtonProps)), /*#__PURE__*/React.createElement(ActionIcon, {
525
- title: locales["delete"] || "Delete",
526
- "aria-label": locales["delete"] || "Delete",
527
- onClick: () => setConfirm(true),
528
- icon: DeleteIcon,
529
- disabled: disabled,
530
- unPadded: true,
531
- style: {
532
- opacity: !disabled ? "1" : "0.2"
533
- }
534
- }));
535
- }
536
-
537
- return /*#__PURE__*/React.createElement(ActionIcon, {
538
- title: locales["delete"] || "Delete",
539
- "aria-label": locales["delete"] || "Delete",
540
- onClick: () => setConfirm(true),
541
- icon: DeleteIcon,
542
- disabled: disabled,
543
- style: {
544
- opacity: !disabled ? "1" : "0.2"
545
- }
546
- });
547
- };
548
-
549
- const DeleteConfirmBanner = _ref6 => {
550
- let {
551
- onDelete,
552
- onCancel,
553
- locales
554
- } = _ref6;
555
- const Banner = styled.div(_templateObject$1 || (_templateObject$1 = _taggedTemplateLiteral(["\n display: flex;\n background: rgb(255, 227, 224);\n justify-content: space-between;\n align-items: center;\n margin-top: 10px;\n border: 1px solid rgb(235, 237, 244);\n border-style: solid;\n border-color: rgb(235, 237, 244);\n border-radius: 5px;\n padding: 20px;\n @media (max-width:480px) {\n flex-direction: column;\n span {\n margin-bottom: 16px;\n }\n }\n "])));
556
- const ButtonContainer = styled.div(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n display: flex;\n button:first-child {\n margin-right: 10px;\n }\n @media (max-width:480px) {\n width: 100%;\n justify-content: center;\n button {\n padding: 6px 32px;\n }\n }\n "])));
557
- return /*#__PURE__*/React.createElement(Banner, null, /*#__PURE__*/React.createElement(Typography, {
558
- component: "span"
559
- }, locales["delete-select-are-you-sure"] || "Are you sure you wish to delete all selected items?"), /*#__PURE__*/React.createElement(ButtonContainer, null, /*#__PURE__*/React.createElement(Button, {
560
- outlined: true,
561
- color: "#333",
562
- onClick: onCancel
563
- }, locales["cancel"] || "Cancel"), /*#__PURE__*/React.createElement(Button, {
564
- danger: true,
565
- onClick: onDelete
566
- }, locales["confirm"] || "Confirm")));
567
- };
568
-
569
- const SortButton = _ref7 => {
570
- let {
571
- onSort,
572
- action,
573
- row,
574
- rowSpacing
575
- } = _ref7;
576
- return /*#__PURE__*/React.createElement(GreyButton, {
577
- action: action,
578
- title: action,
579
- "aria-label": action,
580
- rowSpacing: rowSpacing,
581
- onClick: () => onSort(action, row)
582
- }, /*#__PURE__*/React.createElement(ArrowIcon, {
583
- title: action
584
- }));
585
- };
586
-
587
- const DefaultColumnFilter = _ref => {
588
- let {
589
- column: {
590
- filterValue,
591
- setFilter
592
- }
593
- } = _ref;
594
- return /*#__PURE__*/React.createElement(Input, {
595
- value: filterValue || "",
596
- onChange: e => {
597
- setFilter(e.target.value || undefined); // Set undefined to remove the filter entirely
598
- },
599
- showClear: true
600
- });
601
- };
602
-
603
- const fuzzyTextFilterFn = (rows, id, filterValue) => {
604
- return matchSorter(rows, filterValue, {
605
- keys: [row => row.values[id]]
606
- });
607
- }; // Let the table remove the filter if the string is empty
608
-
609
-
610
- fuzzyTextFilterFn.autoRemove = val => !val;
611
-
612
- const _excluded$1 = ["locale", "data", "filename", "headers", "hoverColor", "activeColor"];
613
-
614
- var _templateObject;
615
- const StyledCSVLink = styled(CSVLink)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n &,\n &:hover {\n text-decoration: none;\n }\n"])));
616
- const ExportCSVButton = _ref => {
617
- let {
618
- locale,
619
- data,
620
- filename,
621
- headers,
622
- hoverColor,
623
- activeColor
624
- } = _ref,
625
- rest = _objectWithoutProperties(_ref, _excluded$1);
626
-
627
- return /*#__PURE__*/React.createElement(StyledCSVLink, _extends({
628
- data: data,
629
- filename: filename,
630
- headers: headers
631
- }, rest), /*#__PURE__*/React.createElement(ActionIcon, {
632
- label: locale("export", "Export"),
633
- icon: () => /*#__PURE__*/React.createElement(ExportIcon, {
634
- width: 18
635
- }),
636
- hoverColor: hoverColor,
637
- activeColor: activeColor
638
- }));
639
- };
640
-
641
- const _excluded = ["columns", "data", "footerRow", "title", "bordered", "rowSpacing", "sortableRows", "onSelectionChange", "onSearchChange", "onRowsLengthChange", "onPageSizeChange", "onPageChange", "onDelete", "onSort", "showDeleteColumn", "export", "defaultSorted", "defaultPageSize", "searchID", "searchLabel", "checkboxProps", "inputProps", "selectHighlight", "staticPageSize", "noPagination", "color", "iconButtonsHoverColor", "iconButtonsActiveColor", "primaryButtonsHoverColor", "primaryButtonsActiveColor", "filterable", "CustomFilterButton", "sortable", "CustomActions", "AddComponent", "customOnEdit", "CustomSelectedActions", "CustomPrimaryActions", "CustomHeaderComponent", "rowSubComponent", "rowSubComponentEditMode", "xOverflow", "xOverflowBg", "locales", "smallTableButtonDesign", "onPreviousPage", "onNextPage", "gotoPageIndex", "onVisibleRowsChange", "onVisibleRowsChangeDebounceTime", "onChangeSortBy"];
642
- const Table = _ref => {
643
- let {
644
- columns,
645
- data,
646
- footerRow,
647
- title,
648
- bordered,
649
- rowSpacing,
650
- sortableRows,
651
- onSelectionChange,
652
- onSearchChange = () => {},
653
- onRowsLengthChange = () => {},
654
- onPageSizeChange = () => {},
655
- onPageChange = () => {},
656
- onDelete,
657
- onSort,
658
- showDeleteColumn,
659
- export: exportSettings,
660
- defaultSorted,
661
- defaultPageSize = 10,
662
- searchID,
663
- searchLabel,
664
- checkboxProps,
665
- inputProps,
666
- selectHighlight,
667
- staticPageSize,
668
- noPagination,
669
- color = "#000",
670
- iconButtonsHoverColor = "#00000019",
671
- iconButtonsActiveColor = "#00000032",
672
- primaryButtonsHoverColor = "#222222",
673
- primaryButtonsActiveColor = "#111111",
674
- filterable,
675
- CustomFilterButton,
676
- sortable = true,
677
- CustomActions,
678
- AddComponent,
679
- customOnEdit,
680
- CustomSelectedActions,
681
- CustomPrimaryActions,
682
- CustomHeaderComponent,
683
- rowSubComponent,
684
- rowSubComponentEditMode,
685
- xOverflow,
686
- xOverflowBg,
687
- locales = {},
688
- smallTableButtonDesign = false,
689
- onPreviousPage = () => {},
690
- onNextPage = () => {},
691
- gotoPageIndex = null,
692
- onVisibleRowsChange = null,
693
- onVisibleRowsChangeDebounceTime = null,
694
- onChangeSortBy = null
695
- } = _ref,
696
- rest = _objectWithoutProperties(_ref, _excluded);
697
-
698
- const [selected, setSelected] = useState({});
699
- const [selectAll, setSelectAll] = useState(false);
700
- const [showFilter, setShowFilter] = useState(false);
701
- const [deleteConfirm, setDeleteConfirm] = useState(false);
702
- const [showAddComponent, setShowAddComponent] = useState(false);
703
- const [search, setSearch] = useState("");
704
- const [currentData, setCurrentData] = useState([]);
705
- const [transformedFooterRow, setTransformedFooterRow] = useState();
706
- const [placeholderHeight, setPlaceholderHeight] = useState();
707
-
708
- const locale = (key, fallback) => locales[key] || fallback;
709
-
710
- const {
711
- isMobile
712
- } = useIsMobile();
713
- const displayCustomActionsBelowSearch = isMobile || smallTableButtonDesign; // recalculate height of simplebar wrapper
714
- // https://github.com/Grsmto/simplebar/tree/master/packages/simplebar-react#accessing-simplebar-instance
715
-
716
- const ref = /*#__PURE__*/createRef();
717
- useEffect(() => {
718
- if (xOverflow && ref && ref.current) {
719
- ref.current.recalculate();
720
- }
721
- }, [ref, xOverflow]);
722
- useEffect(() => {
723
- if (xOverflow && currentData.length) {
724
- const content = document.querySelector(".simplebar-content");
725
- setPlaceholderHeight(content.offsetHeight);
726
- }
727
- }, [currentData, xOverflow]);
728
- const defaultColumn = useMemo(() => ({
729
- Filter: DefaultColumnFilter
730
- }), []);
731
- const filterTypes = useMemo(() => ({
732
- // Add a new fuzzyTextFilterFn filter type.
733
- fuzzyText: fuzzyTextFilterFn,
734
- // override the default text filter to use "startWith"
735
- text: (rows, id, filterValue) => {
736
- return rows.filter(row => {
737
- const rowValue = row.values[id];
738
- return rowValue !== undefined ? String(rowValue).toLowerCase().startsWith(String(filterValue).toLowerCase()) : true;
739
- });
740
- }
741
- }), []); // for xOverflow:
742
-
743
- const isFirstCell = (itemSize, idx, xOverflow) => {
744
- if (idx === 0 && xOverflow) {
745
- return xOverflow;
746
- }
747
-
748
- return itemSize;
749
- };
750
-
751
- const isLastCell = (itemCount, idx, xOverflow) => {
752
- if (itemCount - 1 === idx && xOverflow) {
753
- return true;
754
- }
755
- };
756
-
757
- useEffect(() => {
758
- onSearchChange(search);
759
- }, [search]);
760
- useEffect(() => {
761
- if (!searchID || !search) {
762
- return setCurrentData(data);
763
- }
764
-
765
- const newData = data.filter(item => item[searchID] && item[searchID].toLowerCase().includes(search.toLowerCase()));
766
- setCurrentData(newData);
767
- }, [data, searchID, search]);
768
- useEffect(() => {
769
- if (!footerRow) {
770
- return setTransformedFooterRow(null);
771
- }
772
-
773
- setTransformedFooterRow({
774
- values: footerRow,
775
- original: {
776
- _isFooter: true,
777
- _noSelect: true,
778
- CustomNoSelect: () => null
779
- }
780
- });
781
- }, [footerRow]);
782
- const useTableData = {
783
- columns,
784
- data: currentData,
785
- defaultColumn,
786
- filterTypes,
787
- initialState: {
788
- pageSize: defaultPageSize
789
- }
790
- };
791
-
792
- if (defaultSorted) {
793
- useTableData.initialState = _objectSpread2(_objectSpread2({}, useTableData.initialState), {}, {
794
- sortBy: defaultSorted
795
- });
796
- }
797
-
798
- const instance = useTable(useTableData, useFilters, useSortBy, useExpanded, usePagination);
799
- const {
800
- getTableProps,
801
- getTableBodyProps,
802
- headerGroups,
803
- prepareRow,
804
- rows,
805
- state: {
806
- pageIndex,
807
- pageSize
808
- },
809
- canPreviousPage,
810
- canNextPage,
811
- gotoPage,
812
- nextPage,
813
- previousPage,
814
- setPageSize,
815
- page,
816
- pageOptions
817
- } = instance;
818
- const [debouncedRows] = useDebouncedValue(noPagination ? rows : page, onVisibleRowsChangeDebounceTime);
819
- useEffect(() => {
820
- if (onVisibleRowsChange !== null) {
821
- onVisibleRowsChange(debouncedRows);
822
- }
823
- }, [debouncedRows]);
824
- useEffect(() => {
825
- if (gotoPageIndex !== null) {
826
- gotoPage(gotoPageIndex);
827
- }
828
- }, [gotoPageIndex, pageIndex]);
829
- useEffect(() => {
830
- if (staticPageSize) {
831
- setPageSize(staticPageSize);
832
- }
833
- }, [staticPageSize, setPageSize]);
834
- useEffect(() => {
835
- onPageSizeChange(pageSize);
836
- }, [pageSize]);
837
- useEffect(() => {
838
- onPageChange(pageIndex);
839
- }, [pageIndex]);
840
- useEffect(() => {
841
- if (xOverflow) {
842
- const content = document.querySelector(".simplebar-content");
843
- setPlaceholderHeight(content.offsetHeight);
844
- }
845
- }, [xOverflow, pageSize]);
846
- useEffect(() => {
847
- onRowsLengthChange(rows.length);
848
- }, [rows.length, onRowsLengthChange]);
849
-
850
- const getSelectedList = function () {
851
- let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : selected;
852
- const list = [];
853
- Object.keys(state).forEach(key => {
854
- if (state[key]) {
855
- list.push(key);
856
- }
857
- });
858
- return list;
859
- };
860
-
861
- const handleDeleteSelected = () => {
862
- onDelete(getSelectedList());
863
- setDeleteConfirm(false);
864
- setSelectAll(false);
865
- setSelected({});
866
- };
867
-
868
- const handleSortGeneric = (action, row) => {
869
- const newData = [...currentData];
870
- const index = parseInt(row.id);
871
-
872
- if (action === "increment" && index > 0) {
873
- const firstRow = newData[index];
874
- const lastRow = newData[index - 1];
875
- newData.splice(index - 1, 2, firstRow, lastRow);
876
- }
877
-
878
- if (action === "decrement" && index < newData.length - 1) {
879
- const firstRow = newData[index];
880
- const lastRow = newData[index + 1];
881
- newData.splice(index, 2, lastRow, firstRow);
882
- }
883
-
884
- setCurrentData(newData);
885
- };
886
-
887
- const returnSelectedList = newState => {
888
- onSelectionChange(getSelectedList(newState));
889
- };
890
-
891
- const handleSelectAll = () => {
892
- const newState = {};
893
- page.forEach(row => {
894
- if ("_id" in row.original && !row.original._noSelect) {
895
- const {
896
- _id
897
- } = row.original;
898
- newState[_id] = !selectAll;
899
- }
900
- });
901
- setSelected(newState);
902
- setSelectAll(!selectAll);
903
- returnSelectedList(newState);
904
- };
905
-
906
- const handleOnSelectionChange = row => {
907
- if (!("_id" in row.original)) {
908
- return;
909
- }
910
-
911
- const {
912
- _id
913
- } = row.original;
914
-
915
- const newState = _objectSpread2(_objectSpread2({}, selected), {}, {
916
- [_id]: !selected[_id]
917
- });
918
-
919
- if (selected[_id] && selectAll) {
920
- setSelectAll(false);
921
- } else {
922
- let allSelected = true;
923
- page.forEach(row => {
924
- if ("_id" in row.original && !row.original._noSelect) {
925
- const {
926
- _id
927
- } = row.original;
928
-
929
- if (!newState[_id]) {
930
- allSelected = false;
931
- return;
932
- }
933
- }
934
- });
935
-
936
- if (allSelected) {
937
- setSelectAll(true);
938
- }
939
- }
940
-
941
- setSelected(newState);
942
- returnSelectedList(newState);
943
- };
944
-
945
- const selectedList = getSelectedList();
946
-
947
- const handleClearSearch = () => {
948
- setSearch("");
949
- };
950
-
951
- const itemsSelected = Boolean(selectedList.length);
952
- useEffect(() => {
953
- if (itemsSelected && showAddComponent) {
954
- setShowAddComponent(false);
955
- }
956
- }, [selected.length]); // if data gets updated, check if every selected item is still on the data set
957
-
958
- useEffect(() => {
959
- const newSelected = _objectSpread2({}, selected);
960
-
961
- for (const selectedListElement of selectedList) {
962
- const doesItemStillExists = currentData.find(item => "_id" in item && !item._noSelect && item._id.toString() === selectedListElement);
963
-
964
- if (!doesItemStillExists) {
965
- newSelected[selectedListElement] = false;
966
- }
967
- }
968
-
969
- setSelected(newSelected);
970
- }, [currentData]);
971
- useEffect(() => {
972
- const existingIds = [];
973
-
974
- for (const row of page) {
975
- if ("_id" in row.original && !row.original._noSelect) {
976
- existingIds.push(row.original._id);
977
- }
978
- }
979
-
980
- if (existingIds.length) {
981
- let shouldSelectAll = true;
982
-
983
- for (const id of existingIds) {
984
- if (!selected[id]) {
985
- shouldSelectAll = false;
986
- break;
987
- }
988
- }
989
-
990
- setSelectAll(shouldSelectAll);
991
- }
992
- }, [page]);
993
- const editRowEnabled = rowSubComponentEditMode && rowSubComponent;
994
- return /*#__PURE__*/React.createElement(Container, null, (title || filterable || exportSettings || CustomActions) && /*#__PURE__*/React.createElement(Header, null, /*#__PURE__*/React.createElement(HeaderPrimaryContent, null, /*#__PURE__*/React.createElement(Typography, {
995
- size: "h3",
996
- component: "h3"
997
- }, title)), /*#__PURE__*/React.createElement(ActionBar, null, filterable && (CustomFilterButton ? /*#__PURE__*/React.createElement(CustomFilterButton, {
998
- onClick: () => setShowFilter(!showFilter)
999
- }) : /*#__PURE__*/React.createElement(ActionIcon, {
1000
- title: locale("filter-rows", "Filter rows"),
1001
- "aria-label": locale("filter-rows", "Filter rows"),
1002
- label: locale("filter-rows", "Filter rows"),
1003
- onClick: () => setShowFilter(!showFilter),
1004
- hoverColor: iconButtonsHoverColor,
1005
- activeColor: iconButtonsActiveColor,
1006
- icon: FilterList
1007
- })), exportSettings && /*#__PURE__*/React.createElement(ExportCSVButton, _extends({
1008
- locale: locale,
1009
- data: data,
1010
- filename: exportSettings.filename,
1011
- headers: exportSettings.headers,
1012
- hoverColor: iconButtonsHoverColor,
1013
- activeColor: iconButtonsActiveColor
1014
- }, exportSettings)), CustomActions && /*#__PURE__*/React.createElement(CustomActions, null))), (searchID || CustomPrimaryActions || AddComponent || itemsSelected && (CustomSelectedActions || onDelete)) && /*#__PURE__*/React.createElement(Header, null, searchID && /*#__PURE__*/React.createElement(Search, _extends({
1015
- expand: displayCustomActionsBelowSearch,
1016
- color: color
1017
- }, inputProps, {
1018
- leftIcon: /*#__PURE__*/React.createElement(SearchIcon, {
1019
- title: locale("search", "Search")
1020
- }),
1021
- rightIcon: search && search.length && /*#__PURE__*/React.createElement(ClearSearchButton, {
1022
- handleClearSearch: handleClearSearch
1023
- }),
1024
- label: searchLabel || locale("search", "Search"),
1025
- value: search,
1026
- onChange: ev => setSearch(ev.target.value)
1027
- })), (CustomPrimaryActions || !itemsSelected && AddComponent && !showAddComponent || itemsSelected && (CustomSelectedActions || onDelete)) && /*#__PURE__*/React.createElement(ActionBar, null, CustomPrimaryActions && /*#__PURE__*/React.createElement(CustomPrimaryActions, null), itemsSelected && [CustomSelectedActions && /*#__PURE__*/React.createElement(CustomSelectedActions, null), onDelete && /*#__PURE__*/React.createElement(ActionIcon, {
1028
- title: locale("delete", "Deletex"),
1029
- "aria-label": locale("delete", "Delete"),
1030
- label: locale("delete", "Delete"),
1031
- onClick: () => setDeleteConfirm(true),
1032
- flatIcon: false,
1033
- hoverColor: iconButtonsHoverColor,
1034
- activeColor: iconButtonsActiveColor,
1035
- outlined: true,
1036
- color: color,
1037
- icon: DeleteIcon,
1038
- useMobileLayout: isMobile
1039
- })], AddComponent && !showAddComponent && !itemsSelected && /*#__PURE__*/React.createElement(ActionIcon, {
1040
- title: locale("add", "Add"),
1041
- "aria-label": locale("add", "Add"),
1042
- label: locale("add", "Add"),
1043
- onClick: () => setShowAddComponent(!showAddComponent),
1044
- icon: props => /*#__PURE__*/React.createElement(Cross, _extends({
1045
- rotation: "45deg",
1046
- width: 13
1047
- }, props)),
1048
- flatIcon: false,
1049
- hoverColor: primaryButtonsHoverColor,
1050
- activeColor: primaryButtonsActiveColor,
1051
- color: color,
1052
- flexed: isMobile
1053
- }))), CustomHeaderComponent && /*#__PURE__*/React.createElement(CustomHeaderComponent, null), showAddComponent && AddComponent && /*#__PURE__*/React.createElement(AddComponentContainer, null, /*#__PURE__*/React.createElement(AddComponent, {
1054
- closeAddComponent: () => setShowAddComponent(false)
1055
- })), deleteConfirm && /*#__PURE__*/React.createElement(DeleteConfirmBanner, {
1056
- locales: locales,
1057
- color: color,
1058
- onDelete: handleDeleteSelected,
1059
- onCancel: () => setDeleteConfirm(false)
1060
- }), /*#__PURE__*/React.createElement(StyledTable, _extends({
1061
- selectHighlight: selectHighlight,
1062
- xOverflow: xOverflow,
1063
- bordered: bordered
1064
- }, getTableProps(), rest), /*#__PURE__*/React.createElement(TableContent, {
1065
- ref: ref,
1066
- xOverflow: xOverflow,
1067
- placeholderHeight: placeholderHeight
1068
- }, /*#__PURE__*/React.createElement(TableHeaderSection, {
1069
- role: "rowgroup",
1070
- bordered: bordered,
1071
- xOverflow: xOverflow
1072
- }, headerGroups.map((headerGroup, i) => /*#__PURE__*/React.createElement(Row, _extends({
1073
- role: "row",
1074
- key: "header-row-".concat(i),
1075
- header: true,
1076
- bordered: bordered,
1077
- xOverflow: xOverflow
1078
- }, headerGroup.getHeaderGroupProps()), onSelectionChange && /*#__PURE__*/React.createElement(TableHeaderCell, {
1079
- role: "columnheader",
1080
- checkbox: true,
1081
- size: 50
1082
- }, /*#__PURE__*/React.createElement(Checkbox, _extends({
1083
- dashed: !selectAll && selectedList.length
1084
- }, checkboxProps, {
1085
- hideLabel: true,
1086
- checked: selectAll || selectedList.length,
1087
- onChange: handleSelectAll
1088
- }), "Select all")), headerGroup.headers.map((column, idx) => {
1089
- return /*#__PURE__*/React.createElement(TableHeaderCell, _extends({
1090
- role: "columnheader",
1091
- key: "header-row-".concat(i, "-content-").concat(idx),
1092
- enableFlex: !xOverflow,
1093
- stickyCell: idx === 0 && xOverflow,
1094
- stickyCellNext: idx === 1 && xOverflow,
1095
- size: isFirstCell(column.size, idx, xOverflow),
1096
- lastCell: isLastCell(headerGroup.headers.length, idx, xOverflow),
1097
- sortIconVisible: column.isSorted,
1098
- justifyStart: column.disableFilters && showFilter,
1099
- xOverflowBg: xOverflowBg
1100
- }, column.getHeaderProps()), sortable ? /*#__PURE__*/React.createElement("div", _objectSpread2(_objectSpread2({}, column.getSortByToggleProps()), {}, {
1101
- onClick: function () {
1102
- onChangeSortBy && onChangeSortBy({
1103
- isSorted: column.isSorted,
1104
- isSortedDesc: column.isSortedDesc,
1105
- columnId: column.id
1106
- });
1107
- column.getSortByToggleProps().onClick(...arguments);
1108
- },
1109
- title: "".concat(locale("sort-by", "Sort by"), " ").concat((typeof column.Header == "string" ? column.Header : column.id || column.accessor).toLowerCase())
1110
- }), column.render("Header"), column.canSort && /*#__PURE__*/React.createElement("span", {
1111
- className: "sort-icon"
1112
- }, column.isSorted ? column.isSortedDesc ? /*#__PURE__*/React.createElement(SortDownIcon, null) : /*#__PURE__*/React.createElement(SortUpIcon, null) : /*#__PURE__*/React.createElement(SortUpIcon, null))) : column.render("Header"), showFilter && column.canFilter && /*#__PURE__*/React.createElement("div", {
1113
- style: {
1114
- width: "100%",
1115
- marginBottom: "10px"
1116
- }
1117
- }, column.render("Filter")));
1118
- }), editRowEnabled || onDelete && showDeleteColumn ? /*#__PURE__*/React.createElement(TableHeaderCell, {
1119
- role: "columnheader",
1120
- size: rowSubComponentEditMode && rowSubComponent && showDeleteColumn && onDelete ? 90 : 80
1121
- }, "Actions") : null, rowSubComponent && !editRowEnabled && /*#__PURE__*/React.createElement(TableHeaderCell, {
1122
- role: "columnheader",
1123
- noPadding: true,
1124
- size: 40
1125
- })))), /*#__PURE__*/React.createElement(TableBody, _extends({
1126
- role: "rowgroup"
1127
- }, getTableBodyProps(), {
1128
- xOverflow: xOverflow
1129
- }), [...(noPagination ? rows : page), ...(transformedFooterRow ? [transformedFooterRow] : [])].map((row, rowIdx) => {
1130
- const {
1131
- original: {
1132
- _noSelect,
1133
- _customRowColor,
1134
- _id,
1135
- _isFooter,
1136
- _onClick,
1137
- CustomNoSelect
1138
- }
1139
- } = row;
1140
- return prepareRow(row) || /*#__PURE__*/React.createElement(Fragment, {
1141
- key: "row-".concat(rowIdx)
1142
- }, /*#__PURE__*/React.createElement(Row, _extends({
1143
- role: "row",
1144
- bordered: bordered,
1145
- rowSpacing: rowSpacing,
1146
- selected: selected[row.original._id],
1147
- selectHighlight: selectHighlight,
1148
- rowColor: _isFooter ? undefined : _customRowColor,
1149
- isFooter: _isFooter,
1150
- xOverflow: xOverflow
1151
- }, row.getRowProps()), sortableRows && /*#__PURE__*/React.createElement(SortCell, {
1152
- role: "cell",
1153
- size: 25
1154
- }, /*#__PURE__*/React.createElement(SortButton, {
1155
- action: "increment",
1156
- onSort: onSort ? onSort : handleSortGeneric,
1157
- row: row,
1158
- rowSpacing: rowSpacing
1159
- }), /*#__PURE__*/React.createElement(SortButton, {
1160
- action: "decrement",
1161
- onSort: onSort ? onSort : handleSortGeneric,
1162
- row: row,
1163
- rowSpacing: rowSpacing
1164
- })), onSelectionChange && /*#__PURE__*/React.createElement(Cell, {
1165
- role: "cell",
1166
- rowSpacing: rowSpacing,
1167
- checkbox: true,
1168
- size: 50
1169
- }, CustomNoSelect && _noSelect ? /*#__PURE__*/React.createElement(CustomNoSelect, null) : /*#__PURE__*/React.createElement(Checkbox, _extends({}, checkboxProps, {
1170
- hideLabel: true,
1171
- checked: selected[_id],
1172
- disabled: _noSelect,
1173
- onChange: () => handleOnSelectionChange(row)
1174
- }), locales["select"] || "Select")), row.cells.map((cell, cellIdx) => {
1175
- const cellSize = isFirstCell(cell.column.size, cellIdx, xOverflow);
1176
- const lastCell = isLastCell(row.cells.length, cellIdx, xOverflow);
1177
- return /*#__PURE__*/React.createElement(Cell, _extends({
1178
- role: "cell",
1179
- onClick: _onClick,
1180
- key: cell.value,
1181
- enableFlex: !xOverflow,
1182
- stickyCell: cellIdx === 0 && xOverflow,
1183
- stickyCellNext: cellIdx === 1 && xOverflow,
1184
- xOverflow: xOverflow,
1185
- size: cellSize,
1186
- lastCell: lastCell,
1187
- isNumber: cell.column.isNumber,
1188
- xOverflowBg: xOverflowBg,
1189
- ellipsisOverflow: ["string", "number"].includes(typeof cell.value)
1190
- }, cell.getCellProps()), cell.value || cell.column.isNumber ? cell.render(_isFooter ? "Footer" : "Cell") : "");
1191
- }), (editRowEnabled || showDeleteColumn && onDelete) && /*#__PURE__*/React.createElement(ButtonsRowContainer, {
1192
- size: editRowEnabled && showDeleteColumn && onDelete ? 90 : 80
1193
- }, !_noSelect && showDeleteColumn && onDelete ? /*#__PURE__*/React.createElement(ActionButtons, {
1194
- locales: locales,
1195
- onDelete: onDelete,
1196
- disabled: _noSelect,
1197
- row: row,
1198
- customOnEdit: customOnEdit,
1199
- hoverColor: iconButtonsHoverColor,
1200
- activeColor: iconButtonsActiveColor,
1201
- editButtonProps: editRowEnabled && row.getToggleRowExpandedProps()
1202
- }) : !_noSelect && editRowEnabled && /*#__PURE__*/React.createElement(EditButton, _extends({
1203
- title: locales["edit"] || "Edit",
1204
- row: row,
1205
- customOnEdit: customOnEdit
1206
- }, row.getToggleRowExpandedProps()))), rowSubComponent && !editRowEnabled && /*#__PURE__*/React.createElement(Cell, _extends({
1207
- role: "cell",
1208
- noPadding: true,
1209
- size: 40
1210
- }, row.getToggleRowExpandedProps()), /*#__PURE__*/React.createElement(ExpandIcon, {
1211
- expanded: row.isExpanded || undefined
1212
- }))), row.isExpanded ? /*#__PURE__*/React.createElement("div", null, rowSubComponent({
1213
- row
1214
- })) : null);
1215
- }), /*#__PURE__*/React.createElement(BlankRows, {
1216
- onDelete: onDelete,
1217
- showDeleteColumn: showDeleteColumn,
1218
- onSelectionChange: onSelectionChange,
1219
- staticPageSize: staticPageSize,
1220
- noPagination: noPagination,
1221
- rows: rows,
1222
- page: page,
1223
- bordered: bordered,
1224
- headerGroups: headerGroups,
1225
- editRowEnabled: editRowEnabled,
1226
- rowSubComponent: rowSubComponent
1227
- })))), !noPagination && /*#__PURE__*/React.createElement(Pagination, {
1228
- totalEntries: rows.length,
1229
- gotoPage: gotoPage,
1230
- nextPage: () => {
1231
- onNextPage(pageIndex + 1);
1232
- nextPage();
1233
- },
1234
- previousPage: () => {
1235
- onPreviousPage(pageIndex - 1);
1236
- previousPage();
1237
- },
1238
- pageCount: pageOptions.length,
1239
- staticPageSize: staticPageSize,
1240
- setPageSize: setPageSize,
1241
- pageSize: pageSize,
1242
- pageIndex: pageIndex,
1243
- canNextPage: canNextPage,
1244
- color: color,
1245
- canPreviousPage: canPreviousPage,
1246
- pageSizeOptions: [10, 20, 30, 40, 50],
1247
- locales: locales
1248
- }));
1249
- };
1250
-
1251
- export { Table as T, useDebouncedValue as a, useIsMobile as u };
1252
- //# sourceMappingURL=Table2.js.map