@progress/kendo-vue-form 5.3.0-dev.202409130647 → 5.3.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.
Files changed (137) hide show
  1. package/Field.js +8 -0
  2. package/Field.mjs +124 -0
  3. package/FieldArray.js +8 -0
  4. package/FieldArray.mjs +102 -0
  5. package/FieldWrapper.js +8 -0
  6. package/FieldWrapper.mjs +37 -0
  7. package/Form.js +8 -0
  8. package/Form.mjs +294 -0
  9. package/FormElement.js +8 -0
  10. package/FormElement.mjs +58 -0
  11. package/README.md +24 -25
  12. package/dist/cdn/js/kendo-vue-form.js +8 -1
  13. package/index.d.mts +921 -0
  14. package/index.d.ts +921 -0
  15. package/index.js +8 -0
  16. package/index.mjs +19 -0
  17. package/package-metadata.js +8 -0
  18. package/package-metadata.mjs +18 -0
  19. package/package.json +21 -48
  20. package/dist/es/Field.d.ts +0 -44
  21. package/dist/es/Field.js +0 -160
  22. package/dist/es/FieldArray.d.ts +0 -50
  23. package/dist/es/FieldArray.js +0 -128
  24. package/dist/es/FieldWrapper.d.ts +0 -61
  25. package/dist/es/FieldWrapper.js +0 -46
  26. package/dist/es/Form.d.ts +0 -62
  27. package/dist/es/Form.js +0 -424
  28. package/dist/es/FormContext.d.ts +0 -45
  29. package/dist/es/FormContext.js +0 -1
  30. package/dist/es/FormElement.d.ts +0 -75
  31. package/dist/es/FormElement.js +0 -70
  32. package/dist/es/additionalTypes.ts +0 -21
  33. package/dist/es/interfaces/FieldArrayProps.d.ts +0 -24
  34. package/dist/es/interfaces/FieldArrayProps.js +0 -1
  35. package/dist/es/interfaces/FieldArrayRenderProps.d.ts +0 -85
  36. package/dist/es/interfaces/FieldArrayRenderProps.js +0 -1
  37. package/dist/es/interfaces/FieldInjectedProps.d.ts +0 -156
  38. package/dist/es/interfaces/FieldInjectedProps.js +0 -1
  39. package/dist/es/interfaces/FieldProps.d.ts +0 -36
  40. package/dist/es/interfaces/FieldProps.js +0 -1
  41. package/dist/es/interfaces/FieldRenderProps.d.ts +0 -61
  42. package/dist/es/interfaces/FieldRenderProps.js +0 -1
  43. package/dist/es/interfaces/FieldValidator.d.ts +0 -14
  44. package/dist/es/interfaces/FieldValidator.js +0 -1
  45. package/dist/es/interfaces/FormProps.d.ts +0 -48
  46. package/dist/es/interfaces/FormProps.js +0 -1
  47. package/dist/es/interfaces/FormRenderProps.d.ts +0 -75
  48. package/dist/es/interfaces/FormRenderProps.js +0 -1
  49. package/dist/es/interfaces/FormSubmitClickEvent.d.ts +0 -23
  50. package/dist/es/interfaces/FormSubmitClickEvent.js +0 -1
  51. package/dist/es/interfaces/FormValidator.d.ts +0 -11
  52. package/dist/es/interfaces/FormValidator.js +0 -1
  53. package/dist/es/interfaces/KeyValue.d.ts +0 -6
  54. package/dist/es/interfaces/KeyValue.js +0 -1
  55. package/dist/es/main.d.ts +0 -17
  56. package/dist/es/main.js +0 -6
  57. package/dist/es/package-metadata.d.ts +0 -5
  58. package/dist/es/package-metadata.js +0 -11
  59. package/dist/esm/Field.d.ts +0 -44
  60. package/dist/esm/Field.js +0 -160
  61. package/dist/esm/FieldArray.d.ts +0 -50
  62. package/dist/esm/FieldArray.js +0 -128
  63. package/dist/esm/FieldWrapper.d.ts +0 -61
  64. package/dist/esm/FieldWrapper.js +0 -46
  65. package/dist/esm/Form.d.ts +0 -62
  66. package/dist/esm/Form.js +0 -424
  67. package/dist/esm/FormContext.d.ts +0 -45
  68. package/dist/esm/FormContext.js +0 -1
  69. package/dist/esm/FormElement.d.ts +0 -75
  70. package/dist/esm/FormElement.js +0 -70
  71. package/dist/esm/additionalTypes.ts +0 -21
  72. package/dist/esm/interfaces/FieldArrayProps.d.ts +0 -24
  73. package/dist/esm/interfaces/FieldArrayProps.js +0 -1
  74. package/dist/esm/interfaces/FieldArrayRenderProps.d.ts +0 -85
  75. package/dist/esm/interfaces/FieldArrayRenderProps.js +0 -1
  76. package/dist/esm/interfaces/FieldInjectedProps.d.ts +0 -156
  77. package/dist/esm/interfaces/FieldInjectedProps.js +0 -1
  78. package/dist/esm/interfaces/FieldProps.d.ts +0 -36
  79. package/dist/esm/interfaces/FieldProps.js +0 -1
  80. package/dist/esm/interfaces/FieldRenderProps.d.ts +0 -61
  81. package/dist/esm/interfaces/FieldRenderProps.js +0 -1
  82. package/dist/esm/interfaces/FieldValidator.d.ts +0 -14
  83. package/dist/esm/interfaces/FieldValidator.js +0 -1
  84. package/dist/esm/interfaces/FormProps.d.ts +0 -48
  85. package/dist/esm/interfaces/FormProps.js +0 -1
  86. package/dist/esm/interfaces/FormRenderProps.d.ts +0 -75
  87. package/dist/esm/interfaces/FormRenderProps.js +0 -1
  88. package/dist/esm/interfaces/FormSubmitClickEvent.d.ts +0 -23
  89. package/dist/esm/interfaces/FormSubmitClickEvent.js +0 -1
  90. package/dist/esm/interfaces/FormValidator.d.ts +0 -11
  91. package/dist/esm/interfaces/FormValidator.js +0 -1
  92. package/dist/esm/interfaces/KeyValue.d.ts +0 -6
  93. package/dist/esm/interfaces/KeyValue.js +0 -1
  94. package/dist/esm/main.d.ts +0 -17
  95. package/dist/esm/main.js +0 -6
  96. package/dist/esm/package-metadata.d.ts +0 -5
  97. package/dist/esm/package-metadata.js +0 -11
  98. package/dist/esm/package.json +0 -3
  99. package/dist/npm/Field.d.ts +0 -44
  100. package/dist/npm/Field.js +0 -167
  101. package/dist/npm/FieldArray.d.ts +0 -50
  102. package/dist/npm/FieldArray.js +0 -135
  103. package/dist/npm/FieldWrapper.d.ts +0 -61
  104. package/dist/npm/FieldWrapper.js +0 -53
  105. package/dist/npm/Form.d.ts +0 -62
  106. package/dist/npm/Form.js +0 -431
  107. package/dist/npm/FormContext.d.ts +0 -45
  108. package/dist/npm/FormContext.js +0 -2
  109. package/dist/npm/FormElement.d.ts +0 -75
  110. package/dist/npm/FormElement.js +0 -77
  111. package/dist/npm/additionalTypes.ts +0 -21
  112. package/dist/npm/interfaces/FieldArrayProps.d.ts +0 -24
  113. package/dist/npm/interfaces/FieldArrayProps.js +0 -2
  114. package/dist/npm/interfaces/FieldArrayRenderProps.d.ts +0 -85
  115. package/dist/npm/interfaces/FieldArrayRenderProps.js +0 -2
  116. package/dist/npm/interfaces/FieldInjectedProps.d.ts +0 -156
  117. package/dist/npm/interfaces/FieldInjectedProps.js +0 -2
  118. package/dist/npm/interfaces/FieldProps.d.ts +0 -36
  119. package/dist/npm/interfaces/FieldProps.js +0 -2
  120. package/dist/npm/interfaces/FieldRenderProps.d.ts +0 -61
  121. package/dist/npm/interfaces/FieldRenderProps.js +0 -2
  122. package/dist/npm/interfaces/FieldValidator.d.ts +0 -14
  123. package/dist/npm/interfaces/FieldValidator.js +0 -2
  124. package/dist/npm/interfaces/FormProps.d.ts +0 -48
  125. package/dist/npm/interfaces/FormProps.js +0 -2
  126. package/dist/npm/interfaces/FormRenderProps.d.ts +0 -75
  127. package/dist/npm/interfaces/FormRenderProps.js +0 -2
  128. package/dist/npm/interfaces/FormSubmitClickEvent.d.ts +0 -23
  129. package/dist/npm/interfaces/FormSubmitClickEvent.js +0 -2
  130. package/dist/npm/interfaces/FormValidator.d.ts +0 -11
  131. package/dist/npm/interfaces/FormValidator.js +0 -2
  132. package/dist/npm/interfaces/KeyValue.d.ts +0 -6
  133. package/dist/npm/interfaces/KeyValue.js +0 -2
  134. package/dist/npm/main.d.ts +0 -17
  135. package/dist/npm/main.js +0 -18
  136. package/dist/npm/package-metadata.d.ts +0 -5
  137. package/dist/npm/package-metadata.js +0 -14
package/Field.js ADDED
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @license
3
+ *-------------------------------------------------------------------------------------------
4
+ * Copyright © 2024 Progress Software Corporation. All rights reserved.
5
+ * Licensed under commercial license. See LICENSE.md in the package root for more information
6
+ *-------------------------------------------------------------------------------------------
7
+ */
8
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("vue"),o=require("@progress/kendo-vue-common"),l=r.defineComponent({name:"KendoField",props:{component:[String,Number,Boolean,Object],validator:[Function,Array],name:String,changeOnInput:{type:Boolean,default:!0},id:String,resource:Object,multiple:Boolean,dataItems:Array,textField:String,valueField:String,colorField:String,rows:Number,field:String,start:String,value:[String,Number,Boolean,Object],width:String,editorId:String,isAllDay:Boolean,timezone:String},created(){return this.kendoForm?this.kendoForm.registerField(this.$props.name,this.$props.validator):void 0},inject:{kendoForm:{default:null}},methods:{handleOnChange(e){const t=e&&(e.value!==void 0?e.value:e.target?e.target.value:e.target);this.kendoForm.onChange(this.$props.name,{value:t}),this.$emit("change",e)},handleOnInput(e){const t=e&&(e.value!==void 0?e.value:e.target?e.target.value:e.target);this.changeOnInput&&this.kendoForm.onChange(this.$props.name,{value:t}),this.$emit("input",e)},onNativeComponentChange(e){this.kendoForm.onChange(this.$props.name,{value:e.target.value})},handleOnBlur(){this.kendoForm.onBlur(this.$props.name)},handleOnFocus(){this.kendoForm.onFocus(this.$props.name)}},render(){const e=o.getDefaultSlots(this),{name:t,component:n,id:a}=this.$props;if(!this.kendoForm)return null;const i=this.kendoForm.values[t];if(typeof n=="string"&&n==="input")return r.h(n,{attrs:this.$attrs,...this.$attrs,onChange:this.onNativeComponentChange,onBlur:this.handleOnBlur,onFocus:this.handleOnFocus,name:t,value:i||""});if(n){const s=o.templateRendering.call(this,n,o.getListeners.call(this));return o.getTemplate.call(this,{h:r.h,template:s,additionalProps:{value:i,validationMessage:this.kendoForm.errors[t],touched:this.kendoForm.touchedByField[t],modified:this.kendoForm.modifiedByField[t],visited:this.kendoForm.visitedByField[t],valid:!(this.kendoForm.errors[t]&&this.kendoForm.touchedByField[t]),name:t,id:a,...this.$attrs},additionalListeners:{change:this.handleOnChange,input:this.handleOnInput,blur:this.handleOnBlur,focus:this.handleOnFocus},defaultSlots:e})}}});exports.Field=l;
package/Field.mjs ADDED
@@ -0,0 +1,124 @@
1
+ /**
2
+ * @license
3
+ *-------------------------------------------------------------------------------------------
4
+ * Copyright © 2024 Progress Software Corporation. All rights reserved.
5
+ * Licensed under commercial license. See LICENSE.md in the package root for more information
6
+ *-------------------------------------------------------------------------------------------
7
+ */
8
+ import { defineComponent as s, h as i } from "vue";
9
+ import { getDefaultSlots as l, templateRendering as d, getListeners as h, getTemplate as u } from "@progress/kendo-vue-common";
10
+ const g = /* @__PURE__ */ s({
11
+ name: "KendoField",
12
+ props: {
13
+ component: [String, Number, Boolean, Object],
14
+ validator: [Function, Array],
15
+ name: String,
16
+ changeOnInput: {
17
+ type: Boolean,
18
+ default: !0
19
+ },
20
+ id: String,
21
+ resource: Object,
22
+ multiple: Boolean,
23
+ dataItems: Array,
24
+ textField: String,
25
+ valueField: String,
26
+ colorField: String,
27
+ rows: Number,
28
+ field: String,
29
+ start: String,
30
+ value: [String, Number, Boolean, Object],
31
+ width: String,
32
+ editorId: String,
33
+ isAllDay: Boolean,
34
+ timezone: String
35
+ },
36
+ created() {
37
+ return this.kendoForm ? this.kendoForm.registerField(this.$props.name, this.$props.validator) : void 0;
38
+ },
39
+ inject: {
40
+ kendoForm: {
41
+ default: null
42
+ }
43
+ },
44
+ methods: {
45
+ handleOnChange(e) {
46
+ const t = e && (e.value !== void 0 ? e.value : e.target ? e.target.value : e.target);
47
+ this.kendoForm.onChange(this.$props.name, {
48
+ value: t
49
+ }), this.$emit("change", e);
50
+ },
51
+ handleOnInput(e) {
52
+ const t = e && (e.value !== void 0 ? e.value : e.target ? e.target.value : e.target);
53
+ this.changeOnInput && this.kendoForm.onChange(this.$props.name, {
54
+ value: t
55
+ }), this.$emit("input", e);
56
+ },
57
+ onNativeComponentChange(e) {
58
+ this.kendoForm.onChange(this.$props.name, {
59
+ value: e.target.value
60
+ });
61
+ },
62
+ handleOnBlur() {
63
+ this.kendoForm.onBlur(this.$props.name);
64
+ },
65
+ handleOnFocus() {
66
+ this.kendoForm.onFocus(this.$props.name);
67
+ }
68
+ },
69
+ render() {
70
+ const e = l(this), {
71
+ name: t,
72
+ component: n,
73
+ id: r
74
+ } = this.$props;
75
+ if (!this.kendoForm)
76
+ return null;
77
+ const o = this.kendoForm.values[t];
78
+ if (typeof n == "string" && n === "input")
79
+ return i(n, {
80
+ attrs: this.$attrs,
81
+ ...this.$attrs,
82
+ onChange: this.onNativeComponentChange,
83
+ onBlur: this.handleOnBlur,
84
+ onFocus: this.handleOnFocus,
85
+ name: t,
86
+ value: o || ""
87
+ });
88
+ if (n) {
89
+ const a = d.call(this, n, h.call(this));
90
+ return u.call(this, {
91
+ h: i,
92
+ template: a,
93
+ additionalProps: {
94
+ value: o,
95
+ // meta
96
+ validationMessage: this.kendoForm.errors[t],
97
+ touched: this.kendoForm.touchedByField[t],
98
+ modified: this.kendoForm.modifiedByField[t],
99
+ visited: this.kendoForm.visitedByField[t],
100
+ // Our `valid` implementation requires double submit to show html5 validation errors,
101
+ // however it's NOT recommended to show html5 validation errors at all as:
102
+ // - There is no standard way to change validation look and feel with CSS.
103
+ // - Look different in each browser / OS
104
+ // - You can have a page in one language but an error message
105
+ // displayed in another language (not localizable)
106
+ valid: !(this.kendoForm.errors[t] && this.kendoForm.touchedByField[t]),
107
+ name: t,
108
+ id: r,
109
+ ...this.$attrs
110
+ },
111
+ additionalListeners: {
112
+ change: this.handleOnChange,
113
+ input: this.handleOnInput,
114
+ blur: this.handleOnBlur,
115
+ focus: this.handleOnFocus
116
+ },
117
+ defaultSlots: e
118
+ });
119
+ }
120
+ }
121
+ });
122
+ export {
123
+ g as Field
124
+ };
package/FieldArray.js ADDED
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @license
3
+ *-------------------------------------------------------------------------------------------
4
+ * Copyright © 2024 Progress Software Corporation. All rights reserved.
5
+ * Licensed under commercial license. See LICENSE.md in the package root for more information
6
+ *-------------------------------------------------------------------------------------------
7
+ */
8
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("vue"),n=require("@progress/kendo-vue-common"),d=t.defineComponent({name:"KendoFieldArray",props:{value:[String,Number,Boolean,Object,Array],component:[String,Number,Boolean,Object],validationMessage:String,touched:Boolean,modified:Boolean,validator:[Function,Array],visited:Boolean,valid:Boolean,name:String,id:String},created(){return this.kendoForm?this.kendoForm.registerField(this.$props.name,this.$props.validator):void 0},methods:{onUnshift(e){this.kendoForm.onUnshift(this.$props.name,e)},onPush(e){this.kendoForm.onPush(this.$props.name,e)},onInsert(e){this.kendoForm.onInsert(this.$props.name,e)},onPop(){this.kendoForm.onPop(this.$props.name)},onRemove(e){this.kendoForm.onRemove(this.$props.name,e)},onReplace(e){this.kendoForm.onReplace(this.$props.name,e)},onMove(e){this.kendoForm.onMove(this.$props.name,e)}},inject:{kendoForm:{default:null}},render(){const{name:e,component:o,id:i}=this.$props;if(!this.kendoForm)return null;const r=this.kendoForm.values[e];if(o){const s=o?n.templateRendering.call(this,o,n.getListeners.call(this)):null;return n.getTemplate.call(this,{h:t.h,template:s,additionalProps:{value:r,validationMessage:this.kendoForm.errors[e],touched:this.kendoForm.touchedByField[e],modified:this.kendoForm.modifiedByField[e],visited:this.kendoForm.visitedByField[e],valid:!(this.kendoForm.errors[e]&&this.kendoForm.touchedByField[e]),name:e,id:i,...this.$attrs},additionalListeners:{unshift:this.onUnshift,push:this.onPush,insert:this.onInsert,pop:this.onPop,remove:this.onRemove,replace:this.onReplace,move:this.onMove}})}}});exports.FieldArray=d;
package/FieldArray.mjs ADDED
@@ -0,0 +1,102 @@
1
+ /**
2
+ * @license
3
+ *-------------------------------------------------------------------------------------------
4
+ * Copyright © 2024 Progress Software Corporation. All rights reserved.
5
+ * Licensed under commercial license. See LICENSE.md in the package root for more information
6
+ *-------------------------------------------------------------------------------------------
7
+ */
8
+ import { defineComponent as r, h as s } from "vue";
9
+ import { templateRendering as d, getListeners as a, getTemplate as h } from "@progress/kendo-vue-common";
10
+ const p = /* @__PURE__ */ r({
11
+ name: "KendoFieldArray",
12
+ props: {
13
+ value: [String, Number, Boolean, Object, Array],
14
+ component: [String, Number, Boolean, Object],
15
+ validationMessage: String,
16
+ touched: Boolean,
17
+ modified: Boolean,
18
+ validator: [Function, Array],
19
+ visited: Boolean,
20
+ valid: Boolean,
21
+ name: String,
22
+ id: String
23
+ },
24
+ created() {
25
+ return this.kendoForm ? this.kendoForm.registerField(this.$props.name, this.$props.validator) : void 0;
26
+ },
27
+ methods: {
28
+ onUnshift(e) {
29
+ this.kendoForm.onUnshift(this.$props.name, e);
30
+ },
31
+ onPush(e) {
32
+ this.kendoForm.onPush(this.$props.name, e);
33
+ },
34
+ onInsert(e) {
35
+ this.kendoForm.onInsert(this.$props.name, e);
36
+ },
37
+ onPop() {
38
+ this.kendoForm.onPop(this.$props.name);
39
+ },
40
+ onRemove(e) {
41
+ this.kendoForm.onRemove(this.$props.name, e);
42
+ },
43
+ onReplace(e) {
44
+ this.kendoForm.onReplace(this.$props.name, e);
45
+ },
46
+ onMove(e) {
47
+ this.kendoForm.onMove(this.$props.name, e);
48
+ }
49
+ },
50
+ inject: {
51
+ kendoForm: {
52
+ default: null
53
+ }
54
+ },
55
+ render() {
56
+ const {
57
+ name: e,
58
+ component: o,
59
+ id: n
60
+ } = this.$props;
61
+ if (!this.kendoForm)
62
+ return null;
63
+ const t = this.kendoForm.values[e];
64
+ if (o) {
65
+ const i = o ? d.call(this, o, a.call(this)) : null;
66
+ return h.call(this, {
67
+ h: s,
68
+ template: i,
69
+ additionalProps: {
70
+ value: t,
71
+ // meta
72
+ validationMessage: this.kendoForm.errors[e],
73
+ touched: this.kendoForm.touchedByField[e],
74
+ modified: this.kendoForm.modifiedByField[e],
75
+ visited: this.kendoForm.visitedByField[e],
76
+ // Our `valid` implementation requires double submit to show html5 validation errors,
77
+ // however it's NOT recommended to show html5 validation errors at all as:
78
+ // - There is no standard way to change validation look and feel with CSS.
79
+ // - Look different in each browser / OS
80
+ // - You can have a page in one language but an error message
81
+ // displayed in another language (not localizable)
82
+ valid: !(this.kendoForm.errors[e] && this.kendoForm.touchedByField[e]),
83
+ name: e,
84
+ id: n,
85
+ ...this.$attrs
86
+ },
87
+ additionalListeners: {
88
+ unshift: this.onUnshift,
89
+ push: this.onPush,
90
+ insert: this.onInsert,
91
+ pop: this.onPop,
92
+ remove: this.onRemove,
93
+ replace: this.onReplace,
94
+ move: this.onMove
95
+ }
96
+ });
97
+ }
98
+ }
99
+ });
100
+ export {
101
+ p as FieldArray
102
+ };
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @license
3
+ *-------------------------------------------------------------------------------------------
4
+ * Copyright © 2024 Progress Software Corporation. All rights reserved.
5
+ * Licensed under commercial license. See LICENSE.md in the package root for more information
6
+ *-------------------------------------------------------------------------------------------
7
+ */
8
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),a=require("./package-metadata.js"),t=require("@progress/kendo-vue-common"),o=e.defineComponent({name:"KendoFieldWrapper",props:{dir:String,horizontal:Boolean},created(){t.validatePackage(a.packageMetadata)},computed:{fieldClassName(){return{"k-form-field":!0,"k-rtl":this.$props.dir==="rtl"}}},render(){const r=t.getDefaultSlots(this);return e.createVNode("div",{class:this.fieldClassName},[r])}});exports.FieldWrapper=o;
@@ -0,0 +1,37 @@
1
+ /**
2
+ * @license
3
+ *-------------------------------------------------------------------------------------------
4
+ * Copyright © 2024 Progress Software Corporation. All rights reserved.
5
+ * Licensed under commercial license. See LICENSE.md in the package root for more information
6
+ *-------------------------------------------------------------------------------------------
7
+ */
8
+ import { defineComponent as r, createVNode as t } from "vue";
9
+ import { packageMetadata as a } from "./package-metadata.mjs";
10
+ import { validatePackage as o, getDefaultSlots as i } from "@progress/kendo-vue-common";
11
+ const s = /* @__PURE__ */ r({
12
+ name: "KendoFieldWrapper",
13
+ props: {
14
+ dir: String,
15
+ horizontal: Boolean
16
+ },
17
+ created() {
18
+ o(a);
19
+ },
20
+ computed: {
21
+ fieldClassName() {
22
+ return {
23
+ "k-form-field": !0,
24
+ "k-rtl": this.$props.dir === "rtl"
25
+ };
26
+ }
27
+ },
28
+ render() {
29
+ const e = i(this);
30
+ return t("div", {
31
+ class: this.fieldClassName
32
+ }, [e]);
33
+ }
34
+ });
35
+ export {
36
+ s as FieldWrapper
37
+ };
package/Form.js ADDED
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @license
3
+ *-------------------------------------------------------------------------------------------
4
+ * Copyright © 2024 Progress Software Corporation. All rights reserved.
5
+ * Licensed under commercial license. See LICENSE.md in the package root for more information
6
+ *-------------------------------------------------------------------------------------------
7
+ */
8
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("@progress/kendo-vue-common"),u=require("./package-metadata.js"),h=require("vue"),a=0,n=h.defineComponent({name:"KendoForm",inheritAttrs:!1,props:{renderForm:[Object,Function],initialValues:Object,validator:Function,ignoreModified:Boolean},emits:{submitclick:null,submit:null},created(){this._accumulatorTimeout=void 0,d.validatePackage(u.packageMetadata),this.form.values=d.clone(this.$props.initialValues)},mounted(){this.form.errors=this.getErrors(),this.form.allowSubmit=this.allowSubmit(),this.form.valid=this.isValid()},unmounted(){this.onDestroy()},data(){return{validatorsByField:{},fields:[],unmounted:!1,form:{id:this.id,errors:{},values:{},modifiedByField:{},touchedByField:{},visitedByField:{},valid:!1,modified:!1,touched:!1,visited:!1,submitted:!1,valueGetter:this.valueGetter,allowSubmit:!1,validate:this.validate,onChange:this.onChange,onSubmit:this.onSubmit,onFormReset:this.resetForm,registerField:this.onFieldRegister,onFocus:this.onFocus,onBlur:this.onBlur,onUnshift:this.onUnshift,onPush:this.onPush,onInsert:this.onInsert,onPop:this.onPop,onRemove:this.onRemove,onReplace:this.onReplace,onMove:this.onMove}}},provide(){return{kendoForm:this.$data.form}},watch:{"form.values"(){this.form.errors=this.getErrors(),this.form.allowSubmit=this.allowSubmit(),this.form.valid=this.isValid()},"form.touchedByField"(i){this.form.touched=this.isFormTouched(i,this.fields),this.form.allowSubmit=this.allowSubmit()},"form.modifiedByField"(i){this.form.modified=this.isFormModified(i,this.fields),this.form.allowSubmit=this.allowSubmit()},"form.visitedByField"(i){this.form.visited=this.isFormVisited(i,this.fields)}},methods:{isValid(){return this.isFormValid(this.form.errors)},formErrors(){if(this.$props.validator)return this.$props.validator(this.form.values,this.valueGetter)},getErrors(){const i={},t=this.validatorsByField;return Object.keys(this.fields).forEach(s=>{if(i[s]="",t[s]){const r=[];t[s].forEach(o=>{Array.isArray(o)?r.push(...o):r.push(o)}),r.find(o=>{if(o){const l=o(this.valueGetter(s),this.valueGetter,{name:s});if(l)return i[s]=l,!0}return!1})}}),this.formErrors()&&d.cloneObject(this.formErrors(),i),i},accumulatedForceUpdate(){this._accumulatorTimeout&&clearTimeout(this._accumulatorTimeout),d.canUseDOM&&(this._accumulatorTimeout=window.setTimeout(()=>{this._accumulatorTimeout=void 0},a))},resetForm(){this.form.values=d.clone(this.$props.initialValues),this.id=d.guid(),this.form.touchedByField={},this.form.visitedByField={},this.form.modifiedByField={},this.form.submitted=!1},onReset(){this.resetForm()},addField(i){this.fields[i]=!0},validate(i){const t={},e=i||this.fields;Object.keys(e).forEach(s=>{t[s]=!0}),this.form.touchedByField={...t}},onSubmit(i){const t={},e=this.fields;i&&(typeof i.preventDefault=="function"&&i.preventDefault(),typeof i.stopPropagation=="function"&&i.stopPropagation()),Object.keys(e).forEach(l=>{t[l]=!0}),this.form.visitedByField={...t},this.form.touchedByField={...t};const s=this.form.values,r=this.isValid(),o=this.isFormModified(this.form.modifiedByField,e);this.$emit("submitclick",{values:s,isValid:r,isModified:o,event:i}),r&&(this.$props.ignoreModified||o)&&(this.form.submitted=!0,this.$emit("submit",s,i))},onChange(i,t){const{value:e}=t;this.addField(i),this.form.modifiedByField[i]||(this.form.modifiedByField={...this.form.modifiedByField,[i]:!0}),this.valueSetter(i,e)},onFocus(i){this.form.visitedByField[i]||(this.form.visitedByField={...this.form.visitedByField,[i]:!0})},onBlur(i){this.form.touchedByField[i]||(this.onFocus(i),this.form.touchedByField={...this.form.touchedByField,[i]:!0})},onFieldRegister(i,t){this.addField(i);const e=this.validatorsByField[i]||[],s=e.length;return this.validatorsByField={...this.validatorsByField,[i]:[...e,t]},this.accumulatedForceUpdate(),()=>{if(this._unmounted)return;const r=[...this.validatorsByField[i]||[]],o=!!r[s];r[s]=void 0,this.validatorsByField={...this.validatorsByField,[i]:r},o&&this.accumulatedForceUpdate()}},isFormValid(i){return!Object.keys(i).some(t=>!!i[t])},isFormModified(i,t){return Object.keys(t).some(e=>i[e])},isFormHasNotTouched(i,t){return Object.keys(t).some(e=>!i[e])},isFormTouched(i,t){return Object.keys(t).some(e=>i[e])},isFormVisited(i,t){return Object.keys(t).some(e=>i[e])},formHasNotTouched(){return this.isFormHasNotTouched(this.form.touchedByField,this.fields)},allowSubmit(){return this.formHasNotTouched()&&!this.isValid()||this.isValid()&&(this.$props.ignoreModified||this.isFormModified(this.form.modifiedByField,this.fields))},valueGetter(i){return this.form.values[i]},valueSetter(i,t){this.form.values={...this.form.values,[i]:t}},onArrayAction(i){this.addField(i),this.form.modifiedByField[i]||(this.form.modifiedByField={...this.form.modifiedByField,[i]:!0}),this.onBlur(i,!0)},onInsert(i,t){this.onArrayAction(i);const e=[...this.valueGetter(i)||[]];e.splice(t.index,0,t.value),this.valueSetter(i,e)},onUnshift(i,t){this.onInsert(i,{value:t.value,index:0})},onPush(i,t){this.onArrayAction(i);const e=[...this.valueGetter(i)||[],t.value];this.valueSetter(i,e)},onPop(i){this.onArrayAction(i);const t=[...this.valueGetter(i)||[]],e=t.pop();return this.valueSetter(i,t),e},onRemove(i,t){this.onArrayAction(i);const e=[...this.valueGetter(i)||[]],s=e.splice(t.index,1);return this.valueSetter(i,e),s},onReplace(i,t){this.onArrayAction(i);const e=[...this.valueGetter(i)||[]];e.splice(t.index,1,t.value),this.valueSetter(i,e)},onMove(i,t){this.onArrayAction(i);const e=[...this.valueGetter(i)||[]],s=e[t.prevIndex];e.splice(t.prevIndex,1),e.splice(t.nextIndex,0,s),this.valueSetter(i,e)},onDestroy(){this.unmounted=!0,this._accumulatorTimeout&&clearTimeout(this._accumulatorTimeout)}},render(){return d.getDefaultSlots(this)}});exports.Form=n;
package/Form.mjs ADDED
@@ -0,0 +1,294 @@
1
+ /**
2
+ * @license
3
+ *-------------------------------------------------------------------------------------------
4
+ * Copyright © 2024 Progress Software Corporation. All rights reserved.
5
+ * Licensed under commercial license. See LICENSE.md in the package root for more information
6
+ *-------------------------------------------------------------------------------------------
7
+ */
8
+ import { validatePackage as h, clone as l, cloneObject as u, canUseDOM as a, guid as n, getDefaultSlots as f } from "@progress/kendo-vue-common";
9
+ import { packageMetadata as m } from "./package-metadata.mjs";
10
+ import { defineComponent as c } from "vue";
11
+ const F = 0, B = /* @__PURE__ */ c({
12
+ name: "KendoForm",
13
+ inheritAttrs: !1,
14
+ props: {
15
+ renderForm: [Object, Function],
16
+ initialValues: Object,
17
+ validator: Function,
18
+ ignoreModified: Boolean
19
+ },
20
+ emits: {
21
+ submitclick: null,
22
+ submit: null
23
+ },
24
+ created() {
25
+ this._accumulatorTimeout = void 0, h(m), this.form.values = l(this.$props.initialValues);
26
+ },
27
+ mounted() {
28
+ this.form.errors = this.getErrors(), this.form.allowSubmit = this.allowSubmit(), this.form.valid = this.isValid();
29
+ },
30
+ unmounted() {
31
+ this.onDestroy();
32
+ },
33
+ data() {
34
+ return {
35
+ validatorsByField: {},
36
+ fields: [],
37
+ unmounted: !1,
38
+ form: {
39
+ id: this.id,
40
+ errors: {},
41
+ values: {},
42
+ modifiedByField: {},
43
+ touchedByField: {},
44
+ visitedByField: {},
45
+ valid: !1,
46
+ modified: !1,
47
+ touched: !1,
48
+ visited: !1,
49
+ submitted: !1,
50
+ valueGetter: this.valueGetter,
51
+ allowSubmit: !1,
52
+ validate: this.validate,
53
+ onChange: this.onChange,
54
+ onSubmit: this.onSubmit,
55
+ onFormReset: this.resetForm,
56
+ registerField: this.onFieldRegister,
57
+ onFocus: this.onFocus,
58
+ onBlur: this.onBlur,
59
+ onUnshift: this.onUnshift,
60
+ onPush: this.onPush,
61
+ onInsert: this.onInsert,
62
+ onPop: this.onPop,
63
+ onRemove: this.onRemove,
64
+ onReplace: this.onReplace,
65
+ onMove: this.onMove
66
+ }
67
+ };
68
+ },
69
+ provide() {
70
+ return {
71
+ kendoForm: this.$data.form
72
+ };
73
+ },
74
+ watch: {
75
+ "form.values"() {
76
+ this.form.errors = this.getErrors(), this.form.allowSubmit = this.allowSubmit(), this.form.valid = this.isValid();
77
+ },
78
+ "form.touchedByField"(i) {
79
+ this.form.touched = this.isFormTouched(i, this.fields), this.form.allowSubmit = this.allowSubmit();
80
+ },
81
+ "form.modifiedByField"(i) {
82
+ this.form.modified = this.isFormModified(i, this.fields), this.form.allowSubmit = this.allowSubmit();
83
+ },
84
+ "form.visitedByField"(i) {
85
+ this.form.visited = this.isFormVisited(i, this.fields);
86
+ }
87
+ },
88
+ methods: {
89
+ isValid() {
90
+ return this.isFormValid(this.form.errors);
91
+ },
92
+ formErrors() {
93
+ if (this.$props.validator)
94
+ return this.$props.validator(this.form.values, this.valueGetter);
95
+ },
96
+ getErrors() {
97
+ const i = {}, t = this.validatorsByField;
98
+ return Object.keys(this.fields).forEach((s) => {
99
+ if (i[s] = "", t[s]) {
100
+ const r = [];
101
+ t[s].forEach((o) => {
102
+ Array.isArray(o) ? r.push(...o) : r.push(o);
103
+ }), r.find((o) => {
104
+ if (o) {
105
+ const d = o(this.valueGetter(s), this.valueGetter, {
106
+ name: s
107
+ });
108
+ if (d)
109
+ return i[s] = d, !0;
110
+ }
111
+ return !1;
112
+ });
113
+ }
114
+ }), this.formErrors() && u(this.formErrors(), i), i;
115
+ },
116
+ /**
117
+ * @hidden
118
+ */
119
+ accumulatedForceUpdate() {
120
+ this._accumulatorTimeout && clearTimeout(this._accumulatorTimeout), a && (this._accumulatorTimeout = window.setTimeout(() => {
121
+ this._accumulatorTimeout = void 0;
122
+ }, F));
123
+ },
124
+ /**
125
+ * @hidden
126
+ */
127
+ resetForm() {
128
+ this.form.values = l(this.$props.initialValues), this.id = n(), this.form.touchedByField = {}, this.form.visitedByField = {}, this.form.modifiedByField = {}, this.form.submitted = !1;
129
+ },
130
+ /**
131
+ * Method for resetting the form state outside the form component.
132
+ *
133
+ * > Use `onReset` only if you cannot achieve the desired behavior
134
+ * through the Field component or by FormRenderProps.
135
+ */
136
+ onReset() {
137
+ this.resetForm();
138
+ },
139
+ addField(i) {
140
+ this.fields[i] = !0;
141
+ },
142
+ validate(i) {
143
+ const t = {}, e = i || this.fields;
144
+ Object.keys(e).forEach((s) => {
145
+ t[s] = !0;
146
+ }), this.form.touchedByField = {
147
+ ...t
148
+ };
149
+ },
150
+ onSubmit(i) {
151
+ const t = {}, e = this.fields;
152
+ i && (typeof i.preventDefault == "function" && i.preventDefault(), typeof i.stopPropagation == "function" && i.stopPropagation()), Object.keys(e).forEach((d) => {
153
+ t[d] = !0;
154
+ }), this.form.visitedByField = {
155
+ ...t
156
+ }, this.form.touchedByField = {
157
+ ...t
158
+ };
159
+ const s = this.form.values, r = this.isValid(), o = this.isFormModified(this.form.modifiedByField, e);
160
+ this.$emit("submitclick", {
161
+ values: s,
162
+ isValid: r,
163
+ isModified: o,
164
+ event: i
165
+ }), r && (this.$props.ignoreModified || o) && (this.form.submitted = !0, this.$emit("submit", s, i));
166
+ },
167
+ /**
168
+ * Method for emitting changes to a specific field outside the form component.
169
+ *
170
+ * > Use `onChange` only if you cannot achieve the desired behavior
171
+ * through the Field component by FormRenderProps.
172
+ */
173
+ onChange(i, t) {
174
+ const {
175
+ value: e
176
+ } = t;
177
+ this.addField(i), this.form.modifiedByField[i] || (this.form.modifiedByField = {
178
+ ...this.form.modifiedByField,
179
+ [i]: !0
180
+ }), this.valueSetter(i, e);
181
+ },
182
+ onFocus(i) {
183
+ this.form.visitedByField[i] || (this.form.visitedByField = {
184
+ ...this.form.visitedByField,
185
+ [i]: !0
186
+ });
187
+ },
188
+ onBlur(i) {
189
+ this.form.touchedByField[i] || (this.onFocus(i), this.form.touchedByField = {
190
+ ...this.form.touchedByField,
191
+ [i]: !0
192
+ });
193
+ },
194
+ onFieldRegister(i, t) {
195
+ this.addField(i);
196
+ const e = this.validatorsByField[i] || [], s = e.length;
197
+ return this.validatorsByField = {
198
+ ...this.validatorsByField,
199
+ [i]: [...e, t]
200
+ }, this.accumulatedForceUpdate(), () => {
201
+ if (this._unmounted)
202
+ return;
203
+ const r = [...this.validatorsByField[i] || []], o = !!r[s];
204
+ r[s] = void 0, this.validatorsByField = {
205
+ ...this.validatorsByField,
206
+ [i]: r
207
+ }, o && this.accumulatedForceUpdate();
208
+ };
209
+ },
210
+ isFormValid(i) {
211
+ return !Object.keys(i).some((t) => !!i[t]);
212
+ },
213
+ isFormModified(i, t) {
214
+ return Object.keys(t).some((e) => i[e]);
215
+ },
216
+ isFormHasNotTouched(i, t) {
217
+ return Object.keys(t).some((e) => !i[e]);
218
+ },
219
+ isFormTouched(i, t) {
220
+ return Object.keys(t).some((e) => i[e]);
221
+ },
222
+ isFormVisited(i, t) {
223
+ return Object.keys(t).some((e) => i[e]);
224
+ },
225
+ formHasNotTouched() {
226
+ return this.isFormHasNotTouched(this.form.touchedByField, this.fields);
227
+ },
228
+ // 1. The form is not touched, but has errors - allow submit to force validation.
229
+ // 2. The form is valid and modified - if not modified, disable submit.
230
+ allowSubmit() {
231
+ return this.formHasNotTouched() && !this.isValid() || this.isValid() && (this.$props.ignoreModified || this.isFormModified(this.form.modifiedByField, this.fields));
232
+ },
233
+ valueGetter(i) {
234
+ return this.form.values[i];
235
+ },
236
+ valueSetter(i, t) {
237
+ this.form.values = {
238
+ ...this.form.values,
239
+ [i]: t
240
+ };
241
+ },
242
+ onArrayAction(i) {
243
+ this.addField(i), this.form.modifiedByField[i] || (this.form.modifiedByField = {
244
+ ...this.form.modifiedByField,
245
+ [i]: !0
246
+ }), this.onBlur(i, !0);
247
+ },
248
+ onInsert(i, t) {
249
+ this.onArrayAction(i);
250
+ const e = [...this.valueGetter(i) || []];
251
+ e.splice(t.index, 0, t.value), this.valueSetter(i, e);
252
+ },
253
+ onUnshift(i, t) {
254
+ this.onInsert(i, {
255
+ value: t.value,
256
+ index: 0
257
+ });
258
+ },
259
+ onPush(i, t) {
260
+ this.onArrayAction(i);
261
+ const e = [...this.valueGetter(i) || [], t.value];
262
+ this.valueSetter(i, e);
263
+ },
264
+ onPop(i) {
265
+ this.onArrayAction(i);
266
+ const t = [...this.valueGetter(i) || []], e = t.pop();
267
+ return this.valueSetter(i, t), e;
268
+ },
269
+ onRemove(i, t) {
270
+ this.onArrayAction(i);
271
+ const e = [...this.valueGetter(i) || []], s = e.splice(t.index, 1);
272
+ return this.valueSetter(i, e), s;
273
+ },
274
+ onReplace(i, t) {
275
+ this.onArrayAction(i);
276
+ const e = [...this.valueGetter(i) || []];
277
+ e.splice(t.index, 1, t.value), this.valueSetter(i, e);
278
+ },
279
+ onMove(i, t) {
280
+ this.onArrayAction(i);
281
+ const e = [...this.valueGetter(i) || []], s = e[t.prevIndex];
282
+ e.splice(t.prevIndex, 1), e.splice(t.nextIndex, 0, s), this.valueSetter(i, e);
283
+ },
284
+ onDestroy() {
285
+ this.unmounted = !0, this._accumulatorTimeout && clearTimeout(this._accumulatorTimeout);
286
+ }
287
+ },
288
+ render() {
289
+ return f(this);
290
+ }
291
+ });
292
+ export {
293
+ B as Form
294
+ };
package/FormElement.js ADDED
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @license
3
+ *-------------------------------------------------------------------------------------------
4
+ * Copyright © 2024 Progress Software Corporation. All rights reserved.
5
+ * Licensed under commercial license. See LICENSE.md in the package root for more information
6
+ *-------------------------------------------------------------------------------------------
7
+ */
8
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("vue"),n=require("./package-metadata.js"),t=require("@progress/kendo-vue-common"),r=o.defineComponent({name:"KendoFormElement",props:{horizontal:Boolean,size:{type:String,default:"medium",validator:function(e){return[null,"small","medium","large"].includes(e)}}},created(){t.validatePackage(n.packageMetadata)},inject:{kendoForm:{default:null}},computed:{formElementClassName(){const{size:e}=this.$props;return{"k-form":!0,[`k-form-${t.kendoThemeMaps.sizeMap[e]||e}`]:e,"k-form-horizontal":this.$props.horizontal===!0}}},methods:{handleSubmit(e){this.kendoForm&&this.kendoForm.onSubmit(e)}},render(){const e=t.getDefaultSlots(this);return o.createVNode("form",{class:this.formElementClassName,onSubmit:this.handleSubmit},[e])}});exports.FormElement=r;
@@ -0,0 +1,58 @@
1
+ /**
2
+ * @license
3
+ *-------------------------------------------------------------------------------------------
4
+ * Copyright © 2024 Progress Software Corporation. All rights reserved.
5
+ * Licensed under commercial license. See LICENSE.md in the package root for more information
6
+ *-------------------------------------------------------------------------------------------
7
+ */
8
+ import { defineComponent as t, createVNode as o } from "vue";
9
+ import { packageMetadata as r } from "./package-metadata.mjs";
10
+ import { validatePackage as m, kendoThemeMaps as n, getDefaultSlots as a } from "@progress/kendo-vue-common";
11
+ const d = /* @__PURE__ */ t({
12
+ name: "KendoFormElement",
13
+ props: {
14
+ horizontal: Boolean,
15
+ size: {
16
+ type: String,
17
+ default: "medium",
18
+ validator: function(e) {
19
+ return [null, "small", "medium", "large"].includes(e);
20
+ }
21
+ }
22
+ },
23
+ created() {
24
+ m(r);
25
+ },
26
+ inject: {
27
+ kendoForm: {
28
+ default: null
29
+ }
30
+ },
31
+ computed: {
32
+ formElementClassName() {
33
+ const {
34
+ size: e
35
+ } = this.$props;
36
+ return {
37
+ "k-form": !0,
38
+ [`k-form-${n.sizeMap[e] || e}`]: e,
39
+ "k-form-horizontal": this.$props.horizontal === !0
40
+ };
41
+ }
42
+ },
43
+ methods: {
44
+ handleSubmit(e) {
45
+ this.kendoForm && this.kendoForm.onSubmit(e);
46
+ }
47
+ },
48
+ render() {
49
+ const e = a(this);
50
+ return o("form", {
51
+ class: this.formElementClassName,
52
+ onSubmit: this.handleSubmit
53
+ }, [e]);
54
+ }
55
+ });
56
+ export {
57
+ d as FormElement
58
+ };