@brightspace-ui-labs/facet-filter-sort 4.1.4 → 4.2.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/README.md
CHANGED
|
@@ -28,14 +28,64 @@ npm install @brightspace-ui-labs/facet-filter-sort
|
|
|
28
28
|
|
|
29
29
|
## Components
|
|
30
30
|
|
|
31
|
-
- [d2l-labs-filter-dropdown](#d2l-labs-filter-dropdown)
|
|
32
31
|
- [d2l-labs-search-facets](#d2l-labs-search-facets)
|
|
33
32
|
- [d2l-labs-search-results-count](#d2l-labs-search-results-count)
|
|
34
33
|
- [d2l-labs-sort-by-dropdown](#d2l-labs-sort-by-dropdown)
|
|
34
|
+
- [d2l-labs-applied-core-filters](#d2l-labs-applied-core-filters)
|
|
35
|
+
|
|
36
|
+
### d2l-labs-search-facets
|
|
37
|
+
|
|
38
|
+
<img src="/images/d2l-labs-search-facets.png?raw=true" width="450">
|
|
39
|
+
|
|
40
|
+
#### Usage
|
|
41
|
+
|
|
42
|
+
To Do
|
|
43
|
+
|
|
44
|
+
### d2l-labs-search-results-count
|
|
45
|
+
|
|
46
|
+
<img src="/images/d2l-labs-search-results-count.png?raw=true" width="450">
|
|
47
|
+
|
|
48
|
+
#### Usage
|
|
49
|
+
|
|
50
|
+
To Do
|
|
51
|
+
|
|
52
|
+
### d2l-labs-sort-by-dropdown
|
|
53
|
+
|
|
54
|
+
<img src="/images/d2l-labs-sort-by-dropdown.png?raw=true" width="450">
|
|
55
|
+
|
|
56
|
+
#### Usage
|
|
57
|
+
|
|
58
|
+
To Do
|
|
59
|
+
|
|
60
|
+
### d2l-labs-applied-core-filters
|
|
61
|
+
|
|
62
|
+
The same design as the deprecated `d2l-labs-applied-filters` below, but this version works with the `d2l-filter` component in `core`. It supports hooking up to multiple filters and will be migrated to `core` once designs are finalized.
|
|
63
|
+
|
|
64
|
+
#### Attributes
|
|
65
|
+
|
|
66
|
+
- `filter-ids`: Ids (space-delimited) of the filter components to subscribe to
|
|
67
|
+
- `label-text` (optional): The text displayed in this component's label. Defaults to "Applied Filters:".
|
|
68
|
+
|
|
69
|
+
#### Usage
|
|
70
|
+
|
|
71
|
+
Set the `filter-ids` param to the ids of the `d2l-filter`s that you want to track.
|
|
72
|
+
The `d2l-filter`s must be in the same DOM scope.
|
|
73
|
+
|
|
74
|
+
```html
|
|
75
|
+
<d2l-filter id="course"> ... </d2l-filter>
|
|
76
|
+
<d2l-filter id="role"> ... </d2l-filter>
|
|
77
|
+
<d2l-labs-applied-core-filters filter-ids="course role"></d2l-labs-applied-core-filters>
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Deprecated Components
|
|
81
|
+
|
|
82
|
+
- [d2l-labs-filter-dropdown](#d2l-labs-filter-dropdown)
|
|
35
83
|
- [d2l-labs-applied-filters](#d2l-labs-applied-filters)
|
|
36
84
|
|
|
37
85
|
### d2l-labs-filter-dropdown
|
|
38
86
|
|
|
87
|
+
**DEPRECATED: Use [`d2l-filter`](https://github.com/BrightspaceUI/core/tree/main/components/filter) in `BrightspaceUI/core`.**
|
|
88
|
+
|
|
39
89
|
<img src="/images/d2l-labs-filter-dropdown.png?raw=true" width="450">
|
|
40
90
|
|
|
41
91
|
#### Usage
|
|
@@ -124,33 +174,9 @@ Note that for the header and opener text overrides, if the terms are to reflect
|
|
|
124
174
|
- `d2l-labs-filter-dropdown-category-searched`: Fired when a filter category is searched.
|
|
125
175
|
- `d2l-labs-filter-dropdown-option-change`: Fired when a filter option is selected.
|
|
126
176
|
|
|
127
|
-
### d2l-labs-search-facets
|
|
128
|
-
|
|
129
|
-
<img src="/images/d2l-labs-search-facets.png?raw=true" width="450">
|
|
130
|
-
|
|
131
|
-
#### Usage
|
|
132
|
-
|
|
133
|
-
To Do
|
|
134
|
-
|
|
135
|
-
### d2l-labs-search-results-count
|
|
136
|
-
|
|
137
|
-
<img src="/images/d2l-labs-search-results-count.png?raw=true" width="450">
|
|
138
|
-
|
|
139
|
-
#### Usage
|
|
140
|
-
|
|
141
|
-
To Do
|
|
142
|
-
|
|
143
|
-
### d2l-labs-sort-by-dropdown
|
|
144
|
-
|
|
145
|
-
<img src="/images/d2l-labs-sort-by-dropdown.png?raw=true" width="450">
|
|
146
|
-
|
|
147
|
-
#### Usage
|
|
148
|
-
|
|
149
|
-
To Do
|
|
150
|
-
|
|
151
177
|
### d2l-labs-applied-filters
|
|
152
178
|
|
|
153
|
-
A multi-select-list allowing the user to see (and remove) the currently applied filters.
|
|
179
|
+
A multi-select-list allowing the user to see (and remove) the currently applied filters. Works with the `d2l-labs-filter-dropdown` above. If you are using `d2l-filter` from `core`, see [d2l-labs-applied-core-filters](#d2l-labs-applied-core-filters).
|
|
154
180
|
|
|
155
181
|
NOTE: This component uses the `slotchange` event and so will not work if you require IE support
|
|
156
182
|
|
|
@@ -166,51 +192,51 @@ NOTE: This component uses the `slotchange` event and so will not work if you req
|
|
|
166
192
|
Set the `for` param to be the id of the `d2l-labs-filter-dropdown` that you want to track.
|
|
167
193
|
This also works if the `d2l-labs-filter-dropdown` is a child in the shadow-dom of the element referenced by the id.
|
|
168
194
|
|
|
169
|
-
|
|
170
195
|
```html
|
|
171
196
|
<d2l-labs-applied-filters for="filter"></d2l-labs-applied-filters>
|
|
172
197
|
<d2l-labs-filter-dropdown id="filter"> ... </d2l-labs-filter-dropdown>
|
|
173
198
|
```
|
|
174
199
|
|
|
175
|
-
## Developing
|
|
200
|
+
## Developing
|
|
176
201
|
|
|
177
202
|
After cloning the repo, run `npm install` to install dependencies.
|
|
178
203
|
|
|
179
|
-
|
|
204
|
+
### Running the demos
|
|
180
205
|
|
|
181
|
-
|
|
182
|
-
npm install -g polymer-cli
|
|
183
|
-
```
|
|
184
|
-
|
|
185
|
-
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:
|
|
186
207
|
|
|
187
208
|
```shell
|
|
188
|
-
|
|
209
|
+
npm start
|
|
189
210
|
```
|
|
190
211
|
|
|
191
|
-
|
|
212
|
+
### Linting
|
|
192
213
|
|
|
193
214
|
```shell
|
|
215
|
+
# eslint, lit-analyzer, polymer lint and style linting
|
|
194
216
|
npm run lint
|
|
195
|
-
```
|
|
196
217
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
```shell
|
|
200
|
-
npm run test:polymer:local
|
|
218
|
+
# eslint only
|
|
219
|
+
npm run lint:eslint
|
|
201
220
|
```
|
|
202
221
|
|
|
203
|
-
|
|
222
|
+
### Testing
|
|
204
223
|
|
|
205
224
|
```shell
|
|
225
|
+
# lint & run headless unit tests
|
|
206
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
|
|
207
233
|
```
|
|
208
234
|
|
|
209
235
|
## Versioning & Releasing
|
|
210
236
|
|
|
211
|
-
> TL;DR: Commits prefixed with `fix:` and `feat:` will trigger patch and minor releases when merged to `
|
|
237
|
+
> TL;DR: Commits prefixed with `fix:` and `feat:` will trigger patch and minor releases when merged to `main`. Read on for more details...
|
|
212
238
|
|
|
213
|
-
The [
|
|
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.
|
|
214
240
|
|
|
215
241
|
### Version Changes
|
|
216
242
|
|
|
@@ -0,0 +1,205 @@
|
|
|
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/lit-element.js';
|
|
5
|
+
import { announce } from '@brightspace-ui/core/helpers/announce.js';
|
|
6
|
+
import { bodyCompactStyles } from '@brightspace-ui/core/components/typography/styles.js';
|
|
7
|
+
import { IdSubscriberController } from '@brightspace-ui/core/controllers/subscriber/subscriberControllers.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
|
+
|
|
11
|
+
// eslint-disable-next-line sort-imports
|
|
12
|
+
import ar from './lang/ar-sa.js';
|
|
13
|
+
import de from './lang/de.js';
|
|
14
|
+
import en from './lang/en.js';
|
|
15
|
+
import es from './lang/es.js';
|
|
16
|
+
import esMx from './lang/es-mx.js';
|
|
17
|
+
import fi from './lang/fi.js';
|
|
18
|
+
import fr from './lang/fr.js';
|
|
19
|
+
import frCa from './lang/fr-ca.js';
|
|
20
|
+
import ja from './lang/ja.js';
|
|
21
|
+
import ko from './lang/ko.js';
|
|
22
|
+
import nb from './lang/nb.js';
|
|
23
|
+
import nl from './lang/nl.js';
|
|
24
|
+
import pt from './lang/pt-br.js';
|
|
25
|
+
import sv from './lang/sv.js';
|
|
26
|
+
import tr from './lang/tr.js';
|
|
27
|
+
import zhCn from './lang/zh-cn.js';
|
|
28
|
+
import zhTw from './lang/zh-tw.js';
|
|
29
|
+
|
|
30
|
+
const CLEAR_FILTERS_THRESHOLD = 4;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* A multi-select-list allowing the user to see (and remove) the currently applied filters, adjusted to work with the new core d2l-filter.
|
|
34
|
+
*/
|
|
35
|
+
class D2lLabsAppliedCoreFilters extends RtlMixin(LocalizeStaticMixin(LitElement)) {
|
|
36
|
+
static get properties() {
|
|
37
|
+
return {
|
|
38
|
+
/**
|
|
39
|
+
* Ids (space-delimited) of the filter components to subscribe to
|
|
40
|
+
* @type {string}
|
|
41
|
+
*/
|
|
42
|
+
filterIds: { type: String, attribute: 'filter-ids' },
|
|
43
|
+
/**
|
|
44
|
+
* Optional: The text displayed in this component's label. Default: "Applied Filters:"
|
|
45
|
+
*/
|
|
46
|
+
labelText: { type: String, attribute: 'label-text' }
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
static get styles() {
|
|
51
|
+
return [bodyCompactStyles, css`
|
|
52
|
+
:host {
|
|
53
|
+
display: block;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
d2l-labs-multi-select-list {
|
|
57
|
+
flex: 1;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.d2l-labs-applied-filters-wrapper {
|
|
61
|
+
display: flex;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.d2l-labs-applied-filters-label {
|
|
65
|
+
display: inline-block;
|
|
66
|
+
font-weight: bold;
|
|
67
|
+
margin-right: 0.25rem;
|
|
68
|
+
padding-top: 0.3rem;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
:host([dir="rtl"]) .d2l-labs-applied-filters-label {
|
|
72
|
+
margin-left: 0.25rem;
|
|
73
|
+
margin-right: 0;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.d2l-labs-applied-filters-none-label {
|
|
77
|
+
color: var(--d2l-color-corundum);
|
|
78
|
+
display: inline-block;
|
|
79
|
+
font-style: italic;
|
|
80
|
+
padding-top: 0.3rem;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
#d2l-clear-filters-button {
|
|
84
|
+
margin-left: 3px;
|
|
85
|
+
margin-right: 3px;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
#d2l-list-holder {
|
|
89
|
+
flex: 1;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
:host([hidden]) {
|
|
93
|
+
display: none;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
[hidden] {
|
|
97
|
+
display: none;
|
|
98
|
+
}
|
|
99
|
+
`];
|
|
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
|
+
|
|
113
|
+
static get resources() {
|
|
114
|
+
return {
|
|
115
|
+
'ar': ar,
|
|
116
|
+
'de': de,
|
|
117
|
+
'en': en,
|
|
118
|
+
'es': es,
|
|
119
|
+
'es-mx': esMx,
|
|
120
|
+
'fi': fi,
|
|
121
|
+
'fr': fr,
|
|
122
|
+
'fr-ca': frCa,
|
|
123
|
+
'ja': ja,
|
|
124
|
+
'ko': ko,
|
|
125
|
+
'nb': nb,
|
|
126
|
+
'nl': nl,
|
|
127
|
+
'pt': pt,
|
|
128
|
+
'sv': sv,
|
|
129
|
+
'tr': tr,
|
|
130
|
+
'zh-cn': zhCn,
|
|
131
|
+
'zh-tw': zhTw,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
disconnectedCallback() {
|
|
136
|
+
super.disconnectedCallback();
|
|
137
|
+
this._filters.hostDisconnected();
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
render() {
|
|
141
|
+
let numActiveFilters = 0;
|
|
142
|
+
const allActiveFilters = Array.from(this._allActiveFilters);
|
|
143
|
+
let filters = html`
|
|
144
|
+
<d2l-labs-multi-select-list
|
|
145
|
+
collapsable
|
|
146
|
+
aria-labelledby="d2l-labs-applied-filters-label">
|
|
147
|
+
${allActiveFilters.map(filter => filter[1].map((value, index) => { numActiveFilters++; return html`
|
|
148
|
+
<d2l-labs-multi-select-list-item
|
|
149
|
+
text="${value.text}"
|
|
150
|
+
deletable
|
|
151
|
+
data-filter-id="${filter[0]}"
|
|
152
|
+
data-index="${index}"
|
|
153
|
+
@d2l-labs-multi-select-list-item-deleted="${this._multiSelectItemDeleted}">
|
|
154
|
+
</d2l-labs-multi-select-list-item>
|
|
155
|
+
`;}))}
|
|
156
|
+
</d2l-labs-multi-select-list>
|
|
157
|
+
`;
|
|
158
|
+
if (numActiveFilters === 0) filters = html`<span class="d2l-labs-applied-filters-none-label d2l-body-compact">${this.localize('noActiveFilters')}</span>`;
|
|
159
|
+
|
|
160
|
+
return html`
|
|
161
|
+
<div class="d2l-labs-applied-filters-wrapper">
|
|
162
|
+
<span id="d2l-labs-applied-filters-label" class="d2l-labs-applied-filters-label d2l-body-compact">${this.labelText || this.localize('appliedFilters')}</span>
|
|
163
|
+
<div id="d2l-list-holder">
|
|
164
|
+
${filters}
|
|
165
|
+
<d2l-button-subtle id="d2l-clear-filters-button" text="${this.localize('clearFilters')}" ?hidden="${numActiveFilters < CLEAR_FILTERS_THRESHOLD}" @click="${this._clearFiltersClicked}"></d2l-button-subtle>
|
|
166
|
+
</div>
|
|
167
|
+
</div>
|
|
168
|
+
`;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
updated(changedProperties) {
|
|
172
|
+
super.updated(changedProperties);
|
|
173
|
+
this._filters.hostUpdated(changedProperties);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
updateActiveFilters(filterId, activeFilters) {
|
|
177
|
+
this._allActiveFilters.set(filterId, activeFilters);
|
|
178
|
+
this.requestUpdate();
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
_clearFiltersClicked() {
|
|
182
|
+
this._filters.registries.forEach((filter, index) => {
|
|
183
|
+
if (index === 0) filter.focus();
|
|
184
|
+
filter.requestFilterClearAll();
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
_multiSelectItemDeleted(e) {
|
|
189
|
+
const filterId = e.target.getAttribute('data-filter-id');
|
|
190
|
+
const filterValueIndex = e.target.getAttribute('data-index');
|
|
191
|
+
const filterValue = this._allActiveFilters.get(filterId)[filterValueIndex];
|
|
192
|
+
const filter = this._filters.registries.find(filter => filter.id === filterId);
|
|
193
|
+
filter.requestFilterValueClear(filterValue.keyObject);
|
|
194
|
+
|
|
195
|
+
announce(this.localize('filterRemoved', 'filterText', e.target.text));
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
_removeLostFilter(filterId) {
|
|
199
|
+
this._allActiveFilters.delete(filterId);
|
|
200
|
+
this.requestUpdate();
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
customElements.define('d2l-labs-applied-core-filters', D2lLabsAppliedCoreFilters);
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
import '@brightspace-ui-labs/multi-select/multi-select-list';
|
|
3
|
-
import '@brightspace-ui-labs/multi-select/multi-select-list-item';
|
|
4
|
-
import {
|
|
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/lit-element.js';
|
|
7
5
|
import { announce } from '@brightspace-ui/core/helpers/announce.js';
|
|
8
6
|
import { bodyCompactStyles } from '@brightspace-ui/core/components/typography/styles.js';
|
|
9
7
|
import { getComposedChildren } from '@brightspace-ui/core/helpers/dom';
|
|
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
|
-
|
|
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
|
}
|
|
@@ -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) => {
|
package/custom-elements.json
CHANGED
|
@@ -1,6 +1,39 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": "experimental",
|
|
3
3
|
"tags": [
|
|
4
|
+
{
|
|
5
|
+
"name": "d2l-labs-applied-core-filters",
|
|
6
|
+
"path": "./components/applied-filters/applied-core-filters.js",
|
|
7
|
+
"description": "A multi-select-list allowing the user to see (and remove) the currently applied filters, adjusted to work with the new core d2l-filter.",
|
|
8
|
+
"attributes": [
|
|
9
|
+
{
|
|
10
|
+
"name": "filter-ids",
|
|
11
|
+
"description": "Ids (space-delimited) of the filter components to subscribe to",
|
|
12
|
+
"type": "string"
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"name": "label-text",
|
|
16
|
+
"description": "Optional: The text displayed in this component's label. Default: \"Applied Filters:\"",
|
|
17
|
+
"type": "string",
|
|
18
|
+
"default": "\"\""
|
|
19
|
+
}
|
|
20
|
+
],
|
|
21
|
+
"properties": [
|
|
22
|
+
{
|
|
23
|
+
"name": "filterIds",
|
|
24
|
+
"attribute": "filter-ids",
|
|
25
|
+
"description": "Ids (space-delimited) of the filter components to subscribe to",
|
|
26
|
+
"type": "string"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"name": "labelText",
|
|
30
|
+
"attribute": "label-text",
|
|
31
|
+
"description": "Optional: The text displayed in this component's label. Default: \"Applied Filters:\"",
|
|
32
|
+
"type": "string",
|
|
33
|
+
"default": "\"\""
|
|
34
|
+
}
|
|
35
|
+
]
|
|
36
|
+
},
|
|
4
37
|
{
|
|
5
38
|
"name": "d2l-labs-applied-filters",
|
|
6
39
|
"path": "./components/applied-filters/applied-filters.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,33 +14,42 @@
|
|
|
13
14
|
"/components"
|
|
14
15
|
],
|
|
15
16
|
"scripts": {
|
|
16
|
-
"lint": "npm run lint:
|
|
17
|
-
"lint:
|
|
18
|
-
"lint:
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
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",
|
|
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
|
-
"@
|
|
27
|
-
"@
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
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-
|
|
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
|
-
"
|
|
45
|
+
"sinon": "^12",
|
|
46
|
+
"stylelint": "^14"
|
|
36
47
|
},
|
|
37
|
-
"version": "4.
|
|
48
|
+
"version": "4.2.2",
|
|
38
49
|
"dependencies": {
|
|
39
50
|
"@brightspace-ui/core": "^1",
|
|
40
51
|
"d2l-localize-behavior": "BrightspaceUI/localize-behavior#semver:^2",
|
|
41
|
-
"@brightspace-ui-labs/multi-select": "^
|
|
42
|
-
"d2l-polymer-behaviors": "Brightspace/d2l-polymer-behaviors-ui#semver:^2",
|
|
52
|
+
"@brightspace-ui-labs/multi-select": "^5",
|
|
43
53
|
"d2l-typography": "BrightspaceUI/typography#semver:^7",
|
|
44
54
|
"lit-element": "^2",
|
|
45
55
|
"@polymer/polymer": "^3"
|