@haiilo/catalyst 10.37.0 → 11.1.0

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 (62) hide show
  1. package/dist/catalyst/catalyst.esm.js +1 -1
  2. package/dist/catalyst/catalyst.esm.js.map +1 -1
  3. package/dist/catalyst/{p-3a3e9083.entry.js → p-84333073.entry.js} +4 -4
  4. package/dist/catalyst/p-84333073.entry.js.map +1 -0
  5. package/dist/cjs/cat-alert_30.cjs.entry.js +295 -1795
  6. package/dist/cjs/cat-alert_30.cjs.entry.js.map +1 -1
  7. package/dist/cjs/catalyst.cjs.js +1 -1
  8. package/dist/cjs/loader.cjs.js +1 -1
  9. package/dist/collection/collection-manifest.json +1 -1
  10. package/dist/collection/components/cat-alert/cat-alert.js +1 -1
  11. package/dist/collection/components/cat-badge/cat-badge.js +1 -1
  12. package/dist/collection/components/cat-button-group/cat-button-group.js +1 -1
  13. package/dist/collection/components/cat-card/cat-card.js +1 -1
  14. package/dist/collection/components/cat-checkbox/cat-checkbox.js +2 -2
  15. package/dist/collection/components/cat-date/cat-date.js +10 -5
  16. package/dist/collection/components/cat-date/cat-date.js.map +1 -1
  17. package/dist/collection/components/cat-date-inline/cat-date-inline.js +4 -4
  18. package/dist/collection/components/cat-dropdown/cat-dropdown.css +5 -0
  19. package/dist/collection/components/cat-dropdown/cat-dropdown.js +47 -17
  20. package/dist/collection/components/cat-dropdown/cat-dropdown.js.map +1 -1
  21. package/dist/collection/components/cat-dropdown/cat-dropdown.spec.js +1 -0
  22. package/dist/collection/components/cat-dropdown/cat-dropdown.spec.js.map +1 -1
  23. package/dist/collection/components/cat-input/cat-input.js +58 -43
  24. package/dist/collection/components/cat-input/cat-input.js.map +1 -1
  25. package/dist/collection/components/cat-select/cat-select.js +4 -4
  26. package/dist/collection/components/cat-time/cat-time-locale.js.map +1 -1
  27. package/dist/collection/components/cat-time/cat-time.js +3 -9
  28. package/dist/collection/components/cat-time/cat-time.js.map +1 -1
  29. package/dist/collection/components/cat-tooltip/cat-tooltip.js +2 -2
  30. package/dist/collection/index.js.map +1 -1
  31. package/dist/collection/utils/first-tabbable-with-visibility-hidden.js +49 -0
  32. package/dist/collection/utils/first-tabbable-with-visibility-hidden.js.map +1 -0
  33. package/dist/components/cat-alert.js +1 -1
  34. package/dist/components/cat-badge.js +1 -1
  35. package/dist/components/cat-button-group.js +1 -1
  36. package/dist/components/cat-card.js +1 -1
  37. package/dist/components/cat-checkbox2.js +2 -2
  38. package/dist/components/cat-date-inline2.js +4 -4
  39. package/dist/components/cat-date.js +6 -5
  40. package/dist/components/cat-date.js.map +1 -1
  41. package/dist/components/cat-dropdown2.js +81 -21
  42. package/dist/components/cat-dropdown2.js.map +1 -1
  43. package/dist/components/cat-input2.js +19 -1571
  44. package/dist/components/cat-input2.js.map +1 -1
  45. package/dist/components/cat-select2.js +4 -4
  46. package/dist/components/cat-time.js +3 -9
  47. package/dist/components/cat-time.js.map +1 -1
  48. package/dist/components/cat-tooltip.js +2 -2
  49. package/dist/esm/cat-alert_30.entry.js +297 -1797
  50. package/dist/esm/cat-alert_30.entry.js.map +1 -1
  51. package/dist/esm/catalyst.js +1 -1
  52. package/dist/esm/loader.js +1 -1
  53. package/dist/types/components/cat-date/cat-date.d.ts +2 -0
  54. package/dist/types/components/cat-dropdown/cat-dropdown.d.ts +6 -1
  55. package/dist/types/components/cat-input/cat-input.d.ts +22 -7
  56. package/dist/types/components/cat-time/cat-time-locale.d.ts +4 -3
  57. package/dist/types/components/cat-time/cat-time.d.ts +1 -1
  58. package/dist/types/components.d.ts +26 -7
  59. package/dist/types/index.d.ts +1 -0
  60. package/dist/types/utils/first-tabbable-with-visibility-hidden.d.ts +2 -0
  61. package/package.json +3 -4
  62. package/dist/catalyst/p-3a3e9083.entry.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
1
+ import { proxyCustomElement, HTMLElement as HTMLElement$1, createEvent, h, Host } from '@stencil/core/internal/client';
2
2
  import { a as autoUpdate, s as size, c as computePosition, o as offset, f as flip, b as shift } from './floating-ui.dom.esm.js';
3
3
  import { t as tabbable, a as focusable, i as isTabbable, g as getTabIndex, b as isFocusable, f as firstTabbable } from './first-tabbable.js';
4
4
 
@@ -993,11 +993,59 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
993
993
  return trap;
994
994
  };
995
995
 
996
- const catDropdownCss = ":host{display:contents}:host([hidden]){display:none}::slotted(nav){padding:0.25rem;min-width:8rem;max-width:16rem}.content{position:fixed;background:white;-webkit-overflow-scrolling:touch;min-height:2rem;max-height:calc(100vh - 48px);box-shadow:0 4px 6px -2px rgba(27, 31, 38, 0.03), 0 12px 16px -4px rgba(27, 31, 38, 0.08);border-radius:var(--cat-border-radius-m, 0.25rem);border:1px solid rgb(var(--cat-border-color, 235, 236, 240));z-index:calc(var(--cat-z-index, 1000) + 100);display:none;opacity:0;transform:scale(0.9);transition:transform 125ms cubic-bezier(0.3, 0, 0.8, 0.15), opacity 125ms cubic-bezier(0.3, 0, 0.8, 0.15)}.content[data-placement^=top]{transform-origin:bottom}.content[data-placement^=top-start]{transform-origin:bottom left}.content[data-placement^=top-end]{transform-origin:bottom right}.content[data-placement^=left]{transform-origin:right}.content[data-placement^=left-start]{transform-origin:right top}.content[data-placement^=left-end]{transform-origin:right bottom}.content[data-placement^=right]{transform-origin:left}.content[data-placement^=right-start]{transform-origin:left top}.content[data-placement^=right-end]{transform-origin:left bottom}.content[data-placement^=bottom]{transform-origin:top}.content[data-placement^=bottom-start]{transform-origin:top left}.content[data-placement^=bottom-end]{transform-origin:top right}.content.show{opacity:1;transform:scale(1);transition:transform 250ms cubic-bezier(0.05, 0.7, 0.1, 1), opacity 250ms cubic-bezier(0.05, 0.7, 0.1, 1)}.content.overflow-auto{overflow:auto}";
996
+ const focusableSelectors = [
997
+ 'input',
998
+ 'select',
999
+ 'textarea',
1000
+ 'button',
1001
+ 'a[href]',
1002
+ '[tabindex]',
1003
+ 'iframe',
1004
+ '[contenteditable]',
1005
+ 'audio[controls]',
1006
+ 'video[controls]'
1007
+ ];
1008
+ const findFirstTabbableIncludeHidden = (element) => {
1009
+ if (element instanceof HTMLElement) {
1010
+ const potentiallyTabbableElement = getPotentiallyTabbable(element);
1011
+ if (potentiallyTabbableElement) {
1012
+ return potentiallyTabbableElement;
1013
+ }
1014
+ }
1015
+ const children = Array.from(element.querySelectorAll('*'));
1016
+ for (const child of children) {
1017
+ const potentiallyTabbableElement = getPotentiallyTabbable(child);
1018
+ if (potentiallyTabbableElement) {
1019
+ return potentiallyTabbableElement;
1020
+ }
1021
+ }
1022
+ return undefined;
1023
+ };
1024
+ function couldBeTabbable(value) {
1025
+ if (!value.matches(focusableSelectors.join(','))) {
1026
+ return false;
1027
+ }
1028
+ const tabindex = value.getAttribute('tabindex');
1029
+ return tabindex === null || Number(tabindex) >= 0;
1030
+ }
1031
+ function getPotentiallyTabbable(element) {
1032
+ if (couldBeTabbable(element)) {
1033
+ return element;
1034
+ }
1035
+ if (element.shadowRoot) {
1036
+ const shadowTabbable = findFirstTabbableIncludeHidden(element.shadowRoot);
1037
+ if (shadowTabbable) {
1038
+ return shadowTabbable;
1039
+ }
1040
+ }
1041
+ return undefined;
1042
+ }
1043
+
1044
+ const catDropdownCss = ":host{display:contents}:host([hidden]){display:none}::slotted(nav){padding:0.25rem}.aligned ::slotted(nav){min-width:8rem;max-width:16rem}.justified ::slotted(nav){width:100%}.content{position:fixed;background:white;-webkit-overflow-scrolling:touch;min-height:2rem;max-height:calc(100vh - 48px);box-shadow:0 4px 6px -2px rgba(27, 31, 38, 0.03), 0 12px 16px -4px rgba(27, 31, 38, 0.08);border-radius:var(--cat-border-radius-m, 0.25rem);border:1px solid rgb(var(--cat-border-color, 235, 236, 240));z-index:calc(var(--cat-z-index, 1000) + 100);display:none;opacity:0;transform:scale(0.9);transition:transform 125ms cubic-bezier(0.3, 0, 0.8, 0.15), opacity 125ms cubic-bezier(0.3, 0, 0.8, 0.15)}.content[data-placement^=top]{transform-origin:bottom}.content[data-placement^=top-start]{transform-origin:bottom left}.content[data-placement^=top-end]{transform-origin:bottom right}.content[data-placement^=left]{transform-origin:right}.content[data-placement^=left-start]{transform-origin:right top}.content[data-placement^=left-end]{transform-origin:right bottom}.content[data-placement^=right]{transform-origin:left}.content[data-placement^=right-start]{transform-origin:left top}.content[data-placement^=right-end]{transform-origin:left bottom}.content[data-placement^=bottom]{transform-origin:top}.content[data-placement^=bottom-start]{transform-origin:top left}.content[data-placement^=bottom-end]{transform-origin:top right}.content.show{opacity:1;transform:scale(1);transition:transform 250ms cubic-bezier(0.05, 0.7, 0.1, 1), opacity 250ms cubic-bezier(0.05, 0.7, 0.1, 1)}.content.overflow-auto{overflow:auto}";
997
1045
  const CatDropdownStyle0 = catDropdownCss;
998
1046
 
999
1047
  let nextUniqueId = 0;
1000
- const CatDropdown = /*@__PURE__*/ proxyCustomElement(class CatDropdown extends HTMLElement {
1048
+ const CatDropdown = /*@__PURE__*/ proxyCustomElement(class CatDropdown extends HTMLElement$1 {
1001
1049
  constructor() {
1002
1050
  super();
1003
1051
  this.__registerHost();
@@ -1020,12 +1068,10 @@ const CatDropdown = /*@__PURE__*/ proxyCustomElement(class CatDropdown extends H
1020
1068
  this.overflow = false;
1021
1069
  this.noInitialFocus = false;
1022
1070
  this.noReturnFocus = false;
1071
+ this.delayedTriggerInit = false;
1023
1072
  }
1024
1073
  clickHandler(event) {
1025
- // we need to delay the initialization of the trigger until first
1026
- // interaction because the element might still be hidden (and thus not
1027
- // tabbable) if contained in another Stencil web component
1028
- if (!this.trigger) {
1074
+ if (!this.trigger && this.delayedTriggerInit) {
1029
1075
  this.hasInitialFocus = this.isEventOriginFromKeyboard(event.detail);
1030
1076
  this.initTrigger();
1031
1077
  this.toggle();
@@ -1053,10 +1099,7 @@ const CatDropdown = /*@__PURE__*/ proxyCustomElement(class CatDropdown extends H
1053
1099
  * @param isFocusVisible is dropdown should receive visible focus when it's opened.
1054
1100
  */
1055
1101
  async open(isFocusVisible) {
1056
- // we need to delay the initialization of the trigger until first
1057
- // interaction because the element might still be hidden (and thus not
1058
- // tabbable) if contained in another Stencil web component
1059
- if (!this.trigger) {
1102
+ if (!this.trigger && this.delayedTriggerInit) {
1060
1103
  this.initTrigger();
1061
1104
  }
1062
1105
  if (this.isOpen === null || this.isOpen) {
@@ -1127,11 +1170,14 @@ const CatDropdown = /*@__PURE__*/ proxyCustomElement(class CatDropdown extends H
1127
1170
  this.catClose.emit();
1128
1171
  }, timeTransitionS);
1129
1172
  }
1130
- render() {
1131
- return (h(Host, { key: 'abd5eb8eb84977f0981113b3f7958ec2a31a47bb' }, h("slot", { key: '6049c92c9b30e3fba338fb94d17543476620fe37', name: "anchor", ref: el => (this.anchorSlot = el) }), h("slot", { key: '6eb5f52f222ad08b4a7f0d41d4ace943b371a6b7', name: "trigger", ref: el => (this.triggerSlot = el) }), h("div", { key: 'e186f63a79fcc457bee344ee188fef37f2c27383', id: this.contentId, class: { content: true, 'overflow-auto': !this.overflow }, ref: el => (this.content = el) }, h("slot", { key: 'c0060ac95085f3794f61fd88922368c59a31b1b7', name: "content" }))));
1132
- }
1133
1173
  componentDidLoad() {
1134
1174
  this.initAnchor();
1175
+ if (!this.delayedTriggerInit) {
1176
+ this.initTrigger();
1177
+ }
1178
+ }
1179
+ render() {
1180
+ return (h(Host, { key: 'e101b3a67fd7a0908d311b1c8bae2a999e4f3e9f' }, h("slot", { key: 'e30d1fb968a1c7b762b8932c4e8b4278fde43f30', name: "anchor", ref: el => (this.anchorSlot = el) }), h("slot", { key: '0b56ed3439417a52791ed5d98b81859cebc7189e', name: "trigger", ref: el => (this.triggerSlot = el) }), h("div", { key: '53c4a6bfe56a95e18b2931326d71fda970e2f76a', id: this.contentId, class: { content: true, 'overflow-auto': !this.overflow, justified: this.justify, aligned: !this.justify }, ref: el => (this.content = el) }, h("slot", { key: 'fafbbf8f1fee503f7b282e320dc76955fdf8a4c9', name: "content" }))));
1135
1181
  }
1136
1182
  get contentId() {
1137
1183
  return `cat-dropdown-${this.id}`;
@@ -1161,7 +1207,7 @@ const CatDropdown = /*@__PURE__*/ proxyCustomElement(class CatDropdown extends H
1161
1207
  }
1162
1208
  findTrigger() {
1163
1209
  let trigger;
1164
- const elems = this.triggerSlot?.assignedElements?.() || [];
1210
+ let elems = this.triggerSlot?.assignedElements?.() || [];
1165
1211
  while (!trigger && elems.length) {
1166
1212
  const elem = elems.shift();
1167
1213
  trigger = elem?.hasAttribute('data-trigger')
@@ -1171,6 +1217,15 @@ const CatDropdown = /*@__PURE__*/ proxyCustomElement(class CatDropdown extends H
1171
1217
  if (!trigger) {
1172
1218
  trigger = firstTabbable(this.triggerSlot);
1173
1219
  }
1220
+ // if no tabbable element is still found let's attempt to search through elements with visibility:hidden styles
1221
+ // which stencil assigns to component in prehydration state
1222
+ if (!trigger) {
1223
+ elems = this.triggerSlot?.assignedElements?.() || [];
1224
+ while (!trigger && elems.length) {
1225
+ const elem = elems.shift();
1226
+ trigger = findFirstTabbableIncludeHidden(elem);
1227
+ }
1228
+ }
1174
1229
  if (!trigger) {
1175
1230
  throw new Error('Cannot find tabbable element. Use [data-trigger] to set the trigger.');
1176
1231
  }
@@ -1186,13 +1241,17 @@ const CatDropdown = /*@__PURE__*/ proxyCustomElement(class CatDropdown extends H
1186
1241
  apply({ rects, availableWidth, availableHeight, elements }) {
1187
1242
  if (justify) {
1188
1243
  Object.assign(elements.floating.style, {
1189
- minWidth: `${rects.reference.width}px`
1244
+ minWidth: `${rects.reference.width}px`,
1245
+ maxWidth: `${rects.reference.width}px`,
1246
+ maxHeight: `${availableHeight}px`
1247
+ });
1248
+ }
1249
+ else {
1250
+ Object.assign(elements.floating.style, {
1251
+ maxWidth: `${availableWidth}px`,
1252
+ maxHeight: `${availableHeight}px`
1190
1253
  });
1191
1254
  }
1192
- Object.assign(elements.floating.style, {
1193
- maxWidth: `${availableWidth}px`,
1194
- maxHeight: `${availableHeight}px`
1195
- });
1196
1255
  }
1197
1256
  })
1198
1257
  ];
@@ -1210,7 +1269,7 @@ const CatDropdown = /*@__PURE__*/ proxyCustomElement(class CatDropdown extends H
1210
1269
  }
1211
1270
  }
1212
1271
  hasAttribute(elem, attr) {
1213
- return elem instanceof HTMLElement && elem.hasAttribute(attr);
1272
+ return elem instanceof HTMLElement$1 && elem.hasAttribute(attr);
1214
1273
  }
1215
1274
  static get style() { return CatDropdownStyle0; }
1216
1275
  }, [1, "cat-dropdown", {
@@ -1222,6 +1281,7 @@ const CatDropdown = /*@__PURE__*/ proxyCustomElement(class CatDropdown extends H
1222
1281
  "overflow": [4],
1223
1282
  "noInitialFocus": [4, "no-initial-focus"],
1224
1283
  "noReturnFocus": [4, "no-return-focus"],
1284
+ "delayedTriggerInit": [4, "delayed-trigger-init"],
1225
1285
  "toggle": [64],
1226
1286
  "open": [64],
1227
1287
  "close": [64]