primevue 4.1.0 → 4.1.1

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 (175) hide show
  1. package/README.md +2 -94
  2. package/accordion/index.d.ts +2 -2
  3. package/accordioncontent/index.d.ts +2 -2
  4. package/accordionheader/index.d.ts +2 -2
  5. package/accordionpanel/index.d.ts +2 -2
  6. package/accordiontab/index.d.ts +2 -2
  7. package/autocomplete/index.d.ts +2 -2
  8. package/autocomplete/style/index.mjs +1 -1
  9. package/autocomplete/style/index.mjs.map +1 -1
  10. package/avatar/index.d.ts +2 -2
  11. package/avatargroup/index.d.ts +2 -2
  12. package/badge/index.d.ts +2 -2
  13. package/blockui/index.d.ts +2 -2
  14. package/breadcrumb/index.d.ts +2 -2
  15. package/button/index.d.ts +2 -2
  16. package/buttongroup/index.d.ts +2 -2
  17. package/calendar/index.d.ts +2 -2
  18. package/card/index.d.ts +2 -2
  19. package/carousel/index.d.ts +2 -2
  20. package/cascadeselect/CascadeSelect.vue +54 -32
  21. package/cascadeselect/CascadeSelectSub.vue +8 -17
  22. package/cascadeselect/index.d.ts +2 -2
  23. package/cascadeselect/index.mjs +100 -63
  24. package/cascadeselect/index.mjs.map +1 -1
  25. package/cascadeselect/style/index.mjs +2 -2
  26. package/cascadeselect/style/index.mjs.map +1 -1
  27. package/chart/index.d.ts +2 -2
  28. package/checkbox/index.d.ts +2 -2
  29. package/chip/index.d.ts +2 -2
  30. package/chips/index.d.ts +2 -2
  31. package/colorpicker/index.d.ts +2 -2
  32. package/column/index.d.ts +2 -2
  33. package/columngroup/index.d.ts +2 -2
  34. package/confirmdialog/index.d.ts +2 -2
  35. package/confirmpopup/index.d.ts +2 -2
  36. package/contextmenu/ContextMenu.vue +8 -3
  37. package/contextmenu/index.d.ts +2 -2
  38. package/contextmenu/index.mjs +6 -3
  39. package/contextmenu/index.mjs.map +1 -1
  40. package/contextmenu/style/index.mjs +1 -1
  41. package/contextmenu/style/index.mjs.map +1 -1
  42. package/datatable/DataTable.vue +2 -2
  43. package/datatable/index.d.ts +2 -2
  44. package/datatable/index.mjs +4 -4
  45. package/datatable/index.mjs.map +1 -1
  46. package/datatable/style/index.mjs +1 -1
  47. package/datatable/style/index.mjs.map +1 -1
  48. package/dataview/index.d.ts +2 -2
  49. package/datepicker/index.d.ts +2 -2
  50. package/deferredcontent/index.d.ts +2 -2
  51. package/dialog/index.d.ts +2 -2
  52. package/divider/index.d.ts +2 -2
  53. package/dock/index.d.ts +2 -2
  54. package/drawer/index.d.ts +2 -2
  55. package/dropdown/index.d.ts +2 -2
  56. package/dynamicdialog/index.d.ts +2 -2
  57. package/editor/index.d.ts +2 -2
  58. package/fieldset/index.d.ts +2 -2
  59. package/fileupload/index.d.ts +2 -2
  60. package/floatlabel/index.d.ts +2 -2
  61. package/fluid/index.d.ts +2 -2
  62. package/galleria/index.d.ts +2 -2
  63. package/iconfield/index.d.ts +2 -2
  64. package/iftalabel/index.d.ts +2 -2
  65. package/image/index.d.ts +2 -2
  66. package/imagecompare/index.d.ts +2 -2
  67. package/inlinemessage/index.d.ts +2 -2
  68. package/inplace/index.d.ts +2 -2
  69. package/inputchips/index.d.ts +2 -2
  70. package/inputgroup/index.d.ts +2 -2
  71. package/inputgroupaddon/index.d.ts +2 -2
  72. package/inputicon/index.d.ts +2 -2
  73. package/inputmask/index.d.ts +2 -2
  74. package/inputnumber/index.d.ts +2 -2
  75. package/inputnumber/style/index.mjs +1 -1
  76. package/inputnumber/style/index.mjs.map +1 -1
  77. package/inputotp/index.d.ts +2 -2
  78. package/inputswitch/index.d.ts +2 -2
  79. package/inputtext/index.d.ts +2 -2
  80. package/inputtext/style/index.mjs +1 -1
  81. package/inputtext/style/index.mjs.map +1 -1
  82. package/knob/index.d.ts +2 -2
  83. package/listbox/index.d.ts +2 -2
  84. package/megamenu/BaseMegaMenu.vue +4 -0
  85. package/megamenu/MegaMenu.vue +15 -5
  86. package/megamenu/index.d.ts +7 -2
  87. package/megamenu/index.mjs +23 -6
  88. package/megamenu/index.mjs.map +1 -1
  89. package/megamenu/style/index.mjs +5 -5
  90. package/megamenu/style/index.mjs.map +1 -1
  91. package/menu/index.d.ts +2 -2
  92. package/menubar/Menubar.vue +8 -3
  93. package/menubar/index.d.ts +2 -2
  94. package/menubar/index.mjs +6 -3
  95. package/menubar/index.mjs.map +1 -1
  96. package/menubar/style/index.mjs +1 -1
  97. package/menubar/style/index.mjs.map +1 -1
  98. package/message/index.d.ts +2 -2
  99. package/metergroup/index.d.ts +2 -2
  100. package/multiselect/index.d.ts +2 -2
  101. package/orderlist/index.d.ts +2 -2
  102. package/organizationchart/index.d.ts +2 -2
  103. package/overlaybadge/index.d.ts +2 -2
  104. package/overlaypanel/index.d.ts +2 -2
  105. package/package.json +3 -3
  106. package/paginator/index.d.ts +2 -2
  107. package/panel/index.d.ts +2 -2
  108. package/panelmenu/index.d.ts +2 -2
  109. package/password/index.d.ts +2 -2
  110. package/picklist/index.d.ts +2 -2
  111. package/popover/index.d.ts +2 -2
  112. package/portal/index.d.ts +2 -2
  113. package/progressbar/index.d.ts +2 -2
  114. package/progressspinner/index.d.ts +2 -2
  115. package/radiobutton/index.d.ts +2 -2
  116. package/rating/index.d.ts +2 -2
  117. package/row/index.d.ts +2 -2
  118. package/scrollpanel/index.d.ts +2 -2
  119. package/scrolltop/index.d.ts +2 -2
  120. package/select/index.d.ts +2 -2
  121. package/selectbutton/index.d.ts +2 -2
  122. package/sidebar/index.d.ts +2 -2
  123. package/skeleton/index.d.ts +2 -2
  124. package/slider/index.d.ts +2 -2
  125. package/slider/style/index.mjs +1 -1
  126. package/slider/style/index.mjs.map +1 -1
  127. package/speeddial/index.d.ts +2 -2
  128. package/splitbutton/index.d.ts +2 -2
  129. package/splitter/index.d.ts +2 -2
  130. package/splitterpanel/index.d.ts +2 -2
  131. package/step/index.d.ts +2 -2
  132. package/stepitem/index.d.ts +2 -2
  133. package/steplist/index.d.ts +2 -2
  134. package/steppanel/index.d.ts +2 -2
  135. package/steppanels/index.d.ts +2 -2
  136. package/stepper/index.d.ts +2 -2
  137. package/steps/index.d.ts +2 -2
  138. package/tab/index.d.ts +2 -2
  139. package/tablist/index.d.ts +2 -2
  140. package/tabmenu/index.d.ts +2 -2
  141. package/tabpanel/index.d.ts +2 -2
  142. package/tabpanels/index.d.ts +2 -2
  143. package/tabs/index.d.ts +2 -2
  144. package/tabview/index.d.ts +2 -2
  145. package/tag/index.d.ts +2 -2
  146. package/terminal/index.d.ts +2 -2
  147. package/textarea/index.d.ts +2 -2
  148. package/tieredmenu/TieredMenu.vue +8 -3
  149. package/tieredmenu/index.d.ts +2 -2
  150. package/tieredmenu/index.mjs +6 -3
  151. package/tieredmenu/index.mjs.map +1 -1
  152. package/tieredmenu/style/index.mjs +1 -1
  153. package/tieredmenu/style/index.mjs.map +1 -1
  154. package/timeline/index.d.ts +2 -2
  155. package/toast/index.d.ts +2 -2
  156. package/togglebutton/index.d.ts +2 -2
  157. package/toggleswitch/index.d.ts +2 -2
  158. package/toolbar/index.d.ts +2 -2
  159. package/tooltip/style/index.mjs +1 -1
  160. package/tooltip/style/index.mjs.map +1 -1
  161. package/tree/Tree.vue +1 -1
  162. package/tree/index.d.ts +2 -2
  163. package/tree/index.mjs +3 -2
  164. package/tree/index.mjs.map +1 -1
  165. package/tree/style/index.mjs +2 -1
  166. package/tree/style/index.mjs.map +1 -1
  167. package/treeselect/index.d.ts +2 -2
  168. package/treeselect/style/index.mjs +1 -1
  169. package/treeselect/style/index.mjs.map +1 -1
  170. package/treetable/index.d.ts +2 -2
  171. package/treetable/style/index.mjs +1 -1
  172. package/treetable/style/index.mjs.map +1 -1
  173. package/umd/primevue.min.js +1 -1
  174. package/virtualscroller/index.d.ts +2 -2
  175. package/web-types.json +2 -2
@@ -71,9 +71,10 @@
71
71
  :optionGroupIcon="optionGroupIcon"
72
72
  :optionGroupLabel="optionGroupLabel"
73
73
  :optionGroupChildren="optionGroupChildren"
74
- @option-change="onOptionChange"
75
- @option-focus-move-change="onOptionFocusMoveChange"
76
- @option-focus-enter-change="onOptionFocusChangeEnter"
74
+ :value="modelValue"
75
+ @option-change="onOptionClick"
76
+ @option-focus-change="onOptionMouseMove"
77
+ @option-focus-enter-change="onOptionMouseEnter"
77
78
  :pt="pt"
78
79
  :unstyled="unstyled"
79
80
  />
@@ -304,51 +305,68 @@ export default {
304
305
 
305
306
  this.clicked = false;
306
307
  },
307
- onOptionChange(event, isSelectable = true) {
308
- const { originalEvent, processedOption, isFocus, isHide } = event;
308
+ onOptionChange(event) {
309
+ const { processedOption, type } = event;
309
310
 
310
311
  if (isEmpty(processedOption)) return;
311
312
 
312
313
  const { index, key, level, parentKey, children } = processedOption;
313
314
  const grouped = isNotEmpty(children);
314
- const root = isEmpty(processedOption.parent);
315
+ const activeOptionPath = this.activeOptionPath.filter((p) => p.parentKey !== parentKey && p.parentKey !== key);
316
+
317
+ this.focusedOptionInfo = { index, level, parentKey };
318
+
319
+ if (type == 'hover' && this.queryMatches) {
320
+ return;
321
+ }
322
+
323
+ if (grouped) {
324
+ activeOptionPath.push(processedOption);
325
+ }
326
+
327
+ this.activeOptionPath = activeOptionPath;
328
+ },
329
+ onOptionClick(event) {
330
+ const { originalEvent, processedOption, isFocus, isHide, preventSelection } = event;
331
+ const { index, key, level, parentKey } = processedOption;
332
+ const grouped = this.isProccessedOptionGroup(processedOption);
315
333
  const selected = this.isSelected(processedOption);
316
334
 
317
335
  if (selected) {
318
- this.focusedOptionInfo = { index, level, parentKey };
319
336
  this.activeOptionPath = this.activeOptionPath.filter((p) => key !== p.key && key.startsWith(p.key));
320
-
321
- this.dirty = !root;
337
+ this.focusedOptionInfo = { index, level, parentKey };
322
338
  } else {
323
- const activeOptionPath = this.activeOptionPath.filter((p) => p.parentKey !== parentKey && p.parentKey !== key);
339
+ if (grouped) {
340
+ this.onOptionChange(event);
341
+ this.onOptionGroupSelect(originalEvent, processedOption);
342
+ } else {
343
+ const activeOptionPath = this.activeOptionPath.filter((p) => p.parentKey !== parentKey);
324
344
 
325
- activeOptionPath.push(processedOption);
345
+ activeOptionPath.push(processedOption);
326
346
 
327
- this.focusedOptionInfo = { index, level, parentKey };
328
- this.activeOptionPath = activeOptionPath;
329
- }
347
+ this.focusedOptionInfo = { index, level, parentKey };
330
348
 
331
- if (grouped) {
332
- this.dirty = true;
333
- this.onOptionGroupSelect(originalEvent, processedOption);
334
- } else {
335
- isSelectable && this.onOptionSelect(originalEvent, processedOption, isHide);
349
+ if (!preventSelection || processedOption?.children.length !== 0) {
350
+ this.activeOptionPath = activeOptionPath;
351
+ this.onOptionSelect(originalEvent, processedOption, isHide);
352
+ }
353
+ }
336
354
  }
337
355
 
338
356
  isFocus && focus(this.$refs.focusInput);
339
357
  },
340
- onOptionFocusMoveChange(event) {
358
+ onOptionMouseEnter(event) {
341
359
  if (this.focusOnHover) {
342
- const { originalEvent, processedOption } = event;
343
- const { index, level, parentKey } = processedOption;
344
-
345
- this.focusedOptionInfo = { index, level, parentKey };
346
- this.changeFocusedOptionIndex(originalEvent, index);
360
+ if (this.dirty || (!this.dirty && isNotEmpty(this.modelValue))) {
361
+ this.onOptionChange({ ...event, type: 'hover' });
362
+ } else if (!this.dirty && event.processedOption.level === 0) {
363
+ this.onOptionClick({ ...event, type: 'hover' });
364
+ }
347
365
  }
348
366
  },
349
- onOptionFocusChangeEnter(event) {
350
- if (this.dirty) {
351
- this.onOptionChange(event, false);
367
+ onOptionMouseMove(event) {
368
+ if (this.focused && this.focusOnHover) {
369
+ this.changeFocusedOptionIndex(event, event.processedOption.index);
352
370
  }
353
371
  },
354
372
  onOptionSelect(event, processedOption, isHide = true) {
@@ -397,7 +415,7 @@ export default {
397
415
  } else {
398
416
  const optionIndex = this.focusedOptionInfo.index !== -1 ? this.findNextOptionIndex(this.focusedOptionInfo.index) : this.clicked ? this.findFirstOptionIndex() : this.findFirstFocusedOptionIndex();
399
417
 
400
- this.changeFocusedOptionIndex(event, optionIndex);
418
+ this.changeFocusedOptionIndex(event, optionIndex, true);
401
419
  }
402
420
 
403
421
  event.preventDefault();
@@ -416,7 +434,7 @@ export default {
416
434
  } else {
417
435
  const optionIndex = this.focusedOptionInfo.index !== -1 ? this.findPrevOptionIndex(this.focusedOptionInfo.index) : this.clicked ? this.findLastOptionIndex() : this.findLastFocusedOptionIndex();
418
436
 
419
- this.changeFocusedOptionIndex(event, optionIndex);
437
+ this.changeFocusedOptionIndex(event, optionIndex, true);
420
438
 
421
439
  !this.overlayVisible && this.show();
422
440
  event.preventDefault();
@@ -483,7 +501,7 @@ export default {
483
501
  const processedOption = this.visibleOptions[this.focusedOptionInfo.index];
484
502
  const grouped = this.isProccessedOptionGroup(processedOption);
485
503
 
486
- this.onOptionChange({ originalEvent: event, processedOption });
504
+ this.onOptionClick({ originalEvent: event, processedOption, preventSelection: false });
487
505
  !grouped && this.hide();
488
506
  }
489
507
  }
@@ -713,11 +731,15 @@ export default {
713
731
 
714
732
  return matched;
715
733
  },
716
- changeFocusedOptionIndex(event, index) {
734
+ changeFocusedOptionIndex(event, index, preventSelection) {
717
735
  if (this.focusedOptionInfo.index !== index) {
718
736
  this.focusedOptionInfo.index = index;
719
737
  this.scrollInView();
720
738
 
739
+ if (this.focusOnHover) {
740
+ this.onOptionClick({ originalEvent: event, processedOption: this.visibleOptions[index], isHide: false, preventSelection });
741
+ }
742
+
721
743
  if (this.selectOnFocus) {
722
744
  this.onOptionChange({ originalEvent: event, processedOption: this.visibleOptions[index], isHide: false });
723
745
  }
@@ -51,9 +51,10 @@
51
51
  :optionGroupIcon="optionGroupIcon"
52
52
  :optionGroupLabel="optionGroupLabel"
53
53
  :optionGroupChildren="optionGroupChildren"
54
- @option-change="onOptionChange"
55
- @option-focus-change="onOptionFocusChange"
56
- @option-focus-enter-change="onOptionFocusEnterChange"
54
+ :value="value"
55
+ @option-change="$emit('option-change', $event)"
56
+ @option-focus-change="$emit('option-focus-change', $event)"
57
+ @option-focus-enter-change="$emit('option-focus-enter-change', $event)"
57
58
  :pt="pt"
58
59
  :unstyled="unstyled"
59
60
  />
@@ -63,11 +64,10 @@
63
64
  </template>
64
65
 
65
66
  <script>
66
- import { isNotEmpty, resolveFieldData } from '@primeuix/utils/object';
67
+ import { equals, isNotEmpty, resolveFieldData } from '@primeuix/utils/object';
67
68
  import BaseComponent from '@primevue/core/basecomponent';
68
69
  import AngleRightIcon from '@primevue/icons/angleright';
69
70
  import Ripple from 'primevue/ripple';
70
-
71
71
  export default {
72
72
  name: 'CascadeSelectSub',
73
73
  hostName: 'CascadeSelect',
@@ -89,9 +89,9 @@ export default {
89
89
  },
90
90
  activeOptionPath: Array,
91
91
  level: Number,
92
- templates: null
92
+ templates: null,
93
+ value: null
93
94
  },
94
-
95
95
  methods: {
96
96
  getOptionId(processedOption) {
97
97
  return `${this.selectId}_${processedOption.key}`;
@@ -128,7 +128,7 @@ export default {
128
128
  return isNotEmpty(processedOption.children);
129
129
  },
130
130
  isOptionSelected(processedOption) {
131
- return !this.isOptionGroup(processedOption) && this.isOptionActive(processedOption);
131
+ return equals(this.value, processedOption?.option);
132
132
  },
133
133
  isOptionActive(processedOption) {
134
134
  return this.activeOptionPath.some((path) => path.key === processedOption.key);
@@ -148,15 +148,6 @@ export default {
148
148
  onOptionMouseMove(event, processedOption) {
149
149
  this.$emit('option-focus-change', { originalEvent: event, processedOption });
150
150
  },
151
- onOptionChange(event) {
152
- this.$emit('option-change', event);
153
- },
154
- onOptionFocusChange(event) {
155
- this.$emit('option-focus-change', event);
156
- },
157
- onOptionFocusEnterChange(event) {
158
- this.$emit('option-focus-enter-change', event);
159
- },
160
151
  containerRef(el) {
161
152
  this.container = el;
162
153
  },
@@ -7,7 +7,7 @@
7
7
  * @module cascadeselect
8
8
  *
9
9
  */
10
- import type { DefineComponent, DesignToken, EmitFn, GlobalComponentConstructor, HintedString, PassThrough } from '@primevue/core';
10
+ import type { DefineComponent, DesignToken, EmitFn, HintedString, PassThrough } from '@primevue/core';
11
11
  import type { ComponentHooks } from '@primevue/core/basecomponent';
12
12
  import type { PassThroughOptions } from 'primevue/passthrough';
13
13
  import { HTMLAttributes, InputHTMLAttributes, TransitionProps, VNode } from 'vue';
@@ -609,7 +609,7 @@ declare const CascadeSelect: DefineComponent<CascadeSelectProps, CascadeSelectSl
609
609
 
610
610
  declare module 'vue' {
611
611
  export interface GlobalComponents {
612
- CascadeSelect: GlobalComponentConstructor<CascadeSelectProps, CascadeSelectSlots, CascadeSelectEmits>;
612
+ CascadeSelect: DefineComponent<CascadeSelectProps, CascadeSelectSlots, CascadeSelectEmits>;
613
613
  }
614
614
  }
615
615
 
@@ -1,5 +1,5 @@
1
1
  import { focus, addStyle, relativePosition, getOuterWidth, absolutePosition, isTouchDevice, findSingle } from '@primeuix/utils/dom';
2
- import { resolveFieldData, isNotEmpty, isString, isPrintableCharacter, isEmpty, findLastIndex, equals } from '@primeuix/utils/object';
2
+ import { resolveFieldData, isNotEmpty, equals, isString, isPrintableCharacter, isEmpty, findLastIndex } from '@primeuix/utils/object';
3
3
  import { ZIndex } from '@primeuix/utils/zindex';
4
4
  import { UniqueComponentId, ConnectedOverlayScrollHandler } from '@primevue/core/utils';
5
5
  import AngleRightIcon from '@primevue/icons/angleright';
@@ -181,7 +181,8 @@ var script$1 = {
181
181
  },
182
182
  activeOptionPath: Array,
183
183
  level: Number,
184
- templates: null
184
+ templates: null,
185
+ value: null
185
186
  },
186
187
  methods: {
187
188
  getOptionId: function getOptionId(processedOption) {
@@ -219,7 +220,7 @@ var script$1 = {
219
220
  return isNotEmpty(processedOption.children);
220
221
  },
221
222
  isOptionSelected: function isOptionSelected(processedOption) {
222
- return !this.isOptionGroup(processedOption) && this.isOptionActive(processedOption);
223
+ return equals(this.value, processedOption === null || processedOption === void 0 ? void 0 : processedOption.option);
223
224
  },
224
225
  isOptionActive: function isOptionActive(processedOption) {
225
226
  return this.activeOptionPath.some(function (path) {
@@ -251,15 +252,6 @@ var script$1 = {
251
252
  processedOption: processedOption
252
253
  });
253
254
  },
254
- onOptionChange: function onOptionChange(event) {
255
- this.$emit('option-change', event);
256
- },
257
- onOptionFocusChange: function onOptionFocusChange(event) {
258
- this.$emit('option-focus-change', event);
259
- },
260
- onOptionFocusEnterChange: function onOptionFocusEnterChange(event) {
261
- this.$emit('option-focus-enter-change', event);
262
- },
263
255
  containerRef: function containerRef(el) {
264
256
  this.container = el;
265
257
  },
@@ -356,17 +348,30 @@ function render$1(_ctx, _cache, $props, $setup, $data, $options) {
356
348
  optionGroupIcon: $props.optionGroupIcon,
357
349
  optionGroupLabel: $props.optionGroupLabel,
358
350
  optionGroupChildren: $props.optionGroupChildren,
359
- onOptionChange: $options.onOptionChange,
360
- onOptionFocusChange: $options.onOptionFocusChange,
361
- onOptionFocusEnterChange: $options.onOptionFocusEnterChange,
351
+ value: $props.value,
352
+ onOptionChange: _cache[0] || (_cache[0] = function ($event) {
353
+ return _ctx.$emit('option-change', $event);
354
+ }),
355
+ onOptionFocusChange: _cache[1] || (_cache[1] = function ($event) {
356
+ return _ctx.$emit('option-focus-change', $event);
357
+ }),
358
+ onOptionFocusEnterChange: _cache[2] || (_cache[2] = function ($event) {
359
+ return _ctx.$emit('option-focus-enter-change', $event);
360
+ }),
362
361
  pt: _ctx.pt,
363
362
  unstyled: _ctx.unstyled
364
- }, null, 8, ["class", "selectId", "focusedOptionId", "options", "activeOptionPath", "level", "templates", "optionLabel", "optionValue", "optionDisabled", "optionGroupIcon", "optionGroupLabel", "optionGroupChildren", "onOptionChange", "onOptionFocusChange", "onOptionFocusEnterChange", "pt", "unstyled"])) : createCommentVNode("", true)], 16, _hoisted_1$1);
363
+ }, null, 8, ["class", "selectId", "focusedOptionId", "options", "activeOptionPath", "level", "templates", "optionLabel", "optionValue", "optionDisabled", "optionGroupIcon", "optionGroupLabel", "optionGroupChildren", "value", "pt", "unstyled"])) : createCommentVNode("", true)], 16, _hoisted_1$1);
365
364
  }), 128))], 16);
366
365
  }
367
366
 
368
367
  script$1.render = render$1;
369
368
 
369
+ function _typeof$1(o) { "@babel/helpers - typeof"; return _typeof$1 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof$1(o); }
370
+ function ownKeys$1(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
371
+ function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$1(Object(t), !0).forEach(function (r) { _defineProperty$1(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$1(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
372
+ function _defineProperty$1(e, r, t) { return (r = _toPropertyKey$1(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
373
+ function _toPropertyKey$1(t) { var i = _toPrimitive$1(t, "string"); return "symbol" == _typeof$1(i) ? i : i + ""; }
374
+ function _toPrimitive$1(t, r) { if ("object" != _typeof$1(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof$1(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
370
375
  var script = {
371
376
  name: 'CascadeSelect',
372
377
  "extends": script$2,
@@ -569,11 +574,8 @@ var script = {
569
574
  this.clicked = false;
570
575
  },
571
576
  onOptionChange: function onOptionChange(event) {
572
- var isSelectable = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
573
- var originalEvent = event.originalEvent,
574
- processedOption = event.processedOption,
575
- isFocus = event.isFocus,
576
- isHide = event.isHide;
577
+ var processedOption = event.processedOption,
578
+ type = event.type;
577
579
  if (isEmpty(processedOption)) return;
578
580
  var index = processedOption.index,
579
581
  key = processedOption.key,
@@ -581,56 +583,81 @@ var script = {
581
583
  parentKey = processedOption.parentKey,
582
584
  children = processedOption.children;
583
585
  var grouped = isNotEmpty(children);
584
- var root = isEmpty(processedOption.parent);
586
+ var activeOptionPath = this.activeOptionPath.filter(function (p) {
587
+ return p.parentKey !== parentKey && p.parentKey !== key;
588
+ });
589
+ this.focusedOptionInfo = {
590
+ index: index,
591
+ level: level,
592
+ parentKey: parentKey
593
+ };
594
+ if (type == 'hover' && this.queryMatches) {
595
+ return;
596
+ }
597
+ if (grouped) {
598
+ activeOptionPath.push(processedOption);
599
+ }
600
+ this.activeOptionPath = activeOptionPath;
601
+ },
602
+ onOptionClick: function onOptionClick(event) {
603
+ var originalEvent = event.originalEvent,
604
+ processedOption = event.processedOption,
605
+ isFocus = event.isFocus,
606
+ isHide = event.isHide,
607
+ preventSelection = event.preventSelection;
608
+ var index = processedOption.index,
609
+ key = processedOption.key,
610
+ level = processedOption.level,
611
+ parentKey = processedOption.parentKey;
612
+ var grouped = this.isProccessedOptionGroup(processedOption);
585
613
  var selected = this.isSelected(processedOption);
586
614
  if (selected) {
587
- this.focusedOptionInfo = {
588
- index: index,
589
- level: level,
590
- parentKey: parentKey
591
- };
592
615
  this.activeOptionPath = this.activeOptionPath.filter(function (p) {
593
616
  return key !== p.key && key.startsWith(p.key);
594
617
  });
595
- this.dirty = !root;
596
- } else {
597
- var activeOptionPath = this.activeOptionPath.filter(function (p) {
598
- return p.parentKey !== parentKey && p.parentKey !== key;
599
- });
600
- activeOptionPath.push(processedOption);
601
618
  this.focusedOptionInfo = {
602
619
  index: index,
603
620
  level: level,
604
621
  parentKey: parentKey
605
622
  };
606
- this.activeOptionPath = activeOptionPath;
607
- }
608
- if (grouped) {
609
- this.dirty = true;
610
- this.onOptionGroupSelect(originalEvent, processedOption);
611
623
  } else {
612
- isSelectable && this.onOptionSelect(originalEvent, processedOption, isHide);
624
+ if (grouped) {
625
+ this.onOptionChange(event);
626
+ this.onOptionGroupSelect(originalEvent, processedOption);
627
+ } else {
628
+ var activeOptionPath = this.activeOptionPath.filter(function (p) {
629
+ return p.parentKey !== parentKey;
630
+ });
631
+ activeOptionPath.push(processedOption);
632
+ this.focusedOptionInfo = {
633
+ index: index,
634
+ level: level,
635
+ parentKey: parentKey
636
+ };
637
+ if (!preventSelection || (processedOption === null || processedOption === void 0 ? void 0 : processedOption.children.length) !== 0) {
638
+ this.activeOptionPath = activeOptionPath;
639
+ this.onOptionSelect(originalEvent, processedOption, isHide);
640
+ }
641
+ }
613
642
  }
614
643
  isFocus && focus(this.$refs.focusInput);
615
644
  },
616
- onOptionFocusMoveChange: function onOptionFocusMoveChange(event) {
645
+ onOptionMouseEnter: function onOptionMouseEnter(event) {
617
646
  if (this.focusOnHover) {
618
- var originalEvent = event.originalEvent,
619
- processedOption = event.processedOption;
620
- var index = processedOption.index,
621
- level = processedOption.level,
622
- parentKey = processedOption.parentKey;
623
- this.focusedOptionInfo = {
624
- index: index,
625
- level: level,
626
- parentKey: parentKey
627
- };
628
- this.changeFocusedOptionIndex(originalEvent, index);
647
+ if (this.dirty || !this.dirty && isNotEmpty(this.modelValue)) {
648
+ this.onOptionChange(_objectSpread$1(_objectSpread$1({}, event), {}, {
649
+ type: 'hover'
650
+ }));
651
+ } else if (!this.dirty && event.processedOption.level === 0) {
652
+ this.onOptionClick(_objectSpread$1(_objectSpread$1({}, event), {}, {
653
+ type: 'hover'
654
+ }));
655
+ }
629
656
  }
630
657
  },
631
- onOptionFocusChangeEnter: function onOptionFocusChangeEnter(event) {
632
- if (this.dirty) {
633
- this.onOptionChange(event, false);
658
+ onOptionMouseMove: function onOptionMouseMove(event) {
659
+ if (this.focused && this.focusOnHover) {
660
+ this.changeFocusedOptionIndex(event, event.processedOption.index);
634
661
  }
635
662
  },
636
663
  onOptionSelect: function onOptionSelect(event, processedOption) {
@@ -678,7 +705,7 @@ var script = {
678
705
  this.show();
679
706
  } else {
680
707
  var optionIndex = this.focusedOptionInfo.index !== -1 ? this.findNextOptionIndex(this.focusedOptionInfo.index) : this.clicked ? this.findFirstOptionIndex() : this.findFirstFocusedOptionIndex();
681
- this.changeFocusedOptionIndex(event, optionIndex);
708
+ this.changeFocusedOptionIndex(event, optionIndex, true);
682
709
  }
683
710
  event.preventDefault();
684
711
  },
@@ -696,7 +723,7 @@ var script = {
696
723
  event.preventDefault();
697
724
  } else {
698
725
  var optionIndex = this.focusedOptionInfo.index !== -1 ? this.findPrevOptionIndex(this.focusedOptionInfo.index) : this.clicked ? this.findLastOptionIndex() : this.findLastFocusedOptionIndex();
699
- this.changeFocusedOptionIndex(event, optionIndex);
726
+ this.changeFocusedOptionIndex(event, optionIndex, true);
700
727
  !this.overlayVisible && this.show();
701
728
  event.preventDefault();
702
729
  }
@@ -769,9 +796,10 @@ var script = {
769
796
  if (this.focusedOptionInfo.index !== -1) {
770
797
  var processedOption = this.visibleOptions[this.focusedOptionInfo.index];
771
798
  var grouped = this.isProccessedOptionGroup(processedOption);
772
- this.onOptionChange({
799
+ this.onOptionClick({
773
800
  originalEvent: event,
774
- processedOption: processedOption
801
+ processedOption: processedOption,
802
+ preventSelection: false
775
803
  });
776
804
  !grouped && this.hide();
777
805
  }
@@ -1009,10 +1037,18 @@ var script = {
1009
1037
  }, 500);
1010
1038
  return matched;
1011
1039
  },
1012
- changeFocusedOptionIndex: function changeFocusedOptionIndex(event, index) {
1040
+ changeFocusedOptionIndex: function changeFocusedOptionIndex(event, index, preventSelection) {
1013
1041
  if (this.focusedOptionInfo.index !== index) {
1014
1042
  this.focusedOptionInfo.index = index;
1015
1043
  this.scrollInView();
1044
+ if (this.focusOnHover) {
1045
+ this.onOptionClick({
1046
+ originalEvent: event,
1047
+ processedOption: this.visibleOptions[index],
1048
+ isHide: false,
1049
+ preventSelection: preventSelection
1050
+ });
1051
+ }
1016
1052
  if (this.selectOnFocus) {
1017
1053
  this.onOptionChange({
1018
1054
  originalEvent: event,
@@ -1277,12 +1313,13 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
1277
1313
  optionGroupIcon: _ctx.optionGroupIcon,
1278
1314
  optionGroupLabel: _ctx.optionGroupLabel,
1279
1315
  optionGroupChildren: _ctx.optionGroupChildren,
1280
- onOptionChange: $options.onOptionChange,
1281
- onOptionFocusMoveChange: $options.onOptionFocusMoveChange,
1282
- onOptionFocusEnterChange: $options.onOptionFocusChangeEnter,
1316
+ value: _ctx.modelValue,
1317
+ onOptionChange: $options.onOptionClick,
1318
+ onOptionFocusChange: $options.onOptionMouseMove,
1319
+ onOptionFocusEnterChange: $options.onOptionMouseEnter,
1283
1320
  pt: _ctx.pt,
1284
1321
  unstyled: _ctx.unstyled
1285
- }, null, 8, ["id", "selectId", "focusedOptionId", "options", "activeOptionPath", "templates", "optionLabel", "optionValue", "optionDisabled", "optionGroupIcon", "optionGroupLabel", "optionGroupChildren", "onOptionChange", "onOptionFocusMoveChange", "onOptionFocusEnterChange", "pt", "unstyled"])], 16), createElementVNode("span", mergeProps({
1322
+ }, null, 8, ["id", "selectId", "focusedOptionId", "options", "activeOptionPath", "templates", "optionLabel", "optionValue", "optionDisabled", "optionGroupIcon", "optionGroupLabel", "optionGroupChildren", "value", "onOptionChange", "onOptionFocusChange", "onOptionFocusEnterChange", "pt", "unstyled"])], 16), createElementVNode("span", mergeProps({
1286
1323
  role: "status",
1287
1324
  "aria-live": "polite",
1288
1325
  "class": "p-hidden-accessible"