@brightspace-ui/core 1.231.0 → 1.233.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.
@@ -184,7 +184,7 @@ The `d2l-dialog-confirm` element is a simple confirmation dialog for prompting t
184
184
 
185
185
  | Property | Type | Description |
186
186
  |--|--|--|
187
- | `text` | String, required | The required text content for the confirmation dialog |
187
+ | `text` | String, required | The text content for the confirmation dialog. Newline characters (`
` in HTML or `\n` in JavaScript) will render as multiple paragraphs. |
188
188
  | `opened` | Boolean | Whether or not the dialog is open |
189
189
  | `title-text` | String | The optional title for the confirmation dialog |
190
190
 
@@ -37,6 +37,26 @@
37
37
  </template>
38
38
  </d2l-demo-snippet>
39
39
 
40
+ <h2>Confirm Dialog (Multi Paragraph)</h2>
41
+
42
+ <d2l-demo-snippet>
43
+ <template>
44
+ <d2l-button id="openConfirmMultiParagraph">Show Confirm</d2l-button>
45
+ <d2l-dialog-confirm id="confirmMultiParagraph" title-text="Confirm Title" text="Are you sure you want more cookies?&#10;Are you sure you want more donuts?">
46
+ <d2l-button slot="footer" primary data-dialog-action="ok">Yes</d2l-button>
47
+ <d2l-button slot="footer" data-dialog-action>No</d2l-button>
48
+ </d2l-dialog-confirm>
49
+ <script>
50
+ document.querySelector('#openConfirmMultiParagraph').addEventListener('click', () => {
51
+ document.querySelector('#confirmMultiParagraph').opened = true;
52
+ });
53
+ document.querySelector('#confirmMultiParagraph').addEventListener('d2l-dialog-close', (e) => {
54
+ console.log('confirm action:', e.detail.action);
55
+ });
56
+ </script>
57
+ </template>
58
+ </d2l-demo-snippet>
59
+
40
60
  <h2>Confirm Dialog (No Title)</h2>
41
61
 
42
62
  <d2l-demo-snippet>
@@ -14,7 +14,7 @@ class DialogConfirm extends DialogMixin(LitElement) {
14
14
  static get properties() {
15
15
  return {
16
16
  /**
17
- * REQUIRED: The text content for the confirmation dialog
17
+ * REQUIRED: The text content for the confirmation dialog. Newline characters (`&#10;` in HTML or `\n` in JavaScript) will render as multiple paragraphs.
18
18
  * @type {string}
19
19
  */
20
20
  text: { type: String }
@@ -36,6 +36,18 @@ class DialogConfirm extends DialogMixin(LitElement) {
36
36
  padding-top: 0;
37
37
  }
38
38
 
39
+ .d2l-dialog-content p {
40
+ margin: 1rem 0;
41
+ }
42
+
43
+ .d2l-dialog-content p:first-child {
44
+ margin-top: 0;
45
+ }
46
+
47
+ .d2l-dialog-content p:last-child {
48
+ margin-bottom: 0;
49
+ }
50
+
39
51
  @media (max-width: 615px), (max-height: 420px) and (max-width: 900px) {
40
52
 
41
53
  dialog.d2l-dialog-outer,
@@ -65,7 +77,7 @@ class DialogConfirm extends DialogMixin(LitElement) {
65
77
  <div><h2 id="${this._titleId}" class="d2l-heading-3">${this.titleText}</h2></div>
66
78
  </div>` : null}
67
79
  <div id="${this._textId}" class="d2l-dialog-content">
68
- <div>${this.text}</div>
80
+ <div>${this.text ? this.text.split('\n').map(line => html`<p>${line}</p>`) : null}</div>
69
81
  </div>
70
82
  <div class="d2l-dialog-footer">
71
83
  <slot name="footer" class="d2l-dialog-footer-slot"></slot>
@@ -273,6 +273,7 @@ export const DropdownContentMixin = superclass => class extends LocalizeCoreElem
273
273
  this.__onAutoCloseClick = this.__onAutoCloseClick.bind(this);
274
274
  this.__toggleScrollStyles = this.__toggleScrollStyles.bind(this);
275
275
  this._handleMobileResize = this._handleMobileResize.bind(this);
276
+ this.__disconnectResizeObserver = this.__disconnectResizeObserver.bind(this);
276
277
  }
277
278
 
278
279
  get opened() {
@@ -312,6 +313,8 @@ export const DropdownContentMixin = superclass => class extends LocalizeCoreElem
312
313
  }
313
314
  clearDismissible(this.__dismissibleId);
314
315
  this.__dismissibleId = null;
316
+
317
+ if (this.__resizeObserver) this.__resizeObserver.disconnect();
315
318
  }
316
319
 
317
320
  firstUpdated(changedProperties) {
@@ -374,6 +377,17 @@ export const DropdownContentMixin = superclass => class extends LocalizeCoreElem
374
377
  this._showBackdrop = this._useMobileStyling && this.mobileTray;
375
378
  }
376
379
 
380
+ /**
381
+ * Waits for the next resize when elem has a height > 0px,
382
+ * then calls the __position function.
383
+ */
384
+ requestRepositionNextResize(elem) {
385
+ if (!elem) return;
386
+ if (this.__resizeObserver) this.__resizeObserver.disconnect();
387
+ this.__resizeObserver = new ResizeObserver(this.__disconnectResizeObserver);
388
+ this.__resizeObserver.observe(elem);
389
+ }
390
+
377
391
  async resize() {
378
392
  if (!this.opened) {
379
393
  return;
@@ -403,6 +417,20 @@ export const DropdownContentMixin = superclass => class extends LocalizeCoreElem
403
417
  }
404
418
  }
405
419
 
420
+ __disconnectResizeObserver(entries) {
421
+ for (let i = 0; i < entries.length; i++) {
422
+ const entry = entries[i];
423
+ if (this.__resizeObserver && entry.contentRect.height !== 0) {
424
+ this.__resizeObserver.disconnect();
425
+ // wrap in rAF for Firefox
426
+ requestAnimationFrame(() => {
427
+ if (this.opened) this.__position();
428
+ });
429
+ break;
430
+ }
431
+ }
432
+ }
433
+
406
434
  __getContentBottom() {
407
435
  return this.shadowRoot && this.shadowRoot.querySelector('.d2l-dropdown-content-bottom');
408
436
  }
@@ -90,7 +90,20 @@
90
90
  <d2l-demo-snippet>
91
91
  <template>
92
92
  <d2l-filter>
93
- <d2l-filter-dimension-set key="course" text="Course" loading select-all></d2l-filter-dimension-set>
93
+ <d2l-filter-dimension-set key="course" text="Course" loading select-all>
94
+ <d2l-filter-dimension-set-value key="art" text="Art"></d2l-filter-dimension-set-value>
95
+ <d2l-filter-dimension-set-value key="astronomy" text="Astronomy" selected></d2l-filter-dimension-set-value>
96
+ <d2l-filter-dimension-set-value key="biology" text="Biology"></d2l-filter-dimension-set-value>
97
+ <d2l-filter-dimension-set-value key="chemistry" text="Chemistry"></d2l-filter-dimension-set-value>
98
+ <d2l-filter-dimension-set-value key="drama" text="Drama"></d2l-filter-dimension-set-value>
99
+ <d2l-filter-dimension-set-value key="english" text="English"></d2l-filter-dimension-set-value>
100
+ <d2l-filter-dimension-set-value key="how-to" text="How To Write a How To Article With a Flashy Title"></d2l-filter-dimension-set-value>
101
+ <d2l-filter-dimension-set-value key="math" text="Math"></d2l-filter-dimension-set-value>
102
+ <d2l-filter-dimension-set-value key="physics" text="Physics"></d2l-filter-dimension-set-value>
103
+ <d2l-filter-dimension-set-value key="stats" text="Statistics"></d2l-filter-dimension-set-value>
104
+ <d2l-filter-dimension-set-value key="writerscraft" text="Writer's Craft"></d2l-filter-dimension-set-value>
105
+ </d2l-filter-dimension-set>
106
+
94
107
  </d2l-filter>
95
108
  <d2l-filter>
96
109
  <d2l-filter-dimension-set key="course" text="Course" loading select-all></d2l-filter-dimension-set>
@@ -256,7 +256,10 @@ class Filter extends LocalizeCoreElement(RtlMixin(LitElement)) {
256
256
  let dimensionHTML;
257
257
  switch (dimension.type) {
258
258
  case 'd2l-filter-dimension-set':
259
- dimensionHTML = html`<div aria-live="polite">${this._createSetDimension(dimension)}</div>`;
259
+ dimensionHTML = html`
260
+ <div aria-live="polite" class="d2l-filter-container">
261
+ ${this._createSetDimension(dimension)}
262
+ </div>`;
260
263
  break;
261
264
  }
262
265
 
@@ -519,7 +522,8 @@ class Filter extends LocalizeCoreElement(RtlMixin(LitElement)) {
519
522
 
520
523
  let shouldUpdate = false,
521
524
  shouldSearch = false,
522
- shouldRecount = false;
525
+ shouldRecount = false,
526
+ shouldResizeDropdown = false;
523
527
  changes.forEach((newValue, prop) => {
524
528
  if (toUpdate[prop] === newValue) return;
525
529
 
@@ -538,13 +542,23 @@ class Filter extends LocalizeCoreElement(RtlMixin(LitElement)) {
538
542
  } else if (prop === 'values') {
539
543
  if (dimension.searchValue) shouldSearch = true;
540
544
  shouldRecount = true;
545
+ shouldResizeDropdown = true;
541
546
  this._activeFiltersSubscribers.updateSubscribers();
547
+ } else if (prop === 'loading') {
548
+ shouldResizeDropdown = true;
542
549
  }
543
550
  });
544
551
 
545
552
  if (shouldSearch) this._performDimensionSearch(dimension);
546
553
  if (shouldRecount) this._setFilterCounts(dimension);
547
- if (shouldUpdate) this.requestUpdate();
554
+ if (shouldUpdate) this.requestUpdate();
555
+ if (shouldResizeDropdown) {
556
+ const singleDimension = this._dimensions.length === 1;
557
+ if (singleDimension && this.opened) {
558
+ const dropdown = this.shadowRoot.querySelector('d2l-dropdown-content');
559
+ dropdown.requestRepositionNextResize(this.shadowRoot.querySelector('.d2l-filter-container'));
560
+ }
561
+ }
548
562
  }
549
563
 
550
564
  _handleDimensionHide() {
@@ -80,7 +80,7 @@ search.addEventListener('d2l-input-search-searched', (e) => {
80
80
  When the input is cleared, the same event will be fired with an empty value.
81
81
  <!-- docs: end hidden content -->
82
82
 
83
- ### Accessibility
83
+ ### Accessibility Properties
84
84
 
85
85
  To make your usage of `d2l-input-search` accessible, use the following property when applicable:
86
86
 
@@ -311,6 +311,7 @@ The `d2l-list-header` component can be placed in the `d2l-list`'s `header` slot
311
311
 
312
312
  | Property | Type | Description |
313
313
  |---|---|---|
314
+ | `no-selection` | Boolean | Whether to render select-all and selection summary |
314
315
  | `padding-type` | String | Header whitespace (`normal` (default), `slim`) |
315
316
  | `select-all-pages-allowed` | Boolean | Whether all pages can be selected |
316
317
  <!-- docs: end hidden content -->
@@ -15,12 +15,10 @@ class ListHeader extends RtlMixin(LocalizeCoreElement(LitElement)) {
15
15
  static get properties() {
16
16
  return {
17
17
  /**
18
- * @ignore
19
- * Whether to render a header with reduced whitespace
20
- * TODO: Remove
18
+ * Whether to render select-all and selection summary
21
19
  * @type {boolean}
22
20
  */
23
- slim: { reflect: true, type: Boolean },
21
+ noSelection: { type: Boolean, attribute: 'no-selection' },
24
22
  /**
25
23
  * How much padding to render list items with
26
24
  * @type {'normal'|'slim'}
@@ -31,6 +29,13 @@ class ListHeader extends RtlMixin(LocalizeCoreElement(LitElement)) {
31
29
  * @type {boolean}
32
30
  */
33
31
  selectAllPagesAllowed: { type: Boolean, attribute: 'select-all-pages-allowed' },
32
+ /**
33
+ * @ignore
34
+ * Whether to render a header with reduced whitespace
35
+ * TODO: Remove
36
+ * @type {boolean}
37
+ */
38
+ slim: { reflect: true, type: Boolean }
34
39
  };
35
40
  }
36
41
 
@@ -87,21 +92,24 @@ class ListHeader extends RtlMixin(LocalizeCoreElement(LitElement)) {
87
92
 
88
93
  constructor() {
89
94
  super();
90
- this.slim = false;
95
+ this.noSelection = false;
91
96
  this.paddingType = 'normal';
92
97
  this.selectAllPagesAllowed = false;
98
+ this.slim = false;
93
99
  }
94
100
 
95
101
  render() {
96
102
  return html`
97
103
  <div class="d2l-list-header-container">
98
- <d2l-selection-select-all></d2l-selection-select-all>
99
- <d2l-selection-summary
100
- aria-hidden="true"
101
- class="d2l-list-header-summary"
102
- no-selection-text="${this.localize('components.selection.select-all')}">
103
- </d2l-selection-summary>
104
- ${this.selectAllPagesAllowed ? html`<d2l-selection-select-all-pages></d2l-selection-select-all-pages>` : null}
104
+ ${this.noSelection ? null : html`
105
+ <d2l-selection-select-all></d2l-selection-select-all>
106
+ <d2l-selection-summary
107
+ aria-hidden="true"
108
+ class="d2l-list-header-summary"
109
+ no-selection-text="${this.localize('components.selection.select-all')}">
110
+ </d2l-selection-summary>
111
+ ${this.selectAllPagesAllowed ? html`<d2l-selection-select-all-pages></d2l-selection-select-all-pages>` : null}
112
+ `}
105
113
  <div class="d2l-list-header-actions">
106
114
  <d2l-overflow-group opener-type="icon"><slot></slot></d2l-overflow-group>
107
115
  </div>
@@ -9,6 +9,7 @@ import { SelectionActionMixin } from './selection-action-mixin.js';
9
9
  /**
10
10
  * A dropdown opener associated with a selection component.
11
11
  * @slot - Dropdown content (e.g., "d2l-dropdown-content", "d2l-dropdown-menu" or "d2l-dropdown-tabs")
12
+ * @fires d2l-selection-observer-subscribe - Internal event
12
13
  */
13
14
  class ActionDropdown extends LocalizeCoreElement(SelectionActionMixin(DropdownOpenerMixin(LitElement))) {
14
15
 
@@ -114,11 +114,11 @@ The `d2l-table-wrapper` element can be combined with table styles to apply defau
114
114
  <!-- docs: start hidden content -->
115
115
  ### Properties
116
116
 
117
- | Property | Type | Description |
118
- |---|---|---|
119
- | `no-column-border` | Boolean, default: `false` | Hides the column borders on "default" table type |
120
- | `sticky-headers` | Boolean, default: `false` | Whether to make the header row sticky |
121
- | `type` | String, default: `'default'` | Type of the table style. Can be one of `default`, `light`. |
117
+ | Property | Type | Description | Default Value |
118
+ |---|---|---|---|
119
+ | `no-column-border` | boolean | Hides the column borders on "default" table type | false |
120
+ | `sticky-headers` | boolean | Whether to make the header row sticky | false |
121
+ | `type` | string | Type of the table style. Can be one of `default`, `light`. | 'default' |
122
122
 
123
123
  ## Light Type
124
124
 
@@ -241,10 +241,10 @@ When tabular data can be sorted, the `<d2l-table-col-sort-button>` can be used t
241
241
 
242
242
  ### Properties
243
243
 
244
- | Property | Type | Description |
245
- |---|---|---|
246
- | `desc` | Boolean, default: `false` | Whether sort direction is descending |
247
- | `nosort` | Booealn, default: `false` | Column is not currently sorted. Hides the ascending/descending sort icon. |
244
+ | Property | Type | Description | Default Value |
245
+ |---|---|---|---|
246
+ | `desc` | boolean | Whether sort direction is descending | false |
247
+ | `nosort` | boolean | Column is not currently sorted. Hides the ascending/descending sort icon. | false |
248
248
 
249
249
  ## Selection
250
250
 
@@ -1460,7 +1460,7 @@
1460
1460
  "attributes": [
1461
1461
  {
1462
1462
  "name": "text",
1463
- "description": "REQUIRED: The text content for the confirmation dialog",
1463
+ "description": "REQUIRED: The text content for the confirmation dialog. Newline characters (`&#10;` in HTML or `\\n` in JavaScript) will render as multiple paragraphs.",
1464
1464
  "type": "string"
1465
1465
  },
1466
1466
  {
@@ -1479,7 +1479,7 @@
1479
1479
  {
1480
1480
  "name": "text",
1481
1481
  "attribute": "text",
1482
- "description": "REQUIRED: The text content for the confirmation dialog",
1482
+ "description": "REQUIRED: The text content for the confirmation dialog. Newline characters (`&#10;` in HTML or `\\n` in JavaScript) will render as multiple paragraphs.",
1483
1483
  "type": "string"
1484
1484
  },
1485
1485
  {
@@ -6673,6 +6673,12 @@
6673
6673
  "path": "./components/list/list-header.js",
6674
6674
  "description": "A header for list components containing select-all, etc.",
6675
6675
  "attributes": [
6676
+ {
6677
+ "name": "no-selection",
6678
+ "description": "Whether to render select-all and selection summary",
6679
+ "type": "boolean",
6680
+ "default": "false"
6681
+ },
6676
6682
  {
6677
6683
  "name": "padding-type",
6678
6684
  "description": "How much padding to render list items with",
@@ -6688,7 +6694,9 @@
6688
6694
  ],
6689
6695
  "properties": [
6690
6696
  {
6691
- "name": "slim",
6697
+ "name": "noSelection",
6698
+ "attribute": "no-selection",
6699
+ "description": "Whether to render select-all and selection summary",
6692
6700
  "type": "boolean",
6693
6701
  "default": "false"
6694
6702
  },
@@ -6705,6 +6713,11 @@
6705
6713
  "description": "Whether all pages can be selected",
6706
6714
  "type": "boolean",
6707
6715
  "default": "false"
6716
+ },
6717
+ {
6718
+ "name": "slim",
6719
+ "type": "boolean",
6720
+ "default": "false"
6708
6721
  }
6709
6722
  ],
6710
6723
  "slots": [
@@ -8538,7 +8551,8 @@
8538
8551
  ],
8539
8552
  "events": [
8540
8553
  {
8541
- "name": "d2l-selection-observer-subscribe"
8554
+ "name": "d2l-selection-observer-subscribe",
8555
+ "description": "Internal event"
8542
8556
  }
8543
8557
  ],
8544
8558
  "slots": [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightspace-ui/core",
3
- "version": "1.231.0",
3
+ "version": "1.233.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",
@@ -44,7 +44,7 @@
44
44
  "license": "Apache-2.0",
45
45
  "devDependencies": {
46
46
  "@babel/eslint-parser": "^7",
47
- "@brightspace-ui/stylelint-config": "^0.3",
47
+ "@brightspace-ui/stylelint-config": "^0.4",
48
48
  "@open-wc/testing": "^2",
49
49
  "@web/dev-server": "^0.1",
50
50
  "@web/test-runner": "^0.13",