@pisell/materials 6.0.10 → 6.0.12

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 (270) hide show
  1. package/build/lowcode/assets-daily.json +11 -15
  2. package/build/lowcode/assets-dev.json +2 -6
  3. package/build/lowcode/assets-prod.json +11 -15
  4. package/build/lowcode/index.js +1 -1
  5. package/build/lowcode/meta.js +7 -7
  6. package/build/lowcode/preview.js +7 -7
  7. package/build/lowcode/render/default/view.css +1 -1
  8. package/build/lowcode/render/default/view.js +22 -22
  9. package/build/lowcode/view.css +1 -1
  10. package/build/lowcode/view.js +22 -22
  11. package/dist/umd/materials.min.css +1 -0
  12. package/dist/umd/materials.min.js +1 -0
  13. package/dist/umd/static/DotsSix.57d66266.svg +1 -0
  14. package/dist/umd/static/arrow-left.e542294f.svg +1 -0
  15. package/dist/umd/static/arrow-right.763f03e0.svg +1 -0
  16. package/dist/umd/static/filter-lines.04a54ae9.svg +1 -0
  17. package/dist/umd/static/help-circle.31c9be40.svg +1 -0
  18. package/dist/umd/static/switch-vertical-01.7ebe3ba8.svg +1 -0
  19. package/es/components/dataSourceComponents/dataSourceForm/BaseForm.js +94 -3
  20. package/es/components/dataSourceComponents/dataSourceForm/submitButton/index.js +7 -6
  21. package/es/components/dataSourceComponents/dataSourceForm/type.d.ts +8 -0
  22. package/es/components/dataSourceComponents/dataSourceForm/utils.d.ts +1 -0
  23. package/es/components/dataSourceComponents/dataSourceForm/utils.js +120 -38
  24. package/es/components/dataSourceComponents/dataSourceMenu/index.d.ts +2 -0
  25. package/es/components/dataSourceComponents/dataSourceMenu/index.js +19 -0
  26. package/es/components/dataSourceComponents/dataSourceTable/BaseTable.js +46 -8
  27. package/es/components/dataSourceComponents/dataSourceTable/hooks/useTableProps.d.ts +3 -3
  28. package/es/components/dataSourceComponents/fields/Input/index.d.ts +4 -0
  29. package/es/components/dataSourceComponents/fields/Input/index.js +5 -1
  30. package/es/components/dataSourceComponents/fields/Input.Mobile/ReadPretty.d.ts +5 -0
  31. package/es/components/dataSourceComponents/fields/Input.Mobile/ReadPretty.js +28 -0
  32. package/es/components/dataSourceComponents/fields/Input.Mobile/ReadPretty.less +11 -0
  33. package/es/components/dataSourceComponents/fields/Input.Mobile/WithMode.d.ts +10 -0
  34. package/es/components/dataSourceComponents/fields/Input.Mobile/WithMode.js +212 -0
  35. package/es/components/dataSourceComponents/fields/Input.Mobile/index.d.ts +3 -0
  36. package/es/components/dataSourceComponents/fields/Input.Mobile/index.js +14 -0
  37. package/es/components/dataSourceComponents/fields/Input.Mobile/serve.d.ts +24 -0
  38. package/es/components/dataSourceComponents/fields/Input.Mobile/serve.js +59 -0
  39. package/es/components/dataSourceComponents/fields/Input.Mobile/type.d.ts +5 -0
  40. package/es/components/dataSourceComponents/fields/Input.Mobile/type.js +1 -0
  41. package/es/components/dataSourceComponents/fields/Input.Phone/WithMode.d.ts +2 -3
  42. package/es/components/dataSourceComponents/fields/Input.Phone/WithMode.js +76 -19
  43. package/es/components/dataSourceComponents/fields/Input.Subdomain/ReadPretty.d.ts +5 -0
  44. package/es/components/dataSourceComponents/fields/Input.Subdomain/ReadPretty.js +13 -0
  45. package/es/components/dataSourceComponents/fields/Input.Subdomain/ReadPretty.less +11 -0
  46. package/es/components/dataSourceComponents/fields/Input.Subdomain/WithMode.d.ts +13 -0
  47. package/es/components/dataSourceComponents/fields/Input.Subdomain/WithMode.js +206 -0
  48. package/es/components/dataSourceComponents/fields/Input.Subdomain/index.d.ts +12 -0
  49. package/es/components/dataSourceComponents/fields/Input.Subdomain/index.js +4 -0
  50. package/es/components/dataSourceComponents/fields/Input.Subdomain/serve.d.ts +11 -0
  51. package/es/components/dataSourceComponents/fields/Input.Subdomain/serve.js +63 -0
  52. package/es/components/dataSourceComponents/fields/Input.Subdomain/type.d.ts +5 -0
  53. package/es/components/dataSourceComponents/fields/Input.Subdomain/type.js +1 -0
  54. package/es/components/dataSourceComponents/fields/Translation/BaseTranslation.js +15 -4
  55. package/es/components/dataSourceComponents/fields/Translation/type.d.ts +1 -0
  56. package/es/components/dataSourceComponents/fields/Upload/BaseUpload.js +17 -13
  57. package/es/components/dataSourceComponents/fields/Upload/ReadPretty.d.ts +1 -1
  58. package/es/components/dataSourceComponents/fields/Upload/ReadPretty.js +4 -2
  59. package/es/components/dataSourceComponents/fields/Upload/WithMode.js +5 -4
  60. package/es/components/dataSourceComponents/fields/Upload/index.less +1 -1
  61. package/es/components/dataSourceComponents/fields/Upload/serve.d.ts +1 -1
  62. package/es/components/dataSourceComponents/fields/Upload/serve.js +5 -5
  63. package/es/components/dataSourceComponents/fields/Upload/type.d.ts +8 -0
  64. package/es/components/dataSourceComponents/fields/index.d.ts +25 -2
  65. package/es/components/dataSourceComponents/fields/index.js +1 -0
  66. package/es/components/dataSourceComponents/fields/type.d.ts +1 -0
  67. package/es/components/dataSourceComponents/fields/utils.js +1 -0
  68. package/es/components/dataSourceComponents/provider/actions/ActionsContext.d.ts +6 -1
  69. package/es/components/dataSourceComponents/provider/actions/ActionsProvider.d.ts +4 -1
  70. package/es/components/dataSourceComponents/provider/actions/ActionsProvider.js +0 -1
  71. package/es/components/form/index.js +12 -0
  72. package/es/components/iconfont/index.js +1 -1
  73. package/es/components/pisellDraggable/components/Action/Action.d.ts +10 -0
  74. package/es/components/pisellDraggable/components/Action/Action.js +31 -0
  75. package/es/components/pisellDraggable/components/Action/Action.less +50 -0
  76. package/es/components/pisellDraggable/components/Action/index.d.ts +2 -0
  77. package/es/components/pisellDraggable/components/Action/index.js +1 -0
  78. package/es/components/pisellDraggable/components/Handle/Handle.d.ts +3 -0
  79. package/es/components/pisellDraggable/components/Handle/Handle.js +15 -0
  80. package/es/components/pisellDraggable/components/Handle/index.d.ts +1 -0
  81. package/es/components/pisellDraggable/components/Handle/index.js +1 -0
  82. package/es/components/pisellDraggable/components/Remove/Remove.d.ts +3 -0
  83. package/es/components/pisellDraggable/components/Remove/Remove.js +17 -0
  84. package/es/components/pisellDraggable/components/Remove/index.d.ts +1 -0
  85. package/es/components/pisellDraggable/components/Remove/index.js +1 -0
  86. package/es/components/pisellDraggable/components/TreeItem/SortableTreeItem.d.ts +8 -0
  87. package/es/components/pisellDraggable/components/TreeItem/SortableTreeItem.js +51 -0
  88. package/es/components/pisellDraggable/components/TreeItem/TreeItem.d.ts +21 -0
  89. package/es/components/pisellDraggable/components/TreeItem/TreeItem.js +57 -0
  90. package/es/components/pisellDraggable/components/TreeItem/TreeItem.less +128 -0
  91. package/es/components/pisellDraggable/components/TreeItem/index.d.ts +2 -0
  92. package/es/components/pisellDraggable/components/TreeItem/index.js +2 -0
  93. package/es/components/pisellDraggable/components/index.d.ts +4 -0
  94. package/es/components/pisellDraggable/components/index.js +4 -0
  95. package/es/components/pisellDraggable/index.d.ts +27 -0
  96. package/es/components/pisellDraggable/index.js +380 -0
  97. package/es/components/pisellDraggable/types.d.ts +17 -0
  98. package/es/components/pisellDraggable/types.js +1 -0
  99. package/es/components/pisellDraggable/utilities.d.ts +17 -0
  100. package/es/components/pisellDraggable/utilities.js +230 -0
  101. package/es/components/pisellLayout/content.d.ts +8 -0
  102. package/es/components/pisellLayout/content.js +29 -0
  103. package/es/components/pisellLayout/footer.d.ts +7 -0
  104. package/es/components/pisellLayout/footer.js +12 -0
  105. package/es/components/pisellLayout/header.d.ts +7 -0
  106. package/es/components/pisellLayout/header.js +12 -0
  107. package/es/components/pisellLayout/index.d.ts +14 -0
  108. package/es/components/pisellLayout/index.js +15 -0
  109. package/es/components/pisellLayout/sider.d.ts +7 -0
  110. package/es/components/pisellLayout/sider.js +12 -0
  111. package/es/components/pisellMenu/PisellMenu.d.ts +5 -0
  112. package/es/components/pisellMenu/PisellMenu.js +55 -0
  113. package/es/components/pisellMenu/PisellMenu.less +53 -0
  114. package/es/components/pisellMenu/index.d.ts +3 -0
  115. package/es/components/pisellMenu/index.js +2 -0
  116. package/es/components/pisellMenu/types.d.ts +30 -0
  117. package/es/components/pisellMenu/types.js +1 -0
  118. package/es/components/pisellModal/components/functions/index.less +3 -0
  119. package/es/components/table/Table/utils.d.ts +1 -1
  120. package/es/components/versionModal/index.d.ts +15 -0
  121. package/es/components/versionModal/index.js +192 -0
  122. package/es/components/versionModal/index.less +3 -0
  123. package/es/index.d.ts +92 -120
  124. package/es/index.js +92 -144
  125. package/es/locales/en-US.d.ts +22 -0
  126. package/es/locales/en-US.js +24 -1
  127. package/es/locales/zh-CN.d.ts +21 -0
  128. package/es/locales/zh-CN.js +24 -2
  129. package/es/locales/zh-TW.d.ts +20 -0
  130. package/es/locales/zh-TW.js +23 -2
  131. package/lib/components/dataSourceComponents/dataSourceForm/BaseForm.js +77 -4
  132. package/lib/components/dataSourceComponents/dataSourceForm/submitButton/index.js +1 -0
  133. package/lib/components/dataSourceComponents/dataSourceForm/type.d.ts +8 -0
  134. package/lib/components/dataSourceComponents/dataSourceForm/utils.d.ts +1 -0
  135. package/lib/components/dataSourceComponents/dataSourceForm/utils.js +138 -41
  136. package/lib/components/dataSourceComponents/dataSourceMenu/index.d.ts +2 -0
  137. package/lib/components/dataSourceComponents/dataSourceMenu/index.js +45 -0
  138. package/lib/components/dataSourceComponents/dataSourceTable/BaseTable.js +14 -2
  139. package/lib/components/dataSourceComponents/dataSourceTable/hooks/useTableProps.d.ts +3 -3
  140. package/lib/components/dataSourceComponents/fields/Input/index.d.ts +4 -0
  141. package/lib/components/dataSourceComponents/fields/Input/index.js +4 -0
  142. package/lib/components/dataSourceComponents/fields/Input.Mobile/ReadPretty.d.ts +5 -0
  143. package/lib/components/dataSourceComponents/fields/Input.Mobile/ReadPretty.js +58 -0
  144. package/lib/components/dataSourceComponents/fields/Input.Mobile/ReadPretty.less +11 -0
  145. package/lib/components/dataSourceComponents/fields/Input.Mobile/WithMode.d.ts +10 -0
  146. package/lib/components/dataSourceComponents/fields/Input.Mobile/WithMode.js +171 -0
  147. package/lib/components/dataSourceComponents/fields/Input.Mobile/index.d.ts +3 -0
  148. package/lib/components/dataSourceComponents/fields/Input.Mobile/index.js +48 -0
  149. package/lib/components/dataSourceComponents/fields/Input.Mobile/serve.d.ts +24 -0
  150. package/lib/components/dataSourceComponents/fields/Input.Mobile/serve.js +55 -0
  151. package/lib/components/dataSourceComponents/fields/Input.Mobile/type.d.ts +5 -0
  152. package/lib/components/dataSourceComponents/fields/Input.Mobile/type.js +17 -0
  153. package/lib/components/dataSourceComponents/fields/Input.Phone/WithMode.d.ts +2 -3
  154. package/lib/components/dataSourceComponents/fields/Input.Phone/WithMode.js +36 -17
  155. package/lib/components/dataSourceComponents/fields/Input.Subdomain/ReadPretty.d.ts +5 -0
  156. package/lib/components/dataSourceComponents/fields/Input.Subdomain/ReadPretty.js +50 -0
  157. package/lib/components/dataSourceComponents/fields/Input.Subdomain/ReadPretty.less +11 -0
  158. package/lib/components/dataSourceComponents/fields/Input.Subdomain/WithMode.d.ts +13 -0
  159. package/lib/components/dataSourceComponents/fields/Input.Subdomain/WithMode.js +167 -0
  160. package/lib/components/dataSourceComponents/fields/Input.Subdomain/index.d.ts +12 -0
  161. package/lib/components/dataSourceComponents/fields/Input.Subdomain/index.js +38 -0
  162. package/lib/components/dataSourceComponents/fields/Input.Subdomain/serve.d.ts +11 -0
  163. package/lib/components/dataSourceComponents/fields/Input.Subdomain/serve.js +65 -0
  164. package/lib/components/dataSourceComponents/fields/Input.Subdomain/type.d.ts +5 -0
  165. package/lib/components/dataSourceComponents/fields/Input.Subdomain/type.js +17 -0
  166. package/lib/components/dataSourceComponents/fields/Translation/BaseTranslation.js +15 -4
  167. package/lib/components/dataSourceComponents/fields/Translation/type.d.ts +1 -0
  168. package/lib/components/dataSourceComponents/fields/Upload/BaseUpload.js +5 -3
  169. package/lib/components/dataSourceComponents/fields/Upload/ReadPretty.d.ts +1 -1
  170. package/lib/components/dataSourceComponents/fields/Upload/ReadPretty.js +2 -2
  171. package/lib/components/dataSourceComponents/fields/Upload/WithMode.js +4 -4
  172. package/lib/components/dataSourceComponents/fields/Upload/index.less +1 -1
  173. package/lib/components/dataSourceComponents/fields/Upload/serve.d.ts +1 -1
  174. package/lib/components/dataSourceComponents/fields/Upload/serve.js +5 -5
  175. package/lib/components/dataSourceComponents/fields/Upload/type.d.ts +8 -0
  176. package/lib/components/dataSourceComponents/fields/index.d.ts +25 -2
  177. package/lib/components/dataSourceComponents/fields/index.js +1 -0
  178. package/lib/components/dataSourceComponents/fields/type.d.ts +1 -0
  179. package/lib/components/dataSourceComponents/fields/utils.js +1 -0
  180. package/lib/components/dataSourceComponents/provider/actions/ActionsContext.d.ts +6 -1
  181. package/lib/components/dataSourceComponents/provider/actions/ActionsProvider.d.ts +4 -1
  182. package/lib/components/form/index.js +10 -1
  183. package/lib/components/iconfont/index.js +1 -1
  184. package/lib/components/pisellDraggable/components/Action/Action.d.ts +10 -0
  185. package/lib/components/pisellDraggable/components/Action/Action.js +60 -0
  186. package/lib/components/pisellDraggable/components/Action/Action.less +50 -0
  187. package/lib/components/pisellDraggable/components/Action/index.d.ts +2 -0
  188. package/lib/components/pisellDraggable/components/Action/index.js +29 -0
  189. package/lib/components/pisellDraggable/components/Handle/Handle.d.ts +3 -0
  190. package/lib/components/pisellDraggable/components/Handle/Handle.js +54 -0
  191. package/lib/components/pisellDraggable/components/Handle/index.d.ts +1 -0
  192. package/lib/components/pisellDraggable/components/Handle/index.js +29 -0
  193. package/lib/components/pisellDraggable/components/Remove/Remove.d.ts +3 -0
  194. package/lib/components/pisellDraggable/components/Remove/Remove.js +53 -0
  195. package/lib/components/pisellDraggable/components/Remove/index.d.ts +1 -0
  196. package/lib/components/pisellDraggable/components/Remove/index.js +29 -0
  197. package/lib/components/pisellDraggable/components/TreeItem/SortableTreeItem.d.ts +8 -0
  198. package/lib/components/pisellDraggable/components/TreeItem/SortableTreeItem.js +83 -0
  199. package/lib/components/pisellDraggable/components/TreeItem/TreeItem.d.ts +21 -0
  200. package/lib/components/pisellDraggable/components/TreeItem/TreeItem.js +93 -0
  201. package/lib/components/pisellDraggable/components/TreeItem/TreeItem.less +128 -0
  202. package/lib/components/pisellDraggable/components/TreeItem/index.d.ts +2 -0
  203. package/lib/components/pisellDraggable/components/TreeItem/index.js +32 -0
  204. package/lib/components/pisellDraggable/components/index.d.ts +4 -0
  205. package/lib/components/pisellDraggable/components/index.js +40 -0
  206. package/lib/components/pisellDraggable/index.d.ts +27 -0
  207. package/lib/components/pisellDraggable/index.js +271 -0
  208. package/lib/components/pisellDraggable/types.d.ts +17 -0
  209. package/lib/components/pisellDraggable/types.js +17 -0
  210. package/lib/components/pisellDraggable/utilities.d.ts +17 -0
  211. package/lib/components/pisellDraggable/utilities.js +190 -0
  212. package/lib/components/pisellLayout/content.d.ts +8 -0
  213. package/lib/components/pisellLayout/content.js +50 -0
  214. package/lib/components/pisellLayout/footer.d.ts +7 -0
  215. package/lib/components/pisellLayout/footer.js +42 -0
  216. package/lib/components/pisellLayout/header.d.ts +7 -0
  217. package/lib/components/pisellLayout/header.js +42 -0
  218. package/lib/components/pisellLayout/index.d.ts +14 -0
  219. package/lib/components/pisellLayout/index.js +45 -0
  220. package/lib/components/pisellLayout/sider.d.ts +7 -0
  221. package/lib/components/pisellLayout/sider.js +42 -0
  222. package/lib/components/pisellMenu/PisellMenu.d.ts +5 -0
  223. package/lib/components/pisellMenu/PisellMenu.js +91 -0
  224. package/lib/components/pisellMenu/PisellMenu.less +53 -0
  225. package/lib/components/pisellMenu/index.d.ts +3 -0
  226. package/lib/components/pisellMenu/index.js +36 -0
  227. package/lib/components/pisellMenu/types.d.ts +30 -0
  228. package/lib/components/pisellMenu/types.js +17 -0
  229. package/lib/components/pisellModal/components/functions/index.less +3 -0
  230. package/lib/components/table/Table/utils.d.ts +1 -1
  231. package/lib/components/versionModal/index.d.ts +15 -0
  232. package/lib/components/versionModal/index.js +219 -0
  233. package/lib/components/versionModal/index.less +3 -0
  234. package/lib/index.d.ts +92 -120
  235. package/lib/index.js +146 -157
  236. package/lib/locales/en-US.d.ts +22 -0
  237. package/lib/locales/en-US.js +24 -1
  238. package/lib/locales/zh-CN.d.ts +21 -0
  239. package/lib/locales/zh-CN.js +24 -2
  240. package/lib/locales/zh-TW.d.ts +20 -0
  241. package/lib/locales/zh-TW.js +23 -2
  242. package/lowcode/_utils/defaultSchema.ts +23 -2
  243. package/lowcode/button/meta.ts +4 -20
  244. package/lowcode/data-source-form/constants.ts +4 -0
  245. package/lowcode/data-source-form/meta.ts +138 -1
  246. package/lowcode/data-source-form/snippets.ts +54 -0
  247. package/lowcode/data-source-form/utils.ts +5 -1
  248. package/lowcode/data-source-menu/meta.ts +122 -0
  249. package/lowcode/data-source-table/meta.ts +32 -27
  250. package/lowcode/data-source-table/utils.tsx +33 -1
  251. package/lowcode/data-source-wrapper/meta.ts +6 -2
  252. package/lowcode/form-group/meta.ts +5 -1
  253. package/lowcode/form-item-input.mobile/__screenshots__/mobile.png +0 -0
  254. package/lowcode/form-item-input.mobile/meta.ts +301 -0
  255. package/lowcode/form-item-input.mobile/snippets.ts +27 -0
  256. package/lowcode/form-item-input.phone/meta.ts +9 -43
  257. package/lowcode/form-item-input.phone/snippets.ts +8 -2
  258. package/lowcode/form-item-input.subdomain/__screenshots__/subdomain.png +0 -0
  259. package/lowcode/form-item-input.subdomain/meta.ts +318 -0
  260. package/lowcode/form-item-input.subdomain/snippets.ts +27 -0
  261. package/lowcode/form.item/meta.ts +48 -0
  262. package/lowcode/pisell-content/meta.ts +86 -0
  263. package/lowcode/pisell-draggable/meta.ts +190 -0
  264. package/lowcode/pisell-footer/meta.ts +81 -0
  265. package/lowcode/pisell-header/meta.ts +83 -0
  266. package/lowcode/pisell-layout/meta.ts +174 -0
  267. package/lowcode/pisell-menu/meta.ts +112 -0
  268. package/lowcode/pisell-sider/meta.ts +142 -0
  269. package/lowcode/pisell-text/meta.ts +9 -8080
  270. package/package.json +1 -1
@@ -3,7 +3,9 @@ import Password from "../Input.Password";
3
3
  import TextArea from "../Input.TextArea";
4
4
  import Url from "../Input.Url";
5
5
  import Email from "../Input.Email";
6
- import Phone from "../Input.Phone";
6
+ import Phone from "../Input.Phone"; //固定电话组件
7
+ import Mobile from "../Input.Mobile"; //手机号组件
8
+ import Subdomain from "../Input.Subdomain"; //子域名组件
7
9
  import InputWithMode from "./WithMode";
8
10
  import { withFormItem } from "../../dataSourceForm/utils";
9
11
  var Input = withFormItem(InputWithMode);
@@ -13,4 +15,6 @@ Input.TextArea = TextArea;
13
15
  Input.URL = Url;
14
16
  Input.Email = Email;
15
17
  Input.Phone = Phone;
18
+ Input.Mobile = Mobile;
19
+ Input.Subdomain = Subdomain;
16
20
  export default Input;
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import type { PhoneInputProps } from './WithMode';
3
+ import './ReadPretty.less';
4
+ declare const ReadPretty: React.FC<PhoneInputProps>;
5
+ export default ReadPretty;
@@ -0,0 +1,28 @@
1
+ import React from 'react';
2
+ import { parsePhoneNumberFromString as parsePhoneNumber } from 'libphonenumber-js';
3
+ import classNames from 'classnames';
4
+ import "./ReadPretty.less";
5
+ var ReadPretty = function ReadPretty(_ref) {
6
+ var value = _ref.value,
7
+ renderMode = _ref.renderMode;
8
+ if (!value) return null;
9
+ var className = classNames('pisell-phone-read-pretty', {
10
+ 'pisell-phone-read-pretty-table-view': renderMode === 'tableView'
11
+ });
12
+ try {
13
+ var phoneNumber = parsePhoneNumber(value);
14
+ if (!phoneNumber) return /*#__PURE__*/React.createElement("span", {
15
+ className: className
16
+ }, value);
17
+ var formattedValue = "(".concat(phoneNumber.formatInternational().split(' ')[0], ") ").concat(phoneNumber.formatNational());
18
+ return /*#__PURE__*/React.createElement("span", {
19
+ className: className
20
+ }, formattedValue);
21
+ } catch (error) {
22
+ // 如果解析失败,直接显示原始值
23
+ return /*#__PURE__*/React.createElement("span", {
24
+ className: className
25
+ }, value);
26
+ }
27
+ };
28
+ export default ReadPretty;
@@ -0,0 +1,11 @@
1
+ .pisell-phone-read-pretty {
2
+ color: var(--Gray-900, #101828);
3
+ font-size: 16px;
4
+ font-weight: 600;
5
+ line-height: 24px; /* 150% */
6
+ }
7
+
8
+ .pisell-phone-read-pretty-table-view {
9
+ font-size: 14px;
10
+ font-weight: 400;
11
+ }
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import { InputProps } from 'antd';
3
+ import { ModeType } from "../../dataSourceForm/type";
4
+ export interface PhoneInputProps extends Omit<InputProps, 'value' | 'onChange'> {
5
+ renderMode: ModeType;
6
+ value?: string;
7
+ onChange?: (value: string) => void;
8
+ }
9
+ declare const MobileNumberInputWithMode: React.FC<PhoneInputProps & import("../../dataSourceForm/utils").WithModeProps>;
10
+ export default MobileNumberInputWithMode;
@@ -0,0 +1,212 @@
1
+ var _excluded = ["value", "onChange", "disabled"];
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
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
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."); }
5
+ 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); }
6
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
7
+ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
8
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
9
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
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
+ import React, { useState, useEffect, useMemo } from 'react';
12
+ import { Input, Space } from 'antd';
13
+ import { isNumber } from '@pisell/utils';
14
+ import Select from "../../../select";
15
+ import { useCountries } from "./serve";
16
+ import ReadPretty from "./ReadPretty";
17
+ import { withMode } from "../../dataSourceForm/utils";
18
+ import useTranslationOriginal from "../../../../hooks/useTranslationOriginal";
19
+ var Option = Select.Option;
20
+ /**
21
+ * 手机号码输入组件
22
+ *
23
+ * 校验规则:
24
+ * 1. AU(+61) 验证规则:
25
+ * - 10位或9位数字
26
+ * - 前两位是04或者第一位是4
27
+ * - 格式示例:0412345678 或 412345678
28
+ *
29
+ * 2. CN(+86) 验证规则:
30
+ * - 11位数字
31
+ * - 第一位必须是1
32
+ * - 格式示例:13812345678
33
+ *
34
+ * 3. 其他国家验证规则:
35
+ * - 15位以内数字
36
+ * - 格式示例:123456789
37
+ *
38
+ * 使用方式:
39
+ * <Mobile
40
+ * name="mobile"
41
+ * label="手机号"
42
+ * typeobj={{
43
+ * type: 'mobile',
44
+ * enabled: true
45
+ * }}
46
+ * />
47
+ */
48
+
49
+ var MobileNumberInput = function MobileNumberInput(_ref) {
50
+ var propsValue = _ref.value,
51
+ onChange = _ref.onChange,
52
+ disabled = _ref.disabled,
53
+ props = _objectWithoutProperties(_ref, _excluded);
54
+ var _useCountries = useCountries(),
55
+ _useCountries$data = _useCountries.data,
56
+ countries = _useCountries$data === void 0 ? [] : _useCountries$data;
57
+ var translationOriginal = useTranslationOriginal();
58
+ var value = useMemo(function () {
59
+ if (isNumber(propsValue)) {
60
+ return "".concat(propsValue);
61
+ }
62
+ return propsValue;
63
+ }, [propsValue]);
64
+
65
+ // 解析外部传入的value
66
+ var parseExternalValue = function parseExternalValue(val) {
67
+ if (!val) return {
68
+ countryCode: 'AU',
69
+ phoneNumber: ''
70
+ };
71
+ var matchedPrefix = countries.find(function (country) {
72
+ return val.startsWith(country.prefix);
73
+ });
74
+ if (matchedPrefix) {
75
+ return {
76
+ countryCode: matchedPrefix.code,
77
+ phoneNumber: val.slice(matchedPrefix.prefix.length)
78
+ };
79
+ }
80
+ return {
81
+ countryCode: 'AU',
82
+ phoneNumber: val.replace(/\D/g, '')
83
+ };
84
+ };
85
+ var _useState = useState(function () {
86
+ return parseExternalValue(value).countryCode;
87
+ }),
88
+ _useState2 = _slicedToArray(_useState, 2),
89
+ countryCode = _useState2[0],
90
+ setCountryCode = _useState2[1];
91
+ var _useState3 = useState(function () {
92
+ return parseExternalValue(value).phoneNumber;
93
+ }),
94
+ _useState4 = _slicedToArray(_useState3, 2),
95
+ phoneNumber = _useState4[0],
96
+ setPhoneNumber = _useState4[1];
97
+
98
+ // 监听外部value变化
99
+ useEffect(function () {
100
+ // 只有当 value 不是空字符串时才更新状态
101
+ if (value) {
102
+ var _parseExternalValue = parseExternalValue(value),
103
+ newCountryCode = _parseExternalValue.countryCode,
104
+ newPhoneNumber = _parseExternalValue.phoneNumber;
105
+ setCountryCode(newCountryCode);
106
+ setPhoneNumber(newPhoneNumber);
107
+ } else {
108
+ // 当 value 为空时,只清空号码,保持国家代码不变
109
+ setPhoneNumber('');
110
+ }
111
+ }, [value, countries]);
112
+ var handleCountryChange = function handleCountryChange(value) {
113
+ setCountryCode(value);
114
+
115
+ // 在选择国家时也触发 onChange
116
+ var selectedCountry = countries.find(function (c) {
117
+ return c.code === value;
118
+ });
119
+ var prefix = (selectedCountry === null || selectedCountry === void 0 ? void 0 : selectedCountry.prefix) || "";
120
+ var newValue = "".concat(prefix).concat(phoneNumber);
121
+
122
+ // 先更新值
123
+ onChange === null || onChange === void 0 ? void 0 : onChange(newValue);
124
+
125
+ // 使用 setTimeout 确保值更新后再触发验证
126
+ setTimeout(function () {
127
+ // 手动触发表单验证
128
+ var formInstance = props.form;
129
+ var fieldName = props.fieldKey;
130
+ if (formInstance && fieldName) {
131
+ formInstance.validateFields([fieldName]);
132
+ }
133
+ });
134
+ };
135
+ var handlePhoneNumberChange = function handlePhoneNumberChange(e) {
136
+ var cleanNumber = e.target.value.replace(/\D/g, '');
137
+ setPhoneNumber(cleanNumber);
138
+
139
+ // 在输入时就触发 onChange
140
+ var selectedCountry = countries.find(function (c) {
141
+ return c.code === countryCode;
142
+ });
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 ? void 0 : onChange(newValue);
150
+
151
+ // 如果号码为空,只清除校验信息,不重置国家代码
152
+ if (!cleanNumber) {
153
+ var formInstance = props.form;
154
+ var fieldName = props.fieldKey;
155
+ if (formInstance && fieldName) {
156
+ formInstance.setFields([{
157
+ name: fieldName,
158
+ errors: [],
159
+ // 清除错误信息
160
+ validating: false // 停止验证状态
161
+ }]);
162
+ }
163
+ }
164
+ };
165
+
166
+ var concatenatedNumber = useMemo(function () {
167
+ var selectedCountry = countries.find(function (c) {
168
+ return c.code === countryCode;
169
+ });
170
+ if (phoneNumber.length === 0) {
171
+ return "";
172
+ }
173
+ var prefix = (selectedCountry === null || selectedCountry === void 0 ? void 0 : selectedCountry.prefix) || "";
174
+ return "".concat(prefix).concat(phoneNumber);
175
+ }, [countryCode, phoneNumber, countries]);
176
+ var handleBlur = function handleBlur() {
177
+ var finalValue = concatenatedNumber;
178
+ onChange === null || onChange === void 0 ? void 0 : onChange(finalValue);
179
+ };
180
+ return /*#__PURE__*/React.createElement(Space.Compact, {
181
+ block: true
182
+ }, /*#__PURE__*/React.createElement(Select, {
183
+ disabled: disabled,
184
+ value: countryCode,
185
+ onChange: handleCountryChange,
186
+ style: {
187
+ width: '90px'
188
+ },
189
+ popupMatchSelectWidth: false,
190
+ optionLabelProp: "inputValue",
191
+ optionFilterProp: "label",
192
+ showSearch: true,
193
+ options: countries.map(function (country) {
194
+ return {
195
+ value: country.code,
196
+ label: "".concat(translationOriginal(country.name), " (").concat(country.prefix, ")"),
197
+ inputValue: country.prefix
198
+ };
199
+ })
200
+ }), /*#__PURE__*/React.createElement(Input, _extends({}, props, {
201
+ disabled: disabled,
202
+ type: "tel",
203
+ value: phoneNumber,
204
+ onChange: handlePhoneNumberChange,
205
+ onBlur: handleBlur,
206
+ style: {
207
+ flex: 1
208
+ }
209
+ })));
210
+ };
211
+ var MobileNumberInputWithMode = withMode(MobileNumberInput, ReadPretty);
212
+ export default MobileNumberInputWithMode;
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ declare const Mobile: React.FC<import("./WithMode").PhoneInputProps & import("../../dataSourceForm/utils").WithModeProps & import("../../dataSourceForm/utils").WithFormItemProps>;
3
+ export default Mobile;
@@ -0,0 +1,14 @@
1
+ import { withFormItem } from "../../dataSourceForm/utils";
2
+ import MobileWithMode from "./WithMode";
3
+ var Mobile = withFormItem(MobileWithMode, {
4
+ otherFormItemProps: {
5
+ validateTrigger: ['onChange', 'onBlur']
6
+ },
7
+ innerProps: {
8
+ typeobj: {
9
+ type: 'mobile',
10
+ enabled: true
11
+ }
12
+ }
13
+ });
14
+ export default Mobile;
@@ -0,0 +1,24 @@
1
+ /**
2
+ * 获取nocobase数据列表
3
+ */
4
+ export declare const getCountryDataList: () => Promise<any>;
5
+ export interface Country {
6
+ id: number;
7
+ name: {
8
+ en: string;
9
+ "zh-CN": string;
10
+ "zh-HK": string;
11
+ original: string;
12
+ };
13
+ code: string;
14
+ calling_code: string;
15
+ currency_code: string;
16
+ sort: number;
17
+ status: string;
18
+ created_at: string;
19
+ updated_at: string;
20
+ prefix: string;
21
+ }
22
+ export declare const useCountries: () => {
23
+ data: Country[];
24
+ };
@@ -0,0 +1,59 @@
1
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
3
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
4
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
5
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
7
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
8
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
9
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
10
+ import { useRequest } from 'ahooks';
11
+ import { request } from "../../../table/utils";
12
+
13
+ /**
14
+ * 获取nocobase数据列表
15
+ */
16
+ export var getCountryDataList = /*#__PURE__*/function () {
17
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
18
+ var _yield$request$getReq, data;
19
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
20
+ while (1) switch (_context.prev = _context.next) {
21
+ case 0:
22
+ _context.next = 2;
23
+ return request.getRequest().get("/country:list", {}, {
24
+ isNocobase: true,
25
+ fullResult: true,
26
+ headers: {
27
+ "x-data-source": "pisell2"
28
+ }
29
+ });
30
+ case 2:
31
+ _yield$request$getReq = _context.sent;
32
+ data = _yield$request$getReq.data;
33
+ return _context.abrupt("return", data.map(function (item) {
34
+ return _objectSpread(_objectSpread({}, item), {}, {
35
+ prefix: "+".concat(item.calling_code)
36
+ });
37
+ }));
38
+ case 5:
39
+ case "end":
40
+ return _context.stop();
41
+ }
42
+ }, _callee);
43
+ }));
44
+ return function getCountryDataList() {
45
+ return _ref.apply(this, arguments);
46
+ };
47
+ }();
48
+ export var useCountries = function useCountries() {
49
+ var _useRequest = useRequest(getCountryDataList, {
50
+ cacheKey: 'phone-countries',
51
+ staleTime: 1000 * 60 * 5,
52
+ // 5分钟后数据过期
53
+ cacheTime: 1000 * 60 * 60 // 1小时后清除缓存
54
+ }),
55
+ data = _useRequest.data;
56
+ return {
57
+ data: data
58
+ };
59
+ };
@@ -0,0 +1,5 @@
1
+ import { InputProps as AntInputProps } from 'antd';
2
+ import { ModeType } from "../../dataSourceForm/type";
3
+ export interface InputProps extends AntInputProps {
4
+ renderMode: ModeType;
5
+ }
@@ -5,7 +5,6 @@ export interface PhoneInputProps extends Omit<InputProps, 'value' | 'onChange'>
5
5
  renderMode: ModeType;
6
6
  value?: string;
7
7
  onChange?: (value: string) => void;
8
- isVerification?: boolean;
9
8
  }
10
- declare const PhoneWithMode: React.FC<PhoneInputProps & import("../../dataSourceForm/utils").WithModeProps>;
11
- export default PhoneWithMode;
9
+ declare const PhoneNumberInputWithMode: React.FC<PhoneInputProps & import("../../dataSourceForm/utils").WithModeProps>;
10
+ export default PhoneNumberInputWithMode;
@@ -1,4 +1,4 @@
1
- var _excluded = ["value", "onChange", "isVerification", "disabled"];
1
+ var _excluded = ["value", "onChange", "disabled"];
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,7 +10,6 @@ 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 { isValidPhoneNumber, parsePhoneNumberFromString } from 'libphonenumber-js';
14
13
  import { isNumber } from '@pisell/utils';
15
14
  import Select from "../../../select";
16
15
  import { useCountries } from "./serve";
@@ -18,10 +17,33 @@ import ReadPretty from "./ReadPretty";
18
17
  import { withMode } from "../../dataSourceForm/utils";
19
18
  import useTranslationOriginal from "../../../../hooks/useTranslationOriginal";
20
19
  var Option = Select.Option;
21
- var PhoneInput = function PhoneInput(_ref) {
20
+ /**
21
+ * 电话号码输入组件
22
+ *
23
+ * 校验规则:
24
+ * 使用 libphonenumber-js 进行校验
25
+ * 1. 清除所有空格和括号等特殊字符
26
+ * 2. 验证是否符合 E.164 格式
27
+ * 3. 验证号码是否在对应国家有效
28
+ *
29
+ * 格式示例:
30
+ * - 国际格式:+86 10 1234 5678
31
+ * - 国内格式:010 1234 5678
32
+ *
33
+ * 使用方式:
34
+ * <Phone
35
+ * name="phone"
36
+ * label="电话号码"
37
+ * typeobj={{
38
+ * type: 'phone',
39
+ * enabled: true
40
+ * }}
41
+ * />
42
+ */
43
+
44
+ var PhoneNumberInput = function PhoneNumberInput(_ref) {
22
45
  var propsValue = _ref.value,
23
46
  onChange = _ref.onChange,
24
- isVerification = _ref.isVerification,
25
47
  disabled = _ref.disabled,
26
48
  props = _objectWithoutProperties(_ref, _excluded);
27
49
  var _useCountries = useCountries(),
@@ -76,12 +98,55 @@ var PhoneInput = function PhoneInput(_ref) {
76
98
  setCountryCode(newCountryCode);
77
99
  setPhoneNumber(newPhoneNumber);
78
100
  }, [value, countries]);
79
- var handleCountryChange = function handleCountryChange(value) {
80
- setCountryCode(value);
81
- };
82
101
  var handlePhoneNumberChange = function handlePhoneNumberChange(e) {
83
102
  var cleanNumber = e.target.value.replace(/\D/g, '');
84
103
  setPhoneNumber(cleanNumber);
104
+
105
+ // 在输入时就触发 onChange
106
+ var selectedCountry = countries.find(function (c) {
107
+ return c.code === countryCode;
108
+ });
109
+ var prefix = (selectedCountry === null || selectedCountry === void 0 ? void 0 : selectedCountry.prefix) || "";
110
+
111
+ // 只有当实际输入的号码部分不为空时,才包含区号
112
+ var newValue = cleanNumber ? "".concat(prefix).concat(cleanNumber) : '';
113
+
114
+ // 更新值
115
+ onChange === null || onChange === void 0 ? void 0 : onChange(newValue);
116
+
117
+ // 如果实际号码部分为空,立即触发验证以清除错误信息
118
+ if (!cleanNumber) {
119
+ setTimeout(function () {
120
+ var formInstance = props.form;
121
+ var fieldName = props.fieldKey;
122
+ if (formInstance && fieldName) {
123
+ formInstance.validateFields([fieldName]);
124
+ }
125
+ });
126
+ }
127
+ };
128
+ var handleCountryChange = function handleCountryChange(value) {
129
+ setCountryCode(value);
130
+
131
+ // 在选择国家时也触发 onChange
132
+ var selectedCountry = countries.find(function (c) {
133
+ return c.code === value;
134
+ });
135
+ var prefix = (selectedCountry === null || selectedCountry === void 0 ? void 0 : selectedCountry.prefix) || "";
136
+ var newValue = "".concat(prefix).concat(phoneNumber);
137
+
138
+ // 先更新值
139
+ onChange === null || onChange === void 0 ? void 0 : onChange(newValue);
140
+
141
+ // 使用 setTimeout 确保值更新后再触发验证
142
+ setTimeout(function () {
143
+ // 手动触发表单验证
144
+ var formInstance = props.form;
145
+ var fieldName = props.fieldKey;
146
+ if (formInstance && fieldName) {
147
+ formInstance.validateFields([fieldName]);
148
+ }
149
+ });
85
150
  };
86
151
  var concatenatedNumber = useMemo(function () {
87
152
  var selectedCountry = countries.find(function (c) {
@@ -94,15 +159,9 @@ var PhoneInput = function PhoneInput(_ref) {
94
159
  return "".concat(prefix).concat(phoneNumber);
95
160
  }, [countryCode, phoneNumber, countries]);
96
161
  var handleBlur = function handleBlur() {
97
- onChange === null || onChange === void 0 ? void 0 : onChange(concatenatedNumber);
162
+ var finalValue = concatenatedNumber;
163
+ onChange === null || onChange === void 0 ? void 0 : onChange(finalValue);
98
164
  };
99
- var status = useMemo(function () {
100
- var _parsePhoneNumberFrom;
101
- if (!phoneNumber || !isVerification) {
102
- return undefined;
103
- }
104
- return isValidPhoneNumber(concatenatedNumber) && (_parsePhoneNumberFrom = parsePhoneNumberFromString(concatenatedNumber)) !== null && _parsePhoneNumberFrom !== void 0 && _parsePhoneNumberFrom.isValid() ? undefined : 'error';
105
- }, [concatenatedNumber, phoneNumber, isVerification]);
106
165
  return /*#__PURE__*/React.createElement(Space.Compact, {
107
166
  block: true
108
167
  }, /*#__PURE__*/React.createElement(Select, {
@@ -112,7 +171,6 @@ var PhoneInput = function PhoneInput(_ref) {
112
171
  style: {
113
172
  width: '90px'
114
173
  },
115
- onBlur: handleBlur,
116
174
  popupMatchSelectWidth: false,
117
175
  optionLabelProp: "inputValue",
118
176
  optionFilterProp: "label",
@@ -126,7 +184,6 @@ var PhoneInput = function PhoneInput(_ref) {
126
184
  })
127
185
  }), /*#__PURE__*/React.createElement(Input, _extends({}, props, {
128
186
  disabled: disabled,
129
- status: status,
130
187
  type: "tel",
131
188
  value: phoneNumber,
132
189
  onChange: handlePhoneNumberChange,
@@ -136,5 +193,5 @@ var PhoneInput = function PhoneInput(_ref) {
136
193
  }
137
194
  })));
138
195
  };
139
- var PhoneWithMode = withMode(PhoneInput, ReadPretty);
140
- export default PhoneWithMode;
196
+ var PhoneNumberInputWithMode = withMode(PhoneNumberInput, ReadPretty);
197
+ export default PhoneNumberInputWithMode;
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import { InputProps } from './type';
3
+ import './ReadPretty.less';
4
+ declare const InputReadPretty: (props: InputProps) => React.JSX.Element;
5
+ export default InputReadPretty;
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ import classNames from 'classnames';
3
+ import "./ReadPretty.less";
4
+ var InputReadPretty = function InputReadPretty(props) {
5
+ var value = props.value,
6
+ renderMode = props.renderMode;
7
+ return /*#__PURE__*/React.createElement("span", {
8
+ className: classNames('pisell-input-email-read-pretty', {
9
+ 'pisell-input-email-read-pretty-table-view': renderMode === 'tableView'
10
+ })
11
+ }, value);
12
+ };
13
+ export default InputReadPretty;
@@ -0,0 +1,11 @@
1
+ .pisell-input-email-read-pretty {
2
+ color: var(--Gray-900, #101828);
3
+ font-size: 16px;
4
+ font-weight: 600;
5
+ line-height: 24px; /* 150% */
6
+ }
7
+
8
+ .pisell-input-email-read-pretty-table-view {
9
+ font-size: 14px;
10
+ font-weight: 400;
11
+ }
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ import { InputProps } from 'antd';
3
+ declare const SubdomainlWithMode: React.FC<InputProps & {
4
+ onChange: (value: string) => void;
5
+ onBlur?: ((e: React.FocusEvent<HTMLInputElement>) => void) | undefined;
6
+ rootDomain: 'xzero' | 'saas' | 'custom';
7
+ customDomain?: string | undefined;
8
+ value?: string | undefined;
9
+ tenantId: string;
10
+ name?: string | undefined;
11
+ fieldKey?: string | undefined;
12
+ } & import("../../dataSourceForm/utils").WithModeProps>;
13
+ export default SubdomainlWithMode;