@pisell/materials 1.0.593 → 1.0.595
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 +2 -2
- package/build/lowcode/preview.js +6 -6
- package/build/lowcode/render/default/view.js +22 -22
- package/build/lowcode/view.js +18 -18
- package/es/components/dataSourceComponents/dataSourceForm/utils.js +120 -38
- package/es/components/dataSourceComponents/fields/Input.Mobile/WithMode.d.ts +0 -1
- package/es/components/dataSourceComponents/fields/Input.Mobile/WithMode.js +75 -30
- package/es/components/dataSourceComponents/fields/Input.Mobile/index.js +11 -1
- package/es/components/dataSourceComponents/fields/Input.Phone/WithMode.d.ts +0 -1
- package/es/components/dataSourceComponents/fields/Input.Phone/WithMode.js +73 -19
- package/es/components/dataSourceComponents/fields/Input.Subdomain/WithMode.d.ts +2 -1
- package/es/components/dataSourceComponents/fields/Input.Subdomain/WithMode.js +58 -11
- package/es/components/dataSourceComponents/fields/Input.Subdomain/index.d.ts +2 -1
- package/es/components/dataSourceComponents/fields/Input.Subdomain/index.js +2 -2
- package/es/components/dataSourceComponents/fields/index.d.ts +4 -2
- package/es/components/form/index.js +12 -0
- package/es/components/iconSelect/index.js +3 -1
- package/es/locales/en-US.d.ts +9 -0
- package/es/locales/en-US.js +11 -1
- package/es/locales/zh-CN.d.ts +8 -0
- package/es/locales/zh-CN.js +11 -2
- package/es/locales/zh-TW.d.ts +7 -0
- package/es/locales/zh-TW.js +9 -1
- package/lib/components/dataSourceComponents/dataSourceForm/utils.js +147 -41
- package/lib/components/dataSourceComponents/fields/Input.Mobile/WithMode.d.ts +0 -1
- package/lib/components/dataSourceComponents/fields/Input.Mobile/WithMode.js +31 -26
- package/lib/components/dataSourceComponents/fields/Input.Mobile/index.js +11 -1
- package/lib/components/dataSourceComponents/fields/Input.Phone/WithMode.d.ts +0 -1
- package/lib/components/dataSourceComponents/fields/Input.Phone/WithMode.js +34 -17
- package/lib/components/dataSourceComponents/fields/Input.Subdomain/WithMode.d.ts +2 -1
- package/lib/components/dataSourceComponents/fields/Input.Subdomain/WithMode.js +2 -0
- package/lib/components/dataSourceComponents/fields/Input.Subdomain/index.d.ts +2 -1
- package/lib/components/dataSourceComponents/fields/index.d.ts +4 -2
- package/lib/components/form/index.js +10 -1
- package/lib/components/iconSelect/index.js +2 -1
- package/lib/locales/en-US.d.ts +9 -0
- package/lib/locales/en-US.js +11 -1
- package/lib/locales/zh-CN.d.ts +8 -0
- package/lib/locales/zh-CN.js +11 -2
- package/lib/locales/zh-TW.d.ts +7 -0
- package/lib/locales/zh-TW.js +9 -1
- package/lowcode/_utils/defaultSchema.ts +11 -0
- package/lowcode/form-item-input.mobile/meta.ts +30 -54
- package/lowcode/form-item-input.mobile/snippets.ts +1 -1
- package/lowcode/form-item-input.phone/meta.ts +1 -49
- package/lowcode/form-item-input.subdomain/meta.ts +0 -2
- package/lowcode/form-item-input.subdomain/snippets.ts +8 -9
- package/lowcode/form.item/meta.ts +48 -0
- package/package.json +3 -3
|
@@ -5,7 +5,8 @@ declare const Subdomain: React.FC<import("antd").InputProps & {
|
|
|
5
5
|
rootDomain: "custom" | "xzero" | "saas";
|
|
6
6
|
customDomain?: string | undefined;
|
|
7
7
|
value?: string | undefined;
|
|
8
|
-
isVerification?: boolean | undefined;
|
|
9
8
|
tenantId: string;
|
|
9
|
+
name?: string | undefined;
|
|
10
|
+
fieldKey?: string | undefined;
|
|
10
11
|
} & import("../../dataSourceForm/utils").WithModeProps & import("../../dataSourceForm/utils").WithFormItemProps>;
|
|
11
12
|
export default Subdomain;
|
|
@@ -23,8 +23,9 @@ declare const formFieldMap: {
|
|
|
23
23
|
rootDomain: "custom" | "xzero" | "saas";
|
|
24
24
|
customDomain?: string | undefined;
|
|
25
25
|
value?: string | undefined;
|
|
26
|
-
isVerification?: boolean | undefined;
|
|
27
26
|
tenantId: string;
|
|
27
|
+
name?: string | undefined;
|
|
28
|
+
fieldKey?: string | undefined;
|
|
28
29
|
} & import("../dataSourceForm/utils").WithModeProps & import("../dataSourceForm/utils").WithFormItemProps>;
|
|
29
30
|
};
|
|
30
31
|
FormItemRadio: import("react").FC<{}> & {
|
|
@@ -80,8 +81,9 @@ declare const getFieldComponent: (fieldComponent: string) => import("react").FC<
|
|
|
80
81
|
rootDomain: "custom" | "xzero" | "saas";
|
|
81
82
|
customDomain?: string | undefined;
|
|
82
83
|
value?: string | undefined;
|
|
83
|
-
isVerification?: boolean | undefined;
|
|
84
84
|
tenantId: string;
|
|
85
|
+
name?: string | undefined;
|
|
86
|
+
fieldKey?: string | undefined;
|
|
85
87
|
} & import("../dataSourceForm/utils").WithModeProps & import("../dataSourceForm/utils").WithFormItemProps>;
|
|
86
88
|
}) | import("react").FC<import("./Radio/type").RadioGroupProps & import("../dataSourceForm/utils").WithModeProps> | (import("react").FC<{}> & {
|
|
87
89
|
Group: import("react").FC<import("./Radio/type").RadioGroupProps & import("../dataSourceForm/utils").WithModeProps>;
|
|
@@ -92,6 +92,9 @@ Form.Item = function (props) {
|
|
|
92
92
|
requiredobj = props.requiredobj,
|
|
93
93
|
typeobj = props.typeobj,
|
|
94
94
|
patternobj = props.patternobj,
|
|
95
|
+
subdomainobj = props.subdomainobj,
|
|
96
|
+
phoneobj = props.phoneobj,
|
|
97
|
+
mobileobj = props.mobileobj,
|
|
95
98
|
lenobj = props.lenobj,
|
|
96
99
|
_validator = props.validator;
|
|
97
100
|
var rules = isArr(propsRules) ? propsRules : [];
|
|
@@ -104,6 +107,15 @@ Form.Item = function (props) {
|
|
|
104
107
|
if (patternobj && patternobj.pattern) {
|
|
105
108
|
rules.push(patternobj);
|
|
106
109
|
}
|
|
110
|
+
if (subdomainobj && subdomainobj.subdomain) {
|
|
111
|
+
rules.push(subdomainobj);
|
|
112
|
+
}
|
|
113
|
+
if (phoneobj && phoneobj.phone) {
|
|
114
|
+
rules.push(phoneobj);
|
|
115
|
+
}
|
|
116
|
+
if (mobileobj && mobileobj.mobile) {
|
|
117
|
+
rules.push(mobileobj);
|
|
118
|
+
}
|
|
107
119
|
if (lenobj && (lenobj.max || lenobj.min)) {
|
|
108
120
|
rules.push(lenobj);
|
|
109
121
|
}
|
|
@@ -203,8 +203,10 @@ var IconSelect = function IconSelect(props) {
|
|
|
203
203
|
icon: triggerNode,
|
|
204
204
|
className: "pisell-lowcode-icon-select-button"
|
|
205
205
|
}) : /*#__PURE__*/React.createElement(Button, {
|
|
206
|
-
className: "pisell-lowcode-icon-select-button-text"
|
|
206
|
+
className: "pisell-lowcode-icon-select-button-text",
|
|
207
|
+
size: "large"
|
|
207
208
|
}, getText('pisell-icon-select-select'))), value && !disabled && /*#__PURE__*/React.createElement(Button, {
|
|
209
|
+
size: "large",
|
|
208
210
|
icon: /*#__PURE__*/React.createElement(CloseOutlined, null),
|
|
209
211
|
className: "pisell-lowcode-icon-select-button",
|
|
210
212
|
onClick: function onClick() {
|
package/es/locales/en-US.d.ts
CHANGED
|
@@ -143,6 +143,8 @@ declare const _default: {
|
|
|
143
143
|
'pisell-data-source-form-max-length-message': (maxLength: number) => string;
|
|
144
144
|
'pisell-data-source-form-min-value-message': (minValue: number) => string;
|
|
145
145
|
'pisell-data-source-form-max-value-message': (maxValue: number) => string;
|
|
146
|
+
'pisell-data-source-form-mobile-message': string;
|
|
147
|
+
'pisell-data-source-form-pattern-message': string;
|
|
146
148
|
'pisell-number-format-thousand': string;
|
|
147
149
|
'pisell-number-format-million': string;
|
|
148
150
|
'pisell-number-format-billion': string;
|
|
@@ -194,5 +196,12 @@ declare const _default: {
|
|
|
194
196
|
'pisell-icon-select-iconfont': string;
|
|
195
197
|
'pisell-icon-select-search': string;
|
|
196
198
|
'pisell-icon-select-select': string;
|
|
199
|
+
'subdomain-error-too-short': string;
|
|
200
|
+
'subdomain-error-too-long': string;
|
|
201
|
+
'subdomain-error-pattern': string;
|
|
202
|
+
'subdomain-error-numbers-only': string;
|
|
203
|
+
'subdomain-error-hyphen-ends': string;
|
|
204
|
+
'subdomain-error-consecutive-hyphens': string;
|
|
205
|
+
'subdomain-error-required': string;
|
|
197
206
|
};
|
|
198
207
|
export default _default;
|
package/es/locales/en-US.js
CHANGED
|
@@ -180,6 +180,8 @@ export default {
|
|
|
180
180
|
'pisell-data-source-form-max-value-message': function pisellDataSourceFormMaxValueMessage(maxValue) {
|
|
181
181
|
return "Value must be less than or equal to ".concat(maxValue);
|
|
182
182
|
},
|
|
183
|
+
'pisell-data-source-form-mobile-message': 'Please enter a valid mobile number',
|
|
184
|
+
'pisell-data-source-form-pattern-message': 'Please enter the correct format',
|
|
183
185
|
// Number formatting
|
|
184
186
|
'pisell-number-format-thousand': 'K',
|
|
185
187
|
'pisell-number-format-million': 'M',
|
|
@@ -244,5 +246,13 @@ export default {
|
|
|
244
246
|
'pisell-icon-select-two-tone': 'Two-tone',
|
|
245
247
|
'pisell-icon-select-iconfont': 'Iconfont',
|
|
246
248
|
'pisell-icon-select-search': 'Search icon',
|
|
247
|
-
'pisell-icon-select-select': 'Select icon'
|
|
249
|
+
'pisell-icon-select-select': 'Select icon',
|
|
250
|
+
// 子域名校验错误
|
|
251
|
+
'subdomain-error-too-short': 'Subdomain must be at least 2 characters long',
|
|
252
|
+
'subdomain-error-too-long': 'Subdomain cannot exceed 60 characters',
|
|
253
|
+
'subdomain-error-pattern': 'Subdomain can only contain lowercase letters, numbers and hyphens',
|
|
254
|
+
'subdomain-error-numbers-only': 'Subdomain cannot contain only numbers',
|
|
255
|
+
'subdomain-error-hyphen-ends': 'Subdomain cannot start or end with a hyphen',
|
|
256
|
+
'subdomain-error-consecutive-hyphens': 'Subdomain cannot contain consecutive hyphens',
|
|
257
|
+
'subdomain-error-required': 'Please enter subdomain'
|
|
248
258
|
};
|
package/es/locales/zh-CN.d.ts
CHANGED
|
@@ -143,6 +143,8 @@ declare const _default: {
|
|
|
143
143
|
'pisell-data-source-form-max-length-message': (maxLength: number) => string;
|
|
144
144
|
'pisell-data-source-form-min-value-message': (minValue: number) => string;
|
|
145
145
|
'pisell-data-source-form-max-value-message': (maxValue: number) => string;
|
|
146
|
+
'pisell-data-source-form-mobile-message': string;
|
|
147
|
+
'pisell-data-source-form-pattern-message': string;
|
|
146
148
|
'pisell-number-format-thousand': string;
|
|
147
149
|
'pisell-number-format-million': string;
|
|
148
150
|
'pisell-number-format-billion': string;
|
|
@@ -194,5 +196,11 @@ declare const _default: {
|
|
|
194
196
|
'pisell-icon-select-iconfont': string;
|
|
195
197
|
'pisell-icon-select-search': string;
|
|
196
198
|
'pisell-icon-select-select': string;
|
|
199
|
+
'subdomain-error-too-short': string;
|
|
200
|
+
'subdomain-error-too-long': string;
|
|
201
|
+
'subdomain-error-pattern': string;
|
|
202
|
+
'subdomain-error-numbers-only': string;
|
|
203
|
+
'subdomain-error-hyphen-ends': string;
|
|
204
|
+
'subdomain-error-consecutive-hyphens': string;
|
|
197
205
|
};
|
|
198
206
|
export default _default;
|
package/es/locales/zh-CN.js
CHANGED
|
@@ -166,7 +166,7 @@ export default {
|
|
|
166
166
|
'pisell-data-source-form-email-message': '请输入有效的电子邮件地址',
|
|
167
167
|
'pisell-data-source-form-domain-message': '请输入有效的域名',
|
|
168
168
|
'pisell-data-source-form-url-message': '请输入正确的网址',
|
|
169
|
-
'pisell-data-source-form-phone-message': '
|
|
169
|
+
'pisell-data-source-form-phone-message': '请输入正确的电话号码',
|
|
170
170
|
'pisell-data-source-form-min-length-message': function pisellDataSourceFormMinLengthMessage(minLength) {
|
|
171
171
|
return "\u957F\u5EA6\u5FC5\u987B\u81F3\u5C11\u4E3A".concat(minLength, "\u4E2A\u5B57\u7B26");
|
|
172
172
|
},
|
|
@@ -179,6 +179,8 @@ export default {
|
|
|
179
179
|
'pisell-data-source-form-max-value-message': function pisellDataSourceFormMaxValueMessage(maxValue) {
|
|
180
180
|
return "\u503C\u5FC5\u987B\u5C0F\u4E8E\u6216\u7B49\u4E8E".concat(maxValue);
|
|
181
181
|
},
|
|
182
|
+
'pisell-data-source-form-mobile-message': '请输入正确的手机号',
|
|
183
|
+
'pisell-data-source-form-pattern-message': '请输入正确的格式',
|
|
182
184
|
// 数字格式化
|
|
183
185
|
'pisell-number-format-thousand': '千',
|
|
184
186
|
'pisell-number-format-million': '百万',
|
|
@@ -243,5 +245,12 @@ export default {
|
|
|
243
245
|
'pisell-icon-select-two-tone': '双色风格',
|
|
244
246
|
'pisell-icon-select-iconfont': 'Iconfont',
|
|
245
247
|
'pisell-icon-select-search': '搜索图标',
|
|
246
|
-
'pisell-icon-select-select': '选择图标'
|
|
248
|
+
'pisell-icon-select-select': '选择图标',
|
|
249
|
+
// 子域名校验错误
|
|
250
|
+
'subdomain-error-too-short': '子域名长度不能小于2个字符',
|
|
251
|
+
'subdomain-error-too-long': '子域名长度不能超过60个字符',
|
|
252
|
+
'subdomain-error-pattern': '子域名只能包含小写字母、数字和连字符',
|
|
253
|
+
'subdomain-error-numbers-only': '子域名不能全为数字',
|
|
254
|
+
'subdomain-error-hyphen-ends': '子域名不能以连字符开头或结尾',
|
|
255
|
+
'subdomain-error-consecutive-hyphens': '子域名不能包含连续的连字符'
|
|
247
256
|
};
|
package/es/locales/zh-TW.d.ts
CHANGED
|
@@ -143,6 +143,7 @@ declare const _default: {
|
|
|
143
143
|
'pisell-data-source-form-max-length-message': (maxLength: number) => string;
|
|
144
144
|
'pisell-data-source-form-min-value-message': (minValue: number) => string;
|
|
145
145
|
'pisell-data-source-form-max-value-message': (maxValue: number) => string;
|
|
146
|
+
'pisell-data-source-form-mobile-message': string;
|
|
146
147
|
'pisell-number-format-thousand': string;
|
|
147
148
|
'pisell-number-format-million': string;
|
|
148
149
|
'pisell-number-format-billion': string;
|
|
@@ -194,5 +195,11 @@ declare const _default: {
|
|
|
194
195
|
'pisell-icon-select-iconfont': string;
|
|
195
196
|
'pisell-icon-select-search': string;
|
|
196
197
|
'pisell-icon-select-select': string;
|
|
198
|
+
'subdomain-error-too-short': string;
|
|
199
|
+
'subdomain-error-too-long': string;
|
|
200
|
+
'subdomain-error-pattern': string;
|
|
201
|
+
'subdomain-error-numbers-only': string;
|
|
202
|
+
'subdomain-error-hyphen-ends': string;
|
|
203
|
+
'subdomain-error-consecutive-hyphens': string;
|
|
197
204
|
};
|
|
198
205
|
export default _default;
|
package/es/locales/zh-TW.js
CHANGED
|
@@ -180,6 +180,7 @@ export default {
|
|
|
180
180
|
'pisell-data-source-form-max-value-message': function pisellDataSourceFormMaxValueMessage(maxValue) {
|
|
181
181
|
return "\u503C\u5FC5\u9808\u5C0F\u65BC\u6216\u7B49\u65BC".concat(maxValue);
|
|
182
182
|
},
|
|
183
|
+
'pisell-data-source-form-mobile-message': '請輸入正確的手機號',
|
|
183
184
|
// 數字格式化
|
|
184
185
|
'pisell-number-format-thousand': '千',
|
|
185
186
|
'pisell-number-format-million': '百萬',
|
|
@@ -244,5 +245,12 @@ export default {
|
|
|
244
245
|
'pisell-icon-select-two-tone': '雙色風格',
|
|
245
246
|
'pisell-icon-select-iconfont': 'Iconfont',
|
|
246
247
|
'pisell-icon-select-search': '搜索圖標',
|
|
247
|
-
'pisell-icon-select-select': '選擇圖標'
|
|
248
|
+
'pisell-icon-select-select': '選擇圖標',
|
|
249
|
+
// 子域名校验错误
|
|
250
|
+
'subdomain-error-too-short': '子域名長度不能小於2個字符',
|
|
251
|
+
'subdomain-error-too-long': '子域名長度不能超過60個字符',
|
|
252
|
+
'subdomain-error-pattern': '子域名只能包含小寫字母、數字和連字符',
|
|
253
|
+
'subdomain-error-numbers-only': '子域名不能全為數字',
|
|
254
|
+
'subdomain-error-hyphen-ends': '子域名不能以連字符開頭或結尾',
|
|
255
|
+
'subdomain-error-consecutive-hyphens': '子域名不能包含連續的連字符'
|
|
248
256
|
};
|
|
@@ -119,6 +119,8 @@ var withFormItem = (WrappedComponent, overlayProps) => {
|
|
|
119
119
|
...otherProps
|
|
120
120
|
}) => {
|
|
121
121
|
var _a;
|
|
122
|
+
console.log("withFormItem typeobj:", typeobj);
|
|
123
|
+
console.log("withFormItem overlayProps:", overlayProps);
|
|
122
124
|
const { path: prefixPath = [] } = (0, import_useJsonPrefixPath.default)();
|
|
123
125
|
const { dataSource } = (0, import_useDataSource.default)();
|
|
124
126
|
const { fields } = dataSource || {};
|
|
@@ -126,6 +128,7 @@ var withFormItem = (WrappedComponent, overlayProps) => {
|
|
|
126
128
|
const field = fields == null ? void 0 : fields.find((item) => item.name === propsName);
|
|
127
129
|
const label = propsLabel || ((_a = field == null ? void 0 : field.uiSchema) == null ? void 0 : _a.title) || propsName;
|
|
128
130
|
const effectiveMode = propsRenderMode || globalRenderMode;
|
|
131
|
+
const name = (0, import_utils.isString)(propsName) && propsName.includes(".") ? [propsName] : propsName;
|
|
129
132
|
const renderComponent = (0, import_react.useMemo)(() => {
|
|
130
133
|
var _a2;
|
|
131
134
|
return /* @__PURE__ */ import_react.default.createElement(
|
|
@@ -139,6 +142,7 @@ var withFormItem = (WrappedComponent, overlayProps) => {
|
|
|
139
142
|
...innerStyle || {},
|
|
140
143
|
...((_a2 = overlayProps == null ? void 0 : overlayProps.innerProps) == null ? void 0 : _a2.style) || {}
|
|
141
144
|
},
|
|
145
|
+
fieldKey: name,
|
|
142
146
|
isVerification: typeobj == null ? void 0 : typeobj.enabled,
|
|
143
147
|
size
|
|
144
148
|
}
|
|
@@ -150,11 +154,11 @@ var withFormItem = (WrappedComponent, overlayProps) => {
|
|
|
150
154
|
overlayProps == null ? void 0 : overlayProps.innerProps,
|
|
151
155
|
typeobj == null ? void 0 : typeobj.enabled,
|
|
152
156
|
size,
|
|
153
|
-
innerStyle
|
|
157
|
+
innerStyle,
|
|
158
|
+
name
|
|
154
159
|
]);
|
|
155
160
|
const isDesignMode = __designMode === "design";
|
|
156
161
|
const isHidden = effectiveMode === "hidden";
|
|
157
|
-
const name = (0, import_utils.isString)(propsName) && propsName.includes(".") ? [propsName] : propsName;
|
|
158
162
|
const concatName = name !== void 0 ? [...prefixPath, ...toArr(name)] : void 0;
|
|
159
163
|
const rules = [];
|
|
160
164
|
if (requiredobj && requiredobj.required) {
|
|
@@ -163,45 +167,146 @@ var withFormItem = (WrappedComponent, overlayProps) => {
|
|
|
163
167
|
message: requiredobj.message || (0, import_locales.getText)("pisell-data-source-form-required-message")
|
|
164
168
|
});
|
|
165
169
|
}
|
|
170
|
+
console.log("%c [ typeobj ]-197", "font-size:13px; background:#6c2f3e; color:#b07382;", typeobj);
|
|
166
171
|
if (typeobj && typeobj.enabled) {
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
172
|
+
console.log("Type validation object:", typeobj);
|
|
173
|
+
console.log("Validation enabled:", typeobj.enabled);
|
|
174
|
+
console.log("Validation type:", typeobj.type);
|
|
175
|
+
switch (typeobj.type) {
|
|
176
|
+
case "email":
|
|
177
|
+
rules.push({
|
|
178
|
+
...typeobj,
|
|
179
|
+
message: typeobj.message || (0, import_locales.getText)("pisell-data-source-form-email-message")
|
|
180
|
+
});
|
|
181
|
+
break;
|
|
182
|
+
case "pattern":
|
|
183
|
+
rules.push({
|
|
184
|
+
...typeobj,
|
|
185
|
+
pattern: new RegExp(typeobj.pattern),
|
|
186
|
+
message: typeobj.message || (0, import_locales.getText)("pisell-data-source-form-pattern-message")
|
|
187
|
+
});
|
|
188
|
+
break;
|
|
189
|
+
case "phone":
|
|
190
|
+
rules.push({
|
|
191
|
+
...typeobj,
|
|
192
|
+
validator: (_, value) => {
|
|
193
|
+
if (!(value == null ? void 0 : value.trim())) {
|
|
194
|
+
return Promise.resolve();
|
|
195
|
+
}
|
|
196
|
+
try {
|
|
197
|
+
const cleanedNumber2 = value.replace(/\s|\(|\)/g, "");
|
|
198
|
+
const parsedNumber = (0, import_libphonenumber_js.parsePhoneNumberFromString)(cleanedNumber2);
|
|
199
|
+
if (!(parsedNumber == null ? void 0 : parsedNumber.isValid())) {
|
|
200
|
+
return Promise.reject(
|
|
201
|
+
new Error(
|
|
202
|
+
typeobj.message || (0, import_locales.getText)("pisell-data-source-form-phone-message")
|
|
203
|
+
)
|
|
204
|
+
);
|
|
205
|
+
}
|
|
206
|
+
return Promise.resolve();
|
|
207
|
+
} catch (error) {
|
|
208
|
+
return Promise.reject(
|
|
209
|
+
new Error(
|
|
210
|
+
typeobj.message || (0, import_locales.getText)("pisell-data-source-form-phone-message")
|
|
211
|
+
)
|
|
212
|
+
);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
break;
|
|
217
|
+
case "mobile":
|
|
218
|
+
rules.push({
|
|
219
|
+
...typeobj,
|
|
220
|
+
validator: (_, value) => {
|
|
221
|
+
if (!(value == null ? void 0 : value.trim())) {
|
|
222
|
+
return Promise.resolve();
|
|
223
|
+
}
|
|
224
|
+
try {
|
|
225
|
+
const cleanedNumber2 = value.replace(/\s|\(|\)/g, "");
|
|
226
|
+
if (cleanedNumber2.length > 15) {
|
|
227
|
+
return Promise.reject(
|
|
228
|
+
new Error(
|
|
229
|
+
typeobj.message || (0, import_locales.getText)("pisell-data-source-form-mobile-message")
|
|
230
|
+
)
|
|
231
|
+
);
|
|
232
|
+
}
|
|
233
|
+
if (cleanedNumber2.startsWith("+61")) {
|
|
234
|
+
const numberWithoutPrefix = cleanedNumber2.slice(3);
|
|
235
|
+
if (!/^(04\d{8}|\d{9})$/.test(numberWithoutPrefix)) {
|
|
236
|
+
return Promise.reject(
|
|
237
|
+
new Error(
|
|
238
|
+
typeobj.message || (0, import_locales.getText)("pisell-data-source-form-mobile-message")
|
|
239
|
+
)
|
|
240
|
+
);
|
|
241
|
+
}
|
|
242
|
+
} else if (cleanedNumber2.startsWith("+86")) {
|
|
243
|
+
const numberWithoutPrefix = cleanedNumber2.slice(3);
|
|
244
|
+
if (!/^1[3-9]\d{9}$/.test(numberWithoutPrefix)) {
|
|
245
|
+
return Promise.reject(
|
|
246
|
+
new Error(
|
|
247
|
+
typeobj.message || (0, import_locales.getText)("pisell-data-source-form-mobile-message")
|
|
248
|
+
)
|
|
249
|
+
);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
return Promise.resolve();
|
|
253
|
+
} catch (error) {
|
|
254
|
+
if (cleanedNumber.length > 15) {
|
|
255
|
+
return Promise.reject(
|
|
256
|
+
new Error(
|
|
257
|
+
typeobj.message || (0, import_locales.getText)("pisell-data-source-form-mobile-message")
|
|
258
|
+
)
|
|
259
|
+
);
|
|
260
|
+
}
|
|
261
|
+
return Promise.resolve();
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
break;
|
|
266
|
+
case "subdomain":
|
|
267
|
+
rules.push({
|
|
268
|
+
...typeobj,
|
|
269
|
+
validator: (_, value) => {
|
|
270
|
+
if (!value)
|
|
271
|
+
return Promise.resolve();
|
|
272
|
+
const subdomain = value.split(".")[0];
|
|
273
|
+
if (!subdomain) {
|
|
274
|
+
return Promise.resolve();
|
|
275
|
+
}
|
|
276
|
+
if (subdomain.length < 2) {
|
|
277
|
+
return Promise.reject(
|
|
278
|
+
new Error((0, import_locales.getText)("subdomain-error-too-short"))
|
|
279
|
+
);
|
|
280
|
+
}
|
|
281
|
+
if (subdomain.length > 60) {
|
|
282
|
+
return Promise.reject(
|
|
283
|
+
new Error((0, import_locales.getText)("subdomain-error-too-long"))
|
|
284
|
+
);
|
|
285
|
+
}
|
|
286
|
+
if (!/^[a-z0-9-]+$/.test(subdomain)) {
|
|
287
|
+
return Promise.reject(
|
|
288
|
+
new Error((0, import_locales.getText)("subdomain-error-pattern"))
|
|
289
|
+
);
|
|
290
|
+
}
|
|
291
|
+
if (/^\d+$/.test(subdomain)) {
|
|
292
|
+
return Promise.reject(
|
|
293
|
+
new Error((0, import_locales.getText)("subdomain-error-numbers-only"))
|
|
294
|
+
);
|
|
295
|
+
}
|
|
296
|
+
if (subdomain.startsWith("-") || subdomain.endsWith("-")) {
|
|
297
|
+
return Promise.reject(
|
|
298
|
+
new Error((0, import_locales.getText)("subdomain-error-hyphen-ends"))
|
|
299
|
+
);
|
|
300
|
+
}
|
|
301
|
+
if (subdomain.includes("--")) {
|
|
302
|
+
return Promise.reject(
|
|
303
|
+
new Error((0, import_locales.getText)("subdomain-error-consecutive-hyphens"))
|
|
304
|
+
);
|
|
305
|
+
}
|
|
306
|
+
return Promise.resolve();
|
|
307
|
+
}
|
|
308
|
+
});
|
|
309
|
+
break;
|
|
205
310
|
}
|
|
206
311
|
}
|
|
207
312
|
if (maxLengthobj && maxLengthobj.enabled) {
|
|
@@ -281,6 +386,7 @@ var withFormItem = (WrappedComponent, overlayProps) => {
|
|
|
281
386
|
}
|
|
282
387
|
return propsLabelCol;
|
|
283
388
|
}, [hideLabel, propsLabelCol]);
|
|
389
|
+
console.log("%c [ rules ]-487", "font-size:13px; background:#29ea5f; color:#6dffa3;", rules);
|
|
284
390
|
return /* @__PURE__ */ import_react.default.createElement(
|
|
285
391
|
import_form.default.Item,
|
|
286
392
|
{
|
|
@@ -299,7 +405,7 @@ var withFormItem = (WrappedComponent, overlayProps) => {
|
|
|
299
405
|
rules,
|
|
300
406
|
normalize,
|
|
301
407
|
getValueProps,
|
|
302
|
-
validateTrigger,
|
|
408
|
+
validateTrigger: validateTrigger || ["onChange", "onBlur"],
|
|
303
409
|
labelCol,
|
|
304
410
|
initialValue: otherProps == null ? void 0 : otherProps.defaultValue,
|
|
305
411
|
className: (0, import_classnames.default)("pisell-data-source-form-item", {
|
|
@@ -5,7 +5,6 @@ export interface PhoneInputProps extends Omit<InputProps, 'value' | 'onChange'>
|
|
|
5
5
|
renderMode: ModeType;
|
|
6
6
|
value?: string;
|
|
7
7
|
onChange?: (value: string) => void;
|
|
8
|
-
isVerification?: boolean;
|
|
9
8
|
}
|
|
10
9
|
declare const MobileNumberInputWithMode: React.FC<PhoneInputProps & import("../../dataSourceForm/utils").WithModeProps>;
|
|
11
10
|
export default MobileNumberInputWithMode;
|
|
@@ -41,7 +41,7 @@ var import_ReadPretty = __toESM(require("./ReadPretty"));
|
|
|
41
41
|
var import_utils2 = require("../../dataSourceForm/utils");
|
|
42
42
|
var import_useTranslationOriginal = __toESM(require("../../../../hooks/useTranslationOriginal"));
|
|
43
43
|
var { Option } = import_select.default;
|
|
44
|
-
var MobileNumberInput = ({ value: propsValue, onChange,
|
|
44
|
+
var MobileNumberInput = ({ value: propsValue, onChange, disabled, ...props }) => {
|
|
45
45
|
const { data: countries = [] } = (0, import_serve.useCountries)();
|
|
46
46
|
const translationOriginal = (0, import_useTranslationOriginal.default)();
|
|
47
47
|
const value = (0, import_react.useMemo)(() => {
|
|
@@ -80,10 +80,38 @@ var MobileNumberInput = ({ value: propsValue, onChange, isVerification, disabled
|
|
|
80
80
|
}, [value, countries]);
|
|
81
81
|
const handleCountryChange = (value2) => {
|
|
82
82
|
setCountryCode(value2);
|
|
83
|
+
const selectedCountry = countries.find(
|
|
84
|
+
(c) => c.code === value2
|
|
85
|
+
);
|
|
86
|
+
const prefix = (selectedCountry == null ? void 0 : selectedCountry.prefix) || "";
|
|
87
|
+
const newValue = `${prefix}${phoneNumber}`;
|
|
88
|
+
onChange == null ? void 0 : onChange(newValue);
|
|
89
|
+
setTimeout(() => {
|
|
90
|
+
const formInstance = props.form;
|
|
91
|
+
const fieldName = props.fieldKey;
|
|
92
|
+
if (formInstance && fieldName) {
|
|
93
|
+
formInstance.validateFields([fieldName]);
|
|
94
|
+
}
|
|
95
|
+
});
|
|
83
96
|
};
|
|
84
97
|
const handlePhoneNumberChange = (e) => {
|
|
85
98
|
const cleanNumber = e.target.value.replace(/\D/g, "");
|
|
86
99
|
setPhoneNumber(cleanNumber);
|
|
100
|
+
const selectedCountry = countries.find(
|
|
101
|
+
(c) => c.code === countryCode
|
|
102
|
+
);
|
|
103
|
+
const prefix = (selectedCountry == null ? void 0 : selectedCountry.prefix) || "";
|
|
104
|
+
const newValue = cleanNumber ? `${prefix}${cleanNumber}` : "";
|
|
105
|
+
onChange == null ? void 0 : onChange(newValue);
|
|
106
|
+
if (!cleanNumber) {
|
|
107
|
+
setTimeout(() => {
|
|
108
|
+
const formInstance = props.form;
|
|
109
|
+
const fieldName = props.fieldKey;
|
|
110
|
+
if (formInstance && fieldName) {
|
|
111
|
+
formInstance.validateFields([fieldName]);
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
}
|
|
87
115
|
};
|
|
88
116
|
const concatenatedNumber = (0, import_react.useMemo)(() => {
|
|
89
117
|
const selectedCountry = countries.find(
|
|
@@ -96,30 +124,9 @@ var MobileNumberInput = ({ value: propsValue, onChange, isVerification, disabled
|
|
|
96
124
|
return `${prefix}${phoneNumber}`;
|
|
97
125
|
}, [countryCode, phoneNumber, countries]);
|
|
98
126
|
const handleBlur = () => {
|
|
99
|
-
|
|
127
|
+
const finalValue = concatenatedNumber;
|
|
128
|
+
onChange == null ? void 0 : onChange(finalValue);
|
|
100
129
|
};
|
|
101
|
-
const status = (0, import_react.useMemo)(() => {
|
|
102
|
-
if (!phoneNumber || !isVerification) {
|
|
103
|
-
return void 0;
|
|
104
|
-
}
|
|
105
|
-
if (countryCode === "AU") {
|
|
106
|
-
const auRegex = /^(04\d{8}|\d{9})$/.test(phoneNumber);
|
|
107
|
-
if (!auRegex) {
|
|
108
|
-
return "error";
|
|
109
|
-
}
|
|
110
|
-
} else if (countryCode === "CN") {
|
|
111
|
-
const cnRegex = /^1\d{10}$/.test(phoneNumber);
|
|
112
|
-
if (!cnRegex) {
|
|
113
|
-
return "error";
|
|
114
|
-
}
|
|
115
|
-
} else {
|
|
116
|
-
const otherRegex = /^\d{1,15}$/.test(phoneNumber);
|
|
117
|
-
if (!otherRegex) {
|
|
118
|
-
return "error";
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
return void 0;
|
|
122
|
-
}, [concatenatedNumber, phoneNumber, isVerification, countryCode]);
|
|
123
130
|
return /* @__PURE__ */ import_react.default.createElement(import_antd.Space.Compact, { block: true }, /* @__PURE__ */ import_react.default.createElement(
|
|
124
131
|
import_select.default,
|
|
125
132
|
{
|
|
@@ -127,7 +134,6 @@ var MobileNumberInput = ({ value: propsValue, onChange, isVerification, disabled
|
|
|
127
134
|
value: countryCode,
|
|
128
135
|
onChange: handleCountryChange,
|
|
129
136
|
style: { width: "90px" },
|
|
130
|
-
onBlur: handleBlur,
|
|
131
137
|
popupMatchSelectWidth: false,
|
|
132
138
|
optionLabelProp: "inputValue",
|
|
133
139
|
optionFilterProp: "label",
|
|
@@ -143,7 +149,6 @@ var MobileNumberInput = ({ value: propsValue, onChange, isVerification, disabled
|
|
|
143
149
|
{
|
|
144
150
|
...props,
|
|
145
151
|
disabled,
|
|
146
|
-
status,
|
|
147
152
|
type: "tel",
|
|
148
153
|
value: phoneNumber,
|
|
149
154
|
onChange: handlePhoneNumberChange,
|
|
@@ -34,5 +34,15 @@ __export(Input_exports, {
|
|
|
34
34
|
module.exports = __toCommonJS(Input_exports);
|
|
35
35
|
var import_utils = require("../../dataSourceForm/utils");
|
|
36
36
|
var import_WithMode = __toESM(require("./WithMode"));
|
|
37
|
-
var Mobile = (0, import_utils.withFormItem)(import_WithMode.default
|
|
37
|
+
var Mobile = (0, import_utils.withFormItem)(import_WithMode.default, {
|
|
38
|
+
otherFormItemProps: {
|
|
39
|
+
validateTrigger: ["onChange", "onBlur"]
|
|
40
|
+
},
|
|
41
|
+
innerProps: {
|
|
42
|
+
typeobj: {
|
|
43
|
+
type: "mobile",
|
|
44
|
+
enabled: true
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
});
|
|
38
48
|
var Input_default = Mobile;
|
|
@@ -5,7 +5,6 @@ export interface PhoneInputProps extends Omit<InputProps, 'value' | 'onChange'>
|
|
|
5
5
|
renderMode: ModeType;
|
|
6
6
|
value?: string;
|
|
7
7
|
onChange?: (value: string) => void;
|
|
8
|
-
isVerification?: boolean;
|
|
9
8
|
}
|
|
10
9
|
declare const PhoneNumberInputWithMode: React.FC<PhoneInputProps & import("../../dataSourceForm/utils").WithModeProps>;
|
|
11
10
|
export default PhoneNumberInputWithMode;
|