@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,28 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { PickerRef } from '../../interface';
|
|
3
|
+
export interface InputRef extends PickerRef {
|
|
4
|
+
inputElement: HTMLInputElement;
|
|
5
|
+
}
|
|
6
|
+
export interface InputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'onChange'> {
|
|
7
|
+
format?: string;
|
|
8
|
+
validateFormat: (value: string) => boolean;
|
|
9
|
+
active?: boolean;
|
|
10
|
+
/** Used for single picker only */
|
|
11
|
+
showActiveCls?: boolean;
|
|
12
|
+
suffixIcon?: React.ReactNode;
|
|
13
|
+
value?: string;
|
|
14
|
+
onChange: (value: string) => void;
|
|
15
|
+
onSubmit: VoidFunction;
|
|
16
|
+
/** Meaning current is from the hover cell getting the placeholder text */
|
|
17
|
+
helped?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Trigger when input need additional help.
|
|
20
|
+
* Like open the popup for interactive.
|
|
21
|
+
*/
|
|
22
|
+
onHelp: () => void;
|
|
23
|
+
preserveInvalidOnBlur?: boolean;
|
|
24
|
+
invalid?: boolean;
|
|
25
|
+
clearIcon?: React.ReactNode;
|
|
26
|
+
}
|
|
27
|
+
declare const Input: React.ForwardRefExoticComponent<InputProps & React.RefAttributes<InputRef>>;
|
|
28
|
+
export default Input;
|
|
@@ -0,0 +1,377 @@
|
|
|
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
|
+
var _excluded = ["active", "showActiveCls", "suffixIcon", "format", "validateFormat", "onChange", "onInput", "helped", "onHelp", "onSubmit", "onKeyDown", "preserveInvalidOnBlur", "invalid", "clearIcon"];
|
|
3
|
+
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); }
|
|
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
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
14
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
15
|
+
import classNames from 'classnames';
|
|
16
|
+
import { useEvent } from '@rc-component/util';
|
|
17
|
+
import useLayoutEffect from "@rc-component/util/es/hooks/useLayoutEffect";
|
|
18
|
+
import raf from "@rc-component/util/es/raf";
|
|
19
|
+
import * as React from 'react';
|
|
20
|
+
import { leftPad } from "../../utils/miscUtil";
|
|
21
|
+
import PickerContext from "../context";
|
|
22
|
+
import useLockEffect from "../hooks/useLockEffect";
|
|
23
|
+
import Icon from "./Icon";
|
|
24
|
+
import MaskFormat from "./MaskFormat";
|
|
25
|
+
import { getMaskRange } from "./util";
|
|
26
|
+
|
|
27
|
+
// Format logic
|
|
28
|
+
//
|
|
29
|
+
// First time on focus:
|
|
30
|
+
// 1. check if the text is valid, if not fill with format
|
|
31
|
+
// 2. set highlight cell to the first cell
|
|
32
|
+
// Cells
|
|
33
|
+
// 1. Selection the index cell, set inner `cacheValue` to ''
|
|
34
|
+
// 2. Key input filter non-number char, patch after the `cacheValue`
|
|
35
|
+
// 1. Replace the `cacheValue` with input align the cell length
|
|
36
|
+
// 2. Re-selection the mask cell
|
|
37
|
+
// 3. If `cacheValue` match the limit length or cell format (like 1 ~ 12 month), go to next cell
|
|
38
|
+
|
|
39
|
+
var Input = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
40
|
+
var active = props.active,
|
|
41
|
+
_props$showActiveCls = props.showActiveCls,
|
|
42
|
+
showActiveCls = _props$showActiveCls === void 0 ? true : _props$showActiveCls,
|
|
43
|
+
suffixIcon = props.suffixIcon,
|
|
44
|
+
format = props.format,
|
|
45
|
+
validateFormat = props.validateFormat,
|
|
46
|
+
onChange = props.onChange,
|
|
47
|
+
onInput = props.onInput,
|
|
48
|
+
helped = props.helped,
|
|
49
|
+
onHelp = props.onHelp,
|
|
50
|
+
onSubmit = props.onSubmit,
|
|
51
|
+
onKeyDown = props.onKeyDown,
|
|
52
|
+
_props$preserveInvali = props.preserveInvalidOnBlur,
|
|
53
|
+
preserveInvalidOnBlur = _props$preserveInvali === void 0 ? false : _props$preserveInvali,
|
|
54
|
+
invalid = props.invalid,
|
|
55
|
+
clearIcon = props.clearIcon,
|
|
56
|
+
restProps = _objectWithoutProperties(props, _excluded);
|
|
57
|
+
var value = props.value,
|
|
58
|
+
onFocus = props.onFocus,
|
|
59
|
+
onBlur = props.onBlur,
|
|
60
|
+
onMouseUp = props.onMouseUp;
|
|
61
|
+
var _React$useContext = React.useContext(PickerContext),
|
|
62
|
+
prefixCls = _React$useContext.prefixCls,
|
|
63
|
+
_React$useContext$inp = _React$useContext.input,
|
|
64
|
+
Component = _React$useContext$inp === void 0 ? 'input' : _React$useContext$inp;
|
|
65
|
+
var inputPrefixCls = "".concat(prefixCls, "-input");
|
|
66
|
+
|
|
67
|
+
// ======================== Value =========================
|
|
68
|
+
var _React$useState = React.useState(false),
|
|
69
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
70
|
+
focused = _React$useState2[0],
|
|
71
|
+
setFocused = _React$useState2[1];
|
|
72
|
+
var _React$useState3 = React.useState(value),
|
|
73
|
+
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
74
|
+
internalInputValue = _React$useState4[0],
|
|
75
|
+
setInputValue = _React$useState4[1];
|
|
76
|
+
var _React$useState5 = React.useState(''),
|
|
77
|
+
_React$useState6 = _slicedToArray(_React$useState5, 2),
|
|
78
|
+
focusCellText = _React$useState6[0],
|
|
79
|
+
setFocusCellText = _React$useState6[1];
|
|
80
|
+
var _React$useState7 = React.useState(null),
|
|
81
|
+
_React$useState8 = _slicedToArray(_React$useState7, 2),
|
|
82
|
+
focusCellIndex = _React$useState8[0],
|
|
83
|
+
setFocusCellIndex = _React$useState8[1];
|
|
84
|
+
var _React$useState9 = React.useState(null),
|
|
85
|
+
_React$useState10 = _slicedToArray(_React$useState9, 2),
|
|
86
|
+
forceSelectionSyncMark = _React$useState10[0],
|
|
87
|
+
forceSelectionSync = _React$useState10[1];
|
|
88
|
+
var inputValue = internalInputValue || '';
|
|
89
|
+
|
|
90
|
+
// Sync value if needed
|
|
91
|
+
React.useEffect(function () {
|
|
92
|
+
setInputValue(value);
|
|
93
|
+
}, [value]);
|
|
94
|
+
|
|
95
|
+
// ========================= Refs =========================
|
|
96
|
+
var holderRef = React.useRef();
|
|
97
|
+
var inputRef = React.useRef();
|
|
98
|
+
React.useImperativeHandle(ref, function () {
|
|
99
|
+
return {
|
|
100
|
+
nativeElement: holderRef.current,
|
|
101
|
+
inputElement: inputRef.current,
|
|
102
|
+
focus: function focus(options) {
|
|
103
|
+
inputRef.current.focus(options);
|
|
104
|
+
},
|
|
105
|
+
blur: function blur() {
|
|
106
|
+
inputRef.current.blur();
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
// ======================== Format ========================
|
|
112
|
+
var maskFormat = React.useMemo(function () {
|
|
113
|
+
return new MaskFormat(format || '');
|
|
114
|
+
}, [format]);
|
|
115
|
+
var _React$useMemo = React.useMemo(function () {
|
|
116
|
+
if (helped) {
|
|
117
|
+
return [0, 0];
|
|
118
|
+
}
|
|
119
|
+
return maskFormat.getSelection(focusCellIndex);
|
|
120
|
+
}, [maskFormat, focusCellIndex, helped]),
|
|
121
|
+
_React$useMemo2 = _slicedToArray(_React$useMemo, 2),
|
|
122
|
+
selectionStart = _React$useMemo2[0],
|
|
123
|
+
selectionEnd = _React$useMemo2[1];
|
|
124
|
+
|
|
125
|
+
// ======================== Modify ========================
|
|
126
|
+
// When input modify content, trigger `onHelp` if is not the format
|
|
127
|
+
var onModify = function onModify(text) {
|
|
128
|
+
if (text && text !== format && text !== value) {
|
|
129
|
+
onHelp();
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
// ======================== Change ========================
|
|
134
|
+
/**
|
|
135
|
+
* Triggered by paste, keyDown and focus to show format
|
|
136
|
+
*/
|
|
137
|
+
var triggerInputChange = useEvent(function (text) {
|
|
138
|
+
if (validateFormat(text)) {
|
|
139
|
+
onChange(text);
|
|
140
|
+
}
|
|
141
|
+
setInputValue(text);
|
|
142
|
+
onModify(text);
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
// Directly trigger `onChange` if `format` is empty
|
|
146
|
+
var onInternalChange = function onInternalChange(event) {
|
|
147
|
+
// Hack `onChange` with format to do nothing
|
|
148
|
+
if (!format) {
|
|
149
|
+
var text = event.target.value;
|
|
150
|
+
onModify(text);
|
|
151
|
+
setInputValue(text);
|
|
152
|
+
onChange(text);
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
var onFormatPaste = function onFormatPaste(event) {
|
|
156
|
+
// Get paste text
|
|
157
|
+
var pasteText = event.clipboardData.getData('text');
|
|
158
|
+
if (validateFormat(pasteText)) {
|
|
159
|
+
triggerInputChange(pasteText);
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
// ======================== Mouse =========================
|
|
164
|
+
// When `mouseDown` get focus, it's better to not to change the selection
|
|
165
|
+
// Since the up position maybe not is the first cell
|
|
166
|
+
var mouseDownRef = React.useRef(false);
|
|
167
|
+
var onFormatMouseDown = function onFormatMouseDown() {
|
|
168
|
+
mouseDownRef.current = true;
|
|
169
|
+
};
|
|
170
|
+
var onFormatMouseUp = function onFormatMouseUp(event) {
|
|
171
|
+
var _ref = event.target,
|
|
172
|
+
start = _ref.selectionStart;
|
|
173
|
+
var closeMaskIndex = maskFormat.getMaskCellIndex(start);
|
|
174
|
+
setFocusCellIndex(closeMaskIndex);
|
|
175
|
+
|
|
176
|
+
// Force update the selection
|
|
177
|
+
forceSelectionSync({});
|
|
178
|
+
onMouseUp === null || onMouseUp === void 0 || onMouseUp(event);
|
|
179
|
+
mouseDownRef.current = false;
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
// ====================== Focus Blur ======================
|
|
183
|
+
var onFormatFocus = function onFormatFocus(event) {
|
|
184
|
+
setFocused(true);
|
|
185
|
+
setFocusCellIndex(0);
|
|
186
|
+
setFocusCellText('');
|
|
187
|
+
onFocus(event);
|
|
188
|
+
};
|
|
189
|
+
var onSharedBlur = function onSharedBlur(event) {
|
|
190
|
+
onBlur(event);
|
|
191
|
+
};
|
|
192
|
+
var onFormatBlur = function onFormatBlur(event) {
|
|
193
|
+
setFocused(false);
|
|
194
|
+
onSharedBlur(event);
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
// ======================== Active ========================
|
|
198
|
+
// Check if blur need reset input value
|
|
199
|
+
useLockEffect(active, function () {
|
|
200
|
+
if (!active && !preserveInvalidOnBlur) {
|
|
201
|
+
setInputValue(value);
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
// ======================= Keyboard =======================
|
|
206
|
+
var onSharedKeyDown = function onSharedKeyDown(event) {
|
|
207
|
+
if (event.key === 'Enter' && validateFormat(inputValue)) {
|
|
208
|
+
onSubmit();
|
|
209
|
+
}
|
|
210
|
+
onKeyDown === null || onKeyDown === void 0 || onKeyDown(event);
|
|
211
|
+
};
|
|
212
|
+
var onFormatKeyDown = function onFormatKeyDown(event) {
|
|
213
|
+
onSharedKeyDown(event);
|
|
214
|
+
var key = event.key;
|
|
215
|
+
|
|
216
|
+
// Save the cache with cell text
|
|
217
|
+
var nextCellText = null;
|
|
218
|
+
|
|
219
|
+
// Fill in the input
|
|
220
|
+
var nextFillText = null;
|
|
221
|
+
var maskCellLen = selectionEnd - selectionStart;
|
|
222
|
+
var cellFormat = format.slice(selectionStart, selectionEnd);
|
|
223
|
+
|
|
224
|
+
// Cell Index
|
|
225
|
+
var offsetCellIndex = function offsetCellIndex(offset) {
|
|
226
|
+
setFocusCellIndex(function (idx) {
|
|
227
|
+
var nextIndex = idx + offset;
|
|
228
|
+
nextIndex = Math.max(nextIndex, 0);
|
|
229
|
+
nextIndex = Math.min(nextIndex, maskFormat.size() - 1);
|
|
230
|
+
return nextIndex;
|
|
231
|
+
});
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
// Range
|
|
235
|
+
var offsetCellValue = function offsetCellValue(offset) {
|
|
236
|
+
var _getMaskRange = getMaskRange(cellFormat),
|
|
237
|
+
_getMaskRange2 = _slicedToArray(_getMaskRange, 3),
|
|
238
|
+
rangeStart = _getMaskRange2[0],
|
|
239
|
+
rangeEnd = _getMaskRange2[1],
|
|
240
|
+
rangeDefault = _getMaskRange2[2];
|
|
241
|
+
var currentText = inputValue.slice(selectionStart, selectionEnd);
|
|
242
|
+
var currentTextNum = Number(currentText);
|
|
243
|
+
if (isNaN(currentTextNum)) {
|
|
244
|
+
return String(rangeDefault ? rangeDefault : offset > 0 ? rangeStart : rangeEnd);
|
|
245
|
+
}
|
|
246
|
+
var num = currentTextNum + offset;
|
|
247
|
+
var range = rangeEnd - rangeStart + 1;
|
|
248
|
+
return String(rangeStart + (range + num - rangeStart) % range);
|
|
249
|
+
};
|
|
250
|
+
switch (key) {
|
|
251
|
+
// =============== Remove ===============
|
|
252
|
+
case 'Backspace':
|
|
253
|
+
case 'Delete':
|
|
254
|
+
nextCellText = '';
|
|
255
|
+
nextFillText = cellFormat;
|
|
256
|
+
break;
|
|
257
|
+
|
|
258
|
+
// =============== Arrows ===============
|
|
259
|
+
// Left key
|
|
260
|
+
case 'ArrowLeft':
|
|
261
|
+
nextCellText = '';
|
|
262
|
+
offsetCellIndex(-1);
|
|
263
|
+
break;
|
|
264
|
+
|
|
265
|
+
// Right key
|
|
266
|
+
case 'ArrowRight':
|
|
267
|
+
nextCellText = '';
|
|
268
|
+
offsetCellIndex(1);
|
|
269
|
+
break;
|
|
270
|
+
|
|
271
|
+
// Up key
|
|
272
|
+
case 'ArrowUp':
|
|
273
|
+
nextCellText = '';
|
|
274
|
+
nextFillText = offsetCellValue(1);
|
|
275
|
+
break;
|
|
276
|
+
|
|
277
|
+
// Down key
|
|
278
|
+
case 'ArrowDown':
|
|
279
|
+
nextCellText = '';
|
|
280
|
+
nextFillText = offsetCellValue(-1);
|
|
281
|
+
break;
|
|
282
|
+
|
|
283
|
+
// =============== Number ===============
|
|
284
|
+
default:
|
|
285
|
+
if (!isNaN(Number(key))) {
|
|
286
|
+
nextCellText = focusCellText + key;
|
|
287
|
+
nextFillText = nextCellText;
|
|
288
|
+
}
|
|
289
|
+
break;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
// Update cell text
|
|
293
|
+
if (nextCellText !== null) {
|
|
294
|
+
setFocusCellText(nextCellText);
|
|
295
|
+
if (nextCellText.length >= maskCellLen) {
|
|
296
|
+
// Go to next cell
|
|
297
|
+
offsetCellIndex(1);
|
|
298
|
+
setFocusCellText('');
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
// Update the input text
|
|
303
|
+
if (nextFillText !== null) {
|
|
304
|
+
// Replace selection range with `nextCellText`
|
|
305
|
+
var nextFocusValue =
|
|
306
|
+
// before
|
|
307
|
+
inputValue.slice(0, selectionStart) +
|
|
308
|
+
// replace
|
|
309
|
+
leftPad(nextFillText, maskCellLen) +
|
|
310
|
+
// after
|
|
311
|
+
inputValue.slice(selectionEnd);
|
|
312
|
+
triggerInputChange(nextFocusValue.slice(0, format.length));
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
// Always trigger selection sync after key down
|
|
316
|
+
forceSelectionSync({});
|
|
317
|
+
};
|
|
318
|
+
|
|
319
|
+
// ======================== Format ========================
|
|
320
|
+
var rafRef = React.useRef();
|
|
321
|
+
useLayoutEffect(function () {
|
|
322
|
+
if (!focused || !format || mouseDownRef.current) {
|
|
323
|
+
return;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
// Reset with format if not match
|
|
327
|
+
if (!maskFormat.match(inputValue)) {
|
|
328
|
+
triggerInputChange(format);
|
|
329
|
+
return;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
// Match the selection range
|
|
333
|
+
inputRef.current.setSelectionRange(selectionStart, selectionEnd);
|
|
334
|
+
|
|
335
|
+
// Chrome has the bug anchor position looks not correct but actually correct
|
|
336
|
+
rafRef.current = raf(function () {
|
|
337
|
+
inputRef.current.setSelectionRange(selectionStart, selectionEnd);
|
|
338
|
+
});
|
|
339
|
+
return function () {
|
|
340
|
+
raf.cancel(rafRef.current);
|
|
341
|
+
};
|
|
342
|
+
}, [maskFormat, format, focused, inputValue, focusCellIndex, selectionStart, selectionEnd, forceSelectionSyncMark, triggerInputChange]);
|
|
343
|
+
|
|
344
|
+
// ======================== Render ========================
|
|
345
|
+
// Input props for format
|
|
346
|
+
var inputProps = format ? {
|
|
347
|
+
onFocus: onFormatFocus,
|
|
348
|
+
onBlur: onFormatBlur,
|
|
349
|
+
onKeyDown: onFormatKeyDown,
|
|
350
|
+
onMouseDown: onFormatMouseDown,
|
|
351
|
+
onMouseUp: onFormatMouseUp,
|
|
352
|
+
onPaste: onFormatPaste
|
|
353
|
+
} : {};
|
|
354
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
355
|
+
ref: holderRef,
|
|
356
|
+
className: classNames(inputPrefixCls, _defineProperty(_defineProperty({}, "".concat(inputPrefixCls, "-active"), active && showActiveCls), "".concat(inputPrefixCls, "-placeholder"), helped))
|
|
357
|
+
}, /*#__PURE__*/React.createElement(Component, _extends({
|
|
358
|
+
ref: inputRef,
|
|
359
|
+
"aria-invalid": invalid,
|
|
360
|
+
autoComplete: "off"
|
|
361
|
+
}, restProps, {
|
|
362
|
+
onKeyDown: onSharedKeyDown,
|
|
363
|
+
onBlur: onSharedBlur
|
|
364
|
+
// Replace with format
|
|
365
|
+
}, inputProps, {
|
|
366
|
+
// Value
|
|
367
|
+
value: inputValue,
|
|
368
|
+
onChange: onInternalChange
|
|
369
|
+
})), /*#__PURE__*/React.createElement(Icon, {
|
|
370
|
+
type: "suffix",
|
|
371
|
+
icon: suffixIcon
|
|
372
|
+
}), clearIcon);
|
|
373
|
+
});
|
|
374
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
375
|
+
Input.displayName = 'Input';
|
|
376
|
+
}
|
|
377
|
+
export default Input;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
declare const FORMAT_KEYS: string[];
|
|
2
|
+
export type FormatKey = (typeof FORMAT_KEYS)[number];
|
|
3
|
+
export interface Cell {
|
|
4
|
+
text: string;
|
|
5
|
+
mask: boolean;
|
|
6
|
+
start: number;
|
|
7
|
+
end: number;
|
|
8
|
+
}
|
|
9
|
+
export default class MaskFormat {
|
|
10
|
+
format: string;
|
|
11
|
+
maskFormat: string;
|
|
12
|
+
cells: Cell[];
|
|
13
|
+
maskCells: Cell[];
|
|
14
|
+
constructor(format: string);
|
|
15
|
+
getSelection(maskCellIndex: number): [start: number, end: number];
|
|
16
|
+
/** Check given text match format */
|
|
17
|
+
match(text: string): boolean;
|
|
18
|
+
/** Get mask cell count */
|
|
19
|
+
size(): number;
|
|
20
|
+
getMaskCellIndex(anchorIndex: number): number;
|
|
21
|
+
}
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,107 @@
|
|
|
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 _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
3
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
4
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
5
|
+
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; }
|
|
6
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
7
|
+
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); }
|
|
8
|
+
var FORMAT_KEYS = ['YYYY', 'MM', 'DD', 'HH', 'mm', 'ss', 'SSS'];
|
|
9
|
+
// Use Chinese character to avoid conflict with the mask format
|
|
10
|
+
var REPLACE_KEY = '顧';
|
|
11
|
+
var MaskFormat = /*#__PURE__*/function () {
|
|
12
|
+
function MaskFormat(format) {
|
|
13
|
+
_classCallCheck(this, MaskFormat);
|
|
14
|
+
_defineProperty(this, "format", void 0);
|
|
15
|
+
_defineProperty(this, "maskFormat", void 0);
|
|
16
|
+
_defineProperty(this, "cells", void 0);
|
|
17
|
+
_defineProperty(this, "maskCells", void 0);
|
|
18
|
+
this.format = format;
|
|
19
|
+
|
|
20
|
+
// Generate mask format
|
|
21
|
+
var replaceKeys = FORMAT_KEYS.map(function (key) {
|
|
22
|
+
return "(".concat(key, ")");
|
|
23
|
+
}).join('|');
|
|
24
|
+
var replaceReg = new RegExp(replaceKeys, 'g');
|
|
25
|
+
this.maskFormat = format.replace(replaceReg,
|
|
26
|
+
// Use Chinese character to avoid user use it in format
|
|
27
|
+
function (key) {
|
|
28
|
+
return REPLACE_KEY.repeat(key.length);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
// Generate cells
|
|
32
|
+
var cellReg = new RegExp("(".concat(FORMAT_KEYS.join('|'), ")"));
|
|
33
|
+
var strCells = (format.split(cellReg) || []).filter(function (str) {
|
|
34
|
+
return str;
|
|
35
|
+
});
|
|
36
|
+
var offset = 0;
|
|
37
|
+
this.cells = strCells.map(function (text) {
|
|
38
|
+
var mask = FORMAT_KEYS.includes(text);
|
|
39
|
+
var start = offset;
|
|
40
|
+
var end = offset + text.length;
|
|
41
|
+
offset = end;
|
|
42
|
+
return {
|
|
43
|
+
text: text,
|
|
44
|
+
mask: mask,
|
|
45
|
+
start: start,
|
|
46
|
+
end: end
|
|
47
|
+
};
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
// Mask cells
|
|
51
|
+
this.maskCells = this.cells.filter(function (cell) {
|
|
52
|
+
return cell.mask;
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
_createClass(MaskFormat, [{
|
|
56
|
+
key: "getSelection",
|
|
57
|
+
value: function getSelection(maskCellIndex) {
|
|
58
|
+
var _ref = this.maskCells[maskCellIndex] || {},
|
|
59
|
+
start = _ref.start,
|
|
60
|
+
end = _ref.end;
|
|
61
|
+
return [start || 0, end || 0];
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** Check given text match format */
|
|
65
|
+
}, {
|
|
66
|
+
key: "match",
|
|
67
|
+
value: function match(text) {
|
|
68
|
+
for (var i = 0; i < this.maskFormat.length; i += 1) {
|
|
69
|
+
var maskChar = this.maskFormat[i];
|
|
70
|
+
var textChar = text[i];
|
|
71
|
+
if (!textChar || maskChar !== REPLACE_KEY && maskChar !== textChar) {
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** Get mask cell count */
|
|
79
|
+
}, {
|
|
80
|
+
key: "size",
|
|
81
|
+
value: function size() {
|
|
82
|
+
return this.maskCells.length;
|
|
83
|
+
}
|
|
84
|
+
}, {
|
|
85
|
+
key: "getMaskCellIndex",
|
|
86
|
+
value: function getMaskCellIndex(anchorIndex) {
|
|
87
|
+
var closetDist = Number.MAX_SAFE_INTEGER;
|
|
88
|
+
var closetIndex = 0;
|
|
89
|
+
for (var i = 0; i < this.maskCells.length; i += 1) {
|
|
90
|
+
var _this$maskCells$i = this.maskCells[i],
|
|
91
|
+
start = _this$maskCells$i.start,
|
|
92
|
+
end = _this$maskCells$i.end;
|
|
93
|
+
if (anchorIndex >= start && anchorIndex <= end) {
|
|
94
|
+
return i;
|
|
95
|
+
}
|
|
96
|
+
var dist = Math.min(Math.abs(anchorIndex - start), Math.abs(anchorIndex - end));
|
|
97
|
+
if (dist < closetDist) {
|
|
98
|
+
closetDist = dist;
|
|
99
|
+
closetIndex = i;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return closetIndex;
|
|
103
|
+
}
|
|
104
|
+
}]);
|
|
105
|
+
return MaskFormat;
|
|
106
|
+
}();
|
|
107
|
+
export { MaskFormat as default };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { RangePickerRef, SelectorProps } from '../../interface';
|
|
3
|
+
export type SelectorIdType = string | {
|
|
4
|
+
start?: string;
|
|
5
|
+
end?: string;
|
|
6
|
+
};
|
|
7
|
+
export interface RangeSelectorProps<DateType = any> extends SelectorProps<DateType> {
|
|
8
|
+
id?: SelectorIdType;
|
|
9
|
+
activeIndex: number | null;
|
|
10
|
+
separator?: React.ReactNode;
|
|
11
|
+
value?: [DateType?, DateType?];
|
|
12
|
+
onChange: (date: DateType, index?: number) => void;
|
|
13
|
+
disabled: [boolean, boolean];
|
|
14
|
+
/** All the field show as `placeholder` */
|
|
15
|
+
allHelp: boolean;
|
|
16
|
+
placeholder?: string | [string, string];
|
|
17
|
+
invalid: [boolean, boolean];
|
|
18
|
+
placement?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Trigger when the active bar offset position changed.
|
|
21
|
+
* This is used for popup panel offset.
|
|
22
|
+
*/
|
|
23
|
+
onActiveInfo: (info: [activeInputLeft: number, activeInputRight: number, selectorWidth: number]) => void;
|
|
24
|
+
}
|
|
25
|
+
declare const RefRangeSelector: React.ForwardRefExoticComponent<RangeSelectorProps<object> & React.RefAttributes<RangePickerRef>>;
|
|
26
|
+
export default RefRangeSelector;
|