antd-mobile 5.39.0 → 5.41.0-alpha.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/2x/README.md +8 -1
- package/2x/bundle/antd-mobile.cjs.development.js +2495 -1614
- package/2x/bundle/antd-mobile.cjs.js +7 -7
- package/2x/bundle/antd-mobile.es.development.js +1530 -649
- package/2x/bundle/antd-mobile.es.js +7495 -6799
- package/2x/bundle/antd-mobile.umd.development.js +2494 -1613
- package/2x/bundle/antd-mobile.umd.js +7 -7
- package/2x/bundle/style.css +11 -5
- package/2x/cjs/components/button/button.d.ts +2 -2
- package/2x/cjs/components/button/button.js +1 -0
- package/2x/cjs/components/calendar-picker-view/calendar-picker-view.js +3 -0
- package/2x/cjs/components/date-picker/date-picker-date-utils.d.ts +1 -1
- package/2x/cjs/components/date-picker/date-picker-date-utils.js +23 -8
- package/2x/cjs/components/date-picker/date-picker-quarter-utils.d.ts +3 -1
- package/2x/cjs/components/date-picker/date-picker-quarter-utils.js +7 -2
- package/2x/cjs/components/date-picker/date-picker-week-utils.d.ts +3 -1
- package/2x/cjs/components/date-picker/date-picker-week-utils.js +12 -4
- package/2x/cjs/components/date-picker-view/date-picker-view.d.ts +5 -3
- package/2x/cjs/components/date-picker-view/date-picker-view.js +3 -3
- package/2x/cjs/components/date-picker-view/useRenderLabel.js +2 -2
- package/2x/cjs/components/ellipsis/ellipsis.d.ts +3 -0
- package/2x/cjs/components/ellipsis/ellipsis.js +10 -2
- package/2x/cjs/components/number-keyboard/number-keyboard.d.ts +1 -1
- package/2x/cjs/components/popover/wrapper.d.ts +6 -9
- package/2x/cjs/components/popover/wrapper.js +32 -6
- package/2x/cjs/components/space/space.css +4 -4
- package/2x/cjs/components/swiper/swiper.js +1 -1
- package/2x/cjs/components/tabs/tabs.js +45 -13
- package/2x/cjs/components/virtual-input/virtual-input.css +7 -1
- package/2x/cjs/components/virtual-input/virtual-input.d.ts +6 -0
- package/2x/cjs/components/virtual-input/virtual-input.js +133 -7
- package/2x/cjs/index.d.ts +1 -0
- package/2x/cjs/index.js +7 -0
- package/2x/cjs/locales/ar-SA.d.ts +1 -0
- package/2x/cjs/locales/ar-SA.js +1 -0
- package/2x/cjs/locales/base.d.ts +1 -0
- package/2x/cjs/locales/base.js +1 -0
- package/2x/cjs/locales/cnr-ME.d.ts +1 -0
- package/2x/cjs/locales/cnr-ME.js +1 -0
- package/2x/cjs/locales/da-DK.d.ts +1 -0
- package/2x/cjs/locales/de-DE.d.ts +1 -0
- package/2x/cjs/locales/de-DE.js +1 -0
- package/2x/cjs/locales/en-US.d.ts +1 -0
- package/2x/cjs/locales/es-ES.d.ts +1 -0
- package/2x/cjs/locales/fa-IR.d.ts +1 -0
- package/2x/cjs/locales/fr-FR.d.ts +1 -0
- package/2x/cjs/locales/hr-HR.d.ts +1 -0
- package/2x/cjs/locales/hr-HR.js +1 -0
- package/2x/cjs/locales/hu-HU.d.ts +1 -0
- package/2x/cjs/locales/id-ID.d.ts +1 -0
- package/2x/cjs/locales/in-ID.d.ts +1 -0
- package/2x/cjs/locales/in-ID.js +1 -0
- package/2x/cjs/locales/it-IT.d.ts +1 -0
- package/2x/cjs/locales/ja-JP.d.ts +1 -0
- package/2x/cjs/locales/kk-KZ.d.ts +1 -0
- package/2x/cjs/locales/ko-KR.d.ts +1 -0
- package/2x/cjs/locales/ms-MY.d.ts +1 -0
- package/2x/cjs/locales/ms-MY.js +1 -0
- package/2x/cjs/locales/nb-NO.d.ts +1 -0
- package/2x/cjs/locales/nl-NL.d.ts +1 -0
- package/2x/cjs/locales/pt-BR.d.ts +1 -0
- package/2x/cjs/locales/ru-RU.d.ts +1 -0
- package/2x/cjs/locales/ru-RU.js +8 -2
- package/2x/cjs/locales/sr-RS.d.ts +1 -0
- package/2x/cjs/locales/sr-RS.js +1 -0
- package/2x/cjs/locales/th-TH.d.ts +1 -0
- package/2x/cjs/locales/th-TH.js +1 -0
- package/2x/cjs/locales/tr-TR.d.ts +1 -0
- package/2x/cjs/locales/vi-VN.d.ts +1 -0
- package/2x/cjs/locales/vi-VN.js +1 -0
- package/2x/cjs/locales/zh-CN.js +1 -0
- package/2x/cjs/locales/zh-HK.d.ts +1 -0
- package/2x/cjs/locales/zh-TW.d.ts +1 -0
- package/2x/cjs/utils/render-to-body.d.ts +1 -1
- package/2x/cjs/utils/render-to-body.js +2 -9
- package/2x/cjs/utils/render.d.ts +1 -9
- package/2x/cjs/utils/render.js +10 -68
- package/2x/cjs/utils/unstable-render.d.ts +9 -0
- package/2x/cjs/utils/unstable-render.js +37 -0
- package/2x/es/components/button/button.d.ts +2 -2
- package/2x/es/components/button/button.js +1 -0
- package/2x/es/components/calendar-picker-view/calendar-picker-view.js +3 -0
- package/2x/es/components/date-picker/date-picker-date-utils.d.ts +1 -1
- package/2x/es/components/date-picker/date-picker-date-utils.js +23 -8
- package/2x/es/components/date-picker/date-picker-quarter-utils.d.ts +3 -1
- package/2x/es/components/date-picker/date-picker-quarter-utils.js +7 -2
- package/2x/es/components/date-picker/date-picker-week-utils.d.ts +3 -1
- package/2x/es/components/date-picker/date-picker-week-utils.js +12 -4
- package/2x/es/components/date-picker-view/date-picker-view.d.ts +5 -3
- package/2x/es/components/date-picker-view/date-picker-view.js +4 -4
- package/2x/es/components/date-picker-view/useRenderLabel.js +2 -2
- package/2x/es/components/ellipsis/ellipsis.d.ts +3 -0
- package/2x/es/components/ellipsis/ellipsis.js +10 -2
- package/2x/es/components/number-keyboard/number-keyboard.d.ts +1 -1
- package/2x/es/components/popover/wrapper.d.ts +6 -9
- package/2x/es/components/popover/wrapper.js +30 -5
- package/2x/es/components/space/space.css +4 -4
- package/2x/es/components/swiper/swiper.js +1 -1
- package/2x/es/components/tabs/tabs.js +44 -12
- package/2x/es/components/virtual-input/virtual-input.css +7 -1
- package/2x/es/components/virtual-input/virtual-input.d.ts +6 -0
- package/2x/es/components/virtual-input/virtual-input.js +133 -7
- package/2x/es/index.d.ts +1 -0
- package/2x/es/index.js +3 -1
- package/2x/es/locales/ar-SA.d.ts +1 -0
- package/2x/es/locales/ar-SA.js +1 -0
- package/2x/es/locales/base.d.ts +1 -0
- package/2x/es/locales/base.js +1 -0
- package/2x/es/locales/cnr-ME.d.ts +1 -0
- package/2x/es/locales/cnr-ME.js +1 -0
- package/2x/es/locales/da-DK.d.ts +1 -0
- package/2x/es/locales/de-DE.d.ts +1 -0
- package/2x/es/locales/de-DE.js +1 -0
- package/2x/es/locales/en-US.d.ts +1 -0
- package/2x/es/locales/es-ES.d.ts +1 -0
- package/2x/es/locales/fa-IR.d.ts +1 -0
- package/2x/es/locales/fr-FR.d.ts +1 -0
- package/2x/es/locales/hr-HR.d.ts +1 -0
- package/2x/es/locales/hr-HR.js +1 -0
- package/2x/es/locales/hu-HU.d.ts +1 -0
- package/2x/es/locales/id-ID.d.ts +1 -0
- package/2x/es/locales/in-ID.d.ts +1 -0
- package/2x/es/locales/in-ID.js +1 -0
- package/2x/es/locales/it-IT.d.ts +1 -0
- package/2x/es/locales/ja-JP.d.ts +1 -0
- package/2x/es/locales/kk-KZ.d.ts +1 -0
- package/2x/es/locales/ko-KR.d.ts +1 -0
- package/2x/es/locales/ms-MY.d.ts +1 -0
- package/2x/es/locales/ms-MY.js +1 -0
- package/2x/es/locales/nb-NO.d.ts +1 -0
- package/2x/es/locales/nl-NL.d.ts +1 -0
- package/2x/es/locales/pt-BR.d.ts +1 -0
- package/2x/es/locales/ru-RU.d.ts +1 -0
- package/2x/es/locales/ru-RU.js +8 -2
- package/2x/es/locales/sr-RS.d.ts +1 -0
- package/2x/es/locales/sr-RS.js +1 -0
- package/2x/es/locales/th-TH.d.ts +1 -0
- package/2x/es/locales/th-TH.js +1 -0
- package/2x/es/locales/tr-TR.d.ts +1 -0
- package/2x/es/locales/vi-VN.d.ts +1 -0
- package/2x/es/locales/vi-VN.js +1 -0
- package/2x/es/locales/zh-CN.js +1 -0
- package/2x/es/locales/zh-HK.d.ts +1 -0
- package/2x/es/locales/zh-TW.d.ts +1 -0
- package/2x/es/utils/render-to-body.d.ts +1 -1
- package/2x/es/utils/render-to-body.js +2 -9
- package/2x/es/utils/render.d.ts +1 -9
- package/2x/es/utils/render.js +1 -65
- package/2x/es/utils/unstable-render.d.ts +9 -0
- package/2x/es/utils/unstable-render.js +28 -0
- package/2x/package.json +4 -4
- package/README.md +8 -1
- package/bundle/antd-mobile.cjs.development.js +2495 -1614
- package/bundle/antd-mobile.cjs.js +7 -7
- package/bundle/antd-mobile.compatible.umd.js +1 -1
- package/bundle/antd-mobile.es.development.js +1530 -649
- package/bundle/antd-mobile.es.js +7495 -6799
- package/bundle/antd-mobile.umd.development.js +2494 -1613
- package/bundle/antd-mobile.umd.js +7 -7
- package/bundle/style.css +1 -1
- package/cjs/components/button/button.d.ts +2 -2
- package/cjs/components/button/button.js +1 -0
- package/cjs/components/calendar-picker-view/calendar-picker-view.js +3 -0
- package/cjs/components/date-picker/date-picker-date-utils.d.ts +1 -1
- package/cjs/components/date-picker/date-picker-date-utils.js +23 -8
- package/cjs/components/date-picker/date-picker-quarter-utils.d.ts +3 -1
- package/cjs/components/date-picker/date-picker-quarter-utils.js +7 -2
- package/cjs/components/date-picker/date-picker-week-utils.d.ts +3 -1
- package/cjs/components/date-picker/date-picker-week-utils.js +12 -4
- package/cjs/components/date-picker-view/date-picker-view.d.ts +5 -3
- package/cjs/components/date-picker-view/date-picker-view.js +3 -3
- package/cjs/components/date-picker-view/useRenderLabel.js +2 -2
- package/cjs/components/ellipsis/ellipsis.d.ts +3 -0
- package/cjs/components/ellipsis/ellipsis.js +10 -2
- package/cjs/components/number-keyboard/number-keyboard.d.ts +1 -1
- package/cjs/components/popover/wrapper.d.ts +6 -9
- package/cjs/components/popover/wrapper.js +32 -6
- package/cjs/components/space/space.css +3 -3
- package/cjs/components/swiper/swiper.js +1 -1
- package/cjs/components/tabs/tabs.js +45 -13
- package/cjs/components/virtual-input/virtual-input.css +6 -1
- package/cjs/components/virtual-input/virtual-input.d.ts +6 -0
- package/cjs/components/virtual-input/virtual-input.js +133 -7
- package/cjs/index.d.ts +1 -0
- package/cjs/index.js +7 -0
- package/cjs/locales/ar-SA.d.ts +1 -0
- package/cjs/locales/ar-SA.js +1 -0
- package/cjs/locales/base.d.ts +1 -0
- package/cjs/locales/base.js +1 -0
- package/cjs/locales/cnr-ME.d.ts +1 -0
- package/cjs/locales/cnr-ME.js +1 -0
- package/cjs/locales/da-DK.d.ts +1 -0
- package/cjs/locales/de-DE.d.ts +1 -0
- package/cjs/locales/de-DE.js +1 -0
- package/cjs/locales/en-US.d.ts +1 -0
- package/cjs/locales/es-ES.d.ts +1 -0
- package/cjs/locales/fa-IR.d.ts +1 -0
- package/cjs/locales/fr-FR.d.ts +1 -0
- package/cjs/locales/hr-HR.d.ts +1 -0
- package/cjs/locales/hr-HR.js +1 -0
- package/cjs/locales/hu-HU.d.ts +1 -0
- package/cjs/locales/id-ID.d.ts +1 -0
- package/cjs/locales/in-ID.d.ts +1 -0
- package/cjs/locales/in-ID.js +1 -0
- package/cjs/locales/it-IT.d.ts +1 -0
- package/cjs/locales/ja-JP.d.ts +1 -0
- package/cjs/locales/kk-KZ.d.ts +1 -0
- package/cjs/locales/ko-KR.d.ts +1 -0
- package/cjs/locales/ms-MY.d.ts +1 -0
- package/cjs/locales/ms-MY.js +1 -0
- package/cjs/locales/nb-NO.d.ts +1 -0
- package/cjs/locales/nl-NL.d.ts +1 -0
- package/cjs/locales/pt-BR.d.ts +1 -0
- package/cjs/locales/ru-RU.d.ts +1 -0
- package/cjs/locales/ru-RU.js +8 -2
- package/cjs/locales/sr-RS.d.ts +1 -0
- package/cjs/locales/sr-RS.js +1 -0
- package/cjs/locales/th-TH.d.ts +1 -0
- package/cjs/locales/th-TH.js +1 -0
- package/cjs/locales/tr-TR.d.ts +1 -0
- package/cjs/locales/vi-VN.d.ts +1 -0
- package/cjs/locales/vi-VN.js +1 -0
- package/cjs/locales/zh-CN.js +1 -0
- package/cjs/locales/zh-HK.d.ts +1 -0
- package/cjs/locales/zh-TW.d.ts +1 -0
- package/cjs/utils/render-to-body.d.ts +1 -1
- package/cjs/utils/render-to-body.js +2 -9
- package/cjs/utils/render.d.ts +1 -9
- package/cjs/utils/render.js +10 -68
- package/cjs/utils/unstable-render.d.ts +9 -0
- package/cjs/utils/unstable-render.js +37 -0
- package/es/components/button/button.d.ts +2 -2
- package/es/components/button/button.js +1 -0
- package/es/components/calendar-picker-view/calendar-picker-view.js +3 -0
- package/es/components/date-picker/date-picker-date-utils.d.ts +1 -1
- package/es/components/date-picker/date-picker-date-utils.js +23 -8
- package/es/components/date-picker/date-picker-quarter-utils.d.ts +3 -1
- package/es/components/date-picker/date-picker-quarter-utils.js +7 -2
- package/es/components/date-picker/date-picker-week-utils.d.ts +3 -1
- package/es/components/date-picker/date-picker-week-utils.js +12 -4
- package/es/components/date-picker-view/date-picker-view.d.ts +5 -3
- package/es/components/date-picker-view/date-picker-view.js +4 -4
- package/es/components/date-picker-view/useRenderLabel.js +2 -2
- package/es/components/ellipsis/ellipsis.d.ts +3 -0
- package/es/components/ellipsis/ellipsis.js +10 -2
- package/es/components/number-keyboard/number-keyboard.d.ts +1 -1
- package/es/components/popover/wrapper.d.ts +6 -9
- package/es/components/popover/wrapper.js +30 -5
- package/es/components/space/space.css +3 -3
- package/es/components/swiper/swiper.js +1 -1
- package/es/components/tabs/tabs.js +44 -12
- package/es/components/virtual-input/virtual-input.css +6 -1
- package/es/components/virtual-input/virtual-input.d.ts +6 -0
- package/es/components/virtual-input/virtual-input.js +133 -7
- package/es/index.d.ts +1 -0
- package/es/index.js +3 -1
- package/es/locales/ar-SA.d.ts +1 -0
- package/es/locales/ar-SA.js +1 -0
- package/es/locales/base.d.ts +1 -0
- package/es/locales/base.js +1 -0
- package/es/locales/cnr-ME.d.ts +1 -0
- package/es/locales/cnr-ME.js +1 -0
- package/es/locales/da-DK.d.ts +1 -0
- package/es/locales/de-DE.d.ts +1 -0
- package/es/locales/de-DE.js +1 -0
- package/es/locales/en-US.d.ts +1 -0
- package/es/locales/es-ES.d.ts +1 -0
- package/es/locales/fa-IR.d.ts +1 -0
- package/es/locales/fr-FR.d.ts +1 -0
- package/es/locales/hr-HR.d.ts +1 -0
- package/es/locales/hr-HR.js +1 -0
- package/es/locales/hu-HU.d.ts +1 -0
- package/es/locales/id-ID.d.ts +1 -0
- package/es/locales/in-ID.d.ts +1 -0
- package/es/locales/in-ID.js +1 -0
- package/es/locales/it-IT.d.ts +1 -0
- package/es/locales/ja-JP.d.ts +1 -0
- package/es/locales/kk-KZ.d.ts +1 -0
- package/es/locales/ko-KR.d.ts +1 -0
- package/es/locales/ms-MY.d.ts +1 -0
- package/es/locales/ms-MY.js +1 -0
- package/es/locales/nb-NO.d.ts +1 -0
- package/es/locales/nl-NL.d.ts +1 -0
- package/es/locales/pt-BR.d.ts +1 -0
- package/es/locales/ru-RU.d.ts +1 -0
- package/es/locales/ru-RU.js +8 -2
- package/es/locales/sr-RS.d.ts +1 -0
- package/es/locales/sr-RS.js +1 -0
- package/es/locales/th-TH.d.ts +1 -0
- package/es/locales/th-TH.js +1 -0
- package/es/locales/tr-TR.d.ts +1 -0
- package/es/locales/vi-VN.d.ts +1 -0
- package/es/locales/vi-VN.js +1 -0
- package/es/locales/zh-CN.js +1 -0
- package/es/locales/zh-HK.d.ts +1 -0
- package/es/locales/zh-TW.d.ts +1 -0
- package/es/utils/render-to-body.d.ts +1 -1
- package/es/utils/render-to-body.js +2 -9
- package/es/utils/render.d.ts +1 -9
- package/es/utils/render.js +1 -65
- package/es/utils/unstable-render.d.ts +9 -0
- package/es/utils/unstable-render.js +28 -0
- package/package.json +4 -4
- package/umd/antd-mobile.js +1 -1
- package/2x/cjs/components/ellipsis/~ellipsis.d.ts +0 -15
- package/2x/cjs/components/ellipsis/~ellipsis.js +0 -161
- package/2x/es/components/ellipsis/~ellipsis.d.ts +0 -15
- package/2x/es/components/ellipsis/~ellipsis.js +0 -151
- package/cjs/components/ellipsis/~ellipsis.d.ts +0 -15
- package/cjs/components/ellipsis/~ellipsis.js +0 -161
- package/es/components/ellipsis/~ellipsis.d.ts +0 -15
- package/es/components/ellipsis/~ellipsis.js +0 -151
|
@@ -3,6 +3,10 @@ import React from 'react';
|
|
|
3
3
|
import { NativeProps } from '../../utils/native-props';
|
|
4
4
|
import type { InputProps } from '../input';
|
|
5
5
|
import { NumberKeyboardProps } from '../number-keyboard';
|
|
6
|
+
export declare type Cursor = {
|
|
7
|
+
movable?: boolean;
|
|
8
|
+
onMove?: (position: number) => void;
|
|
9
|
+
};
|
|
6
10
|
export declare type VirtualInputProps = {
|
|
7
11
|
onFocus?: () => void;
|
|
8
12
|
onBlur?: () => void;
|
|
@@ -10,6 +14,7 @@ export declare type VirtualInputProps = {
|
|
|
10
14
|
keyboard?: ReactElement<NumberKeyboardProps>;
|
|
11
15
|
clearable?: boolean;
|
|
12
16
|
onClear?: () => void;
|
|
17
|
+
cursor?: Cursor;
|
|
13
18
|
} & Pick<InputProps, 'value' | 'onChange' | 'placeholder' | 'disabled' | 'clearIcon'> & NativeProps<'--font-size' | '--color' | '--placeholder-color' | '--disabled-color' | '--text-align' | '--caret-width' | '--caret-color'>;
|
|
14
19
|
export declare type VirtualInputRef = {
|
|
15
20
|
focus: () => void;
|
|
@@ -22,6 +27,7 @@ export declare const VirtualInput: React.ForwardRefExoticComponent<{
|
|
|
22
27
|
keyboard?: ReactElement<NumberKeyboardProps, string | React.JSXElementConstructor<any>> | undefined;
|
|
23
28
|
clearable?: boolean | undefined;
|
|
24
29
|
onClear?: (() => void) | undefined;
|
|
30
|
+
cursor?: Cursor | undefined;
|
|
25
31
|
} & Pick<InputProps, "value" | "onChange" | "disabled" | "placeholder" | "clearIcon"> & {
|
|
26
32
|
className?: string | undefined;
|
|
27
33
|
style?: (React.CSSProperties & Partial<Record<"--color" | "--font-size" | "--placeholder-color" | "--text-align" | "--disabled-color" | "--caret-width" | "--caret-color", string>>) | undefined;
|
|
@@ -17,7 +17,10 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
17
17
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
18
18
|
const classPrefix = 'adm-virtual-input';
|
|
19
19
|
const defaultProps = {
|
|
20
|
-
defaultValue: ''
|
|
20
|
+
defaultValue: '',
|
|
21
|
+
cursor: {
|
|
22
|
+
movable: false
|
|
23
|
+
}
|
|
21
24
|
};
|
|
22
25
|
const VirtualInput = (0, _react.forwardRef)((props, ref) => {
|
|
23
26
|
const {
|
|
@@ -29,6 +32,14 @@ const VirtualInput = (0, _react.forwardRef)((props, ref) => {
|
|
|
29
32
|
const rootRef = (0, _react.useRef)(null);
|
|
30
33
|
const contentRef = (0, _react.useRef)(null);
|
|
31
34
|
const [hasFocus, setHasFocus] = (0, _react.useState)(false);
|
|
35
|
+
const [caretPosition, setCaretPosition] = (0, _react.useState)(value.length); // 光标位置,从 0 开始,如值是 2 则表示光标在顺序下标为 2 的数字之前
|
|
36
|
+
const keyboardDataRef = (0, _react.useRef)({}); // 临时记录虚拟键盘输入,在下次更新时用于判断光标位置如何调整
|
|
37
|
+
const touchDataRef = (0, _react.useRef)(); // 记录上一次 touch 时的坐标位置
|
|
38
|
+
const charRef = (0, _react.useRef)(null); // 第一个字符的 DOM
|
|
39
|
+
const charWidthRef = (0, _react.useRef)(0); // 单个字符宽度
|
|
40
|
+
const caretRef = (0, _react.useRef)(null); // 光标的 DOM
|
|
41
|
+
const [isCaretDragging, setIsCaretDragging] = (0, _react.useState)(false);
|
|
42
|
+
const touchMoveTimeoutRef = (0, _react.useRef)();
|
|
32
43
|
const clearIcon = (0, _withDefaultProps.mergeProp)(_react.default.createElement(_antdMobileIcons.CloseCircleFill, null), componentConfig.clearIcon, props.clearIcon);
|
|
33
44
|
function scrollToEnd() {
|
|
34
45
|
const root = rootRef.current;
|
|
@@ -40,6 +51,24 @@ const VirtualInput = (0, _react.forwardRef)((props, ref) => {
|
|
|
40
51
|
if (!content) return;
|
|
41
52
|
content.scrollLeft = content.clientWidth;
|
|
42
53
|
}
|
|
54
|
+
(0, _react.useEffect)(() => {
|
|
55
|
+
// 记录单个字符的宽度,用于光标移动时的计算
|
|
56
|
+
if (charRef.current) {
|
|
57
|
+
charWidthRef.current = charRef.current.getBoundingClientRect().width;
|
|
58
|
+
}
|
|
59
|
+
}, [value]);
|
|
60
|
+
(0, _react.useEffect)(() => {
|
|
61
|
+
// 经过外部受控逻辑后,再调整光标位置,如果受控逻辑改动了值则光标放到最后
|
|
62
|
+
if (value === keyboardDataRef.current.newValue) {
|
|
63
|
+
if (keyboardDataRef.current.mode === 'input') {
|
|
64
|
+
setCaretPosition(c => c + 1);
|
|
65
|
+
} else if (keyboardDataRef.current.mode === 'delete') {
|
|
66
|
+
setCaretPosition(c => c - 1);
|
|
67
|
+
}
|
|
68
|
+
} else {
|
|
69
|
+
setCaretPosition(value.length);
|
|
70
|
+
}
|
|
71
|
+
}, [value]);
|
|
43
72
|
(0, _ahooks.useIsomorphicLayoutEffect)(() => {
|
|
44
73
|
scrollToEnd();
|
|
45
74
|
}, [value]);
|
|
@@ -72,12 +101,25 @@ const VirtualInput = (0, _react.forwardRef)((props, ref) => {
|
|
|
72
101
|
const keyboardElement = keyboard && _react.default.cloneElement(keyboard, {
|
|
73
102
|
onInput: v => {
|
|
74
103
|
var _a, _b;
|
|
75
|
-
|
|
104
|
+
const newValue = value.substring(0, caretPosition) + v + value.substring(caretPosition);
|
|
105
|
+
// 临时记录,用于后续光标位置
|
|
106
|
+
keyboardDataRef.current = {
|
|
107
|
+
newValue,
|
|
108
|
+
mode: 'input'
|
|
109
|
+
};
|
|
110
|
+
setValue(newValue);
|
|
76
111
|
(_b = (_a = keyboard.props).onInput) === null || _b === void 0 ? void 0 : _b.call(_a, v);
|
|
77
112
|
},
|
|
78
113
|
onDelete: () => {
|
|
79
114
|
var _a, _b;
|
|
80
|
-
|
|
115
|
+
if (caretPosition === 0) return;
|
|
116
|
+
const newValue = value.substring(0, caretPosition - 1) + value.substring(caretPosition);
|
|
117
|
+
// 临时记录,用于后续光标位置
|
|
118
|
+
keyboardDataRef.current = {
|
|
119
|
+
newValue,
|
|
120
|
+
mode: 'delete'
|
|
121
|
+
};
|
|
122
|
+
setValue(newValue);
|
|
81
123
|
(_b = (_a = keyboard.props).onDelete) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
82
124
|
},
|
|
83
125
|
visible: hasFocus,
|
|
@@ -95,10 +137,82 @@ const VirtualInput = (0, _react.forwardRef)((props, ref) => {
|
|
|
95
137
|
},
|
|
96
138
|
getContainer: null
|
|
97
139
|
});
|
|
140
|
+
// 点击输入框时,将光标置于最后
|
|
141
|
+
const setCaretPositionToEnd = () => {
|
|
142
|
+
var _a, _b;
|
|
143
|
+
if (caretPosition !== value.length) {
|
|
144
|
+
setCaretPosition(value.length);
|
|
145
|
+
(_b = (_a = mergedProps.cursor) === null || _a === void 0 ? void 0 : _a.onMove) === null || _b === void 0 ? void 0 : _b.call(_a, value.length);
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
// 点击单个字符时,根据点击位置置于字符前或后
|
|
149
|
+
const changeCaretPosition = index => e => {
|
|
150
|
+
var _a, _b, _c;
|
|
151
|
+
if (mergedProps.disabled || !((_a = mergedProps.cursor) === null || _a === void 0 ? void 0 : _a.movable)) return;
|
|
152
|
+
e.stopPropagation();
|
|
153
|
+
const rect = e.target.getBoundingClientRect();
|
|
154
|
+
const midX = rect.left + rect.width / 2;
|
|
155
|
+
const clickX = e.clientX;
|
|
156
|
+
// 点击区域是否偏右
|
|
157
|
+
const isRight = clickX > midX;
|
|
158
|
+
const newCaretPosition = isRight ? index + 1 : index;
|
|
159
|
+
setCaretPosition(newCaretPosition);
|
|
160
|
+
(_c = (_b = mergedProps.cursor) === null || _b === void 0 ? void 0 : _b.onMove) === null || _c === void 0 ? void 0 : _c.call(_b, newCaretPosition);
|
|
161
|
+
};
|
|
162
|
+
// 在光标附近 touchmove 时也可以调整光标位置
|
|
163
|
+
const handleTouchStart = e => {
|
|
164
|
+
var _a;
|
|
165
|
+
if (mergedProps.disabled || !((_a = mergedProps.cursor) === null || _a === void 0 ? void 0 : _a.movable)) return;
|
|
166
|
+
if (!caretRef.current) return;
|
|
167
|
+
const touch = e.touches[0];
|
|
168
|
+
const caretRect = caretRef.current.getBoundingClientRect();
|
|
169
|
+
const distance = Math.abs(touch.clientX - (caretRect.left + caretRect.width / 2));
|
|
170
|
+
if (distance < 20) {
|
|
171
|
+
// 20px 阈值可调整
|
|
172
|
+
touchDataRef.current = {
|
|
173
|
+
startX: touch.clientX,
|
|
174
|
+
startCaretPosition: caretPosition
|
|
175
|
+
};
|
|
176
|
+
} else {
|
|
177
|
+
touchDataRef.current = null;
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
const handleTouchMove = e => {
|
|
181
|
+
var _a, _b, _c;
|
|
182
|
+
if (!touchDataRef.current || !((_a = mergedProps.cursor) === null || _a === void 0 ? void 0 : _a.movable)) return;
|
|
183
|
+
setIsCaretDragging(true);
|
|
184
|
+
const touch = e.touches[0];
|
|
185
|
+
const deltaX = touch.clientX - touchDataRef.current.startX;
|
|
186
|
+
const charWidth = charWidthRef.current;
|
|
187
|
+
const moveChars = Math.round(deltaX / charWidth);
|
|
188
|
+
let newCaretPosition = touchDataRef.current.startCaretPosition + moveChars;
|
|
189
|
+
// 边界处理
|
|
190
|
+
newCaretPosition = Math.max(0, Math.min(newCaretPosition, value.length));
|
|
191
|
+
setCaretPosition(newCaretPosition);
|
|
192
|
+
(_c = (_b = mergedProps.cursor) === null || _b === void 0 ? void 0 : _b.onMove) === null || _c === void 0 ? void 0 : _c.call(_b, newCaretPosition);
|
|
193
|
+
// 防止 touchend 不触发
|
|
194
|
+
if (touchMoveTimeoutRef.current) {
|
|
195
|
+
clearTimeout(touchMoveTimeoutRef.current);
|
|
196
|
+
}
|
|
197
|
+
touchMoveTimeoutRef.current = setTimeout(() => {
|
|
198
|
+
setIsCaretDragging(false);
|
|
199
|
+
touchMoveTimeoutRef.current = null;
|
|
200
|
+
}, 500);
|
|
201
|
+
};
|
|
202
|
+
const handleTouchEnd = () => {
|
|
203
|
+
touchDataRef.current = null;
|
|
204
|
+
setIsCaretDragging(false);
|
|
205
|
+
if (touchMoveTimeoutRef.current) {
|
|
206
|
+
clearTimeout(touchMoveTimeoutRef.current);
|
|
207
|
+
touchMoveTimeoutRef.current = null;
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
const chars = (value + '').split('');
|
|
98
211
|
return (0, _nativeProps.withNativeProps)(mergedProps, _react.default.createElement("div", {
|
|
99
212
|
ref: rootRef,
|
|
100
213
|
className: (0, _classnames.default)(classPrefix, {
|
|
101
|
-
[`${classPrefix}-disabled`]: mergedProps.disabled
|
|
214
|
+
[`${classPrefix}-disabled`]: mergedProps.disabled,
|
|
215
|
+
[`${classPrefix}-caret-dragging`]: isCaretDragging
|
|
102
216
|
}),
|
|
103
217
|
tabIndex: mergedProps.disabled ? undefined : 0,
|
|
104
218
|
role: 'textbox',
|
|
@@ -109,12 +223,24 @@ const VirtualInput = (0, _react.forwardRef)((props, ref) => {
|
|
|
109
223
|
className: `${classPrefix}-content`,
|
|
110
224
|
ref: contentRef,
|
|
111
225
|
"aria-disabled": mergedProps.disabled,
|
|
112
|
-
"aria-label": mergedProps.placeholder
|
|
113
|
-
|
|
226
|
+
"aria-label": mergedProps.placeholder,
|
|
227
|
+
onClick: setCaretPositionToEnd,
|
|
228
|
+
onTouchStart: handleTouchStart,
|
|
229
|
+
onTouchMove: handleTouchMove,
|
|
230
|
+
onTouchEnd: handleTouchEnd
|
|
231
|
+
}, chars.slice(0, caretPosition).map((i, index) => _react.default.createElement("span", {
|
|
232
|
+
ref: index === 0 ? charRef : undefined,
|
|
233
|
+
key: index,
|
|
234
|
+
onClick: changeCaretPosition(index)
|
|
235
|
+
}, i)), _react.default.createElement("div", {
|
|
114
236
|
className: `${classPrefix}-caret-container`
|
|
115
237
|
}, hasFocus && _react.default.createElement("div", {
|
|
238
|
+
ref: caretRef,
|
|
116
239
|
className: `${classPrefix}-caret`
|
|
117
|
-
}))
|
|
240
|
+
})), chars.slice(caretPosition).map((i, index) => _react.default.createElement("span", {
|
|
241
|
+
key: index,
|
|
242
|
+
onClick: changeCaretPosition(index + caretPosition)
|
|
243
|
+
}, i))), mergedProps.clearable && !!value && hasFocus && _react.default.createElement("div", {
|
|
118
244
|
className: `${classPrefix}-clear`,
|
|
119
245
|
onClick: e => {
|
|
120
246
|
var _a;
|
package/2x/cjs/index.d.ts
CHANGED
|
@@ -168,3 +168,4 @@ export { default as Footer } from './components/footer';
|
|
|
168
168
|
export type { FooterProps } from './components/footer';
|
|
169
169
|
export { createErrorBlock } from './components/error-block';
|
|
170
170
|
export { reduceMotion, restoreMotion } from './utils/reduce-and-restore-motion';
|
|
171
|
+
export { unstableSetRender } from './utils/unstable-render';
|
package/2x/cjs/index.js
CHANGED
|
@@ -525,6 +525,12 @@ Object.defineProperty(exports, "setDefaultConfig", {
|
|
|
525
525
|
return _configProvider.setDefaultConfig;
|
|
526
526
|
}
|
|
527
527
|
});
|
|
528
|
+
Object.defineProperty(exports, "unstableSetRender", {
|
|
529
|
+
enumerable: true,
|
|
530
|
+
get: function () {
|
|
531
|
+
return _unstableRender.unstableSetRender;
|
|
532
|
+
}
|
|
533
|
+
});
|
|
528
534
|
Object.defineProperty(exports, "useConfig", {
|
|
529
535
|
enumerable: true,
|
|
530
536
|
get: function () {
|
|
@@ -616,6 +622,7 @@ var _virtualInput = _interopRequireDefault(require("./components/virtual-input")
|
|
|
616
622
|
var _waterMark = _interopRequireDefault(require("./components/water-mark"));
|
|
617
623
|
var _footer = _interopRequireDefault(require("./components/footer"));
|
|
618
624
|
var _reduceAndRestoreMotion = require("./utils/reduce-and-restore-motion");
|
|
625
|
+
var _unstableRender = require("./utils/unstable-render");
|
|
619
626
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
620
627
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
621
628
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
package/2x/cjs/locales/ar-SA.js
CHANGED
|
@@ -20,6 +20,7 @@ const arSA = (0, _mergeLocale.mergeLocale)(_base.base, {
|
|
|
20
20
|
'confirm': 'تأكيد',
|
|
21
21
|
'start': 'يبدأ',
|
|
22
22
|
'end': 'ينهي',
|
|
23
|
+
'startAndEnd': 'يبدأ/ينهي',
|
|
23
24
|
'today': 'اليوم',
|
|
24
25
|
'markItems': ['واحد', 'اثنين', 'ثلاثة', 'أربعة', 'خمسة', 'ستة', 'يوم'],
|
|
25
26
|
'yearAndMonth': '${year} سنة ${month} شهر'
|
package/2x/cjs/locales/base.d.ts
CHANGED
package/2x/cjs/locales/base.js
CHANGED
package/2x/cjs/locales/cnr-ME.js
CHANGED
|
@@ -20,6 +20,7 @@ const cnrME = (0, _mergeLocale.mergeLocale)(_base.base, {
|
|
|
20
20
|
confirm: 'Potvrdi',
|
|
21
21
|
start: 'početak',
|
|
22
22
|
end: 'kraj',
|
|
23
|
+
startAndEnd: 'početak/kraj',
|
|
23
24
|
today: 'danas',
|
|
24
25
|
markItems: ['Pon', 'Uto', 'Sre', 'Čet', 'Pet', 'Sub', 'Ned'],
|
|
25
26
|
yearAndMonth: '${year}/${month}'
|
package/2x/cjs/locales/de-DE.js
CHANGED
|
@@ -20,6 +20,7 @@ const deDE = (0, _mergeLocale.mergeLocale)(_base.base, {
|
|
|
20
20
|
'confirm': 'Bestätigen',
|
|
21
21
|
'start': 'Starten',
|
|
22
22
|
'end': 'Beenden',
|
|
23
|
+
'startAndEnd': 'Starten/Beenden',
|
|
23
24
|
'today': 'Heute',
|
|
24
25
|
'markItems': ['I', 'II', 'III', 'IV', 'V', 'Sechs', 'Tag'],
|
|
25
26
|
'yearAndMonth': '${year}Jahr${month}Monat'
|
package/2x/cjs/locales/hr-HR.js
CHANGED
|
@@ -20,6 +20,7 @@ const hrHR = (0, _mergeLocale.mergeLocale)(_base.base, {
|
|
|
20
20
|
confirm: 'Potvrdi',
|
|
21
21
|
start: 'početak',
|
|
22
22
|
end: 'kraj',
|
|
23
|
+
startAndEnd: 'početak/kraj',
|
|
23
24
|
today: 'danas',
|
|
24
25
|
markItems: ['Pon', 'Uto', 'Sri', 'Čet', 'Pet', 'Sub', 'Ned'],
|
|
25
26
|
yearAndMonth: '${year}/${month}'
|
package/2x/cjs/locales/in-ID.js
CHANGED
|
@@ -20,6 +20,7 @@ const inID = (0, _mergeLocale.mergeLocale)(_base.base, {
|
|
|
20
20
|
confirm: 'OK',
|
|
21
21
|
start: 'Mulai',
|
|
22
22
|
end: 'Selesai',
|
|
23
|
+
startAndEnd: 'Mulai/Selesai',
|
|
23
24
|
today: 'Hari Ini',
|
|
24
25
|
markItems: ['Senin', 'Selasa', 'Rabu', 'Kamis', 'Jumat', 'Sabtu', 'Minggu'],
|
|
25
26
|
yearAndMonth: '${year} Tahun ${month} Bulan'
|
package/2x/cjs/locales/ms-MY.js
CHANGED
|
@@ -20,6 +20,7 @@ const msMY = (0, _mergeLocale.mergeLocale)(_base.base, {
|
|
|
20
20
|
'confirm': 'Ok',
|
|
21
21
|
'start': 'Mula',
|
|
22
22
|
'end': 'Tamat',
|
|
23
|
+
'startAndEnd': 'Mula/Tamat',
|
|
23
24
|
'today': 'Hari ini',
|
|
24
25
|
'markItems': ['Satu', 'Dua', 'Tiga', 'Empat', 'Lima', 'Enam', 'Hari'],
|
|
25
26
|
'yearAndMonth': 'Tahun${year} bulan ${month}'
|
package/2x/cjs/locales/ru-RU.js
CHANGED
|
@@ -16,6 +16,12 @@ const ruRU = (0, _mergeLocale.mergeLocale)(_base.base, {
|
|
|
16
16
|
close: 'Закрыть'
|
|
17
17
|
},
|
|
18
18
|
Calendar: {
|
|
19
|
+
title: 'Выбор даты',
|
|
20
|
+
confirm: 'Подтвердить',
|
|
21
|
+
start: 'начало',
|
|
22
|
+
end: 'конец',
|
|
23
|
+
startAndEnd: 'начало/конец',
|
|
24
|
+
today: 'сегодня',
|
|
19
25
|
markItems: ['Пн', 'Вт', 'Ср', 'Чт', 'Пт', 'Сб', 'Вс'],
|
|
20
26
|
yearAndMonth: '${year}/${month}'
|
|
21
27
|
},
|
|
@@ -119,9 +125,9 @@ const ruRU = (0, _mergeLocale.mergeLocale)(_base.base, {
|
|
|
119
125
|
name: 'Ввод пароля'
|
|
120
126
|
},
|
|
121
127
|
PullToRefresh: {
|
|
122
|
-
pulling: 'Прокрутите вниз, чтобы
|
|
128
|
+
pulling: 'Прокрутите вниз, чтобы обновить',
|
|
123
129
|
canRelease: 'Отпустите, чтобы немедленно обновить',
|
|
124
|
-
complete: '
|
|
130
|
+
complete: 'Обновлено успешно'
|
|
125
131
|
},
|
|
126
132
|
SearchBar: {
|
|
127
133
|
name: 'Панель поиска'
|
package/2x/cjs/locales/sr-RS.js
CHANGED
|
@@ -20,6 +20,7 @@ const srRS = (0, _mergeLocale.mergeLocale)(_base.base, {
|
|
|
20
20
|
confirm: 'Потврди',
|
|
21
21
|
start: 'почетак',
|
|
22
22
|
end: 'крај',
|
|
23
|
+
startAndEnd: 'почетак/крај',
|
|
23
24
|
today: 'данас',
|
|
24
25
|
markItems: ['Пон', 'Уто', 'Сре', 'Чет', 'Пет', 'Суб', 'Нед'],
|
|
25
26
|
yearAndMonth: '${year}/${month}'
|
package/2x/cjs/locales/th-TH.js
CHANGED
|
@@ -20,6 +20,7 @@ const thTH = (0, _mergeLocale.mergeLocale)(_base.base, {
|
|
|
20
20
|
confirm: 'ยืนยัน',
|
|
21
21
|
start: 'เริ่ม',
|
|
22
22
|
end: 'เสร็จ',
|
|
23
|
+
startAndEnd: 'เริ่ม/เสร็จ',
|
|
23
24
|
today: 'วันนี้',
|
|
24
25
|
markItems: ['วันจันทร์', 'วันอังคาร', 'วันพุธ', 'วันพฤหัสบดี', 'วันศุกร์', 'วันเสาร์', 'วันอาทิตย์'],
|
|
25
26
|
yearAndMonth: '${year}/${month}'
|
package/2x/cjs/locales/vi-VN.js
CHANGED
|
@@ -20,6 +20,7 @@ const viVN = (0, _mergeLocale.mergeLocale)(_base.base, {
|
|
|
20
20
|
'confirm': 'Xác nhận',
|
|
21
21
|
'start': 'Bắt đầu',
|
|
22
22
|
'end': 'Kết thúc',
|
|
23
|
+
'startAndEnd': 'Bắt đầu/Kết thúc',
|
|
23
24
|
'today': 'Hôm nay',
|
|
24
25
|
'markItems': ['Một', 'Hai', 'Ba', 'Bốn', 'Năm', 'Sáu', 'Ngày'],
|
|
25
26
|
'yearAndMonth': 'Tháng ${month} năm ${year}'
|
package/2x/cjs/locales/zh-CN.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { ReactElement } from 'react';
|
|
2
|
-
export declare function renderToBody(element: ReactElement): ()
|
|
2
|
+
export declare function renderToBody(element: ReactElement): import("./unstable-render").UnmountType;
|