@progress/kendo-vue-buttons 3.5.0 → 3.5.1-dev.202208150613

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 (135) hide show
  1. package/dist/cdn/js/kendo-vue-buttons.js +1 -1
  2. package/dist/es/Button.js +1 -1
  3. package/dist/es/ButtonGroupInterface.js +1 -0
  4. package/dist/es/ButtonInterface.js +1 -0
  5. package/dist/es/Chip/Chip.js +1 -1
  6. package/dist/es/Chip/ChipList.js +1 -1
  7. package/dist/es/Chip/selection-reducer.js +8 -12
  8. package/dist/es/FloatingActionButton/FloatingActionButton.js +8 -8
  9. package/dist/es/FloatingActionButton/FloatingActionButtonItem.js +3 -3
  10. package/dist/es/FloatingActionButton/interfaces/FloatingActionButtonHandle.js +1 -0
  11. package/dist/es/FloatingActionButton/interfaces/FloatingActionButtonPopupSettings.js +1 -0
  12. package/dist/es/FloatingActionButton/interfaces/FloatingActionButtonProps.js +1 -0
  13. package/dist/es/FloatingActionButton/models/align-offset.js +1 -0
  14. package/dist/es/FloatingActionButton/models/align.js +1 -0
  15. package/dist/es/FloatingActionButton/models/events.js +1 -0
  16. package/dist/es/FloatingActionButton/models/position-mode.js +1 -0
  17. package/dist/es/FloatingActionButton/models/shape.js +1 -0
  18. package/dist/es/FloatingActionButton/models/size.js +1 -0
  19. package/dist/es/FloatingActionButton/models/theme-color.js +1 -0
  20. package/dist/es/FloatingActionButton/utils.js +2 -2
  21. package/dist/es/ListButton/ButtonItem.js +1 -1
  22. package/dist/es/ListButton/DropDownButton.js +8 -8
  23. package/dist/es/ListButton/SplitButton.js +8 -8
  24. package/dist/es/ListButton/models/ButtonItemInterface.js +1 -0
  25. package/dist/es/ListButton/models/ListButtonProps.js +1 -0
  26. package/dist/es/ListButton/models/PopupSettings.js +1 -0
  27. package/dist/es/ListButton/models/events.js +1 -0
  28. package/dist/es/buttonLook.js +1 -0
  29. package/dist/es/models/index.js +1 -0
  30. package/dist/es/package-metadata.js +1 -1
  31. package/dist/es/util.d.ts +3 -3
  32. package/dist/esm/Button.d.ts +123 -0
  33. package/dist/esm/Button.js +280 -0
  34. package/dist/esm/ButtonGroup.d.ts +49 -0
  35. package/dist/esm/ButtonGroup.js +106 -0
  36. package/dist/esm/ButtonGroupInterface.d.ts +30 -0
  37. package/dist/esm/ButtonGroupInterface.js +2 -0
  38. package/dist/esm/ButtonInterface.d.ts +56 -0
  39. package/dist/esm/ButtonInterface.js +2 -0
  40. package/dist/esm/ButtonWrap.d.ts +19 -0
  41. package/dist/esm/ButtonWrap.js +33 -0
  42. package/dist/esm/Chip/Chip.d.ts +199 -0
  43. package/dist/esm/Chip/Chip.js +339 -0
  44. package/dist/esm/Chip/ChipList.d.ts +174 -0
  45. package/dist/esm/Chip/ChipList.js +263 -0
  46. package/dist/esm/Chip/data-reducer.d.ts +21 -0
  47. package/dist/esm/Chip/data-reducer.js +34 -0
  48. package/dist/esm/Chip/focus-reducer.d.ts +24 -0
  49. package/dist/esm/Chip/focus-reducer.js +38 -0
  50. package/dist/esm/Chip/selection-reducer.d.ts +29 -0
  51. package/dist/esm/Chip/selection-reducer.js +102 -0
  52. package/dist/esm/FloatingActionButton/FloatingActionButton.d.ts +49 -0
  53. package/dist/esm/FloatingActionButton/FloatingActionButton.js +494 -0
  54. package/dist/esm/FloatingActionButton/FloatingActionButtonItem.d.ts +118 -0
  55. package/dist/esm/FloatingActionButton/FloatingActionButtonItem.js +121 -0
  56. package/dist/esm/FloatingActionButton/interfaces/FloatingActionButtonHandle.d.ts +13 -0
  57. package/dist/esm/FloatingActionButton/interfaces/FloatingActionButtonHandle.js +1 -0
  58. package/dist/esm/FloatingActionButton/interfaces/FloatingActionButtonPopupSettings.d.ts +24 -0
  59. package/dist/esm/FloatingActionButton/interfaces/FloatingActionButtonPopupSettings.js +1 -0
  60. package/dist/esm/FloatingActionButton/interfaces/FloatingActionButtonProps.d.ts +243 -0
  61. package/dist/esm/FloatingActionButton/interfaces/FloatingActionButtonProps.js +1 -0
  62. package/dist/esm/FloatingActionButton/models/align-offset.d.ts +20 -0
  63. package/dist/esm/FloatingActionButton/models/align-offset.js +1 -0
  64. package/dist/esm/FloatingActionButton/models/align.d.ts +27 -0
  65. package/dist/esm/FloatingActionButton/models/align.js +1 -0
  66. package/dist/esm/FloatingActionButton/models/events.d.ts +18 -0
  67. package/dist/esm/FloatingActionButton/models/events.js +2 -0
  68. package/dist/esm/FloatingActionButton/models/position-mode.d.ts +9 -0
  69. package/dist/esm/FloatingActionButton/models/position-mode.js +1 -0
  70. package/dist/esm/FloatingActionButton/models/shape.d.ts +13 -0
  71. package/dist/esm/FloatingActionButton/models/shape.js +1 -0
  72. package/dist/esm/FloatingActionButton/models/size.d.ts +10 -0
  73. package/dist/esm/FloatingActionButton/models/size.js +1 -0
  74. package/dist/esm/FloatingActionButton/models/theme-color.d.ts +17 -0
  75. package/dist/esm/FloatingActionButton/models/theme-color.js +1 -0
  76. package/dist/esm/FloatingActionButton/utils.d.ts +27 -0
  77. package/dist/esm/FloatingActionButton/utils.js +93 -0
  78. package/dist/esm/ListButton/ButtonItem.d.ts +58 -0
  79. package/dist/esm/ListButton/ButtonItem.js +138 -0
  80. package/dist/esm/ListButton/DropDownButton.d.ts +66 -0
  81. package/dist/esm/ListButton/DropDownButton.js +453 -0
  82. package/dist/esm/ListButton/SplitButton.d.ts +67 -0
  83. package/dist/esm/ListButton/SplitButton.js +515 -0
  84. package/dist/esm/ListButton/models/ButtonItemInterface.d.ts +29 -0
  85. package/dist/esm/ListButton/models/ButtonItemInterface.js +2 -0
  86. package/dist/esm/ListButton/models/ListButtonProps.d.ts +328 -0
  87. package/dist/esm/ListButton/models/ListButtonProps.js +2 -0
  88. package/dist/esm/ListButton/models/PopupSettings.d.ts +24 -0
  89. package/dist/esm/ListButton/models/PopupSettings.js +1 -0
  90. package/dist/esm/ListButton/models/events.d.ts +48 -0
  91. package/dist/esm/ListButton/models/events.js +1 -0
  92. package/dist/esm/ListButton/utils/navigation.d.ts +5 -0
  93. package/dist/esm/ListButton/utils/navigation.js +24 -0
  94. package/dist/esm/ListButton/utils/popup.d.ts +9 -0
  95. package/dist/esm/ListButton/utils/popup.js +20 -0
  96. package/dist/esm/additionalTypes.ts +21 -0
  97. package/dist/esm/buttonLook.d.ts +13 -0
  98. package/dist/esm/buttonLook.js +1 -0
  99. package/dist/esm/main.d.ts +30 -0
  100. package/dist/esm/main.js +15 -0
  101. package/dist/esm/models/index.d.ts +87 -0
  102. package/dist/esm/models/index.js +1 -0
  103. package/dist/esm/package-metadata.d.ts +5 -0
  104. package/dist/esm/package-metadata.js +11 -0
  105. package/dist/esm/package.json +3 -0
  106. package/dist/esm/toolbar/Toolbar.d.ts +112 -0
  107. package/dist/esm/toolbar/Toolbar.js +208 -0
  108. package/dist/esm/toolbar/tools/ToolbarItem.d.ts +64 -0
  109. package/dist/esm/toolbar/tools/ToolbarItem.js +58 -0
  110. package/dist/esm/toolbar/tools/ToolbarSeparator.d.ts +36 -0
  111. package/dist/esm/toolbar/tools/ToolbarSeparator.js +56 -0
  112. package/dist/esm/toolbar/tools/ToolbarSpacer.d.ts +36 -0
  113. package/dist/esm/toolbar/tools/ToolbarSpacer.js +53 -0
  114. package/dist/esm/util.d.ts +31 -0
  115. package/dist/esm/util.js +40 -0
  116. package/dist/npm/Button.js +5 -5
  117. package/dist/npm/ButtonGroup.js +4 -4
  118. package/dist/npm/ButtonWrap.js +1 -1
  119. package/dist/npm/Chip/Chip.js +10 -10
  120. package/dist/npm/Chip/ChipList.js +8 -8
  121. package/dist/npm/Chip/data-reducer.js +4 -2
  122. package/dist/npm/Chip/focus-reducer.js +4 -2
  123. package/dist/npm/Chip/selection-reducer.js +12 -14
  124. package/dist/npm/FloatingActionButton/FloatingActionButton.js +31 -31
  125. package/dist/npm/FloatingActionButton/FloatingActionButtonItem.js +8 -8
  126. package/dist/npm/FloatingActionButton/utils.js +14 -9
  127. package/dist/npm/ListButton/ButtonItem.js +1 -1
  128. package/dist/npm/ListButton/DropDownButton.js +19 -19
  129. package/dist/npm/ListButton/SplitButton.js +19 -19
  130. package/dist/npm/main.js +6 -2
  131. package/dist/npm/package-metadata.js +1 -1
  132. package/dist/npm/toolbar/Toolbar.js +2 -2
  133. package/dist/npm/toolbar/tools/ToolbarItem.js +1 -1
  134. package/dist/npm/util.d.ts +3 -3
  135. package/package.json +11 -5
@@ -0,0 +1,515 @@
1
+ var __assign = this && this.__assign || function () {
2
+ __assign = Object.assign || function (t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+
6
+ for (var p in s) {
7
+ if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
8
+ }
9
+ }
10
+
11
+ return t;
12
+ };
13
+
14
+ return __assign.apply(this, arguments);
15
+ }; // @ts-ignore
16
+
17
+
18
+ import * as Vue from 'vue';
19
+ var allVue = Vue;
20
+ var gh = allVue.h;
21
+ var isV3 = allVue.version && allVue.version[0] === '3';
22
+ var ref = allVue.ref;
23
+ import { Button as KendoButton } from '../Button.js';
24
+ import { classNames, guid, Keys, kendoThemeMaps, getDefaultSlots } from '@progress/kendo-vue-common';
25
+ import { ButtonItem } from './ButtonItem.js';
26
+ import navigation from './utils/navigation.js';
27
+ import { Popup } from '@progress/kendo-vue-popup';
28
+ import { getAnchorAlign, getPopupAlign } from './utils/popup.js';
29
+ import { validatePackage, templateRendering, getListeners, canUseDOM } from '@progress/kendo-vue-common';
30
+ import { packageMetadata } from '../package-metadata.js';
31
+ /**
32
+ * @hidden
33
+ */
34
+
35
+ var SplitButtonVue2 = {
36
+ name: 'KendoSplitButton',
37
+ // @ts-ignore
38
+ emits: {
39
+ focus: null,
40
+ blur: null,
41
+ buttonclick: null,
42
+ itemclick: null,
43
+ open: null,
44
+ close: null
45
+ },
46
+ props: {
47
+ accessKey: String,
48
+ text: String,
49
+ items: {
50
+ type: Array,
51
+ default: function _default() {
52
+ return [];
53
+ }
54
+ },
55
+ textField: String,
56
+ tabIndex: Number,
57
+ disabled: Boolean,
58
+ icon: String,
59
+ size: {
60
+ type: String,
61
+ default: 'medium'
62
+ },
63
+ rounded: {
64
+ type: String,
65
+ default: 'medium'
66
+ },
67
+ fillMode: {
68
+ type: String,
69
+ default: 'solid',
70
+ validator: function validator(value) {
71
+ return [null, 'flat', 'link', 'outline', 'solid'].includes(value);
72
+ }
73
+ },
74
+ // eslint-disable-next-line max-len
75
+ themeColor: {
76
+ type: String,
77
+ default: 'base',
78
+ validator: function validator(value) {
79
+ return [null, 'base', 'dark', 'error', 'info', 'inverse', 'inverse', 'light', 'primary', 'secondary', 'success', 'tertiary', 'warning'].includes(value);
80
+ }
81
+ },
82
+ opened: {
83
+ type: Boolean,
84
+ default: undefined
85
+ },
86
+ iconClass: String,
87
+ imageUrl: String,
88
+ popupSettings: Object,
89
+ itemRender: [String, Function, Object],
90
+ item: [String, Function, Object],
91
+ look: String,
92
+ className: String,
93
+ buttonClass: String,
94
+ dir: String
95
+ },
96
+ data: function data() {
97
+ return {
98
+ focused: false,
99
+ focusedIndex: -1,
100
+ currentOpened: false
101
+ };
102
+ },
103
+ created: function created() {
104
+ this._blurTimeout = null;
105
+ this._anchor = guid();
106
+ this.mainButton = null;
107
+ this.guid = guid();
108
+ this.buttonsData = [];
109
+ validatePackage(packageMetadata);
110
+ },
111
+ mounted: function mounted() {
112
+ this.mainButton = this.$refs[this._anchor]; // If this.$props.opened is true during the initial render, the popup is not aligned.
113
+
114
+ if (this.$props.dir === undefined && this.isRtl() || this.computedOpened) {
115
+ this.$forceUpdate();
116
+ }
117
+ },
118
+ updated: function updated() {
119
+ if (this.focused && this.element()) {
120
+ this.mainButton = this.$refs[this._anchor];
121
+ this.mainButton.focus();
122
+ }
123
+ },
124
+ computed: {
125
+ computedOpened: function computedOpened() {
126
+ return this.$props.opened === undefined ? this.currentOpened : this.$props.opened;
127
+ },
128
+ wrapperClass: function wrapperClass() {
129
+ return {
130
+ 'k-split-button': true,
131
+ 'k-button-group': true,
132
+ 'k-focus': this.focused
133
+ };
134
+ }
135
+ },
136
+ // @ts-ignore
137
+ setup: !isV3 ? undefined : function () {
138
+ var v3 = !!isV3;
139
+ var kendoAnchorRef = ref(null);
140
+ return {
141
+ v3: v3,
142
+ kendoAnchorRef: kendoAnchorRef
143
+ };
144
+ },
145
+ render: function render(createElement) {
146
+ var _this3 = this;
147
+
148
+ var _this = this;
149
+
150
+ var h = gh || createElement;
151
+ this.buttonsData = this.$props.items;
152
+ var rtl = this.isRtl();
153
+ var dir = rtl ? 'rtl' : undefined;
154
+ var _a = this.$props,
155
+ tabIndex = _a.tabIndex,
156
+ disabled = _a.disabled;
157
+ var defaultSlot = getDefaultSlots(this);
158
+
159
+ var renderChildItems = function renderChildItems() {
160
+ var _a = this.$props,
161
+ item = _a.item,
162
+ itemRender = _a.itemRender,
163
+ textField = _a.textField;
164
+ return this.buttonsData.length > 0 ? this.buttonsData.map(function (dataItem, index) {
165
+ var currentDataItem = typeof dataItem !== 'string' ? __assign(__assign({}, dataItem), {
166
+ render: templateRendering.call(this, dataItem.render, getListeners.call(this))
167
+ }) : dataItem;
168
+ return (// @ts-ignore
169
+ h(ButtonItem, {
170
+ "class": "k-menu-item",
171
+ dataItem: currentDataItem,
172
+ attrs: this.v3 ? undefined : {
173
+ dataItem: currentDataItem,
174
+ textField: textField,
175
+ focused: this.focusedIndex === index,
176
+ render: templateRendering.call(this, itemRender, getListeners.call(this)),
177
+ item: item,
178
+ index: index,
179
+ id: "".concat(this.guid, "-").concat(index)
180
+ },
181
+ textField: textField,
182
+ focused: this.focusedIndex === index,
183
+ onClick: this.onItemClick,
184
+ on: this.v3 ? undefined : {
185
+ "click": this.onItemClick,
186
+ "down": this.onItemDown
187
+ },
188
+ onDown: this.onItemDown,
189
+ render: templateRendering.call(this, itemRender, getListeners.call(this)),
190
+ item: item,
191
+ key: index,
192
+ index: index,
193
+ id: "".concat(this.guid, "-").concat(index)
194
+ })
195
+ );
196
+ }, this) : null;
197
+ };
198
+
199
+ var renderPopup = function renderPopup() {
200
+ var _this2 = this;
201
+
202
+ var _a = this.$props,
203
+ _b = _a.popupSettings,
204
+ popupSettings = _b === void 0 ? {} : _b,
205
+ size = _a.size;
206
+ return (// @ts-ignore function children
207
+ h(Popup, {
208
+ anchor: this._anchor,
209
+ attrs: this.v3 ? undefined : {
210
+ anchor: this._anchor,
211
+ show: this.computedOpened,
212
+ animate: popupSettings.animate,
213
+ popupClass: classNames('k-menu-popup', popupSettings.popupClass),
214
+ anchorAlign: popupSettings.anchorAlign || getAnchorAlign(rtl),
215
+ popupAlign: popupSettings.popupAlign || getPopupAlign(rtl)
216
+ },
217
+ show: this.computedOpened,
218
+ animate: popupSettings.animate,
219
+ popupClass: classNames('k-menu-popup', popupSettings.popupClass),
220
+ anchorAlign: popupSettings.anchorAlign || getAnchorAlign(rtl),
221
+ popupAlign: popupSettings.popupAlign || getPopupAlign(rtl),
222
+ style: rtl ? {
223
+ direction: 'rtl'
224
+ } : undefined
225
+ }, this.v3 ? function () {
226
+ return [h("ul", {
227
+ "class": "k-group k-menu-group k-reset k-menu-group-".concat(kendoThemeMaps.sizeMap[size] || size),
228
+ role: "menu",
229
+ attrs: _this2.v3 ? undefined : {
230
+ role: "menu",
231
+ id: _this2.guid
232
+ },
233
+ id: _this2.guid
234
+ }, [renderChildItems.call(_this2)])];
235
+ } : [h("ul", {
236
+ "class": "k-group k-menu-group k-reset k-menu-group-".concat(kendoThemeMaps.sizeMap[size] || size),
237
+ role: "menu",
238
+ attrs: _this2.v3 ? undefined : {
239
+ role: "menu",
240
+ id: _this2.guid
241
+ },
242
+ id: _this2.guid
243
+ }, [renderChildItems.call(_this2)])])
244
+ );
245
+ };
246
+
247
+ return h("div", {
248
+ "class": this.wrapperClass,
249
+ onKeydown: this.onKeyDown,
250
+ on: this.v3 ? undefined : {
251
+ "keydown": this.onKeyDown,
252
+ "focusin": this.onFocus,
253
+ "focusout": this.onBlur
254
+ },
255
+ onFocusin: this.onFocus,
256
+ onFocusout: this.onBlur,
257
+ dir: dir,
258
+ attrs: this.v3 ? undefined : {
259
+ dir: dir
260
+ }
261
+ }, [// @ts-ignore function children
262
+ h(KendoButton, {
263
+ size: this.$props.size,
264
+ attrs: this.v3 ? undefined : {
265
+ size: this.$props.size,
266
+ rounded: this.$props.rounded,
267
+ fillMode: this.$props.fillMode,
268
+ themeColor: this.$props.themeColor,
269
+ disabled: disabled || undefined,
270
+ tabIndex: tabIndex,
271
+ accessKey: this.$props.accessKey,
272
+ icon: this.$props.icon,
273
+ iconClass: this.$props.iconClass,
274
+ imageUrl: this.$props.imageUrl,
275
+ look: this.$props.look,
276
+ dir: dir,
277
+ type: "button",
278
+ "aria-disabled": disabled,
279
+ "aria-haspopup": true,
280
+ "aria-expanded": this.computedOpened,
281
+ "aria-label": "".concat(this.$props.text, " splitbutton"),
282
+ "aria-owns": this.guid,
283
+ "aria-activedescendant": this.focusedIndex !== undefined && this.focusedIndex >= 0 ? "".concat(this.guid, "-").concat(this.focusedIndex) : undefined
284
+ },
285
+ rounded: this.$props.rounded,
286
+ fillMode: this.$props.fillMode,
287
+ themeColor: this.$props.themeColor,
288
+ onClick: function onClick(event) {
289
+ return _this.onItemClick(event, -1);
290
+ },
291
+ on: this.v3 ? undefined : {
292
+ "click": function onClick(event) {
293
+ return _this.onItemClick(event, -1);
294
+ }
295
+ },
296
+ disabled: disabled || undefined,
297
+ tabIndex: tabIndex,
298
+ accessKey: this.$props.accessKey,
299
+ "class": this.$props.buttonClass,
300
+ icon: this.$props.icon,
301
+ iconClass: this.$props.iconClass,
302
+ imageUrl: this.$props.imageUrl,
303
+ look: this.$props.look,
304
+ dir: dir,
305
+ ref: this._anchor,
306
+ type: "button",
307
+ "aria-disabled": disabled,
308
+ "aria-haspopup": true,
309
+ "aria-expanded": this.computedOpened,
310
+ "aria-label": "".concat(this.$props.text, " splitbutton"),
311
+ "aria-owns": this.guid,
312
+ "aria-activedescendant": this.focusedIndex !== undefined && this.focusedIndex >= 0 ? "".concat(this.guid, "-").concat(this.focusedIndex) : undefined
313
+ }, this.v3 ? function () {
314
+ return [_this3.$props.text, defaultSlot];
315
+ } : [_this3.$props.text, defaultSlot]), // @ts-ignore
316
+ h(KendoButton, {
317
+ "class": 'k-split-button-arrow',
318
+ size: this.$props.size,
319
+ attrs: this.v3 ? undefined : {
320
+ size: this.$props.size,
321
+ rounded: this.$props.rounded,
322
+ fillMode: this.$props.fillMode,
323
+ themeColor: this.$props.themeColor,
324
+ icon: "arrow-s",
325
+ disabled: disabled || undefined,
326
+ tabIndex: -1,
327
+ look: this.$props.look,
328
+ dir: dir,
329
+ "aria-label": "menu toggling button"
330
+ },
331
+ rounded: this.$props.rounded,
332
+ fillMode: this.$props.fillMode,
333
+ themeColor: this.$props.themeColor,
334
+ icon: "arrow-s",
335
+ disabled: disabled || undefined,
336
+ tabIndex: -1,
337
+ look: this.$props.look,
338
+ onClick: this.onSplitPartClick,
339
+ on: this.v3 ? undefined : {
340
+ "click": this.onSplitPartClick,
341
+ "mousedown": this.onDownSplitPart,
342
+ "pointerdown": this.onDownSplitPart
343
+ },
344
+ onMousedown: this.onDownSplitPart,
345
+ onPointerdown: this.onDownSplitPart,
346
+ dir: dir,
347
+ "aria-label": "menu toggling button"
348
+ }), renderPopup.call(this)]);
349
+ },
350
+ methods: {
351
+ element: function element() {
352
+ return this.mainButton;
353
+ },
354
+ onKeyDown: function onKeyDown(event) {
355
+ if (event.altKey) {
356
+ if (!this.computedOpened && event.keyCode === Keys.down) {
357
+ this.dispatchPopupEvent(event, true);
358
+ this.focusedIndex = 0;
359
+ this.currentOpened = true;
360
+ } else if (this.computedOpened && event.keyCode === Keys.up) {
361
+ this.dispatchPopupEvent(event, false);
362
+ this.focusedIndex = -1;
363
+ this.currentOpened = false;
364
+ }
365
+
366
+ return;
367
+ }
368
+
369
+ var newState = undefined;
370
+
371
+ if (event.keyCode === Keys.enter || event.keyCode === Keys.space) {
372
+ // Prevent default because otherwise when an item is selected
373
+ // click on the default button gets emitted which opens the popup again.
374
+ event.preventDefault();
375
+ this.dispatchClickEvent(event, this.focusedIndex);
376
+
377
+ if (this.focusedIndex !== undefined && this.focusedIndex >= 0) {
378
+ newState = {
379
+ focusedIndex: this.computedOpened ? -1 : 0,
380
+ currentOpened: !this.computedOpened
381
+ };
382
+ this.dispatchPopupEvent(event, newState.currentOpened);
383
+ }
384
+ } else if (this.computedOpened && event.keyCode === Keys.esc) {
385
+ newState = {
386
+ focusedIndex: -1,
387
+ currentOpened: false
388
+ };
389
+ this.dispatchPopupEvent(event, newState.currentOpened);
390
+ }
391
+
392
+ if (this.computedOpened) {
393
+ var newFocused = navigation(this.focusedIndex, event.keyCode, event.altKey, this.buttonsData.length);
394
+
395
+ if (newFocused !== this.focusedIndex) {
396
+ newState = newState || {}; // @ts-ignore
397
+
398
+ newState.focusedIndex = newFocused;
399
+ }
400
+
401
+ var arrowKey = event.keyCode === Keys.up || event.keyCode === Keys.down || event.keyCode === Keys.left || event.keyCode === Keys.right;
402
+
403
+ if (!event.altKey && arrowKey) {
404
+ // Needed to notify the parent listeners that event is handled.
405
+ event.preventDefault();
406
+ }
407
+ }
408
+
409
+ if (newState) {
410
+ this.focusedIndex = newState.focusedIndex;
411
+ this.focused = newState.focused;
412
+
413
+ if (newState.currentOpened !== undefined) {
414
+ this.currentOpened = newState.currentOpened;
415
+ }
416
+ }
417
+ },
418
+ onFocus: function onFocus(event) {
419
+ if (!this.focused) {
420
+ this.$emit('focus', event, this, undefined);
421
+ this.focused = true;
422
+ }
423
+
424
+ this.focusedIndex = -1;
425
+ clearTimeout(this._blurTimeout);
426
+ },
427
+ onItemClick: function onItemClick(event, clickedItemIndex) {
428
+ var opened = this.computedOpened;
429
+
430
+ if (opened) {
431
+ this.focusedIndex = 0;
432
+ this.currentOpened = false;
433
+ }
434
+
435
+ this.dispatchClickEvent(event, clickedItemIndex);
436
+
437
+ if (opened) {
438
+ this.dispatchPopupEvent(event, false);
439
+ }
440
+ },
441
+ onBlur: function onBlur(event) {
442
+ clearTimeout(this._blurTimeout);
443
+ this.createBlurTimeout(event);
444
+ },
445
+ createBlurTimeout: function createBlurTimeout(event) {
446
+ var _this = this;
447
+
448
+ var that = this;
449
+ this._blurTimeout = setTimeout(function () {
450
+ if (canUseDOM && document.activeElement !== that.mainButton) {
451
+ that.focused = false;
452
+ that.focusedIndex = -1;
453
+ that.$emit('blur', event, _this, undefined);
454
+ var fireCloseEvent = that.computedOpened;
455
+
456
+ if (fireCloseEvent) {
457
+ that.currentOpened = false;
458
+ that.dispatchPopupEvent(event, false);
459
+ }
460
+ }
461
+ }, 200);
462
+ },
463
+ dispatchClickEvent: function dispatchClickEvent(dispatchedEvent, clickedItemIndex) {
464
+ if (!this.isItemDisabled(clickedItemIndex)) {
465
+ if (clickedItemIndex === -1) {
466
+ this.$emit('buttonclick', dispatchedEvent, this, undefined);
467
+ } else {
468
+ this.$emit('itemclick', {
469
+ event: dispatchedEvent,
470
+ component: this,
471
+ item: this.buttonsData[clickedItemIndex],
472
+ itemIndex: clickedItemIndex
473
+ });
474
+ }
475
+ }
476
+ },
477
+ onSplitPartClick: function onSplitPartClick(event) {
478
+ if (this.buttonsData.length) {
479
+ var toOpen = !this.computedOpened;
480
+ this.dispatchPopupEvent(event, toOpen);
481
+ this.focusedIndex = toOpen ? 0 : -1;
482
+ this.currentOpened = toOpen;
483
+ this.focused = true;
484
+ }
485
+ },
486
+ onDownSplitPart: function onDownSplitPart(event) {
487
+ event.preventDefault();
488
+
489
+ if (this.element() && document.activeElement !== this.element()) {
490
+ // @ts-ignore
491
+ this.element().focus();
492
+ }
493
+ },
494
+ onItemDown: function onItemDown(event) {
495
+ if (document.activeElement === this.element()) {
496
+ event.preventDefault();
497
+ }
498
+ },
499
+ dispatchPopupEvent: function dispatchPopupEvent(dispatchedEvent, open) {
500
+ this.$emit(open ? 'open' : 'close', dispatchedEvent, this, undefined);
501
+ },
502
+ isItemDisabled: function isItemDisabled(index) {
503
+ return this.buttonsData[index] ? this.buttonsData[index].disabled : this.$props.disabled;
504
+ },
505
+ isRtl: function isRtl() {
506
+ return this.$props.dir !== undefined ? this.$props.dir === 'rtl' : !!this.$el && getComputedStyle(this.$el).direction === 'rtl';
507
+ }
508
+ }
509
+ };
510
+ /**
511
+ * @hidden
512
+ */
513
+
514
+ var SplitButton = SplitButtonVue2;
515
+ export { SplitButton, SplitButtonVue2 };
@@ -0,0 +1,29 @@
1
+ /**
2
+ * The interface for describing items that can be passed to the `items` property of the SplitButton or the DropDownButton as an alternative to passing them as children.
3
+ */
4
+ export interface ButtonItemInterface {
5
+ /**
6
+ * Specifies the text of the item.
7
+ */
8
+ text: string;
9
+ /**
10
+ * Defines an icon that will be rendered next to the item text.
11
+ */
12
+ icon?: string;
13
+ /**
14
+ * Defines an icon with a custom CSS class that will be rendered next to the item text.
15
+ */
16
+ iconClass?: string;
17
+ /**
18
+ * Defines the location of an image that will be displayed next to the item text.
19
+ */
20
+ imageUrl?: string;
21
+ /**
22
+ * Determines whether the item is disabled.
23
+ */
24
+ disabled?: boolean;
25
+ /**
26
+ * Defines a named slot `string`, functional or class component for rendering the item. The default rendering includes an icon, an image, and text.
27
+ */
28
+ render?: any;
29
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ // tslint:enable:max-line-length