@douyinfe/semi-ui 2.22.0-beta.0 → 2.22.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/css/semi.css +438 -38
- package/dist/css/semi.min.css +1 -1
- package/dist/umd/semi-ui.js +4084 -5300
- package/dist/umd/semi-ui.js.map +1 -1
- package/dist/umd/semi-ui.min.js +1 -1
- package/dist/umd/semi-ui.min.js.map +1 -1
- package/lib/cjs/_cssAnimation/index.d.ts +39 -0
- package/lib/cjs/_cssAnimation/index.js +133 -0
- package/lib/cjs/anchor/index.d.ts +3 -3
- package/lib/cjs/anchor/link.d.ts +1 -1
- package/lib/cjs/autoComplete/index.d.ts +7 -8
- package/lib/cjs/autoComplete/option.d.ts +1 -1
- package/lib/cjs/banner/index.d.ts +2 -2
- package/lib/cjs/breadcrumb/index.d.ts +3 -3
- package/lib/cjs/breadcrumb/item.d.ts +3 -3
- package/lib/cjs/button/index.d.ts +2 -2
- package/lib/cjs/calendar/dayCalendar.d.ts +2 -2
- package/lib/cjs/calendar/index.d.ts +2 -2
- package/lib/cjs/calendar/monthCalendar.d.ts +2 -2
- package/lib/cjs/calendar/rangeCalendar.d.ts +2 -2
- package/lib/cjs/calendar/weekCalendar.d.ts +2 -2
- package/lib/cjs/card/cardGroup.d.ts +1 -1
- package/lib/cjs/carousel/index.d.ts +1 -1
- package/lib/cjs/cascader/index.d.ts +7 -8
- package/lib/cjs/cascader/index.js +8 -6
- package/lib/cjs/collapse/collapse-context.d.ts +1 -2
- package/lib/cjs/collapse/index.d.ts +3 -3
- package/lib/cjs/collapse/item.d.ts +2 -2
- package/lib/cjs/collapsible/index.d.ts +32 -19
- package/lib/cjs/collapsible/index.js +157 -121
- package/lib/cjs/configProvider/index.d.ts +1 -1
- package/lib/cjs/datePicker/dateInput.d.ts +3 -3
- package/lib/cjs/datePicker/datePicker.d.ts +12 -9
- package/lib/cjs/datePicker/datePicker.js +11 -13
- package/lib/cjs/datePicker/month.d.ts +1 -1
- package/lib/cjs/datePicker/month.js +5 -1
- package/lib/cjs/datePicker/monthsGrid.d.ts +7 -6
- package/lib/cjs/datePicker/monthsGrid.js +9 -26
- package/lib/cjs/datePicker/quickControl.d.ts +1 -1
- package/lib/cjs/datePicker/yearAndMonth.d.ts +1 -1
- package/lib/cjs/datePicker/yearAndMonth.js +13 -8
- package/lib/cjs/descriptions/index.d.ts +1 -1
- package/lib/cjs/dropdown/dropdownItem.d.ts +2 -1
- package/lib/cjs/dropdown/dropdownItem.js +3 -1
- package/lib/cjs/dropdown/index.d.ts +5 -6
- package/lib/cjs/form/baseForm.d.ts +7 -5
- package/lib/cjs/form/errorMessage.d.ts +1 -1
- package/lib/cjs/form/field.d.ts +4 -2
- package/lib/cjs/form/label.d.ts +1 -1
- package/lib/cjs/grid/col.d.ts +6 -6
- package/lib/cjs/grid/row.d.ts +1 -1
- package/lib/cjs/iconButton/index.d.ts +2 -2
- package/lib/cjs/image/image.d.ts +4 -4
- package/lib/cjs/image/preview.d.ts +1 -1
- package/lib/cjs/image/previewInner.d.ts +1 -1
- package/lib/cjs/index.d.ts +1 -0
- package/lib/cjs/index.js +8 -0
- package/lib/cjs/inputNumber/index.d.ts +2 -2
- package/lib/cjs/locale/source/ro.d.ts +3 -3
- package/lib/cjs/modal/Modal.d.ts +6 -6
- package/lib/cjs/modal/Modal.js +80 -56
- package/lib/cjs/modal/ModalContent.js +6 -5
- package/lib/cjs/modal/confirm.d.ts +10 -10
- package/lib/cjs/modal/confirm.js +1 -15
- package/lib/cjs/modal/useModal/HookModal.d.ts +0 -2
- package/lib/cjs/modal/useModal/HookModal.js +6 -18
- package/lib/cjs/navigation/Footer.d.ts +1 -1
- package/lib/cjs/navigation/Header.d.ts +3 -3
- package/lib/cjs/navigation/Item.d.ts +4 -4
- package/lib/cjs/navigation/Item.js +11 -5
- package/lib/cjs/navigation/OpenIconTransition.d.ts +1 -15
- package/lib/cjs/navigation/OpenIconTransition.js +1 -82
- package/lib/cjs/navigation/SubNav.d.ts +4 -4
- package/lib/cjs/navigation/SubNav.js +43 -27
- package/lib/cjs/navigation/index.d.ts +8 -11
- package/lib/cjs/notification/index.d.ts +0 -1
- package/lib/cjs/notification/index.js +25 -15
- package/lib/cjs/notification/notice.d.ts +3 -1
- package/lib/cjs/notification/notice.js +3 -1
- package/lib/cjs/popconfirm/index.d.ts +4 -5
- package/lib/cjs/popover/index.d.ts +8 -8
- package/lib/cjs/popover/index.js +1 -1
- package/lib/cjs/progress/index.d.ts +4 -4
- package/lib/cjs/rating/index.d.ts +1 -1
- package/lib/cjs/rating/item.d.ts +1 -1
- package/lib/cjs/scrollList/index.d.ts +1 -1
- package/lib/cjs/scrollList/scrollItem.d.ts +3 -3
- package/lib/cjs/scrollList/scrollItem.js +2 -2
- package/lib/cjs/select/index.d.ts +11 -6
- package/lib/cjs/select/index.js +108 -60
- package/lib/cjs/select/option.d.ts +1 -1
- package/lib/cjs/select/optionGroup.d.ts +1 -1
- package/lib/cjs/sideSheet/SideSheetContent.d.ts +8 -0
- package/lib/cjs/sideSheet/SideSheetContent.js +10 -6
- package/lib/cjs/sideSheet/index.d.ts +4 -4
- package/lib/cjs/sideSheet/index.js +69 -39
- package/lib/cjs/space/index.d.ts +1 -1
- package/lib/cjs/spin/index.js +1 -4
- package/lib/cjs/table/Body/BaseRow.d.ts +5 -5
- package/lib/cjs/table/Body/ExpandedRow.d.ts +3 -3
- package/lib/cjs/table/Body/SectionRow.d.ts +3 -3
- package/lib/cjs/table/Column.d.ts +4 -4
- package/lib/cjs/table/ColumnShape.d.ts +4 -4
- package/lib/cjs/table/ColumnSorter.d.ts +1 -1
- package/lib/cjs/table/CustomExpandIcon.d.ts +1 -1
- package/lib/cjs/table/CustomExpandIcon.js +13 -5
- package/lib/cjs/table/Table.d.ts +16 -16
- package/lib/cjs/table/TableCell.d.ts +4 -4
- package/lib/cjs/table/TableHeaderRow.d.ts +2 -2
- package/lib/cjs/table/TablePagination.d.ts +1 -1
- package/lib/cjs/table/index.d.ts +15 -15
- package/lib/cjs/tabs/TabPane.d.ts +2 -8
- package/lib/cjs/tabs/TabPane.js +40 -38
- package/lib/cjs/tabs/index.d.ts +5 -3
- package/lib/cjs/tabs/index.js +26 -4
- package/lib/cjs/tabs/interface.d.ts +2 -0
- package/lib/cjs/tag/group.d.ts +1 -0
- package/lib/cjs/tag/group.js +6 -3
- package/lib/cjs/tag/index.d.ts +1 -1
- package/lib/cjs/tag/index.js +1 -0
- package/lib/cjs/tag/interface.d.ts +3 -1
- package/lib/cjs/tagInput/index.d.ts +3 -3
- package/lib/cjs/timePicker/Combobox.js +4 -8
- package/lib/cjs/timePicker/PanelShape.d.ts +2 -2
- package/lib/cjs/timePicker/TimePicker.d.ts +11 -11
- package/lib/cjs/timePicker/TimePicker.js +3 -1
- package/lib/cjs/timePicker/TimeShape.d.ts +1 -1
- package/lib/cjs/timePicker/index.d.ts +10 -9
- package/lib/cjs/timeline/index.d.ts +1 -1
- package/lib/cjs/toast/index.d.ts +2 -4
- package/lib/cjs/toast/index.js +29 -14
- package/lib/cjs/toast/toast.d.ts +4 -2
- package/lib/cjs/toast/toast.js +3 -1
- package/lib/cjs/tooltip/index.d.ts +8 -9
- package/lib/cjs/tooltip/index.js +30 -37
- package/lib/cjs/transfer/index.d.ts +1 -1
- package/lib/cjs/tree/autoSizer.d.ts +2 -2
- package/lib/cjs/tree/index.d.ts +5 -5
- package/lib/cjs/tree/nodeCollapsible.d.ts +11 -0
- package/lib/cjs/tree/nodeCollapsible.js +50 -0
- package/lib/cjs/tree/nodeList.js +6 -5
- package/lib/cjs/tree/treeNode.d.ts +1 -1
- package/lib/cjs/treeSelect/index.d.ts +12 -9
- package/lib/cjs/treeSelect/index.js +23 -9
- package/lib/cjs/trigger/index.d.ts +1 -1
- package/lib/cjs/typography/base.d.ts +8 -8
- package/lib/cjs/typography/index.d.ts +2 -0
- package/lib/cjs/typography/index.js +3 -0
- package/lib/cjs/typography/interface.d.ts +2 -0
- package/lib/cjs/typography/numeral.d.ts +68 -0
- package/lib/cjs/typography/numeral.js +106 -0
- package/lib/cjs/typography/paragraph.d.ts +3 -3
- package/lib/cjs/typography/text.d.ts +4 -4
- package/lib/cjs/typography/title.d.ts +4 -4
- package/lib/cjs/upload/fileCard.d.ts +1 -1
- package/lib/es/_cssAnimation/index.d.ts +39 -0
- package/lib/es/_cssAnimation/index.js +122 -0
- package/lib/es/anchor/index.d.ts +3 -3
- package/lib/es/anchor/link.d.ts +1 -1
- package/lib/es/autoComplete/index.d.ts +7 -8
- package/lib/es/autoComplete/option.d.ts +1 -1
- package/lib/es/banner/index.d.ts +2 -2
- package/lib/es/breadcrumb/index.d.ts +3 -3
- package/lib/es/breadcrumb/item.d.ts +3 -3
- package/lib/es/button/index.d.ts +2 -2
- package/lib/es/calendar/dayCalendar.d.ts +2 -2
- package/lib/es/calendar/index.d.ts +2 -2
- package/lib/es/calendar/monthCalendar.d.ts +2 -2
- package/lib/es/calendar/rangeCalendar.d.ts +2 -2
- package/lib/es/calendar/weekCalendar.d.ts +2 -2
- package/lib/es/card/cardGroup.d.ts +1 -1
- package/lib/es/carousel/index.d.ts +1 -1
- package/lib/es/cascader/index.d.ts +7 -8
- package/lib/es/cascader/index.js +8 -6
- package/lib/es/collapse/collapse-context.d.ts +1 -2
- package/lib/es/collapse/index.d.ts +3 -3
- package/lib/es/collapse/item.d.ts +2 -2
- package/lib/es/collapsible/index.d.ts +32 -19
- package/lib/es/collapsible/index.js +158 -119
- package/lib/es/configProvider/index.d.ts +1 -1
- package/lib/es/datePicker/dateInput.d.ts +3 -3
- package/lib/es/datePicker/datePicker.d.ts +12 -9
- package/lib/es/datePicker/datePicker.js +11 -13
- package/lib/es/datePicker/month.d.ts +1 -1
- package/lib/es/datePicker/month.js +5 -1
- package/lib/es/datePicker/monthsGrid.d.ts +7 -6
- package/lib/es/datePicker/monthsGrid.js +9 -26
- package/lib/es/datePicker/quickControl.d.ts +1 -1
- package/lib/es/datePicker/yearAndMonth.d.ts +1 -1
- package/lib/es/datePicker/yearAndMonth.js +13 -8
- package/lib/es/descriptions/index.d.ts +1 -1
- package/lib/es/dropdown/dropdownItem.d.ts +2 -1
- package/lib/es/dropdown/dropdownItem.js +3 -1
- package/lib/es/dropdown/index.d.ts +5 -6
- package/lib/es/form/baseForm.d.ts +7 -5
- package/lib/es/form/errorMessage.d.ts +1 -1
- package/lib/es/form/field.d.ts +4 -2
- package/lib/es/form/label.d.ts +1 -1
- package/lib/es/grid/col.d.ts +6 -6
- package/lib/es/grid/row.d.ts +1 -1
- package/lib/es/iconButton/index.d.ts +2 -2
- package/lib/es/image/image.d.ts +4 -4
- package/lib/es/image/preview.d.ts +1 -1
- package/lib/es/image/previewInner.d.ts +1 -1
- package/lib/es/index.d.ts +1 -0
- package/lib/es/index.js +1 -0
- package/lib/es/inputNumber/index.d.ts +2 -2
- package/lib/es/locale/source/ro.d.ts +3 -3
- package/lib/es/modal/Modal.d.ts +6 -6
- package/lib/es/modal/Modal.js +79 -56
- package/lib/es/modal/ModalContent.js +6 -5
- package/lib/es/modal/confirm.d.ts +10 -10
- package/lib/es/modal/confirm.js +1 -14
- package/lib/es/modal/useModal/HookModal.d.ts +0 -2
- package/lib/es/modal/useModal/HookModal.js +7 -19
- package/lib/es/navigation/Footer.d.ts +1 -1
- package/lib/es/navigation/Header.d.ts +3 -3
- package/lib/es/navigation/Item.d.ts +4 -4
- package/lib/es/navigation/Item.js +11 -5
- package/lib/es/navigation/OpenIconTransition.d.ts +1 -15
- package/lib/es/navigation/OpenIconTransition.js +1 -66
- package/lib/es/navigation/SubNav.d.ts +4 -4
- package/lib/es/navigation/SubNav.js +43 -28
- package/lib/es/navigation/index.d.ts +8 -11
- package/lib/es/notification/index.d.ts +0 -1
- package/lib/es/notification/index.js +24 -14
- package/lib/es/notification/notice.d.ts +3 -1
- package/lib/es/notification/notice.js +3 -1
- package/lib/es/popconfirm/index.d.ts +4 -5
- package/lib/es/popover/index.d.ts +8 -8
- package/lib/es/popover/index.js +1 -1
- package/lib/es/progress/index.d.ts +4 -4
- package/lib/es/rating/index.d.ts +1 -1
- package/lib/es/rating/item.d.ts +1 -1
- package/lib/es/scrollList/index.d.ts +1 -1
- package/lib/es/scrollList/scrollItem.d.ts +3 -3
- package/lib/es/scrollList/scrollItem.js +3 -3
- package/lib/es/select/index.d.ts +11 -6
- package/lib/es/select/index.js +108 -60
- package/lib/es/select/option.d.ts +1 -1
- package/lib/es/select/optionGroup.d.ts +1 -1
- package/lib/es/sideSheet/SideSheetContent.d.ts +8 -0
- package/lib/es/sideSheet/SideSheetContent.js +10 -6
- package/lib/es/sideSheet/index.d.ts +4 -4
- package/lib/es/sideSheet/index.js +67 -37
- package/lib/es/space/index.d.ts +1 -1
- package/lib/es/spin/index.js +1 -4
- package/lib/es/table/Body/BaseRow.d.ts +5 -5
- package/lib/es/table/Body/ExpandedRow.d.ts +3 -3
- package/lib/es/table/Body/SectionRow.d.ts +3 -3
- package/lib/es/table/Column.d.ts +4 -4
- package/lib/es/table/ColumnShape.d.ts +4 -4
- package/lib/es/table/ColumnSorter.d.ts +1 -1
- package/lib/es/table/CustomExpandIcon.d.ts +1 -1
- package/lib/es/table/CustomExpandIcon.js +13 -5
- package/lib/es/table/Table.d.ts +16 -16
- package/lib/es/table/TableCell.d.ts +4 -4
- package/lib/es/table/TableHeaderRow.d.ts +2 -2
- package/lib/es/table/TablePagination.d.ts +1 -1
- package/lib/es/table/index.d.ts +15 -15
- package/lib/es/tabs/TabPane.d.ts +2 -8
- package/lib/es/tabs/TabPane.js +40 -38
- package/lib/es/tabs/index.d.ts +5 -3
- package/lib/es/tabs/index.js +26 -4
- package/lib/es/tabs/interface.d.ts +2 -0
- package/lib/es/tag/group.d.ts +1 -0
- package/lib/es/tag/group.js +6 -3
- package/lib/es/tag/index.d.ts +1 -1
- package/lib/es/tag/index.js +1 -0
- package/lib/es/tag/interface.d.ts +3 -1
- package/lib/es/tagInput/index.d.ts +3 -3
- package/lib/es/timePicker/Combobox.js +4 -8
- package/lib/es/timePicker/PanelShape.d.ts +2 -2
- package/lib/es/timePicker/TimePicker.d.ts +11 -11
- package/lib/es/timePicker/TimePicker.js +3 -1
- package/lib/es/timePicker/TimeShape.d.ts +1 -1
- package/lib/es/timePicker/index.d.ts +10 -9
- package/lib/es/timeline/index.d.ts +1 -1
- package/lib/es/toast/index.d.ts +2 -4
- package/lib/es/toast/index.js +27 -13
- package/lib/es/toast/toast.d.ts +4 -2
- package/lib/es/toast/toast.js +3 -1
- package/lib/es/tooltip/index.d.ts +8 -9
- package/lib/es/tooltip/index.js +27 -36
- package/lib/es/transfer/index.d.ts +1 -1
- package/lib/es/tree/autoSizer.d.ts +2 -2
- package/lib/es/tree/index.d.ts +5 -5
- package/lib/es/tree/nodeCollapsible.d.ts +11 -0
- package/lib/es/tree/nodeCollapsible.js +35 -0
- package/lib/es/tree/nodeList.js +6 -5
- package/lib/es/tree/treeNode.d.ts +1 -1
- package/lib/es/treeSelect/index.d.ts +12 -9
- package/lib/es/treeSelect/index.js +22 -8
- package/lib/es/trigger/index.d.ts +1 -1
- package/lib/es/typography/base.d.ts +8 -8
- package/lib/es/typography/index.d.ts +2 -0
- package/lib/es/typography/index.js +2 -0
- package/lib/es/typography/interface.d.ts +2 -0
- package/lib/es/typography/numeral.d.ts +68 -0
- package/lib/es/typography/numeral.js +86 -0
- package/lib/es/typography/paragraph.d.ts +3 -3
- package/lib/es/typography/text.d.ts +4 -4
- package/lib/es/typography/title.d.ts +4 -4
- package/lib/es/upload/fileCard.d.ts +1 -1
- package/package.json +7 -7
- package/lib/cjs/motions/Rotate.d.ts +0 -23
- package/lib/cjs/motions/Rotate.js +0 -76
- package/lib/cjs/navigation/SubNavTransition.d.ts +0 -17
- package/lib/cjs/navigation/SubNavTransition.js +0 -83
- package/lib/cjs/notification/NoticeTransition.d.ts +0 -10
- package/lib/cjs/notification/NoticeTransition.js +0 -85
- package/lib/cjs/sideSheet/SideSheetTransition.d.ts +0 -12
- package/lib/cjs/sideSheet/SideSheetTransition.js +0 -115
- package/lib/cjs/tabs/TabPaneTransition.d.ts +0 -4
- package/lib/cjs/tabs/TabPaneTransition.js +0 -114
- package/lib/cjs/toast/ToastTransition.d.ts +0 -7
- package/lib/cjs/toast/ToastTransition.js +0 -66
- package/lib/cjs/tooltip/TooltipStyledTransition.d.ts +0 -9
- package/lib/cjs/tooltip/TooltipStyledTransition.js +0 -52
- package/lib/cjs/tree/collapse.d.ts +0 -29
- package/lib/cjs/tree/collapse.js +0 -155
- package/lib/es/motions/Rotate.d.ts +0 -23
- package/lib/es/motions/Rotate.js +0 -60
- package/lib/es/navigation/SubNavTransition.d.ts +0 -17
- package/lib/es/navigation/SubNavTransition.js +0 -66
- package/lib/es/notification/NoticeTransition.d.ts +0 -10
- package/lib/es/notification/NoticeTransition.js +0 -74
- package/lib/es/sideSheet/SideSheetTransition.d.ts +0 -12
- package/lib/es/sideSheet/SideSheetTransition.js +0 -102
- package/lib/es/tabs/TabPaneTransition.d.ts +0 -4
- package/lib/es/tabs/TabPaneTransition.js +0 -103
- package/lib/es/toast/ToastTransition.d.ts +0 -7
- package/lib/es/toast/ToastTransition.js +0 -55
- package/lib/es/tooltip/TooltipStyledTransition.d.ts +0 -9
- package/lib/es/tooltip/TooltipStyledTransition.js +0 -38
- package/lib/es/tree/collapse.d.ts +0 -29
- package/lib/es/tree/collapse.js +0 -136
|
@@ -1,140 +1,186 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
1
|
+
import _isEqual from "lodash/isEqual";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import CollapsibleFoundation from '@douyinfe/semi-foundation/lib/es/collapsible/foundation';
|
|
4
|
+
import BaseComponent from "../_base/baseComponent";
|
|
5
|
+
import PropTypes from "prop-types";
|
|
6
|
+
import cls from "classnames";
|
|
6
7
|
import { cssClasses } from '@douyinfe/semi-foundation/lib/es/collapsible/constants';
|
|
7
|
-
import
|
|
8
|
-
const ease = 'cubicBezier(.25,.1,.25,1)';
|
|
9
|
-
|
|
10
|
-
const Collapsible = props => {
|
|
11
|
-
const {
|
|
12
|
-
motion,
|
|
13
|
-
children,
|
|
14
|
-
isOpen,
|
|
15
|
-
duration,
|
|
16
|
-
keepDOM,
|
|
17
|
-
collapseHeight,
|
|
18
|
-
style,
|
|
19
|
-
className,
|
|
20
|
-
reCalcKey,
|
|
21
|
-
id
|
|
22
|
-
} = props;
|
|
23
|
-
const ref = useRef(null);
|
|
24
|
-
const [maxHeight, setMaxHeight] = useState(0);
|
|
25
|
-
const [open, setOpen] = useState(props.isOpen);
|
|
26
|
-
const [isFirst, setIsFirst] = useState(true);
|
|
27
|
-
const [transitionImmediate, setTransitionImmediate] = useState(open && isFirst);
|
|
28
|
-
const [left, setLeft] = useState(!props.isOpen);
|
|
29
|
-
|
|
30
|
-
if (isOpen !== open) {
|
|
31
|
-
setOpen(isOpen);
|
|
32
|
-
|
|
33
|
-
if (isFirst) {
|
|
34
|
-
setIsFirst(false);
|
|
35
|
-
setTransitionImmediate(false);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
isOpen && setLeft(!isOpen);
|
|
39
|
-
}
|
|
8
|
+
import '@douyinfe/semi-foundation/lib/es/collapsible/collapsible.css';
|
|
40
9
|
|
|
41
|
-
|
|
42
|
-
|
|
10
|
+
class Collapsible extends BaseComponent {
|
|
11
|
+
constructor(props) {
|
|
12
|
+
super(props);
|
|
13
|
+
this.domRef = /*#__PURE__*/React.createRef();
|
|
43
14
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
} // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
15
|
+
this.handleResize = entryList => {
|
|
16
|
+
const entry = entryList[0];
|
|
47
17
|
|
|
48
|
-
|
|
18
|
+
if (entry) {
|
|
19
|
+
const entryInfo = Collapsible.getEntryInfo(entry);
|
|
20
|
+
this.foundation.updateDOMHeight(entryInfo.height);
|
|
21
|
+
this.foundation.updateDOMInRenderTree(entryInfo.isShown);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
49
24
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
25
|
+
this.isChildrenInRenderTree = () => {
|
|
26
|
+
if (this.domRef.current) {
|
|
27
|
+
return this.domRef.current.offsetHeight > 0;
|
|
28
|
+
} else {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
};
|
|
53
32
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
maxHeight: maxHeightInTransitionStyle
|
|
33
|
+
this.state = {
|
|
34
|
+
domInRenderTree: false,
|
|
35
|
+
domHeight: 0,
|
|
36
|
+
visible: this.props.isOpen,
|
|
37
|
+
isTransitioning: false
|
|
60
38
|
};
|
|
61
|
-
|
|
39
|
+
this.foundation = new CollapsibleFoundation(this.adapter);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
get adapter() {
|
|
43
|
+
return Object.assign(Object.assign({}, super.adapter), {
|
|
44
|
+
setDOMInRenderTree: domInRenderTree => {
|
|
45
|
+
if (this.state.domInRenderTree !== domInRenderTree) {
|
|
46
|
+
this.setState({
|
|
47
|
+
domInRenderTree
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
setDOMHeight: domHeight => {
|
|
52
|
+
if (this.state.domHeight !== domHeight) {
|
|
53
|
+
this.setState({
|
|
54
|
+
domHeight
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
setVisible: visible => {
|
|
59
|
+
if (this.state.visible !== visible) {
|
|
60
|
+
this.setState({
|
|
61
|
+
visible
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
setIsTransitioning: isTransitioning => {
|
|
66
|
+
if (this.state.isTransitioning !== isTransitioning) {
|
|
67
|
+
this.setState({
|
|
68
|
+
isTransitioning
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
}
|
|
62
74
|
|
|
63
|
-
|
|
75
|
+
componentDidMount() {
|
|
76
|
+
super.componentDidMount();
|
|
77
|
+
this.resizeObserver = new ResizeObserver(this.handleResize);
|
|
78
|
+
this.resizeObserver.observe(this.domRef.current);
|
|
79
|
+
const domInRenderTree = this.isChildrenInRenderTree();
|
|
80
|
+
this.foundation.updateDOMInRenderTree(domInRenderTree);
|
|
64
81
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
82
|
+
if (domInRenderTree) {
|
|
83
|
+
this.foundation.updateDOMHeight(this.domRef.current.scrollHeight);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
68
86
|
|
|
69
|
-
|
|
70
|
-
const
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
87
|
+
componentDidUpdate(prevProps, prevState, snapshot) {
|
|
88
|
+
const changedPropKeys = Object.keys(this.props).filter(key => !_isEqual(this.props[key], prevProps[key]));
|
|
89
|
+
const changedStateKeys = Object.keys(this.state).filter(key => !_isEqual(this.state[key], prevState[key]));
|
|
90
|
+
|
|
91
|
+
if (changedPropKeys.includes("reCalcKey")) {
|
|
92
|
+
this.foundation.updateDOMHeight(this.domRef.current.scrollHeight);
|
|
93
|
+
}
|
|
75
94
|
|
|
76
|
-
if (
|
|
77
|
-
|
|
95
|
+
if (changedStateKeys.includes("domInRenderTree") && this.state.domInRenderTree) {
|
|
96
|
+
this.foundation.updateDOMHeight(this.domRef.current.scrollHeight);
|
|
78
97
|
}
|
|
79
98
|
|
|
80
|
-
|
|
99
|
+
if (changedPropKeys.includes("isOpen")) {
|
|
100
|
+
if (this.props.isOpen || !this.props.motion) {
|
|
101
|
+
this.foundation.updateVisible(this.props.isOpen);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (this.props.motion && prevProps.isOpen !== this.props.isOpen) {
|
|
106
|
+
this.foundation.updateIsTransitioning(true);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
componentWillUnmount() {
|
|
111
|
+
super.componentWillUnmount();
|
|
112
|
+
this.resizeObserver.disconnect();
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
render() {
|
|
116
|
+
const wrapperStyle = Object.assign({
|
|
117
|
+
overflow: 'hidden',
|
|
118
|
+
height: this.props.isOpen ? this.state.domHeight : this.props.collapseHeight,
|
|
119
|
+
opacity: this.props.isOpen || !this.props.fade || this.props.collapseHeight !== 0 ? 1 : 0,
|
|
120
|
+
transitionDuration: "".concat(this.props.motion && this.state.isTransitioning ? this.props.duration : 0, "ms")
|
|
121
|
+
}, this.props.style);
|
|
122
|
+
const wrapperCls = cls("".concat(cssClasses.PREFIX, "-wrapper"), {
|
|
123
|
+
["".concat(cssClasses.PREFIX, "-transition")]: this.props.motion && this.state.isTransitioning
|
|
124
|
+
}, this.props.className);
|
|
81
125
|
return /*#__PURE__*/React.createElement("div", {
|
|
82
|
-
style: wrapperstyle,
|
|
83
126
|
className: wrapperCls,
|
|
84
|
-
|
|
127
|
+
style: wrapperStyle,
|
|
128
|
+
onTransitionEnd: () => {
|
|
129
|
+
if (!this.props.isOpen) {
|
|
130
|
+
this.foundation.updateVisible(false);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
this.foundation.updateIsTransitioning(false);
|
|
134
|
+
this.props.onMotionEnd();
|
|
135
|
+
}
|
|
85
136
|
}, /*#__PURE__*/React.createElement("div", {
|
|
86
|
-
|
|
137
|
+
"x-semi-prop": "children",
|
|
138
|
+
ref: this.domRef,
|
|
87
139
|
style: {
|
|
88
140
|
overflow: 'hidden'
|
|
89
141
|
},
|
|
90
|
-
id: id
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
};
|
|
142
|
+
id: this.props.id
|
|
143
|
+
}, (this.props.keepDOM || this.props.collapseHeight !== 0 || this.state.visible || this.props.isOpen) && this.props.children));
|
|
144
|
+
}
|
|
94
145
|
|
|
95
|
-
|
|
96
|
-
setLeft(true);
|
|
97
|
-
!shouldKeepDOM() && setMaxHeight(collapseHeight);
|
|
98
|
-
};
|
|
146
|
+
}
|
|
99
147
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
148
|
+
Collapsible.defaultProps = {
|
|
149
|
+
isOpen: false,
|
|
150
|
+
duration: 250,
|
|
151
|
+
motion: true,
|
|
152
|
+
keepDOM: false,
|
|
153
|
+
collapseHeight: 0,
|
|
154
|
+
fade: false
|
|
155
|
+
};
|
|
104
156
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
leave: {
|
|
124
|
-
maxHeight: {
|
|
125
|
-
val: collapseHeight,
|
|
126
|
-
easing: ease,
|
|
127
|
-
duration
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
}, mergedMotion), transitionStyle => renderChildren(motion ? transitionStyle : null));
|
|
131
|
-
};
|
|
157
|
+
Collapsible.getEntryInfo = entry => {
|
|
158
|
+
//judge whether parent or self display none
|
|
159
|
+
let inRenderTree;
|
|
160
|
+
|
|
161
|
+
if (entry.borderBoxSize) {
|
|
162
|
+
inRenderTree = !(entry.borderBoxSize[0].blockSize === 0 && entry.borderBoxSize[0].inlineSize === 0);
|
|
163
|
+
} else {
|
|
164
|
+
inRenderTree = !(entry.contentRect.height === 0 && entry.contentRect.width === 0);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
let height = 0;
|
|
168
|
+
|
|
169
|
+
if (entry.borderBoxSize) {
|
|
170
|
+
height = Math.ceil(entry.borderBoxSize[0].blockSize);
|
|
171
|
+
} else {
|
|
172
|
+
const target = entry.target;
|
|
173
|
+
height = target.clientHeight;
|
|
174
|
+
}
|
|
132
175
|
|
|
133
|
-
return
|
|
176
|
+
return {
|
|
177
|
+
isShown: inRenderTree,
|
|
178
|
+
height
|
|
179
|
+
};
|
|
134
180
|
};
|
|
135
181
|
|
|
136
|
-
Collapsible.
|
|
137
|
-
motion: PropTypes.
|
|
182
|
+
Collapsible.propTypes = {
|
|
183
|
+
motion: PropTypes.bool,
|
|
138
184
|
children: PropTypes.node,
|
|
139
185
|
isOpen: PropTypes.bool,
|
|
140
186
|
duration: PropTypes.number,
|
|
@@ -144,11 +190,4 @@ Collapsible.propType = {
|
|
|
144
190
|
className: PropTypes.string,
|
|
145
191
|
reCalcKey: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
|
|
146
192
|
};
|
|
147
|
-
Collapsible.defaultProps = {
|
|
148
|
-
isOpen: false,
|
|
149
|
-
duration: 250,
|
|
150
|
-
motion: true,
|
|
151
|
-
keepDOM: false,
|
|
152
|
-
collapseHeight: 0
|
|
153
|
-
};
|
|
154
193
|
export default Collapsible;
|
|
@@ -6,7 +6,7 @@ export interface ConfigProviderProps extends ContextValue {
|
|
|
6
6
|
export default class ConfigProvider extends React.Component<ConfigProviderProps> {
|
|
7
7
|
static propTypes: {
|
|
8
8
|
locale: PropTypes.Requireable<object>;
|
|
9
|
-
timeZone: PropTypes.Requireable<string | number
|
|
9
|
+
timeZone: PropTypes.Requireable<NonNullable<string | number>>;
|
|
10
10
|
getPopupContainer: PropTypes.Requireable<(...args: any[]) => any>;
|
|
11
11
|
direction: PropTypes.Requireable<string>;
|
|
12
12
|
};
|
|
@@ -36,14 +36,14 @@ export default class DateInput extends BaseComponent<DateInputProps, {}> {
|
|
|
36
36
|
prefix: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
37
37
|
prefixCls: PropTypes.Requireable<string>;
|
|
38
38
|
dateFnsLocale: PropTypes.Validator<object>;
|
|
39
|
-
placeholder: PropTypes.Requireable<string | any[]
|
|
40
|
-
rangeInputFocus: PropTypes.Requireable<string | boolean
|
|
39
|
+
placeholder: PropTypes.Requireable<NonNullable<string | any[]>>;
|
|
40
|
+
rangeInputFocus: PropTypes.Requireable<NonNullable<string | boolean>>;
|
|
41
41
|
rangeInputStartRef: PropTypes.Requireable<object>;
|
|
42
42
|
rangeInputEndRef: PropTypes.Requireable<object>;
|
|
43
43
|
rangeSeparator: PropTypes.Requireable<string>;
|
|
44
44
|
insetInput: PropTypes.Requireable<boolean>;
|
|
45
45
|
insetInputValue: PropTypes.Requireable<object>;
|
|
46
|
-
defaultPickerValue: PropTypes.Requireable<string | number | object
|
|
46
|
+
defaultPickerValue: PropTypes.Requireable<NonNullable<string | number | object>>;
|
|
47
47
|
};
|
|
48
48
|
static defaultProps: {
|
|
49
49
|
showClear: boolean;
|
|
@@ -9,6 +9,7 @@ import { YearAndMonthProps } from './yearAndMonth';
|
|
|
9
9
|
import '@douyinfe/semi-foundation/lib/es/datePicker/datePicker.css';
|
|
10
10
|
import { Locale } from '../locale/interface';
|
|
11
11
|
import { TimePickerProps } from '../timePicker/TimePicker';
|
|
12
|
+
import { ScrollItemProps } from '../scrollList/scrollItem';
|
|
12
13
|
import { InsetInputChangeProps } from '@douyinfe/semi-foundation/lib/es/datePicker/inputFoundation';
|
|
13
14
|
export interface DatePickerProps extends DatePickerFoundationProps {
|
|
14
15
|
'aria-describedby'?: React.AriaAttributes['aria-describedby'];
|
|
@@ -31,6 +32,7 @@ export interface DatePickerProps extends DatePickerFoundationProps {
|
|
|
31
32
|
onPresetClick?: (item: PresetType, e: React.MouseEvent<HTMLDivElement>) => void;
|
|
32
33
|
locale?: Locale['DatePicker'];
|
|
33
34
|
dateFnsLocale?: Locale['dateFnsLocale'];
|
|
35
|
+
yearAndMonthOpts?: ScrollItemProps<any>;
|
|
34
36
|
}
|
|
35
37
|
export declare type DatePickerState = DatePickerFoundationState;
|
|
36
38
|
export default class DatePicker extends BaseComponent<DatePickerProps, DatePickerState> {
|
|
@@ -44,9 +46,9 @@ export default class DatePicker extends BaseComponent<DatePickerProps, DatePicke
|
|
|
44
46
|
type: PropTypes.Requireable<"dateTime" | "date" | "month" | "dateRange" | "year" | "dateTimeRange">;
|
|
45
47
|
size: PropTypes.Requireable<"default" | "small" | "large">;
|
|
46
48
|
density: PropTypes.Requireable<"default" | "compact">;
|
|
47
|
-
defaultValue: PropTypes.Requireable<string | number | object
|
|
48
|
-
value: PropTypes.Requireable<string | number | object
|
|
49
|
-
defaultPickerValue: PropTypes.Requireable<string | number | object
|
|
49
|
+
defaultValue: PropTypes.Requireable<NonNullable<string | number | object>>;
|
|
50
|
+
value: PropTypes.Requireable<NonNullable<string | number | object>>;
|
|
51
|
+
defaultPickerValue: PropTypes.Requireable<NonNullable<string | number | object>>;
|
|
50
52
|
disabledTime: PropTypes.Requireable<(...args: any[]) => any>;
|
|
51
53
|
disabledTimePicker: PropTypes.Requireable<boolean>;
|
|
52
54
|
hideDisabledOptions: PropTypes.Requireable<boolean>;
|
|
@@ -54,9 +56,9 @@ export default class DatePicker extends BaseComponent<DatePickerProps, DatePicke
|
|
|
54
56
|
disabled: PropTypes.Requireable<boolean>;
|
|
55
57
|
multiple: PropTypes.Requireable<boolean>;
|
|
56
58
|
max: PropTypes.Requireable<number>;
|
|
57
|
-
placeholder: PropTypes.Requireable<string | any[]
|
|
59
|
+
placeholder: PropTypes.Requireable<NonNullable<string | any[]>>;
|
|
58
60
|
presets: PropTypes.Requireable<any[]>;
|
|
59
|
-
presetPosition: PropTypes.Requireable<"
|
|
61
|
+
presetPosition: PropTypes.Requireable<"left" | "top" | "right" | "bottom">;
|
|
60
62
|
onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
61
63
|
onChangeWithDateFirst: PropTypes.Requireable<boolean>;
|
|
62
64
|
weekStartsOn: PropTypes.Requireable<number>;
|
|
@@ -66,22 +68,22 @@ export default class DatePicker extends BaseComponent<DatePickerProps, DatePicke
|
|
|
66
68
|
onOpenChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
67
69
|
open: PropTypes.Requireable<boolean>;
|
|
68
70
|
defaultOpen: PropTypes.Requireable<boolean>;
|
|
69
|
-
motion: PropTypes.Requireable<boolean | object
|
|
71
|
+
motion: PropTypes.Requireable<NonNullable<boolean | object>>;
|
|
70
72
|
className: PropTypes.Requireable<string>;
|
|
71
73
|
prefixCls: PropTypes.Requireable<string>;
|
|
72
74
|
prefix: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
73
75
|
insetLabel: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
74
76
|
insetLabelId: PropTypes.Requireable<string>;
|
|
75
77
|
zIndex: PropTypes.Requireable<number>;
|
|
76
|
-
position: PropTypes.Requireable<"
|
|
78
|
+
position: PropTypes.Requireable<"left" | "top" | "right" | "bottom" | "topLeft" | "topRight" | "leftTop" | "leftBottom" | "rightTop" | "rightBottom" | "bottomLeft" | "bottomRight" | "leftTopOver" | "rightTopOver">;
|
|
77
79
|
getPopupContainer: PropTypes.Requireable<(...args: any[]) => any>;
|
|
78
80
|
onCancel: PropTypes.Requireable<(...args: any[]) => any>;
|
|
79
81
|
onConfirm: PropTypes.Requireable<(...args: any[]) => any>;
|
|
80
82
|
needConfirm: PropTypes.Requireable<boolean>;
|
|
81
83
|
inputStyle: PropTypes.Requireable<object>;
|
|
82
|
-
timeZone: PropTypes.Requireable<string | number
|
|
84
|
+
timeZone: PropTypes.Requireable<NonNullable<string | number>>;
|
|
83
85
|
triggerRender: PropTypes.Requireable<(...args: any[]) => any>;
|
|
84
|
-
stopPropagation: PropTypes.Requireable<string | boolean
|
|
86
|
+
stopPropagation: PropTypes.Requireable<NonNullable<string | boolean>>;
|
|
85
87
|
autoAdjustOverflow: PropTypes.Requireable<boolean>;
|
|
86
88
|
onBlur: PropTypes.Requireable<(...args: any[]) => any>;
|
|
87
89
|
onFocus: PropTypes.Requireable<(...args: any[]) => any>;
|
|
@@ -105,6 +107,7 @@ export default class DatePicker extends BaseComponent<DatePickerProps, DatePicke
|
|
|
105
107
|
onPanelChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
106
108
|
rangeSeparator: PropTypes.Requireable<string>;
|
|
107
109
|
preventScroll: PropTypes.Requireable<boolean>;
|
|
110
|
+
yearAndMonthOpts: PropTypes.Requireable<object>;
|
|
108
111
|
};
|
|
109
112
|
static defaultProps: {
|
|
110
113
|
onChangeWithDateFirst: boolean;
|
|
@@ -189,7 +189,8 @@ export default class DatePicker extends BaseComponent {
|
|
|
189
189
|
this.renderYearMonthPanel = (locale, localeCode) => {
|
|
190
190
|
const {
|
|
191
191
|
density,
|
|
192
|
-
presetPosition
|
|
192
|
+
presetPosition,
|
|
193
|
+
yearAndMonthOpts
|
|
193
194
|
} = this.props;
|
|
194
195
|
const date = this.state.value[0];
|
|
195
196
|
let year = 0;
|
|
@@ -212,7 +213,8 @@ export default class DatePicker extends BaseComponent {
|
|
|
212
213
|
density: density,
|
|
213
214
|
presetPosition: presetPosition,
|
|
214
215
|
renderQuickControls: this.renderQuickControls(),
|
|
215
|
-
renderDateInput: this.renderDateInput()
|
|
216
|
+
renderDateInput: this.renderDateInput(),
|
|
217
|
+
yearAndMonthOpts: yearAndMonthOpts
|
|
216
218
|
});
|
|
217
219
|
};
|
|
218
220
|
|
|
@@ -237,13 +239,12 @@ export default class DatePicker extends BaseComponent {
|
|
|
237
239
|
autoAdjustOverflow,
|
|
238
240
|
spacing
|
|
239
241
|
} = this.props;
|
|
240
|
-
const mergedMotion = this.foundation.getMergedMotion(motion);
|
|
241
242
|
return /*#__PURE__*/React.createElement(Popover, {
|
|
242
243
|
getPopupContainer: getPopupContainer,
|
|
243
244
|
// wrapWhenSpecial={false}
|
|
244
245
|
autoAdjustOverflow: autoAdjustOverflow,
|
|
245
246
|
zIndex: zIndex,
|
|
246
|
-
motion:
|
|
247
|
+
motion: motion,
|
|
247
248
|
content: this.renderPanel(locale, localeCode, dateFnsLocale),
|
|
248
249
|
trigger: "custom",
|
|
249
250
|
position: position,
|
|
@@ -261,7 +262,6 @@ export default class DatePicker extends BaseComponent {
|
|
|
261
262
|
value: [],
|
|
262
263
|
cachedSelectedValue: null,
|
|
263
264
|
prevTimeZone: null,
|
|
264
|
-
motionEnd: false,
|
|
265
265
|
rangeInputFocus: undefined,
|
|
266
266
|
autofocus: props.autoFocus || this.isRangeType(props.type, props.triggerRender) && (props.open || props.defaultOpen),
|
|
267
267
|
insetInputValue: null,
|
|
@@ -381,9 +381,6 @@ export default class DatePicker extends BaseComponent {
|
|
|
381
381
|
},
|
|
382
382
|
needConfirm: () => ['dateTime', 'dateTimeRange'].includes(this.props.type) && this.props.needConfirm === true,
|
|
383
383
|
typeIsYearOrMonth: () => ['month', 'year'].includes(this.props.type),
|
|
384
|
-
setMotionEnd: motionEnd => this.setState({
|
|
385
|
-
motionEnd
|
|
386
|
-
}),
|
|
387
384
|
setRangeInputFocus: rangeInputFocus => {
|
|
388
385
|
const {
|
|
389
386
|
preventScroll
|
|
@@ -549,11 +546,11 @@ export default class DatePicker extends BaseComponent {
|
|
|
549
546
|
timeZone,
|
|
550
547
|
triggerRender,
|
|
551
548
|
insetInput,
|
|
552
|
-
presetPosition
|
|
549
|
+
presetPosition,
|
|
550
|
+
yearAndMonthOpts
|
|
553
551
|
} = this.props;
|
|
554
552
|
const {
|
|
555
553
|
cachedSelectedValue,
|
|
556
|
-
motionEnd,
|
|
557
554
|
rangeInputFocus
|
|
558
555
|
} = this.state;
|
|
559
556
|
const defaultValue = cachedSelectedValue;
|
|
@@ -581,7 +578,6 @@ export default class DatePicker extends BaseComponent {
|
|
|
581
578
|
startDateOffset: startDateOffset,
|
|
582
579
|
endDateOffset: endDateOffset,
|
|
583
580
|
autoSwitchDate: autoSwitchDate,
|
|
584
|
-
motionEnd: motionEnd,
|
|
585
581
|
density: density,
|
|
586
582
|
rangeInputFocus: rangeInputFocus,
|
|
587
583
|
setRangeInputFocus: this.handleSetRangeFocus,
|
|
@@ -594,7 +590,8 @@ export default class DatePicker extends BaseComponent {
|
|
|
594
590
|
insetInput: insetInput,
|
|
595
591
|
presetPosition: presetPosition,
|
|
596
592
|
renderQuickControls: this.renderQuickControls(),
|
|
597
|
-
renderDateInput: this.renderDateInput()
|
|
593
|
+
renderDateInput: this.renderDateInput(),
|
|
594
|
+
yearAndMonthOpts: yearAndMonthOpts
|
|
598
595
|
});
|
|
599
596
|
}
|
|
600
597
|
|
|
@@ -835,7 +832,8 @@ DatePicker.propTypes = {
|
|
|
835
832
|
// Callback function for panel date switching
|
|
836
833
|
onPanelChange: PropTypes.func,
|
|
837
834
|
rangeSeparator: PropTypes.string,
|
|
838
|
-
preventScroll: PropTypes.bool
|
|
835
|
+
preventScroll: PropTypes.bool,
|
|
836
|
+
yearAndMonthOpts: PropTypes.object
|
|
839
837
|
};
|
|
840
838
|
DatePicker.defaultProps = {
|
|
841
839
|
onChangeWithDateFirst: true,
|
|
@@ -31,7 +31,7 @@ export default class Month extends BaseComponent<MonthProps, MonthState> {
|
|
|
31
31
|
hoverDay: PropTypes.Requireable<string>;
|
|
32
32
|
startDateOffset: PropTypes.Requireable<(...args: any[]) => any>;
|
|
33
33
|
endDateOffset: PropTypes.Requireable<(...args: any[]) => any>;
|
|
34
|
-
rangeInputFocus: PropTypes.Requireable<string | boolean
|
|
34
|
+
rangeInputFocus: PropTypes.Requireable<NonNullable<string | boolean>>;
|
|
35
35
|
focusRecordsRef: PropTypes.Requireable<object>;
|
|
36
36
|
multiple: PropTypes.Requireable<boolean>;
|
|
37
37
|
};
|
|
@@ -65,6 +65,9 @@ export default class Month extends BaseComponent {
|
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
getSingleDayStatus(options) {
|
|
68
|
+
const {
|
|
69
|
+
rangeInputFocus
|
|
70
|
+
} = this.props;
|
|
68
71
|
const {
|
|
69
72
|
fullDate,
|
|
70
73
|
todayText,
|
|
@@ -75,7 +78,8 @@ export default class Month extends BaseComponent {
|
|
|
75
78
|
} = options;
|
|
76
79
|
const disabledOptions = {
|
|
77
80
|
rangeStart,
|
|
78
|
-
rangeEnd
|
|
81
|
+
rangeEnd,
|
|
82
|
+
rangeInputFocus
|
|
79
83
|
};
|
|
80
84
|
const isToday = fullDate === todayText;
|
|
81
85
|
const isSelected = selected.has(fullDate);
|
|
@@ -4,6 +4,7 @@ import MonthsGridFoundation, { MonthInfo, MonthsGridAdapter, MonthsGridDateAdapt
|
|
|
4
4
|
import BaseComponent, { BaseProps } from '../_base/baseComponent';
|
|
5
5
|
import Combobox from '../timePicker/Combobox';
|
|
6
6
|
import YearAndMonth from './yearAndMonth';
|
|
7
|
+
import { ScrollItemProps } from '../scrollList/scrollItem';
|
|
7
8
|
export interface MonthsGridProps extends MonthsGridFoundationProps, BaseProps {
|
|
8
9
|
navPrev?: React.ReactNode;
|
|
9
10
|
navNext?: React.ReactNode;
|
|
@@ -13,13 +14,14 @@ export interface MonthsGridProps extends MonthsGridFoundationProps, BaseProps {
|
|
|
13
14
|
rangeStart: boolean;
|
|
14
15
|
rangeEnd: boolean;
|
|
15
16
|
}>;
|
|
17
|
+
yearAndMonthOpts?: ScrollItemProps<any>;
|
|
16
18
|
}
|
|
17
19
|
export declare type MonthsGridState = MonthsGridFoundationState;
|
|
18
20
|
export default class MonthsGrid extends BaseComponent<MonthsGridProps, MonthsGridState> {
|
|
19
21
|
static propTypes: {
|
|
20
22
|
type: PropTypes.Requireable<"dateTime" | "date" | "month" | "dateRange" | "year" | "dateTimeRange">;
|
|
21
|
-
defaultValue: PropTypes.Requireable<string | number | object
|
|
22
|
-
defaultPickerValue: PropTypes.Requireable<string | number | object
|
|
23
|
+
defaultValue: PropTypes.Requireable<NonNullable<string | number | object>>;
|
|
24
|
+
defaultPickerValue: PropTypes.Requireable<NonNullable<string | number | object>>;
|
|
23
25
|
multiple: PropTypes.Requireable<boolean>;
|
|
24
26
|
max: PropTypes.Requireable<number>;
|
|
25
27
|
weekStartsOn: PropTypes.Requireable<number>;
|
|
@@ -33,7 +35,7 @@ export default class MonthsGrid extends BaseComponent<MonthsGridProps, MonthsGri
|
|
|
33
35
|
timePickerOpts: PropTypes.Requireable<object>;
|
|
34
36
|
isControlledComponent: PropTypes.Requireable<boolean>;
|
|
35
37
|
rangeStart: PropTypes.Requireable<string>;
|
|
36
|
-
rangeInputFocus: PropTypes.Requireable<string | boolean
|
|
38
|
+
rangeInputFocus: PropTypes.Requireable<NonNullable<string | boolean>>;
|
|
37
39
|
locale: PropTypes.Requireable<object>;
|
|
38
40
|
localeCode: PropTypes.Requireable<string>;
|
|
39
41
|
format: PropTypes.Requireable<string>;
|
|
@@ -42,15 +44,14 @@ export default class MonthsGrid extends BaseComponent<MonthsGridProps, MonthsGri
|
|
|
42
44
|
startDateOffset: PropTypes.Requireable<(...args: any[]) => any>;
|
|
43
45
|
endDateOffset: PropTypes.Requireable<(...args: any[]) => any>;
|
|
44
46
|
autoSwitchDate: PropTypes.Requireable<boolean>;
|
|
45
|
-
motionEnd: PropTypes.Requireable<boolean>;
|
|
46
47
|
density: PropTypes.Requireable<string>;
|
|
47
48
|
dateFnsLocale: PropTypes.Validator<object>;
|
|
48
|
-
timeZone: PropTypes.Requireable<string | number
|
|
49
|
+
timeZone: PropTypes.Requireable<NonNullable<string | number>>;
|
|
49
50
|
syncSwitchMonth: PropTypes.Requireable<boolean>;
|
|
50
51
|
onPanelChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
51
52
|
focusRecordsRef: PropTypes.Requireable<object>;
|
|
52
53
|
triggerRender: PropTypes.Requireable<(...args: any[]) => any>;
|
|
53
|
-
presetPosition: PropTypes.Requireable<"
|
|
54
|
+
presetPosition: PropTypes.Requireable<"left" | "top" | "right" | "bottom">;
|
|
54
55
|
renderQuickControls: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
55
56
|
renderDateInput: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
56
57
|
};
|
|
@@ -65,18 +65,10 @@ export default class MonthsGrid extends BaseComponent {
|
|
|
65
65
|
|
|
66
66
|
|
|
67
67
|
this.calcScrollListHeight = () => {
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
if (motionEnd) {
|
|
74
|
-
wrapLeft = this.adapter.getCache("wrap-".concat(strings.PANEL_TYPE_LEFT));
|
|
75
|
-
wrapRight = this.adapter.getCache("wrap-".concat(strings.PANEL_TYPE_RIGHT));
|
|
76
|
-
switchLeft = this.adapter.getCache("switch-".concat(strings.PANEL_TYPE_LEFT));
|
|
77
|
-
switchRight = this.adapter.getCache("switch-".concat(strings.PANEL_TYPE_RIGHT));
|
|
78
|
-
}
|
|
79
|
-
|
|
68
|
+
const wrapLeft = this.adapter.getCache("wrap-".concat(strings.PANEL_TYPE_LEFT));
|
|
69
|
+
const wrapRight = this.adapter.getCache("wrap-".concat(strings.PANEL_TYPE_RIGHT));
|
|
70
|
+
const switchLeft = this.adapter.getCache("switch-".concat(strings.PANEL_TYPE_LEFT));
|
|
71
|
+
const switchRight = this.adapter.getCache("switch-".concat(strings.PANEL_TYPE_RIGHT));
|
|
80
72
|
const leftRect = wrapLeft && wrapLeft.getBoundingClientRect();
|
|
81
73
|
const rightRect = wrapRight && wrapRight.getBoundingClientRect();
|
|
82
74
|
let leftHeight = leftRect && leftRect.height || 0;
|
|
@@ -219,8 +211,7 @@ export default class MonthsGrid extends BaseComponent {
|
|
|
219
211
|
componentDidUpdate(prevProps, prevState) {
|
|
220
212
|
const {
|
|
221
213
|
defaultValue,
|
|
222
|
-
defaultPickerValue
|
|
223
|
-
motionEnd
|
|
214
|
+
defaultPickerValue
|
|
224
215
|
} = this.props;
|
|
225
216
|
|
|
226
217
|
if (prevProps.defaultValue !== defaultValue) {
|
|
@@ -232,15 +223,6 @@ export default class MonthsGrid extends BaseComponent {
|
|
|
232
223
|
this.foundation.initDefaultPickerValue();
|
|
233
224
|
}
|
|
234
225
|
|
|
235
|
-
if (prevProps.motionEnd !== motionEnd && motionEnd === true) {
|
|
236
|
-
if (this.foundation.isRangeType()) {
|
|
237
|
-
const currentPanelHeight = this.calcScrollListHeight();
|
|
238
|
-
this.setState({
|
|
239
|
-
currentPanelHeight
|
|
240
|
-
});
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
|
|
244
226
|
const isRange = this.foundation.isRangeType();
|
|
245
227
|
|
|
246
228
|
if (isRange) {
|
|
@@ -491,7 +473,8 @@ export default class MonthsGrid extends BaseComponent {
|
|
|
491
473
|
const {
|
|
492
474
|
locale,
|
|
493
475
|
localeCode,
|
|
494
|
-
density
|
|
476
|
+
density,
|
|
477
|
+
yearAndMonthOpts
|
|
495
478
|
} = this.props;
|
|
496
479
|
const y = pickerDate.getFullYear();
|
|
497
480
|
const m = pickerDate.getMonth() + 1;
|
|
@@ -510,7 +493,8 @@ export default class MonthsGrid extends BaseComponent {
|
|
|
510
493
|
wrapCurrent.style.height = 'auto';
|
|
511
494
|
}
|
|
512
495
|
},
|
|
513
|
-
density: density
|
|
496
|
+
density: density,
|
|
497
|
+
yearAndMonthOpts: yearAndMonthOpts
|
|
514
498
|
});
|
|
515
499
|
}
|
|
516
500
|
|
|
@@ -665,7 +649,6 @@ MonthsGrid.propTypes = {
|
|
|
665
649
|
startDateOffset: PropTypes.func,
|
|
666
650
|
endDateOffset: PropTypes.func,
|
|
667
651
|
autoSwitchDate: PropTypes.bool,
|
|
668
|
-
motionEnd: PropTypes.bool,
|
|
669
652
|
density: PropTypes.string,
|
|
670
653
|
dateFnsLocale: PropTypes.object.isRequired,
|
|
671
654
|
timeZone: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|