@brightspace-ui-labs/facet-filter-sort 5.5.0 → 5.5.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.
@@ -1,7 +1,7 @@
1
1
  import '@brightspace-ui/core/components/button/button-subtle.js';
2
2
  import '@brightspace-ui-labs/multi-select/multi-select-list.js';
3
3
  import '@brightspace-ui-labs/multi-select/multi-select-list-item.js';
4
- import { css, html, LitElement } from 'lit-element';
4
+ import { css, html, LitElement } from 'lit';
5
5
  import { announce } from '@brightspace-ui/core/helpers/announce.js';
6
6
  import { bodyCompactStyles } from '@brightspace-ui/core/components/typography/styles.js';
7
7
  import { FilterLocalizeMixin } from '../localize-mixin.js';
@@ -1,9 +1,9 @@
1
1
  import '@brightspace-ui/core/components/colors/colors.js';
2
2
  import '@brightspace-ui/core/components/inputs/input-search.js';
3
3
  import '@brightspace-ui/core/components/menu/menu.js';
4
- import { css, html, LitElement } from 'lit-element';
4
+ import { css, html, LitElement } from 'lit';
5
5
  import { FilterLocalizeMixin } from '../localize-mixin.js';
6
- import { ifDefined } from 'lit-html/directives/if-defined.js';
6
+ import { ifDefined } from 'lit/directives/if-defined.js';
7
7
  import { TabPanelMixin } from '@brightspace-ui/core/components/tabs/tab-panel-mixin.js';
8
8
 
9
9
  /**
@@ -1,5 +1,5 @@
1
1
  import '@brightspace-ui/core/components/icons/icon.js';
2
- import { css, html, LitElement } from 'lit-element';
2
+ import { css, html, LitElement } from 'lit';
3
3
  import { MenuItemSelectableMixin } from '@brightspace-ui/core/components/menu/menu-item-selectable-mixin.js';
4
4
  import { menuItemSelectableStyles } from '@brightspace-ui/core/components/menu/menu-item-selectable-styles.js';
5
5
  import { RtlMixin } from '@brightspace-ui/core/mixins/rtl-mixin.js';
@@ -114,7 +114,7 @@ class D2LLabsFilterDropdown extends mixinBehaviors([LocalizeBehavior], PolymerEl
114
114
  }
115
115
  </style>
116
116
  <d2l-dropdown-button-subtle
117
- text="[[_getOpenerText(totalSelectedOptionCount, disableOpenerTextVariation, openerText, openerTextSingle, openerTextMultiple)]]"
117
+ text="[[_getOpenerText(totalSelectedOptionCount, disableOpenerTextVariation, openerText, openerTextSingle, openerTextMultiple, localize, resources)]]"
118
118
  disabled="[[disabled]]">
119
119
  <d2l-dropdown-tabs
120
120
  min-width="[[minWidth]]"
@@ -123,7 +123,7 @@ class D2LLabsFilterDropdown extends mixinBehaviors([LocalizeBehavior], PolymerEl
123
123
  no-padding-footer$="[[noPaddingFooter]]"
124
124
  render-content>
125
125
  <div class="d2l-labs-filter-dropdown-content-header">
126
- <span>[[_localizeOrAlt(headerText, 'filterBy')]]</span>
126
+ <span>[[_localizeOrAlt(headerText, 'filterBy', localize, resources)]]</span>
127
127
  <d2l-button-subtle text="[[localize('clear')]]" hidden$="[[!totalSelectedOptionCount]]" on-click="clearFilters"></d2l-button-subtle>
128
128
  </div>
129
129
  <d2l-tabs>
@@ -135,7 +135,7 @@ class D2LLabsFilterDropdown extends mixinBehaviors([LocalizeBehavior], PolymerEl
135
135
  `;
136
136
  }
137
137
 
138
- attached() {
138
+ attached() {
139
139
  this.addEventListener('d2l-dropdown-close', this._handleDropdownClose);
140
140
  this.addEventListener('d2l-tab-panel-selected', this._stopTabPanelSelectedEvent);
141
141
  }
@@ -170,6 +170,8 @@ class D2LLabsFilterDropdown extends mixinBehaviors([LocalizeBehavior], PolymerEl
170
170
  }
171
171
 
172
172
  _getOpenerText(totalSelectedOptionCount, disableOpenerTextVariation, openerText, openerTextSingle, openerTextMultiple) {
173
+ if (!this.localize || !this.resources) return;
174
+
173
175
  if (totalSelectedOptionCount === 0 || disableOpenerTextVariation) {
174
176
  return this._localizeOrAlt(openerText, 'filter');
175
177
  }
@@ -197,6 +199,7 @@ class D2LLabsFilterDropdown extends mixinBehaviors([LocalizeBehavior], PolymerEl
197
199
  }
198
200
 
199
201
  _localizeOrAlt(altText, ...args) {
202
+ if (!this.localize || !this.resources) return;
200
203
  return altText ? altText : this.localize(...args);
201
204
  }
202
205
 
@@ -1,49 +1,8 @@
1
1
  import '@brightspace-ui/localize-behavior/d2l-localize-behavior.js';
2
- import ar from '../lang/ar.js';
3
- import cy from '../lang/cy.js';
4
- import da from '../lang/da.js';
5
- import de from '../lang/de.js';
6
- import en from '../lang/en.js';
7
- import es from '../lang/es.js';
8
- import eses from '../lang/es-es.js';
9
- import fr from '../lang/fr.js';
10
- import frfr from '../lang/fr-fr.js';
11
- import hi from '../lang/hi.js';
12
- import ja from '../lang/ja.js';
13
- import ko from '../lang/ko.js';
14
- import nl from '../lang/nl.js';
15
- import pt from '../lang/pt.js';
16
- import sv from '../lang/sv.js';
17
- import tr from '../lang/tr.js';
18
- import zhcn from '../lang/zh-cn.js';
19
- import zhtw from '../lang/zh-tw.js';
20
2
 
21
3
  const LocalizeBehaviorImpl = {
22
- properties: {
23
- resources: {
24
- value: function() {
25
- return {
26
- 'ar': ar,
27
- 'cy': cy,
28
- 'da': da,
29
- 'de': de,
30
- 'en': en,
31
- 'es': es,
32
- 'es-es': eses,
33
- 'fr': fr,
34
- 'fr-fr': frfr,
35
- 'hi': hi,
36
- 'ja': ja,
37
- 'ko': ko,
38
- 'nl': nl,
39
- 'pt': pt,
40
- 'sv': sv,
41
- 'tr': tr,
42
- 'zh-cn': zhcn,
43
- 'zh-tw': zhtw
44
- };
45
- }
46
- }
4
+ localizeConfig: {
5
+ importFunc: async lang => (await import(`../lang/${lang}.js`)).default
47
6
  }
48
7
  };
49
8
 
@@ -1,5 +1,5 @@
1
1
  import '@brightspace-ui/core/components/icons/icon.js';
2
- import { html, LitElement } from 'lit-element';
2
+ import { html, LitElement } from 'lit';
3
3
  import { MenuItemRadioMixin } from '@brightspace-ui/core/components/menu/menu-item-radio-mixin.js';
4
4
  import { menuItemSelectableStyles } from '@brightspace-ui/core/components/menu/menu-item-selectable-styles.js';
5
5
  import { RtlMixin } from '@brightspace-ui/core/mixins/rtl-mixin.js';
@@ -36,18 +36,14 @@ class LabsSortByDropdown extends mixinBehaviors(
36
36
  */
37
37
  _selectedOptionText: {
38
38
  type: String,
39
+ computed: '_computeSelectedOptionText(_text, localize, resources)'
39
40
  },
40
41
  /**
41
42
  * The text of the currently selected option
42
43
  */
43
44
  _text: {
44
45
  type: String,
45
- value: '',
46
- observer: function(selection) {
47
- this._selectedOptionText = this.compact
48
- ? this.localize('sort')
49
- : this.localize('sortWithOption', 'option', selection);
50
- }
46
+ value: ''
51
47
  },
52
48
 
53
49
  /**
@@ -143,6 +139,13 @@ class LabsSortByDropdown extends mixinBehaviors(
143
139
  this._boundListeners._onItemSelect);
144
140
  }
145
141
 
142
+ _computeSelectedOptionText(selection, localize, resources) {
143
+ if (!selection || !localize || !resources) return;
144
+ return this.compact
145
+ ? this.localize('sort')
146
+ : this.localize('sortWithOption', 'option', selection);
147
+ }
148
+
146
149
  _onItemSelect(e) {
147
150
  this._text = e.target.text;
148
151
  this.value = e.detail.value;
package/package.json CHANGED
@@ -22,35 +22,27 @@
22
22
  "lint:style": "stylelint \"**/*.{js,html}\"",
23
23
  "start": "web-dev-server --node-resolve --watch --open --app-index demo/index.html",
24
24
  "test": "npm run lint && npm run test:headless",
25
- "test:headless": "web-test-runner --group default",
26
- "test:headless:watch": "web-test-runner --group default --watch"
25
+ "test:headless": "d2l-test-runner"
27
26
  },
28
27
  "author": "D2L Corporation",
29
28
  "license": "Apache-2.0",
30
29
  "devDependencies": {
31
30
  "@babel/core": "^7",
32
31
  "@babel/eslint-parser": "^7",
33
- "@brightspace-ui/stylelint-config": "^0.3",
34
- "@open-wc/testing": "^3",
35
- "@web/dev-server": "^0.1",
36
- "@web/test-runner": "^0.13",
32
+ "@brightspace-ui/stylelint-config": "^0.8",
33
+ "@brightspace-ui/testing": "^1",
34
+ "@web/dev-server": "^0.3",
37
35
  "eslint": "^8",
38
- "eslint-config-brightspace": "^0.16",
39
- "eslint-plugin-html": "^6",
40
- "eslint-plugin-import": "^2",
41
- "eslint-plugin-lit": "^1",
42
- "eslint-plugin-sort-class-members": "^1",
36
+ "eslint-config-brightspace": "^0.25",
43
37
  "lit-analyzer": "^1",
44
- "sinon": "^13",
45
- "stylelint": "^14"
38
+ "stylelint": "^15"
46
39
  },
47
- "version": "5.5.0",
40
+ "version": "5.5.2",
48
41
  "dependencies": {
42
+ "@brightspace-ui-labs/multi-select": "^6",
49
43
  "@brightspace-ui/core": "^2",
50
44
  "@brightspace-ui/localize-behavior": "^2",
51
- "@brightspace-ui-labs/multi-select": "^6",
52
- "lit-element": "^3",
53
- "lit-html": "^2",
54
- "@polymer/polymer": "^3"
45
+ "@polymer/polymer": "^3",
46
+ "lit": "^2"
55
47
  }
56
48
  }