@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
|
@@ -25,7 +25,7 @@ __export(FormSettingContext_exports, {
|
|
|
25
25
|
module.exports = __toCommonJS(FormSettingContext_exports);
|
|
26
26
|
var import_react = require("react");
|
|
27
27
|
var initialContext = {
|
|
28
|
-
|
|
28
|
+
renderMode: "edit"
|
|
29
29
|
};
|
|
30
30
|
var FormSettingContext = (0, import_react.createContext)(initialContext);
|
|
31
31
|
var FormSettingContext_default = FormSettingContext;
|
|
@@ -35,14 +35,14 @@ module.exports = __toCommonJS(FormSettingProvider_exports);
|
|
|
35
35
|
var import_react = __toESM(require("react"));
|
|
36
36
|
var import_FormSettingContext = __toESM(require("./FormSettingContext"));
|
|
37
37
|
var FormSettingProvider = (props) => {
|
|
38
|
-
const { children,
|
|
38
|
+
const { children, renderMode, groupInfoPosition, currentValue } = props;
|
|
39
39
|
const value = import_react.default.useMemo(() => {
|
|
40
40
|
return {
|
|
41
|
-
|
|
41
|
+
renderMode,
|
|
42
42
|
groupInfoPosition,
|
|
43
43
|
currentValue
|
|
44
44
|
};
|
|
45
|
-
}, [
|
|
45
|
+
}, [renderMode, groupInfoPosition, currentValue]);
|
|
46
46
|
return /* @__PURE__ */ import_react.default.createElement(
|
|
47
47
|
import_FormSettingContext.default.Provider,
|
|
48
48
|
{
|
|
@@ -56,16 +56,16 @@ var SubmitButton = (props) => {
|
|
|
56
56
|
const [loading, setLoading] = (0, import_react.useState)(false);
|
|
57
57
|
const [api, contextHolder] = import_antd.notification.useNotification();
|
|
58
58
|
const form = import_antd.Form.useFormInstance();
|
|
59
|
-
const {
|
|
59
|
+
const { renderMode } = (0, import_useFormSetting.default)();
|
|
60
60
|
const { setVisible, refreshTableData } = (0, import_useCtxActions.default)();
|
|
61
61
|
const { create, update } = (0, import_useDataSource.default)();
|
|
62
62
|
const isDisabled = status === "disabled";
|
|
63
63
|
const onSubmit = async (values) => {
|
|
64
64
|
try {
|
|
65
65
|
setLoading(true);
|
|
66
|
-
if (
|
|
66
|
+
if (renderMode === "edit") {
|
|
67
67
|
await update.runAsync(values);
|
|
68
|
-
} else if (
|
|
68
|
+
} else if (renderMode === "add") {
|
|
69
69
|
const res = await create.runAsync(values);
|
|
70
70
|
form == null ? void 0 : form.resetFields();
|
|
71
71
|
}
|
|
@@ -141,7 +141,7 @@ var SubmitButton = (props) => {
|
|
|
141
141
|
}
|
|
142
142
|
handleValideFieldsSubmit(values);
|
|
143
143
|
};
|
|
144
|
-
if (status === "hidden" ||
|
|
144
|
+
if (status === "hidden" || renderMode === "view") {
|
|
145
145
|
return null;
|
|
146
146
|
}
|
|
147
147
|
return /* @__PURE__ */ import_react.default.createElement(import_formItem.default, null, /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode-data-source-form-submit-button-wrapper" }, /* @__PURE__ */ import_react.default.createElement(
|
|
@@ -43,6 +43,7 @@ module.exports = __toCommonJS(utils_exports);
|
|
|
43
43
|
var import_react = __toESM(require("react"));
|
|
44
44
|
var import_utils = require("@pisell/utils");
|
|
45
45
|
var import_antd = require("antd");
|
|
46
|
+
var import_libphonenumber_js = require("libphonenumber-js");
|
|
46
47
|
var import_locales = require("../../../locales");
|
|
47
48
|
var import_form = __toESM(require("../../form"));
|
|
48
49
|
var import_useDataSource = __toESM(require("../hooks/useDataSource"));
|
|
@@ -87,6 +88,7 @@ var withFormItem = (WrappedComponent, otherFormItemProps) => {
|
|
|
87
88
|
name: propsName,
|
|
88
89
|
label: propsLabel,
|
|
89
90
|
mode: propsMode,
|
|
91
|
+
renderMode: propsRenderMode,
|
|
90
92
|
tooltip,
|
|
91
93
|
noStyle,
|
|
92
94
|
extra,
|
|
@@ -111,10 +113,10 @@ var withFormItem = (WrappedComponent, otherFormItemProps) => {
|
|
|
111
113
|
const { path: prefixPath = [] } = (0, import_useJsonPrefixPath.default)();
|
|
112
114
|
const { dataSource } = (0, import_useDataSource.default)();
|
|
113
115
|
const { fields } = dataSource || {};
|
|
114
|
-
const {
|
|
116
|
+
const { renderMode: globalRenderMode } = (0, import_useFormSetting.default)();
|
|
115
117
|
const field = fields == null ? void 0 : fields.find((item) => item.name === propsName);
|
|
116
118
|
const label = propsLabel || ((_a = field == null ? void 0 : field.uiSchema) == null ? void 0 : _a.title) || propsName;
|
|
117
|
-
const effectiveMode =
|
|
119
|
+
const effectiveMode = propsRenderMode || globalRenderMode;
|
|
118
120
|
const renderComponent = (0, import_react.useMemo)(() => {
|
|
119
121
|
return /* @__PURE__ */ import_react.default.createElement(
|
|
120
122
|
WrappedComponent,
|
|
@@ -125,10 +127,18 @@ var withFormItem = (WrappedComponent, otherFormItemProps) => {
|
|
|
125
127
|
style: {
|
|
126
128
|
...(otherFormItemProps == null ? void 0 : otherFormItemProps.innerStyle) || {},
|
|
127
129
|
...innerStyle
|
|
128
|
-
}
|
|
130
|
+
},
|
|
131
|
+
isVerification: typeobj == null ? void 0 : typeobj.enabled
|
|
129
132
|
}
|
|
130
133
|
);
|
|
131
|
-
}, [
|
|
134
|
+
}, [
|
|
135
|
+
effectiveMode,
|
|
136
|
+
otherProps,
|
|
137
|
+
propsMode,
|
|
138
|
+
innerStyle,
|
|
139
|
+
otherFormItemProps == null ? void 0 : otherFormItemProps.innerStyle,
|
|
140
|
+
typeobj == null ? void 0 : typeobj.enabled
|
|
141
|
+
]);
|
|
132
142
|
const isDesignMode = __designMode === "design";
|
|
133
143
|
const isHidden = effectiveMode === "hidden";
|
|
134
144
|
const name = (0, import_utils.isString)(propsName) && propsName.includes(".") ? [propsName] : propsName;
|
|
@@ -146,10 +156,23 @@ var withFormItem = (WrappedComponent, otherFormItemProps) => {
|
|
|
146
156
|
...typeobj,
|
|
147
157
|
message: typeobj.message || (0, import_locales.getText)("pisell-data-source-form-email-message")
|
|
148
158
|
});
|
|
149
|
-
}
|
|
159
|
+
}
|
|
160
|
+
if (typeobj.type === "url" && typeobj.enabled) {
|
|
150
161
|
rules.push({
|
|
151
162
|
...typeobj,
|
|
152
|
-
message: typeobj.message || (0, import_locales.getText)("pisell-data-source-form-
|
|
163
|
+
message: typeobj.message || (0, import_locales.getText)("pisell-data-source-form-url-message")
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
if (typeobj.type === "phone" && typeobj.enabled) {
|
|
167
|
+
rules.push({
|
|
168
|
+
validator: (_, value) => {
|
|
169
|
+
var _a2;
|
|
170
|
+
return (0, import_libphonenumber_js.isValidPhoneNumber)(value) && ((_a2 = (0, import_libphonenumber_js.parsePhoneNumberFromString)(value)) == null ? void 0 : _a2.isValid()) ? Promise.resolve() : Promise.reject(
|
|
171
|
+
new Error(
|
|
172
|
+
typeobj.message || (0, import_locales.getText)("pisell-data-source-form-phone-message")
|
|
173
|
+
)
|
|
174
|
+
);
|
|
175
|
+
}
|
|
153
176
|
});
|
|
154
177
|
}
|
|
155
178
|
}
|
|
@@ -202,6 +225,7 @@ var withFormItem = (WrappedComponent, otherFormItemProps) => {
|
|
|
202
225
|
validator,
|
|
203
226
|
validateTrigger,
|
|
204
227
|
labelCol,
|
|
228
|
+
initialValue: otherProps == null ? void 0 : otherProps.defaultValue,
|
|
205
229
|
...otherFormItemProps
|
|
206
230
|
},
|
|
207
231
|
renderComponent
|
|
@@ -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;
|
|
@@ -26,14 +26,30 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
26
|
));
|
|
27
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
28
|
|
|
29
|
-
// src/components/dataSourceComponents/fields/ColorPicker/WithMode.
|
|
29
|
+
// src/components/dataSourceComponents/fields/ColorPicker/WithMode.tsx
|
|
30
30
|
var WithMode_exports = {};
|
|
31
31
|
__export(WithMode_exports, {
|
|
32
32
|
default: () => WithMode_default
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(WithMode_exports);
|
|
35
|
+
var import_react = __toESM(require("react"));
|
|
35
36
|
var import_antd = require("antd");
|
|
37
|
+
var import_colors = require("@ant-design/colors");
|
|
36
38
|
var import_ReadPretty = __toESM(require("./ReadPretty"));
|
|
37
39
|
var import_utils = require("../../dataSourceForm/utils");
|
|
38
|
-
var
|
|
40
|
+
var genPresets = (presets = import_colors.presetPalettes) => Object.entries(presets).map(([label, colors]) => ({
|
|
41
|
+
label,
|
|
42
|
+
colors
|
|
43
|
+
}));
|
|
44
|
+
var ColorPicker = (props) => {
|
|
45
|
+
const { token } = import_antd.theme.useToken();
|
|
46
|
+
const presets = genPresets({
|
|
47
|
+
primary: (0, import_colors.generate)(token.colorPrimary),
|
|
48
|
+
red: import_colors.red,
|
|
49
|
+
green: import_colors.green
|
|
50
|
+
});
|
|
51
|
+
const { renderMode, ...restProps } = props;
|
|
52
|
+
return /* @__PURE__ */ import_react.default.createElement(import_antd.ColorPicker, { ...restProps, presets });
|
|
53
|
+
};
|
|
54
|
+
var ColorPickerWithMode = (0, import_utils.withMode)(ColorPicker, import_ReadPretty.default);
|
|
39
55
|
var WithMode_default = ColorPickerWithMode;
|
|
@@ -33,7 +33,12 @@ __export(ReadPretty_exports, {
|
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(ReadPretty_exports);
|
|
35
35
|
var import_react = __toESM(require("react"));
|
|
36
|
+
var import_utils = require("@pisell/utils");
|
|
36
37
|
var PasswordReadPretty = (props) => {
|
|
37
|
-
|
|
38
|
+
var _a, _b;
|
|
39
|
+
if (props.value && (0, import_utils.isString)(props.value)) {
|
|
40
|
+
return /* @__PURE__ */ import_react.default.createElement("span", null, (_b = (_a = props.value) == null ? void 0 : _a.split) == null ? void 0 : _b.call(_a, "").map(() => "•"));
|
|
41
|
+
}
|
|
42
|
+
return /* @__PURE__ */ import_react.default.createElement("span", null, "••••••");
|
|
38
43
|
};
|
|
39
44
|
var ReadPretty_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;
|
|
@@ -33,7 +33,18 @@ __export(ReadPretty_exports, {
|
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(ReadPretty_exports);
|
|
35
35
|
var import_react = __toESM(require("react"));
|
|
36
|
-
var
|
|
37
|
-
|
|
36
|
+
var import_libphonenumber_js = require("libphonenumber-js");
|
|
37
|
+
var ReadPretty = ({ value }) => {
|
|
38
|
+
if (!value)
|
|
39
|
+
return null;
|
|
40
|
+
try {
|
|
41
|
+
const phoneNumber = (0, import_libphonenumber_js.parsePhoneNumberFromString)(value);
|
|
42
|
+
if (!phoneNumber)
|
|
43
|
+
return /* @__PURE__ */ import_react.default.createElement("span", null, value);
|
|
44
|
+
const formattedValue = `(${phoneNumber.formatInternational().split(" ")[0]}) ${phoneNumber.formatNational()}`;
|
|
45
|
+
return /* @__PURE__ */ import_react.default.createElement("span", null, formattedValue);
|
|
46
|
+
} catch (error) {
|
|
47
|
+
return /* @__PURE__ */ import_react.default.createElement("span", null, value);
|
|
48
|
+
}
|
|
38
49
|
};
|
|
39
|
-
var ReadPretty_default =
|
|
50
|
+
var ReadPretty_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;
|
|
@@ -34,10 +34,105 @@ __export(WithMode_exports, {
|
|
|
34
34
|
module.exports = __toCommonJS(WithMode_exports);
|
|
35
35
|
var import_react = __toESM(require("react"));
|
|
36
36
|
var import_antd = require("antd");
|
|
37
|
+
var import_libphonenumber_js = require("libphonenumber-js");
|
|
38
|
+
var import_useEngineContext = __toESM(require("../../../../hooks/useEngineContext"));
|
|
39
|
+
var import_serve = require("./serve");
|
|
37
40
|
var import_ReadPretty = __toESM(require("./ReadPretty"));
|
|
38
41
|
var import_utils = require("../../dataSourceForm/utils");
|
|
39
|
-
var
|
|
40
|
-
|
|
42
|
+
var { Option } = import_antd.Select;
|
|
43
|
+
var translationOriginal = (val) => val.original;
|
|
44
|
+
var PhoneInput = ({ value, onChange, isVerification, ...props }) => {
|
|
45
|
+
const { data: countries = [] } = (0, import_serve.useCountries)();
|
|
46
|
+
console.log(value, "valuevaluevalue");
|
|
47
|
+
const context = (0, import_useEngineContext.default)();
|
|
48
|
+
translationOriginal = context.appHelper.utils.translationOriginal || translationOriginal;
|
|
49
|
+
const parseExternalValue = (val) => {
|
|
50
|
+
if (!val)
|
|
51
|
+
return { countryCode: "AU", phoneNumber: "" };
|
|
52
|
+
const matchedPrefix = countries.find(
|
|
53
|
+
(country) => val.startsWith(country.prefix)
|
|
54
|
+
);
|
|
55
|
+
if (matchedPrefix) {
|
|
56
|
+
return {
|
|
57
|
+
countryCode: matchedPrefix.code,
|
|
58
|
+
phoneNumber: val.slice(matchedPrefix.prefix.length)
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
return {
|
|
62
|
+
countryCode: "AU",
|
|
63
|
+
phoneNumber: val.replace(/\D/g, "")
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
const [countryCode, setCountryCode] = (0, import_react.useState)(
|
|
67
|
+
() => parseExternalValue(value).countryCode
|
|
68
|
+
);
|
|
69
|
+
const [phoneNumber, setPhoneNumber] = (0, import_react.useState)(
|
|
70
|
+
() => parseExternalValue(value).phoneNumber
|
|
71
|
+
);
|
|
72
|
+
(0, import_react.useEffect)(() => {
|
|
73
|
+
const { countryCode: newCountryCode, phoneNumber: newPhoneNumber } = parseExternalValue(value);
|
|
74
|
+
setCountryCode(newCountryCode);
|
|
75
|
+
setPhoneNumber(newPhoneNumber);
|
|
76
|
+
}, [value, countries]);
|
|
77
|
+
const handleCountryChange = (value2) => {
|
|
78
|
+
setCountryCode(value2);
|
|
79
|
+
};
|
|
80
|
+
const handlePhoneNumberChange = (e) => {
|
|
81
|
+
const cleanNumber = e.target.value.replace(/\D/g, "");
|
|
82
|
+
setPhoneNumber(cleanNumber);
|
|
83
|
+
};
|
|
84
|
+
const concatenatedNumber = (0, import_react.useMemo)(() => {
|
|
85
|
+
const selectedCountry = countries.find(
|
|
86
|
+
(c) => c.code === countryCode
|
|
87
|
+
);
|
|
88
|
+
const prefix = (selectedCountry == null ? void 0 : selectedCountry.prefix) || "";
|
|
89
|
+
return `${prefix}${phoneNumber}`;
|
|
90
|
+
}, [countryCode, phoneNumber, countries]);
|
|
91
|
+
const handleBlur = () => {
|
|
92
|
+
onChange == null ? void 0 : onChange(concatenatedNumber);
|
|
93
|
+
};
|
|
94
|
+
const status = (0, import_react.useMemo)(() => {
|
|
95
|
+
var _a;
|
|
96
|
+
if (!phoneNumber || !isVerification) {
|
|
97
|
+
return void 0;
|
|
98
|
+
}
|
|
99
|
+
return (0, import_libphonenumber_js.isValidPhoneNumber)(concatenatedNumber) && ((_a = (0, import_libphonenumber_js.parsePhoneNumberFromString)(concatenatedNumber)) == null ? void 0 : _a.isValid()) ? void 0 : "error";
|
|
100
|
+
}, [concatenatedNumber, phoneNumber, isVerification]);
|
|
101
|
+
return /* @__PURE__ */ import_react.default.createElement(
|
|
102
|
+
import_antd.Input,
|
|
103
|
+
{
|
|
104
|
+
...props,
|
|
105
|
+
status,
|
|
106
|
+
addonBefore: /* @__PURE__ */ import_react.default.createElement(
|
|
107
|
+
import_antd.Select,
|
|
108
|
+
{
|
|
109
|
+
value: countryCode,
|
|
110
|
+
onChange: handleCountryChange,
|
|
111
|
+
style: { width: "80px" },
|
|
112
|
+
onBlur: handleBlur,
|
|
113
|
+
popupMatchSelectWidth: false,
|
|
114
|
+
optionLabelProp: "label"
|
|
115
|
+
},
|
|
116
|
+
countries.map((country) => /* @__PURE__ */ import_react.default.createElement(
|
|
117
|
+
Option,
|
|
118
|
+
{
|
|
119
|
+
key: country.code,
|
|
120
|
+
value: country.code,
|
|
121
|
+
label: country.prefix
|
|
122
|
+
},
|
|
123
|
+
translationOriginal(country.name),
|
|
124
|
+
" (",
|
|
125
|
+
country.prefix,
|
|
126
|
+
")"
|
|
127
|
+
))
|
|
128
|
+
),
|
|
129
|
+
type: "tel",
|
|
130
|
+
value: phoneNumber,
|
|
131
|
+
onChange: handlePhoneNumberChange,
|
|
132
|
+
onBlur: handleBlur,
|
|
133
|
+
style: { flex: 1 }
|
|
134
|
+
}
|
|
135
|
+
);
|
|
41
136
|
};
|
|
42
|
-
var PhoneWithMode = (0, import_utils.withMode)(
|
|
137
|
+
var PhoneWithMode = (0, import_utils.withMode)(PhoneInput, import_ReadPretty.default);
|
|
43
138
|
var WithMode_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,55 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/components/dataSourceComponents/fields/Input.Phone/serve.ts
|
|
20
|
+
var serve_exports = {};
|
|
21
|
+
__export(serve_exports, {
|
|
22
|
+
getCountryDataList: () => getCountryDataList,
|
|
23
|
+
useCountries: () => useCountries
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(serve_exports);
|
|
26
|
+
var import_ahooks = require("ahooks");
|
|
27
|
+
var import_utils = require("../../../table/utils");
|
|
28
|
+
var getCountryDataList = async () => {
|
|
29
|
+
const { data } = await import_utils.request.getRequest().get(`/country:list`, {}, {
|
|
30
|
+
isNocobase: true,
|
|
31
|
+
fullResult: true,
|
|
32
|
+
headers: {
|
|
33
|
+
"x-data-source": "pisell2"
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
return data.map((item) => ({
|
|
37
|
+
...item,
|
|
38
|
+
prefix: `+${item.calling_code}`
|
|
39
|
+
}));
|
|
40
|
+
};
|
|
41
|
+
var useCountries = () => {
|
|
42
|
+
const { data } = (0, import_ahooks.useRequest)(getCountryDataList, {
|
|
43
|
+
cacheKey: "phone-countries",
|
|
44
|
+
staleTime: 1e3 * 60 * 5,
|
|
45
|
+
// 5分钟后数据过期
|
|
46
|
+
cacheTime: 1e3 * 60 * 60
|
|
47
|
+
// 1小时后清除缓存
|
|
48
|
+
});
|
|
49
|
+
return { data };
|
|
50
|
+
};
|
|
51
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
52
|
+
0 && (module.exports = {
|
|
53
|
+
getCountryDataList,
|
|
54
|
+
useCountries
|
|
55
|
+
});
|
|
@@ -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;
|
|
@@ -33,8 +33,18 @@ __export(ReadPretty_exports, {
|
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(ReadPretty_exports);
|
|
35
35
|
var import_react = __toESM(require("react"));
|
|
36
|
-
var
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
var import_utils = require("./utils");
|
|
37
|
+
var ReadPretty = (props) => {
|
|
38
|
+
const { value, useThousandsSeparator, previewFormatter, precision = 0, addonAfter } = props;
|
|
39
|
+
if (!value && value !== 0) {
|
|
40
|
+
return /* @__PURE__ */ import_react.default.createElement("span", null, "-");
|
|
41
|
+
}
|
|
42
|
+
const formattedValue = (0, import_utils.formatNumberWithUnit)(Number(value), precision, previewFormatter);
|
|
43
|
+
if (useThousandsSeparator && (!previewFormatter || previewFormatter === "none")) {
|
|
44
|
+
const parts = formattedValue.split(".");
|
|
45
|
+
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
46
|
+
return /* @__PURE__ */ import_react.default.createElement("span", null, parts.join("."), addonAfter);
|
|
47
|
+
}
|
|
48
|
+
return /* @__PURE__ */ import_react.default.createElement("span", null, formattedValue, addonAfter);
|
|
39
49
|
};
|
|
40
|
-
var ReadPretty_default =
|
|
50
|
+
var ReadPretty_default = ReadPretty;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
declare const InputNumberWithMode:
|
|
1
|
+
import React from 'react';
|
|
2
|
+
declare const InputNumberWithMode: React.FC<any>;
|
|
3
3
|
export default InputNumberWithMode;
|
|
@@ -26,17 +26,48 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
26
|
));
|
|
27
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
28
|
|
|
29
|
-
// src/components/dataSourceComponents/fields/InputNumber/WithMode.
|
|
29
|
+
// src/components/dataSourceComponents/fields/InputNumber/WithMode.tsx
|
|
30
30
|
var WithMode_exports = {};
|
|
31
31
|
__export(WithMode_exports, {
|
|
32
32
|
default: () => WithMode_default
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(WithMode_exports);
|
|
35
|
+
var import_react = __toESM(require("react"));
|
|
35
36
|
var import_antd = require("antd");
|
|
36
37
|
var import_ReadPretty = __toESM(require("./ReadPretty"));
|
|
37
38
|
var import_utils = require("../../dataSourceForm/utils");
|
|
38
|
-
var
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
var InputNumber = (props) => {
|
|
40
|
+
const {
|
|
41
|
+
useThousandsSeparator,
|
|
42
|
+
formatter: propsFormatter,
|
|
43
|
+
parser: propsParser,
|
|
44
|
+
...rest
|
|
45
|
+
} = props;
|
|
46
|
+
const formatter = (0, import_react.useCallback)(
|
|
47
|
+
(value, info) => {
|
|
48
|
+
if (!value)
|
|
49
|
+
return "";
|
|
50
|
+
if (useThousandsSeparator) {
|
|
51
|
+
const parts = value.toString().split(".");
|
|
52
|
+
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
53
|
+
return parts.join(".");
|
|
54
|
+
}
|
|
55
|
+
return propsFormatter ? propsFormatter(value, info) : value.toString();
|
|
56
|
+
},
|
|
57
|
+
[useThousandsSeparator, propsFormatter]
|
|
58
|
+
);
|
|
59
|
+
const parser = (0, import_react.useCallback)(
|
|
60
|
+
(value) => {
|
|
61
|
+
if (!value)
|
|
62
|
+
return null;
|
|
63
|
+
if (useThousandsSeparator) {
|
|
64
|
+
return value.replace(/,/g, "");
|
|
65
|
+
}
|
|
66
|
+
return propsParser ? propsParser(value) : value;
|
|
67
|
+
},
|
|
68
|
+
[useThousandsSeparator, propsParser]
|
|
69
|
+
);
|
|
70
|
+
return /* @__PURE__ */ import_react.default.createElement(import_antd.InputNumber, { ...rest, formatter, parser });
|
|
71
|
+
};
|
|
72
|
+
var InputNumberWithMode = (0, import_utils.withMode)(InputNumber, import_ReadPretty.default);
|
|
42
73
|
var WithMode_default = InputNumberWithMode;
|
|
@@ -2,4 +2,6 @@ import { InputNumberProps as AntInputNumberProps } from "antd/es/input-number";
|
|
|
2
2
|
import { ModeType } from "../../dataSourceForm/type";
|
|
3
3
|
export interface InputNumberProps extends AntInputNumberProps {
|
|
4
4
|
renderMode: ModeType;
|
|
5
|
+
useThousandsSeparator: boolean;
|
|
6
|
+
previewFormatter?: 'none' | 'thousand' | 'million' | 'billion';
|
|
5
7
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const formatNumberWithUnit: (value: number, precision?: number, previewFormatter?: 'none' | 'thousand' | 'million' | 'billion') => string;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/components/dataSourceComponents/fields/InputNumber/utils.ts
|
|
20
|
+
var utils_exports = {};
|
|
21
|
+
__export(utils_exports, {
|
|
22
|
+
formatNumberWithUnit: () => formatNumberWithUnit
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(utils_exports);
|
|
25
|
+
var import_locales = require("../../../../locales");
|
|
26
|
+
var THOUSAND = 1e3;
|
|
27
|
+
var MILLION = 1e6;
|
|
28
|
+
var BILLION = 1e9;
|
|
29
|
+
var getUnitText = (key) => {
|
|
30
|
+
const textKey = `pisell-number-format-${key}`;
|
|
31
|
+
return (0, import_locales.getText)(textKey);
|
|
32
|
+
};
|
|
33
|
+
var formatNumberWithUnit = (value, precision = 0, previewFormatter) => {
|
|
34
|
+
if (!value)
|
|
35
|
+
return "0";
|
|
36
|
+
const units = {
|
|
37
|
+
billion: {
|
|
38
|
+
value: BILLION,
|
|
39
|
+
getText: () => getUnitText("billion")
|
|
40
|
+
},
|
|
41
|
+
million: {
|
|
42
|
+
value: MILLION,
|
|
43
|
+
getText: () => getUnitText("million")
|
|
44
|
+
},
|
|
45
|
+
thousand: {
|
|
46
|
+
value: THOUSAND,
|
|
47
|
+
getText: () => getUnitText("thousand")
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
if (!previewFormatter || previewFormatter === "none") {
|
|
51
|
+
return value.toFixed(precision);
|
|
52
|
+
}
|
|
53
|
+
const unit = units[previewFormatter];
|
|
54
|
+
if (!unit)
|
|
55
|
+
return value.toFixed(precision);
|
|
56
|
+
const convertedValue = value / unit.value;
|
|
57
|
+
const suffix = unit.getText();
|
|
58
|
+
return `${convertedValue.toFixed(precision)}${suffix}`;
|
|
59
|
+
};
|
|
60
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
61
|
+
0 && (module.exports = {
|
|
62
|
+
formatNumberWithUnit
|
|
63
|
+
});
|