@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,240 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
8
|
+
var _weekday = _interopRequireDefault(require("dayjs/plugin/weekday"));
|
|
9
|
+
var _localeData = _interopRequireDefault(require("dayjs/plugin/localeData"));
|
|
10
|
+
var _weekOfYear = _interopRequireDefault(require("dayjs/plugin/weekOfYear"));
|
|
11
|
+
var _weekYear = _interopRequireDefault(require("dayjs/plugin/weekYear"));
|
|
12
|
+
var _advancedFormat = _interopRequireDefault(require("dayjs/plugin/advancedFormat"));
|
|
13
|
+
var _customParseFormat = _interopRequireDefault(require("dayjs/plugin/customParseFormat"));
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
_dayjs.default.extend(_customParseFormat.default);
|
|
16
|
+
_dayjs.default.extend(_advancedFormat.default);
|
|
17
|
+
_dayjs.default.extend(_weekday.default);
|
|
18
|
+
_dayjs.default.extend(_localeData.default);
|
|
19
|
+
_dayjs.default.extend(_weekOfYear.default);
|
|
20
|
+
_dayjs.default.extend(_weekYear.default);
|
|
21
|
+
_dayjs.default.extend(function (o, c) {
|
|
22
|
+
// todo support Wo (ISO week)
|
|
23
|
+
var proto = c.prototype;
|
|
24
|
+
var oldFormat = proto.format;
|
|
25
|
+
proto.format = function f(formatStr) {
|
|
26
|
+
var str = (formatStr || '').replace('Wo', 'wo');
|
|
27
|
+
return oldFormat.bind(this)(str);
|
|
28
|
+
};
|
|
29
|
+
});
|
|
30
|
+
var localeMap = {
|
|
31
|
+
// ar_EG:
|
|
32
|
+
// az_AZ:
|
|
33
|
+
// bg_BG:
|
|
34
|
+
bn_BD: 'bn-bd',
|
|
35
|
+
by_BY: 'be',
|
|
36
|
+
// ca_ES:
|
|
37
|
+
// cs_CZ:
|
|
38
|
+
// da_DK:
|
|
39
|
+
// de_DE:
|
|
40
|
+
// el_GR:
|
|
41
|
+
en_GB: 'en-gb',
|
|
42
|
+
en_US: 'en',
|
|
43
|
+
// es_ES:
|
|
44
|
+
// et_EE:
|
|
45
|
+
// fa_IR:
|
|
46
|
+
// fi_FI:
|
|
47
|
+
fr_BE: 'fr',
|
|
48
|
+
// todo: dayjs has no fr_BE locale, use fr at present
|
|
49
|
+
fr_CA: 'fr-ca',
|
|
50
|
+
// fr_FR:
|
|
51
|
+
// ga_IE:
|
|
52
|
+
// gl_ES:
|
|
53
|
+
// he_IL:
|
|
54
|
+
// hi_IN:
|
|
55
|
+
// hr_HR:
|
|
56
|
+
// hu_HU:
|
|
57
|
+
hy_AM: 'hy-am',
|
|
58
|
+
// id_ID:
|
|
59
|
+
// is_IS:
|
|
60
|
+
// it_IT:
|
|
61
|
+
// ja_JP:
|
|
62
|
+
// ka_GE:
|
|
63
|
+
// kk_KZ:
|
|
64
|
+
// km_KH:
|
|
65
|
+
kmr_IQ: 'ku',
|
|
66
|
+
// kn_IN:
|
|
67
|
+
// ko_KR:
|
|
68
|
+
// ku_IQ: // previous ku in antd
|
|
69
|
+
// lt_LT:
|
|
70
|
+
// lv_LV:
|
|
71
|
+
// mk_MK:
|
|
72
|
+
// ml_IN:
|
|
73
|
+
// mn_MN:
|
|
74
|
+
// ms_MY:
|
|
75
|
+
// nb_NO:
|
|
76
|
+
// ne_NP:
|
|
77
|
+
nl_BE: 'nl-be',
|
|
78
|
+
// nl_NL:
|
|
79
|
+
// pl_PL:
|
|
80
|
+
pt_BR: 'pt-br',
|
|
81
|
+
// pt_PT:
|
|
82
|
+
// ro_RO:
|
|
83
|
+
// ru_RU:
|
|
84
|
+
// sk_SK:
|
|
85
|
+
// sl_SI:
|
|
86
|
+
// sr_RS:
|
|
87
|
+
// sv_SE:
|
|
88
|
+
// ta_IN:
|
|
89
|
+
// th_TH:
|
|
90
|
+
// tr_TR:
|
|
91
|
+
// uk_UA:
|
|
92
|
+
// ur_PK:
|
|
93
|
+
// vi_VN:
|
|
94
|
+
zh_CN: 'zh-cn',
|
|
95
|
+
zh_HK: 'zh-hk',
|
|
96
|
+
zh_TW: 'zh-tw'
|
|
97
|
+
};
|
|
98
|
+
var parseLocale = function parseLocale(locale) {
|
|
99
|
+
var mapLocale = localeMap[locale];
|
|
100
|
+
return mapLocale || locale.split('_')[0];
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
/* istanbul ignore next */
|
|
104
|
+
var parseNoMatchNotice = function parseNoMatchNotice() {
|
|
105
|
+
// zombieJ:
|
|
106
|
+
// When user typing, its always miss match format.
|
|
107
|
+
// This check is meaningless.
|
|
108
|
+
// https://github.com/ant-design/ant-design/issues/51839
|
|
109
|
+
// noteOnce(false, 'Not match any format. Please help to fire a issue about this.');
|
|
110
|
+
};
|
|
111
|
+
var generateConfig = {
|
|
112
|
+
// get
|
|
113
|
+
getNow: function getNow() {
|
|
114
|
+
var now = (0, _dayjs.default)();
|
|
115
|
+
// https://github.com/ant-design/ant-design/discussions/50934
|
|
116
|
+
if (typeof now.tz === 'function') {
|
|
117
|
+
return now.tz(); // use default timezone
|
|
118
|
+
}
|
|
119
|
+
return now;
|
|
120
|
+
},
|
|
121
|
+
getFixedDate: function getFixedDate(string) {
|
|
122
|
+
return (0, _dayjs.default)(string, ['YYYY-M-DD', 'YYYY-MM-DD']);
|
|
123
|
+
},
|
|
124
|
+
getEndDate: function getEndDate(date) {
|
|
125
|
+
return date.endOf('month');
|
|
126
|
+
},
|
|
127
|
+
getWeekDay: function getWeekDay(date) {
|
|
128
|
+
var clone = date.locale('en');
|
|
129
|
+
return clone.weekday() + clone.localeData().firstDayOfWeek();
|
|
130
|
+
},
|
|
131
|
+
getYear: function getYear(date) {
|
|
132
|
+
return date.year();
|
|
133
|
+
},
|
|
134
|
+
getMonth: function getMonth(date) {
|
|
135
|
+
return date.month();
|
|
136
|
+
},
|
|
137
|
+
getDate: function getDate(date) {
|
|
138
|
+
return date.date();
|
|
139
|
+
},
|
|
140
|
+
getHour: function getHour(date) {
|
|
141
|
+
return date.hour();
|
|
142
|
+
},
|
|
143
|
+
getMinute: function getMinute(date) {
|
|
144
|
+
return date.minute();
|
|
145
|
+
},
|
|
146
|
+
getSecond: function getSecond(date) {
|
|
147
|
+
return date.second();
|
|
148
|
+
},
|
|
149
|
+
getMillisecond: function getMillisecond(date) {
|
|
150
|
+
return date.millisecond();
|
|
151
|
+
},
|
|
152
|
+
// set
|
|
153
|
+
addYear: function addYear(date, diff) {
|
|
154
|
+
return date.add(diff, 'year');
|
|
155
|
+
},
|
|
156
|
+
addMonth: function addMonth(date, diff) {
|
|
157
|
+
return date.add(diff, 'month');
|
|
158
|
+
},
|
|
159
|
+
addDate: function addDate(date, diff) {
|
|
160
|
+
return date.add(diff, 'day');
|
|
161
|
+
},
|
|
162
|
+
setYear: function setYear(date, year) {
|
|
163
|
+
return date.year(year);
|
|
164
|
+
},
|
|
165
|
+
setMonth: function setMonth(date, month) {
|
|
166
|
+
return date.month(month);
|
|
167
|
+
},
|
|
168
|
+
setDate: function setDate(date, num) {
|
|
169
|
+
return date.date(num);
|
|
170
|
+
},
|
|
171
|
+
setHour: function setHour(date, hour) {
|
|
172
|
+
return date.hour(hour);
|
|
173
|
+
},
|
|
174
|
+
setMinute: function setMinute(date, minute) {
|
|
175
|
+
return date.minute(minute);
|
|
176
|
+
},
|
|
177
|
+
setSecond: function setSecond(date, second) {
|
|
178
|
+
return date.second(second);
|
|
179
|
+
},
|
|
180
|
+
setMillisecond: function setMillisecond(date, milliseconds) {
|
|
181
|
+
return date.millisecond(milliseconds);
|
|
182
|
+
},
|
|
183
|
+
// Compare
|
|
184
|
+
isAfter: function isAfter(date1, date2) {
|
|
185
|
+
return date1.isAfter(date2);
|
|
186
|
+
},
|
|
187
|
+
isValidate: function isValidate(date) {
|
|
188
|
+
return date.isValid();
|
|
189
|
+
},
|
|
190
|
+
locale: {
|
|
191
|
+
getWeekFirstDay: function getWeekFirstDay(locale) {
|
|
192
|
+
return (0, _dayjs.default)().locale(parseLocale(locale)).localeData().firstDayOfWeek();
|
|
193
|
+
},
|
|
194
|
+
getWeekFirstDate: function getWeekFirstDate(locale, date) {
|
|
195
|
+
return date.locale(parseLocale(locale)).weekday(0);
|
|
196
|
+
},
|
|
197
|
+
getWeek: function getWeek(locale, date) {
|
|
198
|
+
return date.locale(parseLocale(locale)).week();
|
|
199
|
+
},
|
|
200
|
+
getShortWeekDays: function getShortWeekDays(locale) {
|
|
201
|
+
return (0, _dayjs.default)().locale(parseLocale(locale)).localeData().weekdaysMin();
|
|
202
|
+
},
|
|
203
|
+
getShortMonths: function getShortMonths(locale) {
|
|
204
|
+
return (0, _dayjs.default)().locale(parseLocale(locale)).localeData().monthsShort();
|
|
205
|
+
},
|
|
206
|
+
format: function format(locale, date, _format) {
|
|
207
|
+
return date.locale(parseLocale(locale)).format(_format);
|
|
208
|
+
},
|
|
209
|
+
parse: function parse(locale, text, formats) {
|
|
210
|
+
var localeStr = parseLocale(locale);
|
|
211
|
+
for (var i = 0; i < formats.length; i += 1) {
|
|
212
|
+
var format = formats[i];
|
|
213
|
+
var formatText = text;
|
|
214
|
+
if (format.includes('wo') || format.includes('Wo')) {
|
|
215
|
+
// parse Wo
|
|
216
|
+
var year = formatText.split('-')[0];
|
|
217
|
+
var weekStr = formatText.split('-')[1];
|
|
218
|
+
var firstWeek = (0, _dayjs.default)(year, 'YYYY').startOf('year').locale(localeStr);
|
|
219
|
+
for (var j = 0; j <= 52; j += 1) {
|
|
220
|
+
var nextWeek = firstWeek.add(j, 'week');
|
|
221
|
+
if (nextWeek.format('Wo') === weekStr) {
|
|
222
|
+
return nextWeek;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
parseNoMatchNotice();
|
|
226
|
+
return null;
|
|
227
|
+
}
|
|
228
|
+
var date = (0, _dayjs.default)(formatText, format, true).locale(localeStr);
|
|
229
|
+
if (date.isValid()) {
|
|
230
|
+
return date;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
if (text) {
|
|
234
|
+
parseNoMatchNotice();
|
|
235
|
+
}
|
|
236
|
+
return null;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
};
|
|
240
|
+
var _default = exports.default = generateConfig;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export type GenerateConfig<DateType> = {
|
|
2
|
+
getWeekDay: (value: DateType) => number;
|
|
3
|
+
getMillisecond: (value: DateType) => number;
|
|
4
|
+
getSecond: (value: DateType) => number;
|
|
5
|
+
getMinute: (value: DateType) => number;
|
|
6
|
+
getHour: (value: DateType) => number;
|
|
7
|
+
getDate: (value: DateType) => number;
|
|
8
|
+
getMonth: (value: DateType) => number;
|
|
9
|
+
getYear: (value: DateType) => number;
|
|
10
|
+
getNow: () => DateType;
|
|
11
|
+
getFixedDate: (fixed: string) => DateType;
|
|
12
|
+
getEndDate: (value: DateType) => DateType;
|
|
13
|
+
addYear: (value: DateType, diff: number) => DateType;
|
|
14
|
+
addMonth: (value: DateType, diff: number) => DateType;
|
|
15
|
+
addDate: (value: DateType, diff: number) => DateType;
|
|
16
|
+
setYear: (value: DateType, year: number) => DateType;
|
|
17
|
+
setMonth: (value: DateType, month: number) => DateType;
|
|
18
|
+
setDate: (value: DateType, date: number) => DateType;
|
|
19
|
+
setHour: (value: DateType, hour: number) => DateType;
|
|
20
|
+
setMinute: (value: DateType, minute: number) => DateType;
|
|
21
|
+
setSecond: (value: DateType, second: number) => DateType;
|
|
22
|
+
setMillisecond: (value: DateType, millisecond: number) => DateType;
|
|
23
|
+
isAfter: (date1: DateType, date2: DateType) => boolean;
|
|
24
|
+
isValidate: (date: DateType) => boolean;
|
|
25
|
+
locale: {
|
|
26
|
+
getWeekFirstDay: (locale: string) => number;
|
|
27
|
+
getWeekFirstDate: (locale: string, value: DateType) => DateType;
|
|
28
|
+
getWeek: (locale: string, value: DateType) => number;
|
|
29
|
+
format: (locale: string, date: DateType, format: string) => string;
|
|
30
|
+
/** Should only return validate date instance */
|
|
31
|
+
parse: (locale: string, text: string, formats: string[]) => DateType | null;
|
|
32
|
+
/** A proxy for getting locale with moment or other locale library */
|
|
33
|
+
getShortWeekDays?: (locale: string) => string[];
|
|
34
|
+
/** A proxy for getting locale with moment or other locale library */
|
|
35
|
+
getShortMonths?: (locale: string) => string[];
|
|
36
|
+
};
|
|
37
|
+
};
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _luxon = require("luxon");
|
|
8
|
+
var weekDayFormatMap = {
|
|
9
|
+
zh_CN: 'narrow',
|
|
10
|
+
zh_TW: 'narrow'
|
|
11
|
+
};
|
|
12
|
+
var weekDayLengthMap = {
|
|
13
|
+
en_US: 2,
|
|
14
|
+
en_GB: 2
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Normalizes part of a moment format string that should
|
|
19
|
+
* not be escaped to a luxon compatible format string.
|
|
20
|
+
*
|
|
21
|
+
* @param part string
|
|
22
|
+
* @returns string
|
|
23
|
+
*/
|
|
24
|
+
var normalizeFormatPart = function normalizeFormatPart(part) {
|
|
25
|
+
return part.replace(/Y/g, 'y').replace(/D/g, 'd').replace(/gg/g, 'kk').replace(/Q/g, 'q').replace(/([Ww])o/g, 'WW').replace(/A/g, 'a');
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Normalizes a moment compatible format string to a luxon compatible format string
|
|
30
|
+
*
|
|
31
|
+
* @param format string
|
|
32
|
+
* @returns string
|
|
33
|
+
*/
|
|
34
|
+
var normalizeFormat = function normalizeFormat(format) {
|
|
35
|
+
return format
|
|
36
|
+
// moment escapes strings contained in brackets
|
|
37
|
+
.split(/[[\]]/).map(function (part, index) {
|
|
38
|
+
var shouldEscape = index % 2 > 0;
|
|
39
|
+
return shouldEscape ? part : normalizeFormatPart(part);
|
|
40
|
+
})
|
|
41
|
+
// luxon escapes strings contained in single quotes
|
|
42
|
+
.join("'");
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Normalizes language tags used to luxon compatible
|
|
47
|
+
* language tags by replacing underscores with hyphen-minus.
|
|
48
|
+
*
|
|
49
|
+
* @param locale string
|
|
50
|
+
* @returns string
|
|
51
|
+
*/
|
|
52
|
+
var normalizeLocale = function normalizeLocale(locale) {
|
|
53
|
+
return locale.replace(/_/g, '-');
|
|
54
|
+
};
|
|
55
|
+
var generateConfig = {
|
|
56
|
+
// get
|
|
57
|
+
getNow: function getNow() {
|
|
58
|
+
/**
|
|
59
|
+
* The current time that can respond to tz settings is required. like `dayjs().tz()`.
|
|
60
|
+
* @see: https://github.com/ant-design/ant-design/issues/51282
|
|
61
|
+
* https://github.com/react-component/picker/pull/878
|
|
62
|
+
*/
|
|
63
|
+
return _luxon.DateTime.now();
|
|
64
|
+
},
|
|
65
|
+
getFixedDate: function getFixedDate(string) {
|
|
66
|
+
return _luxon.DateTime.fromFormat(string, 'yyyy-MM-dd');
|
|
67
|
+
},
|
|
68
|
+
getEndDate: function getEndDate(date) {
|
|
69
|
+
return date.endOf('month');
|
|
70
|
+
},
|
|
71
|
+
getWeekDay: function getWeekDay(date) {
|
|
72
|
+
return date.weekday;
|
|
73
|
+
},
|
|
74
|
+
getYear: function getYear(date) {
|
|
75
|
+
return date.year;
|
|
76
|
+
},
|
|
77
|
+
getMonth: function getMonth(date) {
|
|
78
|
+
return date.month - 1;
|
|
79
|
+
},
|
|
80
|
+
// getMonth should return 0-11, luxon month returns 1-12
|
|
81
|
+
getDate: function getDate(date) {
|
|
82
|
+
return date.day;
|
|
83
|
+
},
|
|
84
|
+
getHour: function getHour(date) {
|
|
85
|
+
return date.hour;
|
|
86
|
+
},
|
|
87
|
+
getMinute: function getMinute(date) {
|
|
88
|
+
return date.minute;
|
|
89
|
+
},
|
|
90
|
+
getSecond: function getSecond(date) {
|
|
91
|
+
return date.second;
|
|
92
|
+
},
|
|
93
|
+
getMillisecond: function getMillisecond(date) {
|
|
94
|
+
return date.millisecond;
|
|
95
|
+
},
|
|
96
|
+
// set
|
|
97
|
+
addYear: function addYear(date, diff) {
|
|
98
|
+
return date.plus({
|
|
99
|
+
year: diff
|
|
100
|
+
});
|
|
101
|
+
},
|
|
102
|
+
addMonth: function addMonth(date, diff) {
|
|
103
|
+
return date.plus({
|
|
104
|
+
month: diff
|
|
105
|
+
});
|
|
106
|
+
},
|
|
107
|
+
addDate: function addDate(date, diff) {
|
|
108
|
+
return date.plus({
|
|
109
|
+
day: diff
|
|
110
|
+
});
|
|
111
|
+
},
|
|
112
|
+
setYear: function setYear(date, year) {
|
|
113
|
+
return date.set({
|
|
114
|
+
year: year
|
|
115
|
+
});
|
|
116
|
+
},
|
|
117
|
+
setMonth: function setMonth(date, month) {
|
|
118
|
+
return date.set({
|
|
119
|
+
month: month + 1
|
|
120
|
+
});
|
|
121
|
+
},
|
|
122
|
+
// setMonth month argument is 0-11, luxon months are 1-12
|
|
123
|
+
setDate: function setDate(date, day) {
|
|
124
|
+
return date.set({
|
|
125
|
+
day: day
|
|
126
|
+
});
|
|
127
|
+
},
|
|
128
|
+
setHour: function setHour(date, hour) {
|
|
129
|
+
return date.set({
|
|
130
|
+
hour: hour
|
|
131
|
+
});
|
|
132
|
+
},
|
|
133
|
+
setMinute: function setMinute(date, minute) {
|
|
134
|
+
return date.set({
|
|
135
|
+
minute: minute
|
|
136
|
+
});
|
|
137
|
+
},
|
|
138
|
+
setSecond: function setSecond(date, second) {
|
|
139
|
+
return date.set({
|
|
140
|
+
second: second
|
|
141
|
+
});
|
|
142
|
+
},
|
|
143
|
+
setMillisecond: function setMillisecond(date, milliseconds) {
|
|
144
|
+
return date.set({
|
|
145
|
+
millisecond: milliseconds
|
|
146
|
+
});
|
|
147
|
+
},
|
|
148
|
+
// Compare
|
|
149
|
+
isAfter: function isAfter(date1, date2) {
|
|
150
|
+
return date1 > date2;
|
|
151
|
+
},
|
|
152
|
+
isValidate: function isValidate(date) {
|
|
153
|
+
return date.isValid;
|
|
154
|
+
},
|
|
155
|
+
locale: {
|
|
156
|
+
getWeekFirstDate: function getWeekFirstDate(locale, date) {
|
|
157
|
+
return date.setLocale(normalizeLocale(locale)).startOf('week');
|
|
158
|
+
},
|
|
159
|
+
getWeekFirstDay: function getWeekFirstDay(locale) {
|
|
160
|
+
return _luxon.DateTime.local().setLocale(normalizeLocale(locale)).startOf('week').weekday;
|
|
161
|
+
},
|
|
162
|
+
getWeek: function getWeek(locale, date) {
|
|
163
|
+
return date.setLocale(normalizeLocale(locale)).weekNumber;
|
|
164
|
+
},
|
|
165
|
+
getShortWeekDays: function getShortWeekDays(locale) {
|
|
166
|
+
var weekdays = _luxon.Info.weekdays(weekDayFormatMap[locale] || 'short', {
|
|
167
|
+
locale: normalizeLocale(locale)
|
|
168
|
+
});
|
|
169
|
+
var shifted = weekdays.map(function (weekday) {
|
|
170
|
+
return weekday.slice(0, weekDayLengthMap[locale]);
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
// getShortWeekDays should return weekday labels starting from Sunday.
|
|
174
|
+
// luxon returns them starting from Monday, so we have to shift the results.
|
|
175
|
+
shifted.unshift(shifted.pop());
|
|
176
|
+
return shifted;
|
|
177
|
+
},
|
|
178
|
+
getShortMonths: function getShortMonths(locale) {
|
|
179
|
+
return _luxon.Info.months('short', {
|
|
180
|
+
locale: normalizeLocale(locale)
|
|
181
|
+
});
|
|
182
|
+
},
|
|
183
|
+
format: function format(locale, date, _format) {
|
|
184
|
+
if (!date || !date.isValid) {
|
|
185
|
+
return null;
|
|
186
|
+
}
|
|
187
|
+
return date.setLocale(normalizeLocale(locale)).toFormat(normalizeFormat(_format));
|
|
188
|
+
},
|
|
189
|
+
parse: function parse(locale, text, formats) {
|
|
190
|
+
for (var i = 0; i < formats.length; i += 1) {
|
|
191
|
+
var normalizedFormat = normalizeFormat(formats[i]);
|
|
192
|
+
var date = _luxon.DateTime.fromFormat(text, normalizedFormat, {
|
|
193
|
+
locale: normalizeLocale(locale)
|
|
194
|
+
});
|
|
195
|
+
if (date.isValid) {
|
|
196
|
+
return date;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
return null;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
};
|
|
203
|
+
var _default = exports.default = generateConfig;
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _moment = _interopRequireDefault(require("moment"));
|
|
8
|
+
var _warning = require("@rc-component/util/lib/warning");
|
|
9
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
+
var generateConfig = {
|
|
11
|
+
// get
|
|
12
|
+
getNow: function getNow() {
|
|
13
|
+
return (0, _moment.default)();
|
|
14
|
+
},
|
|
15
|
+
getFixedDate: function getFixedDate(string) {
|
|
16
|
+
return (0, _moment.default)(string, 'YYYY-MM-DD');
|
|
17
|
+
},
|
|
18
|
+
getEndDate: function getEndDate(date) {
|
|
19
|
+
var clone = date.clone();
|
|
20
|
+
return clone.endOf('month');
|
|
21
|
+
},
|
|
22
|
+
getWeekDay: function getWeekDay(date) {
|
|
23
|
+
var clone = date.clone().locale('en_US');
|
|
24
|
+
return clone.weekday() + clone.localeData().firstDayOfWeek();
|
|
25
|
+
},
|
|
26
|
+
getYear: function getYear(date) {
|
|
27
|
+
return date.year();
|
|
28
|
+
},
|
|
29
|
+
getMonth: function getMonth(date) {
|
|
30
|
+
return date.month();
|
|
31
|
+
},
|
|
32
|
+
getDate: function getDate(date) {
|
|
33
|
+
return date.date();
|
|
34
|
+
},
|
|
35
|
+
getHour: function getHour(date) {
|
|
36
|
+
return date.hour();
|
|
37
|
+
},
|
|
38
|
+
getMinute: function getMinute(date) {
|
|
39
|
+
return date.minute();
|
|
40
|
+
},
|
|
41
|
+
getSecond: function getSecond(date) {
|
|
42
|
+
return date.second();
|
|
43
|
+
},
|
|
44
|
+
getMillisecond: function getMillisecond(date) {
|
|
45
|
+
return date.millisecond();
|
|
46
|
+
},
|
|
47
|
+
// set
|
|
48
|
+
addYear: function addYear(date, diff) {
|
|
49
|
+
var clone = date.clone();
|
|
50
|
+
return clone.add(diff, 'year');
|
|
51
|
+
},
|
|
52
|
+
addMonth: function addMonth(date, diff) {
|
|
53
|
+
var clone = date.clone();
|
|
54
|
+
return clone.add(diff, 'month');
|
|
55
|
+
},
|
|
56
|
+
addDate: function addDate(date, diff) {
|
|
57
|
+
var clone = date.clone();
|
|
58
|
+
return clone.add(diff, 'day');
|
|
59
|
+
},
|
|
60
|
+
setYear: function setYear(date, year) {
|
|
61
|
+
var clone = date.clone();
|
|
62
|
+
return clone.year(year);
|
|
63
|
+
},
|
|
64
|
+
setMonth: function setMonth(date, month) {
|
|
65
|
+
var clone = date.clone();
|
|
66
|
+
return clone.month(month);
|
|
67
|
+
},
|
|
68
|
+
setDate: function setDate(date, num) {
|
|
69
|
+
var clone = date.clone();
|
|
70
|
+
return clone.date(num);
|
|
71
|
+
},
|
|
72
|
+
setHour: function setHour(date, hour) {
|
|
73
|
+
var clone = date.clone();
|
|
74
|
+
return clone.hour(hour);
|
|
75
|
+
},
|
|
76
|
+
setMinute: function setMinute(date, minute) {
|
|
77
|
+
var clone = date.clone();
|
|
78
|
+
return clone.minute(minute);
|
|
79
|
+
},
|
|
80
|
+
setSecond: function setSecond(date, second) {
|
|
81
|
+
var clone = date.clone();
|
|
82
|
+
return clone.second(second);
|
|
83
|
+
},
|
|
84
|
+
setMillisecond: function setMillisecond(date, millisecond) {
|
|
85
|
+
var clone = date.clone();
|
|
86
|
+
return clone.millisecond(millisecond);
|
|
87
|
+
},
|
|
88
|
+
// Compare
|
|
89
|
+
isAfter: function isAfter(date1, date2) {
|
|
90
|
+
return date1.isAfter(date2);
|
|
91
|
+
},
|
|
92
|
+
isValidate: function isValidate(date) {
|
|
93
|
+
return date.isValid();
|
|
94
|
+
},
|
|
95
|
+
locale: {
|
|
96
|
+
getWeekFirstDay: function getWeekFirstDay(locale) {
|
|
97
|
+
var date = (0, _moment.default)().locale(locale);
|
|
98
|
+
return date.localeData().firstDayOfWeek();
|
|
99
|
+
},
|
|
100
|
+
getWeekFirstDate: function getWeekFirstDate(locale, date) {
|
|
101
|
+
var clone = date.clone();
|
|
102
|
+
var result = clone.locale(locale);
|
|
103
|
+
return result.weekday(0);
|
|
104
|
+
},
|
|
105
|
+
getWeek: function getWeek(locale, date) {
|
|
106
|
+
var clone = date.clone();
|
|
107
|
+
var result = clone.locale(locale);
|
|
108
|
+
return result.week();
|
|
109
|
+
},
|
|
110
|
+
getShortWeekDays: function getShortWeekDays(locale) {
|
|
111
|
+
var date = (0, _moment.default)().locale(locale);
|
|
112
|
+
return date.localeData().weekdaysMin();
|
|
113
|
+
},
|
|
114
|
+
getShortMonths: function getShortMonths(locale) {
|
|
115
|
+
var date = (0, _moment.default)().locale(locale);
|
|
116
|
+
return date.localeData().monthsShort();
|
|
117
|
+
},
|
|
118
|
+
format: function format(locale, date, _format) {
|
|
119
|
+
var clone = date.clone();
|
|
120
|
+
var result = clone.locale(locale);
|
|
121
|
+
return result.format(_format);
|
|
122
|
+
},
|
|
123
|
+
parse: function parse(locale, text, formats) {
|
|
124
|
+
var fallbackFormatList = [];
|
|
125
|
+
for (var i = 0; i < formats.length; i += 1) {
|
|
126
|
+
var format = formats[i];
|
|
127
|
+
var formatText = text;
|
|
128
|
+
if (format.includes('wo') || format.includes('Wo')) {
|
|
129
|
+
format = format.replace(/wo/g, 'w').replace(/Wo/g, 'W');
|
|
130
|
+
var matchFormat = format.match(/[-YyMmDdHhSsWwGg]+/g);
|
|
131
|
+
var matchText = formatText.match(/[-\d]+/g);
|
|
132
|
+
if (matchFormat && matchText) {
|
|
133
|
+
format = matchFormat.join('');
|
|
134
|
+
formatText = matchText.join('');
|
|
135
|
+
} else {
|
|
136
|
+
fallbackFormatList.push(format.replace(/o/g, ''));
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
var date = (0, _moment.default)(formatText, format, locale, true);
|
|
140
|
+
if (date.isValid()) {
|
|
141
|
+
return date;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// Fallback to fuzzy matching, this should always not reach match or need fire a issue
|
|
146
|
+
for (var _i = 0; _i < fallbackFormatList.length; _i += 1) {
|
|
147
|
+
var _date = (0, _moment.default)(text, fallbackFormatList[_i], locale, false);
|
|
148
|
+
|
|
149
|
+
/* istanbul ignore next */
|
|
150
|
+
if (_date.isValid()) {
|
|
151
|
+
(0, _warning.noteOnce)(false, 'Not match any format strictly and fallback to fuzzy match. Please help to fire a issue about this.');
|
|
152
|
+
return _date;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return null;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
var _default = exports.default = generateConfig;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Locale, SharedTimeProps } from '../interface';
|
|
2
|
+
export declare function fillTimeFormat(showHour: boolean, showMinute: boolean, showSecond: boolean, showMillisecond: boolean, showMeridiem: boolean): string;
|
|
3
|
+
/**
|
|
4
|
+
* Fill locale format as start up
|
|
5
|
+
*/
|
|
6
|
+
export default function useLocale<DateType extends object>(locale: Locale, showProps: Pick<SharedTimeProps<DateType>, 'showHour' | 'showMinute' | 'showSecond' | 'showMillisecond' | 'use12Hours'>): Locale;
|