@laser-ui/components 1.0.1 → 1.1.0
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/badge/Badge.js +1 -1
- package/cascader/Cascader.js +4 -5
- package/context/index.d.ts +0 -2
- package/context/index.js +0 -9
- package/date-picker/DatePicker.js +6 -7
- package/dropdown/Dropdown.js +0 -1
- package/dropdown/internal/DropdownSub.js +0 -1
- package/fab/FabBacktop.js +2 -3
- package/form/model/form-group.d.ts +1 -1
- 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 +0 -1
- package/menu/internal/MenuSub.js +0 -1
- package/package.json +2 -2
- package/popover/Popover.js +1 -3
- package/popover/types.d.ts +0 -2
- package/root/vars.d.ts +1 -1
- package/select/Select.js +4 -5
- package/table/TableFilter.js +2 -2
- package/table/types.d.ts +0 -2
- package/textarea/Textarea.js +27 -44
- package/time-picker/TimePicker.js +6 -7
- package/tooltip/Tooltip.js +1 -3
- package/tooltip/types.d.ts +0 -2
- package/tree-select/TreeSelect.js +4 -5
- package/LICENSE +0 -21
- 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.0](https://github.com/laser-ui/laser-ui/compare/v1.0.2...v1.1.0) (2024-08-30)
|
|
6
|
+
|
|
7
|
+
### Features
|
|
8
|
+
|
|
9
|
+
- automatically update when scrolling ([9030e9e](https://github.com/laser-ui/laser-ui/commit/9030e9e1fa1739bb84f426004eefa6e00d6f2773))
|
|
10
|
+
|
|
11
|
+
## [1.0.2](https://github.com/laser-ui/laser-ui/compare/v1.0.1...v1.0.2) (2024-07-20)
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
- **components:** fix `Textarea` auto rows ([df91d01](https://github.com/laser-ui/laser-ui/commit/df91d01000137f7a93f0f59407c9f1d738e67d85))
|
|
16
|
+
|
|
5
17
|
## [1.0.1](https://github.com/laser-ui/laser-ui/compare/v1.0.0...v1.0.1) (2024-07-12)
|
|
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/badge/Badge.js
CHANGED
|
@@ -17,7 +17,7 @@ export const Badge = (props) => {
|
|
|
17
17
|
valueDown: false,
|
|
18
18
|
});
|
|
19
19
|
const show = showZero || valueProp > 0;
|
|
20
|
-
const value = show ? valueProp : (_a = dataRef.current.saveValue) !== null && _a !== void 0 ? _a : 0;
|
|
20
|
+
const value = show ? valueProp : ((_a = dataRef.current.saveValue) !== null && _a !== void 0 ? _a : 0);
|
|
21
21
|
dataRef.current.saveValue = value;
|
|
22
22
|
const nums = (value > max ? max : value)
|
|
23
23
|
.toString()
|
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);
|
|
@@ -67,7 +67,7 @@ export const DatePicker = forwardRef((props, ref) => {
|
|
|
67
67
|
dataRef.current.latestFocused = 'end';
|
|
68
68
|
}
|
|
69
69
|
const [_value, _changeValue] = useControlled(defaultModel !== null && defaultModel !== void 0 ? defaultModel : null, model, onModelChange, (a, b) => deepCompareDate(a, b, format), formControl === null || formControl === void 0 ? void 0 : formControl.control);
|
|
70
|
-
let [valueLeft, valueRight = null] = range ? (_a = _value) !== null && _a !== void 0 ? _a : [null, null] : [_value, null];
|
|
70
|
+
let [valueLeft, valueRight = null] = range ? ((_a = _value) !== null && _a !== void 0 ? _a : [null, null]) : [_value, null];
|
|
71
71
|
if (range) {
|
|
72
72
|
if (isNull(_value)) {
|
|
73
73
|
[valueLeft, valueRight] = dataRef.current.rangeDate;
|
|
@@ -114,7 +114,7 @@ export const DatePicker = forwardRef((props, ref) => {
|
|
|
114
114
|
forceUpdate();
|
|
115
115
|
};
|
|
116
116
|
const [placeholderLeft = t('DatePicker', range ? 'Start date' : 'Select date'), placeholderRight = t('DatePicker', 'End date')] = range
|
|
117
|
-
? (_b = placeholder) !== null && _b !== void 0 ? _b : []
|
|
117
|
+
? ((_b = placeholder) !== null && _b !== void 0 ? _b : [])
|
|
118
118
|
: [placeholder];
|
|
119
119
|
const { size, disabled } = useScopedProps({ size: sizeProp, disabled: disabledProp || (formControl === null || formControl === void 0 ? void 0 : formControl.control.disabled) });
|
|
120
120
|
const maxZIndex = useMaxIndex(visible);
|
|
@@ -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
|
@@ -42,7 +42,6 @@ export const DropdownSub = forwardRef((props, ref) => {
|
|
|
42
42
|
fn: updatePosition,
|
|
43
43
|
triggerRef,
|
|
44
44
|
popupRef,
|
|
45
|
-
containerRefs: [],
|
|
46
45
|
}, onVisibleChange: onVisibleChange, children: ({ renderTrigger, renderPopup }) => (_jsxs(_Fragment, { children: [renderTrigger(_jsxs("li", Object.assign({}, mergeCS(styled('dropdown__item', 'dropdown__item--sub', {
|
|
47
46
|
'dropdown__item.is-expand': visible,
|
|
48
47
|
'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, {
|
|
@@ -3,7 +3,7 @@ import { AbstractControl } from './abstract-control';
|
|
|
3
3
|
type Mutable<T> = {
|
|
4
4
|
-readonly [P in keyof T]: T[P];
|
|
5
5
|
};
|
|
6
|
-
type GetFormControlPropertyFromArray<T, A> = Mutable<A> extends [infer K, ...infer R] ? K extends keyof T ? GetFormControlPropertyFromArray<T[K], R> : any : T;
|
|
6
|
+
type GetFormControlPropertyFromArray<T, A> = Mutable<A> extends [infer K, ...infer R] ? (K extends keyof T ? GetFormControlPropertyFromArray<T[K], R> : any) : T;
|
|
7
7
|
type GetFormControlProperty<T, S> = S extends `${infer K}.${infer R}` ? K extends keyof T ? GetFormControlProperty<T[K], R> : any : S extends keyof T ? T[S] : any;
|
|
8
8
|
type GetFormGroupT<C extends FormGroup<any>> = C extends FormGroup<infer T> ? T : unknown;
|
|
9
9
|
type GetFormGroupValue<T extends {
|
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 || !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);
|
package/menu/internal/MenuSub.js
CHANGED
|
@@ -56,7 +56,6 @@ export const MenuSub = forwardRef((props, ref) => {
|
|
|
56
56
|
fn: updatePosition,
|
|
57
57
|
triggerRef,
|
|
58
58
|
popupRef,
|
|
59
|
-
containerRefs: [],
|
|
60
59
|
}, onVisibleChange: onVisibleChange, children: ({ renderTrigger, renderPopup }) => (_jsxs(_Fragment, { children: [renderTrigger(_jsxs("li", Object.assign({}, mergeCS(styled('menu__item', 'menu__item--sub', {
|
|
61
60
|
'menu__item--horizontal': inHorizontalNav,
|
|
62
61
|
'menu__item--icon': iconMode,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@laser-ui/components",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
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": "6a7e6e2e141237b816d4a9f414bcf4c5274e14e6"
|
|
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/root/vars.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type { Lang } from '../types';
|
|
|
4
4
|
import resources from '../resources.json';
|
|
5
5
|
export declare const Store: import("rcl-store").Store<{
|
|
6
6
|
dialogs: DialogInstance<any>[];
|
|
7
|
-
}
|
|
7
|
+
}>;
|
|
8
8
|
export declare const ROOT_DATA: {
|
|
9
9
|
clickEvent?: {
|
|
10
10
|
time: number;
|
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;
|
package/textarea/Textarea.js
CHANGED
|
@@ -4,63 +4,46 @@ import { useForkRef } from '@laser-ui/hooks';
|
|
|
4
4
|
import { isFunction, isNumber, isUndefined } from 'lodash';
|
|
5
5
|
import { forwardRef, useEffect, useRef } from 'react';
|
|
6
6
|
import { CLASSES } from './vars';
|
|
7
|
-
import { useComponentProps, useControlled, useDesign,
|
|
7
|
+
import { useComponentProps, useControlled, useDesign, useScopedProps, useStyled } from '../hooks';
|
|
8
8
|
import { mergeCS } from '../utils';
|
|
9
9
|
export const Textarea = forwardRef((props, ref) => {
|
|
10
10
|
const _a = useComponentProps('Textarea', props), { styleOverrides, styleProvider, formControl, model, defaultModel, autoRows = false, resizable = true, showCount = false, size: sizeProp, onModelChange } = _a, restProps = __rest(_a, ["styleOverrides", "styleProvider", "formControl", "model", "defaultModel", "autoRows", "resizable", "showCount", "size", "onModelChange"]);
|
|
11
11
|
const styled = useStyled(CLASSES, { textarea: styleProvider === null || styleProvider === void 0 ? void 0 : styleProvider.textarea }, styleOverrides);
|
|
12
|
-
const sheet = useJSS();
|
|
13
12
|
const textareaRef = useRef(null);
|
|
14
13
|
const combineTextareaRef = useForkRef(textareaRef, ref);
|
|
15
14
|
const [value, changeValue] = useControlled(defaultModel !== null && defaultModel !== void 0 ? defaultModel : '', model, onModelChange, undefined, formControl === null || formControl === void 0 ? void 0 : formControl.control);
|
|
16
15
|
const { size, disabled } = useScopedProps({ size: sizeProp, disabled: restProps.disabled || (formControl === null || formControl === void 0 ? void 0 : formControl.control.disabled) });
|
|
17
16
|
useEffect(() => {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const n = Math.round(textareaRef.current.scrollHeight / lineHeight);
|
|
28
|
-
if (isNumber(restProps.rows)) {
|
|
29
|
-
textareaRef.current.rows = restProps.rows;
|
|
17
|
+
const textareaEl = textareaRef.current;
|
|
18
|
+
if (textareaEl && autoRows !== false) {
|
|
19
|
+
const cssText = textareaEl.style.cssText;
|
|
20
|
+
const rows = textareaEl.rows;
|
|
21
|
+
if (autoRows === true) {
|
|
22
|
+
textareaEl.style.cssText = cssText + 'overflow:hidden;height:0px;min-height:unset;';
|
|
23
|
+
const height = textareaEl.scrollHeight + (textareaEl.offsetHeight - textareaEl.clientHeight);
|
|
24
|
+
textareaEl.style.cssText = cssText;
|
|
25
|
+
textareaEl.style.height = height + 'px';
|
|
30
26
|
}
|
|
31
27
|
else {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
height = n * lineHeight;
|
|
41
|
-
overflow = 'hidden';
|
|
42
|
-
if (autoRows !== true) {
|
|
43
|
-
if (isNumber(autoRows.minRows)) {
|
|
44
|
-
minHeight = autoRows.minRows * lineHeight;
|
|
45
|
-
}
|
|
46
|
-
if (isNumber(autoRows.maxRows)) {
|
|
47
|
-
maxHeight = autoRows.maxRows * lineHeight;
|
|
48
|
-
if (autoRows.maxRows < n) {
|
|
49
|
-
overflow = undefined;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
28
|
+
textareaEl.style.cssText = cssText + 'overflow:hidden;height:0px;padding:0px;min-height:unset;';
|
|
29
|
+
const rowsHeight = textareaEl.scrollHeight + (textareaEl.offsetHeight - textareaEl.clientHeight);
|
|
30
|
+
textareaEl.rows = 1;
|
|
31
|
+
textareaEl.style.cssText = cssText + 'overflow:hidden;padding:0px;height:unset;min-height:unset;';
|
|
32
|
+
const rowHeight = textareaEl.clientHeight;
|
|
33
|
+
let n = Math.round(rowsHeight / rowHeight);
|
|
34
|
+
if (isNumber(autoRows.minRows) && n < autoRows.minRows) {
|
|
35
|
+
n = autoRows.minRows;
|
|
52
36
|
}
|
|
37
|
+
if (isNumber(autoRows.maxRows) && n > autoRows.maxRows) {
|
|
38
|
+
n = autoRows.maxRows;
|
|
39
|
+
}
|
|
40
|
+
textareaEl.rows = n;
|
|
41
|
+
textareaEl.style.cssText = cssText + 'height:unset;min-height:unset;';
|
|
53
42
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
height: isUndefined(height) ? undefined : height + outerSize,
|
|
59
|
-
overflow: isUndefined(overflow) ? undefined : 'hidden',
|
|
60
|
-
minHeight: isUndefined(minHeight) ? undefined : minHeight + outerSize,
|
|
61
|
-
maxHeight: isUndefined(maxHeight) ? undefined : maxHeight + outerSize,
|
|
62
|
-
});
|
|
63
|
-
textareaRef.current.classList.toggle(sheet.classes.rows, true);
|
|
43
|
+
return () => {
|
|
44
|
+
textareaEl.style.cssText = cssText;
|
|
45
|
+
textareaEl.rows = rows;
|
|
46
|
+
};
|
|
64
47
|
}
|
|
65
48
|
});
|
|
66
49
|
const designProps = useDesign({ form: formControl });
|
|
@@ -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);
|
|
@@ -54,7 +54,7 @@ export const TimePicker = forwardRef((props, ref) => {
|
|
|
54
54
|
dataRef.current.latestFocused = 'end';
|
|
55
55
|
}
|
|
56
56
|
const [_value, _changeValue] = useControlled(defaultModel !== null && defaultModel !== void 0 ? defaultModel : null, model, onModelChange, (a, b) => deepCompareDate(a, b, format), formControl === null || formControl === void 0 ? void 0 : formControl.control);
|
|
57
|
-
let [valueLeft, valueRight = null] = range ? (_a = _value) !== null && _a !== void 0 ? _a : [null, null] : [_value, null];
|
|
57
|
+
let [valueLeft, valueRight = null] = range ? ((_a = _value) !== null && _a !== void 0 ? _a : [null, null]) : [_value, null];
|
|
58
58
|
if (range) {
|
|
59
59
|
if (isNull(_value)) {
|
|
60
60
|
[valueLeft, valueRight] = dataRef.current.rangeDate;
|
|
@@ -101,7 +101,7 @@ export const TimePicker = forwardRef((props, ref) => {
|
|
|
101
101
|
forceUpdate();
|
|
102
102
|
};
|
|
103
103
|
const [placeholderLeft = t('TimePicker', range ? 'Start time' : 'Select time'), placeholderRight = t('TimePicker', 'End time')] = range
|
|
104
|
-
? (_b = placeholder) !== null && _b !== void 0 ? _b : []
|
|
104
|
+
? ((_b = placeholder) !== null && _b !== void 0 ? _b : [])
|
|
105
105
|
: [placeholder];
|
|
106
106
|
const { size, disabled } = useScopedProps({ size: sizeProp, disabled: disabledProp || (formControl === null || formControl === void 0 ? void 0 : formControl.control.disabled) });
|
|
107
107
|
const maxZIndex = useMaxIndex(visible);
|
|
@@ -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);
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2023 Xie Jay
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
@@ -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
|
-
}
|