@pisell/materials 1.0.473 → 1.0.475
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 +3 -3
- package/build/lowcode/preview.js +7 -7
- package/build/lowcode/render/default/view.css +1 -1
- package/build/lowcode/render/default/view.js +25 -25
- package/build/lowcode/view.css +1 -1
- package/build/lowcode/view.js +24 -24
- package/es/components/cardMetricItem/index.less +1 -0
- package/es/components/dataSourceComponents/dataSourceForm/BaseForm.js +5 -5
- package/es/components/dataSourceComponents/dataSourceForm/provider/formSetting/FormSettingContext.d.ts +1 -1
- package/es/components/dataSourceComponents/dataSourceForm/provider/formSetting/FormSettingContext.js +1 -1
- package/es/components/dataSourceComponents/dataSourceForm/provider/formSetting/FormSettingProvider.js +3 -3
- package/es/components/dataSourceComponents/dataSourceForm/submitButton/index.js +4 -4
- package/es/components/dataSourceComponents/dataSourceForm/type.d.ts +1 -1
- package/es/components/dataSourceComponents/dataSourceForm/utils.js +21 -8
- package/es/components/dataSourceComponents/dataSourceTable/hooks/useColumns.js +1 -1
- package/es/components/dataSourceComponents/fields/ColorPicker/WithMode.d.ts +3 -2
- package/es/components/dataSourceComponents/fields/ColorPicker/WithMode.js +40 -2
- package/es/components/dataSourceComponents/fields/Input.Password/ReadPretty.d.ts +1 -1
- package/es/components/dataSourceComponents/fields/Input.Password/ReadPretty.js +8 -1
- package/es/components/dataSourceComponents/fields/Input.Phone/ReadPretty.d.ts +3 -3
- package/es/components/dataSourceComponents/fields/Input.Phone/ReadPretty.js +14 -3
- package/es/components/dataSourceComponents/fields/Input.Phone/WithMode.d.ts +6 -1
- package/es/components/dataSourceComponents/fields/Input.Phone/WithMode.js +121 -6
- package/es/components/dataSourceComponents/fields/Input.Phone/serve.d.ts +24 -0
- package/es/components/dataSourceComponents/fields/Input.Phone/serve.js +59 -0
- package/es/components/dataSourceComponents/fields/InputNumber/ReadPretty.d.ts +2 -2
- package/es/components/dataSourceComponents/fields/InputNumber/ReadPretty.js +17 -3
- package/es/components/dataSourceComponents/fields/InputNumber/WithMode.d.ts +2 -2
- package/es/components/dataSourceComponents/fields/InputNumber/WithMode.js +32 -1
- package/es/components/dataSourceComponents/fields/InputNumber/type.d.ts +2 -0
- package/es/components/dataSourceComponents/fields/InputNumber/utils.d.ts +1 -0
- package/es/components/dataSourceComponents/fields/InputNumber/utils.js +41 -0
- package/es/components/pisellAnchor/index.less +77 -77
- package/es/components/pisellStatisticList/index.less +1 -1
- package/es/components/pisellWalletPassCard/index.js +3 -1
- package/es/components/pisellWalletPassCard/index.less +23 -9
- package/es/components/walletCard/index.d.ts +6 -4
- package/es/components/walletCard/index.js +34 -15
- package/es/locales/en-US.d.ts +4 -0
- package/es/locales/en-US.js +6 -1
- package/es/locales/zh-CN.d.ts +4 -0
- package/es/locales/zh-CN.js +6 -1
- package/es/locales/zh-TW.d.ts +4 -0
- package/es/locales/zh-TW.js +6 -1
- package/lib/components/cardMetricItem/index.less +1 -0
- package/lib/components/dataSourceComponents/dataSourceForm/BaseForm.js +4 -4
- package/lib/components/dataSourceComponents/dataSourceForm/provider/formSetting/FormSettingContext.d.ts +1 -1
- package/lib/components/dataSourceComponents/dataSourceForm/provider/formSetting/FormSettingContext.js +1 -1
- package/lib/components/dataSourceComponents/dataSourceForm/provider/formSetting/FormSettingProvider.js +3 -3
- package/lib/components/dataSourceComponents/dataSourceForm/submitButton/index.js +4 -4
- package/lib/components/dataSourceComponents/dataSourceForm/type.d.ts +1 -1
- package/lib/components/dataSourceComponents/dataSourceForm/utils.js +30 -6
- package/lib/components/dataSourceComponents/dataSourceTable/hooks/useColumns.js +1 -1
- package/lib/components/dataSourceComponents/fields/ColorPicker/WithMode.d.ts +3 -2
- package/lib/components/dataSourceComponents/fields/ColorPicker/WithMode.js +18 -2
- package/lib/components/dataSourceComponents/fields/Input.Password/ReadPretty.d.ts +1 -1
- package/lib/components/dataSourceComponents/fields/Input.Password/ReadPretty.js +6 -1
- package/lib/components/dataSourceComponents/fields/Input.Phone/ReadPretty.d.ts +3 -3
- package/lib/components/dataSourceComponents/fields/Input.Phone/ReadPretty.js +14 -3
- package/lib/components/dataSourceComponents/fields/Input.Phone/WithMode.d.ts +6 -1
- package/lib/components/dataSourceComponents/fields/Input.Phone/WithMode.js +98 -3
- package/lib/components/dataSourceComponents/fields/Input.Phone/serve.d.ts +24 -0
- package/lib/components/dataSourceComponents/fields/Input.Phone/serve.js +55 -0
- package/lib/components/dataSourceComponents/fields/InputNumber/ReadPretty.d.ts +2 -2
- package/lib/components/dataSourceComponents/fields/InputNumber/ReadPretty.js +14 -4
- package/lib/components/dataSourceComponents/fields/InputNumber/WithMode.d.ts +2 -2
- package/lib/components/dataSourceComponents/fields/InputNumber/WithMode.js +36 -5
- package/lib/components/dataSourceComponents/fields/InputNumber/type.d.ts +2 -0
- package/lib/components/dataSourceComponents/fields/InputNumber/utils.d.ts +1 -0
- package/lib/components/dataSourceComponents/fields/InputNumber/utils.js +63 -0
- package/lib/components/pisellAnchor/index.less +77 -77
- package/lib/components/pisellStatisticList/index.less +1 -1
- package/lib/components/pisellWalletPassCard/index.js +1 -1
- package/lib/components/pisellWalletPassCard/index.less +23 -9
- package/lib/components/walletCard/index.d.ts +6 -4
- package/lib/components/walletCard/index.js +24 -13
- package/lib/locales/en-US.d.ts +4 -0
- package/lib/locales/en-US.js +6 -1
- package/lib/locales/zh-CN.d.ts +4 -0
- package/lib/locales/zh-CN.js +6 -1
- package/lib/locales/zh-TW.d.ts +4 -0
- package/lib/locales/zh-TW.js +6 -1
- package/lowcode/_utils/defaultSchema.ts +2 -2
- package/lowcode/data-source-form/snippets.ts +3 -3
- package/lowcode/data-source-form/utils.ts +15 -7
- package/lowcode/data-source-table/utils.tsx +2 -2
- package/lowcode/form-item-checkbox/snippets.ts +2 -2
- package/lowcode/form-item-checkbox.group/meta.ts +3 -3
- package/lowcode/form-item-color-picker/meta.ts +1 -1
- package/lowcode/form-item-input/meta.ts +1 -1
- package/lowcode/form-item-input/snippets.ts +1 -0
- package/lowcode/form-item-input-number/meta.ts +276 -109
- package/lowcode/form-item-input-number/snippets.ts +18 -3
- package/lowcode/form-item-input.email/meta.ts +1 -1
- package/lowcode/form-item-input.email/snippets.ts +1 -0
- package/lowcode/form-item-input.password/meta.ts +35 -3
- package/lowcode/form-item-input.password/snippets.ts +3 -1
- package/lowcode/form-item-input.phone/meta.ts +1 -1
- package/lowcode/form-item-input.phone/snippets.ts +1 -0
- package/lowcode/form-item-input.text-area/meta.ts +1 -1
- package/lowcode/form-item-input.text-area/snippets.ts +1 -0
- package/lowcode/form-item-input.url/meta.ts +51 -4
- package/lowcode/form-item-input.url/snippets.ts +3 -2
- package/lowcode/form-item-radio/snippets.ts +11 -11
- package/lowcode/form-item-radio.group/meta.ts +2 -2
- package/lowcode/form-item-select/meta.ts +39 -2
- package/lowcode/form-item-select/snippets.ts +35 -1
- package/package.json +3 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _excluded = ["title", "description", "dataSource", "showTitle", "showDescription", "groupInfoPosition", "variables", "
|
|
1
|
+
var _excluded = ["title", "description", "dataSource", "showTitle", "showDescription", "groupInfoPosition", "variables", "renderMode", "children", "currentValue", "className"];
|
|
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 _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; }
|
|
4
4
|
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; }
|
|
@@ -21,7 +21,7 @@ var BaseForm = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
21
21
|
showDescription = props.showDescription,
|
|
22
22
|
groupInfoPosition = props.groupInfoPosition,
|
|
23
23
|
variables = props.variables,
|
|
24
|
-
|
|
24
|
+
renderMode = props.renderMode,
|
|
25
25
|
children = props.children,
|
|
26
26
|
currentValue = props.currentValue,
|
|
27
27
|
className = props.className,
|
|
@@ -40,15 +40,15 @@ var BaseForm = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
40
40
|
return formRef.current;
|
|
41
41
|
});
|
|
42
42
|
useEffect(function () {
|
|
43
|
-
if (['edit', 'view'].includes(
|
|
43
|
+
if (['edit', 'view'].includes(renderMode || '') && dataSource) {
|
|
44
44
|
get === null || get === void 0 ? void 0 : get.runAsync().then(function (res) {
|
|
45
45
|
var _formRef$current2;
|
|
46
46
|
(_formRef$current2 = formRef.current) === null || _formRef$current2 === void 0 ? void 0 : _formRef$current2.setFieldsValue(res);
|
|
47
47
|
});
|
|
48
48
|
}
|
|
49
|
-
}, [
|
|
49
|
+
}, [renderMode, dataSource]);
|
|
50
50
|
return /*#__PURE__*/React.createElement(FormSettingProvider, {
|
|
51
|
-
|
|
51
|
+
renderMode: renderMode,
|
|
52
52
|
groupInfoPosition: groupInfoPosition,
|
|
53
53
|
currentValue: currentValue
|
|
54
54
|
}, /*#__PURE__*/React.createElement(Form, _extends({}, others, {
|
|
@@ -7,16 +7,16 @@ import FormSettingContext from "./FormSettingContext";
|
|
|
7
7
|
*/
|
|
8
8
|
var FormSettingProvider = function FormSettingProvider(props) {
|
|
9
9
|
var children = props.children,
|
|
10
|
-
|
|
10
|
+
renderMode = props.renderMode,
|
|
11
11
|
groupInfoPosition = props.groupInfoPosition,
|
|
12
12
|
currentValue = props.currentValue;
|
|
13
13
|
var value = React.useMemo(function () {
|
|
14
14
|
return {
|
|
15
|
-
|
|
15
|
+
renderMode: renderMode,
|
|
16
16
|
groupInfoPosition: groupInfoPosition,
|
|
17
17
|
currentValue: currentValue
|
|
18
18
|
};
|
|
19
|
-
}, [
|
|
19
|
+
}, [renderMode, groupInfoPosition, currentValue]);
|
|
20
20
|
return /*#__PURE__*/React.createElement(FormSettingContext.Provider, {
|
|
21
21
|
value: value
|
|
22
22
|
}, children);
|
|
@@ -38,7 +38,7 @@ var SubmitButton = function SubmitButton(props) {
|
|
|
38
38
|
contextHolder = _notification$useNoti2[1];
|
|
39
39
|
var form = Form.useFormInstance();
|
|
40
40
|
var _useFormSetting = useFormSetting(),
|
|
41
|
-
|
|
41
|
+
renderMode = _useFormSetting.renderMode;
|
|
42
42
|
var _useCtxActions = useCtxActions(),
|
|
43
43
|
setVisible = _useCtxActions.setVisible,
|
|
44
44
|
refreshTableData = _useCtxActions.refreshTableData;
|
|
@@ -54,7 +54,7 @@ var SubmitButton = function SubmitButton(props) {
|
|
|
54
54
|
case 0:
|
|
55
55
|
_context.prev = 0;
|
|
56
56
|
setLoading(true);
|
|
57
|
-
if (!(
|
|
57
|
+
if (!(renderMode === 'edit')) {
|
|
58
58
|
_context.next = 7;
|
|
59
59
|
break;
|
|
60
60
|
}
|
|
@@ -64,7 +64,7 @@ var SubmitButton = function SubmitButton(props) {
|
|
|
64
64
|
_context.next = 12;
|
|
65
65
|
break;
|
|
66
66
|
case 7:
|
|
67
|
-
if (!(
|
|
67
|
+
if (!(renderMode === 'add')) {
|
|
68
68
|
_context.next = 12;
|
|
69
69
|
break;
|
|
70
70
|
}
|
|
@@ -206,7 +206,7 @@ var SubmitButton = function SubmitButton(props) {
|
|
|
206
206
|
return _ref3.apply(this, arguments);
|
|
207
207
|
};
|
|
208
208
|
}();
|
|
209
|
-
if (status === 'hidden' ||
|
|
209
|
+
if (status === 'hidden' || renderMode === 'view') {
|
|
210
210
|
return null;
|
|
211
211
|
}
|
|
212
212
|
return /*#__PURE__*/React.createElement(FormItem, null, /*#__PURE__*/React.createElement("div", {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
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
2
|
var _excluded = ["renderMode", "value", "onChange"],
|
|
3
|
-
_excluded2 = ["name", "label", "mode", "tooltip", "noStyle", "extra", "required", "requiredobj", "minLengthobj", "maxLengthobj", "typeobj", "maxobj", "minobj", "normalize", "getValueProps", "validator", "style", "validateTrigger", "__designMode", "labelCol", "innerStyle"];
|
|
3
|
+
_excluded2 = ["name", "label", "mode", "renderMode", "tooltip", "noStyle", "extra", "required", "requiredobj", "minLengthobj", "maxLengthobj", "typeobj", "maxobj", "minobj", "normalize", "getValueProps", "validator", "style", "validateTrigger", "__designMode", "labelCol", "innerStyle"];
|
|
4
4
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
5
5
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
6
6
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
@@ -19,6 +19,7 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
|
19
19
|
import React, { useEffect, useMemo } from 'react';
|
|
20
20
|
import { isArr, isString } from '@pisell/utils';
|
|
21
21
|
import { Tag } from 'antd';
|
|
22
|
+
import { parsePhoneNumberFromString, isValidPhoneNumber } from 'libphonenumber-js';
|
|
22
23
|
import { getText } from "../../../locales";
|
|
23
24
|
import Form from "../../form";
|
|
24
25
|
import useDataSource from "../hooks/useDataSource";
|
|
@@ -84,6 +85,7 @@ export var withFormItem = function withFormItem(WrappedComponent, otherFormItemP
|
|
|
84
85
|
var propsName = _ref2.name,
|
|
85
86
|
propsLabel = _ref2.label,
|
|
86
87
|
propsMode = _ref2.mode,
|
|
88
|
+
propsRenderMode = _ref2.renderMode,
|
|
87
89
|
tooltip = _ref2.tooltip,
|
|
88
90
|
noStyle = _ref2.noStyle,
|
|
89
91
|
extra = _ref2.extra,
|
|
@@ -111,7 +113,7 @@ export var withFormItem = function withFormItem(WrappedComponent, otherFormItemP
|
|
|
111
113
|
var _ref3 = dataSource || {},
|
|
112
114
|
fields = _ref3.fields;
|
|
113
115
|
var _useFormSetting = useFormSetting(),
|
|
114
|
-
|
|
116
|
+
globalRenderMode = _useFormSetting.renderMode;
|
|
115
117
|
var field = fields === null || fields === void 0 ? void 0 : fields.find(function (item) {
|
|
116
118
|
return item.name === propsName;
|
|
117
119
|
});
|
|
@@ -120,15 +122,16 @@ export var withFormItem = function withFormItem(WrappedComponent, otherFormItemP
|
|
|
120
122
|
var label = propsLabel || (field === null || field === void 0 ? void 0 : (_field$uiSchema = field.uiSchema) === null || _field$uiSchema === void 0 ? void 0 : _field$uiSchema.title) || propsName;
|
|
121
123
|
|
|
122
124
|
// 模式优先级:外部传入 mode > 全局模式
|
|
123
|
-
var effectiveMode =
|
|
125
|
+
var effectiveMode = propsRenderMode || globalRenderMode;
|
|
124
126
|
var renderComponent = useMemo(function () {
|
|
125
127
|
// 使用renderMode属性,避免和组件mode冲突
|
|
126
128
|
return /*#__PURE__*/React.createElement(WrappedComponent, _extends({}, otherProps, {
|
|
127
129
|
mode: propsMode,
|
|
128
130
|
renderMode: effectiveMode,
|
|
129
|
-
style: _objectSpread(_objectSpread({}, (otherFormItemProps === null || otherFormItemProps === void 0 ? void 0 : otherFormItemProps.innerStyle) || {}), innerStyle)
|
|
131
|
+
style: _objectSpread(_objectSpread({}, (otherFormItemProps === null || otherFormItemProps === void 0 ? void 0 : otherFormItemProps.innerStyle) || {}), innerStyle),
|
|
132
|
+
isVerification: typeobj === null || typeobj === void 0 ? void 0 : typeobj.enabled
|
|
130
133
|
}));
|
|
131
|
-
}, [effectiveMode, otherProps, propsMode, innerStyle, otherFormItemProps === null || otherFormItemProps === void 0 ? void 0 : otherFormItemProps.innerStyle]);
|
|
134
|
+
}, [effectiveMode, otherProps, propsMode, innerStyle, otherFormItemProps === null || otherFormItemProps === void 0 ? void 0 : otherFormItemProps.innerStyle, typeobj === null || typeobj === void 0 ? void 0 : typeobj.enabled]);
|
|
132
135
|
var isDesignMode = __designMode === 'design';
|
|
133
136
|
var isHidden = effectiveMode === 'hidden';
|
|
134
137
|
|
|
@@ -146,11 +149,20 @@ export var withFormItem = function withFormItem(WrappedComponent, otherFormItemP
|
|
|
146
149
|
rules.push(_objectSpread(_objectSpread({}, typeobj), {}, {
|
|
147
150
|
message: typeobj.message || getText('pisell-data-source-form-email-message')
|
|
148
151
|
}));
|
|
149
|
-
}
|
|
152
|
+
}
|
|
153
|
+
if (typeobj.type === 'url' && typeobj.enabled) {
|
|
150
154
|
rules.push(_objectSpread(_objectSpread({}, typeobj), {}, {
|
|
151
|
-
message: typeobj.message || getText('pisell-data-source-form-
|
|
155
|
+
message: typeobj.message || getText('pisell-data-source-form-url-message')
|
|
152
156
|
}));
|
|
153
157
|
}
|
|
158
|
+
if (typeobj.type === 'phone' && typeobj.enabled) {
|
|
159
|
+
rules.push({
|
|
160
|
+
validator: function validator(_, value) {
|
|
161
|
+
var _parsePhoneNumberFrom;
|
|
162
|
+
return isValidPhoneNumber(value) && (_parsePhoneNumberFrom = parsePhoneNumberFromString(value)) !== null && _parsePhoneNumberFrom !== void 0 && _parsePhoneNumberFrom.isValid() ? Promise.resolve() : Promise.reject(new Error(typeobj.message || getText('pisell-data-source-form-phone-message')));
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
}
|
|
154
166
|
}
|
|
155
167
|
if (maxLengthobj && maxLengthobj.enabled) {
|
|
156
168
|
rules.push(_objectSpread(_objectSpread({}, maxLengthobj), {}, {
|
|
@@ -190,7 +202,8 @@ export var withFormItem = function withFormItem(WrappedComponent, otherFormItemP
|
|
|
190
202
|
getValueProps: getValueProps,
|
|
191
203
|
validator: validator,
|
|
192
204
|
validateTrigger: validateTrigger,
|
|
193
|
-
labelCol: labelCol
|
|
205
|
+
labelCol: labelCol,
|
|
206
|
+
initialValue: otherProps === null || otherProps === void 0 ? void 0 : otherProps.defaultValue
|
|
194
207
|
}, otherFormItemProps), renderComponent);
|
|
195
208
|
};
|
|
196
209
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ColorPickerProps } from './type';
|
|
3
|
+
declare const ColorPickerWithMode: React.FC<ColorPickerProps & import("../../dataSourceForm/utils").WithModeProps>;
|
|
3
4
|
export default ColorPickerWithMode;
|
|
@@ -1,5 +1,43 @@
|
|
|
1
|
-
|
|
1
|
+
var _excluded = ["renderMode"];
|
|
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 _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; }
|
|
4
|
+
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; }
|
|
5
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
6
|
+
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."); }
|
|
7
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
8
|
+
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; }
|
|
9
|
+
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; } }
|
|
10
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
11
|
+
import React from 'react';
|
|
12
|
+
import { ColorPicker as AntColorPicker, theme } from 'antd';
|
|
13
|
+
import { generate, green, presetPalettes, red } from '@ant-design/colors';
|
|
14
|
+
var genPresets = function genPresets() {
|
|
15
|
+
var presets = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : presetPalettes;
|
|
16
|
+
return Object.entries(presets).map(function (_ref) {
|
|
17
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
18
|
+
label = _ref2[0],
|
|
19
|
+
colors = _ref2[1];
|
|
20
|
+
return {
|
|
21
|
+
label: label,
|
|
22
|
+
colors: colors
|
|
23
|
+
};
|
|
24
|
+
});
|
|
25
|
+
};
|
|
2
26
|
import ReadPretty from "./ReadPretty";
|
|
3
27
|
import { withMode } from "../../dataSourceForm/utils";
|
|
4
|
-
var
|
|
28
|
+
var ColorPicker = function ColorPicker(props) {
|
|
29
|
+
var _theme$useToken = theme.useToken(),
|
|
30
|
+
token = _theme$useToken.token;
|
|
31
|
+
var presets = genPresets({
|
|
32
|
+
primary: generate(token.colorPrimary),
|
|
33
|
+
red: red,
|
|
34
|
+
green: green
|
|
35
|
+
});
|
|
36
|
+
var renderMode = props.renderMode,
|
|
37
|
+
restProps = _objectWithoutProperties(props, _excluded);
|
|
38
|
+
return /*#__PURE__*/React.createElement(AntColorPicker, _extends({}, restProps, {
|
|
39
|
+
presets: presets
|
|
40
|
+
}));
|
|
41
|
+
};
|
|
42
|
+
var ColorPickerWithMode = withMode(ColorPicker, ReadPretty);
|
|
5
43
|
export default ColorPickerWithMode;
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { isString } from '@pisell/utils';
|
|
2
3
|
var PasswordReadPretty = function PasswordReadPretty(props) {
|
|
3
|
-
|
|
4
|
+
if (props.value && isString(props.value)) {
|
|
5
|
+
var _props$value, _props$value$split;
|
|
6
|
+
return /*#__PURE__*/React.createElement("span", null, (_props$value = props.value) === null || _props$value === void 0 ? void 0 : (_props$value$split = _props$value.split) === null || _props$value$split === void 0 ? void 0 : _props$value$split.call(_props$value, '').map(function () {
|
|
7
|
+
return '•';
|
|
8
|
+
}));
|
|
9
|
+
}
|
|
10
|
+
return /*#__PURE__*/React.createElement("span", null, '••••••');
|
|
4
11
|
};
|
|
5
12
|
export default PasswordReadPretty;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
declare const
|
|
4
|
-
export default
|
|
2
|
+
import type { PhoneInputProps } from './WithMode';
|
|
3
|
+
declare const ReadPretty: React.FC<Omit<PhoneInputProps, 'onChange'>>;
|
|
4
|
+
export default ReadPretty;
|
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
import { parsePhoneNumberFromString as parsePhoneNumber } from 'libphonenumber-js';
|
|
3
|
+
var ReadPretty = function ReadPretty(_ref) {
|
|
4
|
+
var value = _ref.value;
|
|
5
|
+
if (!value) return null;
|
|
6
|
+
try {
|
|
7
|
+
var phoneNumber = parsePhoneNumber(value);
|
|
8
|
+
if (!phoneNumber) return /*#__PURE__*/React.createElement("span", null, value);
|
|
9
|
+
var formattedValue = "(".concat(phoneNumber.formatInternational().split(' ')[0], ") ").concat(phoneNumber.formatNational());
|
|
10
|
+
return /*#__PURE__*/React.createElement("span", null, formattedValue);
|
|
11
|
+
} catch (error) {
|
|
12
|
+
// 如果解析失败,直接显示原始值
|
|
13
|
+
return /*#__PURE__*/React.createElement("span", null, value);
|
|
14
|
+
}
|
|
4
15
|
};
|
|
5
|
-
export default
|
|
16
|
+
export default ReadPretty;
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { InputProps } from 'antd';
|
|
3
|
-
|
|
3
|
+
export interface PhoneInputProps extends Omit<InputProps, 'value' | 'onChange'> {
|
|
4
|
+
value?: string;
|
|
5
|
+
onChange?: (value: string) => void;
|
|
6
|
+
isVerification?: boolean;
|
|
7
|
+
}
|
|
8
|
+
declare const PhoneWithMode: React.FC<PhoneInputProps & import("../../dataSourceForm/utils").WithModeProps>;
|
|
4
9
|
export default PhoneWithMode;
|
|
@@ -1,12 +1,127 @@
|
|
|
1
|
+
var _excluded = ["value", "onChange", "isVerification"];
|
|
1
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); }
|
|
2
|
-
|
|
3
|
-
|
|
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, Select } from 'antd';
|
|
13
|
+
import { isValidPhoneNumber, parsePhoneNumberFromString } from 'libphonenumber-js';
|
|
14
|
+
import useEngineContext from "../../../../hooks/useEngineContext";
|
|
15
|
+
import { useCountries } from "./serve";
|
|
4
16
|
import ReadPretty from "./ReadPretty";
|
|
5
17
|
import { withMode } from "../../dataSourceForm/utils";
|
|
6
|
-
var
|
|
7
|
-
|
|
8
|
-
|
|
18
|
+
var Option = Select.Option;
|
|
19
|
+
var translationOriginal = function translationOriginal(val) {
|
|
20
|
+
return val.original;
|
|
21
|
+
};
|
|
22
|
+
var PhoneInput = function PhoneInput(_ref) {
|
|
23
|
+
var value = _ref.value,
|
|
24
|
+
onChange = _ref.onChange,
|
|
25
|
+
isVerification = _ref.isVerification,
|
|
26
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
27
|
+
var _useCountries = useCountries(),
|
|
28
|
+
_useCountries$data = _useCountries.data,
|
|
29
|
+
countries = _useCountries$data === void 0 ? [] : _useCountries$data;
|
|
30
|
+
console.log(value, 'valuevaluevalue');
|
|
31
|
+
var context = useEngineContext();
|
|
32
|
+
translationOriginal = context.appHelper.utils.translationOriginal || translationOriginal;
|
|
33
|
+
|
|
34
|
+
// 解析外部传入的value
|
|
35
|
+
var parseExternalValue = function parseExternalValue(val) {
|
|
36
|
+
if (!val) return {
|
|
37
|
+
countryCode: 'AU',
|
|
38
|
+
phoneNumber: ''
|
|
39
|
+
};
|
|
40
|
+
var matchedPrefix = countries.find(function (country) {
|
|
41
|
+
return val.startsWith(country.prefix);
|
|
42
|
+
});
|
|
43
|
+
if (matchedPrefix) {
|
|
44
|
+
return {
|
|
45
|
+
countryCode: matchedPrefix.code,
|
|
46
|
+
phoneNumber: val.slice(matchedPrefix.prefix.length)
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
countryCode: 'AU',
|
|
51
|
+
phoneNumber: val.replace(/\D/g, '')
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
var _useState = useState(function () {
|
|
55
|
+
return parseExternalValue(value).countryCode;
|
|
56
|
+
}),
|
|
57
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
58
|
+
countryCode = _useState2[0],
|
|
59
|
+
setCountryCode = _useState2[1];
|
|
60
|
+
var _useState3 = useState(function () {
|
|
61
|
+
return parseExternalValue(value).phoneNumber;
|
|
62
|
+
}),
|
|
63
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
64
|
+
phoneNumber = _useState4[0],
|
|
65
|
+
setPhoneNumber = _useState4[1];
|
|
66
|
+
|
|
67
|
+
// 监听外部value变化
|
|
68
|
+
useEffect(function () {
|
|
69
|
+
var _parseExternalValue = parseExternalValue(value),
|
|
70
|
+
newCountryCode = _parseExternalValue.countryCode,
|
|
71
|
+
newPhoneNumber = _parseExternalValue.phoneNumber;
|
|
72
|
+
setCountryCode(newCountryCode);
|
|
73
|
+
setPhoneNumber(newPhoneNumber);
|
|
74
|
+
}, [value, countries]);
|
|
75
|
+
var handleCountryChange = function handleCountryChange(value) {
|
|
76
|
+
setCountryCode(value);
|
|
77
|
+
};
|
|
78
|
+
var handlePhoneNumberChange = function handlePhoneNumberChange(e) {
|
|
79
|
+
var cleanNumber = e.target.value.replace(/\D/g, '');
|
|
80
|
+
setPhoneNumber(cleanNumber);
|
|
81
|
+
};
|
|
82
|
+
var concatenatedNumber = useMemo(function () {
|
|
83
|
+
var selectedCountry = countries.find(function (c) {
|
|
84
|
+
return c.code === countryCode;
|
|
85
|
+
});
|
|
86
|
+
var prefix = (selectedCountry === null || selectedCountry === void 0 ? void 0 : selectedCountry.prefix) || "";
|
|
87
|
+
return "".concat(prefix).concat(phoneNumber);
|
|
88
|
+
}, [countryCode, phoneNumber, countries]);
|
|
89
|
+
var handleBlur = function handleBlur() {
|
|
90
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(concatenatedNumber);
|
|
91
|
+
};
|
|
92
|
+
var status = useMemo(function () {
|
|
93
|
+
var _parsePhoneNumberFrom;
|
|
94
|
+
if (!phoneNumber || !isVerification) {
|
|
95
|
+
return undefined;
|
|
96
|
+
}
|
|
97
|
+
return isValidPhoneNumber(concatenatedNumber) && (_parsePhoneNumberFrom = parsePhoneNumberFromString(concatenatedNumber)) !== null && _parsePhoneNumberFrom !== void 0 && _parsePhoneNumberFrom.isValid() ? undefined : 'error';
|
|
98
|
+
}, [concatenatedNumber, phoneNumber, isVerification]);
|
|
99
|
+
return /*#__PURE__*/React.createElement(Input, _extends({}, props, {
|
|
100
|
+
status: status,
|
|
101
|
+
addonBefore: /*#__PURE__*/React.createElement(Select, {
|
|
102
|
+
value: countryCode,
|
|
103
|
+
onChange: handleCountryChange,
|
|
104
|
+
style: {
|
|
105
|
+
width: '80px'
|
|
106
|
+
},
|
|
107
|
+
onBlur: handleBlur,
|
|
108
|
+
popupMatchSelectWidth: false,
|
|
109
|
+
optionLabelProp: "label"
|
|
110
|
+
}, countries.map(function (country) {
|
|
111
|
+
return /*#__PURE__*/React.createElement(Option, {
|
|
112
|
+
key: country.code,
|
|
113
|
+
value: country.code,
|
|
114
|
+
label: country.prefix
|
|
115
|
+
}, translationOriginal(country.name), " (", country.prefix, ")");
|
|
116
|
+
})),
|
|
117
|
+
type: "tel",
|
|
118
|
+
value: phoneNumber,
|
|
119
|
+
onChange: handlePhoneNumberChange,
|
|
120
|
+
onBlur: handleBlur,
|
|
121
|
+
style: {
|
|
122
|
+
flex: 1
|
|
123
|
+
}
|
|
9
124
|
}));
|
|
10
125
|
};
|
|
11
|
-
var PhoneWithMode = withMode(
|
|
126
|
+
var PhoneWithMode = withMode(PhoneInput, ReadPretty);
|
|
12
127
|
export default PhoneWithMode;
|
|
@@ -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
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { InputNumberProps } from './type';
|
|
3
|
-
declare const
|
|
4
|
-
export default
|
|
3
|
+
declare const ReadPretty: React.FC<InputNumberProps>;
|
|
4
|
+
export default ReadPretty;
|