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