@fluid-topics/ft-search-selected-facets 1.2.50 → 1.2.52

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.
@@ -15,6 +15,8 @@ export declare class FtSearchSelectedFacets extends FtSearchSelectedFacets_base
15
15
  constructor();
16
16
  protected render(): typeof nothing | import("lit-html").TemplateResult<1>;
17
17
  private renderFacet;
18
+ private getNextChipToFocusOn;
19
+ private determineAndApplyFocus;
18
20
  private getSelectedValues;
19
21
  private getLabelFromValue;
20
22
  private getBreadcrumbFromValue;
@@ -6,7 +6,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
6
6
  };
7
7
  import { html, nothing } from "lit";
8
8
  import { repeat } from "lit/directives/repeat.js";
9
- import { flatDeep, redux } from "@fluid-topics/ft-wc-utils";
9
+ import { flatDeep, FocusMainContentEvent, redux, shadowQuerySelectorAll } from "@fluid-topics/ft-wc-utils";
10
10
  import { styles } from "./ft-search-selected-facets.styles";
11
11
  import { FtSearchComponent } from "@fluid-topics/ft-search-context/build/registration";
12
12
  import { FtChip } from "@fluid-topics/ft-chip";
@@ -59,7 +59,11 @@ class FtSearchSelectedFacets extends withI18n(FtSearchComponent) {
59
59
  removable hideIconTooltip
60
60
  iconLabel="${searchSelectedFacets.messages.removeFilterLabel()}"
61
61
  label="${label}"
62
- @icon-click=${() => { var _a; return (_a = this.stateManager) === null || _a === void 0 ? void 0 : _a.setValueFilter(facetKey, selectedValues.filter(v => v !== value)); }}
62
+ @icon-click=${(e) => {
63
+ var _a;
64
+ (_a = this.stateManager) === null || _a === void 0 ? void 0 : _a.setValueFilter(facetKey, selectedValues.filter(v => v !== value));
65
+ this.determineAndApplyFocus(e);
66
+ }}
63
67
  data-key="${facetKey}"
64
68
  data-value="${value}">
65
69
  ${this.getLabelFromValue(value)}
@@ -67,6 +71,32 @@ class FtSearchSelectedFacets extends withI18n(FtSearchComponent) {
67
71
  </ft-tooltip>
68
72
  `;
69
73
  }
74
+ getNextChipToFocusOn(currentChip) {
75
+ const allChips = shadowQuerySelectorAll(this.shadowRoot, "ft-chip");
76
+ const currentIndex = allChips.indexOf(currentChip);
77
+ if (currentIndex === -1 || allChips.length <= 1) {
78
+ return null;
79
+ }
80
+ // If there's a next filter, focus it
81
+ if (currentIndex < allChips.length - 1) {
82
+ return allChips[currentIndex + 1];
83
+ }
84
+ // Otherwise focus the previous filter
85
+ return allChips[currentIndex - 1];
86
+ }
87
+ determineAndApplyFocus(e) {
88
+ const chipElement = e.currentTarget;
89
+ const elementToFocus = this.getNextChipToFocusOn(chipElement);
90
+ if (elementToFocus) {
91
+ elementToFocus.elementToFocus = {
92
+ selector: `ft-button`
93
+ };
94
+ }
95
+ else {
96
+ // No chip to focus on anymore, notify to focus main content
97
+ this.dispatchEvent(new FocusMainContentEvent());
98
+ }
99
+ }
70
100
  getSelectedValues(facet) {
71
101
  return flatDeep(facet.rootNodes, n => n.selected ? [] : n.childNodes)
72
102
  .filter(n => n.selected)
@@ -115,7 +145,11 @@ class FtSearchSelectedFacets extends withI18n(FtSearchComponent) {
115
145
  part="ft-search-selected-facets ft-search-selected-facet-period-filter"
116
146
  removable hideIconTooltip
117
147
  iconLabel="${searchSelectedFacets.messages.removeFilterLabel()}"
118
- @icon-click=${() => { var _a; return (_a = this.stateManager) === null || _a === void 0 ? void 0 : _a.removeDateFilter(key); }}>
148
+ @icon-click=${(e) => {
149
+ var _a;
150
+ (_a = this.stateManager) === null || _a === void 0 ? void 0 : _a.removeDateFilter(key);
151
+ this.determineAndApplyFocus(e);
152
+ }}>
119
153
  ${periodFilterContext.messages[dateFilter.type]()}
120
154
  </ft-chip>
121
155
  </ft-tooltip>`;
@@ -127,7 +161,11 @@ class FtSearchSelectedFacets extends withI18n(FtSearchComponent) {
127
161
  part="ft-search-selected-facets ft-search-selected-facet-period-filter"
128
162
  removable hideIconTooltip
129
163
  iconLabel="${searchSelectedFacets.messages.removeFilterLabel()}"
130
- @icon-click=${() => { var _a; return (_a = this.stateManager) === null || _a === void 0 ? void 0 : _a.removeRangeFilter(key); }}>
164
+ @icon-click=${(e) => {
165
+ var _a;
166
+ (_a = this.stateManager) === null || _a === void 0 ? void 0 : _a.removeRangeFilter(key);
167
+ this.determineAndApplyFocus(e);
168
+ }}>
131
169
  ${periodFilterContext.messages["CUSTOM"]()}
132
170
  </ft-chip>
133
171
  </ft-tooltip>`;