@laser-ui/components 1.6.0 → 2.0.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 +16 -0
- package/accordion/Accordion.d.ts +1 -1
- package/accordion/Accordion.js +13 -25
- package/accordion/types.d.ts +1 -0
- package/affix/Affix.d.ts +2 -2
- package/affix/Affix.js +27 -32
- package/affix/types.d.ts +7 -2
- package/alert/Alert.d.ts +1 -1
- package/alert/Alert.js +12 -21
- package/anchor/Anchor.d.ts +2 -4
- package/anchor/Anchor.js +34 -26
- package/anchor/types.d.ts +1 -0
- package/avatar/Avatar.d.ts +1 -1
- package/avatar/Avatar.js +9 -3
- package/badge/Badge.d.ts +1 -1
- package/badge/Badge.js +22 -41
- package/badge/BadgeText.js +12 -26
- package/badge/internal/BadgeNumber.d.ts +2 -2
- package/badge/internal/BadgeNumber.js +34 -24
- package/base-input/BaseInput.d.ts +1 -2
- package/base-input/BaseInput.js +4 -4
- package/base-input/types.d.ts +1 -0
- package/breadcrumb/Breadcrumb.d.ts +1 -1
- package/button/Button.d.ts +1 -2
- package/button/Button.js +18 -22
- package/button/types.d.ts +1 -0
- package/card/Card.d.ts +1 -1
- package/card/CardAction.d.ts +1 -1
- package/card/CardAction.js +3 -4
- package/card/CardActions.d.ts +1 -1
- package/card/CardActions.js +7 -3
- package/card/CardContent.d.ts +1 -1
- package/card/CardHeader.d.ts +1 -1
- package/card/types.d.ts +5 -1
- package/cascader/Cascader.d.ts +2 -4
- package/cascader/Cascader.js +217 -214
- package/cascader/internal/CascaderPanel.d.ts +2 -2
- package/cascader/internal/CascaderPanel.js +21 -7
- package/cascader/internal/CascaderSearchPanel.d.ts +2 -2
- package/cascader/internal/CascaderSearchPanel.js +15 -6
- package/cascader/types.d.ts +3 -3
- package/checkbox/Checkbox.d.ts +1 -1
- package/checkbox/Checkbox.js +4 -5
- package/checkbox/CheckboxGroup.d.ts +1 -1
- package/checkbox/CheckboxGroup.js +8 -7
- package/checkbox/types.d.ts +14 -4
- package/{internal/circular-progress → circular-progress}/CircularProgress.d.ts +1 -1
- package/{internal/circular-progress → circular-progress}/CircularProgress.js +2 -2
- package/compose/Compose.d.ts +1 -1
- package/compose/ComposeItem.d.ts +1 -1
- package/config-provider/ConfigProvider.d.ts +1 -1
- package/config-provider/ConfigProvider.js +3 -3
- package/date-picker/DatePicker.d.ts +2 -2
- package/date-picker/DatePicker.js +116 -98
- package/date-picker/internal/DatePickerPanel.d.ts +2 -1
- package/date-picker/internal/DatePickerPanel.js +4 -4
- package/date-picker/types.d.ts +3 -3
- package/dialog-service.d.ts +9 -6
- package/dialog-service.js +50 -26
- package/drawer/Drawer.d.ts +1 -1
- package/drawer/Drawer.js +83 -92
- package/drawer/DrawerFooter.d.ts +1 -1
- package/drawer/DrawerFooter.js +12 -9
- package/drawer/DrawerHeader.d.ts +1 -1
- package/drawer/DrawerHeader.js +10 -7
- package/drawer/types.d.ts +9 -2
- package/drawer/vars.d.ts +5 -1
- package/drawer/vars.js +1 -1
- package/dropdown/Dropdown.d.ts +2 -4
- package/dropdown/Dropdown.js +83 -104
- package/dropdown/internal/DropdownGroup.d.ts +1 -1
- package/dropdown/internal/DropdownItem.d.ts +1 -1
- package/dropdown/internal/DropdownSub.d.ts +2 -1
- package/dropdown/internal/DropdownSub.js +26 -49
- package/dropdown/types.d.ts +15 -2
- package/empty/Empty.d.ts +1 -1
- package/fab/Fab.d.ts +1 -1
- package/fab/Fab.js +19 -14
- package/fab/FabBacktop.d.ts +1 -1
- package/fab/FabBacktop.js +24 -31
- package/fab/FabButton.d.ts +1 -1
- package/fab/FabButton.js +37 -10
- package/fab/types.d.ts +6 -2
- package/fab/vars.d.ts +14 -0
- package/fab/vars.js +4 -0
- package/form/Form.d.ts +1 -1
- package/form/Form.js +7 -2
- package/form/FormItem.d.ts +1 -1
- package/form/FormItem.js +35 -24
- package/form/internal/FormError.d.ts +3 -2
- package/form/internal/FormError.js +10 -19
- package/hooks/index.d.ts +0 -2
- package/hooks/index.js +0 -2
- package/hooks/useComponentProps.js +2 -2
- package/hooks/useFocusVisible.d.ts +9 -2
- package/hooks/useFocusVisible.js +5 -11
- package/hooks/useLayout.d.ts +2 -2
- package/hooks/useLayout.js +2 -2
- package/hooks/useNamespace.js +2 -2
- package/hooks/useNestedPopup.d.ts +1 -1
- package/hooks/useScopedProps.js +2 -2
- package/hooks/useStyled.js +2 -2
- package/hooks/useTranslation.js +2 -2
- package/icon/Icon.d.ts +1 -1
- package/icon/Icon.js +7 -4
- package/image/Image.d.ts +1 -1
- package/image/Image.js +6 -2
- package/image/ImageAction.d.ts +1 -1
- package/image/ImageAction.js +3 -4
- package/image/ImageLoader.d.ts +1 -1
- package/image/ImagePreview.d.ts +1 -1
- package/image/ImagePreview.js +95 -110
- package/image/types.d.ts +6 -2
- package/input/Input.d.ts +1 -1
- package/input/Input.js +12 -8
- package/input/InputNumber.js +49 -40
- package/input/types.d.ts +3 -5
- package/internal/lazy-loading/LazyLoading.d.ts +3 -0
- package/internal/lazy-loading/LazyLoading.js +9 -0
- package/internal/lazy-loading/index.d.ts +2 -0
- package/internal/lazy-loading/index.js +1 -0
- package/internal/lazy-loading/types.d.ts +7 -0
- package/internal/popup/Popup.d.ts +1 -1
- package/internal/popup/Popup.js +40 -68
- package/internal/popup/types.d.ts +13 -6
- package/internal/portal/Portal.d.ts +1 -1
- package/internal/portal/Portal.js +12 -6
- package/internal/portal/types.d.ts +3 -2
- package/mask/Mask.d.ts +3 -0
- package/mask/Mask.js +31 -0
- package/menu/Menu.d.ts +2 -4
- package/menu/Menu.js +37 -42
- package/menu/internal/MenuGroup.d.ts +1 -1
- package/menu/internal/MenuItem.d.ts +1 -1
- package/menu/internal/MenuItem.js +14 -10
- package/menu/internal/MenuSub.d.ts +2 -1
- package/menu/internal/MenuSub.js +43 -70
- package/menu/types.d.ts +1 -0
- package/modal/Modal.d.ts +1 -1
- package/modal/Modal.js +77 -80
- package/modal/ModalAlert.d.ts +1 -1
- package/modal/ModalFooter.d.ts +1 -1
- package/modal/ModalFooter.js +12 -9
- package/modal/ModalHeader.d.ts +1 -1
- package/modal/ModalHeader.js +10 -7
- package/modal/types.d.ts +9 -2
- package/modal/vars.d.ts +5 -0
- package/modal/vars.js +2 -0
- package/notification/Notification.d.ts +1 -1
- package/notification/Notification.js +44 -71
- package/notification/types.d.ts +1 -0
- package/package.json +2 -2
- package/pagination/Pagination.d.ts +1 -1
- package/pagination/Pagination.js +9 -6
- package/popover/Popover.d.ts +2 -2
- package/popover/Popover.js +82 -118
- package/popover/PopoverFooter.d.ts +1 -1
- package/popover/PopoverFooter.js +12 -9
- package/popover/PopoverHeader.d.ts +1 -1
- package/popover/PopoverHeader.js +10 -7
- package/popover/types.d.ts +18 -4
- package/popover/vars.d.ts +5 -0
- package/popover/vars.js +2 -0
- package/progress/Progress.d.ts +1 -1
- package/radio/Radio.d.ts +1 -1
- package/radio/Radio.js +18 -13
- package/radio/RadioGroup.d.ts +1 -1
- package/radio/RadioGroup.js +12 -7
- package/radio/types.d.ts +16 -4
- package/radio/vars.d.ts +6 -0
- package/radio/vars.js +2 -0
- package/rating/Rating.d.ts +1 -1
- package/rating/internal/RatingStar.d.ts +1 -1
- package/rating/internal/RatingStar.js +23 -21
- package/root/Root.d.ts +1 -1
- package/root/Root.js +1 -1
- package/select/Select.d.ts +2 -4
- package/select/Select.js +245 -243
- package/select/types.d.ts +3 -3
- package/separator/Separator.d.ts +1 -1
- package/skeleton/Skeleton.d.ts +1 -1
- package/slider/Slider.d.ts +1 -1
- package/slider/Slider.js +54 -34
- package/slider/types.d.ts +2 -3
- package/slides/Slides.d.ts +1 -1
- package/slides/Slides.js +8 -3
- package/spinner/Spinner.d.ts +1 -1
- package/spinner/Spinner.js +27 -29
- package/stepper/Stepper.d.ts +1 -1
- package/stepper/Stepper.js +9 -16
- package/switch/Switch.js +33 -24
- package/switch/types.d.ts +2 -3
- package/table/Table.d.ts +1 -1
- package/table/Table.js +14 -10
- package/table/TableEmpty.d.ts +1 -1
- package/table/TableEmpty.js +9 -3
- package/table/TableExpand.d.ts +1 -1
- package/table/TableFilter.d.ts +1 -1
- package/table/TableFilter.js +1 -1
- package/table/TableTd.d.ts +1 -1
- package/table/TableTh.d.ts +1 -1
- package/table/TableThAction.d.ts +1 -1
- package/table/TableThAction.js +3 -4
- package/table/internal/TableCell.d.ts +1 -1
- package/table/internal/TableCell.js +13 -5
- package/table/types.d.ts +9 -2
- package/tabs/Tabs.d.ts +2 -4
- package/tabs/Tabs.js +41 -25
- package/tabs/types.d.ts +1 -0
- package/tag/Tag.d.ts +1 -1
- package/textarea/Textarea.d.ts +1 -1
- package/textarea/Textarea.js +15 -8
- package/textarea/types.d.ts +1 -0
- package/time-picker/TimePicker.d.ts +2 -2
- package/time-picker/TimePicker.js +89 -75
- package/time-picker/internal/TimePickerPanel.d.ts +2 -1
- package/time-picker/internal/TimePickerPanel.js +22 -7
- package/time-picker/types.d.ts +3 -3
- package/timeline/Timeline.d.ts +1 -1
- package/toast/Toast.d.ts +1 -1
- package/toast/Toast.js +44 -72
- package/toast/types.d.ts +1 -0
- package/tooltip/Tooltip.d.ts +2 -2
- package/tooltip/Tooltip.js +50 -74
- package/tooltip/types.d.ts +10 -2
- package/transfer/Transfer.d.ts +1 -1
- package/transfer/internal/TransferPanel.d.ts +1 -1
- package/transfer/internal/TransferPanel.js +7 -2
- package/{internal/transition → transition}/CollapseTransition.d.ts +1 -1
- package/transition/CollapseTransition.js +65 -0
- package/transition/Transition.d.ts +3 -0
- package/transition/Transition.js +148 -0
- package/transition/types.d.ts +29 -0
- package/tree/Tree.d.ts +1 -1
- package/tree/Tree.js +19 -7
- package/tree/internal/TreePanel.d.ts +2 -2
- package/tree/internal/TreePanel.js +32 -26
- package/tree-select/TreeSelect.d.ts +2 -4
- package/tree-select/TreeSelect.js +216 -213
- package/tree-select/internal/TreeSelectSearchPanel.d.ts +2 -2
- package/tree-select/internal/TreeSelectSearchPanel.js +15 -6
- package/tree-select/types.d.ts +3 -3
- package/types.d.ts +1 -1
- package/upload/Upload.d.ts +1 -3
- package/upload/Upload.js +41 -50
- package/upload/UploadAction.d.ts +1 -1
- package/upload/UploadAction.js +19 -16
- package/upload/UploadButton.d.ts +1 -1
- package/upload/UploadButton.js +16 -12
- package/upload/UploadList.d.ts +1 -1
- package/upload/UploadList.js +52 -47
- package/upload/UploadPicture.d.ts +1 -1
- package/upload/UploadPicture.js +47 -53
- package/upload/UploadPictureList.d.ts +1 -1
- package/upload/UploadPictureList.js +52 -47
- package/upload/UploadPreviewAction.d.ts +1 -1
- package/upload/UploadPreviewAction.js +15 -14
- package/upload/hooks.d.ts +2 -0
- package/upload/types.d.ts +27 -6
- package/upload/vars.d.ts +11 -0
- package/upload/vars.js +3 -0
- package/virtual-scroll/VirtualScroll.d.ts +2 -4
- package/virtual-scroll/VirtualScroll.js +13 -21
- package/virtual-scroll/types.d.ts +2 -1
- package/wave/Wave.d.ts +3 -0
- package/{internal/wave → wave}/Wave.js +6 -6
- package/{internal/wave → wave}/types.d.ts +1 -0
- package/wave/types.js +1 -0
- package/hooks/useJSS.d.ts +0 -1
- package/hooks/useJSS.js +0 -15
- package/hooks/useNextTick.d.ts +0 -2
- package/internal/mask/Mask.d.ts +0 -3
- package/internal/mask/Mask.js +0 -36
- package/internal/transition/CollapseTransition.js +0 -101
- package/internal/transition/Transition.d.ts +0 -3
- package/internal/transition/Transition.js +0 -87
- package/internal/transition/types.d.ts +0 -33
- package/internal/wave/Wave.d.ts +0 -3
- /package/{internal/circular-progress → circular-progress}/index.d.ts +0 -0
- /package/{internal/circular-progress → circular-progress}/index.js +0 -0
- /package/{internal/circular-progress → circular-progress}/vars.d.ts +0 -0
- /package/{internal/circular-progress → circular-progress}/vars.js +0 -0
- /package/internal/{mask → lazy-loading}/types.js +0 -0
- /package/{internal/mask → mask}/index.d.ts +0 -0
- /package/{internal/mask → mask}/index.js +0 -0
- /package/{internal/mask → mask}/types.d.ts +0 -0
- /package/{internal/transition → mask}/types.js +0 -0
- /package/{internal/mask → mask}/vars.d.ts +0 -0
- /package/{internal/mask → mask}/vars.js +0 -0
- /package/{internal/transition → transition}/index.d.ts +0 -0
- /package/{internal/transition → transition}/index.js +0 -0
- /package/{internal/wave → transition}/types.js +0 -0
- /package/{hooks/useNextTick.js → upload/hooks.js} +0 -0
- /package/{internal/wave → wave}/index.d.ts +0 -0
- /package/{internal/wave → wave}/index.js +0 -0
- /package/{internal/wave → wave}/vars.d.ts +0 -0
- /package/{internal/wave → wave}/vars.js +0 -0
|
@@ -15,5 +15,5 @@ interface TableCellProps extends React.TdHTMLAttributes<HTMLTableCellElement> {
|
|
|
15
15
|
} | undefined;
|
|
16
16
|
ellipsis: boolean;
|
|
17
17
|
}
|
|
18
|
-
export declare function TableCell(props: TableCellProps):
|
|
18
|
+
export declare function TableCell(props: TableCellProps): React.ReactElement | null;
|
|
19
19
|
export {};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useIsomorphicLayoutEffect } from '@laser-ui/hooks';
|
|
3
4
|
import { isNumber, isUndefined } from 'lodash';
|
|
4
|
-
import {
|
|
5
|
+
import { use, useRef } from 'react';
|
|
5
6
|
import { mergeCS } from '../../utils';
|
|
6
7
|
import { TableContext } from '../vars';
|
|
7
8
|
const ZINDEX_CONFIG = {
|
|
@@ -12,7 +13,7 @@ const ZINDEX_CONFIG = {
|
|
|
12
13
|
};
|
|
13
14
|
export function TableCell(props) {
|
|
14
15
|
const { children, namespace, styled, tag, width, align, fixed, ellipsis: ellipsisProp } = props, restProps = __rest(props, ["children", "namespace", "styled", "tag", "width", "align", "fixed", "ellipsis"]);
|
|
15
|
-
const tableContext =
|
|
16
|
+
const tableContext = use(TableContext);
|
|
16
17
|
const cellRef = useRef(null);
|
|
17
18
|
const ellipsis = ellipsisProp || tableContext.ellipsis;
|
|
18
19
|
let fixedLeft = false;
|
|
@@ -28,7 +29,7 @@ export function TableCell(props) {
|
|
|
28
29
|
fixedRight = true;
|
|
29
30
|
}
|
|
30
31
|
}
|
|
31
|
-
|
|
32
|
+
useIsomorphicLayoutEffect(() => {
|
|
32
33
|
if (cellRef.current && cellRef.current.parentElement) {
|
|
33
34
|
let showShadow = false;
|
|
34
35
|
if (fixedLeft && tableContext.fixed.includes('left')) {
|
|
@@ -46,16 +47,23 @@ export function TableCell(props) {
|
|
|
46
47
|
cellRef.current.classList.toggle(`${namespace}-table__cell--fixed-shadow`, showShadow);
|
|
47
48
|
}
|
|
48
49
|
});
|
|
49
|
-
|
|
50
|
+
const nodeProps = Object.assign(Object.assign(Object.assign({}, restProps), mergeCS(styled('table__cell', `table__cell--${align}`, {
|
|
50
51
|
'table__cell--fixed-left': fixedLeft,
|
|
51
52
|
'table__cell--fixed-right': fixedRight,
|
|
52
53
|
'table__cell--ellipsis': ellipsis,
|
|
53
54
|
}), {
|
|
54
55
|
className: restProps.className,
|
|
55
56
|
style: Object.assign(Object.assign(Object.assign({}, restProps.style), fixedStyle), { width: isUndefined(width) ? undefined : width }),
|
|
56
|
-
})), { ref:
|
|
57
|
+
})), { ref: (instance) => {
|
|
58
|
+
cellRef.current = instance;
|
|
59
|
+
return () => {
|
|
60
|
+
cellRef.current = null;
|
|
61
|
+
};
|
|
62
|
+
} });
|
|
63
|
+
const child = (_jsx("div", Object.assign({}, mergeCS(styled('table__cell-content'), {
|
|
57
64
|
style: {
|
|
58
65
|
width: isUndefined(width) ? undefined : `calc(${width}${isNumber(width) ? 'px' : ''} - var(--padding-size) * 2)`,
|
|
59
66
|
},
|
|
60
67
|
}), { children: children })));
|
|
68
|
+
return tag === 'th' ? _jsx("th", Object.assign({}, nodeProps, { children: child })) : _jsx("td", Object.assign({}, nodeProps, { children: child }));
|
|
61
69
|
}
|
package/table/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { CLASSES } from './vars';
|
|
3
|
-
import type { BaseProps,
|
|
3
|
+
import type { BaseProps, PopupPlacement } from '../types';
|
|
4
4
|
export {};
|
|
5
5
|
export interface TableContextData {
|
|
6
6
|
fixed: ('left' | 'right')[];
|
|
@@ -40,7 +40,13 @@ export interface TableTdProps extends BaseProps<'table', typeof CLASSES>, React.
|
|
|
40
40
|
ellipsis?: boolean;
|
|
41
41
|
}
|
|
42
42
|
export interface TableFilterProps extends BaseProps<'table', typeof CLASSES>, Omit<React.HTMLAttributes<HTMLDivElement>, 'children' | 'content'> {
|
|
43
|
-
children:
|
|
43
|
+
children: (props: {
|
|
44
|
+
id: string;
|
|
45
|
+
onClick: React.MouseEventHandler<HTMLElement>;
|
|
46
|
+
onMouseEnter: React.MouseEventHandler<HTMLElement>;
|
|
47
|
+
onMouseLeave: React.MouseEventHandler<HTMLElement>;
|
|
48
|
+
onKeyDown: React.KeyboardEventHandler<HTMLElement>;
|
|
49
|
+
}) => React.ReactNode;
|
|
44
50
|
content?: React.ReactNode;
|
|
45
51
|
footer?: React.ReactElement | false;
|
|
46
52
|
visible?: boolean;
|
|
@@ -60,6 +66,7 @@ export interface TableFilterProps extends BaseProps<'table', typeof CLASSES>, Om
|
|
|
60
66
|
afterVisibleChange?: (visible: boolean) => void;
|
|
61
67
|
}
|
|
62
68
|
export interface TableThActionProps extends BaseProps<'table', typeof CLASSES>, React.HTMLAttributes<HTMLDivElement> {
|
|
69
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
63
70
|
active?: boolean;
|
|
64
71
|
disabled?: boolean;
|
|
65
72
|
}
|
package/tabs/Tabs.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import type { TabsItem, TabsProps
|
|
3
|
-
declare function
|
|
4
|
-
export declare const Tabs: <ID extends React.Key, T extends TabsItem<ID>>(props: TabsProps<ID, T> & React.RefAttributes<TabsRef>) => ReturnType<typeof TabsFC>;
|
|
5
|
-
export {};
|
|
2
|
+
import type { TabsItem, TabsProps } from './types';
|
|
3
|
+
export declare function Tabs<ID extends React.Key, T extends TabsItem<ID>>(props: TabsProps<ID, T>): React.ReactElement | null;
|
package/tabs/Tabs.js
CHANGED
|
@@ -6,15 +6,16 @@ import { checkScrollEnd, findNested } from '@laser-ui/utils';
|
|
|
6
6
|
import AddOutlined from '@material-design-icons/svg/outlined/add.svg?react';
|
|
7
7
|
import CloseOutlined from '@material-design-icons/svg/outlined/close.svg?react';
|
|
8
8
|
import MoreHorizOutlined from '@material-design-icons/svg/outlined/more_horiz.svg?react';
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
9
|
+
import { isUndefined, nth } from 'lodash';
|
|
10
|
+
import { useEffect, useId, useImperativeHandle, useMemo, useRef, useState } from 'react';
|
|
11
11
|
import { CLASSES } from './vars';
|
|
12
12
|
import { Dropdown } from '../dropdown';
|
|
13
13
|
import { useComponentProps, useControlled, useNamespace, useStyled, useTranslation } from '../hooks';
|
|
14
14
|
import { Icon } from '../icon';
|
|
15
|
+
import { LazyLoading } from '../internal/lazy-loading';
|
|
15
16
|
import { mergeCS } from '../utils';
|
|
16
|
-
function
|
|
17
|
-
const _a = useComponentProps('Tabs', props), { styleOverrides, styleProvider, list, active: activeProp, defaultActive: _defaultActive, pattern, placement = 'top', center = false, size = 'medium', addible = false, lazyLoading = true, onActiveChange, onAddClick, onClose } = _a, restProps = __rest(_a, ["styleOverrides", "styleProvider", "list", "active", "defaultActive", "pattern", "placement", "center", "size", "addible", "lazyLoading", "onActiveChange", "onAddClick", "onClose"]);
|
|
17
|
+
export function Tabs(props) {
|
|
18
|
+
const _a = useComponentProps('Tabs', props), { ref, styleOverrides, styleProvider, list, active: activeProp, defaultActive: _defaultActive, pattern, placement = 'top', center = false, size = 'medium', addible = false, lazyLoading = true, onActiveChange, onAddClick, onClose } = _a, restProps = __rest(_a, ["ref", "styleOverrides", "styleProvider", "list", "active", "defaultActive", "pattern", "placement", "center", "size", "addible", "lazyLoading", "onActiveChange", "onAddClick", "onClose"]);
|
|
18
19
|
const namespace = useNamespace();
|
|
19
20
|
const styled = useStyled(CLASSES, { tabs: styleProvider === null || styleProvider === void 0 ? void 0 : styleProvider.tabs }, styleOverrides);
|
|
20
21
|
const { t } = useTranslation();
|
|
@@ -43,23 +44,10 @@ function TabsFC(props, ref) {
|
|
|
43
44
|
return null;
|
|
44
45
|
}, []);
|
|
45
46
|
const [active, changeActive] = useControlled(defaultActive, activeProp, (id) => {
|
|
46
|
-
panelLoaded.current.add(id);
|
|
47
47
|
if (onActiveChange) {
|
|
48
48
|
onActiveChange(id, findNested(list, (item) => item.id === id));
|
|
49
49
|
}
|
|
50
50
|
});
|
|
51
|
-
const panelLoaded = useRef(new Set(isNull(defaultActive) ? [] : [defaultActive]));
|
|
52
|
-
const newPanelLoaded = new Set();
|
|
53
|
-
const panels = list.map((item) => {
|
|
54
|
-
const { id: itemId, panel: itemPanel } = item;
|
|
55
|
-
const hidden = itemId !== active;
|
|
56
|
-
const loaded = panelLoaded.current.has(itemId);
|
|
57
|
-
if (loaded) {
|
|
58
|
-
newPanelLoaded.add(itemId);
|
|
59
|
-
}
|
|
60
|
-
return (_createElement("div", Object.assign({}, styled('tabs__tabpanel'), { key: itemId, id: getPanelId(itemId), tabIndex: 0, hidden: hidden, role: "tabpanel", "aria-labelledby": getTabId(itemId) }), lazyLoading && hidden && !loaded ? null : itemPanel));
|
|
61
|
-
});
|
|
62
|
-
panelLoaded.current = newPanelLoaded;
|
|
63
51
|
const refreshTabs = () => {
|
|
64
52
|
const tablistWrapperEl = tablistWrapperRef.current;
|
|
65
53
|
if (tablistWrapperEl) {
|
|
@@ -96,7 +84,6 @@ function TabsFC(props, ref) {
|
|
|
96
84
|
};
|
|
97
85
|
useIsomorphicLayoutEffect(() => {
|
|
98
86
|
refreshTabs();
|
|
99
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
100
87
|
}, []);
|
|
101
88
|
useResize(tablistWrapperRef, refreshTabs);
|
|
102
89
|
useResize(tablistRef, refreshTabs);
|
|
@@ -131,9 +118,24 @@ function TabsFC(props, ref) {
|
|
|
131
118
|
}), {
|
|
132
119
|
className: restProps.className,
|
|
133
120
|
style: restProps.style,
|
|
134
|
-
}), { ref:
|
|
121
|
+
}), { ref: (instance) => {
|
|
122
|
+
tabsRef.current = instance;
|
|
123
|
+
return () => {
|
|
124
|
+
tabsRef.current = null;
|
|
125
|
+
};
|
|
126
|
+
}, children: [_jsx("div", Object.assign({}, styled('tabs__tablist-wrapper'), { ref: (instance) => {
|
|
127
|
+
tablistWrapperRef.current = instance;
|
|
128
|
+
return () => {
|
|
129
|
+
tablistWrapperRef.current = null;
|
|
130
|
+
};
|
|
131
|
+
}, onScroll: () => {
|
|
135
132
|
refreshTabs();
|
|
136
|
-
}, children: _jsxs("div", Object.assign({}, styled('tabs__tablist'), { ref:
|
|
133
|
+
}, children: _jsxs("div", Object.assign({}, styled('tabs__tablist'), { ref: (instance) => {
|
|
134
|
+
tablistRef.current = instance;
|
|
135
|
+
return () => {
|
|
136
|
+
tablistRef.current = null;
|
|
137
|
+
};
|
|
138
|
+
}, role: "tablist", "aria-orientation": isHorizontal ? 'horizontal' : 'vertical', children: [list.map((item, index) => {
|
|
137
139
|
const { id: itemId, title: itemTitle, disabled: itemDisabled, closable: itemClosable } = item;
|
|
138
140
|
const isActive = itemId === active;
|
|
139
141
|
const getTab = (next, _index = index) => {
|
|
@@ -242,7 +244,12 @@ function TabsFC(props, ref) {
|
|
|
242
244
|
e.stopPropagation();
|
|
243
245
|
closeTab();
|
|
244
246
|
}, children: _jsx(Icon, { children: _jsx(CloseOutlined, {}) }) })))));
|
|
245
|
-
}), (listOverflow || addible) && (_jsxs("div", Object.assign({}, styled('tabs__button-container'), { ref:
|
|
247
|
+
}), (listOverflow || addible) && (_jsxs("div", Object.assign({}, styled('tabs__button-container'), { ref: (instance) => {
|
|
248
|
+
buttonContainerRef.current = instance;
|
|
249
|
+
return () => {
|
|
250
|
+
buttonContainerRef.current = null;
|
|
251
|
+
};
|
|
252
|
+
}, children: [listOverflow && (_jsx(Dropdown, { list: dropdownList.map((tab) => {
|
|
246
253
|
const { id: itemId, title: itemTitle, dropdownRender: itemDropdownRender, disabled: itemDisabled } = tab;
|
|
247
254
|
return {
|
|
248
255
|
id: itemId,
|
|
@@ -253,10 +260,19 @@ function TabsFC(props, ref) {
|
|
|
253
260
|
};
|
|
254
261
|
}), placement: placement === 'left' ? 'bottom-left' : 'bottom-right', onClick: (id) => {
|
|
255
262
|
changeActive(id);
|
|
256
|
-
}, children: _jsx("div", Object.assign({}, styled('tabs__button', 'tabs__button--more', {
|
|
263
|
+
}, children: (dropdownProps) => (_jsx("div", Object.assign({}, styled('tabs__button', 'tabs__button--more', {
|
|
257
264
|
'tabs__button.is-end': scrollEnd,
|
|
258
|
-
}), { "aria-label": t('More'), children: _jsx(Icon, { size: iconSize, children: _jsx(MoreHorizOutlined, {}) }) })) })), addible && (_jsx("div", Object.assign({}, styled('tabs__button', 'tabs__button--add'), { role: "button", "aria-label": t('Add'), onClick: () => {
|
|
265
|
+
}), dropdownProps, { "aria-label": t('More'), children: _jsx(Icon, { size: iconSize, children: _jsx(MoreHorizOutlined, {}) }) }))) })), addible && (_jsx("div", Object.assign({}, styled('tabs__button', 'tabs__button--add'), { role: "button", "aria-label": t('Add'), onClick: () => {
|
|
259
266
|
onAddClick === null || onAddClick === void 0 ? void 0 : onAddClick();
|
|
260
|
-
}, children: _jsx(Icon, { size: iconSize, children: _jsx(AddOutlined, {}) }) })))] }))), _jsx("div", Object.assign({}, styled(pattern === 'wrap' ? 'tabs__wrap-indicator' : pattern === 'slider' ? 'tabs__slider-indicator' : 'tabs__indicator'), { ref:
|
|
267
|
+
}, children: _jsx(Icon, { size: iconSize, children: _jsx(AddOutlined, {}) }) })))] }))), _jsx("div", Object.assign({}, styled(pattern === 'wrap' ? 'tabs__wrap-indicator' : pattern === 'slider' ? 'tabs__slider-indicator' : 'tabs__indicator'), { ref: (instance) => {
|
|
268
|
+
indicatorRef.current = instance;
|
|
269
|
+
return () => {
|
|
270
|
+
indicatorRef.current = null;
|
|
271
|
+
};
|
|
272
|
+
} }))] })) })), list.map((item) => {
|
|
273
|
+
const { id: itemId, panel: itemPanel } = item;
|
|
274
|
+
const hidden = itemId !== active;
|
|
275
|
+
return (_createElement("div", Object.assign({}, styled('tabs__tabpanel'), { key: itemId, id: getPanelId(itemId), tabIndex: 0, hidden: hidden, role: "tabpanel", "aria-labelledby": getTabId(itemId) }),
|
|
276
|
+
_jsx(LazyLoading, { hidden: hidden, disabled: !lazyLoading, children: itemPanel })));
|
|
277
|
+
})] })));
|
|
261
278
|
}
|
|
262
|
-
export const Tabs = forwardRef(TabsFC);
|
package/tabs/types.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export interface TabsItem<ID extends React.Key> {
|
|
|
14
14
|
disabled?: boolean;
|
|
15
15
|
}
|
|
16
16
|
export interface TabsProps<ID extends React.Key, T extends TabsItem<ID>> extends BaseProps<'tabs', typeof CLASSES>, Omit<React.HTMLAttributes<HTMLDivElement>, 'children'> {
|
|
17
|
+
ref?: React.Ref<TabsRef>;
|
|
17
18
|
list: T[];
|
|
18
19
|
active?: ID;
|
|
19
20
|
defaultActive?: ID;
|
package/tag/Tag.d.ts
CHANGED
package/textarea/Textarea.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { TextareaProps } from './types';
|
|
3
|
-
export declare
|
|
3
|
+
export declare function Textarea(props: TextareaProps): React.ReactElement | null;
|
package/textarea/Textarea.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
2
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import {
|
|
3
|
+
import { useIsomorphicLayoutEffect } from '@laser-ui/hooks';
|
|
4
|
+
import { setRef } from '@laser-ui/utils';
|
|
4
5
|
import { isFunction, isNumber, isUndefined } from 'lodash';
|
|
5
|
-
import {
|
|
6
|
+
import { useRef } from 'react';
|
|
6
7
|
import { CLASSES } from './vars';
|
|
7
8
|
import { useComponentProps, useControlled, useDesign, useScopedProps, useStyled } from '../hooks';
|
|
8
9
|
import { mergeCS } from '../utils';
|
|
9
|
-
export
|
|
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"]);
|
|
10
|
+
export function Textarea(props) {
|
|
11
|
+
const _a = useComponentProps('Textarea', props), { ref, styleOverrides, styleProvider, formControl, model, defaultModel, autoRows = false, resizable = true, showCount = false, size: sizeProp, onModelChange } = _a, restProps = __rest(_a, ["ref", "styleOverrides", "styleProvider", "formControl", "model", "defaultModel", "autoRows", "resizable", "showCount", "size", "onModelChange"]);
|
|
11
12
|
const styled = useStyled(CLASSES, { textarea: styleProvider === null || styleProvider === void 0 ? void 0 : styleProvider.textarea }, styleOverrides);
|
|
12
13
|
const textareaRef = useRef(null);
|
|
13
|
-
const combineTextareaRef = useForkRef(textareaRef, ref);
|
|
14
14
|
const [value, changeValue] = useControlled(defaultModel !== null && defaultModel !== void 0 ? defaultModel : '', model, onModelChange, undefined, formControl === null || formControl === void 0 ? void 0 : formControl.control);
|
|
15
15
|
const { size, disabled } = useScopedProps({ size: sizeProp, disabled: restProps.disabled || (formControl === null || formControl === void 0 ? void 0 : formControl.control.disabled) });
|
|
16
|
-
|
|
16
|
+
useIsomorphicLayoutEffect(() => {
|
|
17
17
|
const textareaEl = textareaRef.current;
|
|
18
18
|
if (textareaEl && autoRows !== false) {
|
|
19
19
|
const cssText = textareaEl.style.cssText;
|
|
@@ -50,7 +50,14 @@ export const Textarea = forwardRef((props, ref) => {
|
|
|
50
50
|
return (_jsxs(_Fragment, { children: [_jsx("textarea", Object.assign({}, restProps, mergeCS(styled('textarea', `textarea--${size}`), {
|
|
51
51
|
className: restProps.className,
|
|
52
52
|
style: Object.assign(Object.assign({}, restProps.style), { resize: resizable && autoRows === false ? undefined : 'none' }),
|
|
53
|
-
}), designProps, { ref:
|
|
53
|
+
}), designProps, { ref: (instance) => {
|
|
54
|
+
const ret = setRef(ref, instance);
|
|
55
|
+
textareaRef.current = instance;
|
|
56
|
+
return () => {
|
|
57
|
+
ret();
|
|
58
|
+
textareaRef.current = null;
|
|
59
|
+
};
|
|
60
|
+
}, value: value, disabled: disabled, onChange: (e) => {
|
|
54
61
|
var _a;
|
|
55
62
|
(_a = restProps.onChange) === null || _a === void 0 ? void 0 : _a.call(restProps, e);
|
|
56
63
|
changeValue(e.currentTarget.value);
|
|
@@ -59,4 +66,4 @@ export const Textarea = forwardRef((props, ref) => {
|
|
|
59
66
|
: isUndefined(restProps.maxLength)
|
|
60
67
|
? value.length
|
|
61
68
|
: `${value.length} / ${restProps.maxLength}` })))] }));
|
|
62
|
-
}
|
|
69
|
+
}
|
package/textarea/types.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import type { FormControlProvider } from '../form/types';
|
|
|
4
4
|
import type { BaseProps, Size } from '../types';
|
|
5
5
|
export {};
|
|
6
6
|
export interface TextareaProps extends BaseProps<'textarea', typeof CLASSES>, React.TextareaHTMLAttributes<HTMLTextAreaElement> {
|
|
7
|
+
ref?: React.Ref<HTMLTextAreaElement>;
|
|
7
8
|
formControl?: FormControlProvider;
|
|
8
9
|
model?: string;
|
|
9
10
|
defaultModel?: string;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import type { TimePickerProps
|
|
3
|
-
export declare
|
|
2
|
+
import type { TimePickerProps } from './types';
|
|
3
|
+
export declare function TimePicker(props: TimePickerProps): React.ReactElement | null;
|
|
@@ -1,30 +1,30 @@
|
|
|
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, useEventCallback, useForceUpdate,
|
|
3
|
+
import { useAsync, useEventCallback, useForceUpdate, useImmer, useIsomorphicLayoutEffect, useResize } from '@laser-ui/hooks';
|
|
4
|
+
import { setRef } from '@laser-ui/utils';
|
|
4
5
|
import CancelFilled from '@material-design-icons/svg/filled/cancel.svg?react';
|
|
5
6
|
import AccessTimeOutlined from '@material-design-icons/svg/outlined/access_time.svg?react';
|
|
6
7
|
import SwapHorizOutlined from '@material-design-icons/svg/outlined/swap_horiz.svg?react';
|
|
7
8
|
import { isNull, isUndefined } from 'lodash';
|
|
8
|
-
import {
|
|
9
|
+
import { useEffect, useImperativeHandle, useRef } from 'react';
|
|
9
10
|
import { TimePickerPanel } from './internal/TimePickerPanel';
|
|
10
11
|
import { deepCompareDate, orderTime } from './utils';
|
|
11
12
|
import { CLASSES } from './vars';
|
|
12
13
|
import { BaseInput } from '../base-input';
|
|
13
14
|
import { Button } from '../button';
|
|
14
15
|
import dayjs from '../dayjs';
|
|
15
|
-
import { useComponentProps, useContainerScrolling, useControlled, useDesign,
|
|
16
|
+
import { useComponentProps, useContainerScrolling, useControlled, useDesign, useLayout, useMaxIndex, useNamespace, useScopedProps, useStyled, useTranslation, } from '../hooks';
|
|
16
17
|
import { Icon } from '../icon';
|
|
17
18
|
import { Portal } from '../internal/portal';
|
|
18
|
-
import { Transition } from '../internal/transition';
|
|
19
19
|
import { ROOT_DATA } from '../root/vars';
|
|
20
|
+
import { Transition } from '../transition';
|
|
20
21
|
import { getVerticalSidePosition, mergeCS } from '../utils';
|
|
21
22
|
import { TTANSITION_DURING_POPUP, WINDOW_SPACE } from '../vars';
|
|
22
|
-
export
|
|
23
|
+
export function TimePicker(props) {
|
|
23
24
|
var _a, _b;
|
|
24
|
-
const _c = useComponentProps('TimePicker', props), { styleOverrides, styleProvider, formControl, model, defaultModel, visible: visibleProp, defaultVisible, placeholder, range = false, format = 'HH:mm:ss', order: orderProp = 'ascend', clearable: clearableProp = false, size: sizeProp, disabled: disabledProp = false, config, escClosable = true,
|
|
25
|
+
const _c = useComponentProps('TimePicker', props), { ref, styleOverrides, styleProvider, formControl, model, defaultModel, visible: visibleProp, defaultVisible, placeholder, range = false, format = 'HH:mm:ss', order: orderProp = 'ascend', clearable: clearableProp = false, size: sizeProp, disabled: disabledProp = false, config, escClosable = true, inputProps, onModelChange, onVisibleChange, onClear, afterVisibleChange } = _c, restProps = __rest(_c, ["ref", "styleOverrides", "styleProvider", "formControl", "model", "defaultModel", "visible", "defaultVisible", "placeholder", "range", "format", "order", "clearable", "size", "disabled", "config", "escClosable", "inputProps", "onModelChange", "onVisibleChange", "onClear", "afterVisibleChange"]);
|
|
25
26
|
const namespace = useNamespace();
|
|
26
27
|
const styled = useStyled(CLASSES, { 'time-picker': styleProvider === null || styleProvider === void 0 ? void 0 : styleProvider['time-picker'], 'time-picker-popup': styleProvider === null || styleProvider === void 0 ? void 0 : styleProvider['time-picker-popup'] }, styleOverrides);
|
|
27
|
-
const sheet = useJSS();
|
|
28
28
|
const { t } = useTranslation();
|
|
29
29
|
const forceUpdate = useForceUpdate();
|
|
30
30
|
const async = useAsync();
|
|
@@ -34,8 +34,6 @@ export const TimePicker = forwardRef((props, ref) => {
|
|
|
34
34
|
const inputLeftRef = useRef(null);
|
|
35
35
|
const inputRightRef = useRef(null);
|
|
36
36
|
const indicatorRef = useRef(null);
|
|
37
|
-
const combineInputLeftRef = useForkRef(inputLeftRef, inputRef === null || inputRef === void 0 ? void 0 : inputRef[0]);
|
|
38
|
-
const combineInputRightRef = useForkRef(inputRightRef, inputRef === null || inputRef === void 0 ? void 0 : inputRef[1]);
|
|
39
37
|
const panelRef = useRef(null);
|
|
40
38
|
const dataRef = useRef({
|
|
41
39
|
latestFocused: 'start',
|
|
@@ -106,7 +104,6 @@ export const TimePicker = forwardRef((props, ref) => {
|
|
|
106
104
|
const { size, disabled } = useScopedProps({ size: sizeProp, disabled: disabledProp || (formControl === null || formControl === void 0 ? void 0 : formControl.control.disabled) });
|
|
107
105
|
const maxZIndex = useMaxIndex(visible);
|
|
108
106
|
const zIndex = `calc(var(--${namespace}-zindex-fixed) + ${maxZIndex})`;
|
|
109
|
-
const transformOrigin = useRef();
|
|
110
107
|
const updatePosition = useEventCallback(() => {
|
|
111
108
|
if (visible && boxRef.current && popupRef.current) {
|
|
112
109
|
const height = popupRef.current.offsetHeight;
|
|
@@ -116,16 +113,10 @@ export const TimePicker = forwardRef((props, ref) => {
|
|
|
116
113
|
placement: 'bottom-left',
|
|
117
114
|
inWindow: WINDOW_SPACE,
|
|
118
115
|
});
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
sheet.replaceRule('position', {
|
|
124
|
-
top: position.top,
|
|
125
|
-
left: position.left,
|
|
126
|
-
maxWidth,
|
|
127
|
-
});
|
|
128
|
-
popupRef.current.classList.toggle(sheet.classes.position, true);
|
|
116
|
+
popupRef.current.style.setProperty(`--popup-down-transform-origin`, position.transformOrigin);
|
|
117
|
+
popupRef.current.style.top = position.top + 'px';
|
|
118
|
+
popupRef.current.style.left = position.left + 'px';
|
|
119
|
+
popupRef.current.style.maxWidth = maxWidth + 'px';
|
|
129
120
|
}
|
|
130
121
|
});
|
|
131
122
|
useContainerScrolling(boxRef, updatePosition, !visible);
|
|
@@ -135,7 +126,7 @@ export const TimePicker = forwardRef((props, ref) => {
|
|
|
135
126
|
useImperativeHandle(ref, () => ({
|
|
136
127
|
updatePosition,
|
|
137
128
|
}), [updatePosition]);
|
|
138
|
-
|
|
129
|
+
useIsomorphicLayoutEffect(() => {
|
|
139
130
|
if (boxRef.current && indicatorRef.current) {
|
|
140
131
|
let focus = false;
|
|
141
132
|
const boxRect = boxRef.current.getBoundingClientRect();
|
|
@@ -190,8 +181,16 @@ export const TimePicker = forwardRef((props, ref) => {
|
|
|
190
181
|
const inputNode = (isLeft) => {
|
|
191
182
|
const index = isLeft ? 0 : 1;
|
|
192
183
|
const value = isLeft ? valueLeft : valueRight;
|
|
193
|
-
const
|
|
194
|
-
|
|
184
|
+
const inputRef = isLeft ? inputLeftRef : inputRightRef;
|
|
185
|
+
return (_jsx(BaseInput, Object.assign({}, inputProps === null || inputProps === void 0 ? void 0 : inputProps[index], styled('time-picker__input'), formControl === null || formControl === void 0 ? void 0 : formControl.inputAria, { ref: (instance) => {
|
|
186
|
+
var _a;
|
|
187
|
+
inputRef.current = instance;
|
|
188
|
+
const ret = setRef((_a = inputProps === null || inputProps === void 0 ? void 0 : inputProps[index]) === null || _a === void 0 ? void 0 : _a.ref, instance);
|
|
189
|
+
return () => {
|
|
190
|
+
inputRef.current = null;
|
|
191
|
+
ret();
|
|
192
|
+
};
|
|
193
|
+
}, type: "text", autoComplete: "off", value: inputValue[index], size: 10, placeholder: isLeft ? placeholderLeft : placeholderRight, disabled: disabled, onValueChange: (val) => {
|
|
195
194
|
var _a;
|
|
196
195
|
forceUpdate();
|
|
197
196
|
dataRef.current.inputValue[index] = val;
|
|
@@ -201,6 +200,8 @@ export const TimePicker = forwardRef((props, ref) => {
|
|
|
201
200
|
(_a = panelRef.current) === null || _a === void 0 ? void 0 : _a.call(panelRef, date);
|
|
202
201
|
}
|
|
203
202
|
}, onKeyDown: (e) => {
|
|
203
|
+
var _a, _b;
|
|
204
|
+
(_b = (_a = inputProps === null || inputProps === void 0 ? void 0 : inputProps[index]) === null || _a === void 0 ? void 0 : _a.onKeyDown) === null || _b === void 0 ? void 0 : _b.call(_a, e);
|
|
204
205
|
if (e.code === 'Escape') {
|
|
205
206
|
if (visible && escClosable) {
|
|
206
207
|
e.stopPropagation();
|
|
@@ -213,24 +214,26 @@ export const TimePicker = forwardRef((props, ref) => {
|
|
|
213
214
|
const time = dayjs(inputValue[index], format).toDate();
|
|
214
215
|
handleEnter(time);
|
|
215
216
|
}
|
|
216
|
-
}, onFocus: () => {
|
|
217
|
-
var _a, _b, _c;
|
|
218
|
-
(_b = (_a =
|
|
217
|
+
}, onFocus: (e) => {
|
|
218
|
+
var _a, _b, _c, _d, _e;
|
|
219
|
+
(_b = (_a = inputProps === null || inputProps === void 0 ? void 0 : inputProps[index]) === null || _a === void 0 ? void 0 : _a.onFocus) === null || _b === void 0 ? void 0 : _b.call(_a, e);
|
|
220
|
+
(_d = (_c = dataRef.current).clearTid) === null || _d === void 0 ? void 0 : _d.call(_c);
|
|
219
221
|
setFocused((draft) => {
|
|
220
222
|
draft.fill(false);
|
|
221
223
|
draft[isLeft ? 0 : 1] = true;
|
|
222
224
|
});
|
|
223
225
|
dataRef.current.inputValue = [undefined, undefined];
|
|
224
226
|
if (visible && range && value) {
|
|
225
|
-
(
|
|
227
|
+
(_e = panelRef.current) === null || _e === void 0 ? void 0 : _e.call(panelRef, value);
|
|
226
228
|
}
|
|
227
|
-
}, onBlur: () => {
|
|
229
|
+
}, onBlur: (e) => {
|
|
230
|
+
var _a, _b;
|
|
231
|
+
(_b = (_a = inputProps === null || inputProps === void 0 ? void 0 : inputProps[index]) === null || _a === void 0 ? void 0 : _a.onBlur) === null || _b === void 0 ? void 0 : _b.call(_a, e);
|
|
228
232
|
dataRef.current.clearTid = async.setTimeout(() => {
|
|
229
233
|
setFocused([false, false]);
|
|
230
234
|
changeVisible(false);
|
|
231
235
|
}, 20);
|
|
232
236
|
} })));
|
|
233
|
-
return render ? render(node) : node;
|
|
234
237
|
};
|
|
235
238
|
const preventBlur = (e) => {
|
|
236
239
|
if ((document.activeElement === inputLeftRef.current || document.activeElement === inputRightRef.current) &&
|
|
@@ -246,7 +249,12 @@ export const TimePicker = forwardRef((props, ref) => {
|
|
|
246
249
|
}), {
|
|
247
250
|
className: restProps.className,
|
|
248
251
|
style: restProps.style,
|
|
249
|
-
}), designProps, { ref:
|
|
252
|
+
}), designProps, { ref: (instance) => {
|
|
253
|
+
boxRef.current = instance;
|
|
254
|
+
return () => {
|
|
255
|
+
boxRef.current = null;
|
|
256
|
+
};
|
|
257
|
+
}, onMouseDown: (e) => {
|
|
250
258
|
var _a;
|
|
251
259
|
(_a = restProps.onMouseDown) === null || _a === void 0 ? void 0 : _a.call(restProps, e);
|
|
252
260
|
preventBlur(e);
|
|
@@ -261,7 +269,12 @@ export const TimePicker = forwardRef((props, ref) => {
|
|
|
261
269
|
(_b = inputLeftRef.current) === null || _b === void 0 ? void 0 : _b.focus({ preventScroll: true });
|
|
262
270
|
}
|
|
263
271
|
changeVisible(true);
|
|
264
|
-
}, children: [inputNode(true), range && (_jsxs(_Fragment, { children: [_jsx("div", Object.assign({}, styled('time-picker__indicator'), { ref:
|
|
272
|
+
}, children: [inputNode(true), range && (_jsxs(_Fragment, { children: [_jsx("div", Object.assign({}, styled('time-picker__indicator'), { ref: (instance) => {
|
|
273
|
+
indicatorRef.current = instance;
|
|
274
|
+
return () => {
|
|
275
|
+
indicatorRef.current = null;
|
|
276
|
+
};
|
|
277
|
+
} })), _jsx("div", Object.assign({}, styled('time-picker__separator'), { children: _jsx(Icon, { children: _jsx(SwapHorizOutlined, {}) }) })), inputNode(false)] })), clearable && (_jsx("div", Object.assign({}, styled('time-picker__clear'), { role: "button", "aria-label": t('Clear'), onClick: (e) => {
|
|
265
278
|
e.stopPropagation();
|
|
266
279
|
dataRef.current.inputValue = [undefined, undefined];
|
|
267
280
|
_changeValue(null);
|
|
@@ -276,7 +289,23 @@ export const TimePicker = forwardRef((props, ref) => {
|
|
|
276
289
|
document.body.appendChild(el);
|
|
277
290
|
}
|
|
278
291
|
return el;
|
|
279
|
-
}, children: _jsx(Transition, { enter: visible,
|
|
292
|
+
}, children: _jsx(Transition, { enter: visible, name: `${namespace}-popup-down`, duration: TTANSITION_DURING_POPUP, onSkipEnter: () => {
|
|
293
|
+
updatePosition();
|
|
294
|
+
const cb = () => {
|
|
295
|
+
var _a;
|
|
296
|
+
const value = focused[0] ? valueLeft : valueRight;
|
|
297
|
+
if (value) {
|
|
298
|
+
(_a = panelRef.current) === null || _a === void 0 ? void 0 : _a.call(panelRef, value);
|
|
299
|
+
}
|
|
300
|
+
};
|
|
301
|
+
if (range) {
|
|
302
|
+
cb();
|
|
303
|
+
}
|
|
304
|
+
else if (!dataRef.current.onceVisible) {
|
|
305
|
+
dataRef.current.onceVisible = true;
|
|
306
|
+
cb();
|
|
307
|
+
}
|
|
308
|
+
}, onBeforeEnter: () => {
|
|
280
309
|
updatePosition();
|
|
281
310
|
const cb = () => {
|
|
282
311
|
var _a;
|
|
@@ -292,48 +321,33 @@ export const TimePicker = forwardRef((props, ref) => {
|
|
|
292
321
|
dataRef.current.onceVisible = true;
|
|
293
322
|
cb();
|
|
294
323
|
}
|
|
295
|
-
},
|
|
324
|
+
}, onAfterEnter: () => {
|
|
296
325
|
afterVisibleChange === null || afterVisibleChange === void 0 ? void 0 : afterVisibleChange(true);
|
|
297
|
-
},
|
|
326
|
+
}, onAfterLeave: () => {
|
|
298
327
|
afterVisibleChange === null || afterVisibleChange === void 0 ? void 0 : afterVisibleChange(false);
|
|
299
|
-
}, children: (
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
return (_jsxs("div", Object.assign({}, mergeCS(styled('time-picker-popup'), {
|
|
326
|
-
style: Object.assign({ zIndex }, transitionStyle),
|
|
327
|
-
}), { ref: popupRef, onMouseDown: (e) => {
|
|
328
|
-
preventBlur(e);
|
|
329
|
-
}, onMouseUp: (e) => {
|
|
330
|
-
preventBlur(e);
|
|
331
|
-
}, children: [_jsx(TimePickerPanel, { ref: panelRef, styled: styled, time: dataRef.current.latestFocused === 'start' ? valueLeft : valueRight, format: format, config: config ? (...args) => config(...args, dataRef.current.latestFocused, [valueLeft, valueRight]) : undefined, onTimeChange: (time) => {
|
|
332
|
-
changeValue(time);
|
|
333
|
-
} }), _jsx("div", Object.assign({}, styled('time-picker__footer'), { children: _jsx(Button, { pattern: "link", onClick: () => {
|
|
334
|
-
const now = new Date();
|
|
335
|
-
changeValue(now);
|
|
336
|
-
handleEnter(now);
|
|
337
|
-
}, children: t('TimePicker', 'Now') }) }))] })));
|
|
338
|
-
} }) })] }));
|
|
339
|
-
});
|
|
328
|
+
}, children: (transitionRef, leaved) => (_jsxs("div", Object.assign({}, mergeCS(styled('time-picker-popup'), {
|
|
329
|
+
style: Object.assign({ zIndex }, (leaved ? { display: 'none' } : undefined)),
|
|
330
|
+
}), { ref: (instance) => {
|
|
331
|
+
popupRef.current = instance;
|
|
332
|
+
transitionRef(instance);
|
|
333
|
+
return () => {
|
|
334
|
+
popupRef.current = null;
|
|
335
|
+
transitionRef(null);
|
|
336
|
+
};
|
|
337
|
+
}, onMouseDown: (e) => {
|
|
338
|
+
preventBlur(e);
|
|
339
|
+
}, onMouseUp: (e) => {
|
|
340
|
+
preventBlur(e);
|
|
341
|
+
}, children: [_jsx(TimePickerPanel, { ref: (instance) => {
|
|
342
|
+
panelRef.current = instance;
|
|
343
|
+
return () => {
|
|
344
|
+
panelRef.current = null;
|
|
345
|
+
};
|
|
346
|
+
}, styled: styled, time: dataRef.current.latestFocused === 'start' ? valueLeft : valueRight, format: format, config: config ? (...args) => config(...args, dataRef.current.latestFocused, [valueLeft, valueRight]) : undefined, onTimeChange: (time) => {
|
|
347
|
+
changeValue(time);
|
|
348
|
+
} }), _jsx("div", Object.assign({}, styled('time-picker__footer'), { children: _jsx(Button, { pattern: "link", onClick: () => {
|
|
349
|
+
const now = new Date();
|
|
350
|
+
changeValue(now);
|
|
351
|
+
handleEnter(now);
|
|
352
|
+
}, children: t('TimePicker', 'Now') }) }))] }))) }) })] }));
|
|
353
|
+
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import type { Styled } from '../../hooks/useStyled';
|
|
3
3
|
import type { CLASSES } from '../vars';
|
|
4
4
|
interface TimePickerPanelProps {
|
|
5
|
+
ref?: React.Ref<(date: Date) => void>;
|
|
5
6
|
styled: Styled<typeof CLASSES>;
|
|
6
7
|
time: Date | null;
|
|
7
8
|
format: string;
|
|
@@ -12,5 +13,5 @@ interface TimePickerPanelProps {
|
|
|
12
13
|
inDatePicker?: boolean;
|
|
13
14
|
onTimeChange: (time: Date) => void;
|
|
14
15
|
}
|
|
15
|
-
export declare
|
|
16
|
+
export declare function TimePickerPanel(props: TimePickerPanelProps): React.ReactElement | null;
|
|
16
17
|
export {};
|