@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.
@@ -11,6 +11,10 @@
11
11
  }
12
12
  }
13
13
 
14
+ @mixin cat-elevation-card {
15
+ box-shadow: 0 0 0 1px cat-token('color.ui.border.card');
16
+ }
17
+
14
18
  @mixin cat-elevation-transition {
15
19
  transition: $cat-elevation-transition;
16
20
  }
@@ -1309,7 +1309,7 @@ const CatButtonGroup = class {
1309
1309
  };
1310
1310
  CatButtonGroup.style = CatButtonGroupStyle0;
1311
1311
 
1312
- 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}";
1312
+ 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}";
1313
1313
  const CatCardStyle0 = catCardCss;
1314
1314
 
1315
1315
  const CatCard = class {
@@ -8671,6 +8671,12 @@ const CatDropdown = class {
8671
8671
  this.catClose = index.createEvent(this, "catClose", 7);
8672
8672
  this.id = nextUniqueId$8++;
8673
8673
  this.isOpen = false;
8674
+ /**
8675
+ * Tracking the origin of opening the dropdown and specify if initial focus should be set.
8676
+ * Currently we set it only when the origin is keyboard.
8677
+ * We might not need to track this in future when focus-visible support is improved across browsers
8678
+ */
8679
+ this.hasInitialFocus = false;
8674
8680
  this.placement = 'bottom-start';
8675
8681
  this.noAutoClose = false;
8676
8682
  this.arrowNavigation = 'vertical';
@@ -8684,6 +8690,7 @@ const CatDropdown = class {
8684
8690
  // interaction because the element might still be hidden (and thus not
8685
8691
  // tabbable) if contained in another Stencil web component
8686
8692
  if (!this.trigger) {
8693
+ this.hasInitialFocus = this.isEventOriginFromKeyboard(event.detail);
8687
8694
  this.initTrigger();
8688
8695
  this.toggle();
8689
8696
  }
@@ -8707,8 +8714,9 @@ const CatDropdown = class {
8707
8714
  }
8708
8715
  /**
8709
8716
  * Opens the dropdown.
8717
+ * @param isFocusVisible is dropdown should receive visible focus when it's opened.
8710
8718
  */
8711
- async open() {
8719
+ async open(isFocusVisible) {
8712
8720
  // we need to delay the initialization of the trigger until first
8713
8721
  // interaction because the element might still be hidden (and thus not
8714
8722
  // tabbable) if contained in another Stencil web component
@@ -8720,6 +8728,7 @@ const CatDropdown = class {
8720
8728
  }
8721
8729
  this.isOpen = null;
8722
8730
  this.content.style.display = 'block';
8731
+ this.hasInitialFocus = isFocusVisible ?? this.hasInitialFocus;
8723
8732
  // give CSS transition time to apply
8724
8733
  setTimeout(() => {
8725
8734
  this.isOpen = true;
@@ -8756,7 +8765,9 @@ const CatDropdown = class {
8756
8765
  }
8757
8766
  return event.key === 'Tab' && event.shiftKey;
8758
8767
  },
8759
- initialFocus: () => (this.noInitialFocus ? false : undefined)
8768
+ initialFocus: () => {
8769
+ return this.hasInitialFocus && !this.noInitialFocus ? undefined : false;
8770
+ }
8760
8771
  });
8761
8772
  this.trap.activate();
8762
8773
  });
@@ -8781,7 +8792,7 @@ const CatDropdown = class {
8781
8792
  }, timeTransitionS);
8782
8793
  }
8783
8794
  render() {
8784
- return (index.h(index.Host, { key: '3ead90dae1ac492a0cb592d7cf7a50fd42f26ca7' }, index.h("slot", { key: 'b91bba7772b2a90850be2ac85b82ec7691ae031d', name: "anchor", ref: el => (this.anchorSlot = el) }), index.h("slot", { key: 'f7e07ffed988133cbccafb8f8c73fdb52757d9fb', name: "trigger", ref: el => (this.triggerSlot = el) }), index.h("div", { key: '868a0578cd30cac249959e0961b0425e56048af9', id: this.contentId, class: { content: true, 'overflow-auto': !this.overflow }, ref: el => (this.content = el) }, index.h("slot", { key: '19fb6b5b92599ed1ae21aac591271957a6e7b060', name: "content" }))));
8795
+ return (index.h(index.Host, { key: '1a87f171daed4f9eccc40a303f3aba45f3501128' }, index.h("slot", { key: 'f74085056470832d32434ebcacdb6d9532177e86', name: "anchor", ref: el => (this.anchorSlot = el) }), index.h("slot", { key: 'fdf8879c10e6ad7179487480d2ff0f890bf5f8da', name: "trigger", ref: el => (this.triggerSlot = el) }), index.h("div", { key: '1c6b50433220e084ea096c38e14c17625c52e5e5', id: this.contentId, class: { content: true, 'overflow-auto': !this.overflow }, ref: el => (this.content = el) }, index.h("slot", { key: '9c8de61eb11c1bb0771b8f0b6a9d7f7f574c928e', name: "content" }))));
8785
8796
  }
8786
8797
  componentDidLoad() {
8787
8798
  this.initAnchor();
@@ -8795,11 +8806,17 @@ const CatDropdown = class {
8795
8806
  this.trigger.setAttribute('aria-haspopup', ariaHaspopup ?? 'true');
8796
8807
  this.trigger.setAttribute('aria-expanded', 'false');
8797
8808
  this.trigger.setAttribute('aria-controls', this.contentId);
8798
- this.trigger.addEventListener('click', () => this.toggle());
8809
+ this.trigger.addEventListener('click', (event) => {
8810
+ this.hasInitialFocus = this.isEventOriginFromKeyboard(event);
8811
+ this.toggle();
8812
+ });
8799
8813
  if (!this.anchor) {
8800
8814
  autoUpdate(this.trigger, this.content, () => this.update(this.trigger));
8801
8815
  }
8802
8816
  }
8817
+ isEventOriginFromKeyboard(event) {
8818
+ return event.detail === 0;
8819
+ }
8803
8820
  initAnchor() {
8804
8821
  this.anchor = (this.anchorSlot?.assignedElements?.() || [])[0];
8805
8822
  if (this.anchor) {