@haiilo/catalyst 14.5.1 → 14.5.2

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 (52) hide show
  1. package/dist/catalyst/catalyst.esm.js +1 -1
  2. package/dist/catalyst/p-0fec1fc5.entry.js +10 -0
  3. package/dist/catalyst/p-0fec1fc5.entry.js.map +1 -0
  4. package/dist/cjs/cat-alert_32.cjs.entry.js +109 -80
  5. package/dist/cjs/catalyst.cjs.js +1 -1
  6. package/dist/cjs/loader.cjs.js +1 -1
  7. package/dist/collection/collection-manifest.json +1 -1
  8. package/dist/collection/components/cat-alert/cat-alert.js +1 -1
  9. package/dist/collection/components/cat-badge/cat-badge.js +1 -1
  10. package/dist/collection/components/cat-button-group/cat-button-group.js +1 -1
  11. package/dist/collection/components/cat-card/cat-card.js +1 -1
  12. package/dist/collection/components/cat-checkbox/cat-checkbox.js +2 -2
  13. package/dist/collection/components/cat-date/cat-date.js +2 -2
  14. package/dist/collection/components/cat-date-inline/cat-date-inline.js +4 -4
  15. package/dist/collection/components/cat-datepicker/cat-datepicker.js +3 -3
  16. package/dist/collection/components/cat-datepicker-inline/cat-datepicker-inline.js +2 -2
  17. package/dist/collection/components/cat-dropdown/cat-dropdown.js +29 -26
  18. package/dist/collection/components/cat-dropdown/cat-dropdown.js.map +1 -1
  19. package/dist/collection/components/cat-form-group/cat-form-group.js +1 -1
  20. package/dist/collection/components/cat-icon/cat-icon.js +1 -1
  21. package/dist/collection/components/cat-menu/cat-menu.js +5 -4
  22. package/dist/collection/components/cat-menu/cat-menu.js.map +1 -1
  23. package/dist/collection/components/cat-menu-item/cat-menu-item.js +37 -4
  24. package/dist/collection/components/cat-menu-item/cat-menu-item.js.map +1 -1
  25. package/dist/components/cat-alert.js +1 -1
  26. package/dist/components/cat-badge.js +1 -1
  27. package/dist/components/cat-button-group.js +1 -1
  28. package/dist/components/cat-card.js +1 -1
  29. package/dist/components/cat-checkbox2.js +2 -2
  30. package/dist/components/cat-date-inline2.js +4 -4
  31. package/dist/components/cat-date.js +2 -2
  32. package/dist/components/cat-datepicker-inline.js +2 -2
  33. package/dist/components/cat-datepicker.js +3 -3
  34. package/dist/components/cat-dropdown2.js +30 -9
  35. package/dist/components/cat-dropdown2.js.map +1 -1
  36. package/dist/components/cat-form-group.js +1 -1
  37. package/dist/components/cat-icon2.js +1 -1
  38. package/dist/components/cat-menu-item2.js +10 -5
  39. package/dist/components/cat-menu-item2.js.map +1 -1
  40. package/dist/components/cat-menu2.js +5 -5
  41. package/dist/components/cat-menu2.js.map +1 -1
  42. package/dist/components/floating-ui.dom.js +49 -45
  43. package/dist/components/floating-ui.dom.js.map +1 -1
  44. package/dist/esm/cat-alert_32.entry.js +109 -80
  45. package/dist/esm/catalyst.js +1 -1
  46. package/dist/esm/loader.js +1 -1
  47. package/dist/types/components/cat-dropdown/cat-dropdown.d.ts +10 -3
  48. package/dist/types/components/cat-menu-item/cat-menu-item.d.ts +3 -1
  49. package/dist/types/components.d.ts +8 -0
  50. package/package.json +2 -4
  51. package/dist/catalyst/p-c04eb2d3.entry.js +0 -10
  52. package/dist/catalyst/p-c04eb2d3.entry.js.map +0 -1
@@ -1116,6 +1116,9 @@ const CatDropdown = /*@__PURE__*/ proxyCustomElement(class CatDropdown extends H
1116
1116
  * @internal
1117
1117
  */
1118
1118
  this.focusTrap = true;
1119
+ this.boundWindowClickListener = this.windowClickListener.bind(this);
1120
+ this.boundWindowMousedownListener = this.windowMousedownListener.bind(this);
1121
+ this.boundWindowTouchStartListener = this.windowTouchStartListener.bind(this);
1119
1122
  }
1120
1123
  /**
1121
1124
  * Whether the dropdown is open.
@@ -1137,6 +1140,7 @@ const CatDropdown = /*@__PURE__*/ proxyCustomElement(class CatDropdown extends H
1137
1140
  path.includes(this.content) &&
1138
1141
  // check if click was not on a trigger for a sub-dropdown
1139
1142
  event.target?.slot !== 'trigger' &&
1143
+ !event.target.subMenu &&
1140
1144
  // check if click was not an element marked with data-dropdown-no-close
1141
1145
  !path.slice(0, path.indexOf(this.content)).find(el => this.hasAttribute(el, 'data-dropdown-no-close'))) {
1142
1146
  this.close();
@@ -1147,13 +1151,13 @@ const CatDropdown = /*@__PURE__*/ proxyCustomElement(class CatDropdown extends H
1147
1151
  this.close();
1148
1152
  }
1149
1153
  }
1150
- globalClickHandler(event) {
1154
+ windowClickListener(event) {
1151
1155
  this.handleClickOutside(event);
1152
1156
  }
1153
- globalMouseDownHandler(event) {
1157
+ windowMousedownListener(event) {
1154
1158
  this.handleClickOutside(event);
1155
1159
  }
1156
- globalTouchStartHandler(event) {
1160
+ windowTouchStartListener(event) {
1157
1161
  this.handleClickOutside(event);
1158
1162
  }
1159
1163
  /**
@@ -1191,6 +1195,8 @@ const CatDropdown = /*@__PURE__*/ proxyCustomElement(class CatDropdown extends H
1191
1195
  : createFocusTrap(this.content, {
1192
1196
  tabbableOptions: this.tabbableOptions,
1193
1197
  allowOutsideClick: true,
1198
+ clickOutsideDeactivates: event => this.shouldCloseByClickEvent(event),
1199
+ onPostDeactivate: () => this.close(),
1194
1200
  onPostActivate: () => this.catOpen.emit(),
1195
1201
  setReturnFocus: elem => (!this.isFocusVisible || this.noReturnFocus ? false : this.trigger || elem),
1196
1202
  isKeyForward: event => {
@@ -1216,6 +1222,7 @@ const CatDropdown = /*@__PURE__*/ proxyCustomElement(class CatDropdown extends H
1216
1222
  this.trap.activate();
1217
1223
  }
1218
1224
  else {
1225
+ this.addListeners();
1219
1226
  this.catOpen.emit();
1220
1227
  }
1221
1228
  });
@@ -1234,6 +1241,7 @@ const CatDropdown = /*@__PURE__*/ proxyCustomElement(class CatDropdown extends H
1234
1241
  if (shouldReturnFocus) {
1235
1242
  this.trigger?.focus();
1236
1243
  }
1244
+ this.removeListeners();
1237
1245
  // give CSS transition time to apply
1238
1246
  setTimeout(() => {
1239
1247
  this._isOpen = false;
@@ -1258,16 +1266,29 @@ const CatDropdown = /*@__PURE__*/ proxyCustomElement(class CatDropdown extends H
1258
1266
  this.cleanupFloatingUi = undefined;
1259
1267
  }
1260
1268
  render() {
1261
- return (h(Host, { key: 'b3cd898551dc3e6d5396db1a4a14bc97cf4a2024' }, h("slot", { key: '6875cfad353891deb54ebcd5155d7ea466384131', name: "anchor", ref: el => (this.anchorSlot = el) }), h("slot", { key: '93fdda4c49a7a956f72548699200feb309779081', name: "trigger", ref: el => (this.triggerSlot = el) }), h("div", { key: '13a68b5f706e61e87599c463e58f1bf932b2d261', id: this.contentId, class: { content: true, 'overflow-auto': !this.overflow, justified: this.justify, aligned: !this.justify }, ref: el => (this.content = el) }, h("slot", { key: '06357a4a970241938900853d78c88427c6a9e69a', name: "content" }))));
1269
+ return (h(Host, { key: 'bd6c2271fbd5a3f9222cb9eb8c59d7113dc72c7a' }, h("slot", { key: '26b1d2b753fffa0f91c8ee505209c46880e9233b', name: "anchor", ref: el => (this.anchorSlot = el) }), h("slot", { key: 'ac3b213022083bdb89edf4583cc216a5308bb1d2', name: "trigger", ref: el => (this.triggerSlot = el) }), h("div", { key: 'c4849c420a3e248bc7192db3a059e3372b7612fb', id: this.contentId, class: { content: true, 'overflow-auto': !this.overflow, justified: this.justify, aligned: !this.justify }, ref: el => (this.content = el) }, h("slot", { key: '1bbcaa8a86c2726e61aff6236e01b3f4ac6004e9', name: "content" }))));
1270
+ }
1271
+ addListeners() {
1272
+ window.addEventListener('click', this.boundWindowClickListener);
1273
+ window.addEventListener('mousedown', this.boundWindowMousedownListener);
1274
+ window.addEventListener('touchstart', this.boundWindowTouchStartListener);
1275
+ }
1276
+ removeListeners() {
1277
+ window.removeEventListener('click', this.boundWindowClickListener);
1278
+ window.removeEventListener('mousedown', this.boundWindowMousedownListener);
1279
+ window.removeEventListener('touchstart', this.boundWindowTouchStartListener);
1262
1280
  }
1263
1281
  handleClickOutside(event) {
1264
- if (!this.noAutoClose &&
1282
+ if (this.shouldCloseByClickEvent(event)) {
1283
+ this.close();
1284
+ }
1285
+ }
1286
+ shouldCloseByClickEvent(event) {
1287
+ return (!this.noAutoClose &&
1265
1288
  // check if click was outside of the dropdown content
1266
1289
  !event.composedPath().includes(this.content) &&
1267
1290
  // check if click was not on an element marked with data-dropdown-no-close
1268
- !event.composedPath().find(el => this.hasAttribute(el, 'data-dropdown-no-close'))) {
1269
- this.close();
1270
- }
1291
+ !event.composedPath().find(el => this.hasAttribute(el, 'data-dropdown-no-close')));
1271
1292
  }
1272
1293
  get contentId() {
1273
1294
  return `cat-dropdown-${this.id}`;
@@ -1386,7 +1407,7 @@ const CatDropdown = /*@__PURE__*/ proxyCustomElement(class CatDropdown extends H
1386
1407
  "toggle": [64],
1387
1408
  "open": [64],
1388
1409
  "close": [64]
1389
- }, [[0, "catClick", "clickHandler"], [0, "keydown", "keydownHandler"], [6, "click", "globalClickHandler"], [7, "mousedown", "globalMouseDownHandler"], [6, "touchstart", "globalTouchStartHandler"]]]);
1410
+ }, [[0, "catClick", "clickHandler"], [0, "keydown", "keydownHandler"]]]);
1390
1411
  CatDropdown.OFFSET = 4;
1391
1412
  function defineCustomElement() {
1392
1413
  if (typeof customElements === "undefined") {