@progress/kendo-angular-common 15.4.0 → 15.5.0-develop.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,10 +2,12 @@
2
2
  * Copyright © 2024 Progress Software Corporation. All rights reserved.
3
3
  * Licensed under commercial license. See LICENSE.md in the project root for more information
4
4
  *-------------------------------------------------------------------------------------------*/
5
- import { Renderer2 } from "@angular/core";
6
5
  /**
7
6
  * @hidden
8
7
  */
9
- export declare const setHTMLAttributes: (attributes: {
10
- [key: string]: string;
11
- }, renderer: Renderer2, element: Element) => void;
8
+ export const isControlRequired = (control) => {
9
+ if (!control?.validator) {
10
+ return false;
11
+ }
12
+ return control.validator({})?.hasOwnProperty('required');
13
+ };
@@ -0,0 +1,35 @@
1
+ /**-----------------------------------------------------------------------------------------
2
+ * Copyright © 2024 Progress Software Corporation. All rights reserved.
3
+ * Licensed under commercial license. See LICENSE.md in the project root for more information
4
+ *-------------------------------------------------------------------------------------------*/
5
+ import { isPresent } from "./ng-class-parser";
6
+ /**
7
+ * @hidden
8
+ */
9
+ export const setHTMLAttributes = (attributes, renderer, element) => {
10
+ for (const attribute in attributes) {
11
+ if (attribute && isPresent(attributes[attribute])) {
12
+ renderer.setAttribute(element, attribute, attributes[attribute]);
13
+ }
14
+ }
15
+ };
16
+ /**
17
+ * @hidden
18
+ */
19
+ export const removeHTMLAttributes = (attributes, renderer, element) => {
20
+ for (const attribute in attributes) {
21
+ if (attribute) {
22
+ renderer.removeAttribute(element, attribute);
23
+ }
24
+ }
25
+ };
26
+ /**
27
+ * @hidden
28
+ */
29
+ export const parseAttributes = (target, source) => {
30
+ const targetObj = target;
31
+ Object.keys(source).forEach(key => {
32
+ delete targetObj[key];
33
+ });
34
+ return targetObj;
35
+ };
@@ -7,6 +7,12 @@
7
7
  * @hidden
8
8
  */
9
9
  export const isPresent = (value) => value !== null && value !== undefined;
10
+ /**
11
+ * @hidden
12
+ */
13
+ export const isObjectPresent = (value) => {
14
+ return isObject(value) && Object.keys(value).length > 0;
15
+ };
10
16
  /**
11
17
  * @hidden
12
18
  */
package/esm2020/utils.mjs CHANGED
@@ -8,4 +8,5 @@ export { anyChanged } from './utils/any-changed';
8
8
  export { hasObservers } from './utils/has-observers';
9
9
  export { guid } from './utils/guid';
10
10
  export { isSafari, isFirefox } from './utils/detect-browser';
11
- export { setHTMLAttributes } from './utils/set-html-attributes';
11
+ export * from './utils/html-attributes';
12
+ export { isControlRequired } from './utils/forms-utils';
@@ -69,16 +69,115 @@ const isFirefox = (userAgent) => {
69
69
  return (desktopBrowser && desktopBrowser.mozilla) || (mobileOS && mobileOS.browser === 'firefox');
70
70
  };
71
71
 
72
+ /* eslint-disable @typescript-eslint/no-explicit-any */
73
+ /**
74
+ * @hidden
75
+ */
76
+ const isPresent = (value) => value !== null && value !== undefined;
77
+ /**
78
+ * @hidden
79
+ */
80
+ const isObjectPresent = (value) => {
81
+ return isObject(value) && Object.keys(value).length > 0;
82
+ };
83
+ /**
84
+ * @hidden
85
+ */
86
+ const isString = (value) => value instanceof String || typeof value === 'string';
87
+ /**
88
+ * @hidden
89
+ */
90
+ const isObject = (value) => isPresent(value) && !Array.isArray(value) && typeof value === 'object';
91
+ /**
92
+ * @hidden
93
+ */
94
+ const splitStringToArray = (value) => value.trim().replace(/\s+/g, " ").split(' ');
95
+ /**
96
+ * Receives CSS class declarations either as an object, string or array and returns an array of the class names.
97
+ *
98
+ * @hidden
99
+ */
100
+ const parseCSSClassNames = (value) => {
101
+ if (Array.isArray(value)) {
102
+ return parseArrayClassNames(value);
103
+ }
104
+ if (isObject(value)) {
105
+ return parseObjectClassNames(value);
106
+ }
107
+ if (isString(value)) {
108
+ return parseStringClassNames(value);
109
+ }
110
+ };
111
+ const parseObjectClassNames = (value) => {
112
+ const classes = [];
113
+ Object.keys(value).forEach((className) => {
114
+ const currentClassName = splitStringToArray(className);
115
+ if (value[className] && currentClassName.length) {
116
+ classes.push(...currentClassName);
117
+ }
118
+ });
119
+ return classes;
120
+ };
121
+ const parseStringClassNames = (value) => {
122
+ const classes = [];
123
+ const classesArray = splitStringToArray(value);
124
+ classesArray.forEach((className) => {
125
+ classes.push(className);
126
+ });
127
+ return classes;
128
+ };
129
+ const parseArrayClassNames = (value) => {
130
+ const classes = [];
131
+ value.forEach((className) => {
132
+ const current = splitStringToArray(className);
133
+ if (current[0]) {
134
+ classes.push(...current);
135
+ }
136
+ });
137
+ return classes;
138
+ };
139
+
72
140
  /**
73
141
  * @hidden
74
142
  */
75
143
  const setHTMLAttributes = (attributes, renderer, element) => {
76
144
  for (const attribute in attributes) {
77
- if (attribute) {
145
+ if (attribute && isPresent(attributes[attribute])) {
78
146
  renderer.setAttribute(element, attribute, attributes[attribute]);
79
147
  }
80
148
  }
81
149
  };
150
+ /**
151
+ * @hidden
152
+ */
153
+ const removeHTMLAttributes = (attributes, renderer, element) => {
154
+ for (const attribute in attributes) {
155
+ if (attribute) {
156
+ renderer.removeAttribute(element, attribute);
157
+ }
158
+ }
159
+ };
160
+ /**
161
+ * @hidden
162
+ */
163
+ const parseAttributes = (target, source) => {
164
+ const targetObj = target;
165
+ Object.keys(source).forEach(key => {
166
+ delete targetObj[key];
167
+ });
168
+ return targetObj;
169
+ };
170
+
171
+ /**
172
+ * @hidden
173
+ */
174
+ const isControlRequired = (control) => {
175
+ var _a;
176
+ if (!(control === null || control === void 0 ? void 0 : control.validator)) {
177
+ return false;
178
+ }
179
+ return (_a = control.validator({})) === null || _a === void 0 ? void 0 : _a.hasOwnProperty('required');
180
+ };
82
181
 
83
182
  class DraggableDirective {
84
183
  constructor(element, ngZone) {
@@ -751,68 +850,6 @@ const focusableSelector = [
751
850
  '*[contenteditable]:not([tabindex^="-"]):not([disabled]):not([contenteditable="false"])'
752
851
  ].join(',');
753
852
 
754
- /* eslint-disable @typescript-eslint/no-explicit-any */
755
- /**
756
- * @hidden
757
- */
758
- const isPresent = (value) => value !== null && value !== undefined;
759
- /**
760
- * @hidden
761
- */
762
- const isString = (value) => value instanceof String || typeof value === 'string';
763
- /**
764
- * @hidden
765
- */
766
- const isObject = (value) => isPresent(value) && !Array.isArray(value) && typeof value === 'object';
767
- /**
768
- * @hidden
769
- */
770
- const splitStringToArray = (value) => value.trim().replace(/\s+/g, " ").split(' ');
771
- /**
772
- * Receives CSS class declarations either as an object, string or array and returns an array of the class names.
773
- *
774
- * @hidden
775
- */
776
- const parseCSSClassNames = (value) => {
777
- if (Array.isArray(value)) {
778
- return parseArrayClassNames(value);
779
- }
780
- if (isObject(value)) {
781
- return parseObjectClassNames(value);
782
- }
783
- if (isString(value)) {
784
- return parseStringClassNames(value);
785
- }
786
- };
787
- const parseObjectClassNames = (value) => {
788
- const classes = [];
789
- Object.keys(value).forEach((className) => {
790
- const currentClassName = splitStringToArray(className);
791
- if (value[className] && currentClassName.length) {
792
- classes.push(...currentClassName);
793
- }
794
- });
795
- return classes;
796
- };
797
- const parseStringClassNames = (value) => {
798
- const classes = [];
799
- const classesArray = splitStringToArray(value);
800
- classesArray.forEach((className) => {
801
- classes.push(className);
802
- });
803
- return classes;
804
- };
805
- const parseArrayClassNames = (value) => {
806
- const classes = [];
807
- value.forEach((className) => {
808
- const current = splitStringToArray(className);
809
- if (current[0]) {
810
- classes.push(...current);
811
- }
812
- });
813
- return classes;
814
- };
815
-
816
853
  /**
817
854
  * @hidden
818
855
  */
@@ -1366,5 +1403,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImpo
1366
1403
  * Generated bundle index. Do not edit.
1367
1404
  */
1368
1405
 
1369
- export { AdornmentsModule, DraggableDirective, DraggableModule, EventsModule, EventsOutsideAngularDirective, KendoInput, Keys, PrefixTemplateDirective, PreventableEvent, ResizeBatchService, ResizeCompatService, ResizeObserverService, ResizeSensorComponent, ResizeSensorModule, ScrollbarWidthService, SeparatorComponent, SuffixTemplateDirective, ToggleButtonTabStopDirective, ToggleButtonTabStopModule, WatermarkModule, WatermarkOverlayComponent, anyChanged, closest, closestBySelector, closestInScope, contains, findElement, findFocusable, findFocusableChild, focusableSelector, guid, hasClasses, hasObservers, isChanged, isDocumentAvailable, isFirefox, isFocusable, isFocusableWithTabKey, isObject, isPresent, isSafari, isString, isVisible, matchesClasses, matchesNodeName, parseCSSClassNames, rtlScrollPosition, scrollbarWidth, setHTMLAttributes, shouldShowValidationUI, splitStringToArray };
1406
+ export { AdornmentsModule, DraggableDirective, DraggableModule, EventsModule, EventsOutsideAngularDirective, KendoInput, Keys, PrefixTemplateDirective, PreventableEvent, ResizeBatchService, ResizeCompatService, ResizeObserverService, ResizeSensorComponent, ResizeSensorModule, ScrollbarWidthService, SeparatorComponent, SuffixTemplateDirective, ToggleButtonTabStopDirective, ToggleButtonTabStopModule, WatermarkModule, WatermarkOverlayComponent, anyChanged, closest, closestBySelector, closestInScope, contains, findElement, findFocusable, findFocusableChild, focusableSelector, guid, hasClasses, hasObservers, isChanged, isControlRequired, isDocumentAvailable, isFirefox, isFocusable, isFocusableWithTabKey, isObject, isObjectPresent, isPresent, isSafari, isString, isVisible, matchesClasses, matchesNodeName, parseAttributes, parseCSSClassNames, removeHTMLAttributes, rtlScrollPosition, scrollbarWidth, setHTMLAttributes, shouldShowValidationUI, splitStringToArray };
1370
1407
 
@@ -69,16 +69,114 @@ const isFirefox = (userAgent) => {
69
69
  return (desktopBrowser && desktopBrowser.mozilla) || (mobileOS && mobileOS.browser === 'firefox');
70
70
  };
71
71
 
72
+ /* eslint-disable @typescript-eslint/no-explicit-any */
73
+ /**
74
+ * @hidden
75
+ */
76
+ const isPresent = (value) => value !== null && value !== undefined;
77
+ /**
78
+ * @hidden
79
+ */
80
+ const isObjectPresent = (value) => {
81
+ return isObject(value) && Object.keys(value).length > 0;
82
+ };
83
+ /**
84
+ * @hidden
85
+ */
86
+ const isString = (value) => value instanceof String || typeof value === 'string';
87
+ /**
88
+ * @hidden
89
+ */
90
+ const isObject = (value) => isPresent(value) && !Array.isArray(value) && typeof value === 'object';
91
+ /**
92
+ * @hidden
93
+ */
94
+ const splitStringToArray = (value) => value.trim().replace(/\s+/g, " ").split(' ');
95
+ /**
96
+ * Receives CSS class declarations either as an object, string or array and returns an array of the class names.
97
+ *
98
+ * @hidden
99
+ */
100
+ const parseCSSClassNames = (value) => {
101
+ if (Array.isArray(value)) {
102
+ return parseArrayClassNames(value);
103
+ }
104
+ if (isObject(value)) {
105
+ return parseObjectClassNames(value);
106
+ }
107
+ if (isString(value)) {
108
+ return parseStringClassNames(value);
109
+ }
110
+ };
111
+ const parseObjectClassNames = (value) => {
112
+ const classes = [];
113
+ Object.keys(value).forEach((className) => {
114
+ const currentClassName = splitStringToArray(className);
115
+ if (value[className] && currentClassName.length) {
116
+ classes.push(...currentClassName);
117
+ }
118
+ });
119
+ return classes;
120
+ };
121
+ const parseStringClassNames = (value) => {
122
+ const classes = [];
123
+ const classesArray = splitStringToArray(value);
124
+ classesArray.forEach((className) => {
125
+ classes.push(className);
126
+ });
127
+ return classes;
128
+ };
129
+ const parseArrayClassNames = (value) => {
130
+ const classes = [];
131
+ value.forEach((className) => {
132
+ const current = splitStringToArray(className);
133
+ if (current[0]) {
134
+ classes.push(...current);
135
+ }
136
+ });
137
+ return classes;
138
+ };
139
+
72
140
  /**
73
141
  * @hidden
74
142
  */
75
143
  const setHTMLAttributes = (attributes, renderer, element) => {
76
144
  for (const attribute in attributes) {
77
- if (attribute) {
145
+ if (attribute && isPresent(attributes[attribute])) {
78
146
  renderer.setAttribute(element, attribute, attributes[attribute]);
79
147
  }
80
148
  }
81
149
  };
150
+ /**
151
+ * @hidden
152
+ */
153
+ const removeHTMLAttributes = (attributes, renderer, element) => {
154
+ for (const attribute in attributes) {
155
+ if (attribute) {
156
+ renderer.removeAttribute(element, attribute);
157
+ }
158
+ }
159
+ };
160
+ /**
161
+ * @hidden
162
+ */
163
+ const parseAttributes = (target, source) => {
164
+ const targetObj = target;
165
+ Object.keys(source).forEach(key => {
166
+ delete targetObj[key];
167
+ });
168
+ return targetObj;
169
+ };
170
+
171
+ /**
172
+ * @hidden
173
+ */
174
+ const isControlRequired = (control) => {
175
+ if (!control?.validator) {
176
+ return false;
177
+ }
178
+ return control.validator({})?.hasOwnProperty('required');
179
+ };
82
180
 
83
181
  class DraggableDirective {
84
182
  constructor(element, ngZone) {
@@ -747,68 +845,6 @@ const focusableSelector = [
747
845
  '*[contenteditable]:not([tabindex^="-"]):not([disabled]):not([contenteditable="false"])'
748
846
  ].join(',');
749
847
 
750
- /* eslint-disable @typescript-eslint/no-explicit-any */
751
- /**
752
- * @hidden
753
- */
754
- const isPresent = (value) => value !== null && value !== undefined;
755
- /**
756
- * @hidden
757
- */
758
- const isString = (value) => value instanceof String || typeof value === 'string';
759
- /**
760
- * @hidden
761
- */
762
- const isObject = (value) => isPresent(value) && !Array.isArray(value) && typeof value === 'object';
763
- /**
764
- * @hidden
765
- */
766
- const splitStringToArray = (value) => value.trim().replace(/\s+/g, " ").split(' ');
767
- /**
768
- * Receives CSS class declarations either as an object, string or array and returns an array of the class names.
769
- *
770
- * @hidden
771
- */
772
- const parseCSSClassNames = (value) => {
773
- if (Array.isArray(value)) {
774
- return parseArrayClassNames(value);
775
- }
776
- if (isObject(value)) {
777
- return parseObjectClassNames(value);
778
- }
779
- if (isString(value)) {
780
- return parseStringClassNames(value);
781
- }
782
- };
783
- const parseObjectClassNames = (value) => {
784
- const classes = [];
785
- Object.keys(value).forEach((className) => {
786
- const currentClassName = splitStringToArray(className);
787
- if (value[className] && currentClassName.length) {
788
- classes.push(...currentClassName);
789
- }
790
- });
791
- return classes;
792
- };
793
- const parseStringClassNames = (value) => {
794
- const classes = [];
795
- const classesArray = splitStringToArray(value);
796
- classesArray.forEach((className) => {
797
- classes.push(className);
798
- });
799
- return classes;
800
- };
801
- const parseArrayClassNames = (value) => {
802
- const classes = [];
803
- value.forEach((className) => {
804
- const current = splitStringToArray(className);
805
- if (current[0]) {
806
- classes.push(...current);
807
- }
808
- });
809
- return classes;
810
- };
811
-
812
848
  /**
813
849
  * @hidden
814
850
  */
@@ -1357,5 +1393,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImpo
1357
1393
  * Generated bundle index. Do not edit.
1358
1394
  */
1359
1395
 
1360
- export { AdornmentsModule, DraggableDirective, DraggableModule, EventsModule, EventsOutsideAngularDirective, KendoInput, Keys, PrefixTemplateDirective, PreventableEvent, ResizeBatchService, ResizeCompatService, ResizeObserverService, ResizeSensorComponent, ResizeSensorModule, ScrollbarWidthService, SeparatorComponent, SuffixTemplateDirective, ToggleButtonTabStopDirective, ToggleButtonTabStopModule, WatermarkModule, WatermarkOverlayComponent, anyChanged, closest, closestBySelector, closestInScope, contains, findElement, findFocusable, findFocusableChild, focusableSelector, guid, hasClasses, hasObservers, isChanged, isDocumentAvailable, isFirefox, isFocusable, isFocusableWithTabKey, isObject, isPresent, isSafari, isString, isVisible, matchesClasses, matchesNodeName, parseCSSClassNames, rtlScrollPosition, scrollbarWidth, setHTMLAttributes, shouldShowValidationUI, splitStringToArray };
1396
+ export { AdornmentsModule, DraggableDirective, DraggableModule, EventsModule, EventsOutsideAngularDirective, KendoInput, Keys, PrefixTemplateDirective, PreventableEvent, ResizeBatchService, ResizeCompatService, ResizeObserverService, ResizeSensorComponent, ResizeSensorModule, ScrollbarWidthService, SeparatorComponent, SuffixTemplateDirective, ToggleButtonTabStopDirective, ToggleButtonTabStopModule, WatermarkModule, WatermarkOverlayComponent, anyChanged, closest, closestBySelector, closestInScope, contains, findElement, findFocusable, findFocusableChild, focusableSelector, guid, hasClasses, hasObservers, isChanged, isControlRequired, isDocumentAvailable, isFirefox, isFocusable, isFocusableWithTabKey, isObject, isObjectPresent, isPresent, isSafari, isString, isVisible, matchesClasses, matchesNodeName, parseAttributes, parseCSSClassNames, removeHTMLAttributes, rtlScrollPosition, scrollbarWidth, setHTMLAttributes, shouldShowValidationUI, splitStringToArray };
1361
1397
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@progress/kendo-angular-common",
3
- "version": "15.4.0",
3
+ "version": "15.5.0-develop.10",
4
4
  "description": "Kendo UI for Angular - Utility Package",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "author": "Progress",
@@ -23,7 +23,7 @@
23
23
  "@progress/kendo-common": "^0.2.1",
24
24
  "@progress/kendo-draggable": "^3.0.2",
25
25
  "tslib": "^2.3.1",
26
- "@progress/kendo-angular-schematics": "15.4.0"
26
+ "@progress/kendo-angular-schematics": "15.5.0-develop.10"
27
27
  },
28
28
  "publishConfig": {
29
29
  "access": "public"
@@ -2,13 +2,8 @@
2
2
  * Copyright © 2024 Progress Software Corporation. All rights reserved.
3
3
  * Licensed under commercial license. See LICENSE.md in the project root for more information
4
4
  *-------------------------------------------------------------------------------------------*/
5
+ import { AbstractControl } from "@angular/forms";
5
6
  /**
6
7
  * @hidden
7
8
  */
8
- export const setHTMLAttributes = (attributes, renderer, element) => {
9
- for (const attribute in attributes) {
10
- if (attribute) {
11
- renderer.setAttribute(element, attribute, attributes[attribute]);
12
- }
13
- }
14
- };
9
+ export declare const isControlRequired: (control: AbstractControl) => boolean;
@@ -0,0 +1,27 @@
1
+ /**-----------------------------------------------------------------------------------------
2
+ * Copyright © 2024 Progress Software Corporation. All rights reserved.
3
+ * Licensed under commercial license. See LICENSE.md in the project root for more information
4
+ *-------------------------------------------------------------------------------------------*/
5
+ import { Renderer2 } from "@angular/core";
6
+ /**
7
+ * @hidden
8
+ */
9
+ export declare const setHTMLAttributes: (attributes: {
10
+ [key: string]: string;
11
+ }, renderer: Renderer2, element: Element) => void;
12
+ /**
13
+ * @hidden
14
+ */
15
+ export declare const removeHTMLAttributes: (attributes: {
16
+ [key: string]: string;
17
+ }, renderer: Renderer2, element: Element) => void;
18
+ /**
19
+ * @hidden
20
+ */
21
+ export declare const parseAttributes: (target: {
22
+ [key: string]: string;
23
+ }, source: {
24
+ [key: string]: string;
25
+ }) => {
26
+ [key: string]: string;
27
+ };
@@ -6,6 +6,10 @@
6
6
  * @hidden
7
7
  */
8
8
  export declare const isPresent: (value: any) => boolean;
9
+ /**
10
+ * @hidden
11
+ */
12
+ export declare const isObjectPresent: (value: any) => boolean;
9
13
  /**
10
14
  * @hidden
11
15
  */
package/utils.d.ts CHANGED
@@ -8,4 +8,5 @@ export { anyChanged } from './utils/any-changed';
8
8
  export { hasObservers } from './utils/has-observers';
9
9
  export { guid } from './utils/guid';
10
10
  export { isSafari, isFirefox } from './utils/detect-browser';
11
- export { setHTMLAttributes } from './utils/set-html-attributes';
11
+ export * from './utils/html-attributes';
12
+ export { isControlRequired } from './utils/forms-utils';