@brightspace-ui/core 1.208.0 → 1.209.1
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/alert/README.md +22 -5
- package/components/dialog/README.md +5 -1
- package/components/form/form-element-mixin.js +13 -0
- package/components/html-block/demo/html-block.html +1 -1
- package/components/html-block/html-block.js +2 -0
- package/components/inputs/input-date-time.js +16 -0
- package/helpers/mathjax.js +2 -0
- package/package.json +5 -5
|
@@ -4,21 +4,38 @@ Alerts communicate critical information relating to the state of the system and
|
|
|
4
4
|
<!-- docs: demo autoSize:false align:start -->
|
|
5
5
|
```html
|
|
6
6
|
<script type="module">
|
|
7
|
-
|
|
7
|
+
import '@brightspace-ui/core/components/alert/alert-toast.js';
|
|
8
|
+
import '@brightspace-ui/core/components/button/button.js';
|
|
9
|
+
|
|
10
|
+
var alert = document.querySelector('#alert');
|
|
11
|
+
var alertToast = document.querySelector('#alert-toast');
|
|
12
|
+
var button = document.querySelector('#open');
|
|
13
|
+
|
|
14
|
+
alert.addEventListener('d2l-alert-close', function() {
|
|
15
|
+
if (!alertToast.open) button.style.display = 'block';
|
|
16
|
+
});
|
|
17
|
+
alertToast.addEventListener('d2l-alert-toast-close', function() {
|
|
18
|
+
if (alert.hasAttribute('hidden')) button.style.display = 'block';
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
button.addEventListener('click', () => {
|
|
22
|
+
alert.removeAttribute('hidden');
|
|
23
|
+
alertToast.open = true;
|
|
24
|
+
button.style.display = 'none';
|
|
25
|
+
});
|
|
8
26
|
</script>
|
|
9
|
-
<!-- docs: start hidden content -->
|
|
10
27
|
<style>
|
|
11
28
|
d2l-alert-toast {
|
|
12
29
|
margin-left: 0 !important;
|
|
13
30
|
margin-right: 0 !important;
|
|
14
31
|
}
|
|
15
32
|
</style>
|
|
16
|
-
<!-- docs: end hidden content -->
|
|
17
33
|
|
|
18
|
-
<d2l-
|
|
34
|
+
<d2l-button id="open" style="align-self:center;display:none;">Show Alerts</d2l-button>
|
|
35
|
+
<d2l-alert id="alert" type="default" button-text="Undo" has-close-button>
|
|
19
36
|
A message.
|
|
20
37
|
</d2l-alert>
|
|
21
|
-
<d2l-alert-toast type="success" open no-auto-close>
|
|
38
|
+
<d2l-alert-toast id="alert-toast" type="success" open no-auto-close>
|
|
22
39
|
A message.
|
|
23
40
|
</d2l-alert-toast>
|
|
24
41
|
```
|
|
@@ -7,13 +7,17 @@ Dialogs interrupt the user to complete a set of tasks, confirm an action, or off
|
|
|
7
7
|
<script type="module">
|
|
8
8
|
import '@brightspace-ui/core/components/button/button.js';
|
|
9
9
|
import '@brightspace-ui/core/components/dialog/dialog.js';
|
|
10
|
-
</script>
|
|
11
10
|
|
|
11
|
+
document.querySelector('#open-demo').addEventListener('click', () => {
|
|
12
|
+
document.querySelector('#dialog-demo').opened = true;
|
|
13
|
+
});
|
|
14
|
+
</script>
|
|
12
15
|
<d2l-dialog id="dialog-demo" title-text="Dialog Title">
|
|
13
16
|
<div>Some dialog content</div>
|
|
14
17
|
<d2l-button slot="footer" primary data-dialog-action="done">Done</d2l-button>
|
|
15
18
|
<d2l-button slot="footer" data-dialog-action>Cancel</d2l-button>
|
|
16
19
|
</d2l-dialog>
|
|
20
|
+
<d2l-button id="open-demo">Show Dialog</d2l-button>
|
|
17
21
|
```
|
|
18
22
|
|
|
19
23
|
## General Dialog [d2l-dialog]
|
|
@@ -97,6 +97,11 @@ export const FormElementMixin = superclass => class extends LocalizeCoreElement(
|
|
|
97
97
|
* @ignore
|
|
98
98
|
*/
|
|
99
99
|
noValidate: { type: Boolean, attribute: 'novalidate' },
|
|
100
|
+
/**
|
|
101
|
+
* @ignore
|
|
102
|
+
* Perform validation immediately instead of waiting for the user to make changes.
|
|
103
|
+
*/
|
|
104
|
+
validateOnInit: { type: Boolean, attribute: 'validate-on-init' },
|
|
100
105
|
/**
|
|
101
106
|
* @ignore
|
|
102
107
|
*/
|
|
@@ -125,6 +130,8 @@ export const FormElementMixin = superclass => class extends LocalizeCoreElement(
|
|
|
125
130
|
/** @ignore */
|
|
126
131
|
this.noValidate = false;
|
|
127
132
|
/** @ignore */
|
|
133
|
+
this.validateOnInit = false;
|
|
134
|
+
/** @ignore */
|
|
128
135
|
this.validationError = null;
|
|
129
136
|
/** @ignore */
|
|
130
137
|
this.childErrors = new Map();
|
|
@@ -171,6 +178,9 @@ export const FormElementMixin = superclass => class extends LocalizeCoreElement(
|
|
|
171
178
|
this.dispatchEvent(new CustomEvent('invalid-change'));
|
|
172
179
|
}
|
|
173
180
|
}
|
|
181
|
+
if (this.validateOnInit && (changedProperties.has('noValidate') || changedProperties.has('validateOnInit'))) {
|
|
182
|
+
this.requestValidate(true);
|
|
183
|
+
}
|
|
174
184
|
}
|
|
175
185
|
|
|
176
186
|
async requestValidate(showNewErrors = true) {
|
|
@@ -210,6 +220,9 @@ export const FormElementMixin = superclass => class extends LocalizeCoreElement(
|
|
|
210
220
|
|
|
211
221
|
validationCustomConnected(custom) {
|
|
212
222
|
this._validationCustoms.add(custom);
|
|
223
|
+
if (this.validateOnInit) {
|
|
224
|
+
this.requestValidate(true);
|
|
225
|
+
}
|
|
213
226
|
}
|
|
214
227
|
|
|
215
228
|
validationCustomDisconnected(custom) {
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
|
|
43
43
|
</script>
|
|
44
44
|
<script>
|
|
45
|
-
document.getElementsByTagName('html')[0].dataset.mathjaxContext = JSON.stringify({ renderLatex: window.location.search.indexOf('latex=true') !== -1 });
|
|
45
|
+
document.getElementsByTagName('html')[0].dataset.mathjaxContext = JSON.stringify({ outputScale: 1.1, renderLatex: window.location.search.indexOf('latex=true') !== -1 });
|
|
46
46
|
</script>
|
|
47
47
|
</head>
|
|
48
48
|
<body unresolved>
|
|
@@ -245,8 +245,10 @@ class HtmlBlock extends LitElement {
|
|
|
245
245
|
if (fragment) {
|
|
246
246
|
|
|
247
247
|
let temp = document.createElement('div');
|
|
248
|
+
temp.style.display = 'none';
|
|
248
249
|
temp.appendChild(fragment);
|
|
249
250
|
|
|
251
|
+
this._renderContainer.appendChild(temp);
|
|
250
252
|
temp = await this._processRenderers(temp);
|
|
251
253
|
this._renderContainer.innerHTML = temp.innerHTML;
|
|
252
254
|
|
|
@@ -15,6 +15,7 @@ import { formatDateInISO,
|
|
|
15
15
|
parseISOTime } from '../../helpers/dateTime.js';
|
|
16
16
|
import { FormElementMixin } from '../form/form-element-mixin.js';
|
|
17
17
|
import { getDefaultTime } from './input-time.js';
|
|
18
|
+
import { getDocumentLocaleSettings } from '@brightspace-ui/intl/lib/common.js';
|
|
18
19
|
import { getUniqueId } from '../../helpers/uniqueId.js';
|
|
19
20
|
import { ifDefined } from 'lit-html/directives/if-defined.js';
|
|
20
21
|
import { LabelledMixin } from '../../mixins/labelled-mixin.js';
|
|
@@ -119,6 +120,7 @@ class InputDateTime extends LabelledMixin(SkeletonMixin(FormElementMixin(Localiz
|
|
|
119
120
|
this.opened = false;
|
|
120
121
|
this.required = false;
|
|
121
122
|
this.timeDefaultValue = 'startOfDay';
|
|
123
|
+
this._documentLocaleSettings = getDocumentLocaleSettings();
|
|
122
124
|
this._inputId = getUniqueId();
|
|
123
125
|
this._namespace = 'components.input-date-time';
|
|
124
126
|
this._preventDefaultValidation = false;
|
|
@@ -190,6 +192,16 @@ class InputDateTime extends LabelledMixin(SkeletonMixin(FormElementMixin(Localiz
|
|
|
190
192
|
return super.validationMessage;
|
|
191
193
|
}
|
|
192
194
|
|
|
195
|
+
connectedCallback() {
|
|
196
|
+
super.connectedCallback();
|
|
197
|
+
this._documentLocaleSettings.addChangeListener(this._handleLocaleChange.bind(this));
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
disconnectedCallback() {
|
|
201
|
+
super.disconnectedCallback();
|
|
202
|
+
this._documentLocaleSettings.removeChangeListener(this._handleLocaleChange.bind(this));
|
|
203
|
+
}
|
|
204
|
+
|
|
193
205
|
firstUpdated(changedProperties) {
|
|
194
206
|
super.firstUpdated(changedProperties);
|
|
195
207
|
|
|
@@ -343,6 +355,10 @@ class InputDateTime extends LabelledMixin(SkeletonMixin(FormElementMixin(Localiz
|
|
|
343
355
|
if (tooltip) tooltip.show();
|
|
344
356
|
}
|
|
345
357
|
|
|
358
|
+
_handleLocaleChange() {
|
|
359
|
+
this.requestUpdate();
|
|
360
|
+
}
|
|
361
|
+
|
|
346
362
|
async _handleTimeChange(e) {
|
|
347
363
|
const date = this.shadowRoot.querySelector('d2l-input-date').value;
|
|
348
364
|
const time = e.target.value;
|
package/helpers/mathjax.js
CHANGED
|
@@ -32,9 +32,11 @@ export class HtmlBlockMathRenderer {
|
|
|
32
32
|
await loadMathJax(mathJaxConfig);
|
|
33
33
|
|
|
34
34
|
const temp = document.createElement('div');
|
|
35
|
+
temp.style.display = 'none';
|
|
35
36
|
temp.attachShadow({ mode: 'open' });
|
|
36
37
|
temp.shadowRoot.innerHTML = `<div><mjx-doc><mjx-head></mjx-head><mjx-body>${elem.innerHTML}</mjx-body></mjx-doc></div>`;
|
|
37
38
|
|
|
39
|
+
elem.appendChild(temp);
|
|
38
40
|
window.MathJax.typesetShadow(temp.shadowRoot);
|
|
39
41
|
return temp.shadowRoot.firstChild;
|
|
40
42
|
}
|
package/package.json
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brightspace-ui/core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.209.1",
|
|
4
4
|
"description": "A collection of accessible, free, open-source web components for building Brightspace applications",
|
|
5
5
|
"repository": "https://github.com/BrightspaceUI/core.git",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
8
8
|
},
|
|
9
9
|
"scripts": {
|
|
10
|
-
"build:clean": "node ./cli/clean.
|
|
11
|
-
"build:icons": "node ./cli/icon-generator.
|
|
10
|
+
"build:clean": "node ./cli/clean.mjs",
|
|
11
|
+
"build:icons": "node ./cli/icon-generator.mjs",
|
|
12
12
|
"build:sass": "node-sass --output-style expanded ./test/sass.scss > ./test/sass.output.css",
|
|
13
13
|
"build": "npm run build:clean && npm run build:icons && npm run build:sass",
|
|
14
14
|
"lint": "npm run lint:eslint && npm run lint:style && npm run lint:lit",
|
|
15
|
-
"lint:eslint": "eslint . --ext .js,.html",
|
|
15
|
+
"lint:eslint": "eslint . --ext .js,.mjs,.html",
|
|
16
16
|
"lint:lit": "lit-analyzer \"{components,directives,helpers,mixins,templates,test,tools}/**/*.js\" --strict",
|
|
17
17
|
"lint:style": "stylelint \"**/*.{js,html}\"",
|
|
18
18
|
"start": "web-dev-server --node-resolve --watch --open",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"@web/test-runner": "^0.13",
|
|
49
49
|
"@web/test-runner-playwright": "^0.8.8",
|
|
50
50
|
"axe-core": "^4",
|
|
51
|
-
"chalk": "^
|
|
51
|
+
"chalk": "^5",
|
|
52
52
|
"eslint": "^7",
|
|
53
53
|
"eslint-config-brightspace": "^0.16",
|
|
54
54
|
"eslint-plugin-html": "^6",
|