@brightspace-ui/core 3.334.0 → 3.335.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/filter.js +2 -3
- package/helpers/README.md +14 -0
- package/helpers/trusted-types.js +21 -0
- package/package.json +2 -1
|
@@ -436,11 +436,10 @@ class Filter extends FocusMixin(LocalizeCoreElement(LitElement)) {
|
|
|
436
436
|
}
|
|
437
437
|
return this._dimensions.map((dimension) => {
|
|
438
438
|
const builtDimension = this._buildDimension(dimension);
|
|
439
|
-
const countBadgeId = `filters-applied-count-${dimension.key}`;
|
|
440
439
|
const filtersAppliedText = `${this.localize('components.filter.filterCountDescription', { number: dimension.appliedCount })}`;
|
|
441
|
-
return html`<d2l-menu-item text="${dimension.text}" description="${dimension.text}.
|
|
440
|
+
return html`<d2l-menu-item text="${dimension.text}" description="${dimension.text}. ${filtersAppliedText}">
|
|
442
441
|
<div slot="supporting">
|
|
443
|
-
<d2l-count-badge
|
|
442
|
+
<d2l-count-badge number="${dimension.appliedCount}" max-digits="2" text="${filtersAppliedText}" hide-zero></d2l-count-badge>
|
|
444
443
|
</div>
|
|
445
444
|
${builtDimension}
|
|
446
445
|
</d2l-menu-item>`;
|
package/helpers/README.md
CHANGED
|
@@ -275,6 +275,20 @@ requestIdleCallback((deadline) => {
|
|
|
275
275
|
}, { timeout: 1000 });
|
|
276
276
|
```
|
|
277
277
|
|
|
278
|
+
## Trusted Types
|
|
279
|
+
|
|
280
|
+
The Trusted Types module provides a polyfill for the browser's TrustedTypes API along with Trusted Type policies. These policies provide a `createHTML` method for creating TrustedHTML objects that can be passed to injection sinks like `innerHTML`.
|
|
281
|
+
|
|
282
|
+
```js
|
|
283
|
+
import { markdownHtmlPolicy, safeHtmlPolicy } from '@brightspace-ui/core/helpers/trusted-types.js';
|
|
284
|
+
|
|
285
|
+
// filters HTML string and returns TrustedHTML
|
|
286
|
+
const result = safeHtmlPolicy.createHTML(html);
|
|
287
|
+
|
|
288
|
+
// filters HTML string for Markdown supported elements and returns TrustedHTML
|
|
289
|
+
const result = markdownHtmlPolicy.createHTML(html);
|
|
290
|
+
```
|
|
291
|
+
|
|
278
292
|
## UniqueId
|
|
279
293
|
|
|
280
294
|
A simple helper that returns a unique id.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import DOMPurify from 'dompurify';
|
|
2
|
+
|
|
3
|
+
if (typeof globalThis.trustedTypes === 'undefined') {
|
|
4
|
+
globalThis.trustedTypes = { createPolicy: (name, rules) => rules };
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export const safeHtmlPolicy = globalThis.trustedTypes.createPolicy('safe-html', {
|
|
8
|
+
createHTML: (input) => DOMPurify.sanitize(input, {
|
|
9
|
+
TRUSTED_TYPES_POLICY: null
|
|
10
|
+
})
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
export const markdownHtmlPolicy = globalThis.trustedTypes.createPolicy('markdown-html', {
|
|
14
|
+
createHTML: (input) => DOMPurify.sanitize(input, {
|
|
15
|
+
ALLOWED_TAGS: ['a', 'blockquote', 'br', 'code', 'em', 'li', 'ol', 'p', 'pre', 'strong', 'ul'],
|
|
16
|
+
ALLOWED_ATTR: ['class', 'href', 'start', 'title'],
|
|
17
|
+
ALLOW_ARIA_ATTR: false,
|
|
18
|
+
ALLOW_DATA_ATTR: false,
|
|
19
|
+
TRUSTED_TYPES_POLICY: null
|
|
20
|
+
})
|
|
21
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brightspace-ui/core",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.335.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",
|
|
@@ -76,6 +76,7 @@
|
|
|
76
76
|
"@brightspace-ui/intl": "^3",
|
|
77
77
|
"@brightspace-ui/lms-context-provider": "^1",
|
|
78
78
|
"@open-wc/dedupe-mixin": "^2",
|
|
79
|
+
"dompurify": "^3.4.17",
|
|
79
80
|
"ifrau": "^0.42",
|
|
80
81
|
"lit": "^3",
|
|
81
82
|
"prismjs": "^1"
|