@canvas-components/react-list-table 0.2.2 → 0.2.4

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