@brightspace-ui-labs/facet-filter-sort 5.3.0 → 5.4.0

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
@@ -31,7 +31,6 @@ npm install @brightspace-ui-labs/facet-filter-sort
31
31
  - [d2l-labs-search-facets](#d2l-labs-search-facets)
32
32
  - [d2l-labs-search-results-count](#d2l-labs-search-results-count)
33
33
  - [d2l-labs-sort-by-dropdown](#d2l-labs-sort-by-dropdown)
34
- - [d2l-labs-applied-core-filters](#d2l-labs-applied-core-filters)
35
34
 
36
35
  ### d2l-labs-search-facets
37
36
 
@@ -61,7 +60,6 @@ To Do
61
60
 
62
61
  - [d2l-labs-filter-dropdown](#d2l-labs-filter-dropdown)
63
62
  - [d2l-labs-applied-filters](#d2l-labs-applied-filters)
64
- - [d2l-labs-applied-core-filters](#d2l-labs-applied-core-filters)
65
63
 
66
64
  ### d2l-labs-filter-dropdown
67
65
 
@@ -157,7 +155,7 @@ Note that for the header and opener text overrides, if the terms are to reflect
157
155
 
158
156
  ### d2l-labs-applied-filters
159
157
 
160
- 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).
158
+ A multi-select-list allowing the user to see (and remove) the currently applied filters. Works with the `d2l-labs-filter-dropdown` above.
161
159
 
162
160
  NOTE: This component uses the `slotchange` event and so will not work if you require IE support
163
161
 
@@ -178,28 +176,6 @@ This also works if the `d2l-labs-filter-dropdown` is a child in the shadow-dom o
178
176
  <d2l-labs-filter-dropdown id="filter"> ... </d2l-labs-filter-dropdown>
179
177
  ```
180
178
 
181
- ### d2l-labs-applied-core-filters
182
-
183
- **DEPRECATED: Use [`d2l-filter-tags`](https://github.com/BrightspaceUI/core/tree/main/components/filter#tags-for-applied-filters-d2l-filter-tags) in `BrightspaceUI/core`.**
184
-
185
- The same design as the deprecated `d2l-labs-applied-filters` above, 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.
186
-
187
- #### Attributes
188
-
189
- - `filter-ids`: Ids (space-delimited) of the filter components to subscribe to
190
- - `label-text` (optional): The text displayed in this component's label. Defaults to "Applied Filters:".
191
-
192
- #### Usage
193
-
194
- Set the `filter-ids` param to the ids of the `d2l-filter`s that you want to track.
195
- The `d2l-filter`s must be in the same DOM scope.
196
-
197
- ```html
198
- <d2l-filter id="course"> ... </d2l-filter>
199
- <d2l-filter id="role"> ... </d2l-filter>
200
- <d2l-labs-applied-core-filters filter-ids="course role"></d2l-labs-applied-core-filters>
201
- ```
202
-
203
179
  ## Developing
204
180
 
205
181
  After cloning the repo, run `npm install` to install dependencies.
@@ -1,39 +1,6 @@
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
- },
37
4
  {
38
5
  "name": "d2l-labs-applied-filters",
39
6
  "path": "./components/applied-filters/applied-filters.js",
@@ -64,6 +31,10 @@
64
31
  "description": "Optional: The text displayed in this component's label. Default: \"Applied Filters:\"",
65
32
  "type": "string",
66
33
  "default": "\"\""
34
+ },
35
+ {
36
+ "name": "documentLocaleSettings",
37
+ "default": "\"getDocumentLocaleSettings()\""
67
38
  }
68
39
  ]
69
40
  },
@@ -154,6 +125,10 @@
154
125
  "type": "number",
155
126
  "default": "0"
156
127
  },
128
+ {
129
+ "name": "documentLocaleSettings",
130
+ "default": "\"getDocumentLocaleSettings()\""
131
+ },
157
132
  {
158
133
  "name": "text",
159
134
  "attribute": "text",
package/package.json CHANGED
@@ -44,7 +44,7 @@
44
44
  "sinon": "^13",
45
45
  "stylelint": "^14"
46
46
  },
47
- "version": "5.3.0",
47
+ "version": "5.4.0",
48
48
  "dependencies": {
49
49
  "@brightspace-ui/core": "^2",
50
50
  "@brightspace-ui/localize-behavior": "^2",
@@ -1,154 +0,0 @@
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';
5
- import { announce } from '@brightspace-ui/core/helpers/announce.js';
6
- import { bodyCompactStyles } from '@brightspace-ui/core/components/typography/styles.js';
7
- import { FilterLocalizeMixin } from '../localize-mixin.js';
8
- import { IdSubscriberController } from '@brightspace-ui/core/controllers/subscriber/subscriberControllers.js';
9
- import { RtlMixin } from '@brightspace-ui/core/mixins/rtl-mixin.js';
10
-
11
- const CLEAR_FILTERS_THRESHOLD = 4;
12
-
13
- /**
14
- * A multi-select-list allowing the user to see (and remove) the currently applied filters, adjusted to work with the new core d2l-filter.
15
- */
16
- class D2lLabsAppliedCoreFilters extends RtlMixin(FilterLocalizeMixin(LitElement)) {
17
- static get properties() {
18
- return {
19
- /**
20
- * Ids (space-delimited) of the filter components to subscribe to
21
- * @type {string}
22
- */
23
- filterIds: { type: String, attribute: 'filter-ids' },
24
- /**
25
- * Optional: The text displayed in this component's label. Default: "Applied Filters:"
26
- */
27
- labelText: { type: String, attribute: 'label-text' }
28
- };
29
- }
30
-
31
- static get styles() {
32
- return [bodyCompactStyles, css`
33
- :host {
34
- display: block;
35
- }
36
-
37
- d2l-labs-multi-select-list {
38
- flex: 1;
39
- }
40
-
41
- .d2l-labs-applied-filters-wrapper {
42
- display: flex;
43
- }
44
-
45
- .d2l-labs-applied-filters-label {
46
- display: inline-block;
47
- font-weight: bold;
48
- margin-right: 0.25rem;
49
- padding-top: 0.3rem;
50
- }
51
-
52
- :host([dir="rtl"]) .d2l-labs-applied-filters-label {
53
- margin-left: 0.25rem;
54
- margin-right: 0;
55
- }
56
-
57
- .d2l-labs-applied-filters-none-label {
58
- color: var(--d2l-color-corundum);
59
- display: inline-block;
60
- font-style: italic;
61
- padding-top: 0.3rem;
62
- }
63
-
64
- #d2l-clear-filters-button {
65
- margin-left: 3px;
66
- margin-right: 3px;
67
- }
68
-
69
- #d2l-list-holder {
70
- flex: 1;
71
- }
72
-
73
- :host([hidden]) {
74
- display: none;
75
- }
76
-
77
- [hidden] {
78
- display: none;
79
- }
80
- `];
81
- }
82
-
83
- constructor() {
84
- super();
85
- this.labelText = '';
86
-
87
- this._allActiveFilters = new Map();
88
- this._filters = new IdSubscriberController(this,
89
- { onUnsubscribe: this._removeLostFilter.bind(this) },
90
- { idPropertyName: 'filterIds' }
91
- );
92
- }
93
-
94
- render() {
95
- let numActiveFilters = 0;
96
- const allActiveFilters = Array.from(this._allActiveFilters);
97
- let filters = html`
98
- <d2l-labs-multi-select-list
99
- collapsable
100
- aria-labelledby="d2l-labs-applied-filters-label">
101
- ${allActiveFilters.map(filter => filter[1].map((value, index) => { numActiveFilters++; return html`
102
- <d2l-labs-multi-select-list-item
103
- text="${value.text}"
104
- deletable
105
- data-filter-id="${filter[0]}"
106
- data-index="${index}"
107
- @d2l-labs-multi-select-list-item-deleted="${this._multiSelectItemDeleted}">
108
- </d2l-labs-multi-select-list-item>
109
- `;}))}
110
- </d2l-labs-multi-select-list>
111
- `;
112
- if (numActiveFilters === 0) filters = html`<span class="d2l-labs-applied-filters-none-label d2l-body-compact">${this.localize('noActiveFilters')}</span>`;
113
-
114
- return html`
115
- <div class="d2l-labs-applied-filters-wrapper">
116
- <span id="d2l-labs-applied-filters-label" class="d2l-labs-applied-filters-label d2l-body-compact">${this.labelText || this.localize('appliedFilters')}</span>
117
- <div id="d2l-list-holder">
118
- ${filters}
119
- <d2l-button-subtle id="d2l-clear-filters-button" text="${this.localize('clearFilters')}" ?hidden="${numActiveFilters < CLEAR_FILTERS_THRESHOLD}" @click="${this._clearFiltersClicked}"></d2l-button-subtle>
120
- </div>
121
- </div>
122
- `;
123
- }
124
-
125
- updateActiveFilters(filterId, activeFilters) {
126
- this._allActiveFilters.set(filterId, activeFilters);
127
- this.requestUpdate();
128
- }
129
-
130
- _clearFiltersClicked() {
131
- this._filters.registries.forEach((filter, index) => {
132
- if (index === 0) filter.focus();
133
- filter.requestFilterClearAll();
134
- });
135
- }
136
-
137
- _multiSelectItemDeleted(e) {
138
- const filterId = e.target.getAttribute('data-filter-id');
139
- const filterValueIndex = e.target.getAttribute('data-index');
140
- const filterValue = this._allActiveFilters.get(filterId)[filterValueIndex];
141
- const filter = this._filters.registries.find(filter => filter.id === filterId);
142
- filter.requestFilterValueClear(filterValue.keyObject);
143
-
144
- announce(this.localize('filterRemoved', 'filterText', e.target.text));
145
- }
146
-
147
- _removeLostFilter(filterId) {
148
- this._allActiveFilters.delete(filterId);
149
- this.requestUpdate();
150
- }
151
-
152
- }
153
-
154
- customElements.define('d2l-labs-applied-core-filters', D2lLabsAppliedCoreFilters);