react-kui 3.1.2 → 3.2.0
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.zh-CN.md +3 -1
- package/ai/kui-components.json +912 -318
- package/es/_virtual/_rolldown/runtime.js +1 -1
- package/es/affix/index.js +1 -1
- package/es/alert/index.js +11 -4
- package/es/anchor/anchor-context.js +1 -1
- package/es/anchor/anchor-link.js +1 -1
- package/es/anchor/anchor.js +1 -1
- package/es/auto-complete/index.js +371 -347
- package/es/avatar/avatar-group-context.js +1 -1
- package/es/avatar/avatar-group.js +1 -1
- package/es/avatar/avatar.js +1 -1
- package/es/back-top/index.js +1 -1
- package/es/badge/index.js +10 -8
- package/es/base/teleport.js +1 -1
- package/es/base/transition-props.js +1 -1
- package/es/base/transition.js +1 -1
- package/es/breadcrumb/breadcrumb-context.js +1 -1
- package/es/breadcrumb/breadcrumb-item.js +1 -1
- package/es/breadcrumb/breadcrumb.js +1 -1
- package/es/button/button-group-context.js +1 -1
- package/es/button/button-group.js +1 -1
- package/es/button/button.js +13 -6
- package/es/calendar/index.js +20 -6
- package/es/card/index.js +11 -4
- package/es/carousel/carousel-context.js +1 -1
- package/es/carousel/carousel-item.js +1 -1
- package/es/carousel/carousel.js +1 -1
- package/es/carousel/drag.js +1 -1
- package/es/cascader/index.js +13 -10
- package/es/check-card/check-card-group.js +3 -3
- package/es/check-card/check-card.js +155 -141
- package/es/check-card/context.js +1 -1
- package/es/checkbox/checkbox-group-context.js +1 -1
- package/es/checkbox/checkbox-group.js +3 -3
- package/es/checkbox/checkbox.js +64 -244
- package/es/checkbox/index.js +1 -1
- package/es/collapse/collapse-panel.js +1 -1
- package/es/collapse/collapse.js +96 -82
- package/es/color-picker/alpha.js +1 -1
- package/es/color-picker/hue.js +1 -1
- package/es/color-picker/index.js +7 -7
- package/es/color-picker/mode.js +2 -2
- package/es/color-picker/paint.js +1 -1
- package/es/color-picker/presets.js +1 -1
- package/es/components.js +4 -4
- package/es/config/config-context.js +16 -3
- package/es/config/context.js +29 -2
- package/es/config/index.js +31 -12
- package/es/config/popup-host.js +106 -0
- package/es/config/size-context.js +1 -1
- package/es/config/use-config-appearance.js +62 -2
- package/es/const/var.js +6 -2
- package/es/date-picker/index.js +404 -885
- package/es/descriptions/descriptions-item.js +1 -1
- package/es/descriptions/descriptions.js +1 -1
- package/es/divider/index.js +1 -1
- package/es/drawer/index.js +328 -240
- package/es/dropdown/dropdown-button.js +69 -51
- package/es/dropdown/dropdown-context.js +1 -1
- package/es/dropdown/dropdown.js +137 -93
- package/es/dropdown/trigger.js +85 -33
- package/es/empty/index.js +3 -4
- package/es/feature-card/index.js +15 -4
- package/es/feedback-panel/index.js +95 -81
- package/es/flame-wrap/index.js +116 -109
- package/es/flame-wrap/types.js +54 -6
- package/es/flex/index.js +1 -1
- package/es/form/field-context.js +16 -2
- package/es/form/form-context.js +1 -1
- package/es/form/form-item.js +7 -6
- package/es/form/form.js +1 -1
- package/es/form/utils.js +1 -1
- package/es/grid/grid-item.js +1 -1
- package/es/grid/grid.js +1 -1
- package/es/grid/useBreakpoint.js +1 -1
- package/es/icon/index.js +1 -1
- package/es/image/group.js +1 -1
- package/es/image/image-group-context.js +1 -1
- package/es/image/image.js +137 -123
- package/es/image/instance.js +1 -1
- package/es/image/preview.js +1 -1
- package/es/image/utils.js +1 -1
- package/es/index.js +3 -3
- package/es/input/index.js +3 -3
- package/es/input/input-base.js +7 -7
- package/es/input/input-box.js +2 -2
- package/es/input/input-group.js +43 -127
- package/es/input/input.js +1 -1
- package/es/input/textarea.js +28 -114
- package/es/input-number/index.js +7 -5
- package/es/input-otp/index.js +5 -5
- package/es/input-tag/index.js +5 -5
- package/es/kanban/index.js +79 -63
- package/es/layout/index.js +1 -1
- package/es/layout/layout-context.js +1 -1
- package/es/list-panel/index.js +96 -83
- package/es/loading/index.js +1 -1
- package/es/loading/loading-bar.js +1 -1
- package/es/locale/de.js +10 -2
- package/es/locale/el.js +10 -2
- package/es/locale/en.js +10 -2
- package/es/locale/fr.js +10 -2
- package/es/locale/it.js +10 -2
- package/es/locale/ja.js +10 -2
- package/es/locale/ko.js +10 -2
- package/es/locale/ru.js +10 -2
- package/es/locale/th.js +10 -2
- package/es/locale/uk.js +10 -2
- package/es/locale/vi.js +10 -2
- package/es/locale/zh-CN.js +10 -2
- package/es/locale/zh-TW.js +10 -2
- package/es/mentions/index.js +291 -286
- package/es/menu/menu-context.js +1 -1
- package/es/menu/menu-divider.js +1 -1
- package/es/menu/menu-group.js +1 -1
- package/es/menu/menu-item.js +1 -1
- package/es/menu/menu-keyboard.js +41 -2
- package/es/menu/menu.js +268 -222
- package/es/menu/recursive-menu.js +1 -1
- package/es/menu/sub-menu.js +81 -23
- package/es/message/index.js +1 -1
- package/es/modal/api.js +46 -12
- package/es/modal/modal.js +441 -345
- package/es/modal/toast.js +177 -64
- package/es/node_modules/.pnpm/kui-icons@5.0.0/node_modules/kui-icons/dist/kui-icons.esm.js +1 -1
- package/es/notice/container.js +1 -1
- package/es/notice/content.js +1 -1
- package/es/notice/index.js +1 -1
- package/es/notice/instance.js +1 -1
- package/es/page/index.js +13 -8
- package/es/page/responsive.js +1 -1
- package/es/page-header/index.js +1 -1
- package/es/popconfirm/index.js +36 -35
- package/es/poptip/index.js +47 -45
- package/es/popup/index.js +5 -2
- package/es/popup/layers.js +11 -2
- package/es/progress/index.js +1 -1
- package/es/qrcode/index.js +13 -7
- package/es/radio/radio-button.js +51 -44
- package/es/radio/radio-group-context.js +1 -1
- package/es/radio/radio-group.js +49 -52
- package/es/radio/radio.js +46 -197
- package/es/rate/index.js +1 -1
- package/es/rate/star.js +1 -1
- package/es/result/index.js +1 -1
- package/es/ripple/index.js +104 -97
- package/es/ripple/types.js +71 -18
- package/es/row-col/col.js +1 -1
- package/es/row-col/row.js +1 -1
- package/es/segmented/index.js +3 -3
- package/es/select/option.js +1 -1
- package/es/select/select.js +29 -29
- package/es/skeleton/skeleton-avatar.js +1 -1
- package/es/skeleton/skeleton-button.js +1 -1
- package/es/skeleton/skeleton-image.js +1 -1
- package/es/skeleton/skeleton-text.js +1 -1
- package/es/skeleton/skeleton.js +1 -1
- package/es/skeleton/use-skeleton-loading.js +1 -1
- package/es/slider/index.js +1 -1
- package/es/slider/thumb.js +1 -1
- package/es/space/index.js +1 -1
- package/es/spin/index.js +1 -1
- package/es/splitter/splitter-panel.js +1 -1
- package/es/splitter/splitter.js +1 -1
- package/es/stat-card/countup.js +2 -2
- package/es/stat-card/rollup.js +1 -1
- package/es/stat-card/stat-card.js +16 -7
- package/es/stat-card/stat-number.js +4 -3
- package/es/stat-card/utils/countup.js +1 -1
- package/es/stat-card/utils/odometer.js +1 -1
- package/es/stat-card/utils/stat-item-key.js +22 -0
- package/es/steps/index.js +1 -1
- package/es/switch/index.js +3 -3
- package/es/table/column-setting.js +104 -115
- package/es/table/index.js +544 -206
- package/es/table/utils.js +141 -3
- package/es/tabs/tab-panel.js +1 -1
- package/es/tabs/tabs.js +1 -1
- package/es/tag/index.js +12 -5
- package/es/time-line/timeline-item.js +1 -1
- package/es/time-line/timeline.js +1 -1
- package/es/tooltip/index.js +114 -94
- package/es/tour/index.js +1 -1
- package/es/transfer/index.js +190 -172
- package/es/tree/index.js +55 -44
- package/es/tree/utils.js +1 -1
- package/es/tree-select/index.js +259 -781
- package/es/typography/index.js +1 -1
- package/es/upload/file-list.js +1 -1
- package/es/upload/index.js +5 -6
- package/es/upload/picture-sort.js +1 -1
- package/es/upload/selector.js +1 -1
- package/es/utils/checked.js +1 -1
- package/es/utils/color.js +25 -2
- package/es/utils/css.js +19 -0
- package/es/utils/focus.js +63 -0
- package/es/utils/number.js +1 -1
- package/es/utils/overlay-order.js +18 -0
- package/es/utils/overlay-stack.js +33 -0
- package/es/utils/placement.js +1 -1
- package/es/utils/popup.js +1 -1
- package/es/utils/promise.js +18 -0
- package/es/utils/react-node.js +55 -30
- package/es/utils/selection-tags.js +6 -4
- package/es/utils/share.js +5 -2
- package/es/utils/theme.js +1 -1
- package/es/utils/transition.js +1 -1
- package/es/utils/use-value.js +1 -1
- package/es/virtual-list/index.js +1 -1
- package/es/virtual-list/range.js +3 -2
- package/es/watermark/index.js +1 -1
- package/lib/index.cjs +2 -2
- package/lib/locale/de.cjs +2 -2
- package/lib/locale/el.cjs +2 -2
- package/lib/locale/en.cjs +2 -2
- package/lib/locale/fr.cjs +2 -2
- package/lib/locale/it.cjs +2 -2
- package/lib/locale/ja.cjs +2 -2
- package/lib/locale/ko.cjs +2 -2
- package/lib/locale/ru.cjs +2 -2
- package/lib/locale/th.cjs +2 -2
- package/lib/locale/uk.cjs +2 -2
- package/lib/locale/vi.cjs +2 -2
- package/lib/locale/zh-CN.cjs +2 -2
- package/lib/locale/zh-TW.cjs +2 -2
- package/package.json +4 -3
- package/readme.md +3 -1
- package/style/base.css +2 -2
- package/style/components.css +2 -2
- package/style/index.css +2 -2
- package/style/theme.css +2 -2
- package/types/alert/index.d.cts +2 -2
- package/types/alert/index.d.ts +2 -2
- package/types/auto-complete/index.d.cts +7 -1
- package/types/auto-complete/index.d.ts +7 -1
- package/types/badge/index.d.cts +2 -1
- package/types/badge/index.d.ts +2 -1
- package/types/button/button.d.cts +2 -2
- package/types/button/button.d.ts +2 -2
- package/types/card/index.d.cts +3 -3
- package/types/card/index.d.ts +3 -3
- package/types/cascader/index.d.cts +1 -1
- package/types/cascader/index.d.ts +1 -1
- package/types/cascader/types.d.cts +2 -0
- package/types/cascader/types.d.ts +2 -0
- package/types/check-card/context.d.cts +4 -3
- package/types/check-card/context.d.ts +4 -3
- package/types/check-card/index.d.cts +1 -1
- package/types/check-card/index.d.ts +1 -1
- package/types/check-card/types.d.cts +3 -4
- package/types/check-card/types.d.ts +3 -4
- package/types/checkbox/checkbox-group.d.cts +2 -2
- package/types/checkbox/checkbox-group.d.ts +2 -2
- package/types/checkbox/checkbox.d.cts +2 -2
- package/types/checkbox/checkbox.d.ts +2 -2
- package/types/collapse/collapse.d.cts +3 -3
- package/types/collapse/collapse.d.ts +3 -3
- package/types/color-picker/index.d.cts +3 -1
- package/types/color-picker/index.d.ts +3 -1
- package/types/components.d.cts +2 -2
- package/types/components.d.ts +2 -2
- package/types/config/config-context.d.cts +15 -2
- package/types/config/config-context.d.ts +15 -2
- package/types/config/context.d.cts +6 -0
- package/types/config/context.d.ts +6 -0
- package/types/config/popup-host.d.cts +16 -0
- package/types/config/popup-host.d.ts +16 -0
- package/types/config/use-config-appearance.d.cts +41 -2
- package/types/config/use-config-appearance.d.ts +41 -2
- package/types/const/types.d.cts +30 -1
- package/types/const/types.d.ts +30 -1
- package/types/const/var.d.cts +6 -1
- package/types/const/var.d.ts +6 -1
- package/types/date-picker/index.d.cts +3 -1
- package/types/date-picker/index.d.ts +3 -1
- package/types/descriptions/descriptions.d.cts +2 -2
- package/types/descriptions/descriptions.d.ts +2 -2
- package/types/drawer/index.d.cts +1 -0
- package/types/drawer/index.d.ts +1 -0
- package/types/dropdown/dropdown-button.d.cts +5 -2
- package/types/dropdown/dropdown-button.d.ts +5 -2
- package/types/dropdown/dropdown-context.d.cts +6 -0
- package/types/dropdown/dropdown-context.d.ts +6 -0
- package/types/dropdown/dropdown.d.cts +2 -0
- package/types/dropdown/dropdown.d.ts +2 -0
- package/types/feature-card/index.d.cts +3 -3
- package/types/feature-card/index.d.ts +3 -3
- package/types/feedback-panel/index.d.cts +3 -3
- package/types/feedback-panel/index.d.ts +3 -3
- package/types/flame-wrap/types.d.cts +18 -0
- package/types/flame-wrap/types.d.ts +18 -0
- package/types/form/field-context.d.cts +2 -0
- package/types/form/field-context.d.ts +2 -0
- package/types/image/image.d.cts +2 -2
- package/types/image/image.d.ts +2 -2
- package/types/input/input-group.d.cts +2 -2
- package/types/input/input-group.d.ts +2 -2
- package/types/input-number/index.d.cts +2 -0
- package/types/input-number/index.d.ts +2 -0
- package/types/kanban/index.d.cts +3 -2
- package/types/kanban/index.d.ts +3 -2
- package/types/list-panel/index.d.cts +3 -3
- package/types/list-panel/index.d.ts +3 -3
- package/types/locale/de.d.cts +6 -0
- package/types/locale/de.d.ts +6 -0
- package/types/locale/el.d.cts +6 -0
- package/types/locale/el.d.ts +6 -0
- package/types/locale/en.d.cts +6 -0
- package/types/locale/en.d.ts +6 -0
- package/types/locale/fr.d.cts +6 -0
- package/types/locale/fr.d.ts +6 -0
- package/types/locale/it.d.cts +6 -0
- package/types/locale/it.d.ts +6 -0
- package/types/locale/ja.d.cts +6 -0
- package/types/locale/ja.d.ts +6 -0
- package/types/locale/ko.d.cts +6 -0
- package/types/locale/ko.d.ts +6 -0
- package/types/locale/ru.d.cts +6 -0
- package/types/locale/ru.d.ts +6 -0
- package/types/locale/th.d.cts +6 -0
- package/types/locale/th.d.ts +6 -0
- package/types/locale/uk.d.cts +6 -0
- package/types/locale/uk.d.ts +6 -0
- package/types/locale/vi.d.cts +6 -0
- package/types/locale/vi.d.ts +6 -0
- package/types/locale/zh-CN.d.cts +6 -0
- package/types/locale/zh-CN.d.ts +6 -0
- package/types/locale/zh-TW.d.cts +6 -0
- package/types/locale/zh-TW.d.ts +6 -0
- package/types/mentions/index.d.cts +2 -0
- package/types/mentions/index.d.ts +2 -0
- package/types/menu/menu-keyboard.d.cts +23 -0
- package/types/menu/menu-keyboard.d.ts +23 -0
- package/types/modal/api.d.cts +6 -1
- package/types/modal/api.d.ts +6 -1
- package/types/modal/modal.d.cts +1 -0
- package/types/modal/modal.d.ts +1 -0
- package/types/modal/toast.d.cts +8 -2
- package/types/modal/toast.d.ts +8 -2
- package/types/page/index.d.cts +2 -2
- package/types/page/index.d.ts +2 -2
- package/types/popconfirm/index.d.cts +2 -0
- package/types/popconfirm/index.d.ts +2 -0
- package/types/poptip/index.d.cts +2 -0
- package/types/poptip/index.d.ts +2 -0
- package/types/popup/layers.d.cts +2 -0
- package/types/popup/layers.d.ts +2 -0
- package/types/qrcode/index.d.cts +2 -2
- package/types/qrcode/index.d.ts +2 -2
- package/types/radio/radio-button.d.cts +2 -2
- package/types/radio/radio-button.d.ts +2 -2
- package/types/radio/radio-group.d.cts +2 -2
- package/types/radio/radio-group.d.ts +2 -2
- package/types/radio/radio.d.cts +2 -2
- package/types/radio/radio.d.ts +2 -2
- package/types/ripple/types.d.cts +18 -0
- package/types/ripple/types.d.ts +18 -0
- package/types/select/select.d.cts +2 -0
- package/types/select/select.d.ts +2 -0
- package/types/stat-card/stat-card.d.cts +3 -3
- package/types/stat-card/stat-card.d.ts +3 -3
- package/types/stat-card/utils/stat-item-key.d.cts +11 -0
- package/types/stat-card/utils/stat-item-key.d.ts +11 -0
- package/types/table/column-setting.d.cts +4 -4
- package/types/table/column-setting.d.ts +4 -4
- package/types/table/index.d.cts +2 -2
- package/types/table/index.d.ts +2 -2
- package/types/table/types.d.cts +21 -2
- package/types/table/types.d.ts +21 -2
- package/types/table/utils.d.cts +75 -0
- package/types/table/utils.d.ts +75 -0
- package/types/tag/index.d.cts +2 -2
- package/types/tag/index.d.ts +2 -2
- package/types/tooltip/index.d.cts +2 -0
- package/types/tooltip/index.d.ts +2 -0
- package/types/transfer/index.d.cts +3 -2
- package/types/transfer/index.d.ts +3 -2
- package/types/tree-select/index.d.cts +3 -1
- package/types/tree-select/index.d.ts +3 -1
- package/types/utils/checked.d.cts +1 -1
- package/types/utils/checked.d.ts +1 -1
- package/types/utils/color.d.cts +13 -0
- package/types/utils/color.d.ts +13 -0
- package/types/utils/css.d.cts +2 -0
- package/types/utils/css.d.ts +2 -0
- package/types/utils/focus.d.cts +5 -0
- package/types/utils/focus.d.ts +5 -0
- package/types/utils/overlay-order.d.cts +6 -0
- package/types/utils/overlay-order.d.ts +6 -0
- package/types/utils/overlay-stack.d.cts +13 -0
- package/types/utils/overlay-stack.d.ts +13 -0
- package/types/utils/promise.d.cts +5 -0
- package/types/utils/promise.d.ts +5 -0
- package/types/utils/react-node.d.cts +10 -0
- package/types/utils/react-node.d.ts +10 -0
package/es/table/index.js
CHANGED
|
@@ -1,47 +1,263 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* react-kui v3.
|
|
2
|
+
* react-kui v3.2.0
|
|
3
3
|
* Copyright 2017-present, kui-react.
|
|
4
4
|
* All rights reserved.
|
|
5
5
|
* Homepage: https://react.k-ui.cn
|
|
6
6
|
* Author: Qiu / https://chuchur.com
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
+
import { ConfigContext, DEFAULT_LOCALE } from "../config/config-context.js";
|
|
9
10
|
import { normalizeSurfaceShape, useConfigAppearance } from "../config/use-config-appearance.js";
|
|
10
11
|
import { ChevronDown, ChevronRight, Triangle } from "../node_modules/.pnpm/kui-icons@5.0.0/node_modules/kui-icons/dist/kui-icons.esm.js";
|
|
11
12
|
import Icon from "../icon/index.js";
|
|
12
13
|
import { useValue } from "../utils/use-value.js";
|
|
13
14
|
import Empty from "../empty/index.js";
|
|
14
15
|
import checkbox_default from "../checkbox/checkbox.js";
|
|
16
|
+
import Tooltip from "../tooltip/index.js";
|
|
15
17
|
import { getVirtualRange } from "../virtual-list/range.js";
|
|
16
18
|
import Spin from "../spin/index.js";
|
|
17
|
-
import { countColumnLeaves, flattenColumns, flattenTreeData, getRecordValue } from "./utils.js";
|
|
19
|
+
import { compareSortValues, countColumnLeaves, flattenColumns, flattenTreeData, getRecordValue, inheritColumnFixed, mergeExpandAllRows, resolveCellEllipsis, resolveRowKey } from "./utils.js";
|
|
18
20
|
import { TableColumnSetting } from "./column-setting.js";
|
|
21
|
+
import { c } from "react/compiler-runtime";
|
|
19
22
|
import clsx from "clsx";
|
|
20
|
-
import { useEffect, useMemo, useRef, useState } from "react";
|
|
23
|
+
import { useCallback, useContext, useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
21
24
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
22
25
|
import { flushSync } from "react-dom";
|
|
23
26
|
//#region components/table/index.tsx
|
|
24
|
-
|
|
27
|
+
/**
|
|
28
|
+
* 默认值必须是稳定引用。每次渲染都新建的 `[]` / `{}` 会让
|
|
29
|
+
* `visibleColumns → leaves → sortRecords → rows → matrix` 这条 memo 链整段失效,
|
|
30
|
+
* 等于每次无关重渲染都重新扁平化、重新排序、重新铺合并矩阵。
|
|
31
|
+
*/
|
|
32
|
+
var EMPTY_DATA = [];
|
|
33
|
+
var EMPTY_COLUMNS = [];
|
|
34
|
+
var EMPTY_KEYS = [];
|
|
35
|
+
var EMPTY_SCROLL = {};
|
|
36
|
+
/**
|
|
37
|
+
* 列宽基准,与 kui-vue `components/table/index.tsx` 的同名常量保持一致。
|
|
38
|
+
*
|
|
39
|
+
* 规矩只有一条:**`<col>` 落地的宽度、算 sticky 偏移的宽度、表格内容的最小宽度,三处都从同一个
|
|
40
|
+
* `width ?? 150` 出发**。写了 `width` 的列(固定与否都一样)照原值写进 colgroup,偏移也按原值累加;
|
|
41
|
+
* 没写 `width` 的固定列按 150 落地;没写 `width` 的普通列在 colgroup 上留 `auto` 去吸收容器撑出来的
|
|
42
|
+
* 多余宽度,但在最小宽度里按 150 计——容器比这份下限还窄时先出横向滚动条,而不是把 `auto` 列一路压到
|
|
43
|
+
* 表头一个字一行。反过来把带宽度的普通列也写成 `auto` 是不行的——`table-layout: fixed`
|
|
44
|
+
* 下它们会被固定列的确切宽度挤到 0 宽,横向能滚的距离也一并消失,固定列就"看着没生效"。
|
|
45
|
+
*/
|
|
46
|
+
var DEFAULT_COLUMN_WIDTH = 150;
|
|
47
|
+
/** 勾选列宽度:colgroup、行内单元格样式和固定列的左偏移三处共用 */
|
|
48
|
+
var SELECTION_COLUMN_WIDTH = 50;
|
|
49
|
+
/** 一列的宽度基准:写了 `width` 照原值,没写按 150。sticky 偏移和表格最小宽度都走它。 */
|
|
50
|
+
var widthBasisOf = (column) => column.width ?? DEFAULT_COLUMN_WIDTH;
|
|
51
|
+
/** colgroup 落地的宽度:有 `width` 照写,缺宽度的固定列按 150,缺宽度的普通列交给 `auto`。 */
|
|
52
|
+
var colgroupWidthOf = (column) => column.width ?? (column.fixed ? DEFAULT_COLUMN_WIDTH : "auto");
|
|
53
|
+
/**
|
|
54
|
+
* 分栏表头要按真实滚动条宽度给表头容器让出一条槽位(见 `styles/index.less` 的 `k-table-split-header`),
|
|
55
|
+
* 这个值只能量、不能写死:新内核走 `.k-scroll` 的 `::-webkit-scrollbar { width }` 拿到 8px,
|
|
56
|
+
* Firefox 走 `scrollbar-width`(不认长度值的旧版退回 `thin` 的约 11px),更老的 Safari/Windows 是 15/17px。
|
|
57
|
+
* 探针必须带 `k-scroll` 类——量裸 `div` 得到的是浏览器默认滚动条宽度,不是库自己那套。
|
|
58
|
+
* 顺带一提 `overflow: scroll` 让两条轴都出滚动条,`offsetWidth - clientWidth` 才是纵向那一条的宽度。
|
|
59
|
+
*
|
|
60
|
+
* kui-react 与 kui-vue 的 `components/table/index.tsx` 里是逐字节相同的副本,改一边必须同步另一边。
|
|
61
|
+
*/
|
|
62
|
+
var measureScrollbarWidth = () => {
|
|
63
|
+
if (typeof document === "undefined") return 0;
|
|
64
|
+
const probe = document.createElement("div");
|
|
65
|
+
probe.className = "k-scroll";
|
|
66
|
+
probe.style.cssText = "position:absolute;top:-9999px;left:-9999px;width:100px;height:100px;overflow:scroll";
|
|
67
|
+
document.body.appendChild(probe);
|
|
68
|
+
const width = probe.offsetWidth - probe.clientWidth;
|
|
69
|
+
probe.remove();
|
|
70
|
+
return width;
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* 单元格省略号。`rows` 是截断行数,`tooltip` 决定悬停提示:省略或 `true` 用被截断的那段文本,
|
|
74
|
+
* 传内容则换成指定的提示,`false` 关掉。
|
|
75
|
+
*
|
|
76
|
+
* 提示只在**真的被截断**时才弹——判定放在 hover 那一刻量 `scrollWidth` / `scrollHeight`,
|
|
77
|
+
* 于是既不用给每格挂观察器,也不会给没截断的格子凭空多出一个气泡。
|
|
78
|
+
* `Tooltip` 在关闭时不产出任何 DOM,所以整表开启时每格挂一份也不吃亏。
|
|
79
|
+
*/
|
|
80
|
+
var EllipsisCell = (t0) => {
|
|
81
|
+
const $ = c(19);
|
|
82
|
+
const { rows, tooltip, className, children } = t0;
|
|
83
|
+
const innerRef = useRef(null);
|
|
84
|
+
const [tip, setTip] = useState(null);
|
|
85
|
+
const multiRows = rows > 1;
|
|
86
|
+
let t1;
|
|
87
|
+
if ($[0] !== multiRows || $[1] !== tooltip) {
|
|
88
|
+
t1 = () => {
|
|
89
|
+
const element = innerRef.current;
|
|
90
|
+
if (!element || tooltip === false) return;
|
|
91
|
+
if (!(multiRows ? element.scrollHeight > element.clientHeight + 1 : element.scrollWidth > element.clientWidth + 1)) return;
|
|
92
|
+
if (tooltip === void 0 || tooltip === true) {
|
|
93
|
+
setTip(element.textContent?.replace(/\s+/g, " ").trim() || null);
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
setTip(tooltip);
|
|
97
|
+
};
|
|
98
|
+
$[0] = multiRows;
|
|
99
|
+
$[1] = tooltip;
|
|
100
|
+
$[2] = t1;
|
|
101
|
+
} else t1 = $[2];
|
|
102
|
+
const enter = t1;
|
|
103
|
+
const t2 = multiRows && "k-table-cell-ellipsis-rows";
|
|
104
|
+
let t3;
|
|
105
|
+
if ($[3] !== className || $[4] !== t2) {
|
|
106
|
+
t3 = clsx("k-table-cell-ellipsis", t2, className);
|
|
107
|
+
$[3] = className;
|
|
108
|
+
$[4] = t2;
|
|
109
|
+
$[5] = t3;
|
|
110
|
+
} else t3 = $[5];
|
|
111
|
+
let t4;
|
|
112
|
+
if ($[6] !== multiRows || $[7] !== rows) {
|
|
113
|
+
t4 = multiRows ? { WebkitLineClamp: rows } : void 0;
|
|
114
|
+
$[6] = multiRows;
|
|
115
|
+
$[7] = rows;
|
|
116
|
+
$[8] = t4;
|
|
117
|
+
} else t4 = $[8];
|
|
118
|
+
let t5;
|
|
119
|
+
if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
|
|
120
|
+
t5 = () => setTip(null);
|
|
121
|
+
$[9] = t5;
|
|
122
|
+
} else t5 = $[9];
|
|
123
|
+
let t6;
|
|
124
|
+
if ($[10] !== children || $[11] !== enter || $[12] !== t3 || $[13] !== t4) {
|
|
125
|
+
t6 = /* @__PURE__ */ jsx("span", {
|
|
126
|
+
ref: innerRef,
|
|
127
|
+
className: t3,
|
|
128
|
+
style: t4,
|
|
129
|
+
onMouseEnter: enter,
|
|
130
|
+
onMouseLeave: t5,
|
|
131
|
+
children
|
|
132
|
+
});
|
|
133
|
+
$[10] = children;
|
|
134
|
+
$[11] = enter;
|
|
135
|
+
$[12] = t3;
|
|
136
|
+
$[13] = t4;
|
|
137
|
+
$[14] = t6;
|
|
138
|
+
} else t6 = $[14];
|
|
139
|
+
const node = t6;
|
|
140
|
+
if (tooltip === false) return node;
|
|
141
|
+
const t7 = Boolean(tip);
|
|
142
|
+
let t8;
|
|
143
|
+
if ($[15] !== node || $[16] !== t7 || $[17] !== tip) {
|
|
144
|
+
t8 = /* @__PURE__ */ jsx(Tooltip, {
|
|
145
|
+
trigger: "manual",
|
|
146
|
+
open: t7,
|
|
147
|
+
title: tip,
|
|
148
|
+
children: node
|
|
149
|
+
});
|
|
150
|
+
$[15] = node;
|
|
151
|
+
$[16] = t7;
|
|
152
|
+
$[17] = tip;
|
|
153
|
+
$[18] = t8;
|
|
154
|
+
} else t8 = $[18];
|
|
155
|
+
return t8;
|
|
156
|
+
};
|
|
157
|
+
/**
|
|
158
|
+
* 行展开状态。`expandedKeys` 提供时完全受控;否则 `expandAllRows` 决定初始是否全部展开,
|
|
159
|
+
* 并且此后 `data` 变化只补“新出现的父行”(见 `mergeExpandAllRows`),
|
|
160
|
+
* 用户手动展开或折叠过的行不会被异步到达的数据覆盖。
|
|
161
|
+
* “新出现”以本次数据里的父行为准,所以从数据里消失又回来的父行算新行、会重新展开,
|
|
162
|
+
* 组件不记住它曾被折叠(kui-vue 同口径)。
|
|
163
|
+
*/
|
|
164
|
+
function useRowExpansion(t0) {
|
|
165
|
+
const $ = c(21);
|
|
166
|
+
const { parentKeys, expandedKeys, expandAllRows } = t0;
|
|
167
|
+
let t1;
|
|
168
|
+
if ($[0] !== expandAllRows || $[1] !== expandedKeys) {
|
|
169
|
+
t1 = {
|
|
170
|
+
expandedKeys,
|
|
171
|
+
expandAllRows
|
|
172
|
+
};
|
|
173
|
+
$[0] = expandAllRows;
|
|
174
|
+
$[1] = expandedKeys;
|
|
175
|
+
$[2] = t1;
|
|
176
|
+
} else t1 = $[2];
|
|
177
|
+
const controlSource = t1;
|
|
178
|
+
let t2;
|
|
179
|
+
if ($[3] !== controlSource || $[4] !== expandAllRows || $[5] !== expandedKeys || $[6] !== parentKeys) {
|
|
180
|
+
t2 = () => ({
|
|
181
|
+
controlSource,
|
|
182
|
+
parentKeys,
|
|
183
|
+
keys: new Set(expandedKeys ?? (expandAllRows ? parentKeys : []))
|
|
184
|
+
});
|
|
185
|
+
$[3] = controlSource;
|
|
186
|
+
$[4] = expandAllRows;
|
|
187
|
+
$[5] = expandedKeys;
|
|
188
|
+
$[6] = parentKeys;
|
|
189
|
+
$[7] = t2;
|
|
190
|
+
} else t2 = $[7];
|
|
191
|
+
const [state, setState] = useState(t2);
|
|
192
|
+
let keys = state.keys;
|
|
193
|
+
if (!Object.is(state.controlSource, controlSource)) {
|
|
194
|
+
let t3;
|
|
195
|
+
if ($[8] !== expandAllRows || $[9] !== expandedKeys || $[10] !== parentKeys) {
|
|
196
|
+
t3 = expandedKeys ?? (expandAllRows ? parentKeys : []);
|
|
197
|
+
$[8] = expandAllRows;
|
|
198
|
+
$[9] = expandedKeys;
|
|
199
|
+
$[10] = parentKeys;
|
|
200
|
+
$[11] = t3;
|
|
201
|
+
} else t3 = $[11];
|
|
202
|
+
let t4;
|
|
203
|
+
if ($[12] !== t3) {
|
|
204
|
+
t4 = new Set(t3);
|
|
205
|
+
$[12] = t3;
|
|
206
|
+
$[13] = t4;
|
|
207
|
+
} else t4 = $[13];
|
|
208
|
+
keys = t4;
|
|
209
|
+
setState({
|
|
210
|
+
controlSource,
|
|
211
|
+
parentKeys,
|
|
212
|
+
keys
|
|
213
|
+
});
|
|
214
|
+
} else if (expandedKeys === void 0 && expandAllRows) {
|
|
215
|
+
let t3;
|
|
216
|
+
if ($[14] !== parentKeys || $[15] !== state.keys || $[16] !== state.parentKeys) {
|
|
217
|
+
t3 = mergeExpandAllRows(state.parentKeys, parentKeys, state.keys);
|
|
218
|
+
$[14] = parentKeys;
|
|
219
|
+
$[15] = state.keys;
|
|
220
|
+
$[16] = state.parentKeys;
|
|
221
|
+
$[17] = t3;
|
|
222
|
+
} else t3 = $[17];
|
|
223
|
+
const merged = t3;
|
|
224
|
+
if (state.parentKeys !== parentKeys || merged.changed) {
|
|
225
|
+
keys = merged.changed ? merged.keys : state.keys;
|
|
226
|
+
setState({
|
|
227
|
+
controlSource,
|
|
228
|
+
parentKeys,
|
|
229
|
+
keys
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
let t3;
|
|
234
|
+
if ($[18] === Symbol.for("react.memo_cache_sentinel")) {
|
|
235
|
+
t3 = (next) => setState((previous) => ({
|
|
236
|
+
...previous,
|
|
237
|
+
keys: next
|
|
238
|
+
}));
|
|
239
|
+
$[18] = t3;
|
|
240
|
+
} else t3 = $[18];
|
|
241
|
+
let t4;
|
|
242
|
+
if ($[19] !== keys) {
|
|
243
|
+
t4 = [keys, t3];
|
|
244
|
+
$[19] = keys;
|
|
245
|
+
$[20] = t4;
|
|
246
|
+
} else t4 = $[20];
|
|
247
|
+
return t4;
|
|
248
|
+
}
|
|
249
|
+
function Table({ data = EMPTY_DATA, columns = EMPTY_COLUMNS, ellipsis: tableEllipsis, selectedKeys, disabledKeys = EMPTY_KEYS, rowKey = "key", childrenColumnName = "children", expandedKeys, expandAllRows = false, expandRowByClick = false, indentSize = 20, scroll = EMPTY_SCROLL, size: sizeProp, striped, bordered = false, shape: shapeProp, checkable, loading, emptyText, header, footer, virtual = false, itemHeight = 44, overscan = 5, hiddenColumnKeys = EMPTY_KEYS, onSort, onRowClick, onSelect, onSelectAll, onSelectedKeysChange, onExpand, onExpandedKeysChange, className, ...rest }) {
|
|
25
250
|
const inheritedAppearance = useConfigAppearance();
|
|
251
|
+
const tableLocale = (useContext(ConfigContext)?.locale || DEFAULT_LOCALE)?.k?.table;
|
|
26
252
|
const size = sizeProp ?? inheritedAppearance.size;
|
|
27
253
|
const shape = normalizeSurfaceShape(shapeProp ?? inheritedAppearance.shape ?? "round");
|
|
28
|
-
const
|
|
254
|
+
const rootRef = useRef(null);
|
|
29
255
|
const bodyRef = useRef(null);
|
|
256
|
+
const headerWrapperRef = useRef(null);
|
|
257
|
+
/** 分栏表头里真正承担裁剪与横向同步的是内层(见 `styles/index.less` 的 `.k-table-thead-inner`)。 */
|
|
258
|
+
const headerScrollRef = useRef(null);
|
|
30
259
|
const scrollFrameRef = useRef(0);
|
|
31
260
|
const [innerSelected, setInnerSelected] = useValue(selectedKeys, (next) => new Set(next ?? []));
|
|
32
|
-
const expansionSource = useMemo(() => ({
|
|
33
|
-
expandedKeys,
|
|
34
|
-
expandAllRows
|
|
35
|
-
}), [expandedKeys, expandAllRows]);
|
|
36
|
-
const [innerExpanded, setInnerExpanded] = useValue(expansionSource, (source) => new Set(source.expandedKeys ?? (source.expandAllRows ? flattenTreeData({
|
|
37
|
-
data,
|
|
38
|
-
childrenColumnName,
|
|
39
|
-
getKey: (record) => {
|
|
40
|
-
if (typeof rowKey === "function") return rowKey(record);
|
|
41
|
-
const key = getRecordValue(record, rowKey);
|
|
42
|
-
return typeof key === "string" || typeof key === "number" ? key : "";
|
|
43
|
-
}
|
|
44
|
-
}).filter((row) => row.hasChildren).map((row_0) => typeof rowKey === "function" ? rowKey(row_0.record) : getRecordValue(row_0.record, rowKey) ?? "") : [])));
|
|
45
261
|
const [sort, setSort] = useState({
|
|
46
262
|
key: "",
|
|
47
263
|
order: null
|
|
@@ -50,11 +266,9 @@ function Table({ data = [], columns = [], selectedKeys, disabledKeys = [], rowKe
|
|
|
50
266
|
left: false,
|
|
51
267
|
right: false
|
|
52
268
|
});
|
|
53
|
-
const [scrollbarWidth, setScrollbarWidth] = useState(0);
|
|
54
269
|
const [scrollTop, setScrollTop] = useState(0);
|
|
55
270
|
const [viewportHeight, setViewportHeight] = useState(0);
|
|
56
271
|
const selected = innerSelected;
|
|
57
|
-
const currentExpanded = innerExpanded;
|
|
58
272
|
const visibleColumns = useMemo(() => {
|
|
59
273
|
const filter = (items) => items.flatMap((column) => {
|
|
60
274
|
if (hiddenColumnKeys.includes(column.key)) return [];
|
|
@@ -67,65 +281,127 @@ function Table({ data = [], columns = [], selectedKeys, disabledKeys = [], rowKe
|
|
|
67
281
|
});
|
|
68
282
|
return filter(columns);
|
|
69
283
|
}, [columns, hiddenColumnKeys]);
|
|
70
|
-
const
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
const
|
|
284
|
+
const inheritedColumns = useMemo(() => inheritColumnFixed(visibleColumns), [visibleColumns]);
|
|
285
|
+
const leaves = useMemo(() => flattenColumns(inheritedColumns), [inheritedColumns]);
|
|
286
|
+
/**
|
|
287
|
+
* 表格内容的最小宽度:每列的宽度基准之和(没写 `width` 的普通列按 150 计),再加勾选列的 50。
|
|
288
|
+
* `<col>` 上它们仍是 `auto`,宽容器里照旧平摊多余空间;这一份只是下限,容器比它还窄就出横向
|
|
289
|
+
* 滚动条。`scroll.x` 显式给了则照旧以 `scroll.x` 为准。
|
|
290
|
+
*/
|
|
291
|
+
const contentMinWidth = useMemo(() => leaves.reduce((sum, column_0) => sum + widthBasisOf(column_0), 0) + (checkable ? SELECTION_COLUMN_WIDTH : 0), [leaves, checkable]);
|
|
292
|
+
const cellEllipsis = useMemo(() => {
|
|
293
|
+
const map = /* @__PURE__ */ new Map();
|
|
294
|
+
leaves.forEach((column_1) => map.set(column_1.key, resolveCellEllipsis(column_1.ellipsis, tableEllipsis)));
|
|
295
|
+
return map;
|
|
296
|
+
}, [leaves, tableEllipsis]);
|
|
297
|
+
const splitHeader = scroll.y != null;
|
|
298
|
+
const virtualEnabled = virtual && splitHeader;
|
|
299
|
+
const rawId = useId();
|
|
300
|
+
const headCellIds = useMemo(() => {
|
|
301
|
+
const ids = /* @__PURE__ */ new Map();
|
|
302
|
+
if (!splitHeader) return ids;
|
|
303
|
+
const prefix = `k-table-${rawId.replace(/[^a-zA-Z0-9_-]/g, "")}-`;
|
|
304
|
+
const visit = (items_0) => items_0.forEach((item) => {
|
|
305
|
+
ids.set(item.key, `${prefix}${ids.size}`);
|
|
306
|
+
if (item.children?.length) visit(item.children);
|
|
307
|
+
});
|
|
308
|
+
visit(inheritedColumns);
|
|
309
|
+
return ids;
|
|
310
|
+
}, [
|
|
311
|
+
splitHeader,
|
|
312
|
+
rawId,
|
|
313
|
+
inheritedColumns
|
|
314
|
+
]);
|
|
315
|
+
const keyOf = useCallback((record) => resolveRowKey(record, rowKey), [rowKey]);
|
|
316
|
+
const isDisabled = (key) => disabledKeys.includes(key);
|
|
317
|
+
const allRows = useMemo(() => flattenTreeData({
|
|
318
|
+
data,
|
|
319
|
+
childrenColumnName,
|
|
320
|
+
getKey: keyOf
|
|
321
|
+
}), [
|
|
322
|
+
data,
|
|
323
|
+
childrenColumnName,
|
|
324
|
+
keyOf
|
|
325
|
+
]);
|
|
326
|
+
const [currentExpanded, setInnerExpanded] = useRowExpansion({
|
|
327
|
+
parentKeys: useMemo(() => new Set(allRows.filter((row) => row.hasChildren).map((row_0) => resolveRowKey(row_0.record, rowKey))), [allRows, rowKey]),
|
|
328
|
+
expandedKeys,
|
|
329
|
+
expandAllRows
|
|
330
|
+
});
|
|
79
331
|
const headerInfo = useMemo(() => {
|
|
80
332
|
let maxDepth = 1;
|
|
81
|
-
const depth = (
|
|
82
|
-
depth(
|
|
333
|
+
const depth = (items_1, level = 1) => items_1.forEach((item_0) => item_0.children?.length ? depth(item_0.children, level + 1) : maxDepth = Math.max(maxDepth, level));
|
|
334
|
+
depth(inheritedColumns);
|
|
335
|
+
const fixedDirectionOf = (leafStart, leafCount) => {
|
|
336
|
+
const direction = leaves[leafStart]?.fixed;
|
|
337
|
+
if (!direction) return void 0;
|
|
338
|
+
for (let index = leafStart + 1; index < leafStart + leafCount; index += 1) if (leaves[index]?.fixed !== direction) return void 0;
|
|
339
|
+
return direction;
|
|
340
|
+
};
|
|
83
341
|
const headerRows = [];
|
|
84
|
-
const
|
|
342
|
+
const visit_0 = (items_2, level_0, startAt) => {
|
|
85
343
|
headerRows[level_0] ??= [];
|
|
86
|
-
|
|
344
|
+
let cursor = startAt;
|
|
345
|
+
items_2.forEach((item_1) => {
|
|
346
|
+
const leafStart_0 = cursor;
|
|
347
|
+
const headerColSpan = countColumnLeaves(item_1);
|
|
87
348
|
headerRows[level_0].push({
|
|
88
|
-
...
|
|
89
|
-
headerColSpan
|
|
90
|
-
headerRowSpan:
|
|
349
|
+
...item_1,
|
|
350
|
+
headerColSpan,
|
|
351
|
+
headerRowSpan: item_1.children?.length ? 1 : maxDepth - level_0,
|
|
352
|
+
leafStart: leafStart_0,
|
|
353
|
+
headerFixed: fixedDirectionOf(leafStart_0, headerColSpan)
|
|
91
354
|
});
|
|
92
|
-
|
|
355
|
+
cursor += headerColSpan;
|
|
356
|
+
if (item_1.children?.length) visit_0(item_1.children, level_0 + 1, leafStart_0);
|
|
93
357
|
});
|
|
94
358
|
};
|
|
95
|
-
|
|
359
|
+
visit_0(inheritedColumns, 0, 0);
|
|
96
360
|
return {
|
|
97
361
|
rows: headerRows,
|
|
98
362
|
maxDepth
|
|
99
363
|
};
|
|
100
|
-
}, [
|
|
364
|
+
}, [inheritedColumns, leaves]);
|
|
101
365
|
const fixed = useMemo(() => {
|
|
102
366
|
const header_0 = {};
|
|
103
367
|
const body = {};
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
368
|
+
const leftBefore = [];
|
|
369
|
+
const rightAfter = [];
|
|
370
|
+
let left = checkable ? SELECTION_COLUMN_WIDTH : 0;
|
|
371
|
+
leaves.forEach((column_2, index_0) => {
|
|
372
|
+
leftBefore[index_0] = left;
|
|
373
|
+
if (column_2.fixed === "left") {
|
|
374
|
+
body[column_2.key] = {
|
|
108
375
|
position: "sticky",
|
|
109
376
|
left
|
|
110
377
|
};
|
|
111
|
-
|
|
112
|
-
body[column_0.key] = style;
|
|
113
|
-
left += column_0.width ?? 150;
|
|
378
|
+
left += widthBasisOf(column_2);
|
|
114
379
|
}
|
|
115
380
|
});
|
|
116
381
|
let right = 0;
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
382
|
+
for (let index_1 = leaves.length - 1; index_1 >= 0; index_1 -= 1) {
|
|
383
|
+
rightAfter[index_1] = right;
|
|
384
|
+
const column_3 = leaves[index_1];
|
|
385
|
+
if (column_3.fixed === "right") {
|
|
386
|
+
body[column_3.key] = {
|
|
120
387
|
position: "sticky",
|
|
121
388
|
right
|
|
122
389
|
};
|
|
123
|
-
|
|
390
|
+
right += widthBasisOf(column_3);
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
headerInfo.rows.forEach((row_1) => {
|
|
394
|
+
row_1.forEach((cell) => {
|
|
395
|
+
const lastLeaf = cell.leafStart + cell.headerColSpan - 1;
|
|
396
|
+
if (cell.headerFixed === "left") header_0[cell.key] = {
|
|
397
|
+
position: "sticky",
|
|
398
|
+
left: leftBefore[cell.leafStart] ?? 0
|
|
399
|
+
};
|
|
400
|
+
else if (cell.headerFixed === "right") header_0[cell.key] = {
|
|
124
401
|
position: "sticky",
|
|
125
|
-
right:
|
|
402
|
+
right: rightAfter[lastLeaf] ?? 0
|
|
126
403
|
};
|
|
127
|
-
|
|
128
|
-
}
|
|
404
|
+
});
|
|
129
405
|
});
|
|
130
406
|
return {
|
|
131
407
|
header: header_0,
|
|
@@ -134,39 +410,52 @@ function Table({ data = [], columns = [], selectedKeys, disabledKeys = [], rowKe
|
|
|
134
410
|
}, [
|
|
135
411
|
checkable,
|
|
136
412
|
leaves,
|
|
137
|
-
|
|
138
|
-
split
|
|
413
|
+
headerInfo
|
|
139
414
|
]);
|
|
140
|
-
const fixedClass = (
|
|
141
|
-
"k-table-cell-fix-left":
|
|
142
|
-
"k-table-cell-fix-left-last":
|
|
143
|
-
"k-table-cell-fix-right":
|
|
144
|
-
"k-table-cell-fix-right-first":
|
|
145
|
-
"k-table-cell-sorter":
|
|
415
|
+
const fixedClass = (column_4, index_2, colSpan = 1) => clsx({
|
|
416
|
+
"k-table-cell-fix-left": column_4.fixed === "left",
|
|
417
|
+
"k-table-cell-fix-left-last": column_4.fixed === "left" && leaves[index_2 + 1]?.fixed !== "left",
|
|
418
|
+
"k-table-cell-fix-right": column_4.fixed === "right",
|
|
419
|
+
"k-table-cell-fix-right-first": column_4.fixed === "right" && leaves[index_2 - 1]?.fixed !== "right",
|
|
420
|
+
"k-table-cell-sorter": column_4.sorter,
|
|
421
|
+
"k-table-cell-last-column": index_2 + colSpan === leaves.length
|
|
422
|
+
});
|
|
423
|
+
/**
|
|
424
|
+
* 表头格的固定类按它覆盖的叶子区间判断。`*-last`/`*-first` 决定横向滚动时 ping 阴影画在哪一格的
|
|
425
|
+
* 边沿上,分组表头若改用叶子下标去查会拿到 `-1`,把不该画阴影的父格标成最后一列固定格。
|
|
426
|
+
*
|
|
427
|
+
* `k-table-cell-last-column` 同理必须按区间末尾算:bordered 时只有真的盖到最后一列的格子才让出
|
|
428
|
+
* 右边框。表头每一行的格数不一样(分组格占 `colSpan`),行末那一格往往并不是最后一列。
|
|
429
|
+
*/
|
|
430
|
+
const headerFixedClass = (cell_0) => clsx({
|
|
431
|
+
"k-table-cell-fix-left": cell_0.headerFixed === "left",
|
|
432
|
+
"k-table-cell-fix-left-last": cell_0.headerFixed === "left" && leaves[cell_0.leafStart + cell_0.headerColSpan]?.fixed !== "left",
|
|
433
|
+
"k-table-cell-fix-right": cell_0.headerFixed === "right",
|
|
434
|
+
"k-table-cell-fix-right-first": cell_0.headerFixed === "right" && leaves[cell_0.leafStart - 1]?.fixed !== "right",
|
|
435
|
+
"k-table-cell-sorter": cell_0.sorter,
|
|
436
|
+
"k-table-cell-last-column": cell_0.leafStart + cell_0.headerColSpan === leaves.length
|
|
146
437
|
});
|
|
147
|
-
const
|
|
148
|
-
const sortRecords = (records) => {
|
|
438
|
+
const sortRecords = useCallback((records) => {
|
|
149
439
|
const result = [...records];
|
|
150
|
-
if (sort.key && sort.order && leaves.find((
|
|
151
|
-
const
|
|
152
|
-
if (first === second) return 0;
|
|
153
|
-
const comparison = typeof first === "number" && typeof second === "number" || typeof first === "string" && typeof second === "string" ? first > second ? 1 : -1 : 0;
|
|
440
|
+
if (sort.key && sort.order && leaves.find((column_5) => column_5.key === sort.key)?.sorter === true) result.sort((a, b) => {
|
|
441
|
+
const comparison = compareSortValues(getRecordValue(a, sort.key), getRecordValue(b, sort.key));
|
|
154
442
|
return sort.order === "asc" ? comparison : -comparison;
|
|
155
443
|
});
|
|
156
444
|
return result;
|
|
157
|
-
};
|
|
158
|
-
const
|
|
159
|
-
data,
|
|
160
|
-
childrenColumnName,
|
|
161
|
-
getKey: keyOf
|
|
162
|
-
});
|
|
163
|
-
const rows = flattenTreeData({
|
|
445
|
+
}, [leaves, sort]);
|
|
446
|
+
const rows = useMemo(() => flattenTreeData({
|
|
164
447
|
data,
|
|
165
448
|
childrenColumnName,
|
|
166
449
|
expandedKeys: currentExpanded,
|
|
167
450
|
getKey: keyOf,
|
|
168
451
|
sortRecords
|
|
169
|
-
})
|
|
452
|
+
}), [
|
|
453
|
+
data,
|
|
454
|
+
childrenColumnName,
|
|
455
|
+
currentExpanded,
|
|
456
|
+
keyOf,
|
|
457
|
+
sortRecords
|
|
458
|
+
]);
|
|
170
459
|
const virtualRange = useMemo(() => {
|
|
171
460
|
if (!virtualEnabled) return {
|
|
172
461
|
start: 0,
|
|
@@ -189,38 +478,46 @@ function Table({ data = [], columns = [], selectedKeys, disabledKeys = [], rowKe
|
|
|
189
478
|
itemHeight,
|
|
190
479
|
overscan
|
|
191
480
|
]);
|
|
192
|
-
const treeEnabled = allRows.some((
|
|
481
|
+
const treeEnabled = useMemo(() => allRows.some((row_2) => row_2.hasChildren), [allRows]);
|
|
193
482
|
const matrix = useMemo(() => {
|
|
194
|
-
if (!leaves.some((
|
|
483
|
+
if (!leaves.some((column_6) => column_6.rowSpan !== void 0 || column_6.colSpan !== void 0)) return [];
|
|
195
484
|
const result_0 = rows.map(() => leaves.map(() => ({
|
|
196
485
|
rowSpan: 1,
|
|
197
486
|
colSpan: 1,
|
|
198
487
|
show: true
|
|
199
488
|
})));
|
|
200
|
-
rows.forEach(({ record:
|
|
201
|
-
if (!result_0[
|
|
202
|
-
const rowSpan = typeof
|
|
203
|
-
const
|
|
489
|
+
rows.forEach(({ record: record_0 }, row_3) => leaves.forEach((column_7, col) => {
|
|
490
|
+
if (!result_0[row_3][col].show) return;
|
|
491
|
+
const rowSpan = typeof column_7.rowSpan === "function" ? column_7.rowSpan(record_0, row_3) : column_7.rowSpan ?? 1;
|
|
492
|
+
const colSpan_0 = typeof column_7.colSpan === "function" ? column_7.colSpan(record_0, row_3) : column_7.colSpan ?? 1;
|
|
204
493
|
const normalizedRowSpan = Number.isFinite(rowSpan) ? Math.max(0, Math.floor(rowSpan)) : 1;
|
|
205
|
-
const normalizedColSpan = Number.isFinite(
|
|
494
|
+
const normalizedColSpan = Number.isFinite(colSpan_0) ? Math.max(0, Math.floor(colSpan_0)) : 1;
|
|
206
495
|
if (normalizedRowSpan === 0 || normalizedColSpan === 0) {
|
|
207
|
-
result_0[
|
|
496
|
+
result_0[row_3][col].show = false;
|
|
208
497
|
return;
|
|
209
498
|
}
|
|
210
|
-
result_0[
|
|
499
|
+
result_0[row_3][col] = {
|
|
211
500
|
rowSpan: normalizedRowSpan,
|
|
212
501
|
colSpan: normalizedColSpan,
|
|
213
502
|
show: true
|
|
214
503
|
};
|
|
215
504
|
for (let r = 0; r < normalizedRowSpan; r++) for (let c = 0; c < normalizedColSpan; c++) if (r || c) {
|
|
216
|
-
const
|
|
217
|
-
if (
|
|
505
|
+
const cell_1 = result_0[row_3 + r]?.[col + c];
|
|
506
|
+
if (cell_1) cell_1.show = false;
|
|
218
507
|
}
|
|
219
508
|
}));
|
|
220
509
|
return result_0;
|
|
221
510
|
}, [leaves, rows]);
|
|
222
|
-
const enabled = allRows.map((
|
|
223
|
-
|
|
511
|
+
const enabled = useMemo(() => allRows.map((row_4) => row_4.record).filter((record_1) => !disabledKeys.includes(keyOf(record_1))), [
|
|
512
|
+
allRows,
|
|
513
|
+
disabledKeys,
|
|
514
|
+
keyOf
|
|
515
|
+
]);
|
|
516
|
+
const checkedCount = useMemo(() => enabled.filter((record_2) => selected.has(keyOf(record_2))).length, [
|
|
517
|
+
enabled,
|
|
518
|
+
selected,
|
|
519
|
+
keyOf
|
|
520
|
+
]);
|
|
224
521
|
const allChecked = enabled.length > 0 && checkedCount === enabled.length;
|
|
225
522
|
const indeterminate = checkedCount > 0 && checkedCount < enabled.length;
|
|
226
523
|
const commitSelection = (next_0) => {
|
|
@@ -231,52 +528,51 @@ function Table({ data = [], columns = [], selectedKeys, disabledKeys = [], rowKe
|
|
|
231
528
|
};
|
|
232
529
|
const toggleAll = ({ checked }) => {
|
|
233
530
|
const next_1 = new Set(selected);
|
|
234
|
-
allRows.forEach(({ record:
|
|
235
|
-
const
|
|
236
|
-
if (!isDisabled(
|
|
237
|
-
if (checked) next_1.add(
|
|
238
|
-
else next_1.delete(
|
|
531
|
+
allRows.forEach(({ record: record_3 }) => {
|
|
532
|
+
const key_0 = keyOf(record_3);
|
|
533
|
+
if (!isDisabled(key_0)) {
|
|
534
|
+
if (checked) next_1.add(key_0);
|
|
535
|
+
else next_1.delete(key_0);
|
|
239
536
|
}
|
|
240
537
|
});
|
|
241
538
|
const keys_0 = commitSelection(next_1);
|
|
242
539
|
onSelectAll?.(checked, keys_0);
|
|
243
540
|
};
|
|
244
|
-
const toggleOne = (event,
|
|
245
|
-
const
|
|
246
|
-
if (isDisabled(
|
|
541
|
+
const toggleOne = (event, record_4) => {
|
|
542
|
+
const key_1 = keyOf(record_4);
|
|
543
|
+
if (isDisabled(key_1)) return;
|
|
247
544
|
const next_2 = new Set(selected);
|
|
248
|
-
if (event.checked) next_2.add(
|
|
249
|
-
else next_2.delete(
|
|
545
|
+
if (event.checked) next_2.add(key_1);
|
|
546
|
+
else next_2.delete(key_1);
|
|
250
547
|
const keys_1 = commitSelection(next_2);
|
|
251
|
-
onSelect?.(
|
|
548
|
+
onSelect?.(record_4, event.checked, keys_1);
|
|
252
549
|
};
|
|
253
|
-
const toggleExpand = (
|
|
254
|
-
const
|
|
550
|
+
const toggleExpand = (record_5) => {
|
|
551
|
+
const key_2 = keyOf(record_5);
|
|
255
552
|
const next_3 = new Set(currentExpanded);
|
|
256
|
-
const nextExpanded = !next_3.has(
|
|
257
|
-
if (nextExpanded) next_3.add(
|
|
258
|
-
else next_3.delete(
|
|
553
|
+
const nextExpanded = !next_3.has(key_2);
|
|
554
|
+
if (nextExpanded) next_3.add(key_2);
|
|
555
|
+
else next_3.delete(key_2);
|
|
259
556
|
setInnerExpanded(next_3);
|
|
260
557
|
onExpandedKeysChange?.([...next_3]);
|
|
261
|
-
onExpand?.(nextExpanded,
|
|
558
|
+
onExpand?.(nextExpanded, record_5);
|
|
262
559
|
};
|
|
263
|
-
const changeSort = (
|
|
264
|
-
if (!
|
|
560
|
+
const changeSort = (column_8) => {
|
|
561
|
+
if (!column_8.sorter) return;
|
|
265
562
|
const next_4 = {
|
|
266
|
-
key:
|
|
267
|
-
order: sort.key !==
|
|
563
|
+
key: column_8.key,
|
|
564
|
+
order: sort.key !== column_8.key ? "asc" : sort.order === "asc" ? "desc" : sort.order === "desc" ? null : "asc"
|
|
268
565
|
};
|
|
269
566
|
setSort(next_4);
|
|
270
|
-
if (typeof
|
|
567
|
+
if (typeof column_8.sorter === "function") column_8.sorter(next_4);
|
|
271
568
|
onSort?.(next_4);
|
|
272
569
|
};
|
|
273
570
|
const handleScroll = (event_0) => {
|
|
274
|
-
const
|
|
571
|
+
const body_0 = bodyRef.current ?? event_0.currentTarget;
|
|
572
|
+
if (splitHeader && headerScrollRef.current) headerScrollRef.current.scrollLeft = body_0.scrollLeft;
|
|
275
573
|
if (scrollFrameRef.current) return;
|
|
276
574
|
scrollFrameRef.current = requestAnimationFrame(() => {
|
|
277
575
|
scrollFrameRef.current = 0;
|
|
278
|
-
const body_0 = bodyRef.current ?? target;
|
|
279
|
-
if (split && headerRef.current) headerRef.current.scrollLeft = body_0.scrollLeft;
|
|
280
576
|
const max = Math.max(0, body_0.scrollWidth - body_0.clientWidth);
|
|
281
577
|
const update = () => {
|
|
282
578
|
if (virtualEnabled) setScrollTop(body_0.scrollTop);
|
|
@@ -294,7 +590,6 @@ function Table({ data = [], columns = [], selectedKeys, disabledKeys = [], rowKe
|
|
|
294
590
|
const body_1 = bodyRef.current;
|
|
295
591
|
if (!body_1) return;
|
|
296
592
|
const measure = () => {
|
|
297
|
-
setScrollbarWidth(split ? Math.max(0, body_1.offsetWidth - body_1.clientWidth - (bordered ? 1 : 0)) : 0);
|
|
298
593
|
setViewportHeight(body_1.clientHeight);
|
|
299
594
|
const max_0 = Math.max(0, body_1.scrollWidth - body_1.clientWidth);
|
|
300
595
|
const nextPing_0 = {
|
|
@@ -313,63 +608,82 @@ function Table({ data = [], columns = [], selectedKeys, disabledKeys = [], rowKe
|
|
|
313
608
|
};
|
|
314
609
|
}
|
|
315
610
|
return () => cancelAnimationFrame(scrollFrameRef.current);
|
|
316
|
-
}, [
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
611
|
+
}, []);
|
|
612
|
+
useLayoutEffect(() => {
|
|
613
|
+
const root = rootRef.current;
|
|
614
|
+
if (!root) return;
|
|
615
|
+
root.style.setProperty("--k-table-scrollbar-width", splitHeader ? `${measureScrollbarWidth()}px` : "");
|
|
616
|
+
}, [splitHeader]);
|
|
617
|
+
useEffect(() => {
|
|
618
|
+
const wrapper = headerWrapperRef.current;
|
|
619
|
+
const body_2 = bodyRef.current;
|
|
620
|
+
if (!splitHeader || !wrapper || !body_2) return;
|
|
621
|
+
const onWheel = (event_1) => {
|
|
622
|
+
const unit = event_1.deltaMode === 1 ? 16 : event_1.deltaMode === 2 ? body_2.clientHeight : 1;
|
|
623
|
+
const maxTop = Math.max(0, body_2.scrollHeight - body_2.clientHeight);
|
|
624
|
+
const maxLeft = Math.max(0, body_2.scrollWidth - body_2.clientWidth);
|
|
625
|
+
const nextTop = Math.min(maxTop, Math.max(0, body_2.scrollTop + event_1.deltaY * unit));
|
|
626
|
+
const nextLeft = Math.min(maxLeft, Math.max(0, body_2.scrollLeft + event_1.deltaX * unit));
|
|
627
|
+
if (nextTop === body_2.scrollTop && nextLeft === body_2.scrollLeft) return;
|
|
628
|
+
event_1.preventDefault();
|
|
629
|
+
body_2.scrollTo({
|
|
630
|
+
top: nextTop,
|
|
631
|
+
left: nextLeft
|
|
632
|
+
});
|
|
633
|
+
};
|
|
634
|
+
wrapper.addEventListener("wheel", onWheel, { passive: false });
|
|
635
|
+
return () => wrapper.removeEventListener("wheel", onWheel);
|
|
636
|
+
}, [splitHeader]);
|
|
637
|
+
const colgroup = /* @__PURE__ */ jsxs("colgroup", { children: [checkable && /* @__PURE__ */ jsx("col", { style: { width: SELECTION_COLUMN_WIDTH } }), leaves.map((column_9) => /* @__PURE__ */ jsx("col", { style: { width: colgroupWidthOf(column_9) } }, column_9.key))] });
|
|
638
|
+
const thead = /* @__PURE__ */ jsx("thead", { children: headerInfo.rows.map((row_5, rowIndex) => /* @__PURE__ */ jsxs("tr", { children: [checkable && rowIndex === 0 && /* @__PURE__ */ jsx("th", {
|
|
639
|
+
rowSpan: headerInfo.maxDepth,
|
|
640
|
+
className: clsx("k-table-cell-fix-left", {
|
|
641
|
+
"k-table-cell-fix-left-last": ping.left,
|
|
642
|
+
"k-table-cell-last-column": !leaves.length
|
|
339
643
|
}),
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
644
|
+
style: { left: 0 },
|
|
645
|
+
children: /* @__PURE__ */ jsx(checkbox_default, {
|
|
646
|
+
checked: allChecked,
|
|
647
|
+
indeterminate,
|
|
648
|
+
onChange: toggleAll,
|
|
649
|
+
disabled: !enabled.length,
|
|
650
|
+
"aria-label": tableLocale?.selectAllRows || "Select all"
|
|
651
|
+
})
|
|
652
|
+
}), row_5.map((column_10, index_3) => /* @__PURE__ */ jsx("th", {
|
|
653
|
+
id: splitHeader ? headCellIds.get(column_10.key) : void 0,
|
|
654
|
+
colSpan: column_10.headerColSpan,
|
|
655
|
+
rowSpan: column_10.headerRowSpan,
|
|
656
|
+
className: headerFixedClass(column_10),
|
|
657
|
+
style: fixed.header[column_10.key],
|
|
658
|
+
tabIndex: column_10.sorter ? 0 : void 0,
|
|
659
|
+
"aria-sort": !column_10.sorter ? void 0 : sort.key !== column_10.key || !sort.order ? "none" : sort.order === "asc" ? "ascending" : "descending",
|
|
660
|
+
onClick: () => changeSort(column_10),
|
|
661
|
+
onKeyDown: (event_2) => {
|
|
662
|
+
if (!column_10.sorter || event_2.key !== "Enter" && event_2.key !== " ") return;
|
|
663
|
+
event_2.preventDefault();
|
|
664
|
+
changeSort(column_10);
|
|
665
|
+
},
|
|
666
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
667
|
+
className: "k-table-header-col",
|
|
668
|
+
children: [column_10.renderHeader?.(column_10, index_3) ?? column_10.title, column_10.sorter && /* @__PURE__ */ jsxs("span", {
|
|
669
|
+
className: "k-table-sorter",
|
|
670
|
+
children: [/* @__PURE__ */ jsx(Icon, {
|
|
671
|
+
type: Triangle,
|
|
672
|
+
reverseFill: true,
|
|
673
|
+
className: clsx("k-table-sorter-up", { "k-table-sorter-active": sort.key === column_10.key && sort.order === "asc" })
|
|
674
|
+
}), /* @__PURE__ */ jsx(Icon, {
|
|
675
|
+
type: Triangle,
|
|
676
|
+
reverseFill: true,
|
|
677
|
+
className: clsx("k-table-sorter-down", { "k-table-sorter-active": sort.key === column_10.key && sort.order === "desc" })
|
|
359
678
|
})]
|
|
360
|
-
})
|
|
361
|
-
}, column_9.key)),
|
|
362
|
-
split && rowIndex === 0 && /* @__PURE__ */ jsx("th", {
|
|
363
|
-
rowSpan: headerInfo.maxDepth,
|
|
364
|
-
className: "k-table-scrollbar-patch",
|
|
365
|
-
style: { width: scrollbarWidth }
|
|
679
|
+
})]
|
|
366
680
|
})
|
|
367
|
-
] }, rowIndex)) });
|
|
681
|
+
}, column_10.key))] }, rowIndex)) });
|
|
368
682
|
const renderedRows = useMemo(() => {
|
|
369
683
|
const start = virtualRange.start;
|
|
370
684
|
const end = virtualRange.end;
|
|
371
|
-
return rows.slice(start, end).map((
|
|
372
|
-
...
|
|
685
|
+
return rows.slice(start, end).map((row_6, idx) => ({
|
|
686
|
+
...row_6,
|
|
373
687
|
rowIndex: start + idx
|
|
374
688
|
}));
|
|
375
689
|
}, [rows, virtualRange]);
|
|
@@ -378,65 +692,82 @@ function Table({ data = [], columns = [], selectedKeys, disabledKeys = [], rowKe
|
|
|
378
692
|
className: "k-table-virtual-spacer k-table-virtual-spacer-top",
|
|
379
693
|
"aria-hidden": "true",
|
|
380
694
|
children: /* @__PURE__ */ jsx("td", {
|
|
695
|
+
className: "k-table-cell-last-column",
|
|
381
696
|
colSpan: leaves.length + (checkable ? 1 : 0),
|
|
382
697
|
style: { height: virtualRange.offset }
|
|
383
698
|
})
|
|
384
699
|
}),
|
|
385
|
-
renderedRows.map(({ record:
|
|
700
|
+
renderedRows.map(({ record: record_6, depth: depth_0, hasChildren, rowIndex: rowIndex_0 }) => /* @__PURE__ */ jsxs("tr", {
|
|
386
701
|
className: virtualEnabled && rowIndex_0 % 2 === 1 ? "k-table-row-even" : void 0,
|
|
387
702
|
style: virtualEnabled ? { height: itemHeight } : void 0,
|
|
388
|
-
onClick: (
|
|
389
|
-
if (
|
|
390
|
-
if (expandRowByClick && hasChildren) toggleExpand(
|
|
391
|
-
onRowClick?.(
|
|
703
|
+
onClick: (event_3) => {
|
|
704
|
+
if (event_3.target.closest(".k-checkbox, .k-table-tree-toggle")) return;
|
|
705
|
+
if (expandRowByClick && hasChildren) toggleExpand(record_6);
|
|
706
|
+
onRowClick?.(record_6, rowIndex_0);
|
|
392
707
|
},
|
|
393
708
|
children: [checkable && /* @__PURE__ */ jsx("td", {
|
|
394
|
-
className: clsx("k-table-cell-fix-left", {
|
|
709
|
+
className: clsx("k-table-cell-fix-left", {
|
|
710
|
+
"k-table-cell-fix-left-last": ping.left,
|
|
711
|
+
"k-table-cell-last-column": !leaves.length
|
|
712
|
+
}),
|
|
395
713
|
style: {
|
|
396
|
-
width:
|
|
714
|
+
width: SELECTION_COLUMN_WIDTH,
|
|
397
715
|
left: 0
|
|
398
716
|
},
|
|
399
717
|
children: /* @__PURE__ */ jsx(checkbox_default, {
|
|
400
|
-
checked: selected.has(keyOf(
|
|
401
|
-
disabled: isDisabled(keyOf(
|
|
402
|
-
onChange: (
|
|
718
|
+
checked: selected.has(keyOf(record_6)),
|
|
719
|
+
disabled: isDisabled(keyOf(record_6)),
|
|
720
|
+
onChange: (event_4) => toggleOne(event_4, record_6),
|
|
721
|
+
"aria-label": tableLocale?.selectRow || "Select row"
|
|
403
722
|
})
|
|
404
|
-
}), leaves.map((
|
|
405
|
-
const
|
|
723
|
+
}), leaves.map((column_11, colIndex) => {
|
|
724
|
+
const cell_2 = matrix[rowIndex_0]?.[colIndex] ?? {
|
|
406
725
|
rowSpan: 1,
|
|
407
726
|
colSpan: 1,
|
|
408
727
|
show: true
|
|
409
728
|
};
|
|
410
|
-
if (!
|
|
411
|
-
const value = getRecordValue(
|
|
412
|
-
const content =
|
|
729
|
+
if (!cell_2.show) return null;
|
|
730
|
+
const value = getRecordValue(record_6, column_11.key);
|
|
731
|
+
const content = column_11.render?.(value, record_6, rowIndex_0, column_11) ?? value;
|
|
732
|
+
const ellipsis = cellEllipsis.get(column_11.key);
|
|
413
733
|
return /* @__PURE__ */ jsx("td", {
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
734
|
+
"aria-labelledby": splitHeader ? headCellIds.get(column_11.key) : void 0,
|
|
735
|
+
rowSpan: cell_2.rowSpan > 1 ? cell_2.rowSpan : void 0,
|
|
736
|
+
colSpan: cell_2.colSpan > 1 ? cell_2.colSpan : void 0,
|
|
737
|
+
className: fixedClass(column_11, colIndex, cell_2.colSpan),
|
|
738
|
+
style: fixed.body[column_11.key],
|
|
418
739
|
children: treeEnabled && colIndex === 0 ? /* @__PURE__ */ jsxs("div", {
|
|
419
740
|
className: "k-table-tree-cell",
|
|
420
741
|
style: { paddingLeft: depth_0 * indentSize },
|
|
421
742
|
children: [hasChildren ? /* @__PURE__ */ jsx("button", {
|
|
422
743
|
type: "button",
|
|
423
744
|
className: "k-table-tree-toggle",
|
|
424
|
-
"aria-label": currentExpanded.has(keyOf(
|
|
425
|
-
"aria-expanded": currentExpanded.has(keyOf(
|
|
426
|
-
onClick: () => toggleExpand(
|
|
427
|
-
children: /* @__PURE__ */ jsx(Icon, { type: currentExpanded.has(keyOf(
|
|
428
|
-
}) : /* @__PURE__ */ jsx("span", { className: "k-table-tree-indent" }), /* @__PURE__ */ jsx(
|
|
745
|
+
"aria-label": currentExpanded.has(keyOf(record_6)) ? tableLocale?.collapseRow || "Collapse row" : tableLocale?.expandRow || "Expand row",
|
|
746
|
+
"aria-expanded": currentExpanded.has(keyOf(record_6)),
|
|
747
|
+
onClick: () => toggleExpand(record_6),
|
|
748
|
+
children: /* @__PURE__ */ jsx(Icon, { type: currentExpanded.has(keyOf(record_6)) ? ChevronDown : ChevronRight })
|
|
749
|
+
}) : /* @__PURE__ */ jsx("span", { className: "k-table-tree-indent" }), ellipsis ? /* @__PURE__ */ jsx(EllipsisCell, {
|
|
750
|
+
rows: ellipsis.rows,
|
|
751
|
+
tooltip: ellipsis.tooltip,
|
|
752
|
+
className: "k-table-tree-content",
|
|
753
|
+
children: content
|
|
754
|
+
}) : /* @__PURE__ */ jsx("span", {
|
|
429
755
|
className: "k-table-tree-content",
|
|
430
756
|
children: content
|
|
431
757
|
})]
|
|
758
|
+
}) : ellipsis ? /* @__PURE__ */ jsx(EllipsisCell, {
|
|
759
|
+
rows: ellipsis.rows,
|
|
760
|
+
tooltip: ellipsis.tooltip,
|
|
761
|
+
children: content
|
|
432
762
|
}) : content
|
|
433
|
-
},
|
|
763
|
+
}, column_11.key);
|
|
434
764
|
})]
|
|
435
|
-
}, keyOf(
|
|
765
|
+
}, keyOf(record_6))),
|
|
436
766
|
virtualEnabled && virtualRange.offset + (virtualRange.end - virtualRange.start) * itemHeight < virtualRange.total && /* @__PURE__ */ jsx("tr", {
|
|
437
767
|
className: "k-table-virtual-spacer k-table-virtual-spacer-bottom",
|
|
438
768
|
"aria-hidden": "true",
|
|
439
769
|
children: /* @__PURE__ */ jsx("td", {
|
|
770
|
+
className: "k-table-cell-last-column",
|
|
440
771
|
colSpan: leaves.length + (checkable ? 1 : 0),
|
|
441
772
|
style: { height: virtualRange.total - virtualRange.offset - (virtualRange.end - virtualRange.start) * itemHeight }
|
|
442
773
|
})
|
|
@@ -444,26 +775,20 @@ function Table({ data = [], columns = [], selectedKeys, disabledKeys = [], rowKe
|
|
|
444
775
|
] });
|
|
445
776
|
const tableStyle = {
|
|
446
777
|
width: "100%",
|
|
447
|
-
minWidth:
|
|
778
|
+
minWidth: scroll.x || (contentMinWidth ? `${contentMinWidth}px` : "100%"),
|
|
448
779
|
tableLayout: "fixed"
|
|
449
780
|
};
|
|
450
|
-
const renderTable = (showHeader, showBody, headerTable_0 = false) => /* @__PURE__ */ jsxs("table", {
|
|
451
|
-
style: tableStyle,
|
|
452
|
-
children: [
|
|
453
|
-
colgroup(headerTable_0),
|
|
454
|
-
showHeader && thead,
|
|
455
|
-
showBody && tbody
|
|
456
|
-
]
|
|
457
|
-
});
|
|
458
781
|
const empty = !rows.length || !visibleColumns.length;
|
|
459
782
|
return /* @__PURE__ */ jsxs("div", {
|
|
460
783
|
...rest,
|
|
784
|
+
ref: rootRef,
|
|
461
785
|
className: clsx("k-table", {
|
|
462
786
|
"k-table-striped": striped,
|
|
463
787
|
"k-table-sm": size === "small",
|
|
464
788
|
"k-table-lg": size === "large",
|
|
465
789
|
"k-table-bordered": bordered,
|
|
466
790
|
"k-table-has-footer": !!footer,
|
|
791
|
+
"k-table-split-header": splitHeader,
|
|
467
792
|
[`k-table-${shape}`]: shape,
|
|
468
793
|
"k-table-ping-left": ping.left,
|
|
469
794
|
"k-table-ping-right": ping.right,
|
|
@@ -474,11 +799,17 @@ function Table({ data = [], columns = [], selectedKeys, disabledKeys = [], rowKe
|
|
|
474
799
|
className: "k-table-header",
|
|
475
800
|
children: header
|
|
476
801
|
}),
|
|
477
|
-
|
|
802
|
+
splitHeader && /* @__PURE__ */ jsx("div", {
|
|
478
803
|
className: "k-table-thead",
|
|
479
|
-
ref:
|
|
480
|
-
|
|
481
|
-
|
|
804
|
+
ref: headerWrapperRef,
|
|
805
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
806
|
+
className: "k-table-thead-inner",
|
|
807
|
+
ref: headerScrollRef,
|
|
808
|
+
children: /* @__PURE__ */ jsxs("table", {
|
|
809
|
+
style: tableStyle,
|
|
810
|
+
children: [colgroup, thead]
|
|
811
|
+
})
|
|
812
|
+
})
|
|
482
813
|
}),
|
|
483
814
|
/* @__PURE__ */ jsxs("div", {
|
|
484
815
|
className: "k-table-body k-scroll",
|
|
@@ -490,12 +821,19 @@ function Table({ data = [], columns = [], selectedKeys, disabledKeys = [], rowKe
|
|
|
490
821
|
},
|
|
491
822
|
onScroll: handleScroll,
|
|
492
823
|
children: [
|
|
493
|
-
|
|
824
|
+
/* @__PURE__ */ jsxs("table", {
|
|
825
|
+
style: tableStyle,
|
|
826
|
+
children: [
|
|
827
|
+
colgroup,
|
|
828
|
+
!splitHeader && thead,
|
|
829
|
+
tbody
|
|
830
|
+
]
|
|
831
|
+
}),
|
|
494
832
|
empty && loading && /* @__PURE__ */ jsx("div", {
|
|
495
833
|
className: "k-table-loading-placeholder",
|
|
496
834
|
"aria-hidden": "true"
|
|
497
835
|
}),
|
|
498
|
-
empty && !loading && /* @__PURE__ */ jsx(Empty, { description: emptyText })
|
|
836
|
+
empty && !loading && /* @__PURE__ */ jsx(Empty, { description: emptyText || tableLocale?.emptyText })
|
|
499
837
|
]
|
|
500
838
|
}),
|
|
501
839
|
footer && /* @__PURE__ */ jsx("div", {
|