@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,553 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _util = require("@rc-component/util");
|
|
9
|
+
var _useLayoutEffect = _interopRequireDefault(require("@rc-component/util/lib/hooks/useLayoutEffect"));
|
|
10
|
+
var _omit = _interopRequireDefault(require("@rc-component/util/lib/omit"));
|
|
11
|
+
var _pickAttrs = _interopRequireDefault(require("@rc-component/util/lib/pickAttrs"));
|
|
12
|
+
var React = _interopRequireWildcard(require("react"));
|
|
13
|
+
var _useToggleDates = _interopRequireDefault(require("../hooks/useToggleDates"));
|
|
14
|
+
var _PickerTrigger = _interopRequireDefault(require("../PickerTrigger"));
|
|
15
|
+
var _util2 = require("../PickerTrigger/util");
|
|
16
|
+
var _miscUtil = require("../utils/miscUtil");
|
|
17
|
+
var _context = _interopRequireDefault(require("./context"));
|
|
18
|
+
var _useCellRender = _interopRequireDefault(require("./hooks/useCellRender"));
|
|
19
|
+
var _useFieldsInvalidate3 = _interopRequireDefault(require("./hooks/useFieldsInvalidate"));
|
|
20
|
+
var _useFilledProps3 = _interopRequireDefault(require("./hooks/useFilledProps"));
|
|
21
|
+
var _useOpen3 = _interopRequireDefault(require("./hooks/useOpen"));
|
|
22
|
+
var _usePickerRef = _interopRequireDefault(require("./hooks/usePickerRef"));
|
|
23
|
+
var _usePresets = _interopRequireDefault(require("./hooks/usePresets"));
|
|
24
|
+
var _useRangeActive3 = _interopRequireDefault(require("./hooks/useRangeActive"));
|
|
25
|
+
var _useRangePickerValue3 = _interopRequireDefault(require("./hooks/useRangePickerValue"));
|
|
26
|
+
var _useRangeValue3 = _interopRequireWildcard(require("./hooks/useRangeValue"));
|
|
27
|
+
var _useShowNow = _interopRequireDefault(require("./hooks/useShowNow"));
|
|
28
|
+
var _Popup = _interopRequireDefault(require("./Popup"));
|
|
29
|
+
var _SingleSelector = _interopRequireDefault(require("./Selector/SingleSelector"));
|
|
30
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
31
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
32
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
33
|
+
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); }
|
|
34
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
35
|
+
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."); }
|
|
36
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
37
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
38
|
+
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; }
|
|
39
|
+
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; }
|
|
40
|
+
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; }
|
|
41
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
42
|
+
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); }
|
|
43
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
44
|
+
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."); }
|
|
45
|
+
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); }
|
|
46
|
+
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; }
|
|
47
|
+
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; } }
|
|
48
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
49
|
+
// TODO: isInvalidateDate with showTime.disabledTime should not provide `range` prop
|
|
50
|
+
|
|
51
|
+
/** Internal usage. For cross function get same aligned props */
|
|
52
|
+
|
|
53
|
+
function Picker(props, ref) {
|
|
54
|
+
// ========================= Prop =========================
|
|
55
|
+
var _useFilledProps = (0, _useFilledProps3.default)(props),
|
|
56
|
+
_useFilledProps2 = _slicedToArray(_useFilledProps, 6),
|
|
57
|
+
filledProps = _useFilledProps2[0],
|
|
58
|
+
internalPicker = _useFilledProps2[1],
|
|
59
|
+
complexPicker = _useFilledProps2[2],
|
|
60
|
+
formatList = _useFilledProps2[3],
|
|
61
|
+
maskFormat = _useFilledProps2[4],
|
|
62
|
+
isInvalidateDate = _useFilledProps2[5];
|
|
63
|
+
var _ref = filledProps,
|
|
64
|
+
prefixCls = _ref.prefixCls,
|
|
65
|
+
styles = _ref.styles,
|
|
66
|
+
classNames = _ref.classNames,
|
|
67
|
+
order = _ref.order,
|
|
68
|
+
defaultValue = _ref.defaultValue,
|
|
69
|
+
value = _ref.value,
|
|
70
|
+
needConfirm = _ref.needConfirm,
|
|
71
|
+
onChange = _ref.onChange,
|
|
72
|
+
onKeyDown = _ref.onKeyDown,
|
|
73
|
+
disabled = _ref.disabled,
|
|
74
|
+
disabledDate = _ref.disabledDate,
|
|
75
|
+
minDate = _ref.minDate,
|
|
76
|
+
maxDate = _ref.maxDate,
|
|
77
|
+
defaultOpen = _ref.defaultOpen,
|
|
78
|
+
open = _ref.open,
|
|
79
|
+
onOpenChange = _ref.onOpenChange,
|
|
80
|
+
locale = _ref.locale,
|
|
81
|
+
generateConfig = _ref.generateConfig,
|
|
82
|
+
picker = _ref.picker,
|
|
83
|
+
showNow = _ref.showNow,
|
|
84
|
+
showToday = _ref.showToday,
|
|
85
|
+
showTime = _ref.showTime,
|
|
86
|
+
mode = _ref.mode,
|
|
87
|
+
onPanelChange = _ref.onPanelChange,
|
|
88
|
+
onCalendarChange = _ref.onCalendarChange,
|
|
89
|
+
onOk = _ref.onOk,
|
|
90
|
+
multiple = _ref.multiple,
|
|
91
|
+
defaultPickerValue = _ref.defaultPickerValue,
|
|
92
|
+
pickerValue = _ref.pickerValue,
|
|
93
|
+
onPickerValueChange = _ref.onPickerValueChange,
|
|
94
|
+
inputReadOnly = _ref.inputReadOnly,
|
|
95
|
+
suffixIcon = _ref.suffixIcon,
|
|
96
|
+
removeIcon = _ref.removeIcon,
|
|
97
|
+
onFocus = _ref.onFocus,
|
|
98
|
+
onBlur = _ref.onBlur,
|
|
99
|
+
presets = _ref.presets,
|
|
100
|
+
components = _ref.components,
|
|
101
|
+
cellRender = _ref.cellRender,
|
|
102
|
+
dateRender = _ref.dateRender,
|
|
103
|
+
monthCellRender = _ref.monthCellRender,
|
|
104
|
+
onClick = _ref.onClick;
|
|
105
|
+
|
|
106
|
+
// ========================= Refs =========================
|
|
107
|
+
var selectorRef = (0, _usePickerRef.default)(ref);
|
|
108
|
+
|
|
109
|
+
// ========================= Util =========================
|
|
110
|
+
function pickerParam(values) {
|
|
111
|
+
if (values === null) {
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
return multiple ? values : values[0];
|
|
115
|
+
}
|
|
116
|
+
var toggleDates = (0, _useToggleDates.default)(generateConfig, locale, internalPicker);
|
|
117
|
+
|
|
118
|
+
// ========================= Open =========================
|
|
119
|
+
var _useOpen = (0, _useOpen3.default)(open, defaultOpen, [disabled], onOpenChange),
|
|
120
|
+
_useOpen2 = _slicedToArray(_useOpen, 2),
|
|
121
|
+
mergedOpen = _useOpen2[0],
|
|
122
|
+
triggerOpen = _useOpen2[1];
|
|
123
|
+
|
|
124
|
+
// ======================= Calendar =======================
|
|
125
|
+
var onInternalCalendarChange = function onInternalCalendarChange(dates, dateStrings, info) {
|
|
126
|
+
if (onCalendarChange) {
|
|
127
|
+
var filteredInfo = _objectSpread({}, info);
|
|
128
|
+
delete filteredInfo.range;
|
|
129
|
+
onCalendarChange(pickerParam(dates), pickerParam(dateStrings), filteredInfo);
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
var onInternalOk = function onInternalOk(dates) {
|
|
133
|
+
onOk === null || onOk === void 0 || onOk(pickerParam(dates));
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
// ======================== Values ========================
|
|
137
|
+
var _useInnerValue = (0, _useRangeValue3.useInnerValue)(generateConfig, locale, formatList, false, order, defaultValue, value, onInternalCalendarChange, onInternalOk),
|
|
138
|
+
_useInnerValue2 = _slicedToArray(_useInnerValue, 5),
|
|
139
|
+
mergedValue = _useInnerValue2[0],
|
|
140
|
+
setInnerValue = _useInnerValue2[1],
|
|
141
|
+
getCalendarValue = _useInnerValue2[2],
|
|
142
|
+
triggerCalendarChange = _useInnerValue2[3],
|
|
143
|
+
triggerOk = _useInnerValue2[4];
|
|
144
|
+
var calendarValue = getCalendarValue();
|
|
145
|
+
|
|
146
|
+
// ======================== Active ========================
|
|
147
|
+
// In SinglePicker, we will always get `activeIndex` is 0.
|
|
148
|
+
var _useRangeActive = (0, _useRangeActive3.default)([disabled]),
|
|
149
|
+
_useRangeActive2 = _slicedToArray(_useRangeActive, 4),
|
|
150
|
+
focused = _useRangeActive2[0],
|
|
151
|
+
triggerFocus = _useRangeActive2[1],
|
|
152
|
+
lastOperation = _useRangeActive2[2],
|
|
153
|
+
activeIndex = _useRangeActive2[3];
|
|
154
|
+
var onSharedFocus = function onSharedFocus(event) {
|
|
155
|
+
triggerFocus(true);
|
|
156
|
+
onFocus === null || onFocus === void 0 || onFocus(event, {});
|
|
157
|
+
};
|
|
158
|
+
var onSharedBlur = function onSharedBlur(event) {
|
|
159
|
+
triggerFocus(false);
|
|
160
|
+
onBlur === null || onBlur === void 0 || onBlur(event, {});
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
// ========================= Mode =========================
|
|
164
|
+
var _useMergedState = (0, _util.useMergedState)(picker, {
|
|
165
|
+
value: mode
|
|
166
|
+
}),
|
|
167
|
+
_useMergedState2 = _slicedToArray(_useMergedState, 2),
|
|
168
|
+
mergedMode = _useMergedState2[0],
|
|
169
|
+
setMode = _useMergedState2[1];
|
|
170
|
+
|
|
171
|
+
/** Extends from `mergedMode` to patch `datetime` mode */
|
|
172
|
+
var internalMode = mergedMode === 'date' && showTime ? 'datetime' : mergedMode;
|
|
173
|
+
|
|
174
|
+
// ======================= Show Now =======================
|
|
175
|
+
var mergedShowNow = (0, _useShowNow.default)(picker, mergedMode, showNow, showToday);
|
|
176
|
+
|
|
177
|
+
// ======================== Value =========================
|
|
178
|
+
var onInternalChange = onChange && function (dates, dateStrings) {
|
|
179
|
+
onChange(pickerParam(dates), pickerParam(dateStrings));
|
|
180
|
+
};
|
|
181
|
+
var _useRangeValue = (0, _useRangeValue3.default)(_objectSpread(_objectSpread({}, filledProps), {}, {
|
|
182
|
+
onChange: onInternalChange
|
|
183
|
+
}), mergedValue, setInnerValue, getCalendarValue, triggerCalendarChange, [],
|
|
184
|
+
//disabled,
|
|
185
|
+
formatList, focused, mergedOpen, isInvalidateDate),
|
|
186
|
+
_useRangeValue2 = _slicedToArray(_useRangeValue, 2),
|
|
187
|
+
/** Trigger `onChange` directly without check `disabledDate` */
|
|
188
|
+
triggerSubmitChange = _useRangeValue2[1];
|
|
189
|
+
|
|
190
|
+
// ======================= Validate =======================
|
|
191
|
+
var _useFieldsInvalidate = (0, _useFieldsInvalidate3.default)(calendarValue, isInvalidateDate),
|
|
192
|
+
_useFieldsInvalidate2 = _slicedToArray(_useFieldsInvalidate, 2),
|
|
193
|
+
submitInvalidates = _useFieldsInvalidate2[0],
|
|
194
|
+
onSelectorInvalid = _useFieldsInvalidate2[1];
|
|
195
|
+
var submitInvalidate = React.useMemo(function () {
|
|
196
|
+
return submitInvalidates.some(function (invalidated) {
|
|
197
|
+
return invalidated;
|
|
198
|
+
});
|
|
199
|
+
}, [submitInvalidates]);
|
|
200
|
+
|
|
201
|
+
// ===================== Picker Value =====================
|
|
202
|
+
// Proxy to single pickerValue
|
|
203
|
+
var onInternalPickerValueChange = function onInternalPickerValueChange(dates, info) {
|
|
204
|
+
if (onPickerValueChange) {
|
|
205
|
+
var cleanInfo = _objectSpread(_objectSpread({}, info), {}, {
|
|
206
|
+
mode: info.mode[0]
|
|
207
|
+
});
|
|
208
|
+
delete cleanInfo.range;
|
|
209
|
+
onPickerValueChange(dates[0], cleanInfo);
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
var _useRangePickerValue = (0, _useRangePickerValue3.default)(generateConfig, locale, calendarValue, [mergedMode], mergedOpen, activeIndex, internalPicker, false,
|
|
213
|
+
// multiplePanel,
|
|
214
|
+
defaultPickerValue, pickerValue, (0, _miscUtil.toArray)(showTime === null || showTime === void 0 ? void 0 : showTime.defaultOpenValue), onInternalPickerValueChange, minDate, maxDate),
|
|
215
|
+
_useRangePickerValue2 = _slicedToArray(_useRangePickerValue, 2),
|
|
216
|
+
currentPickerValue = _useRangePickerValue2[0],
|
|
217
|
+
setCurrentPickerValue = _useRangePickerValue2[1];
|
|
218
|
+
|
|
219
|
+
// >>> Mode need wait for `pickerValue`
|
|
220
|
+
var triggerModeChange = (0, _util.useEvent)(function (nextPickerValue, nextMode, triggerEvent) {
|
|
221
|
+
setMode(nextMode);
|
|
222
|
+
|
|
223
|
+
// Compatible with `onPanelChange`
|
|
224
|
+
if (onPanelChange && triggerEvent !== false) {
|
|
225
|
+
var lastPickerValue = nextPickerValue || calendarValue[calendarValue.length - 1];
|
|
226
|
+
onPanelChange(lastPickerValue, nextMode);
|
|
227
|
+
}
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
// ======================== Submit ========================
|
|
231
|
+
/**
|
|
232
|
+
* Different with RangePicker, confirm should check `multiple` logic.
|
|
233
|
+
* This will never provide `date` instead.
|
|
234
|
+
*/
|
|
235
|
+
var triggerConfirm = function triggerConfirm() {
|
|
236
|
+
triggerSubmitChange(getCalendarValue());
|
|
237
|
+
triggerOpen(false, {
|
|
238
|
+
force: true
|
|
239
|
+
});
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
// ======================== Click =========================
|
|
243
|
+
var onSelectorClick = function onSelectorClick(event) {
|
|
244
|
+
if (!disabled && !selectorRef.current.nativeElement.contains(document.activeElement)) {
|
|
245
|
+
// Click to focus the enabled input
|
|
246
|
+
selectorRef.current.focus();
|
|
247
|
+
}
|
|
248
|
+
triggerOpen(true);
|
|
249
|
+
onClick === null || onClick === void 0 || onClick(event);
|
|
250
|
+
};
|
|
251
|
+
var onSelectorClear = function onSelectorClear() {
|
|
252
|
+
triggerSubmitChange(null);
|
|
253
|
+
triggerOpen(false, {
|
|
254
|
+
force: true
|
|
255
|
+
});
|
|
256
|
+
};
|
|
257
|
+
|
|
258
|
+
// ======================== Hover =========================
|
|
259
|
+
var _React$useState = React.useState(null),
|
|
260
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
261
|
+
hoverSource = _React$useState2[0],
|
|
262
|
+
setHoverSource = _React$useState2[1];
|
|
263
|
+
var _React$useState3 = React.useState(null),
|
|
264
|
+
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
265
|
+
internalHoverValue = _React$useState4[0],
|
|
266
|
+
setInternalHoverValue = _React$useState4[1];
|
|
267
|
+
var hoverValues = React.useMemo(function () {
|
|
268
|
+
var values = [internalHoverValue].concat(_toConsumableArray(calendarValue)).filter(function (date) {
|
|
269
|
+
return date;
|
|
270
|
+
});
|
|
271
|
+
return multiple ? values : values.slice(0, 1);
|
|
272
|
+
}, [calendarValue, internalHoverValue, multiple]);
|
|
273
|
+
|
|
274
|
+
// Selector values is different with RangePicker
|
|
275
|
+
// which can not use `hoverValue` directly
|
|
276
|
+
var selectorValues = React.useMemo(function () {
|
|
277
|
+
if (!multiple && internalHoverValue) {
|
|
278
|
+
return [internalHoverValue];
|
|
279
|
+
}
|
|
280
|
+
return calendarValue.filter(function (date) {
|
|
281
|
+
return date;
|
|
282
|
+
});
|
|
283
|
+
}, [calendarValue, internalHoverValue, multiple]);
|
|
284
|
+
|
|
285
|
+
// Clean up `internalHoverValues` when closed
|
|
286
|
+
React.useEffect(function () {
|
|
287
|
+
if (!mergedOpen) {
|
|
288
|
+
setInternalHoverValue(null);
|
|
289
|
+
}
|
|
290
|
+
}, [mergedOpen]);
|
|
291
|
+
|
|
292
|
+
// ========================================================
|
|
293
|
+
// == Panels ==
|
|
294
|
+
// ========================================================
|
|
295
|
+
// ======================= Presets ========================
|
|
296
|
+
var presetList = (0, _usePresets.default)(presets);
|
|
297
|
+
var onPresetHover = function onPresetHover(nextValue) {
|
|
298
|
+
setInternalHoverValue(nextValue);
|
|
299
|
+
setHoverSource('preset');
|
|
300
|
+
};
|
|
301
|
+
|
|
302
|
+
// TODO: handle this
|
|
303
|
+
var onPresetSubmit = function onPresetSubmit(nextValue) {
|
|
304
|
+
var nextCalendarValues = multiple ? toggleDates(getCalendarValue(), nextValue) : [nextValue];
|
|
305
|
+
var passed = triggerSubmitChange(nextCalendarValues);
|
|
306
|
+
if (passed && !multiple) {
|
|
307
|
+
triggerOpen(false, {
|
|
308
|
+
force: true
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
};
|
|
312
|
+
var onNow = function onNow(now) {
|
|
313
|
+
onPresetSubmit(now);
|
|
314
|
+
};
|
|
315
|
+
|
|
316
|
+
// ======================== Panel =========================
|
|
317
|
+
var onPanelHover = function onPanelHover(date) {
|
|
318
|
+
setInternalHoverValue(date);
|
|
319
|
+
setHoverSource('cell');
|
|
320
|
+
};
|
|
321
|
+
|
|
322
|
+
// >>> Focus
|
|
323
|
+
var onPanelFocus = function onPanelFocus(event) {
|
|
324
|
+
triggerOpen(true);
|
|
325
|
+
onSharedFocus(event);
|
|
326
|
+
};
|
|
327
|
+
|
|
328
|
+
// >>> Calendar
|
|
329
|
+
var onPanelSelect = function onPanelSelect(date) {
|
|
330
|
+
lastOperation('panel');
|
|
331
|
+
|
|
332
|
+
// Not change values if multiple and current panel is to match with picker
|
|
333
|
+
if (multiple && internalMode !== picker) {
|
|
334
|
+
return;
|
|
335
|
+
}
|
|
336
|
+
var nextValues = multiple ? toggleDates(getCalendarValue(), date) : [date];
|
|
337
|
+
|
|
338
|
+
// Only trigger calendar event but not update internal `calendarValue` state
|
|
339
|
+
triggerCalendarChange(nextValues);
|
|
340
|
+
|
|
341
|
+
// >>> Trigger next active if !needConfirm
|
|
342
|
+
// Fully logic check `useRangeValue` hook
|
|
343
|
+
if (!needConfirm && !complexPicker && internalPicker === internalMode) {
|
|
344
|
+
triggerConfirm();
|
|
345
|
+
}
|
|
346
|
+
};
|
|
347
|
+
|
|
348
|
+
// >>> Close
|
|
349
|
+
var onPopupClose = function onPopupClose() {
|
|
350
|
+
// Close popup
|
|
351
|
+
triggerOpen(false);
|
|
352
|
+
};
|
|
353
|
+
|
|
354
|
+
// >>> cellRender
|
|
355
|
+
var onInternalCellRender = (0, _useCellRender.default)(cellRender, dateRender, monthCellRender);
|
|
356
|
+
|
|
357
|
+
// >>> invalid
|
|
358
|
+
|
|
359
|
+
var panelProps = React.useMemo(function () {
|
|
360
|
+
var domProps = (0, _pickAttrs.default)(filledProps, false);
|
|
361
|
+
var restProps = (0, _omit.default)(filledProps, [].concat(_toConsumableArray(Object.keys(domProps)), ['onChange', 'onCalendarChange', 'style', 'className', 'onPanelChange']));
|
|
362
|
+
return _objectSpread(_objectSpread({}, restProps), {}, {
|
|
363
|
+
multiple: filledProps.multiple
|
|
364
|
+
});
|
|
365
|
+
}, [filledProps]);
|
|
366
|
+
|
|
367
|
+
// >>> Render
|
|
368
|
+
var panel = /*#__PURE__*/React.createElement(_Popup.default, _extends({}, panelProps, {
|
|
369
|
+
showNow: mergedShowNow,
|
|
370
|
+
showTime: showTime
|
|
371
|
+
// Disabled
|
|
372
|
+
,
|
|
373
|
+
disabledDate: disabledDate
|
|
374
|
+
// Focus
|
|
375
|
+
,
|
|
376
|
+
onFocus: onPanelFocus,
|
|
377
|
+
onBlur: onSharedBlur
|
|
378
|
+
// Mode
|
|
379
|
+
,
|
|
380
|
+
picker: picker,
|
|
381
|
+
mode: mergedMode,
|
|
382
|
+
internalMode: internalMode,
|
|
383
|
+
onPanelChange: triggerModeChange
|
|
384
|
+
// Value
|
|
385
|
+
,
|
|
386
|
+
format: maskFormat,
|
|
387
|
+
value: calendarValue,
|
|
388
|
+
isInvalid: isInvalidateDate,
|
|
389
|
+
onChange: null,
|
|
390
|
+
onSelect: onPanelSelect
|
|
391
|
+
// PickerValue
|
|
392
|
+
,
|
|
393
|
+
pickerValue: currentPickerValue,
|
|
394
|
+
defaultOpenValue: showTime === null || showTime === void 0 ? void 0 : showTime.defaultOpenValue,
|
|
395
|
+
onPickerValueChange: setCurrentPickerValue
|
|
396
|
+
// Hover
|
|
397
|
+
,
|
|
398
|
+
hoverValue: hoverValues,
|
|
399
|
+
onHover: onPanelHover
|
|
400
|
+
// Submit
|
|
401
|
+
,
|
|
402
|
+
needConfirm: needConfirm,
|
|
403
|
+
onSubmit: triggerConfirm,
|
|
404
|
+
onOk: triggerOk
|
|
405
|
+
// Preset
|
|
406
|
+
,
|
|
407
|
+
presets: presetList,
|
|
408
|
+
onPresetHover: onPresetHover,
|
|
409
|
+
onPresetSubmit: onPresetSubmit,
|
|
410
|
+
onNow: onNow
|
|
411
|
+
// Render
|
|
412
|
+
,
|
|
413
|
+
cellRender: onInternalCellRender
|
|
414
|
+
}));
|
|
415
|
+
|
|
416
|
+
// ========================================================
|
|
417
|
+
// == Selector ==
|
|
418
|
+
// ========================================================
|
|
419
|
+
|
|
420
|
+
// ======================== Change ========================
|
|
421
|
+
var onSelectorChange = function onSelectorChange(date) {
|
|
422
|
+
triggerCalendarChange(date);
|
|
423
|
+
};
|
|
424
|
+
var onSelectorInputChange = function onSelectorInputChange() {
|
|
425
|
+
lastOperation('input');
|
|
426
|
+
};
|
|
427
|
+
|
|
428
|
+
// ======================= Selector =======================
|
|
429
|
+
var onSelectorFocus = function onSelectorFocus(event) {
|
|
430
|
+
lastOperation('input');
|
|
431
|
+
triggerOpen(true, {
|
|
432
|
+
inherit: true
|
|
433
|
+
});
|
|
434
|
+
|
|
435
|
+
// setActiveIndex(index);
|
|
436
|
+
|
|
437
|
+
onSharedFocus(event);
|
|
438
|
+
};
|
|
439
|
+
var onSelectorBlur = function onSelectorBlur(event) {
|
|
440
|
+
triggerOpen(false);
|
|
441
|
+
onSharedBlur(event);
|
|
442
|
+
};
|
|
443
|
+
var onSelectorKeyDown = function onSelectorKeyDown(event, preventDefault) {
|
|
444
|
+
if (event.key === 'Tab') {
|
|
445
|
+
triggerConfirm();
|
|
446
|
+
}
|
|
447
|
+
onKeyDown === null || onKeyDown === void 0 || onKeyDown(event, preventDefault);
|
|
448
|
+
};
|
|
449
|
+
|
|
450
|
+
// ======================= Context ========================
|
|
451
|
+
var context = React.useMemo(function () {
|
|
452
|
+
return {
|
|
453
|
+
prefixCls: prefixCls,
|
|
454
|
+
locale: locale,
|
|
455
|
+
generateConfig: generateConfig,
|
|
456
|
+
button: components.button,
|
|
457
|
+
input: components.input
|
|
458
|
+
};
|
|
459
|
+
}, [prefixCls, locale, generateConfig, components.button, components.input]);
|
|
460
|
+
|
|
461
|
+
// ======================== Effect ========================
|
|
462
|
+
// >>> Mode
|
|
463
|
+
// Reset for every active
|
|
464
|
+
(0, _useLayoutEffect.default)(function () {
|
|
465
|
+
if (mergedOpen && activeIndex !== undefined) {
|
|
466
|
+
// Legacy compatible. This effect update should not trigger `onPanelChange`
|
|
467
|
+
triggerModeChange(null, picker, false);
|
|
468
|
+
}
|
|
469
|
+
}, [mergedOpen, activeIndex, picker]);
|
|
470
|
+
|
|
471
|
+
// >>> For complex picker, we need check if need to focus next one
|
|
472
|
+
(0, _useLayoutEffect.default)(function () {
|
|
473
|
+
var lastOp = lastOperation();
|
|
474
|
+
|
|
475
|
+
// Trade as confirm on field leave
|
|
476
|
+
if (!mergedOpen && lastOp === 'input') {
|
|
477
|
+
triggerOpen(false);
|
|
478
|
+
triggerConfirm();
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
// Submit with complex picker
|
|
482
|
+
if (!mergedOpen && complexPicker && !needConfirm && lastOp === 'panel') {
|
|
483
|
+
triggerOpen(true);
|
|
484
|
+
triggerConfirm();
|
|
485
|
+
}
|
|
486
|
+
}, [mergedOpen]);
|
|
487
|
+
|
|
488
|
+
// ======================== Render ========================
|
|
489
|
+
return /*#__PURE__*/React.createElement(_context.default.Provider, {
|
|
490
|
+
value: context
|
|
491
|
+
}, /*#__PURE__*/React.createElement(_PickerTrigger.default, _extends({}, (0, _util2.pickTriggerProps)(filledProps), {
|
|
492
|
+
popupElement: panel,
|
|
493
|
+
popupStyle: styles.popup,
|
|
494
|
+
popupClassName: classNames.popup
|
|
495
|
+
// Visible
|
|
496
|
+
,
|
|
497
|
+
visible: mergedOpen,
|
|
498
|
+
onClose: onPopupClose
|
|
499
|
+
}), /*#__PURE__*/React.createElement(_SingleSelector.default
|
|
500
|
+
// Shared
|
|
501
|
+
, _extends({}, filledProps, {
|
|
502
|
+
// Ref
|
|
503
|
+
ref: selectorRef
|
|
504
|
+
// Icon
|
|
505
|
+
,
|
|
506
|
+
suffixIcon: suffixIcon,
|
|
507
|
+
removeIcon: removeIcon
|
|
508
|
+
// Active
|
|
509
|
+
,
|
|
510
|
+
activeHelp: !!internalHoverValue,
|
|
511
|
+
allHelp: !!internalHoverValue && hoverSource === 'preset',
|
|
512
|
+
focused: focused,
|
|
513
|
+
onFocus: onSelectorFocus,
|
|
514
|
+
onBlur: onSelectorBlur,
|
|
515
|
+
onKeyDown: onSelectorKeyDown,
|
|
516
|
+
onSubmit: triggerConfirm
|
|
517
|
+
// Change
|
|
518
|
+
,
|
|
519
|
+
value: selectorValues,
|
|
520
|
+
maskFormat: maskFormat,
|
|
521
|
+
onChange: onSelectorChange,
|
|
522
|
+
onInputChange: onSelectorInputChange,
|
|
523
|
+
internalPicker: internalPicker
|
|
524
|
+
// Format
|
|
525
|
+
,
|
|
526
|
+
format: formatList,
|
|
527
|
+
inputReadOnly: inputReadOnly
|
|
528
|
+
// Disabled
|
|
529
|
+
,
|
|
530
|
+
disabled: disabled
|
|
531
|
+
// Open
|
|
532
|
+
,
|
|
533
|
+
open: mergedOpen,
|
|
534
|
+
onOpenChange: triggerOpen
|
|
535
|
+
// Click
|
|
536
|
+
,
|
|
537
|
+
onClick: onSelectorClick,
|
|
538
|
+
onClear: onSelectorClear
|
|
539
|
+
// Invalid
|
|
540
|
+
,
|
|
541
|
+
invalid: submitInvalidate,
|
|
542
|
+
onInvalid: function onInvalid(invalid) {
|
|
543
|
+
// Only `single` mode support type date.
|
|
544
|
+
// `multiple` mode can not typing.
|
|
545
|
+
onSelectorInvalid(invalid, 0);
|
|
546
|
+
}
|
|
547
|
+
}))));
|
|
548
|
+
}
|
|
549
|
+
var RefPicker = /*#__PURE__*/React.forwardRef(Picker);
|
|
550
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
551
|
+
RefPicker.displayName = 'RefPicker';
|
|
552
|
+
}
|
|
553
|
+
var _default = exports.default = RefPicker;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { GenerateConfig } from '../generate';
|
|
3
|
+
import type { Components, Locale } from '../interface';
|
|
4
|
+
export interface PickerContextProps<DateType = any> {
|
|
5
|
+
prefixCls: string;
|
|
6
|
+
locale: Locale;
|
|
7
|
+
generateConfig: GenerateConfig<DateType>;
|
|
8
|
+
/** Customize button component */
|
|
9
|
+
button?: Components['button'];
|
|
10
|
+
input?: Components['input'];
|
|
11
|
+
}
|
|
12
|
+
declare const PickerContext: React.Context<PickerContextProps<any>>;
|
|
13
|
+
export default PickerContext;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var React = _interopRequireWildcard(require("react"));
|
|
9
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
10
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
11
|
+
var PickerContext = /*#__PURE__*/React.createContext(null);
|
|
12
|
+
var _default = exports.default = PickerContext;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import type { CellRender, CellRenderInfo, SharedPickerProps } from '../../interface';
|
|
2
|
+
export default function useCellRender<DateType extends object = any>(cellRender: SharedPickerProps<DateType>['cellRender'], dateRender?: SharedPickerProps<DateType>['dateRender'], monthCellRender?: SharedPickerProps<DateType>['monthCellRender'], range?: CellRenderInfo<DateType>['range']): CellRender<DateType>;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = useCellRender;
|
|
7
|
+
var _util = require("@rc-component/util");
|
|
8
|
+
var React = _interopRequireWildcard(require("react"));
|
|
9
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
10
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
11
|
+
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); }
|
|
12
|
+
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; }
|
|
13
|
+
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; }
|
|
14
|
+
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; }
|
|
15
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
16
|
+
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); }
|
|
17
|
+
function useCellRender(cellRender, dateRender, monthCellRender, range) {
|
|
18
|
+
// ========================= Warn =========================
|
|
19
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
20
|
+
(0, _util.warning)(!dateRender, "'dateRender' is deprecated. Please use 'cellRender' instead.");
|
|
21
|
+
(0, _util.warning)(!monthCellRender, "'monthCellRender' is deprecated. Please use 'cellRender' instead.");
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// ======================== Render ========================
|
|
25
|
+
// Merged render
|
|
26
|
+
var mergedCellRender = React.useMemo(function () {
|
|
27
|
+
if (cellRender) {
|
|
28
|
+
return cellRender;
|
|
29
|
+
}
|
|
30
|
+
return function (current, info) {
|
|
31
|
+
var date = current;
|
|
32
|
+
if (dateRender && info.type === 'date') {
|
|
33
|
+
return dateRender(date, info.today);
|
|
34
|
+
}
|
|
35
|
+
if (monthCellRender && info.type === 'month') {
|
|
36
|
+
return monthCellRender(date, info.locale);
|
|
37
|
+
}
|
|
38
|
+
return info.originNode;
|
|
39
|
+
};
|
|
40
|
+
}, [cellRender, monthCellRender, dateRender]);
|
|
41
|
+
|
|
42
|
+
// Cell render
|
|
43
|
+
var onInternalCellRender = React.useCallback(function (date, info) {
|
|
44
|
+
return mergedCellRender(date, _objectSpread(_objectSpread({}, info), {}, {
|
|
45
|
+
range: range
|
|
46
|
+
}));
|
|
47
|
+
}, [mergedCellRender, range]);
|
|
48
|
+
return onInternalCellRender;
|
|
49
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Will be `true` immediately for next effect.
|
|
3
|
+
* But will be `false` for a delay of effect.
|
|
4
|
+
*/
|
|
5
|
+
export default function useDelayState<T>(value: T, defaultValue?: T, onChange?: (next: T) => void): [state: T, setState: (nextState: T, immediately?: boolean) => void];
|