@haiilo/catalyst 10.31.0 → 10.32.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.
@@ -1305,7 +1305,7 @@ const CatButtonGroup = class {
1305
1305
  };
1306
1306
  CatButtonGroup.style = CatButtonGroupStyle0;
1307
1307
 
1308
- const catCardCss = ":host{display:block;border-radius:var(--cat-border-radius-l, 0.5rem);background-color:white;padding:1.25rem}:host([hidden]){display:none}::slotted(:last-child){margin-bottom:0 !important}::slotted(nav),::slotted(nav:last-child){margin:-1rem -1rem !important}::slotted(.cat-card-pull){margin:-1.25rem !important;width:calc(100% + 2.5rem) !important;height:calc(100% + 2.5rem) !important}::slotted(.cat-card-pull-h){margin-left:-1.25rem !important;margin-right:-1.25rem !important;width:calc(100% + 2.5rem) !important}::slotted(.cat-card-pull-v){margin-top:-1.25rem !important;margin-bottom:-1.25rem !important;height:calc(100% + 2.5rem) !important}::slotted(.cat-card-pull-t){margin-top:-1.25rem !important}::slotted(.cat-card-pull-l){margin-left:-1.25rem !important}::slotted(.cat-card-pull-r){margin-right:-1.25rem !important}::slotted(.cat-card-pull-b){margin-bottom:-1.25rem !important}";
1308
+ const catCardCss = ":host{display:block;border-radius:var(--cat-border-radius-l, 0.5rem);background-color:white;padding:1.25rem;box-shadow:0 0 0 1px rgb(var(--cat-border-color-card, 140, 140, 140, 0.12))}:host([hidden]){display:none}::slotted(:last-child){margin-bottom:0 !important}::slotted(nav),::slotted(nav:last-child){margin:-1rem -1rem !important}::slotted(.cat-card-pull){margin:-1.25rem !important;width:calc(100% + 2.5rem) !important;height:calc(100% + 2.5rem) !important}::slotted(.cat-card-pull-h){margin-left:-1.25rem !important;margin-right:-1.25rem !important;width:calc(100% + 2.5rem) !important}::slotted(.cat-card-pull-v){margin-top:-1.25rem !important;margin-bottom:-1.25rem !important;height:calc(100% + 2.5rem) !important}::slotted(.cat-card-pull-t){margin-top:-1.25rem !important}::slotted(.cat-card-pull-l){margin-left:-1.25rem !important}::slotted(.cat-card-pull-r){margin-right:-1.25rem !important}::slotted(.cat-card-pull-b){margin-bottom:-1.25rem !important}";
1309
1309
  const CatCardStyle0 = catCardCss;
1310
1310
 
1311
1311
  const CatCard = class {
@@ -8667,6 +8667,12 @@ const CatDropdown = class {
8667
8667
  this.catClose = createEvent(this, "catClose", 7);
8668
8668
  this.id = nextUniqueId$8++;
8669
8669
  this.isOpen = false;
8670
+ /**
8671
+ * Tracking the origin of opening the dropdown and specify if initial focus should be set.
8672
+ * Currently we set it only when the origin is keyboard.
8673
+ * We might not need to track this in future when focus-visible support is improved across browsers
8674
+ */
8675
+ this.hasInitialFocus = false;
8670
8676
  this.placement = 'bottom-start';
8671
8677
  this.noAutoClose = false;
8672
8678
  this.arrowNavigation = 'vertical';
@@ -8680,6 +8686,7 @@ const CatDropdown = class {
8680
8686
  // interaction because the element might still be hidden (and thus not
8681
8687
  // tabbable) if contained in another Stencil web component
8682
8688
  if (!this.trigger) {
8689
+ this.hasInitialFocus = this.isEventOriginFromKeyboard(event.detail);
8683
8690
  this.initTrigger();
8684
8691
  this.toggle();
8685
8692
  }
@@ -8703,8 +8710,9 @@ const CatDropdown = class {
8703
8710
  }
8704
8711
  /**
8705
8712
  * Opens the dropdown.
8713
+ * @param isFocusVisible is dropdown should receive visible focus when it's opened.
8706
8714
  */
8707
- async open() {
8715
+ async open(isFocusVisible) {
8708
8716
  // we need to delay the initialization of the trigger until first
8709
8717
  // interaction because the element might still be hidden (and thus not
8710
8718
  // tabbable) if contained in another Stencil web component
@@ -8716,6 +8724,7 @@ const CatDropdown = class {
8716
8724
  }
8717
8725
  this.isOpen = null;
8718
8726
  this.content.style.display = 'block';
8727
+ this.hasInitialFocus = isFocusVisible ?? this.hasInitialFocus;
8719
8728
  // give CSS transition time to apply
8720
8729
  setTimeout(() => {
8721
8730
  this.isOpen = true;
@@ -8752,7 +8761,9 @@ const CatDropdown = class {
8752
8761
  }
8753
8762
  return event.key === 'Tab' && event.shiftKey;
8754
8763
  },
8755
- initialFocus: () => (this.noInitialFocus ? false : undefined)
8764
+ initialFocus: () => {
8765
+ return this.hasInitialFocus && !this.noInitialFocus ? undefined : false;
8766
+ }
8756
8767
  });
8757
8768
  this.trap.activate();
8758
8769
  });
@@ -8777,7 +8788,7 @@ const CatDropdown = class {
8777
8788
  }, timeTransitionS);
8778
8789
  }
8779
8790
  render() {
8780
- return (h(Host, { key: '3ead90dae1ac492a0cb592d7cf7a50fd42f26ca7' }, h("slot", { key: 'b91bba7772b2a90850be2ac85b82ec7691ae031d', name: "anchor", ref: el => (this.anchorSlot = el) }), h("slot", { key: 'f7e07ffed988133cbccafb8f8c73fdb52757d9fb', name: "trigger", ref: el => (this.triggerSlot = el) }), h("div", { key: '868a0578cd30cac249959e0961b0425e56048af9', id: this.contentId, class: { content: true, 'overflow-auto': !this.overflow }, ref: el => (this.content = el) }, h("slot", { key: '19fb6b5b92599ed1ae21aac591271957a6e7b060', name: "content" }))));
8791
+ return (h(Host, { key: '1a87f171daed4f9eccc40a303f3aba45f3501128' }, h("slot", { key: 'f74085056470832d32434ebcacdb6d9532177e86', name: "anchor", ref: el => (this.anchorSlot = el) }), h("slot", { key: 'fdf8879c10e6ad7179487480d2ff0f890bf5f8da', name: "trigger", ref: el => (this.triggerSlot = el) }), h("div", { key: '1c6b50433220e084ea096c38e14c17625c52e5e5', id: this.contentId, class: { content: true, 'overflow-auto': !this.overflow }, ref: el => (this.content = el) }, h("slot", { key: '9c8de61eb11c1bb0771b8f0b6a9d7f7f574c928e', name: "content" }))));
8781
8792
  }
8782
8793
  componentDidLoad() {
8783
8794
  this.initAnchor();
@@ -8791,11 +8802,17 @@ const CatDropdown = class {
8791
8802
  this.trigger.setAttribute('aria-haspopup', ariaHaspopup ?? 'true');
8792
8803
  this.trigger.setAttribute('aria-expanded', 'false');
8793
8804
  this.trigger.setAttribute('aria-controls', this.contentId);
8794
- this.trigger.addEventListener('click', () => this.toggle());
8805
+ this.trigger.addEventListener('click', (event) => {
8806
+ this.hasInitialFocus = this.isEventOriginFromKeyboard(event);
8807
+ this.toggle();
8808
+ });
8795
8809
  if (!this.anchor) {
8796
8810
  autoUpdate(this.trigger, this.content, () => this.update(this.trigger));
8797
8811
  }
8798
8812
  }
8813
+ isEventOriginFromKeyboard(event) {
8814
+ return event.detail === 0;
8815
+ }
8799
8816
  initAnchor() {
8800
8817
  this.anchor = (this.anchorSlot?.assignedElements?.() || [])[0];
8801
8818
  if (this.anchor) {