@canvas-components/react-list-table 0.3.73 → 0.3.75
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/README.md +38 -1
- package/dist/index.cjs +1880 -180
- package/dist/index.d.cts +11 -2
- package/dist/index.d.ts +11 -2
- package/dist/index.js +1883 -183
- package/package.json +9 -9
package/dist/index.js
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import { createContext, memo, forwardRef, useMemo, useRef, useState, useEffect, useImperativeHandle,
|
|
1
|
+
import { createContext, memo, forwardRef, useMemo, useRef, useLayoutEffect, useState, useEffect, useImperativeHandle, useContext, useCallback, useId, Fragment as Fragment$1 } from 'react';
|
|
2
2
|
import { createPortal } from 'react-dom';
|
|
3
|
-
import { getSharedScrollbarSettings, subscribeSharedScrollbarSettings, ReactTooltip, ReactImagePreview, ReactCheckbox, ReactSortableList, ReactInputNumber, ReactSelect, ReactPagination,
|
|
4
|
-
import { EXPAND_COLUMN, SELECTION_COLUMN, ROW_SELECTION_COLUMN, resetListTableStoredColumnConfig, withListTableColumnVisibility,
|
|
3
|
+
import { getSharedScrollbarSettings, subscribeSharedScrollbarSettings, ReactTooltip, ReactImagePreview, reactMessage, ReactCheckbox, ReactSortableList, ReactInputNumber, ReactSelect, ReactPagination, ReactModal, ReactSwitch, ReactInput, ReactButton, ReactFilterPanel, ReactPopup, ReactPopconfirm, ReactContentScaleProvider, ReactScrollbarSettingsDialog, ReactScrollbarPositionDialog, setSharedScrollbarSettings, ReactColorPicker, resolveReactScrollbarMode, ReactAutoComplete, ReactTimeRangePicker, ReactDateTimeRangePicker, ReactDateTimePicker, ReactTimePicker, ReactDateRangePicker, ReactDatePicker, ReactMonthPicker, ReactQuarterPicker, ReactYearPicker, ReactInputRange, ReactCascader, ReactTreeSelect, ReactTableSelect, ReactMathInterval, ReactInputNumberUnit, ReactInputGroup } from '@canvas-components/react-components';
|
|
4
|
+
import { EXPAND_COLUMN, SELECTION_COLUMN, ROW_SELECTION_COLUMN, resetListTableStoredColumnConfig, withListTableColumnVisibility, ListTable, formatPaginationText, getListTableStoredColumnConfig, isListTableColumnHiddenBySource, isListTableColumnHidden, withPaginationDefaults, validatePaginationConfig, saveListTableStoredColumnConfig, resolveListTableEditorItemWidths } from '@canvas-components/list-table';
|
|
5
5
|
export { EXPAND_COLUMN, ROW_SELECTION_COLUMN, SELECTION_COLUMN, getListTableStoredPageSize } from '@canvas-components/list-table';
|
|
6
6
|
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
7
7
|
import { CanvasChart } from '@canvas-components/chart';
|
|
8
8
|
import { formatDateTimeValue, isDateTimeFormatPattern } from '@canvas-components/utils/date';
|
|
9
9
|
import { formatNumberValue, formatPercentValue, formatScientificValue, formatCustomNumberPattern } from '@canvas-components/utils/number';
|
|
10
10
|
import { builtinListTablePrintIntegration } from '@canvas-components/print-design-plugin/list-table-print';
|
|
11
|
+
import { normalizeMathInterval, normalizeNumberUnit as normalizeNumberUnit$1 } from '@canvas-components/utils';
|
|
12
|
+
import { normalizeNumberUnit } from '@canvas-components/utils/number-unit';
|
|
11
13
|
|
|
12
14
|
// #style-inject:#style-inject
|
|
13
15
|
function styleInject(css, { insertAt } = {}) {
|
|
@@ -36,6 +38,29 @@ styleInject(".react-list-table-host {\n touch-action: none;\n min-width: 0;\n
|
|
|
36
38
|
|
|
37
39
|
// ../print-design-plugin/dist/react.css
|
|
38
40
|
styleInject('.cc-print-design-flow-item {\n border: 1px solid var(--pd-border);\n border-radius: 6px;\n padding: 8px;\n}\n.cc-print-design-flow-reverse,\n.cc-print-design-flow-reverse .canvas-react-button {\n width: 100%;\n}\n.cc-print-design-flow-item-heading {\n display: flex;\n align-items: center;\n gap: 4px;\n margin-bottom: 8px;\n}\n.cc-print-design-flow-item-heading strong {\n flex: 1;\n}\n.cc-print-design-flow-item-heading .canvas-react-button {\n padding: 4px;\n}\n.cc-print-design-chart-series {\n border: 1px solid var(--pd-border);\n border-radius: 6px;\n padding: 8px;\n margin: 8px 0;\n}\n.cc-print-design-column-actions > .canvas-react-button {\n box-sizing: border-box;\n width: 32px;\n height: 32px;\n flex: 0 0 32px;\n padding: 4px;\n}\n.cc-print-design-editor .cc-print-design-table-data label {\n font-size: var(--pd-label-font-size, 12px);\n color: var(--pd-muted);\n}\n.cc-print-design-packed-form,\n.cc-print-design-packed-section,\n.cc-print-design-packed-card {\n display: flex;\n flex-direction: column;\n gap: 9px;\n min-width: 0;\n}\n.cc-print-design-packed-form {\n --canvas-react-control-height: 32px;\n gap: 16px;\n padding-top: 9px;\n}\n.cc-print-design-packed-form .canvas-react-select,\n.cc-print-design-packed-form .canvas-react-input-number,\n.cc-print-design-packed-form .canvas-react-input-affix-wrapper {\n height: 32px;\n}\n.cc-print-design-table-data .cc-print-design-packed-form label.cc-print-design-field {\n align-items: stretch;\n margin: 0;\n gap: 5px;\n}\n.cc-print-design-packed-section {\n padding-top: 12px;\n border-top: 1px solid var(--pd-border);\n}\n.cc-print-design-packed-mode {\n display: flex;\n gap: 6px;\n}\n.cc-print-design-packed-mode > button {\n flex: 1;\n}\n.cc-print-design-packed-hint {\n color: var(--pd-muted);\n font-size: 12px;\n line-height: 1.5;\n}\n.cc-print-design-packed-summary-field {\n display: flex;\n flex-direction: column;\n gap: 6px;\n}\n.cc-print-design-packed-summary-field > button {\n width: 100%;\n}\n.cc-print-design-packed-card {\n padding: 9px;\n border: 1px solid var(--pd-border);\n border-radius: 5px;\n}\n.cc-print-design-packed-row {\n display: flex;\n align-items: end;\n gap: 6px;\n min-width: 0;\n}\n.cc-print-design-packed-add {\n width: 100%;\n margin-top: 9px;\n padding: 0;\n border-style: dashed;\n}\n.cc-print-design-packed-row > .cc-print-design-field {\n flex: 1;\n}\n.cc-print-design-packed-row > .cc-print-design-packed-delete {\n flex: none;\n align-self: end;\n width: 32px;\n height: 32px;\n padding: 0;\n}\n.cc-print-design-packed-checks {\n display: grid;\n grid-template-columns: repeat(2, minmax(0, 1fr));\n gap: 6px;\n}\n.cc-print-design-table-data {\n padding: 12px;\n border-bottom: 1px solid var(--pd-border);\n --canvas-react-control-height: 32px;\n}\n.cc-print-design-table-data h4 {\n font-size: var(--pd-primary-font-size, 13px);\n margin: 12px 0;\n}\n.cc-print-design-table-data label:not(.canvas-react-checkbox) {\n display: flex;\n flex-direction: column;\n gap: 6px;\n margin: 10px 0;\n}\n.cc-print-design-diagonal-style {\n grid-column: 1 / -1;\n display: grid;\n grid-template-columns: repeat(2, minmax(0, 1fr));\n gap: 8px;\n padding-top: 8px;\n border-top: 1px solid var(--pd-border);\n}\n.cc-print-design-diagonal-style > strong {\n grid-column: 1 / -1;\n}\n.cc-print-design-cell-merge-actions {\n grid-column: 1 / -1;\n display: flex;\n gap: 8px;\n}\n.cc-print-design-cell-merge-actions > .canvas-react-button {\n flex: 1;\n min-width: 0;\n}\n.cc-print-design-cell-content-format {\n grid-column: 1 / -1;\n display: grid;\n grid-template-columns: repeat(2, minmax(0, 1fr));\n gap: 8px;\n}\n.cc-print-design-cell-content-format > .cc-print-design-cell-content-format-type {\n grid-column: 1 / -1;\n}\n.cc-print-design-diagonal-controls {\n grid-column: 1 / -1;\n display: grid;\n gap: 4px;\n}\n.cc-print-design-compact-grid:not([hidden]) {\n display: grid;\n grid-template-columns: repeat(2, minmax(0, 1fr));\n gap: 8px;\n}\n.cc-print-design-compact-grid > .canvas-react-checkbox,\n.cc-print-design-compact-grid > .cc-print-design-property-toggle {\n grid-column: 1 / -1;\n}\n.cc-print-design-table-data.cc-print-design-compact-grid label:not(.canvas-react-checkbox) {\n min-width: 0;\n gap: 4px;\n margin: 0;\n}\n.cc-print-design-compact-grid .canvas-react-input-number,\n.cc-print-design-compact-grid .canvas-react-color-picker {\n width: 100%;\n min-width: 0;\n}\n.cc-print-design-row-height-controls {\n display: flex;\n align-items: center;\n gap: 8px;\n}\n.cc-print-design-cell-print-mode,\n.cc-print-design-row-height-field {\n align-self: end;\n}\n.cc-print-design-row-height-controls > .canvas-react-input-number {\n flex: 1 1 auto;\n}\n.cc-print-design-row-height-controls > .cc-print-design-row-height-reset {\n box-sizing: border-box;\n width: 32px;\n height: 32px;\n flex: 0 0 32px;\n padding: 4px;\n}\n.cc-print-design-column-conditions,\n.cc-print-design-column-condition {\n display: flex;\n flex-direction: column;\n gap: 8px;\n}\n.cc-print-design-column-conditions {\n padding-top: 10px;\n border-top: 1px solid var(--pd-border);\n}\n.cc-print-design-column-condition {\n padding: 8px;\n border: 1px solid var(--pd-border);\n border-radius: 5px;\n}\n.cc-print-design-column-condition-head,\n.cc-print-design-column-condition-colors {\n display: flex;\n align-items: center;\n gap: 8px;\n}\n.cc-print-design-column-condition-head {\n justify-content: space-between;\n}\n.cc-print-design-column-condition-colors > label {\n flex: 1;\n min-width: 0;\n}\n.cc-print-design-column-heading {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 8px;\n min-width: 0;\n}\n.cc-print-design-column-heading > span {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.cc-print-design-column-heading small {\n flex-shrink: 0;\n color: var(--pd-muted);\n font-size: var(--pd-secondary-font-size, 11px);\n font-weight: normal;\n}\n.cc-print-design-column-grid:not([hidden]) {\n display: grid;\n grid-template-columns: repeat(2, minmax(0, 1fr));\n gap: 8px;\n padding: 8px;\n}\n.cc-print-design-column-grid > * {\n grid-column: 1 / -1;\n min-width: 0;\n}\n.cc-print-design-column-grid > .cc-print-design-column-half {\n grid-column: span 1;\n}\n.cc-print-design-column-field-row {\n display: flex;\n align-items: end;\n gap: 8px;\n min-width: 0;\n}\n.cc-print-design-column-field-row > .cc-print-design-field {\n flex: 1;\n min-width: 0;\n margin: 0;\n}\n.cc-print-design-column-field-row .cc-print-design-column-actions {\n flex: none;\n gap: 4px;\n}\n.cc-print-design-table-data .cc-print-design-column-grid label:not(.canvas-react-checkbox),\n.cc-print-design-column-grid > .cc-print-design-field {\n gap: 4px;\n margin: 0;\n}\n.cc-print-design-column-grid .canvas-react-input-number {\n min-width: 0;\n width: 100%;\n}\n.cc-print-design-cell-appearance .canvas-react-color-picker {\n min-width: 0;\n width: 100%;\n}\n.cc-print-design-table-appearance-colors {\n display: grid;\n grid-template-columns: repeat(2, minmax(0, 1fr));\n gap: 8px;\n}\n.cc-print-design-table-appearance-colors > label {\n min-width: 0;\n}\n.cc-print-design-column-actions {\n display: flex;\n justify-content: flex-end;\n align-items: center;\n gap: 8px;\n}\n.cc-print-design-column-toolbar {\n display: grid;\n grid-template-columns: repeat(3, minmax(0, 1fr));\n gap: 6px;\n margin-top: 8px;\n}\n.cc-print-design-column-toolbar > * {\n min-width: 0;\n width: 100%;\n}\n.cc-print-design-data-merge,\n.cc-print-design-merge-form {\n display: grid;\n gap: 12px;\n}\n.cc-print-design-merge-fields {\n display: flex;\n flex-direction: column;\n gap: 8px;\n margin: 0;\n}\n.cc-print-design-merge-fields > strong {\n font-size: var(--pd-primary-font-size, 13px);\n}\n.cc-print-design-merge-field {\n display: flex;\n align-items: center;\n gap: 6px;\n min-width: 0;\n}\n.cc-print-design-merge-field > .cc-print-design-field {\n flex: 1;\n min-width: 0;\n}\n.cc-print-design-packed-toggle {\n width: 100%;\n}\n.cc-print-design-summary-toggle {\n width: 100%;\n}\n.cc-print-design-table-row {\n border: 1px solid var(--pd-border);\n border-radius: 6px;\n padding: 8px;\n margin: 8px 0;\n}\n.cc-print-design-table-data pre {\n max-height: 200px;\n overflow: auto;\n font-size: var(--pd-primary-font-size, 13px);\n overscroll-behavior: contain;\n}\n.cc-print-design-row-settings:not([hidden]) {\n display: grid;\n grid-template-columns: repeat(2, minmax(0, 1fr));\n gap: 8px;\n}\n.cc-print-design-row-settings > * {\n grid-column: 1 / -1;\n min-width: 0;\n}\n.cc-print-design-row-settings-header-toggle {\n width: 100%;\n}\n.cc-print-design-row-settings > .cc-print-design-column-half {\n grid-column: span 1;\n margin: 0;\n gap: 4px;\n}\n.cc-print-design-row-count {\n display: grid;\n grid-template-columns: repeat(2, minmax(0, 1fr));\n gap: 8px;\n align-items: end;\n}\n.cc-print-design-table-data .cc-print-design-row-count > label {\n min-width: 0;\n margin: 0;\n gap: 4px;\n}\n.cc-print-design-row-count > .canvas-react-button {\n box-sizing: border-box;\n min-width: 0;\n width: 100%;\n height: var(--canvas-react-control-height, 32px);\n padding: 0 4px;\n white-space: nowrap;\n}\n.cc-print-design-row-settings .canvas-react-input-number {\n min-width: 0;\n width: 100%;\n}\n.cc-print-design-row-settings .cc-print-design-hint {\n margin: 0;\n}\n.cc-print-design-data-compact {\n padding: 8px;\n}\n.cc-print-design-table-data-panel:not([hidden]) {\n display: flex;\n flex-direction: column;\n gap: 10px;\n}\n.cc-print-design-static-data-actions {\n display: grid;\n grid-template-columns: repeat(2, minmax(0, 1fr));\n gap: 8px;\n}\n.cc-print-design-static-data-actions > .canvas-react-button {\n min-width: 0;\n width: 100%;\n}\n.cc-print-design-data-compact .cc-print-design-hint {\n margin: 6px 0;\n}\n.cc-print-design-data-compact .cc-print-design-json-field {\n margin: 6px 0;\n}\n.cc-print-design-data-compact .cc-print-design-table-row {\n padding: 0;\n margin: 6px 0;\n overflow: hidden;\n}\n.cc-print-design-static-row-grid:not([hidden]) {\n display: grid;\n grid-template-columns: repeat(2, minmax(0, 1fr));\n gap: 8px;\n padding: 8px;\n}\n.cc-print-design-static-row-grid > * {\n min-width: 0;\n}\n.cc-print-design-table-data .cc-print-design-static-row-grid label:not(.canvas-react-checkbox) {\n margin: 0;\n gap: 4px;\n overflow-wrap: anywhere;\n}\n.cc-print-design-static-row-grid .canvas-react-input-number {\n width: 100%;\n min-width: 0;\n}\n.cc-print-design-static-row-grid > .cc-print-design-json-field,\n.cc-print-design-static-row-grid > .cc-print-design-static-row-actions {\n grid-column: 1 / -1;\n}\n.cc-print-design-static-row-grid > .cc-print-design-static-row-actions-inline {\n grid-column: span 1;\n align-self: end;\n}\n.cc-print-design-border-side-controls {\n display: grid;\n grid-template-columns: repeat(3, 32px);\n grid-template-rows: repeat(3, 32px);\n gap: 2px;\n justify-content: center;\n}\n.cc-print-design-border-editor {\n grid-column: 1 / -1;\n width: 100%;\n min-width: 0;\n padding: 0;\n margin: 0;\n border: 0;\n}\n.cc-print-design-border-editor .cc-print-design-border-side-controls {\n width: 100%;\n}\n.cc-print-design-border-editor > .cc-print-design-border-line-style,\n.cc-print-design-border-editor > .cc-print-design-border-print-mode {\n grid-column: span 1;\n min-width: 0;\n}\n.cc-print-design-border-side-controls .canvas-react-button {\n min-width: 0;\n width: 32px;\n height: 32px;\n padding: 0;\n}\n.cc-print-design-border-side-top {\n grid-area: 1 / 2;\n}\n.cc-print-design-border-side-right {\n grid-area: 2 / 3;\n}\n.cc-print-design-border-side-bottom {\n grid-area: 3 / 2;\n}\n.cc-print-design-border-side-left {\n grid-area: 2 / 1;\n}\n.cc-print-design-border-side-inner {\n grid-area: 2 / 2;\n}\n.cc-print-design-table-data.cc-print-design-pivot-field-config {\n padding: 0;\n border: 0;\n}\n.cc-print-design-pivot-field-config__panel {\n height: 430px;\n min-height: 280px;\n margin-top: 10px;\n}\n.cc-print-pivot-fields {\n display: flex;\n flex-direction: column;\n height: 100%;\n min-width: 0;\n overflow: hidden;\n background: var(--pd-surface);\n color: var(--pd-text);\n font-size: var(--pd-primary-font-size, 13px);\n}\n.cc-print-pivot-fields section {\n min-height: 0;\n box-sizing: border-box;\n}\n.cc-print-pivot-fields__catalog {\n display: flex;\n flex: 0 0 39%;\n flex-direction: column;\n}\n.cc-print-pivot-fields__zones {\n display: flex;\n flex: 1 1 0;\n flex-direction: column;\n padding-top: 12px;\n}\n.cc-print-pivot-fields p {\n margin: 4px 0 8px;\n color: var(--pd-muted);\n font-size: var(--pd-label-font-size, 12px);\n}\n.cc-print-pivot-fields__catalog-list {\n min-height: 0;\n margin-top: 7px;\n overflow: auto;\n}\n.cc-print-pivot-fields__field,\n.cc-print-pivot-fields__area-field {\n display: grid;\n height: 28px;\n align-items: center;\n column-gap: 6px;\n box-sizing: border-box;\n}\n.cc-print-pivot-fields__field:hover,\n.cc-print-pivot-fields__area-field:hover {\n background: var(--pd-hover);\n}\n.cc-print-pivot-fields__field {\n grid-template-columns: 10px 16px minmax(0, 1fr);\n padding: 0 8px 0 6px;\n cursor: grab;\n}\n.cc-print-pivot-fields__field[data-dragging] {\n opacity: 0.45;\n}\n.cc-print-pivot-fields__field > span:last-child,\n.cc-print-pivot-fields__area-field > span:nth-child(2) {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.cc-print-pivot-fields__grip {\n width: 8px;\n height: 12px;\n background-image:\n radial-gradient(\n circle at 2px 2px,\n var(--pd-muted) 1px,\n transparent 1.2px);\n background-size: 4px 4px;\n cursor: grab;\n}\n.cc-print-pivot-fields__grid {\n display: grid;\n min-height: 0;\n grid-template-columns: repeat(2, minmax(0, 1fr));\n grid-template-rows: repeat(2, minmax(0, 1fr));\n gap: 8px;\n flex: 1;\n}\n.cc-print-pivot-fields__zone {\n display: flex;\n min-height: 0;\n min-width: 0;\n flex-direction: column;\n}\n.cc-print-pivot-fields__zone > strong {\n margin-bottom: 4px;\n font-size: 12px;\n}\n.cc-print-pivot-fields__drop {\n min-height: 0;\n flex: 1;\n overflow: auto;\n border: 1px solid var(--pd-border);\n border-radius: 3px;\n background: var(--pd-surface);\n}\n.cc-print-pivot-fields__drop[data-drag-over] {\n border-color: var(--pd-primary);\n background: var(--pd-selected);\n}\n.cc-print-pivot-fields__area-field {\n grid-template-columns: 9px minmax(0, 1fr) 18px;\n padding: 0 7px 0 5px;\n}\n.cc-print-pivot-fields__menu-trigger {\n display: grid;\n width: 18px;\n height: 22px;\n padding: 0;\n place-items: center;\n border: 0;\n background: transparent;\n cursor: pointer;\n}\n.cc-print-pivot-fields__menu-trigger > span {\n width: 0;\n height: 0;\n border-top: 5px solid currentColor;\n border-right: 4px solid transparent;\n border-left: 4px solid transparent;\n}\n.cc-print-pivot-fields__empty {\n display: block;\n padding: 10px 3px;\n color: var(--pd-muted);\n font-size: var(--pd-label-font-size, 12px);\n}\n.cc-print-pivot-fields__menu,\n.cc-print-pivot-fields__settings {\n color: var(--pd-text, #263244);\n font-family:\n "Segoe UI",\n "Microsoft YaHei",\n sans-serif;\n font-size: var(--pd-primary-font-size, 13px);\n}\n.cc-print-pivot-fields__menu button,\n.cc-print-pivot-fields__settings button,\n.cc-print-pivot-fields__settings input {\n font: inherit;\n}\n.cc-print-pivot-fields__menu {\n min-width: 176px;\n padding: 5px 0;\n}\n.cc-print-pivot-fields__menu button {\n display: block;\n width: 100%;\n height: 30px;\n padding: 0 12px;\n border: 0;\n background: transparent;\n text-align: left;\n cursor: pointer;\n}\n.cc-print-pivot-fields__menu button:hover:not(:disabled) {\n background: var(--pd-selected);\n}\n.cc-print-pivot-fields__menu button:disabled {\n color: #a7abb2;\n cursor: default;\n}\n.cc-print-pivot-fields__separator {\n height: 1px;\n margin: 4px 0;\n background: var(--pd-divider);\n}\n.cc-print-pivot-fields__settings {\n display: grid;\n min-width: 260px;\n gap: 12px;\n padding: 14px;\n}\n.cc-print-pivot-fields__settings label:not(.canvas-react-checkbox) {\n display: grid;\n gap: 5px;\n}\n.cc-print-pivot-fields__settings-actions {\n display: flex;\n justify-content: flex-end;\n gap: 8px;\n}\n.cc-print-design-nested-repeat > strong {\n display: block;\n margin: 8px 0 4px;\n}\n.cc-print-design-task-title {\n padding: 8px;\n font-weight: 600;\n}\n.cc-print-design-task-dependency-row {\n display: grid;\n grid-template-columns: repeat(2, minmax(0, 1fr));\n gap: 8px;\n padding: 8px 0;\n border-top: 1px solid #e7edf5;\n}\n.cc-print-design-task-dependency-row > * {\n min-width: 0;\n}\n.cc-print-design-ai-panel {\n display: flex;\n flex-direction: column;\n width: 100%;\n height: 100%;\n min-width: 0;\n min-height: 0;\n background: var(--pd-surface, #fff);\n color: var(--pd-text, #263244);\n border-left: 1px solid var(--pd-border, #e4e8ef);\n}\n.cc-print-design-ai-header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n box-sizing: border-box;\n height: var(--pd-panel-header-height, 36px);\n flex: 0 0 var(--pd-panel-header-height, 36px);\n padding: 0 12px;\n border-bottom: 1px solid var(--pd-border, #e4e8ef);\n}\n.cc-print-design-ai-header > div {\n display: flex;\n align-items: center;\n gap: 8px;\n}\n.cc-print-design-ai-panel button {\n cursor: pointer;\n font: inherit;\n}\n.cc-print-design-ai-header button,\n.cc-print-design-ai-composer-more {\n border: 0;\n background: transparent;\n color: inherit;\n}\n.cc-print-design-ai-messages {\n flex: 1;\n min-height: 0;\n overflow: auto;\n overscroll-behavior: contain;\n}\n.cc-print-design-ai-message {\n box-sizing: border-box;\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n padding: 9px 12px;\n}\n.cc-print-design-ai-message-user {\n align-items: flex-end;\n}\n.cc-print-design-ai-message > span {\n display: block;\n max-width: 85%;\n margin-bottom: 4px;\n color: var(--pd-muted, #8993a2);\n font-size: 11px;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.cc-print-design-ai-message p {\n margin: 0;\n max-width: min(85%, 680px);\n padding: 10px;\n border-radius: 10px;\n background: var(--pd-hover, #f5f7fa);\n white-space: pre-wrap;\n overflow-wrap: anywhere;\n line-height: 1.5;\n}\n.cc-print-design-ai-message-user p {\n background: var(--pd-selected, #edf4ff);\n}\n.cc-print-design-ai-artifact {\n display: flex;\n flex-direction: column;\n gap: 3px;\n max-width: min(85%, 680px);\n margin-top: 7px;\n padding: 10px 12px;\n border: 1px solid var(--pd-border, #e4e8ef);\n border-radius: 10px;\n color: inherit;\n text-decoration: none;\n background: var(--pd-hover, #f5f7fa);\n cursor: pointer;\n text-align: left;\n font: inherit;\n}\n.cc-print-design-ai-artifact:hover {\n border-color: #5b8def;\n}\n.cc-print-design-ai-artifact small {\n color: var(--pd-muted, #64748b);\n line-height: 1.4;\n}\n.cc-print-design-ai-artifact span:last-child {\n color: #2563eb;\n}\n.cc-print-design-ai-reasoning {\n box-sizing: border-box;\n width: min(85%, 680px);\n max-width: 100%;\n margin-bottom: 6px;\n border: 1px solid var(--pd-border, #e4e8ef);\n border-radius: 8px;\n background: var(--pd-hover, #f5f7fa);\n}\n.cc-print-design-ai-reasoning-trigger {\n display: flex;\n align-items: center;\n gap: 6px;\n width: 100%;\n padding: 7px 10px;\n border: 0;\n background: transparent;\n color: var(--pd-muted, #8993a2);\n text-align: left;\n cursor: pointer;\n}\n.cc-print-design-ai-reasoning-trigger > svg {\n flex: 0 0 auto;\n transition: transform 180ms ease;\n}\n.cc-print-design-ai-reasoning-trigger[aria-expanded=true] > svg {\n transform: rotate(90deg);\n}\n.cc-print-design-ai-reasoning-trigger:focus-visible {\n outline: 2px solid var(--pd-primary, #1677ff);\n outline-offset: -2px;\n}\n.cc-print-design-ai-reasoning-content {\n max-height: 180px;\n overflow: auto;\n padding: 0 10px 10px;\n font-size: 12px;\n line-height: 1.5;\n white-space: pre-wrap;\n overflow-wrap: anywhere;\n}\n@media (prefers-reduced-motion: reduce) {\n .cc-print-design-ai-reasoning-trigger > svg {\n transition: none;\n }\n}\n.cc-print-design-ai-message-thinking .cc-print-design-ai-thinking-indicator {\n display: inline-flex;\n align-items: center;\n gap: 8px;\n color: var(--pd-muted, #8993a2);\n}\n.cc-print-design-ai-thinking-dots {\n display: inline-flex;\n align-items: center;\n gap: 3px;\n}\n.cc-print-design-ai-thinking-dots i {\n width: 5px;\n height: 5px;\n border-radius: 50%;\n background: currentColor;\n animation: cc-print-design-ai-thinking 1s ease-in-out infinite;\n}\n.cc-print-design-ai-thinking-dots i:nth-child(2) {\n animation-delay: 0.16s;\n}\n.cc-print-design-ai-thinking-dots i:nth-child(3) {\n animation-delay: 0.32s;\n}\n.cc-print-design-ai-message-thinking.is-paused .cc-print-design-ai-thinking-dots i {\n animation-play-state: paused;\n}\n@keyframes cc-print-design-ai-thinking {\n 0%, 60%, 100% {\n opacity: 0.35;\n transform: translateY(0);\n }\n 30% {\n opacity: 1;\n transform: translateY(-3px);\n }\n}\n@media (prefers-reduced-motion: reduce) {\n .cc-print-design-ai-thinking-dots i {\n animation: none;\n }\n}\n.cc-print-design-ai-settings {\n display: grid;\n gap: 8px;\n padding: 12px;\n border-top: 1px solid var(--pd-border, #e4e8ef);\n max-height: 48%;\n overflow: auto;\n}\n.cc-print-design-ai-settings label {\n display: grid;\n gap: 4px;\n}\n.cc-print-design-ai-composer textarea {\n box-sizing: border-box;\n width: 100%;\n padding: 8px;\n border: 1px solid var(--pd-border, #e4e8ef);\n border-radius: 6px;\n background: var(--pd-surface, #fff);\n color: inherit;\n font: inherit;\n}\n.cc-print-design-ai-settings-actions {\n display: flex;\n justify-content: flex-end;\n gap: 8px;\n}\n.cc-print-design-ai-key-row {\n display: flex;\n align-items: end;\n gap: 8px;\n}\n.cc-print-design-ai-key-row label {\n flex: 1;\n min-width: 0;\n}\n.cc-print-design-ai-key-row button {\n flex: 0 0 auto;\n white-space: nowrap;\n}\n.cc-print-design-ai-width-fields {\n display: grid;\n grid-template-columns: repeat(3, minmax(0, 1fr));\n gap: 6px;\n}\n.cc-print-design-ai-profile-picker {\n display: flex;\n align-items: end;\n gap: 8px;\n}\n.cc-print-design-ai-profile-picker label {\n flex: 1;\n min-width: 0;\n}\n.cc-print-design-ai-profile-picker button {\n height: 34px;\n}\n.cc-print-design-ai-dialog-layout {\n display: flex;\n height: 100%;\n min-height: 0;\n}\n.cc-print-design-ai-dialog-nav {\n display: flex;\n width: 150px;\n flex: 0 0 150px;\n flex-direction: column;\n gap: 4px;\n padding: 14px 8px;\n border-right: 1px solid var(--pd-border, #e4e8ef);\n background: var(--pd-hover, #f5f7fa);\n}\n.cc-print-design-ai-dialog-nav button {\n padding: 10px 12px;\n border: 0;\n border-radius: 6px;\n background: transparent;\n text-align: left;\n cursor: pointer;\n}\n.cc-print-design-ai-dialog-nav button[aria-current=page] {\n background: var(--pd-selected, #edf4ff);\n color: var(--pd-primary, #1677ff);\n}\n.cc-print-design-ai-dialog-content {\n flex: 1;\n min-width: 0;\n min-height: 0;\n overflow: auto;\n}\n.cc-print-design-ai-dialog .cc-print-design-ai-settings {\n max-height: none;\n border-top: 0;\n}\n.cc-print-design-ai-history {\n min-height: 140px;\n max-height: none;\n overflow: auto;\n padding: 8px 0;\n}\n.cc-print-design-ai-history > p {\n color: var(--pd-muted, #8993a2);\n text-align: center;\n}\n.cc-print-design-ai-history-item {\n display: flex;\n align-items: center;\n gap: 8px;\n border-bottom: 1px solid var(--pd-border, #e4e8ef);\n}\n.cc-print-design-ai-history-item > button:first-child {\n display: flex;\n flex: 1;\n min-width: 0;\n flex-direction: column;\n align-items: flex-start;\n gap: 4px;\n padding: 9px 10px;\n border: 0;\n background: transparent;\n text-align: left;\n cursor: pointer;\n}\n.cc-print-design-ai-history-item > button:first-child.active {\n color: var(--pd-primary, #1677ff);\n}\n.cc-print-design-ai-history-item span {\n overflow: hidden;\n max-width: 100%;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.cc-print-design-ai-history-item small {\n color: var(--pd-muted, #8993a2);\n}\n.cc-print-design-ai-history-delete {\n border: 0;\n background: transparent;\n color: var(--pd-danger, #dc2626);\n cursor: pointer;\n}\n.cc-print-design-ai-composer {\n padding: 10px;\n border-top: 1px solid var(--pd-border, #e4e8ef);\n}\n.cc-print-design-ai-attachments,\n.cc-print-design-ai-message-attachments {\n display: flex;\n flex-wrap: wrap;\n gap: 6px;\n min-width: 0;\n}\n.cc-print-design-ai-attachments {\n max-height: 116px;\n margin-bottom: 8px;\n overflow: auto;\n}\n.cc-print-design-ai-attachment {\n display: flex;\n align-items: center;\n gap: 5px;\n max-width: 100%;\n padding: 4px 6px;\n border: 1px solid var(--pd-border, #e4e8ef);\n border-radius: 6px;\n font-size: 11px;\n}\n.cc-print-design-ai-attachment .cc-print-design-ai-image-trigger img {\n width: 28px;\n height: 28px;\n object-fit: cover;\n}\n.cc-print-design-ai-panel .cc-print-design-ai-image-trigger {\n display: block;\n padding: 0;\n border: 0;\n border-radius: 5px;\n background: transparent;\n cursor: zoom-in;\n}\n.cc-print-design-ai-image-trigger:focus-visible {\n outline: 2px solid var(--pd-primary, #1677ff);\n outline-offset: 2px;\n}\n.cc-print-design-ai-attachment > span:nth-last-child(2) {\n overflow: hidden;\n max-width: 145px;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.cc-print-design-ai-attachment > button {\n border: 0;\n background: transparent;\n cursor: pointer;\n}\n.cc-print-design-ai-message-attachments {\n margin-top: 7px;\n}\n.cc-print-design-ai-message-user .cc-print-design-ai-message-attachments {\n align-self: flex-end;\n justify-content: flex-end;\n max-width: min(85%, 680px);\n margin-left: auto;\n}\n.cc-print-design-ai-message-attachments figure {\n display: flex;\n flex-direction: column;\n align-items: flex-end;\n max-width: 100%;\n margin: 0;\n}\n.cc-print-design-ai-message-attachments .cc-print-design-ai-image-trigger {\n max-width: min(100%, 240px);\n}\n.cc-print-design-ai-message-attachments img {\n display: block;\n max-width: min(100%, 240px);\n max-height: 180px;\n border-radius: 5px;\n object-fit: contain;\n}\n.cc-print-design-ai-message-attachments figcaption,\n.cc-print-design-ai-message-attachments > span {\n overflow: hidden;\n max-width: 100%;\n color: var(--pd-muted, #8993a2);\n font-size: 11px;\n text-overflow: ellipsis;\n text-align: right;\n white-space: nowrap;\n}\n.cc-print-design-ai-composer-attach {\n display: grid;\n flex: 0 0 30px;\n width: 30px;\n height: 30px;\n place-items: center;\n border: 0;\n border-radius: 5px;\n background: transparent;\n color: inherit;\n cursor: pointer;\n}\n.cc-print-design-ai-composer-attach:hover {\n background: var(--pd-hover, #f5f7fa);\n}\n.cc-print-design-ai-selection {\n min-width: 0;\n margin-bottom: 8px;\n color: var(--pd-muted, #8993a2);\n font-size: 11px;\n}\n.cc-print-design-ai-selection-items {\n display: flex;\n flex-wrap: wrap;\n gap: 5px;\n max-height: 80px;\n margin-top: 5px;\n overflow: auto;\n}\n.cc-print-design-ai-selection-item {\n max-width: 100%;\n}\n.cc-print-design-ai-selection-item strong,\n.cc-print-design-ai-selection-item small {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.cc-print-design-ai-selection-item strong {\n flex: 0 0 auto;\n max-width: 115px;\n}\n.cc-print-design-ai-selection-item small {\n flex: 1 1 auto;\n min-width: 0;\n color: var(--pd-muted, #8993a2);\n}\n.cc-print-design-ai-composer textarea {\n resize: vertical;\n min-height: 70px;\n}\n.cc-print-design-ai-composer-tools {\n display: flex;\n align-items: center;\n gap: 8px;\n margin-top: 6px;\n}\n.cc-print-design-ai-composer-options {\n display: flex;\n flex: 1 1 auto;\n align-items: center;\n gap: 8px;\n min-width: 0;\n}\n.cc-print-design-ai-composer-options .canvas-react-select-wrap:first-child {\n flex: 1 1 auto;\n min-width: 0;\n}\n.cc-print-design-ai-composer-options .canvas-react-select-wrap:last-child {\n flex: 0 0 94px;\n min-width: 0;\n}\n.cc-print-design-ai-composer-actions {\n display: flex;\n flex: 0 0 auto;\n align-items: center;\n gap: 4px;\n margin-left: auto;\n}\n');
|
|
41
|
+
function useStorageKeyState(storageKey, createInitial) {
|
|
42
|
+
const initial = useMemo(createInitial, [storageKey]);
|
|
43
|
+
const [state, setState] = useState(() => ({ storageKey, value: initial }));
|
|
44
|
+
const activeKey = useRef(storageKey);
|
|
45
|
+
useLayoutEffect(() => {
|
|
46
|
+
activeKey.current = storageKey;
|
|
47
|
+
}, [storageKey]);
|
|
48
|
+
const setValue = useCallback(
|
|
49
|
+
(update) => {
|
|
50
|
+
if (activeKey.current !== storageKey) return;
|
|
51
|
+
setState((current) => {
|
|
52
|
+
if (activeKey.current !== storageKey) return current;
|
|
53
|
+
const value = current.storageKey === storageKey ? current.value : initial;
|
|
54
|
+
return {
|
|
55
|
+
storageKey,
|
|
56
|
+
value: typeof update === "function" ? update(value) : update
|
|
57
|
+
};
|
|
58
|
+
});
|
|
59
|
+
},
|
|
60
|
+
[storageKey, initial]
|
|
61
|
+
);
|
|
62
|
+
return [state.storageKey === storageKey ? state.value : initial, setValue];
|
|
63
|
+
}
|
|
39
64
|
var conditionalOperators = {
|
|
40
65
|
eq: "\u7B49\u4E8E",
|
|
41
66
|
neq: "\u4E0D\u7B49\u4E8E",
|
|
@@ -1382,7 +1407,27 @@ function ReactTableContextMenuView(props) {
|
|
|
1382
1407
|
onChange: request.onChangeDensity
|
|
1383
1408
|
}
|
|
1384
1409
|
),
|
|
1410
|
+
request.onOpenPaginationConfig ? /* @__PURE__ */ jsx(
|
|
1411
|
+
MenuAction,
|
|
1412
|
+
{
|
|
1413
|
+
label: "\u5206\u9875\u914D\u7F6E",
|
|
1414
|
+
onClick: () => {
|
|
1415
|
+
request.onClose();
|
|
1416
|
+
request.onOpenPaginationConfig?.();
|
|
1417
|
+
}
|
|
1418
|
+
}
|
|
1419
|
+
) : null,
|
|
1385
1420
|
/* @__PURE__ */ jsx(ZoomMenu, { value: request.zoom ?? 1, onChange: request.onChangeZoom }),
|
|
1421
|
+
request.onToggleDebug ? /* @__PURE__ */ jsx(
|
|
1422
|
+
MenuAction,
|
|
1423
|
+
{
|
|
1424
|
+
label: request.debugEnabled ? "\u5173\u95ED\u8C03\u8BD5" : "\u5F00\u542F\u8C03\u8BD5",
|
|
1425
|
+
onClick: () => {
|
|
1426
|
+
request.onClose();
|
|
1427
|
+
request.onToggleDebug?.();
|
|
1428
|
+
}
|
|
1429
|
+
}
|
|
1430
|
+
) : null,
|
|
1386
1431
|
request.columnSettingsCacheAvailable === true ? /* @__PURE__ */ jsx(
|
|
1387
1432
|
MenuSubmenu,
|
|
1388
1433
|
{
|
|
@@ -4233,6 +4278,147 @@ function ReactListTablePrintProvider(props) {
|
|
|
4233
4278
|
function useReactListTablePrintIntegration() {
|
|
4234
4279
|
return useContext(PrintIntegrationContext);
|
|
4235
4280
|
}
|
|
4281
|
+
function cancelRequest(session) {
|
|
4282
|
+
session.version++;
|
|
4283
|
+
if (session.timer !== void 0) clearTimeout(session.timer);
|
|
4284
|
+
session.timer = void 0;
|
|
4285
|
+
session.controller?.abort();
|
|
4286
|
+
session.controller = void 0;
|
|
4287
|
+
}
|
|
4288
|
+
function mergeOptions(records, getValue) {
|
|
4289
|
+
const values = /* @__PURE__ */ new Map();
|
|
4290
|
+
records.forEach((record) => values.set(getValue(record), record));
|
|
4291
|
+
return [...values.values()];
|
|
4292
|
+
}
|
|
4293
|
+
function useTableSelectOptions(options) {
|
|
4294
|
+
const { editorKey, config, active } = options;
|
|
4295
|
+
const request = config?.request;
|
|
4296
|
+
const pageSize = typeof config?.pageSize === "number" && Number.isFinite(config.pageSize) && config.pageSize >= 1 ? Math.floor(config.pageSize) : 30;
|
|
4297
|
+
const debounce = typeof config?.debounce === "number" && Number.isFinite(config.debounce) && config.debounce >= 0 ? config.debounce : 300;
|
|
4298
|
+
const sessionRef = useRef();
|
|
4299
|
+
const [, refresh] = useState(0);
|
|
4300
|
+
const previous = sessionRef.current;
|
|
4301
|
+
if (!previous || previous.editorKey !== editorKey || previous.active !== active || previous.request !== request || previous.getOptionValue !== config?.getOptionValue || previous.pageSize !== pageSize || previous.debounce !== debounce) {
|
|
4302
|
+
const sameEditor = previous?.editorKey === editorKey && previous.active && active;
|
|
4303
|
+
if (previous) {
|
|
4304
|
+
previous.alive = false;
|
|
4305
|
+
cancelRequest(previous);
|
|
4306
|
+
}
|
|
4307
|
+
sessionRef.current = {
|
|
4308
|
+
editorKey,
|
|
4309
|
+
active,
|
|
4310
|
+
request,
|
|
4311
|
+
getOptionValue: config?.getOptionValue,
|
|
4312
|
+
pageSize,
|
|
4313
|
+
debounce,
|
|
4314
|
+
alive: true,
|
|
4315
|
+
version: 0,
|
|
4316
|
+
keyword: sameEditor ? previous.keyword : options.initialKeyword ?? "",
|
|
4317
|
+
page: 0,
|
|
4318
|
+
dataSource: config?.dataSource ?? [],
|
|
4319
|
+
loading: active && !!request,
|
|
4320
|
+
hasMore: false
|
|
4321
|
+
};
|
|
4322
|
+
}
|
|
4323
|
+
const session = sessionRef.current;
|
|
4324
|
+
const isCurrent = useCallback(
|
|
4325
|
+
() => session.alive && session.active && sessionRef.current === session,
|
|
4326
|
+
[session]
|
|
4327
|
+
);
|
|
4328
|
+
const notify = useCallback(() => {
|
|
4329
|
+
if (isCurrent()) refresh((value) => value + 1);
|
|
4330
|
+
}, [isCurrent]);
|
|
4331
|
+
const load = useCallback(
|
|
4332
|
+
(page, wait) => {
|
|
4333
|
+
if (!isCurrent() || !session.request || !session.getOptionValue) return;
|
|
4334
|
+
cancelRequest(session);
|
|
4335
|
+
const version = session.version;
|
|
4336
|
+
session.loading = true;
|
|
4337
|
+
session.error = void 0;
|
|
4338
|
+
session.failedPage = void 0;
|
|
4339
|
+
notify();
|
|
4340
|
+
const run = async () => {
|
|
4341
|
+
session.timer = void 0;
|
|
4342
|
+
if (!isCurrent() || session.version !== version) return;
|
|
4343
|
+
const controller = new AbortController();
|
|
4344
|
+
session.controller = controller;
|
|
4345
|
+
try {
|
|
4346
|
+
const result = await session.request({
|
|
4347
|
+
keyword: session.keyword,
|
|
4348
|
+
page,
|
|
4349
|
+
pageSize: session.pageSize,
|
|
4350
|
+
signal: controller.signal
|
|
4351
|
+
});
|
|
4352
|
+
if (!isCurrent() || session.version !== version || controller.signal.aborted)
|
|
4353
|
+
return;
|
|
4354
|
+
if (!result || !Array.isArray(result.data) || typeof result.hasMore !== "boolean")
|
|
4355
|
+
throw new Error("\u5019\u9009\u67E5\u8BE2\u7ED3\u679C\u683C\u5F0F\u65E0\u6548");
|
|
4356
|
+
session.dataSource = mergeOptions(
|
|
4357
|
+
page === 1 ? result.data : [...session.dataSource, ...result.data],
|
|
4358
|
+
session.getOptionValue
|
|
4359
|
+
);
|
|
4360
|
+
session.page = page;
|
|
4361
|
+
session.hasMore = result.hasMore;
|
|
4362
|
+
} catch (error) {
|
|
4363
|
+
if (!isCurrent() || session.version !== version || controller.signal.aborted)
|
|
4364
|
+
return;
|
|
4365
|
+
session.error = error instanceof Error ? error : new Error(
|
|
4366
|
+
typeof error === "string" ? error : "\u5019\u9009\u67E5\u8BE2\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5"
|
|
4367
|
+
);
|
|
4368
|
+
session.failedPage = page;
|
|
4369
|
+
} finally {
|
|
4370
|
+
if (isCurrent() && session.version === version) {
|
|
4371
|
+
session.controller = void 0;
|
|
4372
|
+
session.loading = false;
|
|
4373
|
+
notify();
|
|
4374
|
+
}
|
|
4375
|
+
}
|
|
4376
|
+
};
|
|
4377
|
+
if (wait && session.debounce > 0)
|
|
4378
|
+
session.timer = setTimeout(() => {
|
|
4379
|
+
void run();
|
|
4380
|
+
}, session.debounce);
|
|
4381
|
+
else void run();
|
|
4382
|
+
},
|
|
4383
|
+
[session, isCurrent, notify]
|
|
4384
|
+
);
|
|
4385
|
+
useEffect(() => {
|
|
4386
|
+
session.alive = true;
|
|
4387
|
+
if (session.active && session.request) load(1, false);
|
|
4388
|
+
return () => {
|
|
4389
|
+
session.alive = false;
|
|
4390
|
+
cancelRequest(session);
|
|
4391
|
+
};
|
|
4392
|
+
}, [session, load]);
|
|
4393
|
+
const onSearch = useCallback(
|
|
4394
|
+
(keyword) => {
|
|
4395
|
+
if (!isCurrent() || !session.request || session.keyword === keyword)
|
|
4396
|
+
return;
|
|
4397
|
+
session.keyword = keyword;
|
|
4398
|
+
load(1, true);
|
|
4399
|
+
},
|
|
4400
|
+
[session, isCurrent, load]
|
|
4401
|
+
);
|
|
4402
|
+
const onLoadMore = useCallback(() => {
|
|
4403
|
+
if (!isCurrent() || !session.request || session.loading || session.error || !session.hasMore)
|
|
4404
|
+
return;
|
|
4405
|
+
load(session.page + 1, false);
|
|
4406
|
+
}, [session, isCurrent, load]);
|
|
4407
|
+
const retry = useCallback(() => {
|
|
4408
|
+
if (!isCurrent() || !session.request || session.loading || !session.error)
|
|
4409
|
+
return;
|
|
4410
|
+
load(session.failedPage ?? 1, false);
|
|
4411
|
+
}, [session, isCurrent, load]);
|
|
4412
|
+
return {
|
|
4413
|
+
dataSource: request && active ? session.dataSource : config?.dataSource ?? [],
|
|
4414
|
+
loading: active && !!request && session.loading,
|
|
4415
|
+
error: active && request ? session.error : void 0,
|
|
4416
|
+
hasMore: active && !!request && session.hasMore,
|
|
4417
|
+
onSearch,
|
|
4418
|
+
onLoadMore,
|
|
4419
|
+
retry
|
|
4420
|
+
};
|
|
4421
|
+
}
|
|
4236
4422
|
|
|
4237
4423
|
// src/features/editor/utils.ts
|
|
4238
4424
|
function toNumberValue(value) {
|
|
@@ -4276,6 +4462,7 @@ function getEditorInputStyle(request) {
|
|
|
4276
4462
|
color: request.theme.cellColor ?? request.theme.textColor,
|
|
4277
4463
|
textAlign: request.theme.textAlign,
|
|
4278
4464
|
fontFamily: request.theme.fontFamily,
|
|
4465
|
+
fontWeight: request.theme.fontWeight ?? "normal",
|
|
4279
4466
|
fontSize,
|
|
4280
4467
|
// 用像素 token,确保 select/time/color 触发器与内部 Input 同步缩放。
|
|
4281
4468
|
["--canvas-react-control-height"]: `${height}px`,
|
|
@@ -4305,6 +4492,8 @@ function resolveEditorOverlayStyle(params) {
|
|
|
4305
4492
|
minHeight: height,
|
|
4306
4493
|
zIndex: 1200,
|
|
4307
4494
|
boxSizing: "border-box",
|
|
4495
|
+
fontFamily: params.fontFamily,
|
|
4496
|
+
fontWeight: params.fontWeight ?? "normal",
|
|
4308
4497
|
// 覆盖表单组件 token,使输入框高度/字号/内边距跟随表格缩放。
|
|
4309
4498
|
["--canvas-react-control-height"]: `${height}px`,
|
|
4310
4499
|
["--canvas-react-control-padding-inline"]: `${Math.max(resolvedPaddingInline - 1, 0)}px`,
|
|
@@ -4318,160 +4507,1087 @@ function resolveEditorOverlayStyle(params) {
|
|
|
4318
4507
|
} : null
|
|
4319
4508
|
};
|
|
4320
4509
|
}
|
|
4321
|
-
function
|
|
4322
|
-
const {
|
|
4323
|
-
const
|
|
4324
|
-
|
|
4325
|
-
|
|
4326
|
-
|
|
4327
|
-
|
|
4328
|
-
|
|
4510
|
+
function CompositeItemEditor(props) {
|
|
4511
|
+
const { item, value, onValueChange, initialText } = props;
|
|
4512
|
+
const base = {
|
|
4513
|
+
disabled: item.disabled,
|
|
4514
|
+
readOnly: item.readOnly,
|
|
4515
|
+
"aria-label": item.label ?? item.key,
|
|
4516
|
+
"aria-invalid": props.feedback?.length ? true : void 0,
|
|
4517
|
+
style: {
|
|
4518
|
+
width: "100%",
|
|
4519
|
+
height: "100%",
|
|
4520
|
+
minHeight: 0,
|
|
4521
|
+
border: 0,
|
|
4522
|
+
borderRadius: 0,
|
|
4523
|
+
boxShadow: "none",
|
|
4524
|
+
...props.style
|
|
4329
4525
|
}
|
|
4330
4526
|
};
|
|
4331
|
-
|
|
4332
|
-
|
|
4333
|
-
|
|
4334
|
-
|
|
4335
|
-
|
|
4336
|
-
|
|
4337
|
-
|
|
4338
|
-
|
|
4339
|
-
|
|
4340
|
-
|
|
4341
|
-
|
|
4342
|
-
|
|
4343
|
-
|
|
4344
|
-
|
|
4345
|
-
|
|
4346
|
-
|
|
4347
|
-
|
|
4348
|
-
|
|
4349
|
-
|
|
4350
|
-
|
|
4351
|
-
|
|
4352
|
-
|
|
4353
|
-
|
|
4354
|
-
|
|
4355
|
-
|
|
4356
|
-
}
|
|
4357
|
-
const handleWheel = (event) => {
|
|
4358
|
-
event.preventDefault();
|
|
4359
|
-
event.stopPropagation();
|
|
4360
|
-
if (!wheelCommittedRef.current) {
|
|
4361
|
-
wheelCommittedRef.current = true;
|
|
4362
|
-
request.onCommit();
|
|
4363
|
-
}
|
|
4364
|
-
request.onWheel?.(event);
|
|
4365
|
-
};
|
|
4366
|
-
host.addEventListener("wheel", handleWheel, { passive: false });
|
|
4367
|
-
return () => host.removeEventListener("wheel", handleWheel);
|
|
4368
|
-
}, [request]);
|
|
4369
|
-
return /* @__PURE__ */ jsx(ReactContentScaleProvider, { scale: contentZoom, children: /* @__PURE__ */ jsx("div", { ref: editorHostRef, children: renderEditorByType(editorRequest, style) }, request.editorKey) });
|
|
4370
|
-
}
|
|
4371
|
-
function renderEditorByType(request, style) {
|
|
4372
|
-
switch (request.config.valueType ?? "text") {
|
|
4373
|
-
case "tree-select":
|
|
4374
|
-
return /* @__PURE__ */ jsx(TreeSelectEditor, { request, style });
|
|
4375
|
-
case "cascader":
|
|
4376
|
-
return /* @__PURE__ */ jsx(CascaderEditor, { request, style });
|
|
4527
|
+
const numeric = {
|
|
4528
|
+
min: toNumericProp(item.min),
|
|
4529
|
+
max: toNumericProp(item.max),
|
|
4530
|
+
step: toNumericProp(item.step),
|
|
4531
|
+
precision: item.precision
|
|
4532
|
+
};
|
|
4533
|
+
const scalar = typeof value === "number" || typeof value === "string" ? value : void 0;
|
|
4534
|
+
const text = value == null ? "" : String(value);
|
|
4535
|
+
const stringRange = Array.isArray(value) ? [String(value[0] ?? ""), String(value[1] ?? "")] : ["", ""];
|
|
4536
|
+
const numberRange = Array.isArray(value) ? [toNumberValue(value[0]), toNumberValue(value[1])] : [null, null];
|
|
4537
|
+
const date = {
|
|
4538
|
+
...base,
|
|
4539
|
+
value: text,
|
|
4540
|
+
allowClear: item.allowClear ?? false,
|
|
4541
|
+
showArrow: false,
|
|
4542
|
+
onChange: (next) => onValueChange(next, { trigger: "change" })
|
|
4543
|
+
};
|
|
4544
|
+
const range = {
|
|
4545
|
+
...base,
|
|
4546
|
+
value: stringRange,
|
|
4547
|
+
allowClear: item.allowClear ?? false,
|
|
4548
|
+
rangeSeparator: item.rangeSeparator,
|
|
4549
|
+
onChange: (next) => onValueChange(next, { trigger: "change" })
|
|
4550
|
+
};
|
|
4551
|
+
switch (item.valueType ?? "text") {
|
|
4377
4552
|
case "number":
|
|
4378
|
-
return /* @__PURE__ */ jsx(
|
|
4379
|
-
|
|
4380
|
-
|
|
4553
|
+
return /* @__PURE__ */ jsx(
|
|
4554
|
+
ReactInputNumber,
|
|
4555
|
+
{
|
|
4556
|
+
...base,
|
|
4557
|
+
...numeric,
|
|
4558
|
+
initialText: initialText ?? (typeof value === "string" ? value : void 0),
|
|
4559
|
+
placeholder: item.placeholder,
|
|
4560
|
+
value: toNumberValue(value),
|
|
4561
|
+
onChange: (next) => onValueChange(next, { trigger: "input" })
|
|
4562
|
+
}
|
|
4563
|
+
);
|
|
4564
|
+
case "select":
|
|
4565
|
+
return /* @__PURE__ */ jsx(
|
|
4566
|
+
ReactSelect,
|
|
4567
|
+
{
|
|
4568
|
+
...base,
|
|
4569
|
+
value: scalar,
|
|
4570
|
+
options: item.options ?? [],
|
|
4571
|
+
allowClear: item.allowClear,
|
|
4572
|
+
showSearch: item.showSearch ?? initialText !== void 0,
|
|
4573
|
+
filterOption: item.filterOption,
|
|
4574
|
+
initialSearchValue: initialText,
|
|
4575
|
+
placeholder: item.placeholder,
|
|
4576
|
+
onChange: (next, meta) => {
|
|
4577
|
+
const option = item.options?.find(
|
|
4578
|
+
(option2) => String(option2.value) === String(next)
|
|
4579
|
+
);
|
|
4580
|
+
onValueChange(option?.value ?? next, { ...meta, option });
|
|
4581
|
+
}
|
|
4582
|
+
}
|
|
4583
|
+
);
|
|
4584
|
+
case "auto-complete":
|
|
4585
|
+
return /* @__PURE__ */ jsx(CompositeAutoComplete, { ...props, style: base.style });
|
|
4586
|
+
case "table-select":
|
|
4587
|
+
return /* @__PURE__ */ jsx(CompositeTableSelect, { ...props });
|
|
4381
4588
|
case "year":
|
|
4382
|
-
return /* @__PURE__ */ jsx(
|
|
4589
|
+
return /* @__PURE__ */ jsx(ReactYearPicker, { ...date });
|
|
4383
4590
|
case "quarter":
|
|
4384
|
-
return /* @__PURE__ */ jsx(
|
|
4591
|
+
return /* @__PURE__ */ jsx(ReactQuarterPicker, { ...date });
|
|
4385
4592
|
case "month":
|
|
4386
|
-
return /* @__PURE__ */ jsx(
|
|
4593
|
+
return /* @__PURE__ */ jsx(ReactMonthPicker, { ...date });
|
|
4387
4594
|
case "date":
|
|
4388
|
-
return /* @__PURE__ */ jsx(
|
|
4389
|
-
case "date-range":
|
|
4390
|
-
return /* @__PURE__ */ jsx(DateRangeEditor, { request, style });
|
|
4595
|
+
return /* @__PURE__ */ jsx(ReactDatePicker, { ...date });
|
|
4391
4596
|
case "time":
|
|
4392
|
-
return /* @__PURE__ */ jsx(
|
|
4597
|
+
return /* @__PURE__ */ jsx(ReactTimePicker, { ...date });
|
|
4393
4598
|
case "datetime":
|
|
4394
|
-
return /* @__PURE__ */ jsx(
|
|
4395
|
-
case "
|
|
4396
|
-
return /* @__PURE__ */ jsx(
|
|
4599
|
+
return /* @__PURE__ */ jsx(ReactDateTimePicker, { ...date });
|
|
4600
|
+
case "date-range":
|
|
4601
|
+
return /* @__PURE__ */ jsx(ReactDateRangePicker, { ...range });
|
|
4397
4602
|
case "timerange":
|
|
4398
|
-
return /* @__PURE__ */ jsx(
|
|
4399
|
-
|
|
4400
|
-
|
|
4401
|
-
|
|
4402
|
-
|
|
4403
|
-
|
|
4404
|
-
|
|
4603
|
+
return /* @__PURE__ */ jsx(
|
|
4604
|
+
ReactTimeRangePicker,
|
|
4605
|
+
{
|
|
4606
|
+
...base,
|
|
4607
|
+
value: stringRange,
|
|
4608
|
+
rangeSeparator: item.rangeSeparator,
|
|
4609
|
+
onChange: range.onChange
|
|
4610
|
+
}
|
|
4611
|
+
);
|
|
4612
|
+
case "datetime-range":
|
|
4613
|
+
return /* @__PURE__ */ jsx(ReactDateTimeRangePicker, { ...range });
|
|
4614
|
+
case "input-range":
|
|
4615
|
+
return /* @__PURE__ */ jsx(
|
|
4616
|
+
ReactInputRange,
|
|
4617
|
+
{
|
|
4618
|
+
initialText,
|
|
4619
|
+
...base,
|
|
4620
|
+
...numeric,
|
|
4621
|
+
value: numberRange,
|
|
4622
|
+
rangeSeparator: item.rangeSeparator,
|
|
4623
|
+
onChange: (next) => onValueChange(next, { trigger: "input" })
|
|
4624
|
+
}
|
|
4625
|
+
);
|
|
4626
|
+
case "math-interval":
|
|
4627
|
+
return /* @__PURE__ */ jsx(
|
|
4628
|
+
ReactMathInterval,
|
|
4629
|
+
{
|
|
4630
|
+
...base,
|
|
4631
|
+
...numeric,
|
|
4632
|
+
value: normalizeMathInterval(value),
|
|
4633
|
+
initialText,
|
|
4634
|
+
onChange: (next) => onValueChange(next, { trigger: "input" })
|
|
4635
|
+
}
|
|
4636
|
+
);
|
|
4637
|
+
case "number-unit":
|
|
4638
|
+
return /* @__PURE__ */ jsx(
|
|
4639
|
+
ReactInputNumberUnit,
|
|
4640
|
+
{
|
|
4641
|
+
...base,
|
|
4642
|
+
...numeric,
|
|
4643
|
+
value: normalizeNumberUnit$1(value, item.numberUnit?.unit),
|
|
4644
|
+
initialText,
|
|
4645
|
+
placeholder: item.placeholder,
|
|
4646
|
+
unit: item.numberUnit?.unit,
|
|
4647
|
+
unitOptions: item.numberUnit?.options,
|
|
4648
|
+
unitWidth: item.numberUnit?.unitWidth,
|
|
4649
|
+
unitRequired: item.numberUnit?.unitRequired,
|
|
4650
|
+
unitPlaceholder: item.numberUnit?.unitPlaceholder,
|
|
4651
|
+
onChange: onValueChange
|
|
4652
|
+
}
|
|
4653
|
+
);
|
|
4405
4654
|
default:
|
|
4406
|
-
return /* @__PURE__ */ jsx(
|
|
4655
|
+
return /* @__PURE__ */ jsx(
|
|
4656
|
+
ReactInput,
|
|
4657
|
+
{
|
|
4658
|
+
...base,
|
|
4659
|
+
value: text,
|
|
4660
|
+
placeholder: item.placeholder,
|
|
4661
|
+
allowClear: item.allowClear,
|
|
4662
|
+
onChange: (event) => onValueChange(event.target.value, { trigger: "input" })
|
|
4663
|
+
}
|
|
4664
|
+
);
|
|
4407
4665
|
}
|
|
4408
4666
|
}
|
|
4409
|
-
function
|
|
4410
|
-
const
|
|
4411
|
-
const
|
|
4412
|
-
|
|
4413
|
-
|
|
4414
|
-
|
|
4415
|
-
|
|
4416
|
-
|
|
4417
|
-
|
|
4667
|
+
function CompositeTableSelect(props) {
|
|
4668
|
+
const config = props.item.tableSelect;
|
|
4669
|
+
const options = useTableSelectOptions({
|
|
4670
|
+
editorKey: JSON.stringify([props.editorKey, props.item.key]),
|
|
4671
|
+
config,
|
|
4672
|
+
active: !props.item.disabled,
|
|
4673
|
+
initialKeyword: props.initialText
|
|
4674
|
+
});
|
|
4675
|
+
const generation = useRef(0);
|
|
4418
4676
|
useEffect(() => {
|
|
4419
|
-
|
|
4420
|
-
|
|
4421
|
-
|
|
4422
|
-
|
|
4677
|
+
generation.current++;
|
|
4678
|
+
return () => {
|
|
4679
|
+
generation.current++;
|
|
4680
|
+
};
|
|
4681
|
+
}, [props.editorKey, props.item.key, config?.onCreate]);
|
|
4682
|
+
if (!config) return /* @__PURE__ */ jsx("span", { role: "alert", children: "\u591A\u5217\u9009\u62E9\u7F3A\u5C11\u5019\u9009\u914D\u7F6E" });
|
|
4683
|
+
const {
|
|
4684
|
+
request,
|
|
4685
|
+
debounce,
|
|
4686
|
+
pageSize,
|
|
4687
|
+
dataSource,
|
|
4688
|
+
columns,
|
|
4689
|
+
onCreate,
|
|
4690
|
+
...component
|
|
4691
|
+
} = config;
|
|
4692
|
+
const mapped = columns.map(
|
|
4693
|
+
({ format, ...column }) => ({
|
|
4694
|
+
...column,
|
|
4695
|
+
render: format ? (value, record, index) => {
|
|
4696
|
+
const result = format(value, record, index);
|
|
4697
|
+
return typeof result === "boolean" ? String(result) : result;
|
|
4698
|
+
} : void 0
|
|
4699
|
+
})
|
|
4700
|
+
);
|
|
4701
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4702
|
+
/* @__PURE__ */ jsx(
|
|
4703
|
+
ReactTableSelect,
|
|
4704
|
+
{
|
|
4705
|
+
...component,
|
|
4706
|
+
columns: mapped,
|
|
4707
|
+
dataSource: options.dataSource,
|
|
4708
|
+
value: typeof props.value === "string" || typeof props.value === "number" ? props.value : void 0,
|
|
4709
|
+
disabled: props.item.disabled,
|
|
4710
|
+
readOnly: props.item.readOnly,
|
|
4711
|
+
"aria-label": props.item.label ?? props.item.key,
|
|
4712
|
+
"aria-invalid": !!props.feedback?.length || void 0,
|
|
4713
|
+
placeholder: props.item.placeholder,
|
|
4714
|
+
allowClear: props.item.allowClear,
|
|
4715
|
+
showSearch: props.item.showSearch,
|
|
4716
|
+
initialSearchValue: props.initialText,
|
|
4717
|
+
filterOption: request ? false : config.filterOption,
|
|
4718
|
+
loading: options.loading,
|
|
4719
|
+
hasMore: options.hasMore,
|
|
4720
|
+
onLoadMore: options.onLoadMore,
|
|
4721
|
+
onSearch: options.onSearch,
|
|
4722
|
+
allowCreate: !!config.allowCreate && !options.loading && !options.error,
|
|
4723
|
+
onCreate: onCreate ? async (keyword) => {
|
|
4724
|
+
const epoch = generation.current;
|
|
4725
|
+
const next = await onCreate(keyword);
|
|
4726
|
+
return epoch === generation.current ? next : void 0;
|
|
4727
|
+
} : void 0,
|
|
4728
|
+
onChange: (next, option, info) => props.onValueChange(next, {
|
|
4729
|
+
trigger: info.trigger,
|
|
4730
|
+
...info.trigger === "clear" ? {} : { option }
|
|
4731
|
+
}),
|
|
4732
|
+
style: { width: "100%", height: "100%", border: 0, ...props.style }
|
|
4733
|
+
}
|
|
4734
|
+
),
|
|
4735
|
+
options.error && /* @__PURE__ */ jsxs("div", { role: "alert", children: [
|
|
4736
|
+
options.error.message,
|
|
4737
|
+
/* @__PURE__ */ jsx("button", { type: "button", onClick: options.retry, children: "\u91CD\u8BD5\u67E5\u8BE2" })
|
|
4738
|
+
] })
|
|
4739
|
+
] });
|
|
4740
|
+
}
|
|
4741
|
+
function CompositeAutoComplete(props) {
|
|
4742
|
+
const { item } = props;
|
|
4743
|
+
const options = useRef(item.options ?? []), epoch = useRef(0), alive = useRef(true);
|
|
4744
|
+
useEffect(() => {
|
|
4745
|
+
options.current = item.options ?? [];
|
|
4746
|
+
}, [item.options]);
|
|
4747
|
+
useEffect(() => {
|
|
4748
|
+
alive.current = true;
|
|
4749
|
+
epoch.current++;
|
|
4750
|
+
return () => {
|
|
4751
|
+
alive.current = false;
|
|
4752
|
+
epoch.current++;
|
|
4753
|
+
};
|
|
4754
|
+
}, [props.editorKey, item.key]);
|
|
4755
|
+
return /* @__PURE__ */ jsx(
|
|
4756
|
+
ReactAutoComplete,
|
|
4423
4757
|
{
|
|
4424
|
-
value,
|
|
4425
|
-
|
|
4426
|
-
|
|
4427
|
-
|
|
4428
|
-
|
|
4429
|
-
|
|
4430
|
-
|
|
4431
|
-
|
|
4432
|
-
|
|
4433
|
-
|
|
4434
|
-
|
|
4435
|
-
|
|
4436
|
-
|
|
4437
|
-
|
|
4438
|
-
|
|
4439
|
-
|
|
4440
|
-
|
|
4441
|
-
|
|
4758
|
+
value: typeof props.value === "number" || typeof props.value === "string" ? props.value : void 0,
|
|
4759
|
+
options: item.options ?? [],
|
|
4760
|
+
filterOption: item.filterOption,
|
|
4761
|
+
initialSearchValue: props.initialText,
|
|
4762
|
+
disabled: item.disabled,
|
|
4763
|
+
readOnly: item.readOnly,
|
|
4764
|
+
"aria-label": item.label ?? item.key,
|
|
4765
|
+
"aria-invalid": !!props.feedback?.length || void 0,
|
|
4766
|
+
style: props.style,
|
|
4767
|
+
allowClear: item.allowClear,
|
|
4768
|
+
placeholder: item.placeholder,
|
|
4769
|
+
onChange: (next, meta) => {
|
|
4770
|
+
if (alive.current)
|
|
4771
|
+
props.onValueChange(next, {
|
|
4772
|
+
...meta,
|
|
4773
|
+
option: options.current.find(
|
|
4774
|
+
(option) => String(option.value) === String(next)
|
|
4775
|
+
)
|
|
4776
|
+
});
|
|
4442
4777
|
},
|
|
4443
|
-
|
|
4778
|
+
onPressEnter: async (input) => {
|
|
4779
|
+
const current = epoch.current;
|
|
4780
|
+
const next = await item.onPressEnter?.(input);
|
|
4781
|
+
if (!alive.current || current !== epoch.current) return;
|
|
4782
|
+
if (next) options.current = next;
|
|
4783
|
+
return next;
|
|
4784
|
+
}
|
|
4444
4785
|
}
|
|
4445
|
-
) });
|
|
4446
|
-
}
|
|
4447
|
-
function NumberEditor(props) {
|
|
4448
|
-
const { request, style } = props;
|
|
4449
|
-
const [value, setValue] = useState(
|
|
4450
|
-
toNumberValue(request.value)
|
|
4451
4786
|
);
|
|
4787
|
+
}
|
|
4788
|
+
function CompositeEditor({
|
|
4789
|
+
request,
|
|
4790
|
+
style
|
|
4791
|
+
}) {
|
|
4792
|
+
const items = request.config.items ?? [];
|
|
4452
4793
|
const hostRef = useRef(null);
|
|
4453
|
-
const
|
|
4794
|
+
const seeded = useRef();
|
|
4795
|
+
const [, refresh] = useState(0), local = useRef({});
|
|
4796
|
+
const source = useRef(request.value);
|
|
4797
|
+
if (source.current !== request.value) {
|
|
4798
|
+
source.current = request.value;
|
|
4799
|
+
local.current = {};
|
|
4800
|
+
}
|
|
4801
|
+
const leaving = useRef(false), version = useRef(0), current = useRef(request);
|
|
4802
|
+
current.current = request;
|
|
4803
|
+
const publish = (key, value, meta) => {
|
|
4804
|
+
local.current = { ...local.current, [key]: value };
|
|
4805
|
+
version.current++;
|
|
4806
|
+
leaving.current = false;
|
|
4807
|
+
refresh((next) => next + 1);
|
|
4808
|
+
request.onChange(value, {
|
|
4809
|
+
...meta,
|
|
4810
|
+
trigger: meta?.trigger ?? "change",
|
|
4811
|
+
itemKey: key
|
|
4812
|
+
});
|
|
4813
|
+
};
|
|
4814
|
+
const leave = (direction) => {
|
|
4815
|
+
if (leaving.current || current.current.feedback?.pending) return;
|
|
4816
|
+
leaving.current = true;
|
|
4817
|
+
const epoch = version.current;
|
|
4818
|
+
const result = direction ? current.current.onNavigate?.(direction) : current.current.onCommit({ restoreTableFocus: true });
|
|
4819
|
+
if (result && typeof result.then === "function")
|
|
4820
|
+
void result.then(
|
|
4821
|
+
(accepted) => {
|
|
4822
|
+
if (accepted === false && version.current === epoch)
|
|
4823
|
+
leaving.current = false;
|
|
4824
|
+
},
|
|
4825
|
+
() => {
|
|
4826
|
+
if (version.current === epoch) leaving.current = false;
|
|
4827
|
+
}
|
|
4828
|
+
);
|
|
4829
|
+
};
|
|
4830
|
+
const zoom = request.theme.contentZoom ?? 1;
|
|
4831
|
+
const widths = resolveListTableEditorItemWidths(
|
|
4832
|
+
items,
|
|
4833
|
+
Math.max(0, ((request.hostRect ?? request.rect).width - 2) / zoom)
|
|
4834
|
+
);
|
|
4835
|
+
const scaledWidths = widths.map((width) => width * zoom);
|
|
4836
|
+
const values = request.value && typeof request.value === "object" ? request.value : {};
|
|
4837
|
+
const entry = items.find(
|
|
4838
|
+
(item) => item.key === request.initialItemKey && !item.disabled && !item.readOnly
|
|
4839
|
+
) ?? items.find((item) => !item.disabled && !item.readOnly);
|
|
4454
4840
|
useLayoutEffect(() => {
|
|
4455
|
-
const
|
|
4456
|
-
|
|
4457
|
-
|
|
4458
|
-
|
|
4459
|
-
|
|
4460
|
-
|
|
4841
|
+
const seedKey = JSON.stringify([request.editorKey, entry?.key]);
|
|
4842
|
+
if (seeded.current !== seedKey && request.initialText !== void 0 && entry && ["text", "auto-complete"].includes(entry.valueType ?? "text")) {
|
|
4843
|
+
seeded.current = seedKey;
|
|
4844
|
+
publish(entry.key, request.initialText, { trigger: "input" });
|
|
4845
|
+
}
|
|
4846
|
+
if (request.initialText === void 0 || entry?.valueType !== "math-interval")
|
|
4847
|
+
return;
|
|
4848
|
+
const slot = Array.from(
|
|
4849
|
+
hostRef.current?.querySelectorAll(
|
|
4850
|
+
"[data-input-group-item]"
|
|
4851
|
+
) ?? []
|
|
4852
|
+
).find((element) => element.dataset.inputGroupItem === entry.key);
|
|
4853
|
+
const input = slot?.querySelector(
|
|
4854
|
+
"[data-math-interval-control]"
|
|
4855
|
+
);
|
|
4856
|
+
input?.focus();
|
|
4857
|
+
if (input) {
|
|
4858
|
+
if (request.selectOnFocus === false)
|
|
4859
|
+
input.setSelectionRange(input.value.length, input.value.length);
|
|
4860
|
+
else input.select();
|
|
4861
|
+
}
|
|
4862
|
+
}, [request.editorKey]);
|
|
4461
4863
|
return /* @__PURE__ */ jsx("div", { ref: hostRef, style, children: /* @__PURE__ */ jsx(
|
|
4462
|
-
|
|
4864
|
+
ReactInputGroup,
|
|
4463
4865
|
{
|
|
4464
|
-
|
|
4465
|
-
|
|
4466
|
-
|
|
4467
|
-
|
|
4468
|
-
|
|
4469
|
-
|
|
4470
|
-
|
|
4471
|
-
|
|
4866
|
+
initialItemKey: entry?.key,
|
|
4867
|
+
selectOnFocus: request.selectOnFocus,
|
|
4868
|
+
onLeave: () => leave(),
|
|
4869
|
+
onBoundaryTab: (direction) => leave(direction),
|
|
4870
|
+
onPressEnter: () => leave(),
|
|
4871
|
+
onCancel: () => {
|
|
4872
|
+
if (leaving.current) return;
|
|
4873
|
+
leaving.current = true;
|
|
4874
|
+
request.onCancel();
|
|
4472
4875
|
},
|
|
4473
|
-
|
|
4474
|
-
|
|
4876
|
+
items: items.map((item, index) => {
|
|
4877
|
+
const errors = request.feedback?.itemErrors?.[item.key];
|
|
4878
|
+
const errorStyle = errors?.length ? {
|
|
4879
|
+
backgroundColor: "#ff4d4f",
|
|
4880
|
+
color: "#fff",
|
|
4881
|
+
["--canvas-react-color-bg"]: "#ff4d4f",
|
|
4882
|
+
["--canvas-react-color-text"]: "#fff",
|
|
4883
|
+
["--canvas-react-color-text-muted"]: "#fff",
|
|
4884
|
+
["--canvas-react-color-text-secondary"]: "#fff"
|
|
4885
|
+
} : {};
|
|
4886
|
+
return {
|
|
4887
|
+
key: item.key,
|
|
4888
|
+
width: scaledWidths[index],
|
|
4889
|
+
children: /* @__PURE__ */ jsx(
|
|
4890
|
+
"div",
|
|
4891
|
+
{
|
|
4892
|
+
"data-input-group-readonly": item.readOnly || void 0,
|
|
4893
|
+
onFocusCapture: (event) => {
|
|
4894
|
+
if (item.readOnly) event.stopPropagation();
|
|
4895
|
+
},
|
|
4896
|
+
onClickCapture: (event) => {
|
|
4897
|
+
if (item.readOnly) event.stopPropagation();
|
|
4898
|
+
},
|
|
4899
|
+
onKeyDownCapture: (event) => {
|
|
4900
|
+
if (item.readOnly && !["Tab", "Escape"].includes(event.key) && !event.ctrlKey && !event.metaKey) {
|
|
4901
|
+
event.preventDefault();
|
|
4902
|
+
event.stopPropagation();
|
|
4903
|
+
}
|
|
4904
|
+
},
|
|
4905
|
+
style: { height: "100%", ...errorStyle },
|
|
4906
|
+
"aria-invalid": !!errors?.length || void 0,
|
|
4907
|
+
children: /* @__PURE__ */ jsx(
|
|
4908
|
+
CompositeItemEditor,
|
|
4909
|
+
{
|
|
4910
|
+
item,
|
|
4911
|
+
value: Object.prototype.hasOwnProperty.call(
|
|
4912
|
+
local.current,
|
|
4913
|
+
item.key
|
|
4914
|
+
) ? local.current[item.key] : values[item.key],
|
|
4915
|
+
editorKey: request.editorKey,
|
|
4916
|
+
initialText: entry?.key === item.key ? request.initialText : void 0,
|
|
4917
|
+
feedback: errors,
|
|
4918
|
+
style: {
|
|
4919
|
+
fontSize: request.theme.fontSize,
|
|
4920
|
+
fontFamily: request.theme.fontFamily,
|
|
4921
|
+
fontWeight: request.theme.fontWeight ?? "normal",
|
|
4922
|
+
color: request.theme.textColor,
|
|
4923
|
+
...errorStyle
|
|
4924
|
+
},
|
|
4925
|
+
onValueChange: (value, meta) => {
|
|
4926
|
+
if (!item.disabled && !item.readOnly)
|
|
4927
|
+
publish(item.key, value, meta);
|
|
4928
|
+
}
|
|
4929
|
+
}
|
|
4930
|
+
)
|
|
4931
|
+
}
|
|
4932
|
+
)
|
|
4933
|
+
};
|
|
4934
|
+
})
|
|
4935
|
+
}
|
|
4936
|
+
) });
|
|
4937
|
+
}
|
|
4938
|
+
|
|
4939
|
+
// src/features/editor/editor-change.ts
|
|
4940
|
+
function publishEditorChange(request, value, meta = { trigger: "change" }) {
|
|
4941
|
+
if (!request.config.hasChangeHandler && request.config.valueType !== "table-select") {
|
|
4942
|
+
request.onChange(value);
|
|
4943
|
+
return;
|
|
4944
|
+
}
|
|
4945
|
+
const normalized = meta.trigger === "clear" ? { trigger: "clear" } : {
|
|
4946
|
+
trigger: meta.trigger ?? "change",
|
|
4947
|
+
...meta.option !== void 0 ? { option: meta.option } : {},
|
|
4948
|
+
...meta.options !== void 0 ? { options: meta.options } : {}
|
|
4949
|
+
};
|
|
4950
|
+
request.onChange(value, normalized);
|
|
4951
|
+
}
|
|
4952
|
+
function containsEditorInteraction(host, target, popupClassName) {
|
|
4953
|
+
if (!(target instanceof Node)) return false;
|
|
4954
|
+
if (host?.contains(target)) return true;
|
|
4955
|
+
if (!(target instanceof Element)) return false;
|
|
4956
|
+
const popup = target.closest(".canvas-react-popup");
|
|
4957
|
+
return !!popup && (!popupClassName || !!popup.querySelector(`.${popupClassName}`));
|
|
4958
|
+
}
|
|
4959
|
+
|
|
4960
|
+
// src/features/editor/use-composite-editor-session.ts
|
|
4961
|
+
function useCompositeEditorSession(request) {
|
|
4962
|
+
const hostRef = useRef(null), inputRef = useRef(null);
|
|
4963
|
+
const current = useRef(request);
|
|
4964
|
+
current.current = request;
|
|
4965
|
+
const leaving = useRef(false), version = useRef(0);
|
|
4966
|
+
useLayoutEffect(() => {
|
|
4967
|
+
const input = inputRef.current;
|
|
4968
|
+
if (!input) return;
|
|
4969
|
+
input.focus();
|
|
4970
|
+
if (request.selectOnFocus === false)
|
|
4971
|
+
input.setSelectionRange(input.value.length, input.value.length);
|
|
4972
|
+
else input.select();
|
|
4973
|
+
return () => {
|
|
4974
|
+
version.current++;
|
|
4975
|
+
};
|
|
4976
|
+
}, [request.editorKey]);
|
|
4977
|
+
const settle = (result, epoch) => {
|
|
4978
|
+
if (result && typeof result.then === "function")
|
|
4979
|
+
void result.then(
|
|
4980
|
+
(accepted) => {
|
|
4981
|
+
if (accepted === false && epoch === version.current)
|
|
4982
|
+
leaving.current = false;
|
|
4983
|
+
},
|
|
4984
|
+
() => {
|
|
4985
|
+
if (epoch === version.current) leaving.current = false;
|
|
4986
|
+
}
|
|
4987
|
+
);
|
|
4988
|
+
};
|
|
4989
|
+
const commit = () => {
|
|
4990
|
+
if (leaving.current) return;
|
|
4991
|
+
leaving.current = true;
|
|
4992
|
+
settle(
|
|
4993
|
+
current.current.onCommit({ restoreTableFocus: true }),
|
|
4994
|
+
version.current
|
|
4995
|
+
);
|
|
4996
|
+
};
|
|
4997
|
+
return {
|
|
4998
|
+
hostRef,
|
|
4999
|
+
inputRef,
|
|
5000
|
+
notifyChange(value, meta = { trigger: "input" }) {
|
|
5001
|
+
version.current++;
|
|
5002
|
+
leaving.current = false;
|
|
5003
|
+
publishEditorChange(current.current, value, meta);
|
|
5004
|
+
},
|
|
5005
|
+
onMouseDown(event) {
|
|
5006
|
+
if (event.target === event.currentTarget) event.preventDefault();
|
|
5007
|
+
},
|
|
5008
|
+
onBlur() {
|
|
5009
|
+
if (!leaving.current && !current.current.feedback?.pending) commit();
|
|
5010
|
+
},
|
|
5011
|
+
onKeyDown(event) {
|
|
5012
|
+
if (event.nativeEvent.isComposing) return;
|
|
5013
|
+
if (event.key === "Escape") {
|
|
5014
|
+
event.preventDefault();
|
|
5015
|
+
event.stopPropagation();
|
|
5016
|
+
version.current++;
|
|
5017
|
+
leaving.current = true;
|
|
5018
|
+
current.current.onCancel();
|
|
5019
|
+
return;
|
|
5020
|
+
}
|
|
5021
|
+
if (event.key === "Tab") {
|
|
5022
|
+
const controls = Array.from(
|
|
5023
|
+
hostRef.current?.querySelectorAll(
|
|
5024
|
+
"input:not(:disabled),select:not(:disabled)"
|
|
5025
|
+
) ?? []
|
|
5026
|
+
);
|
|
5027
|
+
const index = controls.indexOf(event.target);
|
|
5028
|
+
const target = controls[index + (event.shiftKey ? -1 : 1)];
|
|
5029
|
+
event.preventDefault();
|
|
5030
|
+
event.stopPropagation();
|
|
5031
|
+
if (target) {
|
|
5032
|
+
target.focus();
|
|
5033
|
+
if (target instanceof HTMLInputElement) target.select();
|
|
5034
|
+
} else if (!current.current.feedback?.pending) {
|
|
5035
|
+
leaving.current = true;
|
|
5036
|
+
settle(
|
|
5037
|
+
current.current.onNavigate?.(event.shiftKey ? "prev" : "next"),
|
|
5038
|
+
version.current
|
|
5039
|
+
);
|
|
5040
|
+
}
|
|
5041
|
+
return;
|
|
5042
|
+
}
|
|
5043
|
+
if ([
|
|
5044
|
+
"ArrowUp",
|
|
5045
|
+
"ArrowDown",
|
|
5046
|
+
"ArrowLeft",
|
|
5047
|
+
"ArrowRight",
|
|
5048
|
+
"Home",
|
|
5049
|
+
"End"
|
|
5050
|
+
].includes(event.key))
|
|
5051
|
+
event.stopPropagation();
|
|
5052
|
+
},
|
|
5053
|
+
onPressEnter(event) {
|
|
5054
|
+
event.preventDefault();
|
|
5055
|
+
event.stopPropagation();
|
|
5056
|
+
commit();
|
|
5057
|
+
}
|
|
5058
|
+
};
|
|
5059
|
+
}
|
|
5060
|
+
function NumberUnitEditor({
|
|
5061
|
+
request,
|
|
5062
|
+
style
|
|
5063
|
+
}) {
|
|
5064
|
+
const config = request.config.numberUnit;
|
|
5065
|
+
const [value, setValue] = useState(
|
|
5066
|
+
() => normalizeNumberUnit(request.value, config?.unit)
|
|
5067
|
+
);
|
|
5068
|
+
const session = useCompositeEditorSession(request);
|
|
5069
|
+
return /* @__PURE__ */ jsx("div", { ref: session.hostRef, style, onMouseDown: session.onMouseDown, children: /* @__PURE__ */ jsx(
|
|
5070
|
+
ReactInputNumberUnit,
|
|
5071
|
+
{
|
|
5072
|
+
ref: session.inputRef,
|
|
5073
|
+
value,
|
|
5074
|
+
initialText: request.initialText,
|
|
5075
|
+
unit: config?.unit,
|
|
5076
|
+
unitOptions: config?.options,
|
|
5077
|
+
unitWidth: config?.unitWidth,
|
|
5078
|
+
unitRequired: config?.unitRequired,
|
|
5079
|
+
unitPlaceholder: config?.unitPlaceholder,
|
|
5080
|
+
placeholder: request.config.placeholder,
|
|
5081
|
+
min: toNumericProp(request.config.min),
|
|
5082
|
+
max: toNumericProp(request.config.max),
|
|
5083
|
+
step: toNumericProp(request.config.step),
|
|
5084
|
+
precision: request.config.precision,
|
|
5085
|
+
style: getEditorInputStyle(request),
|
|
5086
|
+
onChange: (next, info) => {
|
|
5087
|
+
setValue(next);
|
|
5088
|
+
session.notifyChange(next, info);
|
|
5089
|
+
},
|
|
5090
|
+
onBlur: session.onBlur,
|
|
5091
|
+
onKeyDown: session.onKeyDown,
|
|
5092
|
+
onPressEnter: session.onPressEnter
|
|
5093
|
+
}
|
|
5094
|
+
) });
|
|
5095
|
+
}
|
|
5096
|
+
function MathIntervalEditor({
|
|
5097
|
+
request,
|
|
5098
|
+
style
|
|
5099
|
+
}) {
|
|
5100
|
+
const [value, setValue] = useState(
|
|
5101
|
+
() => normalizeMathInterval(request.value)
|
|
5102
|
+
);
|
|
5103
|
+
const session = useCompositeEditorSession(request);
|
|
5104
|
+
return /* @__PURE__ */ jsx("div", { ref: session.hostRef, style, onMouseDown: session.onMouseDown, children: /* @__PURE__ */ jsx(
|
|
5105
|
+
ReactMathInterval,
|
|
5106
|
+
{
|
|
5107
|
+
ref: session.inputRef,
|
|
5108
|
+
value,
|
|
5109
|
+
initialText: request.initialText,
|
|
5110
|
+
min: toNumericProp(request.config.min),
|
|
5111
|
+
max: toNumericProp(request.config.max),
|
|
5112
|
+
step: toNumericProp(request.config.step),
|
|
5113
|
+
precision: request.config.precision,
|
|
5114
|
+
style: getEditorInputStyle(request),
|
|
5115
|
+
onChange: (next) => {
|
|
5116
|
+
setValue(next);
|
|
5117
|
+
session.notifyChange(next);
|
|
5118
|
+
},
|
|
5119
|
+
onBlur: session.onBlur,
|
|
5120
|
+
onKeyDown: session.onKeyDown,
|
|
5121
|
+
onPressEnter: session.onPressEnter
|
|
5122
|
+
}
|
|
5123
|
+
) });
|
|
5124
|
+
}
|
|
5125
|
+
function TableSelectEditor({
|
|
5126
|
+
request,
|
|
5127
|
+
style
|
|
5128
|
+
}) {
|
|
5129
|
+
const config = request.config.tableSelect;
|
|
5130
|
+
const [value, setValue] = useState(
|
|
5131
|
+
toValue(request.value)
|
|
5132
|
+
);
|
|
5133
|
+
const [cancelled, setCancelled] = useState(false);
|
|
5134
|
+
const hostRef = useRef(null);
|
|
5135
|
+
const current = useRef(request);
|
|
5136
|
+
current.current = request;
|
|
5137
|
+
const mounted = useRef(true), creating = useRef(false), submitting = useRef(false), skipBlur = useRef(false), version = useRef(0);
|
|
5138
|
+
const popupClass = useRef(
|
|
5139
|
+
`react-list-table-table-select-${nextEditorIdentity++}`
|
|
5140
|
+
).current;
|
|
5141
|
+
const options = useTableSelectOptions({
|
|
5142
|
+
editorKey: request.editorKey ?? popupClass,
|
|
5143
|
+
config,
|
|
5144
|
+
initialKeyword: request.selectOnFocus === false ? String(request.value ?? "") : void 0,
|
|
5145
|
+
active: !cancelled
|
|
5146
|
+
});
|
|
5147
|
+
useEffect(() => {
|
|
5148
|
+
mounted.current = true;
|
|
5149
|
+
return () => {
|
|
5150
|
+
mounted.current = false;
|
|
5151
|
+
version.current++;
|
|
5152
|
+
};
|
|
5153
|
+
}, []);
|
|
5154
|
+
useEffect(() => {
|
|
5155
|
+
setValue(toValue(request.value));
|
|
5156
|
+
}, [request.value]);
|
|
5157
|
+
const submit = (restoreTableFocus = false, afterChange = false) => {
|
|
5158
|
+
const active = current.current;
|
|
5159
|
+
if (cancelled || !mounted.current || submitting.current || active.feedback?.pending && !afterChange)
|
|
5160
|
+
return;
|
|
5161
|
+
const epoch = version.current;
|
|
5162
|
+
submitting.current = true;
|
|
5163
|
+
const result = active.onCommit(
|
|
5164
|
+
restoreTableFocus ? { restoreTableFocus: true } : void 0
|
|
5165
|
+
);
|
|
5166
|
+
if (result && typeof result.then === "function")
|
|
5167
|
+
void result.then(
|
|
5168
|
+
() => {
|
|
5169
|
+
if (mounted.current && version.current === epoch) {
|
|
5170
|
+
submitting.current = false;
|
|
5171
|
+
skipBlur.current = false;
|
|
5172
|
+
}
|
|
5173
|
+
},
|
|
5174
|
+
() => {
|
|
5175
|
+
if (mounted.current && version.current === epoch) {
|
|
5176
|
+
submitting.current = false;
|
|
5177
|
+
skipBlur.current = false;
|
|
5178
|
+
}
|
|
5179
|
+
}
|
|
5180
|
+
);
|
|
5181
|
+
else submitting.current = false;
|
|
5182
|
+
return result;
|
|
5183
|
+
};
|
|
5184
|
+
const submitRef = useRef(submit);
|
|
5185
|
+
submitRef.current = submit;
|
|
5186
|
+
useEffect(() => {
|
|
5187
|
+
const outside = (event) => {
|
|
5188
|
+
if (creating.current || cancelled || containsEditorInteraction(hostRef.current, event.target, popupClass))
|
|
5189
|
+
return;
|
|
5190
|
+
submitRef.current();
|
|
5191
|
+
};
|
|
5192
|
+
document.addEventListener("mousedown", outside, true);
|
|
5193
|
+
return () => document.removeEventListener("mousedown", outside, true);
|
|
5194
|
+
}, [popupClass, cancelled]);
|
|
5195
|
+
const navigate = (event) => {
|
|
5196
|
+
if (event.key !== "Tab" || !current.current.onNavigate) return;
|
|
5197
|
+
event.preventDefault();
|
|
5198
|
+
event.stopPropagation();
|
|
5199
|
+
if (current.current.feedback?.pending || submitting.current) return;
|
|
5200
|
+
skipBlur.current = true;
|
|
5201
|
+
submitting.current = true;
|
|
5202
|
+
const epoch = version.current;
|
|
5203
|
+
const result = current.current.onNavigate(event.shiftKey ? "prev" : "next");
|
|
5204
|
+
if (result && typeof result.then === "function")
|
|
5205
|
+
void result.then(
|
|
5206
|
+
() => {
|
|
5207
|
+
if (mounted.current && version.current === epoch) {
|
|
5208
|
+
submitting.current = false;
|
|
5209
|
+
skipBlur.current = false;
|
|
5210
|
+
}
|
|
5211
|
+
},
|
|
5212
|
+
() => {
|
|
5213
|
+
if (mounted.current && version.current === epoch) {
|
|
5214
|
+
submitting.current = false;
|
|
5215
|
+
skipBlur.current = false;
|
|
5216
|
+
}
|
|
5217
|
+
}
|
|
5218
|
+
);
|
|
5219
|
+
else submitting.current = false;
|
|
5220
|
+
};
|
|
5221
|
+
if (!config)
|
|
5222
|
+
return /* @__PURE__ */ jsx("div", { style, role: "alert", children: "\u591A\u5217\u9009\u62E9\u7F3A\u5C11\u5019\u9009\u914D\u7F6E" });
|
|
5223
|
+
const {
|
|
5224
|
+
request: remoteRequest,
|
|
5225
|
+
debounce,
|
|
5226
|
+
pageSize,
|
|
5227
|
+
dataSource,
|
|
5228
|
+
columns: sourceColumns,
|
|
5229
|
+
onCreate,
|
|
5230
|
+
...componentConfig
|
|
5231
|
+
} = config;
|
|
5232
|
+
const columns = sourceColumns.map(
|
|
5233
|
+
({ format, ...column }) => ({
|
|
5234
|
+
...column,
|
|
5235
|
+
render: format ? (cell, record, index) => {
|
|
5236
|
+
const result = format(cell, record, index);
|
|
5237
|
+
return typeof result === "boolean" ? String(result) : result;
|
|
5238
|
+
} : void 0
|
|
5239
|
+
})
|
|
5240
|
+
);
|
|
5241
|
+
return /* @__PURE__ */ jsxs(
|
|
5242
|
+
"div",
|
|
5243
|
+
{
|
|
5244
|
+
ref: hostRef,
|
|
5245
|
+
style,
|
|
5246
|
+
onBlur: (event) => {
|
|
5247
|
+
if (creating.current || containsEditorInteraction(
|
|
5248
|
+
hostRef.current,
|
|
5249
|
+
event.relatedTarget,
|
|
5250
|
+
popupClass
|
|
5251
|
+
) || current.current.feedback?.pending || submitting.current)
|
|
5252
|
+
return;
|
|
5253
|
+
if (skipBlur.current) {
|
|
5254
|
+
skipBlur.current = false;
|
|
5255
|
+
return;
|
|
5256
|
+
}
|
|
5257
|
+
submit();
|
|
5258
|
+
},
|
|
5259
|
+
onKeyDownCapture: (event) => {
|
|
5260
|
+
if (event.key === "Escape") {
|
|
5261
|
+
event.preventDefault();
|
|
5262
|
+
event.stopPropagation();
|
|
5263
|
+
version.current++;
|
|
5264
|
+
setCancelled(true);
|
|
5265
|
+
current.current.onCancel();
|
|
5266
|
+
}
|
|
5267
|
+
},
|
|
5268
|
+
onKeyDown: (event) => {
|
|
5269
|
+
if (event.target !== hostRef.current?.querySelector("input"))
|
|
5270
|
+
navigate(event);
|
|
5271
|
+
},
|
|
5272
|
+
children: [
|
|
5273
|
+
/* @__PURE__ */ jsx(
|
|
5274
|
+
ReactTableSelect,
|
|
5275
|
+
{
|
|
5276
|
+
...componentConfig,
|
|
5277
|
+
dataSource: options.dataSource,
|
|
5278
|
+
columns,
|
|
5279
|
+
value,
|
|
5280
|
+
autoFocus: true,
|
|
5281
|
+
selectOnFocus: request.selectOnFocus,
|
|
5282
|
+
initialSearchValue: request.selectOnFocus === false ? String(request.value ?? "") : void 0,
|
|
5283
|
+
placeholder: request.config.placeholder,
|
|
5284
|
+
allowClear: request.config.allowClear,
|
|
5285
|
+
showSearch: request.config.showSearch,
|
|
5286
|
+
filterOption: remoteRequest ? false : config.filterOption,
|
|
5287
|
+
loading: options.loading,
|
|
5288
|
+
hasMore: options.hasMore,
|
|
5289
|
+
onLoadMore: options.onLoadMore,
|
|
5290
|
+
onSearch: options.onSearch,
|
|
5291
|
+
allowCreate: !!config.allowCreate && !options.loading && !options.error,
|
|
5292
|
+
popupClassName: popupClass,
|
|
5293
|
+
onCreate: onCreate ? async (keyword) => {
|
|
5294
|
+
const epoch = version.current;
|
|
5295
|
+
creating.current = true;
|
|
5296
|
+
try {
|
|
5297
|
+
const record = await onCreate(keyword);
|
|
5298
|
+
return mounted.current && !cancelled && version.current === epoch ? record : void 0;
|
|
5299
|
+
} finally {
|
|
5300
|
+
creating.current = false;
|
|
5301
|
+
}
|
|
5302
|
+
} : void 0,
|
|
5303
|
+
onChange: (next, option, info) => {
|
|
5304
|
+
if (cancelled || !mounted.current) return;
|
|
5305
|
+
version.current++;
|
|
5306
|
+
submitting.current = false;
|
|
5307
|
+
skipBlur.current = false;
|
|
5308
|
+
setValue(next);
|
|
5309
|
+
publishEditorChange(
|
|
5310
|
+
current.current,
|
|
5311
|
+
next,
|
|
5312
|
+
info.trigger === "clear" ? { trigger: "clear" } : { trigger: info.trigger, option }
|
|
5313
|
+
);
|
|
5314
|
+
if (info.trigger !== "clear") {
|
|
5315
|
+
skipBlur.current = true;
|
|
5316
|
+
submit(true, true);
|
|
5317
|
+
}
|
|
5318
|
+
},
|
|
5319
|
+
onKeyDown: (event) => {
|
|
5320
|
+
if (event.key === "Tab") navigate(event);
|
|
5321
|
+
else if ([
|
|
5322
|
+
"ArrowUp",
|
|
5323
|
+
"ArrowDown",
|
|
5324
|
+
"ArrowLeft",
|
|
5325
|
+
"ArrowRight",
|
|
5326
|
+
"Home",
|
|
5327
|
+
"End",
|
|
5328
|
+
"F6"
|
|
5329
|
+
].includes(event.key))
|
|
5330
|
+
event.stopPropagation();
|
|
5331
|
+
},
|
|
5332
|
+
style: getEditorInputStyle(request)
|
|
5333
|
+
}
|
|
5334
|
+
),
|
|
5335
|
+
options.error && /* @__PURE__ */ jsxs(
|
|
5336
|
+
"div",
|
|
5337
|
+
{
|
|
5338
|
+
role: "alert",
|
|
5339
|
+
style: { background: "#fff", color: "#cf1322", padding: 4 },
|
|
5340
|
+
children: [
|
|
5341
|
+
options.error.message,
|
|
5342
|
+
/* @__PURE__ */ jsx("button", { type: "button", onClick: options.retry, children: "\u91CD\u8BD5\u67E5\u8BE2" })
|
|
5343
|
+
]
|
|
5344
|
+
}
|
|
5345
|
+
)
|
|
5346
|
+
]
|
|
5347
|
+
}
|
|
5348
|
+
);
|
|
5349
|
+
}
|
|
5350
|
+
var nextEditorIdentity = 0;
|
|
5351
|
+
function toValue(value) {
|
|
5352
|
+
return typeof value === "string" || typeof value === "number" ? value : void 0;
|
|
5353
|
+
}
|
|
5354
|
+
function ReactTableEditorOverlay(props) {
|
|
5355
|
+
const { request } = props;
|
|
5356
|
+
const editorHostRef = useRef(null);
|
|
5357
|
+
const wheelCommittedRef = useRef(false);
|
|
5358
|
+
const changedSinceCommitRef = useRef(false);
|
|
5359
|
+
const editorRequest = {
|
|
5360
|
+
...request,
|
|
5361
|
+
onChange: (value, meta) => {
|
|
5362
|
+
wheelCommittedRef.current = false;
|
|
5363
|
+
changedSinceCommitRef.current = true;
|
|
5364
|
+
if (meta === void 0) request.onChange(value);
|
|
5365
|
+
else request.onChange(value, meta);
|
|
5366
|
+
},
|
|
5367
|
+
onCommit: (options) => {
|
|
5368
|
+
if (!wheelCommittedRef.current && (!request.feedback?.pending || changedSinceCommitRef.current)) {
|
|
5369
|
+
changedSinceCommitRef.current = false;
|
|
5370
|
+
return request.onCommit(options);
|
|
5371
|
+
}
|
|
5372
|
+
}
|
|
5373
|
+
};
|
|
5374
|
+
useEffect(() => {
|
|
5375
|
+
wheelCommittedRef.current = false;
|
|
5376
|
+
changedSinceCommitRef.current = false;
|
|
5377
|
+
}, [request.editorKey]);
|
|
5378
|
+
const style = resolveEditorOverlayStyle({
|
|
5379
|
+
rect: request.rect,
|
|
5380
|
+
hostRect: request.hostRect,
|
|
5381
|
+
fontSize: request.theme.fontSize,
|
|
5382
|
+
fontFamily: request.theme.fontFamily,
|
|
5383
|
+
fontWeight: request.theme.fontWeight,
|
|
5384
|
+
paddingInline: request.theme.paddingInline,
|
|
5385
|
+
paddingBlock: request.theme.paddingBlock,
|
|
5386
|
+
contentZoom: request.theme.contentZoom
|
|
5387
|
+
});
|
|
5388
|
+
const contentZoom = typeof request.theme.contentZoom === "number" && Number.isFinite(request.theme.contentZoom) && request.theme.contentZoom > 0 ? request.theme.contentZoom : 1;
|
|
5389
|
+
useLayoutEffect(() => {
|
|
5390
|
+
if (request.config.valueType === "composite" || request.config.valueType === "math-interval" || request.config.valueType === "number-unit")
|
|
5391
|
+
return;
|
|
5392
|
+
const input = editorHostRef.current?.querySelector("input");
|
|
5393
|
+
if (!input) {
|
|
5394
|
+
return;
|
|
5395
|
+
}
|
|
5396
|
+
focusAndSelectEditorInput(input, request.selectOnFocus);
|
|
5397
|
+
}, [request.editorKey]);
|
|
5398
|
+
useEffect(() => {
|
|
5399
|
+
const host = editorHostRef.current;
|
|
5400
|
+
if (!host) return;
|
|
5401
|
+
const valueType = request.config.valueType ?? "text";
|
|
5402
|
+
if (valueType !== "composite" && valueType !== "text" && valueType !== "number" && valueType !== "input-range") {
|
|
5403
|
+
return;
|
|
5404
|
+
}
|
|
5405
|
+
const handleWheel = (event) => {
|
|
5406
|
+
event.preventDefault();
|
|
5407
|
+
event.stopPropagation();
|
|
5408
|
+
if (wheelCommittedRef.current || request.feedback?.pending) return;
|
|
5409
|
+
wheelCommittedRef.current = true;
|
|
5410
|
+
const result = request.onCommit();
|
|
5411
|
+
if (result && typeof result.then === "function")
|
|
5412
|
+
void result.then(
|
|
5413
|
+
(success) => {
|
|
5414
|
+
if (!success) wheelCommittedRef.current = false;
|
|
5415
|
+
else request.onWheel?.(event);
|
|
5416
|
+
},
|
|
5417
|
+
() => {
|
|
5418
|
+
wheelCommittedRef.current = false;
|
|
5419
|
+
}
|
|
5420
|
+
);
|
|
5421
|
+
else request.onWheel?.(event);
|
|
5422
|
+
};
|
|
5423
|
+
host.addEventListener("wheel", handleWheel, { passive: false });
|
|
5424
|
+
return () => host.removeEventListener("wheel", handleWheel);
|
|
5425
|
+
}, [request]);
|
|
5426
|
+
const itemErrorOwnsFeedback = request.config.valueType === "composite" && Object.values(request.feedback?.itemErrors ?? {}).some(
|
|
5427
|
+
(errors) => errors.includes(request.feedback?.error ?? "")
|
|
5428
|
+
);
|
|
5429
|
+
return /* @__PURE__ */ jsx(ReactContentScaleProvider, { scale: contentZoom, children: /* @__PURE__ */ jsxs(
|
|
5430
|
+
"div",
|
|
5431
|
+
{
|
|
5432
|
+
ref: editorHostRef,
|
|
5433
|
+
"aria-busy": request.feedback?.pending || void 0,
|
|
5434
|
+
children: [
|
|
5435
|
+
renderEditorByType(editorRequest, style),
|
|
5436
|
+
request.feedback?.error && !itemErrorOwnsFeedback && /* @__PURE__ */ jsx(
|
|
5437
|
+
"div",
|
|
5438
|
+
{
|
|
5439
|
+
role: "alert",
|
|
5440
|
+
style: {
|
|
5441
|
+
...style,
|
|
5442
|
+
top: Number(style.top) + Number(style.height),
|
|
5443
|
+
height: "auto",
|
|
5444
|
+
minHeight: 0,
|
|
5445
|
+
padding: 4,
|
|
5446
|
+
background: "#fff",
|
|
5447
|
+
color: "#cf1322",
|
|
5448
|
+
border: "1px solid #ffccc7"
|
|
5449
|
+
},
|
|
5450
|
+
children: request.feedback.error
|
|
5451
|
+
}
|
|
5452
|
+
)
|
|
5453
|
+
]
|
|
5454
|
+
},
|
|
5455
|
+
request.editorKey
|
|
5456
|
+
) });
|
|
5457
|
+
}
|
|
5458
|
+
function renderEditorByType(request, style) {
|
|
5459
|
+
switch (request.config.valueType ?? "text") {
|
|
5460
|
+
case "composite":
|
|
5461
|
+
return /* @__PURE__ */ jsx(
|
|
5462
|
+
CompositeEditor,
|
|
5463
|
+
{
|
|
5464
|
+
request,
|
|
5465
|
+
style
|
|
5466
|
+
},
|
|
5467
|
+
request.editorKey
|
|
5468
|
+
);
|
|
5469
|
+
case "number-unit":
|
|
5470
|
+
return /* @__PURE__ */ jsx(
|
|
5471
|
+
NumberUnitEditor,
|
|
5472
|
+
{
|
|
5473
|
+
request,
|
|
5474
|
+
style
|
|
5475
|
+
},
|
|
5476
|
+
request.editorKey
|
|
5477
|
+
);
|
|
5478
|
+
case "math-interval":
|
|
5479
|
+
return /* @__PURE__ */ jsx(
|
|
5480
|
+
MathIntervalEditor,
|
|
5481
|
+
{
|
|
5482
|
+
request,
|
|
5483
|
+
style
|
|
5484
|
+
},
|
|
5485
|
+
request.editorKey
|
|
5486
|
+
);
|
|
5487
|
+
case "table-select":
|
|
5488
|
+
return /* @__PURE__ */ jsx(TableSelectEditor, { request, style });
|
|
5489
|
+
case "tree-select":
|
|
5490
|
+
return /* @__PURE__ */ jsx(TreeSelectEditor, { request, style });
|
|
5491
|
+
case "cascader":
|
|
5492
|
+
return /* @__PURE__ */ jsx(CascaderEditor, { request, style });
|
|
5493
|
+
case "number":
|
|
5494
|
+
return /* @__PURE__ */ jsx(NumberEditor, { request, style });
|
|
5495
|
+
case "input-range":
|
|
5496
|
+
return /* @__PURE__ */ jsx(InputRangeEditor, { request, style });
|
|
5497
|
+
case "year":
|
|
5498
|
+
return /* @__PURE__ */ jsx(YearEditor, { request, style });
|
|
5499
|
+
case "quarter":
|
|
5500
|
+
return /* @__PURE__ */ jsx(QuarterEditor, { request, style });
|
|
5501
|
+
case "month":
|
|
5502
|
+
return /* @__PURE__ */ jsx(MonthEditor, { request, style });
|
|
5503
|
+
case "date":
|
|
5504
|
+
return /* @__PURE__ */ jsx(DateEditor, { request, style });
|
|
5505
|
+
case "date-range":
|
|
5506
|
+
return /* @__PURE__ */ jsx(DateRangeEditor, { request, style });
|
|
5507
|
+
case "time":
|
|
5508
|
+
return /* @__PURE__ */ jsx(TimeEditor, { request, style });
|
|
5509
|
+
case "datetime":
|
|
5510
|
+
return /* @__PURE__ */ jsx(DateTimeEditor, { request, style });
|
|
5511
|
+
case "datetime-range":
|
|
5512
|
+
return /* @__PURE__ */ jsx(DateTimeRangeEditor, { request, style });
|
|
5513
|
+
case "timerange":
|
|
5514
|
+
return /* @__PURE__ */ jsx(TimeRangeEditor, { request, style });
|
|
5515
|
+
case "color":
|
|
5516
|
+
return /* @__PURE__ */ jsx(ColorEditor, { request, style });
|
|
5517
|
+
case "select":
|
|
5518
|
+
return /* @__PURE__ */ jsx(SelectEditor, { request, style });
|
|
5519
|
+
case "auto-complete":
|
|
5520
|
+
return /* @__PURE__ */ jsx(AutoCompleteEditor, { request, style });
|
|
5521
|
+
default:
|
|
5522
|
+
return /* @__PURE__ */ jsx(TextEditor, { request, style });
|
|
5523
|
+
}
|
|
5524
|
+
}
|
|
5525
|
+
function TextEditor(props) {
|
|
5526
|
+
const { request, style } = props;
|
|
5527
|
+
const [value, setValue] = useState(String(request.value ?? ""));
|
|
5528
|
+
const hostRef = useRef(null);
|
|
5529
|
+
const skipBlurCommitRef = useRef(false);
|
|
5530
|
+
useLayoutEffect(() => {
|
|
5531
|
+
const input = hostRef.current?.querySelector("input");
|
|
5532
|
+
focusAndSelectEditorInput(input, request.selectOnFocus);
|
|
5533
|
+
}, [request.editorKey]);
|
|
5534
|
+
useEffect(() => {
|
|
5535
|
+
setValue(String(request.value ?? ""));
|
|
5536
|
+
}, [request.value]);
|
|
5537
|
+
return /* @__PURE__ */ jsx("div", { ref: hostRef, style, children: /* @__PURE__ */ jsx(
|
|
5538
|
+
ReactInput,
|
|
5539
|
+
{
|
|
5540
|
+
value,
|
|
5541
|
+
placeholder: request.config.placeholder ?? "",
|
|
5542
|
+
onChange: (event) => {
|
|
5543
|
+
const nextValue = event.target.value;
|
|
5544
|
+
setValue(nextValue);
|
|
5545
|
+
publishEditorChange(request, nextValue, { trigger: "input" });
|
|
5546
|
+
},
|
|
5547
|
+
onPressEnter: () => {
|
|
5548
|
+
request.onCommit({ restoreTableFocus: true });
|
|
5549
|
+
},
|
|
5550
|
+
onBlur: (event) => {
|
|
5551
|
+
handleEditorBlur(event, skipBlurCommitRef, request);
|
|
5552
|
+
},
|
|
5553
|
+
onKeyDown: (event) => {
|
|
5554
|
+
if (handleEditorNavigationKey(event, request, skipBlurCommitRef)) {
|
|
5555
|
+
return;
|
|
5556
|
+
}
|
|
5557
|
+
handleEditorEscapeKey(event, request);
|
|
5558
|
+
},
|
|
5559
|
+
style: getEditorInputStyle(request)
|
|
5560
|
+
}
|
|
5561
|
+
) });
|
|
5562
|
+
}
|
|
5563
|
+
function NumberEditor(props) {
|
|
5564
|
+
const { request, style } = props;
|
|
5565
|
+
const [value, setValue] = useState(
|
|
5566
|
+
toNumberValue(request.value)
|
|
5567
|
+
);
|
|
5568
|
+
const hostRef = useRef(null);
|
|
5569
|
+
const skipBlurCommitRef = useRef(false);
|
|
5570
|
+
useLayoutEffect(() => {
|
|
5571
|
+
const input = hostRef.current?.querySelector("input");
|
|
5572
|
+
focusAndSelectEditorInput(input, request.selectOnFocus);
|
|
5573
|
+
}, [request.editorKey]);
|
|
5574
|
+
useEffect(() => {
|
|
5575
|
+
setValue(toNumberValue(request.value));
|
|
5576
|
+
}, [request.value]);
|
|
5577
|
+
return /* @__PURE__ */ jsx("div", { ref: hostRef, style, children: /* @__PURE__ */ jsx(
|
|
5578
|
+
ReactInputNumber,
|
|
5579
|
+
{
|
|
5580
|
+
value,
|
|
5581
|
+
initialText: typeof request.value === "string" ? request.value : void 0,
|
|
5582
|
+
min: toNumericProp(request.config.min),
|
|
5583
|
+
max: toNumericProp(request.config.max),
|
|
5584
|
+
step: toNumericProp(request.config.step),
|
|
5585
|
+
onChange: (nextValue) => {
|
|
5586
|
+
setValue(nextValue);
|
|
5587
|
+
publishEditorChange(request, nextValue, { trigger: "input" });
|
|
5588
|
+
},
|
|
5589
|
+
onPressEnter: () => {
|
|
5590
|
+
request.onCommit({ restoreTableFocus: true });
|
|
4475
5591
|
},
|
|
4476
5592
|
onBlur: (event) => {
|
|
4477
5593
|
handleEditorBlur(event, skipBlurCommitRef, request);
|
|
@@ -4506,7 +5622,7 @@ function InputRangeEditor(props) {
|
|
|
4506
5622
|
rangeSeparator: request.config.rangeSeparator,
|
|
4507
5623
|
onChange: (nextValue) => {
|
|
4508
5624
|
setValue(nextValue);
|
|
4509
|
-
request
|
|
5625
|
+
publishEditorChange(request, nextValue, { trigger: "input" });
|
|
4510
5626
|
},
|
|
4511
5627
|
onPressEnter: () => {
|
|
4512
5628
|
request.onCommit({ restoreTableFocus: true });
|
|
@@ -4545,7 +5661,7 @@ function YearEditor(props) {
|
|
|
4545
5661
|
showArrow: false,
|
|
4546
5662
|
onChange: (nextValue) => {
|
|
4547
5663
|
setValue(nextValue);
|
|
4548
|
-
request
|
|
5664
|
+
publishEditorChange(request, nextValue, { trigger: "change" });
|
|
4549
5665
|
request.onCommit();
|
|
4550
5666
|
},
|
|
4551
5667
|
onBlur: (event) => {
|
|
@@ -4579,7 +5695,7 @@ function QuarterEditor(props) {
|
|
|
4579
5695
|
showArrow: false,
|
|
4580
5696
|
onChange: (nextValue) => {
|
|
4581
5697
|
setValue(nextValue);
|
|
4582
|
-
request
|
|
5698
|
+
publishEditorChange(request, nextValue, { trigger: "change" });
|
|
4583
5699
|
request.onCommit();
|
|
4584
5700
|
},
|
|
4585
5701
|
onBlur: (event) => {
|
|
@@ -4613,7 +5729,7 @@ function MonthEditor(props) {
|
|
|
4613
5729
|
showArrow: false,
|
|
4614
5730
|
onChange: (nextValue) => {
|
|
4615
5731
|
setValue(nextValue);
|
|
4616
|
-
request
|
|
5732
|
+
publishEditorChange(request, nextValue, { trigger: "change" });
|
|
4617
5733
|
request.onCommit();
|
|
4618
5734
|
},
|
|
4619
5735
|
onBlur: (event) => {
|
|
@@ -4647,7 +5763,7 @@ function DateEditor(props) {
|
|
|
4647
5763
|
showArrow: false,
|
|
4648
5764
|
onChange: (nextValue) => {
|
|
4649
5765
|
setValue(nextValue);
|
|
4650
|
-
request
|
|
5766
|
+
publishEditorChange(request, nextValue, { trigger: "change" });
|
|
4651
5767
|
request.onCommit();
|
|
4652
5768
|
},
|
|
4653
5769
|
onBlur: (event) => {
|
|
@@ -4689,7 +5805,10 @@ function TreeSelectEditor({
|
|
|
4689
5805
|
style: getEditorInputStyle(request),
|
|
4690
5806
|
onChange: (next, _nodes, info) => {
|
|
4691
5807
|
setValue(next);
|
|
4692
|
-
request
|
|
5808
|
+
publishEditorChange(request, next, {
|
|
5809
|
+
trigger: info.trigger,
|
|
5810
|
+
options: _nodes
|
|
5811
|
+
});
|
|
4693
5812
|
if (info.complete && info.trigger !== "clear") {
|
|
4694
5813
|
skipBlurCommitRef.current = true;
|
|
4695
5814
|
request.onCommit();
|
|
@@ -4733,7 +5852,10 @@ function CascaderEditor({
|
|
|
4733
5852
|
style: getEditorInputStyle(request),
|
|
4734
5853
|
onChange: (next, _options, info) => {
|
|
4735
5854
|
setValue(next);
|
|
4736
|
-
request
|
|
5855
|
+
publishEditorChange(request, next, {
|
|
5856
|
+
trigger: info.trigger,
|
|
5857
|
+
options: _options
|
|
5858
|
+
});
|
|
4737
5859
|
if (info.complete && info.trigger !== "clear") {
|
|
4738
5860
|
skipBlurCommitRef.current = true;
|
|
4739
5861
|
request.onCommit();
|
|
@@ -4773,9 +5895,13 @@ function SelectEditor(props) {
|
|
|
4773
5895
|
onChange: (nextValue, info) => {
|
|
4774
5896
|
const resolvedValue = String(nextValue);
|
|
4775
5897
|
setValue(resolvedValue);
|
|
4776
|
-
|
|
4777
|
-
|
|
5898
|
+
const option = options.find(
|
|
5899
|
+
(option2) => String(option2.value) === resolvedValue
|
|
4778
5900
|
);
|
|
5901
|
+
publishEditorChange(request, option?.value ?? resolvedValue, {
|
|
5902
|
+
trigger: info.trigger,
|
|
5903
|
+
option
|
|
5904
|
+
});
|
|
4779
5905
|
if (info.trigger === "mouse" || info.trigger === "keyboard") {
|
|
4780
5906
|
skipBlurCommitRef.current = true;
|
|
4781
5907
|
request.onCommit({ restoreTableFocus: true });
|
|
@@ -4804,6 +5930,18 @@ function AutoCompleteEditor(props) {
|
|
|
4804
5930
|
request.value == null ? "" : String(request.value)
|
|
4805
5931
|
);
|
|
4806
5932
|
const [options, setOptions] = useState(request.config.options ?? []);
|
|
5933
|
+
const optionsRef = useRef(options);
|
|
5934
|
+
const aliveRef = useRef(true);
|
|
5935
|
+
useEffect(() => {
|
|
5936
|
+
aliveRef.current = true;
|
|
5937
|
+
return () => {
|
|
5938
|
+
aliveRef.current = false;
|
|
5939
|
+
};
|
|
5940
|
+
}, []);
|
|
5941
|
+
useEffect(() => {
|
|
5942
|
+
optionsRef.current = request.config.options ?? [];
|
|
5943
|
+
setOptions(optionsRef.current);
|
|
5944
|
+
}, [request.config.options]);
|
|
4807
5945
|
const skipBlurCommitRef = useRef(false);
|
|
4808
5946
|
useEffect(() => {
|
|
4809
5947
|
setValue(request.value == null ? "" : String(request.value));
|
|
@@ -4817,8 +5955,14 @@ function AutoCompleteEditor(props) {
|
|
|
4817
5955
|
options,
|
|
4818
5956
|
placeholder: request.config.placeholder ?? "",
|
|
4819
5957
|
onChange: (nextValue, info) => {
|
|
5958
|
+
if (!aliveRef.current) return;
|
|
4820
5959
|
setValue(nextValue);
|
|
4821
|
-
request
|
|
5960
|
+
publishEditorChange(request, nextValue, {
|
|
5961
|
+
trigger: info.trigger,
|
|
5962
|
+
option: optionsRef.current.find(
|
|
5963
|
+
(option) => String(option.value) === String(nextValue)
|
|
5964
|
+
)
|
|
5965
|
+
});
|
|
4822
5966
|
if (info.trigger === "mouse" || info.trigger === "keyboard") {
|
|
4823
5967
|
skipBlurCommitRef.current = true;
|
|
4824
5968
|
request.onCommit({ restoreTableFocus: true });
|
|
@@ -4826,7 +5970,9 @@ function AutoCompleteEditor(props) {
|
|
|
4826
5970
|
},
|
|
4827
5971
|
onPressEnter: async (input) => {
|
|
4828
5972
|
const nextOptions = await request.config.onPressEnter?.(input);
|
|
5973
|
+
if (!aliveRef.current) return;
|
|
4829
5974
|
if (nextOptions) {
|
|
5975
|
+
optionsRef.current = nextOptions;
|
|
4830
5976
|
setOptions(nextOptions);
|
|
4831
5977
|
}
|
|
4832
5978
|
return nextOptions;
|
|
@@ -4866,7 +6012,7 @@ function ColorEditor(props) {
|
|
|
4866
6012
|
showArrow: false,
|
|
4867
6013
|
onChange: (nextValue) => {
|
|
4868
6014
|
setValue(nextValue);
|
|
4869
|
-
request
|
|
6015
|
+
publishEditorChange(request, nextValue, { trigger: "change" });
|
|
4870
6016
|
},
|
|
4871
6017
|
onBlur: (event) => {
|
|
4872
6018
|
handleEditorBlur(event, skipBlurCommitRef, request);
|
|
@@ -4901,7 +6047,7 @@ function DateRangeEditor(props) {
|
|
|
4901
6047
|
rangeSeparator: separator,
|
|
4902
6048
|
onChange: (nextValue) => {
|
|
4903
6049
|
setValue(nextValue);
|
|
4904
|
-
request
|
|
6050
|
+
publishEditorChange(request, nextValue, { trigger: "change" });
|
|
4905
6051
|
},
|
|
4906
6052
|
onBlur: (event) => {
|
|
4907
6053
|
handleEditorBlur(event, skipBlurCommitRef, request);
|
|
@@ -4937,7 +6083,7 @@ function TimeEditor(props) {
|
|
|
4937
6083
|
showArrow: false,
|
|
4938
6084
|
onChange: (nextValue) => {
|
|
4939
6085
|
setValue(nextValue);
|
|
4940
|
-
request
|
|
6086
|
+
publishEditorChange(request, nextValue, { trigger: "change" });
|
|
4941
6087
|
},
|
|
4942
6088
|
onBlur: (event) => {
|
|
4943
6089
|
handleEditorBlur(event, skipBlurCommitRef, request);
|
|
@@ -4970,7 +6116,7 @@ function DateTimeEditor(props) {
|
|
|
4970
6116
|
showArrow: false,
|
|
4971
6117
|
onChange: (nextValue) => {
|
|
4972
6118
|
setValue(nextValue);
|
|
4973
|
-
request
|
|
6119
|
+
publishEditorChange(request, nextValue, { trigger: "change" });
|
|
4974
6120
|
request.onCommit();
|
|
4975
6121
|
},
|
|
4976
6122
|
onBlur: (event) => {
|
|
@@ -5006,7 +6152,7 @@ function DateTimeRangeEditor(props) {
|
|
|
5006
6152
|
rangeSeparator: separator,
|
|
5007
6153
|
onChange: (nextValue) => {
|
|
5008
6154
|
setValue(nextValue);
|
|
5009
|
-
request
|
|
6155
|
+
publishEditorChange(request, nextValue, { trigger: "change" });
|
|
5010
6156
|
},
|
|
5011
6157
|
onBlur: (event) => {
|
|
5012
6158
|
handleEditorBlur(event, skipBlurCommitRef, request);
|
|
@@ -5043,7 +6189,7 @@ function TimeRangeEditor(props) {
|
|
|
5043
6189
|
rangeSeparator: separator,
|
|
5044
6190
|
onChange: (nextValue) => {
|
|
5045
6191
|
setValue(nextValue);
|
|
5046
|
-
request
|
|
6192
|
+
publishEditorChange(request, nextValue, { trigger: "change" });
|
|
5047
6193
|
},
|
|
5048
6194
|
onBlur: (event) => {
|
|
5049
6195
|
handleEditorBlur(event, skipBlurCommitRef, request);
|
|
@@ -5067,8 +6213,18 @@ function handleEditorNavigationKey(event, request, skipBlurCommitRef) {
|
|
|
5067
6213
|
return false;
|
|
5068
6214
|
}
|
|
5069
6215
|
event.preventDefault();
|
|
6216
|
+
if (request.feedback?.pending) return true;
|
|
5070
6217
|
skipBlurCommitRef.current = true;
|
|
5071
|
-
request.onNavigate(direction);
|
|
6218
|
+
const result = request.onNavigate(direction);
|
|
6219
|
+
if (result && typeof result.then === "function")
|
|
6220
|
+
void result.then(
|
|
6221
|
+
(success) => {
|
|
6222
|
+
if (!success) skipBlurCommitRef.current = false;
|
|
6223
|
+
},
|
|
6224
|
+
() => {
|
|
6225
|
+
skipBlurCommitRef.current = false;
|
|
6226
|
+
}
|
|
6227
|
+
);
|
|
5072
6228
|
return true;
|
|
5073
6229
|
}
|
|
5074
6230
|
function handleRangeInputTab(event) {
|
|
@@ -5121,7 +6277,12 @@ function toNumberRangeTuple(value) {
|
|
|
5121
6277
|
}
|
|
5122
6278
|
return [toNumberValue(value[0]), toNumberValue(value[1])];
|
|
5123
6279
|
}
|
|
5124
|
-
function handleEditorBlur(
|
|
6280
|
+
function handleEditorBlur(event, skipBlurCommitRef, request) {
|
|
6281
|
+
if (containsEditorInteraction(
|
|
6282
|
+
event.currentTarget.closest("[data-list-table-range-editor]"),
|
|
6283
|
+
event.relatedTarget
|
|
6284
|
+
) || request.feedback?.pending)
|
|
6285
|
+
return;
|
|
5125
6286
|
if (skipBlurCommitRef.current) {
|
|
5126
6287
|
skipBlurCommitRef.current = false;
|
|
5127
6288
|
return;
|
|
@@ -5226,7 +6387,12 @@ function ReactTableFilterPanelView(props) {
|
|
|
5226
6387
|
}
|
|
5227
6388
|
|
|
5228
6389
|
// src/components/react-list-table-layout.ts
|
|
5229
|
-
function resolveReactListTablePaginationLayout(density) {
|
|
6390
|
+
function resolveReactListTablePaginationLayout(density, size) {
|
|
6391
|
+
if (size && size !== "auto") {
|
|
6392
|
+
return resolveReactListTablePaginationLayout(
|
|
6393
|
+
size === "small" ? 26 : size === "large" ? 48 : 32
|
|
6394
|
+
);
|
|
6395
|
+
}
|
|
5230
6396
|
if (typeof density === "number" && density <= 26) {
|
|
5231
6397
|
return { size: "small", height: 32, paddingTop: 8 };
|
|
5232
6398
|
}
|
|
@@ -5251,7 +6417,7 @@ function ReactTablePaginationView(props) {
|
|
|
5251
6417
|
if (!config) {
|
|
5252
6418
|
return null;
|
|
5253
6419
|
}
|
|
5254
|
-
const layout = resolveReactListTablePaginationLayout(density);
|
|
6420
|
+
const layout = resolveReactListTablePaginationLayout(density, config.size);
|
|
5255
6421
|
return /* @__PURE__ */ jsx(
|
|
5256
6422
|
"div",
|
|
5257
6423
|
{
|
|
@@ -5270,6 +6436,7 @@ function ReactTablePaginationView(props) {
|
|
|
5270
6436
|
{
|
|
5271
6437
|
styles: config.styles,
|
|
5272
6438
|
size: layout.size,
|
|
6439
|
+
pageInfoText: config.pageInfoText,
|
|
5273
6440
|
current: config.current,
|
|
5274
6441
|
total: config.total,
|
|
5275
6442
|
pageSize: config.pageSize,
|
|
@@ -5294,6 +6461,402 @@ function ReactTablePaginationView(props) {
|
|
|
5294
6461
|
}
|
|
5295
6462
|
);
|
|
5296
6463
|
}
|
|
6464
|
+
var pageInfoFormats = [
|
|
6465
|
+
{ value: "", label: "\u4E0D\u989D\u5916\u663E\u793A" },
|
|
6466
|
+
{
|
|
6467
|
+
value: "\u7B2C {current} \u9875 / \u5171 {totalPages} \u9875",
|
|
6468
|
+
label: "\u7B2C 1 \u9875 / \u5171 10 \u9875"
|
|
6469
|
+
},
|
|
6470
|
+
{ value: "{current} / {totalPages}", label: "1 / 10" },
|
|
6471
|
+
{ value: "custom", label: "\u81EA\u5B9A\u4E49\u683C\u5F0F" }
|
|
6472
|
+
];
|
|
6473
|
+
var totalFormats = [
|
|
6474
|
+
{ value: "inherit", label: "\u6CBF\u7528\u4F20\u5165\u683C\u5F0F" },
|
|
6475
|
+
{ value: "\u5171 {total} \u6761", label: "\u5171 200 \u6761" },
|
|
6476
|
+
{
|
|
6477
|
+
value: "\u7B2C {start}\u2013{end} \u6761\uFF0C\u5171 {total} \u6761",
|
|
6478
|
+
label: "\u7B2C 1\u201320 \u6761\uFF0C\u5171 200 \u6761"
|
|
6479
|
+
},
|
|
6480
|
+
{ value: "hide", label: "\u9690\u85CF" },
|
|
6481
|
+
{ value: "custom", label: "\u81EA\u5B9A\u4E49\u683C\u5F0F" }
|
|
6482
|
+
];
|
|
6483
|
+
function createPaginationDraft(snapshot, incoming = false) {
|
|
6484
|
+
const source = incoming ? snapshot.incoming : snapshot.value;
|
|
6485
|
+
const config = withPaginationDefaults(
|
|
6486
|
+
source || (incoming ? {} : snapshot.retained)
|
|
6487
|
+
);
|
|
6488
|
+
const pageTemplate = config.pageInfoFormat ?? "";
|
|
6489
|
+
const totalTemplate = typeof config.totalFormat === "string" ? config.totalFormat : "";
|
|
6490
|
+
return {
|
|
6491
|
+
cacheEnabled: snapshot.cache?.enabled ?? false,
|
|
6492
|
+
cacheScope: snapshot.cache?.scope ?? "all",
|
|
6493
|
+
enabled: !!source,
|
|
6494
|
+
config,
|
|
6495
|
+
current: String(config.current),
|
|
6496
|
+
pageSize: String(config.pageSize),
|
|
6497
|
+
minPageSize: String(config.minPageSize ?? 1),
|
|
6498
|
+
maxPageSize: config.maxPageSize == null ? "" : String(config.maxPageSize),
|
|
6499
|
+
candidates: config.pageSizeOptions.join(", "),
|
|
6500
|
+
pageChoice: pageInfoFormats.some((o) => o.value === pageTemplate) ? pageTemplate : "custom",
|
|
6501
|
+
totalChoice: config.totalFormat === false ? "hide" : config.totalFormat === void 0 ? "inherit" : totalFormats.some((o) => o.value === totalTemplate) ? totalTemplate : "custom",
|
|
6502
|
+
pageTemplate,
|
|
6503
|
+
totalTemplate
|
|
6504
|
+
};
|
|
6505
|
+
}
|
|
6506
|
+
function paginationDraftValue(draft) {
|
|
6507
|
+
if (!draft.enabled) return false;
|
|
6508
|
+
return {
|
|
6509
|
+
...draft.config,
|
|
6510
|
+
current: Number(draft.current),
|
|
6511
|
+
pageSize: Number(draft.pageSize),
|
|
6512
|
+
minPageSize: Number(draft.minPageSize),
|
|
6513
|
+
maxPageSize: draft.maxPageSize.trim() ? Number(draft.maxPageSize) : void 0,
|
|
6514
|
+
pageSizeOptions: [
|
|
6515
|
+
...new Set(draft.candidates.split(/[,,]/).map((n) => Number(n.trim())))
|
|
6516
|
+
].sort((a, b) => a - b),
|
|
6517
|
+
pageInfoFormat: draft.pageChoice === "custom" ? draft.pageTemplate : draft.pageChoice || void 0,
|
|
6518
|
+
totalFormat: draft.totalChoice === "inherit" ? void 0 : draft.totalChoice === "hide" ? false : draft.totalChoice === "custom" ? draft.totalTemplate : draft.totalChoice
|
|
6519
|
+
};
|
|
6520
|
+
}
|
|
6521
|
+
|
|
6522
|
+
// src/features/pagination/pagination-config-dialog.css
|
|
6523
|
+
styleInject(".react-list-table-pagination-config {\n display: grid;\n gap: 18px;\n color: var(--canvas-react-color-text, #253247);\n}\n.react-list-table-pagination-config-enable {\n display: flex;\n justify-content: space-between;\n align-items: center;\n gap: 16px;\n}\n.react-list-table-pagination-config-cache {\n flex-wrap: wrap;\n}\n.react-list-table-pagination-config-cache > label {\n flex-shrink: 0;\n white-space: nowrap;\n}\n.react-list-table-pagination-config-cache-scope {\n flex: 0 1 180px;\n min-width: 120px;\n}\n.react-list-table-pagination-config-help {\n color: var(--canvas-react-color-text-muted, #64748b);\n font-size: 12px;\n margin-top: 6px;\n}\n.react-list-table-pagination-config fieldset {\n border: 0;\n padding: 0;\n margin: 0;\n min-width: 0;\n}\n.react-list-table-pagination-config fieldset:disabled {\n opacity: 0.5;\n}\n.react-list-table-pagination-config h3 {\n font-size: 13px;\n margin: 18px 0 12px;\n}\n.react-list-table-pagination-config h3:first-child {\n margin-top: 0;\n}\n.react-list-table-pagination-config-grid {\n display: grid;\n grid-template-columns: repeat(2, minmax(0, 1fr));\n gap: 14px 20px;\n margin-top: 12px;\n}\n.react-list-table-pagination-config-field {\n display: grid;\n align-content: start;\n gap: 6px;\n min-width: 0;\n font-size: 13px;\n}\n.react-list-table-pagination-config-check {\n display: flex;\n align-items: center;\n gap: 6px;\n font-size: 13px;\n}\n.react-list-table-pagination-config-check input {\n accent-color: var(--canvas-react-color-primary, #2563eb);\n}\n.react-list-table-pagination-config details {\n margin-top: 18px;\n border-top: 1px solid var(--canvas-react-color-border, #e2e8f0);\n padding-top: 14px;\n}\n.react-list-table-pagination-config summary {\n cursor: pointer;\n font-size: 13px;\n font-weight: 600;\n}\n.react-list-table-pagination-config-preview {\n border-top: 1px solid var(--canvas-react-color-border, #e2e8f0);\n padding-top: 10px;\n min-width: 0;\n}\n.react-list-table-pagination-config-pager {\n display: flex;\n justify-content: flex-end;\n margin-top: 12px;\n}\n.react-list-table-pagination-config-pager > div {\n flex-wrap: wrap;\n justify-content: flex-end;\n}\n.react-list-table-pagination-config-off {\n text-align: center;\n padding: 16px 0;\n color: var(--canvas-react-color-text-muted, #64748b);\n}\n.react-list-table-pagination-config-error {\n color: var(--canvas-react-color-danger, #dc2626);\n font-size: 12px;\n}\n.react-list-table-pagination-config-footer {\n display: flex;\n justify-content: space-between;\n align-items: center;\n gap: 12px;\n flex-wrap: wrap;\n width: 100%;\n}\n.react-list-table-pagination-config-footer > div {\n display: flex;\n gap: 10px;\n margin-left: auto;\n}\n@media (max-width: 460px) {\n .react-list-table-pagination-config-grid {\n grid-template-columns: minmax(0, 1fr);\n }\n}\n");
|
|
6524
|
+
function ReactListTablePaginationConfigDialog(props) {
|
|
6525
|
+
const [initial] = useState(() => createPaginationDraft(props.snapshot));
|
|
6526
|
+
const [draft, setDraft] = useState(initial);
|
|
6527
|
+
const [currentEdited, setCurrentEdited] = useState(false);
|
|
6528
|
+
const [errors, setErrors] = useState({});
|
|
6529
|
+
const patch = (next) => setDraft((current2) => ({ ...current2, ...next }));
|
|
6530
|
+
const patchConfig = (next) => setDraft((current2) => ({
|
|
6531
|
+
...current2,
|
|
6532
|
+
config: { ...current2.config, ...next }
|
|
6533
|
+
}));
|
|
6534
|
+
const value = paginationDraftValue(draft);
|
|
6535
|
+
const scroll = draft.config.mode === "scroll";
|
|
6536
|
+
const pageSize = Math.max(
|
|
6537
|
+
1,
|
|
6538
|
+
Number.isSafeInteger(Number(draft.pageSize)) ? Number(draft.pageSize) : 10
|
|
6539
|
+
);
|
|
6540
|
+
const totalPages = Math.max(1, Math.ceil(props.snapshot.total / pageSize));
|
|
6541
|
+
const current = Math.min(totalPages, Math.max(1, Number(draft.current) || 1));
|
|
6542
|
+
const field = (label, key, control) => /* @__PURE__ */ jsxs("div", { className: "react-list-table-pagination-config-field", children: [
|
|
6543
|
+
/* @__PURE__ */ jsx("span", { children: label }),
|
|
6544
|
+
control,
|
|
6545
|
+
errors[key] ? /* @__PURE__ */ jsx("span", { role: "alert", className: "react-list-table-pagination-config-error", children: errors[key] }) : null
|
|
6546
|
+
] });
|
|
6547
|
+
const input = (label, key) => field(
|
|
6548
|
+
label,
|
|
6549
|
+
key === "candidates" ? "pageSizeOptions" : key,
|
|
6550
|
+
/* @__PURE__ */ jsx(
|
|
6551
|
+
ReactInput,
|
|
6552
|
+
{
|
|
6553
|
+
"aria-label": label,
|
|
6554
|
+
value: draft[key],
|
|
6555
|
+
inputMode: key === "candidates" ? "text" : "numeric",
|
|
6556
|
+
allowClear: false,
|
|
6557
|
+
placeholder: key === "maxPageSize" ? "\u4E0D\u9650\u5236" : void 0,
|
|
6558
|
+
onChange: (event) => {
|
|
6559
|
+
if (key === "current") setCurrentEdited(true);
|
|
6560
|
+
patch({
|
|
6561
|
+
[key]: event.target.value,
|
|
6562
|
+
...key === "pageSize" && !currentEdited ? { current: "1" } : {}
|
|
6563
|
+
});
|
|
6564
|
+
}
|
|
6565
|
+
}
|
|
6566
|
+
)
|
|
6567
|
+
);
|
|
6568
|
+
const check = (label, key, disabled = false) => /* @__PURE__ */ jsxs("label", { className: "react-list-table-pagination-config-check", children: [
|
|
6569
|
+
/* @__PURE__ */ jsx(
|
|
6570
|
+
"input",
|
|
6571
|
+
{
|
|
6572
|
+
type: "checkbox",
|
|
6573
|
+
checked: key === "allowPageSizeInput" ? draft.config.allowPageSizeInput ?? !!draft.config.showSizeChanger : !!draft.config[key],
|
|
6574
|
+
disabled,
|
|
6575
|
+
onChange: (event) => patchConfig({ [key]: event.target.checked })
|
|
6576
|
+
}
|
|
6577
|
+
),
|
|
6578
|
+
label
|
|
6579
|
+
] });
|
|
6580
|
+
const confirm = () => {
|
|
6581
|
+
if (JSON.stringify(draft) === JSON.stringify(initial)) {
|
|
6582
|
+
props.onClose();
|
|
6583
|
+
return;
|
|
6584
|
+
}
|
|
6585
|
+
const nextErrors = {
|
|
6586
|
+
...validatePaginationConfig(value, props.snapshot.total)
|
|
6587
|
+
};
|
|
6588
|
+
if (draft.enabled && draft.pageChoice === "custom" && !draft.pageTemplate.trim())
|
|
6589
|
+
nextErrors.pageInfoFormat = "\u8BF7\u8F93\u5165\u9875\u7801\u4FE1\u606F\u683C\u5F0F";
|
|
6590
|
+
setErrors(nextErrors);
|
|
6591
|
+
if (Object.keys(nextErrors).length) return;
|
|
6592
|
+
const result = props.onConfirm(value, {
|
|
6593
|
+
enabled: draft.cacheEnabled,
|
|
6594
|
+
scope: draft.cacheScope
|
|
6595
|
+
});
|
|
6596
|
+
if (result.ok) props.onClose();
|
|
6597
|
+
else setErrors(result.errors);
|
|
6598
|
+
};
|
|
6599
|
+
const totalFormat = value && value.totalFormat;
|
|
6600
|
+
const pageFormat = value && value.pageInfoFormat;
|
|
6601
|
+
return /* @__PURE__ */ jsx(
|
|
6602
|
+
ReactModal,
|
|
6603
|
+
{
|
|
6604
|
+
open: true,
|
|
6605
|
+
title: "\u5206\u9875\u914D\u7F6E",
|
|
6606
|
+
width: 640,
|
|
6607
|
+
fullscreenable: false,
|
|
6608
|
+
onCancel: props.onClose,
|
|
6609
|
+
footer: /* @__PURE__ */ jsxs("div", { className: "react-list-table-pagination-config-footer", children: [
|
|
6610
|
+
/* @__PURE__ */ jsx(
|
|
6611
|
+
ReactButton,
|
|
6612
|
+
{
|
|
6613
|
+
type: "text",
|
|
6614
|
+
onClick: () => {
|
|
6615
|
+
setDraft(createPaginationDraft(props.snapshot, true));
|
|
6616
|
+
setCurrentEdited(false);
|
|
6617
|
+
setErrors({});
|
|
6618
|
+
},
|
|
6619
|
+
children: "\u6062\u590D\u4F20\u5165\u914D\u7F6E"
|
|
6620
|
+
}
|
|
6621
|
+
),
|
|
6622
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
6623
|
+
/* @__PURE__ */ jsx(ReactButton, { onClick: props.onClose, children: "\u53D6\u6D88" }),
|
|
6624
|
+
/* @__PURE__ */ jsx(ReactButton, { type: "primary", onClick: confirm, children: "\u786E\u5B9A" })
|
|
6625
|
+
] })
|
|
6626
|
+
] }),
|
|
6627
|
+
children: /* @__PURE__ */ jsxs("div", { className: "react-list-table-pagination-config", children: [
|
|
6628
|
+
/* @__PURE__ */ jsxs("div", { className: "react-list-table-pagination-config-enable", children: [
|
|
6629
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
6630
|
+
/* @__PURE__ */ jsx("strong", { children: "\u542F\u7528\u5206\u9875" }),
|
|
6631
|
+
/* @__PURE__ */ jsx("div", { className: "react-list-table-pagination-config-help", children: "\u5173\u95ED\u540E\u5C55\u793A\u5168\u90E8\u5DF2\u52A0\u8F7D\u6570\u636E\uFF0C\u4E0D\u663E\u793A\u5206\u9875\u63A7\u4EF6" })
|
|
6632
|
+
] }),
|
|
6633
|
+
/* @__PURE__ */ jsx(
|
|
6634
|
+
ReactSwitch,
|
|
6635
|
+
{
|
|
6636
|
+
"aria-label": "\u542F\u7528\u5206\u9875",
|
|
6637
|
+
checked: draft.enabled,
|
|
6638
|
+
onChange: (enabled) => {
|
|
6639
|
+
setCurrentEdited(false);
|
|
6640
|
+
patch({ enabled, ...enabled ? { current: "1" } : {} });
|
|
6641
|
+
}
|
|
6642
|
+
}
|
|
6643
|
+
)
|
|
6644
|
+
] }),
|
|
6645
|
+
/* @__PURE__ */ jsxs("fieldset", { disabled: !draft.enabled, children: [
|
|
6646
|
+
/* @__PURE__ */ jsx("h3", { children: scroll ? "\u6EDA\u52A8\u52A0\u8F7D" : "\u57FA\u672C\u8BBE\u7F6E" }),
|
|
6647
|
+
/* @__PURE__ */ jsxs("div", { className: "react-list-table-pagination-config-grid", children: [
|
|
6648
|
+
scroll ? /* @__PURE__ */ jsxs("div", { children: [
|
|
6649
|
+
"\u5F53\u524D\u5DF2\u52A0\u8F7D ",
|
|
6650
|
+
draft.current,
|
|
6651
|
+
" \u9875"
|
|
6652
|
+
] }) : input("\u5F53\u524D\u9875", "current"),
|
|
6653
|
+
input(scroll ? "\u6BCF\u6279\u6761\u6570" : "\u6BCF\u9875\u6761\u6570", "pageSize")
|
|
6654
|
+
] }),
|
|
6655
|
+
/* @__PURE__ */ jsxs("div", { className: "react-list-table-pagination-config-help", children: [
|
|
6656
|
+
"\u5171 ",
|
|
6657
|
+
props.snapshot.total,
|
|
6658
|
+
" \u6761\u6570\u636E \xB7 ",
|
|
6659
|
+
totalPages,
|
|
6660
|
+
" \u9875"
|
|
6661
|
+
] }),
|
|
6662
|
+
!scroll ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
6663
|
+
/* @__PURE__ */ jsx("h3", { children: "\u663E\u793A\u8BBE\u7F6E" }),
|
|
6664
|
+
/* @__PURE__ */ jsx("div", { className: "react-list-table-pagination-config-grid", children: field(
|
|
6665
|
+
"\u5206\u9875\u5C3A\u5BF8",
|
|
6666
|
+
"size",
|
|
6667
|
+
/* @__PURE__ */ jsx(
|
|
6668
|
+
ReactSelect,
|
|
6669
|
+
{
|
|
6670
|
+
"aria-label": "\u5206\u9875\u5C3A\u5BF8",
|
|
6671
|
+
value: draft.config.size ?? "auto",
|
|
6672
|
+
options: [
|
|
6673
|
+
{ value: "auto", label: "\u8DDF\u968F\u8868\u683C" },
|
|
6674
|
+
{ value: "small", label: "\u5C0F" },
|
|
6675
|
+
{ value: "middle", label: "\u4E2D" },
|
|
6676
|
+
{ value: "large", label: "\u5927" }
|
|
6677
|
+
],
|
|
6678
|
+
onChange: (size) => patchConfig({
|
|
6679
|
+
size
|
|
6680
|
+
})
|
|
6681
|
+
}
|
|
6682
|
+
)
|
|
6683
|
+
) }),
|
|
6684
|
+
/* @__PURE__ */ jsxs("div", { className: "react-list-table-pagination-config-grid", children: [
|
|
6685
|
+
check("\u7B80\u6D01\u6A21\u5F0F", "simple"),
|
|
6686
|
+
check("\u7D27\u51D1\u9875\u7801", "showLessItems", !!draft.config.simple),
|
|
6687
|
+
check("\u663E\u793A\u6BCF\u9875\u6761\u6570\u9009\u62E9\u5668", "showSizeChanger"),
|
|
6688
|
+
check("\u663E\u793A\u5FEB\u901F\u8DF3\u9875", "showQuickJumper")
|
|
6689
|
+
] }),
|
|
6690
|
+
/* @__PURE__ */ jsx("h3", { children: "\u6587\u6848\u8BBE\u7F6E" }),
|
|
6691
|
+
/* @__PURE__ */ jsxs("div", { className: "react-list-table-pagination-config-grid", children: [
|
|
6692
|
+
field(
|
|
6693
|
+
"\u9875\u7801\u4FE1\u606F\u683C\u5F0F",
|
|
6694
|
+
"pageInfoFormat",
|
|
6695
|
+
/* @__PURE__ */ jsxs(Fragment, { children: [
|
|
6696
|
+
/* @__PURE__ */ jsx(
|
|
6697
|
+
ReactSelect,
|
|
6698
|
+
{
|
|
6699
|
+
"aria-label": "\u9875\u7801\u4FE1\u606F\u683C\u5F0F",
|
|
6700
|
+
value: draft.pageChoice,
|
|
6701
|
+
options: pageInfoFormats,
|
|
6702
|
+
onChange: (pageChoice) => patch({ pageChoice })
|
|
6703
|
+
}
|
|
6704
|
+
),
|
|
6705
|
+
draft.pageChoice === "custom" ? /* @__PURE__ */ jsx(
|
|
6706
|
+
ReactInput,
|
|
6707
|
+
{
|
|
6708
|
+
"aria-label": "\u81EA\u5B9A\u4E49\u9875\u7801\u4FE1\u606F\u683C\u5F0F",
|
|
6709
|
+
maxLength: 500,
|
|
6710
|
+
placeholder: "\u7B2C {current} \u9875 / \u5171 {totalPages} \u9875",
|
|
6711
|
+
value: draft.pageTemplate,
|
|
6712
|
+
onChange: (event) => patch({ pageTemplate: event.target.value })
|
|
6713
|
+
}
|
|
6714
|
+
) : null
|
|
6715
|
+
] })
|
|
6716
|
+
),
|
|
6717
|
+
field(
|
|
6718
|
+
"\u603B\u6761\u6570\u683C\u5F0F",
|
|
6719
|
+
"totalFormat",
|
|
6720
|
+
/* @__PURE__ */ jsxs(Fragment, { children: [
|
|
6721
|
+
/* @__PURE__ */ jsx(
|
|
6722
|
+
ReactSelect,
|
|
6723
|
+
{
|
|
6724
|
+
"aria-label": "\u603B\u6761\u6570\u683C\u5F0F",
|
|
6725
|
+
value: draft.totalChoice,
|
|
6726
|
+
options: totalFormats,
|
|
6727
|
+
onChange: (totalChoice) => patch({ totalChoice })
|
|
6728
|
+
}
|
|
6729
|
+
),
|
|
6730
|
+
draft.totalChoice === "custom" ? /* @__PURE__ */ jsx(
|
|
6731
|
+
ReactInput,
|
|
6732
|
+
{
|
|
6733
|
+
"aria-label": "\u81EA\u5B9A\u4E49\u603B\u6761\u6570\u683C\u5F0F",
|
|
6734
|
+
maxLength: 500,
|
|
6735
|
+
placeholder: "\u7B2C {start}\u2013{end} \u6761\uFF0C\u5171 {total} \u6761",
|
|
6736
|
+
value: draft.totalTemplate,
|
|
6737
|
+
onChange: (event) => patch({ totalTemplate: event.target.value })
|
|
6738
|
+
}
|
|
6739
|
+
) : null
|
|
6740
|
+
] })
|
|
6741
|
+
)
|
|
6742
|
+
] }),
|
|
6743
|
+
draft.pageChoice === "custom" || draft.totalChoice === "custom" ? /* @__PURE__ */ jsxs("div", { className: "react-list-table-pagination-config-help", children: [
|
|
6744
|
+
"\u9875\u7801\uFF1A",
|
|
6745
|
+
"{current}\u3001{totalPages}",
|
|
6746
|
+
"\uFF1B\u603B\u6761\u6570\uFF1A",
|
|
6747
|
+
"{total}\u3001{start}\u3001{end}"
|
|
6748
|
+
] }) : null,
|
|
6749
|
+
/* @__PURE__ */ jsxs("details", { children: [
|
|
6750
|
+
/* @__PURE__ */ jsx("summary", { children: "\u9AD8\u7EA7\u8BBE\u7F6E" }),
|
|
6751
|
+
/* @__PURE__ */ jsxs("div", { className: "react-list-table-pagination-config-grid", children: [
|
|
6752
|
+
input("\u6BCF\u9875\u6761\u6570\u5019\u9009", "candidates"),
|
|
6753
|
+
input("\u6700\u5C0F\u6BCF\u9875\u6761\u6570", "minPageSize"),
|
|
6754
|
+
input("\u6700\u5927\u6BCF\u9875\u6761\u6570", "maxPageSize")
|
|
6755
|
+
] }),
|
|
6756
|
+
/* @__PURE__ */ jsxs("div", { className: "react-list-table-pagination-config-grid", children: [
|
|
6757
|
+
check(
|
|
6758
|
+
"\u5141\u8BB8\u624B\u8F93\u6BCF\u9875\u6761\u6570",
|
|
6759
|
+
"allowPageSizeInput",
|
|
6760
|
+
!draft.config.showSizeChanger
|
|
6761
|
+
),
|
|
6762
|
+
check("\u7981\u7528\u5206\u9875\u64CD\u4F5C", "disabled")
|
|
6763
|
+
] })
|
|
6764
|
+
] })
|
|
6765
|
+
] }) : null
|
|
6766
|
+
] }),
|
|
6767
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
6768
|
+
/* @__PURE__ */ jsxs("div", { className: "react-list-table-pagination-config-enable react-list-table-pagination-config-cache", children: [
|
|
6769
|
+
/* @__PURE__ */ jsxs("label", { className: "react-list-table-pagination-config-check", children: [
|
|
6770
|
+
/* @__PURE__ */ jsx(
|
|
6771
|
+
"input",
|
|
6772
|
+
{
|
|
6773
|
+
type: "checkbox",
|
|
6774
|
+
"aria-label": "\u7F13\u5B58\u5230\u672C\u5730",
|
|
6775
|
+
checked: draft.cacheEnabled,
|
|
6776
|
+
onChange: (event) => patch({ cacheEnabled: event.target.checked })
|
|
6777
|
+
}
|
|
6778
|
+
),
|
|
6779
|
+
"\u7F13\u5B58\u5230\u672C\u5730"
|
|
6780
|
+
] }),
|
|
6781
|
+
/* @__PURE__ */ jsx("div", { className: "react-list-table-pagination-config-cache-scope", children: /* @__PURE__ */ jsx(
|
|
6782
|
+
ReactSelect,
|
|
6783
|
+
{
|
|
6784
|
+
"aria-label": "\u7F13\u5B58\u8303\u56F4",
|
|
6785
|
+
disabled: !draft.cacheEnabled,
|
|
6786
|
+
value: draft.cacheScope,
|
|
6787
|
+
options: [
|
|
6788
|
+
{
|
|
6789
|
+
value: "table",
|
|
6790
|
+
label: "\u5F53\u524D\u8868\u683C",
|
|
6791
|
+
disabled: !props.snapshot.cache?.currentTableAvailable
|
|
6792
|
+
},
|
|
6793
|
+
{ value: "all", label: "\u6240\u6709\u8868\u683C" }
|
|
6794
|
+
],
|
|
6795
|
+
onChange: (scope) => patch({ cacheScope: scope })
|
|
6796
|
+
}
|
|
6797
|
+
) })
|
|
6798
|
+
] }),
|
|
6799
|
+
/* @__PURE__ */ jsxs("div", { className: "react-list-table-pagination-config-help", children: [
|
|
6800
|
+
draft.cacheScope === "all" ? "\u4F5C\u4E3A\u6240\u6709\u8868\u683C\u7684\u5171\u4EAB\u9ED8\u8BA4\u914D\u7F6E\uFF1B\u660E\u786E\u8BBE\u7F6E pagination=false \u7684\u8868\u683C\u4E0D\u4F7F\u7528\u5171\u4EAB\u7F13\u5B58\u3002\u5355\u8868\u7F13\u5B58\u4F18\u5148\u3002" : "\u4EC5\u4FDD\u5B58\u5230\u5F53\u524D\u8868\u683C\uFF1B\u9700\u8981\u7A33\u5B9A\u7684 storageKey\u3002",
|
|
6801
|
+
" ",
|
|
6802
|
+
"\u5F53\u524D\u9875\u4E0D\u7F13\u5B58\u3002"
|
|
6803
|
+
] }),
|
|
6804
|
+
errors.cache ? /* @__PURE__ */ jsx(
|
|
6805
|
+
"div",
|
|
6806
|
+
{
|
|
6807
|
+
role: "alert",
|
|
6808
|
+
className: "react-list-table-pagination-config-error",
|
|
6809
|
+
children: errors.cache
|
|
6810
|
+
}
|
|
6811
|
+
) : null
|
|
6812
|
+
] }),
|
|
6813
|
+
/* @__PURE__ */ jsxs("div", { className: "react-list-table-pagination-config-preview", children: [
|
|
6814
|
+
/* @__PURE__ */ jsx("div", { className: "react-list-table-pagination-config-help", children: "\u5206\u9875\u9884\u89C8" }),
|
|
6815
|
+
!draft.enabled ? /* @__PURE__ */ jsx("div", { className: "react-list-table-pagination-config-off", children: "\u5206\u9875\u5DF2\u5173\u95ED" }) : scroll ? /* @__PURE__ */ jsx("div", { className: "react-list-table-pagination-config-off", children: "\u6EDA\u52A8\u5230\u5E95\u90E8\u52A0\u8F7D\u4E0B\u4E00\u6279\uFF0C\u4E0D\u663E\u793A\u5206\u9875\u63A7\u4EF6" }) : /* @__PURE__ */ jsx("div", { className: "react-list-table-pagination-config-pager", children: /* @__PURE__ */ jsx(
|
|
6816
|
+
ReactPagination,
|
|
6817
|
+
{
|
|
6818
|
+
...draft.config,
|
|
6819
|
+
allowPageSizeInput: draft.config.allowPageSizeInput ?? draft.config.showSizeChanger,
|
|
6820
|
+
size: resolveReactListTablePaginationLayout(
|
|
6821
|
+
void 0,
|
|
6822
|
+
draft.config.size
|
|
6823
|
+
).size,
|
|
6824
|
+
current,
|
|
6825
|
+
pageSize,
|
|
6826
|
+
total: props.snapshot.total,
|
|
6827
|
+
pageSizeOptions: value ? value.pageSizeOptions : void 0,
|
|
6828
|
+
pageInfoText: pageFormat ? formatPaginationText(pageFormat, { current, totalPages }) : void 0,
|
|
6829
|
+
showTotal: typeof totalFormat === "string" ? (total, [start, end]) => formatPaginationText(totalFormat, {
|
|
6830
|
+
total,
|
|
6831
|
+
start: total ? start : 0,
|
|
6832
|
+
end: total ? end : 0
|
|
6833
|
+
}) : totalFormat === false ? void 0 : props.showTotal,
|
|
6834
|
+
onChange: (page) => {
|
|
6835
|
+
setCurrentEdited(true);
|
|
6836
|
+
patch({ current: String(page) });
|
|
6837
|
+
},
|
|
6838
|
+
onPageSizeChange: (_page, size) => patch({
|
|
6839
|
+
pageSize: String(size),
|
|
6840
|
+
...!currentEdited ? { current: "1" } : {}
|
|
6841
|
+
})
|
|
6842
|
+
}
|
|
6843
|
+
) })
|
|
6844
|
+
] }),
|
|
6845
|
+
errors.table ? /* @__PURE__ */ jsx("div", { role: "alert", children: errors.table }) : null
|
|
6846
|
+
] })
|
|
6847
|
+
}
|
|
6848
|
+
);
|
|
6849
|
+
}
|
|
6850
|
+
function usePaginationConfigDialog(request, latest, onClose) {
|
|
6851
|
+
const stale = !!request && !!latest && request.revision !== latest.revision;
|
|
6852
|
+
useEffect(() => {
|
|
6853
|
+
if (stale) {
|
|
6854
|
+
onClose();
|
|
6855
|
+
reactMessage.info("\u5206\u9875\u72B6\u6001\u5DF2\u66F4\u65B0\uFF0C\u8BF7\u91CD\u65B0\u6253\u5F00\u914D\u7F6E");
|
|
6856
|
+
}
|
|
6857
|
+
}, [stale, onClose]);
|
|
6858
|
+
return request && !stale ? request : null;
|
|
6859
|
+
}
|
|
5297
6860
|
function ReactTableDangerConfirmView(props) {
|
|
5298
6861
|
const { request, onClose } = props;
|
|
5299
6862
|
const confirmingRef = useRef(false);
|
|
@@ -5679,7 +7242,7 @@ function ToolButton(props) {
|
|
|
5679
7242
|
}
|
|
5680
7243
|
);
|
|
5681
7244
|
}
|
|
5682
|
-
function flattenColumns(columns, parentKey = "root", level = 0) {
|
|
7245
|
+
function flattenColumns(columns, parentKey = "root", level = 0, parentHidden = false) {
|
|
5683
7246
|
return columns.flatMap((column) => {
|
|
5684
7247
|
if (column.hideInSetting || isListTableColumnHiddenBySource(column)) {
|
|
5685
7248
|
return [];
|
|
@@ -5689,7 +7252,7 @@ function flattenColumns(columns, parentKey = "root", level = 0) {
|
|
|
5689
7252
|
const current = {
|
|
5690
7253
|
key,
|
|
5691
7254
|
label,
|
|
5692
|
-
hidden:
|
|
7255
|
+
hidden: parentHidden || isListTableColumnHidden(column),
|
|
5693
7256
|
parentKey,
|
|
5694
7257
|
width: Number(column.width) || 160,
|
|
5695
7258
|
minWidth: typeof column.minWidth === "number" ? column.minWidth : void 0,
|
|
@@ -5700,12 +7263,23 @@ function flattenColumns(columns, parentKey = "root", level = 0) {
|
|
|
5700
7263
|
disableHide: column.disableHide === true,
|
|
5701
7264
|
sortable: column.allowSort !== false && column.sorter !== false
|
|
5702
7265
|
};
|
|
5703
|
-
return column.children?.length ? [
|
|
7266
|
+
return column.children?.length ? [
|
|
7267
|
+
current,
|
|
7268
|
+
...flattenColumns(column.children, key, level + 1, current.hidden)
|
|
7269
|
+
] : [current];
|
|
5704
7270
|
});
|
|
5705
7271
|
}
|
|
5706
7272
|
function useReactListTableState(options) {
|
|
5707
7273
|
const containerRef = useRef(null);
|
|
5708
7274
|
const tableRef = useRef(null);
|
|
7275
|
+
const [paginationSnapshot, setPaginationSnapshot] = useState(null);
|
|
7276
|
+
const [paginationConfigRequest, setPaginationConfigRequest] = useState(null);
|
|
7277
|
+
const hadPaginationConfigRequest = useRef(false);
|
|
7278
|
+
useEffect(() => {
|
|
7279
|
+
if (hadPaginationConfigRequest.current && !paginationConfigRequest)
|
|
7280
|
+
containerRef.current?.querySelector("canvas")?.focus();
|
|
7281
|
+
hadPaginationConfigRequest.current = !!paginationConfigRequest;
|
|
7282
|
+
}, [paginationConfigRequest]);
|
|
5709
7283
|
const [editorRequest, setEditorRequest] = useState(null);
|
|
5710
7284
|
const [paginationConfig, setPaginationConfig] = useState(null);
|
|
5711
7285
|
const [tooltipRequest, setTooltipRequest] = useState(null);
|
|
@@ -5720,6 +7294,15 @@ function useReactListTableState(options) {
|
|
|
5720
7294
|
const uiOptions = useMemo(
|
|
5721
7295
|
() => ({
|
|
5722
7296
|
...options.ui,
|
|
7297
|
+
onOpenPaginationConfig: () => {
|
|
7298
|
+
const snapshot = tableRef.current?.getPaginationConfig();
|
|
7299
|
+
if (snapshot) setPaginationConfigRequest(snapshot);
|
|
7300
|
+
options.ui?.onOpenPaginationConfig?.();
|
|
7301
|
+
},
|
|
7302
|
+
onPaginationConfigRender: (snapshot) => {
|
|
7303
|
+
setPaginationSnapshot(snapshot);
|
|
7304
|
+
options.ui?.onPaginationConfigRender?.(snapshot);
|
|
7305
|
+
},
|
|
5723
7306
|
onExportNameRequest: (request) => {
|
|
5724
7307
|
setExportNameRequest(request);
|
|
5725
7308
|
options.ui?.onExportNameRequest?.(request);
|
|
@@ -5786,6 +7369,8 @@ function useReactListTableState(options) {
|
|
|
5786
7369
|
appliedOptionsRef.current = null;
|
|
5787
7370
|
setEditorRequest(null);
|
|
5788
7371
|
setPaginationConfig(null);
|
|
7372
|
+
setPaginationSnapshot(null);
|
|
7373
|
+
setPaginationConfigRequest(null);
|
|
5789
7374
|
setTooltipRequest(null);
|
|
5790
7375
|
setLoadingRequest(null);
|
|
5791
7376
|
setFilterPanelRequest(null);
|
|
@@ -5810,6 +7395,9 @@ function useReactListTableState(options) {
|
|
|
5810
7395
|
return {
|
|
5811
7396
|
containerRef,
|
|
5812
7397
|
tableRef,
|
|
7398
|
+
paginationSnapshot,
|
|
7399
|
+
paginationConfigRequest,
|
|
7400
|
+
closePaginationConfigRequest: () => setPaginationConfigRequest(null),
|
|
5813
7401
|
editorRequest,
|
|
5814
7402
|
paginationConfig,
|
|
5815
7403
|
tooltipRequest,
|
|
@@ -5891,7 +7479,7 @@ function useStableTableProps(props) {
|
|
|
5891
7479
|
}
|
|
5892
7480
|
return handler;
|
|
5893
7481
|
};
|
|
5894
|
-
for (const key of ["onChange"]) {
|
|
7482
|
+
for (const key of ["onChange", "onPaginationConfigChange"]) {
|
|
5895
7483
|
if (typeof props[key] === "function") next[key] = event(void 0, key);
|
|
5896
7484
|
}
|
|
5897
7485
|
for (const key of CONFIG_KEYS) {
|
|
@@ -5982,7 +7570,7 @@ function applyColumnManagerState(columns, visibility, orders, config, parentKey
|
|
|
5982
7570
|
const managedConfig = config.get(key);
|
|
5983
7571
|
return {
|
|
5984
7572
|
...column,
|
|
5985
|
-
|
|
7573
|
+
visible: visibility.has(key) ? visibility.get(key) !== false : column.visible !== false,
|
|
5986
7574
|
width: managedConfig?.width ?? column.width,
|
|
5987
7575
|
minWidth: column.minWidth,
|
|
5988
7576
|
maxWidth: column.maxWidth,
|
|
@@ -5997,6 +7585,44 @@ function applyColumnManagerState(columns, visibility, orders, config, parentKey
|
|
|
5997
7585
|
};
|
|
5998
7586
|
});
|
|
5999
7587
|
}
|
|
7588
|
+
function updateColumnManagerVisibility(columns, current, columnKey, visible) {
|
|
7589
|
+
const next = new Map(current);
|
|
7590
|
+
const setSubtree = (column) => {
|
|
7591
|
+
if (column.hidden === true || !visible && column.disableHide) return;
|
|
7592
|
+
next.set(resolveColumnKey(column), visible);
|
|
7593
|
+
column.children?.forEach(setSubtree);
|
|
7594
|
+
};
|
|
7595
|
+
const visit = (items, ancestors) => {
|
|
7596
|
+
for (const column of items) {
|
|
7597
|
+
if (column.hidden === true) continue;
|
|
7598
|
+
if (resolveColumnKey(column) === columnKey) {
|
|
7599
|
+
if (!visible && column.disableHide) return false;
|
|
7600
|
+
if (visible)
|
|
7601
|
+
ancestors.forEach(
|
|
7602
|
+
(parent) => next.set(resolveColumnKey(parent), true)
|
|
7603
|
+
);
|
|
7604
|
+
setSubtree(column);
|
|
7605
|
+
return true;
|
|
7606
|
+
}
|
|
7607
|
+
if (column.children && visit(column.children, [...ancestors, column]))
|
|
7608
|
+
return true;
|
|
7609
|
+
}
|
|
7610
|
+
return false;
|
|
7611
|
+
};
|
|
7612
|
+
visit(columns, []);
|
|
7613
|
+
return next;
|
|
7614
|
+
}
|
|
7615
|
+
function getColumnManagerVisibility(columns) {
|
|
7616
|
+
const result = /* @__PURE__ */ new Map();
|
|
7617
|
+
const visit = (items) => {
|
|
7618
|
+
for (const column of items) {
|
|
7619
|
+
result.set(resolveColumnKey(column), column.visible !== false);
|
|
7620
|
+
if (column.children) visit(column.children);
|
|
7621
|
+
}
|
|
7622
|
+
};
|
|
7623
|
+
visit(columns);
|
|
7624
|
+
return result;
|
|
7625
|
+
}
|
|
6000
7626
|
function normalizeUniqueColumnKeys(columns) {
|
|
6001
7627
|
const usedKeys = /* @__PURE__ */ new Set();
|
|
6002
7628
|
const reservedKeys = /* @__PURE__ */ new Set();
|
|
@@ -6063,6 +7689,7 @@ function getColumnSettingsSignature(columns) {
|
|
|
6063
7689
|
dataIndex: column.dataIndex,
|
|
6064
7690
|
userDefined: column.userDefined,
|
|
6065
7691
|
hidden: column.hidden,
|
|
7692
|
+
visible: column.visible,
|
|
6066
7693
|
width: column.width,
|
|
6067
7694
|
minWidth: column.minWidth,
|
|
6068
7695
|
maxWidth: column.maxWidth,
|
|
@@ -6094,6 +7721,7 @@ function ReactListTableInner(props, ref) {
|
|
|
6094
7721
|
rowKey,
|
|
6095
7722
|
columns,
|
|
6096
7723
|
showCollapsedColumnIcon,
|
|
7724
|
+
showHeaderActions,
|
|
6097
7725
|
dataSource,
|
|
6098
7726
|
loading,
|
|
6099
7727
|
onRow,
|
|
@@ -6114,6 +7742,7 @@ function ReactListTableInner(props, ref) {
|
|
|
6114
7742
|
rowSelection,
|
|
6115
7743
|
expandable,
|
|
6116
7744
|
pagination,
|
|
7745
|
+
onPaginationConfigChange,
|
|
6117
7746
|
scrollbar,
|
|
6118
7747
|
stickToBottom,
|
|
6119
7748
|
carouselScroll,
|
|
@@ -6139,9 +7768,17 @@ function ReactListTableInner(props, ref) {
|
|
|
6139
7768
|
() => resolveReactListTableDebugOptions(debug, inheritedDebugEnabled),
|
|
6140
7769
|
[debug, inheritedDebugEnabled]
|
|
6141
7770
|
);
|
|
7771
|
+
const activeStorageKey = useRef(storageKey);
|
|
7772
|
+
useLayoutEffect(() => {
|
|
7773
|
+
activeStorageKey.current = storageKey;
|
|
7774
|
+
}, [storageKey]);
|
|
6142
7775
|
const shellRef = useRef(null);
|
|
6143
7776
|
const [isFullscreen, setIsFullscreen] = useState(false);
|
|
6144
|
-
const [
|
|
7777
|
+
const [paginationHeight, setPaginationHeight] = useState(0);
|
|
7778
|
+
const [scrollbarOverride, setScrollbarOverride] = useStorageKeyState(
|
|
7779
|
+
storageKey,
|
|
7780
|
+
() => null
|
|
7781
|
+
);
|
|
6145
7782
|
const [sharedScrollbar, setSharedScrollbar] = useState(
|
|
6146
7783
|
getSharedScrollbarSettings
|
|
6147
7784
|
);
|
|
@@ -6152,12 +7789,10 @@ function ReactListTableInner(props, ref) {
|
|
|
6152
7789
|
[]
|
|
6153
7790
|
);
|
|
6154
7791
|
const effectiveScrollbar = sharedScrollbar.shared ? sharedScrollbar.value : scrollbarOverride ?? scrollbar;
|
|
6155
|
-
const [densityOverride, setDensityOverride] =
|
|
6156
|
-
const [columnVisibility, setColumnVisibility] = useState(() => /* @__PURE__ */ new Map());
|
|
6157
|
-
const [columnOrders, setColumnOrders] =
|
|
6158
|
-
|
|
6159
|
-
);
|
|
6160
|
-
const [columnConfig, setColumnConfig] = useState(() => /* @__PURE__ */ new Map());
|
|
7792
|
+
const [densityOverride, setDensityOverride] = useStorageKeyState(storageKey, () => null);
|
|
7793
|
+
const [columnVisibility, setColumnVisibility] = useState(() => ({ storageKey, values: /* @__PURE__ */ new Map() }));
|
|
7794
|
+
const [columnOrders, setColumnOrders] = useStorageKeyState(storageKey, () => /* @__PURE__ */ new Map());
|
|
7795
|
+
const [columnConfig, setColumnConfig] = useStorageKeyState(storageKey, () => /* @__PURE__ */ new Map());
|
|
6161
7796
|
const restoredColumnTreeRef = useRef(null);
|
|
6162
7797
|
const [restoredColumnTree, setRestoredColumnTree] = useState(
|
|
6163
7798
|
restoredColumnTreeRef.current
|
|
@@ -6174,7 +7809,7 @@ function ReactListTableInner(props, ref) {
|
|
|
6174
7809
|
const resolvedColumns = useMemo(
|
|
6175
7810
|
() => applyColumnManagerState(
|
|
6176
7811
|
restoredColumnTree?.sourceColumns === sourceColumns && restoredColumnTree.storageKey === storageKey ? restoredColumnTree.columns : sourceColumns,
|
|
6177
|
-
columnVisibility,
|
|
7812
|
+
columnVisibility.storageKey === storageKey ? columnVisibility.values : /* @__PURE__ */ new Map(),
|
|
6178
7813
|
columnOrders,
|
|
6179
7814
|
columnConfig
|
|
6180
7815
|
),
|
|
@@ -6196,11 +7831,13 @@ function ReactListTableInner(props, ref) {
|
|
|
6196
7831
|
const queryRef = useRef(query);
|
|
6197
7832
|
queryRef.current = retainEqualQueryOption(queryRef.current, query);
|
|
6198
7833
|
const stableQuery = queryRef.current;
|
|
7834
|
+
const autoContentHeight = height == null && style?.height == null && scroll?.y == null ? (resolvedHeaderRowHeight ?? 40) + dataSource.length * (typeof resolvedRowHeight === "number" ? resolvedRowHeight : 40) + paginationHeight : void 0;
|
|
7835
|
+
const resolvedTableHeight = autoContentHeight ?? height;
|
|
6199
7836
|
const options = useMemo(() => {
|
|
6200
7837
|
const nextOptions = buildListTableOptions({
|
|
6201
7838
|
exportOptions,
|
|
6202
7839
|
width,
|
|
6203
|
-
height,
|
|
7840
|
+
height: resolvedTableHeight,
|
|
6204
7841
|
emptyText,
|
|
6205
7842
|
scroll,
|
|
6206
7843
|
locale,
|
|
@@ -6208,6 +7845,7 @@ function ReactListTableInner(props, ref) {
|
|
|
6208
7845
|
rowKey,
|
|
6209
7846
|
columns: resolvedColumns,
|
|
6210
7847
|
showCollapsedColumnIcon,
|
|
7848
|
+
showHeaderActions,
|
|
6211
7849
|
dataSource,
|
|
6212
7850
|
loading,
|
|
6213
7851
|
onRow,
|
|
@@ -6228,6 +7866,7 @@ function ReactListTableInner(props, ref) {
|
|
|
6228
7866
|
rowSelection,
|
|
6229
7867
|
expandable,
|
|
6230
7868
|
pagination,
|
|
7869
|
+
onPaginationConfigChange,
|
|
6231
7870
|
scrollbar: effectiveScrollbar,
|
|
6232
7871
|
stickToBottom,
|
|
6233
7872
|
carouselScroll,
|
|
@@ -6256,6 +7895,7 @@ function ReactListTableInner(props, ref) {
|
|
|
6256
7895
|
onDensityChange: setDensityOverride,
|
|
6257
7896
|
onScrollbarChange: setScrollbarOverride,
|
|
6258
7897
|
onColumnSettingsChange: (restoredColumns, source) => {
|
|
7898
|
+
if (activeStorageKey.current !== storageKey) return;
|
|
6259
7899
|
const signature = getColumnSettingsSignature(restoredColumns);
|
|
6260
7900
|
const current = restoredColumnTreeRef.current;
|
|
6261
7901
|
if (current?.sourceColumns === sourceColumns && current.storageKey === storageKey && current.signature === signature)
|
|
@@ -6268,24 +7908,33 @@ function ReactListTableInner(props, ref) {
|
|
|
6268
7908
|
};
|
|
6269
7909
|
restoredColumnTreeRef.current = next;
|
|
6270
7910
|
setRestoredColumnTree(next);
|
|
7911
|
+
setColumnVisibility({
|
|
7912
|
+
storageKey,
|
|
7913
|
+
values: getColumnManagerVisibility(restoredColumns)
|
|
7914
|
+
});
|
|
6271
7915
|
setColumnOrders(getColumnManagerOrders(restoredColumns));
|
|
6272
7916
|
if (source === "restore") {
|
|
6273
|
-
setColumnVisibility(/* @__PURE__ */ new Map());
|
|
6274
7917
|
setColumnConfig(/* @__PURE__ */ new Map());
|
|
6275
7918
|
}
|
|
6276
7919
|
},
|
|
6277
|
-
onColumnSettingsCacheChange: (value) =>
|
|
6278
|
-
(current
|
|
6279
|
-
|
|
6280
|
-
|
|
6281
|
-
|
|
6282
|
-
|
|
7920
|
+
onColumnSettingsCacheChange: (value) => {
|
|
7921
|
+
if (activeStorageKey.current !== storageKey) return;
|
|
7922
|
+
setColumnSettingsCacheOverride(
|
|
7923
|
+
(current) => current?.storageKey === storageKey && current?.value === value ? current : { storageKey, value }
|
|
7924
|
+
);
|
|
7925
|
+
},
|
|
7926
|
+
onCachePreferencesChange: (next) => {
|
|
7927
|
+
if (activeStorageKey.current !== storageKey) return;
|
|
7928
|
+
setCachePreferencesOverride(
|
|
7929
|
+
(current) => current?.storageKey === storageKey && JSON.stringify(current?.value ?? {}) === JSON.stringify(next) ? current : { storageKey, value: next }
|
|
7930
|
+
);
|
|
7931
|
+
}
|
|
6283
7932
|
}
|
|
6284
7933
|
};
|
|
6285
7934
|
}, [
|
|
6286
7935
|
exportOptions,
|
|
6287
7936
|
width,
|
|
6288
|
-
|
|
7937
|
+
resolvedTableHeight,
|
|
6289
7938
|
emptyText,
|
|
6290
7939
|
scroll,
|
|
6291
7940
|
locale,
|
|
@@ -6293,6 +7942,7 @@ function ReactListTableInner(props, ref) {
|
|
|
6293
7942
|
rowKey,
|
|
6294
7943
|
resolvedColumns,
|
|
6295
7944
|
showCollapsedColumnIcon,
|
|
7945
|
+
showHeaderActions,
|
|
6296
7946
|
dataSource,
|
|
6297
7947
|
loading,
|
|
6298
7948
|
onRow,
|
|
@@ -6313,6 +7963,7 @@ function ReactListTableInner(props, ref) {
|
|
|
6313
7963
|
rowSelection,
|
|
6314
7964
|
expandable,
|
|
6315
7965
|
pagination,
|
|
7966
|
+
onPaginationConfigChange,
|
|
6316
7967
|
effectiveScrollbar,
|
|
6317
7968
|
stickToBottom,
|
|
6318
7969
|
carouselScroll,
|
|
@@ -6332,6 +7983,9 @@ function ReactListTableInner(props, ref) {
|
|
|
6332
7983
|
const {
|
|
6333
7984
|
containerRef,
|
|
6334
7985
|
tableRef,
|
|
7986
|
+
paginationSnapshot,
|
|
7987
|
+
paginationConfigRequest,
|
|
7988
|
+
closePaginationConfigRequest,
|
|
6335
7989
|
editorRequest,
|
|
6336
7990
|
paginationConfig,
|
|
6337
7991
|
tooltipRequest,
|
|
@@ -6348,7 +8002,18 @@ function ReactListTableInner(props, ref) {
|
|
|
6348
8002
|
} = useReactListTableState(options);
|
|
6349
8003
|
const hasPagination = paginationConfig != null;
|
|
6350
8004
|
const [cacheConfigOpen, setCacheConfigOpen] = useState(false);
|
|
6351
|
-
const paginationLayout = resolveReactListTablePaginationLayout(
|
|
8005
|
+
const paginationLayout = resolveReactListTablePaginationLayout(
|
|
8006
|
+
resolvedRowHeight,
|
|
8007
|
+
paginationConfig?.size
|
|
8008
|
+
);
|
|
8009
|
+
useLayoutEffect(() => {
|
|
8010
|
+
setPaginationHeight(hasPagination ? paginationLayout.height : 0);
|
|
8011
|
+
}, [hasPagination, paginationLayout.height]);
|
|
8012
|
+
const paginationDialogSnapshot = usePaginationConfigDialog(
|
|
8013
|
+
paginationConfigRequest,
|
|
8014
|
+
paginationSnapshot,
|
|
8015
|
+
closePaginationConfigRequest
|
|
8016
|
+
);
|
|
6352
8017
|
const portalContainer = resolveFullscreenPortalContainer(shellRef.current);
|
|
6353
8018
|
const PrintHost = printIntegration?.Host;
|
|
6354
8019
|
const contextMenuRequest = headerContextMenuRequest ? {
|
|
@@ -6381,6 +8046,11 @@ function ReactListTableInner(props, ref) {
|
|
|
6381
8046
|
useImperativeHandle(
|
|
6382
8047
|
ref,
|
|
6383
8048
|
() => ({
|
|
8049
|
+
getPaginationConfig: () => tableRef.current?.getPaginationConfig() ?? null,
|
|
8050
|
+
setPaginationConfig: (value, cache) => tableRef.current?.setPaginationConfig(value, cache) ?? {
|
|
8051
|
+
ok: false,
|
|
8052
|
+
errors: { table: "\u8868\u683C\u5C1A\u672A\u6302\u8F7D" }
|
|
8053
|
+
},
|
|
6384
8054
|
getDataSource: () => tableRef.current?.getDataSource() ?? [],
|
|
6385
8055
|
getFilteredData: () => tableRef.current?.getFilteredData() ?? [],
|
|
6386
8056
|
validate: () => tableRef.current?.validate() ?? Promise.resolve([]),
|
|
@@ -6396,6 +8066,19 @@ function ReactListTableInner(props, ref) {
|
|
|
6396
8066
|
scrollTo: (options2) => {
|
|
6397
8067
|
tableRef.current?.scrollTo(options2);
|
|
6398
8068
|
},
|
|
8069
|
+
freezeRow: (targets) => {
|
|
8070
|
+
tableRef.current?.freezeRow(targets);
|
|
8071
|
+
},
|
|
8072
|
+
freezeRows: (targets) => {
|
|
8073
|
+
tableRef.current?.freezeRows(targets);
|
|
8074
|
+
},
|
|
8075
|
+
unfreezeRow: (targets) => {
|
|
8076
|
+
tableRef.current?.unfreezeRow(targets);
|
|
8077
|
+
},
|
|
8078
|
+
unfreezeRows: (targets) => {
|
|
8079
|
+
tableRef.current?.unfreezeRows(targets);
|
|
8080
|
+
},
|
|
8081
|
+
getFrozenRows: () => tableRef.current?.getFrozenRows() ?? [],
|
|
6399
8082
|
getDebugSnapshot: () => tableRef.current?.getDebugSnapshot() ?? null,
|
|
6400
8083
|
resetSorter: () => {
|
|
6401
8084
|
tableRef.current?.resetSorter();
|
|
@@ -6457,11 +8140,15 @@ function ReactListTableInner(props, ref) {
|
|
|
6457
8140
|
}
|
|
6458
8141
|
},
|
|
6459
8142
|
onColumnVisibilityChange: (columnKey, visible) => {
|
|
6460
|
-
setColumnVisibility((current) => {
|
|
6461
|
-
|
|
6462
|
-
|
|
6463
|
-
|
|
6464
|
-
|
|
8143
|
+
setColumnVisibility((current) => ({
|
|
8144
|
+
storageKey,
|
|
8145
|
+
values: updateColumnManagerVisibility(
|
|
8146
|
+
resolvedColumns,
|
|
8147
|
+
current.storageKey === storageKey ? current.values : /* @__PURE__ */ new Map(),
|
|
8148
|
+
columnKey,
|
|
8149
|
+
visible
|
|
8150
|
+
)
|
|
8151
|
+
}));
|
|
6465
8152
|
setColumnConfigRevision((current) => current + 1);
|
|
6466
8153
|
},
|
|
6467
8154
|
onColumnOrderChange: (parentKey, orderedKeys) => {
|
|
@@ -6505,7 +8192,8 @@ function ReactListTableInner(props, ref) {
|
|
|
6505
8192
|
storageKey,
|
|
6506
8193
|
columns: initialColumns
|
|
6507
8194
|
}).finally(() => {
|
|
6508
|
-
|
|
8195
|
+
if (activeStorageKey.current !== storageKey) return;
|
|
8196
|
+
setColumnVisibility({ storageKey, values: /* @__PURE__ */ new Map() });
|
|
6509
8197
|
setColumnOrders(/* @__PURE__ */ new Map());
|
|
6510
8198
|
setColumnConfig(/* @__PURE__ */ new Map());
|
|
6511
8199
|
restoredColumnTreeRef.current = null;
|
|
@@ -6555,6 +8243,18 @@ function ReactListTableInner(props, ref) {
|
|
|
6555
8243
|
]
|
|
6556
8244
|
}
|
|
6557
8245
|
),
|
|
8246
|
+
paginationDialogSnapshot ? /* @__PURE__ */ jsx(
|
|
8247
|
+
ReactListTablePaginationConfigDialog,
|
|
8248
|
+
{
|
|
8249
|
+
snapshot: paginationDialogSnapshot,
|
|
8250
|
+
showTotal: pagination ? pagination.showTotal : void 0,
|
|
8251
|
+
onConfirm: (value, cache) => tableRef.current?.setPaginationConfig(value, cache) ?? {
|
|
8252
|
+
ok: false,
|
|
8253
|
+
errors: { table: "\u8868\u683C\u5C1A\u672A\u6302\u8F7D" }
|
|
8254
|
+
},
|
|
8255
|
+
onClose: closePaginationConfigRequest
|
|
8256
|
+
}
|
|
8257
|
+
) : null,
|
|
6558
8258
|
tooltipRequest ? createPortal(
|
|
6559
8259
|
/* @__PURE__ */ jsx(ReactTooltip, { request: tooltipRequest }),
|
|
6560
8260
|
portalContainer
|