@syncfusion/ej2-ribbon 21.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.
Files changed (188) hide show
  1. package/.eslintrc.json +259 -0
  2. package/.github/PULL_REQUEST_TEMPLATE/Bug.md +60 -0
  3. package/.github/PULL_REQUEST_TEMPLATE/feature.md +37 -0
  4. package/CHANGELOG.md +19 -0
  5. package/README.md +3 -0
  6. package/dist/ej2-ribbon.umd.min.js +11 -0
  7. package/dist/ej2-ribbon.umd.min.js.map +1 -0
  8. package/dist/es6/ej2-ribbon.es2015.js +4946 -0
  9. package/dist/es6/ej2-ribbon.es2015.js.map +1 -0
  10. package/dist/es6/ej2-ribbon.es5.js +5253 -0
  11. package/dist/es6/ej2-ribbon.es5.js.map +1 -0
  12. package/dist/global/ej2-ribbon.min.js +11 -0
  13. package/dist/global/ej2-ribbon.min.js.map +1 -0
  14. package/dist/global/index.d.ts +14 -0
  15. package/index.d.ts +4 -0
  16. package/index.js +4 -0
  17. package/license +10 -0
  18. package/package.json +67 -0
  19. package/ribbon.d.ts +4 -0
  20. package/ribbon.js +4 -0
  21. package/src/global.js +3 -0
  22. package/src/index.d.ts +1 -0
  23. package/src/index.js +3 -0
  24. package/src/ribbon/base/constant.d.ts +151 -0
  25. package/src/ribbon/base/constant.js +151 -0
  26. package/src/ribbon/base/index.d.ts +8 -0
  27. package/src/ribbon/base/index.js +7 -0
  28. package/src/ribbon/base/interface.d.ts +194 -0
  29. package/src/ribbon/base/interface.js +106 -0
  30. package/src/ribbon/base/ribbon-model.d.ts +129 -0
  31. package/src/ribbon/base/ribbon.d.ts +357 -0
  32. package/src/ribbon/base/ribbon.js +2413 -0
  33. package/src/ribbon/base/utils.d.ts +113 -0
  34. package/src/ribbon/base/utils.js +288 -0
  35. package/src/ribbon/index.d.ts +7 -0
  36. package/src/ribbon/index.js +7 -0
  37. package/src/ribbon/items/index.d.ts +6 -0
  38. package/src/ribbon/items/index.js +6 -0
  39. package/src/ribbon/items/ribbon-button.d.ts +65 -0
  40. package/src/ribbon/items/ribbon-button.js +153 -0
  41. package/src/ribbon/items/ribbon-checkbox.d.ts +56 -0
  42. package/src/ribbon/items/ribbon-checkbox.js +134 -0
  43. package/src/ribbon/items/ribbon-colorpicker.d.ts +66 -0
  44. package/src/ribbon/items/ribbon-colorpicker.js +163 -0
  45. package/src/ribbon/items/ribbon-combobox.d.ts +78 -0
  46. package/src/ribbon/items/ribbon-combobox.js +185 -0
  47. package/src/ribbon/items/ribbon-dropdown.d.ts +123 -0
  48. package/src/ribbon/items/ribbon-dropdown.js +268 -0
  49. package/src/ribbon/items/ribbon-splitbutton.d.ts +86 -0
  50. package/src/ribbon/items/ribbon-splitbutton.js +227 -0
  51. package/src/ribbon/models/index.d.ts +24 -0
  52. package/src/ribbon/models/index.js +13 -0
  53. package/src/ribbon/models/ribbon-button-settings-model.d.ts +57 -0
  54. package/src/ribbon/models/ribbon-button-settings.d.ts +55 -0
  55. package/src/ribbon/models/ribbon-button-settings.js +61 -0
  56. package/src/ribbon/models/ribbon-checkbox-settings-model.d.ts +50 -0
  57. package/src/ribbon/models/ribbon-checkbox-settings.d.ts +50 -0
  58. package/src/ribbon/models/ribbon-checkbox-settings.js +58 -0
  59. package/src/ribbon/models/ribbon-collection-model.d.ts +30 -0
  60. package/src/ribbon/models/ribbon-collection.d.ts +33 -0
  61. package/src/ribbon/models/ribbon-collection.js +50 -0
  62. package/src/ribbon/models/ribbon-colorpicker-settings-model.d.ts +123 -0
  63. package/src/ribbon/models/ribbon-colorpicker-settings.d.ts +115 -0
  64. package/src/ribbon/models/ribbon-colorpicker-settings.js +88 -0
  65. package/src/ribbon/models/ribbon-combobox-settings-model.d.ts +241 -0
  66. package/src/ribbon/models/ribbon-combobox-settings.d.ts +223 -0
  67. package/src/ribbon/models/ribbon-combobox-settings.js +122 -0
  68. package/src/ribbon/models/ribbon-dropdown-settings-model.d.ts +100 -0
  69. package/src/ribbon/models/ribbon-dropdown-settings.d.ts +93 -0
  70. package/src/ribbon/models/ribbon-dropdown-settings.js +80 -0
  71. package/src/ribbon/models/ribbon-file-menu-settings-model.d.ts +108 -0
  72. package/src/ribbon/models/ribbon-file-menu-settings.d.ts +159 -0
  73. package/src/ribbon/models/ribbon-file-menu-settings.js +84 -0
  74. package/src/ribbon/models/ribbon-group-model.d.ts +91 -0
  75. package/src/ribbon/models/ribbon-group.d.ts +87 -0
  76. package/src/ribbon/models/ribbon-group.js +74 -0
  77. package/src/ribbon/models/ribbon-item-model.d.ts +120 -0
  78. package/src/ribbon/models/ribbon-item.d.ts +118 -0
  79. package/src/ribbon/models/ribbon-item.js +93 -0
  80. package/src/ribbon/models/ribbon-splitbutton-settings-model.d.ts +107 -0
  81. package/src/ribbon/models/ribbon-splitbutton-settings.d.ts +99 -0
  82. package/src/ribbon/models/ribbon-splitbutton-settings.js +83 -0
  83. package/src/ribbon/models/ribbon-tab-model.d.ts +37 -0
  84. package/src/ribbon/models/ribbon-tab.d.ts +39 -0
  85. package/src/ribbon/models/ribbon-tab.js +53 -0
  86. package/src/ribbon/models/ribbon-tooltip-model.d.ts +43 -0
  87. package/src/ribbon/models/ribbon-tooltip.d.ts +36 -0
  88. package/src/ribbon/models/ribbon-tooltip.js +46 -0
  89. package/src/ribbon/modules/index.d.ts +1 -0
  90. package/src/ribbon/modules/index.js +1 -0
  91. package/src/ribbon/modules/ribbon-filemenu.d.ts +94 -0
  92. package/src/ribbon/modules/ribbon-filemenu.js +318 -0
  93. package/styles/bootstrap-dark.css +1502 -0
  94. package/styles/bootstrap-dark.scss +1 -0
  95. package/styles/bootstrap.css +1507 -0
  96. package/styles/bootstrap.scss +1 -0
  97. package/styles/bootstrap4.css +1557 -0
  98. package/styles/bootstrap4.scss +1 -0
  99. package/styles/bootstrap5-dark.css +1586 -0
  100. package/styles/bootstrap5-dark.scss +1 -0
  101. package/styles/bootstrap5.css +1586 -0
  102. package/styles/bootstrap5.scss +1 -0
  103. package/styles/fabric-dark.css +1478 -0
  104. package/styles/fabric-dark.scss +1 -0
  105. package/styles/fabric.css +1476 -0
  106. package/styles/fabric.scss +1 -0
  107. package/styles/fluent-dark.css +1562 -0
  108. package/styles/fluent-dark.scss +1 -0
  109. package/styles/fluent.css +1562 -0
  110. package/styles/fluent.scss +1 -0
  111. package/styles/highcontrast-light.css +1485 -0
  112. package/styles/highcontrast-light.scss +1 -0
  113. package/styles/highcontrast.css +1494 -0
  114. package/styles/highcontrast.scss +1 -0
  115. package/styles/material-dark.css +1548 -0
  116. package/styles/material-dark.scss +1 -0
  117. package/styles/material.css +1581 -0
  118. package/styles/material.scss +1 -0
  119. package/styles/ribbon/_all.scss +2 -0
  120. package/styles/ribbon/_bootstrap-dark-definition.scss +206 -0
  121. package/styles/ribbon/_bootstrap-definition.scss +206 -0
  122. package/styles/ribbon/_bootstrap4-definition.scss +206 -0
  123. package/styles/ribbon/_bootstrap5-dark-definition.scss +1 -0
  124. package/styles/ribbon/_bootstrap5-definition.scss +206 -0
  125. package/styles/ribbon/_fabric-dark-definition.scss +206 -0
  126. package/styles/ribbon/_fabric-definition.scss +206 -0
  127. package/styles/ribbon/_fluent-dark-definition.scss +1 -0
  128. package/styles/ribbon/_fluent-definition.scss +206 -0
  129. package/styles/ribbon/_fusionnew-definition.scss +206 -0
  130. package/styles/ribbon/_highcontrast-definition.scss +206 -0
  131. package/styles/ribbon/_highcontrast-light-definition.scss +206 -0
  132. package/styles/ribbon/_layout.scss +1040 -0
  133. package/styles/ribbon/_material-dark-definition.scss +206 -0
  134. package/styles/ribbon/_material-definition.scss +206 -0
  135. package/styles/ribbon/_tailwind-dark-definition.scss +1 -0
  136. package/styles/ribbon/_tailwind-definition.scss +206 -0
  137. package/styles/ribbon/_theme.scss +343 -0
  138. package/styles/ribbon/bootstrap-dark.css +1502 -0
  139. package/styles/ribbon/bootstrap-dark.scss +17 -0
  140. package/styles/ribbon/bootstrap.css +1507 -0
  141. package/styles/ribbon/bootstrap.scss +17 -0
  142. package/styles/ribbon/bootstrap4.css +1557 -0
  143. package/styles/ribbon/bootstrap4.scss +17 -0
  144. package/styles/ribbon/bootstrap5-dark.css +1586 -0
  145. package/styles/ribbon/bootstrap5-dark.scss +17 -0
  146. package/styles/ribbon/bootstrap5.css +1586 -0
  147. package/styles/ribbon/bootstrap5.scss +17 -0
  148. package/styles/ribbon/fabric-dark.css +1478 -0
  149. package/styles/ribbon/fabric-dark.scss +17 -0
  150. package/styles/ribbon/fabric.css +1476 -0
  151. package/styles/ribbon/fabric.scss +17 -0
  152. package/styles/ribbon/fluent-dark.css +1562 -0
  153. package/styles/ribbon/fluent-dark.scss +17 -0
  154. package/styles/ribbon/fluent.css +1562 -0
  155. package/styles/ribbon/fluent.scss +17 -0
  156. package/styles/ribbon/highcontrast-light.css +1485 -0
  157. package/styles/ribbon/highcontrast-light.scss +16 -0
  158. package/styles/ribbon/highcontrast.css +1494 -0
  159. package/styles/ribbon/highcontrast.scss +17 -0
  160. package/styles/ribbon/icons/_bootstrap-dark.scss +9 -0
  161. package/styles/ribbon/icons/_bootstrap.scss +9 -0
  162. package/styles/ribbon/icons/_bootstrap4.scss +9 -0
  163. package/styles/ribbon/icons/_bootstrap5-dark.scss +1 -0
  164. package/styles/ribbon/icons/_bootstrap5.scss +9 -0
  165. package/styles/ribbon/icons/_fabric-dark.scss +9 -0
  166. package/styles/ribbon/icons/_fabric.scss +9 -0
  167. package/styles/ribbon/icons/_fluent-dark.scss +1 -0
  168. package/styles/ribbon/icons/_fluent.scss +9 -0
  169. package/styles/ribbon/icons/_fusionnew.scss +9 -0
  170. package/styles/ribbon/icons/_highcontrast.scss +9 -0
  171. package/styles/ribbon/icons/_material-dark.scss +9 -0
  172. package/styles/ribbon/icons/_material.scss +9 -0
  173. package/styles/ribbon/icons/_material3.scss +9 -0
  174. package/styles/ribbon/icons/_tailwind-dark.scss +9 -0
  175. package/styles/ribbon/icons/_tailwind.scss +9 -0
  176. package/styles/ribbon/material-dark.css +1548 -0
  177. package/styles/ribbon/material-dark.scss +17 -0
  178. package/styles/ribbon/material.css +1581 -0
  179. package/styles/ribbon/material.scss +17 -0
  180. package/styles/ribbon/tailwind-dark.css +1560 -0
  181. package/styles/ribbon/tailwind-dark.scss +17 -0
  182. package/styles/ribbon/tailwind.css +1560 -0
  183. package/styles/ribbon/tailwind.scss +17 -0
  184. package/styles/tailwind-dark.css +1560 -0
  185. package/styles/tailwind-dark.scss +1 -0
  186. package/styles/tailwind.css +1560 -0
  187. package/styles/tailwind.scss +1 -0
  188. package/tslint.json +111 -0
@@ -0,0 +1,113 @@
1
+ import { Tooltip, TooltipEventArgs } from '@syncfusion/ej2-popups';
2
+ import { RibbonTabModel, RibbonTooltipModel } from '../models/index';
3
+ import { commonProperties, itemProps, ribbonTooltipData } from './interface';
4
+ import { Ribbon } from './ribbon';
5
+ /**
6
+ * Gets index value.
7
+ *
8
+ * @param {Array} arr - Gets the array to find index.
9
+ * @param {boolean} condition - Defines whether index matches with the value.
10
+ * @returns {number} - Gets the index value.
11
+ */
12
+ export declare function getIndex<T>(arr: Array<T>, condition: (value: T, index: number) => boolean): number;
13
+ /**
14
+ * Gets template content based on the template property value.
15
+ *
16
+ * @param {string | HTMLElement} template - Template property value.
17
+ * @returns {Function} - Return template function.
18
+ */
19
+ export declare function getTemplateFunction(template: string | HTMLElement): Function;
20
+ /**
21
+ * Gets the ribbon item
22
+ *
23
+ * @param {RibbonTabModel} tabs - Gets the ribbon tab model.
24
+ * @param {string} id - Gets the ID of the tab.
25
+ * @returns {itemProps} - Gets the ribbon item.
26
+ */
27
+ export declare function getItem(tabs: RibbonTabModel[], id: string): itemProps;
28
+ /**
29
+ * Gets the ribbon collection.
30
+ *
31
+ * @param {RibbonTabModel} tabs - Gets the ribbon tab model.
32
+ * @param {string} id - Gets the ID of the tab.
33
+ * @returns {itemProps} - Gets the ribbon collection.
34
+ */
35
+ export declare function getCollection(tabs: RibbonTabModel[], id: string): itemProps;
36
+ /**
37
+ * Gets the ribbon group.
38
+ *
39
+ * @param {RibbonTabModel} tabs - Gets the ribbon tab model.
40
+ * @param {string} id - Gets the ID of the tab.
41
+ * @returns {itemProps} - Gets the ribbon group.
42
+ */
43
+ export declare function getGroup(tabs: RibbonTabModel[], id: string): itemProps;
44
+ /**
45
+ * @param {HTMLElement} element - Gets the element to be destroyed.
46
+ * @param {string} moduleName - Gets the module name.
47
+ * @returns {void}
48
+ */
49
+ export declare function destroyControl(element: HTMLElement, moduleName: string): void;
50
+ /**
51
+ * Updates common properties.
52
+ *
53
+ * @param {HTMLElement} element - Gets the element to be updated.
54
+ * @param {string} moduleName - Gets the module name.
55
+ * @param {commonProperties} commonProp - Gets the common properties to be updated.
56
+ * @returns {void}
57
+ */
58
+ export declare function updateCommonProperty(element: HTMLElement, moduleName: string, commonProp: commonProperties): void;
59
+ /**
60
+ * Updates disabled control.
61
+ *
62
+ * @param {HTMLElement} element - Gets the element to be disabled.
63
+ * @param {string} moduleName - Gets the module name.
64
+ * @param {boolean} disable - Defines whether the control to be disabled or not.
65
+ * @returns {void}
66
+ */
67
+ export declare function updateControlDisabled(element: HTMLElement, moduleName: string, disable: boolean): void;
68
+ /**
69
+ * Gets the ribbon item element.
70
+ *
71
+ * @param {Ribbon} parent - Gets the parent element.
72
+ * @param {itemProps} itemProp - Gets the ribbon item.
73
+ * @param {string} id - Gets the ID of the item.
74
+ * @returns {HTMLElement} - Gets the ribbon item element.
75
+ */
76
+ export declare function getItemElement(parent: Ribbon, id: string, itemProp?: itemProps): HTMLElement;
77
+ /**
78
+ * @param {RibbonTooltipModel} tooltip - Gets the property of tooltip.
79
+ * @returns {boolean} - Gets whether the tooltip is present or not.
80
+ */
81
+ export declare function isTooltipPresent(tooltip: RibbonTooltipModel): boolean;
82
+ /**
83
+ * Sets content for tooltip.
84
+ *
85
+ * @param {TooltipEventArgs} args - Gets the argument of tooltip.
86
+ * @param {Tooltip} tooltip - Gets the tooltip to set the content.
87
+ * @param {ribbonTooltipData} tooltipData - Gets the tooltip data.
88
+ * @returns {void}
89
+ */
90
+ export declare function setToolTipContent(args: TooltipEventArgs, tooltip: Tooltip, tooltipData: ribbonTooltipData[]): void;
91
+ /**
92
+ * Creates tooltip.
93
+ *
94
+ * @param {HTMLElement} element - Gets the element to add tooltip.
95
+ * @param {Ribbon} ribbon - Gets the ribbon.
96
+ * @returns {void}
97
+ */
98
+ export declare function createTooltip(element: HTMLElement, ribbon: Ribbon): void;
99
+ /**
100
+ * Destroys tooltip
101
+ *
102
+ * @param {HTMLElement} element - Gets the element in which the tooltip needs to be destroyed.
103
+ * @returns {void}
104
+ */
105
+ export declare function destroyTooltip(element: HTMLElement): void;
106
+ /**
107
+ * Updates tooltip
108
+ *
109
+ * @param {HTMLElement} element - Gets the element in which the tooltip needs to be Updated.
110
+ * @param {commonProperties} prop - Gets the property to be updated.
111
+ * @returns {void}
112
+ */
113
+ export declare function updateTooltipProp(element: HTMLElement, prop: commonProperties): void;
@@ -0,0 +1,288 @@
1
+ import { compile, getComponent, select } from '@syncfusion/ej2-base';
2
+ import { Tooltip } from '@syncfusion/ej2-popups';
3
+ import { DisplayMode, RibbonLayout } from './interface';
4
+ import * as constants from './constant';
5
+ import { DropDownButton } from '@syncfusion/ej2-splitbuttons';
6
+ /**
7
+ * Gets index value.
8
+ *
9
+ * @param {Array} arr - Gets the array to find index.
10
+ * @param {boolean} condition - Defines whether index matches with the value.
11
+ * @returns {number} - Gets the index value.
12
+ */
13
+ export function getIndex(arr, condition) {
14
+ for (var i = 0; i < arr.length; i++) {
15
+ if (condition(arr[parseInt(i.toString(), 10)], i)) {
16
+ return i;
17
+ }
18
+ }
19
+ return -1;
20
+ }
21
+ /**
22
+ * Gets template content based on the template property value.
23
+ *
24
+ * @param {string | HTMLElement} template - Template property value.
25
+ * @returns {Function} - Return template function.
26
+ */
27
+ export function getTemplateFunction(template) {
28
+ if (typeof template === 'string') {
29
+ var content = '';
30
+ try {
31
+ var tempEle = select(template);
32
+ if (tempEle) {
33
+ //Return innerHTML incase of jsrenderer script else outerHTML
34
+ content = tempEle.tagName === 'SCRIPT' ? tempEle.innerHTML : tempEle.outerHTML;
35
+ }
36
+ else {
37
+ content = template;
38
+ }
39
+ }
40
+ catch (e) {
41
+ content = template;
42
+ }
43
+ return compile(content);
44
+ }
45
+ else {
46
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
47
+ return compile(template);
48
+ }
49
+ }
50
+ /**
51
+ * Gets the ribbon item
52
+ *
53
+ * @param {RibbonTabModel} tabs - Gets the ribbon tab model.
54
+ * @param {string} id - Gets the ID of the tab.
55
+ * @returns {itemProps} - Gets the ribbon item.
56
+ */
57
+ export function getItem(tabs, id) {
58
+ for (var i = 0; i < tabs.length; i++) {
59
+ var tab = tabs[parseInt(i.toString(), 10)];
60
+ for (var j = 0; j < tab.groups.length; j++) {
61
+ var group = tab.groups[parseInt(j.toString(), 10)];
62
+ for (var k = 0; k < group.collections.length; k++) {
63
+ var collection = group.collections[parseInt(k.toString(), 10)];
64
+ for (var l = 0; l < collection.items.length; l++) {
65
+ var item = collection.items[parseInt(l.toString(), 10)];
66
+ if (item.id === id) {
67
+ return {
68
+ item: item, collection: collection, group: group,
69
+ tabIndex: i, groupIndex: j, collectionIndex: k, itemIndex: l
70
+ };
71
+ }
72
+ }
73
+ }
74
+ }
75
+ }
76
+ return null;
77
+ }
78
+ /**
79
+ * Gets the ribbon collection.
80
+ *
81
+ * @param {RibbonTabModel} tabs - Gets the ribbon tab model.
82
+ * @param {string} id - Gets the ID of the tab.
83
+ * @returns {itemProps} - Gets the ribbon collection.
84
+ */
85
+ export function getCollection(tabs, id) {
86
+ for (var i = 0; i < tabs.length; i++) {
87
+ var tab = tabs[parseInt(i.toString(), 10)];
88
+ for (var j = 0; j < tab.groups.length; j++) {
89
+ var group = tab.groups[parseInt(j.toString(), 10)];
90
+ for (var k = 0; k < group.collections.length; k++) {
91
+ var collection = group.collections[parseInt(k.toString(), 10)];
92
+ if (collection.id === id) {
93
+ return {
94
+ collection: collection, group: group,
95
+ tabIndex: i, groupIndex: j, collectionIndex: k
96
+ };
97
+ }
98
+ }
99
+ }
100
+ }
101
+ return null;
102
+ }
103
+ /**
104
+ * Gets the ribbon group.
105
+ *
106
+ * @param {RibbonTabModel} tabs - Gets the ribbon tab model.
107
+ * @param {string} id - Gets the ID of the tab.
108
+ * @returns {itemProps} - Gets the ribbon group.
109
+ */
110
+ export function getGroup(tabs, id) {
111
+ for (var i = 0; i < tabs.length; i++) {
112
+ var tab = tabs[parseInt(i.toString(), 10)];
113
+ for (var j = 0; j < tab.groups.length; j++) {
114
+ var group = tab.groups[parseInt(j.toString(), 10)];
115
+ if (group.id === id) {
116
+ return {
117
+ group: group, tabIndex: i, groupIndex: j
118
+ };
119
+ }
120
+ }
121
+ }
122
+ return null;
123
+ }
124
+ /**
125
+ * @param {HTMLElement} element - Gets the element to be destroyed.
126
+ * @param {string} moduleName - Gets the module name.
127
+ * @returns {void}
128
+ */
129
+ export function destroyControl(element, moduleName) {
130
+ var control = getComponent(element, moduleName);
131
+ control.destroy();
132
+ }
133
+ /**
134
+ * Updates common properties.
135
+ *
136
+ * @param {HTMLElement} element - Gets the element to be updated.
137
+ * @param {string} moduleName - Gets the module name.
138
+ * @param {commonProperties} commonProp - Gets the common properties to be updated.
139
+ * @returns {void}
140
+ */
141
+ export function updateCommonProperty(element, moduleName, commonProp) {
142
+ var control = getComponent(element, moduleName);
143
+ control.setProperties(commonProp);
144
+ }
145
+ /**
146
+ * Updates disabled control.
147
+ *
148
+ * @param {HTMLElement} element - Gets the element to be disabled.
149
+ * @param {string} moduleName - Gets the module name.
150
+ * @param {boolean} disable - Defines whether the control to be disabled or not.
151
+ * @returns {void}
152
+ */
153
+ export function updateControlDisabled(element, moduleName, disable) {
154
+ var control = getComponent(element, moduleName);
155
+ control.setProperties(moduleName === 'combobox' ? { enabled: !disable } : { disabled: disable });
156
+ }
157
+ /**
158
+ * Gets the ribbon item element.
159
+ *
160
+ * @param {Ribbon} parent - Gets the parent element.
161
+ * @param {itemProps} itemProp - Gets the ribbon item.
162
+ * @param {string} id - Gets the ID of the item.
163
+ * @returns {HTMLElement} - Gets the ribbon item element.
164
+ */
165
+ export function getItemElement(parent, id, itemProp) {
166
+ if (!itemProp) {
167
+ itemProp = getItem(parent.tabs, id);
168
+ if (!itemProp) {
169
+ return null;
170
+ }
171
+ }
172
+ var contentEle = parent.tabObj.items[itemProp.tabIndex].content;
173
+ if (contentEle.innerHTML === '') {
174
+ return null;
175
+ }
176
+ if (parent.activeLayout === RibbonLayout.Classic) {
177
+ contentEle = (itemProp.group.isCollapsed) ? parent.ribbonDropDownModule.getOverflowDropDownPopup(itemProp, contentEle)
178
+ : contentEle;
179
+ return contentEle.querySelector('#' + id);
180
+ }
181
+ else {
182
+ //Checks for Simplified and Auto options (Auto = simplified + popup)
183
+ var ele = (itemProp.item.displayOptions & DisplayMode.Simplified) ?
184
+ contentEle.querySelector('#' + itemProp.item.id) : null;
185
+ // element will be null for "Popup" and if the item is moved to overflow in "Auto" mode
186
+ if (!ele && (DisplayMode.Simplified !== DisplayMode.None)) {
187
+ var dropdown = itemProp.group.enableGroupOverflow ?
188
+ getComponent(contentEle.querySelector('#' + itemProp.group.id + constants.GROUPOF_BUTTON_ID), DropDownButton)
189
+ : parent.overflowDDB;
190
+ ele = dropdown.target.querySelector('#' + itemProp.item.id);
191
+ }
192
+ return ele;
193
+ }
194
+ }
195
+ /**
196
+ * @param {RibbonTooltipModel} tooltip - Gets the property of tooltip.
197
+ * @returns {boolean} - Gets whether the tooltip is present or not.
198
+ */
199
+ export function isTooltipPresent(tooltip) {
200
+ return (tooltip.content || tooltip.iconCss || tooltip.title || tooltip.id || tooltip.cssClass) ? true : false;
201
+ }
202
+ /**
203
+ * Sets content for tooltip.
204
+ *
205
+ * @param {TooltipEventArgs} args - Gets the argument of tooltip.
206
+ * @param {Tooltip} tooltip - Gets the tooltip to set the content.
207
+ * @param {ribbonTooltipData} tooltipData - Gets the tooltip data.
208
+ * @returns {void}
209
+ */
210
+ export function setToolTipContent(args, tooltip, tooltipData) {
211
+ var targetId = args.target.getAttribute('id');
212
+ var dataObj = tooltipData.filter(function (e) { return e.id === targetId; })[0];
213
+ var data = dataObj.data;
214
+ var content = tooltip.createElement('div', {
215
+ id: data.id ? constants.RIBBON_TOOLTIP_CONTAINER + '_' + data.id : constants.RIBBON_TOOLTIP_CONTAINER
216
+ });
217
+ tooltip.element.append(content);
218
+ if (data.title) {
219
+ var header = tooltip.createElement('div', {
220
+ innerHTML: data.title,
221
+ className: constants.RIBBON_TOOLTIP_TITLE
222
+ });
223
+ content.appendChild(header);
224
+ }
225
+ var textContainer = tooltip.createElement('div', {
226
+ className: constants.RIBBON_TEXT_CONTAINER
227
+ });
228
+ content.appendChild(textContainer);
229
+ if (data.iconCss) {
230
+ var customCss = tooltip.createElement('div', {
231
+ className: data.cssClass ? data.cssClass + ' ' + data.iconCss + ' ' + constants.RIBBON_TOOLTIP_ICON : data.iconCss + ' ' + constants.RIBBON_TOOLTIP_ICON
232
+ });
233
+ textContainer.appendChild(customCss);
234
+ }
235
+ if (data.content) {
236
+ var tooltipContent = tooltip.createElement('div', {
237
+ innerHTML: data.content,
238
+ className: constants.RIBBON_TOOLTIP_CONTENT
239
+ });
240
+ textContainer.appendChild(tooltipContent);
241
+ }
242
+ tooltip.setProperties({
243
+ content: content
244
+ });
245
+ }
246
+ /**
247
+ * Creates tooltip.
248
+ *
249
+ * @param {HTMLElement} element - Gets the element to add tooltip.
250
+ * @param {Ribbon} ribbon - Gets the ribbon.
251
+ * @returns {void}
252
+ */
253
+ export function createTooltip(element, ribbon) {
254
+ var ribbonTooltip = new Tooltip({
255
+ cssClass: (constants.RIBBON_TOOLTIP + ' ' + ribbon.cssClass).trim(),
256
+ target: '.' + constants.RIBBON_TOOLTIP_TARGET,
257
+ beforeRender: beforeTooltipRender.bind(this)
258
+ });
259
+ ribbonTooltip.appendTo(element);
260
+ /**
261
+ * @param {TooltipEventArgs} args - Gets the tooltip argument.
262
+ * @returns {void}
263
+ */
264
+ function beforeTooltipRender(args) {
265
+ setToolTipContent(args, ribbonTooltip, ribbon.tooltipData);
266
+ }
267
+ }
268
+ /**
269
+ * Destroys tooltip
270
+ *
271
+ * @param {HTMLElement} element - Gets the element in which the tooltip needs to be destroyed.
272
+ * @returns {void}
273
+ */
274
+ export function destroyTooltip(element) {
275
+ var control = getComponent(element, Tooltip);
276
+ control.destroy();
277
+ }
278
+ /**
279
+ * Updates tooltip
280
+ *
281
+ * @param {HTMLElement} element - Gets the element in which the tooltip needs to be Updated.
282
+ * @param {commonProperties} prop - Gets the property to be updated.
283
+ * @returns {void}
284
+ */
285
+ export function updateTooltipProp(element, prop) {
286
+ var control = getComponent(element, Tooltip);
287
+ control.setProperties(prop);
288
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Ribbon modules
3
+ */
4
+ export * from './base/index';
5
+ export * from './models/index';
6
+ export * from './items/index';
7
+ export * from './modules/index';
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Ribbon modules
3
+ */
4
+ export * from './base/index';
5
+ export * from './models/index';
6
+ export * from './items/index';
7
+ export * from './modules/index';
@@ -0,0 +1,6 @@
1
+ export * from './ribbon-button';
2
+ export * from './ribbon-checkbox';
3
+ export * from './ribbon-colorpicker';
4
+ export * from './ribbon-combobox';
5
+ export * from './ribbon-dropdown';
6
+ export * from './ribbon-splitbutton';
@@ -0,0 +1,6 @@
1
+ export * from './ribbon-button';
2
+ export * from './ribbon-checkbox';
3
+ export * from './ribbon-colorpicker';
4
+ export * from './ribbon-combobox';
5
+ export * from './ribbon-dropdown';
6
+ export * from './ribbon-splitbutton';
@@ -0,0 +1,65 @@
1
+ import { Ribbon } from '../base/index';
2
+ import { RibbonButtonSettingsModel, RibbonItemModel } from '../models/index';
3
+ import { DropDownButton } from '@syncfusion/ej2-splitbuttons';
4
+ /**
5
+ * Defines the items of Ribbon.
6
+ */
7
+ export declare class RibbonButton {
8
+ private parent;
9
+ constructor(parent: Ribbon);
10
+ protected getModuleName(): string;
11
+ protected destroy(): void;
12
+ /**
13
+ * Creates button.
14
+ *
15
+ * @param {RibbonItemModel} item - Gets the ribbon item model.
16
+ * @param {HTMLElement} itemEle - Gets the ribbon item element.
17
+ * @returns {void}
18
+ * @hidden
19
+ */
20
+ createButton(item: RibbonItemModel, itemEle: HTMLElement): void;
21
+ /**
22
+ * Adds the additional event handlers as the item moved into overflow popup.
23
+ *
24
+ * @param {RibbonItemModel} item - Gets the ribbon item model.
25
+ * @param {HTMLElement} itemEle - Gets the ribbon item element.
26
+ * @param {DropDownButton} overflowButton - Gets the overflow button.
27
+ * @returns {void}
28
+ * @hidden
29
+ */
30
+ addOverFlowEvents(item: RibbonItemModel, itemEle: HTMLElement, overflowButton: DropDownButton): void;
31
+ /**
32
+ * Removes the additional event handlers as the item moved from overflow popup.
33
+ *
34
+ * @param {RibbonItemModel} item - Gets the ribbon item model.
35
+ * @param {HTMLElement} itemEle - Gets the ribbon item element.
36
+ * @param {DropDownButton} overflowButton - Gets the overflow button.
37
+ * @returns {void}
38
+ * @hidden
39
+ */
40
+ removeOverFlowEvents(item: RibbonItemModel, itemEle: HTMLElement): void;
41
+ /**
42
+ * Triggers the click action on the button.
43
+ *
44
+ * @param {string} controlId - Gets the control ID.
45
+ * @returns {void}
46
+ */
47
+ click(controlId: string): void;
48
+ /**
49
+ * Updates the button properties.
50
+ *
51
+ * @param {RibbonButtonSettingsModel} prop - Gets the button property.
52
+ * @param {string} id - Gets the ID of button item.
53
+ * @returns {void}
54
+ */
55
+ updateButton(prop: RibbonButtonSettingsModel, id: string): void;
56
+ /**
57
+ * Updates the button size.
58
+ *
59
+ * @param {HTMLElement} element - Gets the button element.
60
+ * @param {RibbonItemModel} item - Gets the ribbon item.
61
+ * @returns {void}
62
+ * @hidden
63
+ */
64
+ updateButtonSize(element: HTMLElement, item: RibbonItemModel): void;
65
+ }
@@ -0,0 +1,153 @@
1
+ import { getComponent, merge } from '@syncfusion/ej2-base';
2
+ import { Button } from '@syncfusion/ej2-buttons';
3
+ import { getItem, getItemElement, RibbonItemSize } from '../base/index';
4
+ import { ITEM_VERTICAL_CENTER, RIBBON_CONTROL, RIBBON_POPUP_CONTROL, SPACE } from '../base/constant';
5
+ /**
6
+ * Defines the items of Ribbon.
7
+ */
8
+ var RibbonButton = /** @class */ (function () {
9
+ function RibbonButton(parent) {
10
+ this.parent = parent;
11
+ }
12
+ RibbonButton.prototype.getModuleName = function () {
13
+ return 'ribbonButton';
14
+ };
15
+ RibbonButton.prototype.destroy = function () {
16
+ this.parent = null;
17
+ };
18
+ /**
19
+ * Creates button.
20
+ *
21
+ * @param {RibbonItemModel} item - Gets the ribbon item model.
22
+ * @param {HTMLElement} itemEle - Gets the ribbon item element.
23
+ * @returns {void}
24
+ * @hidden
25
+ */
26
+ RibbonButton.prototype.createButton = function (item, itemEle) {
27
+ var _this = this;
28
+ var buttonEle = this.parent.createElement('button', {
29
+ id: item.id
30
+ });
31
+ itemEle.appendChild(buttonEle);
32
+ var btnSettings = item.buttonSettings;
33
+ new Button({
34
+ locale: this.parent.locale,
35
+ enableRtl: this.parent.enableRtl,
36
+ enablePersistence: this.parent.enablePersistence,
37
+ iconPosition: item.activeSize === RibbonItemSize.Large ? 'Top' : 'Left',
38
+ iconCss: btnSettings.iconCss,
39
+ disabled: item.disabled,
40
+ cssClass: (ITEM_VERTICAL_CENTER + SPACE + RIBBON_CONTROL + SPACE + (btnSettings.cssClass ? btnSettings.cssClass : '')).trim(),
41
+ content: item.activeSize === RibbonItemSize.Small ? '' : btnSettings.content,
42
+ isPrimary: btnSettings.isPrimary,
43
+ isToggle: btnSettings.isToggle,
44
+ created: btnSettings.created
45
+ }, buttonEle);
46
+ buttonEle.onclick = function (e) {
47
+ if (btnSettings.clicked) {
48
+ btnSettings.clicked.call(_this, e);
49
+ }
50
+ };
51
+ };
52
+ /**
53
+ * Adds the additional event handlers as the item moved into overflow popup.
54
+ *
55
+ * @param {RibbonItemModel} item - Gets the ribbon item model.
56
+ * @param {HTMLElement} itemEle - Gets the ribbon item element.
57
+ * @param {DropDownButton} overflowButton - Gets the overflow button.
58
+ * @returns {void}
59
+ * @hidden
60
+ */
61
+ RibbonButton.prototype.addOverFlowEvents = function (item, itemEle, overflowButton) {
62
+ var _this = this;
63
+ var buttonEle = itemEle.querySelector('#' + item.id);
64
+ var buttonObj = getComponent(buttonEle, Button);
65
+ buttonObj.setProperties({ cssClass: buttonObj.cssClass + SPACE + RIBBON_POPUP_CONTROL });
66
+ buttonEle.onclick = function (e) {
67
+ if (item.buttonSettings.clicked) {
68
+ item.buttonSettings.clicked.call(_this, e);
69
+ }
70
+ overflowButton.toggle();
71
+ };
72
+ };
73
+ /**
74
+ * Removes the additional event handlers as the item moved from overflow popup.
75
+ *
76
+ * @param {RibbonItemModel} item - Gets the ribbon item model.
77
+ * @param {HTMLElement} itemEle - Gets the ribbon item element.
78
+ * @param {DropDownButton} overflowButton - Gets the overflow button.
79
+ * @returns {void}
80
+ * @hidden
81
+ */
82
+ RibbonButton.prototype.removeOverFlowEvents = function (item, itemEle) {
83
+ var _this = this;
84
+ var buttonEle = itemEle.querySelector('#' + item.id);
85
+ var buttonObj = getComponent(buttonEle, Button);
86
+ var cssClass = buttonObj.cssClass.split(SPACE);
87
+ cssClass = cssClass.filter(function (value) { return value !== RIBBON_POPUP_CONTROL; });
88
+ buttonObj.setProperties({ cssClass: cssClass.join(SPACE) });
89
+ buttonEle.onclick = function (e) {
90
+ if (item.buttonSettings.clicked) {
91
+ item.buttonSettings.clicked.call(_this, e);
92
+ }
93
+ };
94
+ };
95
+ /**
96
+ * Triggers the click action on the button.
97
+ *
98
+ * @param {string} controlId - Gets the control ID.
99
+ * @returns {void}
100
+ */
101
+ RibbonButton.prototype.click = function (controlId) {
102
+ var buttonEle = getItemElement(this.parent, controlId);
103
+ if (!buttonEle) {
104
+ return;
105
+ }
106
+ var buttonObj = getComponent(buttonEle, Button);
107
+ buttonObj.click();
108
+ };
109
+ /**
110
+ * Updates the button properties.
111
+ *
112
+ * @param {RibbonButtonSettingsModel} prop - Gets the button property.
113
+ * @param {string} id - Gets the ID of button item.
114
+ * @returns {void}
115
+ */
116
+ RibbonButton.prototype.updateButton = function (prop, id) {
117
+ var itemProp = getItem(this.parent.tabs, id);
118
+ if (!itemProp) {
119
+ return;
120
+ }
121
+ merge(itemProp.item.buttonSettings, prop);
122
+ var buttonEle = getItemElement(this.parent, id, itemProp);
123
+ if (!buttonEle) {
124
+ return;
125
+ }
126
+ var buttonObj = getComponent(buttonEle, Button);
127
+ if (prop.cssClass) {
128
+ prop.cssClass = (ITEM_VERTICAL_CENTER + SPACE + RIBBON_CONTROL + SPACE + prop.cssClass).trim();
129
+ }
130
+ if (prop.content) {
131
+ prop.content = itemProp.item.activeSize === RibbonItemSize.Small ? '' : prop.content;
132
+ }
133
+ delete prop.clicked;
134
+ buttonObj.setProperties(prop);
135
+ };
136
+ /**
137
+ * Updates the button size.
138
+ *
139
+ * @param {HTMLElement} element - Gets the button element.
140
+ * @param {RibbonItemModel} item - Gets the ribbon item.
141
+ * @returns {void}
142
+ * @hidden
143
+ */
144
+ RibbonButton.prototype.updateButtonSize = function (element, item) {
145
+ var buttonObj = getComponent(element, Button);
146
+ buttonObj.setProperties({
147
+ iconPosition: item.activeSize === RibbonItemSize.Large ? 'Top' : 'Left',
148
+ content: item.activeSize === RibbonItemSize.Small ? '' : item.buttonSettings.content
149
+ });
150
+ };
151
+ return RibbonButton;
152
+ }());
153
+ export { RibbonButton };