@brightspace-ui/core 3.14.0 → 3.15.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/components/filter/README.md +34 -0
- package/package.json +1 -1
@@ -263,6 +263,40 @@ This component is built to be used alongside the [d2l-filter-dimension-set](#d2l
|
|
263
263
|
| `selected` | Boolean, default: `false` | Whether the value in the filter is selected or not |
|
264
264
|
<!-- docs: end hidden content -->
|
265
265
|
|
266
|
+
### Dimension Set Value: Custom Preset Date Range
|
267
|
+
|
268
|
+
In order to create a selectable filter list item that is a text item representing a range that is NOT one of the presets available in the `d2l-filter-dimension-set-date-text-value` component (for example, 60 days), use the regular "Dimension Set Value" component (`d2l-filter-dimension-set-value`) with the localized text of the range in the `text` field, and handle its selection as is appropriate for the consuming application.
|
269
|
+
|
270
|
+
The `getUTCDateTimeRange(rangeType, diff)` helper function can be used to get the `startValue` and `endValue` for the range in ISO strings in UTC, if required. As arguments it takes a `rangeType` (one of `seconds`, `minutes`, `hours`, `days`, `months`, or `years`) and a `diff` (positive or negative number where negative is a range in the past and positive is a range in the future). Either the `startValue` or `endValue` is the current date/time depending on whether the range is in the past or future.
|
271
|
+
|
272
|
+
<!-- docs: demo code align:start autoOpen:true autoSize:false size:large -->
|
273
|
+
```html
|
274
|
+
<script type="module">
|
275
|
+
import '@brightspace-ui/core/components/filter/filter.js';
|
276
|
+
import '@brightspace-ui/core/components/filter/filter-dimension-set.js';
|
277
|
+
import '@brightspace-ui/core/components/filter/filter-dimension-set-value.js';
|
278
|
+
import { getUTCDateTimeRange } from '@brightspace-ui/core/helpers/dateTime.js';
|
279
|
+
|
280
|
+
document.querySelector('d2l-filter').addEventListener('d2l-filter-change', e => {
|
281
|
+
const changes = e.detail.dimensions[0].changes;
|
282
|
+
if (!changes || changes.length === 0) return;
|
283
|
+
let dateTimeRange;
|
284
|
+
if (changes[0].valueKey === '60days' && changes[0].selected) {
|
285
|
+
dateTimeRange = getUTCDateTimeRange('days', -60);
|
286
|
+
} else if (changes[0].valueKey === '8months' && changes[0].selected) {
|
287
|
+
dateTimeRange = getUTCDateTimeRange('months', -8);
|
288
|
+
}
|
289
|
+
if (dateTimeRange) console.log('start date', dateTimeRange.startValue, 'end date', dateTimeRange.endValue);
|
290
|
+
});
|
291
|
+
</script>
|
292
|
+
<d2l-filter>
|
293
|
+
<d2l-filter-dimension-set key="dates" text="Dates" selection-single>
|
294
|
+
<d2l-filter-dimension-set-value key="60days" text="60 days"></d2l-filter-dimension-set-value>
|
295
|
+
<d2l-filter-dimension-set-value key="8months" text="8 months"></d2l-filter-dimension-set-value>
|
296
|
+
</d2l-filter-dimension-set>
|
297
|
+
</d2l-filter>
|
298
|
+
```
|
299
|
+
|
266
300
|
## Search and Paging
|
267
301
|
|
268
302
|
Most filters will not need search or paging features since filter value lists are generally short. For longer lists of filter values when Search is necessary, it can be enabled by setting search-type to `automatic` or `manual`.
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@brightspace-ui/core",
|
3
|
-
"version": "3.
|
3
|
+
"version": "3.15.0",
|
4
4
|
"description": "A collection of accessible, free, open-source web components for building Brightspace applications",
|
5
5
|
"type": "module",
|
6
6
|
"repository": "https://github.com/BrightspaceUI/core.git",
|