@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,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = QuarterPanel;
|
|
8
|
+
var React = _interopRequireWildcard(require("react"));
|
|
9
|
+
var _dateUtil = require("../../utils/dateUtil");
|
|
10
|
+
var _context = require("../context");
|
|
11
|
+
var _PanelBody = _interopRequireDefault(require("../PanelBody"));
|
|
12
|
+
var _PanelHeader = _interopRequireDefault(require("../PanelHeader"));
|
|
13
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
15
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
16
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
17
|
+
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; }
|
|
18
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
19
|
+
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); }
|
|
20
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
21
|
+
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."); }
|
|
22
|
+
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); }
|
|
23
|
+
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; }
|
|
24
|
+
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; } }
|
|
25
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
26
|
+
function QuarterPanel(props) {
|
|
27
|
+
var prefixCls = props.prefixCls,
|
|
28
|
+
locale = props.locale,
|
|
29
|
+
generateConfig = props.generateConfig,
|
|
30
|
+
pickerValue = props.pickerValue,
|
|
31
|
+
onPickerValueChange = props.onPickerValueChange,
|
|
32
|
+
onModeChange = props.onModeChange;
|
|
33
|
+
var panelPrefixCls = "".concat(prefixCls, "-quarter-panel");
|
|
34
|
+
|
|
35
|
+
// ========================== Base ==========================
|
|
36
|
+
var _useInfo = (0, _context.useInfo)(props, 'quarter'),
|
|
37
|
+
_useInfo2 = _slicedToArray(_useInfo, 1),
|
|
38
|
+
info = _useInfo2[0];
|
|
39
|
+
var baseDate = generateConfig.setMonth(pickerValue, 0);
|
|
40
|
+
|
|
41
|
+
// ========================= Cells ==========================
|
|
42
|
+
var getCellDate = function getCellDate(date, offset) {
|
|
43
|
+
return generateConfig.addMonth(date, offset * 3);
|
|
44
|
+
};
|
|
45
|
+
var getCellText = function getCellText(date) {
|
|
46
|
+
return (0, _dateUtil.formatValue)(date, {
|
|
47
|
+
locale: locale,
|
|
48
|
+
format: locale.cellQuarterFormat,
|
|
49
|
+
generateConfig: generateConfig
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
var getCellClassName = function getCellClassName() {
|
|
53
|
+
return _defineProperty({}, "".concat(prefixCls, "-cell-in-view"), true);
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
// ========================= Header =========================
|
|
57
|
+
var yearNode = /*#__PURE__*/React.createElement("button", {
|
|
58
|
+
type: "button",
|
|
59
|
+
key: "year",
|
|
60
|
+
"aria-label": locale.yearSelect,
|
|
61
|
+
onClick: function onClick() {
|
|
62
|
+
onModeChange('year');
|
|
63
|
+
},
|
|
64
|
+
tabIndex: -1,
|
|
65
|
+
className: "".concat(prefixCls, "-year-btn")
|
|
66
|
+
}, (0, _dateUtil.formatValue)(pickerValue, {
|
|
67
|
+
locale: locale,
|
|
68
|
+
format: locale.yearFormat,
|
|
69
|
+
generateConfig: generateConfig
|
|
70
|
+
}));
|
|
71
|
+
|
|
72
|
+
// ========================= Render =========================
|
|
73
|
+
return /*#__PURE__*/React.createElement(_context.PanelContext.Provider, {
|
|
74
|
+
value: info
|
|
75
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
76
|
+
className: panelPrefixCls
|
|
77
|
+
}, /*#__PURE__*/React.createElement(_PanelHeader.default, {
|
|
78
|
+
superOffset: function superOffset(distance) {
|
|
79
|
+
return generateConfig.addYear(pickerValue, distance);
|
|
80
|
+
},
|
|
81
|
+
onChange: onPickerValueChange
|
|
82
|
+
// Limitation
|
|
83
|
+
,
|
|
84
|
+
getStart: function getStart(date) {
|
|
85
|
+
return generateConfig.setMonth(date, 0);
|
|
86
|
+
},
|
|
87
|
+
getEnd: function getEnd(date) {
|
|
88
|
+
return generateConfig.setMonth(date, 11);
|
|
89
|
+
}
|
|
90
|
+
}, yearNode), /*#__PURE__*/React.createElement(_PanelBody.default, _extends({}, props, {
|
|
91
|
+
titleFormat: locale.fieldQuarterFormat,
|
|
92
|
+
colNum: 4,
|
|
93
|
+
rowNum: 1,
|
|
94
|
+
baseDate: baseDate
|
|
95
|
+
// Body
|
|
96
|
+
,
|
|
97
|
+
getCellDate: getCellDate,
|
|
98
|
+
getCellText: getCellText,
|
|
99
|
+
getCellClassName: getCellClassName
|
|
100
|
+
}))));
|
|
101
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export type Unit<ValueType = number | string> = {
|
|
3
|
+
label: React.ReactText;
|
|
4
|
+
value: ValueType;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
};
|
|
7
|
+
export interface TimeUnitColumnProps {
|
|
8
|
+
units: Unit[];
|
|
9
|
+
value: number | string;
|
|
10
|
+
optionalValue?: number | string;
|
|
11
|
+
type: 'hour' | 'minute' | 'second' | 'millisecond' | 'meridiem';
|
|
12
|
+
onChange: (value: number | string) => void;
|
|
13
|
+
onHover: (value: number | string) => void;
|
|
14
|
+
onDblClick?: VoidFunction;
|
|
15
|
+
changeOnScroll?: boolean;
|
|
16
|
+
}
|
|
17
|
+
export default function TimeColumn<DateType extends object>(props: TimeUnitColumnProps): React.JSX.Element;
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = TimeColumn;
|
|
8
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
9
|
+
var _useLayoutEffect = _interopRequireDefault(require("@rc-component/util/lib/hooks/useLayoutEffect"));
|
|
10
|
+
var React = _interopRequireWildcard(require("react"));
|
|
11
|
+
var _context = require("../../context");
|
|
12
|
+
var _useScrollTo3 = _interopRequireDefault(require("./useScrollTo"));
|
|
13
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
14
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
15
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
|
+
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; }
|
|
17
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
18
|
+
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); }
|
|
19
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
20
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
21
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
22
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
23
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
24
|
+
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."); }
|
|
25
|
+
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); }
|
|
26
|
+
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; }
|
|
27
|
+
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; } }
|
|
28
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
29
|
+
var SCROLL_DELAY = 300;
|
|
30
|
+
// Not use JSON.stringify to avoid dead loop
|
|
31
|
+
function flattenUnits(units) {
|
|
32
|
+
return units.map(function (_ref) {
|
|
33
|
+
var value = _ref.value,
|
|
34
|
+
label = _ref.label,
|
|
35
|
+
disabled = _ref.disabled;
|
|
36
|
+
return [value, label, disabled].join(',');
|
|
37
|
+
}).join(';');
|
|
38
|
+
}
|
|
39
|
+
function TimeColumn(props) {
|
|
40
|
+
var units = props.units,
|
|
41
|
+
value = props.value,
|
|
42
|
+
optionalValue = props.optionalValue,
|
|
43
|
+
type = props.type,
|
|
44
|
+
onChange = props.onChange,
|
|
45
|
+
onHover = props.onHover,
|
|
46
|
+
onDblClick = props.onDblClick,
|
|
47
|
+
changeOnScroll = props.changeOnScroll;
|
|
48
|
+
var _usePanelContext = (0, _context.usePanelContext)(),
|
|
49
|
+
prefixCls = _usePanelContext.prefixCls,
|
|
50
|
+
cellRender = _usePanelContext.cellRender,
|
|
51
|
+
now = _usePanelContext.now,
|
|
52
|
+
locale = _usePanelContext.locale;
|
|
53
|
+
var panelPrefixCls = "".concat(prefixCls, "-time-panel");
|
|
54
|
+
var cellPrefixCls = "".concat(prefixCls, "-time-panel-cell");
|
|
55
|
+
|
|
56
|
+
// ========================== Refs ==========================
|
|
57
|
+
var ulRef = React.useRef(null);
|
|
58
|
+
|
|
59
|
+
// ========================= Scroll =========================
|
|
60
|
+
var checkDelayRef = React.useRef();
|
|
61
|
+
var clearDelayCheck = function clearDelayCheck() {
|
|
62
|
+
clearTimeout(checkDelayRef.current);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
// ========================== Sync ==========================
|
|
66
|
+
var _useScrollTo = (0, _useScrollTo3.default)(ulRef, value !== null && value !== void 0 ? value : optionalValue),
|
|
67
|
+
_useScrollTo2 = _slicedToArray(_useScrollTo, 3),
|
|
68
|
+
syncScroll = _useScrollTo2[0],
|
|
69
|
+
stopScroll = _useScrollTo2[1],
|
|
70
|
+
isScrolling = _useScrollTo2[2];
|
|
71
|
+
|
|
72
|
+
// Effect sync value scroll
|
|
73
|
+
(0, _useLayoutEffect.default)(function () {
|
|
74
|
+
syncScroll();
|
|
75
|
+
clearDelayCheck();
|
|
76
|
+
return function () {
|
|
77
|
+
stopScroll();
|
|
78
|
+
clearDelayCheck();
|
|
79
|
+
};
|
|
80
|
+
}, [value, optionalValue, flattenUnits(units)]);
|
|
81
|
+
|
|
82
|
+
// ========================= Change =========================
|
|
83
|
+
// Scroll event if sync onScroll
|
|
84
|
+
var onInternalScroll = function onInternalScroll(event) {
|
|
85
|
+
clearDelayCheck();
|
|
86
|
+
var target = event.target;
|
|
87
|
+
if (!isScrolling() && changeOnScroll) {
|
|
88
|
+
checkDelayRef.current = setTimeout(function () {
|
|
89
|
+
var ul = ulRef.current;
|
|
90
|
+
var firstLiTop = ul.querySelector("li").offsetTop;
|
|
91
|
+
var liList = Array.from(ul.querySelectorAll("li"));
|
|
92
|
+
var liTopList = liList.map(function (li) {
|
|
93
|
+
return li.offsetTop - firstLiTop;
|
|
94
|
+
});
|
|
95
|
+
var liDistList = liTopList.map(function (top, index) {
|
|
96
|
+
if (units[index].disabled) {
|
|
97
|
+
return Number.MAX_SAFE_INTEGER;
|
|
98
|
+
}
|
|
99
|
+
return Math.abs(top - target.scrollTop);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
// Find min distance index
|
|
103
|
+
var minDist = Math.min.apply(Math, _toConsumableArray(liDistList));
|
|
104
|
+
var minDistIndex = liDistList.findIndex(function (dist) {
|
|
105
|
+
return dist === minDist;
|
|
106
|
+
});
|
|
107
|
+
var targetUnit = units[minDistIndex];
|
|
108
|
+
if (targetUnit && !targetUnit.disabled) {
|
|
109
|
+
onChange(targetUnit.value);
|
|
110
|
+
}
|
|
111
|
+
}, SCROLL_DELAY);
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
// ========================= Render =========================
|
|
116
|
+
var columnPrefixCls = "".concat(panelPrefixCls, "-column");
|
|
117
|
+
return /*#__PURE__*/React.createElement("ul", {
|
|
118
|
+
className: columnPrefixCls,
|
|
119
|
+
ref: ulRef,
|
|
120
|
+
"data-type": type,
|
|
121
|
+
onScroll: onInternalScroll
|
|
122
|
+
}, units.map(function (_ref2) {
|
|
123
|
+
var label = _ref2.label,
|
|
124
|
+
unitValue = _ref2.value,
|
|
125
|
+
disabled = _ref2.disabled;
|
|
126
|
+
var inner = /*#__PURE__*/React.createElement("div", {
|
|
127
|
+
className: "".concat(cellPrefixCls, "-inner")
|
|
128
|
+
}, label);
|
|
129
|
+
return /*#__PURE__*/React.createElement("li", {
|
|
130
|
+
key: unitValue,
|
|
131
|
+
className: (0, _classnames.default)(cellPrefixCls, _defineProperty(_defineProperty({}, "".concat(cellPrefixCls, "-selected"), value === unitValue), "".concat(cellPrefixCls, "-disabled"), disabled)),
|
|
132
|
+
onClick: function onClick() {
|
|
133
|
+
if (!disabled) {
|
|
134
|
+
onChange(unitValue);
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
onDoubleClick: function onDoubleClick() {
|
|
138
|
+
if (!disabled && onDblClick) {
|
|
139
|
+
onDblClick();
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
onMouseEnter: function onMouseEnter() {
|
|
143
|
+
onHover(unitValue);
|
|
144
|
+
},
|
|
145
|
+
onMouseLeave: function onMouseLeave() {
|
|
146
|
+
onHover(null);
|
|
147
|
+
},
|
|
148
|
+
"data-value": unitValue
|
|
149
|
+
}, cellRender ? cellRender(unitValue, {
|
|
150
|
+
prefixCls: prefixCls,
|
|
151
|
+
originNode: inner,
|
|
152
|
+
today: now,
|
|
153
|
+
type: 'time',
|
|
154
|
+
subType: type,
|
|
155
|
+
locale: locale
|
|
156
|
+
}) : inner);
|
|
157
|
+
}));
|
|
158
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { SharedPanelProps, SharedTimeProps } from '../../../interface';
|
|
3
|
+
export type TimePanelBodyProps<DateType extends object = any> = SharedPanelProps<DateType>;
|
|
4
|
+
export default function TimePanelBody<DateType extends object = any>(props: SharedTimeProps<DateType>): React.JSX.Element;
|
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = TimePanelBody;
|
|
8
|
+
var React = _interopRequireWildcard(require("react"));
|
|
9
|
+
var _useTimeInfo3 = _interopRequireDefault(require("../../../hooks/useTimeInfo"));
|
|
10
|
+
var _dateUtil = require("../../../utils/dateUtil");
|
|
11
|
+
var _context = require("../../context");
|
|
12
|
+
var _TimeColumn = _interopRequireDefault(require("./TimeColumn"));
|
|
13
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
15
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
16
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
17
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
18
|
+
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."); }
|
|
19
|
+
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); }
|
|
20
|
+
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; }
|
|
21
|
+
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; } }
|
|
22
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
23
|
+
function isAM(hour) {
|
|
24
|
+
return hour < 12;
|
|
25
|
+
}
|
|
26
|
+
function TimePanelBody(props) {
|
|
27
|
+
var showHour = props.showHour,
|
|
28
|
+
showMinute = props.showMinute,
|
|
29
|
+
showSecond = props.showSecond,
|
|
30
|
+
showMillisecond = props.showMillisecond,
|
|
31
|
+
showMeridiem = props.use12Hours,
|
|
32
|
+
changeOnScroll = props.changeOnScroll;
|
|
33
|
+
var _usePanelContext = (0, _context.usePanelContext)(),
|
|
34
|
+
prefixCls = _usePanelContext.prefixCls,
|
|
35
|
+
values = _usePanelContext.values,
|
|
36
|
+
generateConfig = _usePanelContext.generateConfig,
|
|
37
|
+
locale = _usePanelContext.locale,
|
|
38
|
+
onSelect = _usePanelContext.onSelect,
|
|
39
|
+
_usePanelContext$onHo = _usePanelContext.onHover,
|
|
40
|
+
onHover = _usePanelContext$onHo === void 0 ? function () {} : _usePanelContext$onHo,
|
|
41
|
+
pickerValue = _usePanelContext.pickerValue;
|
|
42
|
+
var value = (values === null || values === void 0 ? void 0 : values[0]) || null;
|
|
43
|
+
var _React$useContext = React.useContext(_context.PickerHackContext),
|
|
44
|
+
onCellDblClick = _React$useContext.onCellDblClick;
|
|
45
|
+
|
|
46
|
+
// ========================== Info ==========================
|
|
47
|
+
var _useTimeInfo = (0, _useTimeInfo3.default)(generateConfig, props, value),
|
|
48
|
+
_useTimeInfo2 = _slicedToArray(_useTimeInfo, 5),
|
|
49
|
+
getValidTime = _useTimeInfo2[0],
|
|
50
|
+
rowHourUnits = _useTimeInfo2[1],
|
|
51
|
+
getMinuteUnits = _useTimeInfo2[2],
|
|
52
|
+
getSecondUnits = _useTimeInfo2[3],
|
|
53
|
+
getMillisecondUnits = _useTimeInfo2[4];
|
|
54
|
+
|
|
55
|
+
// ========================= Value ==========================
|
|
56
|
+
// PickerValue will tell which one to align on the top
|
|
57
|
+
var getUnitValue = function getUnitValue(func) {
|
|
58
|
+
var valueUnitVal = value && generateConfig[func](value);
|
|
59
|
+
var pickerUnitValue = pickerValue && generateConfig[func](pickerValue);
|
|
60
|
+
return [valueUnitVal, pickerUnitValue];
|
|
61
|
+
};
|
|
62
|
+
var _getUnitValue = getUnitValue('getHour'),
|
|
63
|
+
_getUnitValue2 = _slicedToArray(_getUnitValue, 2),
|
|
64
|
+
hour = _getUnitValue2[0],
|
|
65
|
+
pickerHour = _getUnitValue2[1];
|
|
66
|
+
var _getUnitValue3 = getUnitValue('getMinute'),
|
|
67
|
+
_getUnitValue4 = _slicedToArray(_getUnitValue3, 2),
|
|
68
|
+
minute = _getUnitValue4[0],
|
|
69
|
+
pickerMinute = _getUnitValue4[1];
|
|
70
|
+
var _getUnitValue5 = getUnitValue('getSecond'),
|
|
71
|
+
_getUnitValue6 = _slicedToArray(_getUnitValue5, 2),
|
|
72
|
+
second = _getUnitValue6[0],
|
|
73
|
+
pickerSecond = _getUnitValue6[1];
|
|
74
|
+
var _getUnitValue7 = getUnitValue('getMillisecond'),
|
|
75
|
+
_getUnitValue8 = _slicedToArray(_getUnitValue7, 2),
|
|
76
|
+
millisecond = _getUnitValue8[0],
|
|
77
|
+
pickerMillisecond = _getUnitValue8[1];
|
|
78
|
+
var meridiem = hour === null ? null : isAM(hour) ? 'am' : 'pm';
|
|
79
|
+
|
|
80
|
+
// ========================= Column =========================
|
|
81
|
+
// Hours
|
|
82
|
+
var hourUnits = React.useMemo(function () {
|
|
83
|
+
if (!showMeridiem) {
|
|
84
|
+
return rowHourUnits;
|
|
85
|
+
}
|
|
86
|
+
return isAM(hour) ? rowHourUnits.filter(function (h) {
|
|
87
|
+
return isAM(h.value);
|
|
88
|
+
}) : rowHourUnits.filter(function (h) {
|
|
89
|
+
return !isAM(h.value);
|
|
90
|
+
});
|
|
91
|
+
}, [hour, rowHourUnits, showMeridiem]);
|
|
92
|
+
|
|
93
|
+
// >>> Pick Fallback
|
|
94
|
+
var getEnabled = function getEnabled(units, val) {
|
|
95
|
+
var _enabledUnits$;
|
|
96
|
+
var enabledUnits = units.filter(function (unit) {
|
|
97
|
+
return !unit.disabled;
|
|
98
|
+
});
|
|
99
|
+
return val !== null && val !== void 0 ? val : // Fallback to enabled value
|
|
100
|
+
enabledUnits === null || enabledUnits === void 0 || (_enabledUnits$ = enabledUnits[0]) === null || _enabledUnits$ === void 0 ? void 0 : _enabledUnits$.value;
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
// >>> Minutes
|
|
104
|
+
var validHour = getEnabled(rowHourUnits, hour);
|
|
105
|
+
var minuteUnits = React.useMemo(function () {
|
|
106
|
+
return getMinuteUnits(validHour);
|
|
107
|
+
}, [getMinuteUnits, validHour]);
|
|
108
|
+
|
|
109
|
+
// >>> Seconds
|
|
110
|
+
var validMinute = getEnabled(minuteUnits, minute);
|
|
111
|
+
var secondUnits = React.useMemo(function () {
|
|
112
|
+
return getSecondUnits(validHour, validMinute);
|
|
113
|
+
}, [getSecondUnits, validHour, validMinute]);
|
|
114
|
+
|
|
115
|
+
// >>> Milliseconds
|
|
116
|
+
var validSecond = getEnabled(secondUnits, second);
|
|
117
|
+
var millisecondUnits = React.useMemo(function () {
|
|
118
|
+
return getMillisecondUnits(validHour, validMinute, validSecond);
|
|
119
|
+
}, [getMillisecondUnits, validHour, validMinute, validSecond]);
|
|
120
|
+
var validMillisecond = getEnabled(millisecondUnits, millisecond);
|
|
121
|
+
|
|
122
|
+
// Meridiem
|
|
123
|
+
var meridiemUnits = React.useMemo(function () {
|
|
124
|
+
if (!showMeridiem) {
|
|
125
|
+
return [];
|
|
126
|
+
}
|
|
127
|
+
var base = generateConfig.getNow();
|
|
128
|
+
var amDate = generateConfig.setHour(base, 6);
|
|
129
|
+
var pmDate = generateConfig.setHour(base, 18);
|
|
130
|
+
var formatMeridiem = function formatMeridiem(date, defaultLabel) {
|
|
131
|
+
var cellMeridiemFormat = locale.cellMeridiemFormat;
|
|
132
|
+
return cellMeridiemFormat ? (0, _dateUtil.formatValue)(date, {
|
|
133
|
+
generateConfig: generateConfig,
|
|
134
|
+
locale: locale,
|
|
135
|
+
format: cellMeridiemFormat
|
|
136
|
+
}) : defaultLabel;
|
|
137
|
+
};
|
|
138
|
+
return [{
|
|
139
|
+
label: formatMeridiem(amDate, 'AM'),
|
|
140
|
+
value: 'am',
|
|
141
|
+
disabled: rowHourUnits.every(function (h) {
|
|
142
|
+
return h.disabled || !isAM(h.value);
|
|
143
|
+
})
|
|
144
|
+
}, {
|
|
145
|
+
label: formatMeridiem(pmDate, 'PM'),
|
|
146
|
+
value: 'pm',
|
|
147
|
+
disabled: rowHourUnits.every(function (h) {
|
|
148
|
+
return h.disabled || isAM(h.value);
|
|
149
|
+
})
|
|
150
|
+
}];
|
|
151
|
+
}, [rowHourUnits, showMeridiem, generateConfig, locale]);
|
|
152
|
+
|
|
153
|
+
// ========================= Change =========================
|
|
154
|
+
/**
|
|
155
|
+
* Check if time is validate or will match to validate one
|
|
156
|
+
*/
|
|
157
|
+
var triggerChange = function triggerChange(nextDate) {
|
|
158
|
+
var validateDate = getValidTime(nextDate);
|
|
159
|
+
onSelect(validateDate);
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
// ========================= Column =========================
|
|
163
|
+
// Create a template date for the trigger change event
|
|
164
|
+
var triggerDateTmpl = React.useMemo(function () {
|
|
165
|
+
var tmpl = value || pickerValue || generateConfig.getNow();
|
|
166
|
+
var isNotNull = function isNotNull(num) {
|
|
167
|
+
return num !== null && num !== undefined;
|
|
168
|
+
};
|
|
169
|
+
if (isNotNull(hour)) {
|
|
170
|
+
tmpl = generateConfig.setHour(tmpl, hour);
|
|
171
|
+
tmpl = generateConfig.setMinute(tmpl, minute);
|
|
172
|
+
tmpl = generateConfig.setSecond(tmpl, second);
|
|
173
|
+
tmpl = generateConfig.setMillisecond(tmpl, millisecond);
|
|
174
|
+
} else if (isNotNull(pickerHour)) {
|
|
175
|
+
tmpl = generateConfig.setHour(tmpl, pickerHour);
|
|
176
|
+
tmpl = generateConfig.setMinute(tmpl, pickerMinute);
|
|
177
|
+
tmpl = generateConfig.setSecond(tmpl, pickerSecond);
|
|
178
|
+
tmpl = generateConfig.setMillisecond(tmpl, pickerMillisecond);
|
|
179
|
+
} else if (isNotNull(validHour)) {
|
|
180
|
+
tmpl = generateConfig.setHour(tmpl, validHour);
|
|
181
|
+
tmpl = generateConfig.setMinute(tmpl, validMinute);
|
|
182
|
+
tmpl = generateConfig.setSecond(tmpl, validSecond);
|
|
183
|
+
tmpl = generateConfig.setMillisecond(tmpl, validMillisecond);
|
|
184
|
+
}
|
|
185
|
+
return tmpl;
|
|
186
|
+
}, [value, pickerValue, hour, minute, second, millisecond, validHour, validMinute, validSecond, validMillisecond, pickerHour, pickerMinute, pickerSecond, pickerMillisecond, generateConfig]);
|
|
187
|
+
|
|
188
|
+
// ===================== Columns Change =====================
|
|
189
|
+
var fillColumnValue = function fillColumnValue(val, func) {
|
|
190
|
+
if (val === null) {
|
|
191
|
+
return null;
|
|
192
|
+
}
|
|
193
|
+
return generateConfig[func](triggerDateTmpl, val);
|
|
194
|
+
};
|
|
195
|
+
var getNextHourTime = function getNextHourTime(val) {
|
|
196
|
+
return fillColumnValue(val, 'setHour');
|
|
197
|
+
};
|
|
198
|
+
var getNextMinuteTime = function getNextMinuteTime(val) {
|
|
199
|
+
return fillColumnValue(val, 'setMinute');
|
|
200
|
+
};
|
|
201
|
+
var getNextSecondTime = function getNextSecondTime(val) {
|
|
202
|
+
return fillColumnValue(val, 'setSecond');
|
|
203
|
+
};
|
|
204
|
+
var getNextMillisecondTime = function getNextMillisecondTime(val) {
|
|
205
|
+
return fillColumnValue(val, 'setMillisecond');
|
|
206
|
+
};
|
|
207
|
+
var getMeridiemTime = function getMeridiemTime(val) {
|
|
208
|
+
if (val === null) {
|
|
209
|
+
return null;
|
|
210
|
+
}
|
|
211
|
+
if (val === 'am' && !isAM(hour)) {
|
|
212
|
+
return generateConfig.setHour(triggerDateTmpl, hour - 12);
|
|
213
|
+
} else if (val === 'pm' && isAM(hour)) {
|
|
214
|
+
return generateConfig.setHour(triggerDateTmpl, hour + 12);
|
|
215
|
+
}
|
|
216
|
+
return triggerDateTmpl;
|
|
217
|
+
};
|
|
218
|
+
var onHourChange = function onHourChange(val) {
|
|
219
|
+
triggerChange(getNextHourTime(val));
|
|
220
|
+
};
|
|
221
|
+
var onMinuteChange = function onMinuteChange(val) {
|
|
222
|
+
triggerChange(getNextMinuteTime(val));
|
|
223
|
+
};
|
|
224
|
+
var onSecondChange = function onSecondChange(val) {
|
|
225
|
+
triggerChange(getNextSecondTime(val));
|
|
226
|
+
};
|
|
227
|
+
var onMillisecondChange = function onMillisecondChange(val) {
|
|
228
|
+
triggerChange(getNextMillisecondTime(val));
|
|
229
|
+
};
|
|
230
|
+
var onMeridiemChange = function onMeridiemChange(val) {
|
|
231
|
+
triggerChange(getMeridiemTime(val));
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
// ====================== Column Hover ======================
|
|
235
|
+
var onHourHover = function onHourHover(val) {
|
|
236
|
+
onHover(getNextHourTime(val));
|
|
237
|
+
};
|
|
238
|
+
var onMinuteHover = function onMinuteHover(val) {
|
|
239
|
+
onHover(getNextMinuteTime(val));
|
|
240
|
+
};
|
|
241
|
+
var onSecondHover = function onSecondHover(val) {
|
|
242
|
+
onHover(getNextSecondTime(val));
|
|
243
|
+
};
|
|
244
|
+
var onMillisecondHover = function onMillisecondHover(val) {
|
|
245
|
+
onHover(getNextMillisecondTime(val));
|
|
246
|
+
};
|
|
247
|
+
var onMeridiemHover = function onMeridiemHover(val) {
|
|
248
|
+
onHover(getMeridiemTime(val));
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
// ========================= Render =========================
|
|
252
|
+
var sharedColumnProps = {
|
|
253
|
+
onDblClick: onCellDblClick,
|
|
254
|
+
changeOnScroll: changeOnScroll
|
|
255
|
+
};
|
|
256
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
257
|
+
className: "".concat(prefixCls, "-content")
|
|
258
|
+
}, showHour && /*#__PURE__*/React.createElement(_TimeColumn.default, _extends({
|
|
259
|
+
units: hourUnits,
|
|
260
|
+
value: hour,
|
|
261
|
+
optionalValue: pickerHour,
|
|
262
|
+
type: "hour",
|
|
263
|
+
onChange: onHourChange,
|
|
264
|
+
onHover: onHourHover
|
|
265
|
+
}, sharedColumnProps)), showMinute && /*#__PURE__*/React.createElement(_TimeColumn.default, _extends({
|
|
266
|
+
units: minuteUnits,
|
|
267
|
+
value: minute,
|
|
268
|
+
optionalValue: pickerMinute,
|
|
269
|
+
type: "minute",
|
|
270
|
+
onChange: onMinuteChange,
|
|
271
|
+
onHover: onMinuteHover
|
|
272
|
+
}, sharedColumnProps)), showSecond && /*#__PURE__*/React.createElement(_TimeColumn.default, _extends({
|
|
273
|
+
units: secondUnits,
|
|
274
|
+
value: second,
|
|
275
|
+
optionalValue: pickerSecond,
|
|
276
|
+
type: "second",
|
|
277
|
+
onChange: onSecondChange,
|
|
278
|
+
onHover: onSecondHover
|
|
279
|
+
}, sharedColumnProps)), showMillisecond && /*#__PURE__*/React.createElement(_TimeColumn.default, _extends({
|
|
280
|
+
units: millisecondUnits,
|
|
281
|
+
value: millisecond,
|
|
282
|
+
optionalValue: pickerMillisecond,
|
|
283
|
+
type: "millisecond",
|
|
284
|
+
onChange: onMillisecondChange,
|
|
285
|
+
onHover: onMillisecondHover
|
|
286
|
+
}, sharedColumnProps)), showMeridiem && /*#__PURE__*/React.createElement(_TimeColumn.default, _extends({
|
|
287
|
+
units: meridiemUnits,
|
|
288
|
+
value: meridiem,
|
|
289
|
+
type: "meridiem",
|
|
290
|
+
onChange: onMeridiemChange,
|
|
291
|
+
onHover: onMeridiemHover
|
|
292
|
+
}, sharedColumnProps)));
|
|
293
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = useScrollTo;
|
|
8
|
+
var _util = require("@rc-component/util");
|
|
9
|
+
var _raf = _interopRequireDefault(require("@rc-component/util/lib/raf"));
|
|
10
|
+
var _isVisible = _interopRequireDefault(require("@rc-component/util/lib/Dom/isVisible"));
|
|
11
|
+
var React = _interopRequireWildcard(require("react"));
|
|
12
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
13
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
var SPEED_PTG = 1 / 3;
|
|
16
|
+
function useScrollTo(ulRef, value) {
|
|
17
|
+
// ========================= Scroll =========================
|
|
18
|
+
var scrollingRef = React.useRef(false);
|
|
19
|
+
var scrollRafRef = React.useRef(null);
|
|
20
|
+
var scrollDistRef = React.useRef(null);
|
|
21
|
+
var isScrolling = function isScrolling() {
|
|
22
|
+
return scrollingRef.current;
|
|
23
|
+
};
|
|
24
|
+
var stopScroll = function stopScroll() {
|
|
25
|
+
_raf.default.cancel(scrollRafRef.current);
|
|
26
|
+
scrollingRef.current = false;
|
|
27
|
+
};
|
|
28
|
+
var scrollRafTimesRef = React.useRef();
|
|
29
|
+
var startScroll = function startScroll() {
|
|
30
|
+
var ul = ulRef.current;
|
|
31
|
+
scrollDistRef.current = null;
|
|
32
|
+
scrollRafTimesRef.current = 0;
|
|
33
|
+
if (ul) {
|
|
34
|
+
var targetLi = ul.querySelector("[data-value=\"".concat(value, "\"]"));
|
|
35
|
+
var firstLi = ul.querySelector("li");
|
|
36
|
+
var doScroll = function doScroll() {
|
|
37
|
+
stopScroll();
|
|
38
|
+
scrollingRef.current = true;
|
|
39
|
+
scrollRafTimesRef.current += 1;
|
|
40
|
+
var currentTop = ul.scrollTop;
|
|
41
|
+
var firstLiTop = firstLi.offsetTop;
|
|
42
|
+
var targetLiTop = targetLi.offsetTop;
|
|
43
|
+
var targetTop = targetLiTop - firstLiTop;
|
|
44
|
+
|
|
45
|
+
// Wait for element exist. 5 frames is enough
|
|
46
|
+
if (targetLiTop === 0 && targetLi !== firstLi || !(0, _isVisible.default)(ul)) {
|
|
47
|
+
if (scrollRafTimesRef.current <= 5) {
|
|
48
|
+
scrollRafRef.current = (0, _raf.default)(doScroll);
|
|
49
|
+
}
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
var nextTop = currentTop + (targetTop - currentTop) * SPEED_PTG;
|
|
53
|
+
var dist = Math.abs(targetTop - nextTop);
|
|
54
|
+
|
|
55
|
+
// Break if dist get larger, which means user is scrolling
|
|
56
|
+
if (scrollDistRef.current !== null && scrollDistRef.current < dist) {
|
|
57
|
+
stopScroll();
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
scrollDistRef.current = dist;
|
|
61
|
+
|
|
62
|
+
// Stop when dist is less than 1
|
|
63
|
+
if (dist <= 1) {
|
|
64
|
+
ul.scrollTop = targetTop;
|
|
65
|
+
stopScroll();
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// IE not support `scrollTo`
|
|
70
|
+
ul.scrollTop = nextTop;
|
|
71
|
+
scrollRafRef.current = (0, _raf.default)(doScroll);
|
|
72
|
+
};
|
|
73
|
+
if (targetLi && firstLi) {
|
|
74
|
+
doScroll();
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
// ======================== Trigger =========================
|
|
80
|
+
var syncScroll = (0, _util.useEvent)(startScroll);
|
|
81
|
+
return [syncScroll, stopScroll, isScrolling];
|
|
82
|
+
}
|