@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,190 @@
|
|
|
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 { formatValue, getWeekStartDate, isSameDate, isSameMonth, WEEK_DAY_COUNT } from "../../utils/dateUtil";
|
|
15
|
+
import { PanelContext, useInfo } from "../context";
|
|
16
|
+
import PanelBody from "../PanelBody";
|
|
17
|
+
import PanelHeader from "../PanelHeader";
|
|
18
|
+
export default function DatePanel(props) {
|
|
19
|
+
var prefixCls = props.prefixCls,
|
|
20
|
+
_props$panelName = props.panelName,
|
|
21
|
+
panelName = _props$panelName === void 0 ? 'date' : _props$panelName,
|
|
22
|
+
locale = props.locale,
|
|
23
|
+
generateConfig = props.generateConfig,
|
|
24
|
+
pickerValue = props.pickerValue,
|
|
25
|
+
onPickerValueChange = props.onPickerValueChange,
|
|
26
|
+
onModeChange = props.onModeChange,
|
|
27
|
+
_props$mode = props.mode,
|
|
28
|
+
mode = _props$mode === void 0 ? 'date' : _props$mode,
|
|
29
|
+
disabledDate = props.disabledDate,
|
|
30
|
+
onSelect = props.onSelect,
|
|
31
|
+
onHover = props.onHover,
|
|
32
|
+
showWeek = props.showWeek;
|
|
33
|
+
var panelPrefixCls = "".concat(prefixCls, "-").concat(panelName, "-panel");
|
|
34
|
+
var cellPrefixCls = "".concat(prefixCls, "-cell");
|
|
35
|
+
var isWeek = mode === 'week';
|
|
36
|
+
|
|
37
|
+
// ========================== Base ==========================
|
|
38
|
+
var _useInfo = useInfo(props, mode),
|
|
39
|
+
_useInfo2 = _slicedToArray(_useInfo, 2),
|
|
40
|
+
info = _useInfo2[0],
|
|
41
|
+
now = _useInfo2[1];
|
|
42
|
+
var weekFirstDay = generateConfig.locale.getWeekFirstDay(locale.locale);
|
|
43
|
+
var monthStartDate = generateConfig.setDate(pickerValue, 1);
|
|
44
|
+
var baseDate = getWeekStartDate(locale.locale, generateConfig, monthStartDate);
|
|
45
|
+
var month = generateConfig.getMonth(pickerValue);
|
|
46
|
+
|
|
47
|
+
// =========================== PrefixColumn ===========================
|
|
48
|
+
var showPrefixColumn = showWeek === undefined ? isWeek : showWeek;
|
|
49
|
+
var prefixColumn = showPrefixColumn ? function (date) {
|
|
50
|
+
// >>> Additional check for disabled
|
|
51
|
+
var disabled = disabledDate === null || disabledDate === void 0 ? void 0 : disabledDate(date, {
|
|
52
|
+
type: 'week'
|
|
53
|
+
});
|
|
54
|
+
return /*#__PURE__*/React.createElement("td", {
|
|
55
|
+
key: "week",
|
|
56
|
+
className: classNames(cellPrefixCls, "".concat(cellPrefixCls, "-week"), _defineProperty({}, "".concat(cellPrefixCls, "-disabled"), disabled))
|
|
57
|
+
// Operation: Same as code in PanelBody
|
|
58
|
+
,
|
|
59
|
+
onClick: function onClick() {
|
|
60
|
+
if (!disabled) {
|
|
61
|
+
onSelect(date);
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
onMouseEnter: function onMouseEnter() {
|
|
65
|
+
if (!disabled) {
|
|
66
|
+
onHover === null || onHover === void 0 || onHover(date);
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
onMouseLeave: function onMouseLeave() {
|
|
70
|
+
if (!disabled) {
|
|
71
|
+
onHover === null || onHover === void 0 || onHover(null);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
75
|
+
className: "".concat(cellPrefixCls, "-inner")
|
|
76
|
+
}, generateConfig.locale.getWeek(locale.locale, date)));
|
|
77
|
+
} : null;
|
|
78
|
+
|
|
79
|
+
// ========================= Cells ==========================
|
|
80
|
+
// >>> Header Cells
|
|
81
|
+
var headerCells = [];
|
|
82
|
+
var weekDaysLocale = locale.shortWeekDays || (generateConfig.locale.getShortWeekDays ? generateConfig.locale.getShortWeekDays(locale.locale) : []);
|
|
83
|
+
if (prefixColumn) {
|
|
84
|
+
headerCells.push( /*#__PURE__*/React.createElement("th", {
|
|
85
|
+
key: "empty"
|
|
86
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
87
|
+
style: {
|
|
88
|
+
width: 0,
|
|
89
|
+
height: 0,
|
|
90
|
+
position: 'absolute',
|
|
91
|
+
overflow: 'hidden',
|
|
92
|
+
opacity: 0
|
|
93
|
+
}
|
|
94
|
+
}, locale.week)));
|
|
95
|
+
}
|
|
96
|
+
for (var i = 0; i < WEEK_DAY_COUNT; i += 1) {
|
|
97
|
+
headerCells.push( /*#__PURE__*/React.createElement("th", {
|
|
98
|
+
key: i
|
|
99
|
+
}, weekDaysLocale[(i + weekFirstDay) % WEEK_DAY_COUNT]));
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// >>> Body Cells
|
|
103
|
+
var getCellDate = function getCellDate(date, offset) {
|
|
104
|
+
return generateConfig.addDate(date, offset);
|
|
105
|
+
};
|
|
106
|
+
var getCellText = function getCellText(date) {
|
|
107
|
+
return formatValue(date, {
|
|
108
|
+
locale: locale,
|
|
109
|
+
format: locale.cellDateFormat,
|
|
110
|
+
generateConfig: generateConfig
|
|
111
|
+
});
|
|
112
|
+
};
|
|
113
|
+
var getCellClassName = function getCellClassName(date) {
|
|
114
|
+
var classObj = _defineProperty(_defineProperty({}, "".concat(prefixCls, "-cell-in-view"), isSameMonth(generateConfig, date, pickerValue)), "".concat(prefixCls, "-cell-today"), isSameDate(generateConfig, date, now));
|
|
115
|
+
return classObj;
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
// ========================= Header =========================
|
|
119
|
+
var monthsLocale = locale.shortMonths || (generateConfig.locale.getShortMonths ? generateConfig.locale.getShortMonths(locale.locale) : []);
|
|
120
|
+
var yearNode = /*#__PURE__*/React.createElement("button", {
|
|
121
|
+
type: "button",
|
|
122
|
+
"aria-label": locale.yearSelect,
|
|
123
|
+
key: "year",
|
|
124
|
+
onClick: function onClick() {
|
|
125
|
+
onModeChange('year', pickerValue);
|
|
126
|
+
},
|
|
127
|
+
tabIndex: -1,
|
|
128
|
+
className: "".concat(prefixCls, "-year-btn")
|
|
129
|
+
}, formatValue(pickerValue, {
|
|
130
|
+
locale: locale,
|
|
131
|
+
format: locale.yearFormat,
|
|
132
|
+
generateConfig: generateConfig
|
|
133
|
+
}));
|
|
134
|
+
var monthNode = /*#__PURE__*/React.createElement("button", {
|
|
135
|
+
type: "button",
|
|
136
|
+
"aria-label": locale.monthSelect,
|
|
137
|
+
key: "month",
|
|
138
|
+
onClick: function onClick() {
|
|
139
|
+
onModeChange('month', pickerValue);
|
|
140
|
+
},
|
|
141
|
+
tabIndex: -1,
|
|
142
|
+
className: "".concat(prefixCls, "-month-btn")
|
|
143
|
+
}, locale.monthFormat ? formatValue(pickerValue, {
|
|
144
|
+
locale: locale,
|
|
145
|
+
format: locale.monthFormat,
|
|
146
|
+
generateConfig: generateConfig
|
|
147
|
+
}) : monthsLocale[month]);
|
|
148
|
+
var monthYearNodes = locale.monthBeforeYear ? [monthNode, yearNode] : [yearNode, monthNode];
|
|
149
|
+
|
|
150
|
+
// ========================= Render =========================
|
|
151
|
+
return /*#__PURE__*/React.createElement(PanelContext.Provider, {
|
|
152
|
+
value: info
|
|
153
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
154
|
+
className: classNames(panelPrefixCls, showWeek && "".concat(panelPrefixCls, "-show-week"))
|
|
155
|
+
}, /*#__PURE__*/React.createElement(PanelHeader, {
|
|
156
|
+
offset: function offset(distance) {
|
|
157
|
+
return generateConfig.addMonth(pickerValue, distance);
|
|
158
|
+
},
|
|
159
|
+
superOffset: function superOffset(distance) {
|
|
160
|
+
return generateConfig.addYear(pickerValue, distance);
|
|
161
|
+
},
|
|
162
|
+
onChange: onPickerValueChange
|
|
163
|
+
// Limitation
|
|
164
|
+
,
|
|
165
|
+
getStart: function getStart(date) {
|
|
166
|
+
return generateConfig.setDate(date, 1);
|
|
167
|
+
},
|
|
168
|
+
getEnd: function getEnd(date) {
|
|
169
|
+
var clone = generateConfig.setDate(date, 1);
|
|
170
|
+
clone = generateConfig.addMonth(clone, 1);
|
|
171
|
+
return generateConfig.addDate(clone, -1);
|
|
172
|
+
}
|
|
173
|
+
}, monthYearNodes), /*#__PURE__*/React.createElement(PanelBody, _extends({
|
|
174
|
+
titleFormat: locale.fieldDateFormat
|
|
175
|
+
}, props, {
|
|
176
|
+
colNum: WEEK_DAY_COUNT,
|
|
177
|
+
rowNum: 6,
|
|
178
|
+
baseDate: baseDate
|
|
179
|
+
// Header
|
|
180
|
+
,
|
|
181
|
+
headerCells: headerCells
|
|
182
|
+
// Body
|
|
183
|
+
,
|
|
184
|
+
getCellDate: getCellDate,
|
|
185
|
+
getCellText: getCellText,
|
|
186
|
+
getCellClassName: getCellClassName,
|
|
187
|
+
prefixColumn: prefixColumn,
|
|
188
|
+
cellSelection: !isWeek
|
|
189
|
+
}))));
|
|
190
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
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 { fillTime } from "../../utils/dateUtil";
|
|
11
|
+
import DatePanel from "../DatePanel";
|
|
12
|
+
import TimePanel from "../TimePanel";
|
|
13
|
+
export default function DateTimePanel(props) {
|
|
14
|
+
var prefixCls = props.prefixCls,
|
|
15
|
+
generateConfig = props.generateConfig,
|
|
16
|
+
showTime = props.showTime,
|
|
17
|
+
onSelect = props.onSelect,
|
|
18
|
+
value = props.value,
|
|
19
|
+
pickerValue = props.pickerValue,
|
|
20
|
+
onHover = props.onHover;
|
|
21
|
+
var panelPrefixCls = "".concat(prefixCls, "-datetime-panel");
|
|
22
|
+
|
|
23
|
+
// =============================== Time ===============================
|
|
24
|
+
var _useTimeInfo = useTimeInfo(generateConfig, showTime),
|
|
25
|
+
_useTimeInfo2 = _slicedToArray(_useTimeInfo, 1),
|
|
26
|
+
getValidTime = _useTimeInfo2[0];
|
|
27
|
+
|
|
28
|
+
// Merge the time info from `value` or `pickerValue`
|
|
29
|
+
var mergeTime = function mergeTime(date) {
|
|
30
|
+
if (value) {
|
|
31
|
+
return fillTime(generateConfig, date, value);
|
|
32
|
+
}
|
|
33
|
+
return fillTime(generateConfig, date, pickerValue);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
// ============================== Hover ===============================
|
|
37
|
+
var onDateHover = function onDateHover(date) {
|
|
38
|
+
onHover === null || onHover === void 0 || onHover(date ? mergeTime(date) : date);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
// ============================== Select ==============================
|
|
42
|
+
var onDateSelect = function onDateSelect(date) {
|
|
43
|
+
// Merge with current time
|
|
44
|
+
var cloneDate = mergeTime(date);
|
|
45
|
+
onSelect(getValidTime(cloneDate, cloneDate));
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
// ============================== Render ==============================
|
|
49
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
50
|
+
className: panelPrefixCls
|
|
51
|
+
}, /*#__PURE__*/React.createElement(DatePanel, _extends({}, props, {
|
|
52
|
+
onSelect: onDateSelect,
|
|
53
|
+
onHover: onDateHover
|
|
54
|
+
})), /*#__PURE__*/React.createElement(TimePanel, props));
|
|
55
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
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, isSameDecade } from "../../utils/dateUtil";
|
|
14
|
+
import { PanelContext, useInfo } from "../context";
|
|
15
|
+
import PanelBody from "../PanelBody";
|
|
16
|
+
import PanelHeader from "../PanelHeader";
|
|
17
|
+
export default function DecadePanel(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
|
+
var panelPrefixCls = "".concat(prefixCls, "-decade-panel");
|
|
25
|
+
|
|
26
|
+
// ========================== Base ==========================
|
|
27
|
+
var _useInfo = useInfo(props, 'decade'),
|
|
28
|
+
_useInfo2 = _slicedToArray(_useInfo, 1),
|
|
29
|
+
info = _useInfo2[0];
|
|
30
|
+
var getStartYear = function getStartYear(date) {
|
|
31
|
+
var startYear = Math.floor(generateConfig.getYear(date) / 100) * 100;
|
|
32
|
+
return generateConfig.setYear(date, startYear);
|
|
33
|
+
};
|
|
34
|
+
var getEndYear = function getEndYear(date) {
|
|
35
|
+
var startYear = getStartYear(date);
|
|
36
|
+
return generateConfig.addYear(startYear, 99);
|
|
37
|
+
};
|
|
38
|
+
var startYearDate = getStartYear(pickerValue);
|
|
39
|
+
var endYearDate = getEndYear(pickerValue);
|
|
40
|
+
var baseDate = generateConfig.addYear(startYearDate, -10);
|
|
41
|
+
|
|
42
|
+
// ========================= Cells ==========================
|
|
43
|
+
var getCellDate = function getCellDate(date, offset) {
|
|
44
|
+
return generateConfig.addYear(date, offset * 10);
|
|
45
|
+
};
|
|
46
|
+
var getCellText = function getCellText(date) {
|
|
47
|
+
var cellYearFormat = locale.cellYearFormat;
|
|
48
|
+
var startYearStr = formatValue(date, {
|
|
49
|
+
locale: locale,
|
|
50
|
+
format: cellYearFormat,
|
|
51
|
+
generateConfig: generateConfig
|
|
52
|
+
});
|
|
53
|
+
var endYearStr = formatValue(generateConfig.addYear(date, 9), {
|
|
54
|
+
locale: locale,
|
|
55
|
+
format: cellYearFormat,
|
|
56
|
+
generateConfig: generateConfig
|
|
57
|
+
});
|
|
58
|
+
return "".concat(startYearStr, "-").concat(endYearStr);
|
|
59
|
+
};
|
|
60
|
+
var getCellClassName = function getCellClassName(date) {
|
|
61
|
+
return _defineProperty({}, "".concat(prefixCls, "-cell-in-view"), isSameDecade(generateConfig, date, startYearDate) || isSameDecade(generateConfig, date, endYearDate) || isInRange(generateConfig, startYearDate, endYearDate, date));
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
// ======================== Disabled ========================
|
|
65
|
+
var mergedDisabledDate = disabledDate ? function (currentDate, disabledInfo) {
|
|
66
|
+
// Start
|
|
67
|
+
var baseStartDate = generateConfig.setDate(currentDate, 1);
|
|
68
|
+
var baseStartMonth = generateConfig.setMonth(baseStartDate, 0);
|
|
69
|
+
var baseStartYear = generateConfig.setYear(baseStartMonth, Math.floor(generateConfig.getYear(baseStartMonth) / 10) * 10);
|
|
70
|
+
|
|
71
|
+
// End
|
|
72
|
+
var baseEndYear = generateConfig.addYear(baseStartYear, 10);
|
|
73
|
+
var baseEndDate = generateConfig.addDate(baseEndYear, -1);
|
|
74
|
+
return disabledDate(baseStartYear, disabledInfo) && disabledDate(baseEndDate, disabledInfo);
|
|
75
|
+
} : null;
|
|
76
|
+
|
|
77
|
+
// ========================= Header =========================
|
|
78
|
+
var yearNode = "".concat(formatValue(startYearDate, {
|
|
79
|
+
locale: locale,
|
|
80
|
+
format: locale.yearFormat,
|
|
81
|
+
generateConfig: generateConfig
|
|
82
|
+
}), "-").concat(formatValue(endYearDate, {
|
|
83
|
+
locale: locale,
|
|
84
|
+
format: locale.yearFormat,
|
|
85
|
+
generateConfig: generateConfig
|
|
86
|
+
}));
|
|
87
|
+
|
|
88
|
+
// ========================= Render =========================
|
|
89
|
+
return /*#__PURE__*/React.createElement(PanelContext.Provider, {
|
|
90
|
+
value: info
|
|
91
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
92
|
+
className: panelPrefixCls
|
|
93
|
+
}, /*#__PURE__*/React.createElement(PanelHeader, {
|
|
94
|
+
superOffset: function superOffset(distance) {
|
|
95
|
+
return generateConfig.addYear(pickerValue, distance * 100);
|
|
96
|
+
},
|
|
97
|
+
onChange: onPickerValueChange
|
|
98
|
+
// Limitation
|
|
99
|
+
,
|
|
100
|
+
getStart: getStartYear,
|
|
101
|
+
getEnd: getEndYear
|
|
102
|
+
}, yearNode), /*#__PURE__*/React.createElement(PanelBody, _extends({}, props, {
|
|
103
|
+
disabledDate: mergedDisabledDate,
|
|
104
|
+
colNum: 3,
|
|
105
|
+
rowNum: 4,
|
|
106
|
+
baseDate: baseDate
|
|
107
|
+
// Body
|
|
108
|
+
,
|
|
109
|
+
getCellDate: getCellDate,
|
|
110
|
+
getCellText: getCellText,
|
|
111
|
+
getCellClassName: getCellClassName
|
|
112
|
+
}))));
|
|
113
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
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 } from "../../utils/dateUtil";
|
|
14
|
+
import { PanelContext, useInfo } from "../context";
|
|
15
|
+
import PanelBody from "../PanelBody";
|
|
16
|
+
import PanelHeader from "../PanelHeader";
|
|
17
|
+
export default function MonthPanel(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, "-month-panel");
|
|
26
|
+
|
|
27
|
+
// ========================== Base ==========================
|
|
28
|
+
var _useInfo = useInfo(props, 'month'),
|
|
29
|
+
_useInfo2 = _slicedToArray(_useInfo, 1),
|
|
30
|
+
info = _useInfo2[0];
|
|
31
|
+
var baseDate = generateConfig.setMonth(pickerValue, 0);
|
|
32
|
+
|
|
33
|
+
// ========================= Month ==========================
|
|
34
|
+
var monthsLocale = locale.shortMonths || (generateConfig.locale.getShortMonths ? generateConfig.locale.getShortMonths(locale.locale) : []);
|
|
35
|
+
|
|
36
|
+
// ========================= Cells ==========================
|
|
37
|
+
var getCellDate = function getCellDate(date, offset) {
|
|
38
|
+
return generateConfig.addMonth(date, offset);
|
|
39
|
+
};
|
|
40
|
+
var getCellText = function getCellText(date) {
|
|
41
|
+
var month = generateConfig.getMonth(date);
|
|
42
|
+
return locale.monthFormat ? formatValue(date, {
|
|
43
|
+
locale: locale,
|
|
44
|
+
format: locale.monthFormat,
|
|
45
|
+
generateConfig: generateConfig
|
|
46
|
+
}) : monthsLocale[month];
|
|
47
|
+
};
|
|
48
|
+
var getCellClassName = function getCellClassName() {
|
|
49
|
+
return _defineProperty({}, "".concat(prefixCls, "-cell-in-view"), true);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
// ======================== Disabled ========================
|
|
53
|
+
var mergedDisabledDate = disabledDate ? function (currentDate, disabledInfo) {
|
|
54
|
+
var startDate = generateConfig.setDate(currentDate, 1);
|
|
55
|
+
var nextMonthStartDate = generateConfig.setMonth(startDate, generateConfig.getMonth(startDate) + 1);
|
|
56
|
+
var endDate = generateConfig.addDate(nextMonthStartDate, -1);
|
|
57
|
+
return disabledDate(startDate, disabledInfo) && disabledDate(endDate, disabledInfo);
|
|
58
|
+
} : null;
|
|
59
|
+
|
|
60
|
+
// ========================= Header =========================
|
|
61
|
+
var yearNode = /*#__PURE__*/React.createElement("button", {
|
|
62
|
+
type: "button",
|
|
63
|
+
key: "year",
|
|
64
|
+
"aria-label": locale.yearSelect,
|
|
65
|
+
onClick: function onClick() {
|
|
66
|
+
onModeChange('year');
|
|
67
|
+
},
|
|
68
|
+
tabIndex: -1,
|
|
69
|
+
className: "".concat(prefixCls, "-year-btn")
|
|
70
|
+
}, formatValue(pickerValue, {
|
|
71
|
+
locale: locale,
|
|
72
|
+
format: locale.yearFormat,
|
|
73
|
+
generateConfig: generateConfig
|
|
74
|
+
}));
|
|
75
|
+
|
|
76
|
+
// ========================= Render =========================
|
|
77
|
+
return /*#__PURE__*/React.createElement(PanelContext.Provider, {
|
|
78
|
+
value: info
|
|
79
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
80
|
+
className: panelPrefixCls
|
|
81
|
+
}, /*#__PURE__*/React.createElement(PanelHeader, {
|
|
82
|
+
superOffset: function superOffset(distance) {
|
|
83
|
+
return generateConfig.addYear(pickerValue, distance);
|
|
84
|
+
},
|
|
85
|
+
onChange: onPickerValueChange
|
|
86
|
+
// Limitation
|
|
87
|
+
,
|
|
88
|
+
getStart: function getStart(date) {
|
|
89
|
+
return generateConfig.setMonth(date, 0);
|
|
90
|
+
},
|
|
91
|
+
getEnd: function getEnd(date) {
|
|
92
|
+
return generateConfig.setMonth(date, 11);
|
|
93
|
+
}
|
|
94
|
+
}, yearNode), /*#__PURE__*/React.createElement(PanelBody, _extends({}, props, {
|
|
95
|
+
disabledDate: mergedDisabledDate,
|
|
96
|
+
titleFormat: locale.fieldMonthFormat,
|
|
97
|
+
colNum: 3,
|
|
98
|
+
rowNum: 4,
|
|
99
|
+
baseDate: baseDate
|
|
100
|
+
// Body
|
|
101
|
+
,
|
|
102
|
+
getCellDate: getCellDate,
|
|
103
|
+
getCellText: getCellText,
|
|
104
|
+
getCellClassName: getCellClassName
|
|
105
|
+
}))));
|
|
106
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { DisabledDate } from '../interface';
|
|
3
|
+
export interface PanelBodyProps<DateType = any> {
|
|
4
|
+
rowNum: number;
|
|
5
|
+
colNum: number;
|
|
6
|
+
baseDate: DateType;
|
|
7
|
+
titleFormat?: string;
|
|
8
|
+
getCellDate: (date: DateType, offset: number) => DateType;
|
|
9
|
+
getCellText: (date: DateType) => React.ReactNode;
|
|
10
|
+
getCellClassName: (date: DateType) => Record<string, any>;
|
|
11
|
+
disabledDate?: DisabledDate<DateType>;
|
|
12
|
+
headerCells?: React.ReactNode[];
|
|
13
|
+
prefixColumn?: (date: DateType) => React.ReactNode;
|
|
14
|
+
rowClassName?: (date: DateType) => string;
|
|
15
|
+
cellSelection?: boolean;
|
|
16
|
+
}
|
|
17
|
+
export default function PanelBody<DateType extends object = any>(props: PanelBodyProps<DateType>): React.JSX.Element;
|
|
@@ -0,0 +1,153 @@
|
|
|
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 ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
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; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
|
+
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); }
|
|
7
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
8
|
+
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."); }
|
|
9
|
+
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); }
|
|
10
|
+
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; }
|
|
11
|
+
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; } }
|
|
12
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
13
|
+
import classNames from 'classnames';
|
|
14
|
+
import * as React from 'react';
|
|
15
|
+
import { formatValue, isInRange, isSame } from "../utils/dateUtil";
|
|
16
|
+
import { PickerHackContext, usePanelContext } from "./context";
|
|
17
|
+
export default function PanelBody(props) {
|
|
18
|
+
var rowNum = props.rowNum,
|
|
19
|
+
colNum = props.colNum,
|
|
20
|
+
baseDate = props.baseDate,
|
|
21
|
+
getCellDate = props.getCellDate,
|
|
22
|
+
prefixColumn = props.prefixColumn,
|
|
23
|
+
rowClassName = props.rowClassName,
|
|
24
|
+
titleFormat = props.titleFormat,
|
|
25
|
+
getCellText = props.getCellText,
|
|
26
|
+
getCellClassName = props.getCellClassName,
|
|
27
|
+
headerCells = props.headerCells,
|
|
28
|
+
_props$cellSelection = props.cellSelection,
|
|
29
|
+
cellSelection = _props$cellSelection === void 0 ? true : _props$cellSelection,
|
|
30
|
+
disabledDate = props.disabledDate;
|
|
31
|
+
var _usePanelContext = usePanelContext(),
|
|
32
|
+
prefixCls = _usePanelContext.prefixCls,
|
|
33
|
+
type = _usePanelContext.panelType,
|
|
34
|
+
now = _usePanelContext.now,
|
|
35
|
+
contextDisabledDate = _usePanelContext.disabledDate,
|
|
36
|
+
cellRender = _usePanelContext.cellRender,
|
|
37
|
+
onHover = _usePanelContext.onHover,
|
|
38
|
+
hoverValue = _usePanelContext.hoverValue,
|
|
39
|
+
hoverRangeValue = _usePanelContext.hoverRangeValue,
|
|
40
|
+
generateConfig = _usePanelContext.generateConfig,
|
|
41
|
+
values = _usePanelContext.values,
|
|
42
|
+
locale = _usePanelContext.locale,
|
|
43
|
+
onSelect = _usePanelContext.onSelect;
|
|
44
|
+
var mergedDisabledDate = disabledDate || contextDisabledDate;
|
|
45
|
+
var cellPrefixCls = "".concat(prefixCls, "-cell");
|
|
46
|
+
|
|
47
|
+
// ============================= Context ==============================
|
|
48
|
+
var _React$useContext = React.useContext(PickerHackContext),
|
|
49
|
+
onCellDblClick = _React$useContext.onCellDblClick;
|
|
50
|
+
|
|
51
|
+
// ============================== Value ===============================
|
|
52
|
+
var matchValues = function matchValues(date) {
|
|
53
|
+
return values.some(function (singleValue) {
|
|
54
|
+
return singleValue && isSame(generateConfig, locale, date, singleValue, type);
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
// =============================== Body ===============================
|
|
59
|
+
var rows = [];
|
|
60
|
+
for (var row = 0; row < rowNum; row += 1) {
|
|
61
|
+
var rowNode = [];
|
|
62
|
+
var rowStartDate = void 0;
|
|
63
|
+
var _loop = function _loop() {
|
|
64
|
+
var offset = row * colNum + col;
|
|
65
|
+
var currentDate = getCellDate(baseDate, offset);
|
|
66
|
+
var disabled = mergedDisabledDate === null || mergedDisabledDate === void 0 ? void 0 : mergedDisabledDate(currentDate, {
|
|
67
|
+
type: type
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
// Row Start Cell
|
|
71
|
+
if (col === 0) {
|
|
72
|
+
rowStartDate = currentDate;
|
|
73
|
+
if (prefixColumn) {
|
|
74
|
+
rowNode.push(prefixColumn(rowStartDate));
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// Range
|
|
79
|
+
var inRange = false;
|
|
80
|
+
var rangeStart = false;
|
|
81
|
+
var rangeEnd = false;
|
|
82
|
+
if (cellSelection && hoverRangeValue) {
|
|
83
|
+
var _hoverRangeValue = _slicedToArray(hoverRangeValue, 2),
|
|
84
|
+
hoverStart = _hoverRangeValue[0],
|
|
85
|
+
hoverEnd = _hoverRangeValue[1];
|
|
86
|
+
inRange = isInRange(generateConfig, hoverStart, hoverEnd, currentDate);
|
|
87
|
+
rangeStart = isSame(generateConfig, locale, currentDate, hoverStart, type);
|
|
88
|
+
rangeEnd = isSame(generateConfig, locale, currentDate, hoverEnd, type);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// Title
|
|
92
|
+
var title = titleFormat ? formatValue(currentDate, {
|
|
93
|
+
locale: locale,
|
|
94
|
+
format: titleFormat,
|
|
95
|
+
generateConfig: generateConfig
|
|
96
|
+
}) : undefined;
|
|
97
|
+
|
|
98
|
+
// Render
|
|
99
|
+
var inner = /*#__PURE__*/React.createElement("div", {
|
|
100
|
+
className: "".concat(cellPrefixCls, "-inner")
|
|
101
|
+
}, getCellText(currentDate));
|
|
102
|
+
rowNode.push( /*#__PURE__*/React.createElement("td", {
|
|
103
|
+
key: col,
|
|
104
|
+
title: title,
|
|
105
|
+
className: classNames(cellPrefixCls, _objectSpread(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, "".concat(cellPrefixCls, "-disabled"), disabled), "".concat(cellPrefixCls, "-hover"), (hoverValue || []).some(function (date) {
|
|
106
|
+
return isSame(generateConfig, locale, currentDate, date, type);
|
|
107
|
+
})), "".concat(cellPrefixCls, "-in-range"), inRange && !rangeStart && !rangeEnd), "".concat(cellPrefixCls, "-range-start"), rangeStart), "".concat(cellPrefixCls, "-range-end"), rangeEnd), "".concat(prefixCls, "-cell-selected"), !hoverRangeValue &&
|
|
108
|
+
// WeekPicker use row instead
|
|
109
|
+
type !== 'week' && matchValues(currentDate)), getCellClassName(currentDate))),
|
|
110
|
+
onClick: function onClick() {
|
|
111
|
+
if (!disabled) {
|
|
112
|
+
onSelect(currentDate);
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
onDoubleClick: function onDoubleClick() {
|
|
116
|
+
if (!disabled && onCellDblClick) {
|
|
117
|
+
onCellDblClick();
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
onMouseEnter: function onMouseEnter() {
|
|
121
|
+
if (!disabled) {
|
|
122
|
+
onHover === null || onHover === void 0 || onHover(currentDate);
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
onMouseLeave: function onMouseLeave() {
|
|
126
|
+
if (!disabled) {
|
|
127
|
+
onHover === null || onHover === void 0 || onHover(null);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}, cellRender ? cellRender(currentDate, {
|
|
131
|
+
prefixCls: prefixCls,
|
|
132
|
+
originNode: inner,
|
|
133
|
+
today: now,
|
|
134
|
+
type: type,
|
|
135
|
+
locale: locale
|
|
136
|
+
}) : inner));
|
|
137
|
+
};
|
|
138
|
+
for (var col = 0; col < colNum; col += 1) {
|
|
139
|
+
_loop();
|
|
140
|
+
}
|
|
141
|
+
rows.push( /*#__PURE__*/React.createElement("tr", {
|
|
142
|
+
key: row,
|
|
143
|
+
className: rowClassName === null || rowClassName === void 0 ? void 0 : rowClassName(rowStartDate)
|
|
144
|
+
}, rowNode));
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// ============================== Render ==============================
|
|
148
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
149
|
+
className: "".concat(prefixCls, "-body")
|
|
150
|
+
}, /*#__PURE__*/React.createElement("table", {
|
|
151
|
+
className: "".concat(prefixCls, "-content")
|
|
152
|
+
}, headerCells && /*#__PURE__*/React.createElement("thead", null, /*#__PURE__*/React.createElement("tr", null, headerCells)), /*#__PURE__*/React.createElement("tbody", null, rows)));
|
|
153
|
+
}
|