@arcblock/ux 2.5.58 → 2.5.59

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 (128) hide show
  1. package/lib/ActionButton/index.js +20 -39
  2. package/lib/ActivityIndicator/index.js +20 -41
  3. package/lib/Address/compact-text.js +16 -38
  4. package/lib/Address/did-address.js +22 -51
  5. package/lib/Address/index.js +6 -19
  6. package/lib/Address/responsive-did-address.js +20 -36
  7. package/lib/Alert/index.js +12 -34
  8. package/lib/AnimationWaiter/index.js +35 -59
  9. package/lib/Async/index.js +5 -19
  10. package/lib/Avatar/did-motif.js +12 -26
  11. package/lib/Avatar/etherscan-blockies.js +2 -20
  12. package/lib/Avatar/index.js +28 -54
  13. package/lib/Badge/index.js +12 -33
  14. package/lib/Blocklet/blocklet.js +19 -46
  15. package/lib/Blocklet/index.js +0 -6
  16. package/lib/Blocklet/utils.js +0 -6
  17. package/lib/BlockletNFT/index.js +36 -66
  18. package/lib/Button/index.js +0 -4
  19. package/lib/Button/wrap.js +19 -38
  20. package/lib/ButtonGroup/index.js +0 -5
  21. package/lib/CardSelector/index.js +9 -22
  22. package/lib/Center/index.js +2 -12
  23. package/lib/ClickToCopy/copy-button.js +9 -26
  24. package/lib/ClickToCopy/hook.js +0 -10
  25. package/lib/ClickToCopy/index.js +13 -41
  26. package/lib/CodeBlock/LightBox.js +1 -6
  27. package/lib/CodeBlock/index.js +12 -80
  28. package/lib/Colors/index.js +0 -2
  29. package/lib/Colors/themes/default.js +2 -3
  30. package/lib/ContactForm/index.js +5 -35
  31. package/lib/CookieConsent/index.js +10 -32
  32. package/lib/CountDown/index.js +10 -35
  33. package/lib/DID/index.js +8 -32
  34. package/lib/Datatable/CustomToolbar.js +9 -56
  35. package/lib/Datatable/DatatableContext.js +2 -5
  36. package/lib/Datatable/TableSearch.js +0 -21
  37. package/lib/Datatable/index.js +76 -152
  38. package/lib/Datatable/utils.js +14 -27
  39. package/lib/Dialog/confirm.js +18 -31
  40. package/lib/Dialog/dialog.js +24 -50
  41. package/lib/Dialog/index.js +0 -3
  42. package/lib/DidLogo/index.js +0 -7
  43. package/lib/DriftBot/index.js +1 -12
  44. package/lib/Earth/index.js +17 -58
  45. package/lib/Earth/util.js +0 -7
  46. package/lib/Empty/index.js +9 -23
  47. package/lib/ErrorBoundary/fallback.js +0 -14
  48. package/lib/ErrorBoundary/index.js +0 -2
  49. package/lib/Footer/index.js +1 -14
  50. package/lib/Header/auto-hidden.js +9 -23
  51. package/lib/Header/header.js +19 -38
  52. package/lib/Header/index.js +0 -3
  53. package/lib/Header/responsive-header.js +16 -40
  54. package/lib/Icon/image.js +12 -26
  55. package/lib/Icon/index.js +15 -34
  56. package/lib/Img/index.js +32 -54
  57. package/lib/InfoRow/index.js +11 -27
  58. package/lib/Layout/dashboard/external-link.js +13 -30
  59. package/lib/Layout/dashboard/full-page.js +8 -24
  60. package/lib/Layout/dashboard/index.js +28 -72
  61. package/lib/Layout/dashboard/sidebar.js +11 -31
  62. package/lib/Layout/dashboard-legacy/header.js +14 -36
  63. package/lib/Layout/dashboard-legacy/index.js +19 -44
  64. package/lib/Layout/dashboard-legacy/sidebar.js +10 -32
  65. package/lib/Layout/index.js +18 -52
  66. package/lib/Locale/browser-lang.js +6 -19
  67. package/lib/Locale/context.js +15 -51
  68. package/lib/Locale/languages.js +3 -7
  69. package/lib/Locale/selector.js +11 -44
  70. package/lib/Locale/util.js +0 -10
  71. package/lib/Logo/index.js +10 -33
  72. package/lib/Metric/index.js +1 -9
  73. package/lib/NFTDisplay/aspect-ratio-container.js +7 -20
  74. package/lib/NFTDisplay/broken.js +0 -8
  75. package/lib/NFTDisplay/index.js +63 -110
  76. package/lib/NFTDisplay/loading.js +0 -6
  77. package/lib/NFTDisplay/svg-embedder/img.js +9 -22
  78. package/lib/NFTDisplay/svg-embedder/inline-svg.js +9 -23
  79. package/lib/NavMenu/index.js +0 -2
  80. package/lib/NavMenu/nav-menu.js +40 -69
  81. package/lib/NavMenu/style.js +1 -5
  82. package/lib/PageScroller/index.js +9 -39
  83. package/lib/PageScroller/story/FifthComponent.js +0 -2
  84. package/lib/PageScroller/story/FirstComponent.js +0 -2
  85. package/lib/PageScroller/story/FourthComponent.js +0 -2
  86. package/lib/PageScroller/story/FullPage.js +1 -14
  87. package/lib/PageScroller/story/PageContain.js +1 -14
  88. package/lib/PageScroller/story/SecondComponent.js +0 -2
  89. package/lib/PageScroller/story/ThirdComponent.js +0 -2
  90. package/lib/PageScroller/usePrevValue.js +1 -2
  91. package/lib/PricingTable/PricingPlan.js +0 -12
  92. package/lib/PricingTable/index.js +0 -14
  93. package/lib/QRCode/index.js +14 -24
  94. package/lib/RelativeTime/index.js +12 -45
  95. package/lib/Result/common.js +43 -63
  96. package/lib/Result/index.js +6 -23
  97. package/lib/Result/result.js +9 -23
  98. package/lib/Screenshot/BaseScreenshot/index.js +9 -26
  99. package/lib/Screenshot/BaseScreenshot/shells/Macbook.js +9 -10
  100. package/lib/Screenshot/BaseScreenshot/shells/Phone.js +3 -8
  101. package/lib/Screenshot/index.js +32 -65
  102. package/lib/SessionManager/index.js +31 -83
  103. package/lib/Sparkline/index.js +40 -42
  104. package/lib/Spinner/index.js +12 -23
  105. package/lib/SplitButton/index.js +20 -48
  106. package/lib/Switch/index.js +7 -22
  107. package/lib/Tabs/index.js +8 -22
  108. package/lib/Tag/index.js +13 -33
  109. package/lib/TextCollapse/index.js +14 -31
  110. package/lib/Theme/index.js +3 -13
  111. package/lib/Theme/theme-provider.js +1 -10
  112. package/lib/Theme/theme.js +15 -27
  113. package/lib/Toast/index.js +13 -40
  114. package/lib/Util/deprecate.js +3 -12
  115. package/lib/Util/index.js +13 -74
  116. package/lib/Util/wallet.js +3 -10
  117. package/lib/Video/index.js +3 -19
  118. package/lib/Wallet/Action.js +9 -28
  119. package/lib/Wallet/Download.js +11 -36
  120. package/lib/Wallet/Open.js +0 -12
  121. package/lib/WebWalletSWKeeper/index.js +30 -55
  122. package/lib/WechatPrompt/index.js +0 -16
  123. package/lib/index.js +0 -38
  124. package/lib/withTheme/index.js +3 -15
  125. package/lib/withTracker/error_boundary.js +3 -14
  126. package/lib/withTracker/index.js +3 -24
  127. package/package.json +5 -5
  128. package/src/NFTDisplay/index.js +4 -4
@@ -5,132 +5,95 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = DataTable;
7
7
  exports.getDurableData = void 0;
8
-
9
8
  var _react = require("react");
10
-
11
9
  var _propTypes = _interopRequireDefault(require("prop-types"));
12
-
13
10
  var _muiDatatables = _interopRequireWildcard(require("mui-datatables"));
14
-
15
11
  var _react2 = require("@emotion/react");
16
-
17
12
  var _isObject = _interopRequireDefault(require("lodash/isObject"));
18
-
19
13
  var _cloneDeep = _interopRequireDefault(require("lodash/cloneDeep"));
20
-
21
14
  var _get = _interopRequireDefault(require("lodash/get"));
22
-
23
15
  var _clsx = _interopRequireDefault(require("clsx"));
24
-
25
16
  var _CircularProgress = _interopRequireDefault(require("@mui/material/CircularProgress"));
26
-
27
17
  var _Empty = _interopRequireDefault(require("../Empty"));
28
-
29
18
  var _CustomToolbar = _interopRequireDefault(require("./CustomToolbar"));
30
-
31
19
  var _DatatableContext = require("./DatatableContext");
32
-
33
20
  var _Theme = require("../Theme");
34
-
35
21
  var _jsxRuntime = require("react/jsx-runtime");
36
-
37
22
  var _templateObject, _templateObject2, _templateObject3, _templateObject4;
38
-
39
23
  const _excluded = ["data", "columns", "locale", "options", "style", "customButtons", "onChange", "loading", "disabled", "stripped", "verticalKeyWidth", "hideTableHeader", "components", "emptyNode", "durable", "durableKeys"];
40
-
41
24
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
42
-
43
25
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
44
-
45
26
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
46
-
47
27
  function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
48
-
49
28
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
50
-
51
29
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
52
-
53
30
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
54
-
55
31
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
56
-
57
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
58
-
59
- /**
60
- * @typedef {{
61
- * icon: import('react').ReactElement,
62
- * title: string,
63
- * }} DataTableCustomButton
64
- */
65
-
66
- /**
67
- * @typedef {{
68
- * name: string,
69
- * label: string,
70
- * width?: number,
71
- * options?: {
72
- * filter?: boolean,
73
- * sort?: boolean,
74
- * customBodyRender?: (value: any) => import('react').ReactElement,
75
- * customBodyRenderLite?: (index: number) => import('react').ReactElement
76
- * } & import('mui-datatables').MUIDataTableColumnOptions
77
- * } & import('mui-datatables').MUIDataTableColumnDef} DataTableColumn
78
- */
79
-
80
- /**
81
- * @typedef {Pick<import('mui-datatables').MUIDataTableState, 'count' | 'page' | 'rowsPerPage' | 'searchText' | 'sortOrder' | 'filterList'>} DataTableState
82
- */
83
-
84
- /**
85
- * @typedef {{
86
- * data: Array<object | number[] | string[]>,
87
- * columns: Array<DataTableColumn>,
88
- * locale?: string,
89
- * options?: import('mui-datatables').MUIDataTableOptions,
90
- * style?: import('react').CSSProperties,
91
- * customButtons?: Array<DataTableCustomButton>,
92
- * onChange?: (state: DataTableState, action: string) => void | Promise<void>,
93
- * loading?: boolean,
94
- * disabled?: boolean,
95
- * stripped?: boolean,
96
- * verticalKeyWidth?: number | string,
97
- * hideTableHeader?: boolean,
98
- * components?: import('react').ReactElement,
99
- * emptyNode?: import('react').ReactElement,
100
- * durable?: string,
101
- * durableKeys?: 'page' | 'rowsPerPage' | 'searchText' | 'sortOrder'
102
- * } & import('mui-datatables').MUIDataTableProps} DataTableProps
103
- */
104
-
105
- /**
106
- * @description
107
- * @export
108
- * @param {DataTableProps} props
109
- * @return {import('react').ReactComponentElement}
110
- */
32
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
33
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
34
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } /* eslint-disable react-hooks/exhaustive-deps */ /**
35
+ * @typedef {{
36
+ * icon: import('react').ReactElement,
37
+ * title: string,
38
+ * }} DataTableCustomButton
39
+ */ /**
40
+ * @typedef {{
41
+ * name: string,
42
+ * label: string,
43
+ * width?: number,
44
+ * options?: {
45
+ * filter?: boolean,
46
+ * sort?: boolean,
47
+ * customBodyRender?: (value: any) => import('react').ReactElement,
48
+ * customBodyRenderLite?: (index: number) => import('react').ReactElement
49
+ * } & import('mui-datatables').MUIDataTableColumnOptions
50
+ * } & import('mui-datatables').MUIDataTableColumnDef} DataTableColumn
51
+ */ /**
52
+ * @typedef {Pick<import('mui-datatables').MUIDataTableState, 'count' | 'page' | 'rowsPerPage' | 'searchText' | 'sortOrder' | 'filterList'>} DataTableState
53
+ */ /**
54
+ * @typedef {{
55
+ * data: Array<object | number[] | string[]>,
56
+ * columns: Array<DataTableColumn>,
57
+ * locale?: string,
58
+ * options?: import('mui-datatables').MUIDataTableOptions,
59
+ * style?: import('react').CSSProperties,
60
+ * customButtons?: Array<DataTableCustomButton>,
61
+ * onChange?: (state: DataTableState, action: string) => void | Promise<void>,
62
+ * loading?: boolean,
63
+ * disabled?: boolean,
64
+ * stripped?: boolean,
65
+ * verticalKeyWidth?: number | string,
66
+ * hideTableHeader?: boolean,
67
+ * components?: import('react').ReactElement,
68
+ * emptyNode?: import('react').ReactElement,
69
+ * durable?: string,
70
+ * durableKeys?: 'page' | 'rowsPerPage' | 'searchText' | 'sortOrder'
71
+ * } & import('mui-datatables').MUIDataTableProps} DataTableProps
72
+ */ /**
73
+ * @description
74
+ * @export
75
+ * @param {DataTableProps} props
76
+ * @return {import('react').ReactComponentElement}
77
+ */
111
78
  function DataTable(props) {
112
79
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_DatatableContext.DatatableProvider, {
113
80
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(ReDataTable, _objectSpread({}, props))
114
81
  });
115
82
  }
116
-
117
83
  const fixCellProp = (tempObj, cellProps) => {
118
84
  const cellStyle = {};
119
-
120
85
  if (tempObj.align) {
121
86
  cellProps.className = (0, _clsx.default)(cellProps.className, "pc-align-".concat(tempObj.align));
122
87
  }
123
-
124
88
  if (tempObj.verticalKeyAlign) {
125
89
  cellProps.className = (0, _clsx.default)(cellProps.className, "vertical-align-".concat(tempObj.verticalKeyAlign));
126
90
  }
127
-
128
91
  if (tempObj.minWidth) {
129
92
  cellStyle.minWidth = tempObj.minWidth;
130
93
  }
131
-
132
94
  cellProps.style = Object.assign({}, cellProps.style, cellStyle);
133
95
  };
96
+
134
97
  /**
135
98
  * @param {Object} props.options The options of mui-datatable,detail see https://github.com/gregnb/mui-datatables/tree/b8d2eee6af4589d254b40918e5d7e70b1ee4baca
136
99
  * @param {Array} props.customButtons Custom buttons for toolbar
@@ -138,30 +101,27 @@ const fixCellProp = (tempObj, cellProps) => {
138
101
  * @param {Boolean} props.loading For dynamic data, usually used with onChange
139
102
  * @returns
140
103
  */
141
-
142
-
143
104
  function ReDataTable(_ref) {
144
105
  let {
145
- data: originData,
146
- columns: originColumns,
147
- locale,
148
- options,
149
- // The options object is usually a property supported by mui-datatable
150
- style,
151
- customButtons,
152
- onChange,
153
- loading,
154
- disabled,
155
- stripped,
156
- verticalKeyWidth,
157
- hideTableHeader,
158
- components,
159
- emptyNode,
160
- durable,
161
- durableKeys
162
- } = _ref,
163
- rest = _objectWithoutProperties(_ref, _excluded);
164
-
106
+ data: originData,
107
+ columns: originColumns,
108
+ locale,
109
+ options,
110
+ // The options object is usually a property supported by mui-datatable
111
+ style,
112
+ customButtons,
113
+ onChange,
114
+ loading,
115
+ disabled,
116
+ stripped,
117
+ verticalKeyWidth,
118
+ hideTableHeader,
119
+ components,
120
+ emptyNode,
121
+ durable,
122
+ durableKeys
123
+ } = _ref,
124
+ rest = _objectWithoutProperties(_ref, _excluded);
165
125
  const oldState = (0, _react.useRef)(null);
166
126
  const {
167
127
  setCustomButtons,
@@ -173,11 +133,11 @@ function ReDataTable(_ref) {
173
133
  cursor: 'not-allowed',
174
134
  pointerEvents: 'none'
175
135
  };
176
- const keys = []; // Convert Columns fields to object sets to support the width function
136
+ const keys = [];
177
137
 
138
+ // Convert Columns fields to object sets to support the width function
178
139
  const columns = originColumns.map(e => {
179
140
  let tempObj;
180
-
181
141
  if (!(0, _isObject.default)(e)) {
182
142
  tempObj = {
183
143
  label: e,
@@ -186,81 +146,70 @@ function ReDataTable(_ref) {
186
146
  } else {
187
147
  tempObj = (0, _cloneDeep.default)(e);
188
148
  }
189
-
190
149
  keys.push(tempObj.name);
191
-
192
150
  if (!tempObj.align) {
193
151
  // There must be an align default for setCellRender to take effect, this is a bug in mui-datatable
194
152
  tempObj.align = 'left';
195
153
  }
196
-
197
154
  if (!tempObj.options) {
198
155
  tempObj.options = {};
199
156
  }
200
-
201
157
  const {
202
158
  setCellHeaderProps,
203
159
  setCellProps
204
160
  } = tempObj.options;
205
-
206
161
  tempObj.options.setCellHeaderProps = function () {
207
162
  let cellProps = {
208
163
  className: ''
209
- }; // Complementing width while inheriting old setCellHeaderProps
164
+ };
210
165
 
166
+ // Complementing width while inheriting old setCellHeaderProps
211
167
  if (setCellHeaderProps && !setCellHeaderProps.__innerFunc) {
212
168
  cellProps = _objectSpread(_objectSpread({}, cellProps), setCellHeaderProps(...arguments) || {});
213
169
  }
214
-
215
170
  if (loading || disabled) {
216
171
  cellProps = _objectSpread(_objectSpread({}, cellProps), {}, {
217
172
  style: disabledCellStyle
218
173
  });
219
174
  }
220
-
221
175
  if (tempObj.width) {
222
176
  cellProps.width = tempObj.width;
223
177
  }
224
-
225
178
  fixCellProp(tempObj, cellProps);
226
179
  return cellProps;
227
- }; // Prevent memory xie caused by recursive forwarding of setCellHeaderProps functions
228
-
180
+ };
229
181
 
182
+ // Prevent memory xie caused by recursive forwarding of setCellHeaderProps functions
230
183
  tempObj.options.setCellHeaderProps.__innerFunc = 1;
231
-
232
184
  if (tempObj.align || tempObj.style) {
233
185
  tempObj.options.setCellProps = function () {
234
186
  let cellProps = {
235
187
  className: ''
236
- }; // Complementing width while inheriting old setCellHeaderProps
188
+ };
237
189
 
190
+ // Complementing width while inheriting old setCellHeaderProps
238
191
  if (setCellProps && !setCellProps.__innerFunc) {
239
192
  cellProps = _objectSpread(_objectSpread({}, cellProps), setCellProps(...arguments) || {});
240
193
  }
241
-
242
194
  fixCellProp(tempObj, cellProps);
243
195
  return cellProps;
244
196
  };
245
-
246
197
  tempObj.options.setCellProps.__innerFunc = 1;
247
198
  }
248
-
249
199
  return tempObj;
250
- }); // Fixing object-type structures
200
+ });
251
201
 
202
+ // Fixing object-type structures
252
203
  const data = originData.map(e => {
253
204
  if (!Array.isArray(e) && (0, _isObject.default)(e)) {
254
205
  return keys.map(key => (0, _get.default)(e, key));
255
206
  }
256
-
257
207
  return e;
258
208
  });
259
209
  (0, _react.useEffect)(() => setCustomButtons(customButtons || []), [customButtons]);
260
210
  (0, _react.useEffect)(() => setLoading(loading), [loading]);
261
211
  (0, _react.useEffect)(() => setDisabled(disabled), [disabled]);
262
212
  let emptyEl;
263
-
264
213
  if (loading) {
265
214
  emptyEl = /*#__PURE__*/(0, _jsxRuntime.jsx)(_CircularProgress.default, {});
266
215
  } else if ( /*#__PURE__*/(0, _react.isValidElement)(emptyNode)) {
@@ -274,7 +223,6 @@ function ReDataTable(_ref) {
274
223
  children: emptyNode || 'No matching records found'
275
224
  });
276
225
  }
277
-
278
226
  let textLabels = {
279
227
  body: {
280
228
  noMatch: emptyEl,
@@ -309,7 +257,6 @@ function ReDataTable(_ref) {
309
257
  deleteAria: 'Delete Selected Rows'
310
258
  }
311
259
  };
312
-
313
260
  if (locale === 'zh') {
314
261
  textLabels = {
315
262
  body: {
@@ -346,10 +293,8 @@ function ReDataTable(_ref) {
346
293
  }
347
294
  };
348
295
  }
349
-
350
296
  (0, _react.useEffect)(() => setFilterLabel(textLabels.filter.title), [textLabels.filter.title]);
351
297
  const durableData = getDurableData(durable);
352
-
353
298
  const opts = _objectSpread(_objectSpread(_objectSpread({
354
299
  selectableRows: 'none',
355
300
  textLabels,
@@ -362,7 +307,6 @@ function ReDataTable(_ref) {
362
307
  if (action === 'propsUpdate') {
363
308
  return;
364
309
  }
365
-
366
310
  const state = {
367
311
  count: tableState.count,
368
312
  page: tableState.page,
@@ -372,7 +316,6 @@ function ReDataTable(_ref) {
372
316
  //
373
317
  filterList: tableState.filterList
374
318
  };
375
-
376
319
  if (durable) {
377
320
  const needSaveState = {};
378
321
  durableKeys.forEach(key => {
@@ -380,25 +323,19 @@ function ReDataTable(_ref) {
380
323
  });
381
324
  localStorage.setItem("datatable-durable-".concat(durable), JSON.stringify(needSaveState));
382
325
  }
383
-
384
326
  const stateStr = JSON.stringify(state);
385
-
386
327
  if (stateStr === oldState.current) {
387
328
  return;
388
329
  }
389
-
390
330
  oldState.current = stateStr;
391
-
392
331
  if (onChange) {
393
332
  onChange(state, action);
394
333
  }
395
334
  }
396
335
  });
397
-
398
336
  if (onChange) {
399
337
  opts.serverSide = true;
400
338
  }
401
-
402
339
  const props = _objectSpread(_objectSpread({
403
340
  options: opts
404
341
  }, rest), {}, {
@@ -408,7 +345,6 @@ function ReDataTable(_ref) {
408
345
  TableFilterList: WrapFilterList
409
346
  })
410
347
  });
411
-
412
348
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(TableContainer, {
413
349
  verticalKeyWidth: verticalKeyWidth,
414
350
  className: (0, _clsx.default)({
@@ -422,7 +358,6 @@ function ReDataTable(_ref) {
422
358
  }, props))
423
359
  });
424
360
  }
425
-
426
361
  ReDataTable.propTypes = {
427
362
  data: _propTypes.default.array.isRequired,
428
363
  columns: _propTypes.default.array.isRequired,
@@ -457,11 +392,9 @@ ReDataTable.defaultProps = {
457
392
  durable: '',
458
393
  durableKeys: ['page', 'rowsPerPage', 'searchText', 'sortOrder']
459
394
  };
460
-
461
395
  const getDurableData = key => {
462
396
  const durableKey = "datatable-durable-".concat(key);
463
397
  let localData = localStorage[durableKey];
464
-
465
398
  if (localData) {
466
399
  try {
467
400
  localData = JSON.parse(localData);
@@ -469,10 +402,8 @@ const getDurableData = key => {
469
402
  console.error("parse durable data error (key:".concat(key, ") => "), err);
470
403
  }
471
404
  }
472
-
473
405
  return localData || {};
474
406
  };
475
-
476
407
  exports.getDurableData = getDurableData;
477
408
  const alignCss = (0, _react2.css)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n .MuiTableCell-head {\n [class*='MUIDataTableHeadCell-toolButton'] {\n width: 100%;\n > [class*='MUIDataTableHeadCell-sortAction'] {\n width: 100%;\n }\n }\n &.pc-align-center {\n text-align: center;\n [class*='MUIDataTableHeadCell-toolButton'] > [class*='MUIDataTableHeadCell-sortAction'] {\n justify-content: center;\n }\n }\n &.pc-align-right {\n text-align: right;\n [class*='MUIDataTableHeadCell-toolButton'] {\n margin-right: 0;\n padding-right: 0;\n & > [class*='MUIDataTableHeadCell-sortAction'] {\n justify-content: flex-end;\n }\n }\n }\n }\n .MuiTableCell-body {\n &.pc-align-center {\n text-align: center;\n }\n &.pc-align-right {\n text-align: right;\n }\n }\n"])));
478
409
  const TableContainer = (0, _Theme.styled)('div', {
@@ -481,17 +412,14 @@ const TableContainer = (0, _Theme.styled)('div', {
481
412
  if (inProps.verticalKeyWidth) {
482
413
  return "\n ".concat(inProps.theme.breakpoints.down('md'), " {\n [class*='MUIDataTable-responsiveBase'] {\n tr:not([class*='responsiveSimple']) {\n td.MuiTableCell-body {\n > div {\n &:first-of-type {\n width: ").concat(inProps.verticalKeyWidth + (!/\D/.test(inProps.verticalKeyWidth) ? 'px' : ''), ";\n }\n }\n }\n }\n }\n }\n ");
483
414
  }
484
-
485
415
  return '';
486
416
  }, props => props.theme.palette.action.hover);
487
417
  const FilterLine = (0, _Theme.styled)('div')(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n display: flex;\n align-items: center;\n .toolbar-filter-content {\n margin-bottom: 8px;\n }\n .toolbar-filter-title {\n font-weight: 700;\n font-size: 14px;\n }\n"])));
488
-
489
418
  function WrapFilterList(props) {
490
419
  const {
491
420
  filterLabel
492
421
  } = (0, _DatatableContext.useDatatableContext)();
493
422
  const hasFilter = !!props.filterList.filter(e => e.length).length;
494
-
495
423
  if (hasFilter) {
496
424
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(FilterLine, {
497
425
  children: [hasFilter && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
@@ -503,17 +431,14 @@ function WrapFilterList(props) {
503
431
  })]
504
432
  });
505
433
  }
506
-
507
434
  return '';
508
435
  }
509
-
510
436
  WrapFilterList.propTypes = {
511
437
  filterList: _propTypes.default.array
512
438
  };
513
439
  WrapFilterList.defaultProps = {
514
440
  filterList: []
515
441
  };
516
-
517
442
  function WrapTableFooter(props) {
518
443
  const {
519
444
  loading,
@@ -526,5 +451,4 @@ function WrapTableFooter(props) {
526
451
  })
527
452
  });
528
453
  }
529
-
530
454
  const FooterContainer = (0, _Theme.styled)('div')(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n display: flex;\n align-items: center;\n .datatable-footer {\n position: relative;\n margin-left: auto;\n &.datatable-footer-disabled {\n position: relative;\n .MuiTablePagination-root {\n opacity: 0.6;\n }\n &:after {\n position: absolute;\n display: block;\n z-index: 2;\n width: 100%;\n height: 100%;\n left: 0;\n top: 0;\n content: '';\n cursor: not-allowed;\n }\n }\n }\n\n ", " {\n .MuiTableCell-footer,\n .MuiToolbar-gutters {\n padding: 0;\n }\n\n div[variant='standard'] {\n margin-left: 4px;\n margin-right: 16px;\n }\n\n .MuiTablePagination-actions {\n margin-left: 10px;\n }\n }\n"])), props => props.theme.breakpoints.down('sm'));
@@ -5,11 +5,8 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
  exports.handleCSVDownload = handleCSVDownload;
8
-
9
8
  var _find = _interopRequireDefault(require("lodash/find"));
10
-
11
9
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
-
13
10
  function escapeDangerousCSVCharacters(data) {
14
11
  if (typeof data === 'string') {
15
12
  // Places single quote before the appearance of dangerous characters if they
@@ -17,36 +14,32 @@ function escapeDangerousCSVCharacters(data) {
17
14
  // eslint-disable-next-line no-useless-escape
18
15
  return data.replace(/^\+|^\-|^\=|^\@/g, "'$&");
19
16
  }
20
-
21
17
  return data;
22
18
  }
23
-
24
19
  function buildCSV(columns, data, options) {
25
- const replaceDoubleQuoteInString = columnData => typeof columnData === 'string' ? columnData.replace(/"/g, '""') : columnData; // eslint-disable-next-line no-shadow
26
-
20
+ const replaceDoubleQuoteInString = columnData => typeof columnData === 'string' ? columnData.replace(/"/g, '""') : columnData;
27
21
 
22
+ // eslint-disable-next-line no-shadow
28
23
  const buildHead = columns => {
29
24
  return "".concat(columns.reduce((soFar, column) => column.download ? "".concat(soFar, "\"").concat(escapeDangerousCSVCharacters(replaceDoubleQuoteInString(column.label || column.name)), "\"").concat(options.downloadOptions.separator) : soFar, '').slice(0, -1), "\r\n");
30
25
  };
26
+ const CSVHead = buildHead(columns);
31
27
 
32
- const CSVHead = buildHead(columns); // eslint-disable-next-line no-shadow
33
-
28
+ // eslint-disable-next-line no-shadow
34
29
  const buildBody = data => {
35
30
  if (!data.length) return '';
36
31
  return data.reduce((soFar, row) => "".concat(soFar, "\"").concat(row.data.filter((_, index) => columns[index].download).map(columnData => escapeDangerousCSVCharacters(replaceDoubleQuoteInString(columnData))).join("\"".concat(options.downloadOptions.separator, "\"")), "\"\r\n"), '').trim();
37
32
  };
38
-
39
33
  const CSVBody = buildBody(data);
40
34
  const csv = options.onDownload ? options.onDownload(buildHead, buildBody, columns, data) : "".concat(CSVHead).concat(CSVBody).trim();
41
35
  return csv;
42
36
  }
43
-
44
37
  function downloadCSV(csv, filename) {
45
38
  const blob = new Blob([csv], {
46
39
  type: 'text/csv'
47
40
  });
48
- /* taken from react-csv */
49
41
 
42
+ /* taken from react-csv */
50
43
  if (navigator && navigator.msSaveOrOpenBlob) {
51
44
  navigator.msSaveOrOpenBlob(blob, filename);
52
45
  } else {
@@ -60,19 +53,16 @@ function downloadCSV(csv, filename) {
60
53
  link.click();
61
54
  document.body.removeChild(link);
62
55
  }
63
- } // eslint-disable-next-line no-shadow
64
-
56
+ }
65
57
 
58
+ // eslint-disable-next-line no-shadow
66
59
  function createCSVDownload(columns, data, options, downloadCSV) {
67
60
  const csv = buildCSV(columns, data, options);
68
-
69
61
  if (options.onDownload && csv === false) {
70
62
  return;
71
63
  }
72
-
73
64
  downloadCSV(csv, options.downloadOptions.filename);
74
65
  }
75
-
76
66
  function handleCSVDownload(props) {
77
67
  const {
78
68
  data,
@@ -84,11 +74,9 @@ function handleCSVDownload(props) {
84
74
  let dataToDownload = [];
85
75
  let columnsToDownload = [];
86
76
  let columnOrderCopy = Array.isArray(columnOrder) ? columnOrder.slice(0) : [];
87
-
88
77
  if (columnOrderCopy.length === 0) {
89
78
  columnOrderCopy = columns.map((item, idx) => idx);
90
79
  }
91
-
92
80
  data.forEach(row => {
93
81
  const newRow = {
94
82
  index: row.index,
@@ -102,20 +90,21 @@ function handleCSVDownload(props) {
102
90
  columnOrderCopy.forEach(idx => {
103
91
  columnsToDownload.push(columns[idx]);
104
92
  });
105
-
106
93
  if (options.downloadOptions && options.downloadOptions.filterOptions) {
107
94
  // check rows first:
108
95
  if (options.downloadOptions.filterOptions.useDisplayedRowsOnly) {
109
96
  const filteredDataToDownload = displayData.map((row, index) => {
110
- let i = -1; // Help to preserve sort order in custom render columns
97
+ let i = -1;
111
98
 
99
+ // Help to preserve sort order in custom render columns
112
100
  row.index = index;
113
101
  return {
114
102
  data: row.data.map(column => {
115
- i += 1; // if we have a custom render, which will appear as a react element, we must grab the actual value from data
103
+ i += 1;
104
+
105
+ // if we have a custom render, which will appear as a react element, we must grab the actual value from data
116
106
  // that matches the dataIndex and column
117
107
  // TODO: Create a utility function for checking whether or not something is a react object
118
-
119
108
  let val = typeof column === 'object' && column !== null && !Array.isArray(column) ? (0, _find.default)(data, d => d.index === row.dataIndex).data[i] : column;
120
109
  val = typeof val === 'function' ? (0, _find.default)(data, d => d.index === row.dataIndex).data[i] : val;
121
110
  return val;
@@ -133,9 +122,9 @@ function handleCSVDownload(props) {
133
122
  });
134
123
  dataToDownload.push(newRow);
135
124
  });
136
- } // now, check columns:
137
-
125
+ }
138
126
 
127
+ // now, check columns:
139
128
  if (options.downloadOptions.filterOptions.useDisplayedColumnsOnly) {
140
129
  columnsToDownload = columnsToDownload.filter(_ => _.display === 'true');
141
130
  dataToDownload = dataToDownload.map(row => {
@@ -144,10 +133,8 @@ function handleCSVDownload(props) {
144
133
  });
145
134
  }
146
135
  }
147
-
148
136
  createCSVDownload(columnsToDownload, dataToDownload, options, downloadCSV);
149
137
  }
150
-
151
138
  var _default = {
152
139
  handleCSVDownload
153
140
  };