@tachybase/schema 0.23.41 → 0.23.48
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/lib/core/effects/index.d.ts +2 -0
- package/lib/core/effects/index.js +23 -0
- package/lib/core/effects/onFieldEffects.d.ts +27 -0
- package/lib/core/effects/onFieldEffects.js +158 -0
- package/lib/core/effects/onFormEffects.d.ts +24 -0
- package/lib/core/effects/onFormEffects.js +117 -0
- package/lib/core/global.d.js +0 -0
- package/lib/core/index.d.ts +4 -0
- package/lib/core/index.js +27 -0
- package/lib/core/models/ArrayField.d.ts +17 -0
- package/lib/core/models/ArrayField.js +145 -0
- package/lib/core/models/BaseField.d.ts +72 -0
- package/lib/core/models/BaseField.js +285 -0
- package/lib/core/models/Field.d.ts +70 -0
- package/lib/core/models/Field.js +426 -0
- package/lib/core/models/Form.d.ts +102 -0
- package/lib/core/models/Form.js +483 -0
- package/lib/core/models/Graph.d.ts +8 -0
- package/lib/core/models/Graph.js +77 -0
- package/lib/core/models/Heart.d.ts +16 -0
- package/lib/core/models/Heart.js +91 -0
- package/lib/core/models/LifeCycle.d.ts +14 -0
- package/lib/core/models/LifeCycle.js +64 -0
- package/lib/core/models/ObjectField.d.ts +12 -0
- package/lib/core/models/ObjectField.js +64 -0
- package/lib/core/models/Query.d.ts +18 -0
- package/lib/core/models/Query.js +105 -0
- package/lib/core/models/VoidField.d.ts +14 -0
- package/lib/core/models/VoidField.js +117 -0
- package/lib/core/models/index.d.ts +9 -0
- package/lib/core/models/index.js +37 -0
- package/lib/core/models/types.d.ts +9 -0
- package/lib/core/models/types.js +15 -0
- package/lib/core/shared/checkers.d.ts +117 -0
- package/lib/core/shared/checkers.js +109 -0
- package/lib/core/shared/constants.d.ts +48 -0
- package/lib/core/shared/constants.js +86 -0
- package/lib/core/shared/effective.d.ts +9 -0
- package/lib/core/shared/effective.js +91 -0
- package/lib/core/shared/externals.d.ts +8 -0
- package/lib/core/shared/externals.js +87 -0
- package/lib/core/shared/internals.d.ts +54 -0
- package/lib/core/shared/internals.js +956 -0
- package/lib/core/types.d.ts +275 -0
- package/lib/core/types.js +76 -0
- package/lib/grid/index.d.ts +67 -0
- package/lib/grid/index.js +378 -0
- package/lib/grid/observer.d.ts +19 -0
- package/lib/grid/observer.js +107 -0
- package/lib/index.d.ts +12 -24
- package/lib/index.js +27 -244
- package/lib/json-schema/compiler.d.ts +8 -0
- package/lib/json-schema/compiler.js +129 -0
- package/lib/json-schema/global.d.js +0 -0
- package/lib/json-schema/index.d.ts +2 -0
- package/lib/json-schema/index.js +23 -0
- package/lib/json-schema/patches.d.ts +5 -0
- package/lib/json-schema/patches.js +68 -0
- package/lib/json-schema/polyfills/SPECIFICATION_1_0.d.ts +2 -0
- package/lib/json-schema/polyfills/SPECIFICATION_1_0.js +132 -0
- package/lib/json-schema/polyfills/index.d.ts +1 -0
- package/lib/json-schema/polyfills/index.js +21 -0
- package/lib/json-schema/schema.d.ts +88 -0
- package/lib/json-schema/schema.js +231 -0
- package/lib/json-schema/shared.d.ts +62 -0
- package/lib/json-schema/shared.js +232 -0
- package/lib/json-schema/transformer.d.ts +4 -0
- package/lib/json-schema/transformer.js +238 -0
- package/lib/json-schema/types.d.ts +119 -0
- package/lib/json-schema/types.js +15 -0
- package/lib/path/contexts.d.ts +10 -0
- package/lib/path/contexts.js +49 -0
- package/lib/path/destructor.d.ts +15 -0
- package/lib/path/destructor.js +151 -0
- package/lib/path/index.d.ts +51 -0
- package/lib/path/index.js +513 -0
- package/lib/path/matcher.d.ts +33 -0
- package/lib/path/matcher.js +197 -0
- package/lib/path/parser.d.ts +33 -0
- package/lib/path/parser.js +379 -0
- package/lib/path/shared.d.ts +13 -0
- package/lib/path/shared.js +121 -0
- package/lib/path/tokenizer.d.ts +27 -0
- package/lib/path/tokenizer.js +269 -0
- package/lib/path/tokens.d.ts +27 -0
- package/lib/path/tokens.js +216 -0
- package/lib/path/types.d.ts +88 -0
- package/lib/path/types.js +63 -0
- package/lib/react/components/ArrayField.d.ts +6 -0
- package/lib/react/components/ArrayField.js +44 -0
- package/lib/react/components/ExpressionScope.d.ts +2 -0
- package/lib/react/components/ExpressionScope.js +35 -0
- package/lib/react/components/Field.d.ts +5 -0
- package/lib/react/components/Field.js +45 -0
- package/lib/react/components/FormConsumer.d.ts +2 -0
- package/lib/react/components/FormConsumer.js +36 -0
- package/lib/react/components/FormProvider.d.ts +2 -0
- package/lib/react/components/FormProvider.js +35 -0
- package/lib/react/components/ObjectField.d.ts +6 -0
- package/lib/react/components/ObjectField.js +39 -0
- package/lib/react/components/ReactiveField.d.ts +11 -0
- package/lib/react/components/ReactiveField.js +115 -0
- package/lib/react/components/RecordScope.d.ts +2 -0
- package/lib/react/components/RecordScope.js +65 -0
- package/lib/react/components/RecordsScope.d.ts +2 -0
- package/lib/react/components/RecordsScope.js +43 -0
- package/lib/react/components/RecursionField.d.ts +2 -0
- package/lib/react/components/RecursionField.js +105 -0
- package/lib/react/components/SchemaField.d.ts +41 -0
- package/lib/react/components/SchemaField.js +154 -0
- package/lib/react/components/VoidField.d.ts +5 -0
- package/lib/react/components/VoidField.js +39 -0
- package/lib/react/components/index.d.ts +11 -0
- package/lib/react/components/index.js +41 -0
- package/lib/react/global.d.js +0 -0
- package/lib/react/hooks/index.d.ts +6 -0
- package/lib/react/hooks/index.js +31 -0
- package/lib/react/hooks/useAttach.d.ts +6 -0
- package/lib/react/hooks/useAttach.js +35 -0
- package/lib/react/hooks/useExpressionScope.d.ts +1 -0
- package/lib/react/hooks/useExpressionScope.js +30 -0
- package/lib/react/hooks/useField.d.ts +2 -0
- package/lib/react/hooks/useField.js +32 -0
- package/lib/react/hooks/useFieldSchema.d.ts +2 -0
- package/lib/react/hooks/useFieldSchema.js +32 -0
- package/lib/react/hooks/useForm.d.ts +2 -0
- package/lib/react/hooks/useForm.js +32 -0
- package/lib/react/hooks/useFormEffects.d.ts +2 -0
- package/lib/react/hooks/useFormEffects.js +42 -0
- package/lib/react/hooks/useParentForm.d.ts +2 -0
- package/lib/react/hooks/useParentForm.js +40 -0
- package/lib/react/index.d.ts +5 -0
- package/lib/react/index.js +29 -0
- package/lib/react/shared/connect.d.ts +9 -0
- package/lib/react/shared/connect.js +118 -0
- package/lib/react/shared/context.d.ts +14 -0
- package/lib/react/shared/context.js +74 -0
- package/lib/react/shared/index.d.ts +2 -0
- package/lib/react/shared/index.js +23 -0
- package/lib/react/shared/render.d.ts +2 -0
- package/lib/react/shared/render.js +69 -0
- package/lib/react/types.d.ts +84 -0
- package/lib/react/types.js +15 -0
- package/lib/reactive/action.d.ts +2 -0
- package/lib/reactive/action.js +48 -0
- package/lib/reactive/annotations/box.d.ts +7 -0
- package/lib/reactive/annotations/box.js +76 -0
- package/lib/reactive/annotations/computed.d.ts +12 -0
- package/lib/reactive/annotations/computed.js +154 -0
- package/lib/reactive/annotations/index.d.ts +5 -0
- package/lib/reactive/annotations/index.js +29 -0
- package/lib/reactive/annotations/observable.d.ts +4 -0
- package/lib/reactive/annotations/observable.js +67 -0
- package/lib/reactive/annotations/ref.d.ts +6 -0
- package/lib/reactive/annotations/ref.js +78 -0
- package/lib/reactive/annotations/shallow.d.ts +2 -0
- package/lib/reactive/annotations/shallow.js +67 -0
- package/lib/reactive/array.d.ts +12 -0
- package/lib/reactive/array.js +83 -0
- package/lib/reactive/autorun.d.ts +7 -0
- package/lib/reactive/autorun.js +155 -0
- package/lib/reactive/batch.d.ts +2 -0
- package/lib/reactive/batch.js +40 -0
- package/lib/reactive/checkers.d.ts +10 -0
- package/lib/reactive/checkers.js +60 -0
- package/lib/reactive/environment.d.ts +28 -0
- package/lib/reactive/environment.js +76 -0
- package/lib/reactive/externals.d.ts +10 -0
- package/lib/reactive/externals.js +156 -0
- package/lib/reactive/global.d.js +0 -0
- package/lib/reactive/handlers.d.ts +4 -0
- package/lib/reactive/handlers.js +246 -0
- package/lib/reactive/index.d.ts +10 -0
- package/lib/reactive/index.js +39 -0
- package/lib/reactive/internals.d.ts +17 -0
- package/lib/reactive/internals.js +139 -0
- package/lib/reactive/model.d.ts +3 -0
- package/lib/reactive/model.js +68 -0
- package/lib/reactive/observable.d.ts +9 -0
- package/lib/reactive/observable.js +50 -0
- package/lib/reactive/observe.d.ts +2 -0
- package/lib/reactive/observe.js +58 -0
- package/lib/reactive/reaction.d.ts +21 -0
- package/lib/reactive/reaction.js +278 -0
- package/lib/reactive/tracker.d.ts +7 -0
- package/lib/reactive/tracker.js +63 -0
- package/lib/reactive/tree.d.ts +25 -0
- package/lib/reactive/tree.js +106 -0
- package/lib/reactive/types.d.ts +79 -0
- package/lib/reactive/types.js +21 -0
- package/lib/reactive/untracked.d.ts +4 -0
- package/lib/reactive/untracked.js +29 -0
- package/lib/reactive-react/hooks/index.d.ts +9 -0
- package/lib/reactive-react/hooks/index.js +48 -0
- package/lib/reactive-react/hooks/useCompatEffect.d.ts +2 -0
- package/lib/reactive-react/hooks/useCompatEffect.js +60 -0
- package/lib/reactive-react/hooks/useCompatFactory.d.ts +3 -0
- package/lib/reactive-react/hooks/useCompatFactory.js +74 -0
- package/lib/reactive-react/hooks/useDidUpdate.d.ts +1 -0
- package/lib/reactive-react/hooks/useDidUpdate.js +38 -0
- package/lib/reactive-react/hooks/useForceUpdate.d.ts +1 -0
- package/lib/reactive-react/hooks/useForceUpdate.js +76 -0
- package/lib/reactive-react/hooks/useLayoutEffect.d.ts +2 -0
- package/lib/reactive-react/hooks/useLayoutEffect.js +28 -0
- package/lib/reactive-react/hooks/useObserver.d.ts +2 -0
- package/lib/reactive-react/hooks/useObserver.js +43 -0
- package/lib/reactive-react/index.d.ts +3 -0
- package/lib/reactive-react/index.js +25 -0
- package/lib/reactive-react/observer.d.ts +8 -0
- package/lib/reactive-react/observer.js +64 -0
- package/lib/reactive-react/shared/gc.d.ts +8 -0
- package/lib/reactive-react/shared/gc.js +59 -0
- package/lib/reactive-react/shared/global.d.ts +1 -0
- package/lib/reactive-react/shared/global.js +50 -0
- package/lib/reactive-react/shared/immediate.d.ts +1 -0
- package/lib/reactive-react/shared/immediate.js +40 -0
- package/lib/reactive-react/shared/index.d.ts +2 -0
- package/lib/reactive-react/shared/index.js +23 -0
- package/lib/reactive-react/types.d.ts +14 -0
- package/lib/reactive-react/types.js +15 -0
- package/lib/shared/array.d.ts +35 -0
- package/lib/shared/array.js +189 -0
- package/lib/shared/case.d.ts +6 -0
- package/lib/shared/case.js +39 -0
- package/lib/shared/checkers.d.ts +21 -0
- package/lib/shared/checkers.js +77 -0
- package/lib/shared/clone.d.ts +2 -0
- package/lib/shared/clone.js +97 -0
- package/lib/shared/compare.d.ts +1 -0
- package/lib/shared/compare.js +129 -0
- package/lib/shared/defaults.d.ts +6 -0
- package/lib/shared/defaults.js +63 -0
- package/lib/shared/deprecate.d.ts +1 -0
- package/lib/shared/deprecate.js +42 -0
- package/lib/shared/global.d.ts +1 -0
- package/lib/shared/global.js +50 -0
- package/lib/shared/index.d.ts +16 -0
- package/lib/shared/index.js +51 -0
- package/lib/shared/instanceof.d.ts +1 -0
- package/lib/shared/instanceof.js +36 -0
- package/lib/shared/isEmpty.d.ts +3 -0
- package/lib/shared/isEmpty.js +94 -0
- package/lib/shared/merge.d.ts +12 -0
- package/lib/shared/merge.js +214 -0
- package/lib/shared/middleware.d.ts +4 -0
- package/lib/shared/middleware.js +41 -0
- package/lib/shared/path.d.ts +3 -0
- package/lib/shared/path.js +27 -0
- package/lib/shared/string.d.ts +1 -0
- package/lib/shared/string.js +38 -0
- package/lib/shared/subscribable.d.ts +11 -0
- package/lib/shared/subscribable.js +74 -0
- package/lib/shared/uid.d.ts +1 -0
- package/lib/shared/uid.js +35 -0
- package/lib/validator/formats.d.ts +16 -0
- package/lib/validator/formats.js +40 -0
- package/lib/validator/index.d.ts +4 -0
- package/lib/validator/index.js +27 -0
- package/lib/validator/locale.d.ts +219 -0
- package/lib/validator/locale.js +240 -0
- package/lib/validator/parser.d.ts +5 -0
- package/lib/validator/parser.js +153 -0
- package/lib/validator/registry.d.ts +15 -0
- package/lib/validator/registry.js +116 -0
- package/lib/validator/rules.d.ts +3 -0
- package/lib/validator/rules.js +154 -0
- package/lib/validator/template.d.ts +2 -0
- package/lib/validator/template.js +42 -0
- package/lib/validator/types.d.ts +62 -0
- package/lib/validator/types.js +28 -0
- package/lib/validator/validator.d.ts +2 -0
- package/lib/validator/validator.js +63 -0
- package/package.json +16 -10
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var BaseField_exports = {};
|
|
20
|
+
__export(BaseField_exports, {
|
|
21
|
+
BaseField: () => BaseField
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(BaseField_exports);
|
|
24
|
+
var import_shared = require("../../shared");
|
|
25
|
+
var import_internals = require("../shared/internals");
|
|
26
|
+
var import_types = require("../types");
|
|
27
|
+
var import_Query = require("./Query");
|
|
28
|
+
const _BaseField = class _BaseField {
|
|
29
|
+
constructor() {
|
|
30
|
+
this.disposers = [];
|
|
31
|
+
this.actions = {};
|
|
32
|
+
this.setTitle = /* @__PURE__ */ __name((title) => {
|
|
33
|
+
this.title = title;
|
|
34
|
+
}, "setTitle");
|
|
35
|
+
this.setDescription = /* @__PURE__ */ __name((description) => {
|
|
36
|
+
this.description = description;
|
|
37
|
+
}, "setDescription");
|
|
38
|
+
this.setDisplay = /* @__PURE__ */ __name((type) => {
|
|
39
|
+
this.display = type;
|
|
40
|
+
}, "setDisplay");
|
|
41
|
+
this.setPattern = /* @__PURE__ */ __name((type) => {
|
|
42
|
+
this.pattern = type;
|
|
43
|
+
}, "setPattern");
|
|
44
|
+
this.setComponent = /* @__PURE__ */ __name((component, props) => {
|
|
45
|
+
if (component) {
|
|
46
|
+
this.componentType = component;
|
|
47
|
+
}
|
|
48
|
+
if (props) {
|
|
49
|
+
this.componentProps = this.componentProps || {};
|
|
50
|
+
Object.assign(this.componentProps, props);
|
|
51
|
+
}
|
|
52
|
+
}, "setComponent");
|
|
53
|
+
this.setComponentProps = /* @__PURE__ */ __name((props) => {
|
|
54
|
+
if (props) {
|
|
55
|
+
this.componentProps = this.componentProps || {};
|
|
56
|
+
Object.assign(this.componentProps, props);
|
|
57
|
+
}
|
|
58
|
+
}, "setComponentProps");
|
|
59
|
+
this.setDecorator = /* @__PURE__ */ __name((component, props) => {
|
|
60
|
+
if (component) {
|
|
61
|
+
this.decoratorType = component;
|
|
62
|
+
}
|
|
63
|
+
if (props) {
|
|
64
|
+
this.decoratorProps = this.decoratorProps || {};
|
|
65
|
+
Object.assign(this.decoratorProps, props);
|
|
66
|
+
}
|
|
67
|
+
}, "setDecorator");
|
|
68
|
+
this.setDecoratorProps = /* @__PURE__ */ __name((props) => {
|
|
69
|
+
if (props) {
|
|
70
|
+
this.decoratorProps = this.decoratorProps || {};
|
|
71
|
+
Object.assign(this.decoratorProps, props);
|
|
72
|
+
}
|
|
73
|
+
}, "setDecoratorProps");
|
|
74
|
+
this.setData = /* @__PURE__ */ __name((data) => {
|
|
75
|
+
this.data = data;
|
|
76
|
+
}, "setData");
|
|
77
|
+
this.setContent = /* @__PURE__ */ __name((content) => {
|
|
78
|
+
this.content = content;
|
|
79
|
+
}, "setContent");
|
|
80
|
+
this.onInit = /* @__PURE__ */ __name(() => {
|
|
81
|
+
this.initialized = true;
|
|
82
|
+
(0, import_internals.initFieldUpdate)(this);
|
|
83
|
+
this.notify(import_types.LifeCycleTypes.ON_FIELD_INIT);
|
|
84
|
+
}, "onInit");
|
|
85
|
+
this.onMount = /* @__PURE__ */ __name(() => {
|
|
86
|
+
this.mounted = true;
|
|
87
|
+
this.unmounted = false;
|
|
88
|
+
this.notify(import_types.LifeCycleTypes.ON_FIELD_MOUNT);
|
|
89
|
+
}, "onMount");
|
|
90
|
+
this.onUnmount = /* @__PURE__ */ __name(() => {
|
|
91
|
+
this.mounted = false;
|
|
92
|
+
this.unmounted = true;
|
|
93
|
+
this.notify(import_types.LifeCycleTypes.ON_FIELD_UNMOUNT);
|
|
94
|
+
}, "onUnmount");
|
|
95
|
+
this.query = /* @__PURE__ */ __name((pattern) => {
|
|
96
|
+
return new import_Query.Query({
|
|
97
|
+
pattern,
|
|
98
|
+
base: this.address,
|
|
99
|
+
form: this.form
|
|
100
|
+
});
|
|
101
|
+
}, "query");
|
|
102
|
+
this.notify = /* @__PURE__ */ __name((type, payload) => {
|
|
103
|
+
return this.form.notify(type, payload ?? this);
|
|
104
|
+
}, "notify");
|
|
105
|
+
this.dispose = /* @__PURE__ */ __name(() => {
|
|
106
|
+
this.disposers.forEach((dispose) => {
|
|
107
|
+
dispose();
|
|
108
|
+
});
|
|
109
|
+
this.form.removeEffects(this);
|
|
110
|
+
}, "dispose");
|
|
111
|
+
this.destroy = /* @__PURE__ */ __name((forceClear = true) => {
|
|
112
|
+
(0, import_internals.destroy)(this.form.fields, this.address.toString(), forceClear);
|
|
113
|
+
}, "destroy");
|
|
114
|
+
this.match = /* @__PURE__ */ __name((pattern) => {
|
|
115
|
+
return import_shared.FormPath.parse(pattern).matchAliasGroup(this.address, this.path);
|
|
116
|
+
}, "match");
|
|
117
|
+
this.inject = /* @__PURE__ */ __name((actions) => {
|
|
118
|
+
(0, import_shared.each)(actions, (action, key) => {
|
|
119
|
+
if ((0, import_shared.isFn)(action)) {
|
|
120
|
+
this.actions[key] = action;
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
}, "inject");
|
|
124
|
+
this.invoke = /* @__PURE__ */ __name((name, ...args) => {
|
|
125
|
+
var _a, _b;
|
|
126
|
+
return (_b = (_a = this.actions)[name]) == null ? void 0 : _b.call(_a, ...args);
|
|
127
|
+
}, "invoke");
|
|
128
|
+
}
|
|
129
|
+
locate(address) {
|
|
130
|
+
this.form.fields[address.toString()] = this;
|
|
131
|
+
(0, import_internals.locateNode)(this, address);
|
|
132
|
+
}
|
|
133
|
+
get indexes() {
|
|
134
|
+
return this.path.transform(/^\d+$/, (...args) => args.map((index) => Number(index)));
|
|
135
|
+
}
|
|
136
|
+
get index() {
|
|
137
|
+
return this.indexes[this.indexes.length - 1] ?? -1;
|
|
138
|
+
}
|
|
139
|
+
get records() {
|
|
140
|
+
const array = (0, import_internals.getArrayParent)(this);
|
|
141
|
+
return array == null ? void 0 : array.value;
|
|
142
|
+
}
|
|
143
|
+
get record() {
|
|
144
|
+
var _a;
|
|
145
|
+
const obj = (0, import_internals.getObjectParent)(this);
|
|
146
|
+
if (obj) {
|
|
147
|
+
return obj.value;
|
|
148
|
+
}
|
|
149
|
+
const index = this.index;
|
|
150
|
+
const array = (0, import_internals.getArrayParent)(this, index);
|
|
151
|
+
if (array) {
|
|
152
|
+
return (_a = array.value) == null ? void 0 : _a[index];
|
|
153
|
+
}
|
|
154
|
+
return this.form.values;
|
|
155
|
+
}
|
|
156
|
+
get component() {
|
|
157
|
+
return [this.componentType, this.componentProps];
|
|
158
|
+
}
|
|
159
|
+
set component(value) {
|
|
160
|
+
const component = (0, import_shared.toArr)(value);
|
|
161
|
+
this.componentType = component[0];
|
|
162
|
+
this.componentProps = component[1] || {};
|
|
163
|
+
}
|
|
164
|
+
get decorator() {
|
|
165
|
+
return [this.decoratorType, this.decoratorProps];
|
|
166
|
+
}
|
|
167
|
+
set decorator(value) {
|
|
168
|
+
const decorator = (0, import_shared.toArr)(value);
|
|
169
|
+
this.decoratorType = decorator[0];
|
|
170
|
+
this.decoratorProps = decorator[1] || {};
|
|
171
|
+
}
|
|
172
|
+
get parent() {
|
|
173
|
+
let parent = this.address.parent();
|
|
174
|
+
let identifier = parent.toString();
|
|
175
|
+
while (!this.form.fields[identifier]) {
|
|
176
|
+
parent = parent.parent();
|
|
177
|
+
identifier = parent.toString();
|
|
178
|
+
if (!identifier) return;
|
|
179
|
+
}
|
|
180
|
+
return this.form.fields[identifier];
|
|
181
|
+
}
|
|
182
|
+
get display() {
|
|
183
|
+
var _a;
|
|
184
|
+
const parentDisplay = (_a = this.parent) == null ? void 0 : _a.display;
|
|
185
|
+
if (parentDisplay && parentDisplay !== "visible") {
|
|
186
|
+
if (this.selfDisplay && this.selfDisplay !== "visible") return this.selfDisplay;
|
|
187
|
+
return parentDisplay;
|
|
188
|
+
}
|
|
189
|
+
if ((0, import_shared.isValid)(this.selfDisplay)) return this.selfDisplay;
|
|
190
|
+
return parentDisplay || this.form.display || "visible";
|
|
191
|
+
}
|
|
192
|
+
get pattern() {
|
|
193
|
+
var _a;
|
|
194
|
+
const parentPattern = ((_a = this.parent) == null ? void 0 : _a.pattern) || this.form.pattern || "editable";
|
|
195
|
+
const selfPattern = this.selfPattern;
|
|
196
|
+
if ((0, import_shared.isValid)(selfPattern)) {
|
|
197
|
+
if (parentPattern === "readPretty" && selfPattern !== "editable") {
|
|
198
|
+
return parentPattern;
|
|
199
|
+
}
|
|
200
|
+
return selfPattern;
|
|
201
|
+
}
|
|
202
|
+
return parentPattern;
|
|
203
|
+
}
|
|
204
|
+
get editable() {
|
|
205
|
+
return this.pattern === "editable";
|
|
206
|
+
}
|
|
207
|
+
get disabled() {
|
|
208
|
+
return this.pattern === "disabled";
|
|
209
|
+
}
|
|
210
|
+
get readOnly() {
|
|
211
|
+
return this.pattern === "readOnly";
|
|
212
|
+
}
|
|
213
|
+
get readPretty() {
|
|
214
|
+
return this.pattern === "readPretty";
|
|
215
|
+
}
|
|
216
|
+
get hidden() {
|
|
217
|
+
return this.display === "hidden";
|
|
218
|
+
}
|
|
219
|
+
get visible() {
|
|
220
|
+
return this.display === "visible";
|
|
221
|
+
}
|
|
222
|
+
get destroyed() {
|
|
223
|
+
return !this.form.fields[this.address.toString()];
|
|
224
|
+
}
|
|
225
|
+
set hidden(hidden) {
|
|
226
|
+
if (!(0, import_shared.isValid)(hidden)) return;
|
|
227
|
+
if (hidden) {
|
|
228
|
+
this.display = "hidden";
|
|
229
|
+
} else {
|
|
230
|
+
this.display = "visible";
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
set visible(visible) {
|
|
234
|
+
if (!(0, import_shared.isValid)(visible)) return;
|
|
235
|
+
if (visible) {
|
|
236
|
+
this.display = "visible";
|
|
237
|
+
} else {
|
|
238
|
+
this.display = "none";
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
set editable(editable) {
|
|
242
|
+
if (!(0, import_shared.isValid)(editable)) return;
|
|
243
|
+
if (editable) {
|
|
244
|
+
this.pattern = "editable";
|
|
245
|
+
} else {
|
|
246
|
+
this.pattern = "readPretty";
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
set readOnly(readOnly) {
|
|
250
|
+
if (!(0, import_shared.isValid)(readOnly)) return;
|
|
251
|
+
if (readOnly) {
|
|
252
|
+
this.pattern = "readOnly";
|
|
253
|
+
} else {
|
|
254
|
+
this.pattern = "editable";
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
set disabled(disabled) {
|
|
258
|
+
if (!(0, import_shared.isValid)(disabled)) return;
|
|
259
|
+
if (disabled) {
|
|
260
|
+
this.pattern = "disabled";
|
|
261
|
+
} else {
|
|
262
|
+
this.pattern = "editable";
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
set readPretty(readPretty) {
|
|
266
|
+
if (!(0, import_shared.isValid)(readPretty)) return;
|
|
267
|
+
if (readPretty) {
|
|
268
|
+
this.pattern = "readPretty";
|
|
269
|
+
} else {
|
|
270
|
+
this.pattern = "editable";
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
set pattern(pattern) {
|
|
274
|
+
this.selfPattern = pattern;
|
|
275
|
+
}
|
|
276
|
+
set display(display) {
|
|
277
|
+
this.selfDisplay = display;
|
|
278
|
+
}
|
|
279
|
+
};
|
|
280
|
+
__name(_BaseField, "BaseField");
|
|
281
|
+
let BaseField = _BaseField;
|
|
282
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
283
|
+
0 && (module.exports = {
|
|
284
|
+
BaseField
|
|
285
|
+
});
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { FormPathPattern } from '../../shared';
|
|
2
|
+
import { ValidatorTriggerType } from '../../validator';
|
|
3
|
+
import { FeedbackMessage, FieldDataSource, FieldValidator, IFieldCaches, IFieldFeedback, IFieldProps, IFieldRequests, IFieldResetOptions, IFieldState, IFormFeedback, IModelGetter, IModelSetter, ISearchFeedback, JSXComponent } from '../types';
|
|
4
|
+
import { BaseField } from './BaseField';
|
|
5
|
+
import { Form } from './Form';
|
|
6
|
+
export declare class Field<Decorator extends JSXComponent = any, Component extends JSXComponent = any, TextType = any, ValueType = any> extends BaseField<Decorator, Component, TextType> {
|
|
7
|
+
displayName: string;
|
|
8
|
+
props: IFieldProps<Decorator, Component, TextType, ValueType>;
|
|
9
|
+
loading: boolean;
|
|
10
|
+
validating: boolean;
|
|
11
|
+
submitting: boolean;
|
|
12
|
+
active: boolean;
|
|
13
|
+
visited: boolean;
|
|
14
|
+
selfModified: boolean;
|
|
15
|
+
modified: boolean;
|
|
16
|
+
inputValue: ValueType;
|
|
17
|
+
inputValues: any[];
|
|
18
|
+
dataSource: FieldDataSource;
|
|
19
|
+
validator: FieldValidator;
|
|
20
|
+
feedbacks: IFieldFeedback[];
|
|
21
|
+
caches: IFieldCaches;
|
|
22
|
+
requests: IFieldRequests;
|
|
23
|
+
constructor(address: FormPathPattern, props: IFieldProps<Decorator, Component, TextType, ValueType>, form: Form, designable: boolean);
|
|
24
|
+
protected initialize(): void;
|
|
25
|
+
protected makeObservable(): void;
|
|
26
|
+
protected makeReactive(): void;
|
|
27
|
+
get selfErrors(): FeedbackMessage;
|
|
28
|
+
get errors(): IFormFeedback[];
|
|
29
|
+
get selfWarnings(): FeedbackMessage;
|
|
30
|
+
get warnings(): IFormFeedback[];
|
|
31
|
+
get selfSuccesses(): FeedbackMessage;
|
|
32
|
+
get successes(): IFormFeedback[];
|
|
33
|
+
get selfValid(): boolean;
|
|
34
|
+
get valid(): boolean;
|
|
35
|
+
get selfInvalid(): boolean;
|
|
36
|
+
get invalid(): boolean;
|
|
37
|
+
get value(): ValueType;
|
|
38
|
+
get initialValue(): ValueType;
|
|
39
|
+
get required(): boolean;
|
|
40
|
+
get validateStatus(): "error" | "warning" | "success" | "validating";
|
|
41
|
+
set required(required: boolean);
|
|
42
|
+
set value(value: ValueType);
|
|
43
|
+
set initialValue(initialValue: ValueType);
|
|
44
|
+
set selfErrors(messages: FeedbackMessage);
|
|
45
|
+
set selfWarnings(messages: FeedbackMessage);
|
|
46
|
+
set selfSuccesses(messages: FeedbackMessage);
|
|
47
|
+
setDataSource: (dataSource?: FieldDataSource) => void;
|
|
48
|
+
setFeedback: (feedback?: IFieldFeedback) => void;
|
|
49
|
+
setSelfErrors: (messages?: FeedbackMessage) => void;
|
|
50
|
+
setSelfWarnings: (messages?: FeedbackMessage) => void;
|
|
51
|
+
setSelfSuccesses: (messages?: FeedbackMessage) => void;
|
|
52
|
+
setValidator: (validator?: FieldValidator) => void;
|
|
53
|
+
setValidatorRule: (name: string, value: any) => void;
|
|
54
|
+
setRequired: (required?: boolean) => void;
|
|
55
|
+
setValue: (value?: ValueType) => void;
|
|
56
|
+
setInitialValue: (initialValue?: ValueType) => void;
|
|
57
|
+
setLoading: (loading?: boolean) => void;
|
|
58
|
+
setValidating: (validating?: boolean) => void;
|
|
59
|
+
setSubmitting: (submitting?: boolean) => void;
|
|
60
|
+
setState: IModelSetter<IFieldState>;
|
|
61
|
+
getState: IModelGetter<IFieldState>;
|
|
62
|
+
onInput: (...args: any[]) => Promise<void>;
|
|
63
|
+
onFocus: (...args: any[]) => Promise<void>;
|
|
64
|
+
onBlur: (...args: any[]) => Promise<void>;
|
|
65
|
+
validate: (triggerType?: ValidatorTriggerType) => Promise<void>;
|
|
66
|
+
submit: <T>(onSubmit?: (values: any) => Promise<T> | void) => Promise<T>;
|
|
67
|
+
reset: (options?: IFieldResetOptions) => Promise<void>;
|
|
68
|
+
queryFeedbacks: (search?: ISearchFeedback) => IFieldFeedback[];
|
|
69
|
+
modify: () => void;
|
|
70
|
+
}
|