@syncfusion/ej2-splitbuttons 24.2.7 → 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.
- package/CHANGELOG.md +2 -32
- 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 +2 -2
- package/dist/es6/ej2-splitbuttons.es2015.js.map +1 -1
- package/dist/es6/ej2-splitbuttons.es5.js +2 -2
- 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 +8 -8
- 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 +1 -1
- 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
package/dist/global/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* filename: index.d.ts
|
|
3
|
-
* version :
|
|
3
|
+
* version : 25.1.35
|
|
4
4
|
* Copyright Syncfusion Inc. 2001 - 2023. All rights reserved.
|
|
5
5
|
* Use of this code is subject to the terms of our license.
|
|
6
6
|
* A copy of the current license can be obtained at any time by e-mailing
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { addClass, createElement as internalCreateElement, isNullOrUndefined } from '@syncfusion/ej2-base';
|
|
2
|
+
import { ButtonModel, Button } from '@syncfusion/ej2-buttons';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Initialize ButtonGroup CSS component with specified properties.
|
|
6
|
+
* ```html
|
|
7
|
+
* <div id='buttongroup'>
|
|
8
|
+
* <button></button>
|
|
9
|
+
* <button></button>
|
|
10
|
+
* <button></button>
|
|
11
|
+
* </div>
|
|
12
|
+
* ```
|
|
13
|
+
* ```typescript
|
|
14
|
+
* createButtonGroup('#buttongroup', {
|
|
15
|
+
* cssClass: 'e-outline',
|
|
16
|
+
* buttons: [
|
|
17
|
+
* { content: 'Day' },
|
|
18
|
+
* { content: 'Week' },
|
|
19
|
+
* { content: 'Work Week'}
|
|
20
|
+
* ]
|
|
21
|
+
* });
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* @param {string} selector
|
|
25
|
+
* @param {CreateButtonGroupModel} options
|
|
26
|
+
* @returns HTMLElement
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Creates button group.
|
|
31
|
+
*
|
|
32
|
+
* @param {string} selector - Specifies the selector.
|
|
33
|
+
* @param {CreateButtonGroupModel} options - Specifies the button group model.
|
|
34
|
+
* @param {Function} createElement - Specifies the element.
|
|
35
|
+
* @returns {HTMLElement} - Button group element.
|
|
36
|
+
*/
|
|
37
|
+
export function createButtonGroup(selector: string, options: CreateButtonGroupModel = {}, createElement?: Function): HTMLElement {
|
|
38
|
+
let child: Element;
|
|
39
|
+
let btnElem: Element;
|
|
40
|
+
let nextChild: Element;
|
|
41
|
+
let btnModel: ButtonModel | null;
|
|
42
|
+
if (isNullOrUndefined(createElement)) {
|
|
43
|
+
createElement = internalCreateElement;
|
|
44
|
+
}
|
|
45
|
+
const wrapper: HTMLElement = document.querySelector(selector) as HTMLElement;
|
|
46
|
+
addClass([wrapper], ['e-btn-group', 'e-css']);
|
|
47
|
+
wrapper.setAttribute('role', 'group');
|
|
48
|
+
const childs: HTMLCollection = wrapper.children;
|
|
49
|
+
options.buttons = options.buttons || [] as ButtonModel[];
|
|
50
|
+
for (let i: number = 0, j: number = 0; j < childs.length; i++, j++) {
|
|
51
|
+
child = childs[j as number];
|
|
52
|
+
btnModel = options.buttons[i as number];
|
|
53
|
+
if (btnModel !== null) {
|
|
54
|
+
if (child.tagName === 'BUTTON') {
|
|
55
|
+
btnElem = child;
|
|
56
|
+
} else {
|
|
57
|
+
btnElem = createElement('label');
|
|
58
|
+
nextChild = childs[j + 1];
|
|
59
|
+
if (nextChild) {
|
|
60
|
+
wrapper.insertBefore(btnElem, nextChild);
|
|
61
|
+
} else {
|
|
62
|
+
wrapper.appendChild(btnElem);
|
|
63
|
+
}
|
|
64
|
+
if (child.id) {
|
|
65
|
+
btnElem.setAttribute('for', child.id);
|
|
66
|
+
}
|
|
67
|
+
if (btnModel && btnModel.disabled) {
|
|
68
|
+
(child as HTMLInputElement).disabled = true;
|
|
69
|
+
}
|
|
70
|
+
j++;
|
|
71
|
+
}
|
|
72
|
+
if (options.cssClass && btnModel && !btnModel.cssClass) {
|
|
73
|
+
btnModel.cssClass = options.cssClass;
|
|
74
|
+
}
|
|
75
|
+
new Button(btnModel || {}, btnElem as HTMLButtonElement);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return wrapper;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export interface CreateButtonGroupModel {
|
|
82
|
+
cssClass?: string;
|
|
83
|
+
buttons?: (ButtonModel | null)[];
|
|
84
|
+
}
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { ChildProperty, extend, deleteObject, Property, BaseEventArgs, addClass, isNullOrUndefined } from '@syncfusion/ej2-base';
|
|
2
|
+
import { ItemModel } from './common-model';
|
|
3
|
+
/**
|
|
4
|
+
* Defines the icon position of Split Button.
|
|
5
|
+
*/
|
|
6
|
+
export type SplitButtonIconPosition = 'Left' | 'Top';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @param {Object} props - Specifies the properties
|
|
10
|
+
* @param {string[]} model - Specifies the model
|
|
11
|
+
* @returns {Object} Component Model
|
|
12
|
+
*/
|
|
13
|
+
export function getModel(props: Object, model: string[]): Object {
|
|
14
|
+
|
|
15
|
+
const obj: Object = extend({}, props);
|
|
16
|
+
for (const prop of Object.keys(obj)) {
|
|
17
|
+
if ((model).indexOf(prop) < 0) {
|
|
18
|
+
deleteObject(obj, prop);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return obj as Object;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** @hidden
|
|
26
|
+
* @param {HTMLElement} ul - Specifies the UL element
|
|
27
|
+
* @param {number} keyCode - Specifies the keycode
|
|
28
|
+
* @returns {void}
|
|
29
|
+
*/
|
|
30
|
+
export function upDownKeyHandler(ul: HTMLElement, keyCode: number): void {
|
|
31
|
+
const defaultIdx: number = keyCode === 40 ? 0 : ul.childElementCount - 1;
|
|
32
|
+
let liIdx: number = defaultIdx;
|
|
33
|
+
let li: Element;
|
|
34
|
+
const selectedLi: Element = ul.querySelector('.e-selected');
|
|
35
|
+
if (selectedLi) { selectedLi.classList.remove('e-selected'); }
|
|
36
|
+
for (let i: number = 0, len: number = ul.children.length; i < len; i++) {
|
|
37
|
+
if (ul.children[i as number].classList.contains('e-focused')) {
|
|
38
|
+
li = ul.children[i as number];
|
|
39
|
+
liIdx = i;
|
|
40
|
+
li.classList.remove('e-focused');
|
|
41
|
+
if (keyCode === 40) {
|
|
42
|
+
liIdx++;
|
|
43
|
+
} else {
|
|
44
|
+
liIdx--;
|
|
45
|
+
}
|
|
46
|
+
if (liIdx === (keyCode === 40 ? ul.childElementCount : -1)) {
|
|
47
|
+
liIdx = defaultIdx;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
li = ul.children[liIdx as number];
|
|
52
|
+
liIdx = isValidLI(ul, li, liIdx, keyCode);
|
|
53
|
+
if (liIdx !== -1) {
|
|
54
|
+
addClass([ul.children[liIdx as number]], 'e-focused');
|
|
55
|
+
(ul.children[liIdx as number] as HTMLElement).focus();
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Get Valid LI element
|
|
61
|
+
*
|
|
62
|
+
* @param {HTMLElement} ul - Specifies the UL element
|
|
63
|
+
* @param {Element} li - Specifies the LI element
|
|
64
|
+
* @param {number} index - Specifies the index
|
|
65
|
+
* @param {number} keyCode - Specifies the keycode
|
|
66
|
+
* @param {number} count - Specifies the count
|
|
67
|
+
* @returns {number} - Index
|
|
68
|
+
*/
|
|
69
|
+
function isValidLI(ul: HTMLElement, li: Element, index: number, keyCode: number, count: number = 0): number {
|
|
70
|
+
if (li.classList.contains('e-separator') || li.classList.contains('e-disabled')) {
|
|
71
|
+
if (index === (keyCode === 40 ? ul.childElementCount - 1 : 0)) {
|
|
72
|
+
index = keyCode === 40 ? 0 : ul.childElementCount - 1;
|
|
73
|
+
} else {
|
|
74
|
+
if (keyCode === 40) {
|
|
75
|
+
index++;
|
|
76
|
+
} else {
|
|
77
|
+
index--;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
li = ul.children[index as number];
|
|
82
|
+
if (li.classList.contains('e-separator') || li.classList.contains('e-disabled')) {
|
|
83
|
+
count++;
|
|
84
|
+
if (count === ul.childElementCount) {
|
|
85
|
+
return index = -1;
|
|
86
|
+
}
|
|
87
|
+
index = isValidLI(ul, li, index, keyCode, count);
|
|
88
|
+
}
|
|
89
|
+
return index;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** @hidden
|
|
93
|
+
* @param {HTMLElement} popup - Specifies the popup element.
|
|
94
|
+
* @returns {void}
|
|
95
|
+
*/
|
|
96
|
+
export function setBlankIconStyle(popup: HTMLElement, blankIcon?: boolean): void {
|
|
97
|
+
const blankIconList: HTMLElement[] = [].slice.call(popup.getElementsByClassName('e-blank-icon'));
|
|
98
|
+
if (blankIcon) {
|
|
99
|
+
const menuItem: HTMLElement[] = [].slice.call(popup.getElementsByClassName('e-item'));
|
|
100
|
+
menuItem.forEach((li: HTMLElement): void => {
|
|
101
|
+
if (li.style.paddingLeft || li.style.paddingRight) {
|
|
102
|
+
li.removeAttribute('style');
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
if (!blankIconList.length) { return; }
|
|
107
|
+
let iconLi: HTMLElement = popup.querySelector('.e-item:not(.e-blank-icon):not(.e-separator)') as HTMLElement;
|
|
108
|
+
if (isNullOrUndefined(iconLi)) {return; }
|
|
109
|
+
if (iconLi.classList.contains('e-url')) { iconLi = iconLi.querySelector('.e-menu-url'); }
|
|
110
|
+
const icon: HTMLElement = iconLi.querySelector('.e-menu-icon') as HTMLElement;
|
|
111
|
+
let cssProp: { padding: string, margin: string };
|
|
112
|
+
const enableRtl: boolean = popup.classList.contains('e-rtl');
|
|
113
|
+
if (enableRtl) {
|
|
114
|
+
cssProp = { padding: 'paddingRight', margin: 'marginLeft' };
|
|
115
|
+
} else {
|
|
116
|
+
cssProp = { padding: 'paddingLeft', margin: 'marginRight' };
|
|
117
|
+
}
|
|
118
|
+
/* eslint-disable */
|
|
119
|
+
let size: string = `${parseInt(getComputedStyle(icon).fontSize, 10) + parseInt(
|
|
120
|
+
(enableRtl ? (getComputedStyle(icon) as any)[cssProp.margin] : (getComputedStyle(icon) as any)[cssProp.margin]), 10)
|
|
121
|
+
+ parseInt(getComputedStyle(iconLi).paddingLeft, 10)}px`;
|
|
122
|
+
blankIconList.forEach((li: HTMLElement): void => {
|
|
123
|
+
if (li.classList.contains('e-url')) {
|
|
124
|
+
((li.querySelector('.e-menu-url') as HTMLElement).style as any)[cssProp.padding] = size;
|
|
125
|
+
} else {
|
|
126
|
+
(li.style as any)[cssProp.padding] = size;
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
/* eslint-enable */
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Defines the items of Split Button/DropDownButton.
|
|
134
|
+
*/
|
|
135
|
+
export class Item extends ChildProperty<Item> {
|
|
136
|
+
/**
|
|
137
|
+
* Defines class/multiple classes separated by a space for the item that is used to include an icon.
|
|
138
|
+
* Action item can include font icon and sprite image.
|
|
139
|
+
*
|
|
140
|
+
* @default ''
|
|
141
|
+
*/
|
|
142
|
+
@Property('')
|
|
143
|
+
public iconCss: string;
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Specifies the id for item.
|
|
147
|
+
*
|
|
148
|
+
* @default ''
|
|
149
|
+
*/
|
|
150
|
+
@Property('')
|
|
151
|
+
public id: string;
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Specifies separator between the items. Separator are horizontal lines used to group action items.
|
|
155
|
+
*
|
|
156
|
+
* @default false
|
|
157
|
+
*/
|
|
158
|
+
@Property(false)
|
|
159
|
+
public separator: boolean;
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Specifies text for item.
|
|
163
|
+
*
|
|
164
|
+
* @default ''
|
|
165
|
+
*/
|
|
166
|
+
@Property('')
|
|
167
|
+
public text: string;
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Specifies url for item that creates the anchor link to navigate to the url provided.
|
|
171
|
+
*
|
|
172
|
+
* @default ''
|
|
173
|
+
*/
|
|
174
|
+
@Property('')
|
|
175
|
+
public url: string;
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Used to enable or disable the item.
|
|
179
|
+
*
|
|
180
|
+
* @default false
|
|
181
|
+
*/
|
|
182
|
+
@Property(false)
|
|
183
|
+
public disabled: boolean;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Interface for before item render / select event.
|
|
188
|
+
*/
|
|
189
|
+
export interface MenuEventArgs extends BaseEventArgs {
|
|
190
|
+
element: HTMLElement;
|
|
191
|
+
item: ItemModel;
|
|
192
|
+
event?: Event;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Interface for before open / close event.
|
|
197
|
+
*/
|
|
198
|
+
export interface BeforeOpenCloseMenuEventArgs extends BaseEventArgs {
|
|
199
|
+
element: HTMLElement;
|
|
200
|
+
items: ItemModel[];
|
|
201
|
+
event: Event;
|
|
202
|
+
cancel?: boolean;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Interface for open/close event.
|
|
207
|
+
*/
|
|
208
|
+
export interface OpenCloseMenuEventArgs extends BaseEventArgs {
|
|
209
|
+
element: HTMLElement;
|
|
210
|
+
items: ItemModel[];
|
|
211
|
+
parentItem?: ItemModel;
|
|
212
|
+
}
|