@laser-ui/components 1.6.1 → 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 +10 -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 +94 -109
- 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/LICENSE +0 -21
- 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
|
@@ -4,12 +4,12 @@ import KeyboardArrowLeftOutlined from '@material-design-icons/svg/outlined/keybo
|
|
|
4
4
|
import KeyboardArrowRightOutlined from '@material-design-icons/svg/outlined/keyboard_arrow_right.svg?react';
|
|
5
5
|
import KeyboardDoubleArrowLeftOutlined from '@material-design-icons/svg/outlined/keyboard_double_arrow_left.svg?react';
|
|
6
6
|
import KeyboardDoubleArrowRightOutlined from '@material-design-icons/svg/outlined/keyboard_double_arrow_right.svg?react';
|
|
7
|
-
import {
|
|
7
|
+
import { useImperativeHandle, useRef, useState } from 'react';
|
|
8
8
|
import dayjs from '../../dayjs';
|
|
9
9
|
import { useTranslation } from '../../hooks';
|
|
10
10
|
import { Icon } from '../../icon';
|
|
11
|
-
export
|
|
12
|
-
const { styled, currentSelected: currentSelectedProp, anotherSelected: anotherSelectedProp, config, range, onDateChange } = props;
|
|
11
|
+
export function DatePickerPanel(props) {
|
|
12
|
+
const { ref, styled, currentSelected: currentSelectedProp, anotherSelected: anotherSelectedProp, config, range, onDateChange } = props;
|
|
13
13
|
const dataRef = useRef({});
|
|
14
14
|
const { t, lang } = useTranslation();
|
|
15
15
|
const async = useAsync();
|
|
@@ -101,4 +101,4 @@ export const DatePickerPanel = forwardRef((props, ref) => {
|
|
|
101
101
|
'date-picker__cell--today': !isCurrentSelected && !isAnotherSelected && day.isSame(dayjs(), 'date'),
|
|
102
102
|
}), { children: day.get('date') })) }, index2));
|
|
103
103
|
}) }, index1))) })] }))] })));
|
|
104
|
-
}
|
|
104
|
+
}
|
package/date-picker/types.d.ts
CHANGED
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
import type { CLASSES } from './vars';
|
|
3
3
|
import type { FormControlProvider } from '../form/types';
|
|
4
4
|
import type { TimePickerProps } from '../time-picker';
|
|
5
|
-
import type { BaseProps,
|
|
5
|
+
import type { BaseProps, Size } from '../types';
|
|
6
6
|
export {};
|
|
7
7
|
export interface DatePickerRef {
|
|
8
8
|
updatePosition: () => void;
|
|
9
9
|
}
|
|
10
10
|
export interface DatePickerProps extends BaseProps<'date-picker' | 'time-picker' | 'date-picker-popup', typeof CLASSES>, Omit<React.HTMLAttributes<HTMLDivElement>, 'children' | 'placeholder'> {
|
|
11
|
+
ref?: React.Ref<DatePickerRef>;
|
|
11
12
|
formControl?: FormControlProvider;
|
|
12
13
|
model?: Date | [Date, Date] | null;
|
|
13
14
|
defaultModel?: Date | [Date, Date] | null;
|
|
@@ -28,8 +29,7 @@ export interface DatePickerProps extends BaseProps<'date-picker' | 'time-picker'
|
|
|
28
29
|
};
|
|
29
30
|
showTime?: boolean | Pick<TimePickerProps, 'config'>;
|
|
30
31
|
escClosable?: boolean;
|
|
31
|
-
|
|
32
|
-
inputRender?: [CloneHTMLElement?, CloneHTMLElement?];
|
|
32
|
+
inputProps?: [React.ComponentPropsWithRef<'input'>?, React.ComponentPropsWithRef<'input'>?];
|
|
33
33
|
onModelChange?: (date: any) => void;
|
|
34
34
|
onVisibleChange?: (visible: boolean) => void;
|
|
35
35
|
onClear?: () => void;
|
package/dialog-service.d.ts
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
export
|
|
2
|
+
export declare class DialogInstance<P extends object> {
|
|
3
3
|
key: string | number;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
private type;
|
|
5
|
+
private props;
|
|
6
|
+
private service;
|
|
7
|
+
get node(): React.ReactElement<P>;
|
|
8
|
+
constructor(key: string | number, type: React.FC<P>, props: any, service: DialogService);
|
|
9
|
+
rerender(props: Partial<P>): void;
|
|
10
|
+
close(): void;
|
|
7
11
|
}
|
|
8
12
|
export declare class DialogService {
|
|
9
13
|
private _key;
|
|
@@ -11,7 +15,6 @@ export declare class DialogService {
|
|
|
11
15
|
private _emitChange;
|
|
12
16
|
constructor(emitChange: (dialogs: DialogInstance<any>[]) => void);
|
|
13
17
|
open<P extends object>(type: React.FC<P>, props: Omit<P, 'visible'>, key?: string | number): DialogInstance<P>;
|
|
14
|
-
|
|
15
|
-
rerender(key: string | number, props: any): void;
|
|
18
|
+
emitChange(key: string | number): void;
|
|
16
19
|
closeAll(animation?: boolean): void;
|
|
17
20
|
}
|
package/dialog-service.js
CHANGED
|
@@ -1,4 +1,44 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
export class DialogInstance {
|
|
3
|
+
get node() {
|
|
4
|
+
const Type = this.type;
|
|
5
|
+
return _jsx(Type, Object.assign({}, this.props), this.key);
|
|
6
|
+
}
|
|
7
|
+
constructor(key, type, props, service) {
|
|
8
|
+
Object.defineProperty(this, "key", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
configurable: true,
|
|
11
|
+
writable: true,
|
|
12
|
+
value: key
|
|
13
|
+
});
|
|
14
|
+
Object.defineProperty(this, "type", {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
configurable: true,
|
|
17
|
+
writable: true,
|
|
18
|
+
value: type
|
|
19
|
+
});
|
|
20
|
+
Object.defineProperty(this, "props", {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
configurable: true,
|
|
23
|
+
writable: true,
|
|
24
|
+
value: props
|
|
25
|
+
});
|
|
26
|
+
Object.defineProperty(this, "service", {
|
|
27
|
+
enumerable: true,
|
|
28
|
+
configurable: true,
|
|
29
|
+
writable: true,
|
|
30
|
+
value: service
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
rerender(props) {
|
|
34
|
+
Object.assign(this.props, props);
|
|
35
|
+
this.service.emitChange(this.key);
|
|
36
|
+
}
|
|
37
|
+
close() {
|
|
38
|
+
this.props.visible = false;
|
|
39
|
+
this.service.emitChange(this.key);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
2
42
|
export class DialogService {
|
|
3
43
|
constructor(emitChange) {
|
|
4
44
|
Object.defineProperty(this, "_key", {
|
|
@@ -27,8 +67,12 @@ export class DialogService {
|
|
|
27
67
|
const dialogKey = key !== null && key !== void 0 ? key : `l_#${++this._key}`;
|
|
28
68
|
const dialogProps = Object.assign(Object.assign({}, props), { visible: true, skipFirstTransition: false, onClose: () => {
|
|
29
69
|
var _a, _b;
|
|
30
|
-
this.close(dialogKey);
|
|
31
70
|
(_b = (_a = props).onClose) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
71
|
+
const index = this._dialogs.findIndex((dialog) => dialog.key === dialogKey);
|
|
72
|
+
if (index !== -1) {
|
|
73
|
+
const instance = this._dialogs[index];
|
|
74
|
+
instance.close();
|
|
75
|
+
}
|
|
32
76
|
}, afterVisibleChange: (visible) => {
|
|
33
77
|
var _a, _b;
|
|
34
78
|
(_b = (_a = props).afterVisibleChange) === null || _b === void 0 ? void 0 : _b.call(_a, visible);
|
|
@@ -40,46 +84,26 @@ export class DialogService {
|
|
|
40
84
|
}
|
|
41
85
|
}
|
|
42
86
|
} });
|
|
43
|
-
const
|
|
44
|
-
const instance = {
|
|
45
|
-
key: dialogKey,
|
|
46
|
-
node,
|
|
47
|
-
close: () => {
|
|
48
|
-
this.close(dialogKey);
|
|
49
|
-
},
|
|
50
|
-
rerender: (props) => {
|
|
51
|
-
this.rerender(dialogKey, props);
|
|
52
|
-
},
|
|
53
|
-
};
|
|
87
|
+
const instance = new DialogInstance(dialogKey, type, dialogProps, this);
|
|
54
88
|
this._dialogs.push(instance);
|
|
55
89
|
this._emitChange();
|
|
56
90
|
return instance;
|
|
57
91
|
}
|
|
58
|
-
|
|
92
|
+
emitChange(key) {
|
|
59
93
|
const index = this._dialogs.findIndex((dialog) => dialog.key === key);
|
|
60
94
|
if (index !== -1) {
|
|
61
|
-
const instance = this._dialogs[index];
|
|
62
|
-
instance.node = cloneElement(instance.node, { visible: false });
|
|
63
|
-
this._emitChange();
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
rerender(key, props) {
|
|
67
|
-
const index = this._dialogs.findIndex((dialog) => dialog.key === key);
|
|
68
|
-
if (index !== -1) {
|
|
69
|
-
const instance = this._dialogs[index];
|
|
70
|
-
instance.node = cloneElement(instance.node, props);
|
|
71
95
|
this._emitChange();
|
|
72
96
|
}
|
|
73
97
|
}
|
|
74
98
|
closeAll(animation = true) {
|
|
75
99
|
if (animation) {
|
|
76
100
|
this._dialogs.forEach((dialog) => {
|
|
77
|
-
dialog.
|
|
101
|
+
dialog.close();
|
|
78
102
|
});
|
|
79
103
|
}
|
|
80
104
|
else {
|
|
81
105
|
this._dialogs = [];
|
|
106
|
+
this._emitChange();
|
|
82
107
|
}
|
|
83
|
-
this._emitChange();
|
|
84
108
|
}
|
|
85
109
|
}
|
package/drawer/Drawer.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { DrawerProps } from './types';
|
|
|
3
3
|
import { DrawerFooter } from './DrawerFooter';
|
|
4
4
|
import { DrawerHeader } from './DrawerHeader';
|
|
5
5
|
export declare const Drawer: {
|
|
6
|
-
(props: DrawerProps):
|
|
6
|
+
(props: DrawerProps): React.ReactElement | null;
|
|
7
7
|
Header: typeof DrawerHeader;
|
|
8
8
|
Footer: typeof DrawerFooter;
|
|
9
9
|
};
|
package/drawer/Drawer.js
CHANGED
|
@@ -1,51 +1,32 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { isString, isUndefined } from 'lodash';
|
|
4
|
-
import {
|
|
4
|
+
import { use, useId, useRef, useState } from 'react';
|
|
5
5
|
import { DrawerFooter } from './DrawerFooter';
|
|
6
6
|
import { DrawerHeader } from './DrawerHeader';
|
|
7
7
|
import { CLASSES, DrawerContext } from './vars';
|
|
8
8
|
import { useComponentProps, useLockScroll, useMaxIndex, useNamespace, useStyled } from '../hooks';
|
|
9
|
-
import {
|
|
9
|
+
import { LazyLoading } from '../internal/lazy-loading';
|
|
10
10
|
import { Portal } from '../internal/portal';
|
|
11
|
-
import {
|
|
11
|
+
import { Mask } from '../mask';
|
|
12
|
+
import { Transition } from '../transition';
|
|
12
13
|
import { handleModalKeyDown, mergeCS } from '../utils';
|
|
13
14
|
import { TTANSITION_DURING_BASE } from '../vars';
|
|
14
15
|
export const Drawer = (props) => {
|
|
15
|
-
const _a = useComponentProps('Drawer', props), { children, styleOverrides, styleProvider, visible, header: headerProp, footer, placement = 'right', width = 400, height = 280, mask = true, maskClosable = true, escClosable = true, container, skipFirstTransition = true, destroyAfterClose = true, zIndex: zIndexProp, onClose, afterVisibleChange } = _a, restProps = __rest(_a, ["children", "styleOverrides", "styleProvider", "visible", "header", "footer", "placement", "width", "height", "mask", "maskClosable", "escClosable", "container", "skipFirstTransition", "destroyAfterClose", "zIndex", "onClose", "afterVisibleChange"]);
|
|
16
|
+
const _a = useComponentProps('Drawer', props), { children, styleOverrides, styleProvider, visible, header: headerProp, footer, placement = 'right', width = 400, height = 280, mask = true, maskClosable = true, escClosable = true, container, skipFirstTransition = true, destroyAfterClose = false, lazyLoading = true, zIndex: zIndexProp, onClose, afterVisibleChange } = _a, restProps = __rest(_a, ["children", "styleOverrides", "styleProvider", "visible", "header", "footer", "placement", "width", "height", "mask", "maskClosable", "escClosable", "container", "skipFirstTransition", "destroyAfterClose", "lazyLoading", "zIndex", "onClose", "afterVisibleChange"]);
|
|
16
17
|
const isFixed = isUndefined(container);
|
|
17
18
|
const namespace = useNamespace();
|
|
18
19
|
const styled = useStyled(CLASSES, { drawer: styleProvider === null || styleProvider === void 0 ? void 0 : styleProvider.drawer }, styleOverrides);
|
|
19
20
|
const drawerRef = useRef(null);
|
|
20
21
|
const drawerContentRef = useRef(null);
|
|
21
|
-
const
|
|
22
|
-
prevActiveEl: null,
|
|
23
|
-
});
|
|
22
|
+
const prevActiveEl = useRef(null);
|
|
24
23
|
const uniqueId = useId();
|
|
25
24
|
const titleId = `${namespace}-drawer-title-${uniqueId}`;
|
|
26
25
|
const bodyId = `${namespace}-drawer-content-${uniqueId}`;
|
|
27
|
-
const drawerContext =
|
|
28
|
-
const drawerContextValue = useCallback((offsets) => {
|
|
29
|
-
const offset = offsets[placement].reduce((sum, v) => Math.min((v / 3) * 2, 200) + sum, 0);
|
|
30
|
-
if (drawerRef.current) {
|
|
31
|
-
drawerRef.current.style.transform =
|
|
32
|
-
placement === 'top'
|
|
33
|
-
? `translateY(${offset}px)`
|
|
34
|
-
: placement === 'right'
|
|
35
|
-
? `translateX(-${offset}px)`
|
|
36
|
-
: placement === 'bottom'
|
|
37
|
-
? `translateY(-${offset}px)`
|
|
38
|
-
: `translateX(${offset}px)`;
|
|
39
|
-
}
|
|
40
|
-
if (drawerContentRef.current) {
|
|
41
|
-
drawerContext(Object.assign(Object.assign({}, offsets), { [placement]: [
|
|
42
|
-
placement === 'top' || placement === 'bottom' ? drawerContentRef.current.offsetHeight : drawerContentRef.current.offsetWidth,
|
|
43
|
-
].concat(offsets[placement]) }));
|
|
44
|
-
}
|
|
45
|
-
}, [drawerContext, placement]);
|
|
26
|
+
const drawerContext = use(DrawerContext);
|
|
46
27
|
const handleVisibleChange = (visible) => {
|
|
47
28
|
if (drawerContentRef.current) {
|
|
48
|
-
drawerContext(Object.assign({ top: [], right: [], bottom: [], left: [] }, {
|
|
29
|
+
drawerContext === null || drawerContext === void 0 ? void 0 : drawerContext.onVisibleChange(Object.assign({ top: [], right: [], bottom: [], left: [] }, {
|
|
49
30
|
[placement]: visible
|
|
50
31
|
? [
|
|
51
32
|
placement === 'top' || placement === 'bottom'
|
|
@@ -56,12 +37,7 @@ export const Drawer = (props) => {
|
|
|
56
37
|
}));
|
|
57
38
|
}
|
|
58
39
|
};
|
|
59
|
-
|
|
60
|
-
if (!visible) {
|
|
61
|
-
handleVisibleChange(false);
|
|
62
|
-
}
|
|
63
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
64
|
-
}, [visible]);
|
|
40
|
+
const [offset, setOffset] = useState(0);
|
|
65
41
|
const maxZIndex = useMaxIndex(visible);
|
|
66
42
|
const zIndex = !isUndefined(zIndexProp)
|
|
67
43
|
? zIndexProp
|
|
@@ -69,37 +45,6 @@ export const Drawer = (props) => {
|
|
|
69
45
|
? `var(--${namespace}-zindex-absolute)`
|
|
70
46
|
: `calc(var(--${namespace}-zindex-fixed) + ${maxZIndex})`;
|
|
71
47
|
useLockScroll(isFixed && visible);
|
|
72
|
-
const transitionStyles = (() => {
|
|
73
|
-
const transform = placement === 'top'
|
|
74
|
-
? 'translate(0, -100%)'
|
|
75
|
-
: placement === 'right'
|
|
76
|
-
? 'translate(100%, 0)'
|
|
77
|
-
: placement === 'bottom'
|
|
78
|
-
? 'translate(0, 100%)'
|
|
79
|
-
: 'translate(-100%, 0)';
|
|
80
|
-
return {
|
|
81
|
-
enter: { transform },
|
|
82
|
-
entering: {
|
|
83
|
-
transition: ['transform'].map((attr) => `${attr} ${TTANSITION_DURING_BASE}ms ease-out`).join(', '),
|
|
84
|
-
},
|
|
85
|
-
leaving: {
|
|
86
|
-
transform,
|
|
87
|
-
transition: ['transform'].map((attr) => `${attr} ${TTANSITION_DURING_BASE}ms ease-in`).join(', '),
|
|
88
|
-
},
|
|
89
|
-
leaved: { transform },
|
|
90
|
-
};
|
|
91
|
-
})();
|
|
92
|
-
const headerNode = (() => {
|
|
93
|
-
if (headerProp) {
|
|
94
|
-
const node = isString(headerProp) ? _jsx(DrawerHeader, { children: headerProp }) : headerProp;
|
|
95
|
-
return cloneElement(node, {
|
|
96
|
-
_id: titleId,
|
|
97
|
-
_onClose: () => {
|
|
98
|
-
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
99
|
-
},
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
})();
|
|
103
48
|
return (_jsx(Portal, { selector: isUndefined(container)
|
|
104
49
|
? () => {
|
|
105
50
|
let el = document.getElementById(`${namespace}-drawer-root`);
|
|
@@ -110,45 +55,91 @@ export const Drawer = (props) => {
|
|
|
110
55
|
}
|
|
111
56
|
return el;
|
|
112
57
|
}
|
|
113
|
-
: container, children: _jsx(Transition, { enter: visible,
|
|
58
|
+
: container, children: _jsx(Transition, { enter: visible, name: `${namespace}-drawer`, duration: TTANSITION_DURING_BASE, skipFirstTransition: skipFirstTransition, onSkipEnter: () => {
|
|
59
|
+
handleVisibleChange(true);
|
|
60
|
+
}, onBeforeEnter: () => {
|
|
114
61
|
handleVisibleChange(true);
|
|
115
|
-
},
|
|
62
|
+
}, onAfterEnter: () => {
|
|
116
63
|
afterVisibleChange === null || afterVisibleChange === void 0 ? void 0 : afterVisibleChange(true);
|
|
117
|
-
|
|
64
|
+
prevActiveEl.current = document.activeElement;
|
|
118
65
|
if (drawerRef.current) {
|
|
119
66
|
drawerRef.current.focus({ preventScroll: true });
|
|
120
67
|
}
|
|
121
|
-
},
|
|
68
|
+
}, onSkipLeave: () => {
|
|
69
|
+
handleVisibleChange(false);
|
|
70
|
+
}, onBeforeLeave: () => {
|
|
71
|
+
handleVisibleChange(false);
|
|
72
|
+
}, onAfterLeave: () => {
|
|
122
73
|
afterVisibleChange === null || afterVisibleChange === void 0 ? void 0 : afterVisibleChange(false);
|
|
123
|
-
if (
|
|
124
|
-
|
|
74
|
+
if (prevActiveEl.current) {
|
|
75
|
+
prevActiveEl.current.focus({ preventScroll: true });
|
|
125
76
|
}
|
|
126
|
-
}, children: (
|
|
77
|
+
}, children: (transitionRef, leaved) => {
|
|
127
78
|
var _a;
|
|
128
|
-
return (
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
79
|
+
return (_jsx(LazyLoading, { hidden: leaved, disabled: !lazyLoading, children: leaved && destroyAfterClose ? null : (_jsx(DrawerContext, { value: {
|
|
80
|
+
id: titleId,
|
|
81
|
+
onClose: () => {
|
|
82
|
+
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
83
|
+
},
|
|
84
|
+
onVisibleChange: (offsets) => {
|
|
85
|
+
const offset = offsets[placement].reduce((sum, v) => Math.min((v / 3) * 2, 200) + sum, 0);
|
|
86
|
+
setOffset(offset);
|
|
87
|
+
if (drawerContentRef.current) {
|
|
88
|
+
drawerContext === null || drawerContext === void 0 ? void 0 : drawerContext.onVisibleChange(Object.assign(Object.assign({}, offsets), { [placement]: [
|
|
89
|
+
placement === 'top' || placement === 'bottom'
|
|
90
|
+
? drawerContentRef.current.offsetHeight
|
|
91
|
+
: drawerContentRef.current.offsetWidth,
|
|
92
|
+
].concat(offsets[placement]) }));
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
}, children: _jsxs("div", Object.assign({}, restProps, mergeCS(styled('drawer', `drawer--${placement}`), {
|
|
96
|
+
className: restProps.className,
|
|
97
|
+
style: Object.assign(Object.assign(Object.assign(Object.assign({}, restProps.style), {
|
|
98
|
+
'--drawer-transform': placement === 'top'
|
|
99
|
+
? 'translate(0, -100%)'
|
|
100
|
+
: placement === 'right'
|
|
101
|
+
? 'translate(100%, 0)'
|
|
102
|
+
: placement === 'bottom'
|
|
103
|
+
? 'translate(0, 100%)'
|
|
104
|
+
: 'translate(-100%, 0)',
|
|
105
|
+
}), { position: isFixed ? undefined : 'absolute', zIndex, transform: placement === 'top'
|
|
106
|
+
? `translateY(${offset}px)`
|
|
107
|
+
: placement === 'right'
|
|
108
|
+
? `translateX(-${offset}px)`
|
|
109
|
+
: placement === 'bottom'
|
|
110
|
+
? `translateY(-${offset}px)`
|
|
111
|
+
: `translateX(${offset}px)` }), (leaved ? { display: 'none' } : undefined)),
|
|
112
|
+
}), { ref: (instance) => {
|
|
113
|
+
drawerRef.current = instance;
|
|
114
|
+
return () => {
|
|
115
|
+
drawerRef.current = null;
|
|
116
|
+
};
|
|
117
|
+
}, tabIndex: (_a = restProps.tabIndex) !== null && _a !== void 0 ? _a : -1, role: "dialog", "aria-modal": true, "aria-labelledby": headerProp ? titleId : undefined, "aria-describedby": bodyId, onKeyDown: (e) => {
|
|
118
|
+
var _a;
|
|
119
|
+
(_a = restProps.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(restProps, e);
|
|
120
|
+
if (visible && escClosable && e.code === 'Escape') {
|
|
121
|
+
e.stopPropagation();
|
|
122
|
+
e.preventDefault();
|
|
142
123
|
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
143
124
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
cloneElement(footer, {
|
|
148
|
-
_onClose: () => {
|
|
125
|
+
handleModalKeyDown(e);
|
|
126
|
+
}, children: [mask && (_jsx(Mask, { visible: visible, onClose: () => {
|
|
127
|
+
if (maskClosable) {
|
|
149
128
|
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
150
|
-
}
|
|
151
|
-
}
|
|
129
|
+
}
|
|
130
|
+
} })), _jsxs("div", Object.assign({}, mergeCS(styled('drawer__content'), {
|
|
131
|
+
style: {
|
|
132
|
+
width: placement === 'left' || placement === 'right' ? width : undefined,
|
|
133
|
+
height: placement === 'bottom' || placement === 'top' ? height : undefined,
|
|
134
|
+
},
|
|
135
|
+
}), { ref: (instance) => {
|
|
136
|
+
drawerContentRef.current = instance;
|
|
137
|
+
transitionRef(instance);
|
|
138
|
+
return () => {
|
|
139
|
+
drawerContentRef.current = null;
|
|
140
|
+
transitionRef(null);
|
|
141
|
+
};
|
|
142
|
+
}, children: [isString(headerProp) ? _jsx(DrawerHeader, { children: headerProp }) : headerProp, _jsx("div", Object.assign({}, styled('drawer__body'), { id: bodyId, children: children })), footer] }))] })) })) }));
|
|
152
143
|
} }) }));
|
|
153
144
|
};
|
|
154
145
|
Drawer.Header = DrawerHeader;
|
package/drawer/DrawerFooter.d.ts
CHANGED
package/drawer/DrawerFooter.js
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { has } from 'lodash';
|
|
4
|
+
import { Fragment, use } from 'react';
|
|
5
|
+
import { CLASSES, DrawerContext } from './vars';
|
|
5
6
|
import { Button } from '../button';
|
|
6
7
|
import { useComponentProps, useControlled, useStyled, useTranslation } from '../hooks';
|
|
7
8
|
import { mergeCS } from '../utils';
|
|
8
9
|
export function DrawerFooter(props) {
|
|
9
|
-
const _a = useComponentProps('DrawerFooter', props), { styleOverrides, styleProvider, align = 'right', actions = ['cancel', 'ok'], cancelProps: cancelPropsProp, okProps: okPropsProp, onCancelClick, onOkClick
|
|
10
|
+
const _a = useComponentProps('DrawerFooter', props), { styleOverrides, styleProvider, align = 'right', actions = ['cancel', 'ok'], cancelProps: cancelPropsProp, okProps: okPropsProp, onCancelClick, onOkClick } = _a, restProps = __rest(_a, ["styleOverrides", "styleProvider", "align", "actions", "cancelProps", "okProps", "onCancelClick", "onOkClick"]);
|
|
10
11
|
const styled = useStyled(CLASSES, { drawer: styleProvider === null || styleProvider === void 0 ? void 0 : styleProvider.drawer }, styleOverrides);
|
|
11
12
|
const { t } = useTranslation();
|
|
13
|
+
const drawerContext = use(DrawerContext);
|
|
12
14
|
const [cancelLoading, changeCancelLoading] = useControlled(false, cancelPropsProp === null || cancelPropsProp === void 0 ? void 0 : cancelPropsProp.loading);
|
|
13
15
|
const [okLoading, changeOkLoading] = useControlled(false, okPropsProp === null || okPropsProp === void 0 ? void 0 : okPropsProp.loading);
|
|
14
16
|
const cancelProps = Object.assign(Object.assign({}, cancelPropsProp), { loading: cancelLoading, onClick: () => {
|
|
@@ -18,12 +20,12 @@ export function DrawerFooter(props) {
|
|
|
18
20
|
shouldClose.then((val) => {
|
|
19
21
|
changeCancelLoading(false);
|
|
20
22
|
if (val !== false) {
|
|
21
|
-
|
|
23
|
+
drawerContext === null || drawerContext === void 0 ? void 0 : drawerContext.onClose();
|
|
22
24
|
}
|
|
23
25
|
});
|
|
24
26
|
}
|
|
25
27
|
else if (shouldClose !== false) {
|
|
26
|
-
|
|
28
|
+
drawerContext === null || drawerContext === void 0 ? void 0 : drawerContext.onClose();
|
|
27
29
|
}
|
|
28
30
|
} });
|
|
29
31
|
const okProps = Object.assign(Object.assign({}, okPropsProp), { loading: okLoading, onClick: () => {
|
|
@@ -33,19 +35,20 @@ export function DrawerFooter(props) {
|
|
|
33
35
|
shouldClose.then((val) => {
|
|
34
36
|
changeOkLoading(false);
|
|
35
37
|
if (val !== false) {
|
|
36
|
-
|
|
38
|
+
drawerContext === null || drawerContext === void 0 ? void 0 : drawerContext.onClose();
|
|
37
39
|
}
|
|
38
40
|
});
|
|
39
41
|
}
|
|
40
42
|
else if (shouldClose !== false) {
|
|
41
|
-
|
|
43
|
+
drawerContext === null || drawerContext === void 0 ? void 0 : drawerContext.onClose();
|
|
42
44
|
}
|
|
43
45
|
} });
|
|
44
46
|
return (_jsx("div", Object.assign({}, restProps, mergeCS(styled('drawer__footer', `drawer__footer--${align}`), {
|
|
45
47
|
className: restProps.className,
|
|
46
48
|
style: restProps.style,
|
|
47
|
-
}), { children:
|
|
49
|
+
}), { children: actions.map((node, index) => {
|
|
48
50
|
var _a, _b, _c;
|
|
49
|
-
|
|
51
|
+
const { id, action } = (has(node, ['id', 'action']) ? node : { id: index, action: node });
|
|
52
|
+
return (_jsx(Fragment, { children: action === 'cancel' ? (_jsx(Button, Object.assign({}, cancelProps, { pattern: (_a = cancelProps.pattern) !== null && _a !== void 0 ? _a : 'secondary', children: (_b = cancelProps.children) !== null && _b !== void 0 ? _b : t('Footer', 'Cancel') }))) : action === 'ok' ? (_jsx(Button, Object.assign({}, okProps, { children: (_c = okProps.children) !== null && _c !== void 0 ? _c : t('Footer', 'OK') }))) : (action) }, id));
|
|
50
53
|
}) })));
|
|
51
54
|
}
|
package/drawer/DrawerHeader.d.ts
CHANGED
package/drawer/DrawerHeader.js
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import CloseOutlined from '@material-design-icons/svg/outlined/close.svg?react';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { has } from 'lodash';
|
|
5
|
+
import { Fragment, use } from 'react';
|
|
6
|
+
import { CLASSES, DrawerContext } from './vars';
|
|
6
7
|
import { Button } from '../button';
|
|
7
8
|
import { useComponentProps, useControlled, useStyled, useTranslation } from '../hooks';
|
|
8
9
|
import { Icon } from '../icon';
|
|
9
10
|
import { mergeCS } from '../utils';
|
|
10
11
|
export function DrawerHeader(props) {
|
|
11
|
-
const _a = useComponentProps('DrawerHeader', props), { styleOverrides, styleProvider, children, actions = ['close'], closeProps: closePropsProp, onCloseClick
|
|
12
|
+
const _a = useComponentProps('DrawerHeader', props), { styleOverrides, styleProvider, children, actions = ['close'], closeProps: closePropsProp, onCloseClick } = _a, restProps = __rest(_a, ["styleOverrides", "styleProvider", "children", "actions", "closeProps", "onCloseClick"]);
|
|
12
13
|
const styled = useStyled(CLASSES, { drawer: styleProvider === null || styleProvider === void 0 ? void 0 : styleProvider.drawer }, styleOverrides);
|
|
13
14
|
const { t } = useTranslation();
|
|
15
|
+
const drawerContext = use(DrawerContext);
|
|
14
16
|
const [closeLoading, changeCloseLoading] = useControlled(false, closePropsProp === null || closePropsProp === void 0 ? void 0 : closePropsProp.loading);
|
|
15
17
|
const closeProps = Object.assign(Object.assign({}, closePropsProp), { loading: closeLoading, onClick: () => {
|
|
16
18
|
const shouldClose = onCloseClick === null || onCloseClick === void 0 ? void 0 : onCloseClick();
|
|
@@ -19,19 +21,20 @@ export function DrawerHeader(props) {
|
|
|
19
21
|
shouldClose.then((val) => {
|
|
20
22
|
changeCloseLoading(false);
|
|
21
23
|
if (val !== false) {
|
|
22
|
-
|
|
24
|
+
drawerContext === null || drawerContext === void 0 ? void 0 : drawerContext.onClose();
|
|
23
25
|
}
|
|
24
26
|
});
|
|
25
27
|
}
|
|
26
28
|
else if (shouldClose !== false) {
|
|
27
|
-
|
|
29
|
+
drawerContext === null || drawerContext === void 0 ? void 0 : drawerContext.onClose();
|
|
28
30
|
}
|
|
29
31
|
} });
|
|
30
32
|
return (_jsxs("div", Object.assign({}, restProps, mergeCS(styled('drawer__header'), {
|
|
31
33
|
className: restProps.className,
|
|
32
34
|
style: restProps.style,
|
|
33
|
-
}), { children: [_jsx("div", Object.assign({}, styled('drawer__header-title'), { id:
|
|
35
|
+
}), { children: [_jsx("div", Object.assign({}, styled('drawer__header-title'), { id: drawerContext === null || drawerContext === void 0 ? void 0 : drawerContext.id, children: children })), _jsx("div", Object.assign({}, styled('drawer__header-actions'), { children: actions.map((node, index) => {
|
|
34
36
|
var _a, _b, _c;
|
|
35
|
-
|
|
37
|
+
const { id, action } = (has(node, ['id', 'action']) ? node : { id: index, action: node });
|
|
38
|
+
return (_jsx(Fragment, { children: action === 'close' ? (_jsx(Button, Object.assign({}, closeProps, { "aria-label": (_a = closeProps['aria-label']) !== null && _a !== void 0 ? _a : t('Close'), pattern: (_b = closeProps.pattern) !== null && _b !== void 0 ? _b : 'text', icon: (_c = closeProps.icon) !== null && _c !== void 0 ? _c : (_jsx(Icon, { children: _jsx(CloseOutlined, {}) })) }))) : (action) }, id));
|
|
36
39
|
}) }))] })));
|
|
37
40
|
}
|
package/drawer/types.d.ts
CHANGED
|
@@ -17,18 +17,25 @@ export interface DrawerProps extends BaseProps<'drawer', typeof CLASSES>, React.
|
|
|
17
17
|
container?: RefExtra;
|
|
18
18
|
skipFirstTransition?: boolean;
|
|
19
19
|
destroyAfterClose?: boolean;
|
|
20
|
+
lazyLoading?: boolean;
|
|
20
21
|
zIndex?: number | string;
|
|
21
22
|
onClose?: () => void;
|
|
22
23
|
afterVisibleChange?: (visible: boolean) => void;
|
|
23
24
|
}
|
|
24
25
|
export interface DrawerHeaderProps extends BaseProps<'drawer', typeof CLASSES>, React.HTMLAttributes<HTMLDivElement> {
|
|
25
|
-
actions?: React.ReactNode
|
|
26
|
+
actions?: (React.ReactNode | {
|
|
27
|
+
id: React.Key;
|
|
28
|
+
action: React.ReactNode;
|
|
29
|
+
})[];
|
|
26
30
|
closeProps?: ButtonProps;
|
|
27
31
|
onCloseClick?: () => any | Promise<any>;
|
|
28
32
|
}
|
|
29
33
|
export interface DrawerFooterProps extends BaseProps<'drawer', typeof CLASSES>, Omit<React.HTMLAttributes<HTMLDivElement>, 'children'> {
|
|
30
34
|
align?: 'left' | 'center' | 'right';
|
|
31
|
-
actions?: React.ReactNode
|
|
35
|
+
actions?: (React.ReactNode | {
|
|
36
|
+
id: React.Key;
|
|
37
|
+
action: React.ReactNode;
|
|
38
|
+
})[];
|
|
32
39
|
cancelProps?: ButtonProps;
|
|
33
40
|
okProps?: ButtonProps;
|
|
34
41
|
onCancelClick?: () => any | Promise<any>;
|
package/drawer/vars.d.ts
CHANGED
|
@@ -16,4 +16,8 @@ export declare const CLASSES: {
|
|
|
16
16
|
'drawer__footer--center': string;
|
|
17
17
|
'drawer__footer--right': string;
|
|
18
18
|
};
|
|
19
|
-
export declare const DrawerContext: import("react").Context<
|
|
19
|
+
export declare const DrawerContext: import("react").Context<{
|
|
20
|
+
id: string;
|
|
21
|
+
onClose: () => void;
|
|
22
|
+
onVisibleChange: (offsets: Offsets) => void;
|
|
23
|
+
} | undefined>;
|
package/drawer/vars.js
CHANGED
package/dropdown/Dropdown.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import type { DropdownItem, DropdownProps
|
|
3
|
-
declare function
|
|
4
|
-
export declare const Dropdown: <ID extends React.Key, T extends DropdownItem<ID>>(props: DropdownProps<ID, T> & React.RefAttributes<DropdownRef>) => ReturnType<typeof DropdownFC>;
|
|
5
|
-
export {};
|
|
2
|
+
import type { DropdownItem, DropdownProps } from './types';
|
|
3
|
+
export declare function Dropdown<ID extends React.Key, T extends DropdownItem<ID>>(props: DropdownProps<ID, T>): React.ReactElement | null;
|