@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,283 @@
|
|
|
1
|
+
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); }
|
|
2
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
3
|
+
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."); }
|
|
4
|
+
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); }
|
|
5
|
+
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; }
|
|
6
|
+
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; } }
|
|
7
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
8
|
+
import * as React from 'react';
|
|
9
|
+
import useTimeInfo from "../../../hooks/useTimeInfo";
|
|
10
|
+
import { formatValue } from "../../../utils/dateUtil";
|
|
11
|
+
import { PickerHackContext, usePanelContext } from "../../context";
|
|
12
|
+
import TimeColumn from "./TimeColumn";
|
|
13
|
+
function isAM(hour) {
|
|
14
|
+
return hour < 12;
|
|
15
|
+
}
|
|
16
|
+
export default function TimePanelBody(props) {
|
|
17
|
+
var showHour = props.showHour,
|
|
18
|
+
showMinute = props.showMinute,
|
|
19
|
+
showSecond = props.showSecond,
|
|
20
|
+
showMillisecond = props.showMillisecond,
|
|
21
|
+
showMeridiem = props.use12Hours,
|
|
22
|
+
changeOnScroll = props.changeOnScroll;
|
|
23
|
+
var _usePanelContext = usePanelContext(),
|
|
24
|
+
prefixCls = _usePanelContext.prefixCls,
|
|
25
|
+
values = _usePanelContext.values,
|
|
26
|
+
generateConfig = _usePanelContext.generateConfig,
|
|
27
|
+
locale = _usePanelContext.locale,
|
|
28
|
+
onSelect = _usePanelContext.onSelect,
|
|
29
|
+
_usePanelContext$onHo = _usePanelContext.onHover,
|
|
30
|
+
onHover = _usePanelContext$onHo === void 0 ? function () {} : _usePanelContext$onHo,
|
|
31
|
+
pickerValue = _usePanelContext.pickerValue;
|
|
32
|
+
var value = (values === null || values === void 0 ? void 0 : values[0]) || null;
|
|
33
|
+
var _React$useContext = React.useContext(PickerHackContext),
|
|
34
|
+
onCellDblClick = _React$useContext.onCellDblClick;
|
|
35
|
+
|
|
36
|
+
// ========================== Info ==========================
|
|
37
|
+
var _useTimeInfo = useTimeInfo(generateConfig, props, value),
|
|
38
|
+
_useTimeInfo2 = _slicedToArray(_useTimeInfo, 5),
|
|
39
|
+
getValidTime = _useTimeInfo2[0],
|
|
40
|
+
rowHourUnits = _useTimeInfo2[1],
|
|
41
|
+
getMinuteUnits = _useTimeInfo2[2],
|
|
42
|
+
getSecondUnits = _useTimeInfo2[3],
|
|
43
|
+
getMillisecondUnits = _useTimeInfo2[4];
|
|
44
|
+
|
|
45
|
+
// ========================= Value ==========================
|
|
46
|
+
// PickerValue will tell which one to align on the top
|
|
47
|
+
var getUnitValue = function getUnitValue(func) {
|
|
48
|
+
var valueUnitVal = value && generateConfig[func](value);
|
|
49
|
+
var pickerUnitValue = pickerValue && generateConfig[func](pickerValue);
|
|
50
|
+
return [valueUnitVal, pickerUnitValue];
|
|
51
|
+
};
|
|
52
|
+
var _getUnitValue = getUnitValue('getHour'),
|
|
53
|
+
_getUnitValue2 = _slicedToArray(_getUnitValue, 2),
|
|
54
|
+
hour = _getUnitValue2[0],
|
|
55
|
+
pickerHour = _getUnitValue2[1];
|
|
56
|
+
var _getUnitValue3 = getUnitValue('getMinute'),
|
|
57
|
+
_getUnitValue4 = _slicedToArray(_getUnitValue3, 2),
|
|
58
|
+
minute = _getUnitValue4[0],
|
|
59
|
+
pickerMinute = _getUnitValue4[1];
|
|
60
|
+
var _getUnitValue5 = getUnitValue('getSecond'),
|
|
61
|
+
_getUnitValue6 = _slicedToArray(_getUnitValue5, 2),
|
|
62
|
+
second = _getUnitValue6[0],
|
|
63
|
+
pickerSecond = _getUnitValue6[1];
|
|
64
|
+
var _getUnitValue7 = getUnitValue('getMillisecond'),
|
|
65
|
+
_getUnitValue8 = _slicedToArray(_getUnitValue7, 2),
|
|
66
|
+
millisecond = _getUnitValue8[0],
|
|
67
|
+
pickerMillisecond = _getUnitValue8[1];
|
|
68
|
+
var meridiem = hour === null ? null : isAM(hour) ? 'am' : 'pm';
|
|
69
|
+
|
|
70
|
+
// ========================= Column =========================
|
|
71
|
+
// Hours
|
|
72
|
+
var hourUnits = React.useMemo(function () {
|
|
73
|
+
if (!showMeridiem) {
|
|
74
|
+
return rowHourUnits;
|
|
75
|
+
}
|
|
76
|
+
return isAM(hour) ? rowHourUnits.filter(function (h) {
|
|
77
|
+
return isAM(h.value);
|
|
78
|
+
}) : rowHourUnits.filter(function (h) {
|
|
79
|
+
return !isAM(h.value);
|
|
80
|
+
});
|
|
81
|
+
}, [hour, rowHourUnits, showMeridiem]);
|
|
82
|
+
|
|
83
|
+
// >>> Pick Fallback
|
|
84
|
+
var getEnabled = function getEnabled(units, val) {
|
|
85
|
+
var _enabledUnits$;
|
|
86
|
+
var enabledUnits = units.filter(function (unit) {
|
|
87
|
+
return !unit.disabled;
|
|
88
|
+
});
|
|
89
|
+
return val !== null && val !== void 0 ? val : // Fallback to enabled value
|
|
90
|
+
enabledUnits === null || enabledUnits === void 0 || (_enabledUnits$ = enabledUnits[0]) === null || _enabledUnits$ === void 0 ? void 0 : _enabledUnits$.value;
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
// >>> Minutes
|
|
94
|
+
var validHour = getEnabled(rowHourUnits, hour);
|
|
95
|
+
var minuteUnits = React.useMemo(function () {
|
|
96
|
+
return getMinuteUnits(validHour);
|
|
97
|
+
}, [getMinuteUnits, validHour]);
|
|
98
|
+
|
|
99
|
+
// >>> Seconds
|
|
100
|
+
var validMinute = getEnabled(minuteUnits, minute);
|
|
101
|
+
var secondUnits = React.useMemo(function () {
|
|
102
|
+
return getSecondUnits(validHour, validMinute);
|
|
103
|
+
}, [getSecondUnits, validHour, validMinute]);
|
|
104
|
+
|
|
105
|
+
// >>> Milliseconds
|
|
106
|
+
var validSecond = getEnabled(secondUnits, second);
|
|
107
|
+
var millisecondUnits = React.useMemo(function () {
|
|
108
|
+
return getMillisecondUnits(validHour, validMinute, validSecond);
|
|
109
|
+
}, [getMillisecondUnits, validHour, validMinute, validSecond]);
|
|
110
|
+
var validMillisecond = getEnabled(millisecondUnits, millisecond);
|
|
111
|
+
|
|
112
|
+
// Meridiem
|
|
113
|
+
var meridiemUnits = React.useMemo(function () {
|
|
114
|
+
if (!showMeridiem) {
|
|
115
|
+
return [];
|
|
116
|
+
}
|
|
117
|
+
var base = generateConfig.getNow();
|
|
118
|
+
var amDate = generateConfig.setHour(base, 6);
|
|
119
|
+
var pmDate = generateConfig.setHour(base, 18);
|
|
120
|
+
var formatMeridiem = function formatMeridiem(date, defaultLabel) {
|
|
121
|
+
var cellMeridiemFormat = locale.cellMeridiemFormat;
|
|
122
|
+
return cellMeridiemFormat ? formatValue(date, {
|
|
123
|
+
generateConfig: generateConfig,
|
|
124
|
+
locale: locale,
|
|
125
|
+
format: cellMeridiemFormat
|
|
126
|
+
}) : defaultLabel;
|
|
127
|
+
};
|
|
128
|
+
return [{
|
|
129
|
+
label: formatMeridiem(amDate, 'AM'),
|
|
130
|
+
value: 'am',
|
|
131
|
+
disabled: rowHourUnits.every(function (h) {
|
|
132
|
+
return h.disabled || !isAM(h.value);
|
|
133
|
+
})
|
|
134
|
+
}, {
|
|
135
|
+
label: formatMeridiem(pmDate, 'PM'),
|
|
136
|
+
value: 'pm',
|
|
137
|
+
disabled: rowHourUnits.every(function (h) {
|
|
138
|
+
return h.disabled || isAM(h.value);
|
|
139
|
+
})
|
|
140
|
+
}];
|
|
141
|
+
}, [rowHourUnits, showMeridiem, generateConfig, locale]);
|
|
142
|
+
|
|
143
|
+
// ========================= Change =========================
|
|
144
|
+
/**
|
|
145
|
+
* Check if time is validate or will match to validate one
|
|
146
|
+
*/
|
|
147
|
+
var triggerChange = function triggerChange(nextDate) {
|
|
148
|
+
var validateDate = getValidTime(nextDate);
|
|
149
|
+
onSelect(validateDate);
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
// ========================= Column =========================
|
|
153
|
+
// Create a template date for the trigger change event
|
|
154
|
+
var triggerDateTmpl = React.useMemo(function () {
|
|
155
|
+
var tmpl = value || pickerValue || generateConfig.getNow();
|
|
156
|
+
var isNotNull = function isNotNull(num) {
|
|
157
|
+
return num !== null && num !== undefined;
|
|
158
|
+
};
|
|
159
|
+
if (isNotNull(hour)) {
|
|
160
|
+
tmpl = generateConfig.setHour(tmpl, hour);
|
|
161
|
+
tmpl = generateConfig.setMinute(tmpl, minute);
|
|
162
|
+
tmpl = generateConfig.setSecond(tmpl, second);
|
|
163
|
+
tmpl = generateConfig.setMillisecond(tmpl, millisecond);
|
|
164
|
+
} else if (isNotNull(pickerHour)) {
|
|
165
|
+
tmpl = generateConfig.setHour(tmpl, pickerHour);
|
|
166
|
+
tmpl = generateConfig.setMinute(tmpl, pickerMinute);
|
|
167
|
+
tmpl = generateConfig.setSecond(tmpl, pickerSecond);
|
|
168
|
+
tmpl = generateConfig.setMillisecond(tmpl, pickerMillisecond);
|
|
169
|
+
} else if (isNotNull(validHour)) {
|
|
170
|
+
tmpl = generateConfig.setHour(tmpl, validHour);
|
|
171
|
+
tmpl = generateConfig.setMinute(tmpl, validMinute);
|
|
172
|
+
tmpl = generateConfig.setSecond(tmpl, validSecond);
|
|
173
|
+
tmpl = generateConfig.setMillisecond(tmpl, validMillisecond);
|
|
174
|
+
}
|
|
175
|
+
return tmpl;
|
|
176
|
+
}, [value, pickerValue, hour, minute, second, millisecond, validHour, validMinute, validSecond, validMillisecond, pickerHour, pickerMinute, pickerSecond, pickerMillisecond, generateConfig]);
|
|
177
|
+
|
|
178
|
+
// ===================== Columns Change =====================
|
|
179
|
+
var fillColumnValue = function fillColumnValue(val, func) {
|
|
180
|
+
if (val === null) {
|
|
181
|
+
return null;
|
|
182
|
+
}
|
|
183
|
+
return generateConfig[func](triggerDateTmpl, val);
|
|
184
|
+
};
|
|
185
|
+
var getNextHourTime = function getNextHourTime(val) {
|
|
186
|
+
return fillColumnValue(val, 'setHour');
|
|
187
|
+
};
|
|
188
|
+
var getNextMinuteTime = function getNextMinuteTime(val) {
|
|
189
|
+
return fillColumnValue(val, 'setMinute');
|
|
190
|
+
};
|
|
191
|
+
var getNextSecondTime = function getNextSecondTime(val) {
|
|
192
|
+
return fillColumnValue(val, 'setSecond');
|
|
193
|
+
};
|
|
194
|
+
var getNextMillisecondTime = function getNextMillisecondTime(val) {
|
|
195
|
+
return fillColumnValue(val, 'setMillisecond');
|
|
196
|
+
};
|
|
197
|
+
var getMeridiemTime = function getMeridiemTime(val) {
|
|
198
|
+
if (val === null) {
|
|
199
|
+
return null;
|
|
200
|
+
}
|
|
201
|
+
if (val === 'am' && !isAM(hour)) {
|
|
202
|
+
return generateConfig.setHour(triggerDateTmpl, hour - 12);
|
|
203
|
+
} else if (val === 'pm' && isAM(hour)) {
|
|
204
|
+
return generateConfig.setHour(triggerDateTmpl, hour + 12);
|
|
205
|
+
}
|
|
206
|
+
return triggerDateTmpl;
|
|
207
|
+
};
|
|
208
|
+
var onHourChange = function onHourChange(val) {
|
|
209
|
+
triggerChange(getNextHourTime(val));
|
|
210
|
+
};
|
|
211
|
+
var onMinuteChange = function onMinuteChange(val) {
|
|
212
|
+
triggerChange(getNextMinuteTime(val));
|
|
213
|
+
};
|
|
214
|
+
var onSecondChange = function onSecondChange(val) {
|
|
215
|
+
triggerChange(getNextSecondTime(val));
|
|
216
|
+
};
|
|
217
|
+
var onMillisecondChange = function onMillisecondChange(val) {
|
|
218
|
+
triggerChange(getNextMillisecondTime(val));
|
|
219
|
+
};
|
|
220
|
+
var onMeridiemChange = function onMeridiemChange(val) {
|
|
221
|
+
triggerChange(getMeridiemTime(val));
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
// ====================== Column Hover ======================
|
|
225
|
+
var onHourHover = function onHourHover(val) {
|
|
226
|
+
onHover(getNextHourTime(val));
|
|
227
|
+
};
|
|
228
|
+
var onMinuteHover = function onMinuteHover(val) {
|
|
229
|
+
onHover(getNextMinuteTime(val));
|
|
230
|
+
};
|
|
231
|
+
var onSecondHover = function onSecondHover(val) {
|
|
232
|
+
onHover(getNextSecondTime(val));
|
|
233
|
+
};
|
|
234
|
+
var onMillisecondHover = function onMillisecondHover(val) {
|
|
235
|
+
onHover(getNextMillisecondTime(val));
|
|
236
|
+
};
|
|
237
|
+
var onMeridiemHover = function onMeridiemHover(val) {
|
|
238
|
+
onHover(getMeridiemTime(val));
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
// ========================= Render =========================
|
|
242
|
+
var sharedColumnProps = {
|
|
243
|
+
onDblClick: onCellDblClick,
|
|
244
|
+
changeOnScroll: changeOnScroll
|
|
245
|
+
};
|
|
246
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
247
|
+
className: "".concat(prefixCls, "-content")
|
|
248
|
+
}, showHour && /*#__PURE__*/React.createElement(TimeColumn, _extends({
|
|
249
|
+
units: hourUnits,
|
|
250
|
+
value: hour,
|
|
251
|
+
optionalValue: pickerHour,
|
|
252
|
+
type: "hour",
|
|
253
|
+
onChange: onHourChange,
|
|
254
|
+
onHover: onHourHover
|
|
255
|
+
}, sharedColumnProps)), showMinute && /*#__PURE__*/React.createElement(TimeColumn, _extends({
|
|
256
|
+
units: minuteUnits,
|
|
257
|
+
value: minute,
|
|
258
|
+
optionalValue: pickerMinute,
|
|
259
|
+
type: "minute",
|
|
260
|
+
onChange: onMinuteChange,
|
|
261
|
+
onHover: onMinuteHover
|
|
262
|
+
}, sharedColumnProps)), showSecond && /*#__PURE__*/React.createElement(TimeColumn, _extends({
|
|
263
|
+
units: secondUnits,
|
|
264
|
+
value: second,
|
|
265
|
+
optionalValue: pickerSecond,
|
|
266
|
+
type: "second",
|
|
267
|
+
onChange: onSecondChange,
|
|
268
|
+
onHover: onSecondHover
|
|
269
|
+
}, sharedColumnProps)), showMillisecond && /*#__PURE__*/React.createElement(TimeColumn, _extends({
|
|
270
|
+
units: millisecondUnits,
|
|
271
|
+
value: millisecond,
|
|
272
|
+
optionalValue: pickerMillisecond,
|
|
273
|
+
type: "millisecond",
|
|
274
|
+
onChange: onMillisecondChange,
|
|
275
|
+
onHover: onMillisecondHover
|
|
276
|
+
}, sharedColumnProps)), showMeridiem && /*#__PURE__*/React.createElement(TimeColumn, _extends({
|
|
277
|
+
units: meridiemUnits,
|
|
278
|
+
value: meridiem,
|
|
279
|
+
type: "meridiem",
|
|
280
|
+
onChange: onMeridiemChange,
|
|
281
|
+
onHover: onMeridiemHover
|
|
282
|
+
}, sharedColumnProps)));
|
|
283
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { useEvent } from '@rc-component/util';
|
|
2
|
+
import raf from "@rc-component/util/es/raf";
|
|
3
|
+
import isVisible from "@rc-component/util/es/Dom/isVisible";
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
var SPEED_PTG = 1 / 3;
|
|
6
|
+
export default function useScrollTo(ulRef, value) {
|
|
7
|
+
// ========================= Scroll =========================
|
|
8
|
+
var scrollingRef = React.useRef(false);
|
|
9
|
+
var scrollRafRef = React.useRef(null);
|
|
10
|
+
var scrollDistRef = React.useRef(null);
|
|
11
|
+
var isScrolling = function isScrolling() {
|
|
12
|
+
return scrollingRef.current;
|
|
13
|
+
};
|
|
14
|
+
var stopScroll = function stopScroll() {
|
|
15
|
+
raf.cancel(scrollRafRef.current);
|
|
16
|
+
scrollingRef.current = false;
|
|
17
|
+
};
|
|
18
|
+
var scrollRafTimesRef = React.useRef();
|
|
19
|
+
var startScroll = function startScroll() {
|
|
20
|
+
var ul = ulRef.current;
|
|
21
|
+
scrollDistRef.current = null;
|
|
22
|
+
scrollRafTimesRef.current = 0;
|
|
23
|
+
if (ul) {
|
|
24
|
+
var targetLi = ul.querySelector("[data-value=\"".concat(value, "\"]"));
|
|
25
|
+
var firstLi = ul.querySelector("li");
|
|
26
|
+
var doScroll = function doScroll() {
|
|
27
|
+
stopScroll();
|
|
28
|
+
scrollingRef.current = true;
|
|
29
|
+
scrollRafTimesRef.current += 1;
|
|
30
|
+
var currentTop = ul.scrollTop;
|
|
31
|
+
var firstLiTop = firstLi.offsetTop;
|
|
32
|
+
var targetLiTop = targetLi.offsetTop;
|
|
33
|
+
var targetTop = targetLiTop - firstLiTop;
|
|
34
|
+
|
|
35
|
+
// Wait for element exist. 5 frames is enough
|
|
36
|
+
if (targetLiTop === 0 && targetLi !== firstLi || !isVisible(ul)) {
|
|
37
|
+
if (scrollRafTimesRef.current <= 5) {
|
|
38
|
+
scrollRafRef.current = raf(doScroll);
|
|
39
|
+
}
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
var nextTop = currentTop + (targetTop - currentTop) * SPEED_PTG;
|
|
43
|
+
var dist = Math.abs(targetTop - nextTop);
|
|
44
|
+
|
|
45
|
+
// Break if dist get larger, which means user is scrolling
|
|
46
|
+
if (scrollDistRef.current !== null && scrollDistRef.current < dist) {
|
|
47
|
+
stopScroll();
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
scrollDistRef.current = dist;
|
|
51
|
+
|
|
52
|
+
// Stop when dist is less than 1
|
|
53
|
+
if (dist <= 1) {
|
|
54
|
+
ul.scrollTop = targetTop;
|
|
55
|
+
stopScroll();
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// IE not support `scrollTo`
|
|
60
|
+
ul.scrollTop = nextTop;
|
|
61
|
+
scrollRafRef.current = raf(doScroll);
|
|
62
|
+
};
|
|
63
|
+
if (targetLi && firstLi) {
|
|
64
|
+
doScroll();
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
// ======================== Trigger =========================
|
|
70
|
+
var syncScroll = useEvent(startScroll);
|
|
71
|
+
return [syncScroll, stopScroll, isScrolling];
|
|
72
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { GenerateConfig } from '../../../generate';
|
|
2
|
+
import type { Unit } from './TimeColumn';
|
|
3
|
+
export declare function findValidateTime<DateType>(date: DateType, getHourUnits: () => Unit<number>[], getMinuteUnits: (hour: number) => Unit<number>[], getSecondUnits: (hour: number, minute: number) => Unit<number>[], getMillisecondUnits: (hour: number, minute: number, second: number) => Unit<number>[], generateConfig: GenerateConfig<DateType>): DateType;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
2
|
+
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."); }
|
|
3
|
+
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); }
|
|
4
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
5
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
6
|
+
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; }
|
|
7
|
+
export function findValidateTime(date, getHourUnits, getMinuteUnits, getSecondUnits, getMillisecondUnits, generateConfig) {
|
|
8
|
+
var nextDate = date;
|
|
9
|
+
function alignValidate(getUnitValue, setUnitValue, units) {
|
|
10
|
+
var nextValue = generateConfig[getUnitValue](nextDate);
|
|
11
|
+
var nextUnit = units.find(function (unit) {
|
|
12
|
+
return unit.value === nextValue;
|
|
13
|
+
});
|
|
14
|
+
if (!nextUnit || nextUnit.disabled) {
|
|
15
|
+
// Find most closest unit
|
|
16
|
+
var validateUnits = units.filter(function (unit) {
|
|
17
|
+
return !unit.disabled;
|
|
18
|
+
});
|
|
19
|
+
var reverseEnabledUnits = _toConsumableArray(validateUnits).reverse();
|
|
20
|
+
var validateUnit = reverseEnabledUnits.find(function (unit) {
|
|
21
|
+
return unit.value <= nextValue;
|
|
22
|
+
}) || validateUnits[0];
|
|
23
|
+
if (validateUnit) {
|
|
24
|
+
nextValue = validateUnit.value;
|
|
25
|
+
nextDate = generateConfig[setUnitValue](nextDate, nextValue);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return nextValue;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Find validate hour
|
|
32
|
+
var nextHour = alignValidate('getHour', 'setHour', getHourUnits());
|
|
33
|
+
|
|
34
|
+
// Find validate minute
|
|
35
|
+
var nextMinute = alignValidate('getMinute', 'setMinute', getMinuteUnits(nextHour));
|
|
36
|
+
|
|
37
|
+
// Find validate second
|
|
38
|
+
var nextSecond = alignValidate('getSecond', 'setSecond', getSecondUnits(nextHour, nextMinute));
|
|
39
|
+
|
|
40
|
+
// Find validate millisecond
|
|
41
|
+
alignValidate('getMillisecond', 'setMillisecond', getMillisecondUnits(nextHour, nextMinute, nextSecond));
|
|
42
|
+
return nextDate;
|
|
43
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { SharedPanelProps } from '../../interface';
|
|
3
|
+
export type TimePanelProps<DateType extends object> = SharedPanelProps<DateType>;
|
|
4
|
+
export default function TimePanel<DateType extends object = any>(props: TimePanelProps<DateType>): React.JSX.Element;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
+
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."); }
|
|
3
|
+
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); }
|
|
4
|
+
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; }
|
|
5
|
+
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; } }
|
|
6
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
|
+
import classNames from 'classnames';
|
|
8
|
+
import * as React from 'react';
|
|
9
|
+
import { formatValue } from "../../utils/dateUtil";
|
|
10
|
+
import { PanelContext, useInfo } from "../context";
|
|
11
|
+
import PanelHeader from "../PanelHeader";
|
|
12
|
+
import TimePanelBody from "./TimePanelBody";
|
|
13
|
+
export default function TimePanel(props) {
|
|
14
|
+
var prefixCls = props.prefixCls,
|
|
15
|
+
value = props.value,
|
|
16
|
+
locale = props.locale,
|
|
17
|
+
generateConfig = props.generateConfig,
|
|
18
|
+
showTime = props.showTime;
|
|
19
|
+
var _ref = showTime || {},
|
|
20
|
+
format = _ref.format;
|
|
21
|
+
var panelPrefixCls = "".concat(prefixCls, "-time-panel");
|
|
22
|
+
|
|
23
|
+
// ========================== Base ==========================
|
|
24
|
+
var _useInfo = useInfo(props, 'time'),
|
|
25
|
+
_useInfo2 = _slicedToArray(_useInfo, 1),
|
|
26
|
+
info = _useInfo2[0];
|
|
27
|
+
|
|
28
|
+
// ========================= Render =========================
|
|
29
|
+
return /*#__PURE__*/React.createElement(PanelContext.Provider, {
|
|
30
|
+
value: info
|
|
31
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
32
|
+
className: classNames(panelPrefixCls)
|
|
33
|
+
}, /*#__PURE__*/React.createElement(PanelHeader, null, value ? formatValue(value, {
|
|
34
|
+
locale: locale,
|
|
35
|
+
format: format,
|
|
36
|
+
generateConfig: generateConfig
|
|
37
|
+
}) : "\xA0"), /*#__PURE__*/React.createElement(TimePanelBody, showTime)));
|
|
38
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
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); }
|
|
2
|
+
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); }
|
|
3
|
+
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; }
|
|
4
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
5
|
+
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); }
|
|
6
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
7
|
+
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."); }
|
|
8
|
+
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); }
|
|
9
|
+
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; }
|
|
10
|
+
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; } }
|
|
11
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
12
|
+
import classNames from 'classnames';
|
|
13
|
+
import * as React from 'react';
|
|
14
|
+
import { isInRange, isSameWeek } from "../../utils/dateUtil";
|
|
15
|
+
import DatePanel from "../DatePanel";
|
|
16
|
+
export default function WeekPanel(props) {
|
|
17
|
+
var prefixCls = props.prefixCls,
|
|
18
|
+
generateConfig = props.generateConfig,
|
|
19
|
+
locale = props.locale,
|
|
20
|
+
value = props.value,
|
|
21
|
+
hoverValue = props.hoverValue,
|
|
22
|
+
hoverRangeValue = props.hoverRangeValue;
|
|
23
|
+
|
|
24
|
+
// =============================== Row ================================
|
|
25
|
+
var localeName = locale.locale;
|
|
26
|
+
var rowPrefixCls = "".concat(prefixCls, "-week-panel-row");
|
|
27
|
+
var rowClassName = function rowClassName(currentDate) {
|
|
28
|
+
var rangeCls = {};
|
|
29
|
+
if (hoverRangeValue) {
|
|
30
|
+
var _hoverRangeValue = _slicedToArray(hoverRangeValue, 2),
|
|
31
|
+
rangeStart = _hoverRangeValue[0],
|
|
32
|
+
rangeEnd = _hoverRangeValue[1];
|
|
33
|
+
var isRangeStart = isSameWeek(generateConfig, localeName, rangeStart, currentDate);
|
|
34
|
+
var isRangeEnd = isSameWeek(generateConfig, localeName, rangeEnd, currentDate);
|
|
35
|
+
rangeCls["".concat(rowPrefixCls, "-range-start")] = isRangeStart;
|
|
36
|
+
rangeCls["".concat(rowPrefixCls, "-range-end")] = isRangeEnd;
|
|
37
|
+
rangeCls["".concat(rowPrefixCls, "-range-hover")] = !isRangeStart && !isRangeEnd && isInRange(generateConfig, rangeStart, rangeEnd, currentDate);
|
|
38
|
+
}
|
|
39
|
+
if (hoverValue) {
|
|
40
|
+
rangeCls["".concat(rowPrefixCls, "-hover")] = hoverValue.some(function (date) {
|
|
41
|
+
return isSameWeek(generateConfig, localeName, currentDate, date);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
return classNames(rowPrefixCls, _defineProperty({}, "".concat(rowPrefixCls, "-selected"), !hoverRangeValue && isSameWeek(generateConfig, localeName, value, currentDate)),
|
|
45
|
+
// Patch for hover range
|
|
46
|
+
rangeCls);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
// ============================== Render ==============================
|
|
50
|
+
return /*#__PURE__*/React.createElement(DatePanel, _extends({}, props, {
|
|
51
|
+
mode: "week",
|
|
52
|
+
panelName: "week",
|
|
53
|
+
rowClassName: rowClassName
|
|
54
|
+
}));
|
|
55
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
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); }
|
|
2
|
+
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); }
|
|
3
|
+
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; }
|
|
4
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
5
|
+
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); }
|
|
6
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
7
|
+
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."); }
|
|
8
|
+
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); }
|
|
9
|
+
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; }
|
|
10
|
+
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; } }
|
|
11
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
12
|
+
import * as React from 'react';
|
|
13
|
+
import { formatValue, isInRange, isSameYear } from "../../utils/dateUtil";
|
|
14
|
+
import { PanelContext, useInfo } from "../context";
|
|
15
|
+
import PanelBody from "../PanelBody";
|
|
16
|
+
import PanelHeader from "../PanelHeader";
|
|
17
|
+
export default function YearPanel(props) {
|
|
18
|
+
var prefixCls = props.prefixCls,
|
|
19
|
+
locale = props.locale,
|
|
20
|
+
generateConfig = props.generateConfig,
|
|
21
|
+
pickerValue = props.pickerValue,
|
|
22
|
+
disabledDate = props.disabledDate,
|
|
23
|
+
onPickerValueChange = props.onPickerValueChange,
|
|
24
|
+
onModeChange = props.onModeChange;
|
|
25
|
+
var panelPrefixCls = "".concat(prefixCls, "-year-panel");
|
|
26
|
+
|
|
27
|
+
// ========================== Base ==========================
|
|
28
|
+
var _useInfo = useInfo(props, 'year'),
|
|
29
|
+
_useInfo2 = _slicedToArray(_useInfo, 1),
|
|
30
|
+
info = _useInfo2[0];
|
|
31
|
+
var getStartYear = function getStartYear(date) {
|
|
32
|
+
var startYear = Math.floor(generateConfig.getYear(date) / 10) * 10;
|
|
33
|
+
return generateConfig.setYear(date, startYear);
|
|
34
|
+
};
|
|
35
|
+
var getEndYear = function getEndYear(date) {
|
|
36
|
+
var startYear = getStartYear(date);
|
|
37
|
+
return generateConfig.addYear(startYear, 9);
|
|
38
|
+
};
|
|
39
|
+
var startYearDate = getStartYear(pickerValue);
|
|
40
|
+
var endYearDate = getEndYear(pickerValue);
|
|
41
|
+
var baseDate = generateConfig.addYear(startYearDate, -1);
|
|
42
|
+
|
|
43
|
+
// ========================= Cells ==========================
|
|
44
|
+
var getCellDate = function getCellDate(date, offset) {
|
|
45
|
+
return generateConfig.addYear(date, offset);
|
|
46
|
+
};
|
|
47
|
+
var getCellText = function getCellText(date) {
|
|
48
|
+
return formatValue(date, {
|
|
49
|
+
locale: locale,
|
|
50
|
+
format: locale.cellYearFormat,
|
|
51
|
+
generateConfig: generateConfig
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
var getCellClassName = function getCellClassName(date) {
|
|
55
|
+
return _defineProperty({}, "".concat(prefixCls, "-cell-in-view"), isSameYear(generateConfig, date, startYearDate) || isSameYear(generateConfig, date, endYearDate) || isInRange(generateConfig, startYearDate, endYearDate, date));
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
// ======================== Disabled ========================
|
|
59
|
+
var mergedDisabledDate = disabledDate ? function (currentDate, disabledInfo) {
|
|
60
|
+
// Start
|
|
61
|
+
var startMonth = generateConfig.setMonth(currentDate, 0);
|
|
62
|
+
var startDate = generateConfig.setDate(startMonth, 1);
|
|
63
|
+
|
|
64
|
+
// End
|
|
65
|
+
var endMonth = generateConfig.addYear(startDate, 1);
|
|
66
|
+
var endDate = generateConfig.addDate(endMonth, -1);
|
|
67
|
+
return disabledDate(startDate, disabledInfo) && disabledDate(endDate, disabledInfo);
|
|
68
|
+
} : null;
|
|
69
|
+
|
|
70
|
+
// ========================= Header =========================
|
|
71
|
+
var yearNode = /*#__PURE__*/React.createElement("button", {
|
|
72
|
+
type: "button",
|
|
73
|
+
key: "decade",
|
|
74
|
+
"aria-label": locale.decadeSelect,
|
|
75
|
+
onClick: function onClick() {
|
|
76
|
+
onModeChange('decade');
|
|
77
|
+
},
|
|
78
|
+
tabIndex: -1,
|
|
79
|
+
className: "".concat(prefixCls, "-decade-btn")
|
|
80
|
+
}, formatValue(startYearDate, {
|
|
81
|
+
locale: locale,
|
|
82
|
+
format: locale.yearFormat,
|
|
83
|
+
generateConfig: generateConfig
|
|
84
|
+
}), "-", formatValue(endYearDate, {
|
|
85
|
+
locale: locale,
|
|
86
|
+
format: locale.yearFormat,
|
|
87
|
+
generateConfig: generateConfig
|
|
88
|
+
}));
|
|
89
|
+
|
|
90
|
+
// ========================= Render =========================
|
|
91
|
+
return /*#__PURE__*/React.createElement(PanelContext.Provider, {
|
|
92
|
+
value: info
|
|
93
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
94
|
+
className: panelPrefixCls
|
|
95
|
+
}, /*#__PURE__*/React.createElement(PanelHeader, {
|
|
96
|
+
superOffset: function superOffset(distance) {
|
|
97
|
+
return generateConfig.addYear(pickerValue, distance * 10);
|
|
98
|
+
},
|
|
99
|
+
onChange: onPickerValueChange
|
|
100
|
+
// Limitation
|
|
101
|
+
,
|
|
102
|
+
getStart: getStartYear,
|
|
103
|
+
getEnd: getEndYear
|
|
104
|
+
}, yearNode), /*#__PURE__*/React.createElement(PanelBody, _extends({}, props, {
|
|
105
|
+
disabledDate: mergedDisabledDate,
|
|
106
|
+
titleFormat: locale.fieldYearFormat,
|
|
107
|
+
colNum: 3,
|
|
108
|
+
rowNum: 4,
|
|
109
|
+
baseDate: baseDate
|
|
110
|
+
// Body
|
|
111
|
+
,
|
|
112
|
+
getCellDate: getCellDate,
|
|
113
|
+
getCellText: getCellText,
|
|
114
|
+
getCellClassName: getCellClassName
|
|
115
|
+
}))));
|
|
116
|
+
}
|