@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
|
@@ -3,14 +3,14 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
3
3
|
import { useEventCallback } from '@laser-ui/hooks';
|
|
4
4
|
import { scrollIntoViewIfNeeded } from '@laser-ui/utils';
|
|
5
5
|
import { isNumber, isUndefined } from 'lodash';
|
|
6
|
-
import {
|
|
6
|
+
import { useImperativeHandle, useMemo, useRef } from 'react';
|
|
7
7
|
import { Checkbox } from '../../checkbox';
|
|
8
8
|
import { Empty } from '../../empty';
|
|
9
9
|
import { getTreeNodeLabel } from '../../tree/utils';
|
|
10
10
|
import { TREE_NODE_KEY } from '../../tree/vars';
|
|
11
11
|
import { VirtualScroll } from '../../virtual-scroll';
|
|
12
|
-
function
|
|
13
|
-
const { namespace, styled, id, list, customItem, itemId, itemFocused, multiple, onlyLeafSelectable, virtual, focusVisible, onClick } = props;
|
|
12
|
+
export function CascaderSearchPanel(props) {
|
|
13
|
+
const { ref, namespace, styled, id, list, customItem, itemId, itemFocused, multiple, onlyLeafSelectable, virtual, focusVisible, onClick, } = props;
|
|
14
14
|
const listRef = useRef(null);
|
|
15
15
|
const vsRef = useRef(null);
|
|
16
16
|
const handleKeyDown = useEventCallback((code) => {
|
|
@@ -46,7 +46,12 @@ function CascaderSearchPanelFC(props, ref) {
|
|
|
46
46
|
itemSize: isNumber(virtual) ? virtual : 32,
|
|
47
47
|
itemFocusable: (item) => item[TREE_NODE_KEY].enabled,
|
|
48
48
|
}), [list, virtual]);
|
|
49
|
-
return (_jsx(VirtualScroll, Object.assign({}, vsProps, { ref:
|
|
49
|
+
return (_jsx(VirtualScroll, Object.assign({}, vsProps, { ref: (instance) => {
|
|
50
|
+
vsRef.current = instance;
|
|
51
|
+
return () => {
|
|
52
|
+
vsRef.current = null;
|
|
53
|
+
};
|
|
54
|
+
}, enable: virtual !== false, listSize: 264, listPadding: 4, itemRender: (item, index, props) => {
|
|
50
55
|
const node = item[TREE_NODE_KEY];
|
|
51
56
|
let inSelected = node.checked;
|
|
52
57
|
if (!onlyLeafSelectable) {
|
|
@@ -68,6 +73,10 @@ function CascaderSearchPanelFC(props, ref) {
|
|
|
68
73
|
focusVisible && (itemFocused === null || itemFocused === void 0 ? void 0 : itemFocused.value) === item.value && _jsx("div", { className: `${namespace}-focus-outline` }),
|
|
69
74
|
multiple && (_jsx("div", Object.assign({}, styled('cascader__option-prefix'), { children: _jsx(Checkbox, { model: node.checked, disabled: node.disabled }) }))),
|
|
70
75
|
_jsx("div", Object.assign({}, styled('cascader__option-content'), { children: customItem ? customItem(node.origin) : getTreeNodeLabel(node) }))));
|
|
71
|
-
}, itemFocused: itemFocused === null || itemFocused === void 0 ? void 0 : itemFocused.value, placeholder: "li", children: (vsList, onScroll) => (_jsx("ul", Object.assign({}, styled('cascader__list'), { ref:
|
|
76
|
+
}, itemFocused: itemFocused === null || itemFocused === void 0 ? void 0 : itemFocused.value, placeholder: "li", children: (vsList, onScroll) => (_jsx("ul", Object.assign({}, styled('cascader__list'), { ref: (instance) => {
|
|
77
|
+
listRef.current = instance;
|
|
78
|
+
return () => {
|
|
79
|
+
listRef.current = null;
|
|
80
|
+
};
|
|
81
|
+
}, id: id, tabIndex: -1, role: "listbox", "aria-multiselectable": multiple, "aria-activedescendant": isUndefined(itemFocused) ? undefined : itemId(itemFocused.value), onScroll: onScroll, children: list.length === 0 ? _jsx(Empty, { style: { padding: '12px 28px' }, image: Empty.SIMPLE_IMG }) : vsList }))) })));
|
|
72
82
|
}
|
|
73
|
-
export const CascaderSearchPanel = forwardRef(CascaderSearchPanelFC);
|
package/cascader/types.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { CLASSES } from './vars';
|
|
3
3
|
import type { FormControlProvider } from '../form/types';
|
|
4
|
-
import type { BaseProps,
|
|
4
|
+
import type { BaseProps, Size } from '../types';
|
|
5
5
|
export {};
|
|
6
6
|
export interface CascaderRef {
|
|
7
7
|
updatePosition: () => void;
|
|
@@ -14,6 +14,7 @@ export interface CascaderItem<V extends React.Key> {
|
|
|
14
14
|
children?: CascaderItem<V>[];
|
|
15
15
|
}
|
|
16
16
|
export interface CascaderProps<V extends React.Key, T extends CascaderItem<V>> extends BaseProps<'cascader' | 'cascader-popup', typeof CLASSES>, Omit<React.HTMLAttributes<HTMLDivElement>, 'children'> {
|
|
17
|
+
ref?: React.Ref<CascaderRef>;
|
|
17
18
|
formControl?: FormControlProvider;
|
|
18
19
|
list: T[];
|
|
19
20
|
model?: V | null | V[];
|
|
@@ -38,8 +39,7 @@ export interface CascaderProps<V extends React.Key, T extends CascaderItem<V>> e
|
|
|
38
39
|
filter?: (value: string, item: T) => boolean;
|
|
39
40
|
sort?: (a: T, b: T) => number;
|
|
40
41
|
};
|
|
41
|
-
|
|
42
|
-
inputRender?: CloneHTMLElement;
|
|
42
|
+
inputProps?: React.ComponentPropsWithRef<'input'>;
|
|
43
43
|
popupRender?: (el: React.ReactElement) => React.ReactNode;
|
|
44
44
|
onModelChange?: (value: any, origin: any) => void;
|
|
45
45
|
onVisibleChange?: (visible: boolean) => void;
|
package/checkbox/Checkbox.d.ts
CHANGED
package/checkbox/Checkbox.js
CHANGED
|
@@ -6,13 +6,10 @@ import { CLASSES } from './vars';
|
|
|
6
6
|
import { useComponentProps, useControlled, useScopedProps, useStyled } from '../hooks';
|
|
7
7
|
import { mergeCS } from '../utils';
|
|
8
8
|
export const Checkbox = (props) => {
|
|
9
|
-
const _a = useComponentProps('Checkbox', props), { children, styleOverrides, styleProvider, formControl, model, defaultModel, indeterminate = false, disabled: disabledProp = false,
|
|
9
|
+
const _a = useComponentProps('Checkbox', props), { children, styleOverrides, styleProvider, formControl, model, defaultModel, indeterminate = false, disabled: disabledProp = false, inputProps, onModelChange } = _a, restProps = __rest(_a, ["children", "styleOverrides", "styleProvider", "formControl", "model", "defaultModel", "indeterminate", "disabled", "inputProps", "onModelChange"]);
|
|
10
10
|
const styled = useStyled(CLASSES, { checkbox: styleProvider === null || styleProvider === void 0 ? void 0 : styleProvider.checkbox }, styleOverrides);
|
|
11
11
|
const [checked, changeChecked] = useControlled(defaultModel !== null && defaultModel !== void 0 ? defaultModel : false, model, onModelChange, undefined, formControl === null || formControl === void 0 ? void 0 : formControl.control);
|
|
12
12
|
const { disabled } = useScopedProps({ disabled: disabledProp || (formControl === null || formControl === void 0 ? void 0 : formControl.control.disabled) });
|
|
13
|
-
const inputNode = (_jsx("input", Object.assign({}, styled('checkbox__input'), formControl === null || formControl === void 0 ? void 0 : formControl.inputAria, { ref: inputRef, type: "checkbox", disabled: disabled, "aria-checked": indeterminate ? 'mixed' : checked, onChange: () => {
|
|
14
|
-
changeChecked((draft) => !draft);
|
|
15
|
-
} })));
|
|
16
13
|
return (_jsxs("label", Object.assign({}, restProps, mergeCS(styled('checkbox', {
|
|
17
14
|
'checkbox.is-checked': checked,
|
|
18
15
|
'checkbox.is-indeterminate': indeterminate,
|
|
@@ -20,6 +17,8 @@ export const Checkbox = (props) => {
|
|
|
20
17
|
}), {
|
|
21
18
|
className: restProps.className,
|
|
22
19
|
style: restProps.style,
|
|
23
|
-
}), { children: [_jsxs("div", Object.assign({}, styled('checkbox__state-container'), { children: [
|
|
20
|
+
}), { children: [_jsxs("div", Object.assign({}, styled('checkbox__state-container'), { children: [_jsx("input", Object.assign({}, inputProps, styled('checkbox__input'), formControl === null || formControl === void 0 ? void 0 : formControl.inputAria, { type: "checkbox", disabled: disabled, "aria-checked": indeterminate ? 'mixed' : checked, onChange: () => {
|
|
21
|
+
changeChecked((draft) => !draft);
|
|
22
|
+
} })), indeterminate ? _jsx("div", Object.assign({}, styled('checkbox__indeterminate'))) : checked && _jsx("div", Object.assign({}, styled('checkbox__tick')))] })), checkNodeExist(children) && _jsx("div", Object.assign({}, styled('checkbox__label'), { children: children }))] })));
|
|
24
23
|
};
|
|
25
24
|
Checkbox.Group = CheckboxGroup;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { CheckboxGroupItem, CheckboxGroupProps } from './types';
|
|
3
|
-
export declare function CheckboxGroup<V extends React.Key, T extends CheckboxGroupItem<V>>(props: CheckboxGroupProps<V, T>):
|
|
3
|
+
export declare function CheckboxGroup<V extends React.Key, T extends CheckboxGroupItem<V>>(props: CheckboxGroupProps<V, T>): React.ReactElement | null;
|
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { cloneElement } from 'react';
|
|
3
|
-
import { Checkbox } from './Checkbox';
|
|
4
1
|
import { useComponentProps, useControlled, useScopedProps } from '../hooks';
|
|
5
2
|
export function CheckboxGroup(props) {
|
|
6
|
-
var _a;
|
|
7
3
|
const { children, formControl, list, model, defaultModel, disabled: disabledProp = false, onModelChange, } = useComponentProps('CheckboxGroup', props);
|
|
8
4
|
const [values, changeValues] = useControlled(defaultModel !== null && defaultModel !== void 0 ? defaultModel : [], model, (vals) => {
|
|
9
5
|
if (onModelChange) {
|
|
@@ -11,7 +7,12 @@ export function CheckboxGroup(props) {
|
|
|
11
7
|
}
|
|
12
8
|
}, undefined, formControl === null || formControl === void 0 ? void 0 : formControl.control);
|
|
13
9
|
const { disabled } = useScopedProps({ disabled: disabledProp || (formControl === null || formControl === void 0 ? void 0 : formControl.control.disabled) });
|
|
14
|
-
|
|
10
|
+
return children({ role: 'group' }, (option) => ({
|
|
11
|
+
children: option.label,
|
|
12
|
+
model: values.includes(option.value),
|
|
13
|
+
disabled: option.disabled || disabled,
|
|
14
|
+
inputProps: formControl === null || formControl === void 0 ? void 0 : formControl.inputAria,
|
|
15
|
+
onModelChange: (checked) => {
|
|
15
16
|
changeValues((draft) => {
|
|
16
17
|
if (checked) {
|
|
17
18
|
draft.push(option.value);
|
|
@@ -20,6 +21,6 @@ export function CheckboxGroup(props) {
|
|
|
20
21
|
draft.splice(draft.findIndex((v) => v === option.value), 1);
|
|
21
22
|
}
|
|
22
23
|
});
|
|
23
|
-
},
|
|
24
|
-
|
|
24
|
+
},
|
|
25
|
+
}), list);
|
|
25
26
|
}
|
package/checkbox/types.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { CLASSES } from './vars';
|
|
3
3
|
import type { FormControlProvider } from '../form/types';
|
|
4
|
-
import type { BaseProps
|
|
4
|
+
import type { BaseProps } from '../types';
|
|
5
5
|
export {};
|
|
6
6
|
export interface CheckboxProps extends BaseProps<'checkbox', typeof CLASSES>, React.LabelHTMLAttributes<HTMLLabelElement> {
|
|
7
7
|
formControl?: FormControlProvider;
|
|
@@ -9,8 +9,7 @@ export interface CheckboxProps extends BaseProps<'checkbox', typeof CLASSES>, Re
|
|
|
9
9
|
defaultModel?: boolean;
|
|
10
10
|
indeterminate?: boolean;
|
|
11
11
|
disabled?: boolean;
|
|
12
|
-
|
|
13
|
-
inputRender?: CloneHTMLElement;
|
|
12
|
+
inputProps?: React.ComponentPropsWithRef<'input'>;
|
|
14
13
|
onModelChange?: (checked: boolean) => void;
|
|
15
14
|
}
|
|
16
15
|
export interface CheckboxGroupItem<V extends React.Key> {
|
|
@@ -19,7 +18,18 @@ export interface CheckboxGroupItem<V extends React.Key> {
|
|
|
19
18
|
disabled?: boolean;
|
|
20
19
|
}
|
|
21
20
|
export interface CheckboxGroupProps<V extends React.Key, T extends CheckboxGroupItem<V>> {
|
|
22
|
-
children: (
|
|
21
|
+
children: (props: {
|
|
22
|
+
role: 'group';
|
|
23
|
+
}, optionProps: (option: T) => {
|
|
24
|
+
children: React.ReactNode;
|
|
25
|
+
model: boolean;
|
|
26
|
+
disabled: boolean;
|
|
27
|
+
inputProps?: {
|
|
28
|
+
'aria-invalid'?: boolean;
|
|
29
|
+
'aria-describedby'?: string;
|
|
30
|
+
};
|
|
31
|
+
onModelChange: (checked: boolean) => void;
|
|
32
|
+
}, options: T[]) => React.ReactElement | null;
|
|
23
33
|
formControl?: FormControlProvider;
|
|
24
34
|
list: T[];
|
|
25
35
|
model?: V[];
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
export declare function CircularProgress(props: React.SVGProps<SVGSVGElement>):
|
|
2
|
+
export declare function CircularProgress(props: React.SVGProps<SVGSVGElement>): React.ReactElement | null;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { CLASSES } from './vars';
|
|
3
|
-
import { useStyled } from '
|
|
4
|
-
import { mergeCS } from '
|
|
3
|
+
import { useStyled } from '../hooks';
|
|
4
|
+
import { mergeCS } from '../utils';
|
|
5
5
|
export function CircularProgress(props) {
|
|
6
6
|
const styled = useStyled(CLASSES, { 'circular-progress': undefined });
|
|
7
7
|
return (_jsx("svg", Object.assign({}, props, mergeCS(styled('circular-progress'), {
|
package/compose/Compose.d.ts
CHANGED
package/compose/ComposeItem.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { use, useMemo } from 'react';
|
|
3
3
|
import { LContextManager } from '../context';
|
|
4
4
|
import { LContext } from '../context';
|
|
5
5
|
export function ConfigProvider(props) {
|
|
6
6
|
const { children, context: contextProp } = props;
|
|
7
|
-
const parent =
|
|
7
|
+
const parent = use(LContext);
|
|
8
8
|
const context = useMemo(() => {
|
|
9
9
|
const context = new LContextManager(parent.derive(contextProp !== null && contextProp !== void 0 ? contextProp : {}));
|
|
10
10
|
context.setParent(parent);
|
|
11
11
|
return context;
|
|
12
12
|
}, [contextProp, parent]);
|
|
13
|
-
return _jsx(LContext
|
|
13
|
+
return _jsx(LContext, { value: context, children: children });
|
|
14
14
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import type { DatePickerProps
|
|
3
|
-
export declare
|
|
2
|
+
import type { DatePickerProps } from './types';
|
|
3
|
+
export declare function DatePicker(props: DatePickerProps): React.ReactElement | null;
|
|
@@ -1,36 +1,36 @@
|
|
|
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, useEventCallback, useForceUpdate,
|
|
4
|
+
import { useAsync, useEventCallback, useForceUpdate, useImmer, useIsomorphicLayoutEffect, useResize } from '@laser-ui/hooks';
|
|
5
|
+
import { setRef } from '@laser-ui/utils';
|
|
5
6
|
import CancelFilled from '@material-design-icons/svg/filled/cancel.svg?react';
|
|
6
7
|
import CalendarTodayOutlined from '@material-design-icons/svg/outlined/calendar_today.svg?react';
|
|
7
8
|
import SwapHorizOutlined from '@material-design-icons/svg/outlined/swap_horiz.svg?react';
|
|
8
9
|
import { isArray, isBoolean, isNull, isUndefined } from 'lodash';
|
|
9
|
-
import {
|
|
10
|
+
import { useEffect, useImperativeHandle, useRef } from 'react';
|
|
10
11
|
import { DatePickerPanel } from './internal/DatePickerPanel';
|
|
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
20
|
import { TimePickerPanel } from '../time-picker/internal/TimePickerPanel';
|
|
21
21
|
import { deepCompareDate, orderDate } from '../time-picker/utils';
|
|
22
|
+
import { Transition } from '../transition';
|
|
22
23
|
import { getVerticalSidePosition, mergeCS } from '../utils';
|
|
23
24
|
import { TTANSITION_DURING_POPUP, WINDOW_SPACE } from '../vars';
|
|
24
|
-
export
|
|
25
|
+
export function DatePicker(props) {
|
|
25
26
|
var _a, _b;
|
|
26
|
-
const _c = useComponentProps('DatePicker', props), { styleOverrides, styleProvider, formControl, model, defaultModel, visible: visibleProp, defaultVisible, placeholder, range = false, format: formatProp, order: orderProp = 'ascend', clearable: clearableProp = false, size: sizeProp, disabled: disabledProp = false, presetDate, config, showTime = false, escClosable = true,
|
|
27
|
+
const _c = useComponentProps('DatePicker', props), { ref, styleOverrides, styleProvider, formControl, model, defaultModel, visible: visibleProp, defaultVisible, placeholder, range = false, format: formatProp, order: orderProp = 'ascend', clearable: clearableProp = false, size: sizeProp, disabled: disabledProp = false, presetDate, config, showTime = false, 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", "presetDate", "config", "showTime", "escClosable", "inputProps", "onModelChange", "onVisibleChange", "onClear", "afterVisibleChange"]);
|
|
27
28
|
const namespace = useNamespace();
|
|
28
29
|
const styled = useStyled(CLASSES, {
|
|
29
30
|
'date-picker': styleProvider === null || styleProvider === void 0 ? void 0 : styleProvider['date-picker'],
|
|
30
31
|
'time-picker': styleProvider === null || styleProvider === void 0 ? void 0 : styleProvider['time-picker'],
|
|
31
32
|
'date-picker-popup': styleProvider === null || styleProvider === void 0 ? void 0 : styleProvider['date-picker-popup'],
|
|
32
33
|
}, styleOverrides);
|
|
33
|
-
const sheet = useJSS();
|
|
34
34
|
const { t } = useTranslation();
|
|
35
35
|
const forceUpdate = useForceUpdate();
|
|
36
36
|
const async = useAsync();
|
|
@@ -40,8 +40,6 @@ export const DatePicker = forwardRef((props, ref) => {
|
|
|
40
40
|
const inputLeftRef = useRef(null);
|
|
41
41
|
const inputRightRef = useRef(null);
|
|
42
42
|
const indicatorRef = useRef(null);
|
|
43
|
-
const combineInputLeftRef = useForkRef(inputLeftRef, inputRef === null || inputRef === void 0 ? void 0 : inputRef[0]);
|
|
44
|
-
const combineInputRightRef = useForkRef(inputRightRef, inputRef === null || inputRef === void 0 ? void 0 : inputRef[1]);
|
|
45
43
|
const panelRef = useRef(null);
|
|
46
44
|
const timePickerPanelRef = useRef(null);
|
|
47
45
|
const updatePanel = (date) => {
|
|
@@ -119,7 +117,6 @@ export const DatePicker = forwardRef((props, ref) => {
|
|
|
119
117
|
const { size, disabled } = useScopedProps({ size: sizeProp, disabled: disabledProp || (formControl === null || formControl === void 0 ? void 0 : formControl.control.disabled) });
|
|
120
118
|
const maxZIndex = useMaxIndex(visible);
|
|
121
119
|
const zIndex = `calc(var(--${namespace}-zindex-fixed) + ${maxZIndex})`;
|
|
122
|
-
const transformOrigin = useRef();
|
|
123
120
|
const updatePosition = useEventCallback(() => {
|
|
124
121
|
if (visible && boxRef.current && popupRef.current) {
|
|
125
122
|
const height = popupRef.current.offsetHeight;
|
|
@@ -129,16 +126,10 @@ export const DatePicker = forwardRef((props, ref) => {
|
|
|
129
126
|
placement: 'bottom-left',
|
|
130
127
|
inWindow: WINDOW_SPACE,
|
|
131
128
|
});
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
sheet.replaceRule('position', {
|
|
137
|
-
top: position.top,
|
|
138
|
-
left: position.left,
|
|
139
|
-
maxWidth,
|
|
140
|
-
});
|
|
141
|
-
popupRef.current.classList.toggle(sheet.classes.position, true);
|
|
129
|
+
popupRef.current.style.setProperty(`--popup-down-transform-origin`, position.transformOrigin);
|
|
130
|
+
popupRef.current.style.top = position.top + 'px';
|
|
131
|
+
popupRef.current.style.left = position.left + 'px';
|
|
132
|
+
popupRef.current.style.maxWidth = maxWidth + 'px';
|
|
142
133
|
}
|
|
143
134
|
});
|
|
144
135
|
useContainerScrolling(boxRef, updatePosition, !visible);
|
|
@@ -148,7 +139,7 @@ export const DatePicker = forwardRef((props, ref) => {
|
|
|
148
139
|
useImperativeHandle(ref, () => ({
|
|
149
140
|
updatePosition,
|
|
150
141
|
}), [updatePosition]);
|
|
151
|
-
|
|
142
|
+
useIsomorphicLayoutEffect(() => {
|
|
152
143
|
if (boxRef.current && indicatorRef.current) {
|
|
153
144
|
let focus = false;
|
|
154
145
|
const boxRect = boxRef.current.getBoundingClientRect();
|
|
@@ -202,8 +193,16 @@ export const DatePicker = forwardRef((props, ref) => {
|
|
|
202
193
|
const inputNode = (isLeft) => {
|
|
203
194
|
const index = isLeft ? 0 : 1;
|
|
204
195
|
const value = isLeft ? valueLeft : valueRight;
|
|
205
|
-
const
|
|
206
|
-
|
|
196
|
+
const inputRef = isLeft ? inputLeftRef : inputRightRef;
|
|
197
|
+
return (_jsx(BaseInput, Object.assign({}, inputProps === null || inputProps === void 0 ? void 0 : inputProps[index], styled('date-picker__input'), formControl === null || formControl === void 0 ? void 0 : formControl.inputAria, { ref: (instance) => {
|
|
198
|
+
var _a;
|
|
199
|
+
inputRef.current = instance;
|
|
200
|
+
const ret = setRef((_a = inputProps === null || inputProps === void 0 ? void 0 : inputProps[index]) === null || _a === void 0 ? void 0 : _a.ref, instance);
|
|
201
|
+
return () => {
|
|
202
|
+
inputRef.current = null;
|
|
203
|
+
ret();
|
|
204
|
+
};
|
|
205
|
+
}, type: "text", autoComplete: "off", value: inputValue[index], size: 22, placeholder: isLeft ? placeholderLeft : placeholderRight, disabled: disabled, onValueChange: (val) => {
|
|
207
206
|
forceUpdate();
|
|
208
207
|
dataRef.current.inputValue[index] = val;
|
|
209
208
|
if (dayjs(val, format, true).isValid()) {
|
|
@@ -212,6 +211,8 @@ export const DatePicker = forwardRef((props, ref) => {
|
|
|
212
211
|
updatePanel(date);
|
|
213
212
|
}
|
|
214
213
|
}, onKeyDown: (e) => {
|
|
214
|
+
var _a, _b;
|
|
215
|
+
(_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);
|
|
215
216
|
if (e.code === 'Escape') {
|
|
216
217
|
if (visible && escClosable) {
|
|
217
218
|
e.stopPropagation();
|
|
@@ -224,9 +225,10 @@ export const DatePicker = forwardRef((props, ref) => {
|
|
|
224
225
|
const date = dayjs(inputValue[index], format).toDate();
|
|
225
226
|
handleEnter(date);
|
|
226
227
|
}
|
|
227
|
-
}, onFocus: () => {
|
|
228
|
-
var _a, _b;
|
|
229
|
-
(_b = (_a =
|
|
228
|
+
}, onFocus: (e) => {
|
|
229
|
+
var _a, _b, _c, _d;
|
|
230
|
+
(_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);
|
|
231
|
+
(_d = (_c = dataRef.current).clearTid) === null || _d === void 0 ? void 0 : _d.call(_c);
|
|
230
232
|
setFocused((draft) => {
|
|
231
233
|
draft.fill(false);
|
|
232
234
|
draft[isLeft ? 0 : 1] = true;
|
|
@@ -235,13 +237,14 @@ export const DatePicker = forwardRef((props, ref) => {
|
|
|
235
237
|
if (visible && range && value) {
|
|
236
238
|
updatePanel(value);
|
|
237
239
|
}
|
|
238
|
-
}, onBlur: () => {
|
|
240
|
+
}, onBlur: (e) => {
|
|
241
|
+
var _a, _b;
|
|
242
|
+
(_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);
|
|
239
243
|
dataRef.current.clearTid = async.setTimeout(() => {
|
|
240
244
|
setFocused([false, false]);
|
|
241
245
|
changeVisible(false);
|
|
242
246
|
}, 20);
|
|
243
247
|
} })));
|
|
244
|
-
return render ? render(node) : node;
|
|
245
248
|
};
|
|
246
249
|
const preventBlur = (e) => {
|
|
247
250
|
if ((document.activeElement === inputLeftRef.current || document.activeElement === inputRightRef.current) &&
|
|
@@ -257,7 +260,12 @@ export const DatePicker = forwardRef((props, ref) => {
|
|
|
257
260
|
}), {
|
|
258
261
|
className: restProps.className,
|
|
259
262
|
style: restProps.style,
|
|
260
|
-
}), designProps, { ref:
|
|
263
|
+
}), designProps, { ref: (instance) => {
|
|
264
|
+
boxRef.current = instance;
|
|
265
|
+
return () => {
|
|
266
|
+
boxRef.current = null;
|
|
267
|
+
};
|
|
268
|
+
}, onMouseDown: (e) => {
|
|
261
269
|
var _a;
|
|
262
270
|
(_a = restProps.onMouseDown) === null || _a === void 0 ? void 0 : _a.call(restProps, e);
|
|
263
271
|
preventBlur(e);
|
|
@@ -272,7 +280,12 @@ export const DatePicker = forwardRef((props, ref) => {
|
|
|
272
280
|
(_b = inputLeftRef.current) === null || _b === void 0 ? void 0 : _b.focus({ preventScroll: true });
|
|
273
281
|
}
|
|
274
282
|
changeVisible(true);
|
|
275
|
-
}, children: [inputNode(true), range && (_jsxs(_Fragment, { children: [_jsx("div", Object.assign({}, styled('date-picker__indicator'), { ref:
|
|
283
|
+
}, children: [inputNode(true), range && (_jsxs(_Fragment, { children: [_jsx("div", Object.assign({}, styled('date-picker__indicator'), { ref: (instance) => {
|
|
284
|
+
indicatorRef.current = instance;
|
|
285
|
+
return () => {
|
|
286
|
+
indicatorRef.current = null;
|
|
287
|
+
};
|
|
288
|
+
} })), _jsx("div", Object.assign({}, styled('date-picker__separator'), { children: _jsx(Icon, { children: _jsx(SwapHorizOutlined, {}) }) })), inputNode(false)] })), clearable && (_jsx("div", Object.assign({}, styled('date-picker__clear'), { role: "button", "aria-label": t('Clear'), onClick: (e) => {
|
|
276
289
|
e.stopPropagation();
|
|
277
290
|
dataRef.current.inputValue = [undefined, undefined];
|
|
278
291
|
_changeValue(null);
|
|
@@ -287,7 +300,7 @@ export const DatePicker = forwardRef((props, ref) => {
|
|
|
287
300
|
document.body.appendChild(el);
|
|
288
301
|
}
|
|
289
302
|
return el;
|
|
290
|
-
}, children: _jsx(Transition, { enter: visible,
|
|
303
|
+
}, children: _jsx(Transition, { enter: visible, name: `${namespace}-popup-down`, duration: TTANSITION_DURING_POPUP, onSkipEnter: () => {
|
|
291
304
|
updatePosition();
|
|
292
305
|
const cb = () => {
|
|
293
306
|
const value = focused[0] ? valueLeft : valueRight;
|
|
@@ -302,76 +315,81 @@ export const DatePicker = forwardRef((props, ref) => {
|
|
|
302
315
|
dataRef.current.onceVisible = true;
|
|
303
316
|
cb();
|
|
304
317
|
}
|
|
305
|
-
},
|
|
318
|
+
}, onBeforeEnter: () => {
|
|
319
|
+
updatePosition();
|
|
320
|
+
const cb = () => {
|
|
321
|
+
const value = focused[0] ? valueLeft : valueRight;
|
|
322
|
+
if (value) {
|
|
323
|
+
updatePanel(value);
|
|
324
|
+
}
|
|
325
|
+
};
|
|
326
|
+
if (range) {
|
|
327
|
+
cb();
|
|
328
|
+
}
|
|
329
|
+
else if (!dataRef.current.onceVisible) {
|
|
330
|
+
dataRef.current.onceVisible = true;
|
|
331
|
+
cb();
|
|
332
|
+
}
|
|
333
|
+
}, onAfterEnter: () => {
|
|
306
334
|
afterVisibleChange === null || afterVisibleChange === void 0 ? void 0 : afterVisibleChange(true);
|
|
307
|
-
},
|
|
335
|
+
}, onAfterLeave: () => {
|
|
308
336
|
afterVisibleChange === null || afterVisibleChange === void 0 ? void 0 : afterVisibleChange(false);
|
|
309
|
-
}, children: (
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
transitionStyle = { display: 'none' };
|
|
331
|
-
break;
|
|
332
|
-
default:
|
|
333
|
-
break;
|
|
334
|
-
}
|
|
335
|
-
return (_jsxs("div", Object.assign({}, mergeCS(styled('date-picker-popup'), {
|
|
336
|
-
style: Object.assign({ zIndex }, transitionStyle),
|
|
337
|
-
}), { ref: popupRef, onMouseDown: (e) => {
|
|
338
|
-
preventBlur(e);
|
|
339
|
-
}, onMouseUp: (e) => {
|
|
340
|
-
preventBlur(e);
|
|
341
|
-
}, children: [presetDate && (_jsx("ul", Object.assign({}, styled('date-picker__preset'), { children: Object.keys(presetDate).map((name) => {
|
|
342
|
-
const handleClick = () => {
|
|
343
|
-
const date = presetDate[name]();
|
|
344
|
-
dataRef.current.inputValue = [undefined, undefined];
|
|
345
|
-
if (range) {
|
|
346
|
-
if (isArray(date)) {
|
|
347
|
-
_changeValue(date);
|
|
348
|
-
changeVisible(false);
|
|
349
|
-
}
|
|
350
|
-
else {
|
|
351
|
-
changeValue(date);
|
|
352
|
-
handleEnter(date);
|
|
353
|
-
}
|
|
337
|
+
}, children: (transitionRef, leaved) => (_jsxs("div", Object.assign({}, mergeCS(styled('date-picker-popup'), {
|
|
338
|
+
style: Object.assign({ zIndex }, (leaved ? { display: 'none' } : undefined)),
|
|
339
|
+
}), { ref: (instance) => {
|
|
340
|
+
popupRef.current = instance;
|
|
341
|
+
transitionRef(instance);
|
|
342
|
+
return () => {
|
|
343
|
+
popupRef.current = null;
|
|
344
|
+
transitionRef(null);
|
|
345
|
+
};
|
|
346
|
+
}, onMouseDown: (e) => {
|
|
347
|
+
preventBlur(e);
|
|
348
|
+
}, onMouseUp: (e) => {
|
|
349
|
+
preventBlur(e);
|
|
350
|
+
}, children: [presetDate && (_jsx("ul", Object.assign({}, styled('date-picker__preset'), { children: Object.keys(presetDate).map((name) => {
|
|
351
|
+
const handleClick = () => {
|
|
352
|
+
const date = presetDate[name]();
|
|
353
|
+
dataRef.current.inputValue = [undefined, undefined];
|
|
354
|
+
if (range) {
|
|
355
|
+
if (isArray(date)) {
|
|
356
|
+
_changeValue(date);
|
|
357
|
+
changeVisible(false);
|
|
354
358
|
}
|
|
355
359
|
else {
|
|
356
|
-
|
|
360
|
+
changeValue(date);
|
|
357
361
|
handleEnter(date);
|
|
358
362
|
}
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
363
|
+
}
|
|
364
|
+
else {
|
|
365
|
+
_changeValue(date);
|
|
366
|
+
handleEnter(date);
|
|
367
|
+
}
|
|
368
|
+
};
|
|
369
|
+
return (_createElement("li", Object.assign({}, styled('date-picker__preset-option'), { key: name, role: "button", onClick: handleClick }), name));
|
|
370
|
+
}) }))), _jsxs("div", Object.assign({}, styled('date-picker__panel-wrapper'), { children: [_jsx(DatePickerPanel, { ref: (instance) => {
|
|
371
|
+
panelRef.current = instance;
|
|
372
|
+
return () => {
|
|
373
|
+
panelRef.current = null;
|
|
374
|
+
};
|
|
375
|
+
}, styled: styled, currentSelected: dataRef.current.latestFocused === 'start' ? valueLeft : valueRight, anotherSelected: dataRef.current.latestFocused === 'start' ? valueRight : valueLeft, config: config ? (...args) => config(...args, dataRef.current.latestFocused, [valueLeft, valueRight]) : undefined, range: range, onDateChange: (date) => {
|
|
376
|
+
changeValue(date);
|
|
377
|
+
if (!showTime) {
|
|
378
|
+
handleEnter(date);
|
|
379
|
+
}
|
|
380
|
+
} }), showTime && (_jsx(TimePickerPanel, { ref: (instance) => {
|
|
381
|
+
timePickerPanelRef.current = instance;
|
|
382
|
+
return () => {
|
|
383
|
+
timePickerPanelRef.current = null;
|
|
384
|
+
};
|
|
385
|
+
}, styled: styled, time: dataRef.current.latestFocused === 'start' ? valueLeft : valueRight, format: format, config: showTime && !isBoolean(showTime) && showTime.config
|
|
386
|
+
? // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
387
|
+
(...args) => showTime.config(...args, dataRef.current.latestFocused, [valueLeft, valueRight])
|
|
388
|
+
: undefined, inDatePicker: true, onTimeChange: (time) => {
|
|
389
|
+
changeValue(time);
|
|
390
|
+
} })), _jsx("div", Object.assign({}, styled('date-picker__footer'), { children: _jsx(Button, { pattern: "link", onClick: () => {
|
|
391
|
+
const now = new Date();
|
|
392
|
+
changeValue(now);
|
|
393
|
+
handleEnter(now);
|
|
394
|
+
}, children: t('DatePicker', showTime ? 'Now' : 'Today') }) }))] }))] }))) }) })] }));
|
|
395
|
+
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import type { Styled } from '../../hooks/useStyled';
|
|
3
3
|
import type { CLASSES } from '../vars';
|
|
4
4
|
interface DatePickerPanelProps {
|
|
5
|
+
ref?: React.Ref<(date: Date) => void>;
|
|
5
6
|
styled: Styled<typeof CLASSES>;
|
|
6
7
|
currentSelected: Date | null;
|
|
7
8
|
anotherSelected: Date | null;
|
|
@@ -11,5 +12,5 @@ interface DatePickerPanelProps {
|
|
|
11
12
|
range: boolean;
|
|
12
13
|
onDateChange: (date: Date) => void;
|
|
13
14
|
}
|
|
14
|
-
export declare
|
|
15
|
+
export declare function DatePickerPanel(props: DatePickerPanelProps): React.ReactElement | null;
|
|
15
16
|
export {};
|