@fluid-topics/ft-search-results-number 1.3.36 → 1.3.37

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.
@@ -1,13 +1,17 @@
1
- import { nothing } from "lit";
2
- import { ElementDefinitionsMap } from "@fluid-topics/ft-wc-utils";
1
+ import { nothing, PropertyValues } from "lit";
2
+ import { I18nAttributeValue } from "@fluid-topics/ft-i18n/build/decorators/i18nAttribute";
3
+ import { Debouncer, ElementDefinitionsMap } from "@fluid-topics/ft-wc-utils";
3
4
  import { FtSearchResultsNumberProperties } from "./ft-search-results-number.properties";
4
5
  import { FtSearchComponent } from "@fluid-topics/ft-search-context/build/registration";
5
- declare const FtSearchResultsNumber_base: typeof FtSearchComponent & import("@fluid-topics/ft-wc-utils").Constructor<import("@fluid-topics/ft-i18n").FtLitElementWithI18nInterface>;
6
+ declare const FtSearchResultsNumber_base: typeof FtSearchComponent & import("@fluid-topics/ft-wc-utils").Constructor<import("@fluid-topics/ft-i18n").FtLitElementWithI18nInterface> & import("@fluid-topics/ft-wc-utils").Constructor<import("@fluid-topics/ft-wc-utils").FtLitElementWithAriaNotificationInterface>;
6
7
  export declare class FtSearchResultsNumber extends FtSearchResultsNumber_base implements FtSearchResultsNumberProperties {
7
8
  static elementDefinitions: ElementDefinitionsMap;
8
9
  static styles: import("lit").CSSResult;
10
+ protected ariaNotificationDebouncer: Debouncer;
11
+ searchNumberOfResults: I18nAttributeValue;
9
12
  private paging?;
10
13
  constructor();
11
14
  protected render(): typeof nothing | import("lit-html").TemplateResult<1>;
15
+ protected willUpdate(props: PropertyValues): void;
12
16
  }
13
17
  export {};
@@ -5,15 +5,21 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
7
  import { html, nothing } from "lit";
8
- import { redux } from "@fluid-topics/ft-wc-utils";
8
+ import { Debouncer, jsonProperty, redux, withAriaNotification } from "@fluid-topics/ft-wc-utils";
9
9
  import { styles } from "./ft-search-results-number.styles";
10
10
  import { FtSearchComponent } from "@fluid-topics/ft-search-context/build/registration";
11
11
  import { withI18n } from "@fluid-topics/ft-i18n";
12
12
  import { defaultResultsNumberContextMessages, resultsNumberContext } from "./SearchResultsNumberMessages";
13
- import { FtTypography } from "@fluid-topics/ft-typography";
14
- class FtSearchResultsNumber extends withI18n(FtSearchComponent) {
13
+ import { FtTypography, FtTypographyVariants } from "@fluid-topics/ft-typography";
14
+ class FtSearchResultsNumber extends withAriaNotification(withI18n(FtSearchComponent)) {
15
15
  constructor() {
16
16
  super();
17
+ this.ariaNotificationDebouncer = new Debouncer(100);
18
+ this.searchNumberOfResults = {
19
+ context: "officialContext",
20
+ key: "searchNumberOfResults",
21
+ message: "",
22
+ };
17
23
  this.addI18nContext(resultsNumberContext, defaultResultsNumberContextMessages);
18
24
  }
19
25
  render() {
@@ -21,16 +27,33 @@ class FtSearchResultsNumber extends withI18n(FtSearchComponent) {
21
27
  return nothing;
22
28
  }
23
29
  return html `
24
- <ft-typography variant="body1">
30
+ <ft-typography variant="${FtTypographyVariants.body1}">
25
31
  ${resultsNumberContext.messages.results(this.paging.totalClustersCount)}
26
32
  </ft-typography>
27
33
  `;
28
34
  }
35
+ willUpdate(props) {
36
+ super.willUpdate(props);
37
+ if (props.has("paging")) {
38
+ this.ariaNotificationDebouncer.run(async () => {
39
+ if (this.paging !== undefined) {
40
+ const notification = await this.awaitI18n({
41
+ ...this.searchNumberOfResults,
42
+ args: [this.paging.totalClustersCount],
43
+ });
44
+ this.sendAriaNotification(notification);
45
+ }
46
+ });
47
+ }
48
+ }
29
49
  }
30
50
  FtSearchResultsNumber.elementDefinitions = {
31
51
  "ft-typography": FtTypography,
32
52
  };
33
53
  FtSearchResultsNumber.styles = styles;
54
+ __decorate([
55
+ jsonProperty({ context: "officialContext", key: "searchNumberOfResults" })
56
+ ], FtSearchResultsNumber.prototype, "searchNumberOfResults", void 0);
34
57
  __decorate([
35
58
  redux()
36
59
  ], FtSearchResultsNumber.prototype, "paging", void 0);