@pisell/materials 6.4.13 → 6.4.15

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.
Files changed (74) hide show
  1. package/build/lowcode/index.js +1 -1
  2. package/build/lowcode/meta.js +1 -1
  3. package/build/lowcode/preview.js +9 -9
  4. package/build/lowcode/render/default/view.js +23 -23
  5. package/build/lowcode/view.js +24 -24
  6. package/es/components/cardPro/index.d.ts +4 -0
  7. package/es/components/cardPro/index.js +3 -10
  8. package/es/components/dataSourceComponents/dataSourceForm/utils.js +31 -5
  9. package/es/components/dataSourceComponents/dataSourceTable/hooks/useTableProps.d.ts +4 -1
  10. package/es/components/dataSourceComponents/dataSourceTable/hooks/useTableProps.js +4 -2
  11. package/es/components/dataSourceComponents/fields/Input.Mobile/WithMode.d.ts +10 -3
  12. package/es/components/dataSourceComponents/fields/Input.Mobile/WithMode.js +70 -28
  13. package/es/components/dataSourceComponents/fields/Input.Mobile/serve.d.ts +2 -2
  14. package/es/components/dataSourceComponents/fields/Input.Mobile/serve.js +24 -2
  15. package/es/components/dataSourceComponents/fields/Input.Phone/WithMode.d.ts +8 -2
  16. package/es/components/dataSourceComponents/fields/Input.Phone/WithMode.js +45 -13
  17. package/es/components/dataSourceComponents/fields/Input.Phone/serve.d.ts +3 -2
  18. package/es/components/dataSourceComponents/fields/Input.Phone/serve.js +76 -8
  19. package/es/components/dataSourceComponents/fields/Input.Subdomain/index.d.ts +1 -1
  20. package/es/components/dataSourceComponents/fields/index.d.ts +19 -19
  21. package/es/components/dataSourceComponents/hooks/usePlatform.d.ts +3 -1
  22. package/es/components/dataSourceComponents/hooks/usePlatform.js +9 -1
  23. package/es/components/drag-sort-tree/TreeItem/index.d.ts +1 -0
  24. package/es/components/filter/types.d.ts +2 -1
  25. package/es/components/iconfont/index.d.ts +8 -0
  26. package/es/components/iconfont/index.js +1 -1
  27. package/es/components/table/Actions/index.d.ts +1 -0
  28. package/es/components/table/Actions/index.js +4 -1
  29. package/es/components/table/Table/fields/index.d.ts +2 -2
  30. package/es/components/table/Table/utils.d.ts +1 -1
  31. package/es/components/table/hooks/useTableSetting.js +2 -2
  32. package/es/components/virtual-keyboard/Amount/index.d.ts +1 -0
  33. package/es/locales/en-US.d.ts +297 -0
  34. package/es/locales/en-US.js +1 -16
  35. package/es/locales/zh-CN.d.ts +292 -0
  36. package/es/locales/zh-CN.js +1 -16
  37. package/es/locales/zh-TW.d.ts +292 -0
  38. package/es/locales/zh-TW.js +1 -16
  39. package/lib/components/cardPro/index.d.ts +4 -0
  40. package/lib/components/cardPro/index.js +2 -3
  41. package/lib/components/dataSourceComponents/dataSourceForm/utils.js +26 -2
  42. package/lib/components/dataSourceComponents/dataSourceTable/hooks/useTableProps.d.ts +4 -1
  43. package/lib/components/dataSourceComponents/dataSourceTable/hooks/useTableProps.js +4 -2
  44. package/lib/components/dataSourceComponents/fields/Input.Mobile/WithMode.d.ts +10 -3
  45. package/lib/components/dataSourceComponents/fields/Input.Mobile/WithMode.js +67 -18
  46. package/lib/components/dataSourceComponents/fields/Input.Mobile/serve.d.ts +2 -2
  47. package/lib/components/dataSourceComponents/fields/Input.Mobile/serve.js +29 -7
  48. package/lib/components/dataSourceComponents/fields/Input.Phone/WithMode.d.ts +8 -2
  49. package/lib/components/dataSourceComponents/fields/Input.Phone/WithMode.js +41 -9
  50. package/lib/components/dataSourceComponents/fields/Input.Phone/serve.d.ts +3 -2
  51. package/lib/components/dataSourceComponents/fields/Input.Phone/serve.js +53 -11
  52. package/lib/components/dataSourceComponents/fields/Input.Subdomain/index.d.ts +1 -1
  53. package/lib/components/dataSourceComponents/fields/index.d.ts +19 -19
  54. package/lib/components/dataSourceComponents/hooks/usePlatform.d.ts +3 -1
  55. package/lib/components/dataSourceComponents/hooks/usePlatform.js +12 -0
  56. package/lib/components/drag-sort-tree/TreeItem/index.d.ts +1 -0
  57. package/lib/components/filter/types.d.ts +2 -1
  58. package/lib/components/iconfont/index.d.ts +8 -0
  59. package/lib/components/iconfont/index.js +1 -1
  60. package/lib/components/table/Actions/index.d.ts +1 -0
  61. package/lib/components/table/Actions/index.js +4 -1
  62. package/lib/components/table/Table/fields/index.d.ts +2 -2
  63. package/lib/components/table/Table/utils.d.ts +1 -1
  64. package/lib/components/table/hooks/useTableSetting.js +2 -2
  65. package/lib/components/virtual-keyboard/Amount/index.d.ts +1 -0
  66. package/lib/locales/en-US.d.ts +297 -0
  67. package/lib/locales/en-US.js +1 -12
  68. package/lib/locales/zh-CN.d.ts +292 -0
  69. package/lib/locales/zh-CN.js +1 -12
  70. package/lib/locales/zh-TW.d.ts +292 -0
  71. package/lib/locales/zh-TW.js +1 -12
  72. package/lowcode/form-item-input.mobile/meta.ts +22 -0
  73. package/lowcode/form-item-input.phone/meta.ts +22 -0
  74. package/package.json +1 -1
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ import './index.less';
3
+ declare const _default: (props: any) => JSX.Element;
4
+ export default _default;
@@ -1,9 +1,3 @@
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 ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
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
1
  import React from 'react';
8
2
  import { withWrap } from "../../utils/hoc";
9
3
  import { Card, Flex } from 'antd';
@@ -25,13 +19,12 @@ var CardPro = function CardPro(props) {
25
19
  isShowHead = props.isShowHead,
26
20
  className = props.className,
27
21
  coverHeight = props.coverHeight,
28
- badge = props.badge,
29
- style = props.style;
22
+ badge = props.badge;
30
23
  return /*#__PURE__*/React.createElement(Card, {
31
24
  title: null,
32
- style: _objectSpread({
25
+ style: {
33
26
  padding: 0
34
- }, style),
27
+ },
35
28
  className: classNames('pisell-cardPro-wrap', className, cover && 'pisell-cardPro-wrap-with-cover')
36
29
  }, !!cover && /*#__PURE__*/React.createElement("div", {
37
30
  className: classNames('pisell-cardPro-cover'),
@@ -1,7 +1,7 @@
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
1
  var _excluded = ["renderMode", "value", "onChange"],
3
2
  _excluded2 = ["name", "label", "mode", "renderMode", "tooltip", "noStyle", "extra", "required", "requiredobj", "minLengthobj", "maxLengthobj", "typeobj", "maxobj", "minobj", "normalize", "getValueProps", "validator", "style", "validateTrigger", "__designMode", "labelCol", "hideLabel", "innerStyle"];
4
3
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
4
+ 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); }
5
5
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
6
6
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
7
7
  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); }
@@ -172,9 +172,27 @@ export var withFormItem = function withFormItem(WrappedComponent, overlayProps)
172
172
  break;
173
173
  case 'phone':
174
174
  rules.push({
175
- validator: function validator(_, value) {
175
+ validator: function validator(_, originValue) {
176
+ var _value, _phone;
177
+ var value = "";
178
+ if (isString(originValue)) {
179
+ value = originValue;
180
+ } else if (originValue && 'phone' in originValue) {
181
+ value = "".concat((originValue === null || originValue === void 0 ? void 0 : originValue.countryCallingCode) || "").concat(originValue.phone || "");
182
+ }
183
+
176
184
  // 如果值为空或者只有空格,直接返回成功,不进行校验
177
- if (!(value !== null && value !== void 0 && value.trim())) {
185
+ if (!((_value = value) !== null && _value !== void 0 && _value.trim())) {
186
+ if ((requiredobj === null || requiredobj === void 0 ? void 0 : requiredobj.required) === false) {
187
+ return Promise.resolve();
188
+ } else if (_typeof(originValue) == 'object') {
189
+ // 如果是object,存在phone和contryCallingCode都为空的场景,需要拦截
190
+ return Promise.reject(new Error(requiredobj.message || getText('pisell-data-source-form-required-message')));
191
+ }
192
+ }
193
+
194
+ // 如果是object返回格式,非必填且phone为空,不进行校验
195
+ if (typeof originValue !== 'string' && (requiredobj === null || requiredobj === void 0 ? void 0 : requiredobj.required) === false && (originValue === null || originValue === void 0 || (_phone = originValue.phone) === null || _phone === void 0 ? void 0 : _phone.trim()) === '') {
178
196
  return Promise.resolve();
179
197
  }
180
198
  try {
@@ -194,9 +212,17 @@ export var withFormItem = function withFormItem(WrappedComponent, overlayProps)
194
212
  break;
195
213
  case 'mobile':
196
214
  rules.push({
197
- validator: function validator(_, value) {
215
+ validator: function validator(_, originValue) {
216
+ var _value2;
217
+ var value = "";
218
+ if (isString(originValue)) {
219
+ value = originValue;
220
+ } else if (originValue && 'phone' in originValue) {
221
+ value = "".concat((originValue === null || originValue === void 0 ? void 0 : originValue.countryCallingCode) || "").concat(originValue.phone || "");
222
+ }
223
+
198
224
  // 如果值为空或者只有空格,直接返回成功,不进行校验
199
- if (!(value !== null && value !== void 0 && value.trim())) {
225
+ if (!((_value2 = value) !== null && _value2 !== void 0 && _value2.trim())) {
200
226
  return Promise.resolve();
201
227
  }
202
228
  try {
@@ -30,7 +30,10 @@ declare const useTableProps: (props: UseTablePropsProps) => {
30
30
  columns: import("./useColumns").Column[];
31
31
  subTitle: number | boolean | React.ReactFragment | JSX.Element | (() => React.ReactNode) | null | undefined;
32
32
  buttons: any[] | null;
33
- filter: any;
33
+ filter: {
34
+ dom: any;
35
+ items: any;
36
+ } | null;
34
37
  onRow: (record: any) => any;
35
38
  actionButtons: any[] | null;
36
39
  __id?: string | undefined;
@@ -300,8 +300,10 @@ var useTableProps = function useTableProps(props) {
300
300
  filterBy: filterBy,
301
301
  getInitialValues: getInitialValues
302
302
  }));
303
- dom.__proto__.__items = propsFilter === null || propsFilter === void 0 ? void 0 : propsFilter.items;
304
- return dom;
303
+ return {
304
+ dom: dom,
305
+ items: propsFilter === null || propsFilter === void 0 ? void 0 : propsFilter.items
306
+ };
305
307
  }, [propsFilter, search]);
306
308
  var onRow = useMemoizedFn(function (record) {
307
309
  if (!(clickToDetail !== null && clickToDetail !== void 0 && clickToDetail.show)) {
@@ -1,10 +1,17 @@
1
1
  import React from 'react';
2
2
  import { InputProps } from 'antd';
3
- import { ModeType } from "../../dataSourceForm/type";
3
+ import { ModeType } from '../../dataSourceForm/type';
4
+ declare type PhoneValue = string | {
5
+ phone: string;
6
+ countryCallingCode: string;
7
+ countryCode?: string;
8
+ };
4
9
  export interface PhoneInputProps extends Omit<InputProps, 'value' | 'onChange'> {
5
10
  renderMode: ModeType;
6
- value?: string;
7
- onChange?: (value: string) => void;
11
+ value?: PhoneValue;
12
+ onChange?: (value: PhoneValue) => void;
13
+ returnFormat?: 'string' | 'object';
14
+ inputRef?: any;
8
15
  }
9
16
  declare const MobileNumberInputWithMode: React.FC<PhoneInputProps & import("../../dataSourceForm/utils").WithModeProps>;
10
17
  export default MobileNumberInputWithMode;
@@ -1,4 +1,4 @@
1
- var _excluded = ["value", "onChange", "disabled"];
1
+ var _excluded = ["value", "onChange", "disabled", "returnFormat"];
2
2
  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); }
3
3
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
4
4
  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."); }
@@ -10,31 +10,32 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
10
10
  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; }
11
11
  import React, { useState, useEffect, useMemo } from 'react';
12
12
  import { Input, Space } from 'antd';
13
- import { isNumber } from '@pisell/utils';
13
+ import { isNumber, isString } from '@pisell/utils';
14
14
  import Select from "../../../select";
15
- import { useCountries } from "./serve";
15
+ import { useCountries } from "./../Input.Phone/serve";
16
16
  import ReadPretty from "./ReadPretty";
17
17
  import { withMode } from "../../dataSourceForm/utils";
18
18
  import useTranslationOriginal from "../../../../hooks/useTranslationOriginal";
19
+ import useSetRequest from "../../../../hooks/useSetRequest";
19
20
  var Option = Select.Option;
20
21
  /**
21
22
  * 手机号码输入组件
22
- *
23
+ *
23
24
  * 校验规则:
24
25
  * 1. AU(+61) 验证规则:
25
26
  * - 10位或9位数字
26
27
  * - 前两位是04或者第一位是4
27
28
  * - 格式示例:0412345678 或 412345678
28
- *
29
+ *
29
30
  * 2. CN(+86) 验证规则:
30
31
  * - 11位数字
31
32
  * - 第一位必须是1
32
33
  * - 格式示例:13812345678
33
- *
34
+ *
34
35
  * 3. 其他国家验证规则:
35
36
  * - 15位以内数字
36
37
  * - 格式示例:123456789
37
- *
38
+ *
38
39
  * 使用方式:
39
40
  * <Mobile
40
41
  * name="mobile"
@@ -50,7 +51,10 @@ var MobileNumberInput = function MobileNumberInput(_ref) {
50
51
  var propsValue = _ref.value,
51
52
  onChange = _ref.onChange,
52
53
  disabled = _ref.disabled,
54
+ _ref$returnFormat = _ref.returnFormat,
55
+ returnFormat = _ref$returnFormat === void 0 ? 'string' : _ref$returnFormat,
53
56
  props = _objectWithoutProperties(_ref, _excluded);
57
+ useSetRequest();
54
58
  var _useCountries = useCountries(),
55
59
  _useCountries$data = _useCountries.data,
56
60
  countries = _useCountries$data === void 0 ? [] : _useCountries$data;
@@ -61,6 +65,19 @@ var MobileNumberInput = function MobileNumberInput(_ref) {
61
65
  }
62
66
  return propsValue;
63
67
  }, [propsValue]);
68
+ var handleChange = function handleChange(prefix, phoneNumber, countryCode) {
69
+ if (returnFormat === 'string') {
70
+ // 只有当实际输入的号码部分不为空时,才包含区号
71
+ var newValue = phoneNumber ? "".concat(prefix).concat(phoneNumber) : '';
72
+ onChange === null || onChange === void 0 || onChange(newValue);
73
+ } else {
74
+ onChange === null || onChange === void 0 || onChange({
75
+ phone: phoneNumber,
76
+ countryCallingCode: prefix,
77
+ countryCode: countryCode
78
+ });
79
+ }
80
+ };
64
81
 
65
82
  // 解析外部传入的value
66
83
  var parseExternalValue = function parseExternalValue(val) {
@@ -68,18 +85,34 @@ var MobileNumberInput = function MobileNumberInput(_ref) {
68
85
  countryCode: 'AU',
69
86
  phoneNumber: ''
70
87
  };
71
- var matchedPrefix = countries.find(function (country) {
72
- return val.startsWith(country.prefix);
73
- });
74
- if (matchedPrefix) {
88
+ var srtValue = '';
89
+ if (isString(val)) {
90
+ srtValue = val;
91
+ } else if ('phone' in val) {
92
+ srtValue = "".concat(val.countryCallingCode || '').concat(val.phone || '');
93
+ }
94
+ var matchedContry = null;
95
+ // 如果外部传入了countryCode,则以countryCode为准进行countryCode匹配
96
+ if (!isString(val) && val !== null && val !== void 0 && val.countryCode) {
97
+ matchedContry = countries.find(function (country) {
98
+ return (country === null || country === void 0 ? void 0 : country.code) === (val === null || val === void 0 ? void 0 : val.countryCode);
99
+ });
100
+ }
101
+ // 如果外部没有传入countryCode或者匹配不到,则以srtValue为准进行prefix匹配
102
+ if (!matchedContry) {
103
+ matchedContry = countries.find(function (country) {
104
+ return srtValue.startsWith(country.prefix);
105
+ });
106
+ }
107
+ if (matchedContry) {
75
108
  return {
76
- countryCode: matchedPrefix.code,
77
- phoneNumber: val.slice(matchedPrefix.prefix.length)
109
+ countryCode: matchedContry.code,
110
+ phoneNumber: srtValue.slice(matchedContry.prefix.length)
78
111
  };
79
112
  }
80
113
  return {
81
114
  countryCode: 'AU',
82
- phoneNumber: val.replace(/\D/g, '')
115
+ phoneNumber: srtValue.replace(/\D/g, '')
83
116
  };
84
117
  };
85
118
  var _useState = useState(function () {
@@ -116,11 +149,9 @@ var MobileNumberInput = function MobileNumberInput(_ref) {
116
149
  var selectedCountry = countries.find(function (c) {
117
150
  return c.code === value;
118
151
  });
119
- var prefix = (selectedCountry === null || selectedCountry === void 0 ? void 0 : selectedCountry.prefix) || "";
120
- var newValue = "".concat(prefix).concat(phoneNumber);
121
-
152
+ var prefix = (selectedCountry === null || selectedCountry === void 0 ? void 0 : selectedCountry.prefix) || '';
122
153
  // 先更新值
123
- onChange === null || onChange === void 0 || onChange(newValue);
154
+ handleChange(prefix, phoneNumber, selectedCountry === null || selectedCountry === void 0 ? void 0 : selectedCountry.code);
124
155
 
125
156
  // 使用 setTimeout 确保值更新后再触发验证
126
157
  setTimeout(function () {
@@ -140,13 +171,8 @@ var MobileNumberInput = function MobileNumberInput(_ref) {
140
171
  var selectedCountry = countries.find(function (c) {
141
172
  return c.code === countryCode;
142
173
  });
143
- var prefix = (selectedCountry === null || selectedCountry === void 0 ? void 0 : selectedCountry.prefix) || "";
144
-
145
- // 只有当实际输入的号码部分不为空时,才包含区号
146
- var newValue = cleanNumber ? "".concat(prefix).concat(cleanNumber) : '';
147
-
148
- // 更新值
149
- onChange === null || onChange === void 0 || onChange(newValue);
174
+ var prefix = (selectedCountry === null || selectedCountry === void 0 ? void 0 : selectedCountry.prefix) || '';
175
+ handleChange(prefix, cleanNumber, selectedCountry === null || selectedCountry === void 0 ? void 0 : selectedCountry.code);
150
176
 
151
177
  // 如果号码为空,只清除校验信息,不重置国家代码
152
178
  if (!cleanNumber) {
@@ -167,14 +193,29 @@ var MobileNumberInput = function MobileNumberInput(_ref) {
167
193
  return c.code === countryCode;
168
194
  });
169
195
  if (phoneNumber.length === 0) {
170
- return "";
196
+ return '';
171
197
  }
172
- var prefix = (selectedCountry === null || selectedCountry === void 0 ? void 0 : selectedCountry.prefix) || "";
198
+ var prefix = (selectedCountry === null || selectedCountry === void 0 ? void 0 : selectedCountry.prefix) || '';
173
199
  return "".concat(prefix).concat(phoneNumber);
174
200
  }, [countryCode, phoneNumber, countries]);
201
+ var objValue = useMemo(function () {
202
+ var selectedCountry = countries.find(function (c) {
203
+ return c.code === countryCode;
204
+ });
205
+ var prefix = (selectedCountry === null || selectedCountry === void 0 ? void 0 : selectedCountry.prefix) || '';
206
+ return {
207
+ phone: phoneNumber || '',
208
+ countryCallingCode: prefix,
209
+ countryCode: countryCode
210
+ };
211
+ }, [countryCode, phoneNumber, countries]);
175
212
  var handleBlur = function handleBlur() {
176
213
  var finalValue = concatenatedNumber;
177
- onChange === null || onChange === void 0 || onChange(finalValue);
214
+ if (returnFormat === 'string') {
215
+ onChange === null || onChange === void 0 || onChange(finalValue);
216
+ } else {
217
+ onChange === null || onChange === void 0 || onChange(objValue);
218
+ }
178
219
  };
179
220
  return /*#__PURE__*/React.createElement(Space.Compact, {
180
221
  block: true
@@ -197,6 +238,7 @@ var MobileNumberInput = function MobileNumberInput(_ref) {
197
238
  };
198
239
  })
199
240
  }), /*#__PURE__*/React.createElement(Input, _extends({}, props, {
241
+ ref: props === null || props === void 0 ? void 0 : props.inputRef,
200
242
  disabled: disabled,
201
243
  type: "tel",
202
244
  value: phoneNumber,
@@ -6,8 +6,8 @@ export interface Country {
6
6
  id: number;
7
7
  name: {
8
8
  en: string;
9
- "zh-CN": string;
10
- "zh-HK": string;
9
+ 'zh-CN': string;
10
+ 'zh-HK': string;
11
11
  original: string;
12
12
  };
13
13
  code: string;
@@ -10,7 +10,7 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar
10
10
  import { useEffect, useMemo } from 'react';
11
11
  import { useRequest } from 'ahooks';
12
12
  import { request } from "../../../table/utils";
13
- import { useIsShop } from "../../hooks/usePlatform";
13
+ import { useIsShop, useIsH5, useIsPc } from "../../hooks/usePlatform";
14
14
  import useEngineContext from "../../../../hooks/useEngineContext";
15
15
 
16
16
  /**
@@ -27,7 +27,7 @@ export var getCountryDataList = /*#__PURE__*/function () {
27
27
  isNocobase: true,
28
28
  fullResult: true,
29
29
  headers: {
30
- "x-data-source": "pisell2"
30
+ 'x-data-source': 'pisell2'
31
31
  }
32
32
  });
33
33
  case 2:
@@ -50,6 +50,8 @@ export var getCountryDataList = /*#__PURE__*/function () {
50
50
  }();
51
51
  export var useCountries = function useCountries() {
52
52
  var isShop = useIsShop();
53
+ var isH5 = useIsH5();
54
+ var isPc = useIsPc();
53
55
  var _useEngineContext = useEngineContext(),
54
56
  appHelper = _useEngineContext.appHelper;
55
57
  var _useRequest = useRequest(getCountryDataList, {
@@ -78,6 +80,26 @@ export var useCountries = function useCountries() {
78
80
  });
79
81
  });
80
82
  }
83
+ } else if (isPc) {
84
+ var _appHelper$utils2;
85
+ var _codeList = appHelper === null || appHelper === void 0 || (_appHelper$utils2 = appHelper.utils) === null || _appHelper$utils2 === void 0 || (_appHelper$utils2 = _appHelper$utils2.store) === null || _appHelper$utils2 === void 0 || (_appHelper$utils2 = _appHelper$utils2.getState()) === null || _appHelper$utils2 === void 0 || (_appHelper$utils2 = _appHelper$utils2.country) === null || _appHelper$utils2 === void 0 ? void 0 : _appHelper$utils2.country;
86
+ if (_codeList) {
87
+ return _codeList.map(function (item) {
88
+ return _objectSpread(_objectSpread({}, item), {}, {
89
+ prefix: "+".concat(item.calling_code)
90
+ });
91
+ });
92
+ }
93
+ } else if (isH5) {
94
+ var _appHelper$utils3;
95
+ var _codeList2 = appHelper === null || appHelper === void 0 || (_appHelper$utils3 = appHelper.utils) === null || _appHelper$utils3 === void 0 || (_appHelper$utils3 = _appHelper$utils3.getStore()) === null || _appHelper$utils3 === void 0 || (_appHelper$utils3 = _appHelper$utils3.getState()) === null || _appHelper$utils3 === void 0 || (_appHelper$utils3 = _appHelper$utils3.country) === null || _appHelper$utils3 === void 0 ? void 0 : _appHelper$utils3.country;
96
+ if (_codeList2) {
97
+ return _codeList2.map(function (item) {
98
+ return _objectSpread(_objectSpread({}, item), {}, {
99
+ prefix: "+".concat(item.calling_code)
100
+ });
101
+ });
102
+ }
81
103
  }
82
104
  return data;
83
105
  }, [isShop, data]);
@@ -1,10 +1,16 @@
1
1
  import React from 'react';
2
2
  import { InputProps } from 'antd';
3
3
  import { ModeType } from "../../dataSourceForm/type";
4
+ declare type PhoneValue = string | {
5
+ phone: string;
6
+ countryCallingCode: string;
7
+ };
4
8
  export interface PhoneInputProps extends Omit<InputProps, 'value' | 'onChange'> {
5
9
  renderMode: ModeType;
6
- value?: string;
7
- onChange?: (value: string) => void;
10
+ value?: PhoneValue;
11
+ onChange?: (value: PhoneValue) => void;
12
+ returnFormat?: 'string' | 'object';
13
+ inputRef?: any;
8
14
  }
9
15
  declare const PhoneNumberInputWithMode: React.FC<PhoneInputProps & import("../../dataSourceForm/utils").WithModeProps>;
10
16
  export default PhoneNumberInputWithMode;
@@ -1,4 +1,4 @@
1
- var _excluded = ["value", "onChange", "disabled"];
1
+ var _excluded = ["value", "onChange", "disabled", "returnFormat"];
2
2
  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); }
3
3
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
4
4
  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."); }
@@ -10,12 +10,13 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
10
10
  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; }
11
11
  import React, { useState, useEffect, useMemo } from 'react';
12
12
  import { Input, Space } from 'antd';
13
- import { isNumber } from '@pisell/utils';
13
+ import { isNumber, isString } from '@pisell/utils';
14
14
  import Select from "../../../select";
15
15
  import { useCountries } from "./serve";
16
16
  import ReadPretty from "./ReadPretty";
17
17
  import { withMode } from "../../dataSourceForm/utils";
18
18
  import useTranslationOriginal from "../../../../hooks/useTranslationOriginal";
19
+ import useSetRequest from "../../../../hooks/useSetRequest";
19
20
  var Option = Select.Option;
20
21
  /**
21
22
  * 电话号码输入组件
@@ -45,7 +46,10 @@ var PhoneNumberInput = function PhoneNumberInput(_ref) {
45
46
  var propsValue = _ref.value,
46
47
  onChange = _ref.onChange,
47
48
  disabled = _ref.disabled,
49
+ _ref$returnFormat = _ref.returnFormat,
50
+ returnFormat = _ref$returnFormat === void 0 ? 'string' : _ref$returnFormat,
48
51
  props = _objectWithoutProperties(_ref, _excluded);
52
+ useSetRequest();
49
53
  var _useCountries = useCountries(),
50
54
  _useCountries$data = _useCountries.data,
51
55
  countries = _useCountries$data === void 0 ? [] : _useCountries$data;
@@ -63,18 +67,24 @@ var PhoneNumberInput = function PhoneNumberInput(_ref) {
63
67
  countryCode: 'AU',
64
68
  phoneNumber: ''
65
69
  };
70
+ var srtValue = "";
71
+ if (isString(val)) {
72
+ srtValue = val;
73
+ } else if ('phone' in val) {
74
+ srtValue = "".concat(val.countryCallingCode || "").concat(val.phone || "");
75
+ }
66
76
  var matchedPrefix = countries.find(function (country) {
67
- return val.startsWith(country.prefix);
77
+ return srtValue.startsWith(country.prefix);
68
78
  });
69
79
  if (matchedPrefix) {
70
80
  return {
71
81
  countryCode: matchedPrefix.code,
72
- phoneNumber: val.slice(matchedPrefix.prefix.length)
82
+ phoneNumber: srtValue.slice(matchedPrefix.prefix.length)
73
83
  };
74
84
  }
75
85
  return {
76
86
  countryCode: 'AU',
77
- phoneNumber: val.replace(/\D/g, '')
87
+ phoneNumber: srtValue.replace(/\D/g, '')
78
88
  };
79
89
  };
80
90
  var _useState = useState(function () {
@@ -98,6 +108,18 @@ var PhoneNumberInput = function PhoneNumberInput(_ref) {
98
108
  setCountryCode(newCountryCode);
99
109
  setPhoneNumber(newPhoneNumber);
100
110
  }, [value, countries]);
111
+ var handleChange = function handleChange(prefix, phoneNumber) {
112
+ if (returnFormat === 'string') {
113
+ // 只有当实际输入的号码部分不为空时,才包含区号
114
+ var newValue = phoneNumber ? "".concat(prefix).concat(phoneNumber) : '';
115
+ onChange === null || onChange === void 0 || onChange(newValue);
116
+ } else {
117
+ onChange === null || onChange === void 0 || onChange({
118
+ phone: phoneNumber,
119
+ countryCallingCode: prefix
120
+ });
121
+ }
122
+ };
101
123
  var handlePhoneNumberChange = function handlePhoneNumberChange(e) {
102
124
  var cleanNumber = e.target.value.replace(/\D/g, '');
103
125
  setPhoneNumber(cleanNumber);
@@ -107,12 +129,8 @@ var PhoneNumberInput = function PhoneNumberInput(_ref) {
107
129
  return c.code === countryCode;
108
130
  });
109
131
  var prefix = (selectedCountry === null || selectedCountry === void 0 ? void 0 : selectedCountry.prefix) || "";
110
-
111
- // 只有当实际输入的号码部分不为空时,才包含区号
112
- var newValue = cleanNumber ? "".concat(prefix).concat(cleanNumber) : '';
113
-
114
132
  // 更新值
115
- onChange === null || onChange === void 0 || onChange(newValue);
133
+ handleChange(prefix, cleanNumber);
116
134
 
117
135
  // 如果实际号码部分为空,立即触发验证以清除错误信息
118
136
  if (!cleanNumber) {
@@ -133,10 +151,9 @@ var PhoneNumberInput = function PhoneNumberInput(_ref) {
133
151
  return c.code === value;
134
152
  });
135
153
  var prefix = (selectedCountry === null || selectedCountry === void 0 ? void 0 : selectedCountry.prefix) || "";
136
- var newValue = "".concat(prefix).concat(phoneNumber);
137
154
 
138
155
  // 先更新值
139
- onChange === null || onChange === void 0 || onChange(newValue);
156
+ handleChange(prefix, phoneNumber);
140
157
 
141
158
  // 使用 setTimeout 确保值更新后再触发验证
142
159
  setTimeout(function () {
@@ -158,9 +175,23 @@ var PhoneNumberInput = function PhoneNumberInput(_ref) {
158
175
  var prefix = (selectedCountry === null || selectedCountry === void 0 ? void 0 : selectedCountry.prefix) || "";
159
176
  return "".concat(prefix).concat(phoneNumber);
160
177
  }, [countryCode, phoneNumber, countries]);
178
+ var objValue = useMemo(function () {
179
+ var selectedCountry = countries.find(function (c) {
180
+ return c.code === countryCode;
181
+ });
182
+ var prefix = (selectedCountry === null || selectedCountry === void 0 ? void 0 : selectedCountry.prefix) || "";
183
+ return {
184
+ phone: phoneNumber || "",
185
+ countryCallingCode: prefix
186
+ };
187
+ }, [countryCode, phoneNumber, countries]);
161
188
  var handleBlur = function handleBlur() {
162
189
  var finalValue = concatenatedNumber;
163
- onChange === null || onChange === void 0 || onChange(finalValue);
190
+ if (returnFormat === 'string') {
191
+ onChange === null || onChange === void 0 || onChange(finalValue);
192
+ } else {
193
+ onChange === null || onChange === void 0 || onChange(objValue);
194
+ }
164
195
  };
165
196
  return /*#__PURE__*/React.createElement(Space.Compact, {
166
197
  block: true
@@ -183,6 +214,7 @@ var PhoneNumberInput = function PhoneNumberInput(_ref) {
183
214
  };
184
215
  })
185
216
  }), /*#__PURE__*/React.createElement(Input, _extends({}, props, {
217
+ ref: props === null || props === void 0 ? void 0 : props.inputRef,
186
218
  disabled: disabled,
187
219
  type: "tel",
188
220
  value: phoneNumber,
@@ -2,12 +2,13 @@
2
2
  * 获取nocobase数据列表
3
3
  */
4
4
  export declare const getCountryDataList: () => Promise<any>;
5
+ export declare const getShopCountryDataList: (locale?: any) => Promise<any>;
5
6
  export interface Country {
6
7
  id: number;
7
8
  name: {
8
9
  en: string;
9
- "zh-CN": string;
10
- "zh-HK": string;
10
+ 'zh-CN': string;
11
+ 'zh-HK': string;
11
12
  original: string;
12
13
  };
13
14
  code: string;