@progress/kendo-react-form 6.1.1 → 7.0.0-develop.1
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/{dist/es/Field.d.ts → Field.d.ts} +4 -0
- package/FieldArray.d.ts +11 -0
- package/{dist/es/FieldWrapper.d.ts → FieldWrapper.d.ts} +4 -0
- package/{dist/es/Form.d.ts → Form.d.ts} +5 -1
- package/{dist/es/FormContext.d.ts → FormContext.d.ts} +5 -1
- package/{dist/es/FormElement.d.ts → FormElement.d.ts} +4 -0
- package/LICENSE.md +1 -1
- package/dist/cdn/js/kendo-react-form.js +5 -1
- package/index.d.ts +20 -0
- package/index.js +5 -0
- package/index.mjs +409 -0
- package/{dist/npm/interfaces → interfaces}/FieldArrayProps.d.ts +4 -1
- package/{dist/npm/interfaces → interfaces}/FieldArrayRenderProps.d.ts +4 -0
- package/{dist/npm/interfaces → interfaces}/FieldProps.d.ts +4 -1
- package/{dist/es/interfaces → interfaces}/FieldRenderProps.d.ts +4 -0
- package/{dist/es/interfaces → interfaces}/FieldValidator.d.ts +5 -1
- package/{dist/es/interfaces → interfaces}/FormProps.d.ts +4 -1
- package/{dist/npm/interfaces → interfaces}/FormRenderProps.d.ts +4 -1
- package/{dist/npm/interfaces → interfaces}/FormSubmitClickEvent.d.ts +4 -1
- package/interfaces/FormValidator.d.ts +14 -0
- package/interfaces/KeyValue.d.ts +10 -0
- package/package-metadata.d.ts +9 -0
- package/package.json +26 -42
- package/about.md +0 -3
- package/dist/es/Field.js +0 -92
- package/dist/es/FieldArray.d.ts +0 -7
- package/dist/es/FieldArray.js +0 -72
- package/dist/es/FieldWrapper.js +0 -15
- package/dist/es/Form.js +0 -607
- package/dist/es/FormContext.js +0 -3
- package/dist/es/FormElement.js +0 -49
- package/dist/es/interfaces/FieldArrayProps.d.ts +0 -29
- package/dist/es/interfaces/FieldArrayProps.js +0 -1
- package/dist/es/interfaces/FieldArrayRenderProps.d.ts +0 -89
- package/dist/es/interfaces/FieldArrayRenderProps.js +0 -1
- package/dist/es/interfaces/FieldProps.d.ts +0 -40
- package/dist/es/interfaces/FieldProps.js +0 -1
- package/dist/es/interfaces/FieldRenderProps.js +0 -1
- package/dist/es/interfaces/FieldValidator.js +0 -1
- package/dist/es/interfaces/FormProps.js +0 -1
- package/dist/es/interfaces/FormRenderProps.d.ts +0 -75
- package/dist/es/interfaces/FormRenderProps.js +0 -1
- package/dist/es/interfaces/FormSubmitClickEvent.d.ts +0 -24
- package/dist/es/interfaces/FormSubmitClickEvent.js +0 -1
- package/dist/es/interfaces/FormValidator.d.ts +0 -10
- package/dist/es/interfaces/FormValidator.js +0 -1
- package/dist/es/interfaces/KeyValue.d.ts +0 -6
- package/dist/es/interfaces/KeyValue.js +0 -1
- package/dist/es/main.d.ts +0 -16
- package/dist/es/main.js +0 -6
- package/dist/es/package-metadata.d.ts +0 -5
- package/dist/es/package-metadata.js +0 -11
- package/dist/npm/Field.d.ts +0 -10
- package/dist/npm/Field.js +0 -96
- package/dist/npm/FieldArray.d.ts +0 -7
- package/dist/npm/FieldArray.js +0 -76
- package/dist/npm/FieldWrapper.d.ts +0 -28
- package/dist/npm/FieldWrapper.js +0 -19
- package/dist/npm/Form.d.ts +0 -262
- package/dist/npm/Form.js +0 -610
- package/dist/npm/FormContext.d.ts +0 -50
- package/dist/npm/FormContext.js +0 -6
- package/dist/npm/FormElement.d.ts +0 -52
- package/dist/npm/FormElement.js +0 -52
- package/dist/npm/interfaces/FieldArrayProps.js +0 -2
- package/dist/npm/interfaces/FieldArrayRenderProps.js +0 -2
- package/dist/npm/interfaces/FieldProps.js +0 -2
- package/dist/npm/interfaces/FieldRenderProps.d.ts +0 -65
- package/dist/npm/interfaces/FieldRenderProps.js +0 -2
- package/dist/npm/interfaces/FieldValidator.d.ts +0 -14
- package/dist/npm/interfaces/FieldValidator.js +0 -2
- package/dist/npm/interfaces/FormProps.d.ts +0 -47
- package/dist/npm/interfaces/FormProps.js +0 -2
- package/dist/npm/interfaces/FormRenderProps.js +0 -2
- package/dist/npm/interfaces/FormSubmitClickEvent.js +0 -2
- package/dist/npm/interfaces/FormValidator.d.ts +0 -10
- package/dist/npm/interfaces/FormValidator.js +0 -2
- package/dist/npm/interfaces/KeyValue.d.ts +0 -6
- package/dist/npm/interfaces/KeyValue.js +0 -2
- package/dist/npm/main.d.ts +0 -16
- package/dist/npm/main.js +0 -13
- package/dist/npm/package-metadata.d.ts +0 -5
- package/dist/npm/package-metadata.js +0 -14
- package/dist/systemjs/kendo-react-form.js +0 -1
- package/e2e-next/form.basic.tests.ts +0 -23
package/index.mjs
ADDED
|
@@ -0,0 +1,409 @@
|
|
|
1
|
+
/**-----------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright © 2023 Progress Software Corporation. All rights reserved.
|
|
3
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
4
|
+
*-------------------------------------------------------------------------------------------*/
|
|
5
|
+
import * as n from "react";
|
|
6
|
+
import * as F from "prop-types";
|
|
7
|
+
import { guid as _, clone as C, getter as U, setter as k, validatePackage as B, cloneObject as E, classNames as b, kendoThemeMaps as T } from "@progress/kendo-react-common";
|
|
8
|
+
const y = n.createContext(null), S = (l) => {
|
|
9
|
+
const { name: e, component: t, validator: i, children: o, onChange: r, ...d } = l, s = n.useContext(y), a = s ? s.id : "";
|
|
10
|
+
n.useEffect(
|
|
11
|
+
() => s ? s.registerField(e, i) : void 0,
|
|
12
|
+
[e, a, i]
|
|
13
|
+
);
|
|
14
|
+
const c = n.useCallback(
|
|
15
|
+
(u) => {
|
|
16
|
+
const g = u && (u.value !== void 0 ? u.value : u.target ? u.target.value : u.target);
|
|
17
|
+
s.onChange(e, { value: g }), r && r.call(void 0, u);
|
|
18
|
+
},
|
|
19
|
+
[e, a, r]
|
|
20
|
+
), m = n.useCallback(
|
|
21
|
+
(u) => s.onChange(e, { value: u.target.value }),
|
|
22
|
+
[e, a]
|
|
23
|
+
), f = n.useCallback(
|
|
24
|
+
() => s.onBlur(e),
|
|
25
|
+
[e, a]
|
|
26
|
+
), v = n.useCallback(
|
|
27
|
+
() => s.onFocus(e),
|
|
28
|
+
[e, a]
|
|
29
|
+
);
|
|
30
|
+
if (!s)
|
|
31
|
+
return null;
|
|
32
|
+
const p = s.valueGetter(e);
|
|
33
|
+
return typeof t == "string" ? n.createElement(t, {
|
|
34
|
+
onChange: m,
|
|
35
|
+
onBlur: f,
|
|
36
|
+
onFocus: v,
|
|
37
|
+
value: p,
|
|
38
|
+
children: o,
|
|
39
|
+
...d
|
|
40
|
+
}) : n.createElement(
|
|
41
|
+
t,
|
|
42
|
+
{
|
|
43
|
+
children: o,
|
|
44
|
+
...d,
|
|
45
|
+
// input
|
|
46
|
+
onChange: c,
|
|
47
|
+
onBlur: f,
|
|
48
|
+
onFocus: v,
|
|
49
|
+
value: p,
|
|
50
|
+
// meta
|
|
51
|
+
validationMessage: s.errors[e],
|
|
52
|
+
touched: s.touched[e],
|
|
53
|
+
modified: s.modified[e],
|
|
54
|
+
visited: s.visited[e],
|
|
55
|
+
// Our `valid` implementation requires double submit to show html5 validation errors,
|
|
56
|
+
// however it's NOT recommended to show html5 validation errors at all as:
|
|
57
|
+
// - There is no standard way to change validation look and feel with CSS.
|
|
58
|
+
// - Look different in each browser / OS
|
|
59
|
+
// - You can have a page in one language but an error message displayed in another language (not localizable)
|
|
60
|
+
valid: !(s.errors[e] && s.touched[e]),
|
|
61
|
+
name: e
|
|
62
|
+
}
|
|
63
|
+
);
|
|
64
|
+
};
|
|
65
|
+
S.displayName = "KendoReactField";
|
|
66
|
+
const M = {
|
|
67
|
+
name: "@progress/kendo-react-form",
|
|
68
|
+
productName: "KendoReact",
|
|
69
|
+
productCodes: ["KENDOUIREACT", "KENDOUICOMPLETE"],
|
|
70
|
+
publishDate: 1700493758,
|
|
71
|
+
version: "",
|
|
72
|
+
licensingDocsUrl: "https://www.telerik.com/kendo-react-ui/components/my-license/"
|
|
73
|
+
}, I = 0;
|
|
74
|
+
class A extends n.Component {
|
|
75
|
+
/**
|
|
76
|
+
* @hidden
|
|
77
|
+
*/
|
|
78
|
+
constructor(e) {
|
|
79
|
+
super(e), this._id = _(), this._touched = {}, this._visited = {}, this._modified = {}, this._validatorsByField = {}, this._values = {}, this._fields = {}, this._unmounted = !1, this._submitted = !1, this.isValid = () => this.isFormValid(this.errors), this.accumulatedForceUpdate = () => {
|
|
80
|
+
this._accumulatorTimeout && clearTimeout(this._accumulatorTimeout), this._accumulatorTimeout = window.setTimeout(
|
|
81
|
+
() => {
|
|
82
|
+
this._accumulatorTimeout = void 0, this.forceUpdate();
|
|
83
|
+
},
|
|
84
|
+
I
|
|
85
|
+
);
|
|
86
|
+
}, this.resetForm = () => {
|
|
87
|
+
this.values = C(this.props.initialValues), this._id = _(), this._touched = {}, this._visited = {}, this._modified = {}, this._validatorsByField = {}, this._fields = {}, this._submitted = !1, this.forceUpdate();
|
|
88
|
+
}, this.onReset = () => this.resetForm(), this.addField = (t) => {
|
|
89
|
+
this._fields[t] = !0;
|
|
90
|
+
}, this.onSubmit = (t) => {
|
|
91
|
+
const i = {}, o = this.fields;
|
|
92
|
+
t && (typeof t.preventDefault == "function" && t.preventDefault(), typeof t.stopPropagation == "function" && t.stopPropagation()), o.forEach((a) => {
|
|
93
|
+
i[a] = !0;
|
|
94
|
+
}), this.visited = { ...i }, this.touched = { ...i };
|
|
95
|
+
const r = this.values, d = this.isFormValid(this.errors), s = this.isFormModified(this.modified, o);
|
|
96
|
+
this.props.onSubmitClick && this.props.onSubmitClick.call(void 0, {
|
|
97
|
+
values: r,
|
|
98
|
+
isValid: d,
|
|
99
|
+
isModified: s,
|
|
100
|
+
event: t
|
|
101
|
+
}), d && (this.props.ignoreModified || s) && this.props.onSubmit && (this._submitted = !0, this.props.onSubmit.call(void 0, r, t)), this.forceUpdate();
|
|
102
|
+
}, this.onChange = (t, i) => {
|
|
103
|
+
const { value: o } = i;
|
|
104
|
+
this.addField(t), this.modified[t] || (this.modified = { ...this.modified, [t]: !0 }), this.valueSetter(t, o), this.forceUpdate();
|
|
105
|
+
}, this.onFocus = (t, i) => {
|
|
106
|
+
this.visited[t] || (this.visited = { ...this.visited, [t]: !0 }, i || this.forceUpdate());
|
|
107
|
+
}, this.onBlur = (t, i) => {
|
|
108
|
+
this.touched[t] || (this.onFocus(t, i), this.touched = { ...this.touched, [t]: !0 }, i || this.forceUpdate());
|
|
109
|
+
}, this.onFieldRegister = (t, i) => {
|
|
110
|
+
this.addField(t);
|
|
111
|
+
const o = this.validatorsByField[t] || [], r = o.length;
|
|
112
|
+
return this.validatorsByField = { ...this.validatorsByField, [t]: [...o, i] }, this.accumulatedForceUpdate(), () => {
|
|
113
|
+
if (this._unmounted)
|
|
114
|
+
return;
|
|
115
|
+
const d = [...this.validatorsByField[t] || []], s = !!d[r];
|
|
116
|
+
d[r] = void 0, this.validatorsByField = { ...this.validatorsByField, [t]: d }, s && this.accumulatedForceUpdate();
|
|
117
|
+
};
|
|
118
|
+
}, this.isFormValid = (t) => !Object.keys(t).some((i) => !!t[i]), this.isFormModified = (t, i) => i.some((o) => t[o]), this.isFormHasNotTouched = (t, i) => i.some((o) => !t[o]), this.isFormTouched = (t, i) => i.some((o) => t[o]), this.isFormVisited = (t, i) => i.some((o) => t[o]), this.valueGetter = (t) => U(t)(this.values), this.valueSetter = (t, i) => k(t)(this.values, i), this.onArrayAction = (t) => {
|
|
119
|
+
this.addField(t), this.modified[t] || (this.modified = { ...this.modified, [t]: !0 }), this.onBlur(t, !0);
|
|
120
|
+
}, this.onInsert = (t, i) => {
|
|
121
|
+
this.onArrayAction(t);
|
|
122
|
+
const o = [...this.valueGetter(t) || []];
|
|
123
|
+
o.splice(i.index, 0, i.value), this.valueSetter(t, o), this.forceUpdate();
|
|
124
|
+
}, this.onUnshift = (t, i) => {
|
|
125
|
+
this.onInsert(t, {
|
|
126
|
+
value: i.value,
|
|
127
|
+
index: 0
|
|
128
|
+
});
|
|
129
|
+
}, this.onPush = (t, i) => {
|
|
130
|
+
this.onArrayAction(t);
|
|
131
|
+
const o = [...this.valueGetter(t) || [], i.value];
|
|
132
|
+
this.valueSetter(t, o), this.forceUpdate();
|
|
133
|
+
}, this.onPop = (t) => {
|
|
134
|
+
this.onArrayAction(t);
|
|
135
|
+
const i = [...this.valueGetter(t) || []], o = i.pop();
|
|
136
|
+
return this.valueSetter(t, i), this.forceUpdate(), o;
|
|
137
|
+
}, this.onRemove = (t, i) => {
|
|
138
|
+
this.onArrayAction(t);
|
|
139
|
+
const o = [...this.valueGetter(t) || []], r = o.splice(i.index, 1);
|
|
140
|
+
return this.valueSetter(t, o), this.forceUpdate(), r;
|
|
141
|
+
}, this.onReplace = (t, i) => {
|
|
142
|
+
this.onArrayAction(t);
|
|
143
|
+
const o = [...this.valueGetter(t) || []];
|
|
144
|
+
o.splice(i.index, 1, i.value), this.valueSetter(t, o), this.forceUpdate();
|
|
145
|
+
}, this.onMove = (t, i) => {
|
|
146
|
+
this.onArrayAction(t);
|
|
147
|
+
const o = [...this.valueGetter(t) || []], r = o[i.prevIndex];
|
|
148
|
+
o.splice(i.prevIndex, 1), o.splice(i.nextIndex, 0, r), this.valueSetter(t, o), this.forceUpdate();
|
|
149
|
+
}, B(M), this.values = C(e.initialValues);
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* @hidden
|
|
153
|
+
*/
|
|
154
|
+
get touched() {
|
|
155
|
+
return this._touched;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* @hidden
|
|
159
|
+
*/
|
|
160
|
+
set touched(e) {
|
|
161
|
+
this._touched = e;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* @hidden
|
|
165
|
+
*/
|
|
166
|
+
get visited() {
|
|
167
|
+
return this._visited;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* @hidden
|
|
171
|
+
*/
|
|
172
|
+
set visited(e) {
|
|
173
|
+
this._visited = e;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* @hidden
|
|
177
|
+
*/
|
|
178
|
+
get modified() {
|
|
179
|
+
return this._modified;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* @hidden
|
|
183
|
+
*/
|
|
184
|
+
set modified(e) {
|
|
185
|
+
this._modified = e;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* @hidden
|
|
189
|
+
*/
|
|
190
|
+
get validatorsByField() {
|
|
191
|
+
return this._validatorsByField;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* @hidden
|
|
195
|
+
*/
|
|
196
|
+
set validatorsByField(e) {
|
|
197
|
+
this._validatorsByField = e;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* @hidden
|
|
201
|
+
*/
|
|
202
|
+
get values() {
|
|
203
|
+
return this._values;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* @hidden
|
|
207
|
+
*/
|
|
208
|
+
set values(e) {
|
|
209
|
+
this._values = e;
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* @hidden
|
|
213
|
+
*/
|
|
214
|
+
get fields() {
|
|
215
|
+
return Object.keys(this._fields);
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* @hidden
|
|
219
|
+
*/
|
|
220
|
+
get formErrors() {
|
|
221
|
+
if (this.props.validator)
|
|
222
|
+
return this.props.validator(this.values, this.valueGetter);
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* @hidden
|
|
226
|
+
*/
|
|
227
|
+
get errors() {
|
|
228
|
+
const e = {}, t = this.fields, i = this.validatorsByField;
|
|
229
|
+
return t.forEach((r) => {
|
|
230
|
+
if (e[r] = "", i[r]) {
|
|
231
|
+
const d = [];
|
|
232
|
+
i[r].forEach((s) => {
|
|
233
|
+
Array.isArray(s) ? d.push(...s) : d.push(s);
|
|
234
|
+
}), d.find((s) => {
|
|
235
|
+
if (s) {
|
|
236
|
+
const a = s(this.valueGetter(r), this.valueGetter, { name: r });
|
|
237
|
+
if (a)
|
|
238
|
+
return e[r] = a, !0;
|
|
239
|
+
}
|
|
240
|
+
return !1;
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
}), this.formErrors && E(this.formErrors, e), e;
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* @hidden
|
|
247
|
+
*/
|
|
248
|
+
componentWillUnmount() {
|
|
249
|
+
this._unmounted = !0, this._accumulatorTimeout && clearTimeout(this._accumulatorTimeout);
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* @hidden
|
|
253
|
+
*/
|
|
254
|
+
render() {
|
|
255
|
+
const { render: e } = this.props, t = this.touched, i = this.visited, o = this.modified, r = this.fields, d = this.errors, s = this.isFormValid(d), a = this.isFormModified(o, r), c = this.isFormTouched(t, r), m = this.isFormVisited(i, r), v = this.isFormHasNotTouched(t, r) && !s || s && (this.props.ignoreModified || a);
|
|
256
|
+
return /* @__PURE__ */ n.createElement(
|
|
257
|
+
y.Provider,
|
|
258
|
+
{
|
|
259
|
+
key: this._id,
|
|
260
|
+
value: {
|
|
261
|
+
id: this._id,
|
|
262
|
+
valueGetter: this.valueGetter,
|
|
263
|
+
errors: d,
|
|
264
|
+
modified: o,
|
|
265
|
+
touched: t,
|
|
266
|
+
visited: i,
|
|
267
|
+
registerField: this.onFieldRegister,
|
|
268
|
+
onSubmit: this.onSubmit,
|
|
269
|
+
onChange: this.onChange,
|
|
270
|
+
onFocus: this.onFocus,
|
|
271
|
+
onBlur: this.onBlur,
|
|
272
|
+
onUnshift: this.onUnshift,
|
|
273
|
+
onPush: this.onPush,
|
|
274
|
+
onInsert: this.onInsert,
|
|
275
|
+
onPop: this.onPop,
|
|
276
|
+
onRemove: this.onRemove,
|
|
277
|
+
onReplace: this.onReplace,
|
|
278
|
+
onMove: this.onMove
|
|
279
|
+
}
|
|
280
|
+
},
|
|
281
|
+
e({
|
|
282
|
+
valid: s,
|
|
283
|
+
modified: a,
|
|
284
|
+
touched: c,
|
|
285
|
+
visited: m,
|
|
286
|
+
submitted: this._submitted,
|
|
287
|
+
valueGetter: this.valueGetter,
|
|
288
|
+
errors: d,
|
|
289
|
+
allowSubmit: v,
|
|
290
|
+
onChange: this.onChange,
|
|
291
|
+
onSubmit: this.onSubmit,
|
|
292
|
+
onFormReset: this.resetForm
|
|
293
|
+
})
|
|
294
|
+
);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
A.displayName = "KendoReactForm";
|
|
298
|
+
A.propTypes = {
|
|
299
|
+
initialValues: F.any,
|
|
300
|
+
onSubmit: F.func,
|
|
301
|
+
onSubmitClick: F.func,
|
|
302
|
+
render: F.func.isRequired
|
|
303
|
+
};
|
|
304
|
+
const P = (l) => {
|
|
305
|
+
const { name: e, component: t, validator: i, type: o, children: r, ...d } = l, s = n.useContext(y), a = s ? s.id : "";
|
|
306
|
+
n.useEffect(
|
|
307
|
+
() => s ? s.registerField(e, i) : void 0,
|
|
308
|
+
[e, a, i]
|
|
309
|
+
);
|
|
310
|
+
const c = n.useCallback(
|
|
311
|
+
(h) => s.onUnshift(e, h),
|
|
312
|
+
[e, a]
|
|
313
|
+
), m = n.useCallback(
|
|
314
|
+
(h) => s.onPush(e, h),
|
|
315
|
+
[e, a]
|
|
316
|
+
), f = n.useCallback(
|
|
317
|
+
(h) => s.onInsert(e, h),
|
|
318
|
+
[e, a]
|
|
319
|
+
), v = n.useCallback(
|
|
320
|
+
() => s.onPop(e),
|
|
321
|
+
[e, a]
|
|
322
|
+
), p = n.useCallback(
|
|
323
|
+
(h) => s.onRemove(e, h),
|
|
324
|
+
[e, a]
|
|
325
|
+
), u = n.useCallback(
|
|
326
|
+
(h) => s.onReplace(e, h),
|
|
327
|
+
[e, a]
|
|
328
|
+
), g = n.useCallback(
|
|
329
|
+
(h) => s.onMove(e, h),
|
|
330
|
+
[e, a]
|
|
331
|
+
);
|
|
332
|
+
if (!s)
|
|
333
|
+
return null;
|
|
334
|
+
const R = s.valueGetter(e);
|
|
335
|
+
return n.createElement(
|
|
336
|
+
t,
|
|
337
|
+
{
|
|
338
|
+
// input
|
|
339
|
+
value: R,
|
|
340
|
+
// meta
|
|
341
|
+
validationMessage: s.errors[e],
|
|
342
|
+
touched: s.touched[e],
|
|
343
|
+
modified: s.modified[e],
|
|
344
|
+
visited: s.visited[e],
|
|
345
|
+
// Our `valid` implementation requires double submit to show html5 validation errors,
|
|
346
|
+
// however it's NOT recommended to show html5 validation errors at all as:
|
|
347
|
+
// - There is no standard way to change validation look and feel with CSS.
|
|
348
|
+
// - Look different in each browser / OS
|
|
349
|
+
// - You can have a page in one language but an error message displayed in another language (not localizable)
|
|
350
|
+
valid: !(s.errors[e] && s.touched[e]),
|
|
351
|
+
onUnshift: c,
|
|
352
|
+
onPush: m,
|
|
353
|
+
onInsert: f,
|
|
354
|
+
onPop: v,
|
|
355
|
+
onRemove: p,
|
|
356
|
+
onReplace: u,
|
|
357
|
+
onMove: g,
|
|
358
|
+
children: r,
|
|
359
|
+
name: e,
|
|
360
|
+
...d
|
|
361
|
+
}
|
|
362
|
+
);
|
|
363
|
+
};
|
|
364
|
+
P.displayName = "KendoReactFieldArray";
|
|
365
|
+
const x = (l) => {
|
|
366
|
+
const e = b(
|
|
367
|
+
{
|
|
368
|
+
"k-form-field": !0,
|
|
369
|
+
"k-rtl": l.dir === "rtl"
|
|
370
|
+
},
|
|
371
|
+
l.className
|
|
372
|
+
);
|
|
373
|
+
return /* @__PURE__ */ n.createElement("div", { className: e, style: l.style }, l.children);
|
|
374
|
+
};
|
|
375
|
+
x.displayName = "KendoReactFieldWrapper";
|
|
376
|
+
const V = n.forwardRef((l, e) => {
|
|
377
|
+
const t = {
|
|
378
|
+
size: "medium",
|
|
379
|
+
...l
|
|
380
|
+
}, i = n.useRef(null), o = n.useRef(null);
|
|
381
|
+
n.useImperativeHandle(o, () => ({ element: i.current, props: t })), n.useImperativeHandle(e, () => o.current);
|
|
382
|
+
const r = n.useContext(y), { className: d, style: s, horizontal: a, size: c, ...m } = t, f = b(
|
|
383
|
+
{
|
|
384
|
+
"k-form": !0,
|
|
385
|
+
[`k-form-${T.sizeMap[c] || c}`]: c,
|
|
386
|
+
"k-form-horizontal": a === !0
|
|
387
|
+
},
|
|
388
|
+
d
|
|
389
|
+
);
|
|
390
|
+
return /* @__PURE__ */ n.createElement(
|
|
391
|
+
"form",
|
|
392
|
+
{
|
|
393
|
+
ref: i,
|
|
394
|
+
...m,
|
|
395
|
+
style: l.style,
|
|
396
|
+
className: f,
|
|
397
|
+
onSubmit: r ? r.onSubmit : void 0
|
|
398
|
+
},
|
|
399
|
+
l.children
|
|
400
|
+
);
|
|
401
|
+
});
|
|
402
|
+
V.displayName = "KendoReactFormElement";
|
|
403
|
+
export {
|
|
404
|
+
S as Field,
|
|
405
|
+
P as FieldArray,
|
|
406
|
+
x as FieldWrapper,
|
|
407
|
+
A as Form,
|
|
408
|
+
V as FormElement
|
|
409
|
+
};
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
/**-----------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright © 2023 Progress Software Corporation. All rights reserved.
|
|
3
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
4
|
+
*-------------------------------------------------------------------------------------------*/
|
|
2
5
|
import { FieldValidatorType } from './FieldValidator';
|
|
3
6
|
/**
|
|
4
7
|
* Represents the props of the FieldArray component that is used inside the KendoReact Form component.
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/**-----------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright © 2023 Progress Software Corporation. All rights reserved.
|
|
3
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
4
|
+
*-------------------------------------------------------------------------------------------*/
|
|
1
5
|
/**
|
|
2
6
|
* Represents the props that are passed to the component which is rendered by FieldArray.
|
|
3
7
|
*/
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
/**-----------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright © 2023 Progress Software Corporation. All rights reserved.
|
|
3
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
4
|
+
*-------------------------------------------------------------------------------------------*/
|
|
2
5
|
import { FieldValidatorType } from './FieldValidator';
|
|
3
6
|
/**
|
|
4
7
|
* Represents the props of the Field component that is used inside the KendoReact Form component.
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/**-----------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright © 2023 Progress Software Corporation. All rights reserved.
|
|
3
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
4
|
+
*-------------------------------------------------------------------------------------------*/
|
|
1
5
|
/**
|
|
2
6
|
* Represents the props that are passed to the component which is rendered by Field.
|
|
3
7
|
*/
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/**-----------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright © 2023 Progress Software Corporation. All rights reserved.
|
|
3
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
4
|
+
*-------------------------------------------------------------------------------------------*/
|
|
1
5
|
/**
|
|
2
6
|
* The validator function for the Field component. The function arguments are:
|
|
3
7
|
*
|
|
@@ -9,6 +13,6 @@
|
|
|
9
13
|
*
|
|
10
14
|
* Returns `string` to signify error or `undefined` to signify validation success.
|
|
11
15
|
*/
|
|
12
|
-
export
|
|
16
|
+
export type FieldValidatorType = (value: any, valueGetter: (name: string) => any, fieldProps: {
|
|
13
17
|
name: string;
|
|
14
18
|
}) => string | undefined;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
/**-----------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright © 2023 Progress Software Corporation. All rights reserved.
|
|
3
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
4
|
+
*-------------------------------------------------------------------------------------------*/
|
|
2
5
|
import { FormRenderProps } from './FormRenderProps';
|
|
3
6
|
import { FormValidatorType } from './FormValidator';
|
|
4
7
|
import { FormSubmitClickEvent } from './FormSubmitClickEvent';
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
/**-----------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright © 2023 Progress Software Corporation. All rights reserved.
|
|
3
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
4
|
+
*-------------------------------------------------------------------------------------------*/
|
|
2
5
|
import { KeyValue } from './KeyValue';
|
|
3
6
|
/**
|
|
4
7
|
* Represents the props that are passed to the `render` option component of the Form.
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
/**-----------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright © 2023 Progress Software Corporation. All rights reserved.
|
|
3
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
4
|
+
*-------------------------------------------------------------------------------------------*/
|
|
2
5
|
/**
|
|
3
6
|
* The FormSubmitClick event.
|
|
4
7
|
*/
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**-----------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright © 2023 Progress Software Corporation. All rights reserved.
|
|
3
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
4
|
+
*-------------------------------------------------------------------------------------------*/
|
|
5
|
+
import { KeyValue } from './KeyValue';
|
|
6
|
+
/**
|
|
7
|
+
* The validator function for the Form component.
|
|
8
|
+
*
|
|
9
|
+
* * values - The current values of the form.
|
|
10
|
+
* * valueGetter - Function which can be used to get field value. Supports field paths.
|
|
11
|
+
*
|
|
12
|
+
* Returns key-value pair with errors if such are present. The key is the field path, where the value is the error message.
|
|
13
|
+
*/
|
|
14
|
+
export type FormValidatorType = (values: any, valueGetter: (name: string) => any) => KeyValue<string> | undefined;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**-----------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright © 2023 Progress Software Corporation. All rights reserved.
|
|
3
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
4
|
+
*-------------------------------------------------------------------------------------------*/
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
export interface KeyValue<ValueType> {
|
|
9
|
+
[name: string]: ValueType;
|
|
10
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**-----------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright © 2023 Progress Software Corporation. All rights reserved.
|
|
3
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
4
|
+
*-------------------------------------------------------------------------------------------*/
|
|
5
|
+
import { PackageMetadata } from '@progress/kendo-licensing';
|
|
6
|
+
/**
|
|
7
|
+
* @hidden
|
|
8
|
+
*/
|
|
9
|
+
export declare const packageMetadata: PackageMetadata;
|
package/package.json
CHANGED
|
@@ -1,20 +1,28 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@progress/kendo-react-form",
|
|
3
|
+
"version": "7.0.0-develop.1",
|
|
3
4
|
"description": "React Form is a small and fast package for form state management with zero dependencies. KendoReact Form package",
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
"author": "Progress",
|
|
6
|
+
"license": "SEE LICENSE IN LICENSE.md",
|
|
7
|
+
"homepage": "https://www.telerik.com/kendo-react-ui",
|
|
8
|
+
"main": "./index.js",
|
|
9
|
+
"types": "./index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"import": "./index.mjs",
|
|
13
|
+
"require": "./index.js"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"sideEffects": false,
|
|
17
|
+
"peerDependencies": {
|
|
18
|
+
"@progress/kendo-licensing": "^1.3.0",
|
|
19
|
+
"@progress/kendo-react-common": "7.0.0-develop.1",
|
|
20
|
+
"react": "^16.8.2 || ^17.0.0 || ^18.0.0",
|
|
21
|
+
"react-dom": "^16.8.2 || ^17.0.0 || ^18.0.0"
|
|
8
22
|
},
|
|
9
|
-
"
|
|
10
|
-
|
|
11
|
-
"module": "dist/es/main.js",
|
|
12
|
-
"jsnext:main": "dist/es/main.js",
|
|
13
|
-
"scripts": {
|
|
14
|
-
"test": "cd ../../ && npm run test -- --testPathPattern=/packages/form/.*",
|
|
15
|
-
"build-package": "gulp build-package"
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"prop-types": "^15.6.0"
|
|
16
25
|
},
|
|
17
|
-
"homepage": "https://www.telerik.com/kendo-react-ui",
|
|
18
26
|
"keywords": [
|
|
19
27
|
"Kendo UI",
|
|
20
28
|
"React",
|
|
@@ -27,39 +35,15 @@
|
|
|
27
35
|
"React component",
|
|
28
36
|
"Telerik"
|
|
29
37
|
],
|
|
30
|
-
"peerDependencies": {
|
|
31
|
-
"@progress/kendo-licensing": "^1.3.0",
|
|
32
|
-
"react": "^16.8.2 || ^17.0.0 || ^18.0.0",
|
|
33
|
-
"react-dom": "^16.8.2 || ^17.0.0 || ^18.0.0"
|
|
34
|
-
},
|
|
35
|
-
"dependencies": {
|
|
36
|
-
"@progress/kendo-react-common": "6.1.1",
|
|
37
|
-
"prop-types": "^15.6.0"
|
|
38
|
-
},
|
|
39
38
|
"@progress": {
|
|
40
39
|
"friendlyName": "Form",
|
|
41
40
|
"framework": "KendoReact"
|
|
42
41
|
},
|
|
43
|
-
"
|
|
44
|
-
|
|
42
|
+
"repository": {
|
|
43
|
+
"type": "git",
|
|
44
|
+
"url": "https://github.com/telerik/kendo-react.git"
|
|
45
|
+
},
|
|
45
46
|
"publishConfig": {
|
|
46
47
|
"access": "public"
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
"@progress/kendo-data-query": "^1.0.0",
|
|
50
|
-
"@progress/kendo-date-math": "^1.4.1",
|
|
51
|
-
"@progress/kendo-drawing": "^1.17.2",
|
|
52
|
-
"@progress/kendo-licensing": "^1.3.0",
|
|
53
|
-
"@progress/kendo-react-buttons": "6.1.1",
|
|
54
|
-
"@progress/kendo-react-data-tools": "6.1.1",
|
|
55
|
-
"@progress/kendo-react-dateinputs": "6.1.1",
|
|
56
|
-
"@progress/kendo-react-dropdowns": "6.1.1",
|
|
57
|
-
"@progress/kendo-react-grid": "6.1.1",
|
|
58
|
-
"@progress/kendo-react-inputs": "6.1.1",
|
|
59
|
-
"@progress/kendo-react-intl": "6.1.1",
|
|
60
|
-
"@progress/kendo-react-labels": "6.1.1",
|
|
61
|
-
"@progress/kendo-react-layout": "6.1.1",
|
|
62
|
-
"@progress/kendo-react-upload": "6.1.1"
|
|
63
|
-
},
|
|
64
|
-
"sideEffects": false
|
|
65
|
-
}
|
|
48
|
+
}
|
|
49
|
+
}
|
package/about.md
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
<a href="https://www.telerik.com/kendo-react-ui?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-form&utm_content=banner" target="_blank">
|
|
2
|
-
<img src="https://www.telerik.com/kendo-react-ui/components/npm-banner.svg" alt="KendoReact NPM Banner">
|
|
3
|
-
</a>
|