@getflip/swirl-components 0.120.1 → 0.120.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.
package/components.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "timestamp": "2024-01-10T11:34:57",
2
+ "timestamp": "2024-01-11T13:30:16",
3
3
  "compiler": {
4
4
  "name": "@stencil/core",
5
5
  "version": "3.3.1",
@@ -479,6 +479,12 @@ const SwirlResourceListItem = class {
479
479
  this.checked = !this.checked;
480
480
  this.valueChange.emit(this.checked);
481
481
  };
482
+ this.onBlur = () => {
483
+ this.makeControlUnfocusable();
484
+ };
485
+ this.onFocus = () => {
486
+ this.makeControlFocusable();
487
+ };
482
488
  this.onMenuTriggerClick = (event) => {
483
489
  if (this.disabled && !Boolean(this.href)) {
484
490
  event.stopPropagation();
@@ -518,6 +524,7 @@ const SwirlResourceListItem = class {
518
524
  this.forceIconProps(this.desktopMediaQuery.matches);
519
525
  this.updateIconSize(this.desktopMediaQuery.matches);
520
526
  this.desktopMediaQuery.onchange = this.desktopMediaQueryHandler;
527
+ this.makeControlUnfocusable();
521
528
  if (Boolean(this.menuTriggerId)) {
522
529
  console.warn('[Swirl] The "menu-trigger-id" prop of swirl-resource-list-item is deprecated and will be removed with the next major release. Please use the "control" slot to add a menu button instead. https://swirl-storybook.flip-app.dev/?path=/docs/components-swirlresourcelistitem--docs');
523
530
  }
@@ -539,6 +546,23 @@ const SwirlResourceListItem = class {
539
546
  this.hasMedia = hasMedia;
540
547
  }
541
548
  }
549
+ getControl() {
550
+ return this.el.querySelector('[slot="control"] button');
551
+ }
552
+ makeControlFocusable() {
553
+ const control = this.getControl();
554
+ if (!Boolean(control)) {
555
+ return;
556
+ }
557
+ control.tabIndex = 0;
558
+ }
559
+ makeControlUnfocusable() {
560
+ const control = this.getControl();
561
+ if (!Boolean(control)) {
562
+ return;
563
+ }
564
+ control.tabIndex = -1;
565
+ }
542
566
  render() {
543
567
  const Tag = !this.interactive && !this.selectable
544
568
  ? "div"
@@ -567,7 +591,7 @@ const SwirlResourceListItem = class {
567
591
  "resource-list-item--show-control-on-focus": showControlOnFocus,
568
592
  "resource-list-item--show-meta": showMeta,
569
593
  });
570
- return (index.h(index.Host, { role: "row" }, index.h("div", { class: className, role: "gridcell" }, index.h(Tag, { "aria-checked": ariaChecked, "aria-disabled": disabled ? "true" : undefined, "aria-labelledby": this.id, class: "resource-list-item__content", href: href, disabled: disabled, onClick: this.onClick, part: "resource-list-item__content", role: role, tabIndex: 0, type: Tag === "button" ? "button" : undefined }, this.hasMedia && (index.h("span", { class: "resource-list-item__media" }, index.h("slot", { name: "media" }))), index.h("span", { class: "resource-list-item__label-container" }, index.h("span", { class: "resource-list-item__label", id: this.id, innerHTML: this.label }), this.description && (index.h("span", { class: "resource-list-item__description" }, this.description))), showMeta && (index.h("span", { class: "resource-list-item__meta" }, index.h("span", { class: "resource-list-item__meta-text" }, this.meta), index.h("span", { class: "resource-list-item__badges" }, index.h("slot", { name: "badges" }))))), this.selectable && (index.h("span", { "aria-hidden": "true", class: "resource-list-item__checkbox" }, index.h("span", { class: "resource-list-item__checkbox-icon" }, this.checked && (index.h("swirl-icon-check-strong", null))))), index.h("span", { class: "resource-list-item__control" }, index.h("slot", { name: "control" })), showMenu && (index.h("swirl-popover-trigger", { popover: this.menuTriggerId }, index.h("swirl-button", { "aria-disabled": disabled ? "true" : undefined, class: "resource-list-item__menu-trigger", disabled: disabled, hideLabel: true, icon: "<swirl-icon-more-horizontal></swirl-icon-more-horizontal>", intent: "primary", label: this.menuTriggerLabel, onClick: this.onMenuTriggerClick })))), this.allowDrag && (index.h("button", { "aria-describedby": this.dragHandleDescription, "aria-label": `${this.dragHandleLabel} "${this.label}"`, class: "resource-list-item__drag-handle", onKeyDown: this.onDragHandleKeyDown, type: "button" }, index.h("swirl-icon-drag-handle", { size: this.iconSize })))));
594
+ return (index.h(index.Host, { role: "row" }, index.h("div", { class: className, role: "gridcell" }, index.h(Tag, { "aria-checked": ariaChecked, "aria-disabled": disabled ? "true" : undefined, "aria-labelledby": this.id, class: "resource-list-item__content", href: href, disabled: disabled, onClick: this.onClick, onBlur: this.onBlur, onFocus: this.onFocus, part: "resource-list-item__content", role: role, tabIndex: 0, type: Tag === "button" ? "button" : undefined }, this.hasMedia && (index.h("span", { class: "resource-list-item__media" }, index.h("slot", { name: "media" }))), index.h("span", { class: "resource-list-item__label-container" }, index.h("span", { class: "resource-list-item__label", id: this.id, innerHTML: this.label }), this.description && (index.h("span", { class: "resource-list-item__description" }, this.description))), showMeta && (index.h("span", { class: "resource-list-item__meta" }, index.h("span", { class: "resource-list-item__meta-text" }, this.meta), index.h("span", { class: "resource-list-item__badges" }, index.h("slot", { name: "badges" }))))), this.selectable && (index.h("span", { "aria-hidden": "true", class: "resource-list-item__checkbox" }, index.h("span", { class: "resource-list-item__checkbox-icon" }, this.checked && (index.h("swirl-icon-check-strong", null))))), index.h("span", { class: "resource-list-item__control" }, index.h("slot", { name: "control" })), showMenu && (index.h("swirl-popover-trigger", { popover: this.menuTriggerId }, index.h("swirl-button", { "aria-disabled": disabled ? "true" : undefined, class: "resource-list-item__menu-trigger", disabled: disabled, hideLabel: true, icon: "<swirl-icon-more-horizontal></swirl-icon-more-horizontal>", intent: "primary", label: this.menuTriggerLabel, onClick: this.onMenuTriggerClick })))), this.allowDrag && (index.h("button", { "aria-describedby": this.dragHandleDescription, "aria-label": `${this.dragHandleLabel} "${this.label}"`, class: "resource-list-item__drag-handle", onKeyDown: this.onDragHandleKeyDown, type: "button" }, index.h("swirl-icon-drag-handle", { size: this.iconSize })))));
571
595
  }
572
596
  get el() { return index.getElement(this); }
573
597
  };