@haiilo/catalyst 14.4.0 → 14.5.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 (109) hide show
  1. package/dist/catalyst/catalyst.css +15 -4
  2. package/dist/catalyst/catalyst.esm.js +1 -1
  3. package/dist/catalyst/{p-CFGROHMy.js → p-7uZgmxXB.js} +2 -2
  4. package/dist/catalyst/p-7uZgmxXB.js.map +1 -0
  5. package/dist/catalyst/p-c04eb2d3.entry.js +10 -0
  6. package/dist/catalyst/p-c04eb2d3.entry.js.map +1 -0
  7. package/dist/catalyst/scss/core/_nav.scss +2 -1
  8. package/dist/catalyst/scss/core/sanitize-overwrite.scss +3 -0
  9. package/dist/catalyst/scss/index.scss +1 -0
  10. package/dist/cjs/{cat-alert_30.cjs.entry.js → cat-alert_32.cjs.entry.js} +348 -102
  11. package/dist/cjs/catalyst.cjs.js +2 -2
  12. package/dist/cjs/{index-B8-TCsLD.js → index-Ddad39qn.js} +7 -4
  13. package/dist/cjs/index-Ddad39qn.js.map +1 -0
  14. package/dist/cjs/loader.cjs.js +2 -2
  15. package/dist/collection/collection-manifest.json +3 -1
  16. package/dist/collection/components/cat-alert/cat-alert.js +1 -1
  17. package/dist/collection/components/cat-badge/cat-badge.js +1 -1
  18. package/dist/collection/components/cat-button/cat-button.css +13 -2
  19. package/dist/collection/components/cat-button-group/cat-button-group.js +1 -1
  20. package/dist/collection/components/cat-card/cat-card.js +1 -1
  21. package/dist/collection/components/cat-checkbox/cat-checkbox.js +2 -2
  22. package/dist/collection/components/cat-date/cat-date.js +2 -2
  23. package/dist/collection/components/cat-date-inline/cat-date-inline.js +4 -4
  24. package/dist/collection/components/cat-datepicker/cat-datepicker.js +3 -3
  25. package/dist/collection/components/cat-datepicker-inline/cat-datepicker-inline.js +2 -2
  26. package/dist/collection/components/cat-dropdown/cat-dropdown.js +133 -47
  27. package/dist/collection/components/cat-dropdown/cat-dropdown.js.map +1 -1
  28. package/dist/collection/components/cat-menu/cat-menu.css +9 -0
  29. package/dist/collection/components/cat-menu/cat-menu.js +652 -0
  30. package/dist/collection/components/cat-menu/cat-menu.js.map +1 -0
  31. package/dist/collection/components/cat-menu-item/cat-menu-item.js +387 -0
  32. package/dist/collection/components/cat-menu-item/cat-menu-item.js.map +1 -0
  33. package/dist/collection/components/cat-pagination/cat-pagination.js +2 -2
  34. package/dist/collection/components/cat-radio/cat-radio.js +2 -2
  35. package/dist/collection/components/cat-radio-group/cat-radio-group.js +1 -1
  36. package/dist/collection/components/cat-scrollable/cat-scrollable.js +3 -3
  37. package/dist/collection/components/cat-select/cat-select.js +14 -18
  38. package/dist/collection/components/cat-select/cat-select.js.map +1 -1
  39. package/dist/collection/components/cat-select-demo/cat-select-demo.js +1 -1
  40. package/dist/collection/components/cat-skeleton/cat-skeleton.js +1 -1
  41. package/dist/collection/components/cat-spinner/cat-spinner.js +2 -2
  42. package/dist/collection/components/cat-tab/cat-tab.js +1 -1
  43. package/dist/collection/components/cat-tabs/cat-tabs.js +1 -1
  44. package/dist/collection/components/cat-tag/cat-tag.js +1 -1
  45. package/dist/collection/components/cat-textarea/cat-textarea.js +3 -3
  46. package/dist/collection/components/cat-time/cat-time.css +0 -9
  47. package/dist/collection/components/cat-time/cat-time.js +4 -5
  48. package/dist/collection/components/cat-time/cat-time.js.map +1 -1
  49. package/dist/collection/components/cat-toggle/cat-toggle.js +2 -2
  50. package/dist/collection/index.js.map +1 -1
  51. package/dist/collection/scss/core/_nav.scss +2 -1
  52. package/dist/collection/scss/core/sanitize-overwrite.scss +3 -0
  53. package/dist/collection/scss/index.scss +1 -0
  54. package/dist/components/cat-alert.js +1 -1
  55. package/dist/components/cat-badge.js +1 -1
  56. package/dist/components/cat-button-group.js +1 -1
  57. package/dist/components/cat-button2.js +1 -1
  58. package/dist/components/cat-button2.js.map +1 -1
  59. package/dist/components/cat-card.js +1 -1
  60. package/dist/components/cat-checkbox2.js +2 -2
  61. package/dist/components/cat-date-inline2.js +4 -4
  62. package/dist/components/cat-date.js +2 -2
  63. package/dist/components/cat-datepicker-inline.js +2 -2
  64. package/dist/components/cat-datepicker.js +3 -3
  65. package/dist/components/cat-dropdown2.js +77 -44
  66. package/dist/components/cat-dropdown2.js.map +1 -1
  67. package/dist/components/cat-menu-item.d.ts +11 -0
  68. package/dist/components/cat-menu-item.js +9 -0
  69. package/dist/components/cat-menu-item.js.map +1 -0
  70. package/dist/components/cat-menu-item2.js +111 -0
  71. package/dist/components/cat-menu-item2.js.map +1 -0
  72. package/dist/components/cat-menu.d.ts +11 -0
  73. package/dist/components/cat-menu.js +9 -0
  74. package/dist/components/cat-menu.js.map +1 -0
  75. package/dist/components/cat-menu2.js +227 -0
  76. package/dist/components/cat-menu2.js.map +1 -0
  77. package/dist/components/cat-pagination.js +2 -2
  78. package/dist/components/cat-radio-group.js +1 -1
  79. package/dist/components/cat-radio.js +2 -2
  80. package/dist/components/cat-scrollable2.js +3 -3
  81. package/dist/components/cat-select-demo.js +1 -1
  82. package/dist/components/cat-select2.js +5 -5
  83. package/dist/components/cat-select2.js.map +1 -1
  84. package/dist/components/cat-skeleton2.js +1 -1
  85. package/dist/components/cat-spinner2.js +2 -2
  86. package/dist/components/cat-tab.js +1 -1
  87. package/dist/components/cat-tabs.js +1 -1
  88. package/dist/components/cat-tag.js +1 -1
  89. package/dist/components/cat-textarea.js +3 -3
  90. package/dist/components/cat-time.js +25 -14
  91. package/dist/components/cat-time.js.map +1 -1
  92. package/dist/components/cat-toggle.js +2 -2
  93. package/dist/esm/{cat-alert_30.entry.js → cat-alert_32.entry.js} +347 -103
  94. package/dist/esm/catalyst.js +3 -3
  95. package/dist/esm/{index-CFGROHMy.js → index-7uZgmxXB.js} +7 -4
  96. package/dist/esm/index-7uZgmxXB.js.map +1 -0
  97. package/dist/esm/loader.js +3 -3
  98. package/dist/types/components/cat-dropdown/cat-dropdown.d.ts +17 -2
  99. package/dist/types/components/cat-menu/cat-menu.d.ts +124 -0
  100. package/dist/types/components/cat-menu-item/cat-menu-item.d.ts +80 -0
  101. package/dist/types/components/cat-select/cat-select.d.ts +3 -2
  102. package/dist/types/components.d.ts +416 -9
  103. package/dist/types/index.d.ts +2 -1
  104. package/package.json +2 -2
  105. package/dist/catalyst/p-76436f4e.entry.js +0 -10
  106. package/dist/catalyst/p-76436f4e.entry.js.map +0 -1
  107. package/dist/catalyst/p-CFGROHMy.js.map +0 -1
  108. package/dist/cjs/index-B8-TCsLD.js.map +0 -1
  109. package/dist/esm/index-CFGROHMy.js.map +0 -1
@@ -139,7 +139,7 @@ const CatDatepickerFlat = /*@__PURE__*/ proxyCustomElement(class CatDatepickerFl
139
139
  }
140
140
  render() {
141
141
  return [
142
- h("cat-input", { key: 'ef465dc2e84455154dde17a4ebd1e742a5c3cd83', ref: el => (this._input = el), requiredMarker: this.requiredMarker, horizontal: this.horizontal ?? this.fallbackHorizontal, autoComplete: this.autoComplete, clearable: this.clearable, disabled: this.disabled, hint: this.hint, icon: this.icon, iconRight: this.iconRight, identifier: this.identifier, label: this.label, labelHidden: this.labelHidden, name: this.name, placeholder: this.placeholder, textPrefix: this.textPrefix, textSuffix: this.textSuffix, readonly: this.readonly, required: this.required, value: this.value, errors: this.errors, errorUpdate: this.errorUpdate, nativeAttributes: this.nativeAttributes, onCatChange: e => {
142
+ h("cat-input", { key: 'd81f695ecf9eb3dd175a14070811b8ca99e13f67', ref: el => (this._input = el), requiredMarker: this.requiredMarker, horizontal: this.horizontal ?? this.fallbackHorizontal, autoComplete: this.autoComplete, clearable: this.clearable, disabled: this.disabled, hint: this.hint, icon: this.icon, iconRight: this.iconRight, identifier: this.identifier, label: this.label, labelHidden: this.labelHidden, name: this.name, placeholder: this.placeholder, textPrefix: this.textPrefix, textSuffix: this.textSuffix, readonly: this.readonly, required: this.required, value: this.value, errors: this.errors, errorUpdate: this.errorUpdate, nativeAttributes: this.nativeAttributes, onCatChange: e => {
143
143
  e.stopPropagation();
144
144
  this.value = e.detail || undefined;
145
145
  }, onCatFocus: e => {
@@ -148,8 +148,8 @@ const CatDatepickerFlat = /*@__PURE__*/ proxyCustomElement(class CatDatepickerFl
148
148
  }, onCatBlur: e => {
149
149
  e.stopPropagation();
150
150
  this.catBlur.emit(e.detail);
151
- } }, this.hasSlottedLabel && (h("span", { key: '99fdcacd96958d6f8f991a5fa539ee10d93918cd', slot: "label" }, h("slot", { key: '361f7fcd45fe913f1187aea3886831681272198a', name: "label" }))), this.hasSlottedHint && (h("span", { key: 'd063e6c5064c6e35781965c6fdfe792adcaf45cd', slot: "hint" }, h("slot", { key: '6f0bfa21a7c8fab7520edca8daa116376dbc2d30', name: "hint" })))),
152
- h("div", { key: '1806da8cb2acf11efd58d94d24b963d69ab08923', ref: el => (this._calendarWrapper = el), class: "datepicker-wrapper" })
151
+ } }, this.hasSlottedLabel && (h("span", { key: '41f0dfcbe0a7ab562a80416a109ee6283d602147', slot: "label" }, h("slot", { key: '4148dec98c036b3f7d604b16c05dfed648ec16a3', name: "label" }))), this.hasSlottedHint && (h("span", { key: '8181253f8adadc606f0d66abe5bad5a85b7a0f7f', slot: "hint" }, h("slot", { key: 'c6807aed385298a19d67e1f2652de82473ea6f16', name: "hint" })))),
152
+ h("div", { key: '8b0f02c5f6cf61ad89dccd831937649c6740035c', ref: el => (this._calendarWrapper = el), class: "datepicker-wrapper" })
153
153
  ];
154
154
  }
155
155
  initDatepicker(input) {
@@ -1056,12 +1056,13 @@ const CatDropdown = /*@__PURE__*/ proxyCustomElement(class CatDropdown extends H
1056
1056
  this.catClose = createEvent(this, "catClose", 7);
1057
1057
  this.id = nextUniqueId++;
1058
1058
  this._isOpen = false;
1059
+ this.tabbableOptions = { getShadowRoot: true };
1059
1060
  /**
1060
1061
  * Tracking the origin of opening the dropdown and specify if initial focus should be set.
1061
1062
  * Currently we set it only when the origin is keyboard.
1062
1063
  * We might not need to track this in future when focus-visible support is improved across browsers
1063
1064
  */
1064
- this.hasInitialFocus = false;
1065
+ this.isFocusVisible = false;
1065
1066
  /**
1066
1067
  * The placement of the dropdown.
1067
1068
  */
@@ -1078,6 +1079,7 @@ const CatDropdown = /*@__PURE__*/ proxyCustomElement(class CatDropdown extends H
1078
1079
  this.noAutoClose = false;
1079
1080
  /**
1080
1081
  * Do not navigate focus inside the dropdown via vertical arrow keys.
1082
+ * @deprecated use cat-menu
1081
1083
  */
1082
1084
  this.arrowNavigation = 'vertical';
1083
1085
  /**
@@ -1100,6 +1102,7 @@ const CatDropdown = /*@__PURE__*/ proxyCustomElement(class CatDropdown extends H
1100
1102
  this.noInitialFocus = false;
1101
1103
  /**
1102
1104
  * Trigger element will not receive focus when dropdown is closed.
1105
+ * Please use this property carefully, consider using cat-menu over using this property
1103
1106
  */
1104
1107
  this.noReturnFocus = false;
1105
1108
  /**
@@ -1107,6 +1110,12 @@ const CatDropdown = /*@__PURE__*/ proxyCustomElement(class CatDropdown extends H
1107
1110
  * Can be useful when trigger is rendered dynamically.
1108
1111
  */
1109
1112
  this.delayedTriggerInit = false;
1113
+ /**
1114
+ * Whether the focus should be trapped inside dropdown popup.
1115
+ * Use it only when the dropdown popup content has role dialog.
1116
+ * @internal
1117
+ */
1118
+ this.focusTrap = true;
1110
1119
  }
1111
1120
  /**
1112
1121
  * Whether the dropdown is open.
@@ -1117,7 +1126,7 @@ const CatDropdown = /*@__PURE__*/ proxyCustomElement(class CatDropdown extends H
1117
1126
  }
1118
1127
  clickHandler(event) {
1119
1128
  if (!this.trigger && this.delayedTriggerInit) {
1120
- this.hasInitialFocus = this.isEventOriginFromKeyboard(event.detail);
1129
+ this.isFocusVisible = this.isEventOriginFromKeyboard(event.detail);
1121
1130
  this.initTrigger();
1122
1131
  this.toggle();
1123
1132
  }
@@ -1133,6 +1142,20 @@ const CatDropdown = /*@__PURE__*/ proxyCustomElement(class CatDropdown extends H
1133
1142
  this.close();
1134
1143
  }
1135
1144
  }
1145
+ keydownHandler(event) {
1146
+ if (this.isOpen && event.key === 'Escape') {
1147
+ this.close();
1148
+ }
1149
+ }
1150
+ globalClickHandler(event) {
1151
+ this.handleClickOutside(event);
1152
+ }
1153
+ globalMouseDownHandler(event) {
1154
+ this.handleClickOutside(event);
1155
+ }
1156
+ globalTouchStartHandler(event) {
1157
+ this.handleClickOutside(event);
1158
+ }
1136
1159
  /**
1137
1160
  * Toggles the dropdown.
1138
1161
  */
@@ -1152,58 +1175,55 @@ const CatDropdown = /*@__PURE__*/ proxyCustomElement(class CatDropdown extends H
1152
1175
  }
1153
1176
  this._isOpen = null;
1154
1177
  this.content.style.display = 'block';
1155
- this.hasInitialFocus = isFocusVisible ?? this.hasInitialFocus;
1178
+ this.isFocusVisible = isFocusVisible ?? this.isFocusVisible;
1156
1179
  const trigger = this.anchor || this.trigger;
1157
1180
  if (trigger) {
1158
1181
  this.cleanupFloatingUi = autoUpdate(trigger, this.content, () => this.update(trigger));
1159
1182
  }
1160
1183
  // give CSS transition time to apply
1161
- setTimeout(() => {
1184
+ requestAnimationFrame(() => {
1162
1185
  this._isOpen = true;
1163
1186
  this.content.classList.add('show');
1164
1187
  this.trigger?.setAttribute('aria-expanded', 'true');
1165
- this.trap = this.trap
1166
- ? this.trap.updateContainerElements(this.content)
1167
- : createFocusTrap(this.content, {
1168
- tabbableOptions: {
1169
- getShadowRoot: true
1170
- },
1171
- allowOutsideClick: true,
1172
- clickOutsideDeactivates: event => !this.noAutoClose &&
1173
- // check if click was outside of the dropdown content
1174
- !event.composedPath().includes(this.content) &&
1175
- // check if click was not on an element marked with data-dropdown-no-close
1176
- !event.composedPath().find(el => this.hasAttribute(el, 'data-dropdown-no-close')),
1177
- onPostDeactivate: () => this.close(),
1178
- onPostActivate: () => this.catOpen.emit(),
1179
- setReturnFocus: elem => (this.noReturnFocus ? false : this.trigger || elem),
1180
- isKeyForward: event => {
1181
- if ((this.arrowNavigation === 'horizontal' && event.key === 'ArrowRight') ||
1182
- (this.arrowNavigation === 'vertical' && event.key === 'ArrowDown')) {
1183
- event.preventDefault();
1184
- return true;
1185
- }
1186
- return event.key === 'Tab';
1187
- },
1188
- isKeyBackward: event => {
1189
- if ((this.arrowNavigation === 'horizontal' && event.key === 'ArrowLeft') ||
1190
- (this.arrowNavigation === 'vertical' && event.key === 'ArrowUp')) {
1191
- event.preventDefault();
1192
- return true;
1188
+ if (this.focusTrap) {
1189
+ this.trap = this.trap
1190
+ ? this.trap.updateContainerElements(this.content)
1191
+ : createFocusTrap(this.content, {
1192
+ tabbableOptions: this.tabbableOptions,
1193
+ allowOutsideClick: true,
1194
+ onPostActivate: () => this.catOpen.emit(),
1195
+ setReturnFocus: elem => (!this.isFocusVisible || this.noReturnFocus ? false : this.trigger || elem),
1196
+ isKeyForward: event => {
1197
+ if ((this.arrowNavigation === 'horizontal' && event.key === 'ArrowRight') ||
1198
+ (this.arrowNavigation === 'vertical' && event.key === 'ArrowDown')) {
1199
+ event.preventDefault();
1200
+ return true;
1201
+ }
1202
+ return event.key === 'Tab';
1203
+ },
1204
+ isKeyBackward: event => {
1205
+ if ((this.arrowNavigation === 'horizontal' && event.key === 'ArrowLeft') ||
1206
+ (this.arrowNavigation === 'vertical' && event.key === 'ArrowUp')) {
1207
+ event.preventDefault();
1208
+ return true;
1209
+ }
1210
+ return event.key === 'Tab' && event.shiftKey;
1211
+ },
1212
+ initialFocus: () => {
1213
+ return this.isFocusVisible ? undefined : false;
1193
1214
  }
1194
- return event.key === 'Tab' && event.shiftKey;
1195
- },
1196
- initialFocus: () => {
1197
- return this.hasInitialFocus && !this.noInitialFocus ? undefined : false;
1198
- }
1199
- });
1200
- this.trap.activate();
1215
+ });
1216
+ this.trap.activate();
1217
+ }
1218
+ else {
1219
+ this.catOpen.emit();
1220
+ }
1201
1221
  });
1202
1222
  }
1203
1223
  /**
1204
1224
  * Closes the dropdown.
1205
1225
  */
1206
- async close() {
1226
+ async close(shouldReturnFocus = this.isFocusVisible) {
1207
1227
  if (!this._isOpen) {
1208
1228
  return; // busy or closed
1209
1229
  }
@@ -1211,6 +1231,9 @@ const CatDropdown = /*@__PURE__*/ proxyCustomElement(class CatDropdown extends H
1211
1231
  this.trap?.deactivate();
1212
1232
  this.trap = undefined;
1213
1233
  this.content.classList.remove('show');
1234
+ if (shouldReturnFocus) {
1235
+ this.trigger?.focus();
1236
+ }
1214
1237
  // give CSS transition time to apply
1215
1238
  setTimeout(() => {
1216
1239
  this._isOpen = false;
@@ -1235,7 +1258,16 @@ const CatDropdown = /*@__PURE__*/ proxyCustomElement(class CatDropdown extends H
1235
1258
  this.cleanupFloatingUi = undefined;
1236
1259
  }
1237
1260
  render() {
1238
- return (h(Host, { key: '0b02719eae82077fd11262620f260c86f6ef5854' }, h("slot", { key: '809f803bad06e9b9dfab850809709191f8a3bc2e', name: "anchor", ref: el => (this.anchorSlot = el) }), h("slot", { key: 'b6e32999e3cb4e4e4e9a4c534a22a17ae7708486', name: "trigger", ref: el => (this.triggerSlot = el) }), h("div", { key: '47592ef2faeb4a5ba26185a98952c56c3b0804f6', id: this.contentId, class: { content: true, 'overflow-auto': !this.overflow, justified: this.justify, aligned: !this.justify }, ref: el => (this.content = el) }, h("slot", { key: '8b6ba45f55abf7983a66550f161652e5a40205d7', name: "content" }))));
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" }))));
1262
+ }
1263
+ handleClickOutside(event) {
1264
+ if (!this.noAutoClose &&
1265
+ // check if click was outside of the dropdown content
1266
+ !event.composedPath().includes(this.content) &&
1267
+ // 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
+ }
1239
1271
  }
1240
1272
  get contentId() {
1241
1273
  return `cat-dropdown-${this.id}`;
@@ -1247,7 +1279,7 @@ const CatDropdown = /*@__PURE__*/ proxyCustomElement(class CatDropdown extends H
1247
1279
  this.trigger.setAttribute('aria-expanded', 'false');
1248
1280
  this.trigger.setAttribute('aria-controls', this.contentId);
1249
1281
  this.trigger.addEventListener('click', (event) => {
1250
- this.hasInitialFocus = this.isEventOriginFromKeyboard(event);
1282
+ this.isFocusVisible = this.isEventOriginFromKeyboard(event);
1251
1283
  this.toggle();
1252
1284
  });
1253
1285
  }
@@ -1325,7 +1357,7 @@ const CatDropdown = /*@__PURE__*/ proxyCustomElement(class CatDropdown extends H
1325
1357
  computePosition(anchorElement, this.content, {
1326
1358
  strategy: 'fixed',
1327
1359
  placement: this.placement,
1328
- middleware: [offset(CatDropdown.OFFSET), ...middleware, ...resize]
1360
+ middleware: [...middleware, ...resize]
1329
1361
  }).then(({ x, y, placement }) => {
1330
1362
  this.content.dataset.placement = placement;
1331
1363
  Object.assign(this.content.style, {
@@ -1350,10 +1382,11 @@ const CatDropdown = /*@__PURE__*/ proxyCustomElement(class CatDropdown extends H
1350
1382
  "isOpen": [2052, "is-open"],
1351
1383
  "noReturnFocus": [4, "no-return-focus"],
1352
1384
  "delayedTriggerInit": [4, "delayed-trigger-init"],
1385
+ "focusTrap": [4, "focus-trap"],
1353
1386
  "toggle": [64],
1354
1387
  "open": [64],
1355
1388
  "close": [64]
1356
- }, [[0, "catClick", "clickHandler"]]]);
1389
+ }, [[0, "catClick", "clickHandler"], [0, "keydown", "keydownHandler"], [6, "click", "globalClickHandler"], [7, "mousedown", "globalMouseDownHandler"], [6, "touchstart", "globalTouchStartHandler"]]]);
1357
1390
  CatDropdown.OFFSET = 4;
1358
1391
  function defineCustomElement() {
1359
1392
  if (typeof customElements === "undefined") {