@ticatec/uniface-flexi-module 0.0.8 → 0.0.10
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.
|
@@ -2,5 +2,8 @@ import FlexiCriteriaSet from "./lib/FlexiCriteriaSet";
|
|
|
2
2
|
import FlexiCriteriaField from "./lib/FlexiCriteriaField";
|
|
3
3
|
import CriteriaFieldsPanel from "./CriteriaFieldsPanel.svelte";
|
|
4
4
|
import { registerCriteriaFieldBuilder } from "./lib/CriteriaFieldBuilder";
|
|
5
|
+
import type { FlexiCriteriaSetSchema } from "./lib/FlexiCriteriaSet";
|
|
6
|
+
import type { FlexiCriteriaFieldSchema } from "./lib/FlexiCriteriaField";
|
|
5
7
|
export default CriteriaFieldsPanel;
|
|
6
8
|
export { FlexiCriteriaSet, FlexiCriteriaField, registerCriteriaFieldBuilder };
|
|
9
|
+
export type { FlexiCriteriaSetSchema, FlexiCriteriaFieldSchema };
|
|
@@ -2,6 +2,8 @@ import FlexiCard from "../flexi_card/FlexiCard";
|
|
|
2
2
|
import { Visibility } from "../lib";
|
|
3
3
|
import ComponentBuilder from "../lib/ComponentBuilder";
|
|
4
4
|
import utils from "../lib/utils";
|
|
5
|
+
import i18nRes from "../../i18n-res";
|
|
6
|
+
import i18n, { i18nUtils } from "@ticatec/i18n";
|
|
5
7
|
export default class FlexiField {
|
|
6
8
|
#parent;
|
|
7
9
|
data;
|
|
@@ -26,7 +28,7 @@ export default class FlexiField {
|
|
|
26
28
|
this.variant = schema.variant;
|
|
27
29
|
this.isReadonly = schema.readonly == true;
|
|
28
30
|
this.disabled = schema.disabled == true;
|
|
29
|
-
this.required = schema.required
|
|
31
|
+
this.required = schema.required == true;
|
|
30
32
|
this.#cell = schema.cell;
|
|
31
33
|
const card = parent instanceof FlexiCard ? parent : parent.card;
|
|
32
34
|
if (schema.events) {
|
|
@@ -51,35 +53,36 @@ export default class FlexiField {
|
|
|
51
53
|
let valueType = typeof value;
|
|
52
54
|
if (value == null || (valueType == "string" && value.trim().length == 0)) {
|
|
53
55
|
if (this.required) {
|
|
54
|
-
this.#error =
|
|
56
|
+
this.#error = i18nRes.flexi.validation.textRequired;
|
|
55
57
|
valid = false;
|
|
56
58
|
}
|
|
57
59
|
}
|
|
58
60
|
else {
|
|
59
61
|
if (valueType == "string") { //检查字符串类型
|
|
60
|
-
if (this.#validation?.minLength &&
|
|
61
|
-
this.#error =
|
|
62
|
+
if (this.#validation?.minLength && value.length < this.#validation?.minLength) {
|
|
63
|
+
this.#error = i18nUtils.formatText(i18nRes.flexi.validation.textMinimalRequired, { length: this.#validation.minLength });
|
|
62
64
|
valid = false;
|
|
63
65
|
}
|
|
64
66
|
if (valid && this.#validation?.format) { //如果有正则表达式,检查正则表达式
|
|
65
|
-
|
|
67
|
+
valid = this.#validation.format.regex.test(value);
|
|
68
|
+
if (!valid) {
|
|
66
69
|
this.#error = this.#validation.format.message;
|
|
67
70
|
}
|
|
68
71
|
}
|
|
69
72
|
}
|
|
70
73
|
else if (valueType == "number") { //如果是数字,检查最大/最小值
|
|
71
|
-
if (this.#validation?.minValue &&
|
|
72
|
-
this.#error =
|
|
74
|
+
if (this.#validation?.minValue && value < this.#validation.minValue) {
|
|
75
|
+
this.#error = i18nUtils.formatText(i18nRes.flexi.validation.textMinimumValue, { value: this.#validation.minValue });
|
|
73
76
|
valid = false;
|
|
74
77
|
}
|
|
75
|
-
else if (this.#validation?.maxValue &&
|
|
76
|
-
this.#error =
|
|
78
|
+
else if (this.#validation?.maxValue && value > this.#validation.maxValue) {
|
|
79
|
+
this.#error = i18nUtils.formatText(i18nRes.flexi.validation.textMaximumValue, { value: this.#validation.minValue });
|
|
77
80
|
valid = false;
|
|
78
81
|
}
|
|
79
82
|
}
|
|
80
83
|
}
|
|
81
84
|
if (valid && this.#validation?.check) { //如果有自定义检查,通过自定义方法检查
|
|
82
|
-
const result = this.#validation.check(
|
|
85
|
+
const result = this.#validation.check(value, this.#parent.data);
|
|
83
86
|
if (!result.valid) {
|
|
84
87
|
valid = false;
|
|
85
88
|
this.#error = result.message;
|
package/dist/i18n-res/i18nRes.js
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { i18nUtils } from "@ticatec/i18n";
|
|
2
2
|
const langRes = {
|
|
3
3
|
flexi: {
|
|
4
|
-
validation: {
|
|
4
|
+
validation: {
|
|
5
|
+
textRequired: "Please enter a value",
|
|
6
|
+
textMinimalRequired: "The input must be at least {{len}} characters long.",
|
|
7
|
+
textMinimumValue: "Please enter an integer no less than {{value}}",
|
|
8
|
+
textMaximumValue: "Please enter an integer no more than {{value}}"
|
|
9
|
+
}
|
|
5
10
|
}
|
|
6
11
|
};
|
|
7
12
|
const i18nRes = i18nUtils.createResourceProxy(langRes, 'uniface');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ticatec/uniface-flexi-module",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.10",
|
|
4
4
|
"description": "A flexible form framework for Svelte applications with dynamic field types, criteria panels, and modular components",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"svelte",
|
|
@@ -104,14 +104,14 @@
|
|
|
104
104
|
"@sveltejs/package": "^2.4.1",
|
|
105
105
|
"@sveltejs/vite-plugin-svelte": "^6.1.1",
|
|
106
106
|
"@ticatec/app-data-manager": "^1.2.4",
|
|
107
|
-
"@ticatec/app-data-service": "^1.1.
|
|
107
|
+
"@ticatec/app-data-service": "^1.1.4",
|
|
108
108
|
"@ticatec/enhanced-utils": "^1.0.1",
|
|
109
|
-
"@ticatec/i18n": "^0.2.
|
|
109
|
+
"@ticatec/i18n": "^0.2.3",
|
|
110
110
|
"@ticatec/restful_service_api": "^0.1.7",
|
|
111
|
-
"@ticatec/uniface-app-component": "^0.2.
|
|
111
|
+
"@ticatec/uniface-app-component": "^0.2.3",
|
|
112
112
|
"@ticatec/uniface-dev-shell": "^0.0.6",
|
|
113
113
|
"@ticatec/uniface-element": "^0.3.4",
|
|
114
|
-
"@ticatec/uniface-filter-panel": "^0.1.
|
|
114
|
+
"@ticatec/uniface-filter-panel": "^0.1.1",
|
|
115
115
|
"@ticatec/uniface-google-material-icons": "^0.1.2",
|
|
116
116
|
"@ticatec/uniface-micro-frame": "^0.0.1",
|
|
117
117
|
"@ticatec/web-bean-validator": "^0.1.9",
|