@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,152 @@
|
|
|
1
|
+
import moment from 'moment';
|
|
2
|
+
import { noteOnce } from "@rc-component/util/es/warning";
|
|
3
|
+
var generateConfig = {
|
|
4
|
+
// get
|
|
5
|
+
getNow: function getNow() {
|
|
6
|
+
return moment();
|
|
7
|
+
},
|
|
8
|
+
getFixedDate: function getFixedDate(string) {
|
|
9
|
+
return moment(string, 'YYYY-MM-DD');
|
|
10
|
+
},
|
|
11
|
+
getEndDate: function getEndDate(date) {
|
|
12
|
+
var clone = date.clone();
|
|
13
|
+
return clone.endOf('month');
|
|
14
|
+
},
|
|
15
|
+
getWeekDay: function getWeekDay(date) {
|
|
16
|
+
var clone = date.clone().locale('en_US');
|
|
17
|
+
return clone.weekday() + clone.localeData().firstDayOfWeek();
|
|
18
|
+
},
|
|
19
|
+
getYear: function getYear(date) {
|
|
20
|
+
return date.year();
|
|
21
|
+
},
|
|
22
|
+
getMonth: function getMonth(date) {
|
|
23
|
+
return date.month();
|
|
24
|
+
},
|
|
25
|
+
getDate: function getDate(date) {
|
|
26
|
+
return date.date();
|
|
27
|
+
},
|
|
28
|
+
getHour: function getHour(date) {
|
|
29
|
+
return date.hour();
|
|
30
|
+
},
|
|
31
|
+
getMinute: function getMinute(date) {
|
|
32
|
+
return date.minute();
|
|
33
|
+
},
|
|
34
|
+
getSecond: function getSecond(date) {
|
|
35
|
+
return date.second();
|
|
36
|
+
},
|
|
37
|
+
getMillisecond: function getMillisecond(date) {
|
|
38
|
+
return date.millisecond();
|
|
39
|
+
},
|
|
40
|
+
// set
|
|
41
|
+
addYear: function addYear(date, diff) {
|
|
42
|
+
var clone = date.clone();
|
|
43
|
+
return clone.add(diff, 'year');
|
|
44
|
+
},
|
|
45
|
+
addMonth: function addMonth(date, diff) {
|
|
46
|
+
var clone = date.clone();
|
|
47
|
+
return clone.add(diff, 'month');
|
|
48
|
+
},
|
|
49
|
+
addDate: function addDate(date, diff) {
|
|
50
|
+
var clone = date.clone();
|
|
51
|
+
return clone.add(diff, 'day');
|
|
52
|
+
},
|
|
53
|
+
setYear: function setYear(date, year) {
|
|
54
|
+
var clone = date.clone();
|
|
55
|
+
return clone.year(year);
|
|
56
|
+
},
|
|
57
|
+
setMonth: function setMonth(date, month) {
|
|
58
|
+
var clone = date.clone();
|
|
59
|
+
return clone.month(month);
|
|
60
|
+
},
|
|
61
|
+
setDate: function setDate(date, num) {
|
|
62
|
+
var clone = date.clone();
|
|
63
|
+
return clone.date(num);
|
|
64
|
+
},
|
|
65
|
+
setHour: function setHour(date, hour) {
|
|
66
|
+
var clone = date.clone();
|
|
67
|
+
return clone.hour(hour);
|
|
68
|
+
},
|
|
69
|
+
setMinute: function setMinute(date, minute) {
|
|
70
|
+
var clone = date.clone();
|
|
71
|
+
return clone.minute(minute);
|
|
72
|
+
},
|
|
73
|
+
setSecond: function setSecond(date, second) {
|
|
74
|
+
var clone = date.clone();
|
|
75
|
+
return clone.second(second);
|
|
76
|
+
},
|
|
77
|
+
setMillisecond: function setMillisecond(date, millisecond) {
|
|
78
|
+
var clone = date.clone();
|
|
79
|
+
return clone.millisecond(millisecond);
|
|
80
|
+
},
|
|
81
|
+
// Compare
|
|
82
|
+
isAfter: function isAfter(date1, date2) {
|
|
83
|
+
return date1.isAfter(date2);
|
|
84
|
+
},
|
|
85
|
+
isValidate: function isValidate(date) {
|
|
86
|
+
return date.isValid();
|
|
87
|
+
},
|
|
88
|
+
locale: {
|
|
89
|
+
getWeekFirstDay: function getWeekFirstDay(locale) {
|
|
90
|
+
var date = moment().locale(locale);
|
|
91
|
+
return date.localeData().firstDayOfWeek();
|
|
92
|
+
},
|
|
93
|
+
getWeekFirstDate: function getWeekFirstDate(locale, date) {
|
|
94
|
+
var clone = date.clone();
|
|
95
|
+
var result = clone.locale(locale);
|
|
96
|
+
return result.weekday(0);
|
|
97
|
+
},
|
|
98
|
+
getWeek: function getWeek(locale, date) {
|
|
99
|
+
var clone = date.clone();
|
|
100
|
+
var result = clone.locale(locale);
|
|
101
|
+
return result.week();
|
|
102
|
+
},
|
|
103
|
+
getShortWeekDays: function getShortWeekDays(locale) {
|
|
104
|
+
var date = moment().locale(locale);
|
|
105
|
+
return date.localeData().weekdaysMin();
|
|
106
|
+
},
|
|
107
|
+
getShortMonths: function getShortMonths(locale) {
|
|
108
|
+
var date = moment().locale(locale);
|
|
109
|
+
return date.localeData().monthsShort();
|
|
110
|
+
},
|
|
111
|
+
format: function format(locale, date, _format) {
|
|
112
|
+
var clone = date.clone();
|
|
113
|
+
var result = clone.locale(locale);
|
|
114
|
+
return result.format(_format);
|
|
115
|
+
},
|
|
116
|
+
parse: function parse(locale, text, formats) {
|
|
117
|
+
var fallbackFormatList = [];
|
|
118
|
+
for (var i = 0; i < formats.length; i += 1) {
|
|
119
|
+
var format = formats[i];
|
|
120
|
+
var formatText = text;
|
|
121
|
+
if (format.includes('wo') || format.includes('Wo')) {
|
|
122
|
+
format = format.replace(/wo/g, 'w').replace(/Wo/g, 'W');
|
|
123
|
+
var matchFormat = format.match(/[-YyMmDdHhSsWwGg]+/g);
|
|
124
|
+
var matchText = formatText.match(/[-\d]+/g);
|
|
125
|
+
if (matchFormat && matchText) {
|
|
126
|
+
format = matchFormat.join('');
|
|
127
|
+
formatText = matchText.join('');
|
|
128
|
+
} else {
|
|
129
|
+
fallbackFormatList.push(format.replace(/o/g, ''));
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
var date = moment(formatText, format, locale, true);
|
|
133
|
+
if (date.isValid()) {
|
|
134
|
+
return date;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// Fallback to fuzzy matching, this should always not reach match or need fire a issue
|
|
139
|
+
for (var _i = 0; _i < fallbackFormatList.length; _i += 1) {
|
|
140
|
+
var _date = moment(text, fallbackFormatList[_i], locale, false);
|
|
141
|
+
|
|
142
|
+
/* istanbul ignore next */
|
|
143
|
+
if (_date.isValid()) {
|
|
144
|
+
noteOnce(false, 'Not match any format strictly and fallback to fuzzy match. Please help to fire a issue about this.');
|
|
145
|
+
return _date;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return null;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
export 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;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
|
+
import React from 'react';
|
|
8
|
+
export function fillTimeFormat(showHour, showMinute, showSecond, showMillisecond, showMeridiem) {
|
|
9
|
+
var timeFormat = '';
|
|
10
|
+
|
|
11
|
+
// Base HH:mm:ss
|
|
12
|
+
var cells = [];
|
|
13
|
+
if (showHour) {
|
|
14
|
+
cells.push(showMeridiem ? 'hh' : 'HH');
|
|
15
|
+
}
|
|
16
|
+
if (showMinute) {
|
|
17
|
+
cells.push('mm');
|
|
18
|
+
}
|
|
19
|
+
if (showSecond) {
|
|
20
|
+
cells.push('ss');
|
|
21
|
+
}
|
|
22
|
+
timeFormat = cells.join(':');
|
|
23
|
+
|
|
24
|
+
// Millisecond
|
|
25
|
+
if (showMillisecond) {
|
|
26
|
+
timeFormat += '.SSS';
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Meridiem
|
|
30
|
+
if (showMeridiem) {
|
|
31
|
+
timeFormat += ' A';
|
|
32
|
+
}
|
|
33
|
+
return timeFormat;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Used for `useFilledProps` since it already in the React.useMemo
|
|
38
|
+
*/
|
|
39
|
+
function fillLocale(locale, showHour, showMinute, showSecond, showMillisecond, use12Hours) {
|
|
40
|
+
// Not fill `monthFormat` since `locale.shortMonths` handle this
|
|
41
|
+
// Not fill `cellMeridiemFormat` since AM & PM by default
|
|
42
|
+
var fieldDateTimeFormat = locale.fieldDateTimeFormat,
|
|
43
|
+
fieldDateFormat = locale.fieldDateFormat,
|
|
44
|
+
fieldTimeFormat = locale.fieldTimeFormat,
|
|
45
|
+
fieldMonthFormat = locale.fieldMonthFormat,
|
|
46
|
+
fieldYearFormat = locale.fieldYearFormat,
|
|
47
|
+
fieldWeekFormat = locale.fieldWeekFormat,
|
|
48
|
+
fieldQuarterFormat = locale.fieldQuarterFormat,
|
|
49
|
+
yearFormat = locale.yearFormat,
|
|
50
|
+
cellYearFormat = locale.cellYearFormat,
|
|
51
|
+
cellQuarterFormat = locale.cellQuarterFormat,
|
|
52
|
+
dayFormat = locale.dayFormat,
|
|
53
|
+
cellDateFormat = locale.cellDateFormat;
|
|
54
|
+
var timeFormat = fillTimeFormat(showHour, showMinute, showSecond, showMillisecond, use12Hours);
|
|
55
|
+
return _objectSpread(_objectSpread({}, locale), {}, {
|
|
56
|
+
fieldDateTimeFormat: fieldDateTimeFormat || "YYYY-MM-DD ".concat(timeFormat),
|
|
57
|
+
fieldDateFormat: fieldDateFormat || 'YYYY-MM-DD',
|
|
58
|
+
fieldTimeFormat: fieldTimeFormat || timeFormat,
|
|
59
|
+
fieldMonthFormat: fieldMonthFormat || 'YYYY-MM',
|
|
60
|
+
fieldYearFormat: fieldYearFormat || 'YYYY',
|
|
61
|
+
fieldWeekFormat: fieldWeekFormat || 'gggg-wo',
|
|
62
|
+
fieldQuarterFormat: fieldQuarterFormat || 'YYYY-[Q]Q',
|
|
63
|
+
yearFormat: yearFormat || 'YYYY',
|
|
64
|
+
cellYearFormat: cellYearFormat || 'YYYY',
|
|
65
|
+
cellQuarterFormat: cellQuarterFormat || '[Q]Q',
|
|
66
|
+
cellDateFormat: cellDateFormat || dayFormat || 'D'
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Fill locale format as start up
|
|
72
|
+
*/
|
|
73
|
+
export default function useLocale(locale, showProps) {
|
|
74
|
+
var showHour = showProps.showHour,
|
|
75
|
+
showMinute = showProps.showMinute,
|
|
76
|
+
showSecond = showProps.showSecond,
|
|
77
|
+
showMillisecond = showProps.showMillisecond,
|
|
78
|
+
use12Hours = showProps.use12Hours;
|
|
79
|
+
return React.useMemo(function () {
|
|
80
|
+
return fillLocale(locale, showHour, showMinute, showSecond, showMillisecond, use12Hours);
|
|
81
|
+
}, [locale, showHour, showMinute, showSecond, showMillisecond, use12Hours]);
|
|
82
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sync value with state.
|
|
3
|
+
* This should only used for internal which not affect outside calculation.
|
|
4
|
+
* Since it's not safe for suspense.
|
|
5
|
+
*/
|
|
6
|
+
export default function useSyncState<T>(defaultValue: T, controlledValue?: T): [getter: (useControlledValueFirst?: boolean) => T, setter: (nextValue: T) => void, value: T];
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
4
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
5
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
6
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
|
+
import * as React from 'react';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Sync value with state.
|
|
11
|
+
* This should only used for internal which not affect outside calculation.
|
|
12
|
+
* Since it's not safe for suspense.
|
|
13
|
+
*/
|
|
14
|
+
export default function useSyncState(defaultValue, controlledValue) {
|
|
15
|
+
var valueRef = React.useRef(defaultValue);
|
|
16
|
+
var _React$useState = React.useState({}),
|
|
17
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
18
|
+
forceUpdate = _React$useState2[1];
|
|
19
|
+
var getter = function getter(useControlledValueFirst) {
|
|
20
|
+
return useControlledValueFirst && controlledValue !== undefined ? controlledValue : valueRef.current;
|
|
21
|
+
};
|
|
22
|
+
var setter = function setter(nextValue) {
|
|
23
|
+
valueRef.current = nextValue;
|
|
24
|
+
forceUpdate({});
|
|
25
|
+
};
|
|
26
|
+
return [getter, setter, getter(true)];
|
|
27
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { InternalMode, Locale, SharedPickerProps, SharedTimeProps } from '../interface';
|
|
2
|
+
export interface ComponentProps<DateType extends object> {
|
|
3
|
+
picker?: InternalMode;
|
|
4
|
+
showTime?: boolean | Partial<SharedTimeProps<DateType>>;
|
|
5
|
+
locale: Locale;
|
|
6
|
+
format?: SharedPickerProps['format'];
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Get `showHour`, `showMinute`, `showSecond` or other from the props.
|
|
10
|
+
* This is pure function, will not get `showXXX` from the `format` prop.
|
|
11
|
+
*/
|
|
12
|
+
export declare function getTimeProps<DateType extends object>(componentProps: ComponentProps<DateType>): [
|
|
13
|
+
showTimeProps: SharedTimeProps<DateType>,
|
|
14
|
+
showTimePropsForLocale: SharedTimeProps<DateType>,
|
|
15
|
+
showTimeFormat: string,
|
|
16
|
+
propFormat: string
|
|
17
|
+
];
|
|
18
|
+
export declare function fillShowTimeConfig<DateType extends object>(picker: InternalMode, showTimeFormat: string, propFormat: string, timeConfig: SharedTimeProps<DateType>, locale: Locale): SharedTimeProps<DateType>;
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
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; }
|
|
2
|
+
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; }
|
|
3
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
4
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
5
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
6
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
7
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
8
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
9
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
10
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
11
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
12
|
+
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); }
|
|
13
|
+
import { getRowFormat, pickProps, toArray } from "../utils/miscUtil";
|
|
14
|
+
import { fillTimeFormat } from "./useLocale";
|
|
15
|
+
function checkShow(format, keywords, show) {
|
|
16
|
+
return show !== null && show !== void 0 ? show : keywords.some(function (keyword) {
|
|
17
|
+
return format.includes(keyword);
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
var showTimeKeys = [
|
|
21
|
+
// 'format',
|
|
22
|
+
'showNow', 'showHour', 'showMinute', 'showSecond', 'showMillisecond', 'use12Hours', 'hourStep', 'minuteStep', 'secondStep', 'millisecondStep', 'hideDisabledOptions', 'defaultValue', 'disabledHours', 'disabledMinutes', 'disabledSeconds', 'disabledMilliseconds', 'disabledTime', 'changeOnScroll', 'defaultOpenValue'];
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Get SharedTimeProps from props.
|
|
26
|
+
*/
|
|
27
|
+
function pickTimeProps(props) {
|
|
28
|
+
var timeProps = pickProps(props, showTimeKeys);
|
|
29
|
+
var format = props.format,
|
|
30
|
+
picker = props.picker;
|
|
31
|
+
var propFormat = null;
|
|
32
|
+
if (format) {
|
|
33
|
+
propFormat = format;
|
|
34
|
+
if (Array.isArray(propFormat)) {
|
|
35
|
+
propFormat = propFormat[0];
|
|
36
|
+
}
|
|
37
|
+
propFormat = _typeof(propFormat) === 'object' ? propFormat.format : propFormat;
|
|
38
|
+
}
|
|
39
|
+
if (picker === 'time') {
|
|
40
|
+
timeProps.format = propFormat;
|
|
41
|
+
}
|
|
42
|
+
return [timeProps, propFormat];
|
|
43
|
+
}
|
|
44
|
+
function isStringFormat(format) {
|
|
45
|
+
return format && typeof format === 'string';
|
|
46
|
+
}
|
|
47
|
+
/** Check if all the showXXX is `undefined` */
|
|
48
|
+
function existShowConfig(showHour, showMinute, showSecond, showMillisecond) {
|
|
49
|
+
return [showHour, showMinute, showSecond, showMillisecond].some(function (show) {
|
|
50
|
+
return show !== undefined;
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** Fill the showXXX if needed */
|
|
55
|
+
function fillShowConfig(hasShowConfig, showHour, showMinute, showSecond, showMillisecond) {
|
|
56
|
+
var parsedShowHour = showHour;
|
|
57
|
+
var parsedShowMinute = showMinute;
|
|
58
|
+
var parsedShowSecond = showSecond;
|
|
59
|
+
if (!hasShowConfig && !parsedShowHour && !parsedShowMinute && !parsedShowSecond && !showMillisecond) {
|
|
60
|
+
parsedShowHour = true;
|
|
61
|
+
parsedShowMinute = true;
|
|
62
|
+
parsedShowSecond = true;
|
|
63
|
+
} else if (hasShowConfig) {
|
|
64
|
+
var _parsedShowHour, _parsedShowMinute, _parsedShowSecond;
|
|
65
|
+
var existFalse = [parsedShowHour, parsedShowMinute, parsedShowSecond].some(function (show) {
|
|
66
|
+
return show === false;
|
|
67
|
+
});
|
|
68
|
+
var existTrue = [parsedShowHour, parsedShowMinute, parsedShowSecond].some(function (show) {
|
|
69
|
+
return show === true;
|
|
70
|
+
});
|
|
71
|
+
var defaultShow = existFalse ? true : !existTrue;
|
|
72
|
+
parsedShowHour = (_parsedShowHour = parsedShowHour) !== null && _parsedShowHour !== void 0 ? _parsedShowHour : defaultShow;
|
|
73
|
+
parsedShowMinute = (_parsedShowMinute = parsedShowMinute) !== null && _parsedShowMinute !== void 0 ? _parsedShowMinute : defaultShow;
|
|
74
|
+
parsedShowSecond = (_parsedShowSecond = parsedShowSecond) !== null && _parsedShowSecond !== void 0 ? _parsedShowSecond : defaultShow;
|
|
75
|
+
}
|
|
76
|
+
return [parsedShowHour, parsedShowMinute, parsedShowSecond, showMillisecond];
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Get `showHour`, `showMinute`, `showSecond` or other from the props.
|
|
81
|
+
* This is pure function, will not get `showXXX` from the `format` prop.
|
|
82
|
+
*/
|
|
83
|
+
export function getTimeProps(componentProps) {
|
|
84
|
+
var showTime = componentProps.showTime;
|
|
85
|
+
var _pickTimeProps = pickTimeProps(componentProps),
|
|
86
|
+
_pickTimeProps2 = _slicedToArray(_pickTimeProps, 2),
|
|
87
|
+
pickedProps = _pickTimeProps2[0],
|
|
88
|
+
propFormat = _pickTimeProps2[1];
|
|
89
|
+
var showTimeConfig = showTime && _typeof(showTime) === 'object' ? showTime : {};
|
|
90
|
+
var timeConfig = _objectSpread(_objectSpread({
|
|
91
|
+
defaultOpenValue: showTimeConfig.defaultOpenValue || showTimeConfig.defaultValue
|
|
92
|
+
}, pickedProps), showTimeConfig);
|
|
93
|
+
var showMillisecond = timeConfig.showMillisecond;
|
|
94
|
+
var showHour = timeConfig.showHour,
|
|
95
|
+
showMinute = timeConfig.showMinute,
|
|
96
|
+
showSecond = timeConfig.showSecond;
|
|
97
|
+
var hasShowConfig = existShowConfig(showHour, showMinute, showSecond, showMillisecond);
|
|
98
|
+
var _fillShowConfig = fillShowConfig(hasShowConfig, showHour, showMinute, showSecond, showMillisecond);
|
|
99
|
+
var _fillShowConfig2 = _slicedToArray(_fillShowConfig, 3);
|
|
100
|
+
showHour = _fillShowConfig2[0];
|
|
101
|
+
showMinute = _fillShowConfig2[1];
|
|
102
|
+
showSecond = _fillShowConfig2[2];
|
|
103
|
+
return [timeConfig, _objectSpread(_objectSpread({}, timeConfig), {}, {
|
|
104
|
+
showHour: showHour,
|
|
105
|
+
showMinute: showMinute,
|
|
106
|
+
showSecond: showSecond,
|
|
107
|
+
showMillisecond: showMillisecond
|
|
108
|
+
}), timeConfig.format, propFormat];
|
|
109
|
+
}
|
|
110
|
+
export function fillShowTimeConfig(picker, showTimeFormat, propFormat, timeConfig, locale) {
|
|
111
|
+
var isTimePicker = picker === 'time';
|
|
112
|
+
if (picker === 'datetime' || isTimePicker) {
|
|
113
|
+
var pickedProps = timeConfig;
|
|
114
|
+
|
|
115
|
+
// ====================== BaseFormat ======================
|
|
116
|
+
var defaultLocaleFormat = getRowFormat(picker, locale, null);
|
|
117
|
+
var baselineFormat = defaultLocaleFormat;
|
|
118
|
+
var formatList = [showTimeFormat, propFormat];
|
|
119
|
+
for (var i = 0; i < formatList.length; i += 1) {
|
|
120
|
+
var format = toArray(formatList[i])[0];
|
|
121
|
+
if (isStringFormat(format)) {
|
|
122
|
+
baselineFormat = format;
|
|
123
|
+
break;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// ========================= Show =========================
|
|
128
|
+
var showHour = pickedProps.showHour,
|
|
129
|
+
showMinute = pickedProps.showMinute,
|
|
130
|
+
showSecond = pickedProps.showSecond,
|
|
131
|
+
showMillisecond = pickedProps.showMillisecond;
|
|
132
|
+
var use12Hours = pickedProps.use12Hours;
|
|
133
|
+
var showMeridiem = checkShow(baselineFormat, ['a', 'A', 'LT', 'LLL', 'LTS'], use12Hours);
|
|
134
|
+
var hasShowConfig = existShowConfig(showHour, showMinute, showSecond, showMillisecond);
|
|
135
|
+
|
|
136
|
+
// Fill with format, if needed
|
|
137
|
+
if (!hasShowConfig) {
|
|
138
|
+
showHour = checkShow(baselineFormat, ['H', 'h', 'k', 'LT', 'LLL']);
|
|
139
|
+
showMinute = checkShow(baselineFormat, ['m', 'LT', 'LLL']);
|
|
140
|
+
showSecond = checkShow(baselineFormat, ['s', 'LTS']);
|
|
141
|
+
showMillisecond = checkShow(baselineFormat, ['SSS']);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// Fallback if all can not see
|
|
145
|
+
// ======================== Format ========================
|
|
146
|
+
var _fillShowConfig3 = fillShowConfig(hasShowConfig, showHour, showMinute, showSecond, showMillisecond);
|
|
147
|
+
var _fillShowConfig4 = _slicedToArray(_fillShowConfig3, 3);
|
|
148
|
+
showHour = _fillShowConfig4[0];
|
|
149
|
+
showMinute = _fillShowConfig4[1];
|
|
150
|
+
showSecond = _fillShowConfig4[2];
|
|
151
|
+
var timeFormat = showTimeFormat || fillTimeFormat(showHour, showMinute, showSecond, showMillisecond, showMeridiem);
|
|
152
|
+
|
|
153
|
+
// ======================== Props =========================
|
|
154
|
+
return _objectSpread(_objectSpread({}, pickedProps), {}, {
|
|
155
|
+
// Format
|
|
156
|
+
format: timeFormat,
|
|
157
|
+
// Show Config
|
|
158
|
+
showHour: showHour,
|
|
159
|
+
showMinute: showMinute,
|
|
160
|
+
showSecond: showSecond,
|
|
161
|
+
showMillisecond: showMillisecond,
|
|
162
|
+
use12Hours: showMeridiem
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
return null;
|
|
166
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { GenerateConfig } from '../generate';
|
|
3
|
+
import type { SharedTimeProps } from '../interface';
|
|
4
|
+
export type Unit<ValueType = number | string> = {
|
|
5
|
+
label: React.ReactText;
|
|
6
|
+
value: ValueType;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Parse time props to get util info
|
|
11
|
+
*/
|
|
12
|
+
export default function useTimeInfo<DateType extends object = any>(generateConfig: GenerateConfig<DateType>, props?: SharedTimeProps<DateType>, date?: DateType): readonly [(nextTime: DateType, certainDate?: DateType) => DateType, Unit<number>[], (nextHour: number) => Unit<number>[], (nextHour: number, nextMinute: number) => Unit<number>[], (nextHour: number, nextMinute: number, nextSecond: number) => Unit<number>[]];
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
8
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
9
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
10
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
11
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
12
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
13
|
+
import { warning } from '@rc-component/util';
|
|
14
|
+
import * as React from 'react';
|
|
15
|
+
import { findValidateTime } from "../PickerPanel/TimePanel/TimePanelBody/util";
|
|
16
|
+
import { leftPad } from "../utils/miscUtil";
|
|
17
|
+
function emptyDisabled() {
|
|
18
|
+
return [];
|
|
19
|
+
}
|
|
20
|
+
function generateUnits(start, end) {
|
|
21
|
+
var step = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
|
22
|
+
var hideDisabledOptions = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
23
|
+
var disabledUnits = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : [];
|
|
24
|
+
var pad = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 2;
|
|
25
|
+
var units = [];
|
|
26
|
+
var integerStep = step >= 1 ? step | 0 : 1;
|
|
27
|
+
for (var i = start; i <= end; i += integerStep) {
|
|
28
|
+
var disabled = disabledUnits.includes(i);
|
|
29
|
+
if (!disabled || !hideDisabledOptions) {
|
|
30
|
+
units.push({
|
|
31
|
+
label: leftPad(i, pad),
|
|
32
|
+
value: i,
|
|
33
|
+
disabled: disabled
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return units;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Parse time props to get util info
|
|
42
|
+
*/
|
|
43
|
+
export default function useTimeInfo(generateConfig) {
|
|
44
|
+
var props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
45
|
+
var date = arguments.length > 2 ? arguments[2] : undefined;
|
|
46
|
+
var _ref = props || {},
|
|
47
|
+
use12Hours = _ref.use12Hours,
|
|
48
|
+
_ref$hourStep = _ref.hourStep,
|
|
49
|
+
hourStep = _ref$hourStep === void 0 ? 1 : _ref$hourStep,
|
|
50
|
+
_ref$minuteStep = _ref.minuteStep,
|
|
51
|
+
minuteStep = _ref$minuteStep === void 0 ? 1 : _ref$minuteStep,
|
|
52
|
+
_ref$secondStep = _ref.secondStep,
|
|
53
|
+
secondStep = _ref$secondStep === void 0 ? 1 : _ref$secondStep,
|
|
54
|
+
_ref$millisecondStep = _ref.millisecondStep,
|
|
55
|
+
millisecondStep = _ref$millisecondStep === void 0 ? 100 : _ref$millisecondStep,
|
|
56
|
+
hideDisabledOptions = _ref.hideDisabledOptions,
|
|
57
|
+
disabledTime = _ref.disabledTime,
|
|
58
|
+
disabledHours = _ref.disabledHours,
|
|
59
|
+
disabledMinutes = _ref.disabledMinutes,
|
|
60
|
+
disabledSeconds = _ref.disabledSeconds;
|
|
61
|
+
var mergedDate = React.useMemo(function () {
|
|
62
|
+
return date || generateConfig.getNow();
|
|
63
|
+
}, [date, generateConfig]);
|
|
64
|
+
|
|
65
|
+
// ======================== Warnings ========================
|
|
66
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
67
|
+
var isHourStepValid = 24 % hourStep === 0;
|
|
68
|
+
var isMinuteStepValid = 60 % minuteStep === 0;
|
|
69
|
+
var isSecondStepValid = 60 % secondStep === 0;
|
|
70
|
+
warning(isHourStepValid, "`hourStep` ".concat(hourStep, " is invalid. It should be a factor of 24."));
|
|
71
|
+
warning(isMinuteStepValid, "`minuteStep` ".concat(minuteStep, " is invalid. It should be a factor of 60."));
|
|
72
|
+
warning(isSecondStepValid, "`secondStep` ".concat(secondStep, " is invalid. It should be a factor of 60."));
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// ======================== Disabled ========================
|
|
76
|
+
var getDisabledTimes = React.useCallback(function (targetDate) {
|
|
77
|
+
var disabledConfig = (disabledTime === null || disabledTime === void 0 ? void 0 : disabledTime(targetDate)) || {};
|
|
78
|
+
return [disabledConfig.disabledHours || disabledHours || emptyDisabled, disabledConfig.disabledMinutes || disabledMinutes || emptyDisabled, disabledConfig.disabledSeconds || disabledSeconds || emptyDisabled, disabledConfig.disabledMilliseconds || emptyDisabled];
|
|
79
|
+
}, [disabledTime, disabledHours, disabledMinutes, disabledSeconds]);
|
|
80
|
+
var _React$useMemo = React.useMemo(function () {
|
|
81
|
+
return getDisabledTimes(mergedDate);
|
|
82
|
+
}, [mergedDate, getDisabledTimes]),
|
|
83
|
+
_React$useMemo2 = _slicedToArray(_React$useMemo, 4),
|
|
84
|
+
mergedDisabledHours = _React$useMemo2[0],
|
|
85
|
+
mergedDisabledMinutes = _React$useMemo2[1],
|
|
86
|
+
mergedDisabledSeconds = _React$useMemo2[2],
|
|
87
|
+
mergedDisabledMilliseconds = _React$useMemo2[3];
|
|
88
|
+
|
|
89
|
+
// ========================= Column =========================
|
|
90
|
+
var getAllUnits = React.useCallback(function (getDisabledHours, getDisabledMinutes, getDisabledSeconds, getDisabledMilliseconds) {
|
|
91
|
+
var hours = generateUnits(0, 23, hourStep, hideDisabledOptions, getDisabledHours());
|
|
92
|
+
|
|
93
|
+
// Hours
|
|
94
|
+
var rowHourUnits = use12Hours ? hours.map(function (unit) {
|
|
95
|
+
return _objectSpread(_objectSpread({}, unit), {}, {
|
|
96
|
+
label: leftPad(unit.value % 12 || 12, 2)
|
|
97
|
+
});
|
|
98
|
+
}) : hours;
|
|
99
|
+
|
|
100
|
+
// Minutes
|
|
101
|
+
var getMinuteUnits = function getMinuteUnits(nextHour) {
|
|
102
|
+
return generateUnits(0, 59, minuteStep, hideDisabledOptions, getDisabledMinutes(nextHour));
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
// Seconds
|
|
106
|
+
var getSecondUnits = function getSecondUnits(nextHour, nextMinute) {
|
|
107
|
+
return generateUnits(0, 59, secondStep, hideDisabledOptions, getDisabledSeconds(nextHour, nextMinute));
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
// Milliseconds
|
|
111
|
+
var getMillisecondUnits = function getMillisecondUnits(nextHour, nextMinute, nextSecond) {
|
|
112
|
+
return generateUnits(0, 999, millisecondStep, hideDisabledOptions, getDisabledMilliseconds(nextHour, nextMinute, nextSecond), 3);
|
|
113
|
+
};
|
|
114
|
+
return [rowHourUnits, getMinuteUnits, getSecondUnits, getMillisecondUnits];
|
|
115
|
+
}, [hideDisabledOptions, hourStep, use12Hours, millisecondStep, minuteStep, secondStep]);
|
|
116
|
+
var _React$useMemo3 = React.useMemo(function () {
|
|
117
|
+
return getAllUnits(mergedDisabledHours, mergedDisabledMinutes, mergedDisabledSeconds, mergedDisabledMilliseconds);
|
|
118
|
+
}, [getAllUnits, mergedDisabledHours, mergedDisabledMinutes, mergedDisabledSeconds, mergedDisabledMilliseconds]),
|
|
119
|
+
_React$useMemo4 = _slicedToArray(_React$useMemo3, 4),
|
|
120
|
+
rowHourUnits = _React$useMemo4[0],
|
|
121
|
+
getMinuteUnits = _React$useMemo4[1],
|
|
122
|
+
getSecondUnits = _React$useMemo4[2],
|
|
123
|
+
getMillisecondUnits = _React$useMemo4[3];
|
|
124
|
+
|
|
125
|
+
// ======================== Validate ========================
|
|
126
|
+
/**
|
|
127
|
+
* Get validate time with `disabledTime`, `certainDate` to specific the date need to check
|
|
128
|
+
*/
|
|
129
|
+
var getValidTime = function getValidTime(nextTime, certainDate) {
|
|
130
|
+
var getCheckHourUnits = function getCheckHourUnits() {
|
|
131
|
+
return rowHourUnits;
|
|
132
|
+
};
|
|
133
|
+
var getCheckMinuteUnits = getMinuteUnits;
|
|
134
|
+
var getCheckSecondUnits = getSecondUnits;
|
|
135
|
+
var getCheckMillisecondUnits = getMillisecondUnits;
|
|
136
|
+
if (certainDate) {
|
|
137
|
+
var _getDisabledTimes = getDisabledTimes(certainDate),
|
|
138
|
+
_getDisabledTimes2 = _slicedToArray(_getDisabledTimes, 4),
|
|
139
|
+
targetDisabledHours = _getDisabledTimes2[0],
|
|
140
|
+
targetDisabledMinutes = _getDisabledTimes2[1],
|
|
141
|
+
targetDisabledSeconds = _getDisabledTimes2[2],
|
|
142
|
+
targetDisabledMilliseconds = _getDisabledTimes2[3];
|
|
143
|
+
var _getAllUnits = getAllUnits(targetDisabledHours, targetDisabledMinutes, targetDisabledSeconds, targetDisabledMilliseconds),
|
|
144
|
+
_getAllUnits2 = _slicedToArray(_getAllUnits, 4),
|
|
145
|
+
targetRowHourUnits = _getAllUnits2[0],
|
|
146
|
+
targetGetMinuteUnits = _getAllUnits2[1],
|
|
147
|
+
targetGetSecondUnits = _getAllUnits2[2],
|
|
148
|
+
targetGetMillisecondUnits = _getAllUnits2[3];
|
|
149
|
+
getCheckHourUnits = function getCheckHourUnits() {
|
|
150
|
+
return targetRowHourUnits;
|
|
151
|
+
};
|
|
152
|
+
getCheckMinuteUnits = targetGetMinuteUnits;
|
|
153
|
+
getCheckSecondUnits = targetGetSecondUnits;
|
|
154
|
+
getCheckMillisecondUnits = targetGetMillisecondUnits;
|
|
155
|
+
}
|
|
156
|
+
var validateDate = findValidateTime(nextTime, getCheckHourUnits, getCheckMinuteUnits, getCheckSecondUnits, getCheckMillisecondUnits, generateConfig);
|
|
157
|
+
return validateDate;
|
|
158
|
+
};
|
|
159
|
+
return [
|
|
160
|
+
// getValidTime
|
|
161
|
+
getValidTime,
|
|
162
|
+
// Units
|
|
163
|
+
rowHourUnits, getMinuteUnits, getSecondUnits, getMillisecondUnits];
|
|
164
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { GenerateConfig } from '../generate';
|
|
2
|
+
import type { InternalMode, Locale } from '../interface';
|
|
3
|
+
/**
|
|
4
|
+
* Toggles the presence of a value in an array.
|
|
5
|
+
* If the value exists in the array, removed it.
|
|
6
|
+
* Else add it.
|
|
7
|
+
*/
|
|
8
|
+
export default function useToggleDates<DateType>(generateConfig: GenerateConfig<DateType>, locale: Locale, panelMode: InternalMode): (list: DateType[], target: DateType) => DateType[];
|