@brightspace-ui/core 3.46.1 → 3.47.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,13 +1,14 @@
1
1
  import '../colors/colors.js';
2
2
  import { codeStyles, createHtmlBlockRenderer as createCodeRenderer } from '../../helpers/prism.js';
3
- import { css, html, LitElement, nothing, unsafeCSS } from 'lit';
3
+ import { createRef, ref } from 'lit/directives/ref.js';
4
+ import { css, html, LitElement, unsafeCSS } from 'lit';
4
5
  import { classMap } from 'lit/directives/class-map.js';
5
6
  import { createHtmlBlockRenderer as createMathRenderer } from '../../helpers/mathjax.js';
6
7
  import { getFocusPseudoClass } from '../../helpers/focus.js';
8
+ import { LoadingCompleteMixin } from '../../mixins/loading-complete/loading-complete-mixin.js';
7
9
  import { renderEmbeds } from '../../helpers/embeds.js';
8
10
  import { requestInstance } from '../../mixins/provider/provider-mixin.js';
9
11
  import { tryGet } from '@brightspace-ui/lms-context-provider/client.js';
10
- import { until } from 'lit/directives/until.js';
11
12
 
12
13
  export const htmlBlockContentStyles = css`
13
14
  .d2l-html-block-rendered {
@@ -142,7 +143,7 @@ const getRenderers = async() => {
142
143
  /**
143
144
  * A component for displaying user-authored HTML.
144
145
  */
145
- class HtmlBlock extends LitElement {
146
+ class HtmlBlock extends LoadingCompleteMixin(LitElement) {
146
147
 
147
148
  static get properties() {
148
149
  return {
@@ -206,8 +207,7 @@ class HtmlBlock extends LitElement {
206
207
  this._initialContextResolve = undefined;
207
208
  this._initialContextPromise = new Promise(resolve => this._initialContextResolve = resolve);
208
209
 
209
- this._renderersProcessedResolve = undefined;
210
- this._renderersProcessedPromise = new Promise(resolve => this._renderersProcessedResolve = resolve);
210
+ this._renderContainerRef = createRef();
211
211
 
212
212
  const contextKeysPromise = getRenderers().then(renderers => renderers.reduce((keys, currentRenderer) => {
213
213
  if (currentRenderer.contextKeys) currentRenderer.contextKeys.forEach(key => keys.push(key));
@@ -216,10 +216,7 @@ class HtmlBlock extends LitElement {
216
216
 
217
217
  const contextValsPromise = contextKeysPromise.then(contextKeys => {
218
218
  return Promise.allSettled(contextKeys.map(key => {
219
- return tryGet(key, undefined, ctx => {
220
- this._context.set(key, ctx);
221
- this.updated(new Map([['_context']]));
222
- });
219
+ return tryGet(key, undefined, ctx => this._context.set(key, ctx));
223
220
  }));
224
221
  });
225
222
 
@@ -238,24 +235,18 @@ class HtmlBlock extends LitElement {
238
235
  };
239
236
 
240
237
  return html`
241
- <div class="${classMap(renderContainerClasses)}">
242
- ${!this.noDeferredRendering ? until(this._processEmbeds(), nothing) : nothing}
243
- </div>
238
+ <div class="${classMap(renderContainerClasses)}" ${ref(this._renderContainerRef)}></div>
244
239
  ${this.noDeferredRendering ? html`<slot @slotchange="${this._handleSlotChange}"></slot>` : ''}
245
240
  `;
246
241
  }
247
242
 
248
243
  async updated(changedProperties) {
249
244
  super.updated(changedProperties);
250
- if ((changedProperties.has('embeds') || changedProperties.has('_context')) && this.html !== undefined && this.html !== null && !this.noDeferredRendering) {
245
+ if (this.html !== undefined && this.html !== null && !this.noDeferredRendering) {
251
246
  await this._updateRenderContainer();
252
247
  }
253
248
  }
254
249
 
255
- async getLoadingComplete() {
256
- return this._renderersProcessedPromise;
257
- }
258
-
259
250
  async _handleSlotChange(e) {
260
251
  if (!e.target || !this.shadowRoot || !this.noDeferredRendering) return;
261
252
  await this._renderInline(e.target);
@@ -264,7 +255,6 @@ class HtmlBlock extends LitElement {
264
255
  async _processEmbeds() {
265
256
  const htmlFragment = document.createRange().createContextualFragment(this.html);
266
257
  await renderEmbeds(htmlFragment);
267
- this.updated(new Map([['embeds']]));
268
258
  return htmlFragment;
269
259
  }
270
260
 
@@ -289,7 +279,7 @@ class HtmlBlock extends LitElement {
289
279
  loadingCompletePromises.push(renderer.getLoadingComplete());
290
280
  }
291
281
  }
292
- Promise.all(loadingCompletePromises).then(() => this._renderersProcessedResolve());
282
+ Promise.all(loadingCompletePromises).then(this.resolveLoadingComplete);
293
283
  }
294
284
 
295
285
  async _renderInline(slot) {
@@ -300,15 +290,16 @@ class HtmlBlock extends LitElement {
300
290
  .find(node => (node.nodeType === Node.ELEMENT_NODE && node.tagName === 'DIV'));
301
291
 
302
292
  if (!noDeferredRenderingContainer) {
303
- this._renderersProcessedResolve();
293
+ this.resolveLoadingComplete();
304
294
  return;
305
295
  }
306
296
  await this._processRenderers(noDeferredRenderingContainer);
307
297
  }
308
298
 
309
299
  async _updateRenderContainer() {
310
- const renderContainer = this.shadowRoot.querySelector('.d2l-html-block-rendered');
311
- await this._processRenderers(renderContainer);
300
+ this._renderContainerRef.value.innerHTML = '';
301
+ this._renderContainerRef.value.append(await this._processEmbeds());
302
+ await this._processRenderers(this._renderContainerRef.value);
312
303
  }
313
304
 
314
305
  _validateHtml() {
@@ -42,13 +42,6 @@
42
42
  </template>
43
43
  </d2l-demo-snippet>
44
44
 
45
- <h2>Placeholder</h2>
46
- <d2l-demo-snippet>
47
- <template>
48
- <d2l-input-number label="Age" label-hidden placeholder="Age"></d2l-input-number>
49
- </template>
50
- </d2l-demo-snippet>
51
-
52
45
  <h2>Min and Max Values</h2>
53
46
  <d2l-demo-snippet>
54
47
  <template>
@@ -40,13 +40,6 @@
40
40
  </template>
41
41
  </d2l-demo-snippet>
42
42
 
43
- <h2>Placeholder</h2>
44
- <d2l-demo-snippet>
45
- <template>
46
- <d2l-input-percent label="Grade" label-hidden placeholder="Grade"></d2l-input-percent>
47
- </template>
48
- </d2l-demo-snippet>
49
-
50
43
  <h2>Min and Max Fraction Digits</h2>
51
44
  <d2l-demo-snippet>
52
45
  <template>
@@ -15,7 +15,7 @@
15
15
  <h2>Search Input</h2>
16
16
  <d2l-demo-snippet>
17
17
  <template>
18
- <d2l-input-search label="Search" value="apples" placeholder="Search for some stuff">
18
+ <d2l-input-search label="Search" value="apples" placeholder="Search...">
19
19
  </d2l-input-search>
20
20
  </template>
21
21
  </d2l-demo-snippet>
@@ -23,7 +23,7 @@
23
23
  <h2>Search Input (No Clear)</h2>
24
24
  <d2l-demo-snippet>
25
25
  <template>
26
- <d2l-input-search label="Search" value="Clear button will never appear" placeholder="Search for some stuff" no-clear>
26
+ <d2l-input-search label="Search" value="Clear button will never appear" placeholder="Search..." no-clear>
27
27
  </d2l-input-search>
28
28
  </template>
29
29
  </d2l-demo-snippet>
@@ -31,7 +31,7 @@
31
31
  <h2>Search Input (Search on Input)</h2>
32
32
  <d2l-demo-snippet>
33
33
  <template>
34
- <d2l-input-search label="Search" value="Will dispatch search after every input" placeholder="Search for some stuff" search-on-input>
34
+ <d2l-input-search label="Search" value="Will dispatch search after every input" placeholder="Search..." search-on-input>
35
35
  </d2l-input-search>
36
36
  </template>
37
37
  </d2l-demo-snippet>
@@ -39,7 +39,7 @@
39
39
  <h2>Search Input with Inline Help</h2>
40
40
  <d2l-demo-snippet>
41
41
  <template>
42
- <d2l-input-search label="Search" value="apples" placeholder="Search for some stuff">
42
+ <d2l-input-search label="Search" value="apples" placeholder="Search...">
43
43
  <div slot="inline-help">
44
44
  Help text <b>right here</b>!
45
45
  </div>
@@ -50,7 +50,7 @@
50
50
  <h2>Search Input with Inline Help (multiline)</h2>
51
51
  <d2l-demo-snippet>
52
52
  <template>
53
- <d2l-input-search label="Search" value="apples" placeholder="Search for some stuff">
53
+ <d2l-input-search label="Search" value="apples" placeholder="Search...">
54
54
  <div slot="inline-help">
55
55
  Lorem ipsum dolor sit amet, consectetur adipiscing elit,
56
56
  sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
@@ -62,13 +62,6 @@
62
62
  </template>
63
63
  </d2l-demo-snippet>
64
64
 
65
- <h2>Placeholder</h2>
66
- <d2l-demo-snippet>
67
- <template>
68
- <d2l-input-text label="Name" label-hidden placeholder="Enter a name..."></d2l-input-text>
69
- </template>
70
- </d2l-demo-snippet>
71
-
72
65
  <h2>Instructions</h2>
73
66
  <d2l-demo-snippet>
74
67
  <template>
@@ -47,10 +47,10 @@
47
47
  </template>
48
48
  </d2l-demo-snippet>
49
49
 
50
- <h2>Placeholder</h2>
50
+ <h2>Long Label</h2>
51
51
  <d2l-demo-snippet>
52
52
  <template>
53
- <d2l-input-textarea label="Description" placeholder="Enter a description of your favorite cartoon character. It must be between 30 and 60 characters in length. Good luck!"></d2l-input-textarea>
53
+ <d2l-input-textarea label="Enter a description of your favorite cartoon character. It must be between 30 and 60 characters in length."></d2l-input-textarea>
54
54
  </template>
55
55
  </d2l-demo-snippet>
56
56
 
@@ -54,7 +54,6 @@ The `<d2l-input-number>` element is similar to `<d2l-input-text>`, except it's i
54
54
  | `min` | Number | Minimum value allowed. |
55
55
  | `min-exclusive` | Boolean, default: `false` | Indicates whether the min value is exclusive. |
56
56
  | `min-fraction-digits` | Number, default: `0` | Minimum number of digits allowed after the decimal place. Must be between 0 and 20 and less than or equal to `maxFractionDigits` |
57
- | `placeholder` | String | Placeholder text. |
58
57
  | `required` | Boolean, default: `false` | Indicates that a value is required. |
59
58
  | `unit` | String | Unit associated with the input value, displayed next to input and announced as part of the label |
60
59
  | `value` | Number | Value of the input. |
@@ -128,7 +127,6 @@ The `<d2l-input-percent>` element is similar to `<d2l-input-number>`, except it
128
127
  | `label-hidden` | Boolean, default: `false` | Hides the label visually (moves it to the input's `aria-label` attribute). |
129
128
  | `max-fraction-digits` | Number | Maximum number of digits allowed after the decimal place. |
130
129
  | `min-fraction-digits` | Number | Minimum number of digits allowed after the decimal place. |
131
- | `placeholder` | String | Placeholder text. |
132
130
  | `required` | Boolean, default: `false` | Indicates that a value is required. |
133
131
  | `value` | Number | Value of the input. |
134
132
 
@@ -86,7 +86,6 @@ When the input is cleared, the same event will be fired with an empty value.
86
86
 
87
87
  - While the component does not have a visible label, the search icon clearly indicates its purpose
88
88
  - While not required to meet WCAG, this [pattern](https://www.w3.org/WAI/WCAG2/supplemental/patterns/o1p07-icons-used/) is a great way to help individuals with cognitive accessibility needs
89
- - The contrast ratio of the placeholder text can be safely ignored since the search icon serves the same purpose, and meets that criteria
90
89
  - It is important to note that `placeholder` is not a suitable replacement for `label` or `description`, since it only applies when the input is empty, and not all users will be able to read it in the first place
91
90
  - Search results should be announced to screen reader users using a live region around the result summary or by using the [`announce`](https://github.com/BrightspaceUI/core/blob/main/helpers/announce.js) helper
92
91
  - It can also be used to help confirm what exactly was searched, along with how many results were found
@@ -28,23 +28,14 @@ Text inputs allow users to input, edit, and select text.
28
28
  * Make sure you include an obvious indication of what the field is for. Usually this means a label.
29
29
  * Design the length of the text input to give the user a scent of how long the expected data should be.
30
30
  * Ensure the label remains visible when a user focuses on the input using their mobile device. Often this means using a top-aligned label, but a left-aligned label with a very short text input can work also.
31
- * Placeholder text is inaccessible so only use it for decorative or supporting text.
32
31
  <!-- docs: end dos -->
33
32
 
34
33
  <!-- docs: start donts -->
35
- * Don’t use placeholder text as the label.
36
- * Don’t use placeholder text if it is redundant (ie: “Click to start typing”)
37
- * Don’t use placeholder text to communicate the required format of the input (ie: “YY/MM/DD”). Use help or label text for this.
34
+ * Don’t use placeholder text - support for this property is being removed. Find an alternative method of communicating text input instructions.
38
35
  * Don’t use different font sizes. Text should always be Compact.
39
36
  <!-- docs: end donts -->
40
37
  <!-- docs: end best practices -->
41
38
 
42
- ## Accessibility
43
-
44
- Due to widespread popularity, users have a strong association that placeholder text in text inputs should appear “light gray” compared to active text colour. This has been confirmed in our own usability tests; any text that appears dark enough to pass WCAG AA colour contrast tests is also interpreted as “editable” by users.
45
-
46
- Therefore in text inputs, placeholder text is a light colour (Mica), which fails colour contrast. Because of this, placeholder text should be used sparingly, and never be used to communicate crucial information unless that information is also made available to screen readers via an equivalent experience (hidden label, etc). Text which is decorative or supplemental is okay, as is using a hidden label which provides the same information.
47
-
48
39
  ## Text Input [d2l-input-text]
49
40
 
50
41
  The `<d2l-input-text>` element is a simple wrapper around the native `<input type="text">` tag. It's intended primarily for inputting generic text, email addresses and URLs.
@@ -90,7 +81,6 @@ The `<d2l-input-text>` element is a simple wrapper around the native `<input typ
90
81
  | `name` | String | Name of the input |
91
82
  | `novalidate` | Boolean | Disables the built-in validation |
92
83
  | `pattern` | String | Regular expression pattern to validate the value |
93
- | `placeholder` | String | Placeholder text |
94
84
  | `prevent-submit` | Boolean | Prevents pressing ENTER from submitting forms |
95
85
  | `readonly` | Boolean | Makes the input read-only |
96
86
  | `required` | Boolean | Indicates that a value is required |
@@ -207,7 +197,6 @@ The `<d2l-input-textarea>` is a wrapper around the native `<textarea>` element t
207
197
  | `minlength` | Number | Imposes a lower character limit |
208
198
  | `no-border` | Boolean | Hides the border |
209
199
  | `no-padding` | Boolean | Removes left/right padding |
210
- | `placeholder` | String | Placeholder text |
211
200
  | `required` | Boolean | Indicates that a value is required |
212
201
  | `rows` | Number, default: 5 | Minimum number of rows. If `rows` and `max-rows` are equal then auto-grow will be disabled. |
213
202
  | `value` | String, default: `''` | Value of the `textarea` |
@@ -142,8 +142,7 @@ class InputNumber extends FocusMixin(LabelledMixin(SkeletonMixin(FormElementMixi
142
142
  */
143
143
  minFractionDigits: { type: Number, attribute: 'min-fraction-digits' },
144
144
  /**
145
- * Placeholder text
146
- * @type {string}
145
+ * @ignore
147
146
  */
148
147
  placeholder: { type: String },
149
148
  /**
@@ -49,8 +49,7 @@ class InputPercent extends FocusMixin(LabelledMixin(SkeletonMixin(FormElementMix
49
49
  */
50
50
  minFractionDigits: { type: Number, attribute: 'min-fraction-digits' },
51
51
  /**
52
- * Placeholder text
53
- * @type {string}
52
+ * @ignore
54
53
  */
55
54
  placeholder: { type: String },
56
55
  /**
@@ -33,13 +33,13 @@ export const inputStyles = css`
33
33
  padding: var(--d2l-input-padding, 0.4rem 0.75rem);
34
34
  }
35
35
  .d2l-input::placeholder {
36
- color: var(--d2l-color-mica);
36
+ color: var(--d2l-color-galena);
37
37
  font-size: 0.8rem;
38
38
  font-weight: 400;
39
39
  opacity: 1; /* Firefox has non-1 default */
40
40
  }
41
41
  .d2l-input::-ms-input-placeholder {
42
- color: var(--d2l-color-mica);
42
+ color: var(--d2l-color-galena);
43
43
  font-size: 0.8rem;
44
44
  font-weight: 400;
45
45
  }
@@ -107,8 +107,7 @@ class InputText extends InputInlineHelpMixin(PropertyRequiredMixin(FocusMixin(La
107
107
  */
108
108
  pattern: { type: String },
109
109
  /**
110
- * Placeholder text
111
- * @type {string}
110
+ * @ignore
112
111
  */
113
112
  placeholder: { type: String },
114
113
  /**
@@ -71,8 +71,7 @@ class InputTextArea extends InputInlineHelpMixin(FocusMixin(LabelledMixin(FormEl
71
71
  */
72
72
  noPadding: { type: Boolean, attribute: 'no-padding' },
73
73
  /**
74
- * Placeholder text
75
- * @type {string}
74
+ * @ignore
76
75
  */
77
76
  placeholder: { type: String },
78
77
  /**
@@ -27,7 +27,7 @@
27
27
  width: 100%;
28
28
  &::placeholder,
29
29
  &::-ms-input-placeholder {
30
- color: $d2l-color-mica;
30
+ color: $d2l-color-galena;
31
31
  font-size: 0.8rem;
32
32
  font-weight: 400;
33
33
  opacity: 1; /* Firefox has non-1 default */
@@ -90,7 +90,7 @@ The `d2l-tooltip` component is used to display additional information when users
90
90
  });
91
91
  </script>
92
92
  <!-- docs: end hidden content -->
93
- <d2l-input-text placeholder="Hover for Error" id="tooltip-error" aria-invalid="true" label="Text Input" label-hidden style="max-width:250px;"></d2l-input-text>
93
+ <d2l-input-text id="tooltip-error" aria-invalid="true" label="Text Input (hover for error)" label-hidden style="max-width:250px;"></d2l-input-text>
94
94
  <d2l-tooltip for="tooltip-error" state="error">
95
95
  Your error message will display here
96
96
  </d2l-tooltip>
@@ -4759,6 +4759,14 @@
4759
4759
  "description": "Whether to disable deferred rendering of the user-authored HTML. Do *not* set this\nunless your HTML relies on script executions that may break upon stamping.",
4760
4760
  "type": "Boolean",
4761
4761
  "default": "false"
4762
+ },
4763
+ {
4764
+ "name": "loadingComplete",
4765
+ "type": "Promise<any>"
4766
+ },
4767
+ {
4768
+ "name": "resolveLoadingComplete",
4769
+ "type": "() => void"
4762
4770
  }
4763
4771
  ]
4764
4772
  },
@@ -6185,11 +6193,6 @@
6185
6193
  "description": "Minimum value allowed",
6186
6194
  "type": "number"
6187
6195
  },
6188
- {
6189
- "name": "placeholder",
6190
- "description": "Placeholder text",
6191
- "type": "string"
6192
- },
6193
6196
  {
6194
6197
  "name": "unit",
6195
6198
  "description": "Unit associated with the input value, displayed next to input and announced as part of the label",
@@ -6303,12 +6306,6 @@
6303
6306
  "description": "Minimum value allowed",
6304
6307
  "type": "number"
6305
6308
  },
6306
- {
6307
- "name": "placeholder",
6308
- "attribute": "placeholder",
6309
- "description": "Placeholder text",
6310
- "type": "string"
6311
- },
6312
6309
  {
6313
6310
  "name": "unit",
6314
6311
  "attribute": "unit",
@@ -6476,11 +6473,6 @@
6476
6473
  "description": "Minimum number of decimal values to show.",
6477
6474
  "type": "number"
6478
6475
  },
6479
- {
6480
- "name": "placeholder",
6481
- "description": "Placeholder text",
6482
- "type": "string"
6483
- },
6484
6476
  {
6485
6477
  "name": "value",
6486
6478
  "description": "Value of the input",
@@ -6544,12 +6536,6 @@
6544
6536
  "description": "Minimum number of decimal values to show.",
6545
6537
  "type": "number"
6546
6538
  },
6547
- {
6548
- "name": "placeholder",
6549
- "attribute": "placeholder",
6550
- "description": "Placeholder text",
6551
- "type": "string"
6552
- },
6553
6539
  {
6554
6540
  "name": "value",
6555
6541
  "attribute": "value",
@@ -6821,11 +6807,6 @@
6821
6807
  "description": "Regular expression pattern to validate the value",
6822
6808
  "type": "string"
6823
6809
  },
6824
- {
6825
- "name": "placeholder",
6826
- "description": "Placeholder text",
6827
- "type": "string"
6828
- },
6829
6810
  {
6830
6811
  "name": "size",
6831
6812
  "description": "Size of the input",
@@ -6987,12 +6968,6 @@
6987
6968
  "description": "Regular expression pattern to validate the value",
6988
6969
  "type": "string"
6989
6970
  },
6990
- {
6991
- "name": "placeholder",
6992
- "attribute": "placeholder",
6993
- "description": "Placeholder text",
6994
- "type": "string"
6995
- },
6996
6971
  {
6997
6972
  "name": "size",
6998
6973
  "attribute": "size",
@@ -7178,11 +7153,6 @@
7178
7153
  "description": "Removes default left/right padding",
7179
7154
  "type": "boolean"
7180
7155
  },
7181
- {
7182
- "name": "placeholder",
7183
- "description": "Placeholder text",
7184
- "type": "string"
7185
- },
7186
7156
  {
7187
7157
  "name": "disabled",
7188
7158
  "description": "Disables the input",
@@ -7277,12 +7247,6 @@
7277
7247
  "description": "Removes default left/right padding",
7278
7248
  "type": "boolean"
7279
7249
  },
7280
- {
7281
- "name": "placeholder",
7282
- "attribute": "placeholder",
7283
- "description": "Placeholder text",
7284
- "type": "string"
7285
- },
7286
7250
  {
7287
7251
  "name": "disabled",
7288
7252
  "attribute": "disabled",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightspace-ui/core",
3
- "version": "3.46.1",
3
+ "version": "3.47.1",
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",