@canvas-components/react-list-table 0.2.3 → 0.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -3,6 +3,8 @@
3
3
  var react = require('react');
4
4
  var reactDom = require('react-dom');
5
5
  var reactComponents = require('@canvas-components/react-components');
6
+ var date = require('@canvas-components/utils/date');
7
+ var number = require('@canvas-components/utils/number');
6
8
  var jsxRuntime = require('react/jsx-runtime');
7
9
  var listTable = require('@canvas-components/list-table');
8
10
 
@@ -37,213 +39,366 @@ var CONTEXT_MENU_SURFACE_STYLE = {
37
39
  };
38
40
  function ReactTableContextMenuView(props) {
39
41
  const { request } = props;
42
+ const [menuOpen, setMenuOpen] = react.useState(true);
43
+ const [moreFormatRequest, setMoreFormatRequest] = react.useState(null);
44
+ const [customSelectionRequest, setCustomSelectionRequest] = react.useState(null);
40
45
  if (!request) {
41
- return null;
46
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
47
+ moreFormatRequest ? /* @__PURE__ */ jsxRuntime.jsx(
48
+ MoreFormatDialog,
49
+ {
50
+ request: moreFormatRequest,
51
+ onClose: () => setMoreFormatRequest(null)
52
+ }
53
+ ) : null,
54
+ customSelectionRequest ? /* @__PURE__ */ jsxRuntime.jsx(
55
+ CustomSelectionDialog,
56
+ {
57
+ request: customSelectionRequest,
58
+ onClose: () => {
59
+ setCustomSelectionRequest(null);
60
+ customSelectionRequest.onClose();
61
+ }
62
+ }
63
+ ) : null
64
+ ] });
42
65
  }
43
66
  const surfaceStyle = {
44
67
  ...CONTEXT_MENU_SURFACE_STYLE,
45
- width: 260,
46
- maxHeight: 420,
47
- overflow: "auto"
68
+ width: 260
48
69
  };
49
- return /* @__PURE__ */ jsxRuntime.jsx(
50
- reactComponents.ReactPopup,
51
- {
52
- open: true,
53
- anchorRect: { x: request.x, y: request.y, width: 0, height: 0 },
54
- minWidth: 260,
55
- onOpenChange: (open) => {
56
- if (!open) {
57
- request.onClose();
58
- }
59
- },
60
- surfaceStyle,
61
- children: /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
62
- /* @__PURE__ */ jsxRuntime.jsx(
63
- MenuSubmenu,
64
- {
65
- label: "\u590D\u5236",
66
- items: [
67
- {
68
- key: "copy-cell",
69
- label: "\u590D\u5236\u5355\u5143\u683C",
70
- onClick: request.onCopyCell
71
- },
72
- {
73
- key: "copy-column",
74
- label: "\u590D\u5236\u6574\u5217",
75
- onClick: request.onCopyColumn
76
- },
77
- {
78
- key: "copy-row-text",
79
- label: "\u590D\u5236\u5F53\u524D\u884C\u6587\u672C",
80
- onClick: request.onCopyRowText
81
- },
82
- {
83
- key: "copy-row-json",
84
- label: "\u590D\u5236\u5F53\u524D\u884C JSON",
85
- onClick: request.onCopyRowJson
86
- },
87
- {
88
- key: "copy-selection",
89
- label: "\u590D\u5236\u9009\u533A",
90
- onClick: request.onCopySelection
91
- }
92
- ]
93
- }
94
- ),
95
- /* @__PURE__ */ jsxRuntime.jsx(CustomSelectionMenu, { request }),
96
- /* @__PURE__ */ jsxRuntime.jsx(
97
- MenuSubmenu,
98
- {
99
- label: "\u5BFC\u51FA",
100
- items: [
101
- {
102
- key: "export-txt",
103
- label: "\u5BFC\u51FA TXT",
104
- onClick: request.onExportTxt
105
- },
106
- {
107
- key: "export-csv",
108
- label: "\u5BFC\u51FA CSV",
109
- onClick: request.onExportCsv
110
- },
111
- {
112
- key: "export-xlsx",
113
- label: "\u5BFC\u51FA XLSX",
114
- onClick: request.onExportXlsx
115
- },
116
- {
117
- key: "export-json",
118
- label: "\u5BFC\u51FA JSON",
119
- onClick: request.onExportJson
120
- }
121
- ]
122
- }
123
- ),
124
- /* @__PURE__ */ jsxRuntime.jsx(
125
- MenuAction,
126
- {
127
- label: request.downloadContentLabel ?? "",
128
- onClick: request.onDownloadContent
129
- }
130
- ),
131
- /* @__PURE__ */ jsxRuntime.jsx(
132
- MenuAction,
133
- {
134
- label: request.toggleExpandRowLabel ?? "",
135
- onClick: request.onToggleExpandRow
136
- }
137
- ),
138
- /* @__PURE__ */ jsxRuntime.jsx(
139
- MenuAction,
140
- {
141
- label: "\u53D6\u6D88\u5168\u90E8\u6298\u53E0\u884C",
142
- onClick: request.onExpandAllCollapsedRows
143
- }
144
- ),
145
- /* @__PURE__ */ jsxRuntime.jsx(
146
- MenuAction,
147
- {
148
- label: request.toggleColumnLabel ?? "",
149
- onClick: request.onToggleCurrentColumn
150
- }
151
- ),
152
- /* @__PURE__ */ jsxRuntime.jsx(
153
- MenuAction,
154
- {
155
- label: "\u53D6\u6D88\u5168\u90E8\u6298\u53E0\u5217",
156
- onClick: request.onExpandAllCollapsedColumns
157
- }
158
- ),
159
- /* @__PURE__ */ jsxRuntime.jsx(
160
- MenuAction,
161
- {
162
- label: request.summaryVisible ? "\u9690\u85CF\u6C47\u603B\u680F" : "\u663E\u793A\u6C47\u603B\u680F",
163
- onClick: request.onToggleSummary
164
- }
165
- ),
166
- /* @__PURE__ */ jsxRuntime.jsx(SummaryMenu, { request }),
167
- /* @__PURE__ */ jsxRuntime.jsx(AlignmentMenu, { request }),
168
- /* @__PURE__ */ jsxRuntime.jsx(DataFormatMenu, { request }),
169
- /* @__PURE__ */ jsxRuntime.jsx(
170
- MenuSubmenu,
171
- {
172
- label: "\u51BB\u7ED3",
173
- items: [
174
- {
175
- key: "freeze-top",
176
- label: "\u51BB\u7ED3\u5230\u9876\u90E8",
177
- onClick: request.onFreezeRowTop
178
- },
179
- {
180
- key: "freeze-bottom",
181
- label: "\u51BB\u7ED3\u5230\u5E95\u90E8",
182
- onClick: request.onFreezeRowBottom
183
- },
184
- {
185
- key: "unfreeze",
186
- label: "\u53D6\u6D88\u51BB\u7ED3",
187
- onClick: request.onUnfreezeRow
188
- }
189
- ]
70
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
71
+ /* @__PURE__ */ jsxRuntime.jsx(
72
+ reactComponents.ReactPopup,
73
+ {
74
+ open: menuOpen,
75
+ anchorRect: { x: request.x, y: request.y, width: 0, height: 0 },
76
+ minWidth: 260,
77
+ onOpenChange: (open) => {
78
+ setMenuOpen(open);
79
+ if (!open && !moreFormatRequest && !customSelectionRequest) {
80
+ request.onClose();
190
81
  }
191
- ),
192
- /* @__PURE__ */ jsxRuntime.jsx(
193
- MenuSubmenu,
194
- {
195
- label: "\u91CD\u7F6E",
196
- items: [
197
- {
198
- key: "reset-filter",
199
- label: "\u91CD\u7F6E\u7B5B\u9009",
200
- onClick: request.onResetFilter
201
- },
202
- {
203
- key: "reset-sort",
204
- label: "\u91CD\u7F6E\u6392\u5E8F",
205
- onClick: request.onResetSort
206
- },
207
- {
208
- key: "reset-header",
209
- label: "\u91CD\u7F6E\u8868\u5934\u914D\u7F6E",
210
- onClick: request.onResetHeader
82
+ },
83
+ surfaceStyle,
84
+ children: /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
85
+ /* @__PURE__ */ jsxRuntime.jsx(
86
+ MenuSubmenu,
87
+ {
88
+ label: "\u590D\u5236",
89
+ items: [
90
+ {
91
+ key: "copy-cell",
92
+ label: "\u590D\u5236\u5355\u5143\u683C",
93
+ onClick: request.onCopyCell
94
+ },
95
+ {
96
+ key: "copy-column",
97
+ label: "\u590D\u5236\u6574\u5217",
98
+ onClick: request.onCopyColumn
99
+ },
100
+ {
101
+ key: "copy-row-text",
102
+ label: "\u590D\u5236\u5F53\u524D\u884C\u6587\u672C",
103
+ onClick: request.onCopyRowText
104
+ },
105
+ {
106
+ key: "copy-row-json",
107
+ label: "\u590D\u5236\u5F53\u524D\u884C JSON",
108
+ onClick: request.onCopyRowJson
109
+ },
110
+ {
111
+ key: "copy-selection",
112
+ label: "\u590D\u5236\u9009\u533A",
113
+ onClick: request.onCopySelection
114
+ }
115
+ ],
116
+ children: /* @__PURE__ */ jsxRuntime.jsx(
117
+ CustomSelectionMenu,
118
+ {
119
+ request,
120
+ onOpen: () => {
121
+ setCustomSelectionRequest(request);
122
+ setMenuOpen(false);
123
+ }
124
+ }
125
+ )
126
+ }
127
+ ),
128
+ /* @__PURE__ */ jsxRuntime.jsx(MenuAction, { label: "\u67E5\u627E", onClick: request.onOpenSearch }),
129
+ /* @__PURE__ */ jsxRuntime.jsx(
130
+ MenuSubmenu,
131
+ {
132
+ label: "\u5BFC\u51FA",
133
+ items: [
134
+ {
135
+ key: "export-txt",
136
+ label: "\u5BFC\u51FA TXT",
137
+ onClick: request.onExportTxt
138
+ },
139
+ {
140
+ key: "export-csv",
141
+ label: "\u5BFC\u51FA CSV",
142
+ onClick: request.onExportCsv
143
+ },
144
+ {
145
+ key: "export-xlsx",
146
+ label: "\u5BFC\u51FA XLSX",
147
+ onClick: request.onExportXlsx
148
+ },
149
+ {
150
+ key: "export-json",
151
+ label: "\u5BFC\u51FA JSON",
152
+ onClick: request.onExportJson
153
+ }
154
+ ]
155
+ }
156
+ ),
157
+ /* @__PURE__ */ jsxRuntime.jsx(
158
+ MenuAction,
159
+ {
160
+ label: request.downloadContentLabel ?? "",
161
+ onClick: request.onDownloadContent
162
+ }
163
+ ),
164
+ /* @__PURE__ */ jsxRuntime.jsx(
165
+ MenuAction,
166
+ {
167
+ label: request.toggleExpandRowLabel ?? "",
168
+ onClick: request.onToggleExpandRow
169
+ }
170
+ ),
171
+ /* @__PURE__ */ jsxRuntime.jsx(
172
+ MenuAction,
173
+ {
174
+ label: "\u53D6\u6D88\u5168\u90E8\u6298\u53E0\u884C",
175
+ onClick: request.onExpandAllCollapsedRows
176
+ }
177
+ ),
178
+ /* @__PURE__ */ jsxRuntime.jsx(
179
+ MenuAction,
180
+ {
181
+ label: request.toggleColumnLabel ?? "",
182
+ onClick: request.onToggleCurrentColumn
183
+ }
184
+ ),
185
+ /* @__PURE__ */ jsxRuntime.jsx(
186
+ MenuSubmenu,
187
+ {
188
+ label: "\u81EA\u52A8\u8C03\u6574\u5217\u5BBD",
189
+ items: [
190
+ {
191
+ key: "auto-fit-current",
192
+ label: "\u5F53\u524D\u5217",
193
+ onClick: request.onAutoFitCurrentColumn
194
+ },
195
+ {
196
+ key: "auto-fit-all",
197
+ label: "\u5168\u90E8\u5217",
198
+ onClick: request.onAutoFitAllColumns
199
+ }
200
+ ]
201
+ }
202
+ ),
203
+ /* @__PURE__ */ jsxRuntime.jsx(
204
+ MenuAction,
205
+ {
206
+ label: request.groupingBarVisible ? "\u9690\u85CF\u5206\u7EC4\u680F" : "\u663E\u793A\u5206\u7EC4\u680F",
207
+ onClick: request.onToggleGroupingBar
208
+ }
209
+ ),
210
+ /* @__PURE__ */ jsxRuntime.jsx(
211
+ MenuAction,
212
+ {
213
+ label: "\u53D6\u6D88\u5168\u90E8\u6298\u53E0\u5217",
214
+ onClick: request.onExpandAllCollapsedColumns
215
+ }
216
+ ),
217
+ /* @__PURE__ */ jsxRuntime.jsx(
218
+ MenuAction,
219
+ {
220
+ label: request.summaryVisible ? "\u9690\u85CF\u6C47\u603B\u680F" : "\u663E\u793A\u6C47\u603B\u680F",
221
+ onClick: request.onToggleSummary
222
+ }
223
+ ),
224
+ /* @__PURE__ */ jsxRuntime.jsx(SummaryMenu, { request }),
225
+ /* @__PURE__ */ jsxRuntime.jsx(AlignmentMenu, { request }),
226
+ /* @__PURE__ */ jsxRuntime.jsx(
227
+ DataFormatMenu,
228
+ {
229
+ request,
230
+ onOpenMoreFormat: () => {
231
+ setMoreFormatRequest(request);
232
+ setMenuOpen(false);
211
233
  }
212
- ]
213
- }
214
- ),
215
- /* @__PURE__ */ jsxRuntime.jsx(
216
- DensityMenu,
217
- {
218
- value: request.density ?? "middle",
219
- onChange: request.onChangeDensity
220
- }
221
- ),
222
- /* @__PURE__ */ jsxRuntime.jsx(ZoomMenu, { value: request.zoom ?? 1, onChange: request.onChangeZoom }),
223
- request.columns?.length && request.onToggleColumn ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
224
- /* @__PURE__ */ jsxRuntime.jsx(MenuDivider, {}),
234
+ }
235
+ ),
225
236
  /* @__PURE__ */ jsxRuntime.jsx(
226
- ColumnVisibilityMenu,
237
+ MenuSubmenu,
227
238
  {
228
- columns: request.columns,
229
- onToggle: request.onToggleColumn
239
+ label: "\u51BB\u7ED3",
240
+ items: [
241
+ {
242
+ key: "freeze-top",
243
+ label: "\u51BB\u7ED3\u5230\u9876\u90E8",
244
+ onClick: request.onFreezeRowTop
245
+ },
246
+ {
247
+ key: "freeze-bottom",
248
+ label: "\u51BB\u7ED3\u5230\u5E95\u90E8",
249
+ onClick: request.onFreezeRowBottom
250
+ },
251
+ {
252
+ key: "unfreeze",
253
+ label: "\u53D6\u6D88\u51BB\u7ED3",
254
+ onClick: request.onUnfreezeRow
255
+ }
256
+ ]
230
257
  }
231
- )
232
- ] }) : null
233
- ] })
234
- }
235
- );
258
+ ),
259
+ /* @__PURE__ */ jsxRuntime.jsx(
260
+ MenuSubmenu,
261
+ {
262
+ label: "\u6392\u5E8F",
263
+ items: [
264
+ {
265
+ key: "sort-ascend",
266
+ label: "\u5347\u5E8F",
267
+ onClick: request.onSortAscend
268
+ },
269
+ {
270
+ key: "sort-descend",
271
+ label: "\u964D\u5E8F",
272
+ onClick: request.onSortDescend
273
+ },
274
+ {
275
+ key: "sort-clear",
276
+ label: "\u53D6\u6D88\u6392\u5E8F",
277
+ onClick: request.onClearSort
278
+ }
279
+ ]
280
+ }
281
+ ),
282
+ /* @__PURE__ */ jsxRuntime.jsx(
283
+ MenuSubmenu,
284
+ {
285
+ label: "\u56FA\u5B9A",
286
+ items: [
287
+ {
288
+ key: "fix-left",
289
+ label: "\u5DE6\u4FA7",
290
+ onClick: request.onFixLeft
291
+ },
292
+ {
293
+ key: "fix-right",
294
+ label: "\u53F3\u4FA7",
295
+ onClick: request.onFixRight
296
+ },
297
+ {
298
+ key: "unfix",
299
+ label: "\u53D6\u6D88\u56FA\u5B9A",
300
+ onClick: request.onUnfix
301
+ }
302
+ ]
303
+ }
304
+ ),
305
+ /* @__PURE__ */ jsxRuntime.jsx(
306
+ MenuSubmenu,
307
+ {
308
+ label: "\u91CD\u7F6E",
309
+ items: [
310
+ {
311
+ key: "reset-filter",
312
+ label: "\u91CD\u7F6E\u7B5B\u9009",
313
+ onClick: request.onResetFilter
314
+ },
315
+ {
316
+ key: "reset-sort",
317
+ label: "\u91CD\u7F6E\u6392\u5E8F",
318
+ onClick: request.onResetSort
319
+ },
320
+ {
321
+ key: "reset-header",
322
+ label: "\u91CD\u7F6E\u8868\u5934\u914D\u7F6E",
323
+ onClick: request.onResetHeader
324
+ },
325
+ {
326
+ key: "reset-grouping",
327
+ label: "\u91CD\u7F6E\u5206\u7EC4",
328
+ onClick: request.onResetGrouping
329
+ },
330
+ {
331
+ key: "reset-summary",
332
+ label: "\u91CD\u7F6E\u6C47\u603B",
333
+ onClick: request.onResetSummary
334
+ },
335
+ {
336
+ key: "reset-alignment",
337
+ label: "\u91CD\u7F6E\u5BF9\u9F50",
338
+ onClick: request.onResetAlignment
339
+ },
340
+ {
341
+ key: "reset-data-format",
342
+ label: "\u91CD\u7F6E\u683C\u5F0F",
343
+ onClick: request.onResetDataFormat
344
+ }
345
+ ]
346
+ }
347
+ ),
348
+ /* @__PURE__ */ jsxRuntime.jsx(
349
+ DensityMenu,
350
+ {
351
+ value: request.density ?? "middle",
352
+ onChange: request.onChangeDensity
353
+ }
354
+ ),
355
+ /* @__PURE__ */ jsxRuntime.jsx(ZoomMenu, { value: request.zoom ?? 1, onChange: request.onChangeZoom }),
356
+ request.columns?.length && request.onToggleColumn ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
357
+ /* @__PURE__ */ jsxRuntime.jsx(MenuDivider, {}),
358
+ /* @__PURE__ */ jsxRuntime.jsx(
359
+ ColumnVisibilityMenu,
360
+ {
361
+ columns: request.columns,
362
+ onToggle: request.onToggleColumn
363
+ }
364
+ )
365
+ ] }) : null
366
+ ] })
367
+ }
368
+ ),
369
+ moreFormatRequest ? /* @__PURE__ */ jsxRuntime.jsx(
370
+ MoreFormatDialog,
371
+ {
372
+ request: moreFormatRequest,
373
+ onClose: () => {
374
+ setMoreFormatRequest(null);
375
+ request.onClose();
376
+ }
377
+ }
378
+ ) : null,
379
+ customSelectionRequest ? /* @__PURE__ */ jsxRuntime.jsx(
380
+ CustomSelectionDialog,
381
+ {
382
+ request: customSelectionRequest,
383
+ onClose: () => {
384
+ setCustomSelectionRequest(null);
385
+ customSelectionRequest.onClose();
386
+ }
387
+ }
388
+ ) : null
389
+ ] });
236
390
  }
237
391
  function MenuAction(props) {
238
- const { label, onClick, selected, reserveSelectionIcon } = props;
239
- if (!onClick) {
392
+ const { label, preview, onClick, selected, disabled, reserveSelectionIcon } = props;
393
+ if (!onClick && !disabled) {
240
394
  return null;
241
395
  }
242
396
  return /* @__PURE__ */ jsxRuntime.jsxs(
243
397
  "button",
244
398
  {
245
399
  type: "button",
246
- onClick,
400
+ onClick: disabled ? void 0 : onClick,
401
+ disabled,
247
402
  className: "react-list-table-menu-action",
248
403
  style: {
249
404
  display: "flex",
@@ -254,9 +409,9 @@ function MenuAction(props) {
254
409
  border: "none",
255
410
  borderRadius: 8,
256
411
  background: "transparent",
257
- color: "#374151",
412
+ color: disabled ? "#9ca3af" : "#374151",
258
413
  textAlign: "left",
259
- cursor: "pointer"
414
+ cursor: disabled ? "default" : "pointer"
260
415
  },
261
416
  children: [
262
417
  reserveSelectionIcon ? /* @__PURE__ */ jsxRuntime.jsx(
@@ -272,21 +427,28 @@ function MenuAction(props) {
272
427
  children: selected ? "\u2713" : ""
273
428
  }
274
429
  ) : null,
275
- /* @__PURE__ */ jsxRuntime.jsx("span", { children: label })
430
+ /* @__PURE__ */ jsxRuntime.jsx("span", { style: { flex: 1, whiteSpace: "nowrap" }, children: label }),
431
+ preview ? /* @__PURE__ */ jsxRuntime.jsx(
432
+ "span",
433
+ {
434
+ style: { marginLeft: 16, color: "#9ca3af", whiteSpace: "nowrap" },
435
+ children: preview
436
+ }
437
+ ) : null
276
438
  ]
277
439
  }
278
440
  );
279
441
  }
280
442
  function MenuSubmenu(props) {
281
- const { label, items, footer } = props;
282
- const menuItems = items.filter((item) => item.onClick);
443
+ const { label, items, footer, children, minWidth = 220 } = props;
444
+ const menuItems = items.filter((item) => item.onClick || item.disabled);
283
445
  const reserveSelectionIcon = menuItems.some(
284
446
  (item) => typeof item.selected === "boolean"
285
447
  );
286
448
  const triggerRef = react.useRef(null);
287
449
  const [open, setOpen] = react.useState(false);
288
450
  const closeTimerRef = react.useRef(null);
289
- if (!menuItems.length && !footer) {
451
+ if (!menuItems.length && !footer && !children) {
290
452
  return null;
291
453
  }
292
454
  const clearCloseTimer = () => {
@@ -352,12 +514,11 @@ function MenuSubmenu(props) {
352
514
  anchorRef: triggerRef,
353
515
  placement: "rightTop",
354
516
  offset: 2,
355
- minWidth: 220,
517
+ minWidth,
356
518
  onOpenChange: setOpen,
357
519
  surfaceStyle: {
358
520
  ...CONTEXT_MENU_SURFACE_STYLE,
359
- maxHeight: 360,
360
- overflow: "auto"
521
+ width: minWidth
361
522
  },
362
523
  children: /* @__PURE__ */ jsxRuntime.jsxs(
363
524
  "div",
@@ -369,16 +530,21 @@ function MenuSubmenu(props) {
369
530
  scheduleClose();
370
531
  },
371
532
  children: [
372
- menuItems.map((item) => /* @__PURE__ */ jsxRuntime.jsx(
373
- MenuAction,
374
- {
375
- label: item.label,
376
- onClick: item.onClick,
377
- selected: item.selected,
378
- reserveSelectionIcon
379
- },
380
- item.key
381
- )),
533
+ menuItems.map((item) => /* @__PURE__ */ jsxRuntime.jsxs(react.Fragment, { children: [
534
+ item.separatorBefore ? /* @__PURE__ */ jsxRuntime.jsx(MenuDivider, {}) : null,
535
+ /* @__PURE__ */ jsxRuntime.jsx(
536
+ MenuAction,
537
+ {
538
+ label: item.label,
539
+ preview: item.preview,
540
+ onClick: item.onClick,
541
+ selected: item.selected,
542
+ disabled: item.disabled,
543
+ reserveSelectionIcon
544
+ }
545
+ )
546
+ ] }, item.key)),
547
+ children,
382
548
  footer
383
549
  ]
384
550
  }
@@ -835,8 +1001,19 @@ function MenuDivider() {
835
1001
  }
836
1002
  function CustomSelectionMenu(props) {
837
1003
  const { request } = props;
838
- const triggerRef = react.useRef(null);
839
- const [open, setOpen] = react.useState(false);
1004
+ if (!request.onCopyCustomSelection || !request.customSelection) {
1005
+ return null;
1006
+ }
1007
+ return /* @__PURE__ */ jsxRuntime.jsx(
1008
+ MenuAction,
1009
+ {
1010
+ label: "\u590D\u5236\u81EA\u5B9A\u4E49\u9009\u533A",
1011
+ onClick: props.onOpen
1012
+ }
1013
+ );
1014
+ }
1015
+ function CustomSelectionDialog(props) {
1016
+ const { request } = props;
840
1017
  const initial = request.customSelection ?? {
841
1018
  startRow: 1,
842
1019
  startColumn: 1,
@@ -846,122 +1023,86 @@ function CustomSelectionMenu(props) {
846
1023
  columnCount: 0
847
1024
  };
848
1025
  const [range, setRange] = react.useState(initial);
849
- if (!request.onCopyCustomSelection || !request.customSelection) {
850
- return null;
851
- }
852
- const update = (key, value) => {
853
- setRange((current) => ({
854
- ...current,
855
- [key]: value == null ? 1 : Math.floor(value)
856
- }));
857
- };
858
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
859
- /* @__PURE__ */ jsxRuntime.jsx(
860
- "button",
861
- {
862
- ref: triggerRef,
863
- type: "button",
864
- className: "react-list-table-menu-action",
865
- style: {
866
- display: "flex",
867
- alignItems: "center",
868
- width: "100%",
869
- height: 32,
870
- padding: "0 10px",
871
- border: "none",
872
- borderRadius: 8,
873
- background: "transparent",
874
- color: "#374151",
875
- textAlign: "left",
876
- cursor: "pointer"
877
- },
878
- onClick: () => setOpen((value) => !value),
879
- children: /* @__PURE__ */ jsxRuntime.jsx("span", { children: "\u590D\u5236\u81EA\u5B9A\u4E49\u9009\u533A" })
880
- }
881
- ),
882
- /* @__PURE__ */ jsxRuntime.jsx(
883
- reactComponents.ReactPopup,
884
- {
885
- open,
886
- anchorRef: triggerRef,
887
- placement: "rightTop",
888
- offset: 2,
889
- minWidth: 250,
890
- onOpenChange: setOpen,
891
- surfaceStyle: { ...CONTEXT_MENU_SURFACE_STYLE, width: 250 },
892
- children: /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { padding: 6 }, children: [
893
- /* @__PURE__ */ jsxRuntime.jsx("div", { style: { color: "#6b7280", fontSize: 12, marginBottom: 6 }, children: "\u8F93\u5165\u8D77\u59CB\u4F4D\u7F6E\u548C\u7ED3\u675F\u4F4D\u7F6E" }),
894
- /* @__PURE__ */ jsxRuntime.jsxs(
895
- "div",
896
- {
897
- style: {
898
- display: "grid",
899
- gridTemplateColumns: "38px 1fr 1fr",
900
- gap: 6,
901
- marginBottom: 4,
902
- color: "#6b7280",
903
- fontSize: 12,
904
- textAlign: "center"
905
- },
906
- children: [
907
- /* @__PURE__ */ jsxRuntime.jsx("span", {}),
908
- /* @__PURE__ */ jsxRuntime.jsx("span", { children: "\u884C" }),
909
- /* @__PURE__ */ jsxRuntime.jsx("span", { children: "\u5217" })
910
- ]
911
- }
912
- ),
913
- /* @__PURE__ */ jsxRuntime.jsx(
914
- CustomSelectionRow,
915
- {
916
- label: "\u8D77\u59CB",
917
- row: range.startRow,
918
- column: range.startColumn,
919
- onRowChange: (value) => update("startRow", value),
920
- onColumnChange: (value) => update("startColumn", value)
921
- }
922
- ),
923
- /* @__PURE__ */ jsxRuntime.jsx(
924
- CustomSelectionRow,
925
- {
926
- label: "\u7ED3\u675F",
927
- row: range.endRow,
928
- column: range.endColumn,
929
- onRowChange: (value) => update("endRow", value),
930
- onColumnChange: (value) => update("endColumn", value)
931
- }
932
- ),
933
- /* @__PURE__ */ jsxRuntime.jsx(
934
- "button",
935
- {
936
- type: "button",
937
- className: "react-list-table-custom-selection-copy",
938
- style: {
939
- display: "block",
940
- width: "100%",
941
- height: 32,
942
- marginTop: 6,
943
- border: "none",
944
- borderRadius: 8,
945
- background: "#1677ff",
946
- color: "#fff",
947
- cursor: "pointer"
948
- },
949
- onClick: () => {
950
- request.onCopyCustomSelection?.({
951
- startRow: Math.max(range.startRow, 1),
952
- startColumn: Math.max(range.startColumn, 1),
953
- endRow: Math.max(range.endRow, 1),
954
- endColumn: Math.max(range.endColumn, 1)
955
- });
956
- setOpen(false);
957
- },
958
- children: "\u590D\u5236"
959
- }
960
- )
961
- ] })
962
- }
963
- )
964
- ] });
1026
+ react.useEffect(() => {
1027
+ setRange(initial);
1028
+ }, [
1029
+ initial.startRow,
1030
+ initial.startColumn,
1031
+ initial.endRow,
1032
+ initial.endColumn
1033
+ ]);
1034
+ if (!request.onCopyCustomSelection || !request.customSelection) {
1035
+ return null;
1036
+ }
1037
+ const update = (key, value) => {
1038
+ setRange((current) => ({
1039
+ ...current,
1040
+ [key]: value == null ? 1 : Math.floor(value)
1041
+ }));
1042
+ };
1043
+ return /* @__PURE__ */ jsxRuntime.jsxs(
1044
+ reactComponents.ReactModal,
1045
+ {
1046
+ open: true,
1047
+ title: "\u590D\u5236\u81EA\u5B9A\u4E49\u9009\u533A",
1048
+ width: 360,
1049
+ centered: true,
1050
+ fullscreenable: false,
1051
+ onCancel: props.onClose,
1052
+ onOk: () => {
1053
+ request.onCopyCustomSelection?.({
1054
+ startRow: Math.max(range.startRow, 1),
1055
+ startColumn: Math.max(range.startColumn, 1),
1056
+ endRow: Math.max(range.endRow, 1),
1057
+ endColumn: Math.max(range.endColumn, 1)
1058
+ });
1059
+ props.onClose();
1060
+ },
1061
+ bodyStyle: { padding: "4px 20px 18px" },
1062
+ children: [
1063
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: { color: "#6b7280", fontSize: 12, marginBottom: 10 }, children: "\u8F93\u5165\u8D77\u59CB\u4F4D\u7F6E\u548C\u7ED3\u675F\u4F4D\u7F6E" }),
1064
+ /* @__PURE__ */ jsxRuntime.jsxs(
1065
+ "div",
1066
+ {
1067
+ style: {
1068
+ display: "grid",
1069
+ gridTemplateColumns: "38px 1fr 1fr",
1070
+ gap: 8,
1071
+ marginBottom: 6,
1072
+ color: "#6b7280",
1073
+ fontSize: 12,
1074
+ textAlign: "center"
1075
+ },
1076
+ children: [
1077
+ /* @__PURE__ */ jsxRuntime.jsx("span", {}),
1078
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: "\u884C" }),
1079
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: "\u5217" })
1080
+ ]
1081
+ }
1082
+ ),
1083
+ /* @__PURE__ */ jsxRuntime.jsx(
1084
+ CustomSelectionRow,
1085
+ {
1086
+ label: "\u8D77\u59CB",
1087
+ row: range.startRow,
1088
+ column: range.startColumn,
1089
+ onRowChange: (value) => update("startRow", value),
1090
+ onColumnChange: (value) => update("startColumn", value)
1091
+ }
1092
+ ),
1093
+ /* @__PURE__ */ jsxRuntime.jsx(
1094
+ CustomSelectionRow,
1095
+ {
1096
+ label: "\u7ED3\u675F",
1097
+ row: range.endRow,
1098
+ column: range.endColumn,
1099
+ onRowChange: (value) => update("endRow", value),
1100
+ onColumnChange: (value) => update("endColumn", value)
1101
+ }
1102
+ )
1103
+ ]
1104
+ }
1105
+ );
965
1106
  }
966
1107
  function CustomSelectionRow(props) {
967
1108
  return /* @__PURE__ */ jsxRuntime.jsxs(
@@ -1009,9 +1150,22 @@ function SummaryMenu(props) {
1009
1150
  const [precision, setPrecision] = react.useState(
1010
1151
  request.summaryPrecision ?? null
1011
1152
  );
1153
+ const [roundingMode, setRoundingMode] = react.useState(
1154
+ request.summaryRoundingMode ?? "round"
1155
+ );
1156
+ const [preserveTrailingZeros, setPreserveTrailingZeros] = react.useState(
1157
+ request.summaryPreserveTrailingZeros ?? false
1158
+ );
1012
1159
  react.useEffect(() => {
1013
1160
  setPrecision(request.summaryPrecision ?? null);
1014
- }, [request.summaryColumnKey, request.summaryPrecision]);
1161
+ setRoundingMode(request.summaryRoundingMode ?? "round");
1162
+ setPreserveTrailingZeros(request.summaryPreserveTrailingZeros ?? false);
1163
+ }, [
1164
+ request.summaryColumnKey,
1165
+ request.summaryPrecision,
1166
+ request.summaryRoundingMode,
1167
+ request.summaryPreserveTrailingZeros
1168
+ ]);
1015
1169
  if (!request.summaryColumnKey) {
1016
1170
  return null;
1017
1171
  }
@@ -1029,13 +1183,14 @@ function SummaryMenu(props) {
1029
1183
  MenuSubmenu,
1030
1184
  {
1031
1185
  label: "\u6C47\u603B\u65B9\u5F0F",
1186
+ minWidth: 268,
1032
1187
  items: summaryTypes.map((item) => ({
1033
1188
  key: item.key,
1034
1189
  label: item.label,
1035
1190
  selected: request.summaryType === item.value,
1036
1191
  onClick: () => request.onChangeSummaryType?.(item.value)
1037
1192
  })),
1038
- footer: request.onChangeSummaryPrecision ? /* @__PURE__ */ jsxRuntime.jsxs(
1193
+ footer: request.onChangeSummaryPrecision || request.onChangeSummaryRoundingMode || request.onChangeSummaryPreserveTrailingZeros ? /* @__PURE__ */ jsxRuntime.jsxs(
1039
1194
  "div",
1040
1195
  {
1041
1196
  style: {
@@ -1048,22 +1203,62 @@ function SummaryMenu(props) {
1048
1203
  borderTop: "1px solid #e5e7eb"
1049
1204
  },
1050
1205
  children: [
1051
- /* @__PURE__ */ jsxRuntime.jsx("span", { style: { color: "#374151", fontSize: 13 }, children: "\u5C0F\u6570\u4F4D\u6570" }),
1052
- /* @__PURE__ */ jsxRuntime.jsx(
1053
- reactComponents.ReactInputNumber,
1054
- {
1055
- value: precision,
1056
- min: 0,
1057
- max: 20,
1058
- step: 1,
1059
- precision: 0,
1060
- placeholder: "\u9ED8\u8BA4",
1061
- onChange: setPrecision,
1062
- onCommit: (value) => {
1063
- request.onChangeSummaryPrecision?.(value ?? void 0);
1206
+ request.onChangeSummaryPrecision ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1207
+ /* @__PURE__ */ jsxRuntime.jsx("span", { style: { color: "#374151", fontSize: 13 }, children: "\u5C0F\u6570\u4F4D\u6570" }),
1208
+ /* @__PURE__ */ jsxRuntime.jsx(
1209
+ reactComponents.ReactInputNumber,
1210
+ {
1211
+ value: precision,
1212
+ min: 0,
1213
+ max: 20,
1214
+ step: 1,
1215
+ precision: 0,
1216
+ placeholder: "\u9ED8\u8BA4",
1217
+ onChange: setPrecision,
1218
+ onCommit: (value) => {
1219
+ request.onChangeSummaryPrecision?.(value ?? void 0);
1220
+ }
1064
1221
  }
1065
- }
1066
- )
1222
+ )
1223
+ ] }) : null,
1224
+ request.onChangeSummaryRoundingMode ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1225
+ /* @__PURE__ */ jsxRuntime.jsx("span", { style: { color: "#374151", fontSize: 13 }, children: "\u53D6\u6574\u65B9\u5F0F" }),
1226
+ /* @__PURE__ */ jsxRuntime.jsx(
1227
+ reactComponents.ReactSelect,
1228
+ {
1229
+ value: roundingMode,
1230
+ options: [
1231
+ { label: "\u56DB\u820D\u4E94\u5165", value: "round" },
1232
+ { label: "\u5411\u4E0B\u53D6\u6574", value: "floor" },
1233
+ { label: "\u5411\u4E0A\u53D6\u6574", value: "ceil" },
1234
+ { label: "\u820D\u53BB\u4E0D\u5904\u7406", value: "truncate" }
1235
+ ],
1236
+ onChange: (value) => {
1237
+ const mode = value;
1238
+ setRoundingMode(mode);
1239
+ request.onChangeSummaryRoundingMode?.(mode);
1240
+ }
1241
+ }
1242
+ )
1243
+ ] }) : null,
1244
+ request.onChangeSummaryPreserveTrailingZeros ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1245
+ /* @__PURE__ */ jsxRuntime.jsx("span", { style: { color: "#374151", fontSize: 13 }, children: "\u4FDD\u7559\u65E0\u6548\u96F6" }),
1246
+ /* @__PURE__ */ jsxRuntime.jsx(
1247
+ reactComponents.ReactSelect,
1248
+ {
1249
+ value: preserveTrailingZeros ? "true" : "false",
1250
+ options: [
1251
+ { label: "\u4E0D\u4FDD\u7559", value: "false" },
1252
+ { label: "\u4FDD\u7559", value: "true" }
1253
+ ],
1254
+ onChange: (selectedValue) => {
1255
+ const value = selectedValue === "true";
1256
+ setPreserveTrailingZeros(value);
1257
+ request.onChangeSummaryPreserveTrailingZeros?.(value);
1258
+ }
1259
+ }
1260
+ )
1261
+ ] }) : null
1067
1262
  ]
1068
1263
  }
1069
1264
  ) : void 0
@@ -1175,24 +1370,800 @@ function DataFormatMenu(props) {
1175
1370
  if (!request.onChangeDataFormat) {
1176
1371
  return null;
1177
1372
  }
1178
- return /* @__PURE__ */ jsxRuntime.jsx(
1373
+ return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsx(
1179
1374
  MenuSubmenu,
1180
1375
  {
1181
- label: "\u6570\u636E\u683C\u5F0F",
1376
+ label: "\u683C\u5F0F",
1377
+ minWidth: 340,
1182
1378
  items: [
1183
- { key: "default", label: "\u9ED8\u8BA4", value: "default" },
1184
- { key: "number", label: "\u666E\u901A\u6570\u5B57", value: "number" },
1185
- { key: "thousands", label: "\u5343\u4F4D\u5206\u9694", value: "thousands" },
1186
- { key: "money", label: "\u91D1\u989D\uFF08\u4E24\u4F4D\u5C0F\u6570\uFF09", value: "money" }
1379
+ { key: "default", label: "\u5E38\u89C4", value: "default" },
1380
+ { key: "text", label: "\u7EAF\u6587\u672C", value: "text" },
1381
+ {
1382
+ key: "number",
1383
+ label: "\u6570\u5B57",
1384
+ preview: "1024",
1385
+ value: "number",
1386
+ separatorBefore: true
1387
+ },
1388
+ {
1389
+ key: "thousands",
1390
+ label: "\u6570\u5B57\uFF08\u5343\u5206\u4F4D\uFF09",
1391
+ preview: "1,024",
1392
+ value: "thousands"
1393
+ },
1394
+ {
1395
+ key: "decimal",
1396
+ label: "\u6570\u5B57\uFF08\u5343\u5206\u4F4D\uFF0C\u5C0F\u6570\u70B9\uFF09",
1397
+ preview: "1,024.56",
1398
+ value: "decimal"
1399
+ },
1400
+ {
1401
+ key: "percent",
1402
+ label: "\u767E\u5206\u6BD4",
1403
+ preview: "10%",
1404
+ value: "percent",
1405
+ separatorBefore: true
1406
+ },
1407
+ {
1408
+ key: "percentDecimal",
1409
+ label: "\u767E\u5206\u6BD4\uFF08\u5C0F\u6570\u70B9\uFF09",
1410
+ preview: "10.24%",
1411
+ value: "percentDecimal"
1412
+ },
1413
+ {
1414
+ key: "scientific",
1415
+ label: "\u79D1\u5B66\u8BB0\u6570",
1416
+ preview: "1.02E+003",
1417
+ value: "scientific"
1418
+ },
1419
+ {
1420
+ key: "numberToChineseUpper",
1421
+ label: "\u6570\u5B57\u8F6C\u5927\u5199",
1422
+ preview: "\u7396\u62FE\u58F9\u4E07\u634C\u4EDF",
1423
+ value: "numberToChineseUpper"
1424
+ },
1425
+ {
1426
+ key: "chineseUpperToNumber",
1427
+ label: "\u5927\u5199\u8F6C\u6570\u5B57",
1428
+ preview: "918000",
1429
+ value: "chineseUpperToNumber"
1430
+ },
1431
+ {
1432
+ key: "cny",
1433
+ label: "\u4EBA\u6C11\u5E01",
1434
+ preview: "\xA51,024",
1435
+ value: "cny",
1436
+ separatorBefore: true
1437
+ },
1438
+ {
1439
+ key: "cnyDecimal",
1440
+ label: "\u4EBA\u6C11\u5E01\uFF08\u5C0F\u6570\u70B9\uFF09",
1441
+ preview: "\xA51,024.56",
1442
+ value: "cnyDecimal"
1443
+ },
1444
+ {
1445
+ key: "usd",
1446
+ label: "\u7F8E\u5143",
1447
+ preview: "$1,024",
1448
+ value: "usd"
1449
+ },
1450
+ {
1451
+ key: "usdDecimal",
1452
+ label: "\u7F8E\u5143\uFF08\u5C0F\u6570\u70B9\uFF09",
1453
+ preview: "$1,024.56",
1454
+ value: "usdDecimal"
1455
+ },
1456
+ {
1457
+ key: "dateSlash",
1458
+ label: "\u65E5\u671F\uFF08\u659C\u6760\uFF09",
1459
+ preview: "2017/08/01",
1460
+ value: "dateSlash",
1461
+ separatorBefore: true
1462
+ },
1463
+ {
1464
+ key: "dateDash",
1465
+ label: "\u65E5\u671F\uFF08\u77ED\u6A2A\u7EBF\uFF09",
1466
+ preview: "2017-08-01",
1467
+ value: "dateDash"
1468
+ },
1469
+ {
1470
+ key: "dateFullCN",
1471
+ label: "\u65E5\u671F\uFF08\u4E2D\u6587\uFF09",
1472
+ preview: "2017\u5E748\u67081\u65E5",
1473
+ value: "dateFullCN"
1474
+ },
1475
+ { key: "time", label: "\u65F6\u95F4", preview: "23:24:25", value: "time" },
1476
+ {
1477
+ key: "timeShort",
1478
+ label: "\u65F6\u95F4\uFF08\u5206\uFF09",
1479
+ preview: "23:24",
1480
+ value: "timeShort"
1481
+ },
1482
+ {
1483
+ key: "datetime",
1484
+ label: "\u65E5\u671F\u65F6\u95F4",
1485
+ preview: "2017/08/01 23:24:25",
1486
+ value: "datetime"
1487
+ },
1488
+ {
1489
+ key: "datetime12",
1490
+ label: "\u65E5\u671F\u65F6\u95F4\uFF08\u4E0A\u4E0B\uFF09",
1491
+ preview: "2017/08/01 \u4E0B\u534811:24",
1492
+ value: "datetime12"
1493
+ },
1494
+ {
1495
+ key: "more",
1496
+ label: "\u66F4\u591A\u683C\u5F0F",
1497
+ separatorBefore: true,
1498
+ onClick: props.onOpenMoreFormat
1499
+ }
1187
1500
  ].map((item) => ({
1188
1501
  key: `data-format-${item.key}`,
1189
1502
  label: item.label,
1190
- selected: request.dataFormat === item.value,
1191
- onClick: () => request.onChangeDataFormat?.(item.value)
1503
+ preview: "preview" in item ? item.preview : void 0,
1504
+ separatorBefore: "separatorBefore" in item ? item.separatorBefore : void 0,
1505
+ disabled: "disabled" in item && item.disabled === true,
1506
+ selected: "value" in item && request.dataFormat === item.value,
1507
+ onClick: "onClick" in item ? item.onClick : "value" in item ? () => request.onChangeDataFormat?.(item.value) : void 0
1192
1508
  }))
1193
1509
  }
1510
+ ) });
1511
+ }
1512
+ function MoreFormatDialog(props) {
1513
+ const { request } = props;
1514
+ const [category, setCategory] = react.useState(
1515
+ () => resolveMoreFormatCategory(request.dataFormat)
1516
+ );
1517
+ const [customPattern, setCustomPattern] = react.useState(
1518
+ () => typeof request.dataFormat === "object" && request.dataFormat.type === "custom" ? request.dataFormat.pattern ?? "#,##0.00" : "#,##0.00"
1519
+ );
1520
+ const [decimalPlaces, setDecimalPlaces] = react.useState(
1521
+ () => typeof request.dataFormat === "object" ? request.dataFormat.decimalPlaces ?? 2 : 2
1522
+ );
1523
+ const [useGrouping, setUseGrouping] = react.useState(
1524
+ () => typeof request.dataFormat === "object" ? request.dataFormat.useGrouping ?? false : false
1525
+ );
1526
+ const [currency, setCurrency] = react.useState(
1527
+ () => typeof request.dataFormat === "object" ? request.dataFormat.symbol ?? "\xA5" : "\xA5"
1528
+ );
1529
+ const [datePattern, setDatePattern] = react.useState(
1530
+ () => resolveInitialFormatPattern(request.dataFormat, "date")
1531
+ );
1532
+ const [timePattern, setTimePattern] = react.useState(
1533
+ () => resolveInitialFormatPattern(request.dataFormat, "time")
1534
+ );
1535
+ return /* @__PURE__ */ jsxRuntime.jsx(
1536
+ reactComponents.ReactModal,
1537
+ {
1538
+ open: true,
1539
+ title: "\u8BBE\u7F6E\u5355\u5143\u683C\u6570\u5B57\u683C\u5F0F",
1540
+ width: 480,
1541
+ centered: true,
1542
+ fullscreenable: false,
1543
+ onCancel: props.onClose,
1544
+ onOk: () => {
1545
+ request.onChangeDataFormat?.(
1546
+ resolveMoreFormatValue(
1547
+ category,
1548
+ customPattern,
1549
+ decimalPlaces,
1550
+ currency,
1551
+ datePattern,
1552
+ timePattern,
1553
+ useGrouping
1554
+ )
1555
+ );
1556
+ props.onClose();
1557
+ },
1558
+ bodyStyle: { padding: "0 20px 18px" },
1559
+ children: /* @__PURE__ */ jsxRuntime.jsx(
1560
+ MoreFormatDialogBody,
1561
+ {
1562
+ category,
1563
+ customPattern,
1564
+ decimalPlaces,
1565
+ useGrouping,
1566
+ currency,
1567
+ datePattern,
1568
+ timePattern,
1569
+ onCategoryChange: setCategory,
1570
+ onCustomPatternChange: setCustomPattern,
1571
+ onDecimalPlacesChange: setDecimalPlaces,
1572
+ onGroupingChange: setUseGrouping,
1573
+ onCurrencyChange: setCurrency,
1574
+ onDatePatternChange: setDatePattern,
1575
+ onTimePatternChange: setTimePattern
1576
+ }
1577
+ )
1578
+ }
1579
+ );
1580
+ }
1581
+ var MORE_FORMAT_CATEGORIES = [
1582
+ { key: "general", label: "\u5E38\u89C4" },
1583
+ { key: "number", label: "\u6570\u503C" },
1584
+ { key: "currency", label: "\u8D27\u5E01" },
1585
+ { key: "date", label: "\u65E5\u671F" },
1586
+ { key: "time", label: "\u65F6\u95F4" },
1587
+ { key: "percent", label: "\u767E\u5206\u6BD4" },
1588
+ { key: "scientific", label: "\u79D1\u5B66\u8BB0\u6570" },
1589
+ { key: "text", label: "\u6587\u672C" },
1590
+ { key: "custom", label: "\u81EA\u5B9A\u4E49" }
1591
+ ];
1592
+ function MoreFormatDialogBody(props) {
1593
+ const sample = resolveMoreFormatSample(
1594
+ props.category,
1595
+ props.customPattern,
1596
+ props.decimalPlaces,
1597
+ props.currency,
1598
+ props.datePattern,
1599
+ props.timePattern,
1600
+ props.useGrouping
1601
+ );
1602
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "grid", gap: 14 }, children: [
1603
+ /* @__PURE__ */ jsxRuntime.jsxs(
1604
+ "div",
1605
+ {
1606
+ style: {
1607
+ display: "grid",
1608
+ gridTemplateColumns: "120px 1fr",
1609
+ gap: 18,
1610
+ alignItems: "stretch",
1611
+ height: 320
1612
+ },
1613
+ children: [
1614
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", flexDirection: "column" }, children: [
1615
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: moreFormatLabelStyle, children: "\u7C7B\u522B" }),
1616
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: { ...moreFormatCategoryListStyle, flex: 1 }, children: MORE_FORMAT_CATEGORIES.map((item) => /* @__PURE__ */ jsxRuntime.jsx(
1617
+ "button",
1618
+ {
1619
+ type: "button",
1620
+ onClick: () => props.onCategoryChange(item.key),
1621
+ style: {
1622
+ ...moreFormatCategoryButtonStyle,
1623
+ ...props.category === item.key ? moreFormatCategorySelectedStyle : null
1624
+ },
1625
+ children: item.label
1626
+ },
1627
+ item.key
1628
+ )) })
1629
+ ] }),
1630
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1631
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: moreFormatLabelStyle, children: "\u793A\u4F8B" }),
1632
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: moreFormatExampleStyle, children: sample }),
1633
+ /* @__PURE__ */ jsxRuntime.jsx(MoreFormatOptions, { ...props })
1634
+ ] })
1635
+ ]
1636
+ }
1637
+ ),
1638
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: moreFormatDescriptionStyle, children: "\u5E38\u89C4\u5355\u5143\u683C\u683C\u5F0F\u4E0D\u5305\u542B\u4EFB\u4F55\u7279\u5B9A\u7684\u6570\u5B57\u683C\u5F0F" })
1639
+ ] });
1640
+ }
1641
+ function MoreFormatOptions(props) {
1642
+ if (props.category === "number" || props.category === "percent" || props.category === "scientific") {
1643
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: moreFormatOptionsStyle, children: [
1644
+ /* @__PURE__ */ jsxRuntime.jsx("span", { style: moreFormatLabelStyle, children: "\u5C0F\u6570\u4F4D\u6570" }),
1645
+ /* @__PURE__ */ jsxRuntime.jsx(
1646
+ reactComponents.ReactInputNumber,
1647
+ {
1648
+ value: props.decimalPlaces,
1649
+ min: 0,
1650
+ max: 20,
1651
+ precision: 0,
1652
+ onChange: (value) => props.onDecimalPlacesChange(value ?? 0),
1653
+ style: { width: 96 }
1654
+ }
1655
+ ),
1656
+ props.category === "number" ? /* @__PURE__ */ jsxRuntime.jsx(
1657
+ reactComponents.ReactCheckbox,
1658
+ {
1659
+ checked: props.useGrouping,
1660
+ onChange: (event) => props.onGroupingChange(event.target.checked),
1661
+ children: "\u663E\u793A\u5343\u5206\u4F4D\u5206\u9694\u7B26\uFF08,\uFF09"
1662
+ }
1663
+ ) : null
1664
+ ] });
1665
+ }
1666
+ if (props.category === "currency") {
1667
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: moreFormatOptionsStyle, children: [
1668
+ /* @__PURE__ */ jsxRuntime.jsx("span", { style: moreFormatLabelStyle, children: "\u5C0F\u6570\u4F4D\u6570" }),
1669
+ /* @__PURE__ */ jsxRuntime.jsx(
1670
+ reactComponents.ReactInputNumber,
1671
+ {
1672
+ value: props.decimalPlaces,
1673
+ min: 0,
1674
+ max: 20,
1675
+ precision: 0,
1676
+ onChange: (value) => props.onDecimalPlacesChange(value ?? 0),
1677
+ style: { width: 96 }
1678
+ }
1679
+ ),
1680
+ /* @__PURE__ */ jsxRuntime.jsx("span", { style: moreFormatLabelStyle, children: "\u8D27\u5E01\u7B26\u53F7" }),
1681
+ /* @__PURE__ */ jsxRuntime.jsx(
1682
+ reactComponents.ReactSelect,
1683
+ {
1684
+ value: props.currency,
1685
+ options: [
1686
+ { label: "\xA5", value: "\xA5" },
1687
+ { label: "$", value: "$" }
1688
+ ],
1689
+ onChange: props.onCurrencyChange,
1690
+ style: { width: 150 }
1691
+ }
1692
+ )
1693
+ ] });
1694
+ }
1695
+ if (props.category === "date") {
1696
+ return /* @__PURE__ */ jsxRuntime.jsx(
1697
+ FormatChoiceList,
1698
+ {
1699
+ label: "\u7C7B\u578B",
1700
+ value: props.datePattern,
1701
+ options: DATE_FORMAT_OPTIONS,
1702
+ onChange: props.onDatePatternChange,
1703
+ allowInput: true,
1704
+ inputLabel: "\u81EA\u5B9A\u4E49\u683C\u5F0F",
1705
+ inputPlaceholder: "\u4F8B\u5982\uFF1AYYYY-MM-DD HH:mm:ss"
1706
+ }
1707
+ );
1708
+ }
1709
+ if (props.category === "time") {
1710
+ return /* @__PURE__ */ jsxRuntime.jsx(
1711
+ FormatChoiceList,
1712
+ {
1713
+ label: "\u7C7B\u578B",
1714
+ value: props.timePattern,
1715
+ options: TIME_FORMAT_OPTIONS,
1716
+ onChange: props.onTimePatternChange
1717
+ }
1718
+ );
1719
+ }
1720
+ if (props.category === "custom") {
1721
+ return /* @__PURE__ */ jsxRuntime.jsx(
1722
+ FormatChoiceList,
1723
+ {
1724
+ label: "\u7C7B\u578B",
1725
+ value: props.customPattern,
1726
+ options: [
1727
+ "@",
1728
+ "G/\u901A\u7528\u683C\u5F0F",
1729
+ '0,"\u4E07"',
1730
+ '0.0,"\u4E07"',
1731
+ '0.00,"\u4E07"',
1732
+ '"**********"',
1733
+ "0",
1734
+ "0.0",
1735
+ "0.00",
1736
+ "0.000",
1737
+ "#,##0",
1738
+ "#,##0.0",
1739
+ "#,##0.00",
1740
+ "#,##0.000",
1741
+ "#,##0;[\u7EA2\u8272]-#,##0",
1742
+ "0%",
1743
+ "0.0%",
1744
+ "0.00%",
1745
+ "\xA5#,##0",
1746
+ "\xA5#,##0.00",
1747
+ "$#,##0",
1748
+ "$#,##0.00",
1749
+ "0.00E+00",
1750
+ "YYYY/M/D",
1751
+ "YYYY/MM/DD",
1752
+ "YYYY-MM-DD",
1753
+ "HH:mm",
1754
+ "HH:mm:ss",
1755
+ "Ah:mm",
1756
+ "Ah:mm:ss",
1757
+ "YYYY/M/D HH:mm",
1758
+ "YYYY-MM-DD HH:mm:ss"
1759
+ ],
1760
+ onChange: props.onCustomPatternChange,
1761
+ allowInput: true
1762
+ }
1763
+ );
1764
+ }
1765
+ return null;
1766
+ }
1767
+ function FormatChoiceList(props) {
1768
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginTop: 16 }, children: [
1769
+ props.allowInput ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1770
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: moreFormatLabelStyle, children: props.inputLabel ?? props.label }),
1771
+ /* @__PURE__ */ jsxRuntime.jsx(
1772
+ reactComponents.ReactInput,
1773
+ {
1774
+ value: props.value,
1775
+ placeholder: props.inputPlaceholder,
1776
+ onChange: (event) => props.onChange(event.target.value)
1777
+ }
1778
+ )
1779
+ ] }) : null,
1780
+ /* @__PURE__ */ jsxRuntime.jsx(
1781
+ "div",
1782
+ {
1783
+ style: {
1784
+ ...moreFormatLabelStyle,
1785
+ marginTop: props.allowInput ? 14 : 0
1786
+ },
1787
+ children: props.label
1788
+ }
1789
+ ),
1790
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: moreFormatChoiceListStyle, children: props.options.map((option) => {
1791
+ const value = typeof option === "string" ? option : option.value;
1792
+ const label = typeof option === "string" ? option : option.label;
1793
+ return /* @__PURE__ */ jsxRuntime.jsx(
1794
+ "button",
1795
+ {
1796
+ type: "button",
1797
+ onClick: () => props.onChange(value),
1798
+ style: {
1799
+ ...moreFormatChoiceStyle,
1800
+ ...props.value === value ? moreFormatChoiceSelectedStyle : null
1801
+ },
1802
+ children: label
1803
+ },
1804
+ value
1805
+ );
1806
+ }) })
1807
+ ] });
1808
+ }
1809
+ function resolveMoreFormatCategory(dataFormat) {
1810
+ const type = typeof dataFormat === "object" ? dataFormat.type : dataFormat;
1811
+ if (type === "custom") return "custom";
1812
+ if (type === "percent" || type === "percentDecimal") return "percent";
1813
+ if (type === "cny" || type === "cnyDecimal" || type === "usd" || type === "usdDecimal" || type === "money")
1814
+ return "currency";
1815
+ if (type === "dateSlash" || type === "dateDash" || type === "dateFullCN" || type === "dateYearMonthCN" || type === "dateMonthDayCN" || type === "dateSlashWeek" || type === "dateDashWeek" || type === "dateWeekdayCNFull" || type === "dateWeekdayCNShort" || type === "datetime" || type === "datetime12" || type === "datetime12Seconds")
1816
+ return "date";
1817
+ if (type === "time" || type === "timeShort" || type === "time12" || type === "time12Seconds" || type === "timeMillisecond" || type === "time12Millisecond" || type === "timeChineseHour" || type === "timeChineseSecond" || type === "time12ChineseHour" || type === "time12ChineseSecond")
1818
+ return "time";
1819
+ if (type === "scientific") return "scientific";
1820
+ if (type === "text") return "text";
1821
+ if (type === "number" || type === "thousands" || type === "decimal" || type === "numberToChineseUpper" || type === "chineseUpperToNumber")
1822
+ return "number";
1823
+ return "general";
1824
+ }
1825
+ var DATE_FORMAT_OPTIONS = [
1826
+ { label: "2012/3/14", value: "YYYY/M/D", type: "dateSlash" },
1827
+ { label: "2012/03/14", value: "YYYY/MM/DD", type: "dateSlash" },
1828
+ { label: "2012-3-14", value: "YYYY-M-D", type: "dateDash" },
1829
+ { label: "2012-03-14", value: "YYYY-MM-DD", type: "dateDash" },
1830
+ { label: "2012.03.14", value: "YYYY.MM.DD", type: "dateSlash" },
1831
+ { label: "14/03/2012", value: "DD/MM/YYYY", type: "dateSlash" },
1832
+ { label: "03/14/2012", value: "MM/DD/YYYY", type: "dateSlash" },
1833
+ { label: "12\u5E743\u670814\u65E5", value: "YY\u5E74M\u6708D\u65E5", type: "dateFullCN" },
1834
+ { label: "2012\u5E743\u670814\u65E5", value: "YYYY\u5E74M\u6708D\u65E5", type: "dateFullCN" },
1835
+ { label: "2012\u5E743\u6708", value: "YYYY\u5E74M\u6708", type: "dateYearMonthCN" },
1836
+ { label: "3\u670814\u65E5", value: "M\u6708D\u65E5", type: "dateMonthDayCN" },
1837
+ { label: "\u661F\u671F\u4E09", value: "dddd", type: "dateWeekdayCNFull" },
1838
+ { label: "\u5468\u4E09", value: "ddd", type: "dateWeekdayCNShort" },
1839
+ { label: "2012/3/14 \u661F\u671F\u4E09", value: "YYYY/M/D dddd", type: "dateSlashWeek" },
1840
+ {
1841
+ label: "2012-03-14 \u661F\u671F\u4E09",
1842
+ value: "YYYY-MM-DD dddd",
1843
+ type: "dateDashWeek"
1844
+ },
1845
+ { label: "2012/3/14 14:30", value: "YYYY/M/D HH:mm", type: "datetime" },
1846
+ { label: "2012/3/14 14:30:55", value: "YYYY/M/D HH:mm:ss", type: "datetime" },
1847
+ {
1848
+ label: "2012-03-14 14:30:55",
1849
+ value: "YYYY-MM-DD HH:mm:ss",
1850
+ type: "datetime"
1851
+ },
1852
+ { label: "2012/3/14 \u4E0B\u53482:30", value: "YYYY/M/D Ah:mm", type: "datetime12" },
1853
+ {
1854
+ label: "2012/3/14 \u4E0B\u53482:30:55",
1855
+ value: "YYYY/M/D Ah:mm:ss",
1856
+ type: "datetime12Seconds"
1857
+ }
1858
+ ];
1859
+ var TIME_FORMAT_OPTIONS = [
1860
+ { label: "14:30", value: "HH:mm", type: "timeShort" },
1861
+ { label: "14:30:55", value: "HH:mm:ss", type: "time" },
1862
+ { label: "14:30:55.123", value: "HH:mm:ss.SSS", type: "timeMillisecond" },
1863
+ { label: "\u4E0B\u53482:30", value: "Ah:mm", type: "time12" },
1864
+ { label: "\u4E0B\u53482:30:55", value: "Ah:mm:ss", type: "time12Seconds" },
1865
+ {
1866
+ label: "\u4E0B\u53482:30:55.123",
1867
+ value: "Ah:mm:ss.SSS",
1868
+ type: "time12Millisecond"
1869
+ },
1870
+ { label: "14\u65F630\u5206", value: "H\u65F6mm\u5206", type: "timeChineseHour" },
1871
+ { label: "14\u65F630\u520655\u79D2", value: "H\u65F6mm\u5206ss\u79D2", type: "timeChineseSecond" },
1872
+ { label: "\u4E0B\u53482\u65F630\u5206", value: "Ah\u65F6mm\u5206", type: "time12ChineseHour" },
1873
+ {
1874
+ label: "\u4E0B\u53482\u65F630\u520655\u79D2",
1875
+ value: "Ah\u65F6mm\u5206ss\u79D2",
1876
+ type: "time12ChineseSecond"
1877
+ }
1878
+ ];
1879
+ var DATE_TIME_FORMAT_SAMPLE = new Date(2012, 2, 14, 14, 30, 55, 123);
1880
+ function resolveInitialFormatPattern(dataFormat, kind) {
1881
+ if (typeof dataFormat === "object" && dataFormat.pattern) {
1882
+ return dataFormat.pattern;
1883
+ }
1884
+ if (typeof dataFormat === "string") {
1885
+ const source = kind === "date" ? DATE_FORMAT_OPTIONS : TIME_FORMAT_OPTIONS;
1886
+ const match = source.find((option) => option.type === dataFormat);
1887
+ if (match) return match.value;
1888
+ }
1889
+ return kind === "date" ? "YYYY/M/D" : "HH:mm";
1890
+ }
1891
+ function resolveMoreFormatValue(category, customPattern, decimalPlaces = 2, currency = "\xA5", datePattern = "YYYY/M/D", timePattern = "HH:mm", useGrouping = false) {
1892
+ if (category === "number")
1893
+ return { type: "number", decimalPlaces, useGrouping };
1894
+ if (category === "currency") {
1895
+ return {
1896
+ type: currency === "$" ? "usd" : "cny",
1897
+ decimalPlaces,
1898
+ useGrouping: true,
1899
+ symbol: currency
1900
+ };
1901
+ }
1902
+ if (category === "date") {
1903
+ return {
1904
+ type: DATE_FORMAT_OPTIONS.find((option) => option.value === datePattern)?.type ?? "datetime",
1905
+ pattern: datePattern
1906
+ };
1907
+ }
1908
+ if (category === "time") {
1909
+ return {
1910
+ type: TIME_FORMAT_OPTIONS.find((option) => option.value === timePattern)?.type ?? "time",
1911
+ pattern: timePattern
1912
+ };
1913
+ }
1914
+ if (category === "percent") return { type: "percent", decimalPlaces };
1915
+ if (category === "scientific") return { type: "scientific", decimalPlaces };
1916
+ if (category === "text") return "text";
1917
+ if (category === "custom") return { type: "custom", pattern: customPattern };
1918
+ return "default";
1919
+ }
1920
+ function resolveMoreFormatSample(category, customPattern, decimalPlaces = 2, currency = "\xA5", datePattern = "YYYY/M/D", timePattern = "HH:mm", useGrouping = false) {
1921
+ if (category === "date") {
1922
+ return date.formatDateTimeValue(DATE_TIME_FORMAT_SAMPLE, datePattern) ?? "";
1923
+ }
1924
+ if (category === "time") {
1925
+ return date.formatDateTimeValue(DATE_TIME_FORMAT_SAMPLE, timePattern) ?? "";
1926
+ }
1927
+ if (category === "number") {
1928
+ return number.formatNumberValue(1024.56, {
1929
+ decimalPlaces,
1930
+ thousandsSeparator: useGrouping
1931
+ });
1932
+ }
1933
+ if (category === "currency") {
1934
+ return number.formatNumberValue(1024.56, {
1935
+ decimalPlaces,
1936
+ thousandsSeparator: true,
1937
+ symbol: currency
1938
+ });
1939
+ }
1940
+ if (category === "percent") return number.formatPercentValue(0.1024, decimalPlaces);
1941
+ if (category === "scientific") {
1942
+ return number.formatScientificValue(1024, decimalPlaces);
1943
+ }
1944
+ if (category === "custom") {
1945
+ return date.isDateTimeFormatPattern(customPattern) ? date.formatDateTimeValue(DATE_TIME_FORMAT_SAMPLE, customPattern) ?? "" : number.formatCustomNumberPattern(1024.56, customPattern);
1946
+ }
1947
+ const format = resolveMoreFormatValue(
1948
+ category,
1949
+ customPattern,
1950
+ decimalPlaces,
1951
+ currency,
1952
+ datePattern
1953
+ );
1954
+ const samples = {
1955
+ default: "",
1956
+ text: "1024",
1957
+ number: "1024",
1958
+ thousands: "1,024",
1959
+ decimal: "1,024.56",
1960
+ percent: "10%",
1961
+ percentDecimal: "10.24%",
1962
+ scientific: "1.02E+003",
1963
+ numberToChineseUpper: "\u7396\u62FE\u58F9\u4E07\u634C\u4EDF",
1964
+ chineseUpperToNumber: "918000",
1965
+ cny: "\xA51,024",
1966
+ cnyDecimal: "\xA51,024.56",
1967
+ usd: "$1,024",
1968
+ usdDecimal: "$1,024.56",
1969
+ dateSlash: "2017/08/01",
1970
+ dateDash: "2017-08-01",
1971
+ dateFullCN: "2017\u5E748\u67081\u65E5",
1972
+ dateYearMonthCN: "2017\u5E748\u6708",
1973
+ dateMonthDayCN: "8\u67081\u65E5",
1974
+ dateSlashWeek: "2017/08/01 \u661F\u671F\u4E8C",
1975
+ dateDashWeek: "2017-08-01 \u661F\u671F\u4E8C",
1976
+ dateWeekdayCNFull: "\u661F\u671F\u4E8C",
1977
+ dateWeekdayCNShort: "\u5468\u4E8C",
1978
+ time: "23:24:25",
1979
+ timeShort: "23:24",
1980
+ time12: "\u4E0B\u534811:24",
1981
+ time12Seconds: "\u4E0B\u534811:24:25",
1982
+ timeMillisecond: "23:24:25.123",
1983
+ time12Millisecond: "\u4E0B\u534811:24:25.123",
1984
+ timeChineseHour: "23\u65F624\u5206",
1985
+ timeChineseSecond: "23\u65F624\u520625\u79D2",
1986
+ time12ChineseHour: "\u4E0B\u534811\u65F624\u5206",
1987
+ time12ChineseSecond: "\u4E0B\u534811\u65F624\u520625\u79D2",
1988
+ datetime: "2017/08/01 23:24:25",
1989
+ datetime12: "2017/08/01 \u4E0B\u534811:24",
1990
+ datetime12Seconds: "2017/08/01 \u4E0B\u534811:24:25",
1991
+ money: "1,024.00"
1992
+ };
1993
+ return samples[typeof format === "string" ? format : format.type] ?? "";
1994
+ }
1995
+ var moreFormatLabelStyle = {
1996
+ marginBottom: 6,
1997
+ color: "#4b5563",
1998
+ fontSize: 12
1999
+ };
2000
+ var moreFormatCategoryListStyle = {
2001
+ display: "grid",
2002
+ gap: 2,
2003
+ padding: 4,
2004
+ border: "1px solid #d1d5db",
2005
+ borderRadius: 4
2006
+ };
2007
+ var moreFormatCategoryButtonStyle = {
2008
+ height: 28,
2009
+ padding: "0 8px",
2010
+ border: 0,
2011
+ borderRadius: 4,
2012
+ background: "transparent",
2013
+ color: "#374151",
2014
+ textAlign: "left",
2015
+ cursor: "pointer"
2016
+ };
2017
+ var moreFormatCategorySelectedStyle = {
2018
+ background: "#dbeafe",
2019
+ color: "#1677ff"
2020
+ };
2021
+ var moreFormatExampleStyle = {
2022
+ height: 32,
2023
+ padding: "0 10px",
2024
+ display: "flex",
2025
+ alignItems: "center",
2026
+ border: "1px solid #d1d5db",
2027
+ borderRadius: 4,
2028
+ color: "#374151",
2029
+ background: "#f8fafc"
2030
+ };
2031
+ var moreFormatDescriptionStyle = {
2032
+ color: "#6b7280",
2033
+ fontSize: 12
2034
+ };
2035
+ var moreFormatOptionsStyle = {
2036
+ display: "flex",
2037
+ alignItems: "center",
2038
+ flexWrap: "wrap",
2039
+ gap: 8,
2040
+ marginTop: 16
2041
+ };
2042
+ var moreFormatChoiceListStyle = {
2043
+ display: "grid",
2044
+ gap: 2,
2045
+ maxHeight: 150,
2046
+ overflow: "auto",
2047
+ padding: 4,
2048
+ border: "1px solid #d1d5db",
2049
+ borderRadius: 4
2050
+ };
2051
+ var moreFormatChoiceStyle = {
2052
+ minHeight: 26,
2053
+ padding: "3px 8px",
2054
+ border: 0,
2055
+ borderRadius: 3,
2056
+ background: "transparent",
2057
+ color: "#1f2937",
2058
+ textAlign: "left",
2059
+ cursor: "pointer"
2060
+ };
2061
+ var moreFormatChoiceSelectedStyle = {
2062
+ background: "#f3f4f6",
2063
+ color: "#1677ff"
2064
+ };
2065
+ var SEARCH_MODAL_BODY_STYLE = {
2066
+ padding: 12
2067
+ };
2068
+ function ReactListTableSearchDialog(props) {
2069
+ const { request } = props;
2070
+ const [keyword, setKeyword] = react.useState(request.keyword);
2071
+ react.useEffect(() => {
2072
+ setKeyword(request.keyword);
2073
+ }, [request.keyword]);
2074
+ const matchText = request.matchCount > 0 ? `${request.currentIndex + 1} / ${request.matchCount}` : "\u672A\u627E\u5230";
2075
+ return /* @__PURE__ */ jsxRuntime.jsx(
2076
+ reactComponents.ReactModal,
2077
+ {
2078
+ open: true,
2079
+ title: "\u67E5\u627E",
2080
+ width: 360,
2081
+ mask: false,
2082
+ centered: false,
2083
+ draggable: true,
2084
+ fullscreenable: false,
2085
+ footer: false,
2086
+ onCancel: request.onClose,
2087
+ bodyStyle: SEARCH_MODAL_BODY_STYLE,
2088
+ style: { marginTop: 96 },
2089
+ children: /* @__PURE__ */ jsxRuntime.jsxs("div", { style: searchContentStyle, children: [
2090
+ /* @__PURE__ */ jsxRuntime.jsx(
2091
+ reactComponents.ReactInput,
2092
+ {
2093
+ autoFocus: true,
2094
+ value: keyword,
2095
+ placeholder: "\u67E5\u627E\u5185\u5BB9",
2096
+ onChange: (event) => {
2097
+ const value = event.target.value;
2098
+ setKeyword(value);
2099
+ },
2100
+ onPressEnter: () => {
2101
+ request.onSubmit(keyword);
2102
+ }
2103
+ }
2104
+ ),
2105
+ /* @__PURE__ */ jsxRuntime.jsx("span", { style: matchTextStyle, children: matchText }),
2106
+ /* @__PURE__ */ jsxRuntime.jsx(
2107
+ "button",
2108
+ {
2109
+ type: "button",
2110
+ title: "\u4E0A\u4E00\u4E2A",
2111
+ onClick: () => {
2112
+ if (keyword !== request.keyword) {
2113
+ request.onSubmit(keyword);
2114
+ } else {
2115
+ request.onNavigate("previous");
2116
+ }
2117
+ },
2118
+ disabled: request.matchCount === 0 && keyword === request.keyword,
2119
+ style: toolButtonStyle,
2120
+ children: "\u2039"
2121
+ }
2122
+ ),
2123
+ /* @__PURE__ */ jsxRuntime.jsx(
2124
+ "button",
2125
+ {
2126
+ type: "button",
2127
+ title: "\u4E0B\u4E00\u4E2A",
2128
+ onClick: () => {
2129
+ if (keyword !== request.keyword) {
2130
+ request.onSubmit(keyword);
2131
+ } else {
2132
+ request.onNavigate("next");
2133
+ }
2134
+ },
2135
+ disabled: request.matchCount === 0 && keyword === request.keyword,
2136
+ style: toolButtonStyle,
2137
+ children: "\u203A"
2138
+ }
2139
+ )
2140
+ ] })
2141
+ }
1194
2142
  );
1195
2143
  }
2144
+ var searchContentStyle = {
2145
+ display: "flex",
2146
+ alignItems: "center",
2147
+ gap: 8
2148
+ };
2149
+ var matchTextStyle = {
2150
+ minWidth: 58,
2151
+ color: "#64748b",
2152
+ fontSize: 12,
2153
+ whiteSpace: "nowrap"
2154
+ };
2155
+ var toolButtonStyle = {
2156
+ width: 28,
2157
+ height: 28,
2158
+ padding: 0,
2159
+ border: "1px solid #d1d5db",
2160
+ borderRadius: 4,
2161
+ background: "#ffffff",
2162
+ color: "#475569",
2163
+ fontSize: 18,
2164
+ lineHeight: 1,
2165
+ cursor: "pointer"
2166
+ };
1196
2167
 
1197
2168
  // src/features/editor/utils.ts
1198
2169
  function toNumberValue(value) {
@@ -2641,6 +3612,7 @@ function useReactListTableState(options) {
2641
3612
  const [filterPanelRequest, setFilterPanelRequest] = react.useState(null);
2642
3613
  const [fixedPopupRequest, setFixedPopupRequest] = react.useState(null);
2643
3614
  const [headerContextMenuRequest, setHeaderContextMenuRequest] = react.useState(null);
3615
+ const [searchRequest, setSearchRequest] = react.useState(null);
2644
3616
  const [imagePreviewRequest, setImagePreviewRequest] = react.useState(null);
2645
3617
  const [dangerConfirmRequest, setDangerConfirmRequest] = react.useState(null);
2646
3618
  const uiOptions = react.useMemo(
@@ -2674,6 +3646,10 @@ function useReactListTableState(options) {
2674
3646
  setHeaderContextMenuRequest(request);
2675
3647
  options.ui?.onHeaderContextMenuRequest?.(request);
2676
3648
  },
3649
+ onSearchRequest: (request) => {
3650
+ setSearchRequest(request);
3651
+ options.ui?.onSearchRequest?.(request);
3652
+ },
2677
3653
  onImagePreviewRequest: (request) => {
2678
3654
  setImagePreviewRequest(request);
2679
3655
  options.ui?.onImagePreviewRequest?.(request);
@@ -2706,6 +3682,7 @@ function useReactListTableState(options) {
2706
3682
  setFilterPanelRequest(null);
2707
3683
  setFixedPopupRequest(null);
2708
3684
  setHeaderContextMenuRequest(null);
3685
+ setSearchRequest(null);
2709
3686
  setImagePreviewRequest(null);
2710
3687
  setDangerConfirmRequest(null);
2711
3688
  };
@@ -2726,6 +3703,7 @@ function useReactListTableState(options) {
2726
3703
  filterPanelRequest,
2727
3704
  fixedPopupRequest,
2728
3705
  headerContextMenuRequest,
3706
+ searchRequest,
2729
3707
  imagePreviewRequest,
2730
3708
  dangerConfirmRequest,
2731
3709
  closeDangerConfirmRequest: () => {
@@ -2777,11 +3755,13 @@ function ReactListTableInner(props, ref) {
2777
3755
  striped,
2778
3756
  highlightMode,
2779
3757
  contextMenu,
3758
+ grouping,
2780
3759
  rowHeight,
2781
3760
  headerRowHeight,
2782
3761
  summaryRowHeight,
2783
3762
  overscanRowCount,
2784
3763
  query,
3764
+ rowSelector,
2785
3765
  rowSelection,
2786
3766
  expandable,
2787
3767
  pagination,
@@ -2832,11 +3812,13 @@ function ReactListTableInner(props, ref) {
2832
3812
  striped,
2833
3813
  highlightMode,
2834
3814
  contextMenu,
3815
+ grouping,
2835
3816
  rowHeight: resolvedRowHeight,
2836
3817
  headerRowHeight,
2837
3818
  summaryRowHeight,
2838
3819
  overscanRowCount,
2839
3820
  query,
3821
+ rowSelector,
2840
3822
  rowSelection,
2841
3823
  expandable,
2842
3824
  pagination,
@@ -2865,11 +3847,13 @@ function ReactListTableInner(props, ref) {
2865
3847
  striped,
2866
3848
  highlightMode,
2867
3849
  contextMenu,
3850
+ grouping,
2868
3851
  resolvedRowHeight,
2869
3852
  headerRowHeight,
2870
3853
  summaryRowHeight,
2871
3854
  overscanRowCount,
2872
3855
  query,
3856
+ rowSelector,
2873
3857
  rowSelection,
2874
3858
  expandable,
2875
3859
  pagination,
@@ -2894,6 +3878,7 @@ function ReactListTableInner(props, ref) {
2894
3878
  filterPanelRequest,
2895
3879
  fixedPopupRequest,
2896
3880
  headerContextMenuRequest,
3881
+ searchRequest,
2897
3882
  imagePreviewRequest,
2898
3883
  dangerConfirmRequest,
2899
3884
  closeDangerConfirmRequest
@@ -3034,6 +4019,10 @@ function ReactListTableInner(props, ref) {
3034
4019
  /* @__PURE__ */ jsxRuntime.jsx(ReactTableContextMenuView, { request: headerContextMenuRequest }),
3035
4020
  document.body
3036
4021
  ) : null,
4022
+ searchRequest ? reactDom.createPortal(
4023
+ /* @__PURE__ */ jsxRuntime.jsx(ReactListTableSearchDialog, { request: searchRequest }),
4024
+ document.body
4025
+ ) : null,
3037
4026
  dangerConfirmRequest ? reactDom.createPortal(
3038
4027
  /* @__PURE__ */ jsxRuntime.jsx(
3039
4028
  ReactTableDangerConfirmView,