@brightspace-ui/core 1.213.2 → 1.217.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.
Files changed (73) hide show
  1. package/components/button/button-mixin.js +1 -1
  2. package/components/calendar/calendar.js +5 -5
  3. package/components/card/card-footer-link.js +2 -2
  4. package/components/card/card.js +1 -1
  5. package/components/count-badge/count-badge-mixin.js +1 -1
  6. package/components/demo/code-view.js +4 -3
  7. package/components/demo/demo-snippet.js +5 -2
  8. package/components/dialog/dialog-confirm.js +1 -0
  9. package/components/dialog/dialog-mixin.js +7 -2
  10. package/components/dropdown/dropdown-button-subtle.js +1 -1
  11. package/components/dropdown/dropdown-button.js +1 -1
  12. package/components/dropdown/dropdown-content-mixin.js +6 -6
  13. package/components/dropdown/dropdown-context-menu.js +1 -1
  14. package/components/dropdown/dropdown-menu.js +1 -0
  15. package/components/dropdown/dropdown-more.js +1 -1
  16. package/components/dropdown/dropdown-opener-mixin.js +1 -0
  17. package/components/dropdown/dropdown-tabs.js +1 -0
  18. package/components/dropdown/dropdown.js +1 -0
  19. package/components/expand-collapse/expand-collapse-content.js +4 -4
  20. package/components/filter/filter.js +5 -4
  21. package/components/focus-trap/focus-trap.js +6 -5
  22. package/components/form/demo/form-demo.js +1 -1
  23. package/components/form/demo/form-dialog-demo.js +4 -4
  24. package/components/form/demo/form-native-demo.js +1 -1
  25. package/components/form/form-element-mixin.js +12 -3
  26. package/components/form/form-errory-summary.js +2 -2
  27. package/components/form/form-native.js +1 -1
  28. package/components/form/form.js +1 -1
  29. package/components/hierarchical-view/hierarchical-view-mixin.js +7 -6
  30. package/components/html-block/demo/html-block.html +31 -0
  31. package/components/html-block/html-block.js +18 -7
  32. package/components/inputs/demo/input-radio-solo-test.js +1 -1
  33. package/components/inputs/demo/input-radio-spacer-test.js +1 -1
  34. package/components/inputs/demo/input-select-test.js +1 -1
  35. package/components/inputs/input-checkbox.js +1 -1
  36. package/components/inputs/input-date-range.js +4 -3
  37. package/components/inputs/input-date-time-range-to.js +1 -1
  38. package/components/inputs/input-date-time-range.js +4 -3
  39. package/components/inputs/input-date-time.js +6 -5
  40. package/components/inputs/input-date.js +3 -0
  41. package/components/inputs/input-number.js +2 -1
  42. package/components/inputs/input-percent.js +2 -1
  43. package/components/inputs/input-search.js +3 -3
  44. package/components/inputs/input-text.js +8 -8
  45. package/components/inputs/input-textarea.js +5 -5
  46. package/components/inputs/input-time-range.js +4 -4
  47. package/components/inputs/input-time.js +1 -1
  48. package/components/link/link.js +1 -1
  49. package/components/list/demo/list-drag-and-drop.js +3 -1
  50. package/components/list/list-item-checkbox-mixin.js +1 -1
  51. package/components/list/list-item-drag-drop-mixin.js +10 -5
  52. package/components/list/list-item-generic-layout.js +5 -4
  53. package/components/list/list-item-mixin.js +1 -0
  54. package/components/list/list.js +2 -0
  55. package/components/menu/demo/custom-view.js +1 -1
  56. package/components/menu/menu-item-link.js +1 -1
  57. package/components/menu/menu-item-mixin.js +1 -1
  58. package/components/menu/menu.js +2 -2
  59. package/components/overflow-group/overflow-group.js +1 -1
  60. package/components/scroll-wrapper/demo/scroll-wrapper-test.js +1 -1
  61. package/components/selection/selection-action.js +1 -1
  62. package/components/selection/selection-input.js +1 -1
  63. package/components/selection/selection-select-all.js +1 -1
  64. package/components/switch/switch-mixin.js +1 -1
  65. package/components/table/table-col-sort-button.js +1 -1
  66. package/components/tabs/tabs.js +20 -15
  67. package/components/tooltip/tooltip.js +1 -1
  68. package/custom-elements.json +13 -0
  69. package/directives/animate/animate.js +35 -18
  70. package/helpers/demo/announce-test.js +1 -0
  71. package/mixins/arrow-keys-mixin.js +3 -1
  72. package/package.json +1 -1
  73. package/templates/primary-secondary/primary-secondary.js +2 -1
@@ -53,7 +53,7 @@ class TestScrollWrapper extends RtlMixin(LitElement) {
53
53
  }
54
54
 
55
55
  focus() {
56
- forceFocusVisible(this.shadowRoot.querySelector('d2l-scroll-wrapper')._container);
56
+ if (this.shadowRoot) forceFocusVisible(this.shadowRoot.querySelector('d2l-scroll-wrapper')._container);
57
57
  }
58
58
 
59
59
  }
@@ -79,7 +79,7 @@ class Action extends LocalizeCoreElement(SelectionObserverMixin(ButtonMixin(RtlM
79
79
  }
80
80
 
81
81
  focus() {
82
- const elem = this.shadowRoot.querySelector('d2l-button-subtle');
82
+ const elem = this.shadowRoot && this.shadowRoot.querySelector('d2l-button-subtle');
83
83
  if (elem) elem.focus();
84
84
  }
85
85
 
@@ -142,7 +142,7 @@ class Input extends SkeletonMixin(LabelledMixin(LitElement)) {
142
142
  }
143
143
 
144
144
  focus() {
145
- const elem = this.shadowRoot.firstElementChild;
145
+ const elem = this.shadowRoot && this.shadowRoot.firstElementChild;
146
146
  if (elem) elem.focus();
147
147
  }
148
148
 
@@ -57,7 +57,7 @@ class SelectAll extends LocalizeCoreElement(SelectionObserverMixin(LitElement))
57
57
  }
58
58
 
59
59
  focus() {
60
- const elem = this.shadowRoot.querySelector('d2l-input-checkbox');
60
+ const elem = this.shadowRoot && this.shadowRoot.querySelector('d2l-input-checkbox');
61
61
  if (elem) elem.focus();
62
62
  }
63
63
 
@@ -213,7 +213,7 @@ export const SwitchMixin = superclass => class extends RtlMixin(FocusVisiblePoly
213
213
  }
214
214
 
215
215
  focus() {
216
- const elem = this.shadowRoot.querySelector('.d2l-switch-container');
216
+ const elem = this.shadowRoot && this.shadowRoot.querySelector('.d2l-switch-container');
217
217
  if (elem) elem.focus();
218
218
  }
219
219
 
@@ -71,7 +71,7 @@ export class TableColSortButton extends LitElement {
71
71
  }
72
72
 
73
73
  focus() {
74
- const button = this.shadowRoot.querySelector('button');
74
+ const button = this.shadowRoot && this.shadowRoot.querySelector('button');
75
75
  if (button) button.focus();
76
76
  }
77
77
 
@@ -374,34 +374,37 @@ class Tabs extends LocalizeCoreElement(ArrowKeysMixin(RtlMixin(FocusVisiblePolyf
374
374
  }
375
375
 
376
376
  getTabListRect() {
377
+ if (!this.shadowRoot) return undefined;
377
378
  return this.shadowRoot.querySelector('.d2l-tabs-container-list').getBoundingClientRect();
378
379
  }
379
380
 
380
381
  _animateTabAddition(tabInfo) {
381
- const tab = this.shadowRoot.querySelector(`d2l-tab-internal[controls-panel="${cssEscape(tabInfo.id)}"]`);
382
+ const tab = this.shadowRoot
383
+ && this.shadowRoot.querySelector(`d2l-tab-internal[controls-panel="${cssEscape(tabInfo.id)}"]`);
382
384
  return new Promise((resolve) => {
383
385
  const handleTransitionEnd = (e) => {
384
386
  if (e.propertyName !== 'max-width') return;
385
- tab.removeEventListener('transitionend', handleTransitionEnd);
387
+ if (tab) tab.removeEventListener('transitionend', handleTransitionEnd);
386
388
  resolve();
387
389
  };
388
- tab.addEventListener('transitionend', handleTransitionEnd);
390
+ if (tab) tab.addEventListener('transitionend', handleTransitionEnd);
389
391
  tabInfo.state = '';
390
392
  this.requestUpdate();
391
393
  });
392
394
  }
393
395
 
394
396
  _animateTabRemoval(tabInfo) {
395
- const tab = this.shadowRoot.querySelector(`d2l-tab-internal[controls-panel="${cssEscape(tabInfo.id)}"]`);
397
+ const tab = this.shadowRoot &&
398
+ this.shadowRoot.querySelector(`d2l-tab-internal[controls-panel="${cssEscape(tabInfo.id)}"]`);
396
399
  return new Promise((resolve) => {
397
400
  const handleTransitionEnd = (e) => {
398
401
  if (e.propertyName !== 'max-width') return;
399
- tab.removeEventListener('transitionend', handleTransitionEnd);
402
+ if (tab) tab.removeEventListener('transitionend', handleTransitionEnd);
400
403
  this._tabInfos.splice(this._tabInfos.findIndex(info => info.id === tabInfo.id), 1);
401
404
  this.requestUpdate();
402
405
  resolve();
403
406
  };
404
- tab.addEventListener('transitionend', handleTransitionEnd);
407
+ if (tab) tab.addEventListener('transitionend', handleTransitionEnd);
405
408
  });
406
409
  }
407
410
 
@@ -488,7 +491,7 @@ class Tabs extends LocalizeCoreElement(ArrowKeysMixin(RtlMixin(FocusVisiblePolyf
488
491
  }
489
492
 
490
493
  async _focusSelected() {
491
- const selectedTab = this.shadowRoot.querySelector('d2l-tab-internal[aria-selected="true"]');
494
+ const selectedTab = this.shadowRoot && this.shadowRoot.querySelector('d2l-tab-internal[aria-selected="true"]');
492
495
  if (!selectedTab) return;
493
496
 
494
497
  const selectedTabInfo = this._getTabInfo(selectedTab.controlsPanel);
@@ -517,6 +520,7 @@ class Tabs extends LocalizeCoreElement(ArrowKeysMixin(RtlMixin(FocusVisiblePolyf
517
520
  }
518
521
 
519
522
  _getPanel(id) {
523
+ if (!this.shadowRoot) return;
520
524
  // use simple selector for slot (Edge)
521
525
  const slot = this.shadowRoot.querySelector('.d2l-panels-container').querySelector('slot');
522
526
  const panels = this._getPanels(slot);
@@ -702,7 +706,7 @@ class Tabs extends LocalizeCoreElement(ArrowKeysMixin(RtlMixin(FocusVisiblePolyf
702
706
  await this._scrollToPosition(newTranslationValue);
703
707
  await this._updateScrollVisibility(newMeasures);
704
708
 
705
- if (!isOverflowingNext) {
709
+ if (!isOverflowingNext && this.shadowRoot) {
706
710
  this.shadowRoot.querySelector('.d2l-tabs-scroll-previous-container button').focus();
707
711
  }
708
712
 
@@ -735,7 +739,7 @@ class Tabs extends LocalizeCoreElement(ArrowKeysMixin(RtlMixin(FocusVisiblePolyf
735
739
  await this._scrollToPosition(newTranslationValue);
736
740
  await this._updateScrollVisibility(newMeasures);
737
741
 
738
- if (!isOverflowingPrevious) {
742
+ if (!isOverflowingPrevious && this.shadowRoot) {
739
743
  this.shadowRoot.querySelector('.d2l-tabs-scroll-next-container button').focus();
740
744
  }
741
745
 
@@ -777,7 +781,7 @@ class Tabs extends LocalizeCoreElement(ArrowKeysMixin(RtlMixin(FocusVisiblePolyf
777
781
  }
778
782
 
779
783
  this._translationValue = translationValue;
780
- if (reduceMotion) return this.updateComplete;
784
+ if (!this.shadowRoot || reduceMotion) return this.updateComplete;
781
785
 
782
786
  return new Promise((resolve) => {
783
787
  const tabList = this.shadowRoot.querySelector('.d2l-tabs-container-list');
@@ -805,13 +809,13 @@ class Tabs extends LocalizeCoreElement(ArrowKeysMixin(RtlMixin(FocusVisiblePolyf
805
809
  expandedPromise = this.updateComplete;
806
810
  } else {
807
811
  expandedPromise = new Promise((resolve) => {
808
- const tabsContainer = this.shadowRoot.querySelector('.d2l-tabs-container');
812
+ const tabsContainer = this.shadowRoot && this.shadowRoot.querySelector('.d2l-tabs-container');
809
813
  const handleTransitionEnd = (e) => {
810
814
  if (e.propertyName !== 'max-width') return;
811
- tabsContainer.removeEventListener('transitionend', handleTransitionEnd);
815
+ if (tabsContainer) tabsContainer.removeEventListener('transitionend', handleTransitionEnd);
812
816
  resolve();
813
817
  };
814
- tabsContainer.addEventListener('transitionend', handleTransitionEnd);
818
+ if (tabsContainer) tabsContainer.addEventListener('transitionend', handleTransitionEnd);
815
819
  this._scrollCollapsed = false;
816
820
  this._maxWidth = measures.totalTabsWidth + 50;
817
821
  });
@@ -828,7 +832,7 @@ class Tabs extends LocalizeCoreElement(ArrowKeysMixin(RtlMixin(FocusVisiblePolyf
828
832
  if (!this._allowScrollPrevious) {
829
833
  this._focusSelected();
830
834
  } else {
831
- this.shadowRoot.querySelector('.d2l-tabs-scroll-previous-container button').focus();
835
+ if (this.shadowRoot) this.shadowRoot.querySelector('.d2l-tabs-scroll-previous-container button').focus();
832
836
  }
833
837
  }
834
838
 
@@ -838,6 +842,7 @@ class Tabs extends LocalizeCoreElement(ArrowKeysMixin(RtlMixin(FocusVisiblePolyf
838
842
 
839
843
  _updateMeasures() {
840
844
  let totalTabsWidth = 0;
845
+ if (!this.shadowRoot) return;
841
846
  const tabs = [...this.shadowRoot.querySelectorAll('d2l-tab-internal')];
842
847
 
843
848
  const tabRects = tabs.map((tab) => {
@@ -894,7 +899,7 @@ class Tabs extends LocalizeCoreElement(ArrowKeysMixin(RtlMixin(FocusVisiblePolyf
894
899
  // don't animate the tabs list visibility if it's the inital render
895
900
  if (reduceMotion || !this._initialized) {
896
901
  this._state = 'hidden';
897
- } else {
902
+ } else if (this.shadowRoot) {
898
903
  const layout = this.shadowRoot.querySelector('.d2l-tabs-layout');
899
904
  const handleTransitionEnd = (e) => {
900
905
  if (e.propertyName !== 'max-height') return;
@@ -715,7 +715,7 @@ class Tooltip extends RtlMixin(LitElement) {
715
715
  }
716
716
 
717
717
  _getContent() {
718
- return this.shadowRoot.querySelector('.d2l-tooltip-content');
718
+ return this.shadowRoot && this.shadowRoot.querySelector('.d2l-tooltip-content');
719
719
  }
720
720
 
721
721
  _isAboveOrBelow() {
@@ -3378,6 +3378,12 @@
3378
3378
  "path": "./components/html-block/html-block.js",
3379
3379
  "description": "A component for displaying user-authored HTML.",
3380
3380
  "attributes": [
3381
+ {
3382
+ "name": "compact",
3383
+ "description": "Whether compact styles should be applied",
3384
+ "type": "Boolean",
3385
+ "default": "false"
3386
+ },
3381
3387
  {
3382
3388
  "name": "no-deferred-rendering",
3383
3389
  "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.",
@@ -3386,6 +3392,13 @@
3386
3392
  }
3387
3393
  ],
3388
3394
  "properties": [
3395
+ {
3396
+ "name": "compact",
3397
+ "attribute": "compact",
3398
+ "description": "Whether compact styles should be applied",
3399
+ "type": "Boolean",
3400
+ "default": "false"
3401
+ },
3389
3402
  {
3390
3403
  "name": "noDeferredRendering",
3391
3404
  "attribute": "no-deferred-rendering",
@@ -1,6 +1,8 @@
1
- import { directive, PropertyPart } from 'lit-html';
1
+ import { directive, PartType } from 'lit-html/directive.js';
2
2
  import { getComposedActiveElement, getNextFocusable } from '../../helpers/focus.js';
3
+ import { AsyncDirective } from 'lit-html/async-directive.js';
3
4
  import { isComposedAncestor } from '../../helpers/dom.js';
5
+ import { noChange } from 'lit-html';
4
6
 
5
7
  const stateMap = new WeakMap();
6
8
  const reduceMotion = matchMedia('(prefers-reduced-motion: reduce)').matches;
@@ -10,15 +12,13 @@ const moveYValue = 20;
10
12
 
11
13
  class AnimationState {
12
14
 
13
- constructor(propertyPart) {
14
-
15
- if (!(propertyPart instanceof PropertyPart) || propertyPart.committer.name !== 'animate') {
16
- throw new Error('animation directives must be used with "animate" property');
15
+ constructor(partInfo) {
16
+ if (!(partInfo.type === PartType.PROPERTY) || partInfo.name !== 'animate') {
17
+ throw new Error('animate directives must be used with "animate" property');
17
18
  }
18
-
19
19
  this.id = 0;
20
20
  this.clone = null;
21
- this.elem = propertyPart.committer.element;
21
+ this.elem = partInfo.element;
22
22
  this.state = 'unknown';
23
23
  this.styleAttr = null;
24
24
  this.styleAttrUse = false;
@@ -289,20 +289,37 @@ class AnimationState {
289
289
 
290
290
  }
291
291
 
292
- async function helper(part, action, opts) {
293
- let state = stateMap.get(part);
294
- if (state === undefined) {
295
- state = new AnimationState(part);
296
- stateMap.set(part, state);
292
+ class Hide extends AsyncDirective {
293
+ render() {
294
+ return noChange;
297
295
  }
298
- opts = opts || {};
299
- if (action === 'show') {
300
- state.show(opts);
301
- } else if (action === 'hide') {
296
+ update(part, [opts]) {
297
+ opts = opts || {};
298
+ let state = stateMap.get(part.element);
299
+ if (state === undefined) {
300
+ state = new AnimationState(part);
301
+ stateMap.set(part.element, state);
302
+ }
302
303
  state.hide(opts);
304
+ return this.render();
303
305
  }
304
306
  }
305
307
 
306
- export const hide = directive((opts) => async(part) => helper(part, 'hide', opts));
308
+ class Show extends AsyncDirective {
309
+ render() {
310
+ return noChange;
311
+ }
312
+ update(part, [opts]) {
313
+ opts = opts || {};
314
+ let state = stateMap.get(part.element);
315
+ if (state === undefined) {
316
+ state = new AnimationState(part);
317
+ stateMap.set(part.element, state);
318
+ }
319
+ state.show(opts);
320
+ return this.render();
321
+ }
322
+ }
307
323
 
308
- export const show = directive((opts) => async(part) => helper(part, 'show', opts));
324
+ export const hide = directive(Hide);
325
+ export const show = directive(Show);
@@ -25,6 +25,7 @@ class AnnounceTest extends LitElement {
25
25
  }
26
26
 
27
27
  _handleAnnounce() {
28
+ if (!this.shadowRoot) return;
28
29
  const value1 = this.shadowRoot.querySelector('#msg1').value;
29
30
  if (value1.length > 0) announce(value1);
30
31
  const value2 = this.shadowRoot.querySelector('#msg2').value;
@@ -37,7 +37,9 @@ export const ArrowKeysMixin = superclass => class extends superclass {
37
37
  }
38
38
 
39
39
  async arrowKeysFocusablesProvider() {
40
- return [...this.shadowRoot.querySelectorAll('.d2l-arrowkeys-focusable')];
40
+ return this.shadowRoot ?
41
+ [...this.shadowRoot.querySelectorAll('.d2l-arrowkeys-focusable')]
42
+ : [];
41
43
  }
42
44
 
43
45
  async _focus(elem) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightspace-ui/core",
3
- "version": "1.213.2",
3
+ "version": "1.217.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",
@@ -1014,6 +1014,7 @@ class TemplatePrimarySecondary extends FocusVisiblePolyfillMixin(RtlMixin(Locali
1014
1014
  }
1015
1015
 
1016
1016
  _computeContentBounds(contentRect) {
1017
+ if (!this.shadowRoot) return;
1017
1018
  const divider = this.shadowRoot.querySelector('.d2l-template-primary-secondary-divider');
1018
1019
  const desktopDividerSize = divider.offsetWidth;
1019
1020
  const mobileDividerSize = divider.offsetHeight;
@@ -1057,7 +1058,7 @@ class TemplatePrimarySecondary extends FocusVisiblePolyfillMixin(RtlMixin(Locali
1057
1058
  } else {
1058
1059
  if (this._isMobile) {
1059
1060
  this._size = this._contentBounds.minHeight;
1060
- } else {
1061
+ } else if (this.shadowRoot) {
1061
1062
  const divider = this.shadowRoot.querySelector('.d2l-template-primary-secondary-divider');
1062
1063
  const desktopDividerSize = contentRect.width - divider.offsetWidth;
1063
1064
  this._size = Math.max(desktopMinSize, desktopDividerSize * (1 / 3));