@pisell/materials 1.0.474 → 1.0.476
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 +142 -142
- package/build/lowcode/render/default/view.js +25 -25
- package/build/lowcode/view.js +24 -24
- 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/dataSourceTable/hooks/useDrawerState.d.ts +25 -12
- package/es/components/dataSourceComponents/dataSourceTable/hooks/useDrawerState.js +14 -3
- 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/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/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/dataSourceTable/hooks/useDrawerState.d.ts +25 -12
- package/lib/components/dataSourceComponents/dataSourceTable/hooks/useDrawerState.js +18 -2
- 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/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/meta.ts +1 -2
- package/lowcode/data-source-table/utils.tsx +11 -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 +5 -3
|
@@ -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
|
+
});
|
package/lib/locales/en-US.d.ts
CHANGED
|
@@ -135,10 +135,14 @@ declare const _default: {
|
|
|
135
135
|
'pisell-record-view-unavailable': string;
|
|
136
136
|
'pisell-data-source-form-required-message': string;
|
|
137
137
|
'pisell-data-source-form-email-message': string;
|
|
138
|
+
'pisell-data-source-form-url-message': string;
|
|
138
139
|
'pisell-data-source-form-phone-message': string;
|
|
139
140
|
'pisell-data-source-form-min-length-message': (minLength: number) => string;
|
|
140
141
|
'pisell-data-source-form-max-length-message': (maxLength: number) => string;
|
|
141
142
|
'pisell-data-source-form-min-value-message': (minValue: number) => string;
|
|
142
143
|
'pisell-data-source-form-max-value-message': (maxValue: number) => string;
|
|
144
|
+
'pisell-number-format-thousand': string;
|
|
145
|
+
'pisell-number-format-million': string;
|
|
146
|
+
'pisell-number-format-billion': string;
|
|
143
147
|
};
|
|
144
148
|
export default _default;
|
package/lib/locales/en-US.js
CHANGED
|
@@ -170,9 +170,14 @@ var en_US_default = {
|
|
|
170
170
|
"pisell-record-view-unavailable": "No available",
|
|
171
171
|
"pisell-data-source-form-required-message": "This field is required",
|
|
172
172
|
"pisell-data-source-form-email-message": "Please enter a valid email address",
|
|
173
|
+
"pisell-data-source-form-url-message": "Please enter a valid URL",
|
|
173
174
|
"pisell-data-source-form-phone-message": "Please enter a valid phone number",
|
|
174
175
|
"pisell-data-source-form-min-length-message": (minLength) => `Length must be at least ${minLength} character`,
|
|
175
176
|
"pisell-data-source-form-max-length-message": (maxLength) => `Length must be at most ${maxLength} character`,
|
|
176
177
|
"pisell-data-source-form-min-value-message": (minValue) => `Value must be greater than or equal to ${minValue}`,
|
|
177
|
-
"pisell-data-source-form-max-value-message": (maxValue) => `Value must be less than or equal to ${maxValue}
|
|
178
|
+
"pisell-data-source-form-max-value-message": (maxValue) => `Value must be less than or equal to ${maxValue}`,
|
|
179
|
+
// Number formatting
|
|
180
|
+
"pisell-number-format-thousand": "K",
|
|
181
|
+
"pisell-number-format-million": "M",
|
|
182
|
+
"pisell-number-format-billion": "B"
|
|
178
183
|
};
|
package/lib/locales/zh-CN.d.ts
CHANGED
|
@@ -135,10 +135,14 @@ declare const _default: {
|
|
|
135
135
|
'pisell-record-view-unavailable': string;
|
|
136
136
|
'pisell-data-source-form-required-message': string;
|
|
137
137
|
'pisell-data-source-form-email-message': string;
|
|
138
|
+
'pisell-data-source-form-url-message': string;
|
|
138
139
|
'pisell-data-source-form-phone-message': string;
|
|
139
140
|
'pisell-data-source-form-min-length-message': (minLength: number) => string;
|
|
140
141
|
'pisell-data-source-form-max-length-message': (maxLength: number) => string;
|
|
141
142
|
'pisell-data-source-form-min-value-message': (minValue: number) => string;
|
|
142
143
|
'pisell-data-source-form-max-value-message': (maxValue: number) => string;
|
|
144
|
+
'pisell-number-format-thousand': string;
|
|
145
|
+
'pisell-number-format-million': string;
|
|
146
|
+
'pisell-number-format-billion': string;
|
|
143
147
|
};
|
|
144
148
|
export default _default;
|
package/lib/locales/zh-CN.js
CHANGED
|
@@ -169,9 +169,14 @@ var zh_CN_default = {
|
|
|
169
169
|
"pisell-record-view-unavailable": "不可用",
|
|
170
170
|
"pisell-data-source-form-required-message": "该字段为必填项",
|
|
171
171
|
"pisell-data-source-form-email-message": "请输入有效的电子邮件地址",
|
|
172
|
+
"pisell-data-source-form-url-message": "请输入正确的网址",
|
|
172
173
|
"pisell-data-source-form-phone-message": "请输入有效的电话号码",
|
|
173
174
|
"pisell-data-source-form-min-length-message": (minLength) => `长度必须至少为${minLength}个字符`,
|
|
174
175
|
"pisell-data-source-form-max-length-message": (maxLength) => `长度必须最多为${maxLength}个字符`,
|
|
175
176
|
"pisell-data-source-form-min-value-message": (minValue) => `值必须大于或等于${minValue}`,
|
|
176
|
-
"pisell-data-source-form-max-value-message": (maxValue) => `值必须小于或等于${maxValue}
|
|
177
|
+
"pisell-data-source-form-max-value-message": (maxValue) => `值必须小于或等于${maxValue}`,
|
|
178
|
+
// 数字格式化
|
|
179
|
+
"pisell-number-format-thousand": "千",
|
|
180
|
+
"pisell-number-format-million": "百万",
|
|
181
|
+
"pisell-number-format-billion": "十亿"
|
|
177
182
|
};
|
package/lib/locales/zh-TW.d.ts
CHANGED
|
@@ -135,10 +135,14 @@ declare const _default: {
|
|
|
135
135
|
'pisell-record-view-unavailable': string;
|
|
136
136
|
'pisell-data-source-form-required-message': string;
|
|
137
137
|
'pisell-data-source-form-email-message': string;
|
|
138
|
+
'pisell-data-source-form-url-message': string;
|
|
138
139
|
'pisell-data-source-form-phone-message': string;
|
|
139
140
|
'pisell-data-source-form-min-length-message': (minLength: number) => string;
|
|
140
141
|
'pisell-data-source-form-max-length-message': (maxLength: number) => string;
|
|
141
142
|
'pisell-data-source-form-min-value-message': (minValue: number) => string;
|
|
142
143
|
'pisell-data-source-form-max-value-message': (maxValue: number) => string;
|
|
144
|
+
'pisell-number-format-thousand': string;
|
|
145
|
+
'pisell-number-format-million': string;
|
|
146
|
+
'pisell-number-format-billion': string;
|
|
143
147
|
};
|
|
144
148
|
export default _default;
|
package/lib/locales/zh-TW.js
CHANGED
|
@@ -170,9 +170,14 @@ var zh_TW_default = {
|
|
|
170
170
|
"pisell-record-view-unavailable": "不可用",
|
|
171
171
|
"pisell-data-source-form-required-message": "該字段為必填項",
|
|
172
172
|
"pisell-data-source-form-email-message": "請輸入有效的電子郵件地址",
|
|
173
|
+
"pisell-data-source-form-url-message": "請輸入正確的網址",
|
|
173
174
|
"pisell-data-source-form-phone-message": "請輸入有效的電話號碼",
|
|
174
175
|
"pisell-data-source-form-min-length-message": (minLength) => `長度必須至少為${minLength}个字符`,
|
|
175
176
|
"pisell-data-source-form-max-length-message": (maxLength) => `長度必須最多為${maxLength}个字符`,
|
|
176
177
|
"pisell-data-source-form-min-value-message": (minValue) => `值必須大於或等於${minValue}`,
|
|
177
|
-
"pisell-data-source-form-max-value-message": (maxValue) => `值必須小於或等於${maxValue}
|
|
178
|
+
"pisell-data-source-form-max-value-message": (maxValue) => `值必須小於或等於${maxValue}`,
|
|
179
|
+
// 數字格式化
|
|
180
|
+
"pisell-number-format-thousand": "千",
|
|
181
|
+
"pisell-number-format-million": "百萬",
|
|
182
|
+
"pisell-number-format-billion": "十億"
|
|
178
183
|
};
|
|
@@ -10,7 +10,7 @@ export default [
|
|
|
10
10
|
style: {
|
|
11
11
|
padding: '24px',
|
|
12
12
|
},
|
|
13
|
-
|
|
13
|
+
renderMode: 'add',
|
|
14
14
|
groupInfoPosition: 'top',
|
|
15
15
|
labelWrap: true,
|
|
16
16
|
layout: 'vertical',
|
|
@@ -55,7 +55,7 @@ export default [
|
|
|
55
55
|
style: {
|
|
56
56
|
padding: '24px',
|
|
57
57
|
},
|
|
58
|
-
|
|
58
|
+
renderMode: 'edit',
|
|
59
59
|
groupInfoPosition: 'top',
|
|
60
60
|
labelWrap: true,
|
|
61
61
|
layout: 'vertical',
|
|
@@ -101,7 +101,7 @@ export default [
|
|
|
101
101
|
style: {
|
|
102
102
|
padding: '24px',
|
|
103
103
|
},
|
|
104
|
-
|
|
104
|
+
renderMode: 'view',
|
|
105
105
|
groupInfoPosition: 'top',
|
|
106
106
|
labelWrap: true,
|
|
107
107
|
layout: 'vertical',
|