@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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
2
2
|
import { useImperativeHandle, useRef } from 'react';
|
|
3
3
|
import { classes, useStyle } from './inputBase.style';
|
|
4
|
-
import { fixInputNumber, mergeComponentProps, useControlled } from '../../utils';
|
|
4
|
+
import { fixInputNumber, isUnset, mergeComponentProps, useControlled } from '../../utils';
|
|
5
5
|
import { useTheme } from '../theme';
|
|
6
6
|
import { Button } from '../button';
|
|
7
7
|
import { LoadingIndicator } from '../loadingIndicator';
|
|
@@ -53,6 +53,15 @@ min, max, step, precision, placeholder, disabled, readOnly, autoFocus, defaultVa
|
|
|
53
53
|
changeHandler(e);
|
|
54
54
|
}
|
|
55
55
|
};
|
|
56
|
+
const shouldRenderClearButton = () => {
|
|
57
|
+
if (!clearable || disabled || readOnly || isUnset(innerValue.current)) {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
if (Array.isArray(innerValue.current) || typeof innerValue.current === 'string') {
|
|
61
|
+
return !!innerValue.current.length;
|
|
62
|
+
}
|
|
63
|
+
return true;
|
|
64
|
+
};
|
|
56
65
|
return (_jsxs("div", { ...mergeComponentProps(props, {
|
|
57
66
|
ref: innerRef,
|
|
58
67
|
className: classes.root,
|
|
@@ -83,7 +92,7 @@ min, max, step, precision, placeholder, disabled, readOnly, autoFocus, defaultVa
|
|
|
83
92
|
onBlur: blurHandler,
|
|
84
93
|
onKeyDown: (e) => e.key === 'Enter' && blurHandler(e)
|
|
85
94
|
}) }), loading &&
|
|
86
|
-
_jsx(LoadingIndicator, {}),
|
|
95
|
+
_jsx(LoadingIndicator, {}), shouldRenderClearButton() &&
|
|
87
96
|
_jsx(Button, { className: classes.clear, variant: "plain", color: "text.disabled", onClick: clear, tabIndex: -1, children: _jsx(Icon, { icon: faCircleXmark }) }), !!suffix &&
|
|
88
97
|
_jsx("div", { className: classes.suffix, children: suffix })] }));
|
|
89
98
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
2
2
|
import { cloneElement, isValidElement, useCallback, useEffect, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState } from 'react';
|
|
3
3
|
import { createPortal } from 'react-dom';
|
|
4
|
-
import { clsx, cloneRef,
|
|
4
|
+
import { clsx, cloneRef, listenAllPredecessorsScroll, toArray, useControlled, useDerivedState, useForceUpdate, useSync, useSyncState, useUnmounted, useContainer, isElementOverflowed } from '../../utils';
|
|
5
5
|
import { ClickAway } from '../clickAway';
|
|
6
6
|
import { classes, style } from './popper.style';
|
|
7
7
|
import { PopperContext, usePopperContext } from './popperContext';
|
|
@@ -12,8 +12,8 @@ const getAttemptOrder = (placement) => {
|
|
|
12
12
|
if (index > -1) {
|
|
13
13
|
return [
|
|
14
14
|
placement,
|
|
15
|
-
...order.slice(0, index),
|
|
16
15
|
...order.slice(index + 1),
|
|
16
|
+
...order.slice(0, index),
|
|
17
17
|
placement
|
|
18
18
|
];
|
|
19
19
|
}
|
|
@@ -62,8 +62,8 @@ export function Popper({ ref, popperRef, anchorElement, container = document.bod
|
|
|
62
62
|
}
|
|
63
63
|
tellParentOpenChange(innerOpen.current);
|
|
64
64
|
}, [innerOpen.current]);
|
|
65
|
-
const onChildrenOpenChange = (
|
|
66
|
-
hold(
|
|
65
|
+
const onChildrenOpenChange = (childrenOpen) => {
|
|
66
|
+
hold(childrenOpen) === 0 && setInnerOpen(false);
|
|
67
67
|
};
|
|
68
68
|
const setOpenForce = (open) => {
|
|
69
69
|
if (!open) {
|
|
@@ -123,7 +123,7 @@ export function Popper({ ref, popperRef, anchorElement, container = document.bod
|
|
|
123
123
|
// 右键菜单
|
|
124
124
|
const mouseX = contextMenuEvent.current.clientX - containerRect.left;
|
|
125
125
|
const mouseY = contextMenuEvent.current.clientY - containerRect.top;
|
|
126
|
-
attempt =
|
|
126
|
+
attempt = placement => {
|
|
127
127
|
[, pA, pB] = placement.match(/^(top|bottom|left|right)(Top|Bottom|Left|Right)?/);
|
|
128
128
|
if (pB) {
|
|
129
129
|
switch (placement) {
|
|
@@ -187,7 +187,7 @@ export function Popper({ ref, popperRef, anchorElement, container = document.bod
|
|
|
187
187
|
}
|
|
188
188
|
popperEl.style.left = left + 'px';
|
|
189
189
|
popperEl.style.top = top + 'px';
|
|
190
|
-
return
|
|
190
|
+
return isElementOverflowed(popperEl, containerEl.current === document.body ? void 0 : containerEl.current);
|
|
191
191
|
};
|
|
192
192
|
}
|
|
193
193
|
else {
|
|
@@ -195,7 +195,7 @@ export function Popper({ ref, popperRef, anchorElement, container = document.bod
|
|
|
195
195
|
const anchorRect = getAnchorElement().getBoundingClientRect();
|
|
196
196
|
const topEdge = anchorRect.top - containerRect.top;
|
|
197
197
|
const leftEdge = anchorRect.left - containerRect.left;
|
|
198
|
-
attempt =
|
|
198
|
+
attempt = placement => {
|
|
199
199
|
[, pA, pB] = placement.match(/^(top|bottom|left|right)(Top|Bottom|Left|Right)?/);
|
|
200
200
|
if (sizeAdaptable) {
|
|
201
201
|
if (pA === 'top' || pA === 'bottom') {
|
|
@@ -258,7 +258,7 @@ export function Popper({ ref, popperRef, anchorElement, container = document.bod
|
|
|
258
258
|
}
|
|
259
259
|
popperEl.style.left = left + 'px';
|
|
260
260
|
popperEl.style.top = top + 'px';
|
|
261
|
-
return
|
|
261
|
+
return isElementOverflowed(popperEl, containerEl.current === document.body ? void 0 : containerEl.current);
|
|
262
262
|
};
|
|
263
263
|
}
|
|
264
264
|
if (options?.forcePlacement) {
|
|
@@ -267,7 +267,7 @@ export function Popper({ ref, popperRef, anchorElement, container = document.bod
|
|
|
267
267
|
else {
|
|
268
268
|
const attemptOrder = getAttemptOrder(placement);
|
|
269
269
|
for (let i = 0; i < attemptOrder.length; i++) {
|
|
270
|
-
if (attempt(attemptOrder[i])) {
|
|
270
|
+
if (attempt(attemptOrder[i]) === false) {
|
|
271
271
|
break;
|
|
272
272
|
}
|
|
273
273
|
}
|
|
@@ -292,8 +292,8 @@ export function Popper({ ref, popperRef, anchorElement, container = document.bod
|
|
|
292
292
|
popperEl.style.transform = variant === 'collapse'
|
|
293
293
|
? pA === 'top' || pA === 'bottom' ? 'scaleY(0)' : 'scaleX(0)'
|
|
294
294
|
: 'scale(0)';
|
|
295
|
+
animating.current = true;
|
|
295
296
|
requestAnimationFrame(() => {
|
|
296
|
-
animating.current = true;
|
|
297
297
|
settle();
|
|
298
298
|
setOpenNextFrame(true);
|
|
299
299
|
});
|
|
@@ -357,26 +357,26 @@ export function Popper({ ref, popperRef, anchorElement, container = document.bod
|
|
|
357
357
|
const hoverable = triggersSet.has('hover');
|
|
358
358
|
const enterTimeout = useRef(void 0);
|
|
359
359
|
const leaveTimeout = useRef(void 0);
|
|
360
|
-
const
|
|
360
|
+
const hoverStack = useRef(0);
|
|
361
361
|
const pointerEnter = () => {
|
|
362
|
-
if (
|
|
362
|
+
if (hoverStack.current++) {
|
|
363
363
|
return;
|
|
364
364
|
}
|
|
365
|
-
isEntered.current = true;
|
|
366
|
-
hold(true);
|
|
367
365
|
clearTimeout(leaveTimeout.current);
|
|
368
366
|
mouseEnterDelay
|
|
369
367
|
? enterTimeout.current = setTimeout(() => setInnerOpen(true), mouseEnterDelay)
|
|
370
368
|
: setInnerOpen(true);
|
|
371
369
|
};
|
|
372
370
|
const pointerLeave = () => {
|
|
373
|
-
|
|
374
|
-
|
|
371
|
+
if (--hoverStack.current) {
|
|
372
|
+
return;
|
|
373
|
+
}
|
|
375
374
|
clearTimeout(enterTimeout.current);
|
|
376
375
|
mouseLeaveDelay
|
|
377
376
|
? leaveTimeout.current = setTimeout(() => setInnerOpen(false), mouseLeaveDelay)
|
|
378
377
|
: setInnerOpen(false);
|
|
379
378
|
};
|
|
379
|
+
// 绑定锚点元素
|
|
380
380
|
useEffect(() => {
|
|
381
381
|
if (!hoverable) {
|
|
382
382
|
return;
|
|
@@ -389,6 +389,7 @@ export function Popper({ ref, popperRef, anchorElement, container = document.bod
|
|
|
389
389
|
anchorEl.removeEventListener('pointerleave', pointerLeave);
|
|
390
390
|
};
|
|
391
391
|
}, [hoverable]);
|
|
392
|
+
// 绑定弹框元素,鼠标移入弹框也要保持弹框打开
|
|
392
393
|
useEffect(() => {
|
|
393
394
|
if (!hoverable || !innerPopperRef.current) {
|
|
394
395
|
return;
|
|
@@ -428,7 +429,9 @@ export function Popper({ ref, popperRef, anchorElement, container = document.bod
|
|
|
428
429
|
return;
|
|
429
430
|
}
|
|
430
431
|
const keyDown = (e) => {
|
|
431
|
-
e.key === 'Enter'
|
|
432
|
+
if (e.key === 'Enter') {
|
|
433
|
+
openAndHold(true);
|
|
434
|
+
}
|
|
432
435
|
};
|
|
433
436
|
const anchorEl = anchorRef.current;
|
|
434
437
|
anchorEl.addEventListener('keydown', keyDown);
|
|
@@ -444,9 +447,7 @@ export function Popper({ ref, popperRef, anchorElement, container = document.bod
|
|
|
444
447
|
if (!clickable) {
|
|
445
448
|
return;
|
|
446
449
|
}
|
|
447
|
-
const click = () =>
|
|
448
|
-
openAndHold(true);
|
|
449
|
-
};
|
|
450
|
+
const click = () => openAndHold(true);
|
|
450
451
|
const anchorEl = anchorRef.current;
|
|
451
452
|
anchorEl.addEventListener('click', click);
|
|
452
453
|
return () => {
|
|
@@ -454,7 +455,7 @@ export function Popper({ ref, popperRef, anchorElement, container = document.bod
|
|
|
454
455
|
};
|
|
455
456
|
}, []);
|
|
456
457
|
const onClickAway = () => {
|
|
457
|
-
innerOpen.current &&
|
|
458
|
+
innerOpen.current && setOpenForce(false);
|
|
458
459
|
};
|
|
459
460
|
/**
|
|
460
461
|
* 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;
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { useRef } from 'react';
|
|
2
3
|
import { classes, style } from './table.style';
|
|
3
|
-
import { clsx } from '../../utils';
|
|
4
|
+
import { cloneRef, clsx } from '../../utils';
|
|
4
5
|
import { useTheme } from '../theme';
|
|
5
6
|
import { TdCell, ThCell } from './tableSticky';
|
|
6
7
|
export function Table({ size, bordered = 'none', striped = false, ...props }) {
|
|
7
8
|
const theme = useTheme();
|
|
8
9
|
size ??= theme.size;
|
|
9
|
-
|
|
10
|
+
const tableRef = useRef(null);
|
|
11
|
+
return (_jsx("table", { ...props, css: style, ref: cloneRef(props.ref, tableRef), className: clsx(classes.root, props.className), "data-size": size, "data-bordered": bordered, "data-striped": striped }));
|
|
10
12
|
}
|
|
11
13
|
export function TableRow({ selected, ...props }) {
|
|
12
14
|
return _jsx("tr", { ...props, "data-selected": selected });
|
|
@@ -5,9 +5,9 @@ export const classes = defineInnerClasses('table', [
|
|
|
5
5
|
'container',
|
|
6
6
|
'cell'
|
|
7
7
|
]);
|
|
8
|
-
export const style = defineCss(({ mode, spacing, gray, divider, easing, colors }) => {
|
|
9
|
-
const headerBg = gray(mode === 'light' ? .
|
|
10
|
-
const stripedBg = gray(mode === 'light' ? .
|
|
8
|
+
export const style = defineCss(({ mode, spacing, gray, divider, background, easing, colors }) => {
|
|
9
|
+
const headerBg = gray(mode === 'light' ? .03 : .22);
|
|
10
|
+
const stripedBg = gray(mode === 'light' ? .02 : .21);
|
|
11
11
|
const selectedBg = Color(colors.primary.main).alpha(mode === 'light' ? .05 : .1).string();
|
|
12
12
|
return css `
|
|
13
13
|
width: 100%;
|
|
@@ -34,6 +34,14 @@ export const style = defineCss(({ mode, spacing, gray, divider, easing, colors }
|
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
+
tbody tr {
|
|
38
|
+
&:not(:hover):not([data-selected=true]) {
|
|
39
|
+
th, td {
|
|
40
|
+
background-color: ${background.content};
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
37
45
|
th, td {
|
|
38
46
|
position: relative;
|
|
39
47
|
text-align: left;
|
|
@@ -55,11 +63,18 @@ export const style = defineCss(({ mode, spacing, gray, divider, easing, colors }
|
|
|
55
63
|
}
|
|
56
64
|
|
|
57
65
|
&[data-bordered=all], &[data-bordered=true] {
|
|
58
|
-
border-top: 1px solid ${divider};
|
|
59
|
-
border-left: 1px solid ${divider};
|
|
60
|
-
|
|
61
66
|
th, td {
|
|
62
67
|
border-right: 1px solid ${divider};
|
|
68
|
+
|
|
69
|
+
&:first-of-type {
|
|
70
|
+
border-left: 1px solid ${divider};
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
thead tr:first-of-type {
|
|
75
|
+
th, td {
|
|
76
|
+
border-top: 1px solid ${divider};
|
|
77
|
+
}
|
|
63
78
|
}
|
|
64
79
|
}
|
|
65
80
|
|
|
@@ -1,25 +1,32 @@
|
|
|
1
1
|
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
2
2
|
import { useEffect, useRef, useState } from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import { mergeComponentProps } from '../../utils';
|
|
4
4
|
import { classes } from './table.style';
|
|
5
5
|
import { style } from './tableSticky.style';
|
|
6
6
|
export const TableContainer = (({ component: Component = 'div', ...props }) => {
|
|
7
|
-
const [scrolledLeft, setScrolledLeft] = useState(false);
|
|
8
|
-
const [scrolledRight, setScrolledRight] = useState(false);
|
|
9
7
|
const innerRef = useRef(null);
|
|
10
8
|
useEffect(() => {
|
|
11
9
|
const el = innerRef.current;
|
|
12
10
|
const scroll = () => {
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
el.dataset.scrolledLeft = (el.scrollLeft > 0).toString();
|
|
12
|
+
el.dataset.scrolledRight = (el.scrollWidth - el.clientWidth > el.scrollLeft).toString();
|
|
15
13
|
};
|
|
16
14
|
scroll();
|
|
17
15
|
el.addEventListener('scroll', scroll);
|
|
16
|
+
const table = el.getElementsByTagName('table')[0];
|
|
17
|
+
const resizeObserver = new ResizeObserver(scroll);
|
|
18
|
+
resizeObserver.observe(el);
|
|
19
|
+
table && resizeObserver.observe(table);
|
|
18
20
|
return () => {
|
|
19
21
|
el.removeEventListener('scroll', scroll);
|
|
22
|
+
resizeObserver.disconnect();
|
|
20
23
|
};
|
|
21
24
|
}, []);
|
|
22
|
-
return (_jsx(Component, { ...
|
|
25
|
+
return (_jsx(Component, { ...mergeComponentProps(props, {
|
|
26
|
+
ref: innerRef,
|
|
27
|
+
css: style,
|
|
28
|
+
className: classes.container
|
|
29
|
+
}) }));
|
|
23
30
|
});
|
|
24
31
|
export function TdCell(props) {
|
|
25
32
|
return _jsx("td", { ...useStickyCellProps(props) });
|
|
@@ -27,7 +34,7 @@ export function TdCell(props) {
|
|
|
27
34
|
export function ThCell(props) {
|
|
28
35
|
return _jsx("th", { ...useStickyCellProps(props) });
|
|
29
36
|
}
|
|
30
|
-
function useStickyCellProps({
|
|
37
|
+
function useStickyCellProps({ sticky, ...props }) {
|
|
31
38
|
const innerRef = useRef(null);
|
|
32
39
|
const [offset, setOffset] = useState(0);
|
|
33
40
|
useEffect(() => {
|
|
@@ -57,15 +64,11 @@ function useStickyCellProps({ ref, sticky, ...props }) {
|
|
|
57
64
|
resizeObserver.disconnect();
|
|
58
65
|
};
|
|
59
66
|
});
|
|
60
|
-
return {
|
|
61
|
-
|
|
62
|
-
ref: cloneRef(ref, innerRef),
|
|
67
|
+
return mergeComponentProps(props, {
|
|
68
|
+
ref: innerRef,
|
|
63
69
|
css: style,
|
|
64
|
-
className:
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
...props.style
|
|
69
|
-
}
|
|
70
|
-
};
|
|
70
|
+
className: classes.cell,
|
|
71
|
+
style: sticky && { [sticky]: offset },
|
|
72
|
+
'data-sticky': sticky
|
|
73
|
+
});
|
|
71
74
|
}
|
|
@@ -3,14 +3,6 @@ import { css } from '@emotion/react';
|
|
|
3
3
|
export const style = defineCss(({ background, easing }) => css `
|
|
4
4
|
overflow: auto;
|
|
5
5
|
|
|
6
|
-
tbody tr {
|
|
7
|
-
&:not(:hover):not([data-selected=true]) {
|
|
8
|
-
th, td {
|
|
9
|
-
background-color: ${background.content};
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
|
|
14
6
|
th, td {
|
|
15
7
|
&[data-sticky=left], &[data-sticky=right] {
|
|
16
8
|
overflow: visible;
|
|
@@ -122,8 +122,8 @@ export const defaultLightTheme = {
|
|
|
122
122
|
spacing: defaultSpacing,
|
|
123
123
|
gap: defaultSpacing[6],
|
|
124
124
|
gray,
|
|
125
|
-
/* divider: gray(.
|
|
126
|
-
divider: '#
|
|
125
|
+
/* divider: gray(.15), */
|
|
126
|
+
divider: '#d9d9d9',
|
|
127
127
|
colors: {
|
|
128
128
|
primary: '#1E71EC',
|
|
129
129
|
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/esm/utils/utils.js
CHANGED
|
@@ -113,18 +113,33 @@ export function mergeDeep(target, ...sources) {
|
|
|
113
113
|
}
|
|
114
114
|
/**
|
|
115
115
|
* 判断元素是否完全在目标容器内,用于Popper组件
|
|
116
|
-
* @param target
|
|
117
|
-
* @param container
|
|
116
|
+
* @param target 目标元素
|
|
117
|
+
* @param container 容器
|
|
118
|
+
* @returns 'top' | 'bottom' | 'left' | 'right' | false
|
|
118
119
|
*/
|
|
119
|
-
export function
|
|
120
|
+
export function isElementOverflowed(target, container) {
|
|
120
121
|
const { left, top, right, bottom } = target.getBoundingClientRect();
|
|
122
|
+
const judge = (containerBounding) => {
|
|
123
|
+
if (left < containerBounding.left) {
|
|
124
|
+
return 'left';
|
|
125
|
+
}
|
|
126
|
+
if (top < containerBounding.top) {
|
|
127
|
+
return 'top';
|
|
128
|
+
}
|
|
129
|
+
if (right > containerBounding.right) {
|
|
130
|
+
return 'right';
|
|
131
|
+
}
|
|
132
|
+
if (bottom > containerBounding.bottom) {
|
|
133
|
+
return 'bottom';
|
|
134
|
+
}
|
|
135
|
+
return false;
|
|
136
|
+
};
|
|
121
137
|
if (container) {
|
|
122
|
-
|
|
123
|
-
return left >= containerLeft && top >= containerTop && right <= containerRight && bottom <= containerBottom;
|
|
138
|
+
return judge(container.getBoundingClientRect());
|
|
124
139
|
}
|
|
125
140
|
const vWidth = window.innerWidth || document.documentElement.clientWidth;
|
|
126
141
|
const vHeight = window.innerHeight || document.documentElement.clientHeight;
|
|
127
|
-
return left
|
|
142
|
+
return judge({ left: 0, top: 0, right: vWidth, bottom: vHeight });
|
|
128
143
|
}
|
|
129
144
|
/**
|
|
130
145
|
* 下一个事件循环
|