@v-c/picker 0.0.1
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 +21 -0
- package/dist/PickerInput/Popup/Footer.cjs +115 -0
- package/dist/PickerInput/Popup/Footer.d.ts +19 -0
- package/dist/PickerInput/Popup/Footer.js +109 -0
- package/dist/PickerInput/Popup/PopupPanel.cjs +413 -0
- package/dist/PickerInput/Popup/PopupPanel.d.ts +11 -0
- package/dist/PickerInput/Popup/PopupPanel.js +407 -0
- package/dist/PickerInput/Popup/PresetPanel.cjs +54 -0
- package/dist/PickerInput/Popup/PresetPanel.d.ts +16 -0
- package/dist/PickerInput/Popup/PresetPanel.js +48 -0
- package/dist/PickerInput/Popup/index.cjs +528 -0
- package/dist/PickerInput/Popup/index.d.ts +37 -0
- package/dist/PickerInput/Popup/index.js +522 -0
- package/dist/PickerInput/RangePicker.cjs +1910 -0
- package/dist/PickerInput/RangePicker.d.ts +57 -0
- package/dist/PickerInput/RangePicker.js +1901 -0
- package/dist/PickerInput/Selector/Icon.cjs +89 -0
- package/dist/PickerInput/Selector/Icon.d.ts +11 -0
- package/dist/PickerInput/Selector/Icon.js +83 -0
- package/dist/PickerInput/Selector/Input.cjs +376 -0
- package/dist/PickerInput/Selector/Input.d.ts +9 -0
- package/dist/PickerInput/Selector/Input.js +370 -0
- package/dist/PickerInput/Selector/MaskFormat.cjs +72 -0
- package/dist/PickerInput/Selector/MaskFormat.d.ts +22 -0
- package/dist/PickerInput/Selector/MaskFormat.js +68 -0
- package/dist/PickerInput/Selector/RangeSelector.cjs +1390 -0
- package/dist/PickerInput/Selector/RangeSelector.d.ts +28 -0
- package/dist/PickerInput/Selector/RangeSelector.js +1383 -0
- package/dist/PickerInput/Selector/SingleSelector/MultipleDates.cjs +110 -0
- package/dist/PickerInput/Selector/SingleSelector/MultipleDates.d.ts +13 -0
- package/dist/PickerInput/Selector/SingleSelector/MultipleDates.js +103 -0
- package/dist/PickerInput/Selector/SingleSelector/index.cjs +1358 -0
- package/dist/PickerInput/Selector/SingleSelector/index.d.ts +21 -0
- package/dist/PickerInput/Selector/SingleSelector/index.js +1352 -0
- package/dist/PickerInput/Selector/hooks/useClearIcon.cjs +17 -0
- package/dist/PickerInput/Selector/hooks/useClearIcon.d.ts +17 -0
- package/dist/PickerInput/Selector/hooks/useClearIcon.js +11 -0
- package/dist/PickerInput/Selector/hooks/useInputHooks.cjs +125 -0
- package/dist/PickerInput/Selector/hooks/useInputHooks.d.ts +56 -0
- package/dist/PickerInput/Selector/hooks/useInputHooks.js +120 -0
- package/dist/PickerInput/Selector/hooks/useRootProps.cjs +14 -0
- package/dist/PickerInput/Selector/hooks/useRootProps.d.ts +2 -0
- package/dist/PickerInput/Selector/hooks/useRootProps.js +9 -0
- package/dist/PickerInput/Selector/util.cjs +32 -0
- package/dist/PickerInput/Selector/util.d.ts +5 -0
- package/dist/PickerInput/Selector/util.js +30 -0
- package/dist/PickerInput/SinglePicker.cjs +1881 -0
- package/dist/PickerInput/SinglePicker.d.ts +46 -0
- package/dist/PickerInput/SinglePicker.js +1873 -0
- package/dist/PickerInput/context.cjs +12 -0
- package/dist/PickerInput/context.d.ts +16 -0
- package/dist/PickerInput/context.js +9 -0
- package/dist/PickerInput/hooks/useCellRender.cjs +25 -0
- package/dist/PickerInput/hooks/useCellRender.d.ts +3 -0
- package/dist/PickerInput/hooks/useCellRender.js +20 -0
- package/dist/PickerInput/hooks/useDelayState.cjs +34 -0
- package/dist/PickerInput/hooks/useDelayState.d.ts +2 -0
- package/dist/PickerInput/hooks/useDelayState.js +29 -0
- package/dist/PickerInput/hooks/useDisabledBoundary.cjs +15 -0
- package/dist/PickerInput/hooks/useDisabledBoundary.d.ts +8 -0
- package/dist/PickerInput/hooks/useDisabledBoundary.js +11 -0
- package/dist/PickerInput/hooks/useFieldFormat.cjs +17 -0
- package/dist/PickerInput/hooks/useFieldFormat.d.ts +3 -0
- package/dist/PickerInput/hooks/useFieldFormat.js +15 -0
- package/dist/PickerInput/hooks/useFieldsInvalidate.cjs +24 -0
- package/dist/PickerInput/hooks/useFieldsInvalidate.d.ts +6 -0
- package/dist/PickerInput/hooks/useFieldsInvalidate.js +19 -0
- package/dist/PickerInput/hooks/useFilledProps.cjs +103 -0
- package/dist/PickerInput/hooks/useFilledProps.d.ts +33 -0
- package/dist/PickerInput/hooks/useFilledProps.js +98 -0
- package/dist/PickerInput/hooks/useInputReadOnly.cjs +13 -0
- package/dist/PickerInput/hooks/useInputReadOnly.d.ts +3 -0
- package/dist/PickerInput/hooks/useInputReadOnly.js +8 -0
- package/dist/PickerInput/hooks/useInvalidate.cjs +34 -0
- package/dist/PickerInput/hooks/useInvalidate.d.ts +10 -0
- package/dist/PickerInput/hooks/useInvalidate.js +30 -0
- package/dist/PickerInput/hooks/useLockEffect.cjs +16 -0
- package/dist/PickerInput/hooks/useLockEffect.d.ts +6 -0
- package/dist/PickerInput/hooks/useLockEffect.js +11 -0
- package/dist/PickerInput/hooks/useOpen.cjs +15 -0
- package/dist/PickerInput/hooks/useOpen.d.ts +7 -0
- package/dist/PickerInput/hooks/useOpen.js +10 -0
- package/dist/PickerInput/hooks/usePresets.cjs +21 -0
- package/dist/PickerInput/hooks/usePresets.d.ts +3 -0
- package/dist/PickerInput/hooks/usePresets.js +16 -0
- package/dist/PickerInput/hooks/useRangeActive.cjs +57 -0
- package/dist/PickerInput/hooks/useRangeActive.d.ts +9 -0
- package/dist/PickerInput/hooks/useRangeActive.js +52 -0
- package/dist/PickerInput/hooks/useRangeDisabledDate.cjs +21 -0
- package/dist/PickerInput/hooks/useRangeDisabledDate.d.ts +9 -0
- package/dist/PickerInput/hooks/useRangeDisabledDate.js +17 -0
- package/dist/PickerInput/hooks/useRangePickerValue.cjs +100 -0
- package/dist/PickerInput/hooks/useRangePickerValue.d.ts +5 -0
- package/dist/PickerInput/hooks/useRangePickerValue.js +94 -0
- package/dist/PickerInput/hooks/useRangeValue.cjs +134 -0
- package/dist/PickerInput/hooks/useRangeValue.d.ts +21 -0
- package/dist/PickerInput/hooks/useRangeValue.js +128 -0
- package/dist/PickerInput/hooks/useShowNow.cjs +15 -0
- package/dist/PickerInput/hooks/useShowNow.d.ts +3 -0
- package/dist/PickerInput/hooks/useShowNow.js +10 -0
- package/dist/PickerPanel/DatePanel/index.cjs +294 -0
- package/dist/PickerPanel/DatePanel/index.d.ts +9 -0
- package/dist/PickerPanel/DatePanel/index.js +288 -0
- package/dist/PickerPanel/DateTimePanel/index.cjs +180 -0
- package/dist/PickerPanel/DateTimePanel/index.d.ts +3 -0
- package/dist/PickerPanel/DateTimePanel/index.js +174 -0
- package/dist/PickerPanel/DecadePanel/index.cjs +230 -0
- package/dist/PickerPanel/DecadePanel/index.d.ts +3 -0
- package/dist/PickerPanel/DecadePanel/index.js +224 -0
- package/dist/PickerPanel/MonthPanel/index.cjs +219 -0
- package/dist/PickerPanel/MonthPanel/index.d.ts +3 -0
- package/dist/PickerPanel/MonthPanel/index.js +213 -0
- package/dist/PickerPanel/PanelBody.cjs +157 -0
- package/dist/PickerPanel/PanelBody.d.ts +17 -0
- package/dist/PickerPanel/PanelBody.js +151 -0
- package/dist/PickerPanel/PanelHeader.cjs +132 -0
- package/dist/PickerPanel/PanelHeader.d.ts +9 -0
- package/dist/PickerPanel/PanelHeader.js +126 -0
- package/dist/PickerPanel/QuarterPanel/index.cjs +211 -0
- package/dist/PickerPanel/QuarterPanel/index.d.ts +3 -0
- package/dist/PickerPanel/QuarterPanel/index.js +205 -0
- package/dist/PickerPanel/TimePanel/TimePanelBody/TimeColumn.cjs +145 -0
- package/dist/PickerPanel/TimePanel/TimePanelBody/TimeColumn.d.ts +17 -0
- package/dist/PickerPanel/TimePanel/TimePanelBody/TimeColumn.js +139 -0
- package/dist/PickerPanel/TimePanel/TimePanelBody/index.cjs +286 -0
- package/dist/PickerPanel/TimePanel/TimePanelBody/index.d.ts +3 -0
- package/dist/PickerPanel/TimePanel/TimePanelBody/index.js +280 -0
- package/dist/PickerPanel/TimePanel/TimePanelBody/useScrollTo.cjs +65 -0
- package/dist/PickerPanel/TimePanel/TimePanelBody/useScrollTo.d.ts +1 -0
- package/dist/PickerPanel/TimePanel/TimePanelBody/useScrollTo.js +60 -0
- package/dist/PickerPanel/TimePanel/index.cjs +173 -0
- package/dist/PickerPanel/TimePanel/index.d.ts +3 -0
- package/dist/PickerPanel/TimePanel/index.js +167 -0
- package/dist/PickerPanel/WeekPanel/index.cjs +179 -0
- package/dist/PickerPanel/WeekPanel/index.d.ts +3 -0
- package/dist/PickerPanel/WeekPanel/index.js +173 -0
- package/dist/PickerPanel/YearPanel/index.cjs +239 -0
- package/dist/PickerPanel/YearPanel/index.d.ts +3 -0
- package/dist/PickerPanel/YearPanel/index.js +233 -0
- package/dist/PickerPanel/context.cjs +61 -0
- package/dist/PickerPanel/context.d.ts +26 -0
- package/dist/PickerPanel/context.js +53 -0
- package/dist/PickerPanel/index.cjs +473 -0
- package/dist/PickerPanel/index.d.ts +65 -0
- package/dist/PickerPanel/index.js +467 -0
- package/dist/PickerTrigger/index.cjs +137 -0
- package/dist/PickerTrigger/index.d.ts +18 -0
- package/dist/PickerTrigger/index.js +130 -0
- package/dist/PickerTrigger/util.cjs +13 -0
- package/dist/PickerTrigger/util.d.ts +2 -0
- package/dist/PickerTrigger/util.js +12 -0
- package/dist/_virtual/rolldown_runtime.cjs +21 -0
- package/dist/generate/dateFns.cjs +80 -0
- package/dist/generate/dateFns.d.ts +3 -0
- package/dist/generate/dateFns.js +73 -0
- package/dist/generate/dayjs.cjs +117 -0
- package/dist/generate/dayjs.d.ts +4 -0
- package/dist/generate/dayjs.js +104 -0
- package/dist/generate/index.cjs +1 -0
- package/dist/generate/index.d.ts +37 -0
- package/dist/generate/index.js +0 -0
- package/dist/generate/luxon.cjs +75 -0
- package/dist/generate/luxon.d.ts +4 -0
- package/dist/generate/luxon.js +69 -0
- package/dist/generate/moment.cjs +107 -0
- package/dist/generate/moment.d.ts +4 -0
- package/dist/generate/moment.js +100 -0
- package/dist/hooks/useLocale.cjs +45 -0
- package/dist/hooks/useLocale.d.ts +9 -0
- package/dist/hooks/useLocale.js +39 -0
- package/dist/hooks/useSemantic.cjs +18 -0
- package/dist/hooks/useSemantic.d.ts +14 -0
- package/dist/hooks/useSemantic.js +13 -0
- package/dist/hooks/useSyncState.cjs +29 -0
- package/dist/hooks/useSyncState.d.ts +7 -0
- package/dist/hooks/useSyncState.js +24 -0
- package/dist/hooks/useTimeConfig.cjs +161 -0
- package/dist/hooks/useTimeConfig.d.ts +18 -0
- package/dist/hooks/useTimeConfig.js +159 -0
- package/dist/hooks/useTimeInfo.cjs +113 -0
- package/dist/hooks/useTimeInfo.d.ts +12 -0
- package/dist/hooks/useTimeInfo.js +108 -0
- package/dist/hooks/useToggleDates.cjs +16 -0
- package/dist/hooks/useToggleDates.d.ts +9 -0
- package/dist/hooks/useToggleDates.js +12 -0
- package/dist/index.cjs +12 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +5 -0
- package/dist/interface.cjs +1 -0
- package/dist/interface.d.ts +379 -0
- package/dist/interface.js +0 -0
- package/dist/locale/am_ET.cjs +34 -0
- package/dist/locale/am_ET.d.ts +3 -0
- package/dist/locale/am_ET.js +29 -0
- package/dist/locale/ar_EG.cjs +32 -0
- package/dist/locale/ar_EG.d.ts +3 -0
- package/dist/locale/ar_EG.js +27 -0
- package/dist/locale/az_AZ.cjs +33 -0
- package/dist/locale/az_AZ.d.ts +3 -0
- package/dist/locale/az_AZ.js +28 -0
- package/dist/locale/bg_BG.cjs +32 -0
- package/dist/locale/bg_BG.d.ts +3 -0
- package/dist/locale/bg_BG.js +27 -0
- package/dist/locale/bn_BD.cjs +33 -0
- package/dist/locale/bn_BD.d.ts +3 -0
- package/dist/locale/bn_BD.js +28 -0
- package/dist/locale/by_BY.cjs +33 -0
- package/dist/locale/by_BY.d.ts +3 -0
- package/dist/locale/by_BY.js +28 -0
- package/dist/locale/ca_ES.cjs +32 -0
- package/dist/locale/ca_ES.d.ts +3 -0
- package/dist/locale/ca_ES.js +27 -0
- package/dist/locale/common.cjs +8 -0
- package/dist/locale/common.d.ts +2 -0
- package/dist/locale/common.js +7 -0
- package/dist/locale/cs_CZ.cjs +32 -0
- package/dist/locale/cs_CZ.d.ts +3 -0
- package/dist/locale/cs_CZ.js +27 -0
- package/dist/locale/da_DK.cjs +32 -0
- package/dist/locale/da_DK.d.ts +3 -0
- package/dist/locale/da_DK.js +27 -0
- package/dist/locale/de_DE.cjs +32 -0
- package/dist/locale/de_DE.d.ts +3 -0
- package/dist/locale/de_DE.js +27 -0
- package/dist/locale/el_GR.cjs +32 -0
- package/dist/locale/el_GR.d.ts +3 -0
- package/dist/locale/el_GR.js +27 -0
- package/dist/locale/en_GB.cjs +32 -0
- package/dist/locale/en_GB.d.ts +3 -0
- package/dist/locale/en_GB.js +27 -0
- package/dist/locale/en_US.cjs +33 -0
- package/dist/locale/en_US.d.ts +3 -0
- package/dist/locale/en_US.js +28 -0
- package/dist/locale/es_ES.cjs +32 -0
- package/dist/locale/es_ES.d.ts +3 -0
- package/dist/locale/es_ES.js +27 -0
- package/dist/locale/es_MX.cjs +33 -0
- package/dist/locale/es_MX.d.ts +3 -0
- package/dist/locale/es_MX.js +28 -0
- package/dist/locale/et_EE.cjs +32 -0
- package/dist/locale/et_EE.d.ts +3 -0
- package/dist/locale/et_EE.js +27 -0
- package/dist/locale/eu_ES.cjs +34 -0
- package/dist/locale/eu_ES.d.ts +3 -0
- package/dist/locale/eu_ES.js +29 -0
- package/dist/locale/fa_IR.cjs +32 -0
- package/dist/locale/fa_IR.d.ts +3 -0
- package/dist/locale/fa_IR.js +27 -0
- package/dist/locale/fi_FI.cjs +32 -0
- package/dist/locale/fi_FI.d.ts +3 -0
- package/dist/locale/fi_FI.js +27 -0
- package/dist/locale/fr_BE.cjs +32 -0
- package/dist/locale/fr_BE.d.ts +3 -0
- package/dist/locale/fr_BE.js +27 -0
- package/dist/locale/fr_CA.cjs +33 -0
- package/dist/locale/fr_CA.d.ts +3 -0
- package/dist/locale/fr_CA.js +28 -0
- package/dist/locale/fr_FR.cjs +33 -0
- package/dist/locale/fr_FR.d.ts +3 -0
- package/dist/locale/fr_FR.js +28 -0
- package/dist/locale/ga_IE.cjs +33 -0
- package/dist/locale/ga_IE.d.ts +3 -0
- package/dist/locale/ga_IE.js +28 -0
- package/dist/locale/gl_ES.cjs +32 -0
- package/dist/locale/gl_ES.d.ts +3 -0
- package/dist/locale/gl_ES.js +27 -0
- package/dist/locale/he_IL.cjs +33 -0
- package/dist/locale/he_IL.d.ts +3 -0
- package/dist/locale/he_IL.js +28 -0
- package/dist/locale/hi_IN.cjs +33 -0
- package/dist/locale/hi_IN.d.ts +3 -0
- package/dist/locale/hi_IN.js +28 -0
- package/dist/locale/hr_HR.cjs +33 -0
- package/dist/locale/hr_HR.d.ts +3 -0
- package/dist/locale/hr_HR.js +28 -0
- package/dist/locale/hu_HU.cjs +33 -0
- package/dist/locale/hu_HU.d.ts +3 -0
- package/dist/locale/hu_HU.js +28 -0
- package/dist/locale/id_ID.cjs +33 -0
- package/dist/locale/id_ID.d.ts +3 -0
- package/dist/locale/id_ID.js +28 -0
- package/dist/locale/is_IS.cjs +32 -0
- package/dist/locale/is_IS.d.ts +3 -0
- package/dist/locale/is_IS.js +27 -0
- package/dist/locale/it_IT.cjs +55 -0
- package/dist/locale/it_IT.d.ts +3 -0
- package/dist/locale/it_IT.js +50 -0
- package/dist/locale/ja_JP.cjs +35 -0
- package/dist/locale/ja_JP.d.ts +3 -0
- package/dist/locale/ja_JP.js +30 -0
- package/dist/locale/ka_GE.cjs +33 -0
- package/dist/locale/ka_GE.d.ts +3 -0
- package/dist/locale/ka_GE.js +28 -0
- package/dist/locale/kk_KZ.cjs +32 -0
- package/dist/locale/kk_KZ.d.ts +3 -0
- package/dist/locale/kk_KZ.js +27 -0
- package/dist/locale/km_KH.cjs +34 -0
- package/dist/locale/km_KH.d.ts +3 -0
- package/dist/locale/km_KH.js +29 -0
- package/dist/locale/kmr_IQ.cjs +32 -0
- package/dist/locale/kmr_IQ.d.ts +3 -0
- package/dist/locale/kmr_IQ.js +27 -0
- package/dist/locale/kn_IN.cjs +33 -0
- package/dist/locale/kn_IN.d.ts +3 -0
- package/dist/locale/kn_IN.js +28 -0
- package/dist/locale/ko_KR.cjs +34 -0
- package/dist/locale/ko_KR.d.ts +3 -0
- package/dist/locale/ko_KR.js +29 -0
- package/dist/locale/lt_LT.cjs +34 -0
- package/dist/locale/lt_LT.d.ts +3 -0
- package/dist/locale/lt_LT.js +29 -0
- package/dist/locale/lv_LV.cjs +32 -0
- package/dist/locale/lv_LV.d.ts +3 -0
- package/dist/locale/lv_LV.js +27 -0
- package/dist/locale/mk_MK.cjs +32 -0
- package/dist/locale/mk_MK.d.ts +3 -0
- package/dist/locale/mk_MK.js +27 -0
- package/dist/locale/ml_IN.cjs +33 -0
- package/dist/locale/ml_IN.d.ts +3 -0
- package/dist/locale/ml_IN.js +28 -0
- package/dist/locale/mn_MN.cjs +34 -0
- package/dist/locale/mn_MN.d.ts +3 -0
- package/dist/locale/mn_MN.js +29 -0
- package/dist/locale/mr_IN.cjs +59 -0
- package/dist/locale/mr_IN.d.ts +3 -0
- package/dist/locale/mr_IN.js +54 -0
- package/dist/locale/ms_MY.cjs +34 -0
- package/dist/locale/ms_MY.d.ts +3 -0
- package/dist/locale/ms_MY.js +29 -0
- package/dist/locale/my_MM.cjs +33 -0
- package/dist/locale/my_MM.d.ts +3 -0
- package/dist/locale/my_MM.js +28 -0
- package/dist/locale/nb_NO.cjs +34 -0
- package/dist/locale/nb_NO.d.ts +3 -0
- package/dist/locale/nb_NO.js +29 -0
- package/dist/locale/ne_NP.cjs +33 -0
- package/dist/locale/ne_NP.d.ts +3 -0
- package/dist/locale/ne_NP.js +28 -0
- package/dist/locale/nl_BE.cjs +32 -0
- package/dist/locale/nl_BE.d.ts +3 -0
- package/dist/locale/nl_BE.js +27 -0
- package/dist/locale/nl_NL.cjs +32 -0
- package/dist/locale/nl_NL.d.ts +3 -0
- package/dist/locale/nl_NL.js +27 -0
- package/dist/locale/pl_PL.cjs +32 -0
- package/dist/locale/pl_PL.d.ts +3 -0
- package/dist/locale/pl_PL.js +27 -0
- package/dist/locale/pt_BR.cjs +56 -0
- package/dist/locale/pt_BR.d.ts +3 -0
- package/dist/locale/pt_BR.js +51 -0
- package/dist/locale/pt_PT.cjs +55 -0
- package/dist/locale/pt_PT.d.ts +3 -0
- package/dist/locale/pt_PT.js +50 -0
- package/dist/locale/ro_RO.cjs +33 -0
- package/dist/locale/ro_RO.d.ts +3 -0
- package/dist/locale/ro_RO.js +28 -0
- package/dist/locale/ru_RU.cjs +32 -0
- package/dist/locale/ru_RU.d.ts +3 -0
- package/dist/locale/ru_RU.js +27 -0
- package/dist/locale/si_LK.cjs +34 -0
- package/dist/locale/si_LK.d.ts +3 -0
- package/dist/locale/si_LK.js +29 -0
- package/dist/locale/sk_SK.cjs +32 -0
- package/dist/locale/sk_SK.d.ts +3 -0
- package/dist/locale/sk_SK.js +27 -0
- package/dist/locale/sl_SI.cjs +32 -0
- package/dist/locale/sl_SI.d.ts +3 -0
- package/dist/locale/sl_SI.js +27 -0
- package/dist/locale/sr_Cyrl_RS.cjs +32 -0
- package/dist/locale/sr_Cyrl_RS.d.ts +3 -0
- package/dist/locale/sr_Cyrl_RS.js +27 -0
- package/dist/locale/sr_RS.cjs +32 -0
- package/dist/locale/sr_RS.d.ts +3 -0
- package/dist/locale/sr_RS.js +27 -0
- package/dist/locale/sv_SE.cjs +32 -0
- package/dist/locale/sv_SE.d.ts +3 -0
- package/dist/locale/sv_SE.js +27 -0
- package/dist/locale/ta_IN.cjs +33 -0
- package/dist/locale/ta_IN.d.ts +3 -0
- package/dist/locale/ta_IN.js +28 -0
- package/dist/locale/te_IN.cjs +33 -0
- package/dist/locale/te_IN.d.ts +3 -0
- package/dist/locale/te_IN.js +28 -0
- package/dist/locale/th_TH.cjs +32 -0
- package/dist/locale/th_TH.d.ts +3 -0
- package/dist/locale/th_TH.js +27 -0
- package/dist/locale/tk_TK.cjs +32 -0
- package/dist/locale/tk_TK.d.ts +3 -0
- package/dist/locale/tk_TK.js +27 -0
- package/dist/locale/tr_TR.cjs +55 -0
- package/dist/locale/tr_TR.d.ts +3 -0
- package/dist/locale/tr_TR.js +50 -0
- package/dist/locale/ug_CN.cjs +35 -0
- package/dist/locale/ug_CN.d.ts +3 -0
- package/dist/locale/ug_CN.js +30 -0
- package/dist/locale/uk_UA.cjs +32 -0
- package/dist/locale/uk_UA.d.ts +3 -0
- package/dist/locale/uk_UA.js +27 -0
- package/dist/locale/ur_PK.cjs +33 -0
- package/dist/locale/ur_PK.d.ts +3 -0
- package/dist/locale/ur_PK.js +28 -0
- package/dist/locale/uz_UZ.cjs +33 -0
- package/dist/locale/uz_UZ.d.ts +3 -0
- package/dist/locale/uz_UZ.js +28 -0
- package/dist/locale/vi_VN.cjs +33 -0
- package/dist/locale/vi_VN.d.ts +3 -0
- package/dist/locale/vi_VN.js +28 -0
- package/dist/locale/zh_CN.cjs +36 -0
- package/dist/locale/zh_CN.d.ts +3 -0
- package/dist/locale/zh_CN.js +31 -0
- package/dist/locale/zh_TW.cjs +36 -0
- package/dist/locale/zh_TW.d.ts +3 -0
- package/dist/locale/zh_TW.js +31 -0
- package/dist/utils/dateUtil.cjs +105 -0
- package/dist/utils/dateUtil.d.ts +29 -0
- package/dist/utils/dateUtil.js +89 -0
- package/dist/utils/getClearIcon.cjs +7 -0
- package/dist/utils/getClearIcon.d.ts +6 -0
- package/dist/utils/getClearIcon.js +5 -0
- package/dist/utils/miscUtil.cjs +46 -0
- package/dist/utils/miscUtil.d.ts +14 -0
- package/dist/utils/miscUtil.js +40 -0
- package/dist/utils/uiUtil.cjs +6 -0
- package/dist/utils/uiUtil.d.ts +1 -0
- package/dist/utils/uiUtil.js +5 -0
- package/dist/utils/warnUtil.cjs +8 -0
- package/dist/utils/warnUtil.d.ts +5 -0
- package/dist/utils/warnUtil.js +6 -0
- package/package.json +82 -0
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
import { usePickerContext } from "../context.js";
|
|
2
|
+
import { leftPad } from "../../utils/miscUtil.js";
|
|
3
|
+
import { getMaskRange, raf as raf$1 } from "./util.js";
|
|
4
|
+
import useLockEffect from "../hooks/useLockEffect.js";
|
|
5
|
+
import Icon_default from "./Icon.js";
|
|
6
|
+
import MaskFormat from "./MaskFormat.js";
|
|
7
|
+
import { computed, createVNode, defineComponent, mergeProps, onBeforeUnmount, ref, toRef, watch } from "vue";
|
|
8
|
+
import { clsx } from "@v-c/util";
|
|
9
|
+
var Input_default = /* @__PURE__ */ defineComponent((props, { attrs, expose }) => {
|
|
10
|
+
const pickerCtx = usePickerContext();
|
|
11
|
+
const prefixCls = computed(() => pickerCtx.value.prefixCls);
|
|
12
|
+
const classNames = computed(() => pickerCtx.value.classNames);
|
|
13
|
+
const styles = computed(() => pickerCtx.value.styles);
|
|
14
|
+
const inputPrefixCls = computed(() => `${prefixCls.value}-input`);
|
|
15
|
+
const focused = ref(false);
|
|
16
|
+
const internalInputValue = ref(props.value);
|
|
17
|
+
const focusCellText = ref("");
|
|
18
|
+
const focusCellIndex = ref(null);
|
|
19
|
+
const forceSelectionSyncMark = ref(null);
|
|
20
|
+
const inputValue = computed(() => internalInputValue.value || "");
|
|
21
|
+
watch(() => props.value, (val) => {
|
|
22
|
+
internalInputValue.value = val;
|
|
23
|
+
});
|
|
24
|
+
const holderRef = ref();
|
|
25
|
+
const inputRef = ref();
|
|
26
|
+
expose({
|
|
27
|
+
get nativeElement() {
|
|
28
|
+
return holderRef.value;
|
|
29
|
+
},
|
|
30
|
+
get inputElement() {
|
|
31
|
+
return inputRef.value;
|
|
32
|
+
},
|
|
33
|
+
focus: (options) => {
|
|
34
|
+
inputRef.value?.focus(options);
|
|
35
|
+
},
|
|
36
|
+
blur: () => {
|
|
37
|
+
inputRef.value?.blur();
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
const maskFormat = computed(() => new MaskFormat(props.format || ""));
|
|
41
|
+
const selectionRange = computed(() => {
|
|
42
|
+
if (props.helped) return [0, 0];
|
|
43
|
+
return maskFormat.value.getSelection(focusCellIndex.value);
|
|
44
|
+
});
|
|
45
|
+
const selectionStart = computed(() => selectionRange.value[0]);
|
|
46
|
+
const selectionEnd = computed(() => selectionRange.value[1]);
|
|
47
|
+
const onModify = (text) => {
|
|
48
|
+
if (text && text !== props.format && text !== props.value) props?.onHelp?.();
|
|
49
|
+
};
|
|
50
|
+
const triggerInputChange = (text) => {
|
|
51
|
+
if (props.validateFormat?.(text)) props?.onChange?.(text);
|
|
52
|
+
internalInputValue.value = text;
|
|
53
|
+
onModify(text);
|
|
54
|
+
};
|
|
55
|
+
const onInternalChange = (event) => {
|
|
56
|
+
const target = event.target;
|
|
57
|
+
if (!props.format) {
|
|
58
|
+
const text = target.value;
|
|
59
|
+
onModify(text);
|
|
60
|
+
internalInputValue.value = text;
|
|
61
|
+
props?.onChange?.(text);
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
const onFormatPaste = (event) => {
|
|
65
|
+
const pasteText = event.clipboardData?.getData("text") || "";
|
|
66
|
+
if (props?.validateFormat?.(pasteText)) triggerInputChange(pasteText);
|
|
67
|
+
};
|
|
68
|
+
const mouseDownRef = ref(false);
|
|
69
|
+
const onFormatMouseDown = () => {
|
|
70
|
+
mouseDownRef.value = true;
|
|
71
|
+
};
|
|
72
|
+
const onFormatMouseUp = (event) => {
|
|
73
|
+
const { selectionStart: start } = event.target;
|
|
74
|
+
focusCellIndex.value = maskFormat.value.getMaskCellIndex(start);
|
|
75
|
+
forceSelectionSyncMark.value = {};
|
|
76
|
+
props.onMouseUp?.(event);
|
|
77
|
+
mouseDownRef.value = false;
|
|
78
|
+
};
|
|
79
|
+
const onFormatFocus = (event) => {
|
|
80
|
+
focused.value = true;
|
|
81
|
+
focusCellIndex.value = 0;
|
|
82
|
+
focusCellText.value = "";
|
|
83
|
+
props.onFocus?.(event);
|
|
84
|
+
};
|
|
85
|
+
const onSharedBlur = (event) => {
|
|
86
|
+
props.onBlur?.(event);
|
|
87
|
+
};
|
|
88
|
+
const onFormatBlur = (event) => {
|
|
89
|
+
focused.value = false;
|
|
90
|
+
onSharedBlur(event);
|
|
91
|
+
};
|
|
92
|
+
useLockEffect(toRef(props, "active"), () => {
|
|
93
|
+
if (!props.active && !props.preserveInvalidOnBlur) internalInputValue.value = props.value;
|
|
94
|
+
});
|
|
95
|
+
const onSharedKeyDown = (event) => {
|
|
96
|
+
if (event.key === "Enter" && props?.validateFormat?.(inputValue.value)) props?.onSubmit?.();
|
|
97
|
+
props.onKeyDown?.(event);
|
|
98
|
+
};
|
|
99
|
+
const onFormatKeyDown = (event) => {
|
|
100
|
+
onSharedKeyDown(event);
|
|
101
|
+
const { key } = event;
|
|
102
|
+
let nextCellText = null;
|
|
103
|
+
let nextFillText = null;
|
|
104
|
+
const maskCellLen = selectionEnd.value - selectionStart.value;
|
|
105
|
+
const cellFormat = props.format.slice(selectionStart.value, selectionEnd.value);
|
|
106
|
+
const offsetCellIndex = (offset) => {
|
|
107
|
+
let nextIndex = focusCellIndex.value + offset;
|
|
108
|
+
nextIndex = Math.max(nextIndex, 0);
|
|
109
|
+
nextIndex = Math.min(nextIndex, maskFormat.value.size() - 1);
|
|
110
|
+
focusCellIndex.value = nextIndex;
|
|
111
|
+
};
|
|
112
|
+
const offsetCellValue = (offset) => {
|
|
113
|
+
const [rangeStart, rangeEnd, rangeDefault] = getMaskRange(cellFormat);
|
|
114
|
+
const currentText = inputValue.value.slice(selectionStart.value, selectionEnd.value);
|
|
115
|
+
const currentTextNum = Number(currentText);
|
|
116
|
+
if (Number.isNaN(currentTextNum)) return String(rangeDefault || (offset > 0 ? rangeStart : rangeEnd));
|
|
117
|
+
const num = currentTextNum + offset;
|
|
118
|
+
const range = rangeEnd - rangeStart + 1;
|
|
119
|
+
return String(rangeStart + (range + num - rangeStart) % range);
|
|
120
|
+
};
|
|
121
|
+
switch (key) {
|
|
122
|
+
case "Backspace":
|
|
123
|
+
case "Delete":
|
|
124
|
+
nextCellText = "";
|
|
125
|
+
nextFillText = cellFormat;
|
|
126
|
+
break;
|
|
127
|
+
case "ArrowLeft":
|
|
128
|
+
nextCellText = "";
|
|
129
|
+
offsetCellIndex(-1);
|
|
130
|
+
break;
|
|
131
|
+
case "ArrowRight":
|
|
132
|
+
nextCellText = "";
|
|
133
|
+
offsetCellIndex(1);
|
|
134
|
+
break;
|
|
135
|
+
case "ArrowUp":
|
|
136
|
+
nextCellText = "";
|
|
137
|
+
nextFillText = offsetCellValue(1);
|
|
138
|
+
break;
|
|
139
|
+
case "ArrowDown":
|
|
140
|
+
nextCellText = "";
|
|
141
|
+
nextFillText = offsetCellValue(-1);
|
|
142
|
+
break;
|
|
143
|
+
default:
|
|
144
|
+
if (!Number.isNaN(Number(key))) {
|
|
145
|
+
nextCellText = focusCellText.value + key;
|
|
146
|
+
nextFillText = nextCellText;
|
|
147
|
+
}
|
|
148
|
+
break;
|
|
149
|
+
}
|
|
150
|
+
if (nextCellText !== null) {
|
|
151
|
+
focusCellText.value = nextCellText;
|
|
152
|
+
if (nextCellText.length >= maskCellLen) {
|
|
153
|
+
offsetCellIndex(1);
|
|
154
|
+
focusCellText.value = "";
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
if (nextFillText !== null) triggerInputChange((inputValue.value.slice(0, selectionStart.value) + leftPad(nextFillText, maskCellLen) + inputValue.value.slice(selectionEnd.value)).slice(0, props.format.length));
|
|
158
|
+
forceSelectionSyncMark.value = {};
|
|
159
|
+
};
|
|
160
|
+
const rafRef = ref();
|
|
161
|
+
watch([
|
|
162
|
+
maskFormat,
|
|
163
|
+
() => props.format,
|
|
164
|
+
focused,
|
|
165
|
+
inputValue,
|
|
166
|
+
focusCellIndex,
|
|
167
|
+
selectionStart,
|
|
168
|
+
selectionEnd,
|
|
169
|
+
forceSelectionSyncMark
|
|
170
|
+
], () => {
|
|
171
|
+
if (!focused.value || !props.format || mouseDownRef.value) return;
|
|
172
|
+
if (!maskFormat.value.match(inputValue.value)) {
|
|
173
|
+
triggerInputChange(props.format);
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
inputRef.value?.setSelectionRange(selectionStart.value, selectionEnd.value);
|
|
177
|
+
rafRef.value = raf$1(() => {
|
|
178
|
+
inputRef.value?.setSelectionRange(selectionStart.value, selectionEnd.value);
|
|
179
|
+
});
|
|
180
|
+
}, { flush: "post" });
|
|
181
|
+
onBeforeUnmount(() => {
|
|
182
|
+
raf$1.cancel(rafRef.value);
|
|
183
|
+
});
|
|
184
|
+
return () => {
|
|
185
|
+
const { className, active, showActiveCls, suffixIcon, format, validateFormat, onChange, onInput, helped, onHelp, onSubmit, onKeyDown, preserveInvalidOnBlur, invalid, clearIcon, ...restProps } = props;
|
|
186
|
+
const inputProps = props.format ? {
|
|
187
|
+
onFocus: onFormatFocus,
|
|
188
|
+
onBlur: onFormatBlur,
|
|
189
|
+
onKeydown: onFormatKeyDown,
|
|
190
|
+
onMousedown: onFormatMouseDown,
|
|
191
|
+
onMouseup: onFormatMouseUp,
|
|
192
|
+
onPaste: onFormatPaste
|
|
193
|
+
} : {};
|
|
194
|
+
const Component = pickerCtx.value.input ?? "input";
|
|
195
|
+
return createVNode("div", {
|
|
196
|
+
"ref": holderRef,
|
|
197
|
+
"class": clsx(inputPrefixCls.value, {
|
|
198
|
+
[`${inputPrefixCls.value}-active`]: props.active && props.showActiveCls,
|
|
199
|
+
[`${inputPrefixCls.value}-placeholder`]: props.helped
|
|
200
|
+
}, attrs.class),
|
|
201
|
+
"style": attrs.style
|
|
202
|
+
}, [
|
|
203
|
+
createVNode(Component, mergeProps({
|
|
204
|
+
"ref": inputRef,
|
|
205
|
+
"aria-invalid": props.invalid,
|
|
206
|
+
"autoComplete": "off"
|
|
207
|
+
}, attrs, restProps, {
|
|
208
|
+
"onKeydown": onSharedKeyDown,
|
|
209
|
+
"onBlur": onSharedBlur
|
|
210
|
+
}, inputProps, {
|
|
211
|
+
"value": inputValue.value,
|
|
212
|
+
"onInput": onInternalChange,
|
|
213
|
+
"class": classNames.value.input,
|
|
214
|
+
"style": styles.value.input,
|
|
215
|
+
"readonly": props.inputReadOnly
|
|
216
|
+
}), null),
|
|
217
|
+
createVNode(Icon_default, {
|
|
218
|
+
"type": "suffix",
|
|
219
|
+
"icon": props.suffixIcon
|
|
220
|
+
}, null),
|
|
221
|
+
props.clearIcon
|
|
222
|
+
]);
|
|
223
|
+
};
|
|
224
|
+
}, {
|
|
225
|
+
props: {
|
|
226
|
+
readOnly: {
|
|
227
|
+
type: Boolean,
|
|
228
|
+
required: false,
|
|
229
|
+
default: void 0
|
|
230
|
+
},
|
|
231
|
+
required: {
|
|
232
|
+
type: Boolean,
|
|
233
|
+
required: false,
|
|
234
|
+
default: void 0
|
|
235
|
+
},
|
|
236
|
+
"aria-required": {
|
|
237
|
+
type: Boolean,
|
|
238
|
+
required: false,
|
|
239
|
+
default: void 0
|
|
240
|
+
},
|
|
241
|
+
name: {
|
|
242
|
+
type: String,
|
|
243
|
+
required: false,
|
|
244
|
+
default: void 0
|
|
245
|
+
},
|
|
246
|
+
autoComplete: {
|
|
247
|
+
type: String,
|
|
248
|
+
required: false,
|
|
249
|
+
default: void 0
|
|
250
|
+
},
|
|
251
|
+
size: {
|
|
252
|
+
type: Number,
|
|
253
|
+
required: false,
|
|
254
|
+
default: void 0
|
|
255
|
+
},
|
|
256
|
+
id: {
|
|
257
|
+
type: String,
|
|
258
|
+
required: false,
|
|
259
|
+
default: void 0
|
|
260
|
+
},
|
|
261
|
+
placeholder: {
|
|
262
|
+
type: String,
|
|
263
|
+
required: false,
|
|
264
|
+
default: void 0
|
|
265
|
+
},
|
|
266
|
+
disabled: {
|
|
267
|
+
type: Boolean,
|
|
268
|
+
required: false,
|
|
269
|
+
default: void 0
|
|
270
|
+
},
|
|
271
|
+
onFocus: {
|
|
272
|
+
type: Function,
|
|
273
|
+
required: false,
|
|
274
|
+
default: void 0
|
|
275
|
+
},
|
|
276
|
+
onBlur: {
|
|
277
|
+
type: Function,
|
|
278
|
+
required: false,
|
|
279
|
+
default: void 0
|
|
280
|
+
},
|
|
281
|
+
onKeyDown: {
|
|
282
|
+
type: Function,
|
|
283
|
+
required: false,
|
|
284
|
+
default: void 0
|
|
285
|
+
},
|
|
286
|
+
format: {
|
|
287
|
+
type: String,
|
|
288
|
+
required: false,
|
|
289
|
+
default: void 0
|
|
290
|
+
},
|
|
291
|
+
validateFormat: {
|
|
292
|
+
type: Function,
|
|
293
|
+
required: true,
|
|
294
|
+
default: void 0
|
|
295
|
+
},
|
|
296
|
+
active: {
|
|
297
|
+
type: Boolean,
|
|
298
|
+
required: false,
|
|
299
|
+
default: void 0
|
|
300
|
+
},
|
|
301
|
+
showActiveCls: {
|
|
302
|
+
type: Boolean,
|
|
303
|
+
required: false,
|
|
304
|
+
default: void 0
|
|
305
|
+
},
|
|
306
|
+
suffixIcon: {
|
|
307
|
+
type: [
|
|
308
|
+
Object,
|
|
309
|
+
Function,
|
|
310
|
+
String,
|
|
311
|
+
Number,
|
|
312
|
+
null,
|
|
313
|
+
Boolean,
|
|
314
|
+
Array
|
|
315
|
+
],
|
|
316
|
+
required: false,
|
|
317
|
+
default: void 0
|
|
318
|
+
},
|
|
319
|
+
value: {
|
|
320
|
+
type: String,
|
|
321
|
+
required: false,
|
|
322
|
+
default: void 0
|
|
323
|
+
},
|
|
324
|
+
onChange: {
|
|
325
|
+
type: Function,
|
|
326
|
+
required: true,
|
|
327
|
+
default: void 0
|
|
328
|
+
},
|
|
329
|
+
onSubmit: {
|
|
330
|
+
required: true,
|
|
331
|
+
default: void 0
|
|
332
|
+
},
|
|
333
|
+
helped: {
|
|
334
|
+
type: Boolean,
|
|
335
|
+
required: false,
|
|
336
|
+
default: void 0
|
|
337
|
+
},
|
|
338
|
+
onHelp: {
|
|
339
|
+
type: Function,
|
|
340
|
+
required: true,
|
|
341
|
+
default: void 0
|
|
342
|
+
},
|
|
343
|
+
preserveInvalidOnBlur: {
|
|
344
|
+
type: Boolean,
|
|
345
|
+
required: false,
|
|
346
|
+
default: void 0
|
|
347
|
+
},
|
|
348
|
+
invalid: {
|
|
349
|
+
type: Boolean,
|
|
350
|
+
required: false,
|
|
351
|
+
default: void 0
|
|
352
|
+
},
|
|
353
|
+
clearIcon: {
|
|
354
|
+
type: [
|
|
355
|
+
Object,
|
|
356
|
+
Function,
|
|
357
|
+
String,
|
|
358
|
+
Number,
|
|
359
|
+
null,
|
|
360
|
+
Boolean,
|
|
361
|
+
Array
|
|
362
|
+
],
|
|
363
|
+
required: false,
|
|
364
|
+
default: void 0
|
|
365
|
+
}
|
|
366
|
+
},
|
|
367
|
+
name: "Input",
|
|
368
|
+
inheritAttrs: false
|
|
369
|
+
});
|
|
370
|
+
export { Input_default as default };
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
4
|
+
});
|
|
5
|
+
var FORMAT_KEYS = [
|
|
6
|
+
"YYYY",
|
|
7
|
+
"MM",
|
|
8
|
+
"DD",
|
|
9
|
+
"HH",
|
|
10
|
+
"mm",
|
|
11
|
+
"ss",
|
|
12
|
+
"SSS"
|
|
13
|
+
];
|
|
14
|
+
var REPLACE_KEY = "顧";
|
|
15
|
+
var MaskFormat = class {
|
|
16
|
+
format;
|
|
17
|
+
maskFormat;
|
|
18
|
+
cells;
|
|
19
|
+
maskCells;
|
|
20
|
+
constructor(format) {
|
|
21
|
+
this.format = format;
|
|
22
|
+
const replaceKeys = FORMAT_KEYS.map((key) => `(${key})`).join("|");
|
|
23
|
+
const replaceReg = new RegExp(replaceKeys, "g");
|
|
24
|
+
this.maskFormat = format.replace(replaceReg, (key) => REPLACE_KEY.repeat(key.length));
|
|
25
|
+
const cellReg = /* @__PURE__ */ new RegExp(`(${FORMAT_KEYS.join("|")})`);
|
|
26
|
+
const strCells = (format.split(cellReg) || []).filter((str) => str);
|
|
27
|
+
let offset = 0;
|
|
28
|
+
this.cells = strCells.map((text) => {
|
|
29
|
+
const mask = FORMAT_KEYS.includes(text);
|
|
30
|
+
const start = offset;
|
|
31
|
+
const end = offset + text.length;
|
|
32
|
+
offset = end;
|
|
33
|
+
return {
|
|
34
|
+
text,
|
|
35
|
+
mask,
|
|
36
|
+
start,
|
|
37
|
+
end
|
|
38
|
+
};
|
|
39
|
+
});
|
|
40
|
+
this.maskCells = this.cells.filter((cell) => cell.mask);
|
|
41
|
+
}
|
|
42
|
+
getSelection(maskCellIndex) {
|
|
43
|
+
const { start, end } = this.maskCells[maskCellIndex] || {};
|
|
44
|
+
return [start || 0, end || 0];
|
|
45
|
+
}
|
|
46
|
+
match(text) {
|
|
47
|
+
for (let i = 0; i < this.maskFormat.length; i += 1) {
|
|
48
|
+
const maskChar = this.maskFormat[i];
|
|
49
|
+
const textChar = text[i];
|
|
50
|
+
if (!textChar || maskChar !== REPLACE_KEY && maskChar !== textChar) return false;
|
|
51
|
+
}
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
size() {
|
|
55
|
+
return this.maskCells.length;
|
|
56
|
+
}
|
|
57
|
+
getMaskCellIndex(anchorIndex) {
|
|
58
|
+
let closetDist = Number.MAX_SAFE_INTEGER;
|
|
59
|
+
let closetIndex = 0;
|
|
60
|
+
for (let i = 0; i < this.maskCells.length; i += 1) {
|
|
61
|
+
const { start, end } = this.maskCells[i];
|
|
62
|
+
if (anchorIndex >= start && anchorIndex <= end) return i;
|
|
63
|
+
const dist = Math.min(Math.abs(anchorIndex - start), Math.abs(anchorIndex - end));
|
|
64
|
+
if (dist < closetDist) {
|
|
65
|
+
closetDist = dist;
|
|
66
|
+
closetIndex = i;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return closetIndex;
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
exports.default = MaskFormat;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
declare const FORMAT_KEYS: readonly ["YYYY", "MM", "DD", "HH", "mm", "ss", "SSS"];
|
|
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,68 @@
|
|
|
1
|
+
var FORMAT_KEYS = [
|
|
2
|
+
"YYYY",
|
|
3
|
+
"MM",
|
|
4
|
+
"DD",
|
|
5
|
+
"HH",
|
|
6
|
+
"mm",
|
|
7
|
+
"ss",
|
|
8
|
+
"SSS"
|
|
9
|
+
];
|
|
10
|
+
var REPLACE_KEY = "顧";
|
|
11
|
+
var MaskFormat = class {
|
|
12
|
+
format;
|
|
13
|
+
maskFormat;
|
|
14
|
+
cells;
|
|
15
|
+
maskCells;
|
|
16
|
+
constructor(format) {
|
|
17
|
+
this.format = format;
|
|
18
|
+
const replaceKeys = FORMAT_KEYS.map((key) => `(${key})`).join("|");
|
|
19
|
+
const replaceReg = new RegExp(replaceKeys, "g");
|
|
20
|
+
this.maskFormat = format.replace(replaceReg, (key) => REPLACE_KEY.repeat(key.length));
|
|
21
|
+
const cellReg = /* @__PURE__ */ new RegExp(`(${FORMAT_KEYS.join("|")})`);
|
|
22
|
+
const strCells = (format.split(cellReg) || []).filter((str) => str);
|
|
23
|
+
let offset = 0;
|
|
24
|
+
this.cells = strCells.map((text) => {
|
|
25
|
+
const mask = FORMAT_KEYS.includes(text);
|
|
26
|
+
const start = offset;
|
|
27
|
+
const end = offset + text.length;
|
|
28
|
+
offset = end;
|
|
29
|
+
return {
|
|
30
|
+
text,
|
|
31
|
+
mask,
|
|
32
|
+
start,
|
|
33
|
+
end
|
|
34
|
+
};
|
|
35
|
+
});
|
|
36
|
+
this.maskCells = this.cells.filter((cell) => cell.mask);
|
|
37
|
+
}
|
|
38
|
+
getSelection(maskCellIndex) {
|
|
39
|
+
const { start, end } = this.maskCells[maskCellIndex] || {};
|
|
40
|
+
return [start || 0, end || 0];
|
|
41
|
+
}
|
|
42
|
+
match(text) {
|
|
43
|
+
for (let i = 0; i < this.maskFormat.length; i += 1) {
|
|
44
|
+
const maskChar = this.maskFormat[i];
|
|
45
|
+
const textChar = text[i];
|
|
46
|
+
if (!textChar || maskChar !== REPLACE_KEY && maskChar !== textChar) return false;
|
|
47
|
+
}
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
size() {
|
|
51
|
+
return this.maskCells.length;
|
|
52
|
+
}
|
|
53
|
+
getMaskCellIndex(anchorIndex) {
|
|
54
|
+
let closetDist = Number.MAX_SAFE_INTEGER;
|
|
55
|
+
let closetIndex = 0;
|
|
56
|
+
for (let i = 0; i < this.maskCells.length; i += 1) {
|
|
57
|
+
const { start, end } = this.maskCells[i];
|
|
58
|
+
if (anchorIndex >= start && anchorIndex <= end) return i;
|
|
59
|
+
const dist = Math.min(Math.abs(anchorIndex - start), Math.abs(anchorIndex - end));
|
|
60
|
+
if (dist < closetDist) {
|
|
61
|
+
closetDist = dist;
|
|
62
|
+
closetIndex = i;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return closetIndex;
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
export { MaskFormat as default };
|