react-kui 3.1.2 → 3.2.1
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 +918 -324
- 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 +112 -92
- 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 +556 -207
- package/es/table/utils.js +140 -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/segmented/index.d.cts +2 -1
- package/types/segmented/index.d.ts +2 -1
- 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,274 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* react-kui v3.1
|
|
2
|
+
* react-kui v3.2.1
|
|
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 { isValidElement, 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
|
+
* 单元格原始值的渲染兜底,与 kui-vue 同口径(vue 的渲染器会把对象子节点转成文本:普通对象与
|
|
159
|
+
* `Date` 调 `String()`,数组逐项展开)。React 遇到同样的对象会直接抛
|
|
160
|
+
* "Objects are not valid as a React child" 把整张表打崩,所以先在这一层转掉。
|
|
161
|
+
* React 元素原样保留,数组继续按子节点序列交给 React(`[1, 2]` 两边都渲染成 "12")。
|
|
162
|
+
*/
|
|
163
|
+
var renderRawValue = (value) => {
|
|
164
|
+
if (Array.isArray(value)) return value.map(renderRawValue);
|
|
165
|
+
if (value !== null && typeof value === "object" && !isValidElement(value)) return String(value);
|
|
166
|
+
return value;
|
|
167
|
+
};
|
|
168
|
+
/**
|
|
169
|
+
* 行展开状态。`expandedKeys` 提供时完全受控;否则 `expandAllRows` 决定初始是否全部展开,
|
|
170
|
+
* 并且此后 `data` 变化只补“新出现的父行”(见 `mergeExpandAllRows`),
|
|
171
|
+
* 用户手动展开或折叠过的行不会被异步到达的数据覆盖。
|
|
172
|
+
* “新出现”以本次数据里的父行为准,所以从数据里消失又回来的父行算新行、会重新展开,
|
|
173
|
+
* 组件不记住它曾被折叠(kui-vue 同口径)。
|
|
174
|
+
*/
|
|
175
|
+
function useRowExpansion(t0) {
|
|
176
|
+
const $ = c(21);
|
|
177
|
+
const { parentKeys, expandedKeys, expandAllRows } = t0;
|
|
178
|
+
let t1;
|
|
179
|
+
if ($[0] !== expandAllRows || $[1] !== expandedKeys) {
|
|
180
|
+
t1 = {
|
|
181
|
+
expandedKeys,
|
|
182
|
+
expandAllRows
|
|
183
|
+
};
|
|
184
|
+
$[0] = expandAllRows;
|
|
185
|
+
$[1] = expandedKeys;
|
|
186
|
+
$[2] = t1;
|
|
187
|
+
} else t1 = $[2];
|
|
188
|
+
const controlSource = t1;
|
|
189
|
+
let t2;
|
|
190
|
+
if ($[3] !== controlSource || $[4] !== expandAllRows || $[5] !== expandedKeys || $[6] !== parentKeys) {
|
|
191
|
+
t2 = () => ({
|
|
192
|
+
controlSource,
|
|
193
|
+
parentKeys,
|
|
194
|
+
keys: new Set(expandedKeys ?? (expandAllRows ? parentKeys : []))
|
|
195
|
+
});
|
|
196
|
+
$[3] = controlSource;
|
|
197
|
+
$[4] = expandAllRows;
|
|
198
|
+
$[5] = expandedKeys;
|
|
199
|
+
$[6] = parentKeys;
|
|
200
|
+
$[7] = t2;
|
|
201
|
+
} else t2 = $[7];
|
|
202
|
+
const [state, setState] = useState(t2);
|
|
203
|
+
let keys = state.keys;
|
|
204
|
+
if (!Object.is(state.controlSource, controlSource)) {
|
|
205
|
+
let t3;
|
|
206
|
+
if ($[8] !== expandAllRows || $[9] !== expandedKeys || $[10] !== parentKeys) {
|
|
207
|
+
t3 = expandedKeys ?? (expandAllRows ? parentKeys : []);
|
|
208
|
+
$[8] = expandAllRows;
|
|
209
|
+
$[9] = expandedKeys;
|
|
210
|
+
$[10] = parentKeys;
|
|
211
|
+
$[11] = t3;
|
|
212
|
+
} else t3 = $[11];
|
|
213
|
+
let t4;
|
|
214
|
+
if ($[12] !== t3) {
|
|
215
|
+
t4 = new Set(t3);
|
|
216
|
+
$[12] = t3;
|
|
217
|
+
$[13] = t4;
|
|
218
|
+
} else t4 = $[13];
|
|
219
|
+
keys = t4;
|
|
220
|
+
setState({
|
|
221
|
+
controlSource,
|
|
222
|
+
parentKeys,
|
|
223
|
+
keys
|
|
224
|
+
});
|
|
225
|
+
} else if (expandedKeys === void 0 && expandAllRows) {
|
|
226
|
+
let t3;
|
|
227
|
+
if ($[14] !== parentKeys || $[15] !== state.keys || $[16] !== state.parentKeys) {
|
|
228
|
+
t3 = mergeExpandAllRows(state.parentKeys, parentKeys, state.keys);
|
|
229
|
+
$[14] = parentKeys;
|
|
230
|
+
$[15] = state.keys;
|
|
231
|
+
$[16] = state.parentKeys;
|
|
232
|
+
$[17] = t3;
|
|
233
|
+
} else t3 = $[17];
|
|
234
|
+
const merged = t3;
|
|
235
|
+
if (state.parentKeys !== parentKeys || merged.changed) {
|
|
236
|
+
keys = merged.changed ? merged.keys : state.keys;
|
|
237
|
+
setState({
|
|
238
|
+
controlSource,
|
|
239
|
+
parentKeys,
|
|
240
|
+
keys
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
let t3;
|
|
245
|
+
if ($[18] === Symbol.for("react.memo_cache_sentinel")) {
|
|
246
|
+
t3 = (next) => setState((previous) => ({
|
|
247
|
+
...previous,
|
|
248
|
+
keys: next
|
|
249
|
+
}));
|
|
250
|
+
$[18] = t3;
|
|
251
|
+
} else t3 = $[18];
|
|
252
|
+
let t4;
|
|
253
|
+
if ($[19] !== keys) {
|
|
254
|
+
t4 = [keys, t3];
|
|
255
|
+
$[19] = keys;
|
|
256
|
+
$[20] = t4;
|
|
257
|
+
} else t4 = $[20];
|
|
258
|
+
return t4;
|
|
259
|
+
}
|
|
260
|
+
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
261
|
const inheritedAppearance = useConfigAppearance();
|
|
262
|
+
const tableLocale = (useContext(ConfigContext)?.locale || DEFAULT_LOCALE)?.k?.table;
|
|
26
263
|
const size = sizeProp ?? inheritedAppearance.size;
|
|
27
264
|
const shape = normalizeSurfaceShape(shapeProp ?? inheritedAppearance.shape ?? "round");
|
|
28
|
-
const
|
|
265
|
+
const rootRef = useRef(null);
|
|
29
266
|
const bodyRef = useRef(null);
|
|
267
|
+
const headerWrapperRef = useRef(null);
|
|
268
|
+
/** 分栏表头里真正承担裁剪与横向同步的是内层(见 `styles/index.less` 的 `.k-table-thead-inner`)。 */
|
|
269
|
+
const headerScrollRef = useRef(null);
|
|
30
270
|
const scrollFrameRef = useRef(0);
|
|
31
271
|
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
272
|
const [sort, setSort] = useState({
|
|
46
273
|
key: "",
|
|
47
274
|
order: null
|
|
@@ -50,11 +277,9 @@ function Table({ data = [], columns = [], selectedKeys, disabledKeys = [], rowKe
|
|
|
50
277
|
left: false,
|
|
51
278
|
right: false
|
|
52
279
|
});
|
|
53
|
-
const [scrollbarWidth, setScrollbarWidth] = useState(0);
|
|
54
280
|
const [scrollTop, setScrollTop] = useState(0);
|
|
55
281
|
const [viewportHeight, setViewportHeight] = useState(0);
|
|
56
282
|
const selected = innerSelected;
|
|
57
|
-
const currentExpanded = innerExpanded;
|
|
58
283
|
const visibleColumns = useMemo(() => {
|
|
59
284
|
const filter = (items) => items.flatMap((column) => {
|
|
60
285
|
if (hiddenColumnKeys.includes(column.key)) return [];
|
|
@@ -67,65 +292,127 @@ function Table({ data = [], columns = [], selectedKeys, disabledKeys = [], rowKe
|
|
|
67
292
|
});
|
|
68
293
|
return filter(columns);
|
|
69
294
|
}, [columns, hiddenColumnKeys]);
|
|
70
|
-
const
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
const
|
|
295
|
+
const inheritedColumns = useMemo(() => inheritColumnFixed(visibleColumns), [visibleColumns]);
|
|
296
|
+
const leaves = useMemo(() => flattenColumns(inheritedColumns), [inheritedColumns]);
|
|
297
|
+
/**
|
|
298
|
+
* 表格内容的最小宽度:每列的宽度基准之和(没写 `width` 的普通列按 150 计),再加勾选列的 50。
|
|
299
|
+
* `<col>` 上它们仍是 `auto`,宽容器里照旧平摊多余空间;这一份只是下限,容器比它还窄就出横向
|
|
300
|
+
* 滚动条。`scroll.x` 显式给了则照旧以 `scroll.x` 为准。
|
|
301
|
+
*/
|
|
302
|
+
const contentMinWidth = useMemo(() => leaves.reduce((sum, column_0) => sum + widthBasisOf(column_0), 0) + (checkable ? SELECTION_COLUMN_WIDTH : 0), [leaves, checkable]);
|
|
303
|
+
const cellEllipsis = useMemo(() => {
|
|
304
|
+
const map = /* @__PURE__ */ new Map();
|
|
305
|
+
leaves.forEach((column_1) => map.set(column_1.key, resolveCellEllipsis(column_1.ellipsis, tableEllipsis)));
|
|
306
|
+
return map;
|
|
307
|
+
}, [leaves, tableEllipsis]);
|
|
308
|
+
const splitHeader = scroll.y != null;
|
|
309
|
+
const virtualEnabled = virtual && splitHeader;
|
|
310
|
+
const rawId = useId();
|
|
311
|
+
const headCellIds = useMemo(() => {
|
|
312
|
+
const ids = /* @__PURE__ */ new Map();
|
|
313
|
+
if (!splitHeader) return ids;
|
|
314
|
+
const prefix = `k-table-${rawId.replace(/[^a-zA-Z0-9_-]/g, "")}-`;
|
|
315
|
+
const visit = (items_0) => items_0.forEach((item) => {
|
|
316
|
+
ids.set(item.key, `${prefix}${ids.size}`);
|
|
317
|
+
if (item.children?.length) visit(item.children);
|
|
318
|
+
});
|
|
319
|
+
visit(inheritedColumns);
|
|
320
|
+
return ids;
|
|
321
|
+
}, [
|
|
322
|
+
splitHeader,
|
|
323
|
+
rawId,
|
|
324
|
+
inheritedColumns
|
|
325
|
+
]);
|
|
326
|
+
const keyOf = useCallback((record) => resolveRowKey(record, rowKey), [rowKey]);
|
|
327
|
+
const isDisabled = (key) => disabledKeys.includes(key);
|
|
328
|
+
const allRows = useMemo(() => flattenTreeData({
|
|
329
|
+
data,
|
|
330
|
+
childrenColumnName,
|
|
331
|
+
getKey: keyOf
|
|
332
|
+
}), [
|
|
333
|
+
data,
|
|
334
|
+
childrenColumnName,
|
|
335
|
+
keyOf
|
|
336
|
+
]);
|
|
337
|
+
const [currentExpanded, setInnerExpanded] = useRowExpansion({
|
|
338
|
+
parentKeys: useMemo(() => new Set(allRows.filter((row) => row.hasChildren).map((row_0) => resolveRowKey(row_0.record, rowKey))), [allRows, rowKey]),
|
|
339
|
+
expandedKeys,
|
|
340
|
+
expandAllRows
|
|
341
|
+
});
|
|
79
342
|
const headerInfo = useMemo(() => {
|
|
80
343
|
let maxDepth = 1;
|
|
81
|
-
const depth = (
|
|
82
|
-
depth(
|
|
344
|
+
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));
|
|
345
|
+
depth(inheritedColumns);
|
|
346
|
+
const fixedDirectionOf = (leafStart, leafCount) => {
|
|
347
|
+
const direction = leaves[leafStart]?.fixed;
|
|
348
|
+
if (!direction) return void 0;
|
|
349
|
+
for (let index = leafStart + 1; index < leafStart + leafCount; index += 1) if (leaves[index]?.fixed !== direction) return void 0;
|
|
350
|
+
return direction;
|
|
351
|
+
};
|
|
83
352
|
const headerRows = [];
|
|
84
|
-
const
|
|
353
|
+
const visit_0 = (items_2, level_0, startAt) => {
|
|
85
354
|
headerRows[level_0] ??= [];
|
|
86
|
-
|
|
355
|
+
let cursor = startAt;
|
|
356
|
+
items_2.forEach((item_1) => {
|
|
357
|
+
const leafStart_0 = cursor;
|
|
358
|
+
const headerColSpan = countColumnLeaves(item_1);
|
|
87
359
|
headerRows[level_0].push({
|
|
88
|
-
...
|
|
89
|
-
headerColSpan
|
|
90
|
-
headerRowSpan:
|
|
360
|
+
...item_1,
|
|
361
|
+
headerColSpan,
|
|
362
|
+
headerRowSpan: item_1.children?.length ? 1 : maxDepth - level_0,
|
|
363
|
+
leafStart: leafStart_0,
|
|
364
|
+
headerFixed: fixedDirectionOf(leafStart_0, headerColSpan)
|
|
91
365
|
});
|
|
92
|
-
|
|
366
|
+
cursor += headerColSpan;
|
|
367
|
+
if (item_1.children?.length) visit_0(item_1.children, level_0 + 1, leafStart_0);
|
|
93
368
|
});
|
|
94
369
|
};
|
|
95
|
-
|
|
370
|
+
visit_0(inheritedColumns, 0, 0);
|
|
96
371
|
return {
|
|
97
372
|
rows: headerRows,
|
|
98
373
|
maxDepth
|
|
99
374
|
};
|
|
100
|
-
}, [
|
|
375
|
+
}, [inheritedColumns, leaves]);
|
|
101
376
|
const fixed = useMemo(() => {
|
|
102
377
|
const header_0 = {};
|
|
103
378
|
const body = {};
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
379
|
+
const leftBefore = [];
|
|
380
|
+
const rightAfter = [];
|
|
381
|
+
let left = checkable ? SELECTION_COLUMN_WIDTH : 0;
|
|
382
|
+
leaves.forEach((column_2, index_0) => {
|
|
383
|
+
leftBefore[index_0] = left;
|
|
384
|
+
if (column_2.fixed === "left") {
|
|
385
|
+
body[column_2.key] = {
|
|
108
386
|
position: "sticky",
|
|
109
387
|
left
|
|
110
388
|
};
|
|
111
|
-
|
|
112
|
-
body[column_0.key] = style;
|
|
113
|
-
left += column_0.width ?? 150;
|
|
389
|
+
left += widthBasisOf(column_2);
|
|
114
390
|
}
|
|
115
391
|
});
|
|
116
392
|
let right = 0;
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
393
|
+
for (let index_1 = leaves.length - 1; index_1 >= 0; index_1 -= 1) {
|
|
394
|
+
rightAfter[index_1] = right;
|
|
395
|
+
const column_3 = leaves[index_1];
|
|
396
|
+
if (column_3.fixed === "right") {
|
|
397
|
+
body[column_3.key] = {
|
|
120
398
|
position: "sticky",
|
|
121
399
|
right
|
|
122
400
|
};
|
|
123
|
-
|
|
401
|
+
right += widthBasisOf(column_3);
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
headerInfo.rows.forEach((row_1) => {
|
|
405
|
+
row_1.forEach((cell) => {
|
|
406
|
+
const lastLeaf = cell.leafStart + cell.headerColSpan - 1;
|
|
407
|
+
if (cell.headerFixed === "left") header_0[cell.key] = {
|
|
408
|
+
position: "sticky",
|
|
409
|
+
left: leftBefore[cell.leafStart] ?? 0
|
|
410
|
+
};
|
|
411
|
+
else if (cell.headerFixed === "right") header_0[cell.key] = {
|
|
124
412
|
position: "sticky",
|
|
125
|
-
right:
|
|
413
|
+
right: rightAfter[lastLeaf] ?? 0
|
|
126
414
|
};
|
|
127
|
-
|
|
128
|
-
}
|
|
415
|
+
});
|
|
129
416
|
});
|
|
130
417
|
return {
|
|
131
418
|
header: header_0,
|
|
@@ -134,39 +421,52 @@ function Table({ data = [], columns = [], selectedKeys, disabledKeys = [], rowKe
|
|
|
134
421
|
}, [
|
|
135
422
|
checkable,
|
|
136
423
|
leaves,
|
|
137
|
-
|
|
138
|
-
split
|
|
424
|
+
headerInfo
|
|
139
425
|
]);
|
|
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":
|
|
426
|
+
const fixedClass = (column_4, index_2, colSpan = 1) => clsx({
|
|
427
|
+
"k-table-cell-fix-left": column_4.fixed === "left",
|
|
428
|
+
"k-table-cell-fix-left-last": column_4.fixed === "left" && leaves[index_2 + colSpan]?.fixed !== "left",
|
|
429
|
+
"k-table-cell-fix-right": column_4.fixed === "right",
|
|
430
|
+
"k-table-cell-fix-right-first": column_4.fixed === "right" && leaves[index_2 - 1]?.fixed !== "right",
|
|
431
|
+
"k-table-cell-sorter": column_4.sorter,
|
|
432
|
+
"k-table-cell-last-column": index_2 + colSpan === leaves.length
|
|
433
|
+
});
|
|
434
|
+
/**
|
|
435
|
+
* 表头格的固定类按它覆盖的叶子区间判断。`*-last`/`*-first` 决定横向滚动时 ping 阴影画在哪一格的
|
|
436
|
+
* 边沿上,分组表头若改用叶子下标去查会拿到 `-1`,把不该画阴影的父格标成最后一列固定格。
|
|
437
|
+
*
|
|
438
|
+
* `k-table-cell-last-column` 同理必须按区间末尾算:bordered 时只有真的盖到最后一列的格子才让出
|
|
439
|
+
* 右边框。表头每一行的格数不一样(分组格占 `colSpan`),行末那一格往往并不是最后一列。
|
|
440
|
+
*/
|
|
441
|
+
const headerFixedClass = (cell_0) => clsx({
|
|
442
|
+
"k-table-cell-fix-left": cell_0.headerFixed === "left",
|
|
443
|
+
"k-table-cell-fix-left-last": cell_0.headerFixed === "left" && leaves[cell_0.leafStart + cell_0.headerColSpan]?.fixed !== "left",
|
|
444
|
+
"k-table-cell-fix-right": cell_0.headerFixed === "right",
|
|
445
|
+
"k-table-cell-fix-right-first": cell_0.headerFixed === "right" && leaves[cell_0.leafStart - 1]?.fixed !== "right",
|
|
446
|
+
"k-table-cell-sorter": cell_0.sorter,
|
|
447
|
+
"k-table-cell-last-column": cell_0.leafStart + cell_0.headerColSpan === leaves.length
|
|
146
448
|
});
|
|
147
|
-
const
|
|
148
|
-
const sortRecords = (records) => {
|
|
449
|
+
const sortRecords = useCallback((records) => {
|
|
149
450
|
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;
|
|
451
|
+
if (sort.key && sort.order && leaves.find((column_5) => column_5.key === sort.key)?.sorter === true) result.sort((a, b) => {
|
|
452
|
+
const comparison = compareSortValues(getRecordValue(a, sort.key), getRecordValue(b, sort.key));
|
|
154
453
|
return sort.order === "asc" ? comparison : -comparison;
|
|
155
454
|
});
|
|
156
455
|
return result;
|
|
157
|
-
};
|
|
158
|
-
const
|
|
159
|
-
data,
|
|
160
|
-
childrenColumnName,
|
|
161
|
-
getKey: keyOf
|
|
162
|
-
});
|
|
163
|
-
const rows = flattenTreeData({
|
|
456
|
+
}, [leaves, sort]);
|
|
457
|
+
const rows = useMemo(() => flattenTreeData({
|
|
164
458
|
data,
|
|
165
459
|
childrenColumnName,
|
|
166
460
|
expandedKeys: currentExpanded,
|
|
167
461
|
getKey: keyOf,
|
|
168
462
|
sortRecords
|
|
169
|
-
})
|
|
463
|
+
}), [
|
|
464
|
+
data,
|
|
465
|
+
childrenColumnName,
|
|
466
|
+
currentExpanded,
|
|
467
|
+
keyOf,
|
|
468
|
+
sortRecords
|
|
469
|
+
]);
|
|
170
470
|
const virtualRange = useMemo(() => {
|
|
171
471
|
if (!virtualEnabled) return {
|
|
172
472
|
start: 0,
|
|
@@ -189,38 +489,46 @@ function Table({ data = [], columns = [], selectedKeys, disabledKeys = [], rowKe
|
|
|
189
489
|
itemHeight,
|
|
190
490
|
overscan
|
|
191
491
|
]);
|
|
192
|
-
const treeEnabled = allRows.some((
|
|
492
|
+
const treeEnabled = useMemo(() => allRows.some((row_2) => row_2.hasChildren), [allRows]);
|
|
193
493
|
const matrix = useMemo(() => {
|
|
194
|
-
if (!leaves.some((
|
|
494
|
+
if (!leaves.some((column_6) => column_6.rowSpan !== void 0 || column_6.colSpan !== void 0)) return [];
|
|
195
495
|
const result_0 = rows.map(() => leaves.map(() => ({
|
|
196
496
|
rowSpan: 1,
|
|
197
497
|
colSpan: 1,
|
|
198
498
|
show: true
|
|
199
499
|
})));
|
|
200
|
-
rows.forEach(({ record:
|
|
201
|
-
if (!result_0[
|
|
202
|
-
const rowSpan = typeof
|
|
203
|
-
const
|
|
500
|
+
rows.forEach(({ record: record_0 }, row_3) => leaves.forEach((column_7, col) => {
|
|
501
|
+
if (!result_0[row_3][col].show) return;
|
|
502
|
+
const rowSpan = typeof column_7.rowSpan === "function" ? column_7.rowSpan(record_0, row_3) : column_7.rowSpan ?? 1;
|
|
503
|
+
const colSpan_0 = typeof column_7.colSpan === "function" ? column_7.colSpan(record_0, row_3) : column_7.colSpan ?? 1;
|
|
204
504
|
const normalizedRowSpan = Number.isFinite(rowSpan) ? Math.max(0, Math.floor(rowSpan)) : 1;
|
|
205
|
-
const normalizedColSpan = Number.isFinite(
|
|
505
|
+
const normalizedColSpan = Number.isFinite(colSpan_0) ? Math.max(0, Math.floor(colSpan_0)) : 1;
|
|
206
506
|
if (normalizedRowSpan === 0 || normalizedColSpan === 0) {
|
|
207
|
-
result_0[
|
|
507
|
+
result_0[row_3][col].show = false;
|
|
208
508
|
return;
|
|
209
509
|
}
|
|
210
|
-
result_0[
|
|
510
|
+
result_0[row_3][col] = {
|
|
211
511
|
rowSpan: normalizedRowSpan,
|
|
212
512
|
colSpan: normalizedColSpan,
|
|
213
513
|
show: true
|
|
214
514
|
};
|
|
215
515
|
for (let r = 0; r < normalizedRowSpan; r++) for (let c = 0; c < normalizedColSpan; c++) if (r || c) {
|
|
216
|
-
const
|
|
217
|
-
if (
|
|
516
|
+
const cell_1 = result_0[row_3 + r]?.[col + c];
|
|
517
|
+
if (cell_1) cell_1.show = false;
|
|
218
518
|
}
|
|
219
519
|
}));
|
|
220
520
|
return result_0;
|
|
221
521
|
}, [leaves, rows]);
|
|
222
|
-
const enabled = allRows.map((
|
|
223
|
-
|
|
522
|
+
const enabled = useMemo(() => allRows.map((row_4) => row_4.record).filter((record_1) => !disabledKeys.includes(keyOf(record_1))), [
|
|
523
|
+
allRows,
|
|
524
|
+
disabledKeys,
|
|
525
|
+
keyOf
|
|
526
|
+
]);
|
|
527
|
+
const checkedCount = useMemo(() => enabled.filter((record_2) => selected.has(keyOf(record_2))).length, [
|
|
528
|
+
enabled,
|
|
529
|
+
selected,
|
|
530
|
+
keyOf
|
|
531
|
+
]);
|
|
224
532
|
const allChecked = enabled.length > 0 && checkedCount === enabled.length;
|
|
225
533
|
const indeterminate = checkedCount > 0 && checkedCount < enabled.length;
|
|
226
534
|
const commitSelection = (next_0) => {
|
|
@@ -231,52 +539,51 @@ function Table({ data = [], columns = [], selectedKeys, disabledKeys = [], rowKe
|
|
|
231
539
|
};
|
|
232
540
|
const toggleAll = ({ checked }) => {
|
|
233
541
|
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(
|
|
542
|
+
allRows.forEach(({ record: record_3 }) => {
|
|
543
|
+
const key_0 = keyOf(record_3);
|
|
544
|
+
if (!isDisabled(key_0)) {
|
|
545
|
+
if (checked) next_1.add(key_0);
|
|
546
|
+
else next_1.delete(key_0);
|
|
239
547
|
}
|
|
240
548
|
});
|
|
241
549
|
const keys_0 = commitSelection(next_1);
|
|
242
550
|
onSelectAll?.(checked, keys_0);
|
|
243
551
|
};
|
|
244
|
-
const toggleOne = (event,
|
|
245
|
-
const
|
|
246
|
-
if (isDisabled(
|
|
552
|
+
const toggleOne = (event, record_4) => {
|
|
553
|
+
const key_1 = keyOf(record_4);
|
|
554
|
+
if (isDisabled(key_1)) return;
|
|
247
555
|
const next_2 = new Set(selected);
|
|
248
|
-
if (event.checked) next_2.add(
|
|
249
|
-
else next_2.delete(
|
|
556
|
+
if (event.checked) next_2.add(key_1);
|
|
557
|
+
else next_2.delete(key_1);
|
|
250
558
|
const keys_1 = commitSelection(next_2);
|
|
251
|
-
onSelect?.(
|
|
559
|
+
onSelect?.(record_4, event.checked, keys_1);
|
|
252
560
|
};
|
|
253
|
-
const toggleExpand = (
|
|
254
|
-
const
|
|
561
|
+
const toggleExpand = (record_5) => {
|
|
562
|
+
const key_2 = keyOf(record_5);
|
|
255
563
|
const next_3 = new Set(currentExpanded);
|
|
256
|
-
const nextExpanded = !next_3.has(
|
|
257
|
-
if (nextExpanded) next_3.add(
|
|
258
|
-
else next_3.delete(
|
|
564
|
+
const nextExpanded = !next_3.has(key_2);
|
|
565
|
+
if (nextExpanded) next_3.add(key_2);
|
|
566
|
+
else next_3.delete(key_2);
|
|
259
567
|
setInnerExpanded(next_3);
|
|
260
568
|
onExpandedKeysChange?.([...next_3]);
|
|
261
|
-
onExpand?.(nextExpanded,
|
|
569
|
+
onExpand?.(nextExpanded, record_5);
|
|
262
570
|
};
|
|
263
|
-
const changeSort = (
|
|
264
|
-
if (!
|
|
571
|
+
const changeSort = (column_8) => {
|
|
572
|
+
if (!column_8.sorter) return;
|
|
265
573
|
const next_4 = {
|
|
266
|
-
key:
|
|
267
|
-
order: sort.key !==
|
|
574
|
+
key: column_8.key,
|
|
575
|
+
order: sort.key !== column_8.key ? "asc" : sort.order === "asc" ? "desc" : sort.order === "desc" ? null : "asc"
|
|
268
576
|
};
|
|
269
577
|
setSort(next_4);
|
|
270
|
-
if (typeof
|
|
578
|
+
if (typeof column_8.sorter === "function") column_8.sorter(next_4);
|
|
271
579
|
onSort?.(next_4);
|
|
272
580
|
};
|
|
273
581
|
const handleScroll = (event_0) => {
|
|
274
|
-
const
|
|
582
|
+
const body_0 = bodyRef.current ?? event_0.currentTarget;
|
|
583
|
+
if (splitHeader && headerScrollRef.current) headerScrollRef.current.scrollLeft = body_0.scrollLeft;
|
|
275
584
|
if (scrollFrameRef.current) return;
|
|
276
585
|
scrollFrameRef.current = requestAnimationFrame(() => {
|
|
277
586
|
scrollFrameRef.current = 0;
|
|
278
|
-
const body_0 = bodyRef.current ?? target;
|
|
279
|
-
if (split && headerRef.current) headerRef.current.scrollLeft = body_0.scrollLeft;
|
|
280
587
|
const max = Math.max(0, body_0.scrollWidth - body_0.clientWidth);
|
|
281
588
|
const update = () => {
|
|
282
589
|
if (virtualEnabled) setScrollTop(body_0.scrollTop);
|
|
@@ -294,7 +601,6 @@ function Table({ data = [], columns = [], selectedKeys, disabledKeys = [], rowKe
|
|
|
294
601
|
const body_1 = bodyRef.current;
|
|
295
602
|
if (!body_1) return;
|
|
296
603
|
const measure = () => {
|
|
297
|
-
setScrollbarWidth(split ? Math.max(0, body_1.offsetWidth - body_1.clientWidth - (bordered ? 1 : 0)) : 0);
|
|
298
604
|
setViewportHeight(body_1.clientHeight);
|
|
299
605
|
const max_0 = Math.max(0, body_1.scrollWidth - body_1.clientWidth);
|
|
300
606
|
const nextPing_0 = {
|
|
@@ -313,63 +619,82 @@ function Table({ data = [], columns = [], selectedKeys, disabledKeys = [], rowKe
|
|
|
313
619
|
};
|
|
314
620
|
}
|
|
315
621
|
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
|
-
|
|
622
|
+
}, []);
|
|
623
|
+
useLayoutEffect(() => {
|
|
624
|
+
const root = rootRef.current;
|
|
625
|
+
if (!root) return;
|
|
626
|
+
root.style.setProperty("--k-table-scrollbar-width", splitHeader ? `${measureScrollbarWidth()}px` : "");
|
|
627
|
+
}, [splitHeader]);
|
|
628
|
+
useEffect(() => {
|
|
629
|
+
const wrapper = headerWrapperRef.current;
|
|
630
|
+
const body_2 = bodyRef.current;
|
|
631
|
+
if (!splitHeader || !wrapper || !body_2) return;
|
|
632
|
+
const onWheel = (event_1) => {
|
|
633
|
+
const unit = event_1.deltaMode === 1 ? 16 : event_1.deltaMode === 2 ? body_2.clientHeight : 1;
|
|
634
|
+
const maxTop = Math.max(0, body_2.scrollHeight - body_2.clientHeight);
|
|
635
|
+
const maxLeft = Math.max(0, body_2.scrollWidth - body_2.clientWidth);
|
|
636
|
+
const nextTop = Math.min(maxTop, Math.max(0, body_2.scrollTop + event_1.deltaY * unit));
|
|
637
|
+
const nextLeft = Math.min(maxLeft, Math.max(0, body_2.scrollLeft + event_1.deltaX * unit));
|
|
638
|
+
if (nextTop === body_2.scrollTop && nextLeft === body_2.scrollLeft) return;
|
|
639
|
+
event_1.preventDefault();
|
|
640
|
+
body_2.scrollTo({
|
|
641
|
+
top: nextTop,
|
|
642
|
+
left: nextLeft
|
|
643
|
+
});
|
|
644
|
+
};
|
|
645
|
+
wrapper.addEventListener("wheel", onWheel, { passive: false });
|
|
646
|
+
return () => wrapper.removeEventListener("wheel", onWheel);
|
|
647
|
+
}, [splitHeader]);
|
|
648
|
+
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))] });
|
|
649
|
+
const thead = /* @__PURE__ */ jsx("thead", { children: headerInfo.rows.map((row_5, rowIndex) => /* @__PURE__ */ jsxs("tr", { children: [checkable && rowIndex === 0 && /* @__PURE__ */ jsx("th", {
|
|
650
|
+
rowSpan: headerInfo.maxDepth,
|
|
651
|
+
className: clsx("k-table-cell-fix-left", {
|
|
652
|
+
"k-table-cell-fix-left-last": ping.left && leaves[0]?.fixed !== "left",
|
|
653
|
+
"k-table-cell-last-column": !leaves.length
|
|
339
654
|
}),
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
655
|
+
style: { left: 0 },
|
|
656
|
+
children: /* @__PURE__ */ jsx(checkbox_default, {
|
|
657
|
+
checked: allChecked,
|
|
658
|
+
indeterminate,
|
|
659
|
+
onChange: toggleAll,
|
|
660
|
+
disabled: !enabled.length,
|
|
661
|
+
"aria-label": tableLocale?.selectAllRows || "Select all"
|
|
662
|
+
})
|
|
663
|
+
}), row_5.map((column_10, index_3) => /* @__PURE__ */ jsx("th", {
|
|
664
|
+
id: splitHeader ? headCellIds.get(column_10.key) : void 0,
|
|
665
|
+
colSpan: column_10.headerColSpan,
|
|
666
|
+
rowSpan: column_10.headerRowSpan,
|
|
667
|
+
className: headerFixedClass(column_10),
|
|
668
|
+
style: fixed.header[column_10.key],
|
|
669
|
+
tabIndex: column_10.sorter ? 0 : void 0,
|
|
670
|
+
"aria-sort": !column_10.sorter ? void 0 : sort.key !== column_10.key || !sort.order ? "none" : sort.order === "asc" ? "ascending" : "descending",
|
|
671
|
+
onClick: () => changeSort(column_10),
|
|
672
|
+
onKeyDown: (event_2) => {
|
|
673
|
+
if (!column_10.sorter || event_2.key !== "Enter" && event_2.key !== " ") return;
|
|
674
|
+
event_2.preventDefault();
|
|
675
|
+
changeSort(column_10);
|
|
676
|
+
},
|
|
677
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
678
|
+
className: "k-table-header-col",
|
|
679
|
+
children: [column_10.renderHeader?.(column_10, index_3) ?? column_10.title, column_10.sorter && /* @__PURE__ */ jsxs("span", {
|
|
680
|
+
className: "k-table-sorter",
|
|
681
|
+
children: [/* @__PURE__ */ jsx(Icon, {
|
|
682
|
+
type: Triangle,
|
|
683
|
+
reverseFill: true,
|
|
684
|
+
className: clsx("k-table-sorter-up", { "k-table-sorter-active": sort.key === column_10.key && sort.order === "asc" })
|
|
685
|
+
}), /* @__PURE__ */ jsx(Icon, {
|
|
686
|
+
type: Triangle,
|
|
687
|
+
reverseFill: true,
|
|
688
|
+
className: clsx("k-table-sorter-down", { "k-table-sorter-active": sort.key === column_10.key && sort.order === "desc" })
|
|
359
689
|
})]
|
|
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 }
|
|
690
|
+
})]
|
|
366
691
|
})
|
|
367
|
-
] }, rowIndex)) });
|
|
692
|
+
}, column_10.key))] }, rowIndex)) });
|
|
368
693
|
const renderedRows = useMemo(() => {
|
|
369
694
|
const start = virtualRange.start;
|
|
370
695
|
const end = virtualRange.end;
|
|
371
|
-
return rows.slice(start, end).map((
|
|
372
|
-
...
|
|
696
|
+
return rows.slice(start, end).map((row_6, idx) => ({
|
|
697
|
+
...row_6,
|
|
373
698
|
rowIndex: start + idx
|
|
374
699
|
}));
|
|
375
700
|
}, [rows, virtualRange]);
|
|
@@ -378,65 +703,82 @@ function Table({ data = [], columns = [], selectedKeys, disabledKeys = [], rowKe
|
|
|
378
703
|
className: "k-table-virtual-spacer k-table-virtual-spacer-top",
|
|
379
704
|
"aria-hidden": "true",
|
|
380
705
|
children: /* @__PURE__ */ jsx("td", {
|
|
706
|
+
className: "k-table-cell-last-column",
|
|
381
707
|
colSpan: leaves.length + (checkable ? 1 : 0),
|
|
382
708
|
style: { height: virtualRange.offset }
|
|
383
709
|
})
|
|
384
710
|
}),
|
|
385
|
-
renderedRows.map(({ record:
|
|
711
|
+
renderedRows.map(({ record: record_6, depth: depth_0, hasChildren, rowIndex: rowIndex_0 }) => /* @__PURE__ */ jsxs("tr", {
|
|
386
712
|
className: virtualEnabled && rowIndex_0 % 2 === 1 ? "k-table-row-even" : void 0,
|
|
387
713
|
style: virtualEnabled ? { height: itemHeight } : void 0,
|
|
388
|
-
onClick: (
|
|
389
|
-
if (
|
|
390
|
-
if (expandRowByClick && hasChildren) toggleExpand(
|
|
391
|
-
onRowClick?.(
|
|
714
|
+
onClick: (event_3) => {
|
|
715
|
+
if (event_3.target.closest(".k-checkbox, .k-table-tree-toggle")) return;
|
|
716
|
+
if (expandRowByClick && hasChildren) toggleExpand(record_6);
|
|
717
|
+
onRowClick?.(record_6, rowIndex_0);
|
|
392
718
|
},
|
|
393
719
|
children: [checkable && /* @__PURE__ */ jsx("td", {
|
|
394
|
-
className: clsx("k-table-cell-fix-left", {
|
|
720
|
+
className: clsx("k-table-cell-fix-left", {
|
|
721
|
+
"k-table-cell-fix-left-last": ping.left && leaves[0]?.fixed !== "left",
|
|
722
|
+
"k-table-cell-last-column": !leaves.length
|
|
723
|
+
}),
|
|
395
724
|
style: {
|
|
396
|
-
width:
|
|
725
|
+
width: SELECTION_COLUMN_WIDTH,
|
|
397
726
|
left: 0
|
|
398
727
|
},
|
|
399
728
|
children: /* @__PURE__ */ jsx(checkbox_default, {
|
|
400
|
-
checked: selected.has(keyOf(
|
|
401
|
-
disabled: isDisabled(keyOf(
|
|
402
|
-
onChange: (
|
|
729
|
+
checked: selected.has(keyOf(record_6)),
|
|
730
|
+
disabled: isDisabled(keyOf(record_6)),
|
|
731
|
+
onChange: (event_4) => toggleOne(event_4, record_6),
|
|
732
|
+
"aria-label": tableLocale?.selectRow || "Select row"
|
|
403
733
|
})
|
|
404
|
-
}), leaves.map((
|
|
405
|
-
const
|
|
734
|
+
}), leaves.map((column_11, colIndex) => {
|
|
735
|
+
const cell_2 = matrix[rowIndex_0]?.[colIndex] ?? {
|
|
406
736
|
rowSpan: 1,
|
|
407
737
|
colSpan: 1,
|
|
408
738
|
show: true
|
|
409
739
|
};
|
|
410
|
-
if (!
|
|
411
|
-
const value = getRecordValue(
|
|
412
|
-
const content =
|
|
740
|
+
if (!cell_2.show) return null;
|
|
741
|
+
const value = getRecordValue(record_6, column_11.key);
|
|
742
|
+
const content = column_11.render?.(value, record_6, rowIndex_0, column_11) ?? renderRawValue(value);
|
|
743
|
+
const ellipsis = cellEllipsis.get(column_11.key);
|
|
413
744
|
return /* @__PURE__ */ jsx("td", {
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
745
|
+
"aria-labelledby": splitHeader ? headCellIds.get(column_11.key) : void 0,
|
|
746
|
+
rowSpan: cell_2.rowSpan > 1 ? cell_2.rowSpan : void 0,
|
|
747
|
+
colSpan: cell_2.colSpan > 1 ? cell_2.colSpan : void 0,
|
|
748
|
+
className: fixedClass(column_11, colIndex, cell_2.colSpan),
|
|
749
|
+
style: fixed.body[column_11.key],
|
|
418
750
|
children: treeEnabled && colIndex === 0 ? /* @__PURE__ */ jsxs("div", {
|
|
419
751
|
className: "k-table-tree-cell",
|
|
420
752
|
style: { paddingLeft: depth_0 * indentSize },
|
|
421
753
|
children: [hasChildren ? /* @__PURE__ */ jsx("button", {
|
|
422
754
|
type: "button",
|
|
423
755
|
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(
|
|
756
|
+
"aria-label": currentExpanded.has(keyOf(record_6)) ? tableLocale?.collapseRow || "Collapse row" : tableLocale?.expandRow || "Expand row",
|
|
757
|
+
"aria-expanded": currentExpanded.has(keyOf(record_6)),
|
|
758
|
+
onClick: () => toggleExpand(record_6),
|
|
759
|
+
children: /* @__PURE__ */ jsx(Icon, { type: currentExpanded.has(keyOf(record_6)) ? ChevronDown : ChevronRight })
|
|
760
|
+
}) : /* @__PURE__ */ jsx("span", { className: "k-table-tree-indent" }), ellipsis ? /* @__PURE__ */ jsx(EllipsisCell, {
|
|
761
|
+
rows: ellipsis.rows,
|
|
762
|
+
tooltip: ellipsis.tooltip,
|
|
763
|
+
className: "k-table-tree-content",
|
|
764
|
+
children: content
|
|
765
|
+
}) : /* @__PURE__ */ jsx("span", {
|
|
429
766
|
className: "k-table-tree-content",
|
|
430
767
|
children: content
|
|
431
768
|
})]
|
|
769
|
+
}) : ellipsis ? /* @__PURE__ */ jsx(EllipsisCell, {
|
|
770
|
+
rows: ellipsis.rows,
|
|
771
|
+
tooltip: ellipsis.tooltip,
|
|
772
|
+
children: content
|
|
432
773
|
}) : content
|
|
433
|
-
},
|
|
774
|
+
}, column_11.key);
|
|
434
775
|
})]
|
|
435
|
-
}, keyOf(
|
|
776
|
+
}, keyOf(record_6))),
|
|
436
777
|
virtualEnabled && virtualRange.offset + (virtualRange.end - virtualRange.start) * itemHeight < virtualRange.total && /* @__PURE__ */ jsx("tr", {
|
|
437
778
|
className: "k-table-virtual-spacer k-table-virtual-spacer-bottom",
|
|
438
779
|
"aria-hidden": "true",
|
|
439
780
|
children: /* @__PURE__ */ jsx("td", {
|
|
781
|
+
className: "k-table-cell-last-column",
|
|
440
782
|
colSpan: leaves.length + (checkable ? 1 : 0),
|
|
441
783
|
style: { height: virtualRange.total - virtualRange.offset - (virtualRange.end - virtualRange.start) * itemHeight }
|
|
442
784
|
})
|
|
@@ -444,26 +786,20 @@ function Table({ data = [], columns = [], selectedKeys, disabledKeys = [], rowKe
|
|
|
444
786
|
] });
|
|
445
787
|
const tableStyle = {
|
|
446
788
|
width: "100%",
|
|
447
|
-
minWidth:
|
|
789
|
+
minWidth: scroll.x || (contentMinWidth ? `${contentMinWidth}px` : "100%"),
|
|
448
790
|
tableLayout: "fixed"
|
|
449
791
|
};
|
|
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
792
|
const empty = !rows.length || !visibleColumns.length;
|
|
459
793
|
return /* @__PURE__ */ jsxs("div", {
|
|
460
794
|
...rest,
|
|
795
|
+
ref: rootRef,
|
|
461
796
|
className: clsx("k-table", {
|
|
462
797
|
"k-table-striped": striped,
|
|
463
798
|
"k-table-sm": size === "small",
|
|
464
799
|
"k-table-lg": size === "large",
|
|
465
800
|
"k-table-bordered": bordered,
|
|
466
801
|
"k-table-has-footer": !!footer,
|
|
802
|
+
"k-table-split-header": splitHeader,
|
|
467
803
|
[`k-table-${shape}`]: shape,
|
|
468
804
|
"k-table-ping-left": ping.left,
|
|
469
805
|
"k-table-ping-right": ping.right,
|
|
@@ -474,28 +810,41 @@ function Table({ data = [], columns = [], selectedKeys, disabledKeys = [], rowKe
|
|
|
474
810
|
className: "k-table-header",
|
|
475
811
|
children: header
|
|
476
812
|
}),
|
|
477
|
-
|
|
813
|
+
splitHeader && /* @__PURE__ */ jsx("div", {
|
|
478
814
|
className: "k-table-thead",
|
|
479
|
-
ref:
|
|
480
|
-
|
|
481
|
-
|
|
815
|
+
ref: headerWrapperRef,
|
|
816
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
817
|
+
className: "k-table-thead-inner",
|
|
818
|
+
ref: headerScrollRef,
|
|
819
|
+
children: /* @__PURE__ */ jsxs("table", {
|
|
820
|
+
style: tableStyle,
|
|
821
|
+
children: [colgroup, thead]
|
|
822
|
+
})
|
|
823
|
+
})
|
|
482
824
|
}),
|
|
483
825
|
/* @__PURE__ */ jsxs("div", {
|
|
484
826
|
className: "k-table-body k-scroll",
|
|
485
827
|
ref: bodyRef,
|
|
486
828
|
style: {
|
|
487
829
|
overflowY: scroll.y ? "scroll" : "auto",
|
|
488
|
-
overflowX:
|
|
830
|
+
overflowX: "auto",
|
|
489
831
|
maxHeight: scroll.y
|
|
490
832
|
},
|
|
491
833
|
onScroll: handleScroll,
|
|
492
834
|
children: [
|
|
493
|
-
|
|
835
|
+
/* @__PURE__ */ jsxs("table", {
|
|
836
|
+
style: tableStyle,
|
|
837
|
+
children: [
|
|
838
|
+
colgroup,
|
|
839
|
+
!splitHeader && thead,
|
|
840
|
+
tbody
|
|
841
|
+
]
|
|
842
|
+
}),
|
|
494
843
|
empty && loading && /* @__PURE__ */ jsx("div", {
|
|
495
844
|
className: "k-table-loading-placeholder",
|
|
496
845
|
"aria-hidden": "true"
|
|
497
846
|
}),
|
|
498
|
-
empty && !loading && /* @__PURE__ */ jsx(Empty, { description: emptyText })
|
|
847
|
+
empty && !loading && /* @__PURE__ */ jsx(Empty, { description: emptyText || tableLocale?.emptyText })
|
|
499
848
|
]
|
|
500
849
|
}),
|
|
501
850
|
footer && /* @__PURE__ */ jsx("div", {
|