@brightspace-ui-labs/facet-filter-sort 4.2.0 → 4.2.4

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/README.md CHANGED
@@ -197,45 +197,46 @@ This also works if the `d2l-labs-filter-dropdown` is a child in the shadow-dom o
197
197
  <d2l-labs-filter-dropdown id="filter"> ... </d2l-labs-filter-dropdown>
198
198
  ```
199
199
 
200
- ## Developing, Testing and Contributing
200
+ ## Developing
201
201
 
202
202
  After cloning the repo, run `npm install` to install dependencies.
203
203
 
204
- If you don't have it already, install the [Polymer CLI](https://www.polymer-project.org/3.0/docs/tools/polymer-cli) globally:
204
+ ### Running the demos
205
205
 
206
- ```shell
207
- npm install -g polymer-cli
208
- ```
209
-
210
- To start a [local web server](https://www.polymer-project.org/3.0/docs/tools/polymer-cli-commands#serve) that hosts the demo page and tests:
206
+ To start a [@web/dev-server](https://modern-web.dev/docs/dev-server/overview/) that hosts the demo page and tests:
211
207
 
212
208
  ```shell
213
- polymer serve
209
+ npm start
214
210
  ```
215
211
 
216
- To lint ([eslint](http://eslint.org/) and [Polymer lint](https://www.polymer-project.org/3.0/docs/tools/polymer-cli-commands#lint)):
212
+ ### Linting
217
213
 
218
214
  ```shell
215
+ # eslint, lit-analyzer, polymer lint and style linting
219
216
  npm run lint
220
- ```
221
217
 
222
- To run unit tests locally using [Polymer test](https://www.polymer-project.org/3.0/docs/tools/polymer-cli-commands#tests):
223
-
224
- ```shell
225
- npm run test:polymer:local
218
+ # eslint only
219
+ npm run lint:eslint
226
220
  ```
227
221
 
228
- To lint AND run local unit tests:
222
+ ### Testing
229
223
 
230
224
  ```shell
225
+ # lint & run headless unit tests
231
226
  npm test
227
+
228
+ # unit tests only
229
+ npm run test:headless
230
+
231
+ # debug or run a subset of local unit tests
232
+ npm run test:headless:watch
232
233
  ```
233
234
 
234
235
  ## Versioning & Releasing
235
236
 
236
- > TL;DR: Commits prefixed with `fix:` and `feat:` will trigger patch and minor releases when merged to `master`. Read on for more details...
237
+ > TL;DR: Commits prefixed with `fix:` and `feat:` will trigger patch and minor releases when merged to `main`. Read on for more details...
237
238
 
238
- The [sematic-release GitHub Action](https://github.com/BrightspaceUI/actions/tree/master/semantic-release) is called from the `release.yml` GitHub Action workflow to handle version changes and releasing.
239
+ The [semantic-release GitHub Action](https://github.com/BrightspaceUI/actions/tree/main/semantic-release) is called from the `release.yml` GitHub Action workflow to handle version changes and releasing.
239
240
 
240
241
  ### Version Changes
241
242
 
@@ -1,13 +1,14 @@
1
- /* eslint sort-imports: ["error", {"allowSeparatedGroups": true}] */
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 { LitElement, css, html } from 'lit-element';
4
+ import { css, html, LitElement } from 'lit-element';
5
+ import { announce } from '@brightspace-ui/core/helpers/announce.js';
6
+ import { bodyCompactStyles } from '@brightspace-ui/core/components/typography/styles.js';
5
7
  import { IdSubscriberController } from '@brightspace-ui/core/controllers/subscriber/subscriberControllers.js';
6
8
  import { LocalizeStaticMixin } from '@brightspace-ui/core/mixins/localize-static-mixin.js';
7
9
  import { RtlMixin } from '@brightspace-ui/core/mixins/rtl-mixin.js';
8
- import { announce } from '@brightspace-ui/core/helpers/announce.js';
9
- import { bodyCompactStyles } from '@brightspace-ui/core/components/typography/styles.js';
10
10
 
11
+ // eslint-disable-next-line sort-imports
11
12
  import ar from './lang/ar-sa.js';
12
13
  import de from './lang/de.js';
13
14
  import en from './lang/en.js';
@@ -61,22 +62,22 @@ class D2lLabsAppliedCoreFilters extends RtlMixin(LocalizeStaticMixin(LitElement)
61
62
  }
62
63
 
63
64
  .d2l-labs-applied-filters-label {
64
- margin-right: 0.25rem;
65
65
  display: inline-block;
66
- padding-top: 0.3rem;
67
66
  font-weight: bold;
67
+ margin-right: 0.25rem;
68
+ padding-top: 0.3rem;
68
69
  }
69
70
 
70
71
  :host([dir="rtl"]) .d2l-labs-applied-filters-label {
71
- margin-right: 0;
72
72
  margin-left: 0.25rem;
73
+ margin-right: 0;
73
74
  }
74
75
 
75
76
  .d2l-labs-applied-filters-none-label {
77
+ color: var(--d2l-color-corundum);
76
78
  display: inline-block;
77
- padding-top: 0.3rem;
78
79
  font-style: italic;
79
- color: var(--d2l-color-corundum);
80
+ padding-top: 0.3rem;
80
81
  }
81
82
 
82
83
  #d2l-clear-filters-button {
@@ -98,6 +99,17 @@ class D2lLabsAppliedCoreFilters extends RtlMixin(LocalizeStaticMixin(LitElement)
98
99
  `];
99
100
  }
100
101
 
102
+ constructor() {
103
+ super();
104
+ this.labelText = '';
105
+
106
+ this._allActiveFilters = new Map();
107
+ this._filters = new IdSubscriberController(this,
108
+ { onUnsubscribe: this._removeLostFilter.bind(this) },
109
+ { idPropertyName: 'filterIds' }
110
+ );
111
+ }
112
+
101
113
  static get resources() {
102
114
  return {
103
115
  'ar': ar,
@@ -120,17 +132,6 @@ class D2lLabsAppliedCoreFilters extends RtlMixin(LocalizeStaticMixin(LitElement)
120
132
  };
121
133
  }
122
134
 
123
- constructor() {
124
- super();
125
- this.labelText = '';
126
-
127
- this._allActiveFilters = new Map();
128
- this._filters = new IdSubscriberController(this,
129
- { onUnsubscribe: this._removeLostFilter.bind(this) },
130
- { idPropertyName: 'filterIds' }
131
- );
132
- }
133
-
134
135
  disconnectedCallback() {
135
136
  super.disconnectedCallback();
136
137
  this._filters.hostDisconnected();
@@ -1,13 +1,14 @@
1
- /* eslint sort-imports: ["error", {"allowSeparatedGroups": true}] */
2
- import '@brightspace-ui-labs/multi-select/multi-select-list';
3
- import '@brightspace-ui-labs/multi-select/multi-select-list-item';
4
- import { LitElement, css, html } from 'lit-element';
5
- import { LocalizeStaticMixin } from '@brightspace-ui/core/mixins/localize-static-mixin.js';
6
- import { RtlMixin } from '@brightspace-ui/core/mixins/rtl-mixin.js';
1
+ import '@brightspace-ui/core/components/button/button-subtle.js';
2
+ import '@brightspace-ui-labs/multi-select/multi-select-list.js';
3
+ import '@brightspace-ui-labs/multi-select/multi-select-list-item.js';
4
+ import { css, html, LitElement } from 'lit-element';
7
5
  import { announce } from '@brightspace-ui/core/helpers/announce.js';
8
6
  import { bodyCompactStyles } from '@brightspace-ui/core/components/typography/styles.js';
9
- import { getComposedChildren } from '@brightspace-ui/core/helpers/dom';
7
+ import { getComposedChildren } from '@brightspace-ui/core/helpers/dom.js';
8
+ import { LocalizeStaticMixin } from '@brightspace-ui/core/mixins/localize-static-mixin.js';
9
+ import { RtlMixin } from '@brightspace-ui/core/mixins/rtl-mixin.js';
10
10
 
11
+ // eslint-disable-next-line sort-imports
11
12
  import ar from './lang/ar-sa.js';
12
13
  import de from './lang/de.js';
13
14
  import en from './lang/en.js';
@@ -66,22 +67,22 @@ class D2lLabsAppliedFilters extends RtlMixin(LocalizeStaticMixin(LitElement)) {
66
67
  }
67
68
 
68
69
  .d2l-labs-applied-filters-label {
69
- margin-right: 0.25rem;
70
70
  display: inline-block;
71
- padding-top: 0.3rem;
72
71
  font-weight: bold;
72
+ margin-right: 0.25rem;
73
+ padding-top: 0.3rem;
73
74
  }
74
75
 
75
76
  :host([dir="rtl"]) .d2l-labs-applied-filters-label {
76
- margin-right: 0;
77
77
  margin-left: 0.25rem;
78
+ margin-right: 0;
78
79
  }
79
80
 
80
81
  .d2l-labs-applied-filters-none-label {
82
+ color: var(--d2l-color-corundum);
81
83
  display: inline-block;
82
- padding-top: 0.3rem;
83
84
  font-style: italic;
84
- color: var(--d2l-color-corundum);
85
+ padding-top: 0.3rem;
85
86
  }
86
87
 
87
88
  #d2l-clear-filters-button {
@@ -103,6 +104,18 @@ class D2lLabsAppliedFilters extends RtlMixin(LocalizeStaticMixin(LitElement)) {
103
104
  `];
104
105
  }
105
106
 
107
+ constructor() {
108
+ super();
109
+ this.labelText = '';
110
+
111
+ this._clearFiltersClicked = this._clearFiltersClicked.bind(this);
112
+ this._clearSelected = this._clearSelected.bind(this);
113
+ this._setSelectedOptions = this._setSelectedOptions.bind(this);
114
+ this._update = this._update.bind(this);
115
+
116
+ this._setSelectedOptions();
117
+ }
118
+
106
119
  static get resources() {
107
120
  return {
108
121
  'ar': ar,
@@ -125,18 +138,6 @@ class D2lLabsAppliedFilters extends RtlMixin(LocalizeStaticMixin(LitElement)) {
125
138
  };
126
139
  }
127
140
 
128
- constructor() {
129
- super();
130
- this.labelText = '';
131
-
132
- this._clearFiltersClicked = this._clearFiltersClicked.bind(this);
133
- this._clearSelected = this._clearSelected.bind(this);
134
- this._setSelectedOptions = this._setSelectedOptions.bind(this);
135
- this._update = this._update.bind(this);
136
-
137
- this._setSelectedOptions();
138
- }
139
-
140
141
  firstUpdated() {
141
142
  this._update();
142
143
  }
@@ -157,11 +158,10 @@ class D2lLabsAppliedFilters extends RtlMixin(LocalizeStaticMixin(LitElement)) {
157
158
  </d2l-labs-multi-select-list-item>
158
159
  `)}
159
160
  </d2l-labs-multi-select-list>`
160
- : html`<span class="d2l-labs-applied-filters-none-label d2l-body-compact">${this.localize('noActiveFilters')}</span>`;
161
+ : null;
161
162
 
162
163
  return html`
163
164
  <div class="d2l-labs-applied-filters-wrapper">
164
- <span id="d2l-labs-applied-filters-label" class="d2l-labs-applied-filters-label d2l-body-compact">${this.labelText || this.localize('appliedFilters')}</span>
165
165
  <div id="d2l-list-holder">
166
166
  ${filters}
167
167
  <d2l-button-subtle id="d2l-clear-filters-button" text="${this.localize('clearFilters')}" ?hidden="${this._selectedEntries.length < CLEAR_FILTERS_THRESHOLD}" @click="${this._clearFiltersClicked}"></d2l-button-subtle>
@@ -1,7 +1,7 @@
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/lit-element.js';
4
+ import { css, html, LitElement } from 'lit-element';
5
5
  import { ifDefined } from 'lit-html/directives/if-defined.js';
6
6
  import { LocalizeStaticMixin } from '@brightspace-ui/core/mixins/localize-static-mixin.js';
7
7
  import { TabPanelMixin } from '@brightspace-ui/core/components/tabs/tab-panel-mixin.js';
@@ -44,8 +44,8 @@ class LabsFilterDropdownCategory extends LocalizeStaticMixin(TabPanelMixin(LitEl
44
44
  static get styles() {
45
45
  return [super.styles, css`
46
46
  :host {
47
- margin: -1px -1rem 0 -1rem;
48
47
  border-top: 1px solid var(--d2l-color-gypsum);
48
+ margin: -1px -1rem 0 -1rem;
49
49
  padding: 1.2rem 1rem 0 1rem;
50
50
  }
51
51
  .d2l-labs-filter-dropdown-page-search {
@@ -58,6 +58,44 @@ class LabsFilterDropdownCategory extends LocalizeStaticMixin(TabPanelMixin(LitEl
58
58
  `];
59
59
  }
60
60
 
61
+ constructor() {
62
+ super();
63
+ this.categoryText = '';
64
+ this.disableSearch = false;
65
+ this.key = '';
66
+ this.selectedOptionCount = 0;
67
+ }
68
+
69
+ get categoryText() {
70
+ return this._categoryText;
71
+ }
72
+
73
+ set categoryText(val) {
74
+ const oldVal = this._categoryText;
75
+ if (oldVal !== val) {
76
+ this._categoryText = val;
77
+ this.requestUpdate();
78
+ this.updateComplete.then(() => {
79
+ this._updateTabText(this._categoryText, this.selectedOptionCount);
80
+ });
81
+ }
82
+ }
83
+
84
+ get selectedOptionCount() {
85
+ return this._selectedOptionCount;
86
+ }
87
+
88
+ set selectedOptionCount(val) {
89
+ const oldVal = this._selectedOptionCount;
90
+ if (oldVal !== val) {
91
+ this._selectedOptionCount = val;
92
+ this.requestUpdate();
93
+ this.updateComplete.then(() => {
94
+ this._updateTabText(this.categoryText, this._selectedOptionCount);
95
+ });
96
+ }
97
+ }
98
+
61
99
  static get resources() {
62
100
  return {
63
101
  'ar': {
@@ -139,44 +177,6 @@ class LabsFilterDropdownCategory extends LocalizeStaticMixin(TabPanelMixin(LitEl
139
177
  };
140
178
  }
141
179
 
142
- constructor() {
143
- super();
144
- this.categoryText = '';
145
- this.disableSearch = false;
146
- this.key = '';
147
- this.selectedOptionCount = 0;
148
- }
149
-
150
- get categoryText() {
151
- return this._categoryText;
152
- }
153
-
154
- set categoryText(val) {
155
- const oldVal = this._categoryText;
156
- if (oldVal !== val) {
157
- this._categoryText = val;
158
- this.requestUpdate();
159
- this.updateComplete.then(() => {
160
- this._updateTabText(this._categoryText, this.selectedOptionCount);
161
- });
162
- }
163
- }
164
-
165
- get selectedOptionCount() {
166
- return this._selectedOptionCount;
167
- }
168
-
169
- set selectedOptionCount(val) {
170
- const oldVal = this._selectedOptionCount;
171
- if (oldVal !== val) {
172
- this._selectedOptionCount = val;
173
- this.requestUpdate();
174
- this.updateComplete.then(() => {
175
- this._updateTabText(this.categoryText, this._selectedOptionCount);
176
- });
177
- }
178
- }
179
-
180
180
  firstUpdated(changedProperties) {
181
181
  super.firstUpdated(changedProperties);
182
182
  this.addEventListener('d2l-menu-item-select', (e) => {
@@ -1,5 +1,5 @@
1
1
  import '@brightspace-ui/core/components/icons/icon.js';
2
- import { css, html, LitElement } from 'lit-element/lit-element.js';
2
+ import { css, html, LitElement } from 'lit-element';
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';
@@ -1,5 +1,5 @@
1
1
  import '@brightspace-ui/core/components/icons/icon.js';
2
- import { html, LitElement } from 'lit-element/lit-element.js';
2
+ import { html, LitElement } from 'lit-element';
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';
package/package.json CHANGED
@@ -1,5 +1,6 @@
1
1
  {
2
2
  "description": "Collection of (search) facet, filter and sort elements",
3
+ "type": "module",
3
4
  "repository": {
4
5
  "type": "git",
5
6
  "url": "https://github.com/BrightspaceUILabs/facet-filter-sort.git"
@@ -13,35 +14,45 @@
13
14
  "/components"
14
15
  ],
15
16
  "scripts": {
16
- "lint": "npm run lint:wc && npm run lint:js",
17
- "lint:js": "eslint . --ext .js,.html test/**/*.js test/**/*.html demo/**/*.js demo/**/*.html",
18
- "lint:wc": "polymer lint -i \"./*\" \"test\" \"demo\" \"components\"",
19
- "test:polymer:local": "polymer test --skip-plugin sauce",
20
- "test:polymer:sauce": "polymer test --skip-plugin local",
21
- "test": "npm run lint && npm run test:polymer:local"
17
+ "lint": "npm run lint:eslint && npm run lint:lit && npm run lint:polymer && npm run lint:style",
18
+ "lint:eslint": "eslint . --ext .js,.html",
19
+ "lint:lit": "lit-analyzer \"{components, test, demo}/**/*.js\" --strict --rules.no-unknown-tag-name off",
20
+ "lint:polymer": "polymer lint -i \"test/**/*.js\" \"demo/**/*.js\" \"components/**/*.js\"",
21
+ "lint:style": "stylelint \"**/*.{js,html}\"",
22
+ "start": "web-dev-server --node-resolve --watch --open --app-index demo/index.html",
23
+ "test": "npm run lint && npm run test:headless",
24
+ "test:headless": "web-test-runner --group default",
25
+ "test:headless:watch": "web-test-runner --group default --watch"
22
26
  },
23
27
  "author": "D2L Corporation",
24
28
  "license": "Apache-2.0",
25
29
  "devDependencies": {
26
- "@polymer/iron-test-helpers": "^3",
27
- "@webcomponents/webcomponentsjs": "^2",
28
- "babel-eslint": "^10",
29
- "eslint": "^7",
30
- "eslint-config-brightspace": "^0.10",
30
+ "@babel/core": "^7",
31
+ "@babel/eslint-parser": "^7",
32
+ "@brightspace-ui/stylelint-config": "^0.3",
33
+ "@open-wc/testing": "^2",
34
+ "@web/dev-server": "^0.1",
35
+ "@web/test-runner": "^0.13",
36
+ "@web/test-runner-saucelabs": "^0.6",
37
+ "eslint": "^8",
38
+ "eslint-config-brightspace": "^0.16",
31
39
  "eslint-plugin-html": "^6",
32
- "eslint-plugin-lit": "~1.4.0",
40
+ "eslint-plugin-import": "^2",
41
+ "eslint-plugin-lit": "^1",
33
42
  "eslint-plugin-sort-class-members": "^1",
43
+ "lit-analyzer": "^1",
34
44
  "polymer-cli": "^1",
35
- "wct-browser-legacy": "^1"
45
+ "sinon": "^13",
46
+ "stylelint": "^14"
36
47
  },
37
- "version": "4.2.0",
48
+ "version": "4.2.4",
38
49
  "dependencies": {
39
50
  "@brightspace-ui/core": "^1",
40
51
  "d2l-localize-behavior": "BrightspaceUI/localize-behavior#semver:^2",
41
52
  "@brightspace-ui-labs/multi-select": "^5",
42
- "d2l-polymer-behaviors": "Brightspace/d2l-polymer-behaviors-ui#semver:^2",
43
53
  "d2l-typography": "BrightspaceUI/typography#semver:^7",
44
54
  "lit-element": "^2",
55
+ "lit-html": "^1",
45
56
  "@polymer/polymer": "^3"
46
57
  }
47
58
  }