antd-mobile 5.42.0-alpha.0 → 5.42.0-alpha.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.
@@ -1,11 +1,15 @@
1
1
  import type { FC } from 'react';
2
2
  import { NativeProps } from '../../utils/native-props';
3
3
  import { PopupProps } from '../popup';
4
+ declare type CustomKeyType = string | {
5
+ key: string;
6
+ title: string;
7
+ };
4
8
  export declare type NumberKeyboardProps = {
5
9
  visible?: boolean;
6
10
  title?: string;
7
11
  confirmText?: string | null;
8
- customKey?: string | [string, string];
12
+ customKey?: CustomKeyType | CustomKeyType[];
9
13
  randomOrder?: boolean;
10
14
  showCloseButton?: boolean;
11
15
  onInput?: (v: string) => void;
@@ -16,3 +20,4 @@ export declare type NumberKeyboardProps = {
16
20
  safeArea?: boolean;
17
21
  } & Pick<PopupProps, 'afterClose' | 'afterShow' | 'getContainer' | 'destroyOnClose' | 'forceRender' | 'stopPropagation'> & NativeProps<'--adm-safe-area-multiple'>;
18
22
  export declare const NumberKeyboard: FC<NumberKeyboardProps>;
23
+ export {};
@@ -124,20 +124,27 @@ const NumberKeyboard = p => {
124
124
  onKeyPress(e, 'BACKSPACE');
125
125
  };
126
126
  const renderKey = (key, index) => {
127
- const isNumberKey = /^\d$/.test(key);
128
- const isBackspace = key === 'BACKSPACE';
127
+ const keyConfig = typeof key === 'string' ? {
128
+ key,
129
+ title: key
130
+ } : key;
131
+ const realKey = keyConfig.key;
132
+ const isNumberKey = /^\d$/.test(realKey);
133
+ const isBackspace = realKey === 'BACKSPACE';
134
+ const title = isBackspace ? locale.Input.clear : keyConfig.title;
129
135
  const className = (0, _classnames.default)(`${classPrefix}-key`, {
130
136
  [`${classPrefix}-key-number`]: isNumberKey,
131
- [`${classPrefix}-key-sign`]: !isNumberKey && key,
137
+ [`${classPrefix}-key-sign`]: !isNumberKey && realKey,
132
138
  [`${classPrefix}-key-mid`]: index === 9 && !!confirmText && keys.length < 12
133
139
  });
134
- const ariaProps = key ? {
140
+ const ariaProps = realKey ? {
135
141
  role: 'button',
136
- title: isBackspace ? locale.Input.clear : key,
142
+ title,
143
+ 'aria-label': title,
137
144
  tabIndex: -1
138
145
  } : undefined;
139
146
  return _react.default.createElement("div", Object.assign({
140
- key: key,
147
+ key: realKey,
141
148
  className: className,
142
149
  // 仅为 backspace 绑定,支持长按快速删除
143
150
  onTouchStart: isBackspace ? onBackspaceTouchStart : undefined,
@@ -149,9 +156,9 @@ const NumberKeyboard = p => {
149
156
  // backspace touchend 时会 preventDefault 阻止其后续 click 事件
150
157
  onClick: e => {
151
158
  stopContinueClear();
152
- onKeyPress(e, key);
159
+ onKeyPress(e, realKey);
153
160
  }
154
- }, ariaProps), isBackspace ? _react.default.createElement(_antdMobileIcons.TextDeletionOutline, null) : key);
161
+ }, ariaProps), isBackspace ? _react.default.createElement(_antdMobileIcons.TextDeletionOutline, null) : realKey);
155
162
  };
156
163
  return _react.default.createElement(_popup.default, {
157
164
  visible: visible,
@@ -1,11 +1,15 @@
1
1
  import type { FC } from 'react';
2
2
  import { NativeProps } from '../../utils/native-props';
3
3
  import { PopupProps } from '../popup';
4
+ declare type CustomKeyType = string | {
5
+ key: string;
6
+ title: string;
7
+ };
4
8
  export declare type NumberKeyboardProps = {
5
9
  visible?: boolean;
6
10
  title?: string;
7
11
  confirmText?: string | null;
8
- customKey?: string | [string, string];
12
+ customKey?: CustomKeyType | CustomKeyType[];
9
13
  randomOrder?: boolean;
10
14
  showCloseButton?: boolean;
11
15
  onInput?: (v: string) => void;
@@ -16,3 +20,4 @@ export declare type NumberKeyboardProps = {
16
20
  safeArea?: boolean;
17
21
  } & Pick<PopupProps, 'afterClose' | 'afterShow' | 'getContainer' | 'destroyOnClose' | 'forceRender' | 'stopPropagation'> & NativeProps<'--adm-safe-area-multiple'>;
18
22
  export declare const NumberKeyboard: FC<NumberKeyboardProps>;
23
+ export {};
@@ -115,20 +115,27 @@ export const NumberKeyboard = p => {
115
115
  onKeyPress(e, 'BACKSPACE');
116
116
  };
117
117
  const renderKey = (key, index) => {
118
- const isNumberKey = /^\d$/.test(key);
119
- const isBackspace = key === 'BACKSPACE';
118
+ const keyConfig = typeof key === 'string' ? {
119
+ key,
120
+ title: key
121
+ } : key;
122
+ const realKey = keyConfig.key;
123
+ const isNumberKey = /^\d$/.test(realKey);
124
+ const isBackspace = realKey === 'BACKSPACE';
125
+ const title = isBackspace ? locale.Input.clear : keyConfig.title;
120
126
  const className = classNames(`${classPrefix}-key`, {
121
127
  [`${classPrefix}-key-number`]: isNumberKey,
122
- [`${classPrefix}-key-sign`]: !isNumberKey && key,
128
+ [`${classPrefix}-key-sign`]: !isNumberKey && realKey,
123
129
  [`${classPrefix}-key-mid`]: index === 9 && !!confirmText && keys.length < 12
124
130
  });
125
- const ariaProps = key ? {
131
+ const ariaProps = realKey ? {
126
132
  role: 'button',
127
- title: isBackspace ? locale.Input.clear : key,
133
+ title,
134
+ 'aria-label': title,
128
135
  tabIndex: -1
129
136
  } : undefined;
130
137
  return React.createElement("div", Object.assign({
131
- key: key,
138
+ key: realKey,
132
139
  className: className,
133
140
  // 仅为 backspace 绑定,支持长按快速删除
134
141
  onTouchStart: isBackspace ? onBackspaceTouchStart : undefined,
@@ -140,9 +147,9 @@ export const NumberKeyboard = p => {
140
147
  // backspace touchend 时会 preventDefault 阻止其后续 click 事件
141
148
  onClick: e => {
142
149
  stopContinueClear();
143
- onKeyPress(e, key);
150
+ onKeyPress(e, realKey);
144
151
  }
145
- }, ariaProps), isBackspace ? React.createElement(TextDeletionOutline, null) : key);
152
+ }, ariaProps), isBackspace ? React.createElement(TextDeletionOutline, null) : realKey);
146
153
  };
147
154
  return React.createElement(Popup, {
148
155
  visible: visible,
package/2x/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "antd-mobile",
3
- "version": "5.42.0-alpha.0",
3
+ "version": "5.42.0-alpha.1",
4
4
  "homepage": "https://github.com/ant-design/ant-design-mobile#readme",
5
5
  "bugs": {
6
6
  "url": "https://github.com/ant-design/ant-design-mobile/issues"
@@ -23254,20 +23254,27 @@ const NumberKeyboard = (p) => {
23254
23254
  onKeyPress(e2, "BACKSPACE");
23255
23255
  };
23256
23256
  const renderKey = (key, index2) => {
23257
- const isNumberKey = /^\d$/.test(key);
23258
- const isBackspace = key === "BACKSPACE";
23257
+ const keyConfig = typeof key === "string" ? {
23258
+ key,
23259
+ title: key
23260
+ } : key;
23261
+ const realKey = keyConfig.key;
23262
+ const isNumberKey = /^\d$/.test(realKey);
23263
+ const isBackspace = realKey === "BACKSPACE";
23264
+ const title2 = isBackspace ? locale.Input.clear : keyConfig.title;
23259
23265
  const className = classNames(`${classPrefix$x}-key`, {
23260
23266
  [`${classPrefix$x}-key-number`]: isNumberKey,
23261
- [`${classPrefix$x}-key-sign`]: !isNumberKey && key,
23267
+ [`${classPrefix$x}-key-sign`]: !isNumberKey && realKey,
23262
23268
  [`${classPrefix$x}-key-mid`]: index2 === 9 && !!confirmText && keys2.length < 12
23263
23269
  });
23264
- const ariaProps = key ? {
23270
+ const ariaProps = realKey ? {
23265
23271
  role: "button",
23266
- title: isBackspace ? locale.Input.clear : key,
23272
+ title: title2,
23273
+ "aria-label": title2,
23267
23274
  tabIndex: -1
23268
23275
  } : void 0;
23269
23276
  return React$3.createElement("div", Object.assign({
23270
- key,
23277
+ key: realKey,
23271
23278
  className,
23272
23279
  // 仅为 backspace 绑定,支持长按快速删除
23273
23280
  onTouchStart: isBackspace ? onBackspaceTouchStart : void 0,
@@ -23279,9 +23286,9 @@ const NumberKeyboard = (p) => {
23279
23286
  // backspace touchend 时会 preventDefault 阻止其后续 click 事件
23280
23287
  onClick: (e2) => {
23281
23288
  stopContinueClear();
23282
- onKeyPress(e2, key);
23289
+ onKeyPress(e2, realKey);
23283
23290
  }
23284
- }, ariaProps), isBackspace ? React$3.createElement(TextDeletionOutline, null) : key);
23291
+ }, ariaProps), isBackspace ? React$3.createElement(TextDeletionOutline, null) : realKey);
23285
23292
  };
23286
23293
  return React$3.createElement(Popup, {
23287
23294
  visible,