@syncfusion/ej2-splitbuttons 29.2.4 → 30.1.37

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 (100) hide show
  1. package/dist/ej2-splitbuttons.min.js +2 -2
  2. package/dist/ej2-splitbuttons.umd.min.js +1 -1
  3. package/dist/global/ej2-splitbuttons.min.js +1 -1
  4. package/dist/global/index.d.ts +1 -1
  5. package/dist/ts/button-group/button-group.d.ts +38 -0
  6. package/dist/ts/button-group/button-group.ts +84 -0
  7. package/dist/ts/button-group/index.d.ts +4 -0
  8. package/dist/ts/button-group/index.ts +4 -0
  9. package/dist/ts/common/common-model.d.ts +51 -0
  10. package/dist/ts/common/common.d.ts +95 -0
  11. package/dist/ts/common/common.ts +218 -0
  12. package/dist/ts/common/index.d.ts +5 -0
  13. package/dist/ts/common/index.ts +5 -0
  14. package/dist/ts/drop-down-button/drop-down-button-model.d.ts +195 -0
  15. package/dist/ts/drop-down-button/drop-down-button.d.ts +308 -0
  16. package/dist/ts/drop-down-button/drop-down-button.ts +1110 -0
  17. package/dist/ts/drop-down-button/index.d.ts +5 -0
  18. package/dist/ts/drop-down-button/index.ts +5 -0
  19. package/dist/ts/index.d.ts +8 -0
  20. package/dist/ts/index.ts +8 -0
  21. package/dist/ts/progress-button/index.d.ts +5 -0
  22. package/dist/ts/progress-button/index.ts +5 -0
  23. package/dist/ts/progress-button/progress-button-model.d.ts +206 -0
  24. package/dist/ts/progress-button/progress-button.d.ts +323 -0
  25. package/dist/ts/progress-button/progress-button.ts +689 -0
  26. package/dist/ts/split-button/index.d.ts +5 -0
  27. package/dist/ts/split-button/index.ts +5 -0
  28. package/dist/ts/split-button/split-button-model.d.ts +133 -0
  29. package/dist/ts/split-button/split-button.d.ts +236 -0
  30. package/dist/ts/split-button/split-button.ts +535 -0
  31. package/package.json +9 -9
  32. package/styles/bds-lite.css +1 -7
  33. package/styles/bds.css +2 -7
  34. package/styles/bootstrap-dark-lite.css +0 -1
  35. package/styles/bootstrap-dark.css +0 -1
  36. package/styles/bootstrap-lite.css +0 -1
  37. package/styles/bootstrap.css +0 -1
  38. package/styles/bootstrap4-lite.css +0 -1
  39. package/styles/bootstrap4.css +3 -1
  40. package/styles/bootstrap5-dark-lite.css +2 -4
  41. package/styles/bootstrap5-dark.css +2 -4
  42. package/styles/bootstrap5-lite.css +2 -4
  43. package/styles/bootstrap5.3-lite.css +0 -2
  44. package/styles/bootstrap5.3.css +0 -2
  45. package/styles/bootstrap5.css +2 -4
  46. package/styles/drop-down-button/_layout.scss +0 -1
  47. package/styles/drop-down-button/material3-dark.css +0 -1
  48. package/styles/drop-down-button/material3.css +0 -1
  49. package/styles/fabric-dark-lite.css +0 -1
  50. package/styles/fabric-dark.css +0 -1
  51. package/styles/fabric-lite.css +0 -1
  52. package/styles/fabric.css +0 -1
  53. package/styles/fluent-dark-lite.css +0 -1
  54. package/styles/fluent-dark.css +1 -1
  55. package/styles/fluent-lite.css +0 -1
  56. package/styles/fluent.css +1 -1
  57. package/styles/fluent2-lite.css +1 -3
  58. package/styles/fluent2.css +1 -3
  59. package/styles/highcontrast-light-lite.css +0 -1
  60. package/styles/highcontrast-light.css +0 -1
  61. package/styles/highcontrast-lite.css +0 -1
  62. package/styles/highcontrast.css +0 -1
  63. package/styles/material-dark-lite.css +0 -1
  64. package/styles/material-dark.css +0 -1
  65. package/styles/material-lite.css +0 -1
  66. package/styles/material.css +0 -1
  67. package/styles/material3-dark-lite.css +3 -6
  68. package/styles/material3-dark.css +5 -8
  69. package/styles/material3-lite.css +3 -6
  70. package/styles/material3.css +5 -8
  71. package/styles/split-button/_bigger.scss +7 -1
  72. package/styles/split-button/_layout.scss +7 -13
  73. package/styles/split-button/_theme.scss +2 -8
  74. package/styles/split-button/bds.css +2 -7
  75. package/styles/split-button/bootstrap-dark.css +0 -1
  76. package/styles/split-button/bootstrap.css +0 -1
  77. package/styles/split-button/bootstrap4.css +3 -1
  78. package/styles/split-button/bootstrap5-dark.css +2 -4
  79. package/styles/split-button/bootstrap5.3.css +0 -2
  80. package/styles/split-button/bootstrap5.css +2 -4
  81. package/styles/split-button/fabric-dark.css +0 -1
  82. package/styles/split-button/fabric.css +0 -1
  83. package/styles/split-button/fluent-dark.css +1 -1
  84. package/styles/split-button/fluent.css +1 -1
  85. package/styles/split-button/fluent2.css +1 -3
  86. package/styles/split-button/highcontrast-light.css +0 -1
  87. package/styles/split-button/highcontrast.css +0 -1
  88. package/styles/split-button/material-dark.css +0 -1
  89. package/styles/split-button/material.css +0 -1
  90. package/styles/split-button/material3-dark.css +5 -7
  91. package/styles/split-button/material3.css +5 -7
  92. package/styles/split-button/tailwind-dark.css +2 -7
  93. package/styles/split-button/tailwind.css +2 -7
  94. package/styles/split-button/tailwind3.css +1 -3
  95. package/styles/tailwind-dark-lite.css +1 -7
  96. package/styles/tailwind-dark.css +2 -7
  97. package/styles/tailwind-lite.css +1 -7
  98. package/styles/tailwind.css +2 -7
  99. package/styles/tailwind3-lite.css +1 -3
  100. package/styles/tailwind3.css +1 -3
@@ -0,0 +1,689 @@
1
+ import { Button, IconPosition } from '@syncfusion/ej2-buttons';
2
+ import { EventHandler, Property, INotifyPropertyChanged, NotifyPropertyChanges, Animation, Effect, attributes, animationMode } from '@syncfusion/ej2-base';
3
+ import { EmitType, Event, BaseEventArgs, remove, removeClass } from '@syncfusion/ej2-base';
4
+ import { Complex, ChildProperty, SanitizeHtmlHelper } from '@syncfusion/ej2-base';
5
+ import { createSpinner, showSpinner, hideSpinner } from '@syncfusion/ej2-popups';
6
+ import { ProgressButtonModel, SpinSettingsModel, AnimationSettingsModel } from './progress-button-model';
7
+
8
+ const HIDESPINNER: string = 'e-hide-spinner';
9
+ const PROGRESS: string = 'e-progress';
10
+ const PROGRESSACTIVE: string = 'e-progress-active';
11
+ const CONTENTCLS: string = 'e-btn-content';
12
+ /**
13
+ * Defines the spin settings.
14
+ */
15
+ export class SpinSettings extends ChildProperty<SpinSettings> {
16
+ /**
17
+ * Specifies the template content to be displayed in a spinner.
18
+ *
19
+ * @default null
20
+ * @aspType string
21
+ */
22
+ @Property(null)
23
+ public template: string | Function;
24
+ /**
25
+ * Sets the width of a spinner.
26
+ *
27
+ * @default '16'
28
+ */
29
+ @Property(16)
30
+ public width: string | number;
31
+ /**
32
+ * Specifies the position of a spinner in the progress button. The possible values are:
33
+ * * Left: The spinner will be positioned to the left of the text content.
34
+ * * Right: The spinner will be positioned to the right of the text content.
35
+ * * Top: The spinner will be positioned at the top of the text content.
36
+ * * Bottom: The spinner will be positioned at the bottom of the text content.
37
+ * * Center: The spinner will be positioned at the center of the progress button.
38
+ *
39
+ * @default 'Left'
40
+ * @aspType Syncfusion.EJ2.SplitButtons.SpinPosition
41
+ * @blazorType Syncfusion.Blazor.SplitButtons.SpinPosition
42
+ * @isEnumeration true
43
+ */
44
+ @Property('Left')
45
+ public position: SpinPosition;
46
+ }
47
+ /**
48
+ * Defines the animation settings.
49
+ */
50
+ export class AnimationSettings extends ChildProperty<AnimationSettings> {
51
+ /**
52
+ * Specifies the duration taken to animate.
53
+ *
54
+ * @default 400
55
+ */
56
+ @Property(400)
57
+ public duration: number;
58
+ /**
59
+ * Specifies the effect of animation.
60
+ *
61
+ * @default 'None'
62
+ * @aspType Syncfusion.EJ2.SplitButtons.AnimationEffect
63
+ * @blazorType Syncfusion.Blazor.SplitButtons.AnimationEffect
64
+ * @isEnumeration true
65
+ */
66
+ @Property('None')
67
+ public effect: AnimationEffect;
68
+ /**
69
+ * Specifies the animation timing function.
70
+ *
71
+ * @default 'ease'
72
+ */
73
+ @Property('ease')
74
+ public easing: string;
75
+ }
76
+
77
+ /**
78
+ * The ProgressButton visualizes the progression of an operation to indicate the user
79
+ * that a process is happening in the background with visual representation.
80
+ * ```html
81
+ * <button id="element"></button>
82
+ * ```
83
+ * ```typescript
84
+ * <script>
85
+ * var progressButtonObj = new ProgressButton({ content: 'Progress Button' });
86
+ * progressButtonObj.appendTo("#element");
87
+ * </script>
88
+ * ```
89
+ */
90
+ @NotifyPropertyChanges
91
+ export class ProgressButton extends Button implements INotifyPropertyChanged {
92
+ private progressTime: number;
93
+ private percent: number;
94
+ private isPaused: boolean;
95
+ private timerId: number;
96
+ private step: number = 1;
97
+ private interval: number;
98
+ private eIsVertical: boolean;
99
+
100
+ /**
101
+ * Enables or disables the background filler UI in the progress button.
102
+ *
103
+ * @default false
104
+ */
105
+ @Property(false)
106
+ public enableProgress: boolean;
107
+
108
+ /**
109
+ * Specifies the duration of progression in the progress button.
110
+ *
111
+ * @default 2000
112
+ */
113
+ @Property(2000)
114
+ public duration: number;
115
+
116
+ /**
117
+ * Positions an icon in the progress button. The possible values are:
118
+ * * Left: The icon will be positioned to the left of the text content.
119
+ * * Right: The icon will be positioned to the right of the text content.
120
+ * * Top: The icon will be positioned at the top of the text content.
121
+ * * Bottom: The icon will be positioned at the bottom of the text content.
122
+ *
123
+ * @isenumeration true
124
+ * @default Syncfusion.EJ2.Buttons.IconPosition.Left
125
+ * @asptype Syncfusion.EJ2.Buttons.IconPosition
126
+ */
127
+ @Property('Left')
128
+ public iconPosition: string | IconPosition;
129
+
130
+ /**
131
+ * Defines class/multiple classes separated by a space for the progress button that is used to include an icon.
132
+ * Progress button can also include font icon and sprite image.
133
+ *
134
+ * @default ""
135
+ */
136
+ @Property('')
137
+ public iconCss: string;
138
+
139
+ /**
140
+ * Enables or disables the progress button.
141
+ *
142
+ * @default false.
143
+ */
144
+ @Property(false)
145
+ public disabled: boolean;
146
+
147
+ /**
148
+ * Allows the appearance of the progress button to be enhanced and visually appealing when set to `true`.
149
+ *
150
+ * @default false
151
+ */
152
+ @Property(false)
153
+ public isPrimary: boolean;
154
+
155
+ /**
156
+ * Specifies the root CSS class of the progress button that allows customization of component’s appearance.
157
+ * The progress button types, styles, and size can be achieved by using this property.
158
+ *
159
+ * @default ""
160
+ */
161
+ @Property('')
162
+ public cssClass: string;
163
+
164
+ /**
165
+ * Defines the text `content` of the progress button element.
166
+ *
167
+ * @default ""
168
+ */
169
+ @Property('')
170
+ public content: string;
171
+
172
+ /**
173
+ * Makes the progress button toggle, when set to `true`. When you click it, the state changes from normal to active.
174
+ *
175
+ * @default false
176
+ */
177
+ @Property(false)
178
+ public isToggle: boolean;
179
+
180
+ /**
181
+ * Specifies whether to enable the rendering of untrusted HTML values in the Progress button component.
182
+ * If 'enableHtmlSanitizer' set to true, the component will sanitize any suspected untrusted strings and scripts before rendering them.
183
+ *
184
+ * @default true
185
+ */
186
+ @Property(true)
187
+ public enableHtmlSanitizer: boolean;
188
+
189
+ /**
190
+ * Specifies a spinner and its related properties.
191
+ */
192
+ @Complex<SpinSettingsModel>({}, SpinSettings)
193
+ public spinSettings: SpinSettingsModel;
194
+
195
+ /**
196
+ * Specifies the animation settings.
197
+ */
198
+ @Complex<AnimationSettingsModel>({}, AnimationSettings)
199
+ public animationSettings: AnimationSettingsModel;
200
+
201
+ /**
202
+ * Triggers once the component rendering is completed.
203
+ *
204
+ * @event created
205
+ * @blazorProperty 'Created'
206
+ */
207
+ @Event()
208
+ public created: EmitType<Event>;
209
+
210
+ /**
211
+ * Triggers when the progress starts.
212
+ *
213
+ * @event begin
214
+ * @blazorProperty 'OnBegin'
215
+ */
216
+ @Event()
217
+ public begin: EmitType<ProgressEventArgs>;
218
+
219
+ /**
220
+ * Triggers in specified intervals.
221
+ *
222
+ * @event progress
223
+ * @blazorProperty 'Progressing'
224
+ */
225
+ @Event()
226
+ public progress: EmitType<ProgressEventArgs>;
227
+
228
+ /**
229
+ * Triggers when the progress is completed.
230
+ *
231
+ * @event end
232
+ * @blazorProperty 'OnEnd'
233
+ */
234
+ @Event()
235
+ public end: EmitType<ProgressEventArgs>;
236
+
237
+ /**
238
+ * Triggers when the progress is incomplete.
239
+ *
240
+ * @event fail
241
+ * @blazorProperty 'OnFailure'
242
+ */
243
+ @Event()
244
+ public fail: EmitType<Event>;
245
+
246
+ /**
247
+ * Constructor for creating the widget.
248
+ *
249
+ * @param {ProgressButtonModel} options - Specifies progress button model
250
+ * @param {string|HTMLButtonElement} element - Specifies element
251
+ */
252
+ constructor(options?: ProgressButtonModel, element?: string | HTMLButtonElement) {
253
+ super(options, element);
254
+ }
255
+
256
+ protected preRender(): void {
257
+ super.preRender();
258
+ }
259
+
260
+ /**
261
+ * Initialize the Component rendering
262
+ *
263
+ * @returns {void}
264
+ * @private
265
+ */
266
+ public render(): void {
267
+ super.render();
268
+ this.init();
269
+ this.wireEvents();
270
+ this.setAria();
271
+ this.renderComplete();
272
+ }
273
+
274
+ /**
275
+ * Starts the button progress at the specified percent.
276
+ *
277
+ * @param {number} percent - Starts the button progress at this percent.
278
+ * @returns {void}
279
+ */
280
+ public start(percent?: number): void {
281
+ this.isPaused = false;
282
+ this.startProgress(percent ? percent : this.percent, this.progressTime);
283
+ }
284
+
285
+ /**
286
+ * Stops the button progress.
287
+ *
288
+ * @returns {void}
289
+ */
290
+ public stop(): void {
291
+ this.isPaused = true;
292
+ cancelAnimationFrame(this.timerId);
293
+ }
294
+
295
+ /**
296
+ * Complete the button progress.
297
+ *
298
+ * @returns {void}
299
+ */
300
+ public progressComplete(): void {
301
+ this.isPaused = false;
302
+ this.finishProgress();
303
+ }
304
+
305
+ /**
306
+ * Get component name.
307
+ *
308
+ * @returns {string} - Module Name
309
+ * @private
310
+ */
311
+ public getModuleName(): string {
312
+ return 'progress-btn';
313
+ }
314
+
315
+ /**
316
+ * Destroys the widget.
317
+ *
318
+ * @returns {void}
319
+ */
320
+ public destroy(): void {
321
+ let classList: string[] = [HIDESPINNER, PROGRESSACTIVE, 'e-round-corner', 'e-' + super.getModuleName()];
322
+ if (this.spinSettings.position) {
323
+ classList.push('e-spin-' + this.spinSettings.position.toLowerCase());
324
+ }
325
+ super.destroy();
326
+ this.unWireEvents();
327
+ this.element.innerHTML = '';
328
+ if (this.cssClass) {
329
+ classList = classList.concat(this.cssClass.split(' '));
330
+ }
331
+ removeClass([this.element], classList);
332
+ const css: string[] = this.element.getAttribute('class') ? ['aria-label', 'aria-valuemin', 'aria-valuemax', 'aria-valuenow']
333
+ : ['aria-label', 'aria-valuemin', 'aria-valuemax', 'aria-valuenow', 'class'];
334
+ css.forEach((key: string) => {
335
+ this.element.removeAttribute(key);
336
+ });
337
+ if (this.disabled) {
338
+ this.element.removeAttribute('disabled');
339
+ }
340
+ }
341
+
342
+ private init(): void {
343
+ this.element.classList.add('e-' + super.getModuleName());
344
+ this.setContent();
345
+ this.createSpinner();
346
+ if (this.enableProgress) {
347
+ this.createProgress();
348
+ }
349
+ }
350
+
351
+ private createSpinner(): void {
352
+ const spinner: HTMLElement = this.createElement('span', { className: 'e-spinner' });
353
+ this.setSpinPosition(spinner);
354
+ createSpinner(
355
+ {
356
+ target: spinner, width: this.spinSettings.width || 16, template: this.spinSettings.template as string
357
+ },
358
+ this.createElement);
359
+ }
360
+
361
+ private getSpinner(): HTMLElement {
362
+ return this.element.getElementsByClassName('e-spinner')[0] as HTMLElement;
363
+ }
364
+
365
+ private getProgress(): HTMLElement {
366
+ return this.element.getElementsByClassName(PROGRESS)[0] as HTMLElement;
367
+ }
368
+
369
+ private setSpinPosition(ele: HTMLElement): void {
370
+ const position: SpinPosition = this.spinSettings.position || 'Left';
371
+ if (position === 'Left' || position === 'Top') {
372
+ this.element.insertBefore(ele, this.element.getElementsByClassName(CONTENTCLS)[0]);
373
+ } else {
374
+ this.element.appendChild(ele);
375
+ }
376
+ this.element.classList.add('e-spin-' + position.toLowerCase());
377
+ }
378
+
379
+ private createProgress(): void {
380
+ this.element.appendChild(this.createElement('span', { className: PROGRESS }));
381
+ }
382
+
383
+ private setContent(): void {
384
+ let cont: string;
385
+ cont = this.element.innerHTML;
386
+ if (this.enableHtmlSanitizer) {
387
+ cont = SanitizeHtmlHelper.sanitize(this.element.innerHTML);
388
+ }
389
+ this.element.innerHTML = '';
390
+ this.element.appendChild(this.createElement('span', { className: CONTENTCLS, innerHTML: cont }));
391
+ }
392
+
393
+ private clickHandler(): void {
394
+ if (this.element.classList.contains(PROGRESSACTIVE)) {
395
+ return;
396
+ }
397
+ this.startProgress();
398
+ }
399
+
400
+ private startProgress(percent?: number, progressTime?: number): void {
401
+ const clsList: DOMTokenList = this.element.classList;
402
+ const isVertical: boolean = clsList.contains('e-vertical');
403
+ clsList.add(PROGRESSACTIVE);
404
+ if (!(clsList.contains(HIDESPINNER))) {
405
+ showSpinner(this.element.querySelector('.e-spinner'));
406
+ }
407
+ this.startAnimate(
408
+ Date.now(), progressTime ? progressTime : 0, progressTime ? Date.now() - (this.duration * 1 / 100) : Date.now(),
409
+ percent ? percent : 0, 0, this.step, 0, isVertical);
410
+ this.startContAnimate();
411
+ }
412
+
413
+ private startAnimate(
414
+ timestamp: number, progressTime: number, prevTime: number, percent: number, prevPercent: number,
415
+ step: number, prevProgressTime: number, isVertical: boolean): void {
416
+ try {
417
+ const timeDiff: number = timestamp - prevTime;
418
+ const stepTime: number = this.duration * step / 100;
419
+ const timeDiffBuffer: number = timeDiff ? (timeDiff < stepTime ? timeDiff - stepTime : timeDiff % stepTime) : 0;
420
+ this.progressTime = progressTime = progressTime + timeDiff - timeDiffBuffer;
421
+ prevTime = timestamp - timeDiffBuffer;
422
+ percent = percent + (timeDiff - timeDiffBuffer) / this.duration * 100;
423
+ prevPercent = ((progressTime - prevProgressTime) % stepTime === 0 || percent === 100) ? percent : prevPercent;
424
+ const args: ProgressEventArgs = { percent: prevPercent, currentDuration: progressTime, step: step };
425
+ this.eIsVertical = isVertical;
426
+ if (percent === 0) {
427
+ this.trigger('begin', args, (observedArgs: ProgressEventArgs) => {
428
+ this.successCallback(observedArgs, percent, prevPercent, progressTime, prevProgressTime, timeDiffBuffer, prevTime);
429
+ });
430
+ } else if (percent === 100 || progressTime === this.duration) {
431
+ this.trigger('end', args, (observedArgs: ProgressEventArgs) => {
432
+ this.successCallback(observedArgs, percent, prevPercent, progressTime, prevProgressTime, timeDiffBuffer, prevTime);
433
+ });
434
+ } else {
435
+ this.trigger('progress', args, (observedArgs: ProgressEventArgs) => {
436
+ this.successCallback(observedArgs, percent, prevPercent, progressTime, prevProgressTime, timeDiffBuffer, prevTime);
437
+ });
438
+ }
439
+ } catch (e) {
440
+ cancelAnimationFrame(this.timerId);
441
+ this.trigger('fail', e);
442
+ }
443
+ }
444
+
445
+ private successCallback(
446
+ args: ProgressEventArgs, perc: number, pPerc: number, prgTim: number, pPrgTim: number, timDif: number, pTim: number): void {
447
+ let percent: number = perc; let prevPercent: number = pPerc; const timeDiffBuffer: number = timDif;
448
+ const progressTime: number = prgTim; let prevProgressTime: number = pPrgTim;
449
+ const prevTime: number = pTim; const isVertical: boolean = this.eIsVertical;
450
+ if (percent !== args.percent && args.percent !== prevPercent) {
451
+ percent = args.percent;
452
+ }
453
+ this.percent = percent;
454
+ this.step = args.step;
455
+ if ((progressTime - prevProgressTime) % (this.duration * args.step / 100) === 0 || percent === 100) {
456
+ this.timerId = requestAnimationFrame(() => {
457
+ if (this.enableProgress && this.getProgress()) {
458
+ this.getProgress().style[isVertical ? 'height' : 'width'] = percent + '%';
459
+ }
460
+ this.element.setAttribute('aria-valuenow', percent.toString());
461
+ });
462
+ prevPercent = percent;
463
+ prevProgressTime = progressTime;
464
+ }
465
+ if (!this.isPaused) {
466
+ if (progressTime < this.duration && percent < 100) {
467
+ this.interval = window.setTimeout(() => {
468
+ this.startAnimate(
469
+ Date.now(), progressTime, prevTime, percent,
470
+ prevPercent, args.step, prevProgressTime, isVertical);
471
+ }, (this.duration / 100) - timeDiffBuffer);
472
+ } else {
473
+ this.interval = window.setTimeout(() => {
474
+ this.progressTime = this.percent = 0;
475
+ if (this.enableProgress && this.getProgress()) {
476
+ this.getProgress().style[isVertical ? 'height' : 'width'] = '0%';
477
+ }
478
+ this.element.setAttribute('aria-valuenow', '0');
479
+ this.hideSpin();
480
+ }, 100);
481
+ }
482
+ }
483
+ }
484
+ private startContAnimate(): void {
485
+ const ele: HTMLElement = this.element.getElementsByClassName(CONTENTCLS)[0] as HTMLElement;
486
+ if (this.animationSettings.effect !== 'None') {
487
+ (new Animation({})).animate(
488
+ ele,
489
+ {
490
+ duration: (this.animationSettings.duration === 0 && animationMode === 'Enable') ? 400 : this.animationSettings.duration,
491
+ name: 'Progress' + this.animationSettings.effect as Effect,
492
+ timingFunction: this.animationSettings.easing,
493
+ begin: () => {
494
+ if (this.spinSettings.position === 'Center') {
495
+ this.setSpinnerSize();
496
+ }
497
+ },
498
+ end: () => {
499
+ ele.classList.add('e-animate-end');
500
+ }
501
+ });
502
+ } else if (this.spinSettings.position === 'Center') {
503
+ this.setSpinnerSize();
504
+ }
505
+ }
506
+
507
+ private finishProgress(): void {
508
+ const clsList: DOMTokenList = this.element.classList;
509
+ const isVertical: boolean = clsList.contains('e-vertical');
510
+ clsList.add(PROGRESSACTIVE);
511
+ const count: number = 100;
512
+ for (let i: number = this.percent; i < count; i++) {
513
+ i += 10;
514
+ if (i > 100) {
515
+ i = 100;
516
+ }
517
+ if (this.enableProgress && this.getProgress()) {
518
+ this.getProgress().style[isVertical ? 'height' : 'width'] = (this.percent < 100) ? (i + '%') : '100%';
519
+ }
520
+ }
521
+ this.element.setAttribute('aria-valuenow', '0');
522
+ this.hideSpin();
523
+ const args: ProgressEventArgs = {step: this.step, currentDuration: this.progressTime, percent: 100};
524
+ clearTimeout(this.interval);
525
+ this.trigger('end', args);
526
+ this.progressTime = this.percent = 0;
527
+ }
528
+
529
+ private setSpinnerSize(): void {
530
+ const ele: HTMLElement = this.element.getElementsByClassName(CONTENTCLS)[0] as HTMLElement;
531
+ const spinner: HTMLElement = this.getSpinner();
532
+ spinner.style.width = Math.max(spinner.offsetWidth, ele.offsetWidth) + 'px';
533
+ spinner.style.height = Math.max(spinner.offsetHeight, ele.offsetHeight) + 'px';
534
+ ele.classList.add('e-cont-animate');
535
+ }
536
+
537
+ private hideSpin(): void {
538
+ const cont: Element = this.element.getElementsByClassName(CONTENTCLS)[0];
539
+ if (!(this.element.classList.contains(HIDESPINNER))) {
540
+ hideSpinner(this.element.querySelector('.e-spinner'));
541
+ }
542
+ this.element.classList.remove(PROGRESSACTIVE);
543
+ if (this.animationSettings.effect !== 'None') {
544
+ cont.classList.remove('e-animate-end');
545
+ }
546
+ if (this.spinSettings.position === 'Center') {
547
+ const ele: HTMLElement = this.getSpinner();
548
+ cont.classList.remove('e-cont-animate');
549
+ ele.style.width = 'auto';
550
+ ele.style.height = 'auto';
551
+ }
552
+ }
553
+
554
+ private setIconSpan(): void {
555
+ const cont: Element = this.element.getElementsByClassName(CONTENTCLS)[0];
556
+ const iconSpan: Element = this.element.getElementsByClassName('e-btn-icon')[0];
557
+ if (cont.childNodes[0] && (this.iconPosition === 'Left' || this.iconPosition === 'Top')) {
558
+ cont.insertBefore(iconSpan, cont.childNodes[0]);
559
+ } else {
560
+ cont.appendChild(iconSpan);
561
+ }
562
+ }
563
+
564
+ private setAria(): void {
565
+ attributes(this.element, {
566
+ 'aria-label': this.element.textContent + ' progress'
567
+ });
568
+ }
569
+
570
+ protected wireEvents(): void {
571
+ EventHandler.add(this.element, 'click', this.clickHandler, this);
572
+ }
573
+
574
+ protected unWireEvents(): void {
575
+ EventHandler.remove(this.element, 'click', this.clickHandler);
576
+ }
577
+
578
+ /**
579
+ * Called internally if any of the property value changed.
580
+ *
581
+ * @param {ProgressButtonModel} newProp - Specifies new properties
582
+ * @param {ProgressButtonModel} oldProp - Specifies old properties
583
+ * @returns {void}
584
+ * @private
585
+ */
586
+ public onPropertyChanged(newProp: ProgressButtonModel, oldProp: ProgressButtonModel): void {
587
+ const ele: HTMLButtonElement = this.element; let isSpinning: boolean = false;
588
+ const clsList: DOMTokenList = this.element.querySelector('.e-spinner-pane').classList;
589
+ if (clsList.contains('e-spin-show')) {
590
+ isSpinning = true;
591
+ }
592
+ super.onPropertyChanged(newProp, oldProp);
593
+ for (const prop of Object.keys(newProp)) {
594
+ switch (prop) {
595
+ case 'content':
596
+ this.setContent();
597
+ this.createSpinner();
598
+ if (isSpinning) {
599
+ showSpinner(this.element.querySelector('.e-spinner'));
600
+ isSpinning = false;
601
+ }
602
+ if (this.enableProgress) {
603
+ this.createProgress();
604
+ }
605
+ ele.setAttribute('aria-label', ele.textContent + ' progress');
606
+ break;
607
+ case 'iconCss':
608
+ if (!oldProp.iconCss) {
609
+ this.setIconSpan();
610
+ }
611
+ break;
612
+ case 'iconPosition':
613
+ this.setIconSpan();
614
+ break;
615
+ case 'enableProgress':
616
+ if (newProp.enableProgress) {
617
+ this.createProgress();
618
+ } else {
619
+ remove(this.getProgress());
620
+ }
621
+ break;
622
+ case 'spinSettings':
623
+ if (newProp.spinSettings.position) {
624
+ ele.classList.remove('e-spin-' + oldProp.spinSettings.position.toLowerCase());
625
+ this.setSpinPosition(this.getSpinner());
626
+ }
627
+ if (newProp.spinSettings.template || newProp.spinSettings.width) {
628
+ ele.removeChild(this.getSpinner());
629
+ this.createSpinner();
630
+ }
631
+ break;
632
+ }
633
+ }
634
+ }
635
+
636
+ /**
637
+ * Sets the focus to ProgressButton
638
+ * its native method
639
+ *
640
+ * @public
641
+ * @returns {void}
642
+ */
643
+ public focusIn(): void {
644
+ this.element.focus();
645
+ }
646
+ }
647
+ /**
648
+ * Defines the spin position of progress button.
649
+ * ```props
650
+ * Left :- The spinner will be positioned to the left of the text content.
651
+ * Right :- The spinner will be positioned to the right of the text content.
652
+ * Top :- The spinner will be positioned at the top of the text content.
653
+ * Bottom :- The spinner will be positioned at the bottom of the text content.
654
+ * Center :- The spinner will be positioned at the center of the progress button.
655
+ * ```
656
+ */
657
+ export type SpinPosition = 'Left' | 'Right' | 'Top' | 'Bottom' | 'Center';
658
+ /**
659
+ * Defines the animation effect of progress button.
660
+ * ```props
661
+ * None :- The button will not have any animation effect on the text content.
662
+ * SlideLeft :- The text content will slide to the left as an animation effect.
663
+ * SlideRight :- The text content will slide to the right as an animation effect.
664
+ * SlideUp :- The text content will slide up as an animation effect.
665
+ * SlideDown :- The text content will slide down as an animation effect.
666
+ * ZoomIn :- The text content will zoom in as an animation effect.
667
+ * ZoomOut :- The text content will zoom out as an animation effect.
668
+ * ```
669
+ */
670
+ export type AnimationEffect = 'None' | 'SlideLeft' | 'SlideRight' | 'SlideUp' | 'SlideDown' | 'ZoomIn' | 'ZoomOut';
671
+ /**
672
+ * Interface for progress event arguments.
673
+ */
674
+ export interface ProgressEventArgs extends BaseEventArgs {
675
+ /**
676
+ * Indicates the current state of progress in percentage.
677
+ */
678
+ percent: number;
679
+ /**
680
+ * Indicates the current duration of the progress.
681
+ */
682
+ currentDuration: number;
683
+ /**
684
+ * Specifies the interval.
685
+ *
686
+ * @default 1
687
+ */
688
+ step: number;
689
+ }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Split Button modules
3
+ */
4
+ export * from './split-button';
5
+ export * from './split-button-model';
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Split Button modules
3
+ */
4
+ export * from './split-button';
5
+ export * from './split-button-model';