@laser-ui/components 1.0.2 → 1.1.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/CHANGELOG.md +12 -0
- package/affix/Affix.js +3 -5
- package/anchor/Anchor.js +2 -3
- package/cascader/Cascader.js +4 -5
- package/context/index.d.ts +0 -2
- package/context/index.js +0 -9
- package/date-picker/DatePicker.js +4 -5
- package/dropdown/Dropdown.js +9 -10
- package/dropdown/internal/DropdownSub.js +2 -2
- package/fab/FabBacktop.js +2 -3
- package/hooks/index.d.ts +1 -1
- package/hooks/index.js +1 -1
- package/hooks/useContainerScrolling.d.ts +2 -0
- package/hooks/useContainerScrolling.js +17 -0
- package/internal/popup/Popup.js +4 -20
- package/internal/popup/types.d.ts +1 -1
- package/menu/Menu.js +15 -11
- package/menu/internal/MenuSub.js +2 -2
- package/package.json +2 -2
- package/popover/Popover.js +1 -3
- package/popover/types.d.ts +0 -2
- package/select/Select.js +4 -5
- package/table/TableFilter.js +2 -2
- package/table/types.d.ts +0 -2
- package/time-picker/TimePicker.js +4 -5
- package/tooltip/Tooltip.js +1 -3
- package/tooltip/types.d.ts +0 -2
- package/tree-select/TreeSelect.js +4 -5
- package/hooks/useListenGlobalScrolling.d.ts +0 -1
- package/hooks/useListenGlobalScrolling.js +0 -9
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
## [1.1.1](https://github.com/laser-ui/laser-ui/compare/v1.1.0...v1.1.1) (2024-08-30)
|
|
6
|
+
|
|
7
|
+
### Bug Fixes
|
|
8
|
+
|
|
9
|
+
- fix automatically update when nested ([d1c0b46](https://github.com/laser-ui/laser-ui/commit/d1c0b4645965e31b382058b60b2569b253c162e5))
|
|
10
|
+
|
|
11
|
+
# [1.1.0](https://github.com/laser-ui/laser-ui/compare/v1.0.2...v1.1.0) (2024-08-30)
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
|
|
15
|
+
- automatically update when scrolling ([9030e9e](https://github.com/laser-ui/laser-ui/commit/9030e9e1fa1739bb84f426004eefa6e00d6f2773))
|
|
16
|
+
|
|
5
17
|
## [1.0.2](https://github.com/laser-ui/laser-ui/compare/v1.0.1...v1.0.2) (2024-07-20)
|
|
6
18
|
|
|
7
19
|
### Bug Fixes
|
package/affix/Affix.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { useEventCallback, useMount, useRefExtra, useResize } from '@laser-ui/hooks';
|
|
3
3
|
import { getOffsetToRoot, toPx } from '@laser-ui/utils';
|
|
4
4
|
import { isFunction, isString, isUndefined } from 'lodash';
|
|
5
5
|
import { cloneElement, forwardRef, useId, useImperativeHandle, useState } from 'react';
|
|
6
|
-
import { useComponentProps, useJSS, useLayout,
|
|
6
|
+
import { useComponentProps, useContainerScrolling, useJSS, useLayout, useNamespace } from '../hooks';
|
|
7
7
|
export const Affix = forwardRef((props, ref) => {
|
|
8
8
|
const { children, top = 0, target, zIndex } = useComponentProps('Affix', props);
|
|
9
9
|
const namespace = useNamespace();
|
|
@@ -46,9 +46,7 @@ export const Affix = forwardRef((props, ref) => {
|
|
|
46
46
|
useMount(() => {
|
|
47
47
|
updatePosition();
|
|
48
48
|
});
|
|
49
|
-
|
|
50
|
-
useEvent(pageScrollRef, 'scroll', updatePosition, { passive: true }, listenGlobalScrolling);
|
|
51
|
-
useEvent(targetRef, 'scroll', updatePosition, { passive: true }, listenGlobalScrolling || isUndefined(target));
|
|
49
|
+
useContainerScrolling(affixRef, updatePosition);
|
|
52
50
|
useResize(sticky ? placeholderRef : affixRef, updatePosition);
|
|
53
51
|
useResize(contentResizeRef, updatePosition);
|
|
54
52
|
useImperativeHandle(ref, () => ({
|
package/anchor/Anchor.js
CHANGED
|
@@ -5,7 +5,7 @@ import { getOffsetToRoot, scrollTo, toPx } from '@laser-ui/utils';
|
|
|
5
5
|
import { isArray, isString, isUndefined } from 'lodash';
|
|
6
6
|
import { Fragment, forwardRef, useImperativeHandle, useRef, useState } from 'react';
|
|
7
7
|
import { CLASSES, DOT_INDICATOR, LINE_INDICATOR } from './vars';
|
|
8
|
-
import { useComponentProps, useLayout,
|
|
8
|
+
import { useComponentProps, useLayout, useStyled } from '../hooks';
|
|
9
9
|
import { mergeCS } from '../utils';
|
|
10
10
|
function AnchorFC(props, ref) {
|
|
11
11
|
const _a = useComponentProps('Anchor', props), { styleOverrides, styleProvider, list, page, distance: distanceProp = 0, scrollBehavior = 'instant', indicator = DOT_INDICATOR, onClick } = _a, restProps = __rest(_a, ["styleOverrides", "styleProvider", "list", "page", "distance", "scrollBehavior", "indicator", "onClick"]);
|
|
@@ -56,8 +56,7 @@ function AnchorFC(props, ref) {
|
|
|
56
56
|
useMount(() => {
|
|
57
57
|
updateAnchor();
|
|
58
58
|
});
|
|
59
|
-
|
|
60
|
-
useEvent(pageRef, 'scroll', updateAnchor, { passive: true }, listenGlobalScrolling);
|
|
59
|
+
useEvent(pageRef, 'scroll', updateAnchor, { passive: true });
|
|
61
60
|
useResize(contentResizeRef, updateAnchor);
|
|
62
61
|
useImperativeHandle(ref, () => ({
|
|
63
62
|
active,
|
package/cascader/Cascader.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
-
import {
|
|
3
|
+
import { useEventCallback, useForkRef, useResize } from '@laser-ui/hooks';
|
|
4
4
|
import { findNested } from '@laser-ui/utils';
|
|
5
5
|
import CancelFilled from '@material-design-icons/svg/filled/cancel.svg?react';
|
|
6
6
|
import CloseOutlined from '@material-design-icons/svg/outlined/close.svg?react';
|
|
@@ -13,7 +13,7 @@ import { CascaderSearchPanel } from './internal/CascaderSearchPanel';
|
|
|
13
13
|
import { CLASSES } from './vars';
|
|
14
14
|
import { BaseInput } from '../base-input';
|
|
15
15
|
import { Dropdown } from '../dropdown';
|
|
16
|
-
import { useComponentProps, useControlled, useDesign, useFocusVisible, useJSS, useLayout,
|
|
16
|
+
import { useComponentProps, useContainerScrolling, useControlled, useDesign, useFocusVisible, useJSS, useLayout, useMaxIndex, useNamespace, useScopedProps, useStyled, useTranslation, } from '../hooks';
|
|
17
17
|
import { Icon } from '../icon';
|
|
18
18
|
import { CircularProgress } from '../internal/circular-progress';
|
|
19
19
|
import { Portal } from '../internal/portal';
|
|
@@ -35,7 +35,7 @@ function CascaderFC(props, ref) {
|
|
|
35
35
|
const uniqueId = useId();
|
|
36
36
|
const listId = `${namespace}-cascader-list-${uniqueId}`;
|
|
37
37
|
const getItemId = (val) => `${namespace}-cascader-item-${val}-${uniqueId}`;
|
|
38
|
-
const {
|
|
38
|
+
const { contentResizeRef } = useLayout();
|
|
39
39
|
const boxRef = useRef(null);
|
|
40
40
|
const popupRef = useRef(null);
|
|
41
41
|
const inputRef = useRef(null);
|
|
@@ -202,8 +202,7 @@ function CascaderFC(props, ref) {
|
|
|
202
202
|
popupRef.current.classList.toggle(sheet.classes.position, true);
|
|
203
203
|
}
|
|
204
204
|
});
|
|
205
|
-
|
|
206
|
-
useEvent(pageScrollRef, 'scroll', updatePosition, { passive: true }, !visible || listenGlobalScrolling);
|
|
205
|
+
useContainerScrolling(boxRef, updatePosition, !visible);
|
|
207
206
|
useResize(boxRef, updatePosition, undefined, !visible);
|
|
208
207
|
useResize(popupRef, updatePosition, undefined, !visible);
|
|
209
208
|
useResize(contentResizeRef, updatePosition, undefined, !visible);
|
package/context/index.d.ts
CHANGED
|
@@ -11,7 +11,6 @@ interface LContextData {
|
|
|
11
11
|
};
|
|
12
12
|
layoutPageScrollEl: RefExtra | null;
|
|
13
13
|
layoutContentResizeEl: RefExtra | null;
|
|
14
|
-
listenGlobalScrolling: boolean;
|
|
15
14
|
}
|
|
16
15
|
export type LContextIn = Partial<LContextData>;
|
|
17
16
|
export declare class LContextManager {
|
|
@@ -21,7 +20,6 @@ export declare class LContextManager {
|
|
|
21
20
|
componentDefaultProps: LContextData['componentDefaultProps'];
|
|
22
21
|
layoutPageScrollEl: LContextData['layoutPageScrollEl'];
|
|
23
22
|
layoutContentResizeEl: LContextData['layoutContentResizeEl'];
|
|
24
|
-
listenGlobalScrolling: LContextData['listenGlobalScrolling'];
|
|
25
23
|
private _parent;
|
|
26
24
|
get parent(): LContextManager | null;
|
|
27
25
|
get root(): LContextManager;
|
package/context/index.js
CHANGED
|
@@ -49,12 +49,6 @@ export class LContextManager {
|
|
|
49
49
|
writable: true,
|
|
50
50
|
value: void 0
|
|
51
51
|
});
|
|
52
|
-
Object.defineProperty(this, "listenGlobalScrolling", {
|
|
53
|
-
enumerable: true,
|
|
54
|
-
configurable: true,
|
|
55
|
-
writable: true,
|
|
56
|
-
value: void 0
|
|
57
|
-
});
|
|
58
52
|
Object.defineProperty(this, "_parent", {
|
|
59
53
|
enumerable: true,
|
|
60
54
|
configurable: true,
|
|
@@ -67,7 +61,6 @@ export class LContextManager {
|
|
|
67
61
|
this.componentDefaultProps = context.componentDefaultProps;
|
|
68
62
|
this.layoutPageScrollEl = context.layoutPageScrollEl;
|
|
69
63
|
this.layoutContentResizeEl = context.layoutContentResizeEl;
|
|
70
|
-
this.listenGlobalScrolling = context.listenGlobalScrolling;
|
|
71
64
|
}
|
|
72
65
|
setParent(parent) {
|
|
73
66
|
this._parent = parent;
|
|
@@ -80,7 +73,6 @@ export class LContextManager {
|
|
|
80
73
|
componentDefaultProps: Object.assign({}, this.componentDefaultProps),
|
|
81
74
|
layoutPageScrollEl: this.layoutPageScrollEl,
|
|
82
75
|
layoutContentResizeEl: this.layoutContentResizeEl,
|
|
83
|
-
listenGlobalScrolling: this.listenGlobalScrolling,
|
|
84
76
|
};
|
|
85
77
|
Object.keys(context).forEach((key) => {
|
|
86
78
|
if (!isUndefined(context[key])) {
|
|
@@ -102,5 +94,4 @@ export const LContext = createContext(new LContextManager({
|
|
|
102
94
|
componentDefaultProps: {},
|
|
103
95
|
layoutPageScrollEl: ':root',
|
|
104
96
|
layoutContentResizeEl: null,
|
|
105
|
-
listenGlobalScrolling: false,
|
|
106
97
|
}));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
2
|
import { createElement as _createElement } from "react";
|
|
3
3
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
4
|
-
import { useAsync,
|
|
4
|
+
import { useAsync, useEventCallback, useForceUpdate, useForkRef, useImmer, useResize } from '@laser-ui/hooks';
|
|
5
5
|
import CancelFilled from '@material-design-icons/svg/filled/cancel.svg?react';
|
|
6
6
|
import CalendarTodayOutlined from '@material-design-icons/svg/outlined/calendar_today.svg?react';
|
|
7
7
|
import SwapHorizOutlined from '@material-design-icons/svg/outlined/swap_horiz.svg?react';
|
|
@@ -12,7 +12,7 @@ import { CLASSES } from './vars';
|
|
|
12
12
|
import { BaseInput } from '../base-input';
|
|
13
13
|
import { Button } from '../button';
|
|
14
14
|
import dayjs from '../dayjs';
|
|
15
|
-
import { useComponentProps, useControlled, useDesign, useJSS, useLayout,
|
|
15
|
+
import { useComponentProps, useContainerScrolling, useControlled, useDesign, useJSS, useLayout, useMaxIndex, useNamespace, useScopedProps, useStyled, useTranslation, } from '../hooks';
|
|
16
16
|
import { Icon } from '../icon';
|
|
17
17
|
import { Portal } from '../internal/portal';
|
|
18
18
|
import { Transition } from '../internal/transition';
|
|
@@ -34,7 +34,7 @@ export const DatePicker = forwardRef((props, ref) => {
|
|
|
34
34
|
const { t } = useTranslation();
|
|
35
35
|
const forceUpdate = useForceUpdate();
|
|
36
36
|
const async = useAsync();
|
|
37
|
-
const {
|
|
37
|
+
const { contentResizeRef } = useLayout();
|
|
38
38
|
const boxRef = useRef(null);
|
|
39
39
|
const popupRef = useRef(null);
|
|
40
40
|
const inputLeftRef = useRef(null);
|
|
@@ -141,8 +141,7 @@ export const DatePicker = forwardRef((props, ref) => {
|
|
|
141
141
|
popupRef.current.classList.toggle(sheet.classes.position, true);
|
|
142
142
|
}
|
|
143
143
|
});
|
|
144
|
-
|
|
145
|
-
useEvent(pageScrollRef, 'scroll', updatePosition, { passive: true }, !visible || listenGlobalScrolling);
|
|
144
|
+
useContainerScrolling(boxRef, updatePosition, !visible);
|
|
146
145
|
useResize(boxRef, updatePosition, undefined, !visible);
|
|
147
146
|
useResize(popupRef, updatePosition, undefined, !visible);
|
|
148
147
|
useResize(contentResizeRef, updatePosition, undefined, !visible);
|
package/dropdown/Dropdown.js
CHANGED
|
@@ -9,7 +9,7 @@ import { DropdownItem as DropdownItemFC } from './internal/DropdownItem';
|
|
|
9
9
|
import { DropdownSub } from './internal/DropdownSub';
|
|
10
10
|
import { checkEnableItem, getSameLevelEnableItems } from './utils';
|
|
11
11
|
import { CLASSES } from './vars';
|
|
12
|
-
import { useComponentProps, useControlled, useFocusVisible, useJSS, useMaxIndex, useNamespace, useNestedPopup, useStyled, useTranslation, } from '../hooks';
|
|
12
|
+
import { useComponentProps, useContainerScrolling, useControlled, useFocusVisible, useJSS, useMaxIndex, useNamespace, useNestedPopup, useStyled, useTranslation, } from '../hooks';
|
|
13
13
|
import { Popup } from '../internal/popup';
|
|
14
14
|
import { Portal } from '../internal/portal';
|
|
15
15
|
import { Transition } from '../internal/transition';
|
|
@@ -254,19 +254,18 @@ function DropdownFC(props, ref) {
|
|
|
254
254
|
});
|
|
255
255
|
return getNodes(list, 0, []);
|
|
256
256
|
})();
|
|
257
|
-
|
|
258
|
-
updatePosition
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
}), [
|
|
257
|
+
const updateAllPosition = useEventCallback(() => {
|
|
258
|
+
updatePosition();
|
|
259
|
+
for (const fn of dataRef.current.updatePosition.values()) {
|
|
260
|
+
fn();
|
|
261
|
+
}
|
|
262
|
+
});
|
|
263
|
+
useContainerScrolling(triggerRef, updateAllPosition, !visible);
|
|
264
|
+
useImperativeHandle(ref, () => ({ updatePosition: updateAllPosition }), [updateAllPosition]);
|
|
265
265
|
return (_jsx(Popup, { visible: visible, trigger: trigger, updatePosition: {
|
|
266
266
|
fn: updatePosition,
|
|
267
267
|
triggerRef,
|
|
268
268
|
popupRef,
|
|
269
|
-
containerRefs: [],
|
|
270
269
|
}, onVisibleChange: changeVisible, children: ({ renderTrigger, renderPopup }) => {
|
|
271
270
|
const render = (el) => {
|
|
272
271
|
var _a, _b;
|
|
@@ -20,7 +20,7 @@ export const DropdownSub = forwardRef((props, ref) => {
|
|
|
20
20
|
const visible = !isUndefined(popupState);
|
|
21
21
|
const transformOrigin = useRef();
|
|
22
22
|
const updatePosition = useEventCallback(() => {
|
|
23
|
-
if (visible && popupRef.current && triggerRef.current) {
|
|
23
|
+
if (!disabled && visible && popupRef.current && triggerRef.current) {
|
|
24
24
|
const [width, height] = [popupRef.current.offsetWidth, popupRef.current.offsetHeight];
|
|
25
25
|
const position = getHorizontalSidePosition(triggerRef.current, { width, height }, {
|
|
26
26
|
placement: 'right',
|
|
@@ -42,7 +42,7 @@ export const DropdownSub = forwardRef((props, ref) => {
|
|
|
42
42
|
fn: updatePosition,
|
|
43
43
|
triggerRef,
|
|
44
44
|
popupRef,
|
|
45
|
-
|
|
45
|
+
scroll: false,
|
|
46
46
|
}, onVisibleChange: onVisibleChange, children: ({ renderTrigger, renderPopup }) => (_jsxs(_Fragment, { children: [renderTrigger(_jsxs("li", Object.assign({}, mergeCS(styled('dropdown__item', 'dropdown__item--sub', {
|
|
47
47
|
'dropdown__item.is-expand': visible,
|
|
48
48
|
'dropdown__item.is-disabled': disabled,
|
package/fab/FabBacktop.js
CHANGED
|
@@ -6,7 +6,7 @@ import VerticalAlignTopOutlined from '@material-design-icons/svg/outlined/vertic
|
|
|
6
6
|
import { isString } from 'lodash';
|
|
7
7
|
import { cloneElement, useRef, useState } from 'react';
|
|
8
8
|
import { FabButton } from './FabButton';
|
|
9
|
-
import { useComponentProps, useLayout
|
|
9
|
+
import { useComponentProps, useLayout } from '../hooks';
|
|
10
10
|
import { Icon } from '../icon';
|
|
11
11
|
import { Transition } from '../internal/transition';
|
|
12
12
|
import { TTANSITION_DURING_BASE } from '../vars';
|
|
@@ -37,8 +37,7 @@ export function FabBacktop(props) {
|
|
|
37
37
|
updateBackTop();
|
|
38
38
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
39
39
|
}, []);
|
|
40
|
-
|
|
41
|
-
useEvent(pageRef, 'scroll', updateBackTop, { passive: true }, listenGlobalScrolling);
|
|
40
|
+
useEvent(pageRef, 'scroll', updateBackTop, { passive: true });
|
|
42
41
|
useResize(contentResizeRef, updateBackTop);
|
|
43
42
|
const node = (_jsx(FabButton, Object.assign({}, restProps, { children: children !== null && children !== void 0 ? children : (_jsx(Icon, { children: _jsx(VerticalAlignTopOutlined, {}) })) })));
|
|
44
43
|
return (_jsx(Transition, { enter: visible, during: TTANSITION_DURING_BASE, children: (state) => cloneElement(node, {
|
package/hooks/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
export { useComponentProps } from './useComponentProps';
|
|
2
|
+
export { useContainerScrolling } from './useContainerScrolling';
|
|
2
3
|
export { useControlled } from './useControlled';
|
|
3
4
|
export { useDesign } from './useDesign';
|
|
4
5
|
export { useDialogService } from './useDialogService';
|
|
5
6
|
export { useFocusVisible } from './useFocusVisible';
|
|
6
7
|
export { useJSS } from './useJSS';
|
|
7
8
|
export { useLayout } from './useLayout';
|
|
8
|
-
export { useListenGlobalScrolling } from './useListenGlobalScrolling';
|
|
9
9
|
export { useLockScroll } from './useLockScroll';
|
|
10
10
|
export { useMaxIndex } from './useMaxIndex';
|
|
11
11
|
export { useNamespace } from './useNamespace';
|
package/hooks/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
export { useComponentProps } from './useComponentProps';
|
|
2
|
+
export { useContainerScrolling } from './useContainerScrolling';
|
|
2
3
|
export { useControlled } from './useControlled';
|
|
3
4
|
export { useDesign } from './useDesign';
|
|
4
5
|
export { useDialogService } from './useDialogService';
|
|
5
6
|
export { useFocusVisible } from './useFocusVisible';
|
|
6
7
|
export { useJSS } from './useJSS';
|
|
7
8
|
export { useLayout } from './useLayout';
|
|
8
|
-
export { useListenGlobalScrolling } from './useListenGlobalScrolling';
|
|
9
9
|
export { useLockScroll } from './useLockScroll';
|
|
10
10
|
export { useMaxIndex } from './useMaxIndex';
|
|
11
11
|
export { useNamespace } from './useNamespace';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { useScroll } from '@laser-ui/hooks';
|
|
2
|
+
import { useEffect, useRef } from 'react';
|
|
3
|
+
export function useContainerScrolling(target, callback, disabled = false) {
|
|
4
|
+
const parentElements = useRef(new WeakSet());
|
|
5
|
+
useEffect(() => {
|
|
6
|
+
let el = target.current;
|
|
7
|
+
while (el) {
|
|
8
|
+
parentElements.current.add(el);
|
|
9
|
+
el = el.parentElement;
|
|
10
|
+
}
|
|
11
|
+
}, []);
|
|
12
|
+
useScroll(false, (e) => {
|
|
13
|
+
if (parentElements.current.has(e.target)) {
|
|
14
|
+
callback === null || callback === void 0 ? void 0 : callback();
|
|
15
|
+
}
|
|
16
|
+
}, disabled);
|
|
17
|
+
}
|
package/internal/popup/Popup.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { useAsync, useEvent, useRefExtra, useResize } from '@laser-ui/hooks';
|
|
2
2
|
import { isUndefined } from 'lodash';
|
|
3
|
-
import { cloneElement,
|
|
4
|
-
import {
|
|
3
|
+
import { cloneElement, useRef } from 'react';
|
|
4
|
+
import { useContainerScrolling, useLayout } from '../../hooks';
|
|
5
5
|
export function Popup(props) {
|
|
6
6
|
const { children, visible: visibleProp, trigger, disabled = false, mouseEnterDelay = 150, mouseLeaveDelay = 200, updatePosition, onVisibleChange, } = props;
|
|
7
|
-
const {
|
|
7
|
+
const { contentResizeRef } = useLayout();
|
|
8
8
|
const windowRef = useRefExtra(() => window);
|
|
9
9
|
const dataRef = useRef({});
|
|
10
10
|
const async = useAsync();
|
|
@@ -42,23 +42,7 @@ export function Popup(props) {
|
|
|
42
42
|
changeVisible();
|
|
43
43
|
}
|
|
44
44
|
};
|
|
45
|
-
|
|
46
|
-
useEffect(() => {
|
|
47
|
-
if (!disabled && visibleProp && !listenGlobalScrolling) {
|
|
48
|
-
const els = [pageScrollRef, ...updatePosition.containerRefs].map((ref) => ref.current).filter((el) => el);
|
|
49
|
-
const listener = () => {
|
|
50
|
-
updatePosition.fn();
|
|
51
|
-
};
|
|
52
|
-
els.forEach((el) => {
|
|
53
|
-
el.addEventListener('scroll', listener, { passive: true });
|
|
54
|
-
});
|
|
55
|
-
return () => {
|
|
56
|
-
els.forEach((el) => {
|
|
57
|
-
el.removeEventListener('scroll', listener, { passive: true });
|
|
58
|
-
});
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
});
|
|
45
|
+
useContainerScrolling(updatePosition.triggerRef, updatePosition.fn, disabled || updatePosition.scroll === false || !visibleProp);
|
|
62
46
|
useResize(updatePosition.triggerRef, updatePosition.fn, undefined, disabled || !visibleProp);
|
|
63
47
|
useResize(updatePosition.popupRef, updatePosition.fn, undefined, disabled || !visibleProp);
|
|
64
48
|
useResize(contentResizeRef, updatePosition.fn, undefined, disabled || !visibleProp);
|
|
@@ -15,7 +15,7 @@ export interface PopupProps {
|
|
|
15
15
|
fn: () => void;
|
|
16
16
|
triggerRef: React.RefObject<HTMLElement>;
|
|
17
17
|
popupRef: React.RefObject<HTMLElement>;
|
|
18
|
-
|
|
18
|
+
scroll?: boolean;
|
|
19
19
|
};
|
|
20
20
|
onVisibleChange: (visible: boolean) => void;
|
|
21
21
|
}
|
package/menu/Menu.js
CHANGED
|
@@ -2,13 +2,13 @@ import { __rest } from "tslib";
|
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import { findNested } from '@laser-ui/utils';
|
|
4
4
|
import { isNull, isUndefined, nth } from 'lodash';
|
|
5
|
-
import { Fragment, forwardRef, useId, useImperativeHandle, useRef, useState } from 'react';
|
|
5
|
+
import { Fragment, forwardRef, useCallback, useId, useImperativeHandle, useRef, useState } from 'react';
|
|
6
6
|
import { MenuGroup } from './internal/MenuGroup';
|
|
7
7
|
import { MenuItem as MenuItemFC } from './internal/MenuItem';
|
|
8
8
|
import { MenuSub } from './internal/MenuSub';
|
|
9
9
|
import { checkEnableItem, getSameLevelEnableItems } from './utils';
|
|
10
10
|
import { CLASSES } from './vars';
|
|
11
|
-
import { useComponentProps, useControlled, useFocusVisible, useNamespace, useNestedPopup, useStyled } from '../hooks';
|
|
11
|
+
import { useComponentProps, useContainerScrolling, useControlled, useFocusVisible, useNamespace, useNestedPopup, useStyled, } from '../hooks';
|
|
12
12
|
import { CollapseTransition } from '../internal/transition';
|
|
13
13
|
import { mergeCS } from '../utils';
|
|
14
14
|
import { TTANSITION_DURING_BASE } from '../vars';
|
|
@@ -18,6 +18,7 @@ function MenuFC(props, ref) {
|
|
|
18
18
|
const styled = useStyled(CLASSES, { menu: styleProvider === null || styleProvider === void 0 ? void 0 : styleProvider.menu, 'menu-popup': styleProvider === null || styleProvider === void 0 ? void 0 : styleProvider['menu-popup'] }, styleOverrides);
|
|
19
19
|
const uniqueId = useId();
|
|
20
20
|
const getItemId = (id) => `${namespace}-menu-item-${id}-${uniqueId}`;
|
|
21
|
+
const menuRef = useRef(null);
|
|
21
22
|
const dataRef = useRef({
|
|
22
23
|
mousedown: false,
|
|
23
24
|
updatePosition: new Map(),
|
|
@@ -324,13 +325,13 @@ function MenuFC(props, ref) {
|
|
|
324
325
|
};
|
|
325
326
|
return getNodes(list, 0, [], true);
|
|
326
327
|
})();
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
}), []);
|
|
328
|
+
const updatePosition = useCallback(() => {
|
|
329
|
+
for (const fn of dataRef.current.updatePosition.values()) {
|
|
330
|
+
fn();
|
|
331
|
+
}
|
|
332
|
+
}, []);
|
|
333
|
+
useContainerScrolling(menuRef, updatePosition);
|
|
334
|
+
useImperativeHandle(ref, () => ({ updatePosition }), [updatePosition]);
|
|
334
335
|
return (_jsx(CollapseTransition, { originalSize: {
|
|
335
336
|
width,
|
|
336
337
|
}, collapsedSize: {
|
|
@@ -342,7 +343,7 @@ function MenuFC(props, ref) {
|
|
|
342
343
|
leaving: {
|
|
343
344
|
transition: ['width', 'padding', 'margin'].map((attr) => `${attr} ${TTANSITION_DURING_BASE}ms linear`).join(', '),
|
|
344
345
|
},
|
|
345
|
-
}, children: (
|
|
346
|
+
}, children: (collapseRef, collapseStyle) => {
|
|
346
347
|
var _a;
|
|
347
348
|
const preventBlur = (e) => {
|
|
348
349
|
if (document.activeElement === e.currentTarget && e.button === 0) {
|
|
@@ -354,7 +355,10 @@ function MenuFC(props, ref) {
|
|
|
354
355
|
_jsx("nav", Object.assign({}, restProps, mergeCS(styled('menu', { 'menu--horizontal': mode === 'horizontal' }), {
|
|
355
356
|
className: restProps.className,
|
|
356
357
|
style: Object.assign(Object.assign(Object.assign({}, restProps.style), { width }), collapseStyle),
|
|
357
|
-
}), { ref:
|
|
358
|
+
}), { ref: (el) => {
|
|
359
|
+
collapseRef.current = el;
|
|
360
|
+
menuRef.current = el;
|
|
361
|
+
}, tabIndex: (_a = restProps.tabIndex) !== null && _a !== void 0 ? _a : 0, role: "menubar", "aria-orientation": mode === 'horizontal' ? 'horizontal' : 'vertical', "aria-activedescendant": isUndefined(focusId) ? undefined : getItemId(focusId), onFocus: (e) => {
|
|
358
362
|
var _a;
|
|
359
363
|
(_a = restProps.onFocus) === null || _a === void 0 ? void 0 : _a.call(restProps, e);
|
|
360
364
|
if (!dataRef.current.mousedown) {
|
package/menu/internal/MenuSub.js
CHANGED
|
@@ -21,7 +21,7 @@ export const MenuSub = forwardRef((props, ref) => {
|
|
|
21
21
|
const iconMode = mode === 'icon' && inNav;
|
|
22
22
|
const transformOrigin = useRef();
|
|
23
23
|
const updatePosition = useEventCallback(() => {
|
|
24
|
-
if (visible && popupRef.current && triggerRef.current) {
|
|
24
|
+
if (!(disabled || mode === 'vertical') && visible && popupRef.current && triggerRef.current) {
|
|
25
25
|
const height = popupRef.current.offsetHeight;
|
|
26
26
|
let width = popupRef.current.offsetWidth;
|
|
27
27
|
if (inHorizontalNav) {
|
|
@@ -56,7 +56,7 @@ export const MenuSub = forwardRef((props, ref) => {
|
|
|
56
56
|
fn: updatePosition,
|
|
57
57
|
triggerRef,
|
|
58
58
|
popupRef,
|
|
59
|
-
|
|
59
|
+
scroll: false,
|
|
60
60
|
}, onVisibleChange: onVisibleChange, children: ({ renderTrigger, renderPopup }) => (_jsxs(_Fragment, { children: [renderTrigger(_jsxs("li", Object.assign({}, mergeCS(styled('menu__item', 'menu__item--sub', {
|
|
61
61
|
'menu__item--horizontal': inHorizontalNav,
|
|
62
62
|
'menu__item--icon': iconMode,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@laser-ui/components",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "React components.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ui",
|
|
@@ -40,5 +40,5 @@
|
|
|
40
40
|
"access": "public",
|
|
41
41
|
"directory": "../../dist/libs/components"
|
|
42
42
|
},
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "5d76520ca057de8e9b23faa06ad88d5e7429d64d"
|
|
44
44
|
}
|
package/popover/Popover.js
CHANGED
|
@@ -12,7 +12,7 @@ import { Portal } from '../internal/portal';
|
|
|
12
12
|
import { Transition } from '../internal/transition';
|
|
13
13
|
import { getPopupPosition, handleModalKeyDown, mergeCS } from '../utils';
|
|
14
14
|
function PopoverFC(props, ref) {
|
|
15
|
-
const _a = useComponentProps('Popover', props), { children, styleOverrides, styleProvider, content, header: headerProp, footer, visible: visibleProp, defaultVisible, trigger: triggerProp = 'hover', placement: placementProp = 'top', placementFixed = false, arrow = true, escClosable = true, gap = 10, inWindow = false, mouseEnterDelay = 150, mouseLeaveDelay = 200, modal = false, skipFirstTransition = true, destroyAfterClose = true, zIndex: zIndexProp,
|
|
15
|
+
const _a = useComponentProps('Popover', props), { children, styleOverrides, styleProvider, content, header: headerProp, footer, visible: visibleProp, defaultVisible, trigger: triggerProp = 'hover', placement: placementProp = 'top', placementFixed = false, arrow = true, escClosable = true, gap = 10, inWindow = false, mouseEnterDelay = 150, mouseLeaveDelay = 200, modal = false, skipFirstTransition = true, destroyAfterClose = true, zIndex: zIndexProp, onVisibleChange, afterVisibleChange } = _a, restProps = __rest(_a, ["children", "styleOverrides", "styleProvider", "content", "header", "footer", "visible", "defaultVisible", "trigger", "placement", "placementFixed", "arrow", "escClosable", "gap", "inWindow", "mouseEnterDelay", "mouseLeaveDelay", "modal", "skipFirstTransition", "destroyAfterClose", "zIndex", "onVisibleChange", "afterVisibleChange"]);
|
|
16
16
|
const trigger = modal ? 'click' : triggerProp;
|
|
17
17
|
const namespace = useNamespace();
|
|
18
18
|
const styled = useStyled(CLASSES, { popover: styleProvider === null || styleProvider === void 0 ? void 0 : styleProvider.popover }, styleOverrides);
|
|
@@ -24,7 +24,6 @@ function PopoverFC(props, ref) {
|
|
|
24
24
|
const triggerRef = useRefExtra(() => document.getElementById(triggerId));
|
|
25
25
|
const popoverRef = useRef(null);
|
|
26
26
|
const popupRef = useRef(null);
|
|
27
|
-
const scrollingRef = useRefExtra(scrolling);
|
|
28
27
|
const dataRef = useRef({
|
|
29
28
|
prevActiveEl: null,
|
|
30
29
|
});
|
|
@@ -75,7 +74,6 @@ function PopoverFC(props, ref) {
|
|
|
75
74
|
fn: updatePosition,
|
|
76
75
|
triggerRef,
|
|
77
76
|
popupRef,
|
|
78
|
-
containerRefs: [scrollingRef],
|
|
79
77
|
}, onVisibleChange: changeVisible, children: ({ renderTrigger, renderPopup }) => {
|
|
80
78
|
const render = (el) => {
|
|
81
79
|
var _a;
|
package/popover/types.d.ts
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
import type { CLASSES } from './vars';
|
|
3
3
|
import type { ButtonProps } from '../button';
|
|
4
4
|
import type { BaseProps, CloneHTMLElement, PopupPlacement } from '../types';
|
|
5
|
-
import type { RefExtra } from '@laser-ui/hooks/useRefExtra';
|
|
6
5
|
export {};
|
|
7
6
|
export interface PopoverRef {
|
|
8
7
|
updatePosition: () => void;
|
|
@@ -27,7 +26,6 @@ export interface PopoverProps extends BaseProps<'popover', typeof CLASSES>, Omit
|
|
|
27
26
|
skipFirstTransition?: boolean;
|
|
28
27
|
destroyAfterClose?: boolean;
|
|
29
28
|
zIndex?: number | string;
|
|
30
|
-
scrolling?: RefExtra;
|
|
31
29
|
onVisibleChange?: (visible: boolean) => void;
|
|
32
30
|
afterVisibleChange?: (visible: boolean) => void;
|
|
33
31
|
}
|
package/select/Select.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
2
|
import { createElement as _createElement } from "react";
|
|
3
3
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
4
|
-
import {
|
|
4
|
+
import { useEventCallback, useForkRef, useResize } from '@laser-ui/hooks';
|
|
5
5
|
import { findNested, scrollIntoViewIfNeeded } from '@laser-ui/utils';
|
|
6
6
|
import CancelFilled from '@material-design-icons/svg/filled/cancel.svg?react';
|
|
7
7
|
import AddOutlined from '@material-design-icons/svg/outlined/add.svg?react';
|
|
@@ -15,7 +15,7 @@ import { BaseInput } from '../base-input';
|
|
|
15
15
|
import { Checkbox } from '../checkbox';
|
|
16
16
|
import { Dropdown } from '../dropdown';
|
|
17
17
|
import { Empty } from '../empty';
|
|
18
|
-
import { useComponentProps, useControlled, useDesign, useFocusVisible, useJSS, useLayout,
|
|
18
|
+
import { useComponentProps, useContainerScrolling, useControlled, useDesign, useFocusVisible, useJSS, useLayout, useMaxIndex, useNamespace, useScopedProps, useStyled, useTranslation, } from '../hooks';
|
|
19
19
|
import { Icon } from '../icon';
|
|
20
20
|
import { CircularProgress } from '../internal/circular-progress';
|
|
21
21
|
import { Portal } from '../internal/portal';
|
|
@@ -34,7 +34,7 @@ function SelectFC(props, ref) {
|
|
|
34
34
|
const uniqueId = useId();
|
|
35
35
|
const listId = `${namespace}-select-list-${uniqueId}`;
|
|
36
36
|
const getItemId = (val) => `${namespace}-select-item-${val}-${uniqueId}`;
|
|
37
|
-
const {
|
|
37
|
+
const { contentResizeRef } = useLayout();
|
|
38
38
|
const boxRef = useRef(null);
|
|
39
39
|
const popupRef = useRef(null);
|
|
40
40
|
const listRef = useRef(null);
|
|
@@ -217,8 +217,7 @@ function SelectFC(props, ref) {
|
|
|
217
217
|
}
|
|
218
218
|
}
|
|
219
219
|
});
|
|
220
|
-
|
|
221
|
-
useEvent(pageScrollRef, 'scroll', updatePosition, { passive: true }, !visible || listenGlobalScrolling);
|
|
220
|
+
useContainerScrolling(boxRef, updatePosition, !visible);
|
|
222
221
|
useResize(boxRef, updatePosition, undefined, !visible);
|
|
223
222
|
useResize(popupRef, updatePosition, undefined, !visible);
|
|
224
223
|
useResize(contentResizeRef, updatePosition, undefined, !visible);
|
package/table/TableFilter.js
CHANGED
|
@@ -9,7 +9,7 @@ import { Icon } from '../icon';
|
|
|
9
9
|
import { Input } from '../input';
|
|
10
10
|
import { Popover } from '../popover';
|
|
11
11
|
export function TableFilter(props) {
|
|
12
|
-
const _a = useComponentProps('TableFilter', props), { children, styleOverrides, styleProvider, content, footer, visible, placement = 'bottom-right', placementFixed = false, escClosable = true, gap, inWindow = false, searchable = false, searchValue, modal = false, destroyAfterClose = true, zIndex,
|
|
12
|
+
const _a = useComponentProps('TableFilter', props), { children, styleOverrides, styleProvider, content, footer, visible, placement = 'bottom-right', placementFixed = false, escClosable = true, gap, inWindow = false, searchable = false, searchValue, modal = false, destroyAfterClose = true, zIndex, onVisibleChange, onSearch, onReset, afterVisibleChange } = _a, restProps = __rest(_a, ["children", "styleOverrides", "styleProvider", "content", "footer", "visible", "placement", "placementFixed", "escClosable", "gap", "inWindow", "searchable", "searchValue", "modal", "destroyAfterClose", "zIndex", "onVisibleChange", "onSearch", "onReset", "afterVisibleChange"]);
|
|
13
13
|
const styled = useStyled(CLASSES, { table: styleProvider === null || styleProvider === void 0 ? void 0 : styleProvider.table }, styleOverrides);
|
|
14
14
|
const { t } = useTranslation();
|
|
15
15
|
return (_jsx(Popover, Object.assign({}, restProps, { children: children, content: _jsxs("div", Object.assign({}, styled('table__filter'), { children: [searchable && (_jsx(Input, { style: { display: 'flex' }, model: searchValue, prefix: _jsx(Icon, { children: _jsx(SearchOutlined, {}) }), placeholder: t('Search'), clearable: true, onModelChange: (value) => {
|
|
@@ -19,5 +19,5 @@ export function TableFilter(props) {
|
|
|
19
19
|
onReset === null || onReset === void 0 ? void 0 : onReset();
|
|
20
20
|
}, children: t('Table', 'Reset') }),
|
|
21
21
|
'ok',
|
|
22
|
-
] })) : footer === false ? undefined : (footer), visible: visible, trigger: "click", placement: placement, placementFixed: placementFixed, arrow: false, escClosable: escClosable, gap: gap, inWindow: inWindow, modal: modal, destroyAfterClose: destroyAfterClose, zIndex: zIndex,
|
|
22
|
+
] })) : footer === false ? undefined : (footer), visible: visible, trigger: "click", placement: placement, placementFixed: placementFixed, arrow: false, escClosable: escClosable, gap: gap, inWindow: inWindow, modal: modal, destroyAfterClose: destroyAfterClose, zIndex: zIndex, onVisibleChange: onVisibleChange, afterVisibleChange: afterVisibleChange })));
|
|
23
23
|
}
|
package/table/types.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { CLASSES } from './vars';
|
|
3
3
|
import type { BaseProps, CloneHTMLElement, PopupPlacement } from '../types';
|
|
4
|
-
import type { RefExtra } from '@laser-ui/hooks/useRefExtra';
|
|
5
4
|
export {};
|
|
6
5
|
export interface TableContextData {
|
|
7
6
|
fixed: ('left' | 'right')[];
|
|
@@ -55,7 +54,6 @@ export interface TableFilterProps extends BaseProps<'table', typeof CLASSES>, Om
|
|
|
55
54
|
modal?: boolean;
|
|
56
55
|
destroyAfterClose?: boolean;
|
|
57
56
|
zIndex?: number | string;
|
|
58
|
-
scrolling?: RefExtra;
|
|
59
57
|
onVisibleChange?: (visible: boolean) => void;
|
|
60
58
|
onSearch?: (value: string) => void;
|
|
61
59
|
onReset?: () => void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
2
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { useAsync,
|
|
3
|
+
import { useAsync, useEventCallback, useForceUpdate, useForkRef, useImmer, useResize } from '@laser-ui/hooks';
|
|
4
4
|
import CancelFilled from '@material-design-icons/svg/filled/cancel.svg?react';
|
|
5
5
|
import AccessTimeOutlined from '@material-design-icons/svg/outlined/access_time.svg?react';
|
|
6
6
|
import SwapHorizOutlined from '@material-design-icons/svg/outlined/swap_horiz.svg?react';
|
|
@@ -12,7 +12,7 @@ import { CLASSES } from './vars';
|
|
|
12
12
|
import { BaseInput } from '../base-input';
|
|
13
13
|
import { Button } from '../button';
|
|
14
14
|
import dayjs from '../dayjs';
|
|
15
|
-
import { useComponentProps, useControlled, useDesign, useJSS, useLayout,
|
|
15
|
+
import { useComponentProps, useContainerScrolling, useControlled, useDesign, useJSS, useLayout, useMaxIndex, useNamespace, useScopedProps, useStyled, useTranslation, } from '../hooks';
|
|
16
16
|
import { Icon } from '../icon';
|
|
17
17
|
import { Portal } from '../internal/portal';
|
|
18
18
|
import { Transition } from '../internal/transition';
|
|
@@ -28,7 +28,7 @@ export const TimePicker = forwardRef((props, ref) => {
|
|
|
28
28
|
const { t } = useTranslation();
|
|
29
29
|
const forceUpdate = useForceUpdate();
|
|
30
30
|
const async = useAsync();
|
|
31
|
-
const {
|
|
31
|
+
const { contentResizeRef } = useLayout();
|
|
32
32
|
const boxRef = useRef(null);
|
|
33
33
|
const popupRef = useRef(null);
|
|
34
34
|
const inputLeftRef = useRef(null);
|
|
@@ -128,8 +128,7 @@ export const TimePicker = forwardRef((props, ref) => {
|
|
|
128
128
|
popupRef.current.classList.toggle(sheet.classes.position, true);
|
|
129
129
|
}
|
|
130
130
|
});
|
|
131
|
-
|
|
132
|
-
useEvent(pageScrollRef, 'scroll', updatePosition, { passive: true }, !visible || listenGlobalScrolling);
|
|
131
|
+
useContainerScrolling(boxRef, updatePosition, !visible);
|
|
133
132
|
useResize(boxRef, updatePosition, undefined, !visible);
|
|
134
133
|
useResize(popupRef, updatePosition, undefined, !visible);
|
|
135
134
|
useResize(contentResizeRef, updatePosition, undefined, !visible);
|
package/tooltip/Tooltip.js
CHANGED
|
@@ -11,7 +11,7 @@ import { Transition } from '../internal/transition';
|
|
|
11
11
|
import { getPopupPosition, mergeCS } from '../utils';
|
|
12
12
|
export const Tooltip = forwardRef((props, ref) => {
|
|
13
13
|
var _a;
|
|
14
|
-
const _b = useComponentProps('Tooltip', props), { children, styleOverrides, styleProvider, title, visible: visibleProp, defaultVisible, trigger = 'hover', placement: placementProp = 'top', placementFixed = false, arrow = true, escClosable = true, gap = 10, inWindow = false, mouseEnterDelay = 150, mouseLeaveDelay = 200, skipFirstTransition = true, destroyAfterClose = true, zIndex: zIndexProp,
|
|
14
|
+
const _b = useComponentProps('Tooltip', props), { children, styleOverrides, styleProvider, title, visible: visibleProp, defaultVisible, trigger = 'hover', placement: placementProp = 'top', placementFixed = false, arrow = true, escClosable = true, gap = 10, inWindow = false, mouseEnterDelay = 150, mouseLeaveDelay = 200, skipFirstTransition = true, destroyAfterClose = true, zIndex: zIndexProp, onVisibleChange, afterVisibleChange } = _b, restProps = __rest(_b, ["children", "styleOverrides", "styleProvider", "title", "visible", "defaultVisible", "trigger", "placement", "placementFixed", "arrow", "escClosable", "gap", "inWindow", "mouseEnterDelay", "mouseLeaveDelay", "skipFirstTransition", "destroyAfterClose", "zIndex", "onVisibleChange", "afterVisibleChange"]);
|
|
15
15
|
const namespace = useNamespace();
|
|
16
16
|
const styled = useStyled(CLASSES, { tooltip: styleProvider === null || styleProvider === void 0 ? void 0 : styleProvider.tooltip }, styleOverrides);
|
|
17
17
|
const sheet = useJSS();
|
|
@@ -19,7 +19,6 @@ export const Tooltip = forwardRef((props, ref) => {
|
|
|
19
19
|
const id = (_a = restProps.id) !== null && _a !== void 0 ? _a : `${namespace}-tooltip-${uniqueId}`;
|
|
20
20
|
const triggerRef = useRefExtra(() => document.querySelector(`[aria-describedby="${id}"]`));
|
|
21
21
|
const tooltipRef = useRef(null);
|
|
22
|
-
const scrollingRef = useRefExtra(scrolling);
|
|
23
22
|
const [visible, changeVisible] = useControlled(defaultVisible !== null && defaultVisible !== void 0 ? defaultVisible : false, visibleProp, onVisibleChange);
|
|
24
23
|
const maxZIndex = useMaxIndex(visible);
|
|
25
24
|
const zIndex = !isUndefined(zIndexProp) ? zIndexProp : `calc(var(--${namespace}-zindex-fixed) + ${maxZIndex})`;
|
|
@@ -55,7 +54,6 @@ export const Tooltip = forwardRef((props, ref) => {
|
|
|
55
54
|
fn: updatePosition,
|
|
56
55
|
triggerRef,
|
|
57
56
|
popupRef: tooltipRef,
|
|
58
|
-
containerRefs: [scrollingRef],
|
|
59
57
|
}, onVisibleChange: changeVisible, children: ({ renderTrigger, renderPopup }) => {
|
|
60
58
|
const render = (el) => renderTrigger(cloneElement(el, {
|
|
61
59
|
'aria-describedby': id,
|
package/tooltip/types.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { CLASSES } from './vars';
|
|
3
3
|
import type { BaseProps, CloneHTMLElement, PopupPlacement } from '../types';
|
|
4
|
-
import type { RefExtra } from '@laser-ui/hooks/useRefExtra';
|
|
5
4
|
export {};
|
|
6
5
|
export interface TooltipRef {
|
|
7
6
|
updatePosition: () => void;
|
|
@@ -23,7 +22,6 @@ export interface TooltipProps extends BaseProps<'tooltip', typeof CLASSES>, Omit
|
|
|
23
22
|
skipFirstTransition?: boolean;
|
|
24
23
|
destroyAfterClose?: boolean;
|
|
25
24
|
zIndex?: number | string;
|
|
26
|
-
scrolling?: RefExtra;
|
|
27
25
|
onVisibleChange?: (visible: boolean) => void;
|
|
28
26
|
afterVisibleChange?: (visible: boolean) => void;
|
|
29
27
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
-
import {
|
|
3
|
+
import { useEventCallback, useForkRef, useResize } from '@laser-ui/hooks';
|
|
4
4
|
import { findNested } from '@laser-ui/utils';
|
|
5
5
|
import CancelFilled from '@material-design-icons/svg/filled/cancel.svg?react';
|
|
6
6
|
import CloseOutlined from '@material-design-icons/svg/outlined/close.svg?react';
|
|
@@ -12,7 +12,7 @@ import { TreeSelectSearchPanel } from './internal/TreeSelectSearchPanel';
|
|
|
12
12
|
import { CLASSES } from './vars';
|
|
13
13
|
import { BaseInput } from '../base-input';
|
|
14
14
|
import { Dropdown } from '../dropdown';
|
|
15
|
-
import { useComponentProps, useControlled, useDesign, useFocusVisible, useJSS, useLayout,
|
|
15
|
+
import { useComponentProps, useContainerScrolling, useControlled, useDesign, useFocusVisible, useJSS, useLayout, useMaxIndex, useNamespace, useScopedProps, useStyled, useTranslation, } from '../hooks';
|
|
16
16
|
import { Icon } from '../icon';
|
|
17
17
|
import { CircularProgress } from '../internal/circular-progress';
|
|
18
18
|
import { Portal } from '../internal/portal';
|
|
@@ -42,7 +42,7 @@ function TreeSelectFC(props, ref) {
|
|
|
42
42
|
const uniqueId = useId();
|
|
43
43
|
const listId = `${namespace}-tree-select-list-${uniqueId}`;
|
|
44
44
|
const getItemId = (val) => `${namespace}-tree-select-item-${val}-${uniqueId}`;
|
|
45
|
-
const {
|
|
45
|
+
const { contentResizeRef } = useLayout();
|
|
46
46
|
const boxRef = useRef(null);
|
|
47
47
|
const popupRef = useRef(null);
|
|
48
48
|
const inputRef = useRef(null);
|
|
@@ -203,8 +203,7 @@ function TreeSelectFC(props, ref) {
|
|
|
203
203
|
popupRef.current.classList.toggle(sheet.classes.position, true);
|
|
204
204
|
}
|
|
205
205
|
});
|
|
206
|
-
|
|
207
|
-
useEvent(pageScrollRef, 'scroll', updatePosition, { passive: true }, !visible || listenGlobalScrolling);
|
|
206
|
+
useContainerScrolling(boxRef, updatePosition, !visible);
|
|
208
207
|
useResize(boxRef, updatePosition, undefined, !visible);
|
|
209
208
|
useResize(popupRef, updatePosition, undefined, !visible);
|
|
210
209
|
useResize(contentResizeRef, updatePosition, undefined, !visible);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function useListenGlobalScrolling(callback?: () => void, disabled?: boolean): boolean;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { useEvent, useRefExtra } from '@laser-ui/hooks';
|
|
2
|
-
import { useContext } from 'react';
|
|
3
|
-
import { LContext } from '../context';
|
|
4
|
-
export function useListenGlobalScrolling(callback, disabled = false) {
|
|
5
|
-
const context = useContext(LContext);
|
|
6
|
-
const windowRef = useRefExtra(() => window);
|
|
7
|
-
useEvent(windowRef, 'scroll', callback, { passive: true, capture: true }, !context.listenGlobalScrolling || disabled);
|
|
8
|
-
return context.listenGlobalScrolling;
|
|
9
|
-
}
|