@rc-component/picker 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +9 -0
- package/README.md +154 -0
- package/assets/index.css +407 -0
- package/assets/index.less +570 -0
- package/es/PickerInput/Popup/Footer.d.ts +19 -0
- package/es/PickerInput/Popup/Footer.js +78 -0
- package/es/PickerInput/Popup/PopupPanel.d.ts +10 -0
- package/es/PickerInput/Popup/PopupPanel.js +84 -0
- package/es/PickerInput/Popup/PresetPanel.d.ts +9 -0
- package/es/PickerInput/Popup/PresetPanel.js +31 -0
- package/es/PickerInput/Popup/index.d.ts +20 -0
- package/es/PickerInput/Popup/index.js +198 -0
- package/es/PickerInput/RangePicker.d.ts +54 -0
- package/es/PickerInput/RangePicker.js +641 -0
- package/es/PickerInput/Selector/Icon.d.ts +10 -0
- package/es/PickerInput/Selector/Icon.js +32 -0
- package/es/PickerInput/Selector/Input.d.ts +28 -0
- package/es/PickerInput/Selector/Input.js +377 -0
- package/es/PickerInput/Selector/MaskFormat.d.ts +22 -0
- package/es/PickerInput/Selector/MaskFormat.js +107 -0
- package/es/PickerInput/Selector/RangeSelector.d.ts +26 -0
- package/es/PickerInput/Selector/RangeSelector.js +218 -0
- package/es/PickerInput/Selector/SingleSelector/MultipleDates.d.ts +12 -0
- package/es/PickerInput/Selector/SingleSelector/MultipleDates.js +66 -0
- package/es/PickerInput/Selector/SingleSelector/index.d.ts +18 -0
- package/es/PickerInput/Selector/SingleSelector/index.js +187 -0
- package/es/PickerInput/Selector/hooks/useClearIcon.d.ts +8 -0
- package/es/PickerInput/Selector/hooks/useClearIcon.js +19 -0
- package/es/PickerInput/Selector/hooks/useInputProps.d.ts +16 -0
- package/es/PickerInput/Selector/hooks/useInputProps.js +178 -0
- package/es/PickerInput/Selector/hooks/useRootProps.d.ts +2 -0
- package/es/PickerInput/Selector/hooks/useRootProps.js +8 -0
- package/es/PickerInput/Selector/util.d.ts +1 -0
- package/es/PickerInput/Selector/util.js +12 -0
- package/es/PickerInput/SinglePicker.d.ts +51 -0
- package/es/PickerInput/SinglePicker.js +545 -0
- package/es/PickerInput/context.d.ts +13 -0
- package/es/PickerInput/context.js +3 -0
- package/es/PickerInput/hooks/useCellRender.d.ts +2 -0
- package/es/PickerInput/hooks/useCellRender.js +41 -0
- package/es/PickerInput/hooks/useDelayState.d.ts +5 -0
- package/es/PickerInput/hooks/useDelayState.js +48 -0
- package/es/PickerInput/hooks/useDisabledBoundary.d.ts +7 -0
- package/es/PickerInput/hooks/useDisabledBoundary.js +20 -0
- package/es/PickerInput/hooks/useFieldFormat.d.ts +2 -0
- package/es/PickerInput/hooks/useFieldFormat.js +18 -0
- package/es/PickerInput/hooks/useFieldsInvalidate.d.ts +5 -0
- package/es/PickerInput/hooks/useFieldsInvalidate.js +55 -0
- package/es/PickerInput/hooks/useFilledProps.d.ts +37 -0
- package/es/PickerInput/hooks/useFilledProps.js +155 -0
- package/es/PickerInput/hooks/useInputReadOnly.d.ts +2 -0
- package/es/PickerInput/hooks/useInputReadOnly.js +6 -0
- package/es/PickerInput/hooks/useInvalidate.d.ts +9 -0
- package/es/PickerInput/hooks/useInvalidate.js +61 -0
- package/es/PickerInput/hooks/useLockEffect.d.ts +5 -0
- package/es/PickerInput/hooks/useLockEffect.js +25 -0
- package/es/PickerInput/hooks/useOpen.d.ts +6 -0
- package/es/PickerInput/hooks/useOpen.js +33 -0
- package/es/PickerInput/hooks/usePickerRef.d.ts +7 -0
- package/es/PickerInput/hooks/usePickerRef.js +19 -0
- package/es/PickerInput/hooks/usePresets.d.ts +2 -0
- package/es/PickerInput/hooks/usePresets.js +28 -0
- package/es/PickerInput/hooks/useRangeActive.d.ts +19 -0
- package/es/PickerInput/hooks/useRangeActive.js +74 -0
- package/es/PickerInput/hooks/useRangeDisabledDate.d.ts +8 -0
- package/es/PickerInput/hooks/useRangeDisabledDate.js +53 -0
- package/es/PickerInput/hooks/useRangePickerValue.d.ts +5 -0
- package/es/PickerInput/hooks/useRangePickerValue.js +192 -0
- package/es/PickerInput/hooks/useRangeValue.d.ts +28 -0
- package/es/PickerInput/hooks/useRangeValue.js +297 -0
- package/es/PickerInput/hooks/useShowNow.d.ts +2 -0
- package/es/PickerInput/hooks/useShowNow.js +14 -0
- package/es/PickerPanel/DatePanel/index.d.ts +10 -0
- package/es/PickerPanel/DatePanel/index.js +190 -0
- package/es/PickerPanel/DateTimePanel/index.d.ts +3 -0
- package/es/PickerPanel/DateTimePanel/index.js +55 -0
- package/es/PickerPanel/DecadePanel/index.d.ts +3 -0
- package/es/PickerPanel/DecadePanel/index.js +113 -0
- package/es/PickerPanel/MonthPanel/index.d.ts +3 -0
- package/es/PickerPanel/MonthPanel/index.js +106 -0
- package/es/PickerPanel/PanelBody.d.ts +17 -0
- package/es/PickerPanel/PanelBody.js +153 -0
- package/es/PickerPanel/PanelHeader.d.ts +11 -0
- package/es/PickerPanel/PanelHeader.js +133 -0
- package/es/PickerPanel/QuarterPanel/index.d.ts +3 -0
- package/es/PickerPanel/QuarterPanel/index.js +92 -0
- package/es/PickerPanel/TimePanel/TimePanelBody/TimeColumn.d.ts +17 -0
- package/es/PickerPanel/TimePanel/TimePanelBody/TimeColumn.js +149 -0
- package/es/PickerPanel/TimePanel/TimePanelBody/index.d.ts +4 -0
- package/es/PickerPanel/TimePanel/TimePanelBody/index.js +283 -0
- package/es/PickerPanel/TimePanel/TimePanelBody/useScrollTo.d.ts +2 -0
- package/es/PickerPanel/TimePanel/TimePanelBody/useScrollTo.js +72 -0
- package/es/PickerPanel/TimePanel/TimePanelBody/util.d.ts +3 -0
- package/es/PickerPanel/TimePanel/TimePanelBody/util.js +43 -0
- package/es/PickerPanel/TimePanel/index.d.ts +4 -0
- package/es/PickerPanel/TimePanel/index.js +38 -0
- package/es/PickerPanel/WeekPanel/index.d.ts +3 -0
- package/es/PickerPanel/WeekPanel/index.js +55 -0
- package/es/PickerPanel/YearPanel/index.d.ts +3 -0
- package/es/PickerPanel/YearPanel/index.js +116 -0
- package/es/PickerPanel/context.d.ts +24 -0
- package/es/PickerPanel/context.js +67 -0
- package/es/PickerPanel/index.d.ts +60 -0
- package/es/PickerPanel/index.js +315 -0
- package/es/PickerTrigger/index.d.ts +19 -0
- package/es/PickerTrigger/index.js +86 -0
- package/es/PickerTrigger/util.d.ts +2 -0
- package/es/PickerTrigger/util.js +4 -0
- package/es/generate/dateFns.d.ts +3 -0
- package/es/generate/dateFns.js +163 -0
- package/es/generate/dayjs.d.ts +4 -0
- package/es/generate/dayjs.js +233 -0
- package/es/generate/index.d.ts +37 -0
- package/es/generate/index.js +1 -0
- package/es/generate/luxon.d.ts +4 -0
- package/es/generate/luxon.js +197 -0
- package/es/generate/moment.d.ts +4 -0
- package/es/generate/moment.js +152 -0
- package/es/hooks/useLocale.d.ts +6 -0
- package/es/hooks/useLocale.js +82 -0
- package/es/hooks/useSyncState.d.ts +6 -0
- package/es/hooks/useSyncState.js +27 -0
- package/es/hooks/useTimeConfig.d.ts +18 -0
- package/es/hooks/useTimeConfig.js +166 -0
- package/es/hooks/useTimeInfo.d.ts +12 -0
- package/es/hooks/useTimeInfo.js +164 -0
- package/es/hooks/useToggleDates.d.ts +8 -0
- package/es/hooks/useToggleDates.js +26 -0
- package/es/index.d.ts +35 -0
- package/es/index.js +34 -0
- package/es/interface.d.ts +365 -0
- package/es/interface.js +1 -0
- package/es/locale/am_ET.d.ts +3 -0
- package/es/locale/am_ET.js +31 -0
- package/es/locale/ar_EG.d.ts +3 -0
- package/es/locale/ar_EG.js +34 -0
- package/es/locale/az_AZ.d.ts +3 -0
- package/es/locale/az_AZ.js +35 -0
- package/es/locale/bg_BG.d.ts +3 -0
- package/es/locale/bg_BG.js +34 -0
- package/es/locale/bn_BD.d.ts +3 -0
- package/es/locale/bn_BD.js +35 -0
- package/es/locale/by_BY.d.ts +3 -0
- package/es/locale/by_BY.js +35 -0
- package/es/locale/ca_ES.d.ts +3 -0
- package/es/locale/ca_ES.js +34 -0
- package/es/locale/common.d.ts +2 -0
- package/es/locale/common.js +6 -0
- package/es/locale/cs_CZ.d.ts +3 -0
- package/es/locale/cs_CZ.js +34 -0
- package/es/locale/da_DK.d.ts +3 -0
- package/es/locale/da_DK.js +34 -0
- package/es/locale/de_DE.d.ts +3 -0
- package/es/locale/de_DE.js +34 -0
- package/es/locale/el_GR.d.ts +3 -0
- package/es/locale/el_GR.js +34 -0
- package/es/locale/en_GB.d.ts +3 -0
- package/es/locale/en_GB.js +34 -0
- package/es/locale/en_US.d.ts +3 -0
- package/es/locale/en_US.js +35 -0
- package/es/locale/es_ES.d.ts +3 -0
- package/es/locale/es_ES.js +34 -0
- package/es/locale/es_MX.d.ts +3 -0
- package/es/locale/es_MX.js +35 -0
- package/es/locale/et_EE.d.ts +3 -0
- package/es/locale/et_EE.js +34 -0
- package/es/locale/eu_ES.d.ts +3 -0
- package/es/locale/eu_ES.js +36 -0
- package/es/locale/fa_IR.d.ts +3 -0
- package/es/locale/fa_IR.js +34 -0
- package/es/locale/fi_FI.d.ts +3 -0
- package/es/locale/fi_FI.js +34 -0
- package/es/locale/fr_BE.d.ts +3 -0
- package/es/locale/fr_BE.js +34 -0
- package/es/locale/fr_CA.d.ts +3 -0
- package/es/locale/fr_CA.js +35 -0
- package/es/locale/fr_FR.d.ts +3 -0
- package/es/locale/fr_FR.js +35 -0
- package/es/locale/ga_IE.d.ts +3 -0
- package/es/locale/ga_IE.js +35 -0
- package/es/locale/gl_ES.d.ts +3 -0
- package/es/locale/gl_ES.js +34 -0
- package/es/locale/he_IL.d.ts +3 -0
- package/es/locale/he_IL.js +35 -0
- package/es/locale/hi_IN.d.ts +3 -0
- package/es/locale/hi_IN.js +35 -0
- package/es/locale/hr_HR.d.ts +3 -0
- package/es/locale/hr_HR.js +35 -0
- package/es/locale/hu_HU.d.ts +3 -0
- package/es/locale/hu_HU.js +58 -0
- package/es/locale/id_ID.d.ts +3 -0
- package/es/locale/id_ID.js +35 -0
- package/es/locale/is_IS.d.ts +3 -0
- package/es/locale/is_IS.js +34 -0
- package/es/locale/it_IT.d.ts +3 -0
- package/es/locale/it_IT.js +34 -0
- package/es/locale/ja_JP.d.ts +3 -0
- package/es/locale/ja_JP.js +37 -0
- package/es/locale/ka_GE.d.ts +3 -0
- package/es/locale/ka_GE.js +35 -0
- package/es/locale/kk_KZ.d.ts +3 -0
- package/es/locale/kk_KZ.js +34 -0
- package/es/locale/km_KH.d.ts +3 -0
- package/es/locale/km_KH.js +36 -0
- package/es/locale/kmr_IQ.d.ts +3 -0
- package/es/locale/kmr_IQ.js +34 -0
- package/es/locale/kn_IN.d.ts +3 -0
- package/es/locale/kn_IN.js +35 -0
- package/es/locale/ko_KR.d.ts +3 -0
- package/es/locale/ko_KR.js +36 -0
- package/es/locale/lt_LT.d.ts +3 -0
- package/es/locale/lt_LT.js +36 -0
- package/es/locale/lv_LV.d.ts +3 -0
- package/es/locale/lv_LV.js +34 -0
- package/es/locale/mk_MK.d.ts +3 -0
- package/es/locale/mk_MK.js +34 -0
- package/es/locale/ml_IN.d.ts +3 -0
- package/es/locale/ml_IN.js +35 -0
- package/es/locale/mn_MN.d.ts +3 -0
- package/es/locale/mn_MN.js +36 -0
- package/es/locale/ms_MY.d.ts +3 -0
- package/es/locale/ms_MY.js +36 -0
- package/es/locale/my_MM.d.ts +3 -0
- package/es/locale/my_MM.js +35 -0
- package/es/locale/nb_NO.d.ts +3 -0
- package/es/locale/nb_NO.js +36 -0
- package/es/locale/ne_NP.d.ts +3 -0
- package/es/locale/ne_NP.js +35 -0
- package/es/locale/nl_BE.d.ts +3 -0
- package/es/locale/nl_BE.js +34 -0
- package/es/locale/nl_NL.d.ts +3 -0
- package/es/locale/nl_NL.js +34 -0
- package/es/locale/pl_PL.d.ts +3 -0
- package/es/locale/pl_PL.js +34 -0
- package/es/locale/pt_BR.d.ts +3 -0
- package/es/locale/pt_BR.js +37 -0
- package/es/locale/pt_PT.d.ts +3 -0
- package/es/locale/pt_PT.js +36 -0
- package/es/locale/ro_RO.d.ts +3 -0
- package/es/locale/ro_RO.js +35 -0
- package/es/locale/ru_RU.d.ts +3 -0
- package/es/locale/ru_RU.js +34 -0
- package/es/locale/si_LK.d.ts +3 -0
- package/es/locale/si_LK.js +36 -0
- package/es/locale/sk_SK.d.ts +3 -0
- package/es/locale/sk_SK.js +34 -0
- package/es/locale/sl_SI.d.ts +3 -0
- package/es/locale/sl_SI.js +34 -0
- package/es/locale/sr_Cyrl_RS.d.ts +3 -0
- package/es/locale/sr_Cyrl_RS.js +34 -0
- package/es/locale/sr_RS.d.ts +3 -0
- package/es/locale/sr_RS.js +34 -0
- package/es/locale/sv_SE.d.ts +3 -0
- package/es/locale/sv_SE.js +34 -0
- package/es/locale/ta_IN.d.ts +3 -0
- package/es/locale/ta_IN.js +35 -0
- package/es/locale/th_TH.d.ts +3 -0
- package/es/locale/th_TH.js +34 -0
- package/es/locale/tk_TK.d.ts +3 -0
- package/es/locale/tk_TK.js +34 -0
- package/es/locale/tr_TR.d.ts +3 -0
- package/es/locale/tr_TR.js +36 -0
- package/es/locale/ug_CN.d.ts +3 -0
- package/es/locale/ug_CN.js +37 -0
- package/es/locale/uk_UA.d.ts +3 -0
- package/es/locale/uk_UA.js +34 -0
- package/es/locale/ur_PK.d.ts +3 -0
- package/es/locale/ur_PK.js +35 -0
- package/es/locale/uz_UZ.d.ts +3 -0
- package/es/locale/uz_UZ.js +35 -0
- package/es/locale/vi_VN.d.ts +3 -0
- package/es/locale/vi_VN.js +35 -0
- package/es/locale/zh_CN.d.ts +3 -0
- package/es/locale/zh_CN.js +36 -0
- package/es/locale/zh_TW.d.ts +3 -0
- package/es/locale/zh_TW.js +38 -0
- package/es/utils/dateUtil.d.ts +29 -0
- package/es/utils/dateUtil.js +140 -0
- package/es/utils/getClearIcon.d.ts +5 -0
- package/es/utils/getClearIcon.js +8 -0
- package/es/utils/miscUtil.d.ts +14 -0
- package/es/utils/miscUtil.js +70 -0
- package/es/utils/uiUtil.d.ts +1 -0
- package/es/utils/uiUtil.js +7 -0
- package/es/utils/warnUtil.d.ts +5 -0
- package/es/utils/warnUtil.js +10 -0
- package/lib/PickerInput/Popup/Footer.d.ts +19 -0
- package/lib/PickerInput/Popup/Footer.js +88 -0
- package/lib/PickerInput/Popup/PopupPanel.d.ts +10 -0
- package/lib/PickerInput/Popup/PopupPanel.js +93 -0
- package/lib/PickerInput/Popup/PresetPanel.d.ts +9 -0
- package/lib/PickerInput/Popup/PresetPanel.js +40 -0
- package/lib/PickerInput/Popup/index.d.ts +20 -0
- package/lib/PickerInput/Popup/index.js +207 -0
- package/lib/PickerInput/RangePicker.d.ts +54 -0
- package/lib/PickerInput/RangePicker.js +650 -0
- package/lib/PickerInput/Selector/Icon.d.ts +10 -0
- package/lib/PickerInput/Selector/Icon.js +43 -0
- package/lib/PickerInput/Selector/Input.d.ts +28 -0
- package/lib/PickerInput/Selector/Input.js +385 -0
- package/lib/PickerInput/Selector/MaskFormat.d.ts +22 -0
- package/lib/PickerInput/Selector/MaskFormat.js +112 -0
- package/lib/PickerInput/Selector/RangeSelector.d.ts +26 -0
- package/lib/PickerInput/Selector/RangeSelector.js +227 -0
- package/lib/PickerInput/Selector/SingleSelector/MultipleDates.d.ts +12 -0
- package/lib/PickerInput/Selector/SingleSelector/MultipleDates.js +76 -0
- package/lib/PickerInput/Selector/SingleSelector/index.d.ts +18 -0
- package/lib/PickerInput/Selector/SingleSelector/index.js +196 -0
- package/lib/PickerInput/Selector/hooks/useClearIcon.d.ts +8 -0
- package/lib/PickerInput/Selector/hooks/useClearIcon.js +27 -0
- package/lib/PickerInput/Selector/hooks/useInputProps.d.ts +16 -0
- package/lib/PickerInput/Selector/hooks/useInputProps.js +187 -0
- package/lib/PickerInput/Selector/hooks/useRootProps.d.ts +2 -0
- package/lib/PickerInput/Selector/hooks/useRootProps.js +17 -0
- package/lib/PickerInput/Selector/util.d.ts +1 -0
- package/lib/PickerInput/Selector/util.js +18 -0
- package/lib/PickerInput/SinglePicker.d.ts +51 -0
- package/lib/PickerInput/SinglePicker.js +553 -0
- package/lib/PickerInput/context.d.ts +13 -0
- package/lib/PickerInput/context.js +12 -0
- package/lib/PickerInput/hooks/useCellRender.d.ts +2 -0
- package/lib/PickerInput/hooks/useCellRender.js +49 -0
- package/lib/PickerInput/hooks/useDelayState.d.ts +5 -0
- package/lib/PickerInput/hooks/useDelayState.js +54 -0
- package/lib/PickerInput/hooks/useDisabledBoundary.d.ts +7 -0
- package/lib/PickerInput/hooks/useDisabledBoundary.js +26 -0
- package/lib/PickerInput/hooks/useFieldFormat.d.ts +2 -0
- package/lib/PickerInput/hooks/useFieldFormat.js +26 -0
- package/lib/PickerInput/hooks/useFieldsInvalidate.d.ts +5 -0
- package/lib/PickerInput/hooks/useFieldsInvalidate.js +64 -0
- package/lib/PickerInput/hooks/useFilledProps.d.ts +37 -0
- package/lib/PickerInput/hooks/useFilledProps.js +164 -0
- package/lib/PickerInput/hooks/useInputReadOnly.d.ts +2 -0
- package/lib/PickerInput/hooks/useInputReadOnly.js +12 -0
- package/lib/PickerInput/hooks/useInvalidate.d.ts +9 -0
- package/lib/PickerInput/hooks/useInvalidate.js +67 -0
- package/lib/PickerInput/hooks/useLockEffect.d.ts +5 -0
- package/lib/PickerInput/hooks/useLockEffect.js +34 -0
- package/lib/PickerInput/hooks/useOpen.d.ts +6 -0
- package/lib/PickerInput/hooks/useOpen.js +39 -0
- package/lib/PickerInput/hooks/usePickerRef.d.ts +7 -0
- package/lib/PickerInput/hooks/usePickerRef.js +28 -0
- package/lib/PickerInput/hooks/usePresets.d.ts +2 -0
- package/lib/PickerInput/hooks/usePresets.js +38 -0
- package/lib/PickerInput/hooks/useRangeActive.d.ts +19 -0
- package/lib/PickerInput/hooks/useRangeActive.js +84 -0
- package/lib/PickerInput/hooks/useRangeDisabledDate.d.ts +8 -0
- package/lib/PickerInput/hooks/useRangeDisabledDate.js +58 -0
- package/lib/PickerInput/hooks/useRangePickerValue.d.ts +5 -0
- package/lib/PickerInput/hooks/useRangePickerValue.js +203 -0
- package/lib/PickerInput/hooks/useRangeValue.d.ts +28 -0
- package/lib/PickerInput/hooks/useRangeValue.js +308 -0
- package/lib/PickerInput/hooks/useShowNow.d.ts +2 -0
- package/lib/PickerInput/hooks/useShowNow.js +20 -0
- package/lib/PickerPanel/DatePanel/index.d.ts +10 -0
- package/lib/PickerPanel/DatePanel/index.js +199 -0
- package/lib/PickerPanel/DateTimePanel/index.d.ts +3 -0
- package/lib/PickerPanel/DateTimePanel/index.js +65 -0
- package/lib/PickerPanel/DecadePanel/index.d.ts +3 -0
- package/lib/PickerPanel/DecadePanel/index.js +122 -0
- package/lib/PickerPanel/MonthPanel/index.d.ts +3 -0
- package/lib/PickerPanel/MonthPanel/index.js +115 -0
- package/lib/PickerPanel/PanelBody.d.ts +17 -0
- package/lib/PickerPanel/PanelBody.js +162 -0
- package/lib/PickerPanel/PanelHeader.d.ts +11 -0
- package/lib/PickerPanel/PanelHeader.js +143 -0
- package/lib/PickerPanel/QuarterPanel/index.d.ts +3 -0
- package/lib/PickerPanel/QuarterPanel/index.js +101 -0
- package/lib/PickerPanel/TimePanel/TimePanelBody/TimeColumn.d.ts +17 -0
- package/lib/PickerPanel/TimePanel/TimePanelBody/TimeColumn.js +158 -0
- package/lib/PickerPanel/TimePanel/TimePanelBody/index.d.ts +4 -0
- package/lib/PickerPanel/TimePanel/TimePanelBody/index.js +293 -0
- package/lib/PickerPanel/TimePanel/TimePanelBody/useScrollTo.d.ts +2 -0
- package/lib/PickerPanel/TimePanel/TimePanelBody/useScrollTo.js +82 -0
- package/lib/PickerPanel/TimePanel/TimePanelBody/util.d.ts +3 -0
- package/lib/PickerPanel/TimePanel/TimePanelBody/util.js +49 -0
- package/lib/PickerPanel/TimePanel/index.d.ts +4 -0
- package/lib/PickerPanel/TimePanel/index.js +48 -0
- package/lib/PickerPanel/WeekPanel/index.d.ts +3 -0
- package/lib/PickerPanel/WeekPanel/index.js +64 -0
- package/lib/PickerPanel/YearPanel/index.d.ts +3 -0
- package/lib/PickerPanel/YearPanel/index.js +125 -0
- package/lib/PickerPanel/context.d.ts +24 -0
- package/lib/PickerPanel/context.js +78 -0
- package/lib/PickerPanel/index.d.ts +60 -0
- package/lib/PickerPanel/index.js +324 -0
- package/lib/PickerTrigger/index.d.ts +19 -0
- package/lib/PickerTrigger/index.js +95 -0
- package/lib/PickerTrigger/util.d.ts +2 -0
- package/lib/PickerTrigger/util.js +10 -0
- package/lib/generate/dateFns.d.ts +3 -0
- package/lib/generate/dateFns.js +172 -0
- package/lib/generate/dayjs.d.ts +4 -0
- package/lib/generate/dayjs.js +240 -0
- package/lib/generate/index.d.ts +37 -0
- package/lib/generate/index.js +5 -0
- package/lib/generate/luxon.d.ts +4 -0
- package/lib/generate/luxon.js +203 -0
- package/lib/generate/moment.d.ts +4 -0
- package/lib/generate/moment.js +159 -0
- package/lib/hooks/useLocale.d.ts +6 -0
- package/lib/hooks/useLocale.js +90 -0
- package/lib/hooks/useSyncState.d.ts +6 -0
- package/lib/hooks/useSyncState.js +35 -0
- package/lib/hooks/useTimeConfig.d.ts +18 -0
- package/lib/hooks/useTimeConfig.js +173 -0
- package/lib/hooks/useTimeInfo.d.ts +12 -0
- package/lib/hooks/useTimeInfo.js +172 -0
- package/lib/hooks/useToggleDates.d.ts +8 -0
- package/lib/hooks/useToggleDates.js +32 -0
- package/lib/index.d.ts +35 -0
- package/lib/index.js +57 -0
- package/lib/interface.d.ts +365 -0
- package/lib/interface.js +5 -0
- package/lib/locale/am_ET.d.ts +3 -0
- package/lib/locale/am_ET.js +37 -0
- package/lib/locale/ar_EG.d.ts +3 -0
- package/lib/locale/ar_EG.js +40 -0
- package/lib/locale/az_AZ.d.ts +3 -0
- package/lib/locale/az_AZ.js +41 -0
- package/lib/locale/bg_BG.d.ts +3 -0
- package/lib/locale/bg_BG.js +40 -0
- package/lib/locale/bn_BD.d.ts +3 -0
- package/lib/locale/bn_BD.js +41 -0
- package/lib/locale/by_BY.d.ts +3 -0
- package/lib/locale/by_BY.js +41 -0
- package/lib/locale/ca_ES.d.ts +3 -0
- package/lib/locale/ca_ES.js +40 -0
- package/lib/locale/common.d.ts +2 -0
- package/lib/locale/common.js +12 -0
- package/lib/locale/cs_CZ.d.ts +3 -0
- package/lib/locale/cs_CZ.js +40 -0
- package/lib/locale/da_DK.d.ts +3 -0
- package/lib/locale/da_DK.js +40 -0
- package/lib/locale/de_DE.d.ts +3 -0
- package/lib/locale/de_DE.js +40 -0
- package/lib/locale/el_GR.d.ts +3 -0
- package/lib/locale/el_GR.js +40 -0
- package/lib/locale/en_GB.d.ts +3 -0
- package/lib/locale/en_GB.js +40 -0
- package/lib/locale/en_US.d.ts +3 -0
- package/lib/locale/en_US.js +41 -0
- package/lib/locale/es_ES.d.ts +3 -0
- package/lib/locale/es_ES.js +40 -0
- package/lib/locale/es_MX.d.ts +3 -0
- package/lib/locale/es_MX.js +41 -0
- package/lib/locale/et_EE.d.ts +3 -0
- package/lib/locale/et_EE.js +40 -0
- package/lib/locale/eu_ES.d.ts +3 -0
- package/lib/locale/eu_ES.js +42 -0
- package/lib/locale/fa_IR.d.ts +3 -0
- package/lib/locale/fa_IR.js +40 -0
- package/lib/locale/fi_FI.d.ts +3 -0
- package/lib/locale/fi_FI.js +40 -0
- package/lib/locale/fr_BE.d.ts +3 -0
- package/lib/locale/fr_BE.js +40 -0
- package/lib/locale/fr_CA.d.ts +3 -0
- package/lib/locale/fr_CA.js +41 -0
- package/lib/locale/fr_FR.d.ts +3 -0
- package/lib/locale/fr_FR.js +41 -0
- package/lib/locale/ga_IE.d.ts +3 -0
- package/lib/locale/ga_IE.js +41 -0
- package/lib/locale/gl_ES.d.ts +3 -0
- package/lib/locale/gl_ES.js +40 -0
- package/lib/locale/he_IL.d.ts +3 -0
- package/lib/locale/he_IL.js +41 -0
- package/lib/locale/hi_IN.d.ts +3 -0
- package/lib/locale/hi_IN.js +41 -0
- package/lib/locale/hr_HR.d.ts +3 -0
- package/lib/locale/hr_HR.js +41 -0
- package/lib/locale/hu_HU.d.ts +3 -0
- package/lib/locale/hu_HU.js +64 -0
- package/lib/locale/id_ID.d.ts +3 -0
- package/lib/locale/id_ID.js +41 -0
- package/lib/locale/is_IS.d.ts +3 -0
- package/lib/locale/is_IS.js +40 -0
- package/lib/locale/it_IT.d.ts +3 -0
- package/lib/locale/it_IT.js +40 -0
- package/lib/locale/ja_JP.d.ts +3 -0
- package/lib/locale/ja_JP.js +43 -0
- package/lib/locale/ka_GE.d.ts +3 -0
- package/lib/locale/ka_GE.js +41 -0
- package/lib/locale/kk_KZ.d.ts +3 -0
- package/lib/locale/kk_KZ.js +40 -0
- package/lib/locale/km_KH.d.ts +3 -0
- package/lib/locale/km_KH.js +42 -0
- package/lib/locale/kmr_IQ.d.ts +3 -0
- package/lib/locale/kmr_IQ.js +40 -0
- package/lib/locale/kn_IN.d.ts +3 -0
- package/lib/locale/kn_IN.js +41 -0
- package/lib/locale/ko_KR.d.ts +3 -0
- package/lib/locale/ko_KR.js +42 -0
- package/lib/locale/lt_LT.d.ts +3 -0
- package/lib/locale/lt_LT.js +42 -0
- package/lib/locale/lv_LV.d.ts +3 -0
- package/lib/locale/lv_LV.js +40 -0
- package/lib/locale/mk_MK.d.ts +3 -0
- package/lib/locale/mk_MK.js +40 -0
- package/lib/locale/ml_IN.d.ts +3 -0
- package/lib/locale/ml_IN.js +41 -0
- package/lib/locale/mn_MN.d.ts +3 -0
- package/lib/locale/mn_MN.js +42 -0
- package/lib/locale/ms_MY.d.ts +3 -0
- package/lib/locale/ms_MY.js +42 -0
- package/lib/locale/my_MM.d.ts +3 -0
- package/lib/locale/my_MM.js +41 -0
- package/lib/locale/nb_NO.d.ts +3 -0
- package/lib/locale/nb_NO.js +42 -0
- package/lib/locale/ne_NP.d.ts +3 -0
- package/lib/locale/ne_NP.js +41 -0
- package/lib/locale/nl_BE.d.ts +3 -0
- package/lib/locale/nl_BE.js +40 -0
- package/lib/locale/nl_NL.d.ts +3 -0
- package/lib/locale/nl_NL.js +40 -0
- package/lib/locale/pl_PL.d.ts +3 -0
- package/lib/locale/pl_PL.js +40 -0
- package/lib/locale/pt_BR.d.ts +3 -0
- package/lib/locale/pt_BR.js +43 -0
- package/lib/locale/pt_PT.d.ts +3 -0
- package/lib/locale/pt_PT.js +42 -0
- package/lib/locale/ro_RO.d.ts +3 -0
- package/lib/locale/ro_RO.js +41 -0
- package/lib/locale/ru_RU.d.ts +3 -0
- package/lib/locale/ru_RU.js +40 -0
- package/lib/locale/si_LK.d.ts +3 -0
- package/lib/locale/si_LK.js +42 -0
- package/lib/locale/sk_SK.d.ts +3 -0
- package/lib/locale/sk_SK.js +40 -0
- package/lib/locale/sl_SI.d.ts +3 -0
- package/lib/locale/sl_SI.js +40 -0
- package/lib/locale/sr_Cyrl_RS.d.ts +3 -0
- package/lib/locale/sr_Cyrl_RS.js +40 -0
- package/lib/locale/sr_RS.d.ts +3 -0
- package/lib/locale/sr_RS.js +40 -0
- package/lib/locale/sv_SE.d.ts +3 -0
- package/lib/locale/sv_SE.js +40 -0
- package/lib/locale/ta_IN.d.ts +3 -0
- package/lib/locale/ta_IN.js +41 -0
- package/lib/locale/th_TH.d.ts +3 -0
- package/lib/locale/th_TH.js +40 -0
- package/lib/locale/tk_TK.d.ts +3 -0
- package/lib/locale/tk_TK.js +40 -0
- package/lib/locale/tr_TR.d.ts +3 -0
- package/lib/locale/tr_TR.js +42 -0
- package/lib/locale/ug_CN.d.ts +3 -0
- package/lib/locale/ug_CN.js +43 -0
- package/lib/locale/uk_UA.d.ts +3 -0
- package/lib/locale/uk_UA.js +40 -0
- package/lib/locale/ur_PK.d.ts +3 -0
- package/lib/locale/ur_PK.js +41 -0
- package/lib/locale/uz_UZ.d.ts +3 -0
- package/lib/locale/uz_UZ.js +41 -0
- package/lib/locale/vi_VN.d.ts +3 -0
- package/lib/locale/vi_VN.js +41 -0
- package/lib/locale/zh_CN.d.ts +3 -0
- package/lib/locale/zh_CN.js +42 -0
- package/lib/locale/zh_TW.d.ts +3 -0
- package/lib/locale/zh_TW.js +44 -0
- package/lib/utils/dateUtil.d.ts +29 -0
- package/lib/utils/dateUtil.js +161 -0
- package/lib/utils/getClearIcon.d.ts +5 -0
- package/lib/utils/getClearIcon.js +15 -0
- package/lib/utils/miscUtil.d.ts +14 -0
- package/lib/utils/miscUtil.js +81 -0
- package/lib/utils/uiUtil.d.ts +1 -0
- package/lib/utils/uiUtil.js +13 -0
- package/lib/utils/warnUtil.d.ts +5 -0
- package/lib/utils/warnUtil.js +17 -0
- package/package.json +107 -0
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = useRangeValue;
|
|
8
|
+
exports.useInnerValue = useInnerValue;
|
|
9
|
+
var _util = require("@rc-component/util");
|
|
10
|
+
var React = _interopRequireWildcard(require("react"));
|
|
11
|
+
var _useSyncState5 = _interopRequireDefault(require("../../hooks/useSyncState"));
|
|
12
|
+
var _dateUtil = require("../../utils/dateUtil");
|
|
13
|
+
var _miscUtil = require("../../utils/miscUtil");
|
|
14
|
+
var _useLockEffect = _interopRequireDefault(require("./useLockEffect"));
|
|
15
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
17
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
18
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
19
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
20
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
21
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
22
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
23
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
24
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
25
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
26
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
27
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
28
|
+
var EMPTY_VALUE = [];
|
|
29
|
+
|
|
30
|
+
// Submit Logic:
|
|
31
|
+
// * ✅ Value:
|
|
32
|
+
// * merged value using controlled value, if not, use stateValue
|
|
33
|
+
// * When merged value change, [1] resync calendar value and submit value
|
|
34
|
+
// * ✅ Calender Value:
|
|
35
|
+
// * 💻 When user typing is validate, change the calendar value
|
|
36
|
+
// * 🌅 When user click on the panel, change the calendar value
|
|
37
|
+
// * Submit Value:
|
|
38
|
+
// * 💻 When user blur the input, flush calendar value to submit value
|
|
39
|
+
// * 🌅 When user click on the panel is no needConfirm, flush calendar value to submit value
|
|
40
|
+
// * 🌅 When user click on the panel is needConfirm and click OK, flush calendar value to submit value
|
|
41
|
+
// * Blur logic & close logic:
|
|
42
|
+
// * ✅ For value, always try flush submit
|
|
43
|
+
// * ✅ If `needConfirm`, reset as [1]
|
|
44
|
+
// * Else (`!needConfirm`)
|
|
45
|
+
// * If has another index field, active another index
|
|
46
|
+
// * ✅ Flush submit:
|
|
47
|
+
// * If all the start & end field is confirmed or all blur or panel closed
|
|
48
|
+
// * Update `needSubmit` mark to true
|
|
49
|
+
// * trigger onChange by `needSubmit` and update stateValue
|
|
50
|
+
|
|
51
|
+
function useUtil(generateConfig, locale, formatList) {
|
|
52
|
+
var getDateTexts = function getDateTexts(dates) {
|
|
53
|
+
return dates.map(function (date) {
|
|
54
|
+
return (0, _dateUtil.formatValue)(date, {
|
|
55
|
+
generateConfig: generateConfig,
|
|
56
|
+
locale: locale,
|
|
57
|
+
format: formatList[0]
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
var isSameDates = function isSameDates(source, target) {
|
|
62
|
+
var maxLen = Math.max(source.length, target.length);
|
|
63
|
+
var diffIndex = -1;
|
|
64
|
+
for (var i = 0; i < maxLen; i += 1) {
|
|
65
|
+
var prev = source[i] || null;
|
|
66
|
+
var next = target[i] || null;
|
|
67
|
+
if (prev !== next && !(0, _dateUtil.isSameTimestamp)(generateConfig, prev, next)) {
|
|
68
|
+
diffIndex = i;
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return [diffIndex < 0, diffIndex !== 0];
|
|
73
|
+
};
|
|
74
|
+
return [getDateTexts, isSameDates];
|
|
75
|
+
}
|
|
76
|
+
function orderDates(dates, generateConfig) {
|
|
77
|
+
return _toConsumableArray(dates).sort(function (a, b) {
|
|
78
|
+
return generateConfig.isAfter(a, b) ? 1 : -1;
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Used for internal value management.
|
|
84
|
+
* It should always use `mergedValue` in render logic
|
|
85
|
+
*/
|
|
86
|
+
function useCalendarValue(mergedValue) {
|
|
87
|
+
var _useSyncState = (0, _useSyncState5.default)(mergedValue),
|
|
88
|
+
_useSyncState2 = _slicedToArray(_useSyncState, 2),
|
|
89
|
+
calendarValue = _useSyncState2[0],
|
|
90
|
+
setCalendarValue = _useSyncState2[1];
|
|
91
|
+
|
|
92
|
+
/** Sync calendarValue & submitValue back with value */
|
|
93
|
+
var syncWithValue = (0, _util.useEvent)(function () {
|
|
94
|
+
setCalendarValue(mergedValue);
|
|
95
|
+
});
|
|
96
|
+
React.useEffect(function () {
|
|
97
|
+
syncWithValue();
|
|
98
|
+
}, [mergedValue]);
|
|
99
|
+
return [calendarValue, setCalendarValue];
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Control the internal `value` align with prop `value` and provide a temp `calendarValue` for ui.
|
|
104
|
+
* `calendarValue` will be reset when blur & focus & open.
|
|
105
|
+
*/
|
|
106
|
+
function useInnerValue(generateConfig, locale, formatList, /** Used for RangePicker. `true` means [DateType, DateType] or will be DateType[] */
|
|
107
|
+
rangeValue,
|
|
108
|
+
/**
|
|
109
|
+
* Trigger order when trigger calendar value change.
|
|
110
|
+
* This should only used in SinglePicker with `multiple` mode.
|
|
111
|
+
* So when `rangeValue` is `true`, order will be ignored.
|
|
112
|
+
*/
|
|
113
|
+
order, defaultValue, value, onCalendarChange, onOk) {
|
|
114
|
+
// This is the root value which will sync with controlled or uncontrolled value
|
|
115
|
+
var _useMergedState = (0, _util.useMergedState)(defaultValue, {
|
|
116
|
+
value: value
|
|
117
|
+
}),
|
|
118
|
+
_useMergedState2 = _slicedToArray(_useMergedState, 2),
|
|
119
|
+
innerValue = _useMergedState2[0],
|
|
120
|
+
setInnerValue = _useMergedState2[1];
|
|
121
|
+
var mergedValue = innerValue || EMPTY_VALUE;
|
|
122
|
+
|
|
123
|
+
// ========================= Inner Values =========================
|
|
124
|
+
var _useCalendarValue = useCalendarValue(mergedValue),
|
|
125
|
+
_useCalendarValue2 = _slicedToArray(_useCalendarValue, 2),
|
|
126
|
+
calendarValue = _useCalendarValue2[0],
|
|
127
|
+
setCalendarValue = _useCalendarValue2[1];
|
|
128
|
+
|
|
129
|
+
// ============================ Change ============================
|
|
130
|
+
var _useUtil = useUtil(generateConfig, locale, formatList),
|
|
131
|
+
_useUtil2 = _slicedToArray(_useUtil, 2),
|
|
132
|
+
getDateTexts = _useUtil2[0],
|
|
133
|
+
isSameDates = _useUtil2[1];
|
|
134
|
+
var triggerCalendarChange = (0, _util.useEvent)(function (nextCalendarValues) {
|
|
135
|
+
var clone = _toConsumableArray(nextCalendarValues);
|
|
136
|
+
if (rangeValue) {
|
|
137
|
+
for (var i = 0; i < 2; i += 1) {
|
|
138
|
+
clone[i] = clone[i] || null;
|
|
139
|
+
}
|
|
140
|
+
} else if (order) {
|
|
141
|
+
clone = orderDates(clone.filter(function (date) {
|
|
142
|
+
return date;
|
|
143
|
+
}), generateConfig);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// Update merged value
|
|
147
|
+
var _isSameDates = isSameDates(calendarValue(), clone),
|
|
148
|
+
_isSameDates2 = _slicedToArray(_isSameDates, 2),
|
|
149
|
+
isSameMergedDates = _isSameDates2[0],
|
|
150
|
+
isSameStart = _isSameDates2[1];
|
|
151
|
+
if (!isSameMergedDates) {
|
|
152
|
+
setCalendarValue(clone);
|
|
153
|
+
|
|
154
|
+
// Trigger calendar change event
|
|
155
|
+
if (onCalendarChange) {
|
|
156
|
+
var cellTexts = getDateTexts(clone);
|
|
157
|
+
onCalendarChange(clone, cellTexts, {
|
|
158
|
+
range: isSameStart ? 'end' : 'start'
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
var triggerOk = function triggerOk() {
|
|
164
|
+
if (onOk) {
|
|
165
|
+
onOk(calendarValue());
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
return [mergedValue, setInnerValue, calendarValue, triggerCalendarChange, triggerOk];
|
|
169
|
+
}
|
|
170
|
+
function useRangeValue(info, mergedValue, setInnerValue, getCalendarValue, triggerCalendarChange, disabled, formatList, focused, open, isInvalidateDate) {
|
|
171
|
+
var generateConfig = info.generateConfig,
|
|
172
|
+
locale = info.locale,
|
|
173
|
+
picker = info.picker,
|
|
174
|
+
onChange = info.onChange,
|
|
175
|
+
allowEmpty = info.allowEmpty,
|
|
176
|
+
order = info.order;
|
|
177
|
+
var orderOnChange = disabled.some(function (d) {
|
|
178
|
+
return d;
|
|
179
|
+
}) ? false : order;
|
|
180
|
+
|
|
181
|
+
// ============================= Util =============================
|
|
182
|
+
var _useUtil3 = useUtil(generateConfig, locale, formatList),
|
|
183
|
+
_useUtil4 = _slicedToArray(_useUtil3, 2),
|
|
184
|
+
getDateTexts = _useUtil4[0],
|
|
185
|
+
isSameDates = _useUtil4[1];
|
|
186
|
+
|
|
187
|
+
// ============================ Values ============================
|
|
188
|
+
// Used for trigger `onChange` event.
|
|
189
|
+
// Record current value which is wait for submit.
|
|
190
|
+
var _useSyncState3 = (0, _useSyncState5.default)(mergedValue),
|
|
191
|
+
_useSyncState4 = _slicedToArray(_useSyncState3, 2),
|
|
192
|
+
submitValue = _useSyncState4[0],
|
|
193
|
+
setSubmitValue = _useSyncState4[1];
|
|
194
|
+
|
|
195
|
+
/** Sync calendarValue & submitValue back with value */
|
|
196
|
+
var syncWithValue = (0, _util.useEvent)(function () {
|
|
197
|
+
setSubmitValue(mergedValue);
|
|
198
|
+
});
|
|
199
|
+
React.useEffect(function () {
|
|
200
|
+
syncWithValue();
|
|
201
|
+
}, [mergedValue]);
|
|
202
|
+
|
|
203
|
+
// ============================ Submit ============================
|
|
204
|
+
var triggerSubmit = (0, _util.useEvent)(function (nextValue) {
|
|
205
|
+
var isNullValue = nextValue === null;
|
|
206
|
+
var clone = _toConsumableArray(nextValue || submitValue());
|
|
207
|
+
|
|
208
|
+
// Fill null value
|
|
209
|
+
if (isNullValue) {
|
|
210
|
+
var maxLen = Math.max(disabled.length, clone.length);
|
|
211
|
+
for (var i = 0; i < maxLen; i += 1) {
|
|
212
|
+
if (!disabled[i]) {
|
|
213
|
+
clone[i] = null;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
// Only when exist value to sort
|
|
219
|
+
if (orderOnChange && clone[0] && clone[1]) {
|
|
220
|
+
clone = orderDates(clone, generateConfig);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// Sync `calendarValue`
|
|
224
|
+
triggerCalendarChange(clone);
|
|
225
|
+
|
|
226
|
+
// ========= Validate check =========
|
|
227
|
+
var _clone = clone,
|
|
228
|
+
_clone2 = _slicedToArray(_clone, 2),
|
|
229
|
+
start = _clone2[0],
|
|
230
|
+
end = _clone2[1];
|
|
231
|
+
|
|
232
|
+
// >>> Empty
|
|
233
|
+
var startEmpty = !start;
|
|
234
|
+
var endEmpty = !end;
|
|
235
|
+
var validateEmptyDateRange = allowEmpty ?
|
|
236
|
+
// Validate empty start
|
|
237
|
+
(!startEmpty || allowEmpty[0]) && (
|
|
238
|
+
// Validate empty end
|
|
239
|
+
!endEmpty || allowEmpty[1]) : true;
|
|
240
|
+
|
|
241
|
+
// >>> Order
|
|
242
|
+
var validateOrder = !order || startEmpty || endEmpty || (0, _dateUtil.isSame)(generateConfig, locale, start, end, picker) || generateConfig.isAfter(end, start);
|
|
243
|
+
|
|
244
|
+
// >>> Invalid
|
|
245
|
+
var validateDates =
|
|
246
|
+
// Validate start
|
|
247
|
+
(disabled[0] || !start || !isInvalidateDate(start, {
|
|
248
|
+
activeIndex: 0
|
|
249
|
+
})) && (
|
|
250
|
+
// Validate end
|
|
251
|
+
disabled[1] || !end || !isInvalidateDate(end, {
|
|
252
|
+
from: start,
|
|
253
|
+
activeIndex: 1
|
|
254
|
+
}));
|
|
255
|
+
// >>> Result
|
|
256
|
+
var allPassed =
|
|
257
|
+
// Null value is from clear button
|
|
258
|
+
isNullValue ||
|
|
259
|
+
// Normal check
|
|
260
|
+
validateEmptyDateRange && validateOrder && validateDates;
|
|
261
|
+
if (allPassed) {
|
|
262
|
+
// Sync value with submit value
|
|
263
|
+
setInnerValue(clone);
|
|
264
|
+
var _isSameDates3 = isSameDates(clone, mergedValue),
|
|
265
|
+
_isSameDates4 = _slicedToArray(_isSameDates3, 1),
|
|
266
|
+
isSameMergedDates = _isSameDates4[0];
|
|
267
|
+
|
|
268
|
+
// Trigger `onChange` if needed
|
|
269
|
+
if (onChange && !isSameMergedDates) {
|
|
270
|
+
onChange(
|
|
271
|
+
// Return null directly if all date are empty
|
|
272
|
+
isNullValue && clone.every(function (val) {
|
|
273
|
+
return !val;
|
|
274
|
+
}) ? null : clone, getDateTexts(clone));
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
return allPassed;
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
// ========================= Flush Submit =========================
|
|
281
|
+
var flushSubmit = (0, _util.useEvent)(function (index, needTriggerChange) {
|
|
282
|
+
var nextSubmitValue = (0, _miscUtil.fillIndex)(submitValue(), index, getCalendarValue()[index]);
|
|
283
|
+
setSubmitValue(nextSubmitValue);
|
|
284
|
+
if (needTriggerChange) {
|
|
285
|
+
triggerSubmit();
|
|
286
|
+
}
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
// ============================ Effect ============================
|
|
290
|
+
// All finished action trigger after 2 frames
|
|
291
|
+
var interactiveFinished = !focused && !open;
|
|
292
|
+
(0, _useLockEffect.default)(!interactiveFinished, function () {
|
|
293
|
+
if (interactiveFinished) {
|
|
294
|
+
// Always try to trigger submit first
|
|
295
|
+
triggerSubmit();
|
|
296
|
+
|
|
297
|
+
// Trigger calendar change since this is a effect reset
|
|
298
|
+
// https://github.com/ant-design/ant-design/issues/22351
|
|
299
|
+
triggerCalendarChange(mergedValue);
|
|
300
|
+
|
|
301
|
+
// Sync with value anyway
|
|
302
|
+
syncWithValue();
|
|
303
|
+
}
|
|
304
|
+
}, 2);
|
|
305
|
+
|
|
306
|
+
// ============================ Return ============================
|
|
307
|
+
return [flushSubmit, triggerSubmit];
|
|
308
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = useShowNow;
|
|
7
|
+
function useShowNow(picker, mode, showNow, showToday, rangePicker) {
|
|
8
|
+
if (mode !== 'date' && mode !== 'time') {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
if (showNow !== undefined) {
|
|
12
|
+
return showNow;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// Compatible with old version `showToday`
|
|
16
|
+
if (showToday !== undefined) {
|
|
17
|
+
return showToday;
|
|
18
|
+
}
|
|
19
|
+
return !rangePicker && (picker === 'date' || picker === 'time');
|
|
20
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { PanelMode, SharedPanelProps } from '../../interface';
|
|
3
|
+
export interface DatePanelProps<DateType extends object> extends SharedPanelProps<DateType> {
|
|
4
|
+
panelName?: PanelMode;
|
|
5
|
+
rowClassName?: (date: DateType) => string;
|
|
6
|
+
/** Used for `WeekPanel` */
|
|
7
|
+
mode?: PanelMode;
|
|
8
|
+
cellSelection?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export default function DatePanel<DateType extends object = any>(props: DatePanelProps<DateType>): React.JSX.Element;
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = DatePanel;
|
|
8
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
9
|
+
var React = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _dateUtil = require("../../utils/dateUtil");
|
|
11
|
+
var _context = require("../context");
|
|
12
|
+
var _PanelBody = _interopRequireDefault(require("../PanelBody"));
|
|
13
|
+
var _PanelHeader = _interopRequireDefault(require("../PanelHeader"));
|
|
14
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
15
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
16
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
18
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
19
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
20
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
21
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
22
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
23
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
24
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
25
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
26
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
27
|
+
function DatePanel(props) {
|
|
28
|
+
var prefixCls = props.prefixCls,
|
|
29
|
+
_props$panelName = props.panelName,
|
|
30
|
+
panelName = _props$panelName === void 0 ? 'date' : _props$panelName,
|
|
31
|
+
locale = props.locale,
|
|
32
|
+
generateConfig = props.generateConfig,
|
|
33
|
+
pickerValue = props.pickerValue,
|
|
34
|
+
onPickerValueChange = props.onPickerValueChange,
|
|
35
|
+
onModeChange = props.onModeChange,
|
|
36
|
+
_props$mode = props.mode,
|
|
37
|
+
mode = _props$mode === void 0 ? 'date' : _props$mode,
|
|
38
|
+
disabledDate = props.disabledDate,
|
|
39
|
+
onSelect = props.onSelect,
|
|
40
|
+
onHover = props.onHover,
|
|
41
|
+
showWeek = props.showWeek;
|
|
42
|
+
var panelPrefixCls = "".concat(prefixCls, "-").concat(panelName, "-panel");
|
|
43
|
+
var cellPrefixCls = "".concat(prefixCls, "-cell");
|
|
44
|
+
var isWeek = mode === 'week';
|
|
45
|
+
|
|
46
|
+
// ========================== Base ==========================
|
|
47
|
+
var _useInfo = (0, _context.useInfo)(props, mode),
|
|
48
|
+
_useInfo2 = _slicedToArray(_useInfo, 2),
|
|
49
|
+
info = _useInfo2[0],
|
|
50
|
+
now = _useInfo2[1];
|
|
51
|
+
var weekFirstDay = generateConfig.locale.getWeekFirstDay(locale.locale);
|
|
52
|
+
var monthStartDate = generateConfig.setDate(pickerValue, 1);
|
|
53
|
+
var baseDate = (0, _dateUtil.getWeekStartDate)(locale.locale, generateConfig, monthStartDate);
|
|
54
|
+
var month = generateConfig.getMonth(pickerValue);
|
|
55
|
+
|
|
56
|
+
// =========================== PrefixColumn ===========================
|
|
57
|
+
var showPrefixColumn = showWeek === undefined ? isWeek : showWeek;
|
|
58
|
+
var prefixColumn = showPrefixColumn ? function (date) {
|
|
59
|
+
// >>> Additional check for disabled
|
|
60
|
+
var disabled = disabledDate === null || disabledDate === void 0 ? void 0 : disabledDate(date, {
|
|
61
|
+
type: 'week'
|
|
62
|
+
});
|
|
63
|
+
return /*#__PURE__*/React.createElement("td", {
|
|
64
|
+
key: "week",
|
|
65
|
+
className: (0, _classnames.default)(cellPrefixCls, "".concat(cellPrefixCls, "-week"), _defineProperty({}, "".concat(cellPrefixCls, "-disabled"), disabled))
|
|
66
|
+
// Operation: Same as code in PanelBody
|
|
67
|
+
,
|
|
68
|
+
onClick: function onClick() {
|
|
69
|
+
if (!disabled) {
|
|
70
|
+
onSelect(date);
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
onMouseEnter: function onMouseEnter() {
|
|
74
|
+
if (!disabled) {
|
|
75
|
+
onHover === null || onHover === void 0 || onHover(date);
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
onMouseLeave: function onMouseLeave() {
|
|
79
|
+
if (!disabled) {
|
|
80
|
+
onHover === null || onHover === void 0 || onHover(null);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
84
|
+
className: "".concat(cellPrefixCls, "-inner")
|
|
85
|
+
}, generateConfig.locale.getWeek(locale.locale, date)));
|
|
86
|
+
} : null;
|
|
87
|
+
|
|
88
|
+
// ========================= Cells ==========================
|
|
89
|
+
// >>> Header Cells
|
|
90
|
+
var headerCells = [];
|
|
91
|
+
var weekDaysLocale = locale.shortWeekDays || (generateConfig.locale.getShortWeekDays ? generateConfig.locale.getShortWeekDays(locale.locale) : []);
|
|
92
|
+
if (prefixColumn) {
|
|
93
|
+
headerCells.push( /*#__PURE__*/React.createElement("th", {
|
|
94
|
+
key: "empty"
|
|
95
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
96
|
+
style: {
|
|
97
|
+
width: 0,
|
|
98
|
+
height: 0,
|
|
99
|
+
position: 'absolute',
|
|
100
|
+
overflow: 'hidden',
|
|
101
|
+
opacity: 0
|
|
102
|
+
}
|
|
103
|
+
}, locale.week)));
|
|
104
|
+
}
|
|
105
|
+
for (var i = 0; i < _dateUtil.WEEK_DAY_COUNT; i += 1) {
|
|
106
|
+
headerCells.push( /*#__PURE__*/React.createElement("th", {
|
|
107
|
+
key: i
|
|
108
|
+
}, weekDaysLocale[(i + weekFirstDay) % _dateUtil.WEEK_DAY_COUNT]));
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// >>> Body Cells
|
|
112
|
+
var getCellDate = function getCellDate(date, offset) {
|
|
113
|
+
return generateConfig.addDate(date, offset);
|
|
114
|
+
};
|
|
115
|
+
var getCellText = function getCellText(date) {
|
|
116
|
+
return (0, _dateUtil.formatValue)(date, {
|
|
117
|
+
locale: locale,
|
|
118
|
+
format: locale.cellDateFormat,
|
|
119
|
+
generateConfig: generateConfig
|
|
120
|
+
});
|
|
121
|
+
};
|
|
122
|
+
var getCellClassName = function getCellClassName(date) {
|
|
123
|
+
var classObj = _defineProperty(_defineProperty({}, "".concat(prefixCls, "-cell-in-view"), (0, _dateUtil.isSameMonth)(generateConfig, date, pickerValue)), "".concat(prefixCls, "-cell-today"), (0, _dateUtil.isSameDate)(generateConfig, date, now));
|
|
124
|
+
return classObj;
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
// ========================= Header =========================
|
|
128
|
+
var monthsLocale = locale.shortMonths || (generateConfig.locale.getShortMonths ? generateConfig.locale.getShortMonths(locale.locale) : []);
|
|
129
|
+
var yearNode = /*#__PURE__*/React.createElement("button", {
|
|
130
|
+
type: "button",
|
|
131
|
+
"aria-label": locale.yearSelect,
|
|
132
|
+
key: "year",
|
|
133
|
+
onClick: function onClick() {
|
|
134
|
+
onModeChange('year', pickerValue);
|
|
135
|
+
},
|
|
136
|
+
tabIndex: -1,
|
|
137
|
+
className: "".concat(prefixCls, "-year-btn")
|
|
138
|
+
}, (0, _dateUtil.formatValue)(pickerValue, {
|
|
139
|
+
locale: locale,
|
|
140
|
+
format: locale.yearFormat,
|
|
141
|
+
generateConfig: generateConfig
|
|
142
|
+
}));
|
|
143
|
+
var monthNode = /*#__PURE__*/React.createElement("button", {
|
|
144
|
+
type: "button",
|
|
145
|
+
"aria-label": locale.monthSelect,
|
|
146
|
+
key: "month",
|
|
147
|
+
onClick: function onClick() {
|
|
148
|
+
onModeChange('month', pickerValue);
|
|
149
|
+
},
|
|
150
|
+
tabIndex: -1,
|
|
151
|
+
className: "".concat(prefixCls, "-month-btn")
|
|
152
|
+
}, locale.monthFormat ? (0, _dateUtil.formatValue)(pickerValue, {
|
|
153
|
+
locale: locale,
|
|
154
|
+
format: locale.monthFormat,
|
|
155
|
+
generateConfig: generateConfig
|
|
156
|
+
}) : monthsLocale[month]);
|
|
157
|
+
var monthYearNodes = locale.monthBeforeYear ? [monthNode, yearNode] : [yearNode, monthNode];
|
|
158
|
+
|
|
159
|
+
// ========================= Render =========================
|
|
160
|
+
return /*#__PURE__*/React.createElement(_context.PanelContext.Provider, {
|
|
161
|
+
value: info
|
|
162
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
163
|
+
className: (0, _classnames.default)(panelPrefixCls, showWeek && "".concat(panelPrefixCls, "-show-week"))
|
|
164
|
+
}, /*#__PURE__*/React.createElement(_PanelHeader.default, {
|
|
165
|
+
offset: function offset(distance) {
|
|
166
|
+
return generateConfig.addMonth(pickerValue, distance);
|
|
167
|
+
},
|
|
168
|
+
superOffset: function superOffset(distance) {
|
|
169
|
+
return generateConfig.addYear(pickerValue, distance);
|
|
170
|
+
},
|
|
171
|
+
onChange: onPickerValueChange
|
|
172
|
+
// Limitation
|
|
173
|
+
,
|
|
174
|
+
getStart: function getStart(date) {
|
|
175
|
+
return generateConfig.setDate(date, 1);
|
|
176
|
+
},
|
|
177
|
+
getEnd: function getEnd(date) {
|
|
178
|
+
var clone = generateConfig.setDate(date, 1);
|
|
179
|
+
clone = generateConfig.addMonth(clone, 1);
|
|
180
|
+
return generateConfig.addDate(clone, -1);
|
|
181
|
+
}
|
|
182
|
+
}, monthYearNodes), /*#__PURE__*/React.createElement(_PanelBody.default, _extends({
|
|
183
|
+
titleFormat: locale.fieldDateFormat
|
|
184
|
+
}, props, {
|
|
185
|
+
colNum: _dateUtil.WEEK_DAY_COUNT,
|
|
186
|
+
rowNum: 6,
|
|
187
|
+
baseDate: baseDate
|
|
188
|
+
// Header
|
|
189
|
+
,
|
|
190
|
+
headerCells: headerCells
|
|
191
|
+
// Body
|
|
192
|
+
,
|
|
193
|
+
getCellDate: getCellDate,
|
|
194
|
+
getCellText: getCellText,
|
|
195
|
+
getCellClassName: getCellClassName,
|
|
196
|
+
prefixColumn: prefixColumn,
|
|
197
|
+
cellSelection: !isWeek
|
|
198
|
+
}))));
|
|
199
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = DateTimePanel;
|
|
8
|
+
var React = _interopRequireWildcard(require("react"));
|
|
9
|
+
var _useTimeInfo3 = _interopRequireDefault(require("../../hooks/useTimeInfo"));
|
|
10
|
+
var _dateUtil = require("../../utils/dateUtil");
|
|
11
|
+
var _DatePanel = _interopRequireDefault(require("../DatePanel"));
|
|
12
|
+
var _TimePanel = _interopRequireDefault(require("../TimePanel"));
|
|
13
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
15
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
16
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
17
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
18
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
19
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
20
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
21
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
22
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
23
|
+
function DateTimePanel(props) {
|
|
24
|
+
var prefixCls = props.prefixCls,
|
|
25
|
+
generateConfig = props.generateConfig,
|
|
26
|
+
showTime = props.showTime,
|
|
27
|
+
onSelect = props.onSelect,
|
|
28
|
+
value = props.value,
|
|
29
|
+
pickerValue = props.pickerValue,
|
|
30
|
+
onHover = props.onHover;
|
|
31
|
+
var panelPrefixCls = "".concat(prefixCls, "-datetime-panel");
|
|
32
|
+
|
|
33
|
+
// =============================== Time ===============================
|
|
34
|
+
var _useTimeInfo = (0, _useTimeInfo3.default)(generateConfig, showTime),
|
|
35
|
+
_useTimeInfo2 = _slicedToArray(_useTimeInfo, 1),
|
|
36
|
+
getValidTime = _useTimeInfo2[0];
|
|
37
|
+
|
|
38
|
+
// Merge the time info from `value` or `pickerValue`
|
|
39
|
+
var mergeTime = function mergeTime(date) {
|
|
40
|
+
if (value) {
|
|
41
|
+
return (0, _dateUtil.fillTime)(generateConfig, date, value);
|
|
42
|
+
}
|
|
43
|
+
return (0, _dateUtil.fillTime)(generateConfig, date, pickerValue);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
// ============================== Hover ===============================
|
|
47
|
+
var onDateHover = function onDateHover(date) {
|
|
48
|
+
onHover === null || onHover === void 0 || onHover(date ? mergeTime(date) : date);
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
// ============================== Select ==============================
|
|
52
|
+
var onDateSelect = function onDateSelect(date) {
|
|
53
|
+
// Merge with current time
|
|
54
|
+
var cloneDate = mergeTime(date);
|
|
55
|
+
onSelect(getValidTime(cloneDate, cloneDate));
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
// ============================== Render ==============================
|
|
59
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
60
|
+
className: panelPrefixCls
|
|
61
|
+
}, /*#__PURE__*/React.createElement(_DatePanel.default, _extends({}, props, {
|
|
62
|
+
onSelect: onDateSelect,
|
|
63
|
+
onHover: onDateHover
|
|
64
|
+
})), /*#__PURE__*/React.createElement(_TimePanel.default, props));
|
|
65
|
+
}
|