@syncfusion/ej2-splitbuttons 24.2.5 → 25.1.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -26
- package/dist/ej2-splitbuttons.min.js +2 -2
- package/dist/ej2-splitbuttons.umd.min.js +2 -2
- package/dist/ej2-splitbuttons.umd.min.js.map +1 -1
- package/dist/es6/ej2-splitbuttons.es2015.js +5 -5
- package/dist/es6/ej2-splitbuttons.es2015.js.map +1 -1
- package/dist/es6/ej2-splitbuttons.es5.js +5 -5
- package/dist/es6/ej2-splitbuttons.es5.js.map +1 -1
- package/dist/global/ej2-splitbuttons.min.js +2 -2
- package/dist/global/ej2-splitbuttons.min.js.map +1 -1
- package/dist/global/index.d.ts +1 -1
- package/dist/ts/button-group/button-group.ts +84 -0
- package/dist/ts/common/common.ts +212 -0
- package/dist/ts/drop-down-button/drop-down-button.ts +920 -0
- package/dist/ts/progress-button/progress-button.ts +709 -0
- package/dist/ts/split-button/split-button.ts +534 -0
- package/package.json +7 -7
- package/src/drop-down-button/drop-down-button-model.d.ts +3 -2
- package/src/drop-down-button/drop-down-button.d.ts +3 -2
- package/src/drop-down-button/drop-down-button.js +1 -1
- package/src/progress-button/progress-button-model.d.ts +3 -2
- package/src/progress-button/progress-button.d.ts +3 -2
- package/src/progress-button/progress-button.js +4 -4
- package/styles/button-group/_bds-definition.scss +31 -0
- package/styles/drop-down-button/_bds-definition.scss +89 -0
- package/styles/drop-down-button/icons/_bds.scss +10 -0
- package/styles/progress-button/_bds-definition.scss +28 -0
- package/styles/split-button/_bds-definition.scss +24 -0
|
@@ -0,0 +1,534 @@
|
|
|
1
|
+
// eslint-disable-next-line @typescript-eslint/triple-slash-reference
|
|
2
|
+
/// <reference path='../drop-down-button/drop-down-button-model.d.ts'/>
|
|
3
|
+
import { Event, EmitType, remove, addClass, removeClass, detach, getValue, setValue } from '@syncfusion/ej2-base';
|
|
4
|
+
import { EventHandler, Collection, BaseEventArgs, NotifyPropertyChanges, INotifyPropertyChanged, Property } from '@syncfusion/ej2-base';
|
|
5
|
+
import { attributes, getUniqueID, getInstance, KeyboardEvents, KeyboardEventArgs } from '@syncfusion/ej2-base';
|
|
6
|
+
import { Button, ButtonModel } from '@syncfusion/ej2-buttons';
|
|
7
|
+
import { MenuEventArgs, BeforeOpenCloseMenuEventArgs, OpenCloseMenuEventArgs } from './../common/common';
|
|
8
|
+
import { getModel, SplitButtonIconPosition, Item } from './../common/common';
|
|
9
|
+
import { DropDownButton } from '../drop-down-button/drop-down-button';
|
|
10
|
+
import { ItemModel } from './../common/common-model';
|
|
11
|
+
import { SplitButtonModel } from './split-button-model';
|
|
12
|
+
|
|
13
|
+
const RTL: string = 'e-rtl';
|
|
14
|
+
|
|
15
|
+
const TAGNAME: string = 'EJS-SPLITBUTTON';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* SplitButton component has primary and secondary button. Primary button is used to select
|
|
19
|
+
* default action and secondary button is used to toggle contextual overlays for displaying list of
|
|
20
|
+
* action items. It can contain both text and images.
|
|
21
|
+
* ```html
|
|
22
|
+
* <button id="element"></button>
|
|
23
|
+
* ```
|
|
24
|
+
* ```typescript
|
|
25
|
+
* <script>
|
|
26
|
+
* var splitBtnObj = new SplitButton({content: 'SplitButton'});
|
|
27
|
+
* splitBtnObj.appendTo("#element");
|
|
28
|
+
* </script>
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
@NotifyPropertyChanges
|
|
32
|
+
export class SplitButton extends DropDownButton implements INotifyPropertyChanged {
|
|
33
|
+
private wrapper: HTMLElement;
|
|
34
|
+
private primaryBtnObj: Button;
|
|
35
|
+
private secondaryBtnObj: DropDownButton;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Defines the content of the SplitButton primary action button can either be a text or HTML elements.
|
|
39
|
+
*
|
|
40
|
+
* @default ""
|
|
41
|
+
*/
|
|
42
|
+
@Property('')
|
|
43
|
+
public content: string;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Defines class/multiple classes separated by a space in the SplitButton element. The SplitButton
|
|
47
|
+
* size and styles can be customized by using this.
|
|
48
|
+
*
|
|
49
|
+
* @default ""
|
|
50
|
+
*/
|
|
51
|
+
@Property('')
|
|
52
|
+
public cssClass: string;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Specifies a value that indicates whether the SplitButton is disabled or not.
|
|
56
|
+
*
|
|
57
|
+
* @default false.
|
|
58
|
+
*/
|
|
59
|
+
@Property(false)
|
|
60
|
+
public disabled: boolean;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Defines class/multiple classes separated by a space for the SplitButton that is used to include an
|
|
64
|
+
* icon. SplitButton can also include font icon and sprite image.
|
|
65
|
+
*
|
|
66
|
+
* @default ""
|
|
67
|
+
*/
|
|
68
|
+
@Property('')
|
|
69
|
+
public iconCss: string;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Positions the icon before/top of the text content in the SplitButton. The possible values are
|
|
73
|
+
* * Left: The icon will be positioned to the left of the text content.
|
|
74
|
+
* * Top: The icon will be positioned to the top of the text content.
|
|
75
|
+
*
|
|
76
|
+
* @default "Left"
|
|
77
|
+
*/
|
|
78
|
+
@Property('Left')
|
|
79
|
+
public iconPosition: SplitButtonIconPosition;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Specifies the popup element creation on open.
|
|
83
|
+
*
|
|
84
|
+
* @default false
|
|
85
|
+
*/
|
|
86
|
+
@Property(false)
|
|
87
|
+
public createPopupOnClick: boolean;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Specifies action items with its properties which will be rendered as SplitButton secondary button popup.
|
|
91
|
+
*
|
|
92
|
+
* @default []
|
|
93
|
+
*/
|
|
94
|
+
@Collection<ItemModel>([], Item)
|
|
95
|
+
public items: ItemModel[];
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Allows to specify the SplitButton popup item element.
|
|
99
|
+
*
|
|
100
|
+
* @default ""
|
|
101
|
+
*/
|
|
102
|
+
@Property('')
|
|
103
|
+
public target: string | Element;
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Triggers while rendering each Popup item of SplitButton.
|
|
107
|
+
*
|
|
108
|
+
* @event beforeItemRender
|
|
109
|
+
*/
|
|
110
|
+
@Event()
|
|
111
|
+
public beforeItemRender: EmitType<MenuEventArgs>;
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Triggers before opening the SplitButton popup.
|
|
115
|
+
*
|
|
116
|
+
* @event beforeOpen
|
|
117
|
+
*/
|
|
118
|
+
@Event()
|
|
119
|
+
public beforeOpen: EmitType<BeforeOpenCloseMenuEventArgs>;
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Triggers before closing the SplitButton popup.
|
|
123
|
+
*
|
|
124
|
+
* @event beforeClose
|
|
125
|
+
*/
|
|
126
|
+
@Event()
|
|
127
|
+
public beforeClose: EmitType<BeforeOpenCloseMenuEventArgs>;
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Triggers when the primary button of SplitButton has been clicked.
|
|
131
|
+
*
|
|
132
|
+
* @event click
|
|
133
|
+
*/
|
|
134
|
+
@Event()
|
|
135
|
+
public click: EmitType<ClickEventArgs>;
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Triggers while closing the SplitButton popup.
|
|
139
|
+
*
|
|
140
|
+
* @event close
|
|
141
|
+
*/
|
|
142
|
+
@Event()
|
|
143
|
+
public close: EmitType<OpenCloseMenuEventArgs>;
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Triggers while opening the SplitButton popup.
|
|
147
|
+
*
|
|
148
|
+
* @event open
|
|
149
|
+
*/
|
|
150
|
+
@Event()
|
|
151
|
+
public open: EmitType<OpenCloseMenuEventArgs>;
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Triggers while selecting action item of SplitButton popup.
|
|
155
|
+
*
|
|
156
|
+
* @event select
|
|
157
|
+
*/
|
|
158
|
+
@Event()
|
|
159
|
+
public select: EmitType<MenuEventArgs>;
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Triggers once the component rendering is completed.
|
|
163
|
+
*
|
|
164
|
+
* @event created
|
|
165
|
+
*/
|
|
166
|
+
@Event()
|
|
167
|
+
public created: EmitType<Event>;
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Constructor for creating the widget
|
|
171
|
+
*
|
|
172
|
+
* @param {SplitButtonModel} options - Specifies the splitbutton model
|
|
173
|
+
* @param {string|HTMLButtonElement} element - Specifies the element
|
|
174
|
+
* @hidden
|
|
175
|
+
*/
|
|
176
|
+
public constructor(options?: SplitButtonModel, element?: string | HTMLButtonElement) {
|
|
177
|
+
super(options, <string | HTMLButtonElement>element);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Initialize Angular support.
|
|
182
|
+
*
|
|
183
|
+
* @private
|
|
184
|
+
* @returns {void}
|
|
185
|
+
*/
|
|
186
|
+
protected preRender(): void {
|
|
187
|
+
let ele: Element = this.element;
|
|
188
|
+
if (ele.tagName === TAGNAME) {
|
|
189
|
+
const ejInstance: Object = getValue('ej2_instances', ele);
|
|
190
|
+
const btn: Element = this.createElement('button', { attrs: { 'type': 'button' } });
|
|
191
|
+
const wrapper: HTMLElement = this.createElement(TAGNAME, { className: 'e-' + this.getModuleName() + '-wrapper' });
|
|
192
|
+
for (let idx: number = 0, len: number = ele.attributes.length; idx < len; idx++) {
|
|
193
|
+
btn.setAttribute(ele.attributes[idx as number].nodeName, ele.attributes[idx as number].nodeValue);
|
|
194
|
+
}
|
|
195
|
+
ele.parentNode.insertBefore(wrapper, ele);
|
|
196
|
+
detach(ele);
|
|
197
|
+
ele = btn;
|
|
198
|
+
wrapper.appendChild(ele);
|
|
199
|
+
setValue('ej2_instances', ejInstance, ele);
|
|
200
|
+
this.wrapper = wrapper;
|
|
201
|
+
this.element = ele as HTMLButtonElement;
|
|
202
|
+
}
|
|
203
|
+
if (!this.element.id) {
|
|
204
|
+
this.element.id = getUniqueID('e-' + this.getModuleName());
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Initialize the Component rendering.
|
|
209
|
+
*
|
|
210
|
+
* @returns {void}
|
|
211
|
+
* @private
|
|
212
|
+
*/
|
|
213
|
+
public render(): void {
|
|
214
|
+
this.initWrapper();
|
|
215
|
+
this.createPrimaryButton();
|
|
216
|
+
this.renderControl();
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
private renderControl(): void {
|
|
220
|
+
this.createSecondaryButton();
|
|
221
|
+
this.setActiveElem([this.element, this.secondaryBtnObj.element]);
|
|
222
|
+
this.setAria();
|
|
223
|
+
this.wireEvents();
|
|
224
|
+
this.renderComplete();
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Adds a new item to the menu. By default, new item appends to the list as the last item,
|
|
228
|
+
* but you can insert based on the text parameter.
|
|
229
|
+
*
|
|
230
|
+
* @param { ItemModel[] } items - Specifies an array of JSON data.
|
|
231
|
+
* @param { string } text - Specifies the text to insert the newly added item in the menu.
|
|
232
|
+
* @returns {void}.
|
|
233
|
+
*/
|
|
234
|
+
public addItems(items: ItemModel[], text?: string): void {
|
|
235
|
+
super.addItems(items, text);
|
|
236
|
+
this.secondaryBtnObj.items = this.items;
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Removes the items from the menu.
|
|
240
|
+
*
|
|
241
|
+
* @param { string[] } items - Specifies an array of string to remove the items.
|
|
242
|
+
* @param { string } isUniqueId - Set `true` if specified items is a collection of unique id.
|
|
243
|
+
* @returns {void}.
|
|
244
|
+
*/
|
|
245
|
+
public removeItems(items: string[], isUniqueId?: boolean): void {
|
|
246
|
+
super.removeItems(items, isUniqueId);
|
|
247
|
+
this.secondaryBtnObj.items = this.items;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
private initWrapper(): void {
|
|
251
|
+
if (!this.wrapper) {
|
|
252
|
+
this.wrapper = this.createElement('div', { className: 'e-' + this.getModuleName() + '-wrapper' });
|
|
253
|
+
this.element.parentNode.insertBefore(this.wrapper, this.element);
|
|
254
|
+
}
|
|
255
|
+
this.element.classList.remove('e-' + this.getModuleName());
|
|
256
|
+
if (this.enableRtl) {
|
|
257
|
+
this.wrapper.classList.add(RTL);
|
|
258
|
+
}
|
|
259
|
+
if (this.cssClass) {
|
|
260
|
+
addClass([this.wrapper], this.cssClass.replace(/\s+/g, ' ').trim().split(' '));
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
private createPrimaryButton(): void {
|
|
265
|
+
const btnModel: ButtonModel = {
|
|
266
|
+
cssClass: this.cssClass,
|
|
267
|
+
enableRtl: this.enableRtl,
|
|
268
|
+
iconCss: this.iconCss,
|
|
269
|
+
iconPosition: this.iconPosition,
|
|
270
|
+
content: this.content,
|
|
271
|
+
disabled: this.disabled
|
|
272
|
+
};
|
|
273
|
+
this.primaryBtnObj = new Button(btnModel);
|
|
274
|
+
this.primaryBtnObj.createElement = this.createElement;
|
|
275
|
+
this.primaryBtnObj.appendTo(this.element);
|
|
276
|
+
this.element.classList.add('e-' + this.getModuleName());
|
|
277
|
+
this.element.type = 'button';
|
|
278
|
+
this.wrapper.appendChild(this.element);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
private createSecondaryButton(): void {
|
|
282
|
+
const btnElem : HTMLButtonElement = this.createElement('button', {
|
|
283
|
+
className: 'e-icon-btn',
|
|
284
|
+
attrs: { 'tabindex': '-1' },
|
|
285
|
+
id: this.element.id + '_dropdownbtn'
|
|
286
|
+
}) as HTMLButtonElement;
|
|
287
|
+
this.wrapper.appendChild(btnElem);
|
|
288
|
+
const dropDownBtnModel: SplitButtonModel = {
|
|
289
|
+
cssClass: this.cssClass,
|
|
290
|
+
disabled: this.disabled,
|
|
291
|
+
enableRtl: this.enableRtl,
|
|
292
|
+
items: this.items,
|
|
293
|
+
target: this.target,
|
|
294
|
+
createPopupOnClick: this.createPopupOnClick
|
|
295
|
+
};
|
|
296
|
+
dropDownBtnModel.beforeItemRender = (args: MenuEventArgs): void => {
|
|
297
|
+
if (this.createPopupOnClick) {
|
|
298
|
+
this.secondaryBtnObj.dropDown.relateTo = this.wrapper;
|
|
299
|
+
this.dropDown = this.secondaryBtnObj.dropDown;
|
|
300
|
+
}
|
|
301
|
+
this.trigger('beforeItemRender', args);
|
|
302
|
+
};
|
|
303
|
+
dropDownBtnModel.open = (args: OpenCloseMenuEventArgs): void => {
|
|
304
|
+
this.trigger('open', args);
|
|
305
|
+
};
|
|
306
|
+
dropDownBtnModel.close = (args: OpenCloseMenuEventArgs): void => {
|
|
307
|
+
this.trigger('close', args);
|
|
308
|
+
};
|
|
309
|
+
dropDownBtnModel.select = (args: MenuEventArgs): void => {
|
|
310
|
+
this.trigger('select', args);
|
|
311
|
+
};
|
|
312
|
+
dropDownBtnModel.beforeOpen = (args: BeforeOpenCloseMenuEventArgs): Deferred | void => {
|
|
313
|
+
if (this.createPopupOnClick && this.items.length == 0) {
|
|
314
|
+
this.secondaryBtnObj.dropDown.relateTo = this.wrapper;
|
|
315
|
+
this.dropDown = this.secondaryBtnObj.dropDown;
|
|
316
|
+
}
|
|
317
|
+
const callBackPromise: Deferred = new Deferred();
|
|
318
|
+
this.trigger('beforeOpen', args, (observedArgs: BeforeOpenCloseMenuEventArgs) => {
|
|
319
|
+
callBackPromise.resolve(observedArgs);
|
|
320
|
+
});
|
|
321
|
+
return callBackPromise;
|
|
322
|
+
};
|
|
323
|
+
dropDownBtnModel.beforeClose = (args: BeforeOpenCloseMenuEventArgs): Deferred | void => {
|
|
324
|
+
const callBackPromise: Deferred = new Deferred();
|
|
325
|
+
this.trigger('beforeClose', args, (observedArgs: BeforeOpenCloseMenuEventArgs) => {
|
|
326
|
+
callBackPromise.resolve(observedArgs);
|
|
327
|
+
});
|
|
328
|
+
return callBackPromise;
|
|
329
|
+
};
|
|
330
|
+
this.secondaryBtnObj = new DropDownButton(dropDownBtnModel);
|
|
331
|
+
this.secondaryBtnObj.createElement = this.createElement;
|
|
332
|
+
this.secondaryBtnObj.appendTo(btnElem);
|
|
333
|
+
if (!this.createPopupOnClick) {
|
|
334
|
+
this.secondaryBtnObj.dropDown.relateTo = this.wrapper;
|
|
335
|
+
this.dropDown = this.secondaryBtnObj.dropDown;
|
|
336
|
+
}
|
|
337
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
338
|
+
(this as any).isPopupCreated = (this.secondaryBtnObj as any).isPopupCreated;
|
|
339
|
+
this.secondaryBtnObj.activeElem = [this.element, this.secondaryBtnObj.element];
|
|
340
|
+
this.secondaryBtnObj.element.querySelector('.e-btn-icon').classList.remove('e-icon-right');
|
|
341
|
+
if (this.disabled) {
|
|
342
|
+
this.wrapper.classList.add('e-splitbtn-disabled');
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
private setAria(): void {
|
|
347
|
+
attributes(this.element, {
|
|
348
|
+
'aria-expanded': 'false', 'aria-haspopup': 'true',
|
|
349
|
+
'aria-label': this.element.textContent ? this.element.textContent + ' splitbutton' : 'splitbutton', 'aria-owns': this.element.id + '_dropdownbtn-popup'
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
/**
|
|
354
|
+
* Get component name.
|
|
355
|
+
*
|
|
356
|
+
* @returns {string} - Module Name
|
|
357
|
+
* @private
|
|
358
|
+
*/
|
|
359
|
+
public getModuleName(): string {
|
|
360
|
+
return 'split-btn';
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
/**
|
|
364
|
+
* To open/close SplitButton popup based on current state of the SplitButton.
|
|
365
|
+
*
|
|
366
|
+
* @returns {void}
|
|
367
|
+
*/
|
|
368
|
+
public toggle(): void {
|
|
369
|
+
this.secondaryBtnObj.toggle();
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
public destroy(): void {
|
|
373
|
+
let classList: string[] = [RTL];
|
|
374
|
+
if (this.cssClass) {
|
|
375
|
+
classList = classList.concat(this.cssClass.split(' '));
|
|
376
|
+
}
|
|
377
|
+
if (this.element) {
|
|
378
|
+
const element: Element = document.getElementById(this.element.id);
|
|
379
|
+
if (element && element.parentElement === this.wrapper) {
|
|
380
|
+
if (this.wrapper.tagName === TAGNAME) {
|
|
381
|
+
this.wrapper.innerHTML = '';
|
|
382
|
+
removeClass([this.wrapper], ['e-rtl', 'e-' + this.getModuleName() + '-wrapper']);
|
|
383
|
+
removeClass([this.wrapper], this.cssClass.split(' '));
|
|
384
|
+
} else {
|
|
385
|
+
removeClass([this.element], classList);
|
|
386
|
+
['aria-label', 'aria-haspopup', 'aria-expanded', 'aria-owns', 'type'].forEach((key: string) => {
|
|
387
|
+
this.element.removeAttribute(key);
|
|
388
|
+
});
|
|
389
|
+
this.wrapper.parentNode.insertBefore(this.element, this.wrapper);
|
|
390
|
+
remove(this.wrapper);
|
|
391
|
+
}
|
|
392
|
+
this.unWireEvents();
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
this.primaryBtnObj.destroy();
|
|
396
|
+
this.secondaryBtnObj.destroy();
|
|
397
|
+
super.destroy();
|
|
398
|
+
if (this.element && !this.element.getAttribute('class')) {
|
|
399
|
+
this.element.removeAttribute('class');
|
|
400
|
+
}
|
|
401
|
+
if (this.refreshing && (this as any).isAngular) {
|
|
402
|
+
this.element = this.wrapper as HTMLButtonElement;
|
|
403
|
+
['e-control', 'e-split-btn', 'e-lib'].forEach((key: string) => {
|
|
404
|
+
this.element.classList.add(key);
|
|
405
|
+
});
|
|
406
|
+
setValue('ej2_instances', [this], this.element);
|
|
407
|
+
}
|
|
408
|
+
this.wrapper = null;
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
protected wireEvents(): void {
|
|
412
|
+
EventHandler.add(this.element, 'click', this.primaryBtnClickHandler, this);
|
|
413
|
+
new KeyboardEvents(this.element, {
|
|
414
|
+
keyAction: this.btnKeyBoardHandler.bind(this),
|
|
415
|
+
keyConfigs: {
|
|
416
|
+
altdownarrow: 'alt+downarrow',
|
|
417
|
+
enter: 'enter'
|
|
418
|
+
}
|
|
419
|
+
});
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
protected unWireEvents(): void {
|
|
423
|
+
EventHandler.remove(this.element, 'click', this.primaryBtnClickHandler);
|
|
424
|
+
(getInstance(this.element, KeyboardEvents) as KeyboardEvents).destroy();
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
private primaryBtnClickHandler(): void {
|
|
428
|
+
this.trigger('click', { element: this.element });
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
private btnKeyBoardHandler(e: KeyboardEventArgs): void {
|
|
432
|
+
switch (e.action) {
|
|
433
|
+
case 'altdownarrow':
|
|
434
|
+
this.clickHandler(e);
|
|
435
|
+
break;
|
|
436
|
+
case 'enter':
|
|
437
|
+
this.clickHandler(e);
|
|
438
|
+
if (this.getPopUpElement() && !this.getPopUpElement().classList.contains('e-popup-close')) {
|
|
439
|
+
this.element.classList.remove('e-active');
|
|
440
|
+
this.secondaryBtnObj.element.classList.add('e-active');
|
|
441
|
+
} else {
|
|
442
|
+
this.secondaryBtnObj.element.classList.remove('e-active');
|
|
443
|
+
}
|
|
444
|
+
break;
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
/**
|
|
449
|
+
* Called internally if any of the property value changed.
|
|
450
|
+
*
|
|
451
|
+
* @param {SplitButtonModel} newProp - Specifies new properties
|
|
452
|
+
* @param {SplitButtonModel} oldProp - Specifies old properties
|
|
453
|
+
* @returns {void}
|
|
454
|
+
*/
|
|
455
|
+
public onPropertyChanged(newProp: SplitButtonModel, oldProp: SplitButtonModel): void {
|
|
456
|
+
let model: string[] = ['content', 'iconCss', 'iconPosition', 'cssClass', 'disabled', 'enableRtl'];
|
|
457
|
+
this.primaryBtnObj.setProperties(getModel(newProp, model));
|
|
458
|
+
model = ['beforeOpen', 'beforeItemRender', 'select', 'open',
|
|
459
|
+
'close', 'cssClass', 'disabled', 'enableRtl', 'createPopupOnClick'];
|
|
460
|
+
if (Object.keys(newProp).indexOf('items') > -1) {
|
|
461
|
+
this.secondaryBtnObj.items = newProp.items;
|
|
462
|
+
this.secondaryBtnObj.dataBind();
|
|
463
|
+
}
|
|
464
|
+
this.secondaryBtnObj.setProperties(getModel(newProp, model));
|
|
465
|
+
for (const prop of Object.keys(newProp)) {
|
|
466
|
+
switch (prop) {
|
|
467
|
+
case 'cssClass':
|
|
468
|
+
if (oldProp.cssClass) {
|
|
469
|
+
removeClass([this.wrapper], oldProp.cssClass.split(' '));
|
|
470
|
+
}
|
|
471
|
+
addClass([this.wrapper], newProp.cssClass.replace(/\s+/g, ' ').trim().split(' '));
|
|
472
|
+
break;
|
|
473
|
+
case 'enableRtl':
|
|
474
|
+
if (newProp.enableRtl) {
|
|
475
|
+
addClass([this.wrapper], RTL);
|
|
476
|
+
} else {
|
|
477
|
+
removeClass([this.wrapper], RTL);
|
|
478
|
+
}
|
|
479
|
+
break;
|
|
480
|
+
case 'disabled':
|
|
481
|
+
if (newProp.disabled) {
|
|
482
|
+
addClass([this.wrapper], 'e-splitbtn-disabled');
|
|
483
|
+
} else {
|
|
484
|
+
removeClass([this.wrapper], 'e-splitbtn-disabled');
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
/**
|
|
491
|
+
* Sets the focus to SplitButton
|
|
492
|
+
* its native method
|
|
493
|
+
*
|
|
494
|
+
* @public
|
|
495
|
+
* @returns {void}
|
|
496
|
+
*/
|
|
497
|
+
public focusIn(): void {
|
|
498
|
+
this.element.focus();
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
/**
|
|
502
|
+
* Interface for Split Button click event arguments.
|
|
503
|
+
*/
|
|
504
|
+
export interface ClickEventArgs extends BaseEventArgs {
|
|
505
|
+
element: Element;
|
|
506
|
+
}
|
|
507
|
+
/**
|
|
508
|
+
* Deferred is used to handle asynchronous operation.
|
|
509
|
+
*/
|
|
510
|
+
export class Deferred {
|
|
511
|
+
/**
|
|
512
|
+
* Reject a Deferred object and call failCallbacks with the given args.
|
|
513
|
+
*/
|
|
514
|
+
public reject: Function;
|
|
515
|
+
/**
|
|
516
|
+
* Resolve a Deferred object and call doneCallbacks with the given args.
|
|
517
|
+
*/
|
|
518
|
+
public resolve: Function;
|
|
519
|
+
/**
|
|
520
|
+
* Promise is an object that represents a value that may not be available yet, but will be resolved at some point in the future.
|
|
521
|
+
*/
|
|
522
|
+
public promise: Promise<Object> = new Promise((resolve: Function, reject: Function) => {
|
|
523
|
+
this.resolve = resolve;
|
|
524
|
+
this.reject = reject;
|
|
525
|
+
});
|
|
526
|
+
/**
|
|
527
|
+
* Defines the callback function triggers when the Deferred object is rejected.
|
|
528
|
+
*/
|
|
529
|
+
public catch: Function = this.promise.catch.bind(this.promise);
|
|
530
|
+
/**
|
|
531
|
+
* Defines the callback function triggers when the Deferred object is resolved.
|
|
532
|
+
*/
|
|
533
|
+
public then: Function = this.promise.then.bind(this.promise);
|
|
534
|
+
}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"_from": "@syncfusion/ej2-splitbuttons@*",
|
|
3
3
|
"_id": "@syncfusion/ej2-splitbuttons@24.2.3",
|
|
4
4
|
"_inBundle": false,
|
|
5
|
-
"_integrity": "sha512-
|
|
5
|
+
"_integrity": "sha512-KIXV0nuWJPsJL5BezwqUGneU9e0sGScBXmPuLqamHkd18V9JiuKbJ898cqSo3oE/NtJBm8fffh/C/9lTwcO2gg==",
|
|
6
6
|
"_location": "/@syncfusion/ej2-splitbuttons",
|
|
7
7
|
"_phantomChildren": {},
|
|
8
8
|
"_requested": {
|
|
@@ -33,10 +33,10 @@
|
|
|
33
33
|
"/@syncfusion/ej2-richtexteditor",
|
|
34
34
|
"/@syncfusion/ej2-vue-splitbuttons"
|
|
35
35
|
],
|
|
36
|
-
"_resolved": "https://nexus.syncfusioninternal.com/repository/ej2-
|
|
37
|
-
"_shasum": "
|
|
36
|
+
"_resolved": "https://nexus.syncfusioninternal.com/repository/ej2-release/@syncfusion/ej2-splitbuttons/-/ej2-splitbuttons-24.2.3.tgz",
|
|
37
|
+
"_shasum": "d96bcd57d2e6822f5179b2b142b7e5e241eead00",
|
|
38
38
|
"_spec": "@syncfusion/ej2-splitbuttons@*",
|
|
39
|
-
"_where": "/jenkins/workspace/elease-
|
|
39
|
+
"_where": "/jenkins/workspace/elease-automation_release_25.1.1/packages/included",
|
|
40
40
|
"author": {
|
|
41
41
|
"name": "Syncfusion Inc."
|
|
42
42
|
},
|
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
},
|
|
46
46
|
"bundleDependencies": false,
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@syncfusion/ej2-base": "~
|
|
49
|
-
"@syncfusion/ej2-popups": "~
|
|
48
|
+
"@syncfusion/ej2-base": "~25.1.35",
|
|
49
|
+
"@syncfusion/ej2-popups": "~25.1.35"
|
|
50
50
|
},
|
|
51
51
|
"deprecated": false,
|
|
52
52
|
"description": "A package of feature-rich Essential JS 2 components such as DropDownButton, SplitButton, ProgressButton and ButtonGroup.",
|
|
@@ -89,6 +89,6 @@
|
|
|
89
89
|
"url": "git+https://github.com/syncfusion/ej2-javascript-ui-controls.git"
|
|
90
90
|
},
|
|
91
91
|
"typings": "index.d.ts",
|
|
92
|
-
"version": "
|
|
92
|
+
"version": "25.1.35",
|
|
93
93
|
"sideEffects": false
|
|
94
94
|
}
|
|
@@ -46,9 +46,10 @@ export interface DropDownButtonModel extends ComponentModel{
|
|
|
46
46
|
iconPosition?: SplitButtonIconPosition;
|
|
47
47
|
|
|
48
48
|
/**
|
|
49
|
-
*
|
|
49
|
+
* Specifies whether to enable the rendering of untrusted HTML values in the DropDownButton component.
|
|
50
|
+
* If 'enableHtmlSanitizer' set to true, the component will sanitize any suspected untrusted strings and scripts before rendering them.
|
|
50
51
|
*
|
|
51
|
-
* @default
|
|
52
|
+
* @default true
|
|
52
53
|
*/
|
|
53
54
|
enableHtmlSanitizer?: boolean;
|
|
54
55
|
|
|
@@ -65,9 +65,10 @@ export declare class DropDownButton extends Component<HTMLButtonElement> impleme
|
|
|
65
65
|
*/
|
|
66
66
|
iconPosition: SplitButtonIconPosition;
|
|
67
67
|
/**
|
|
68
|
-
*
|
|
68
|
+
* Specifies whether to enable the rendering of untrusted HTML values in the DropDownButton component.
|
|
69
|
+
* If 'enableHtmlSanitizer' set to true, the component will sanitize any suspected untrusted strings and scripts before rendering them.
|
|
69
70
|
*
|
|
70
|
-
* @default
|
|
71
|
+
* @default true
|
|
71
72
|
*/
|
|
72
73
|
enableHtmlSanitizer: boolean;
|
|
73
74
|
/**
|
|
@@ -803,7 +803,7 @@ var DropDownButton = /** @class */ (function (_super) {
|
|
|
803
803
|
Property('Left')
|
|
804
804
|
], DropDownButton.prototype, "iconPosition", void 0);
|
|
805
805
|
__decorate([
|
|
806
|
-
Property(
|
|
806
|
+
Property(true)
|
|
807
807
|
], DropDownButton.prototype, "enableHtmlSanitizer", void 0);
|
|
808
808
|
__decorate([
|
|
809
809
|
Collection([], Item)
|
|
@@ -146,9 +146,10 @@ export interface ProgressButtonModel {
|
|
|
146
146
|
isToggle?: boolean;
|
|
147
147
|
|
|
148
148
|
/**
|
|
149
|
-
*
|
|
149
|
+
* Specifies whether to enable the rendering of untrusted HTML values in the Progress button component.
|
|
150
|
+
* If 'enableHtmlSanitizer' set to true, the component will sanitize any suspected untrusted strings and scripts before rendering them.
|
|
150
151
|
*
|
|
151
|
-
* @default
|
|
152
|
+
* @default true
|
|
152
153
|
*/
|
|
153
154
|
enableHtmlSanitizer?: boolean;
|
|
154
155
|
|
|
@@ -145,9 +145,10 @@ export declare class ProgressButton extends Button implements INotifyPropertyCha
|
|
|
145
145
|
*/
|
|
146
146
|
isToggle: boolean;
|
|
147
147
|
/**
|
|
148
|
-
*
|
|
148
|
+
* Specifies whether to enable the rendering of untrusted HTML values in the Progress button component.
|
|
149
|
+
* If 'enableHtmlSanitizer' set to true, the component will sanitize any suspected untrusted strings and scripts before rendering them.
|
|
149
150
|
*
|
|
150
|
-
* @default
|
|
151
|
+
* @default true
|
|
151
152
|
*/
|
|
152
153
|
enableHtmlSanitizer: boolean;
|
|
153
154
|
/**
|
|
@@ -301,7 +301,7 @@ var ProgressButton = /** @class */ (function (_super) {
|
|
|
301
301
|
this.step = args.step;
|
|
302
302
|
if ((progressTime - prevProgressTime) % (this.duration * args.step / 100) === 0 || percent === 100) {
|
|
303
303
|
this.timerId = requestAnimationFrame(function () {
|
|
304
|
-
if (_this.enableProgress) {
|
|
304
|
+
if (_this.enableProgress && _this.getProgress()) {
|
|
305
305
|
_this.getProgress().style[isVertical ? 'height' : 'width'] = percent + '%';
|
|
306
306
|
}
|
|
307
307
|
_this.element.setAttribute('aria-valuenow', percent.toString());
|
|
@@ -318,7 +318,7 @@ var ProgressButton = /** @class */ (function (_super) {
|
|
|
318
318
|
else {
|
|
319
319
|
this.interval = window.setTimeout(function () {
|
|
320
320
|
_this.progressTime = _this.percent = 0;
|
|
321
|
-
if (_this.enableProgress) {
|
|
321
|
+
if (_this.enableProgress && _this.getProgress()) {
|
|
322
322
|
_this.getProgress().style[isVertical ? 'height' : 'width'] = '0%';
|
|
323
323
|
}
|
|
324
324
|
_this.element.setAttribute('aria-valuenow', '0');
|
|
@@ -359,7 +359,7 @@ var ProgressButton = /** @class */ (function (_super) {
|
|
|
359
359
|
if (i > 100) {
|
|
360
360
|
i = 100;
|
|
361
361
|
}
|
|
362
|
-
if (this.enableProgress) {
|
|
362
|
+
if (this.enableProgress && this.getProgress()) {
|
|
363
363
|
this.getProgress().style[isVertical ? 'height' : 'width'] = (this.percent < 100) ? (i + '%') : '100%';
|
|
364
364
|
}
|
|
365
365
|
}
|
|
@@ -512,7 +512,7 @@ var ProgressButton = /** @class */ (function (_super) {
|
|
|
512
512
|
Property(false)
|
|
513
513
|
], ProgressButton.prototype, "isToggle", void 0);
|
|
514
514
|
__decorate([
|
|
515
|
-
Property(
|
|
515
|
+
Property(true)
|
|
516
516
|
], ProgressButton.prototype, "enableHtmlSanitizer", void 0);
|
|
517
517
|
__decorate([
|
|
518
518
|
Complex({}, SpinSettings)
|