@pisell/materials 6.0.9 → 6.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/lowcode/assets-daily.json +11 -11
- package/build/lowcode/assets-dev.json +2 -2
- package/build/lowcode/assets-prod.json +11 -11
- package/build/lowcode/index.js +1 -1
- package/build/lowcode/meta.js +7 -7
- package/build/lowcode/preview.js +8 -8
- package/build/lowcode/render/default/view.css +1 -1
- package/build/lowcode/render/default/view.js +12 -12
- package/build/lowcode/view.css +1 -1
- package/build/lowcode/view.js +12 -12
- package/es/components/dataSourceComponents/fields/Input/index.d.ts +4 -0
- package/es/components/dataSourceComponents/fields/Input/index.js +5 -1
- package/es/components/dataSourceComponents/fields/Input.Mobile/ReadPretty.d.ts +5 -0
- package/es/components/dataSourceComponents/fields/Input.Mobile/ReadPretty.js +28 -0
- package/es/components/dataSourceComponents/fields/Input.Mobile/ReadPretty.less +11 -0
- package/es/components/dataSourceComponents/fields/Input.Mobile/WithMode.d.ts +11 -0
- package/es/components/dataSourceComponents/fields/Input.Mobile/WithMode.js +157 -0
- package/es/components/dataSourceComponents/fields/Input.Mobile/index.d.ts +3 -0
- package/es/components/dataSourceComponents/fields/Input.Mobile/index.js +4 -0
- package/es/components/dataSourceComponents/fields/Input.Mobile/serve.d.ts +24 -0
- package/es/components/dataSourceComponents/fields/Input.Mobile/serve.js +59 -0
- package/es/components/dataSourceComponents/fields/Input.Mobile/type.d.ts +5 -0
- package/es/components/dataSourceComponents/fields/Input.Mobile/type.js +1 -0
- package/es/components/dataSourceComponents/fields/Input.Phone/WithMode.d.ts +2 -2
- package/es/components/dataSourceComponents/fields/Input.Phone/WithMode.js +7 -4
- package/es/components/dataSourceComponents/fields/Input.Subdomain/ReadPretty.d.ts +5 -0
- package/es/components/dataSourceComponents/fields/Input.Subdomain/ReadPretty.js +13 -0
- package/es/components/dataSourceComponents/fields/Input.Subdomain/ReadPretty.less +11 -0
- package/es/components/dataSourceComponents/fields/Input.Subdomain/WithMode.d.ts +11 -0
- package/es/components/dataSourceComponents/fields/Input.Subdomain/WithMode.js +97 -0
- package/es/components/dataSourceComponents/fields/Input.Subdomain/index.d.ts +10 -0
- package/es/components/dataSourceComponents/fields/Input.Subdomain/index.js +4 -0
- package/es/components/dataSourceComponents/fields/Input.Subdomain/serve.d.ts +21 -0
- package/es/components/dataSourceComponents/fields/Input.Subdomain/serve.js +61 -0
- package/es/components/dataSourceComponents/fields/Input.Subdomain/type.d.ts +5 -0
- package/es/components/dataSourceComponents/fields/Input.Subdomain/type.js +1 -0
- package/es/components/dataSourceComponents/fields/index.d.ts +31 -4
- package/es/components/dataSourceComponents/fields/index.js +1 -0
- package/es/components/dataSourceComponents/hooks/useActions.js +14 -5
- package/es/components/login-and-register/index.less +2 -2
- package/es/components/organizationTenantSwitcher/index.less +1 -0
- package/es/components/pisellLayout/content.d.ts +7 -0
- package/es/components/pisellLayout/content.js +12 -0
- package/es/components/pisellLayout/footer.d.ts +7 -0
- package/es/components/pisellLayout/footer.js +12 -0
- package/es/components/pisellLayout/header.d.ts +7 -0
- package/es/components/pisellLayout/header.js +12 -0
- package/es/components/pisellLayout/index.d.ts +14 -0
- package/es/components/pisellLayout/index.js +15 -0
- package/es/components/pisellLayout/sider.d.ts +7 -0
- package/es/components/pisellLayout/sider.js +12 -0
- package/es/index.d.ts +87 -120
- package/es/index.js +88 -144
- package/lib/components/dataSourceComponents/dataSourceForm/serve.js +7 -2
- package/lib/components/dataSourceComponents/fields/Input/index.d.ts +4 -0
- package/lib/components/dataSourceComponents/fields/Input/index.js +4 -0
- package/lib/components/dataSourceComponents/fields/Input.Mobile/ReadPretty.d.ts +5 -0
- package/lib/components/dataSourceComponents/fields/Input.Mobile/ReadPretty.js +58 -0
- package/lib/components/dataSourceComponents/fields/Input.Mobile/ReadPretty.less +11 -0
- package/lib/components/dataSourceComponents/fields/Input.Mobile/WithMode.d.ts +11 -0
- package/lib/components/dataSourceComponents/fields/Input.Mobile/WithMode.js +156 -0
- package/lib/components/dataSourceComponents/fields/Input.Mobile/index.d.ts +3 -0
- package/lib/components/dataSourceComponents/fields/Input.Mobile/index.js +38 -0
- package/lib/components/dataSourceComponents/fields/Input.Mobile/serve.d.ts +24 -0
- package/lib/components/dataSourceComponents/fields/Input.Mobile/serve.js +55 -0
- package/lib/components/dataSourceComponents/fields/Input.Mobile/type.d.ts +5 -0
- package/lib/components/dataSourceComponents/fields/Input.Mobile/type.js +17 -0
- package/lib/components/dataSourceComponents/fields/Input.Phone/WithMode.d.ts +2 -2
- package/lib/components/dataSourceComponents/fields/Input.Phone/WithMode.js +6 -4
- package/lib/components/dataSourceComponents/fields/Input.Subdomain/ReadPretty.d.ts +5 -0
- package/lib/components/dataSourceComponents/fields/Input.Subdomain/ReadPretty.js +50 -0
- package/lib/components/dataSourceComponents/fields/Input.Subdomain/ReadPretty.less +11 -0
- package/lib/components/dataSourceComponents/fields/Input.Subdomain/WithMode.d.ts +11 -0
- package/lib/components/dataSourceComponents/fields/Input.Subdomain/WithMode.js +107 -0
- package/lib/components/dataSourceComponents/fields/Input.Subdomain/index.d.ts +10 -0
- package/lib/components/dataSourceComponents/fields/Input.Subdomain/index.js +38 -0
- package/lib/components/dataSourceComponents/fields/Input.Subdomain/serve.d.ts +21 -0
- package/lib/components/dataSourceComponents/fields/Input.Subdomain/serve.js +60 -0
- package/lib/components/dataSourceComponents/fields/Input.Subdomain/type.d.ts +5 -0
- package/lib/components/dataSourceComponents/fields/Input.Subdomain/type.js +17 -0
- package/lib/components/dataSourceComponents/fields/index.d.ts +31 -4
- package/lib/components/dataSourceComponents/fields/index.js +1 -0
- package/lib/components/dataSourceComponents/hooks/useActions.js +11 -6
- package/lib/components/login-and-register/index.less +2 -2
- package/lib/components/organizationTenantSwitcher/index.less +1 -0
- package/lib/components/pisellLayout/content.d.ts +7 -0
- package/lib/components/pisellLayout/content.js +42 -0
- package/lib/components/pisellLayout/footer.d.ts +7 -0
- package/lib/components/pisellLayout/footer.js +42 -0
- package/lib/components/pisellLayout/header.d.ts +7 -0
- package/lib/components/pisellLayout/header.js +42 -0
- package/lib/components/pisellLayout/index.d.ts +14 -0
- package/lib/components/pisellLayout/index.js +45 -0
- package/lib/components/pisellLayout/sider.d.ts +7 -0
- package/lib/components/pisellLayout/sider.js +42 -0
- package/lib/index.d.ts +87 -120
- package/lib/index.js +134 -157
- package/lowcode/data-source-form/constants.ts +4 -0
- package/lowcode/data-source-form/utils.ts +5 -1
- package/lowcode/form-item-input.mobile/__screenshots__/phone.png +0 -0
- package/lowcode/form-item-input.mobile/meta.ts +311 -0
- package/lowcode/form-item-input.mobile/snippets.ts +21 -0
- package/lowcode/form-item-input.phone/meta.ts +1 -1
- package/lowcode/form-item-input.phone/snippets.ts +2 -2
- package/lowcode/form-item-input.subdomain/meta.ts +304 -0
- package/lowcode/form-item-input.subdomain/snippets.ts +28 -0
- package/lowcode/pisell-content/meta.ts +83 -0
- package/lowcode/pisell-footer/meta.ts +81 -0
- package/lowcode/pisell-header/meta.ts +83 -0
- package/lowcode/pisell-layout/meta.ts +174 -0
- package/lowcode/pisell-sider/meta.ts +142 -0
- package/lowcode/pisell-text/meta.ts +9 -8080
- package/package.json +3 -3
|
@@ -5,6 +5,8 @@ import TextArea from '../Input.TextArea';
|
|
|
5
5
|
import Url from '../Input.Url';
|
|
6
6
|
import Email from '../Input.Email';
|
|
7
7
|
import Phone from '../Input.Phone';
|
|
8
|
+
import Mobile from '../Input.Mobile';
|
|
9
|
+
import Subdomain from '../Input.Subdomain';
|
|
8
10
|
import { InputProps } from './type';
|
|
9
11
|
declare type InputComponent = React.FC<InputProps> & {
|
|
10
12
|
JSON: typeof JSON;
|
|
@@ -13,6 +15,8 @@ declare type InputComponent = React.FC<InputProps> & {
|
|
|
13
15
|
URL: typeof Url;
|
|
14
16
|
Email: typeof Email;
|
|
15
17
|
Phone: typeof Phone;
|
|
18
|
+
Mobile: typeof Mobile;
|
|
19
|
+
Subdomain: typeof Subdomain;
|
|
16
20
|
};
|
|
17
21
|
declare const Input: InputComponent;
|
|
18
22
|
export default Input;
|
|
@@ -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,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
|
+
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
|
+
isVerification?: boolean;
|
|
9
|
+
}
|
|
10
|
+
declare const MobileNumberInputWithMode: React.FC<PhoneInputProps & import("../../dataSourceForm/utils").WithModeProps>;
|
|
11
|
+
export default MobileNumberInputWithMode;
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
var _excluded = ["value", "onChange", "isVerification", "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
|
+
var MobileNumberInput = function MobileNumberInput(_ref) {
|
|
21
|
+
var propsValue = _ref.value,
|
|
22
|
+
onChange = _ref.onChange,
|
|
23
|
+
isVerification = _ref.isVerification,
|
|
24
|
+
disabled = _ref.disabled,
|
|
25
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
26
|
+
var _useCountries = useCountries(),
|
|
27
|
+
_useCountries$data = _useCountries.data,
|
|
28
|
+
countries = _useCountries$data === void 0 ? [] : _useCountries$data;
|
|
29
|
+
var translationOriginal = useTranslationOriginal();
|
|
30
|
+
var value = useMemo(function () {
|
|
31
|
+
if (isNumber(propsValue)) {
|
|
32
|
+
return "".concat(propsValue);
|
|
33
|
+
}
|
|
34
|
+
return propsValue;
|
|
35
|
+
}, [propsValue]);
|
|
36
|
+
|
|
37
|
+
// 解析外部传入的value
|
|
38
|
+
var parseExternalValue = function parseExternalValue(val) {
|
|
39
|
+
if (!val) return {
|
|
40
|
+
countryCode: 'AU',
|
|
41
|
+
phoneNumber: ''
|
|
42
|
+
};
|
|
43
|
+
var matchedPrefix = countries.find(function (country) {
|
|
44
|
+
return val.startsWith(country.prefix);
|
|
45
|
+
});
|
|
46
|
+
if (matchedPrefix) {
|
|
47
|
+
return {
|
|
48
|
+
countryCode: matchedPrefix.code,
|
|
49
|
+
phoneNumber: val.slice(matchedPrefix.prefix.length)
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
countryCode: 'AU',
|
|
54
|
+
phoneNumber: val.replace(/\D/g, '')
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
var _useState = useState(function () {
|
|
58
|
+
return parseExternalValue(value).countryCode;
|
|
59
|
+
}),
|
|
60
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
61
|
+
countryCode = _useState2[0],
|
|
62
|
+
setCountryCode = _useState2[1];
|
|
63
|
+
var _useState3 = useState(function () {
|
|
64
|
+
return parseExternalValue(value).phoneNumber;
|
|
65
|
+
}),
|
|
66
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
67
|
+
phoneNumber = _useState4[0],
|
|
68
|
+
setPhoneNumber = _useState4[1];
|
|
69
|
+
|
|
70
|
+
// 监听外部value变化
|
|
71
|
+
useEffect(function () {
|
|
72
|
+
var _parseExternalValue = parseExternalValue(value),
|
|
73
|
+
newCountryCode = _parseExternalValue.countryCode,
|
|
74
|
+
newPhoneNumber = _parseExternalValue.phoneNumber;
|
|
75
|
+
setCountryCode(newCountryCode);
|
|
76
|
+
setPhoneNumber(newPhoneNumber);
|
|
77
|
+
}, [value, countries]);
|
|
78
|
+
var handleCountryChange = function handleCountryChange(value) {
|
|
79
|
+
setCountryCode(value);
|
|
80
|
+
};
|
|
81
|
+
var handlePhoneNumberChange = function handlePhoneNumberChange(e) {
|
|
82
|
+
var cleanNumber = e.target.value.replace(/\D/g, '');
|
|
83
|
+
setPhoneNumber(cleanNumber);
|
|
84
|
+
};
|
|
85
|
+
var concatenatedNumber = useMemo(function () {
|
|
86
|
+
var selectedCountry = countries.find(function (c) {
|
|
87
|
+
return c.code === countryCode;
|
|
88
|
+
});
|
|
89
|
+
if (phoneNumber.length === 0) {
|
|
90
|
+
return "";
|
|
91
|
+
}
|
|
92
|
+
var prefix = (selectedCountry === null || selectedCountry === void 0 ? void 0 : selectedCountry.prefix) || "";
|
|
93
|
+
return "".concat(prefix).concat(phoneNumber);
|
|
94
|
+
}, [countryCode, phoneNumber, countries]);
|
|
95
|
+
var handleBlur = function handleBlur() {
|
|
96
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(concatenatedNumber);
|
|
97
|
+
};
|
|
98
|
+
var status = useMemo(function () {
|
|
99
|
+
if (!phoneNumber || !isVerification) {
|
|
100
|
+
return undefined;
|
|
101
|
+
}
|
|
102
|
+
if (countryCode === 'AU') {
|
|
103
|
+
// AU(+61) 验证规则:10位或9位数字,前两位是04或者第一位是4
|
|
104
|
+
var auRegex = /^(04\d{8}|\d{9})$/.test(phoneNumber);
|
|
105
|
+
if (!auRegex) {
|
|
106
|
+
return 'error';
|
|
107
|
+
}
|
|
108
|
+
} else if (countryCode === 'CN') {
|
|
109
|
+
// CN(+86) 验证规则:11位数字,第一位是1
|
|
110
|
+
var cnRegex = /^1\d{10}$/.test(phoneNumber);
|
|
111
|
+
if (!cnRegex) {
|
|
112
|
+
return 'error';
|
|
113
|
+
}
|
|
114
|
+
} else {
|
|
115
|
+
// 其他国家验证规则:15位以内数字
|
|
116
|
+
var otherRegex = /^\d{1,15}$/.test(phoneNumber);
|
|
117
|
+
if (!otherRegex) {
|
|
118
|
+
return 'error';
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return undefined;
|
|
122
|
+
}, [concatenatedNumber, phoneNumber, isVerification, countryCode]);
|
|
123
|
+
return /*#__PURE__*/React.createElement(Space.Compact, {
|
|
124
|
+
block: true
|
|
125
|
+
}, /*#__PURE__*/React.createElement(Select, {
|
|
126
|
+
disabled: disabled,
|
|
127
|
+
value: countryCode,
|
|
128
|
+
onChange: handleCountryChange,
|
|
129
|
+
style: {
|
|
130
|
+
width: '90px'
|
|
131
|
+
},
|
|
132
|
+
onBlur: handleBlur,
|
|
133
|
+
popupMatchSelectWidth: false,
|
|
134
|
+
optionLabelProp: "inputValue",
|
|
135
|
+
optionFilterProp: "label",
|
|
136
|
+
showSearch: true,
|
|
137
|
+
options: countries.map(function (country) {
|
|
138
|
+
return {
|
|
139
|
+
value: country.code,
|
|
140
|
+
label: "".concat(translationOriginal(country.name), " (").concat(country.prefix, ")"),
|
|
141
|
+
inputValue: country.prefix
|
|
142
|
+
};
|
|
143
|
+
})
|
|
144
|
+
}), /*#__PURE__*/React.createElement(Input, _extends({}, props, {
|
|
145
|
+
disabled: disabled,
|
|
146
|
+
status: status,
|
|
147
|
+
type: "tel",
|
|
148
|
+
value: phoneNumber,
|
|
149
|
+
onChange: handlePhoneNumberChange,
|
|
150
|
+
onBlur: handleBlur,
|
|
151
|
+
style: {
|
|
152
|
+
flex: 1
|
|
153
|
+
}
|
|
154
|
+
})));
|
|
155
|
+
};
|
|
156
|
+
var MobileNumberInputWithMode = withMode(MobileNumberInput, ReadPretty);
|
|
157
|
+
export default MobileNumberInputWithMode;
|
|
@@ -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 @@
|
|
|
1
|
+
export {};
|
|
@@ -7,5 +7,5 @@ export interface PhoneInputProps extends Omit<InputProps, 'value' | 'onChange'>
|
|
|
7
7
|
onChange?: (value: string) => void;
|
|
8
8
|
isVerification?: boolean;
|
|
9
9
|
}
|
|
10
|
-
declare const
|
|
11
|
-
export default
|
|
10
|
+
declare const PhoneNumberInputWithMode: React.FC<PhoneInputProps & import("../../dataSourceForm/utils").WithModeProps>;
|
|
11
|
+
export default PhoneNumberInputWithMode;
|
|
@@ -18,7 +18,7 @@ import ReadPretty from "./ReadPretty";
|
|
|
18
18
|
import { withMode } from "../../dataSourceForm/utils";
|
|
19
19
|
import useTranslationOriginal from "../../../../hooks/useTranslationOriginal";
|
|
20
20
|
var Option = Select.Option;
|
|
21
|
-
var
|
|
21
|
+
var PhoneNumberInput = function PhoneNumberInput(_ref) {
|
|
22
22
|
var propsValue = _ref.value,
|
|
23
23
|
onChange = _ref.onChange,
|
|
24
24
|
isVerification = _ref.isVerification,
|
|
@@ -101,7 +101,10 @@ var PhoneInput = function PhoneInput(_ref) {
|
|
|
101
101
|
if (!phoneNumber || !isVerification) {
|
|
102
102
|
return undefined;
|
|
103
103
|
}
|
|
104
|
-
|
|
104
|
+
// 宽松的 E.164 格式校验
|
|
105
|
+
var cleanedNumber = concatenatedNumber.replace(/\s|\(|\)/g, '');
|
|
106
|
+
var isValid = isValidPhoneNumber(cleanedNumber) && ((_parsePhoneNumberFrom = parsePhoneNumberFromString(cleanedNumber)) === null || _parsePhoneNumberFrom === void 0 ? void 0 : _parsePhoneNumberFrom.isValid());
|
|
107
|
+
return isValid ? undefined : 'error';
|
|
105
108
|
}, [concatenatedNumber, phoneNumber, isVerification]);
|
|
106
109
|
return /*#__PURE__*/React.createElement(Space.Compact, {
|
|
107
110
|
block: true
|
|
@@ -136,5 +139,5 @@ var PhoneInput = function PhoneInput(_ref) {
|
|
|
136
139
|
}
|
|
137
140
|
})));
|
|
138
141
|
};
|
|
139
|
-
var
|
|
140
|
-
export default
|
|
142
|
+
var PhoneNumberInputWithMode = withMode(PhoneNumberInput, ReadPretty);
|
|
143
|
+
export default PhoneNumberInputWithMode;
|
|
@@ -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
|
+
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: string;
|
|
7
|
+
customDomain?: string | undefined;
|
|
8
|
+
value?: string | undefined;
|
|
9
|
+
isVerification?: boolean | undefined;
|
|
10
|
+
} & import("../../dataSourceForm/utils").WithModeProps>;
|
|
11
|
+
export default SubdomainlWithMode;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
var _excluded = ["onBlur", "onChange", "rootDomain", "customDomain", "value"];
|
|
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, { useCallback, useState, useEffect } from 'react';
|
|
12
|
+
import { Input as AntInput } from 'antd';
|
|
13
|
+
import { useTenantData } from "./serve";
|
|
14
|
+
import ReadPretty from "./ReadPretty";
|
|
15
|
+
import { withMode } from "../../dataSourceForm/utils";
|
|
16
|
+
import useEngineContext from "../../../../hooks/useEngineContext";
|
|
17
|
+
var Subdomain = function Subdomain(props) {
|
|
18
|
+
var _context$appHelper$ut, _context$appHelper$ut2, _context$appHelper$ut3, _context$appHelper$ut4, _context$appHelper$ut5, _context$appHelper$ut6, _context$appHelper$ut7, _context$appHelper$ut8;
|
|
19
|
+
var propsOnBlur = props.onBlur,
|
|
20
|
+
propsOnChange = props.onChange,
|
|
21
|
+
_props$rootDomain = props.rootDomain,
|
|
22
|
+
rootDomain = _props$rootDomain === void 0 ? '' : _props$rootDomain,
|
|
23
|
+
customDomain = props.customDomain,
|
|
24
|
+
value = props.value,
|
|
25
|
+
rest = _objectWithoutProperties(props, _excluded);
|
|
26
|
+
var context = useEngineContext();
|
|
27
|
+
var coreData = (_context$appHelper$ut = context.appHelper.utils) === null || _context$appHelper$ut === void 0 ? void 0 : (_context$appHelper$ut2 = _context$appHelper$ut.getApp) === null || _context$appHelper$ut2 === void 0 ? void 0 : (_context$appHelper$ut3 = _context$appHelper$ut2.call(_context$appHelper$ut)) === null || _context$appHelper$ut3 === void 0 ? void 0 : (_context$appHelper$ut4 = _context$appHelper$ut3.data) === null || _context$appHelper$ut4 === void 0 ? void 0 : (_context$appHelper$ut5 = _context$appHelper$ut4.store) === null || _context$appHelper$ut5 === void 0 ? void 0 : (_context$appHelper$ut6 = _context$appHelper$ut5.getStore) === null || _context$appHelper$ut6 === void 0 ? void 0 : (_context$appHelper$ut7 = _context$appHelper$ut6.call(_context$appHelper$ut5)) === null || _context$appHelper$ut7 === void 0 ? void 0 : (_context$appHelper$ut8 = _context$appHelper$ut7.getDataByModel) === null || _context$appHelper$ut8 === void 0 ? void 0 : _context$appHelper$ut8.call(_context$appHelper$ut7, 'core', 'core');
|
|
28
|
+
var tenantData = useTenantData();
|
|
29
|
+
|
|
30
|
+
// 解析外部传入的value
|
|
31
|
+
var parseExternalValue = function parseExternalValue(val) {
|
|
32
|
+
if (!val) return {
|
|
33
|
+
subdomain: '',
|
|
34
|
+
suffix: coreData ? coreData.tenant_domain : ''
|
|
35
|
+
};
|
|
36
|
+
var parts = val.split('.');
|
|
37
|
+
var subdomain = parts.length > 1 ? parts[0] : val;
|
|
38
|
+
var suffix = parts.length > 1 ? ".".concat(parts.slice(1).join('.')) : coreData ? coreData.tenant_domain : '';
|
|
39
|
+
return {
|
|
40
|
+
subdomain: subdomain,
|
|
41
|
+
suffix: suffix
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
// 使用状态管理子域名和后缀
|
|
46
|
+
var _useState = useState(''),
|
|
47
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
48
|
+
subdomain = _useState2[0],
|
|
49
|
+
setSubdomain = _useState2[1];
|
|
50
|
+
var _useState3 = useState(''),
|
|
51
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
52
|
+
suffix = _useState4[0],
|
|
53
|
+
setSuffix = _useState4[1];
|
|
54
|
+
useEffect(function () {
|
|
55
|
+
if (value) {
|
|
56
|
+
// 如果传入值存在,解析并更新子域名和后缀
|
|
57
|
+
var _parseExternalValue = parseExternalValue(value),
|
|
58
|
+
_subdomain = _parseExternalValue.subdomain,
|
|
59
|
+
_suffix = _parseExternalValue.suffix;
|
|
60
|
+
setSubdomain(_subdomain);
|
|
61
|
+
setSuffix(_suffix);
|
|
62
|
+
} else {
|
|
63
|
+
// 根据 rootDomain 获取后缀
|
|
64
|
+
if (rootDomain === '1') {
|
|
65
|
+
setSuffix(coreData ? ".".concat(coreData.tenant_domain) : '');
|
|
66
|
+
} else if (rootDomain === '2') {
|
|
67
|
+
var _ref = tenantData || {},
|
|
68
|
+
_ref$default_domain = _ref.default_domain,
|
|
69
|
+
default_domain = _ref$default_domain === void 0 ? '' : _ref$default_domain;
|
|
70
|
+
var firstDotIndex = default_domain.indexOf('.');
|
|
71
|
+
var result = ".".concat(default_domain.slice(firstDotIndex + 1));
|
|
72
|
+
setSuffix(result);
|
|
73
|
+
} else {
|
|
74
|
+
setSuffix(customDomain ? customDomain.startsWith('.') ? customDomain : ".".concat(customDomain) : '');
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}, [value, rootDomain, customDomain, tenantData, coreData]);
|
|
78
|
+
var handleChange = function handleChange(e) {
|
|
79
|
+
var inputValue = e.target.value.toLowerCase();
|
|
80
|
+
var _parseExternalValue2 = parseExternalValue(inputValue),
|
|
81
|
+
subdomain = _parseExternalValue2.subdomain;
|
|
82
|
+
setSubdomain(subdomain);
|
|
83
|
+
propsOnChange === null || propsOnChange === void 0 ? void 0 : propsOnChange(subdomain + suffix);
|
|
84
|
+
};
|
|
85
|
+
var onBlur = useCallback(function (e) {
|
|
86
|
+
propsOnBlur === null || propsOnBlur === void 0 ? void 0 : propsOnBlur(e);
|
|
87
|
+
propsOnChange(subdomain + suffix);
|
|
88
|
+
}, [propsOnBlur, propsOnChange, subdomain, suffix]);
|
|
89
|
+
return /*#__PURE__*/React.createElement(AntInput, _extends({}, rest, {
|
|
90
|
+
value: subdomain,
|
|
91
|
+
onChange: handleChange,
|
|
92
|
+
onBlur: onBlur,
|
|
93
|
+
addonAfter: suffix
|
|
94
|
+
}));
|
|
95
|
+
};
|
|
96
|
+
var SubdomainlWithMode = withMode(Subdomain, ReadPretty);
|
|
97
|
+
export default SubdomainlWithMode;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
declare const Subdomain: React.FC<import("antd").InputProps & {
|
|
3
|
+
onChange: (value: string) => void;
|
|
4
|
+
onBlur?: ((e: React.FocusEvent<HTMLInputElement, Element>) => void) | undefined;
|
|
5
|
+
rootDomain: string;
|
|
6
|
+
customDomain?: string | undefined;
|
|
7
|
+
value?: string | undefined;
|
|
8
|
+
isVerification?: boolean | undefined;
|
|
9
|
+
} & import("../../dataSourceForm/utils").WithModeProps & import("../../dataSourceForm/utils").WithFormItemProps>;
|
|
10
|
+
export default Subdomain;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 获取nocobase数据列表 获取域名后缀
|
|
3
|
+
*/
|
|
4
|
+
export declare const getTenantData: () => Promise<TenantData>;
|
|
5
|
+
export interface TenantData {
|
|
6
|
+
id: number;
|
|
7
|
+
name: {
|
|
8
|
+
en: string;
|
|
9
|
+
"zh-CN": string;
|
|
10
|
+
"zh-HK": string;
|
|
11
|
+
original: string;
|
|
12
|
+
};
|
|
13
|
+
default_domain: string;
|
|
14
|
+
created_at: string;
|
|
15
|
+
locale: string;
|
|
16
|
+
updated_at: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* 自定义 Hook,用于获取租户数据
|
|
20
|
+
*/
|
|
21
|
+
export declare const useTenantData: () => TenantData | undefined;
|