@rockshin/tao-ui 0.0.47 → 0.0.49
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/affix/affix.js +20 -16
- package/dist/components/alert/alert.js +114 -99
- package/dist/components/app/app-modals.js +134 -96
- package/dist/components/app/app-notices.js +39 -23
- package/dist/components/auto-complete/auto-complete.js +21 -7
- package/dist/components/avatar/avatar.js +31 -11
- package/dist/components/badge/badge.css +1 -1
- package/dist/components/badge/badge.js +72 -257
- package/dist/components/border-beam/border-beam.js +21 -17
- package/dist/components/breadcrumb/breadcrumb.js +178 -159
- package/dist/components/button/button.js +61 -53
- package/dist/components/calendar/calendar.js +6 -4
- package/dist/components/card/card.js +24 -8
- package/dist/components/carousel/carousel.d.ts +1 -1
- package/dist/components/carousel/carousel.js +105 -68
- package/dist/components/cascader/cascader.js +54 -19
- package/dist/components/checkbox/checkbox.css +13 -2
- package/dist/components/checkbox/checkbox.d.ts +2 -0
- package/dist/components/checkbox/checkbox.js +320 -229
- package/dist/components/collapse/collapse-panels.d.ts +1 -1
- package/dist/components/collapse/collapse-panels.js +122 -113
- package/dist/components/collapse/collapse.js +98 -63
- package/dist/components/color-picker/color-picker.js +539 -441
- package/dist/components/color-picker/color.js +1 -1
- package/dist/components/context-menu/context-menu.d.ts +1 -1
- package/dist/components/context-menu/context-menu.js +108 -68
- package/dist/components/date-picker/calendar/calendar-grid.js +42 -39
- package/dist/components/date-picker/calendar/month-grid.d.ts +8 -1
- package/dist/components/date-picker/calendar/month-grid.js +79 -37
- package/dist/components/date-picker/calendar/time-panel.d.ts +2 -1
- package/dist/components/date-picker/calendar/time-panel.js +94 -89
- package/dist/components/date-picker/calendar/year-grid.d.ts +8 -1
- package/dist/components/date-picker/calendar/year-grid.js +66 -35
- package/dist/components/date-picker/date-picker.css +24 -1
- package/dist/components/date-picker/date-picker.js +99 -53
- package/dist/components/date-picker/presets.d.ts +2 -1
- package/dist/components/date-picker/presets.js +27 -24
- package/dist/components/date-picker/range-picker.js +308 -153
- package/dist/components/descriptions/descriptions.js +7 -3
- package/dist/components/divider/divider.css +1 -1
- package/dist/components/divider/divider.js +1 -1
- package/dist/components/drawer/drawer.js +201 -369
- package/dist/components/dropdown/dropdown.d.ts +1 -1
- package/dist/components/dropdown/dropdown.js +183 -279
- package/dist/components/empty/empty.js +57 -78
- package/dist/components/float-button/float-button.d.ts +1 -0
- package/dist/components/float-button/float-button.js +47 -30
- package/dist/components/form/field-control.d.ts +4 -2
- package/dist/components/form/field-control.js +17 -9
- package/dist/components/form/form-context.d.ts +8 -2
- package/dist/components/form/form-context.js +2 -1
- package/dist/components/form/form-item.js +85 -63
- package/dist/components/form/form.css +3 -2
- package/dist/components/form/use-form.d.ts +2 -1
- package/dist/components/form/use-form.js +2 -1
- package/dist/components/form-field/form-field-view.d.ts +3 -1
- package/dist/components/form-field/form-field-view.js +194 -141
- package/dist/components/form-section/form-section.d.ts +1 -1
- package/dist/components/form-section/form-section.js +52 -45
- package/dist/components/image/image.js +585 -477
- package/dist/components/input/base-input.js +8 -9
- package/dist/components/input/input-shared.d.ts +5 -2
- package/dist/components/input/input-shared.js +42 -18
- package/dist/components/input/otp.js +236 -217
- package/dist/components/input/password.js +2 -1
- package/dist/components/input/search.js +8 -7
- package/dist/components/list/list-pagination.js +41 -36
- package/dist/components/list/list.js +141 -125
- package/dist/components/listy/listy.js +175 -106
- package/dist/components/masonry/masonry.js +108 -85
- package/dist/components/mentions/mentions.js +12 -3
- package/dist/components/menu/menu-render.d.ts +9 -3
- package/dist/components/menu/menu-render.js +99 -36
- package/dist/components/modal/confirm-dialog.js +10 -4
- package/dist/components/modal/confirm.js +3 -7
- package/dist/components/modal/index.js +9 -3
- package/dist/components/modal/modal.js +390 -365
- package/dist/components/pagination/pagination.js +105 -96
- package/dist/components/popconfirm/popconfirm.d.ts +1 -1
- package/dist/components/popconfirm/popconfirm.js +219 -168
- package/dist/components/popover/popover.js +330 -243
- package/dist/components/progress/progress.css +2 -2
- package/dist/components/progress/progress.js +232 -458
- package/dist/components/qr-code/qr-code.js +72 -66
- package/dist/components/radio/radio.css +15 -4
- package/dist/components/radio/radio.d.ts +2 -1
- package/dist/components/radio/radio.js +260 -198
- package/dist/components/rate/rate.js +173 -113
- package/dist/components/scroll-area/scroll-area.js +241 -211
- package/dist/components/segmented/segmented.js +73 -41
- package/dist/components/select/mobile-select.d.ts +2 -1
- package/dist/components/select/mobile-select.js +24 -13
- package/dist/components/select/select-searchable-list.d.ts +2 -1
- package/dist/components/select/select-searchable-list.js +2 -3
- package/dist/components/select/select.js +49 -25
- package/dist/components/select/use-select-selection.d.ts +1 -1
- package/dist/components/select/use-select-selection.js +7 -4
- package/dist/components/skeleton/skeleton.js +56 -48
- package/dist/components/slider/slider.js +87 -212
- package/dist/components/sonner/sonner.js +109 -93
- package/dist/components/spinner/spinner.js +147 -138
- package/dist/components/splitter/splitter.js +222 -159
- package/dist/components/statistic/statistic.js +7 -6
- package/dist/components/steps/steps.js +88 -81
- package/dist/components/steps/use-display-steps.js +1 -1
- package/dist/components/switch/switch.js +89 -89
- package/dist/components/table/table-filter.js +66 -56
- package/dist/components/table/table-icons.d.ts +2 -1
- package/dist/components/table/table-icons.js +11 -9
- package/dist/components/table/table-model.js +1 -1
- package/dist/components/table/table.js +107 -83
- package/dist/components/table/use-table-data.d.ts +6 -3
- package/dist/components/table/use-table-data.js +166 -130
- package/dist/components/tabs/tabs.css +1 -1
- package/dist/components/tabs/tabs.js +236 -179
- package/dist/components/tag/tag.d.ts +2 -2
- package/dist/components/tag/tag.js +111 -108
- package/dist/components/textarea/textarea.js +22 -17
- package/dist/components/time-picker/time-picker.js +5 -3
- package/dist/components/timeline/timeline.css +6 -1
- package/dist/components/timeline/timeline.js +21 -11
- package/dist/components/tooltip/tooltip.d.ts +2 -2
- package/dist/components/tooltip/tooltip.js +123 -233
- package/dist/components/tour/tour.css +4 -0
- package/dist/components/tour/tour.js +400 -331
- package/dist/components/transfer/transfer-list.js +29 -11
- package/dist/components/transfer/transfer-parts.js +1 -1
- package/dist/components/transfer/transfer-types.d.ts +1 -0
- package/dist/components/transfer/transfer.js +29 -14
- package/dist/components/tree/tree-keyboard.d.ts +1 -1
- package/dist/components/tree/tree-keyboard.js +5 -3
- package/dist/components/tree/tree.js +74 -59
- package/dist/components/tree-select/select-engine.d.ts +3 -2
- package/dist/components/tree-select/select-engine.js +18 -16
- package/dist/components/tree-select/tree-select.js +21 -5
- package/dist/components/upload/upload.css +8 -0
- package/dist/components/upload/upload.js +160 -72
- package/dist/components/watermark/watermark.js +36 -29
- package/dist/number-input/use-number-input.js +129 -90
- package/dist/number-input/validate.js +32 -5
- package/dist/provider/merge-locale.js +12 -9
- package/dist/provider/tao-provider.d.ts +3 -1
- package/dist/provider/tao-provider.js +123 -86
- package/package.json +1 -1
|
@@ -4,9 +4,9 @@ import { TaoPortalScope, useTaoConfig } from "../../provider/tao-provider.js";
|
|
|
4
4
|
import { CheckIcon, FilterIcon } from "./table-icons.js";
|
|
5
5
|
import * as __rspack_external__radix_ui_react_dropdown_menu_154a7470 from "@radix-ui/react-dropdown-menu";
|
|
6
6
|
function TableFilterDropdown(t0) {
|
|
7
|
-
const $ = c(
|
|
7
|
+
const $ = c(28);
|
|
8
8
|
const { filters, activeValues, onSelect } = t0;
|
|
9
|
-
const { locale } = useTaoConfig();
|
|
9
|
+
const { locale, disabled } = useTaoConfig();
|
|
10
10
|
let t1;
|
|
11
11
|
if ($[0] !== activeValues || $[1] !== onSelect) {
|
|
12
12
|
t1 = (value)=>{
|
|
@@ -30,25 +30,35 @@ function TableFilterDropdown(t0) {
|
|
|
30
30
|
$[4] = t3;
|
|
31
31
|
} else t3 = $[4];
|
|
32
32
|
let t4;
|
|
33
|
-
if ($[5] !== locale.messages.filter || $[
|
|
34
|
-
t4 = /*#__PURE__*/ jsx(
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
children: t3
|
|
41
|
-
})
|
|
33
|
+
if ($[5] !== disabled || $[6] !== locale.messages.filter || $[7] !== t3) {
|
|
34
|
+
t4 = /*#__PURE__*/ jsx("button", {
|
|
35
|
+
type: "button",
|
|
36
|
+
"data-tao-table-filter-trigger": "",
|
|
37
|
+
"aria-label": locale.messages.filter,
|
|
38
|
+
disabled: disabled,
|
|
39
|
+
children: t3
|
|
42
40
|
});
|
|
43
|
-
$[5] =
|
|
44
|
-
$[6] =
|
|
45
|
-
$[7] =
|
|
46
|
-
|
|
41
|
+
$[5] = disabled;
|
|
42
|
+
$[6] = locale.messages.filter;
|
|
43
|
+
$[7] = t3;
|
|
44
|
+
$[8] = t4;
|
|
45
|
+
} else t4 = $[8];
|
|
46
|
+
const trigger = t4;
|
|
47
|
+
if (disabled) return trigger;
|
|
47
48
|
let t5;
|
|
48
|
-
if ($[
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
if ($[9] !== trigger) {
|
|
50
|
+
t5 = /*#__PURE__*/ jsx(__rspack_external__radix_ui_react_dropdown_menu_154a7470.Trigger, {
|
|
51
|
+
asChild: true,
|
|
52
|
+
children: trigger
|
|
53
|
+
});
|
|
54
|
+
$[9] = trigger;
|
|
55
|
+
$[10] = t5;
|
|
56
|
+
} else t5 = $[10];
|
|
57
|
+
let t6;
|
|
58
|
+
if ($[11] !== activeValues || $[12] !== filters || $[13] !== toggle) {
|
|
59
|
+
let t7;
|
|
60
|
+
if ($[15] !== activeValues || $[16] !== toggle) {
|
|
61
|
+
t7 = (filter)=>{
|
|
52
62
|
const checked = activeValues.includes(filter.value);
|
|
53
63
|
return /*#__PURE__*/ jsxs(__rspack_external__radix_ui_react_dropdown_menu_154a7470.CheckboxItem, {
|
|
54
64
|
checked: checked,
|
|
@@ -69,31 +79,31 @@ function TableFilterDropdown(t0) {
|
|
|
69
79
|
]
|
|
70
80
|
}, filter.value);
|
|
71
81
|
};
|
|
72
|
-
$[
|
|
73
|
-
$[
|
|
74
|
-
$[
|
|
75
|
-
} else
|
|
76
|
-
|
|
77
|
-
$[
|
|
78
|
-
$[
|
|
79
|
-
$[
|
|
80
|
-
$[
|
|
81
|
-
} else
|
|
82
|
-
let
|
|
83
|
-
if ($[
|
|
84
|
-
|
|
82
|
+
$[15] = activeValues;
|
|
83
|
+
$[16] = toggle;
|
|
84
|
+
$[17] = t7;
|
|
85
|
+
} else t7 = $[17];
|
|
86
|
+
t6 = filters.map(t7);
|
|
87
|
+
$[11] = activeValues;
|
|
88
|
+
$[12] = filters;
|
|
89
|
+
$[13] = toggle;
|
|
90
|
+
$[14] = t6;
|
|
91
|
+
} else t6 = $[14];
|
|
92
|
+
let t7;
|
|
93
|
+
if ($[18] !== activeValues.length || $[19] !== locale.messages.filterReset || $[20] !== onSelect) {
|
|
94
|
+
t7 = activeValues.length > 0 && /*#__PURE__*/ jsx(__rspack_external__radix_ui_react_dropdown_menu_154a7470.Item, {
|
|
85
95
|
"data-tao-table-filter-reset": "",
|
|
86
96
|
onSelect: ()=>onSelect([]),
|
|
87
97
|
children: locale.messages.filterReset
|
|
88
98
|
});
|
|
89
|
-
$[
|
|
90
|
-
$[
|
|
91
|
-
$[
|
|
92
|
-
$[
|
|
93
|
-
} else
|
|
94
|
-
let
|
|
95
|
-
if ($[
|
|
96
|
-
|
|
99
|
+
$[18] = activeValues.length;
|
|
100
|
+
$[19] = locale.messages.filterReset;
|
|
101
|
+
$[20] = onSelect;
|
|
102
|
+
$[21] = t7;
|
|
103
|
+
} else t7 = $[21];
|
|
104
|
+
let t8;
|
|
105
|
+
if ($[22] !== t6 || $[23] !== t7) {
|
|
106
|
+
t8 = /*#__PURE__*/ jsx(__rspack_external__radix_ui_react_dropdown_menu_154a7470.Portal, {
|
|
97
107
|
children: /*#__PURE__*/ jsx(TaoPortalScope, {
|
|
98
108
|
asChild: true,
|
|
99
109
|
children: /*#__PURE__*/ jsxs(__rspack_external__radix_ui_react_dropdown_menu_154a7470.Content, {
|
|
@@ -102,29 +112,29 @@ function TableFilterDropdown(t0) {
|
|
|
102
112
|
sideOffset: 4,
|
|
103
113
|
loop: true,
|
|
104
114
|
children: [
|
|
105
|
-
|
|
106
|
-
|
|
115
|
+
t6,
|
|
116
|
+
t7
|
|
107
117
|
]
|
|
108
118
|
})
|
|
109
119
|
})
|
|
110
120
|
});
|
|
111
|
-
$[
|
|
112
|
-
$[20] = t6;
|
|
113
|
-
$[21] = t7;
|
|
114
|
-
} else t7 = $[21];
|
|
115
|
-
let t8;
|
|
116
|
-
if ($[22] !== t4 || $[23] !== t7) {
|
|
117
|
-
t8 = /*#__PURE__*/ jsxs(__rspack_external__radix_ui_react_dropdown_menu_154a7470.Root, {
|
|
118
|
-
children: [
|
|
119
|
-
t4,
|
|
120
|
-
t7
|
|
121
|
-
]
|
|
122
|
-
});
|
|
123
|
-
$[22] = t4;
|
|
121
|
+
$[22] = t6;
|
|
124
122
|
$[23] = t7;
|
|
125
123
|
$[24] = t8;
|
|
126
124
|
} else t8 = $[24];
|
|
127
|
-
|
|
125
|
+
let t9;
|
|
126
|
+
if ($[25] !== t5 || $[26] !== t8) {
|
|
127
|
+
t9 = /*#__PURE__*/ jsxs(__rspack_external__radix_ui_react_dropdown_menu_154a7470.Root, {
|
|
128
|
+
children: [
|
|
129
|
+
t5,
|
|
130
|
+
t8
|
|
131
|
+
]
|
|
132
|
+
});
|
|
133
|
+
$[25] = t5;
|
|
134
|
+
$[26] = t8;
|
|
135
|
+
$[27] = t9;
|
|
136
|
+
} else t9 = $[27];
|
|
137
|
+
return t9;
|
|
128
138
|
}
|
|
129
139
|
function _temp(event) {
|
|
130
140
|
return event.preventDefault();
|
|
@@ -8,7 +8,8 @@ export declare function FilterIcon({ active }: {
|
|
|
8
8
|
}): import("react").JSX.Element;
|
|
9
9
|
export declare function TableLoadingSpinner(): import("react").JSX.Element;
|
|
10
10
|
export declare function CheckIcon(): import("react").JSX.Element;
|
|
11
|
-
export declare function ExpandIcon({ expanded, onClick, }: {
|
|
11
|
+
export declare function ExpandIcon({ expanded, disabled, onClick, }: {
|
|
12
12
|
expanded: boolean;
|
|
13
|
+
disabled?: boolean;
|
|
13
14
|
onClick: (event: MouseEvent<HTMLButtonElement>) => void;
|
|
14
15
|
}): import("react").JSX.Element;
|
|
@@ -156,27 +156,29 @@ function CheckIcon() {
|
|
|
156
156
|
return t0;
|
|
157
157
|
}
|
|
158
158
|
function ExpandIcon(t0) {
|
|
159
|
-
const $ = c(
|
|
160
|
-
const { expanded, onClick } = t0;
|
|
159
|
+
const $ = c(6);
|
|
160
|
+
const { expanded, disabled, onClick } = t0;
|
|
161
161
|
const { locale } = useTaoConfig();
|
|
162
162
|
const t1 = expanded || void 0;
|
|
163
163
|
const t2 = expanded ? locale.messages.collapseRow : locale.messages.expandRow;
|
|
164
164
|
let t3;
|
|
165
|
-
if ($[0] !==
|
|
165
|
+
if ($[0] !== disabled || $[1] !== expanded || $[2] !== onClick || $[3] !== t1 || $[4] !== t2) {
|
|
166
166
|
t3 = /*#__PURE__*/ jsx("button", {
|
|
167
167
|
type: "button",
|
|
168
168
|
"data-tao-table-expand-icon": "",
|
|
169
169
|
"data-tao-expanded": t1,
|
|
170
|
+
disabled: disabled,
|
|
170
171
|
"aria-expanded": expanded,
|
|
171
172
|
"aria-label": t2,
|
|
172
173
|
onClick: onClick
|
|
173
174
|
});
|
|
174
|
-
$[0] =
|
|
175
|
-
$[1] =
|
|
176
|
-
$[2] =
|
|
177
|
-
$[3] =
|
|
178
|
-
$[4] =
|
|
179
|
-
|
|
175
|
+
$[0] = disabled;
|
|
176
|
+
$[1] = expanded;
|
|
177
|
+
$[2] = onClick;
|
|
178
|
+
$[3] = t1;
|
|
179
|
+
$[4] = t2;
|
|
180
|
+
$[5] = t3;
|
|
181
|
+
} else t3 = $[5];
|
|
180
182
|
return t3;
|
|
181
183
|
}
|
|
182
184
|
export { CheckIcon, ExpandIcon, FilterIcon, SortIcon, TableLoadingSpinner };
|
|
@@ -6,7 +6,7 @@ function getColKey(col, index) {
|
|
|
6
6
|
return col.key ?? (null == col.dataIndex ? String(index) : String(col.dataIndex));
|
|
7
7
|
}
|
|
8
8
|
function getCellValue(record, dataIndex) {
|
|
9
|
-
if (
|
|
9
|
+
if (null == dataIndex) return;
|
|
10
10
|
return record[dataIndex];
|
|
11
11
|
}
|
|
12
12
|
function resolveSemanticClassNames(classNames, props) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Fragment, createElement, isValidElement, useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
2
|
+
import { Fragment, createElement, isValidElement, useCallback, useEffect, useId, useMemo, useRef, useState } from "react";
|
|
3
3
|
import { useTaoConfig, useTaoDirection } from "../../provider/tao-provider.js";
|
|
4
4
|
import { useBreakpoint } from "../../utils/breakpoint.js";
|
|
5
5
|
import { getScrollLeft } from "../../utils/scroll-left.js";
|
|
@@ -9,10 +9,12 @@ import { Pagination } from "../pagination/pagination.js";
|
|
|
9
9
|
import { Radio } from "../radio/radio.js";
|
|
10
10
|
import { TableFilterDropdown } from "./table-filter.js";
|
|
11
11
|
import { ExpandIcon, SortIcon, TableLoadingSpinner } from "./table-icons.js";
|
|
12
|
-
import { getCellValue,
|
|
12
|
+
import { getCellValue, getRowKey, resolveRowClassName, resolveRowStyle, resolveSemanticClassNames, resolveSemanticStyles } from "./table-model.js";
|
|
13
13
|
import { TableSummary, TableSummaryContext } from "./table-summary.js";
|
|
14
14
|
import { useTableData } from "./use-table-data.js";
|
|
15
15
|
import "./table.css";
|
|
16
|
+
const EXPAND_COLUMN_INDEX = -2;
|
|
17
|
+
const SELECTION_COLUMN_INDEX = -1;
|
|
16
18
|
function stickyStyle(pos, zIndex) {
|
|
17
19
|
return pos ? {
|
|
18
20
|
position: 'sticky',
|
|
@@ -20,6 +22,10 @@ function stickyStyle(pos, zIndex) {
|
|
|
20
22
|
zIndex
|
|
21
23
|
} : void 0;
|
|
22
24
|
}
|
|
25
|
+
function fixedColumnWidth(width) {
|
|
26
|
+
if ('number' == typeof width) return width;
|
|
27
|
+
return width?.trim().toLowerCase().endsWith('px') ? Number.parseFloat(width) || 0 : 0;
|
|
28
|
+
}
|
|
23
29
|
function Table({ columns: columnsProp, dataSource, rowKey, loading = false, pagination: paginationProp, onChange, scroll, rowSelection, expandable, summary, size, variant, headerBackground = true, emptyText: emptyTextProp, bordered = false, className, style, classNames, styles, rowClassName, rowStyle, onRow, onHeaderRow }) {
|
|
24
30
|
const ctx = useTaoConfig();
|
|
25
31
|
const emptyText = void 0 === emptyTextProp ? ctx.locale.messages.tableEmpty : emptyTextProp;
|
|
@@ -60,6 +66,7 @@ function Table({ columns: columnsProp, dataSource, rowKey, loading = false, pagi
|
|
|
60
66
|
const resolvedStyles = resolveSemanticStyles(styles, semanticProps);
|
|
61
67
|
const tableData = useTableData({
|
|
62
68
|
columns,
|
|
69
|
+
configuredColumns: columnsProp,
|
|
63
70
|
dataSource,
|
|
64
71
|
pagination: paginationProp,
|
|
65
72
|
onChange
|
|
@@ -67,17 +74,15 @@ function Table({ columns: columnsProp, dataSource, rowKey, loading = false, pagi
|
|
|
67
74
|
const paginatedData = tableData.rows;
|
|
68
75
|
const selectionColWidth = rowSelection?.columnWidth ?? 48;
|
|
69
76
|
const selectionType = rowSelection?.type ?? 'checkbox';
|
|
70
|
-
const
|
|
77
|
+
const selectionName = useId();
|
|
78
|
+
const isSelectionControlled = null != rowSelection && 'selectedRowKeys' in rowSelection;
|
|
71
79
|
const [internalSelectedKeys, setInternalSelectedKeys] = useState([]);
|
|
72
|
-
const selectedKeys = rowSelection
|
|
80
|
+
const selectedKeys = isSelectionControlled ? rowSelection.selectedRowKeys ?? [] : internalSelectedKeys;
|
|
73
81
|
const selectedKeySet = useMemo(()=>new Set(selectedKeys), [
|
|
74
82
|
selectedKeys
|
|
75
83
|
]);
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
rowSelection,
|
|
79
|
-
rowKey
|
|
80
|
-
]);
|
|
84
|
+
const disabledRows = rowSelection ? paginatedData.map((record)=>rowSelection.getCheckboxProps?.(record)?.disabled) : [];
|
|
85
|
+
const selectablePageKeys = rowSelection ? paginatedData.filter((_, index)=>!disabledRows[index]).map((record_0)=>getRowKey(record_0, rowKey)) : [];
|
|
81
86
|
const handleSelectRow = useCallback((key)=>{
|
|
82
87
|
let nextKeys;
|
|
83
88
|
nextKeys = 'radio' === selectionType ? [
|
|
@@ -90,7 +95,9 @@ function Table({ columns: columnsProp, dataSource, rowKey, loading = false, pagi
|
|
|
90
95
|
if (!rowSelection?.onChange) return;
|
|
91
96
|
const nextKeySet = new Set(nextKeys);
|
|
92
97
|
const nextRows = dataSource.filter((r)=>nextKeySet.has(getRowKey(r, rowKey)));
|
|
93
|
-
rowSelection.onChange(
|
|
98
|
+
rowSelection.onChange([
|
|
99
|
+
...nextKeys
|
|
100
|
+
], nextRows);
|
|
94
101
|
}, [
|
|
95
102
|
rowSelection,
|
|
96
103
|
selectionType,
|
|
@@ -110,7 +117,9 @@ function Table({ columns: columnsProp, dataSource, rowKey, loading = false, pagi
|
|
|
110
117
|
if (!isSelectionControlled) setInternalSelectedKeys(nextKeys_0);
|
|
111
118
|
if (!rowSelection?.onChange) return;
|
|
112
119
|
const nextRows_0 = dataSource.filter((record_1)=>nextKeySet_0.has(getRowKey(record_1, rowKey)));
|
|
113
|
-
rowSelection.onChange(
|
|
120
|
+
rowSelection.onChange([
|
|
121
|
+
...nextKeys_0
|
|
122
|
+
], nextRows_0);
|
|
114
123
|
}, [
|
|
115
124
|
rowSelection,
|
|
116
125
|
selectedKeys,
|
|
@@ -121,7 +130,8 @@ function Table({ columns: columnsProp, dataSource, rowKey, loading = false, pagi
|
|
|
121
130
|
]);
|
|
122
131
|
const expandColWidth = expandable?.columnWidth ?? 48;
|
|
123
132
|
const [internalExpandedKeys, setInternalExpandedKeys] = useState(()=>expandable?.defaultExpandedRowKeys ?? []);
|
|
124
|
-
const
|
|
133
|
+
const isExpansionControlled = null != expandable && 'expandedRowKeys' in expandable;
|
|
134
|
+
const expandedKeys = isExpansionControlled ? expandable.expandedRowKeys ?? [] : internalExpandedKeys;
|
|
125
135
|
const expandedKeySet = useMemo(()=>new Set(expandedKeys), [
|
|
126
136
|
expandedKeys
|
|
127
137
|
]);
|
|
@@ -131,11 +141,13 @@ function Table({ columns: columnsProp, dataSource, rowKey, loading = false, pagi
|
|
|
131
141
|
...expandedKeys,
|
|
132
142
|
key_1
|
|
133
143
|
] : expandedKeys.filter((k_0)=>k_0 !== key_1);
|
|
134
|
-
if (
|
|
144
|
+
if (!isExpansionControlled) setInternalExpandedKeys(nextKeys_1);
|
|
135
145
|
expandable?.onExpand?.(expanded, record_2);
|
|
136
146
|
expandable?.onExpandedRowsChange?.(nextKeys_1);
|
|
137
147
|
};
|
|
138
148
|
const scrollRef = useRef(null);
|
|
149
|
+
const headerRowRef = useRef(null);
|
|
150
|
+
const [headerWidths, setHeaderWidths] = useState([]);
|
|
139
151
|
const [direction, directionRef] = useTaoDirection(void 0, 'self');
|
|
140
152
|
const [viewportWidth, setViewportWidth] = useState();
|
|
141
153
|
const [scrollState, setScrollState] = useState('left');
|
|
@@ -153,37 +165,23 @@ function Table({ columns: columnsProp, dataSource, rowKey, loading = false, pagi
|
|
|
153
165
|
}, [
|
|
154
166
|
direction
|
|
155
167
|
]);
|
|
156
|
-
useEffect(()=>{
|
|
157
|
-
const el_0 = scrollRef.current;
|
|
158
|
-
if (!scroll?.x || !el_0) return;
|
|
159
|
-
handleScroll();
|
|
160
|
-
const observer = new ResizeObserver(handleScroll);
|
|
161
|
-
observer.observe(el_0);
|
|
162
|
-
if (el_0.firstElementChild) observer.observe(el_0.firstElementChild);
|
|
163
|
-
return ()=>observer.disconnect();
|
|
164
|
-
}, [
|
|
165
|
-
scroll?.x,
|
|
166
|
-
handleScroll
|
|
167
|
-
]);
|
|
168
168
|
const allColumns = useMemo(()=>{
|
|
169
169
|
const cols = [];
|
|
170
170
|
if (expandable) cols.push({
|
|
171
|
-
|
|
172
|
-
_index: -2,
|
|
171
|
+
index: EXPAND_COLUMN_INDEX,
|
|
173
172
|
width: expandColWidth,
|
|
174
173
|
fixed: expandable.fixed ? 'left' : void 0
|
|
175
174
|
});
|
|
176
175
|
if (rowSelection) cols.push({
|
|
177
|
-
|
|
178
|
-
_index: -1,
|
|
176
|
+
index: SELECTION_COLUMN_INDEX,
|
|
179
177
|
width: selectionColWidth,
|
|
180
178
|
fixed: rowSelection.fixed ? 'left' : void 0
|
|
181
179
|
});
|
|
182
|
-
columns.forEach((
|
|
180
|
+
columns.forEach(({ fixed, width }, index_0)=>{
|
|
183
181
|
cols.push({
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
182
|
+
fixed,
|
|
183
|
+
width,
|
|
184
|
+
index: index_0
|
|
187
185
|
});
|
|
188
186
|
});
|
|
189
187
|
return cols;
|
|
@@ -194,40 +192,63 @@ function Table({ columns: columnsProp, dataSource, rowKey, loading = false, pagi
|
|
|
194
192
|
expandable,
|
|
195
193
|
expandColWidth
|
|
196
194
|
]);
|
|
195
|
+
useEffect(()=>{
|
|
196
|
+
const el_0 = scrollRef.current;
|
|
197
|
+
if (!scroll?.x || !el_0) return;
|
|
198
|
+
const cells = allColumns.some(({ fixed: fixed_0 })=>fixed_0) ? Array.from(headerRowRef.current?.cells ?? []) : [];
|
|
199
|
+
const measure = ()=>{
|
|
200
|
+
handleScroll();
|
|
201
|
+
const widths = cells.map((cell)=>cell.offsetWidth);
|
|
202
|
+
setHeaderWidths((previous)=>previous.length === widths.length && previous.every((width_0, index_1)=>width_0 === widths[index_1]) ? previous : widths);
|
|
203
|
+
};
|
|
204
|
+
measure();
|
|
205
|
+
const observer = new ResizeObserver(measure);
|
|
206
|
+
observer.observe(el_0);
|
|
207
|
+
if (el_0.firstElementChild) observer.observe(el_0.firstElementChild);
|
|
208
|
+
for (const cell_0 of cells)observer.observe(cell_0);
|
|
209
|
+
return ()=>observer.disconnect();
|
|
210
|
+
}, [
|
|
211
|
+
scroll?.x,
|
|
212
|
+
handleScroll,
|
|
213
|
+
allColumns
|
|
214
|
+
]);
|
|
197
215
|
const stickyPositions = useMemo(()=>{
|
|
198
216
|
if (!scroll?.x) return {};
|
|
199
217
|
const positions = {};
|
|
200
218
|
let leftOffset = 0;
|
|
201
|
-
for (const
|
|
202
|
-
positions[
|
|
219
|
+
for (const [index_2, col_1] of allColumns.entries())if ('left' === col_1.fixed) {
|
|
220
|
+
positions[col_1.index] = {
|
|
203
221
|
['rtl' === direction ? 'right' : 'left']: leftOffset
|
|
204
222
|
};
|
|
205
|
-
leftOffset +=
|
|
223
|
+
leftOffset += headerWidths[index_2] || fixedColumnWidth(col_1.width);
|
|
206
224
|
}
|
|
207
225
|
let rightOffset = 0;
|
|
208
|
-
for(let
|
|
209
|
-
const
|
|
210
|
-
if ('right' ===
|
|
211
|
-
positions[
|
|
226
|
+
for(let i = allColumns.length - 1; i >= 0; i--){
|
|
227
|
+
const col_2 = allColumns[i];
|
|
228
|
+
if ('right' === col_2.fixed) {
|
|
229
|
+
positions[col_2.index] = {
|
|
212
230
|
['rtl' === direction ? 'left' : 'right']: rightOffset
|
|
213
231
|
};
|
|
214
|
-
rightOffset +=
|
|
232
|
+
rightOffset += headerWidths[i] || fixedColumnWidth(col_2.width);
|
|
215
233
|
}
|
|
216
234
|
}
|
|
217
235
|
return positions;
|
|
218
236
|
}, [
|
|
219
237
|
allColumns,
|
|
220
238
|
scroll?.x,
|
|
221
|
-
direction
|
|
239
|
+
direction,
|
|
240
|
+
headerWidths
|
|
222
241
|
]);
|
|
223
|
-
const summaryColumns = useMemo(()=>allColumns.map((
|
|
224
|
-
fixed:
|
|
225
|
-
sticky: stickyPositions[
|
|
242
|
+
const summaryColumns = useMemo(()=>allColumns.map((col_3)=>({
|
|
243
|
+
fixed: col_3.fixed,
|
|
244
|
+
sticky: stickyPositions[col_3.index]
|
|
226
245
|
})), [
|
|
227
246
|
allColumns,
|
|
228
247
|
stickyPositions
|
|
229
248
|
]);
|
|
230
|
-
const summaryNode = summary?.(
|
|
249
|
+
const summaryNode = summary?.([
|
|
250
|
+
...paginatedData
|
|
251
|
+
]);
|
|
231
252
|
const summaryFixed = /*#__PURE__*/ isValidElement(summaryNode) && summaryNode.type === TableSummary && !!summaryNode.props.fixed;
|
|
232
253
|
const tableStyle = scroll?.x ? {
|
|
233
254
|
minWidth: 'number' == typeof scroll.x ? `${scroll.x}px` : scroll.x
|
|
@@ -277,6 +298,7 @@ function Table({ columns: columnsProp, dataSource, rowKey, loading = false, pagi
|
|
|
277
298
|
const headerRowProps = onHeaderRow?.(columns, 0) ?? {};
|
|
278
299
|
return /*#__PURE__*/ jsxs("tr", {
|
|
279
300
|
...headerRowProps,
|
|
301
|
+
ref: headerRowRef,
|
|
280
302
|
className: cx(resolvedClassNames['header.row'], headerRowProps.className),
|
|
281
303
|
style: {
|
|
282
304
|
...resolvedStyles['header.row'],
|
|
@@ -286,50 +308,50 @@ function Table({ columns: columnsProp, dataSource, rowKey, loading = false, pagi
|
|
|
286
308
|
expandable && /*#__PURE__*/ jsx("th", {
|
|
287
309
|
"data-tao-table-cell": "",
|
|
288
310
|
"data-tao-table-expand-cell": "",
|
|
289
|
-
"data-tao-fixed": stickyPositions
|
|
311
|
+
"data-tao-fixed": stickyPositions[EXPAND_COLUMN_INDEX] ? 'left' : void 0,
|
|
290
312
|
style: {
|
|
291
313
|
width: expandColWidth,
|
|
292
|
-
...stickyStyle(stickyPositions
|
|
314
|
+
...stickyStyle(stickyPositions[EXPAND_COLUMN_INDEX], 3)
|
|
293
315
|
}
|
|
294
316
|
}),
|
|
295
317
|
rowSelection && /*#__PURE__*/ jsx("th", {
|
|
296
318
|
"data-tao-table-cell": "",
|
|
297
319
|
"data-tao-table-selection-cell": "",
|
|
298
|
-
"data-tao-fixed": stickyPositions
|
|
320
|
+
"data-tao-fixed": stickyPositions[SELECTION_COLUMN_INDEX] ? 'left' : void 0,
|
|
299
321
|
className: resolvedClassNames['selection.cell'],
|
|
300
322
|
style: {
|
|
301
323
|
width: selectionColWidth,
|
|
302
|
-
...stickyStyle(stickyPositions
|
|
324
|
+
...stickyStyle(stickyPositions[SELECTION_COLUMN_INDEX], 3),
|
|
303
325
|
...resolvedStyles['selection.cell']
|
|
304
326
|
},
|
|
305
327
|
children: 'checkbox' === selectionType && /*#__PURE__*/ jsx(Checkbox, {
|
|
306
328
|
"aria-label": ctx.locale.messages.selectAllRows,
|
|
307
329
|
checked: isAllSelected,
|
|
308
|
-
disabled: 0 === selectablePageKeys.length,
|
|
330
|
+
disabled: ctx.disabled || 0 === selectablePageKeys.length,
|
|
309
331
|
indeterminate: isIndeterminate,
|
|
310
332
|
onChange: (e)=>handleSelectAll(e.target.checked)
|
|
311
333
|
})
|
|
312
334
|
}),
|
|
313
|
-
columns.map((
|
|
314
|
-
const colKey =
|
|
315
|
-
const hasSorter = !!
|
|
316
|
-
const hasFilter = !!(
|
|
317
|
-
const { sortOrder: resolvedOrder, filteredValue: activeFilterValues, onSort, onFilter } = tableData.getColumnState(
|
|
318
|
-
const stickyPos = stickyPositions[
|
|
319
|
-
const isFixed = !!
|
|
320
|
-
const headerCellProps =
|
|
335
|
+
columns.map((col_4, i_0)=>{
|
|
336
|
+
const colKey = tableData.columnKeys[i_0];
|
|
337
|
+
const hasSorter = !!col_4.sorter;
|
|
338
|
+
const hasFilter = !!(col_4.filters && col_4.filters.length > 0);
|
|
339
|
+
const { sortOrder: resolvedOrder, filteredValue: activeFilterValues, onSort, onFilter } = tableData.getColumnState(i_0);
|
|
340
|
+
const stickyPos = stickyPositions[i_0];
|
|
341
|
+
const isFixed = !!col_4.fixed && !!scroll?.x;
|
|
342
|
+
const headerCellProps = col_4.onHeaderCell?.(col_4) ?? {};
|
|
321
343
|
return /*#__PURE__*/ createElement("th", {
|
|
322
344
|
...headerCellProps,
|
|
323
345
|
key: colKey,
|
|
324
346
|
"data-tao-table-cell": "",
|
|
325
347
|
"data-tao-table-header": "",
|
|
326
|
-
"data-tao-align":
|
|
327
|
-
"data-tao-fixed": isFixed ?
|
|
348
|
+
"data-tao-align": col_4.align,
|
|
349
|
+
"data-tao-fixed": isFixed ? col_4.fixed : void 0,
|
|
328
350
|
"aria-sort": hasSorter ? 'ascend' === resolvedOrder ? 'ascending' : 'descend' === resolvedOrder ? 'descending' : 'none' : void 0,
|
|
329
351
|
className: cx(resolvedClassNames['header.cell'], headerCellProps.className),
|
|
330
352
|
style: {
|
|
331
353
|
...resolvedStyles['header.cell'],
|
|
332
|
-
width:
|
|
354
|
+
width: col_4.width,
|
|
333
355
|
...stickyStyle(isFixed ? stickyPos : void 0, 3),
|
|
334
356
|
...headerCellProps.style
|
|
335
357
|
}
|
|
@@ -344,9 +366,10 @@ function Table({ columns: columnsProp, dataSource, rowKey, loading = false, pagi
|
|
|
344
366
|
"data-tao-sortable": "",
|
|
345
367
|
className: resolvedClassNames['header.title'],
|
|
346
368
|
style: resolvedStyles['header.title'],
|
|
369
|
+
disabled: ctx.disabled,
|
|
347
370
|
onClick: onSort,
|
|
348
371
|
children: [
|
|
349
|
-
|
|
372
|
+
col_4.title,
|
|
350
373
|
/*#__PURE__*/ jsx(SortIcon, {
|
|
351
374
|
order: resolvedOrder
|
|
352
375
|
})
|
|
@@ -355,10 +378,10 @@ function Table({ columns: columnsProp, dataSource, rowKey, loading = false, pagi
|
|
|
355
378
|
"data-tao-table-header-title": "",
|
|
356
379
|
className: resolvedClassNames['header.title'],
|
|
357
380
|
style: resolvedStyles['header.title'],
|
|
358
|
-
children:
|
|
381
|
+
children: col_4.title
|
|
359
382
|
}),
|
|
360
383
|
hasFilter && /*#__PURE__*/ jsx(TableFilterDropdown, {
|
|
361
|
-
filters:
|
|
384
|
+
filters: col_4.filters,
|
|
362
385
|
activeValues: activeFilterValues,
|
|
363
386
|
onSelect: onFilter
|
|
364
387
|
})
|
|
@@ -383,7 +406,6 @@ function Table({ columns: columnsProp, dataSource, rowKey, loading = false, pagi
|
|
|
383
406
|
}) : paginatedData.map((record_3, rowIdx)=>{
|
|
384
407
|
const key_3 = getRowKey(record_3, rowKey);
|
|
385
408
|
const isSelected = selectedKeySet.has(key_3);
|
|
386
|
-
const checkboxProps = rowSelection?.getCheckboxProps?.(record_3);
|
|
387
409
|
const rowProps = onRow?.(record_3, rowIdx) ?? {};
|
|
388
410
|
const rowExpandable = !!expandable && (expandable.rowExpandable?.(record_3) ?? true);
|
|
389
411
|
const isExpanded = rowExpandable && expandedKeySet.has(key_3);
|
|
@@ -397,7 +419,7 @@ function Table({ columns: columnsProp, dataSource, rowKey, loading = false, pagi
|
|
|
397
419
|
const selectionCell = event.target.closest('[data-tao-table-selection-cell]');
|
|
398
420
|
if (selectionCell && event.target !== selectionCell) return void event.stopPropagation();
|
|
399
421
|
rowProps.onClick?.(event);
|
|
400
|
-
if (rowExpandable && expandable?.expandRowByClick) toggleExpand(record_3, key_3);
|
|
422
|
+
if (!event.defaultPrevented && !ctx.disabled && rowExpandable && expandable?.expandRowByClick) toggleExpand(record_3, key_3);
|
|
401
423
|
},
|
|
402
424
|
className: cx(resolvedClassNames['body.row'], resolveRowClassName(rowClassName, record_3, rowIdx), rowProps.className),
|
|
403
425
|
style: {
|
|
@@ -409,10 +431,11 @@ function Table({ columns: columnsProp, dataSource, rowKey, loading = false, pagi
|
|
|
409
431
|
expandable && /*#__PURE__*/ jsx("td", {
|
|
410
432
|
"data-tao-table-cell": "",
|
|
411
433
|
"data-tao-table-expand-cell": "",
|
|
412
|
-
"data-tao-fixed": stickyPositions
|
|
413
|
-
style: stickyStyle(stickyPositions
|
|
434
|
+
"data-tao-fixed": stickyPositions[EXPAND_COLUMN_INDEX] ? 'left' : void 0,
|
|
435
|
+
style: stickyStyle(stickyPositions[EXPAND_COLUMN_INDEX], 1),
|
|
414
436
|
children: rowExpandable && /*#__PURE__*/ jsx(ExpandIcon, {
|
|
415
437
|
expanded: isExpanded,
|
|
438
|
+
disabled: ctx.disabled,
|
|
416
439
|
onClick: (e_0)=>{
|
|
417
440
|
e_0.stopPropagation();
|
|
418
441
|
toggleExpand(record_3, key_3);
|
|
@@ -422,44 +445,45 @@ function Table({ columns: columnsProp, dataSource, rowKey, loading = false, pagi
|
|
|
422
445
|
rowSelection && /*#__PURE__*/ jsx("td", {
|
|
423
446
|
"data-tao-table-cell": "",
|
|
424
447
|
"data-tao-table-selection-cell": "",
|
|
425
|
-
"data-tao-fixed": stickyPositions
|
|
448
|
+
"data-tao-fixed": stickyPositions[SELECTION_COLUMN_INDEX] ? 'left' : void 0,
|
|
426
449
|
className: resolvedClassNames['selection.cell'],
|
|
427
450
|
style: {
|
|
428
|
-
...stickyStyle(stickyPositions
|
|
451
|
+
...stickyStyle(stickyPositions[SELECTION_COLUMN_INDEX], 1),
|
|
429
452
|
...resolvedStyles['selection.cell']
|
|
430
453
|
},
|
|
431
454
|
children: 'radio' === selectionType ? /*#__PURE__*/ jsx(Radio, {
|
|
455
|
+
name: selectionName,
|
|
432
456
|
checked: isSelected,
|
|
433
457
|
"aria-label": ctx.locale.messages.selectRow(String(key_3)),
|
|
434
|
-
disabled:
|
|
458
|
+
disabled: ctx.disabled || disabledRows[rowIdx],
|
|
435
459
|
onChange: ()=>handleSelectRow(key_3)
|
|
436
460
|
}) : /*#__PURE__*/ jsx(Checkbox, {
|
|
437
461
|
checked: isSelected,
|
|
438
462
|
"aria-label": ctx.locale.messages.selectRow(String(key_3)),
|
|
439
|
-
disabled:
|
|
463
|
+
disabled: ctx.disabled || disabledRows[rowIdx],
|
|
440
464
|
onChange: ()=>handleSelectRow(key_3)
|
|
441
465
|
})
|
|
442
466
|
}),
|
|
443
|
-
columns.map((
|
|
444
|
-
const colKey_0 =
|
|
445
|
-
const value = getCellValue(record_3,
|
|
446
|
-
const stickyPos_0 = stickyPositions[
|
|
447
|
-
const isFixed_0 = !!
|
|
448
|
-
const cellProps =
|
|
467
|
+
columns.map((col_5, colIdx)=>{
|
|
468
|
+
const colKey_0 = tableData.columnKeys[colIdx];
|
|
469
|
+
const value = getCellValue(record_3, col_5.dataIndex);
|
|
470
|
+
const stickyPos_0 = stickyPositions[colIdx];
|
|
471
|
+
const isFixed_0 = !!col_5.fixed && !!scroll?.x;
|
|
472
|
+
const cellProps = col_5.onCell?.(record_3, rowIdx) ?? {};
|
|
449
473
|
return /*#__PURE__*/ createElement("td", {
|
|
450
474
|
...cellProps,
|
|
451
475
|
key: colKey_0,
|
|
452
476
|
"data-tao-table-cell": "",
|
|
453
|
-
"data-tao-align":
|
|
454
|
-
"data-tao-ellipsis":
|
|
455
|
-
"data-tao-fixed": isFixed_0 ?
|
|
477
|
+
"data-tao-align": col_5.align,
|
|
478
|
+
"data-tao-ellipsis": col_5.ellipsis || void 0,
|
|
479
|
+
"data-tao-fixed": isFixed_0 ? col_5.fixed : void 0,
|
|
456
480
|
className: cx(resolvedClassNames['body.cell'], cellProps.className),
|
|
457
481
|
style: {
|
|
458
482
|
...resolvedStyles['body.cell'],
|
|
459
483
|
...stickyStyle(isFixed_0 ? stickyPos_0 : void 0, 1),
|
|
460
484
|
...cellProps.style
|
|
461
485
|
}
|
|
462
|
-
},
|
|
486
|
+
}, col_5.render ? col_5.render(value, record_3, rowIdx) : value);
|
|
463
487
|
})
|
|
464
488
|
]
|
|
465
489
|
}),
|