@canvas-components/react-list-table 0.3.72 → 0.3.74

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,13 +1,15 @@
1
- import { createContext, memo, forwardRef, useMemo, useRef, useState, useEffect, useImperativeHandle, useLayoutEffect, useContext, useId, Fragment as Fragment$1 } from 'react';
1
+ import { createContext, memo, forwardRef, useMemo, useRef, useLayoutEffect, useState, useEffect, useImperativeHandle, useContext, useCallback, useId, Fragment as Fragment$1 } from 'react';
2
2
  import { createPortal } from 'react-dom';
3
- import { getSharedScrollbarSettings, subscribeSharedScrollbarSettings, ReactTooltip, ReactImagePreview, ReactCheckbox, ReactSortableList, ReactInputNumber, ReactSelect, ReactPagination, ReactFilterPanel, ReactPopup, ReactModal, ReactInput, ReactPopconfirm, ReactContentScaleProvider, ReactScrollbarSettingsDialog, ReactScrollbarPositionDialog, setSharedScrollbarSettings, ReactButton, ReactColorPicker, resolveReactScrollbarMode, ReactAutoComplete, ReactTimeRangePicker, ReactDateTimeRangePicker, ReactDateTimePicker, ReactTimePicker, ReactDateRangePicker, ReactDatePicker, ReactMonthPicker, ReactQuarterPicker, ReactYearPicker, ReactInputRange, ReactCascader, ReactTreeSelect } from '@canvas-components/react-components';
4
- import { EXPAND_COLUMN, SELECTION_COLUMN, ROW_SELECTION_COLUMN, resetListTableStoredColumnConfig, withListTableColumnVisibility, isListTableColumnHiddenBySource, ListTable, getListTableStoredColumnConfig, saveListTableStoredColumnConfig } from '@canvas-components/list-table';
3
+ import { getSharedScrollbarSettings, subscribeSharedScrollbarSettings, ReactTooltip, ReactImagePreview, ReactCheckbox, ReactSortableList, ReactInputNumber, ReactSelect, ReactPagination, ReactFilterPanel, ReactPopup, ReactModal, ReactInput, ReactPopconfirm, ReactContentScaleProvider, ReactScrollbarSettingsDialog, ReactScrollbarPositionDialog, setSharedScrollbarSettings, ReactButton, ReactColorPicker, resolveReactScrollbarMode, ReactAutoComplete, ReactTimeRangePicker, ReactDateTimeRangePicker, ReactDateTimePicker, ReactTimePicker, ReactDateRangePicker, ReactDatePicker, ReactMonthPicker, ReactQuarterPicker, ReactYearPicker, ReactInputRange, ReactCascader, ReactTreeSelect, ReactTableSelect, ReactMathInterval, ReactInputNumberUnit, ReactInputGroup } from '@canvas-components/react-components';
4
+ import { EXPAND_COLUMN, SELECTION_COLUMN, ROW_SELECTION_COLUMN, resetListTableStoredColumnConfig, withListTableColumnVisibility, ListTable, getListTableStoredColumnConfig, isListTableColumnHiddenBySource, isListTableColumnHidden, saveListTableStoredColumnConfig, resolveListTableEditorItemWidths } from '@canvas-components/list-table';
5
5
  export { EXPAND_COLUMN, ROW_SELECTION_COLUMN, SELECTION_COLUMN, getListTableStoredPageSize } from '@canvas-components/list-table';
6
6
  import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
7
7
  import { CanvasChart } from '@canvas-components/chart';
8
8
  import { formatDateTimeValue, isDateTimeFormatPattern } from '@canvas-components/utils/date';
9
9
  import { formatNumberValue, formatPercentValue, formatScientificValue, formatCustomNumberPattern } from '@canvas-components/utils/number';
10
10
  import { builtinListTablePrintIntegration } from '@canvas-components/print-design-plugin/list-table-print';
11
+ import { normalizeMathInterval, normalizeNumberUnit as normalizeNumberUnit$1 } from '@canvas-components/utils';
12
+ import { normalizeNumberUnit } from '@canvas-components/utils/number-unit';
11
13
 
12
14
  // #style-inject:#style-inject
13
15
  function styleInject(css, { insertAt } = {}) {
@@ -36,6 +38,29 @@ styleInject(".react-list-table-host {\n touch-action: none;\n min-width: 0;\n
36
38
 
37
39
  // ../print-design-plugin/dist/react.css
38
40
  styleInject('.cc-print-design-flow-item {\n border: 1px solid var(--pd-border);\n border-radius: 6px;\n padding: 8px;\n}\n.cc-print-design-flow-reverse,\n.cc-print-design-flow-reverse .canvas-react-button {\n width: 100%;\n}\n.cc-print-design-flow-item-heading {\n display: flex;\n align-items: center;\n gap: 4px;\n margin-bottom: 8px;\n}\n.cc-print-design-flow-item-heading strong {\n flex: 1;\n}\n.cc-print-design-flow-item-heading .canvas-react-button {\n padding: 4px;\n}\n.cc-print-design-chart-series {\n border: 1px solid var(--pd-border);\n border-radius: 6px;\n padding: 8px;\n margin: 8px 0;\n}\n.cc-print-design-column-actions > .canvas-react-button {\n box-sizing: border-box;\n width: 32px;\n height: 32px;\n flex: 0 0 32px;\n padding: 4px;\n}\n.cc-print-design-editor .cc-print-design-table-data label {\n font-size: var(--pd-label-font-size, 12px);\n color: var(--pd-muted);\n}\n.cc-print-design-packed-form,\n.cc-print-design-packed-section,\n.cc-print-design-packed-card {\n display: flex;\n flex-direction: column;\n gap: 9px;\n min-width: 0;\n}\n.cc-print-design-packed-form {\n --canvas-react-control-height: 32px;\n gap: 16px;\n padding-top: 9px;\n}\n.cc-print-design-packed-form .canvas-react-select,\n.cc-print-design-packed-form .canvas-react-input-number,\n.cc-print-design-packed-form .canvas-react-input-affix-wrapper {\n height: 32px;\n}\n.cc-print-design-table-data .cc-print-design-packed-form label.cc-print-design-field {\n align-items: stretch;\n margin: 0;\n gap: 5px;\n}\n.cc-print-design-packed-section {\n padding-top: 12px;\n border-top: 1px solid var(--pd-border);\n}\n.cc-print-design-packed-mode {\n display: flex;\n gap: 6px;\n}\n.cc-print-design-packed-mode > button {\n flex: 1;\n}\n.cc-print-design-packed-hint {\n color: var(--pd-muted);\n font-size: 12px;\n line-height: 1.5;\n}\n.cc-print-design-packed-summary-field {\n display: flex;\n flex-direction: column;\n gap: 6px;\n}\n.cc-print-design-packed-summary-field > button {\n width: 100%;\n}\n.cc-print-design-packed-card {\n padding: 9px;\n border: 1px solid var(--pd-border);\n border-radius: 5px;\n}\n.cc-print-design-packed-row {\n display: flex;\n align-items: end;\n gap: 6px;\n min-width: 0;\n}\n.cc-print-design-packed-add {\n width: 100%;\n margin-top: 9px;\n padding: 0;\n border-style: dashed;\n}\n.cc-print-design-packed-row > .cc-print-design-field {\n flex: 1;\n}\n.cc-print-design-packed-row > .cc-print-design-packed-delete {\n flex: none;\n align-self: end;\n width: 32px;\n height: 32px;\n padding: 0;\n}\n.cc-print-design-packed-checks {\n display: grid;\n grid-template-columns: repeat(2, minmax(0, 1fr));\n gap: 6px;\n}\n.cc-print-design-table-data {\n padding: 12px;\n border-bottom: 1px solid var(--pd-border);\n --canvas-react-control-height: 32px;\n}\n.cc-print-design-table-data h4 {\n font-size: var(--pd-primary-font-size, 13px);\n margin: 12px 0;\n}\n.cc-print-design-table-data label:not(.canvas-react-checkbox) {\n display: flex;\n flex-direction: column;\n gap: 6px;\n margin: 10px 0;\n}\n.cc-print-design-diagonal-style {\n grid-column: 1 / -1;\n display: grid;\n grid-template-columns: repeat(2, minmax(0, 1fr));\n gap: 8px;\n padding-top: 8px;\n border-top: 1px solid var(--pd-border);\n}\n.cc-print-design-diagonal-style > strong {\n grid-column: 1 / -1;\n}\n.cc-print-design-cell-merge-actions {\n grid-column: 1 / -1;\n display: flex;\n gap: 8px;\n}\n.cc-print-design-cell-merge-actions > .canvas-react-button {\n flex: 1;\n min-width: 0;\n}\n.cc-print-design-cell-content-format {\n grid-column: 1 / -1;\n display: grid;\n grid-template-columns: repeat(2, minmax(0, 1fr));\n gap: 8px;\n}\n.cc-print-design-cell-content-format > .cc-print-design-cell-content-format-type {\n grid-column: 1 / -1;\n}\n.cc-print-design-diagonal-controls {\n grid-column: 1 / -1;\n display: grid;\n gap: 4px;\n}\n.cc-print-design-compact-grid:not([hidden]) {\n display: grid;\n grid-template-columns: repeat(2, minmax(0, 1fr));\n gap: 8px;\n}\n.cc-print-design-compact-grid > .canvas-react-checkbox,\n.cc-print-design-compact-grid > .cc-print-design-property-toggle {\n grid-column: 1 / -1;\n}\n.cc-print-design-table-data.cc-print-design-compact-grid label:not(.canvas-react-checkbox) {\n min-width: 0;\n gap: 4px;\n margin: 0;\n}\n.cc-print-design-compact-grid .canvas-react-input-number,\n.cc-print-design-compact-grid .canvas-react-color-picker {\n width: 100%;\n min-width: 0;\n}\n.cc-print-design-row-height-controls {\n display: flex;\n align-items: center;\n gap: 8px;\n}\n.cc-print-design-cell-print-mode,\n.cc-print-design-row-height-field {\n align-self: end;\n}\n.cc-print-design-row-height-controls > .canvas-react-input-number {\n flex: 1 1 auto;\n}\n.cc-print-design-row-height-controls > .cc-print-design-row-height-reset {\n box-sizing: border-box;\n width: 32px;\n height: 32px;\n flex: 0 0 32px;\n padding: 4px;\n}\n.cc-print-design-column-conditions,\n.cc-print-design-column-condition {\n display: flex;\n flex-direction: column;\n gap: 8px;\n}\n.cc-print-design-column-conditions {\n padding-top: 10px;\n border-top: 1px solid var(--pd-border);\n}\n.cc-print-design-column-condition {\n padding: 8px;\n border: 1px solid var(--pd-border);\n border-radius: 5px;\n}\n.cc-print-design-column-condition-head,\n.cc-print-design-column-condition-colors {\n display: flex;\n align-items: center;\n gap: 8px;\n}\n.cc-print-design-column-condition-head {\n justify-content: space-between;\n}\n.cc-print-design-column-condition-colors > label {\n flex: 1;\n min-width: 0;\n}\n.cc-print-design-column-heading {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 8px;\n min-width: 0;\n}\n.cc-print-design-column-heading > span {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.cc-print-design-column-heading small {\n flex-shrink: 0;\n color: var(--pd-muted);\n font-size: var(--pd-secondary-font-size, 11px);\n font-weight: normal;\n}\n.cc-print-design-column-grid:not([hidden]) {\n display: grid;\n grid-template-columns: repeat(2, minmax(0, 1fr));\n gap: 8px;\n padding: 8px;\n}\n.cc-print-design-column-grid > * {\n grid-column: 1 / -1;\n min-width: 0;\n}\n.cc-print-design-column-grid > .cc-print-design-column-half {\n grid-column: span 1;\n}\n.cc-print-design-column-field-row {\n display: flex;\n align-items: end;\n gap: 8px;\n min-width: 0;\n}\n.cc-print-design-column-field-row > .cc-print-design-field {\n flex: 1;\n min-width: 0;\n margin: 0;\n}\n.cc-print-design-column-field-row .cc-print-design-column-actions {\n flex: none;\n gap: 4px;\n}\n.cc-print-design-table-data .cc-print-design-column-grid label:not(.canvas-react-checkbox),\n.cc-print-design-column-grid > .cc-print-design-field {\n gap: 4px;\n margin: 0;\n}\n.cc-print-design-column-grid .canvas-react-input-number {\n min-width: 0;\n width: 100%;\n}\n.cc-print-design-cell-appearance .canvas-react-color-picker {\n min-width: 0;\n width: 100%;\n}\n.cc-print-design-table-appearance-colors {\n display: grid;\n grid-template-columns: repeat(2, minmax(0, 1fr));\n gap: 8px;\n}\n.cc-print-design-table-appearance-colors > label {\n min-width: 0;\n}\n.cc-print-design-column-actions {\n display: flex;\n justify-content: flex-end;\n align-items: center;\n gap: 8px;\n}\n.cc-print-design-column-toolbar {\n display: grid;\n grid-template-columns: repeat(3, minmax(0, 1fr));\n gap: 6px;\n margin-top: 8px;\n}\n.cc-print-design-column-toolbar > * {\n min-width: 0;\n width: 100%;\n}\n.cc-print-design-data-merge,\n.cc-print-design-merge-form {\n display: grid;\n gap: 12px;\n}\n.cc-print-design-merge-fields {\n display: flex;\n flex-direction: column;\n gap: 8px;\n margin: 0;\n}\n.cc-print-design-merge-fields > strong {\n font-size: var(--pd-primary-font-size, 13px);\n}\n.cc-print-design-merge-field {\n display: flex;\n align-items: center;\n gap: 6px;\n min-width: 0;\n}\n.cc-print-design-merge-field > .cc-print-design-field {\n flex: 1;\n min-width: 0;\n}\n.cc-print-design-packed-toggle {\n width: 100%;\n}\n.cc-print-design-summary-toggle {\n width: 100%;\n}\n.cc-print-design-table-row {\n border: 1px solid var(--pd-border);\n border-radius: 6px;\n padding: 8px;\n margin: 8px 0;\n}\n.cc-print-design-table-data pre {\n max-height: 200px;\n overflow: auto;\n font-size: var(--pd-primary-font-size, 13px);\n overscroll-behavior: contain;\n}\n.cc-print-design-row-settings:not([hidden]) {\n display: grid;\n grid-template-columns: repeat(2, minmax(0, 1fr));\n gap: 8px;\n}\n.cc-print-design-row-settings > * {\n grid-column: 1 / -1;\n min-width: 0;\n}\n.cc-print-design-row-settings-header-toggle {\n width: 100%;\n}\n.cc-print-design-row-settings > .cc-print-design-column-half {\n grid-column: span 1;\n margin: 0;\n gap: 4px;\n}\n.cc-print-design-row-count {\n display: grid;\n grid-template-columns: repeat(2, minmax(0, 1fr));\n gap: 8px;\n align-items: end;\n}\n.cc-print-design-table-data .cc-print-design-row-count > label {\n min-width: 0;\n margin: 0;\n gap: 4px;\n}\n.cc-print-design-row-count > .canvas-react-button {\n box-sizing: border-box;\n min-width: 0;\n width: 100%;\n height: var(--canvas-react-control-height, 32px);\n padding: 0 4px;\n white-space: nowrap;\n}\n.cc-print-design-row-settings .canvas-react-input-number {\n min-width: 0;\n width: 100%;\n}\n.cc-print-design-row-settings .cc-print-design-hint {\n margin: 0;\n}\n.cc-print-design-data-compact {\n padding: 8px;\n}\n.cc-print-design-table-data-panel:not([hidden]) {\n display: flex;\n flex-direction: column;\n gap: 10px;\n}\n.cc-print-design-static-data-actions {\n display: grid;\n grid-template-columns: repeat(2, minmax(0, 1fr));\n gap: 8px;\n}\n.cc-print-design-static-data-actions > .canvas-react-button {\n min-width: 0;\n width: 100%;\n}\n.cc-print-design-data-compact .cc-print-design-hint {\n margin: 6px 0;\n}\n.cc-print-design-data-compact .cc-print-design-json-field {\n margin: 6px 0;\n}\n.cc-print-design-data-compact .cc-print-design-table-row {\n padding: 0;\n margin: 6px 0;\n overflow: hidden;\n}\n.cc-print-design-static-row-grid:not([hidden]) {\n display: grid;\n grid-template-columns: repeat(2, minmax(0, 1fr));\n gap: 8px;\n padding: 8px;\n}\n.cc-print-design-static-row-grid > * {\n min-width: 0;\n}\n.cc-print-design-table-data .cc-print-design-static-row-grid label:not(.canvas-react-checkbox) {\n margin: 0;\n gap: 4px;\n overflow-wrap: anywhere;\n}\n.cc-print-design-static-row-grid .canvas-react-input-number {\n width: 100%;\n min-width: 0;\n}\n.cc-print-design-static-row-grid > .cc-print-design-json-field,\n.cc-print-design-static-row-grid > .cc-print-design-static-row-actions {\n grid-column: 1 / -1;\n}\n.cc-print-design-static-row-grid > .cc-print-design-static-row-actions-inline {\n grid-column: span 1;\n align-self: end;\n}\n.cc-print-design-border-side-controls {\n display: grid;\n grid-template-columns: repeat(3, 32px);\n grid-template-rows: repeat(3, 32px);\n gap: 2px;\n justify-content: center;\n}\n.cc-print-design-border-editor {\n grid-column: 1 / -1;\n width: 100%;\n min-width: 0;\n padding: 0;\n margin: 0;\n border: 0;\n}\n.cc-print-design-border-editor .cc-print-design-border-side-controls {\n width: 100%;\n}\n.cc-print-design-border-editor > .cc-print-design-border-line-style,\n.cc-print-design-border-editor > .cc-print-design-border-print-mode {\n grid-column: span 1;\n min-width: 0;\n}\n.cc-print-design-border-side-controls .canvas-react-button {\n min-width: 0;\n width: 32px;\n height: 32px;\n padding: 0;\n}\n.cc-print-design-border-side-top {\n grid-area: 1 / 2;\n}\n.cc-print-design-border-side-right {\n grid-area: 2 / 3;\n}\n.cc-print-design-border-side-bottom {\n grid-area: 3 / 2;\n}\n.cc-print-design-border-side-left {\n grid-area: 2 / 1;\n}\n.cc-print-design-border-side-inner {\n grid-area: 2 / 2;\n}\n.cc-print-design-table-data.cc-print-design-pivot-field-config {\n padding: 0;\n border: 0;\n}\n.cc-print-design-pivot-field-config__panel {\n height: 430px;\n min-height: 280px;\n margin-top: 10px;\n}\n.cc-print-pivot-fields {\n display: flex;\n flex-direction: column;\n height: 100%;\n min-width: 0;\n overflow: hidden;\n background: var(--pd-surface);\n color: var(--pd-text);\n font-size: var(--pd-primary-font-size, 13px);\n}\n.cc-print-pivot-fields section {\n min-height: 0;\n box-sizing: border-box;\n}\n.cc-print-pivot-fields__catalog {\n display: flex;\n flex: 0 0 39%;\n flex-direction: column;\n}\n.cc-print-pivot-fields__zones {\n display: flex;\n flex: 1 1 0;\n flex-direction: column;\n padding-top: 12px;\n}\n.cc-print-pivot-fields p {\n margin: 4px 0 8px;\n color: var(--pd-muted);\n font-size: var(--pd-label-font-size, 12px);\n}\n.cc-print-pivot-fields__catalog-list {\n min-height: 0;\n margin-top: 7px;\n overflow: auto;\n}\n.cc-print-pivot-fields__field,\n.cc-print-pivot-fields__area-field {\n display: grid;\n height: 28px;\n align-items: center;\n column-gap: 6px;\n box-sizing: border-box;\n}\n.cc-print-pivot-fields__field:hover,\n.cc-print-pivot-fields__area-field:hover {\n background: var(--pd-hover);\n}\n.cc-print-pivot-fields__field {\n grid-template-columns: 10px 16px minmax(0, 1fr);\n padding: 0 8px 0 6px;\n cursor: grab;\n}\n.cc-print-pivot-fields__field[data-dragging] {\n opacity: 0.45;\n}\n.cc-print-pivot-fields__field > span:last-child,\n.cc-print-pivot-fields__area-field > span:nth-child(2) {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.cc-print-pivot-fields__grip {\n width: 8px;\n height: 12px;\n background-image:\n radial-gradient(\n circle at 2px 2px,\n var(--pd-muted) 1px,\n transparent 1.2px);\n background-size: 4px 4px;\n cursor: grab;\n}\n.cc-print-pivot-fields__grid {\n display: grid;\n min-height: 0;\n grid-template-columns: repeat(2, minmax(0, 1fr));\n grid-template-rows: repeat(2, minmax(0, 1fr));\n gap: 8px;\n flex: 1;\n}\n.cc-print-pivot-fields__zone {\n display: flex;\n min-height: 0;\n min-width: 0;\n flex-direction: column;\n}\n.cc-print-pivot-fields__zone > strong {\n margin-bottom: 4px;\n font-size: 12px;\n}\n.cc-print-pivot-fields__drop {\n min-height: 0;\n flex: 1;\n overflow: auto;\n border: 1px solid var(--pd-border);\n border-radius: 3px;\n background: var(--pd-surface);\n}\n.cc-print-pivot-fields__drop[data-drag-over] {\n border-color: var(--pd-primary);\n background: var(--pd-selected);\n}\n.cc-print-pivot-fields__area-field {\n grid-template-columns: 9px minmax(0, 1fr) 18px;\n padding: 0 7px 0 5px;\n}\n.cc-print-pivot-fields__menu-trigger {\n display: grid;\n width: 18px;\n height: 22px;\n padding: 0;\n place-items: center;\n border: 0;\n background: transparent;\n cursor: pointer;\n}\n.cc-print-pivot-fields__menu-trigger > span {\n width: 0;\n height: 0;\n border-top: 5px solid currentColor;\n border-right: 4px solid transparent;\n border-left: 4px solid transparent;\n}\n.cc-print-pivot-fields__empty {\n display: block;\n padding: 10px 3px;\n color: var(--pd-muted);\n font-size: var(--pd-label-font-size, 12px);\n}\n.cc-print-pivot-fields__menu,\n.cc-print-pivot-fields__settings {\n color: var(--pd-text, #263244);\n font-family:\n "Segoe UI",\n "Microsoft YaHei",\n sans-serif;\n font-size: var(--pd-primary-font-size, 13px);\n}\n.cc-print-pivot-fields__menu button,\n.cc-print-pivot-fields__settings button,\n.cc-print-pivot-fields__settings input {\n font: inherit;\n}\n.cc-print-pivot-fields__menu {\n min-width: 176px;\n padding: 5px 0;\n}\n.cc-print-pivot-fields__menu button {\n display: block;\n width: 100%;\n height: 30px;\n padding: 0 12px;\n border: 0;\n background: transparent;\n text-align: left;\n cursor: pointer;\n}\n.cc-print-pivot-fields__menu button:hover:not(:disabled) {\n background: var(--pd-selected);\n}\n.cc-print-pivot-fields__menu button:disabled {\n color: #a7abb2;\n cursor: default;\n}\n.cc-print-pivot-fields__separator {\n height: 1px;\n margin: 4px 0;\n background: var(--pd-divider);\n}\n.cc-print-pivot-fields__settings {\n display: grid;\n min-width: 260px;\n gap: 12px;\n padding: 14px;\n}\n.cc-print-pivot-fields__settings label:not(.canvas-react-checkbox) {\n display: grid;\n gap: 5px;\n}\n.cc-print-pivot-fields__settings-actions {\n display: flex;\n justify-content: flex-end;\n gap: 8px;\n}\n.cc-print-design-nested-repeat > strong {\n display: block;\n margin: 8px 0 4px;\n}\n.cc-print-design-task-title {\n padding: 8px;\n font-weight: 600;\n}\n.cc-print-design-task-dependency-row {\n display: grid;\n grid-template-columns: repeat(2, minmax(0, 1fr));\n gap: 8px;\n padding: 8px 0;\n border-top: 1px solid #e7edf5;\n}\n.cc-print-design-task-dependency-row > * {\n min-width: 0;\n}\n.cc-print-design-ai-panel {\n display: flex;\n flex-direction: column;\n width: 100%;\n height: 100%;\n min-width: 0;\n min-height: 0;\n background: var(--pd-surface, #fff);\n color: var(--pd-text, #263244);\n border-left: 1px solid var(--pd-border, #e4e8ef);\n}\n.cc-print-design-ai-header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n box-sizing: border-box;\n height: var(--pd-panel-header-height, 36px);\n flex: 0 0 var(--pd-panel-header-height, 36px);\n padding: 0 12px;\n border-bottom: 1px solid var(--pd-border, #e4e8ef);\n}\n.cc-print-design-ai-header > div {\n display: flex;\n align-items: center;\n gap: 8px;\n}\n.cc-print-design-ai-panel button {\n cursor: pointer;\n font: inherit;\n}\n.cc-print-design-ai-header button,\n.cc-print-design-ai-composer-more {\n border: 0;\n background: transparent;\n color: inherit;\n}\n.cc-print-design-ai-messages {\n flex: 1;\n min-height: 0;\n overflow: auto;\n overscroll-behavior: contain;\n}\n.cc-print-design-ai-message {\n box-sizing: border-box;\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n padding: 9px 12px;\n}\n.cc-print-design-ai-message-user {\n align-items: flex-end;\n}\n.cc-print-design-ai-message > span {\n display: block;\n max-width: 85%;\n margin-bottom: 4px;\n color: var(--pd-muted, #8993a2);\n font-size: 11px;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.cc-print-design-ai-message p {\n margin: 0;\n max-width: min(85%, 680px);\n padding: 10px;\n border-radius: 10px;\n background: var(--pd-hover, #f5f7fa);\n white-space: pre-wrap;\n overflow-wrap: anywhere;\n line-height: 1.5;\n}\n.cc-print-design-ai-message-user p {\n background: var(--pd-selected, #edf4ff);\n}\n.cc-print-design-ai-artifact {\n display: flex;\n flex-direction: column;\n gap: 3px;\n max-width: min(85%, 680px);\n margin-top: 7px;\n padding: 10px 12px;\n border: 1px solid var(--pd-border, #e4e8ef);\n border-radius: 10px;\n color: inherit;\n text-decoration: none;\n background: var(--pd-hover, #f5f7fa);\n cursor: pointer;\n text-align: left;\n font: inherit;\n}\n.cc-print-design-ai-artifact:hover {\n border-color: #5b8def;\n}\n.cc-print-design-ai-artifact small {\n color: var(--pd-muted, #64748b);\n line-height: 1.4;\n}\n.cc-print-design-ai-artifact span:last-child {\n color: #2563eb;\n}\n.cc-print-design-ai-reasoning {\n box-sizing: border-box;\n width: min(85%, 680px);\n max-width: 100%;\n margin-bottom: 6px;\n border: 1px solid var(--pd-border, #e4e8ef);\n border-radius: 8px;\n background: var(--pd-hover, #f5f7fa);\n}\n.cc-print-design-ai-reasoning-trigger {\n display: flex;\n align-items: center;\n gap: 6px;\n width: 100%;\n padding: 7px 10px;\n border: 0;\n background: transparent;\n color: var(--pd-muted, #8993a2);\n text-align: left;\n cursor: pointer;\n}\n.cc-print-design-ai-reasoning-trigger > svg {\n flex: 0 0 auto;\n transition: transform 180ms ease;\n}\n.cc-print-design-ai-reasoning-trigger[aria-expanded=true] > svg {\n transform: rotate(90deg);\n}\n.cc-print-design-ai-reasoning-trigger:focus-visible {\n outline: 2px solid var(--pd-primary, #1677ff);\n outline-offset: -2px;\n}\n.cc-print-design-ai-reasoning-content {\n max-height: 180px;\n overflow: auto;\n padding: 0 10px 10px;\n font-size: 12px;\n line-height: 1.5;\n white-space: pre-wrap;\n overflow-wrap: anywhere;\n}\n@media (prefers-reduced-motion: reduce) {\n .cc-print-design-ai-reasoning-trigger > svg {\n transition: none;\n }\n}\n.cc-print-design-ai-message-thinking .cc-print-design-ai-thinking-indicator {\n display: inline-flex;\n align-items: center;\n gap: 8px;\n color: var(--pd-muted, #8993a2);\n}\n.cc-print-design-ai-thinking-dots {\n display: inline-flex;\n align-items: center;\n gap: 3px;\n}\n.cc-print-design-ai-thinking-dots i {\n width: 5px;\n height: 5px;\n border-radius: 50%;\n background: currentColor;\n animation: cc-print-design-ai-thinking 1s ease-in-out infinite;\n}\n.cc-print-design-ai-thinking-dots i:nth-child(2) {\n animation-delay: 0.16s;\n}\n.cc-print-design-ai-thinking-dots i:nth-child(3) {\n animation-delay: 0.32s;\n}\n.cc-print-design-ai-message-thinking.is-paused .cc-print-design-ai-thinking-dots i {\n animation-play-state: paused;\n}\n@keyframes cc-print-design-ai-thinking {\n 0%, 60%, 100% {\n opacity: 0.35;\n transform: translateY(0);\n }\n 30% {\n opacity: 1;\n transform: translateY(-3px);\n }\n}\n@media (prefers-reduced-motion: reduce) {\n .cc-print-design-ai-thinking-dots i {\n animation: none;\n }\n}\n.cc-print-design-ai-settings {\n display: grid;\n gap: 8px;\n padding: 12px;\n border-top: 1px solid var(--pd-border, #e4e8ef);\n max-height: 48%;\n overflow: auto;\n}\n.cc-print-design-ai-settings label {\n display: grid;\n gap: 4px;\n}\n.cc-print-design-ai-composer textarea {\n box-sizing: border-box;\n width: 100%;\n padding: 8px;\n border: 1px solid var(--pd-border, #e4e8ef);\n border-radius: 6px;\n background: var(--pd-surface, #fff);\n color: inherit;\n font: inherit;\n}\n.cc-print-design-ai-settings-actions {\n display: flex;\n justify-content: flex-end;\n gap: 8px;\n}\n.cc-print-design-ai-key-row {\n display: flex;\n align-items: end;\n gap: 8px;\n}\n.cc-print-design-ai-key-row label {\n flex: 1;\n min-width: 0;\n}\n.cc-print-design-ai-key-row button {\n flex: 0 0 auto;\n white-space: nowrap;\n}\n.cc-print-design-ai-width-fields {\n display: grid;\n grid-template-columns: repeat(3, minmax(0, 1fr));\n gap: 6px;\n}\n.cc-print-design-ai-profile-picker {\n display: flex;\n align-items: end;\n gap: 8px;\n}\n.cc-print-design-ai-profile-picker label {\n flex: 1;\n min-width: 0;\n}\n.cc-print-design-ai-profile-picker button {\n height: 34px;\n}\n.cc-print-design-ai-dialog-layout {\n display: flex;\n height: 100%;\n min-height: 0;\n}\n.cc-print-design-ai-dialog-nav {\n display: flex;\n width: 150px;\n flex: 0 0 150px;\n flex-direction: column;\n gap: 4px;\n padding: 14px 8px;\n border-right: 1px solid var(--pd-border, #e4e8ef);\n background: var(--pd-hover, #f5f7fa);\n}\n.cc-print-design-ai-dialog-nav button {\n padding: 10px 12px;\n border: 0;\n border-radius: 6px;\n background: transparent;\n text-align: left;\n cursor: pointer;\n}\n.cc-print-design-ai-dialog-nav button[aria-current=page] {\n background: var(--pd-selected, #edf4ff);\n color: var(--pd-primary, #1677ff);\n}\n.cc-print-design-ai-dialog-content {\n flex: 1;\n min-width: 0;\n min-height: 0;\n overflow: auto;\n}\n.cc-print-design-ai-dialog .cc-print-design-ai-settings {\n max-height: none;\n border-top: 0;\n}\n.cc-print-design-ai-history {\n min-height: 140px;\n max-height: none;\n overflow: auto;\n padding: 8px 0;\n}\n.cc-print-design-ai-history > p {\n color: var(--pd-muted, #8993a2);\n text-align: center;\n}\n.cc-print-design-ai-history-item {\n display: flex;\n align-items: center;\n gap: 8px;\n border-bottom: 1px solid var(--pd-border, #e4e8ef);\n}\n.cc-print-design-ai-history-item > button:first-child {\n display: flex;\n flex: 1;\n min-width: 0;\n flex-direction: column;\n align-items: flex-start;\n gap: 4px;\n padding: 9px 10px;\n border: 0;\n background: transparent;\n text-align: left;\n cursor: pointer;\n}\n.cc-print-design-ai-history-item > button:first-child.active {\n color: var(--pd-primary, #1677ff);\n}\n.cc-print-design-ai-history-item span {\n overflow: hidden;\n max-width: 100%;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.cc-print-design-ai-history-item small {\n color: var(--pd-muted, #8993a2);\n}\n.cc-print-design-ai-history-delete {\n border: 0;\n background: transparent;\n color: var(--pd-danger, #dc2626);\n cursor: pointer;\n}\n.cc-print-design-ai-composer {\n padding: 10px;\n border-top: 1px solid var(--pd-border, #e4e8ef);\n}\n.cc-print-design-ai-attachments,\n.cc-print-design-ai-message-attachments {\n display: flex;\n flex-wrap: wrap;\n gap: 6px;\n min-width: 0;\n}\n.cc-print-design-ai-attachments {\n max-height: 116px;\n margin-bottom: 8px;\n overflow: auto;\n}\n.cc-print-design-ai-attachment {\n display: flex;\n align-items: center;\n gap: 5px;\n max-width: 100%;\n padding: 4px 6px;\n border: 1px solid var(--pd-border, #e4e8ef);\n border-radius: 6px;\n font-size: 11px;\n}\n.cc-print-design-ai-attachment .cc-print-design-ai-image-trigger img {\n width: 28px;\n height: 28px;\n object-fit: cover;\n}\n.cc-print-design-ai-panel .cc-print-design-ai-image-trigger {\n display: block;\n padding: 0;\n border: 0;\n border-radius: 5px;\n background: transparent;\n cursor: zoom-in;\n}\n.cc-print-design-ai-image-trigger:focus-visible {\n outline: 2px solid var(--pd-primary, #1677ff);\n outline-offset: 2px;\n}\n.cc-print-design-ai-attachment > span:nth-last-child(2) {\n overflow: hidden;\n max-width: 145px;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.cc-print-design-ai-attachment > button {\n border: 0;\n background: transparent;\n cursor: pointer;\n}\n.cc-print-design-ai-message-attachments {\n margin-top: 7px;\n}\n.cc-print-design-ai-message-user .cc-print-design-ai-message-attachments {\n align-self: flex-end;\n justify-content: flex-end;\n max-width: min(85%, 680px);\n margin-left: auto;\n}\n.cc-print-design-ai-message-attachments figure {\n display: flex;\n flex-direction: column;\n align-items: flex-end;\n max-width: 100%;\n margin: 0;\n}\n.cc-print-design-ai-message-attachments .cc-print-design-ai-image-trigger {\n max-width: min(100%, 240px);\n}\n.cc-print-design-ai-message-attachments img {\n display: block;\n max-width: min(100%, 240px);\n max-height: 180px;\n border-radius: 5px;\n object-fit: contain;\n}\n.cc-print-design-ai-message-attachments figcaption,\n.cc-print-design-ai-message-attachments > span {\n overflow: hidden;\n max-width: 100%;\n color: var(--pd-muted, #8993a2);\n font-size: 11px;\n text-overflow: ellipsis;\n text-align: right;\n white-space: nowrap;\n}\n.cc-print-design-ai-composer-attach {\n display: grid;\n flex: 0 0 30px;\n width: 30px;\n height: 30px;\n place-items: center;\n border: 0;\n border-radius: 5px;\n background: transparent;\n color: inherit;\n cursor: pointer;\n}\n.cc-print-design-ai-composer-attach:hover {\n background: var(--pd-hover, #f5f7fa);\n}\n.cc-print-design-ai-selection {\n min-width: 0;\n margin-bottom: 8px;\n color: var(--pd-muted, #8993a2);\n font-size: 11px;\n}\n.cc-print-design-ai-selection-items {\n display: flex;\n flex-wrap: wrap;\n gap: 5px;\n max-height: 80px;\n margin-top: 5px;\n overflow: auto;\n}\n.cc-print-design-ai-selection-item {\n max-width: 100%;\n}\n.cc-print-design-ai-selection-item strong,\n.cc-print-design-ai-selection-item small {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.cc-print-design-ai-selection-item strong {\n flex: 0 0 auto;\n max-width: 115px;\n}\n.cc-print-design-ai-selection-item small {\n flex: 1 1 auto;\n min-width: 0;\n color: var(--pd-muted, #8993a2);\n}\n.cc-print-design-ai-composer textarea {\n resize: vertical;\n min-height: 70px;\n}\n.cc-print-design-ai-composer-tools {\n display: flex;\n align-items: center;\n gap: 8px;\n margin-top: 6px;\n}\n.cc-print-design-ai-composer-options {\n display: flex;\n flex: 1 1 auto;\n align-items: center;\n gap: 8px;\n min-width: 0;\n}\n.cc-print-design-ai-composer-options .canvas-react-select-wrap:first-child {\n flex: 1 1 auto;\n min-width: 0;\n}\n.cc-print-design-ai-composer-options .canvas-react-select-wrap:last-child {\n flex: 0 0 94px;\n min-width: 0;\n}\n.cc-print-design-ai-composer-actions {\n display: flex;\n flex: 0 0 auto;\n align-items: center;\n gap: 4px;\n margin-left: auto;\n}\n');
41
+ function useStorageKeyState(storageKey, createInitial) {
42
+ const initial = useMemo(createInitial, [storageKey]);
43
+ const [state, setState] = useState(() => ({ storageKey, value: initial }));
44
+ const activeKey = useRef(storageKey);
45
+ useLayoutEffect(() => {
46
+ activeKey.current = storageKey;
47
+ }, [storageKey]);
48
+ const setValue = useCallback(
49
+ (update) => {
50
+ if (activeKey.current !== storageKey) return;
51
+ setState((current) => {
52
+ if (activeKey.current !== storageKey) return current;
53
+ const value = current.storageKey === storageKey ? current.value : initial;
54
+ return {
55
+ storageKey,
56
+ value: typeof update === "function" ? update(value) : update
57
+ };
58
+ });
59
+ },
60
+ [storageKey, initial]
61
+ );
62
+ return [state.storageKey === storageKey ? state.value : initial, setValue];
63
+ }
39
64
  var conditionalOperators = {
40
65
  eq: "\u7B49\u4E8E",
41
66
  neq: "\u4E0D\u7B49\u4E8E",
@@ -4233,6 +4258,147 @@ function ReactListTablePrintProvider(props) {
4233
4258
  function useReactListTablePrintIntegration() {
4234
4259
  return useContext(PrintIntegrationContext);
4235
4260
  }
4261
+ function cancelRequest(session) {
4262
+ session.version++;
4263
+ if (session.timer !== void 0) clearTimeout(session.timer);
4264
+ session.timer = void 0;
4265
+ session.controller?.abort();
4266
+ session.controller = void 0;
4267
+ }
4268
+ function mergeOptions(records, getValue) {
4269
+ const values = /* @__PURE__ */ new Map();
4270
+ records.forEach((record) => values.set(getValue(record), record));
4271
+ return [...values.values()];
4272
+ }
4273
+ function useTableSelectOptions(options) {
4274
+ const { editorKey, config, active } = options;
4275
+ const request = config?.request;
4276
+ const pageSize = typeof config?.pageSize === "number" && Number.isFinite(config.pageSize) && config.pageSize >= 1 ? Math.floor(config.pageSize) : 30;
4277
+ const debounce = typeof config?.debounce === "number" && Number.isFinite(config.debounce) && config.debounce >= 0 ? config.debounce : 300;
4278
+ const sessionRef = useRef();
4279
+ const [, refresh] = useState(0);
4280
+ const previous = sessionRef.current;
4281
+ if (!previous || previous.editorKey !== editorKey || previous.active !== active || previous.request !== request || previous.getOptionValue !== config?.getOptionValue || previous.pageSize !== pageSize || previous.debounce !== debounce) {
4282
+ const sameEditor = previous?.editorKey === editorKey && previous.active && active;
4283
+ if (previous) {
4284
+ previous.alive = false;
4285
+ cancelRequest(previous);
4286
+ }
4287
+ sessionRef.current = {
4288
+ editorKey,
4289
+ active,
4290
+ request,
4291
+ getOptionValue: config?.getOptionValue,
4292
+ pageSize,
4293
+ debounce,
4294
+ alive: true,
4295
+ version: 0,
4296
+ keyword: sameEditor ? previous.keyword : options.initialKeyword ?? "",
4297
+ page: 0,
4298
+ dataSource: config?.dataSource ?? [],
4299
+ loading: active && !!request,
4300
+ hasMore: false
4301
+ };
4302
+ }
4303
+ const session = sessionRef.current;
4304
+ const isCurrent = useCallback(
4305
+ () => session.alive && session.active && sessionRef.current === session,
4306
+ [session]
4307
+ );
4308
+ const notify = useCallback(() => {
4309
+ if (isCurrent()) refresh((value) => value + 1);
4310
+ }, [isCurrent]);
4311
+ const load = useCallback(
4312
+ (page, wait) => {
4313
+ if (!isCurrent() || !session.request || !session.getOptionValue) return;
4314
+ cancelRequest(session);
4315
+ const version = session.version;
4316
+ session.loading = true;
4317
+ session.error = void 0;
4318
+ session.failedPage = void 0;
4319
+ notify();
4320
+ const run = async () => {
4321
+ session.timer = void 0;
4322
+ if (!isCurrent() || session.version !== version) return;
4323
+ const controller = new AbortController();
4324
+ session.controller = controller;
4325
+ try {
4326
+ const result = await session.request({
4327
+ keyword: session.keyword,
4328
+ page,
4329
+ pageSize: session.pageSize,
4330
+ signal: controller.signal
4331
+ });
4332
+ if (!isCurrent() || session.version !== version || controller.signal.aborted)
4333
+ return;
4334
+ if (!result || !Array.isArray(result.data) || typeof result.hasMore !== "boolean")
4335
+ throw new Error("\u5019\u9009\u67E5\u8BE2\u7ED3\u679C\u683C\u5F0F\u65E0\u6548");
4336
+ session.dataSource = mergeOptions(
4337
+ page === 1 ? result.data : [...session.dataSource, ...result.data],
4338
+ session.getOptionValue
4339
+ );
4340
+ session.page = page;
4341
+ session.hasMore = result.hasMore;
4342
+ } catch (error) {
4343
+ if (!isCurrent() || session.version !== version || controller.signal.aborted)
4344
+ return;
4345
+ session.error = error instanceof Error ? error : new Error(
4346
+ typeof error === "string" ? error : "\u5019\u9009\u67E5\u8BE2\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5"
4347
+ );
4348
+ session.failedPage = page;
4349
+ } finally {
4350
+ if (isCurrent() && session.version === version) {
4351
+ session.controller = void 0;
4352
+ session.loading = false;
4353
+ notify();
4354
+ }
4355
+ }
4356
+ };
4357
+ if (wait && session.debounce > 0)
4358
+ session.timer = setTimeout(() => {
4359
+ void run();
4360
+ }, session.debounce);
4361
+ else void run();
4362
+ },
4363
+ [session, isCurrent, notify]
4364
+ );
4365
+ useEffect(() => {
4366
+ session.alive = true;
4367
+ if (session.active && session.request) load(1, false);
4368
+ return () => {
4369
+ session.alive = false;
4370
+ cancelRequest(session);
4371
+ };
4372
+ }, [session, load]);
4373
+ const onSearch = useCallback(
4374
+ (keyword) => {
4375
+ if (!isCurrent() || !session.request || session.keyword === keyword)
4376
+ return;
4377
+ session.keyword = keyword;
4378
+ load(1, true);
4379
+ },
4380
+ [session, isCurrent, load]
4381
+ );
4382
+ const onLoadMore = useCallback(() => {
4383
+ if (!isCurrent() || !session.request || session.loading || session.error || !session.hasMore)
4384
+ return;
4385
+ load(session.page + 1, false);
4386
+ }, [session, isCurrent, load]);
4387
+ const retry = useCallback(() => {
4388
+ if (!isCurrent() || !session.request || session.loading || !session.error)
4389
+ return;
4390
+ load(session.failedPage ?? 1, false);
4391
+ }, [session, isCurrent, load]);
4392
+ return {
4393
+ dataSource: request && active ? session.dataSource : config?.dataSource ?? [],
4394
+ loading: active && !!request && session.loading,
4395
+ error: active && request ? session.error : void 0,
4396
+ hasMore: active && !!request && session.hasMore,
4397
+ onSearch,
4398
+ onLoadMore,
4399
+ retry
4400
+ };
4401
+ }
4236
4402
 
4237
4403
  // src/features/editor/utils.ts
4238
4404
  function toNumberValue(value) {
@@ -4318,18 +4484,872 @@ function resolveEditorOverlayStyle(params) {
4318
4484
  } : null
4319
4485
  };
4320
4486
  }
4487
+ function CompositeItemEditor(props) {
4488
+ const { item, value, onValueChange, initialText } = props;
4489
+ const base = {
4490
+ disabled: item.disabled,
4491
+ readOnly: item.readOnly,
4492
+ "aria-label": item.label ?? item.key,
4493
+ "aria-invalid": props.feedback?.length ? true : void 0,
4494
+ style: {
4495
+ width: "100%",
4496
+ height: "100%",
4497
+ minHeight: 0,
4498
+ border: 0,
4499
+ borderRadius: 0,
4500
+ boxShadow: "none",
4501
+ ...props.style
4502
+ }
4503
+ };
4504
+ const numeric = {
4505
+ min: toNumericProp(item.min),
4506
+ max: toNumericProp(item.max),
4507
+ step: toNumericProp(item.step),
4508
+ precision: item.precision
4509
+ };
4510
+ const scalar = typeof value === "number" || typeof value === "string" ? value : void 0;
4511
+ const text = value == null ? "" : String(value);
4512
+ const stringRange = Array.isArray(value) ? [String(value[0] ?? ""), String(value[1] ?? "")] : ["", ""];
4513
+ const numberRange = Array.isArray(value) ? [toNumberValue(value[0]), toNumberValue(value[1])] : [null, null];
4514
+ const date = {
4515
+ ...base,
4516
+ value: text,
4517
+ allowClear: item.allowClear ?? false,
4518
+ showArrow: false,
4519
+ onChange: (next) => onValueChange(next, { trigger: "change" })
4520
+ };
4521
+ const range = {
4522
+ ...base,
4523
+ value: stringRange,
4524
+ allowClear: item.allowClear ?? false,
4525
+ rangeSeparator: item.rangeSeparator,
4526
+ onChange: (next) => onValueChange(next, { trigger: "change" })
4527
+ };
4528
+ switch (item.valueType ?? "text") {
4529
+ case "number":
4530
+ return /* @__PURE__ */ jsx(
4531
+ ReactInputNumber,
4532
+ {
4533
+ ...base,
4534
+ ...numeric,
4535
+ initialText: initialText ?? (typeof value === "string" ? value : void 0),
4536
+ placeholder: item.placeholder,
4537
+ value: toNumberValue(value),
4538
+ onChange: (next) => onValueChange(next, { trigger: "input" })
4539
+ }
4540
+ );
4541
+ case "select":
4542
+ return /* @__PURE__ */ jsx(
4543
+ ReactSelect,
4544
+ {
4545
+ ...base,
4546
+ value: scalar,
4547
+ options: item.options ?? [],
4548
+ allowClear: item.allowClear,
4549
+ showSearch: item.showSearch ?? initialText !== void 0,
4550
+ filterOption: item.filterOption,
4551
+ initialSearchValue: initialText,
4552
+ placeholder: item.placeholder,
4553
+ onChange: (next, meta) => {
4554
+ const option = item.options?.find(
4555
+ (option2) => String(option2.value) === String(next)
4556
+ );
4557
+ onValueChange(option?.value ?? next, { ...meta, option });
4558
+ }
4559
+ }
4560
+ );
4561
+ case "auto-complete":
4562
+ return /* @__PURE__ */ jsx(CompositeAutoComplete, { ...props, style: base.style });
4563
+ case "table-select":
4564
+ return /* @__PURE__ */ jsx(CompositeTableSelect, { ...props });
4565
+ case "year":
4566
+ return /* @__PURE__ */ jsx(ReactYearPicker, { ...date });
4567
+ case "quarter":
4568
+ return /* @__PURE__ */ jsx(ReactQuarterPicker, { ...date });
4569
+ case "month":
4570
+ return /* @__PURE__ */ jsx(ReactMonthPicker, { ...date });
4571
+ case "date":
4572
+ return /* @__PURE__ */ jsx(ReactDatePicker, { ...date });
4573
+ case "time":
4574
+ return /* @__PURE__ */ jsx(ReactTimePicker, { ...date });
4575
+ case "datetime":
4576
+ return /* @__PURE__ */ jsx(ReactDateTimePicker, { ...date });
4577
+ case "date-range":
4578
+ return /* @__PURE__ */ jsx(ReactDateRangePicker, { ...range });
4579
+ case "timerange":
4580
+ return /* @__PURE__ */ jsx(
4581
+ ReactTimeRangePicker,
4582
+ {
4583
+ ...base,
4584
+ value: stringRange,
4585
+ rangeSeparator: item.rangeSeparator,
4586
+ onChange: range.onChange
4587
+ }
4588
+ );
4589
+ case "datetime-range":
4590
+ return /* @__PURE__ */ jsx(ReactDateTimeRangePicker, { ...range });
4591
+ case "input-range":
4592
+ return /* @__PURE__ */ jsx(
4593
+ ReactInputRange,
4594
+ {
4595
+ initialText,
4596
+ ...base,
4597
+ ...numeric,
4598
+ value: numberRange,
4599
+ rangeSeparator: item.rangeSeparator,
4600
+ onChange: (next) => onValueChange(next, { trigger: "input" })
4601
+ }
4602
+ );
4603
+ case "math-interval":
4604
+ return /* @__PURE__ */ jsx(
4605
+ ReactMathInterval,
4606
+ {
4607
+ ...base,
4608
+ ...numeric,
4609
+ value: normalizeMathInterval(value),
4610
+ initialText,
4611
+ onChange: (next) => onValueChange(next, { trigger: "input" })
4612
+ }
4613
+ );
4614
+ case "number-unit":
4615
+ return /* @__PURE__ */ jsx(
4616
+ ReactInputNumberUnit,
4617
+ {
4618
+ ...base,
4619
+ ...numeric,
4620
+ value: normalizeNumberUnit$1(value, item.numberUnit?.unit),
4621
+ initialText,
4622
+ placeholder: item.placeholder,
4623
+ unit: item.numberUnit?.unit,
4624
+ unitOptions: item.numberUnit?.options,
4625
+ unitWidth: item.numberUnit?.unitWidth,
4626
+ unitRequired: item.numberUnit?.unitRequired,
4627
+ unitPlaceholder: item.numberUnit?.unitPlaceholder,
4628
+ onChange: onValueChange
4629
+ }
4630
+ );
4631
+ default:
4632
+ return /* @__PURE__ */ jsx(
4633
+ ReactInput,
4634
+ {
4635
+ ...base,
4636
+ value: text,
4637
+ placeholder: item.placeholder,
4638
+ allowClear: item.allowClear,
4639
+ onChange: (event) => onValueChange(event.target.value, { trigger: "input" })
4640
+ }
4641
+ );
4642
+ }
4643
+ }
4644
+ function CompositeTableSelect(props) {
4645
+ const config = props.item.tableSelect;
4646
+ const options = useTableSelectOptions({
4647
+ editorKey: JSON.stringify([props.editorKey, props.item.key]),
4648
+ config,
4649
+ active: !props.item.disabled,
4650
+ initialKeyword: props.initialText
4651
+ });
4652
+ const generation = useRef(0);
4653
+ useEffect(() => {
4654
+ generation.current++;
4655
+ return () => {
4656
+ generation.current++;
4657
+ };
4658
+ }, [props.editorKey, props.item.key, config?.onCreate]);
4659
+ if (!config) return /* @__PURE__ */ jsx("span", { role: "alert", children: "\u591A\u5217\u9009\u62E9\u7F3A\u5C11\u5019\u9009\u914D\u7F6E" });
4660
+ const {
4661
+ request,
4662
+ debounce,
4663
+ pageSize,
4664
+ dataSource,
4665
+ columns,
4666
+ onCreate,
4667
+ ...component
4668
+ } = config;
4669
+ const mapped = columns.map(
4670
+ ({ format, ...column }) => ({
4671
+ ...column,
4672
+ render: format ? (value, record, index) => {
4673
+ const result = format(value, record, index);
4674
+ return typeof result === "boolean" ? String(result) : result;
4675
+ } : void 0
4676
+ })
4677
+ );
4678
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
4679
+ /* @__PURE__ */ jsx(
4680
+ ReactTableSelect,
4681
+ {
4682
+ ...component,
4683
+ columns: mapped,
4684
+ dataSource: options.dataSource,
4685
+ value: typeof props.value === "string" || typeof props.value === "number" ? props.value : void 0,
4686
+ disabled: props.item.disabled,
4687
+ readOnly: props.item.readOnly,
4688
+ "aria-label": props.item.label ?? props.item.key,
4689
+ "aria-invalid": !!props.feedback?.length || void 0,
4690
+ placeholder: props.item.placeholder,
4691
+ allowClear: props.item.allowClear,
4692
+ showSearch: props.item.showSearch,
4693
+ initialSearchValue: props.initialText,
4694
+ filterOption: request ? false : config.filterOption,
4695
+ loading: options.loading,
4696
+ hasMore: options.hasMore,
4697
+ onLoadMore: options.onLoadMore,
4698
+ onSearch: options.onSearch,
4699
+ allowCreate: !!config.allowCreate && !options.loading && !options.error,
4700
+ onCreate: onCreate ? async (keyword) => {
4701
+ const epoch = generation.current;
4702
+ const next = await onCreate(keyword);
4703
+ return epoch === generation.current ? next : void 0;
4704
+ } : void 0,
4705
+ onChange: (next, option, info) => props.onValueChange(next, {
4706
+ trigger: info.trigger,
4707
+ ...info.trigger === "clear" ? {} : { option }
4708
+ }),
4709
+ style: { width: "100%", height: "100%", border: 0, ...props.style }
4710
+ }
4711
+ ),
4712
+ options.error && /* @__PURE__ */ jsxs("div", { role: "alert", children: [
4713
+ options.error.message,
4714
+ /* @__PURE__ */ jsx("button", { type: "button", onClick: options.retry, children: "\u91CD\u8BD5\u67E5\u8BE2" })
4715
+ ] })
4716
+ ] });
4717
+ }
4718
+ function CompositeAutoComplete(props) {
4719
+ const { item } = props;
4720
+ const options = useRef(item.options ?? []), epoch = useRef(0), alive = useRef(true);
4721
+ useEffect(() => {
4722
+ options.current = item.options ?? [];
4723
+ }, [item.options]);
4724
+ useEffect(() => {
4725
+ alive.current = true;
4726
+ epoch.current++;
4727
+ return () => {
4728
+ alive.current = false;
4729
+ epoch.current++;
4730
+ };
4731
+ }, [props.editorKey, item.key]);
4732
+ return /* @__PURE__ */ jsx(
4733
+ ReactAutoComplete,
4734
+ {
4735
+ value: typeof props.value === "number" || typeof props.value === "string" ? props.value : void 0,
4736
+ options: item.options ?? [],
4737
+ filterOption: item.filterOption,
4738
+ initialSearchValue: props.initialText,
4739
+ disabled: item.disabled,
4740
+ readOnly: item.readOnly,
4741
+ "aria-label": item.label ?? item.key,
4742
+ "aria-invalid": !!props.feedback?.length || void 0,
4743
+ style: props.style,
4744
+ allowClear: item.allowClear,
4745
+ placeholder: item.placeholder,
4746
+ onChange: (next, meta) => {
4747
+ if (alive.current)
4748
+ props.onValueChange(next, {
4749
+ ...meta,
4750
+ option: options.current.find(
4751
+ (option) => String(option.value) === String(next)
4752
+ )
4753
+ });
4754
+ },
4755
+ onPressEnter: async (input) => {
4756
+ const current = epoch.current;
4757
+ const next = await item.onPressEnter?.(input);
4758
+ if (!alive.current || current !== epoch.current) return;
4759
+ if (next) options.current = next;
4760
+ return next;
4761
+ }
4762
+ }
4763
+ );
4764
+ }
4765
+ function CompositeEditor({
4766
+ request,
4767
+ style
4768
+ }) {
4769
+ const items = request.config.items ?? [];
4770
+ const hostRef = useRef(null);
4771
+ const seeded = useRef();
4772
+ const [, refresh] = useState(0), local = useRef({});
4773
+ const source = useRef(request.value);
4774
+ if (source.current !== request.value) {
4775
+ source.current = request.value;
4776
+ local.current = {};
4777
+ }
4778
+ const leaving = useRef(false), version = useRef(0), current = useRef(request);
4779
+ current.current = request;
4780
+ const publish = (key, value, meta) => {
4781
+ local.current = { ...local.current, [key]: value };
4782
+ version.current++;
4783
+ leaving.current = false;
4784
+ refresh((next) => next + 1);
4785
+ request.onChange(value, {
4786
+ ...meta,
4787
+ trigger: meta?.trigger ?? "change",
4788
+ itemKey: key
4789
+ });
4790
+ };
4791
+ const leave = (direction) => {
4792
+ if (leaving.current || current.current.feedback?.pending) return;
4793
+ leaving.current = true;
4794
+ const epoch = version.current;
4795
+ const result = direction ? current.current.onNavigate?.(direction) : current.current.onCommit({ restoreTableFocus: true });
4796
+ if (result && typeof result.then === "function")
4797
+ void result.then(
4798
+ (accepted) => {
4799
+ if (accepted === false && version.current === epoch)
4800
+ leaving.current = false;
4801
+ },
4802
+ () => {
4803
+ if (version.current === epoch) leaving.current = false;
4804
+ }
4805
+ );
4806
+ };
4807
+ const zoom = request.theme.contentZoom ?? 1;
4808
+ const widths = resolveListTableEditorItemWidths(
4809
+ items,
4810
+ Math.max(0, ((request.hostRect ?? request.rect).width - 2) / zoom)
4811
+ );
4812
+ const scaledWidths = widths.map((width) => width * zoom);
4813
+ const values = request.value && typeof request.value === "object" ? request.value : {};
4814
+ const entry = items.find(
4815
+ (item) => item.key === request.initialItemKey && !item.disabled && !item.readOnly
4816
+ ) ?? items.find((item) => !item.disabled && !item.readOnly);
4817
+ useLayoutEffect(() => {
4818
+ const seedKey = JSON.stringify([request.editorKey, entry?.key]);
4819
+ if (seeded.current !== seedKey && request.initialText !== void 0 && entry && ["text", "auto-complete"].includes(entry.valueType ?? "text")) {
4820
+ seeded.current = seedKey;
4821
+ publish(entry.key, request.initialText, { trigger: "input" });
4822
+ }
4823
+ if (request.initialText === void 0 || entry?.valueType !== "math-interval")
4824
+ return;
4825
+ const slot = Array.from(
4826
+ hostRef.current?.querySelectorAll(
4827
+ "[data-input-group-item]"
4828
+ ) ?? []
4829
+ ).find((element) => element.dataset.inputGroupItem === entry.key);
4830
+ const input = slot?.querySelector(
4831
+ "[data-math-interval-control]"
4832
+ );
4833
+ input?.focus();
4834
+ if (input) {
4835
+ if (request.selectOnFocus === false)
4836
+ input.setSelectionRange(input.value.length, input.value.length);
4837
+ else input.select();
4838
+ }
4839
+ }, [request.editorKey]);
4840
+ return /* @__PURE__ */ jsx("div", { ref: hostRef, style, children: /* @__PURE__ */ jsx(
4841
+ ReactInputGroup,
4842
+ {
4843
+ initialItemKey: entry?.key,
4844
+ selectOnFocus: request.selectOnFocus,
4845
+ onLeave: () => leave(),
4846
+ onBoundaryTab: (direction) => leave(direction),
4847
+ onPressEnter: () => leave(),
4848
+ onCancel: () => {
4849
+ if (leaving.current) return;
4850
+ leaving.current = true;
4851
+ request.onCancel();
4852
+ },
4853
+ items: items.map((item, index) => {
4854
+ const errors = request.feedback?.itemErrors?.[item.key];
4855
+ const errorStyle = errors?.length ? {
4856
+ backgroundColor: "#ff4d4f",
4857
+ color: "#fff",
4858
+ ["--canvas-react-color-bg"]: "#ff4d4f",
4859
+ ["--canvas-react-color-text"]: "#fff",
4860
+ ["--canvas-react-color-text-muted"]: "#fff",
4861
+ ["--canvas-react-color-text-secondary"]: "#fff"
4862
+ } : {};
4863
+ return {
4864
+ key: item.key,
4865
+ width: scaledWidths[index],
4866
+ children: /* @__PURE__ */ jsx(
4867
+ "div",
4868
+ {
4869
+ "data-input-group-readonly": item.readOnly || void 0,
4870
+ onFocusCapture: (event) => {
4871
+ if (item.readOnly) event.stopPropagation();
4872
+ },
4873
+ onClickCapture: (event) => {
4874
+ if (item.readOnly) event.stopPropagation();
4875
+ },
4876
+ onKeyDownCapture: (event) => {
4877
+ if (item.readOnly && !["Tab", "Escape"].includes(event.key) && !event.ctrlKey && !event.metaKey) {
4878
+ event.preventDefault();
4879
+ event.stopPropagation();
4880
+ }
4881
+ },
4882
+ style: { height: "100%", ...errorStyle },
4883
+ "aria-invalid": !!errors?.length || void 0,
4884
+ children: /* @__PURE__ */ jsx(
4885
+ CompositeItemEditor,
4886
+ {
4887
+ item,
4888
+ value: Object.prototype.hasOwnProperty.call(
4889
+ local.current,
4890
+ item.key
4891
+ ) ? local.current[item.key] : values[item.key],
4892
+ editorKey: request.editorKey,
4893
+ initialText: entry?.key === item.key ? request.initialText : void 0,
4894
+ feedback: errors,
4895
+ style: {
4896
+ fontSize: request.theme.fontSize,
4897
+ fontFamily: request.theme.fontFamily,
4898
+ color: request.theme.textColor,
4899
+ ...errorStyle
4900
+ },
4901
+ onValueChange: (value, meta) => {
4902
+ if (!item.disabled && !item.readOnly)
4903
+ publish(item.key, value, meta);
4904
+ }
4905
+ }
4906
+ )
4907
+ }
4908
+ )
4909
+ };
4910
+ })
4911
+ }
4912
+ ) });
4913
+ }
4914
+
4915
+ // src/features/editor/editor-change.ts
4916
+ function publishEditorChange(request, value, meta = { trigger: "change" }) {
4917
+ if (!request.config.hasChangeHandler && request.config.valueType !== "table-select") {
4918
+ request.onChange(value);
4919
+ return;
4920
+ }
4921
+ const normalized = meta.trigger === "clear" ? { trigger: "clear" } : {
4922
+ trigger: meta.trigger ?? "change",
4923
+ ...meta.option !== void 0 ? { option: meta.option } : {},
4924
+ ...meta.options !== void 0 ? { options: meta.options } : {}
4925
+ };
4926
+ request.onChange(value, normalized);
4927
+ }
4928
+ function containsEditorInteraction(host, target, popupClassName) {
4929
+ if (!(target instanceof Node)) return false;
4930
+ if (host?.contains(target)) return true;
4931
+ if (!(target instanceof Element)) return false;
4932
+ const popup = target.closest(".canvas-react-popup");
4933
+ return !!popup && (!popupClassName || !!popup.querySelector(`.${popupClassName}`));
4934
+ }
4935
+
4936
+ // src/features/editor/use-composite-editor-session.ts
4937
+ function useCompositeEditorSession(request) {
4938
+ const hostRef = useRef(null), inputRef = useRef(null);
4939
+ const current = useRef(request);
4940
+ current.current = request;
4941
+ const leaving = useRef(false), version = useRef(0);
4942
+ useLayoutEffect(() => {
4943
+ const input = inputRef.current;
4944
+ if (!input) return;
4945
+ input.focus();
4946
+ if (request.selectOnFocus === false)
4947
+ input.setSelectionRange(input.value.length, input.value.length);
4948
+ else input.select();
4949
+ return () => {
4950
+ version.current++;
4951
+ };
4952
+ }, [request.editorKey]);
4953
+ const settle = (result, epoch) => {
4954
+ if (result && typeof result.then === "function")
4955
+ void result.then(
4956
+ (accepted) => {
4957
+ if (accepted === false && epoch === version.current)
4958
+ leaving.current = false;
4959
+ },
4960
+ () => {
4961
+ if (epoch === version.current) leaving.current = false;
4962
+ }
4963
+ );
4964
+ };
4965
+ const commit = () => {
4966
+ if (leaving.current) return;
4967
+ leaving.current = true;
4968
+ settle(
4969
+ current.current.onCommit({ restoreTableFocus: true }),
4970
+ version.current
4971
+ );
4972
+ };
4973
+ return {
4974
+ hostRef,
4975
+ inputRef,
4976
+ notifyChange(value, meta = { trigger: "input" }) {
4977
+ version.current++;
4978
+ leaving.current = false;
4979
+ publishEditorChange(current.current, value, meta);
4980
+ },
4981
+ onMouseDown(event) {
4982
+ if (event.target === event.currentTarget) event.preventDefault();
4983
+ },
4984
+ onBlur() {
4985
+ if (!leaving.current && !current.current.feedback?.pending) commit();
4986
+ },
4987
+ onKeyDown(event) {
4988
+ if (event.nativeEvent.isComposing) return;
4989
+ if (event.key === "Escape") {
4990
+ event.preventDefault();
4991
+ event.stopPropagation();
4992
+ version.current++;
4993
+ leaving.current = true;
4994
+ current.current.onCancel();
4995
+ return;
4996
+ }
4997
+ if (event.key === "Tab") {
4998
+ const controls = Array.from(
4999
+ hostRef.current?.querySelectorAll(
5000
+ "input:not(:disabled),select:not(:disabled)"
5001
+ ) ?? []
5002
+ );
5003
+ const index = controls.indexOf(event.target);
5004
+ const target = controls[index + (event.shiftKey ? -1 : 1)];
5005
+ event.preventDefault();
5006
+ event.stopPropagation();
5007
+ if (target) {
5008
+ target.focus();
5009
+ if (target instanceof HTMLInputElement) target.select();
5010
+ } else if (!current.current.feedback?.pending) {
5011
+ leaving.current = true;
5012
+ settle(
5013
+ current.current.onNavigate?.(event.shiftKey ? "prev" : "next"),
5014
+ version.current
5015
+ );
5016
+ }
5017
+ return;
5018
+ }
5019
+ if ([
5020
+ "ArrowUp",
5021
+ "ArrowDown",
5022
+ "ArrowLeft",
5023
+ "ArrowRight",
5024
+ "Home",
5025
+ "End"
5026
+ ].includes(event.key))
5027
+ event.stopPropagation();
5028
+ },
5029
+ onPressEnter(event) {
5030
+ event.preventDefault();
5031
+ event.stopPropagation();
5032
+ commit();
5033
+ }
5034
+ };
5035
+ }
5036
+ function NumberUnitEditor({
5037
+ request,
5038
+ style
5039
+ }) {
5040
+ const config = request.config.numberUnit;
5041
+ const [value, setValue] = useState(
5042
+ () => normalizeNumberUnit(request.value, config?.unit)
5043
+ );
5044
+ const session = useCompositeEditorSession(request);
5045
+ return /* @__PURE__ */ jsx("div", { ref: session.hostRef, style, onMouseDown: session.onMouseDown, children: /* @__PURE__ */ jsx(
5046
+ ReactInputNumberUnit,
5047
+ {
5048
+ ref: session.inputRef,
5049
+ value,
5050
+ initialText: request.initialText,
5051
+ unit: config?.unit,
5052
+ unitOptions: config?.options,
5053
+ unitWidth: config?.unitWidth,
5054
+ unitRequired: config?.unitRequired,
5055
+ unitPlaceholder: config?.unitPlaceholder,
5056
+ placeholder: request.config.placeholder,
5057
+ min: toNumericProp(request.config.min),
5058
+ max: toNumericProp(request.config.max),
5059
+ step: toNumericProp(request.config.step),
5060
+ precision: request.config.precision,
5061
+ style: getEditorInputStyle(request),
5062
+ onChange: (next, info) => {
5063
+ setValue(next);
5064
+ session.notifyChange(next, info);
5065
+ },
5066
+ onBlur: session.onBlur,
5067
+ onKeyDown: session.onKeyDown,
5068
+ onPressEnter: session.onPressEnter
5069
+ }
5070
+ ) });
5071
+ }
5072
+ function MathIntervalEditor({
5073
+ request,
5074
+ style
5075
+ }) {
5076
+ const [value, setValue] = useState(
5077
+ () => normalizeMathInterval(request.value)
5078
+ );
5079
+ const session = useCompositeEditorSession(request);
5080
+ return /* @__PURE__ */ jsx("div", { ref: session.hostRef, style, onMouseDown: session.onMouseDown, children: /* @__PURE__ */ jsx(
5081
+ ReactMathInterval,
5082
+ {
5083
+ ref: session.inputRef,
5084
+ value,
5085
+ initialText: request.initialText,
5086
+ min: toNumericProp(request.config.min),
5087
+ max: toNumericProp(request.config.max),
5088
+ step: toNumericProp(request.config.step),
5089
+ precision: request.config.precision,
5090
+ style: getEditorInputStyle(request),
5091
+ onChange: (next) => {
5092
+ setValue(next);
5093
+ session.notifyChange(next);
5094
+ },
5095
+ onBlur: session.onBlur,
5096
+ onKeyDown: session.onKeyDown,
5097
+ onPressEnter: session.onPressEnter
5098
+ }
5099
+ ) });
5100
+ }
5101
+ function TableSelectEditor({
5102
+ request,
5103
+ style
5104
+ }) {
5105
+ const config = request.config.tableSelect;
5106
+ const [value, setValue] = useState(
5107
+ toValue(request.value)
5108
+ );
5109
+ const [cancelled, setCancelled] = useState(false);
5110
+ const hostRef = useRef(null);
5111
+ const current = useRef(request);
5112
+ current.current = request;
5113
+ const mounted = useRef(true), creating = useRef(false), submitting = useRef(false), skipBlur = useRef(false), version = useRef(0);
5114
+ const popupClass = useRef(
5115
+ `react-list-table-table-select-${nextEditorIdentity++}`
5116
+ ).current;
5117
+ const options = useTableSelectOptions({
5118
+ editorKey: request.editorKey ?? popupClass,
5119
+ config,
5120
+ initialKeyword: request.selectOnFocus === false ? String(request.value ?? "") : void 0,
5121
+ active: !cancelled
5122
+ });
5123
+ useEffect(() => {
5124
+ mounted.current = true;
5125
+ return () => {
5126
+ mounted.current = false;
5127
+ version.current++;
5128
+ };
5129
+ }, []);
5130
+ useEffect(() => {
5131
+ setValue(toValue(request.value));
5132
+ }, [request.value]);
5133
+ const submit = (restoreTableFocus = false, afterChange = false) => {
5134
+ const active = current.current;
5135
+ if (cancelled || !mounted.current || submitting.current || active.feedback?.pending && !afterChange)
5136
+ return;
5137
+ const epoch = version.current;
5138
+ submitting.current = true;
5139
+ const result = active.onCommit(
5140
+ restoreTableFocus ? { restoreTableFocus: true } : void 0
5141
+ );
5142
+ if (result && typeof result.then === "function")
5143
+ void result.then(
5144
+ () => {
5145
+ if (mounted.current && version.current === epoch) {
5146
+ submitting.current = false;
5147
+ skipBlur.current = false;
5148
+ }
5149
+ },
5150
+ () => {
5151
+ if (mounted.current && version.current === epoch) {
5152
+ submitting.current = false;
5153
+ skipBlur.current = false;
5154
+ }
5155
+ }
5156
+ );
5157
+ else submitting.current = false;
5158
+ return result;
5159
+ };
5160
+ const submitRef = useRef(submit);
5161
+ submitRef.current = submit;
5162
+ useEffect(() => {
5163
+ const outside = (event) => {
5164
+ if (creating.current || cancelled || containsEditorInteraction(hostRef.current, event.target, popupClass))
5165
+ return;
5166
+ submitRef.current();
5167
+ };
5168
+ document.addEventListener("mousedown", outside, true);
5169
+ return () => document.removeEventListener("mousedown", outside, true);
5170
+ }, [popupClass, cancelled]);
5171
+ const navigate = (event) => {
5172
+ if (event.key !== "Tab" || !current.current.onNavigate) return;
5173
+ event.preventDefault();
5174
+ event.stopPropagation();
5175
+ if (current.current.feedback?.pending || submitting.current) return;
5176
+ skipBlur.current = true;
5177
+ submitting.current = true;
5178
+ const epoch = version.current;
5179
+ const result = current.current.onNavigate(event.shiftKey ? "prev" : "next");
5180
+ if (result && typeof result.then === "function")
5181
+ void result.then(
5182
+ () => {
5183
+ if (mounted.current && version.current === epoch) {
5184
+ submitting.current = false;
5185
+ skipBlur.current = false;
5186
+ }
5187
+ },
5188
+ () => {
5189
+ if (mounted.current && version.current === epoch) {
5190
+ submitting.current = false;
5191
+ skipBlur.current = false;
5192
+ }
5193
+ }
5194
+ );
5195
+ else submitting.current = false;
5196
+ };
5197
+ if (!config)
5198
+ return /* @__PURE__ */ jsx("div", { style, role: "alert", children: "\u591A\u5217\u9009\u62E9\u7F3A\u5C11\u5019\u9009\u914D\u7F6E" });
5199
+ const {
5200
+ request: remoteRequest,
5201
+ debounce,
5202
+ pageSize,
5203
+ dataSource,
5204
+ columns: sourceColumns,
5205
+ onCreate,
5206
+ ...componentConfig
5207
+ } = config;
5208
+ const columns = sourceColumns.map(
5209
+ ({ format, ...column }) => ({
5210
+ ...column,
5211
+ render: format ? (cell, record, index) => {
5212
+ const result = format(cell, record, index);
5213
+ return typeof result === "boolean" ? String(result) : result;
5214
+ } : void 0
5215
+ })
5216
+ );
5217
+ return /* @__PURE__ */ jsxs(
5218
+ "div",
5219
+ {
5220
+ ref: hostRef,
5221
+ style,
5222
+ onBlur: (event) => {
5223
+ if (creating.current || containsEditorInteraction(
5224
+ hostRef.current,
5225
+ event.relatedTarget,
5226
+ popupClass
5227
+ ) || current.current.feedback?.pending || submitting.current)
5228
+ return;
5229
+ if (skipBlur.current) {
5230
+ skipBlur.current = false;
5231
+ return;
5232
+ }
5233
+ submit();
5234
+ },
5235
+ onKeyDownCapture: (event) => {
5236
+ if (event.key === "Escape") {
5237
+ event.preventDefault();
5238
+ event.stopPropagation();
5239
+ version.current++;
5240
+ setCancelled(true);
5241
+ current.current.onCancel();
5242
+ }
5243
+ },
5244
+ onKeyDown: (event) => {
5245
+ if (event.target !== hostRef.current?.querySelector("input"))
5246
+ navigate(event);
5247
+ },
5248
+ children: [
5249
+ /* @__PURE__ */ jsx(
5250
+ ReactTableSelect,
5251
+ {
5252
+ ...componentConfig,
5253
+ dataSource: options.dataSource,
5254
+ columns,
5255
+ value,
5256
+ autoFocus: true,
5257
+ selectOnFocus: request.selectOnFocus,
5258
+ initialSearchValue: request.selectOnFocus === false ? String(request.value ?? "") : void 0,
5259
+ placeholder: request.config.placeholder,
5260
+ allowClear: request.config.allowClear,
5261
+ showSearch: request.config.showSearch,
5262
+ filterOption: remoteRequest ? false : config.filterOption,
5263
+ loading: options.loading,
5264
+ hasMore: options.hasMore,
5265
+ onLoadMore: options.onLoadMore,
5266
+ onSearch: options.onSearch,
5267
+ allowCreate: !!config.allowCreate && !options.loading && !options.error,
5268
+ popupClassName: popupClass,
5269
+ onCreate: onCreate ? async (keyword) => {
5270
+ const epoch = version.current;
5271
+ creating.current = true;
5272
+ try {
5273
+ const record = await onCreate(keyword);
5274
+ return mounted.current && !cancelled && version.current === epoch ? record : void 0;
5275
+ } finally {
5276
+ creating.current = false;
5277
+ }
5278
+ } : void 0,
5279
+ onChange: (next, option, info) => {
5280
+ if (cancelled || !mounted.current) return;
5281
+ version.current++;
5282
+ submitting.current = false;
5283
+ skipBlur.current = false;
5284
+ setValue(next);
5285
+ publishEditorChange(
5286
+ current.current,
5287
+ next,
5288
+ info.trigger === "clear" ? { trigger: "clear" } : { trigger: info.trigger, option }
5289
+ );
5290
+ if (info.trigger !== "clear") {
5291
+ skipBlur.current = true;
5292
+ submit(true, true);
5293
+ }
5294
+ },
5295
+ onKeyDown: (event) => {
5296
+ if (event.key === "Tab") navigate(event);
5297
+ else if ([
5298
+ "ArrowUp",
5299
+ "ArrowDown",
5300
+ "ArrowLeft",
5301
+ "ArrowRight",
5302
+ "Home",
5303
+ "End",
5304
+ "F6"
5305
+ ].includes(event.key))
5306
+ event.stopPropagation();
5307
+ },
5308
+ style: getEditorInputStyle(request)
5309
+ }
5310
+ ),
5311
+ options.error && /* @__PURE__ */ jsxs(
5312
+ "div",
5313
+ {
5314
+ role: "alert",
5315
+ style: { background: "#fff", color: "#cf1322", padding: 4 },
5316
+ children: [
5317
+ options.error.message,
5318
+ /* @__PURE__ */ jsx("button", { type: "button", onClick: options.retry, children: "\u91CD\u8BD5\u67E5\u8BE2" })
5319
+ ]
5320
+ }
5321
+ )
5322
+ ]
5323
+ }
5324
+ );
5325
+ }
5326
+ var nextEditorIdentity = 0;
5327
+ function toValue(value) {
5328
+ return typeof value === "string" || typeof value === "number" ? value : void 0;
5329
+ }
4321
5330
  function ReactTableEditorOverlay(props) {
4322
5331
  const { request } = props;
4323
5332
  const editorHostRef = useRef(null);
4324
5333
  const wheelCommittedRef = useRef(false);
5334
+ const changedSinceCommitRef = useRef(false);
4325
5335
  const editorRequest = {
4326
5336
  ...request,
5337
+ onChange: (value, meta) => {
5338
+ wheelCommittedRef.current = false;
5339
+ changedSinceCommitRef.current = true;
5340
+ if (meta === void 0) request.onChange(value);
5341
+ else request.onChange(value, meta);
5342
+ },
4327
5343
  onCommit: (options) => {
4328
- if (!wheelCommittedRef.current) request.onCommit(options);
5344
+ if (!wheelCommittedRef.current && (!request.feedback?.pending || changedSinceCommitRef.current)) {
5345
+ changedSinceCommitRef.current = false;
5346
+ return request.onCommit(options);
5347
+ }
4329
5348
  }
4330
5349
  };
4331
5350
  useEffect(() => {
4332
5351
  wheelCommittedRef.current = false;
5352
+ changedSinceCommitRef.current = false;
4333
5353
  }, [request.editorKey]);
4334
5354
  const style = resolveEditorOverlayStyle({
4335
5355
  rect: request.rect,
@@ -4341,35 +5361,105 @@ function ReactTableEditorOverlay(props) {
4341
5361
  });
4342
5362
  const contentZoom = typeof request.theme.contentZoom === "number" && Number.isFinite(request.theme.contentZoom) && request.theme.contentZoom > 0 ? request.theme.contentZoom : 1;
4343
5363
  useLayoutEffect(() => {
5364
+ if (request.config.valueType === "composite" || request.config.valueType === "math-interval" || request.config.valueType === "number-unit")
5365
+ return;
4344
5366
  const input = editorHostRef.current?.querySelector("input");
4345
5367
  if (!input) {
4346
5368
  return;
4347
5369
  }
4348
5370
  focusAndSelectEditorInput(input, request.selectOnFocus);
4349
- }, [request]);
5371
+ }, [request.editorKey]);
4350
5372
  useEffect(() => {
4351
5373
  const host = editorHostRef.current;
4352
5374
  if (!host) return;
4353
5375
  const valueType = request.config.valueType ?? "text";
4354
- if (valueType !== "text" && valueType !== "number" && valueType !== "input-range") {
5376
+ if (valueType !== "composite" && valueType !== "text" && valueType !== "number" && valueType !== "input-range") {
4355
5377
  return;
4356
5378
  }
4357
5379
  const handleWheel = (event) => {
4358
5380
  event.preventDefault();
4359
5381
  event.stopPropagation();
4360
- if (!wheelCommittedRef.current) {
4361
- wheelCommittedRef.current = true;
4362
- request.onCommit();
4363
- }
4364
- request.onWheel?.(event);
5382
+ if (wheelCommittedRef.current || request.feedback?.pending) return;
5383
+ wheelCommittedRef.current = true;
5384
+ const result = request.onCommit();
5385
+ if (result && typeof result.then === "function")
5386
+ void result.then(
5387
+ (success) => {
5388
+ if (!success) wheelCommittedRef.current = false;
5389
+ else request.onWheel?.(event);
5390
+ },
5391
+ () => {
5392
+ wheelCommittedRef.current = false;
5393
+ }
5394
+ );
5395
+ else request.onWheel?.(event);
4365
5396
  };
4366
5397
  host.addEventListener("wheel", handleWheel, { passive: false });
4367
5398
  return () => host.removeEventListener("wheel", handleWheel);
4368
5399
  }, [request]);
4369
- return /* @__PURE__ */ jsx(ReactContentScaleProvider, { scale: contentZoom, children: /* @__PURE__ */ jsx("div", { ref: editorHostRef, children: renderEditorByType(editorRequest, style) }, request.editorKey) });
5400
+ const itemErrorOwnsFeedback = request.config.valueType === "composite" && Object.values(request.feedback?.itemErrors ?? {}).some(
5401
+ (errors) => errors.includes(request.feedback?.error ?? "")
5402
+ );
5403
+ return /* @__PURE__ */ jsx(ReactContentScaleProvider, { scale: contentZoom, children: /* @__PURE__ */ jsxs(
5404
+ "div",
5405
+ {
5406
+ ref: editorHostRef,
5407
+ "aria-busy": request.feedback?.pending || void 0,
5408
+ children: [
5409
+ renderEditorByType(editorRequest, style),
5410
+ request.feedback?.error && !itemErrorOwnsFeedback && /* @__PURE__ */ jsx(
5411
+ "div",
5412
+ {
5413
+ role: "alert",
5414
+ style: {
5415
+ ...style,
5416
+ top: Number(style.top) + Number(style.height),
5417
+ height: "auto",
5418
+ minHeight: 0,
5419
+ padding: 4,
5420
+ background: "#fff",
5421
+ color: "#cf1322",
5422
+ border: "1px solid #ffccc7"
5423
+ },
5424
+ children: request.feedback.error
5425
+ }
5426
+ )
5427
+ ]
5428
+ },
5429
+ request.editorKey
5430
+ ) });
4370
5431
  }
4371
5432
  function renderEditorByType(request, style) {
4372
5433
  switch (request.config.valueType ?? "text") {
5434
+ case "composite":
5435
+ return /* @__PURE__ */ jsx(
5436
+ CompositeEditor,
5437
+ {
5438
+ request,
5439
+ style
5440
+ },
5441
+ request.editorKey
5442
+ );
5443
+ case "number-unit":
5444
+ return /* @__PURE__ */ jsx(
5445
+ NumberUnitEditor,
5446
+ {
5447
+ request,
5448
+ style
5449
+ },
5450
+ request.editorKey
5451
+ );
5452
+ case "math-interval":
5453
+ return /* @__PURE__ */ jsx(
5454
+ MathIntervalEditor,
5455
+ {
5456
+ request,
5457
+ style
5458
+ },
5459
+ request.editorKey
5460
+ );
5461
+ case "table-select":
5462
+ return /* @__PURE__ */ jsx(TableSelectEditor, { request, style });
4373
5463
  case "tree-select":
4374
5464
  return /* @__PURE__ */ jsx(TreeSelectEditor, { request, style });
4375
5465
  case "cascader":
@@ -4414,7 +5504,7 @@ function TextEditor(props) {
4414
5504
  useLayoutEffect(() => {
4415
5505
  const input = hostRef.current?.querySelector("input");
4416
5506
  focusAndSelectEditorInput(input, request.selectOnFocus);
4417
- }, [request]);
5507
+ }, [request.editorKey]);
4418
5508
  useEffect(() => {
4419
5509
  setValue(String(request.value ?? ""));
4420
5510
  }, [request.value]);
@@ -4426,7 +5516,7 @@ function TextEditor(props) {
4426
5516
  onChange: (event) => {
4427
5517
  const nextValue = event.target.value;
4428
5518
  setValue(nextValue);
4429
- request.onChange(nextValue);
5519
+ publishEditorChange(request, nextValue, { trigger: "input" });
4430
5520
  },
4431
5521
  onPressEnter: () => {
4432
5522
  request.onCommit({ restoreTableFocus: true });
@@ -4454,7 +5544,7 @@ function NumberEditor(props) {
4454
5544
  useLayoutEffect(() => {
4455
5545
  const input = hostRef.current?.querySelector("input");
4456
5546
  focusAndSelectEditorInput(input, request.selectOnFocus);
4457
- }, [request]);
5547
+ }, [request.editorKey]);
4458
5548
  useEffect(() => {
4459
5549
  setValue(toNumberValue(request.value));
4460
5550
  }, [request.value]);
@@ -4468,7 +5558,7 @@ function NumberEditor(props) {
4468
5558
  step: toNumericProp(request.config.step),
4469
5559
  onChange: (nextValue) => {
4470
5560
  setValue(nextValue);
4471
- request.onChange(nextValue);
5561
+ publishEditorChange(request, nextValue, { trigger: "input" });
4472
5562
  },
4473
5563
  onPressEnter: () => {
4474
5564
  request.onCommit({ restoreTableFocus: true });
@@ -4506,7 +5596,7 @@ function InputRangeEditor(props) {
4506
5596
  rangeSeparator: request.config.rangeSeparator,
4507
5597
  onChange: (nextValue) => {
4508
5598
  setValue(nextValue);
4509
- request.onChange(nextValue);
5599
+ publishEditorChange(request, nextValue, { trigger: "input" });
4510
5600
  },
4511
5601
  onPressEnter: () => {
4512
5602
  request.onCommit({ restoreTableFocus: true });
@@ -4545,7 +5635,7 @@ function YearEditor(props) {
4545
5635
  showArrow: false,
4546
5636
  onChange: (nextValue) => {
4547
5637
  setValue(nextValue);
4548
- request.onChange(nextValue);
5638
+ publishEditorChange(request, nextValue, { trigger: "change" });
4549
5639
  request.onCommit();
4550
5640
  },
4551
5641
  onBlur: (event) => {
@@ -4579,7 +5669,7 @@ function QuarterEditor(props) {
4579
5669
  showArrow: false,
4580
5670
  onChange: (nextValue) => {
4581
5671
  setValue(nextValue);
4582
- request.onChange(nextValue);
5672
+ publishEditorChange(request, nextValue, { trigger: "change" });
4583
5673
  request.onCommit();
4584
5674
  },
4585
5675
  onBlur: (event) => {
@@ -4613,7 +5703,7 @@ function MonthEditor(props) {
4613
5703
  showArrow: false,
4614
5704
  onChange: (nextValue) => {
4615
5705
  setValue(nextValue);
4616
- request.onChange(nextValue);
5706
+ publishEditorChange(request, nextValue, { trigger: "change" });
4617
5707
  request.onCommit();
4618
5708
  },
4619
5709
  onBlur: (event) => {
@@ -4647,7 +5737,7 @@ function DateEditor(props) {
4647
5737
  showArrow: false,
4648
5738
  onChange: (nextValue) => {
4649
5739
  setValue(nextValue);
4650
- request.onChange(nextValue);
5740
+ publishEditorChange(request, nextValue, { trigger: "change" });
4651
5741
  request.onCommit();
4652
5742
  },
4653
5743
  onBlur: (event) => {
@@ -4689,7 +5779,10 @@ function TreeSelectEditor({
4689
5779
  style: getEditorInputStyle(request),
4690
5780
  onChange: (next, _nodes, info) => {
4691
5781
  setValue(next);
4692
- request.onChange(next);
5782
+ publishEditorChange(request, next, {
5783
+ trigger: info.trigger,
5784
+ options: _nodes
5785
+ });
4693
5786
  if (info.complete && info.trigger !== "clear") {
4694
5787
  skipBlurCommitRef.current = true;
4695
5788
  request.onCommit();
@@ -4733,7 +5826,10 @@ function CascaderEditor({
4733
5826
  style: getEditorInputStyle(request),
4734
5827
  onChange: (next, _options, info) => {
4735
5828
  setValue(next);
4736
- request.onChange(next);
5829
+ publishEditorChange(request, next, {
5830
+ trigger: info.trigger,
5831
+ options: _options
5832
+ });
4737
5833
  if (info.complete && info.trigger !== "clear") {
4738
5834
  skipBlurCommitRef.current = true;
4739
5835
  request.onCommit();
@@ -4773,9 +5869,13 @@ function SelectEditor(props) {
4773
5869
  onChange: (nextValue, info) => {
4774
5870
  const resolvedValue = String(nextValue);
4775
5871
  setValue(resolvedValue);
4776
- request.onChange(
4777
- options.find((option) => String(option.value) === resolvedValue)?.value ?? resolvedValue
5872
+ const option = options.find(
5873
+ (option2) => String(option2.value) === resolvedValue
4778
5874
  );
5875
+ publishEditorChange(request, option?.value ?? resolvedValue, {
5876
+ trigger: info.trigger,
5877
+ option
5878
+ });
4779
5879
  if (info.trigger === "mouse" || info.trigger === "keyboard") {
4780
5880
  skipBlurCommitRef.current = true;
4781
5881
  request.onCommit({ restoreTableFocus: true });
@@ -4804,6 +5904,18 @@ function AutoCompleteEditor(props) {
4804
5904
  request.value == null ? "" : String(request.value)
4805
5905
  );
4806
5906
  const [options, setOptions] = useState(request.config.options ?? []);
5907
+ const optionsRef = useRef(options);
5908
+ const aliveRef = useRef(true);
5909
+ useEffect(() => {
5910
+ aliveRef.current = true;
5911
+ return () => {
5912
+ aliveRef.current = false;
5913
+ };
5914
+ }, []);
5915
+ useEffect(() => {
5916
+ optionsRef.current = request.config.options ?? [];
5917
+ setOptions(optionsRef.current);
5918
+ }, [request.config.options]);
4807
5919
  const skipBlurCommitRef = useRef(false);
4808
5920
  useEffect(() => {
4809
5921
  setValue(request.value == null ? "" : String(request.value));
@@ -4817,8 +5929,14 @@ function AutoCompleteEditor(props) {
4817
5929
  options,
4818
5930
  placeholder: request.config.placeholder ?? "",
4819
5931
  onChange: (nextValue, info) => {
5932
+ if (!aliveRef.current) return;
4820
5933
  setValue(nextValue);
4821
- request.onChange(nextValue);
5934
+ publishEditorChange(request, nextValue, {
5935
+ trigger: info.trigger,
5936
+ option: optionsRef.current.find(
5937
+ (option) => String(option.value) === String(nextValue)
5938
+ )
5939
+ });
4822
5940
  if (info.trigger === "mouse" || info.trigger === "keyboard") {
4823
5941
  skipBlurCommitRef.current = true;
4824
5942
  request.onCommit({ restoreTableFocus: true });
@@ -4826,7 +5944,9 @@ function AutoCompleteEditor(props) {
4826
5944
  },
4827
5945
  onPressEnter: async (input) => {
4828
5946
  const nextOptions = await request.config.onPressEnter?.(input);
5947
+ if (!aliveRef.current) return;
4829
5948
  if (nextOptions) {
5949
+ optionsRef.current = nextOptions;
4830
5950
  setOptions(nextOptions);
4831
5951
  }
4832
5952
  return nextOptions;
@@ -4866,7 +5986,7 @@ function ColorEditor(props) {
4866
5986
  showArrow: false,
4867
5987
  onChange: (nextValue) => {
4868
5988
  setValue(nextValue);
4869
- request.onChange(nextValue);
5989
+ publishEditorChange(request, nextValue, { trigger: "change" });
4870
5990
  },
4871
5991
  onBlur: (event) => {
4872
5992
  handleEditorBlur(event, skipBlurCommitRef, request);
@@ -4901,7 +6021,7 @@ function DateRangeEditor(props) {
4901
6021
  rangeSeparator: separator,
4902
6022
  onChange: (nextValue) => {
4903
6023
  setValue(nextValue);
4904
- request.onChange(nextValue);
6024
+ publishEditorChange(request, nextValue, { trigger: "change" });
4905
6025
  },
4906
6026
  onBlur: (event) => {
4907
6027
  handleEditorBlur(event, skipBlurCommitRef, request);
@@ -4937,7 +6057,7 @@ function TimeEditor(props) {
4937
6057
  showArrow: false,
4938
6058
  onChange: (nextValue) => {
4939
6059
  setValue(nextValue);
4940
- request.onChange(nextValue);
6060
+ publishEditorChange(request, nextValue, { trigger: "change" });
4941
6061
  },
4942
6062
  onBlur: (event) => {
4943
6063
  handleEditorBlur(event, skipBlurCommitRef, request);
@@ -4970,7 +6090,7 @@ function DateTimeEditor(props) {
4970
6090
  showArrow: false,
4971
6091
  onChange: (nextValue) => {
4972
6092
  setValue(nextValue);
4973
- request.onChange(nextValue);
6093
+ publishEditorChange(request, nextValue, { trigger: "change" });
4974
6094
  request.onCommit();
4975
6095
  },
4976
6096
  onBlur: (event) => {
@@ -5006,7 +6126,7 @@ function DateTimeRangeEditor(props) {
5006
6126
  rangeSeparator: separator,
5007
6127
  onChange: (nextValue) => {
5008
6128
  setValue(nextValue);
5009
- request.onChange(nextValue);
6129
+ publishEditorChange(request, nextValue, { trigger: "change" });
5010
6130
  },
5011
6131
  onBlur: (event) => {
5012
6132
  handleEditorBlur(event, skipBlurCommitRef, request);
@@ -5043,7 +6163,7 @@ function TimeRangeEditor(props) {
5043
6163
  rangeSeparator: separator,
5044
6164
  onChange: (nextValue) => {
5045
6165
  setValue(nextValue);
5046
- request.onChange(nextValue);
6166
+ publishEditorChange(request, nextValue, { trigger: "change" });
5047
6167
  },
5048
6168
  onBlur: (event) => {
5049
6169
  handleEditorBlur(event, skipBlurCommitRef, request);
@@ -5067,8 +6187,18 @@ function handleEditorNavigationKey(event, request, skipBlurCommitRef) {
5067
6187
  return false;
5068
6188
  }
5069
6189
  event.preventDefault();
6190
+ if (request.feedback?.pending) return true;
5070
6191
  skipBlurCommitRef.current = true;
5071
- request.onNavigate(direction);
6192
+ const result = request.onNavigate(direction);
6193
+ if (result && typeof result.then === "function")
6194
+ void result.then(
6195
+ (success) => {
6196
+ if (!success) skipBlurCommitRef.current = false;
6197
+ },
6198
+ () => {
6199
+ skipBlurCommitRef.current = false;
6200
+ }
6201
+ );
5072
6202
  return true;
5073
6203
  }
5074
6204
  function handleRangeInputTab(event) {
@@ -5121,7 +6251,12 @@ function toNumberRangeTuple(value) {
5121
6251
  }
5122
6252
  return [toNumberValue(value[0]), toNumberValue(value[1])];
5123
6253
  }
5124
- function handleEditorBlur(_event, skipBlurCommitRef, request) {
6254
+ function handleEditorBlur(event, skipBlurCommitRef, request) {
6255
+ if (containsEditorInteraction(
6256
+ event.currentTarget.closest("[data-list-table-range-editor]"),
6257
+ event.relatedTarget
6258
+ ) || request.feedback?.pending)
6259
+ return;
5125
6260
  if (skipBlurCommitRef.current) {
5126
6261
  skipBlurCommitRef.current = false;
5127
6262
  return;
@@ -5679,7 +6814,7 @@ function ToolButton(props) {
5679
6814
  }
5680
6815
  );
5681
6816
  }
5682
- function flattenColumns(columns, parentKey = "root", level = 0) {
6817
+ function flattenColumns(columns, parentKey = "root", level = 0, parentHidden = false) {
5683
6818
  return columns.flatMap((column) => {
5684
6819
  if (column.hideInSetting || isListTableColumnHiddenBySource(column)) {
5685
6820
  return [];
@@ -5689,7 +6824,7 @@ function flattenColumns(columns, parentKey = "root", level = 0) {
5689
6824
  const current = {
5690
6825
  key,
5691
6826
  label,
5692
- hidden: column.hidden === true,
6827
+ hidden: parentHidden || isListTableColumnHidden(column),
5693
6828
  parentKey,
5694
6829
  width: Number(column.width) || 160,
5695
6830
  minWidth: typeof column.minWidth === "number" ? column.minWidth : void 0,
@@ -5700,7 +6835,10 @@ function flattenColumns(columns, parentKey = "root", level = 0) {
5700
6835
  disableHide: column.disableHide === true,
5701
6836
  sortable: column.allowSort !== false && column.sorter !== false
5702
6837
  };
5703
- return column.children?.length ? [current, ...flattenColumns(column.children, key, level + 1)] : [current];
6838
+ return column.children?.length ? [
6839
+ current,
6840
+ ...flattenColumns(column.children, key, level + 1, current.hidden)
6841
+ ] : [current];
5704
6842
  });
5705
6843
  }
5706
6844
  function useReactListTableState(options) {
@@ -5982,7 +7120,7 @@ function applyColumnManagerState(columns, visibility, orders, config, parentKey
5982
7120
  const managedConfig = config.get(key);
5983
7121
  return {
5984
7122
  ...column,
5985
- hidden: isListTableColumnHiddenBySource(column) ? true : visibility.has(key) ? visibility.get(key) === false : column.hidden ?? column.initialHide,
7123
+ visible: visibility.has(key) ? visibility.get(key) !== false : column.visible !== false,
5986
7124
  width: managedConfig?.width ?? column.width,
5987
7125
  minWidth: column.minWidth,
5988
7126
  maxWidth: column.maxWidth,
@@ -5997,6 +7135,44 @@ function applyColumnManagerState(columns, visibility, orders, config, parentKey
5997
7135
  };
5998
7136
  });
5999
7137
  }
7138
+ function updateColumnManagerVisibility(columns, current, columnKey, visible) {
7139
+ const next = new Map(current);
7140
+ const setSubtree = (column) => {
7141
+ if (column.hidden === true || !visible && column.disableHide) return;
7142
+ next.set(resolveColumnKey(column), visible);
7143
+ column.children?.forEach(setSubtree);
7144
+ };
7145
+ const visit = (items, ancestors) => {
7146
+ for (const column of items) {
7147
+ if (column.hidden === true) continue;
7148
+ if (resolveColumnKey(column) === columnKey) {
7149
+ if (!visible && column.disableHide) return false;
7150
+ if (visible)
7151
+ ancestors.forEach(
7152
+ (parent) => next.set(resolveColumnKey(parent), true)
7153
+ );
7154
+ setSubtree(column);
7155
+ return true;
7156
+ }
7157
+ if (column.children && visit(column.children, [...ancestors, column]))
7158
+ return true;
7159
+ }
7160
+ return false;
7161
+ };
7162
+ visit(columns, []);
7163
+ return next;
7164
+ }
7165
+ function getColumnManagerVisibility(columns) {
7166
+ const result = /* @__PURE__ */ new Map();
7167
+ const visit = (items) => {
7168
+ for (const column of items) {
7169
+ result.set(resolveColumnKey(column), column.visible !== false);
7170
+ if (column.children) visit(column.children);
7171
+ }
7172
+ };
7173
+ visit(columns);
7174
+ return result;
7175
+ }
6000
7176
  function normalizeUniqueColumnKeys(columns) {
6001
7177
  const usedKeys = /* @__PURE__ */ new Set();
6002
7178
  const reservedKeys = /* @__PURE__ */ new Set();
@@ -6063,6 +7239,7 @@ function getColumnSettingsSignature(columns) {
6063
7239
  dataIndex: column.dataIndex,
6064
7240
  userDefined: column.userDefined,
6065
7241
  hidden: column.hidden,
7242
+ visible: column.visible,
6066
7243
  width: column.width,
6067
7244
  minWidth: column.minWidth,
6068
7245
  maxWidth: column.maxWidth,
@@ -6094,6 +7271,7 @@ function ReactListTableInner(props, ref) {
6094
7271
  rowKey,
6095
7272
  columns,
6096
7273
  showCollapsedColumnIcon,
7274
+ showHeaderActions,
6097
7275
  dataSource,
6098
7276
  loading,
6099
7277
  onRow,
@@ -6139,9 +7317,16 @@ function ReactListTableInner(props, ref) {
6139
7317
  () => resolveReactListTableDebugOptions(debug, inheritedDebugEnabled),
6140
7318
  [debug, inheritedDebugEnabled]
6141
7319
  );
7320
+ const activeStorageKey = useRef(storageKey);
7321
+ useLayoutEffect(() => {
7322
+ activeStorageKey.current = storageKey;
7323
+ }, [storageKey]);
6142
7324
  const shellRef = useRef(null);
6143
7325
  const [isFullscreen, setIsFullscreen] = useState(false);
6144
- const [scrollbarOverride, setScrollbarOverride] = useState(null);
7326
+ const [scrollbarOverride, setScrollbarOverride] = useStorageKeyState(
7327
+ storageKey,
7328
+ () => null
7329
+ );
6145
7330
  const [sharedScrollbar, setSharedScrollbar] = useState(
6146
7331
  getSharedScrollbarSettings
6147
7332
  );
@@ -6152,12 +7337,10 @@ function ReactListTableInner(props, ref) {
6152
7337
  []
6153
7338
  );
6154
7339
  const effectiveScrollbar = sharedScrollbar.shared ? sharedScrollbar.value : scrollbarOverride ?? scrollbar;
6155
- const [densityOverride, setDensityOverride] = useState(null);
6156
- const [columnVisibility, setColumnVisibility] = useState(() => /* @__PURE__ */ new Map());
6157
- const [columnOrders, setColumnOrders] = useState(
6158
- () => /* @__PURE__ */ new Map()
6159
- );
6160
- const [columnConfig, setColumnConfig] = useState(() => /* @__PURE__ */ new Map());
7340
+ const [densityOverride, setDensityOverride] = useStorageKeyState(storageKey, () => null);
7341
+ const [columnVisibility, setColumnVisibility] = useState(() => ({ storageKey, values: /* @__PURE__ */ new Map() }));
7342
+ const [columnOrders, setColumnOrders] = useStorageKeyState(storageKey, () => /* @__PURE__ */ new Map());
7343
+ const [columnConfig, setColumnConfig] = useStorageKeyState(storageKey, () => /* @__PURE__ */ new Map());
6161
7344
  const restoredColumnTreeRef = useRef(null);
6162
7345
  const [restoredColumnTree, setRestoredColumnTree] = useState(
6163
7346
  restoredColumnTreeRef.current
@@ -6174,7 +7357,7 @@ function ReactListTableInner(props, ref) {
6174
7357
  const resolvedColumns = useMemo(
6175
7358
  () => applyColumnManagerState(
6176
7359
  restoredColumnTree?.sourceColumns === sourceColumns && restoredColumnTree.storageKey === storageKey ? restoredColumnTree.columns : sourceColumns,
6177
- columnVisibility,
7360
+ columnVisibility.storageKey === storageKey ? columnVisibility.values : /* @__PURE__ */ new Map(),
6178
7361
  columnOrders,
6179
7362
  columnConfig
6180
7363
  ),
@@ -6208,6 +7391,7 @@ function ReactListTableInner(props, ref) {
6208
7391
  rowKey,
6209
7392
  columns: resolvedColumns,
6210
7393
  showCollapsedColumnIcon,
7394
+ showHeaderActions,
6211
7395
  dataSource,
6212
7396
  loading,
6213
7397
  onRow,
@@ -6256,6 +7440,7 @@ function ReactListTableInner(props, ref) {
6256
7440
  onDensityChange: setDensityOverride,
6257
7441
  onScrollbarChange: setScrollbarOverride,
6258
7442
  onColumnSettingsChange: (restoredColumns, source) => {
7443
+ if (activeStorageKey.current !== storageKey) return;
6259
7444
  const signature = getColumnSettingsSignature(restoredColumns);
6260
7445
  const current = restoredColumnTreeRef.current;
6261
7446
  if (current?.sourceColumns === sourceColumns && current.storageKey === storageKey && current.signature === signature)
@@ -6268,18 +7453,27 @@ function ReactListTableInner(props, ref) {
6268
7453
  };
6269
7454
  restoredColumnTreeRef.current = next;
6270
7455
  setRestoredColumnTree(next);
7456
+ setColumnVisibility({
7457
+ storageKey,
7458
+ values: getColumnManagerVisibility(restoredColumns)
7459
+ });
6271
7460
  setColumnOrders(getColumnManagerOrders(restoredColumns));
6272
7461
  if (source === "restore") {
6273
- setColumnVisibility(/* @__PURE__ */ new Map());
6274
7462
  setColumnConfig(/* @__PURE__ */ new Map());
6275
7463
  }
6276
7464
  },
6277
- onColumnSettingsCacheChange: (value) => setColumnSettingsCacheOverride(
6278
- (current) => current?.storageKey === storageKey && current?.value === value ? current : { storageKey, value }
6279
- ),
6280
- onCachePreferencesChange: (next) => setCachePreferencesOverride(
6281
- (current) => current?.storageKey === storageKey && JSON.stringify(current?.value ?? {}) === JSON.stringify(next) ? current : { storageKey, value: next }
6282
- )
7465
+ onColumnSettingsCacheChange: (value) => {
7466
+ if (activeStorageKey.current !== storageKey) return;
7467
+ setColumnSettingsCacheOverride(
7468
+ (current) => current?.storageKey === storageKey && current?.value === value ? current : { storageKey, value }
7469
+ );
7470
+ },
7471
+ onCachePreferencesChange: (next) => {
7472
+ if (activeStorageKey.current !== storageKey) return;
7473
+ setCachePreferencesOverride(
7474
+ (current) => current?.storageKey === storageKey && JSON.stringify(current?.value ?? {}) === JSON.stringify(next) ? current : { storageKey, value: next }
7475
+ );
7476
+ }
6283
7477
  }
6284
7478
  };
6285
7479
  }, [
@@ -6293,6 +7487,7 @@ function ReactListTableInner(props, ref) {
6293
7487
  rowKey,
6294
7488
  resolvedColumns,
6295
7489
  showCollapsedColumnIcon,
7490
+ showHeaderActions,
6296
7491
  dataSource,
6297
7492
  loading,
6298
7493
  onRow,
@@ -6457,11 +7652,15 @@ function ReactListTableInner(props, ref) {
6457
7652
  }
6458
7653
  },
6459
7654
  onColumnVisibilityChange: (columnKey, visible) => {
6460
- setColumnVisibility((current) => {
6461
- const next = new Map(current);
6462
- next.set(columnKey, visible);
6463
- return next;
6464
- });
7655
+ setColumnVisibility((current) => ({
7656
+ storageKey,
7657
+ values: updateColumnManagerVisibility(
7658
+ resolvedColumns,
7659
+ current.storageKey === storageKey ? current.values : /* @__PURE__ */ new Map(),
7660
+ columnKey,
7661
+ visible
7662
+ )
7663
+ }));
6465
7664
  setColumnConfigRevision((current) => current + 1);
6466
7665
  },
6467
7666
  onColumnOrderChange: (parentKey, orderedKeys) => {
@@ -6505,7 +7704,8 @@ function ReactListTableInner(props, ref) {
6505
7704
  storageKey,
6506
7705
  columns: initialColumns
6507
7706
  }).finally(() => {
6508
- setColumnVisibility(/* @__PURE__ */ new Map());
7707
+ if (activeStorageKey.current !== storageKey) return;
7708
+ setColumnVisibility({ storageKey, values: /* @__PURE__ */ new Map() });
6509
7709
  setColumnOrders(/* @__PURE__ */ new Map());
6510
7710
  setColumnConfig(/* @__PURE__ */ new Map());
6511
7711
  restoredColumnTreeRef.current = null;