naive-ui 2.21.4 → 2.23.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/es/_internal/close/src/styles/index.cssr.js +6 -5
- package/es/_internal/scrollbar/src/ScrollBar.d.ts +4 -0
- package/es/_internal/scrollbar/src/ScrollBar.js +5 -2
- package/es/_internal/selection/src/Selection.js +11 -9
- package/es/_internal/selection/src/styles/index.cssr.js +6 -2
- package/es/_utils/composable/use-houdini.js +10 -7
- package/es/alert/src/Alert.d.ts +20 -20
- package/es/alert/src/Alert.js +22 -22
- package/es/alert/src/styles/index.cssr.js +45 -45
- package/es/anchor/src/AnchorAdapter.js +12 -12
- package/es/anchor/src/styles/index.cssr.js +41 -41
- package/es/auto-complete/src/AutoComplete.d.ts +2 -2
- package/es/auto-complete/src/AutoComplete.js +2 -2
- package/es/auto-complete/src/styles/index.cssr.js +4 -4
- package/es/avatar/src/Avatar.d.ts +10 -8
- package/es/avatar/src/Avatar.js +11 -9
- package/es/avatar/src/styles/index.cssr.js +14 -16
- package/es/back-top/src/BackTop.d.ts +13 -13
- package/es/back-top/src/BackTop.js +13 -13
- package/es/back-top/src/styles/index.cssr.js +29 -29
- package/es/badge/src/Badge.d.ts +6 -6
- package/es/badge/src/Badge.js +6 -6
- package/es/badge/src/styles/index.cssr.js +15 -15
- package/es/button/src/Button.d.ts +43 -38
- package/es/button/src/Button.js +124 -116
- package/es/button/src/styles/button.cssr.js +83 -80
- package/es/button/styles/light.js +1 -1
- package/es/calendar/src/Calendar.d.ts +6 -0
- package/es/cascader/src/Cascader.d.ts +135 -0
- package/es/cascader/src/Cascader.js +2 -4
- package/es/cascader/src/CascaderMenu.d.ts +345 -0
- package/es/cascader/src/CascaderMenu.js +6 -5
- package/es/cascader/src/CascaderOption.d.ts +18 -0
- package/es/cascader/src/CascaderSelectMenu.d.ts +18 -0
- package/es/cascader/src/CascaderSubmenu.d.ts +18 -0
- package/es/cascader/styles/dark.js +3 -1
- package/es/cascader/styles/light.d.ts +13 -0
- package/es/cascader/styles/light.js +3 -1
- package/es/config-provider/src/ConfigProvider.d.ts +18 -0
- package/es/data-table/src/DataTable.js +7 -13
- package/es/data-table/src/MainTable.js +2 -3
- package/es/data-table/src/TableParts/Body.d.ts +15 -4
- package/es/data-table/src/TableParts/Body.js +80 -28
- package/es/data-table/src/TableParts/Cell.js +2 -3
- package/es/data-table/src/TableParts/Header.js +2 -2
- package/es/data-table/src/interface.d.ts +4 -1
- package/es/data-table/src/styles/index.cssr.js +4 -3
- package/es/data-table/src/use-check.js +6 -2
- package/es/data-table/src/use-scroll.d.ts +2 -0
- package/es/data-table/src/use-scroll.js +34 -4
- package/es/data-table/src/use-table-data.js +3 -1
- package/es/data-table/styles/_common.js +1 -1
- package/es/date-picker/src/DatePicker.d.ts +30 -5
- package/es/date-picker/src/DatePicker.js +32 -9
- package/es/date-picker/src/config.d.ts +1 -9
- package/es/date-picker/src/config.js +0 -8
- package/es/date-picker/src/interface.d.ts +2 -1
- package/es/date-picker/src/panel/date.d.ts +17 -10
- package/es/date-picker/src/panel/date.js +2 -2
- package/es/date-picker/src/panel/daterange.d.ts +15 -9
- package/es/date-picker/src/panel/daterange.js +2 -2
- package/es/date-picker/src/panel/datetime.d.ts +17 -16
- package/es/date-picker/src/panel/datetime.js +2 -2
- package/es/date-picker/src/panel/datetimerange.d.ts +15 -9
- package/es/date-picker/src/panel/datetimerange.js +2 -2
- package/es/date-picker/src/panel/month.d.ts +21 -20
- package/es/date-picker/src/panel/month.js +23 -12
- package/es/date-picker/src/panel/use-calendar.d.ts +17 -39
- package/es/date-picker/src/panel/use-calendar.js +41 -23
- package/es/date-picker/src/panel/use-dual-calendar.d.ts +13 -36
- package/es/date-picker/src/panel/use-dual-calendar.js +35 -21
- package/es/date-picker/src/panel/use-panel-common.d.ts +13 -32
- package/es/date-picker/src/panel/use-panel-common.js +4 -8
- package/es/date-picker/src/utils.d.ts +19 -3
- package/es/date-picker/src/utils.js +40 -5
- package/es/date-picker/styles/_common.d.ts +2 -0
- package/es/date-picker/styles/_common.js +3 -1
- package/es/date-picker/styles/light.d.ts +4 -0
- package/es/dialog/src/Dialog.d.ts +21 -21
- package/es/dialog/src/Dialog.js +23 -23
- package/es/dialog/src/styles/index.cssr.js +45 -45
- package/es/divider/src/Divider.d.ts +4 -4
- package/es/divider/src/Divider.js +4 -4
- package/es/divider/src/styles/index.cssr.js +12 -12
- package/es/dynamic-tags/src/DynamicTags.d.ts +1 -1
- package/es/dynamic-tags/src/DynamicTags.js +1 -1
- package/es/dynamic-tags/src/styles/index.cssr.js +1 -1
- package/es/form/src/Form.d.ts +27 -27
- package/es/form/src/FormItem.d.ts +27 -27
- package/es/form/src/FormItemCol.d.ts +27 -27
- package/es/form/src/FormItemGridItem.d.ts +27 -27
- package/es/form/src/FormItemRow.d.ts +27 -27
- package/es/form/styles/_common.d.ts +0 -3
- package/es/form/styles/_common.js +0 -3
- package/es/form/styles/light.d.ts +3 -3
- package/es/form/styles/light.js +2 -2
- package/es/image/src/Image.js +8 -12
- package/es/input/src/Input.js +2 -0
- package/es/input-number/src/InputNumber.js +2 -0
- package/es/input-number/src/utils.js +1 -1
- package/es/locales/common/deDE.js +6 -0
- package/es/locales/common/enUS.d.ts +6 -0
- package/es/locales/common/enUS.js +7 -1
- package/es/locales/common/frFR.d.ts +3 -0
- package/es/locales/common/frFR.js +101 -0
- package/es/locales/common/idID.d.ts +2 -94
- package/es/locales/common/idID.js +6 -0
- package/es/locales/common/jaJP.js +6 -0
- package/es/locales/common/nbNO.js +6 -0
- package/es/locales/common/ruRU.js +6 -0
- package/es/locales/common/ukUA.js +6 -0
- package/es/locales/common/zhCN.js +6 -0
- package/es/locales/common/zhTW.d.ts +3 -0
- package/es/locales/common/zhTW.js +100 -0
- package/es/locales/date/frFR.d.ts +3 -0
- package/es/locales/date/frFR.js +6 -0
- package/es/locales/date/idID.d.ts +1 -6
- package/es/locales/date/zhTW.d.ts +3 -0
- package/es/locales/date/zhTW.js +6 -0
- package/es/locales/index.d.ts +4 -0
- package/es/locales/index.js +4 -0
- package/es/log/src/Log.d.ts +6 -6
- package/es/log/src/Log.js +6 -6
- package/es/log/src/styles/index.cssr.js +16 -18
- package/es/page-header/src/PageHeader.js +3 -3
- package/es/page-header/src/styles/index.cssr.js +2 -4
- package/es/popover/src/Popover.js +4 -1
- package/es/popover/src/PopoverBody.js +3 -3
- package/es/popselect/src/Popselect.d.ts +2 -11
- package/es/popselect/src/Popselect.js +2 -2
- package/es/popselect/src/PopselectPanel.d.ts +3 -11
- package/es/popselect/src/PopselectPanel.js +17 -11
- package/es/radio/src/Radio.js +3 -3
- package/es/radio/src/RadioButton.js +4 -5
- package/es/radio/src/styles/radio-group.cssr.js +8 -4
- package/es/radio/src/styles/radio.cssr.js +8 -4
- package/es/radio/src/use-radio.d.ts +0 -3
- package/es/radio/src/use-radio.js +1 -26
- package/es/steps/src/Step.d.ts +12 -12
- package/es/steps/src/Step.js +12 -12
- package/es/steps/src/styles/index.cssr.js +46 -46
- package/es/switch/src/Switch.d.ts +19 -19
- package/es/switch/src/Switch.js +26 -19
- package/es/switch/src/styles/index.cssr.js +59 -57
- package/es/tabs/src/styles/index.cssr.js +1 -0
- package/es/tag/src/Tag.d.ts +26 -26
- package/es/tag/src/Tag.js +26 -26
- package/es/tag/src/styles/index.cssr.js +55 -55
- package/es/tag/src/styles/rtl.cssr.js +1 -1
- package/es/time-picker/src/TimePicker.d.ts +17 -17
- package/es/time-picker/src/TimePicker.js +17 -17
- package/es/time-picker/src/styles/index.cssr.js +47 -47
- package/es/timeline/src/TimelineItem.d.ts +12 -12
- package/es/timeline/src/TimelineItem.js +12 -12
- package/es/timeline/src/styles/index.cssr.js +44 -44
- package/es/transfer/src/styles/index.cssr.js +9 -4
- package/es/tree/src/Tree.d.ts +11 -11
- package/es/tree/src/Tree.js +11 -11
- package/es/tree/src/dnd.js +2 -2
- package/es/tree/src/styles/index.cssr.js +33 -33
- package/es/tree-select/src/TreeSelect.d.ts +43 -6
- package/es/tree-select/src/TreeSelect.js +29 -14
- package/es/tree-select/src/styles/index.cssr.js +20 -11
- package/es/tree-select/styles/light.d.ts +6 -0
- package/es/tree-select/styles/light.js +5 -2
- package/es/typography/src/a.d.ts +2 -2
- package/es/typography/src/a.js +2 -2
- package/es/typography/src/blockquote.d.ts +5 -5
- package/es/typography/src/blockquote.js +5 -5
- package/es/typography/src/create-header.d.ts +8 -8
- package/es/typography/src/create-header.js +8 -8
- package/es/typography/src/headers.d.ts +48 -48
- package/es/typography/src/hr.d.ts +2 -1
- package/es/typography/src/hr.js +3 -1
- package/es/typography/src/ol.d.ts +7 -7
- package/es/typography/src/ol.js +7 -7
- package/es/typography/src/p.d.ts +5 -5
- package/es/typography/src/p.js +5 -5
- package/es/typography/src/styles/a.cssr.js +6 -6
- package/es/typography/src/styles/blockquote.cssr.js +11 -11
- package/es/typography/src/styles/header.cssr.js +19 -19
- package/es/typography/src/styles/hr.cssr.js +3 -3
- package/es/typography/src/styles/list.cssr.js +15 -15
- package/es/typography/src/styles/p.cssr.js +10 -10
- package/es/typography/src/styles/text.cssr.js +18 -18
- package/es/typography/src/text.d.ts +8 -7
- package/es/typography/src/text.js +9 -8
- package/es/typography/src/ul.d.ts +7 -7
- package/es/typography/src/ul.js +7 -7
- package/es/upload/src/Upload.js +16 -16
- package/es/upload/src/styles/index.cssr.js +36 -36
- package/es/version.d.ts +1 -1
- package/es/version.js +1 -1
- package/lib/_internal/close/src/styles/index.cssr.js +6 -5
- package/lib/_internal/scrollbar/src/ScrollBar.d.ts +4 -0
- package/lib/_internal/scrollbar/src/ScrollBar.js +5 -2
- package/lib/_internal/selection/src/Selection.js +11 -9
- package/lib/_internal/selection/src/styles/index.cssr.js +6 -2
- package/lib/_utils/composable/use-houdini.js +10 -7
- package/lib/alert/src/Alert.d.ts +20 -20
- package/lib/alert/src/Alert.js +22 -22
- package/lib/alert/src/styles/index.cssr.js +45 -45
- package/lib/anchor/src/AnchorAdapter.js +12 -12
- package/lib/anchor/src/styles/index.cssr.js +41 -41
- package/lib/auto-complete/src/AutoComplete.d.ts +2 -2
- package/lib/auto-complete/src/AutoComplete.js +2 -2
- package/lib/auto-complete/src/styles/index.cssr.js +4 -4
- package/lib/avatar/src/Avatar.d.ts +10 -8
- package/lib/avatar/src/Avatar.js +11 -9
- package/lib/avatar/src/styles/index.cssr.js +14 -16
- package/lib/back-top/src/BackTop.d.ts +13 -13
- package/lib/back-top/src/BackTop.js +13 -13
- package/lib/back-top/src/styles/index.cssr.js +29 -29
- package/lib/badge/src/Badge.d.ts +6 -6
- package/lib/badge/src/Badge.js +6 -6
- package/lib/badge/src/styles/index.cssr.js +15 -15
- package/lib/button/src/Button.d.ts +43 -38
- package/lib/button/src/Button.js +123 -115
- package/lib/button/src/styles/button.cssr.js +83 -80
- package/lib/button/styles/light.js +1 -1
- package/lib/calendar/src/Calendar.d.ts +6 -0
- package/lib/cascader/src/Cascader.d.ts +135 -0
- package/lib/cascader/src/Cascader.js +2 -4
- package/lib/cascader/src/CascaderMenu.d.ts +345 -0
- package/lib/cascader/src/CascaderMenu.js +6 -5
- package/lib/cascader/src/CascaderOption.d.ts +18 -0
- package/lib/cascader/src/CascaderSelectMenu.d.ts +18 -0
- package/lib/cascader/src/CascaderSubmenu.d.ts +18 -0
- package/lib/cascader/styles/dark.js +3 -1
- package/lib/cascader/styles/light.d.ts +13 -0
- package/lib/cascader/styles/light.js +3 -1
- package/lib/config-provider/src/ConfigProvider.d.ts +18 -0
- package/lib/data-table/src/DataTable.js +6 -12
- package/lib/data-table/src/MainTable.js +1 -2
- package/lib/data-table/src/TableParts/Body.d.ts +15 -4
- package/lib/data-table/src/TableParts/Body.js +78 -26
- package/lib/data-table/src/TableParts/Cell.js +2 -3
- package/lib/data-table/src/TableParts/Header.js +2 -2
- package/lib/data-table/src/interface.d.ts +4 -1
- package/lib/data-table/src/styles/index.cssr.js +4 -3
- package/lib/data-table/src/use-check.js +6 -2
- package/lib/data-table/src/use-scroll.d.ts +2 -0
- package/lib/data-table/src/use-scroll.js +34 -4
- package/lib/data-table/src/use-table-data.js +3 -1
- package/lib/data-table/styles/_common.js +1 -1
- package/lib/date-picker/src/DatePicker.d.ts +30 -5
- package/lib/date-picker/src/DatePicker.js +31 -8
- package/lib/date-picker/src/config.d.ts +1 -9
- package/lib/date-picker/src/config.js +1 -9
- package/lib/date-picker/src/interface.d.ts +2 -1
- package/lib/date-picker/src/panel/date.d.ts +17 -10
- package/lib/date-picker/src/panel/date.js +1 -1
- package/lib/date-picker/src/panel/daterange.d.ts +15 -9
- package/lib/date-picker/src/panel/daterange.js +1 -1
- package/lib/date-picker/src/panel/datetime.d.ts +17 -16
- package/lib/date-picker/src/panel/datetime.js +1 -1
- package/lib/date-picker/src/panel/datetimerange.d.ts +15 -9
- package/lib/date-picker/src/panel/datetimerange.js +2 -2
- package/lib/date-picker/src/panel/month.d.ts +21 -20
- package/lib/date-picker/src/panel/month.js +23 -12
- package/lib/date-picker/src/panel/use-calendar.d.ts +17 -39
- package/lib/date-picker/src/panel/use-calendar.js +40 -21
- package/lib/date-picker/src/panel/use-dual-calendar.d.ts +13 -36
- package/lib/date-picker/src/panel/use-dual-calendar.js +34 -19
- package/lib/date-picker/src/panel/use-panel-common.d.ts +13 -32
- package/lib/date-picker/src/panel/use-panel-common.js +5 -8
- package/lib/date-picker/src/utils.d.ts +19 -3
- package/lib/date-picker/src/utils.js +41 -4
- package/lib/date-picker/styles/_common.d.ts +2 -0
- package/lib/date-picker/styles/_common.js +3 -1
- package/lib/date-picker/styles/light.d.ts +4 -0
- package/lib/dialog/src/Dialog.d.ts +21 -21
- package/lib/dialog/src/Dialog.js +23 -23
- package/lib/dialog/src/styles/index.cssr.js +45 -45
- package/lib/divider/src/Divider.d.ts +4 -4
- package/lib/divider/src/Divider.js +4 -4
- package/lib/divider/src/styles/index.cssr.js +12 -12
- package/lib/dynamic-tags/src/DynamicTags.d.ts +1 -1
- package/lib/dynamic-tags/src/DynamicTags.js +1 -1
- package/lib/dynamic-tags/src/styles/index.cssr.js +1 -1
- package/lib/form/src/Form.d.ts +27 -27
- package/lib/form/src/FormItem.d.ts +27 -27
- package/lib/form/src/FormItemCol.d.ts +27 -27
- package/lib/form/src/FormItemGridItem.d.ts +27 -27
- package/lib/form/src/FormItemRow.d.ts +27 -27
- package/lib/form/styles/_common.d.ts +0 -3
- package/lib/form/styles/_common.js +0 -3
- package/lib/form/styles/light.d.ts +3 -3
- package/lib/form/styles/light.js +2 -2
- package/lib/image/src/Image.js +7 -11
- package/lib/input/src/Input.js +2 -0
- package/lib/input-number/src/InputNumber.js +2 -0
- package/lib/input-number/src/utils.js +1 -1
- package/lib/locales/common/deDE.js +6 -0
- package/lib/locales/common/enUS.d.ts +6 -0
- package/lib/locales/common/enUS.js +7 -1
- package/lib/locales/common/frFR.d.ts +3 -0
- package/lib/locales/common/frFR.js +103 -0
- package/lib/locales/common/idID.d.ts +2 -94
- package/lib/locales/common/idID.js +6 -0
- package/lib/locales/common/jaJP.js +6 -0
- package/lib/locales/common/nbNO.js +6 -0
- package/lib/locales/common/ruRU.js +6 -0
- package/lib/locales/common/ukUA.js +6 -0
- package/lib/locales/common/zhCN.js +6 -0
- package/lib/locales/common/zhTW.d.ts +3 -0
- package/lib/locales/common/zhTW.js +102 -0
- package/lib/locales/date/frFR.d.ts +3 -0
- package/lib/locales/date/frFR.js +11 -0
- package/lib/locales/date/idID.d.ts +1 -6
- package/lib/locales/date/zhTW.d.ts +3 -0
- package/lib/locales/date/zhTW.js +11 -0
- package/lib/locales/index.d.ts +4 -0
- package/lib/locales/index.js +9 -1
- package/lib/log/src/Log.d.ts +6 -6
- package/lib/log/src/Log.js +6 -6
- package/lib/log/src/styles/index.cssr.js +16 -18
- package/lib/page-header/src/PageHeader.js +3 -3
- package/lib/page-header/src/styles/index.cssr.js +2 -4
- package/lib/popover/src/Popover.js +4 -1
- package/lib/popover/src/PopoverBody.js +3 -3
- package/lib/popselect/src/Popselect.d.ts +2 -11
- package/lib/popselect/src/Popselect.js +2 -2
- package/lib/popselect/src/PopselectPanel.d.ts +3 -11
- package/lib/popselect/src/PopselectPanel.js +16 -10
- package/lib/radio/src/Radio.js +3 -3
- package/lib/radio/src/RadioButton.js +4 -5
- package/lib/radio/src/styles/radio-group.cssr.js +8 -4
- package/lib/radio/src/styles/radio.cssr.js +8 -4
- package/lib/radio/src/use-radio.d.ts +0 -3
- package/lib/radio/src/use-radio.js +1 -26
- package/lib/steps/src/Step.d.ts +12 -12
- package/lib/steps/src/Step.js +12 -12
- package/lib/steps/src/styles/index.cssr.js +46 -46
- package/lib/switch/src/Switch.d.ts +19 -19
- package/lib/switch/src/Switch.js +26 -19
- package/lib/switch/src/styles/index.cssr.js +59 -57
- package/lib/tabs/src/styles/index.cssr.js +1 -0
- package/lib/tag/src/Tag.d.ts +26 -26
- package/lib/tag/src/Tag.js +26 -26
- package/lib/tag/src/styles/index.cssr.js +55 -55
- package/lib/tag/src/styles/rtl.cssr.js +1 -1
- package/lib/time-picker/src/TimePicker.d.ts +17 -17
- package/lib/time-picker/src/TimePicker.js +17 -17
- package/lib/time-picker/src/styles/index.cssr.js +47 -47
- package/lib/timeline/src/TimelineItem.d.ts +12 -12
- package/lib/timeline/src/TimelineItem.js +12 -12
- package/lib/timeline/src/styles/index.cssr.js +44 -44
- package/lib/transfer/src/styles/index.cssr.js +9 -4
- package/lib/tree/src/Tree.d.ts +11 -11
- package/lib/tree/src/Tree.js +11 -11
- package/lib/tree/src/dnd.js +2 -2
- package/lib/tree/src/styles/index.cssr.js +33 -33
- package/lib/tree-select/src/TreeSelect.d.ts +43 -6
- package/lib/tree-select/src/TreeSelect.js +28 -13
- package/lib/tree-select/src/styles/index.cssr.js +20 -11
- package/lib/tree-select/styles/light.d.ts +6 -0
- package/lib/tree-select/styles/light.js +5 -2
- package/lib/typography/src/a.d.ts +2 -2
- package/lib/typography/src/a.js +2 -2
- package/lib/typography/src/blockquote.d.ts +5 -5
- package/lib/typography/src/blockquote.js +5 -5
- package/lib/typography/src/create-header.d.ts +8 -8
- package/lib/typography/src/create-header.js +8 -8
- package/lib/typography/src/headers.d.ts +48 -48
- package/lib/typography/src/hr.d.ts +2 -1
- package/lib/typography/src/hr.js +3 -1
- package/lib/typography/src/ol.d.ts +7 -7
- package/lib/typography/src/ol.js +7 -7
- package/lib/typography/src/p.d.ts +5 -5
- package/lib/typography/src/p.js +5 -5
- package/lib/typography/src/styles/a.cssr.js +6 -6
- package/lib/typography/src/styles/blockquote.cssr.js +11 -11
- package/lib/typography/src/styles/header.cssr.js +19 -19
- package/lib/typography/src/styles/hr.cssr.js +3 -3
- package/lib/typography/src/styles/list.cssr.js +15 -15
- package/lib/typography/src/styles/p.cssr.js +10 -10
- package/lib/typography/src/styles/text.cssr.js +18 -18
- package/lib/typography/src/text.d.ts +8 -7
- package/lib/typography/src/text.js +9 -8
- package/lib/typography/src/ul.d.ts +7 -7
- package/lib/typography/src/ul.js +7 -7
- package/lib/upload/src/Upload.js +16 -16
- package/lib/upload/src/styles/index.cssr.js +36 -36
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +29 -28
- package/web-types.json +25 -7
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { ref, computed, inject, watch } from 'vue';
|
|
2
|
-
import { addMonths, addYears, isSameMonth, getTime, format, set, getYear, getMonth, getDate, isValid, startOfDay, startOfSecond, startOfMonth, startOfYear } from 'date-fns';
|
|
3
|
-
import { dateArray, monthArray, strictParse, yearArray } from '../utils';
|
|
4
|
-
import { usePanelCommon } from './use-panel-common';
|
|
2
|
+
import { addMonths, addYears, isSameMonth, getTime, format, set, getYear, getMonth, getDate, isValid, startOfDay, startOfSecond, startOfMonth, startOfYear, startOfQuarter, setQuarter, setYear } from 'date-fns';
|
|
3
|
+
import { getDefaultTime, dateArray, monthArray, strictParse, yearArray, quarterArray } from '../utils';
|
|
5
4
|
import { datePickerInjectionKey } from '../interface';
|
|
6
|
-
|
|
5
|
+
import { usePanelCommon, usePanelCommonProps } from './use-panel-common';
|
|
6
|
+
const useCalendarProps = Object.assign(Object.assign({}, usePanelCommonProps), { actions: {
|
|
7
7
|
type: Array,
|
|
8
8
|
default: () => ['now', 'clear', 'confirm']
|
|
9
9
|
} });
|
|
10
10
|
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
11
11
|
function useCalendar(props, type) {
|
|
12
12
|
const panelCommon = usePanelCommon(props);
|
|
13
|
-
const { isValueInvalidRef, isDateDisabledRef, isDateInvalidRef, isTimeInvalidRef, isDateTimeInvalidRef, isHourDisabledRef, isMinuteDisabledRef, isSecondDisabledRef, localeRef, firstDayOfWeekRef, datePickerSlots,
|
|
13
|
+
const { isValueInvalidRef, isDateDisabledRef, isDateInvalidRef, isTimeInvalidRef, isDateTimeInvalidRef, isHourDisabledRef, isMinuteDisabledRef, isSecondDisabledRef, localeRef, firstDayOfWeekRef, datePickerSlots, scrollPickerColumns
|
|
14
14
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
15
15
|
} = inject(datePickerInjectionKey);
|
|
16
16
|
const validation = {
|
|
@@ -23,9 +23,10 @@ function useCalendar(props, type) {
|
|
|
23
23
|
isMinuteDisabled: isMinuteDisabledRef,
|
|
24
24
|
isSecondDisabled: isSecondDisabledRef
|
|
25
25
|
};
|
|
26
|
+
const mergedDateFormatRef = computed(() => props.dateFormat || localeRef.value.dateFormat);
|
|
26
27
|
const dateInputValueRef = ref(props.value === null || Array.isArray(props.value)
|
|
27
28
|
? ''
|
|
28
|
-
: format(props.value,
|
|
29
|
+
: format(props.value, mergedDateFormatRef.value));
|
|
29
30
|
const calendarValueRef = ref(props.value === null || Array.isArray(props.value)
|
|
30
31
|
? Date.now()
|
|
31
32
|
: props.value);
|
|
@@ -43,6 +44,9 @@ function useCalendar(props, type) {
|
|
|
43
44
|
const yearArrayRef = computed(() => {
|
|
44
45
|
return yearArray(calendarValueRef.value, props.value, nowRef.value);
|
|
45
46
|
});
|
|
47
|
+
const querterArrayRef = computed(() => {
|
|
48
|
+
return quarterArray(calendarValueRef.value, props.value, nowRef.value);
|
|
49
|
+
});
|
|
46
50
|
const weekdaysRef = computed(() => {
|
|
47
51
|
return dateArrayRef.value.slice(0, 7).map((dateItem) => {
|
|
48
52
|
const { ts } = dateItem;
|
|
@@ -62,7 +66,7 @@ function useCalendar(props, type) {
|
|
|
62
66
|
});
|
|
63
67
|
watch(computed(() => props.value), (value) => {
|
|
64
68
|
if (value !== null && !Array.isArray(value)) {
|
|
65
|
-
dateInputValueRef.value = format(value,
|
|
69
|
+
dateInputValueRef.value = format(value, mergedDateFormatRef.value, panelCommon.dateFnsOptions.value);
|
|
66
70
|
calendarValueRef.value = value;
|
|
67
71
|
}
|
|
68
72
|
else {
|
|
@@ -76,6 +80,8 @@ function useCalendar(props, type) {
|
|
|
76
80
|
return getTime(startOfMonth(value));
|
|
77
81
|
if (type === 'year')
|
|
78
82
|
return getTime(startOfYear(value));
|
|
83
|
+
if (type === 'quarter')
|
|
84
|
+
return getTime(startOfQuarter(value));
|
|
79
85
|
return getTime(startOfDay(value));
|
|
80
86
|
}
|
|
81
87
|
function mergedIsDateDisabled(ts) {
|
|
@@ -85,7 +91,7 @@ function useCalendar(props, type) {
|
|
|
85
91
|
return isDateDisabled(ts);
|
|
86
92
|
}
|
|
87
93
|
function handleDateInput(value) {
|
|
88
|
-
const date = strictParse(value,
|
|
94
|
+
const date = strictParse(value, mergedDateFormatRef.value, new Date(), panelCommon.dateFnsOptions.value);
|
|
89
95
|
if (isValid(date)) {
|
|
90
96
|
if (props.value === null) {
|
|
91
97
|
panelCommon.doUpdateValue(getTime(sanitizeValue(Date.now())), false);
|
|
@@ -104,7 +110,7 @@ function useCalendar(props, type) {
|
|
|
104
110
|
}
|
|
105
111
|
}
|
|
106
112
|
function handleDateInputBlur() {
|
|
107
|
-
const date = strictParse(dateInputValueRef.value,
|
|
113
|
+
const date = strictParse(dateInputValueRef.value, mergedDateFormatRef.value, new Date(), panelCommon.dateFnsOptions.value);
|
|
108
114
|
if (isValid(date)) {
|
|
109
115
|
if (props.value === null) {
|
|
110
116
|
panelCommon.doUpdateValue(getTime(sanitizeValue(Date.now())), false);
|
|
@@ -143,17 +149,30 @@ function useCalendar(props, type) {
|
|
|
143
149
|
else {
|
|
144
150
|
newValue = Date.now();
|
|
145
151
|
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
scrollYearMonth(newValue);
|
|
152
|
+
if (type === 'datetime' &&
|
|
153
|
+
props.defaultTime !== null &&
|
|
154
|
+
!Array.isArray(props.defaultTime)) {
|
|
155
|
+
const time = getDefaultTime(props.defaultTime);
|
|
156
|
+
if (time) {
|
|
157
|
+
newValue = getTime(set(newValue, time)); // setDate getTime(addMilliseconds(startOfDay(newValue), time))
|
|
158
|
+
}
|
|
154
159
|
}
|
|
155
|
-
|
|
156
|
-
|
|
160
|
+
newValue = getTime(dateItem.type === 'quarter' && dateItem.dateObject.quarter
|
|
161
|
+
? setQuarter(setYear(newValue, dateItem.dateObject.year), dateItem.dateObject.quarter)
|
|
162
|
+
: set(newValue, dateItem.dateObject));
|
|
163
|
+
panelCommon.doUpdateValue(sanitizeValue(newValue), type === 'date' || type === 'year');
|
|
164
|
+
switch (type) {
|
|
165
|
+
case 'date':
|
|
166
|
+
case 'year':
|
|
167
|
+
panelCommon.doClose();
|
|
168
|
+
break;
|
|
169
|
+
case 'month':
|
|
170
|
+
panelCommon.disableTransitionOneTick();
|
|
171
|
+
scrollPickerColumns(newValue);
|
|
172
|
+
break;
|
|
173
|
+
case 'quarter':
|
|
174
|
+
scrollPickerColumns(newValue);
|
|
175
|
+
break;
|
|
157
176
|
}
|
|
158
177
|
}
|
|
159
178
|
function deriveDateInputValue(time) {
|
|
@@ -166,7 +185,7 @@ function useCalendar(props, type) {
|
|
|
166
185
|
if (time === undefined) {
|
|
167
186
|
time = props.value;
|
|
168
187
|
}
|
|
169
|
-
dateInputValueRef.value = format(time,
|
|
188
|
+
dateInputValueRef.value = format(time, mergedDateFormatRef.value, panelCommon.dateFnsOptions.value);
|
|
170
189
|
}
|
|
171
190
|
function handleConfirmClick() {
|
|
172
191
|
if (validation.isDateInvalid.value || validation.isTimeInvalid.value) {
|
|
@@ -227,7 +246,7 @@ function useCalendar(props, type) {
|
|
|
227
246
|
panelCommon.clearPendingValue();
|
|
228
247
|
handleConfirmClick();
|
|
229
248
|
}
|
|
230
|
-
return Object.assign(Object.assign(Object.assign({ dateArray: dateArrayRef, monthArray: monthArrayRef, yearArray: yearArrayRef, calendarYear: calendarYearRef, calendarMonth: calendarMonthRef, weekdays: weekdaysRef, mergedIsDateDisabled,
|
|
249
|
+
return Object.assign(Object.assign(Object.assign({ dateArray: dateArrayRef, monthArray: monthArrayRef, yearArray: yearArrayRef, quarterArray: querterArrayRef, calendarYear: calendarYearRef, calendarMonth: calendarMonthRef, weekdays: weekdaysRef, mergedIsDateDisabled,
|
|
231
250
|
nextYear,
|
|
232
251
|
prevYear,
|
|
233
252
|
nextMonth,
|
|
@@ -249,5 +268,4 @@ function useCalendar(props, type) {
|
|
|
249
268
|
yearScrollRef,
|
|
250
269
|
scrollbarInstRef });
|
|
251
270
|
}
|
|
252
|
-
useCalendar
|
|
253
|
-
export { useCalendar };
|
|
271
|
+
export { useCalendar, useCalendarProps };
|
|
@@ -1,25 +1,23 @@
|
|
|
1
1
|
import { ExtractPropTypes } from 'vue';
|
|
2
2
|
import { DateItem } from '../utils';
|
|
3
|
-
import { Shortcuts } from '../interface';
|
|
3
|
+
import type { Shortcuts } from '../interface';
|
|
4
4
|
declare const useDualCalendarProps: {
|
|
5
5
|
readonly actions: {
|
|
6
6
|
readonly type: ArrayConstructor;
|
|
7
7
|
readonly default: () => string[];
|
|
8
8
|
};
|
|
9
9
|
readonly active: BooleanConstructor;
|
|
10
|
-
readonly dateFormat:
|
|
11
|
-
readonly type: StringConstructor;
|
|
12
|
-
readonly default: "yyyy-MM-dd";
|
|
13
|
-
};
|
|
10
|
+
readonly dateFormat: StringConstructor;
|
|
14
11
|
readonly timeFormat: {
|
|
15
12
|
readonly type: StringConstructor;
|
|
16
|
-
readonly
|
|
13
|
+
readonly value: "HH:mm:ss";
|
|
17
14
|
};
|
|
18
15
|
readonly value: {
|
|
19
16
|
readonly type: import("vue").PropType<import("../interface").Value | null>;
|
|
20
17
|
readonly default: null;
|
|
21
18
|
};
|
|
22
19
|
readonly shortcuts: import("vue").PropType<Shortcuts>;
|
|
20
|
+
readonly defaultTime: import("vue").PropType<import("../interface").DefaultTime>;
|
|
23
21
|
readonly onConfirm: FunctionConstructor;
|
|
24
22
|
readonly onClose: import("vue").PropType<import("../interface").OnClose>;
|
|
25
23
|
readonly onTabOut: FunctionConstructor;
|
|
@@ -210,12 +208,14 @@ declare function useDualCalendar(props: ExtractPropTypes<typeof useDualCalendarP
|
|
|
210
208
|
calendarLeftPaddingDatetimerange: string;
|
|
211
209
|
calendarLeftPaddingMonth: string;
|
|
212
210
|
calendarLeftPaddingYear: string;
|
|
211
|
+
calendarLeftPaddingQuarter: string;
|
|
213
212
|
calendarRightPaddingDate: string;
|
|
214
213
|
calendarRightPaddingDatetime: string;
|
|
215
214
|
calendarRightPaddingDaterange: string;
|
|
216
215
|
calendarRightPaddingDatetimerange: string;
|
|
217
216
|
calendarRightPaddingMonth: string;
|
|
218
217
|
calendarRightPaddingYear: string;
|
|
218
|
+
calendarRightPaddingQuarter: string;
|
|
219
219
|
};
|
|
220
220
|
peers: {
|
|
221
221
|
Input: import("../../../_mixins").Theme<"Input", {
|
|
@@ -1072,6 +1072,11 @@ declare function useDualCalendar(props: ExtractPropTypes<typeof useDualCalendarP
|
|
|
1072
1072
|
yearFormat: string;
|
|
1073
1073
|
monthFormat: string;
|
|
1074
1074
|
dayFormat: string;
|
|
1075
|
+
yearTypeFormat: string;
|
|
1076
|
+
monthTypeFormat: string;
|
|
1077
|
+
dateFormat: string;
|
|
1078
|
+
dateTimeFormat: string;
|
|
1079
|
+
quarterFormat: string;
|
|
1075
1080
|
clear: string;
|
|
1076
1081
|
now: string;
|
|
1077
1082
|
confirm: string;
|
|
@@ -1081,6 +1086,7 @@ declare function useDualCalendar(props: ExtractPropTypes<typeof useDualCalendarP
|
|
|
1081
1086
|
datetimePlaceholder: string;
|
|
1082
1087
|
monthPlaceholder: string;
|
|
1083
1088
|
yearPlaceholder: string;
|
|
1089
|
+
quarterPlaceholder: string;
|
|
1084
1090
|
startDatePlaceholder: string;
|
|
1085
1091
|
endDatePlaceholder: string;
|
|
1086
1092
|
startDatetimePlaceholder: string;
|
|
@@ -1129,33 +1135,4 @@ declare function useDualCalendar(props: ExtractPropTypes<typeof useDualCalendarP
|
|
|
1129
1135
|
handleRangeShortcutMouseenter: (shortcut: Shortcuts[string]) => void;
|
|
1130
1136
|
handleRangeShortcutClick: (shortcut: Shortcuts[string]) => void;
|
|
1131
1137
|
};
|
|
1132
|
-
|
|
1133
|
-
var props: {
|
|
1134
|
-
readonly actions: {
|
|
1135
|
-
readonly type: ArrayConstructor;
|
|
1136
|
-
readonly default: () => string[];
|
|
1137
|
-
};
|
|
1138
|
-
readonly active: BooleanConstructor;
|
|
1139
|
-
readonly dateFormat: {
|
|
1140
|
-
readonly type: StringConstructor;
|
|
1141
|
-
readonly default: "yyyy-MM-dd";
|
|
1142
|
-
};
|
|
1143
|
-
readonly timeFormat: {
|
|
1144
|
-
readonly type: StringConstructor;
|
|
1145
|
-
readonly default: "HH:mm:ss";
|
|
1146
|
-
};
|
|
1147
|
-
readonly value: {
|
|
1148
|
-
readonly type: import("vue").PropType<import("../interface").Value | null>;
|
|
1149
|
-
readonly default: null;
|
|
1150
|
-
};
|
|
1151
|
-
readonly shortcuts: import("vue").PropType<Shortcuts>;
|
|
1152
|
-
readonly onConfirm: FunctionConstructor;
|
|
1153
|
-
readonly onClose: import("vue").PropType<import("../interface").OnClose>;
|
|
1154
|
-
readonly onTabOut: FunctionConstructor;
|
|
1155
|
-
readonly onUpdateValue: {
|
|
1156
|
-
readonly type: import("vue").PropType<import("../interface").OnPanelUpdateValue>;
|
|
1157
|
-
readonly required: true;
|
|
1158
|
-
};
|
|
1159
|
-
};
|
|
1160
|
-
}
|
|
1161
|
-
export { useDualCalendar };
|
|
1138
|
+
export { useDualCalendar, useDualCalendarProps };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { inject, computed, watch, ref } from 'vue';
|
|
2
|
-
import { addMonths, format,
|
|
3
|
-
import { dateArray, strictParse } from '../utils';
|
|
4
|
-
import { usePanelCommon } from './use-panel-common';
|
|
2
|
+
import { addMonths, format, getYear, getMonth, startOfMonth, isValid, startOfSecond, startOfDay, set, getDate, getTime } from 'date-fns';
|
|
3
|
+
import { getDefaultTime, dateArray, strictParse } from '../utils';
|
|
5
4
|
import { datePickerInjectionKey } from '../interface';
|
|
6
|
-
|
|
5
|
+
import { usePanelCommon, usePanelCommonProps } from './use-panel-common';
|
|
6
|
+
const useDualCalendarProps = Object.assign(Object.assign({}, usePanelCommonProps), { actions: {
|
|
7
7
|
type: Array,
|
|
8
8
|
default: () => ['clear', 'confirm']
|
|
9
9
|
} });
|
|
@@ -36,12 +36,13 @@ function useDualCalendar(props, type = 'datetime') {
|
|
|
36
36
|
const nowRef = ref(Date.now());
|
|
37
37
|
const isSelectingRef = ref(false);
|
|
38
38
|
const memorizedStartDateTimeRef = ref(0);
|
|
39
|
-
const
|
|
39
|
+
const mergedDateFormatRef = computed(() => props.dateFormat || localeRef.value.dateFormat);
|
|
40
|
+
const { value } = props;
|
|
40
41
|
const startDateInput = ref(Array.isArray(value)
|
|
41
|
-
? format(value[0],
|
|
42
|
+
? format(value[0], mergedDateFormatRef.value, panelCommon.dateFnsOptions.value)
|
|
42
43
|
: '');
|
|
43
44
|
const endDateInputRef = ref(Array.isArray(value)
|
|
44
|
-
? format(value[1],
|
|
45
|
+
? format(value[1], mergedDateFormatRef.value, panelCommon.dateFnsOptions.value)
|
|
45
46
|
: '');
|
|
46
47
|
if (Array.isArray(value)) {
|
|
47
48
|
syncCalendarTimeWithValue(value);
|
|
@@ -98,9 +99,8 @@ function useDualCalendar(props, type = 'datetime') {
|
|
|
98
99
|
watch(computed(() => props.value), (value) => {
|
|
99
100
|
if (value !== null && Array.isArray(value)) {
|
|
100
101
|
const [startMoment, endMoment] = value;
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
endDateInputRef.value = format(endMoment, dateFormat, panelCommon.dateFnsOptions.value);
|
|
102
|
+
startDateInput.value = format(startMoment, mergedDateFormatRef.value, panelCommon.dateFnsOptions.value);
|
|
103
|
+
endDateInputRef.value = format(endMoment, mergedDateFormatRef.value, panelCommon.dateFnsOptions.value);
|
|
104
104
|
if (!isSelectingRef.value) {
|
|
105
105
|
syncCalendarTimeWithValue(value);
|
|
106
106
|
}
|
|
@@ -287,8 +287,24 @@ function useDualCalendar(props, type = 'datetime') {
|
|
|
287
287
|
if (typeof startTime !== 'number') {
|
|
288
288
|
startTime = getTime(startTime);
|
|
289
289
|
}
|
|
290
|
-
|
|
291
|
-
|
|
290
|
+
let startDefaultTime;
|
|
291
|
+
let endDefaultTime;
|
|
292
|
+
if (type === 'datetimerange') {
|
|
293
|
+
const { defaultTime } = props;
|
|
294
|
+
if (Array.isArray(defaultTime)) {
|
|
295
|
+
startDefaultTime = getDefaultTime(defaultTime[0]);
|
|
296
|
+
endDefaultTime = getDefaultTime(defaultTime[1]);
|
|
297
|
+
}
|
|
298
|
+
else {
|
|
299
|
+
startDefaultTime = getDefaultTime(defaultTime);
|
|
300
|
+
endDefaultTime = startDefaultTime;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
if (startDefaultTime) {
|
|
304
|
+
startTime = getTime(set(startTime, startDefaultTime));
|
|
305
|
+
}
|
|
306
|
+
if (endDefaultTime) {
|
|
307
|
+
endTime = getTime(set(endTime, endDefaultTime));
|
|
292
308
|
}
|
|
293
309
|
panelCommon.doUpdateValue([startTime, endTime], false);
|
|
294
310
|
}
|
|
@@ -302,7 +318,7 @@ function useDualCalendar(props, type = 'datetime') {
|
|
|
302
318
|
}
|
|
303
319
|
}
|
|
304
320
|
function handleStartDateInput(value) {
|
|
305
|
-
const date = strictParse(value,
|
|
321
|
+
const date = strictParse(value, mergedDateFormatRef.value, new Date(), panelCommon.dateFnsOptions.value);
|
|
306
322
|
if (isValid(date)) {
|
|
307
323
|
if (!props.value) {
|
|
308
324
|
const newValue = set(new Date(), {
|
|
@@ -327,7 +343,7 @@ function useDualCalendar(props, type = 'datetime') {
|
|
|
327
343
|
}
|
|
328
344
|
function handleEndDateInput(value) {
|
|
329
345
|
/** strict check when input */
|
|
330
|
-
const date = strictParse(value,
|
|
346
|
+
const date = strictParse(value, mergedDateFormatRef.value, new Date(), panelCommon.dateFnsOptions.value);
|
|
331
347
|
if (isValid(date)) {
|
|
332
348
|
if (props.value === null) {
|
|
333
349
|
const newValue = set(new Date(), {
|
|
@@ -351,7 +367,7 @@ function useDualCalendar(props, type = 'datetime') {
|
|
|
351
367
|
}
|
|
352
368
|
}
|
|
353
369
|
function handleStartDateInputBlur() {
|
|
354
|
-
const date = strictParse(startDateInput.value,
|
|
370
|
+
const date = strictParse(startDateInput.value, mergedDateFormatRef.value, new Date(), panelCommon.dateFnsOptions.value);
|
|
355
371
|
const { value } = props;
|
|
356
372
|
if (isValid(date)) {
|
|
357
373
|
if (value === null) {
|
|
@@ -376,7 +392,7 @@ function useDualCalendar(props, type = 'datetime') {
|
|
|
376
392
|
}
|
|
377
393
|
}
|
|
378
394
|
function handleEndDateInputBlur() {
|
|
379
|
-
const date = strictParse(endDateInputRef.value,
|
|
395
|
+
const date = strictParse(endDateInputRef.value, mergedDateFormatRef.value, new Date(), panelCommon.dateFnsOptions.value);
|
|
380
396
|
const { value } = props;
|
|
381
397
|
if (isValid(date)) {
|
|
382
398
|
if (value === null) {
|
|
@@ -409,12 +425,11 @@ function useDualCalendar(props, type = 'datetime') {
|
|
|
409
425
|
endDateInputRef.value = '';
|
|
410
426
|
return;
|
|
411
427
|
}
|
|
412
|
-
const { dateFormat } = props;
|
|
413
428
|
if (times === undefined) {
|
|
414
429
|
times = value;
|
|
415
430
|
}
|
|
416
|
-
startDateInput.value = format(times[0],
|
|
417
|
-
endDateInputRef.value = format(times[1],
|
|
431
|
+
startDateInput.value = format(times[0], mergedDateFormatRef.value, panelCommon.dateFnsOptions.value);
|
|
432
|
+
endDateInputRef.value = format(times[1], mergedDateFormatRef.value, panelCommon.dateFnsOptions.value);
|
|
418
433
|
}
|
|
419
434
|
function handleStartTimePickerChange(value) {
|
|
420
435
|
if (value === null)
|
|
@@ -467,5 +482,4 @@ function useDualCalendar(props, type = 'datetime') {
|
|
|
467
482
|
handleEndDateInputBlur,
|
|
468
483
|
datePickerSlots, shortcuts: shortcutsRef });
|
|
469
484
|
}
|
|
470
|
-
useDualCalendar
|
|
471
|
-
export { useDualCalendar };
|
|
485
|
+
export { useDualCalendar, useDualCalendarProps };
|
|
@@ -1,20 +1,18 @@
|
|
|
1
1
|
import { PropType, ExtractPropTypes } from 'vue';
|
|
2
|
-
import { Value, OnPanelUpdateValue, OnClose, Shortcuts } from '../interface';
|
|
2
|
+
import { Value, OnPanelUpdateValue, OnClose, Shortcuts, DefaultTime } from '../interface';
|
|
3
3
|
declare const usePanelCommonProps: {
|
|
4
4
|
readonly active: BooleanConstructor;
|
|
5
|
-
readonly dateFormat:
|
|
6
|
-
readonly type: StringConstructor;
|
|
7
|
-
readonly default: "yyyy-MM-dd";
|
|
8
|
-
};
|
|
5
|
+
readonly dateFormat: StringConstructor;
|
|
9
6
|
readonly timeFormat: {
|
|
10
7
|
readonly type: StringConstructor;
|
|
11
|
-
readonly
|
|
8
|
+
readonly value: "HH:mm:ss";
|
|
12
9
|
};
|
|
13
10
|
readonly value: {
|
|
14
11
|
readonly type: PropType<Value | null>;
|
|
15
12
|
readonly default: null;
|
|
16
13
|
};
|
|
17
14
|
readonly shortcuts: PropType<Shortcuts>;
|
|
15
|
+
readonly defaultTime: PropType<DefaultTime>;
|
|
18
16
|
readonly onConfirm: FunctionConstructor;
|
|
19
17
|
readonly onClose: PropType<OnClose>;
|
|
20
18
|
readonly onTabOut: FunctionConstructor;
|
|
@@ -176,12 +174,14 @@ declare function usePanelCommon(props: UsePanelCommonProps): {
|
|
|
176
174
|
calendarLeftPaddingDatetimerange: string;
|
|
177
175
|
calendarLeftPaddingMonth: string;
|
|
178
176
|
calendarLeftPaddingYear: string;
|
|
177
|
+
calendarLeftPaddingQuarter: string;
|
|
179
178
|
calendarRightPaddingDate: string;
|
|
180
179
|
calendarRightPaddingDatetime: string;
|
|
181
180
|
calendarRightPaddingDaterange: string;
|
|
182
181
|
calendarRightPaddingDatetimerange: string;
|
|
183
182
|
calendarRightPaddingMonth: string;
|
|
184
183
|
calendarRightPaddingYear: string;
|
|
184
|
+
calendarRightPaddingQuarter: string;
|
|
185
185
|
};
|
|
186
186
|
peers: {
|
|
187
187
|
Input: import("../../../_mixins").Theme<"Input", {
|
|
@@ -1039,6 +1039,11 @@ declare function usePanelCommon(props: UsePanelCommonProps): {
|
|
|
1039
1039
|
yearFormat: string;
|
|
1040
1040
|
monthFormat: string;
|
|
1041
1041
|
dayFormat: string;
|
|
1042
|
+
yearTypeFormat: string;
|
|
1043
|
+
monthTypeFormat: string;
|
|
1044
|
+
dateFormat: string;
|
|
1045
|
+
dateTimeFormat: string;
|
|
1046
|
+
quarterFormat: string;
|
|
1042
1047
|
clear: string;
|
|
1043
1048
|
now: string;
|
|
1044
1049
|
confirm: string;
|
|
@@ -1048,6 +1053,7 @@ declare function usePanelCommon(props: UsePanelCommonProps): {
|
|
|
1048
1053
|
datetimePlaceholder: string;
|
|
1049
1054
|
monthPlaceholder: string;
|
|
1050
1055
|
yearPlaceholder: string;
|
|
1056
|
+
quarterPlaceholder: string;
|
|
1051
1057
|
startDatePlaceholder: string;
|
|
1052
1058
|
endDatePlaceholder: string;
|
|
1053
1059
|
startDatetimePlaceholder: string;
|
|
@@ -1071,29 +1077,4 @@ declare function usePanelCommon(props: UsePanelCommonProps): {
|
|
|
1071
1077
|
getShortcutValue: (shortcut: Shortcuts[string]) => number | [number, number];
|
|
1072
1078
|
handleShortcutMouseleave: () => void;
|
|
1073
1079
|
};
|
|
1074
|
-
|
|
1075
|
-
var props: {
|
|
1076
|
-
readonly active: BooleanConstructor;
|
|
1077
|
-
readonly dateFormat: {
|
|
1078
|
-
readonly type: StringConstructor;
|
|
1079
|
-
readonly default: "yyyy-MM-dd";
|
|
1080
|
-
};
|
|
1081
|
-
readonly timeFormat: {
|
|
1082
|
-
readonly type: StringConstructor;
|
|
1083
|
-
readonly default: "HH:mm:ss";
|
|
1084
|
-
};
|
|
1085
|
-
readonly value: {
|
|
1086
|
-
readonly type: PropType<Value | null>;
|
|
1087
|
-
readonly default: null;
|
|
1088
|
-
};
|
|
1089
|
-
readonly shortcuts: PropType<Shortcuts>;
|
|
1090
|
-
readonly onConfirm: FunctionConstructor;
|
|
1091
|
-
readonly onClose: PropType<OnClose>;
|
|
1092
|
-
readonly onTabOut: FunctionConstructor;
|
|
1093
|
-
readonly onUpdateValue: {
|
|
1094
|
-
readonly type: PropType<OnPanelUpdateValue>;
|
|
1095
|
-
readonly required: true;
|
|
1096
|
-
};
|
|
1097
|
-
};
|
|
1098
|
-
}
|
|
1099
|
-
export { usePanelCommon };
|
|
1080
|
+
export { usePanelCommon, usePanelCommonProps };
|
|
@@ -1,23 +1,20 @@
|
|
|
1
1
|
import { computed, inject, ref, nextTick } from 'vue';
|
|
2
2
|
import { useKeyboard } from 'vooks';
|
|
3
3
|
import { datePickerInjectionKey } from '../interface';
|
|
4
|
-
const DATE_FORMAT = 'yyyy-MM-dd';
|
|
5
4
|
const TIME_FORMAT = 'HH:mm:ss';
|
|
6
5
|
const usePanelCommonProps = {
|
|
7
6
|
active: Boolean,
|
|
8
|
-
dateFormat:
|
|
9
|
-
type: String,
|
|
10
|
-
default: DATE_FORMAT
|
|
11
|
-
},
|
|
7
|
+
dateFormat: String,
|
|
12
8
|
timeFormat: {
|
|
13
9
|
type: String,
|
|
14
|
-
|
|
10
|
+
value: TIME_FORMAT
|
|
15
11
|
},
|
|
16
12
|
value: {
|
|
17
13
|
type: [Array, Number],
|
|
18
14
|
default: null
|
|
19
15
|
},
|
|
20
16
|
shortcuts: Object,
|
|
17
|
+
defaultTime: [Number, String, Array],
|
|
21
18
|
onConfirm: Function,
|
|
22
19
|
onClose: Function,
|
|
23
20
|
onTabOut: Function,
|
|
@@ -139,5 +136,4 @@ function usePanelCommon(props) {
|
|
|
139
136
|
handleShortcutMouseleave: restorePendingValue
|
|
140
137
|
};
|
|
141
138
|
}
|
|
142
|
-
usePanelCommon
|
|
143
|
-
export { usePanelCommon };
|
|
139
|
+
export { usePanelCommon, usePanelCommonProps };
|
|
@@ -21,7 +21,7 @@ export interface MonthItem {
|
|
|
21
21
|
month: number;
|
|
22
22
|
year: number;
|
|
23
23
|
};
|
|
24
|
-
|
|
24
|
+
isCurrent: boolean;
|
|
25
25
|
selected: boolean;
|
|
26
26
|
ts: number;
|
|
27
27
|
}
|
|
@@ -30,7 +30,17 @@ export interface YearItem {
|
|
|
30
30
|
dateObject: {
|
|
31
31
|
year: number;
|
|
32
32
|
};
|
|
33
|
-
|
|
33
|
+
isCurrent: boolean;
|
|
34
|
+
selected: boolean;
|
|
35
|
+
ts: number;
|
|
36
|
+
}
|
|
37
|
+
export interface QuarterItem {
|
|
38
|
+
type: 'quarter';
|
|
39
|
+
dateObject: {
|
|
40
|
+
quarter: number;
|
|
41
|
+
year: number;
|
|
42
|
+
};
|
|
43
|
+
isCurrent: boolean;
|
|
34
44
|
selected: boolean;
|
|
35
45
|
ts: number;
|
|
36
46
|
}
|
|
@@ -40,8 +50,14 @@ export interface YearItem {
|
|
|
40
50
|
*/
|
|
41
51
|
declare function dateArray(monthTs: number, valueTs: number | [number, number] | null, currentTs: number, startDay: 0 | 1 | 2 | 3 | 4 | 5 | 6, strip?: boolean): DateItem[];
|
|
42
52
|
declare function monthArray(monthTs: number, valueTs: number | [number, number] | null, currentTs: number): MonthItem[];
|
|
53
|
+
declare function quarterArray(quarterTs: number, valueTs: number | [number, number] | null, currentTs: number): QuarterItem[];
|
|
43
54
|
declare function yearArray(yearTs: number, valueTs: number | [number, number] | null, currentTs: number): YearItem[];
|
|
44
55
|
declare function strictParse(string: string, pattern: string, backup: Date, option: {
|
|
45
56
|
locale: Locale;
|
|
46
57
|
}): Date;
|
|
47
|
-
|
|
58
|
+
declare function getDefaultTime(timeValue: string | undefined): {
|
|
59
|
+
hours: number;
|
|
60
|
+
minutes: number;
|
|
61
|
+
seconds: number;
|
|
62
|
+
} | undefined;
|
|
63
|
+
export { dateArray, monthArray, yearArray, quarterArray, strictParse, getDerivedTimeFromKeyboardEvent, getDefaultTime };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isValid, isSameDay, getDate, getMonth, getYear, isSameMonth, isSameYear, getTime, startOfMonth, addDays, addMonths, addYears, getDay, parse, format, startOfYear } from 'date-fns';
|
|
1
|
+
import { isValid, isSameDay, getDate, getMonth, getYear, isSameMonth, isSameYear, getTime, startOfMonth, addDays, addMonths, addYears, addQuarters, getDay, parse, format, startOfYear, getQuarter, isSameQuarter } from 'date-fns';
|
|
2
2
|
import { START_YEAR } from './config';
|
|
3
3
|
function getDerivedTimeFromKeyboardEvent(prevValue, event) {
|
|
4
4
|
const now = getTime(Date.now());
|
|
@@ -19,7 +19,8 @@ function getDerivedTimeFromKeyboardEvent(prevValue, event) {
|
|
|
19
19
|
const matcherMap = {
|
|
20
20
|
date: isSameDay,
|
|
21
21
|
month: isSameMonth,
|
|
22
|
-
year: isSameYear
|
|
22
|
+
year: isSameYear,
|
|
23
|
+
quarter: isSameQuarter
|
|
23
24
|
};
|
|
24
25
|
function matchDate(sourceTime, patternTime, type = 'date') {
|
|
25
26
|
const matcher = matcherMap[type];
|
|
@@ -66,7 +67,7 @@ function monthItem(monthTs, valueTs, currentTs) {
|
|
|
66
67
|
month: getMonth(monthTs),
|
|
67
68
|
year: getYear(monthTs)
|
|
68
69
|
},
|
|
69
|
-
|
|
70
|
+
isCurrent: isSameMonth(currentTs, monthTs),
|
|
70
71
|
selected: valueTs !== null && matchDate(valueTs, monthTs, 'month'),
|
|
71
72
|
ts: getTime(monthTs)
|
|
72
73
|
};
|
|
@@ -77,11 +78,23 @@ function yearItem(yearTs, valueTs, currentTs) {
|
|
|
77
78
|
dateObject: {
|
|
78
79
|
year: getYear(yearTs)
|
|
79
80
|
},
|
|
80
|
-
|
|
81
|
+
isCurrent: isSameYear(currentTs, yearTs),
|
|
81
82
|
selected: valueTs !== null && matchDate(valueTs, yearTs, 'year'),
|
|
82
83
|
ts: getTime(yearTs)
|
|
83
84
|
};
|
|
84
85
|
}
|
|
86
|
+
function quarterItem(quarterTs, valueTs, currentTs) {
|
|
87
|
+
return {
|
|
88
|
+
type: 'quarter',
|
|
89
|
+
dateObject: {
|
|
90
|
+
quarter: getQuarter(quarterTs),
|
|
91
|
+
year: getYear(quarterTs)
|
|
92
|
+
},
|
|
93
|
+
isCurrent: isSameQuarter(currentTs, quarterTs),
|
|
94
|
+
selected: valueTs !== null && matchDate(valueTs, quarterTs, 'quarter'),
|
|
95
|
+
ts: getTime(quarterTs)
|
|
96
|
+
};
|
|
97
|
+
}
|
|
85
98
|
/**
|
|
86
99
|
* Given time to display calendar, given the selected time, given current time,
|
|
87
100
|
* return the date array of display time's month.
|
|
@@ -125,6 +138,14 @@ function monthArray(monthTs, valueTs, currentTs) {
|
|
|
125
138
|
}
|
|
126
139
|
return calendarMonths;
|
|
127
140
|
}
|
|
141
|
+
function quarterArray(quarterTs, valueTs, currentTs) {
|
|
142
|
+
const calendarQuarters = [];
|
|
143
|
+
const yearStart = startOfYear(quarterTs);
|
|
144
|
+
for (let i = 0; i < 4; i++) {
|
|
145
|
+
calendarQuarters.push(quarterItem(getTime(addQuarters(yearStart, i)), valueTs, currentTs));
|
|
146
|
+
}
|
|
147
|
+
return calendarQuarters;
|
|
148
|
+
}
|
|
128
149
|
function yearArray(yearTs, valueTs, currentTs) {
|
|
129
150
|
const calendarYears = [];
|
|
130
151
|
const time1900 = new Date(START_YEAR, 0, 1);
|
|
@@ -145,4 +166,18 @@ function strictParse(string, pattern, backup, option) {
|
|
|
145
166
|
else
|
|
146
167
|
return new Date(NaN);
|
|
147
168
|
}
|
|
148
|
-
|
|
169
|
+
function getDefaultTime(timeValue) {
|
|
170
|
+
if (timeValue === undefined) {
|
|
171
|
+
return undefined;
|
|
172
|
+
}
|
|
173
|
+
if (typeof timeValue === 'number') {
|
|
174
|
+
return timeValue;
|
|
175
|
+
}
|
|
176
|
+
const [hour, minute, second] = timeValue.split(':');
|
|
177
|
+
return {
|
|
178
|
+
hours: Number(hour),
|
|
179
|
+
minutes: Number(minute),
|
|
180
|
+
seconds: Number(second)
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
export { dateArray, monthArray, yearArray, quarterArray, strictParse, getDerivedTimeFromKeyboardEvent, getDefaultTime };
|
|
@@ -18,11 +18,13 @@ declare const _default: {
|
|
|
18
18
|
calendarLeftPaddingDatetimerange: string;
|
|
19
19
|
calendarLeftPaddingMonth: string;
|
|
20
20
|
calendarLeftPaddingYear: string;
|
|
21
|
+
calendarLeftPaddingQuarter: string;
|
|
21
22
|
calendarRightPaddingDate: string;
|
|
22
23
|
calendarRightPaddingDatetime: string;
|
|
23
24
|
calendarRightPaddingDaterange: string;
|
|
24
25
|
calendarRightPaddingDatetimerange: string;
|
|
25
26
|
calendarRightPaddingMonth: string;
|
|
26
27
|
calendarRightPaddingYear: string;
|
|
28
|
+
calendarRightPaddingQuarter: string;
|
|
27
29
|
};
|
|
28
30
|
export default _default;
|
|
@@ -19,10 +19,12 @@ export default {
|
|
|
19
19
|
calendarLeftPaddingDatetimerange: '4px 12px',
|
|
20
20
|
calendarLeftPaddingMonth: '0',
|
|
21
21
|
calendarLeftPaddingYear: '0',
|
|
22
|
+
calendarLeftPaddingQuarter: '0',
|
|
22
23
|
calendarRightPaddingDate: '6px 12px 4px 12px',
|
|
23
24
|
calendarRightPaddingDatetime: '4px 12px',
|
|
24
25
|
calendarRightPaddingDaterange: '6px 12px 4px 12px',
|
|
25
26
|
calendarRightPaddingDatetimerange: '4px 12px',
|
|
26
27
|
calendarRightPaddingMonth: '0',
|
|
27
|
-
calendarRightPaddingYear: '0'
|
|
28
|
+
calendarRightPaddingYear: '0',
|
|
29
|
+
calendarRightPaddingQuarter: '0'
|
|
28
30
|
};
|