@canlooks/can-ui 0.0.74 → 0.0.76
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/cjs/components/calendar/calendar.style.js +124 -124
- package/dist/cjs/components/clickAway/clickAway.d.ts +1 -1
- package/dist/cjs/components/curd/curdResizable.js +1 -1
- package/dist/cjs/components/dateTimePicker/dateTimePicker.d.ts +4 -4
- package/dist/cjs/components/dateTimePicker/dateTimePicker.js +14 -190
- package/dist/cjs/components/dateTimePicker/dateTimePicker.style.d.ts +2 -12
- package/dist/cjs/components/dateTimePicker/dateTimePicker.style.js +20 -17
- package/dist/cjs/components/descriptions/descriptions.js +1 -5
- package/dist/cjs/components/dialog/dialog.js +1 -1
- package/dist/cjs/components/dialog/dialog.style.js +2 -0
- package/dist/cjs/components/inputBase/inputBase.js +10 -1
- package/dist/cjs/components/popper/popper.js +21 -20
- package/dist/cjs/components/status/status.d.ts +6 -6
- package/dist/cjs/components/table/table.d.ts +1 -1
- package/dist/cjs/components/table/table.js +3 -1
- package/dist/cjs/components/table/table.style.js +21 -6
- package/dist/cjs/components/table/tableSticky.js +19 -16
- package/dist/cjs/components/table/tableSticky.style.js +0 -8
- package/dist/cjs/components/theme/themeVariables.js +2 -2
- package/dist/cjs/utils/utils.d.ts +5 -3
- package/dist/cjs/utils/utils.js +22 -7
- package/dist/esm/components/calendar/calendar.style.js +124 -124
- package/dist/esm/components/clickAway/clickAway.d.ts +1 -1
- package/dist/esm/components/curd/curdResizable.js +1 -1
- package/dist/esm/components/dateTimePicker/dateTimePicker.d.ts +4 -4
- package/dist/esm/components/dateTimePicker/dateTimePicker.js +15 -191
- package/dist/esm/components/dateTimePicker/dateTimePicker.style.d.ts +2 -12
- package/dist/esm/components/dateTimePicker/dateTimePicker.style.js +20 -17
- package/dist/esm/components/descriptions/descriptions.js +1 -5
- package/dist/esm/components/dialog/dialog.js +1 -1
- package/dist/esm/components/dialog/dialog.style.js +2 -0
- package/dist/esm/components/inputBase/inputBase.js +11 -2
- package/dist/esm/components/popper/popper.js +22 -21
- package/dist/esm/components/status/status.d.ts +6 -6
- package/dist/esm/components/table/table.d.ts +1 -1
- package/dist/esm/components/table/table.js +4 -2
- package/dist/esm/components/table/table.style.js +21 -6
- package/dist/esm/components/table/tableSticky.js +20 -17
- package/dist/esm/components/table/tableSticky.style.js +0 -8
- package/dist/esm/components/theme/themeVariables.js +2 -2
- package/dist/esm/utils/utils.d.ts +5 -3
- package/dist/esm/utils/utils.js +21 -6
- package/documentation/dist/assets/index-DvrKS6Tv.js +7747 -0
- package/documentation/dist/atom-one-dark.min.css +1 -0
- package/documentation/dist/components/accordion.md +38 -0
- package/documentation/dist/components/actionSheet.md +49 -0
- package/documentation/dist/components/alert.md +38 -0
- package/documentation/dist/components/anchorList.md +36 -0
- package/documentation/dist/components/autocomplete.md +68 -0
- package/documentation/dist/components/avatar.md +79 -0
- package/documentation/dist/components/badge.md +33 -0
- package/documentation/dist/components/bottomNavigation.md +39 -0
- package/documentation/dist/components/breadcrumb.md +28 -0
- package/documentation/dist/components/bubbleConfirm.md +34 -0
- package/documentation/dist/components/button.md +62 -0
- package/documentation/dist/components/card.md +30 -0
- package/documentation/dist/components/cascade.md +48 -0
- package/documentation/dist/components/checkbox.md +36 -0
- package/documentation/dist/components/colorPicker.md +27 -0
- package/documentation/dist/components/contextMenu.md +27 -0
- package/documentation/dist/components/counter.md +29 -0
- package/documentation/dist/components/dataGrid.md +112 -0
- package/documentation/dist/components/dateTimePicker.md +35 -0
- package/documentation/dist/components/dateTimeRangePicker.md +36 -0
- package/documentation/dist/components/descriptions.md +35 -0
- package/documentation/dist/components/dialog.md +56 -0
- package/documentation/dist/components/divider.md +26 -0
- package/documentation/dist/components/drawer.md +40 -0
- package/documentation/dist/components/flex.md +20 -0
- package/documentation/dist/components/form.md +131 -0
- package/documentation/dist/components/formDialog.md +36 -0
- package/documentation/dist/components/grid.md +34 -0
- package/documentation/dist/components/highlight.md +26 -0
- package/documentation/dist/components/image.md +90 -0
- package/documentation/dist/components/input.md +39 -0
- package/documentation/dist/components/loading.md +46 -0
- package/documentation/dist/components/menu.md +85 -0
- package/documentation/dist/components/pagination.md +38 -0
- package/documentation/dist/components/pickerDialog.md +56 -0
- package/documentation/dist/components/placeholder.md +30 -0
- package/documentation/dist/components/progress.md +43 -0
- package/documentation/dist/components/radio.md +37 -0
- package/documentation/dist/components/rating.md +35 -0
- package/documentation/dist/components/resizable.md +41 -0
- package/documentation/dist/components/scrollbar.md +31 -0
- package/documentation/dist/components/segmented.md +57 -0
- package/documentation/dist/components/select.md +30 -0
- package/documentation/dist/components/skeleton.md +26 -0
- package/documentation/dist/components/slidableActions.md +53 -0
- package/documentation/dist/guide/appComponent.md +30 -0
- package/documentation/dist/guide/globalMethods.md +238 -0
- package/documentation/dist/guide/icon.md +57 -0
- package/documentation/dist/guide/introduction.md +2 -0
- package/documentation/dist/guide/overrideProps.md +0 -0
- package/documentation/dist/guide/startup.md +23 -0
- package/documentation/dist/guide/theme.md +249 -0
- package/documentation/dist/index.html +13 -0
- package/documentation/dist/logo.png +0 -0
- package/extensions/curd.cjs +5 -5
- package/extensions/documentViewer.cjs +5 -5
- package/extensions/textFormatter.cjs +5 -5
- package/package.json +1 -1
|
@@ -56,6 +56,15 @@ min, max, step, precision, placeholder, disabled, readOnly, autoFocus, defaultVa
|
|
|
56
56
|
changeHandler(e);
|
|
57
57
|
}
|
|
58
58
|
};
|
|
59
|
+
const shouldRenderClearButton = () => {
|
|
60
|
+
if (!clearable || disabled || readOnly || (0, utils_1.isUnset)(innerValue.current)) {
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
if (Array.isArray(innerValue.current) || typeof innerValue.current === 'string') {
|
|
64
|
+
return !!innerValue.current.length;
|
|
65
|
+
}
|
|
66
|
+
return true;
|
|
67
|
+
};
|
|
59
68
|
return ((0, jsx_runtime_1.jsxs)("div", { ...(0, utils_1.mergeComponentProps)(props, {
|
|
60
69
|
ref: innerRef,
|
|
61
70
|
className: inputBase_style_1.classes.root,
|
|
@@ -86,7 +95,7 @@ min, max, step, precision, placeholder, disabled, readOnly, autoFocus, defaultVa
|
|
|
86
95
|
onBlur: blurHandler,
|
|
87
96
|
onKeyDown: (e) => e.key === 'Enter' && blurHandler(e)
|
|
88
97
|
}) }), loading &&
|
|
89
|
-
(0, jsx_runtime_1.jsx)(loadingIndicator_1.LoadingIndicator, {}),
|
|
98
|
+
(0, jsx_runtime_1.jsx)(loadingIndicator_1.LoadingIndicator, {}), shouldRenderClearButton() &&
|
|
90
99
|
(0, jsx_runtime_1.jsx)(button_1.Button, { className: inputBase_style_1.classes.clear, variant: "plain", color: "text.disabled", onClick: clear, tabIndex: -1, children: (0, jsx_runtime_1.jsx)(icon_1.Icon, { icon: faCircleXmark_1.faCircleXmark }) }), !!suffix &&
|
|
91
100
|
(0, jsx_runtime_1.jsx)("div", { className: inputBase_style_1.classes.suffix, children: suffix })] }));
|
|
92
101
|
});
|
|
@@ -15,8 +15,8 @@ const getAttemptOrder = (placement) => {
|
|
|
15
15
|
if (index > -1) {
|
|
16
16
|
return [
|
|
17
17
|
placement,
|
|
18
|
-
...order.slice(0, index),
|
|
19
18
|
...order.slice(index + 1),
|
|
19
|
+
...order.slice(0, index),
|
|
20
20
|
placement
|
|
21
21
|
];
|
|
22
22
|
}
|
|
@@ -65,8 +65,8 @@ function Popper({ ref, popperRef, anchorElement, container = document.body, effe
|
|
|
65
65
|
}
|
|
66
66
|
tellParentOpenChange(innerOpen.current);
|
|
67
67
|
}, [innerOpen.current]);
|
|
68
|
-
const onChildrenOpenChange = (
|
|
69
|
-
hold(
|
|
68
|
+
const onChildrenOpenChange = (childrenOpen) => {
|
|
69
|
+
hold(childrenOpen) === 0 && setInnerOpen(false);
|
|
70
70
|
};
|
|
71
71
|
const setOpenForce = (open) => {
|
|
72
72
|
if (!open) {
|
|
@@ -126,7 +126,7 @@ function Popper({ ref, popperRef, anchorElement, container = document.body, effe
|
|
|
126
126
|
// 右键菜单
|
|
127
127
|
const mouseX = contextMenuEvent.current.clientX - containerRect.left;
|
|
128
128
|
const mouseY = contextMenuEvent.current.clientY - containerRect.top;
|
|
129
|
-
attempt =
|
|
129
|
+
attempt = placement => {
|
|
130
130
|
[, pA, pB] = placement.match(/^(top|bottom|left|right)(Top|Bottom|Left|Right)?/);
|
|
131
131
|
if (pB) {
|
|
132
132
|
switch (placement) {
|
|
@@ -190,7 +190,7 @@ function Popper({ ref, popperRef, anchorElement, container = document.body, effe
|
|
|
190
190
|
}
|
|
191
191
|
popperEl.style.left = left + 'px';
|
|
192
192
|
popperEl.style.top = top + 'px';
|
|
193
|
-
return (0, utils_1.
|
|
193
|
+
return (0, utils_1.isElementOverflowed)(popperEl, containerEl.current === document.body ? void 0 : containerEl.current);
|
|
194
194
|
};
|
|
195
195
|
}
|
|
196
196
|
else {
|
|
@@ -198,7 +198,7 @@ function Popper({ ref, popperRef, anchorElement, container = document.body, effe
|
|
|
198
198
|
const anchorRect = getAnchorElement().getBoundingClientRect();
|
|
199
199
|
const topEdge = anchorRect.top - containerRect.top;
|
|
200
200
|
const leftEdge = anchorRect.left - containerRect.left;
|
|
201
|
-
attempt =
|
|
201
|
+
attempt = placement => {
|
|
202
202
|
[, pA, pB] = placement.match(/^(top|bottom|left|right)(Top|Bottom|Left|Right)?/);
|
|
203
203
|
if (sizeAdaptable) {
|
|
204
204
|
if (pA === 'top' || pA === 'bottom') {
|
|
@@ -261,7 +261,7 @@ function Popper({ ref, popperRef, anchorElement, container = document.body, effe
|
|
|
261
261
|
}
|
|
262
262
|
popperEl.style.left = left + 'px';
|
|
263
263
|
popperEl.style.top = top + 'px';
|
|
264
|
-
return (0, utils_1.
|
|
264
|
+
return (0, utils_1.isElementOverflowed)(popperEl, containerEl.current === document.body ? void 0 : containerEl.current);
|
|
265
265
|
};
|
|
266
266
|
}
|
|
267
267
|
if (options?.forcePlacement) {
|
|
@@ -270,7 +270,7 @@ function Popper({ ref, popperRef, anchorElement, container = document.body, effe
|
|
|
270
270
|
else {
|
|
271
271
|
const attemptOrder = getAttemptOrder(placement);
|
|
272
272
|
for (let i = 0; i < attemptOrder.length; i++) {
|
|
273
|
-
if (attempt(attemptOrder[i])) {
|
|
273
|
+
if (attempt(attemptOrder[i]) === false) {
|
|
274
274
|
break;
|
|
275
275
|
}
|
|
276
276
|
}
|
|
@@ -295,8 +295,8 @@ function Popper({ ref, popperRef, anchorElement, container = document.body, effe
|
|
|
295
295
|
popperEl.style.transform = variant === 'collapse'
|
|
296
296
|
? pA === 'top' || pA === 'bottom' ? 'scaleY(0)' : 'scaleX(0)'
|
|
297
297
|
: 'scale(0)';
|
|
298
|
+
animating.current = true;
|
|
298
299
|
requestAnimationFrame(() => {
|
|
299
|
-
animating.current = true;
|
|
300
300
|
settle();
|
|
301
301
|
setOpenNextFrame(true);
|
|
302
302
|
});
|
|
@@ -360,26 +360,26 @@ function Popper({ ref, popperRef, anchorElement, container = document.body, effe
|
|
|
360
360
|
const hoverable = triggersSet.has('hover');
|
|
361
361
|
const enterTimeout = (0, react_1.useRef)(void 0);
|
|
362
362
|
const leaveTimeout = (0, react_1.useRef)(void 0);
|
|
363
|
-
const
|
|
363
|
+
const hoverStack = (0, react_1.useRef)(0);
|
|
364
364
|
const pointerEnter = () => {
|
|
365
|
-
if (
|
|
365
|
+
if (hoverStack.current++) {
|
|
366
366
|
return;
|
|
367
367
|
}
|
|
368
|
-
isEntered.current = true;
|
|
369
|
-
hold(true);
|
|
370
368
|
clearTimeout(leaveTimeout.current);
|
|
371
369
|
mouseEnterDelay
|
|
372
370
|
? enterTimeout.current = setTimeout(() => setInnerOpen(true), mouseEnterDelay)
|
|
373
371
|
: setInnerOpen(true);
|
|
374
372
|
};
|
|
375
373
|
const pointerLeave = () => {
|
|
376
|
-
|
|
377
|
-
|
|
374
|
+
if (--hoverStack.current) {
|
|
375
|
+
return;
|
|
376
|
+
}
|
|
378
377
|
clearTimeout(enterTimeout.current);
|
|
379
378
|
mouseLeaveDelay
|
|
380
379
|
? leaveTimeout.current = setTimeout(() => setInnerOpen(false), mouseLeaveDelay)
|
|
381
380
|
: setInnerOpen(false);
|
|
382
381
|
};
|
|
382
|
+
// 绑定锚点元素
|
|
383
383
|
(0, react_1.useEffect)(() => {
|
|
384
384
|
if (!hoverable) {
|
|
385
385
|
return;
|
|
@@ -392,6 +392,7 @@ function Popper({ ref, popperRef, anchorElement, container = document.body, effe
|
|
|
392
392
|
anchorEl.removeEventListener('pointerleave', pointerLeave);
|
|
393
393
|
};
|
|
394
394
|
}, [hoverable]);
|
|
395
|
+
// 绑定弹框元素,鼠标移入弹框也要保持弹框打开
|
|
395
396
|
(0, react_1.useEffect)(() => {
|
|
396
397
|
if (!hoverable || !innerPopperRef.current) {
|
|
397
398
|
return;
|
|
@@ -431,7 +432,9 @@ function Popper({ ref, popperRef, anchorElement, container = document.body, effe
|
|
|
431
432
|
return;
|
|
432
433
|
}
|
|
433
434
|
const keyDown = (e) => {
|
|
434
|
-
e.key === 'Enter'
|
|
435
|
+
if (e.key === 'Enter') {
|
|
436
|
+
openAndHold(true);
|
|
437
|
+
}
|
|
435
438
|
};
|
|
436
439
|
const anchorEl = anchorRef.current;
|
|
437
440
|
anchorEl.addEventListener('keydown', keyDown);
|
|
@@ -447,9 +450,7 @@ function Popper({ ref, popperRef, anchorElement, container = document.body, effe
|
|
|
447
450
|
if (!clickable) {
|
|
448
451
|
return;
|
|
449
452
|
}
|
|
450
|
-
const click = () =>
|
|
451
|
-
openAndHold(true);
|
|
452
|
-
};
|
|
453
|
+
const click = () => openAndHold(true);
|
|
453
454
|
const anchorEl = anchorRef.current;
|
|
454
455
|
anchorEl.addEventListener('click', click);
|
|
455
456
|
return () => {
|
|
@@ -457,7 +458,7 @@ function Popper({ ref, popperRef, anchorElement, container = document.body, effe
|
|
|
457
458
|
};
|
|
458
459
|
}, []);
|
|
459
460
|
const onClickAway = () => {
|
|
460
|
-
innerOpen.current &&
|
|
461
|
+
innerOpen.current && setOpenForce(false);
|
|
461
462
|
};
|
|
462
463
|
/**
|
|
463
464
|
* clickToClose
|
|
@@ -3,12 +3,12 @@ import { DivProps, Status as IStatus } from '../../types';
|
|
|
3
3
|
import { FontAwesomeIconProps } from '@fortawesome/react-fontawesome';
|
|
4
4
|
export type StatusType = IStatus | 'confirm' | 'unknown';
|
|
5
5
|
export declare const statusMapToIconDefinition: {
|
|
6
|
-
info: import("@fortawesome/
|
|
7
|
-
success: import("@fortawesome/
|
|
8
|
-
warning: import("@fortawesome/
|
|
9
|
-
error: import("@fortawesome/
|
|
10
|
-
confirm: import("@fortawesome/
|
|
11
|
-
unknown: import("@fortawesome/
|
|
6
|
+
info: import("@fortawesome/fontawesome-common-types").IconDefinition;
|
|
7
|
+
success: import("@fortawesome/fontawesome-common-types").IconDefinition;
|
|
8
|
+
warning: import("@fortawesome/fontawesome-common-types").IconDefinition;
|
|
9
|
+
error: import("@fortawesome/fontawesome-common-types").IconDefinition;
|
|
10
|
+
confirm: import("@fortawesome/fontawesome-common-types").IconDefinition;
|
|
11
|
+
unknown: import("@fortawesome/fontawesome-common-types").IconDefinition;
|
|
12
12
|
};
|
|
13
13
|
export interface StatusIconProps extends Partial<FontAwesomeIconProps> {
|
|
14
14
|
status?: StatusType;
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Table = Table;
|
|
4
4
|
exports.TableRow = TableRow;
|
|
5
5
|
const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
|
|
6
|
+
const react_1 = require("react");
|
|
6
7
|
const table_style_1 = require("./table.style");
|
|
7
8
|
const utils_1 = require("../../utils");
|
|
8
9
|
const theme_1 = require("../theme");
|
|
@@ -10,7 +11,8 @@ const tableSticky_1 = require("./tableSticky");
|
|
|
10
11
|
function Table({ size, bordered = 'none', striped = false, ...props }) {
|
|
11
12
|
const theme = (0, theme_1.useTheme)();
|
|
12
13
|
size ??= theme.size;
|
|
13
|
-
|
|
14
|
+
const tableRef = (0, react_1.useRef)(null);
|
|
15
|
+
return ((0, jsx_runtime_1.jsx)("table", { ...props, css: table_style_1.style, ref: (0, utils_1.cloneRef)(props.ref, tableRef), className: (0, utils_1.clsx)(table_style_1.classes.root, props.className), "data-size": size, "data-bordered": bordered, "data-striped": striped }));
|
|
14
16
|
}
|
|
15
17
|
function TableRow({ selected, ...props }) {
|
|
16
18
|
return (0, jsx_runtime_1.jsx)("tr", { ...props, "data-selected": selected });
|
|
@@ -9,9 +9,9 @@ exports.classes = (0, utils_1.defineInnerClasses)('table', [
|
|
|
9
9
|
'container',
|
|
10
10
|
'cell'
|
|
11
11
|
]);
|
|
12
|
-
exports.style = (0, utils_1.defineCss)(({ mode, spacing, gray, divider, easing, colors }) => {
|
|
13
|
-
const headerBg = gray(mode === 'light' ? .
|
|
14
|
-
const stripedBg = gray(mode === 'light' ? .
|
|
12
|
+
exports.style = (0, utils_1.defineCss)(({ mode, spacing, gray, divider, background, easing, colors }) => {
|
|
13
|
+
const headerBg = gray(mode === 'light' ? .03 : .22);
|
|
14
|
+
const stripedBg = gray(mode === 'light' ? .02 : .21);
|
|
15
15
|
const selectedBg = (0, color_1.default)(colors.primary.main).alpha(mode === 'light' ? .05 : .1).string();
|
|
16
16
|
return (0, react_1.css) `
|
|
17
17
|
width: 100%;
|
|
@@ -38,6 +38,14 @@ exports.style = (0, utils_1.defineCss)(({ mode, spacing, gray, divider, easing,
|
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
tbody tr {
|
|
42
|
+
&:not(:hover):not([data-selected=true]) {
|
|
43
|
+
th, td {
|
|
44
|
+
background-color: ${background.content};
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
41
49
|
th, td {
|
|
42
50
|
position: relative;
|
|
43
51
|
text-align: left;
|
|
@@ -59,11 +67,18 @@ exports.style = (0, utils_1.defineCss)(({ mode, spacing, gray, divider, easing,
|
|
|
59
67
|
}
|
|
60
68
|
|
|
61
69
|
&[data-bordered=all], &[data-bordered=true] {
|
|
62
|
-
border-top: 1px solid ${divider};
|
|
63
|
-
border-left: 1px solid ${divider};
|
|
64
|
-
|
|
65
70
|
th, td {
|
|
66
71
|
border-right: 1px solid ${divider};
|
|
72
|
+
|
|
73
|
+
&:first-of-type {
|
|
74
|
+
border-left: 1px solid ${divider};
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
thead tr:first-of-type {
|
|
79
|
+
th, td {
|
|
80
|
+
border-top: 1px solid ${divider};
|
|
81
|
+
}
|
|
67
82
|
}
|
|
68
83
|
}
|
|
69
84
|
|
|
@@ -9,22 +9,29 @@ const utils_1 = require("../../utils");
|
|
|
9
9
|
const table_style_1 = require("./table.style");
|
|
10
10
|
const tableSticky_style_1 = require("./tableSticky.style");
|
|
11
11
|
exports.TableContainer = (({ component: Component = 'div', ...props }) => {
|
|
12
|
-
const [scrolledLeft, setScrolledLeft] = (0, react_1.useState)(false);
|
|
13
|
-
const [scrolledRight, setScrolledRight] = (0, react_1.useState)(false);
|
|
14
12
|
const innerRef = (0, react_1.useRef)(null);
|
|
15
13
|
(0, react_1.useEffect)(() => {
|
|
16
14
|
const el = innerRef.current;
|
|
17
15
|
const scroll = () => {
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
el.dataset.scrolledLeft = (el.scrollLeft > 0).toString();
|
|
17
|
+
el.dataset.scrolledRight = (el.scrollWidth - el.clientWidth > el.scrollLeft).toString();
|
|
20
18
|
};
|
|
21
19
|
scroll();
|
|
22
20
|
el.addEventListener('scroll', scroll);
|
|
21
|
+
const table = el.getElementsByTagName('table')[0];
|
|
22
|
+
const resizeObserver = new ResizeObserver(scroll);
|
|
23
|
+
resizeObserver.observe(el);
|
|
24
|
+
table && resizeObserver.observe(table);
|
|
23
25
|
return () => {
|
|
24
26
|
el.removeEventListener('scroll', scroll);
|
|
27
|
+
resizeObserver.disconnect();
|
|
25
28
|
};
|
|
26
29
|
}, []);
|
|
27
|
-
return ((0, jsx_runtime_1.jsx)(Component, { ...
|
|
30
|
+
return ((0, jsx_runtime_1.jsx)(Component, { ...(0, utils_1.mergeComponentProps)(props, {
|
|
31
|
+
ref: innerRef,
|
|
32
|
+
css: tableSticky_style_1.style,
|
|
33
|
+
className: table_style_1.classes.container
|
|
34
|
+
}) }));
|
|
28
35
|
});
|
|
29
36
|
function TdCell(props) {
|
|
30
37
|
return (0, jsx_runtime_1.jsx)("td", { ...useStickyCellProps(props) });
|
|
@@ -32,7 +39,7 @@ function TdCell(props) {
|
|
|
32
39
|
function ThCell(props) {
|
|
33
40
|
return (0, jsx_runtime_1.jsx)("th", { ...useStickyCellProps(props) });
|
|
34
41
|
}
|
|
35
|
-
function useStickyCellProps({
|
|
42
|
+
function useStickyCellProps({ sticky, ...props }) {
|
|
36
43
|
const innerRef = (0, react_1.useRef)(null);
|
|
37
44
|
const [offset, setOffset] = (0, react_1.useState)(0);
|
|
38
45
|
(0, react_1.useEffect)(() => {
|
|
@@ -62,15 +69,11 @@ function useStickyCellProps({ ref, sticky, ...props }) {
|
|
|
62
69
|
resizeObserver.disconnect();
|
|
63
70
|
};
|
|
64
71
|
});
|
|
65
|
-
return {
|
|
66
|
-
|
|
67
|
-
ref: (0, utils_1.cloneRef)(ref, innerRef),
|
|
72
|
+
return (0, utils_1.mergeComponentProps)(props, {
|
|
73
|
+
ref: innerRef,
|
|
68
74
|
css: tableSticky_style_1.style,
|
|
69
|
-
className:
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
...props.style
|
|
74
|
-
}
|
|
75
|
-
};
|
|
75
|
+
className: table_style_1.classes.cell,
|
|
76
|
+
style: sticky && { [sticky]: offset },
|
|
77
|
+
'data-sticky': sticky
|
|
78
|
+
});
|
|
76
79
|
}
|
|
@@ -6,14 +6,6 @@ const react_1 = require("@emotion/react");
|
|
|
6
6
|
exports.style = (0, utils_1.defineCss)(({ background, easing }) => (0, react_1.css) `
|
|
7
7
|
overflow: auto;
|
|
8
8
|
|
|
9
|
-
tbody tr {
|
|
10
|
-
&:not(:hover):not([data-selected=true]) {
|
|
11
|
-
th, td {
|
|
12
|
-
background-color: ${background.content};
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
9
|
th, td {
|
|
18
10
|
&[data-sticky=left], &[data-sticky=right] {
|
|
19
11
|
overflow: visible;
|
|
@@ -128,8 +128,8 @@ exports.defaultLightTheme = {
|
|
|
128
128
|
spacing: defaultSpacing,
|
|
129
129
|
gap: defaultSpacing[6],
|
|
130
130
|
gray,
|
|
131
|
-
/* divider: gray(.
|
|
132
|
-
divider: '#
|
|
131
|
+
/* divider: gray(.15), */
|
|
132
|
+
divider: '#d9d9d9',
|
|
133
133
|
colors: {
|
|
134
134
|
primary: '#1E71EC',
|
|
135
135
|
secondary: '#925CC1',
|
|
@@ -47,12 +47,14 @@ export declare function mergeDeep<T extends {}, U, V, W, X>(target: T, source: U
|
|
|
47
47
|
export declare function mergeDeep<T extends {}, U, V, W, X, Y>(target: T, source: U, source2: V, source3: W, source4: X, source5: Y): T & U & V & W & X & Y;
|
|
48
48
|
export declare function mergeDeep<T extends {}, U, V, W, X, Y, Z>(target: T, source: U, source2: V, source3: W, source4: X, source5: Y, source6: Z): T & U & V & W & X & Y & Z;
|
|
49
49
|
export declare function mergeDeep(target: object, ...sources: any[]): any;
|
|
50
|
+
export type OverflowEdge = 'top' | 'bottom' | 'left' | 'right';
|
|
50
51
|
/**
|
|
51
52
|
* 判断元素是否完全在目标容器内,用于Popper组件
|
|
52
|
-
* @param target
|
|
53
|
-
* @param container
|
|
53
|
+
* @param target 目标元素
|
|
54
|
+
* @param container 容器
|
|
55
|
+
* @returns 'top' | 'bottom' | 'left' | 'right' | false
|
|
54
56
|
*/
|
|
55
|
-
export declare function
|
|
57
|
+
export declare function isElementOverflowed(target: Element, container?: Element): OverflowEdge | false;
|
|
56
58
|
/**
|
|
57
59
|
* 下一个事件循环
|
|
58
60
|
* @param callback
|
package/dist/cjs/utils/utils.js
CHANGED
|
@@ -8,7 +8,7 @@ exports.toArray = toArray;
|
|
|
8
8
|
exports.isSelected = isSelected;
|
|
9
9
|
exports.cloneDeep = cloneDeep;
|
|
10
10
|
exports.mergeDeep = mergeDeep;
|
|
11
|
-
exports.
|
|
11
|
+
exports.isElementOverflowed = isElementOverflowed;
|
|
12
12
|
exports.nextTick = nextTick;
|
|
13
13
|
exports.cloneRef = cloneRef;
|
|
14
14
|
exports.isUnset = isUnset;
|
|
@@ -138,18 +138,33 @@ function mergeDeep(target, ...sources) {
|
|
|
138
138
|
}
|
|
139
139
|
/**
|
|
140
140
|
* 判断元素是否完全在目标容器内,用于Popper组件
|
|
141
|
-
* @param target
|
|
142
|
-
* @param container
|
|
141
|
+
* @param target 目标元素
|
|
142
|
+
* @param container 容器
|
|
143
|
+
* @returns 'top' | 'bottom' | 'left' | 'right' | false
|
|
143
144
|
*/
|
|
144
|
-
function
|
|
145
|
+
function isElementOverflowed(target, container) {
|
|
145
146
|
const { left, top, right, bottom } = target.getBoundingClientRect();
|
|
147
|
+
const judge = (containerBounding) => {
|
|
148
|
+
if (left < containerBounding.left) {
|
|
149
|
+
return 'left';
|
|
150
|
+
}
|
|
151
|
+
if (top < containerBounding.top) {
|
|
152
|
+
return 'top';
|
|
153
|
+
}
|
|
154
|
+
if (right > containerBounding.right) {
|
|
155
|
+
return 'right';
|
|
156
|
+
}
|
|
157
|
+
if (bottom > containerBounding.bottom) {
|
|
158
|
+
return 'bottom';
|
|
159
|
+
}
|
|
160
|
+
return false;
|
|
161
|
+
};
|
|
146
162
|
if (container) {
|
|
147
|
-
|
|
148
|
-
return left >= containerLeft && top >= containerTop && right <= containerRight && bottom <= containerBottom;
|
|
163
|
+
return judge(container.getBoundingClientRect());
|
|
149
164
|
}
|
|
150
165
|
const vWidth = window.innerWidth || document.documentElement.clientWidth;
|
|
151
166
|
const vHeight = window.innerHeight || document.documentElement.clientHeight;
|
|
152
|
-
return left
|
|
167
|
+
return judge({ left: 0, top: 0, right: vWidth, bottom: vHeight });
|
|
153
168
|
}
|
|
154
169
|
/**
|
|
155
170
|
* 下一个事件循环
|