@syncfusion/ej2-base 24.2.8 → 25.1.35-579988

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 (163) hide show
  1. package/.eslintrc.json +2 -1
  2. package/CHANGELOG.md +641 -677
  3. package/{README.md → ReadMe.md} +100 -100
  4. package/dist/ej2-base.umd.min.js +1 -10
  5. package/dist/ej2-base.umd.min.js.map +1 -1
  6. package/dist/es6/ej2-base.es2015.js +178 -1025
  7. package/dist/es6/ej2-base.es2015.js.map +1 -1
  8. package/dist/es6/ej2-base.es5.js +226 -934
  9. package/dist/es6/ej2-base.es5.js.map +1 -1
  10. package/dist/global/ej2-base.min.js +1 -10
  11. package/dist/global/ej2-base.min.js.map +1 -1
  12. package/dist/global/index.d.ts +0 -9
  13. package/dist/ts/ajax.ts +236 -0
  14. package/dist/ts/animation.ts +544 -0
  15. package/dist/ts/base.ts +357 -0
  16. package/dist/ts/browser.ts +387 -0
  17. package/dist/ts/child-property.ts +192 -0
  18. package/dist/ts/component.ts +519 -0
  19. package/dist/ts/dom.ts +488 -0
  20. package/dist/ts/draggable.ts +1155 -0
  21. package/dist/ts/droppable.ts +172 -0
  22. package/dist/ts/event-handler.ts +169 -0
  23. package/dist/ts/internationalization.ts +369 -0
  24. package/dist/ts/intl/date-formatter.ts +317 -0
  25. package/dist/ts/intl/date-parser.ts +426 -0
  26. package/dist/ts/intl/intl-base.ts +1104 -0
  27. package/dist/ts/intl/number-formatter.ts +411 -0
  28. package/dist/ts/intl/number-parser.ts +158 -0
  29. package/dist/ts/intl/parser-base.ts +394 -0
  30. package/dist/ts/keyboard.ts +238 -0
  31. package/dist/ts/l10n.ts +94 -0
  32. package/dist/ts/module-loader.ts +149 -0
  33. package/dist/ts/notify-property-change.ts +726 -0
  34. package/dist/ts/observer.ts +236 -0
  35. package/dist/ts/sanitize-helper.ts +224 -0
  36. package/dist/ts/template-engine.ts +191 -0
  37. package/dist/ts/template.ts +329 -0
  38. package/dist/ts/touch.ts +544 -0
  39. package/dist/ts/util.ts +523 -0
  40. package/dist/ts/validate-lic.ts +0 -0
  41. package/e2e/crypto.js +16 -16
  42. package/e2e/m.protractor.config.js +286 -286
  43. package/e2e/modified-protractor/protractor.config.js +316 -316
  44. package/e2e/protractor.config.js +389 -332
  45. package/helpers/e2e/index.js +3 -3
  46. package/license +10 -10
  47. package/package.json +225 -174
  48. package/src/ajax.d.ts +1 -1
  49. package/src/ajax.js +3 -8
  50. package/src/animation-model.d.ts +41 -41
  51. package/src/animation.d.ts +6 -6
  52. package/src/animation.js +25 -25
  53. package/src/base.d.ts +2 -1
  54. package/src/base.js +9 -7
  55. package/src/component-model.d.ts +16 -16
  56. package/src/component.d.ts +9 -3
  57. package/src/component.js +50 -38
  58. package/src/draggable-model.d.ts +113 -113
  59. package/src/draggable.d.ts +2 -0
  60. package/src/draggable.js +45 -29
  61. package/src/droppable-model.d.ts +23 -23
  62. package/src/droppable.js +19 -19
  63. package/src/event-handler.js +2 -1
  64. package/src/index.d.ts +0 -3
  65. package/src/index.js +0 -3
  66. package/src/intl/date-formatter.js +2 -6
  67. package/src/intl/date-parser.js +1 -20
  68. package/src/intl/intl-base.js +1 -164
  69. package/src/intl/number-formatter.d.ts +3 -0
  70. package/src/intl/number-formatter.js +7 -7
  71. package/src/intl/number-parser.js +1 -0
  72. package/src/keyboard-model.d.ts +16 -16
  73. package/src/keyboard.js +19 -19
  74. package/src/module-loader.d.ts +12 -0
  75. package/src/module-loader.js +11 -0
  76. package/src/notify-property-change.js +3 -2
  77. package/src/observer.js +2 -0
  78. package/src/sanitize-helper.js +5 -0
  79. package/src/template-engine.js +1 -0
  80. package/src/template.js +3 -2
  81. package/src/touch-model.d.ts +39 -39
  82. package/src/touch.js +19 -19
  83. package/src/validate-lic.d.ts +0 -11
  84. package/src/validate-lic.js +1 -259
  85. package/styles/_all.scss +2 -2
  86. package/styles/_bds-dark-definition.scss +15 -0
  87. package/styles/_bds-definition.scss +15 -0
  88. package/styles/_bootstrap-dark-definition.scss +42 -42
  89. package/styles/_bootstrap-definition.scss +42 -42
  90. package/styles/_bootstrap4-definition.scss +11 -11
  91. package/styles/_bootstrap5-dark-definition.scss +9 -9
  92. package/styles/_bootstrap5-definition.scss +8 -8
  93. package/styles/_fabric-dark-definition.scss +42 -42
  94. package/styles/_fabric-definition.scss +42 -42
  95. package/styles/_fluent-dark-definition.scss +9 -9
  96. package/styles/_fluent-definition.scss +9 -9
  97. package/styles/_fluent2-definition.scss +9 -0
  98. package/styles/_fusionnew-dark-definition.scss +8 -8
  99. package/styles/_fusionnew-definition.scss +8 -8
  100. package/styles/_highcontrast-definition.scss +42 -42
  101. package/styles/_highcontrast-light-definition.scss +42 -42
  102. package/styles/_material-dark-definition.scss +48 -48
  103. package/styles/_material-definition.scss +49 -49
  104. package/styles/_material3-dark-definition.scss +14 -14
  105. package/styles/_material3-definition.scss +15 -15
  106. package/styles/_tailwind-dark-definition.scss +15 -15
  107. package/styles/_tailwind-definition.scss +15 -15
  108. package/styles/animation/_all.scss +560 -560
  109. package/styles/bootstrap-dark.css +10 -1
  110. package/styles/bootstrap.css +10 -1
  111. package/styles/bootstrap4.css +10 -1
  112. package/styles/bootstrap5-dark.css +10 -1
  113. package/styles/bootstrap5.css +10 -1
  114. package/styles/common/_all.scss +2 -2
  115. package/styles/common/_core.scss +117 -117
  116. package/styles/common/_mixin.scss +9 -9
  117. package/styles/definition/_bds-dark.scss +1179 -0
  118. package/styles/definition/_bds.scss +1474 -0
  119. package/styles/definition/_bootstrap-dark.scss +219 -219
  120. package/styles/definition/_bootstrap.scss +215 -215
  121. package/styles/definition/_bootstrap4.scss +167 -167
  122. package/styles/definition/_bootstrap5-dark.scss +493 -493
  123. package/styles/definition/_bootstrap5.scss +494 -494
  124. package/styles/definition/_fabric-dark.scss +200 -200
  125. package/styles/definition/_fabric.scss +198 -198
  126. package/styles/definition/_fluent-dark.scss +557 -557
  127. package/styles/definition/_fluent.scss +558 -558
  128. package/styles/definition/_fluent2.scss +2198 -0
  129. package/styles/definition/_fusionnew-dark.scss +362 -362
  130. package/styles/definition/_fusionnew.scss +363 -363
  131. package/styles/definition/_highcontrast-light.scss +193 -193
  132. package/styles/definition/_highcontrast.scss +195 -195
  133. package/styles/definition/_material-dark.scss +198 -198
  134. package/styles/definition/_material.scss +192 -192
  135. package/styles/definition/_material3-dark.scss +710 -710
  136. package/styles/definition/_material3.scss +792 -792
  137. package/styles/definition/_tailwind-dark.scss +488 -488
  138. package/styles/definition/_tailwind.scss +485 -485
  139. package/styles/fabric-dark.css +10 -1
  140. package/styles/fabric.css +10 -1
  141. package/styles/fluent-dark.css +10 -1
  142. package/styles/fluent.css +10 -1
  143. package/styles/highcontrast-light.css +10 -1
  144. package/styles/highcontrast.css +10 -1
  145. package/styles/material-dark.css +10 -1
  146. package/styles/material.css +10 -1
  147. package/styles/material3-dark.css +10 -1
  148. package/styles/material3.css +10 -1
  149. package/styles/offline-theme/material-dark.css +10 -1
  150. package/styles/offline-theme/material.css +10 -1
  151. package/styles/offline-theme/tailwind-dark.css +10 -1
  152. package/styles/offline-theme/tailwind.css +10 -1
  153. package/styles/tailwind-dark.css +10 -1
  154. package/styles/tailwind.css +10 -1
  155. package/.github/PULL_REQUEST_TEMPLATE/Bug.md +0 -60
  156. package/.github/PULL_REQUEST_TEMPLATE/feature.md +0 -42
  157. package/bin/syncfusion-license.js +0 -2
  158. package/dist/ej2-base.min.js +0 -10
  159. package/e2e/index.d.ts +0 -27
  160. package/src/fetch.d.ts +0 -114
  161. package/src/fetch.js +0 -116
  162. package/src/hijri-parser.d.ts +0 -19
  163. package/src/hijri-parser.js +0 -204
@@ -0,0 +1,357 @@
1
+ import { isUndefined, isNullOrUndefined, merge, setImmediate, setValue, isBlazor, getValue, extend } from './util';
2
+ import { addClass, removeClass } from './dom';
3
+ import { Observer } from './observer';
4
+ export interface DomElements extends HTMLElement {
5
+ // eslint-disable-next-line
6
+ ej2_instances: Object[];
7
+ }
8
+
9
+ const isColEName: RegExp = new RegExp(']');
10
+
11
+ /* eslint-disable @typescript-eslint/no-explicit-any */
12
+
13
+ export interface AngularEventEmitter {
14
+ subscribe?: (generatorOrNext?: any, error?: any, complete?: any) => any;
15
+ }
16
+
17
+ // eslint-disable-next-line
18
+ export declare type EmitType<T> = AngularEventEmitter & ((arg?: any, ...rest: any[]) => void);
19
+
20
+ export interface BlazorDotnetObject {
21
+ dispose(): void;
22
+ invokeMethod(methodName: string): void;
23
+ invokeMethodAsync(methodName: string, ...args: any[]): void;
24
+ }
25
+ /* tslint:enable:no-any */
26
+
27
+
28
+ /**
29
+ * Base library module is common module for Framework modules like touch,keyboard and etc.,
30
+ *
31
+ * @private
32
+ */
33
+ export abstract class Base<ElementType extends HTMLElement> {
34
+ public element: ElementType;
35
+ public isDestroyed: boolean;
36
+ protected isRendered: boolean = false;
37
+ protected isComplexArraySetter: boolean = false;
38
+ public isServerRendered: boolean = false;
39
+ public allowServerDataBinding: boolean = true;
40
+ protected isProtectedOnChange: boolean = true;
41
+ protected properties: { [key: string]: Object } = {};
42
+ protected changedProperties: { [key: string]: Object } = {};
43
+ protected oldProperties: { [key: string]: Object } = {};
44
+ protected bulkChanges: { [key: string]: Object } = {};
45
+ protected refreshing: boolean = false;
46
+ public ignoreCollectionWatch : boolean = false;
47
+ // eslint-disable-next-line
48
+ protected finalUpdate: Function = (): void => { };
49
+ protected modelObserver: Observer;
50
+ protected childChangedProperties: { [key: string]: Object } = {};
51
+ protected abstract getModuleName(): string;
52
+ protected abstract onPropertyChanged(newProperties: Object, oldProperties?: Object): void;
53
+ /** Property base section */
54
+ /**
55
+ * Function used to set bunch of property at a time.
56
+ *
57
+ * @private
58
+ * @param {Object} prop - JSON object which holds components properties.
59
+ * @param {boolean} muteOnChange ? - Specifies to true when we set properties.
60
+ * @returns {void} ?
61
+ */
62
+ public setProperties(prop: Object, muteOnChange?: boolean): void {
63
+ const prevDetection: boolean = this.isProtectedOnChange;
64
+ this.isProtectedOnChange = !!muteOnChange;
65
+ merge(this, prop);
66
+ if (muteOnChange !== true) {
67
+ merge(this.changedProperties, prop);
68
+ this.dataBind();
69
+ } else if (isBlazor() && this.isRendered) {
70
+ this.serverDataBind(prop);
71
+ }
72
+ this.finalUpdate();
73
+ this.changedProperties = {};
74
+ this.oldProperties = {};
75
+ this.isProtectedOnChange = prevDetection;
76
+ }
77
+ /**
78
+ * Calls for child element data bind
79
+ *
80
+ * @param {Object} obj ?
81
+ * @param {Object} parent ?
82
+ * @returns {void} ?
83
+ */
84
+ // tslint:disable-next-line:no-any
85
+ private static callChildDataBind(obj: Object, parent: { [key: string]: any }): void {
86
+ const keys: string[] = Object.keys(obj);
87
+ for (const key of keys) {
88
+ if (parent[`${key}`] instanceof Array) {
89
+ for (const obj of parent[`${key}`]) {
90
+ if (obj.dataBind !== undefined) {
91
+ obj.dataBind();
92
+ }
93
+ }
94
+ } else {
95
+ parent[`${key}`].dataBind();
96
+ }
97
+ }
98
+ }
99
+
100
+ protected clearChanges(): void {
101
+ this.finalUpdate();
102
+ this.changedProperties = {};
103
+ this.oldProperties = {};
104
+ this.childChangedProperties = {};
105
+ }
106
+
107
+ /**
108
+ * Bind property changes immediately to components
109
+ *
110
+ * @returns {void} ?
111
+ */
112
+ public dataBind(): void {
113
+ Base.callChildDataBind(this.childChangedProperties, this);
114
+ if (Object.getOwnPropertyNames(this.changedProperties).length) {
115
+ const prevDetection: boolean = this.isProtectedOnChange;
116
+ const newChanges: Object = this.changedProperties;
117
+ const oldChanges: Object = this.oldProperties;
118
+ this.clearChanges();
119
+ this.isProtectedOnChange = true;
120
+ this.onPropertyChanged(newChanges, oldChanges);
121
+ this.isProtectedOnChange = prevDetection;
122
+ }
123
+ }
124
+
125
+ /* tslint:disable:no-any */
126
+ public serverDataBind(newChanges?: { [key: string]: any }): void {
127
+ if (!isBlazor()) {
128
+ return;
129
+ }
130
+ newChanges = newChanges ? newChanges : {};
131
+ extend(this.bulkChanges, {}, newChanges, true);
132
+ const sfBlazor: string = 'sfBlazor';
133
+ if (this.allowServerDataBinding && (window as any)[`${sfBlazor}`].updateModel) {
134
+ (window as any)[`${sfBlazor}`].updateModel(this);
135
+ this.bulkChanges = {};
136
+ }
137
+ }
138
+ /* tslint:enable:no-any */
139
+
140
+ protected saveChanges(key: string, newValue: string, oldValue: string): void {
141
+ if (isBlazor()) {
142
+ // tslint:disable-next-line:no-any
143
+ const newChanges: any = {};
144
+ newChanges[`${key}`] = newValue;
145
+ this.serverDataBind(newChanges);
146
+ }
147
+ if (this.isProtectedOnChange) {
148
+ return;
149
+ }
150
+ this.oldProperties[`${key}`] = oldValue;
151
+ this.changedProperties[`${key}`] = newValue;
152
+ this.finalUpdate();
153
+ this.finalUpdate = setImmediate(this.dataBind.bind(this));
154
+ }
155
+
156
+ /** Event Base Section */
157
+ /**
158
+ * Adds the handler to the given event listener.
159
+ *
160
+ * @param {string} eventName - A String that specifies the name of the event
161
+ * @param {Function} handler - Specifies the call to run when the event occurs.
162
+ * @returns {void} ?
163
+ */
164
+ public addEventListener(eventName: string, handler: Function): void {
165
+ this.modelObserver.on(eventName, handler);
166
+ }
167
+
168
+ /**
169
+ * Removes the handler from the given event listener.
170
+ *
171
+ * @param {string} eventName - A String that specifies the name of the event to remove
172
+ * @param {Function} handler - Specifies the function to remove
173
+ * @returns {void} ?
174
+ */
175
+ public removeEventListener(eventName: string, handler: Function): void {
176
+ this.modelObserver.off(eventName, handler);
177
+ }
178
+ /**
179
+ * Triggers the handlers in the specified event.
180
+ *
181
+ * @private
182
+ * @param {string} eventName - Specifies the event to trigger for the specified component properties.
183
+ * Can be a custom event, or any of the standard events.
184
+ * @param {Event} eventProp - Additional parameters to pass on to the event properties
185
+ * @param {Function} successHandler - this function will invoke after event successfully triggered
186
+ * @param {Function} errorHandler - this function will invoke after event if it failured to call.
187
+ * @returns {void} ?
188
+ */
189
+ public trigger(
190
+ eventName: string,
191
+ eventProp?: Object,
192
+ successHandler?: Function,
193
+ errorHandler?: Function): void | object {
194
+ if (this.isDestroyed !== true) {
195
+ const prevDetection: boolean = this.isProtectedOnChange;
196
+ this.isProtectedOnChange = false;
197
+ let data: object = this.modelObserver.notify(eventName, eventProp, successHandler, errorHandler) as object;
198
+ if (isColEName.test(eventName)) {
199
+ const handler: Function = getValue(eventName, this);
200
+ if (handler) {
201
+ const blazor: string = 'Blazor';
202
+ if (window[`${blazor}`]) {
203
+ const promise: Promise<object> = handler.call(this, eventProp);
204
+ if (promise && typeof promise.then === 'function') {
205
+ if (!successHandler) {
206
+ data = promise;
207
+ } else {
208
+ promise.then((data: object) => {
209
+ if (successHandler) {
210
+ data = typeof data === 'string' && this.modelObserver.isJson(data) ?
211
+ JSON.parse(data as string) : data;
212
+ successHandler.call(this, data);
213
+ }
214
+ }).catch((data: object) => {
215
+ if (errorHandler) {
216
+ data = typeof data === 'string' && this.modelObserver.isJson(data) ? JSON.parse(data) : data;
217
+ errorHandler.call(this, data);
218
+ }
219
+ });
220
+ }
221
+ } else if (successHandler) {
222
+ successHandler.call(this, eventProp);
223
+ }
224
+ } else {
225
+ handler.call(this, eventProp);
226
+ if (successHandler) {
227
+ successHandler.call(this, eventProp);
228
+ }
229
+ }
230
+ } else if (successHandler) {
231
+ successHandler.call(this, eventProp);
232
+ }
233
+ }
234
+ this.isProtectedOnChange = prevDetection;
235
+ return data;
236
+ }
237
+ }
238
+
239
+ /**
240
+ * Base constructor accept options and element
241
+ *
242
+ * @param {Object} options ?
243
+ * @param {string} element ?
244
+ */
245
+ constructor(options: Object, element: ElementType | string) {
246
+ this.modelObserver = new Observer(this);
247
+ if (!isUndefined(element)) {
248
+ if ('string' === typeof (element)) {
249
+ this.element = <ElementType>document.querySelector(<string>element);
250
+ } else {
251
+ this.element = <ElementType>element;
252
+ }
253
+ if (!isNullOrUndefined(this.element)) {
254
+ this.isProtectedOnChange = false;
255
+ this.addInstance();
256
+ }
257
+ }
258
+ if (!isUndefined(options)) {
259
+ this.setProperties(options, true);
260
+ }
261
+ this.isDestroyed = false;
262
+ }
263
+
264
+ /**
265
+ * To maintain instance in base class
266
+ *
267
+ * @returns {void} ?
268
+ */
269
+ protected addInstance(): void {
270
+ // Add module class to the root element
271
+ const moduleClass: string = 'e-' + this.getModuleName().toLowerCase();
272
+ addClass([this.element], ['e-lib', moduleClass]);
273
+ if (!isNullOrUndefined((<DomElements>(this.element as HTMLElement)).ej2_instances)) {
274
+ (<DomElements>(this.element as HTMLElement)).ej2_instances.push(this);
275
+ } else {
276
+ setValue('ej2_instances', [this], (<DomElements>(this.element as HTMLElement)));
277
+ }
278
+ }
279
+ /**
280
+ * To remove the instance from the element
281
+ *
282
+ * @returns {void} ?
283
+ */
284
+ protected destroy(): void {
285
+ // eslint-disable-next-line
286
+ (<DomElements>(this.element as HTMLElement)).ej2_instances =
287
+ (<DomElements>(this.element as HTMLElement)).ej2_instances ?
288
+ (<DomElements>(this.element as HTMLElement)).ej2_instances.filter((i: Object) => {
289
+ if (proxyToRaw) {
290
+ return proxyToRaw(i) !== proxyToRaw(this);
291
+ }
292
+ return i !== this;
293
+ })
294
+ : [];
295
+ removeClass([this.element], ['e-' + this.getModuleName()]);
296
+ if ((<DomElements>(this.element as HTMLElement)).ej2_instances.length === 0) {
297
+ // Remove module class from the root element
298
+ removeClass([this.element], ['e-lib']);
299
+ }
300
+ this.clearChanges();
301
+ this.modelObserver.destroy();
302
+ this.isDestroyed = true;
303
+ }
304
+ }
305
+
306
+ /**
307
+ * Global function to get the component instance from the rendered element.
308
+ *
309
+ * @param {HTMLElement} elem Specifies the HTMLElement or element id string.
310
+ * @param {string} comp Specifies the component module name or Component.
311
+ * @returns {any} ?
312
+ */
313
+ // tslint:disable-next-line:no-any
314
+ export function getComponent<T>(elem: HTMLElement | string, comp: string | any | T): T {
315
+ let instance: T;
316
+ let i: number;
317
+ const ele: HTMLElement = typeof elem === 'string' ? document.getElementById(elem) : elem;
318
+ for (i = 0; i < (<DomElements>(ele as HTMLElement)).ej2_instances.length; i++) {
319
+ instance = <T>(ele as DomElements).ej2_instances[parseInt(i.toString(), 10)];
320
+ if (typeof comp === 'string') {
321
+ const compName: string = (instance as { getModuleName: () => string } & T).getModuleName();
322
+ if (comp === compName) {
323
+ return instance;
324
+ }
325
+ } else {
326
+ // tslint:disable-next-line:no-any
327
+ if (instance instanceof <any>comp) {
328
+ return instance;
329
+ }
330
+ }
331
+ }
332
+ return undefined;
333
+ }
334
+
335
+ /**
336
+ * Function to remove the child instances.
337
+ *
338
+ * @param {HTMLElement} element ?
339
+ * @return {void}
340
+ * @private
341
+ */
342
+ // tslint:disable-next-line:no-any
343
+ export function removeChildInstance(element: HTMLElement): void {
344
+ // tslint:disable-next-line:no-any
345
+ const childEle: any = [].slice.call(element.getElementsByClassName('e-control'));
346
+ for (let i: number = 0; i < childEle.length; i++) {
347
+ const compName: string = childEle[parseInt(i.toString(), 10)].classList[1].split('e-')[1];
348
+ // tslint:disable-next-line:no-any
349
+ const compInstance: any = getComponent(childEle[parseInt(i.toString(), 10)], compName);
350
+ if (!isUndefined(compInstance)) {
351
+ compInstance.destroy();
352
+ }
353
+ }
354
+ }
355
+
356
+ export let proxyToRaw: Function;
357
+ export const setProxyToRaw: Function = (toRaw: Function): void => { proxyToRaw = toRaw; };