@brightspace-ui/core 3.60.1 → 3.61.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -16,7 +16,7 @@
16
16
  import './filter-load-more-demo.js';
17
17
  </script>
18
18
  <script>
19
- window.D2L = { LP: { Web: { UI: { Flags: { Flag: () => true } } } } };
19
+ window.D2L = { LP: { Web: { UI: { Flags: { Flag: () => false } } } } };
20
20
  </script>
21
21
  <meta name="viewport" content="width=device-width, minimum-scale=1, initial-scale=1.0">
22
22
  <meta charset="UTF-8">
@@ -172,7 +172,12 @@
172
172
  <d2l-filter-dimension-set-date-text-value key="today" range="today"></d2l-filter-dimension-set-date-text-value>
173
173
  <d2l-filter-dimension-set-date-text-value key="6months" range="6months"></d2l-filter-dimension-set-date-text-value>
174
174
  <d2l-filter-dimension-set-date-time-range-value key="custom" type="date"></d2l-filter-dimension-set-date-time-range-value>
175
- <d2l-filter-dimension-set-date-time-range-value key="custom2" text="Custom Date Range with Time"></d2l-filter-dimension-set-date-time-range-value>
175
+ <d2l-filter-dimension-set-date-time-range-value key="custom2" text="Custom Date Range with Time" start-value="2024-10-12T12:00:00Z"></d2l-filter-dimension-set-date-time-range-value>
176
+ </d2l-filter-dimension-set>
177
+ <d2l-filter-dimension-set key="role" text="Role" selected-first>
178
+ <d2l-filter-dimension-set-value key="admin" text="Admin" count="0"></d2l-filter-dimension-set-value>
179
+ <d2l-filter-dimension-set-value key="instructor" text="Instructor" count="22"></d2l-filter-dimension-set-value>
180
+ <d2l-filter-dimension-set-value key="student" text="Student" count="50"></d2l-filter-dimension-set-value>
176
181
  </d2l-filter-dimension-set>
177
182
  </d2l-filter>
178
183
  </template>
@@ -257,13 +257,6 @@ class Filter extends FocusMixin(LocalizeCoreElement(RtlMixin(LitElement))) {
257
257
  firstUpdated(changedProperties) {
258
258
  super.firstUpdated(changedProperties);
259
259
  this.addEventListener('d2l-filter-dimension-data-change', this._handleDimensionDataChange);
260
-
261
- // Prevent these events from bubbling out of the filter
262
- this.addEventListener('d2l-hierarchical-view-hide-complete', this._stopPropagation);
263
- this.addEventListener('d2l-hierarchical-view-hide-start', this._stopPropagation);
264
- this.addEventListener('d2l-hierarchical-view-show-complete', this._stopPropagation);
265
- this.addEventListener('d2l-hierarchical-view-show-start', this._stopPropagation);
266
- this.addEventListener('d2l-hierarchical-view-resize', this._stopPropagation);
267
260
  }
268
261
 
269
262
  render() {
@@ -7,6 +7,11 @@
7
7
  <script type="module">
8
8
  import '../../demo/demo-page.js';
9
9
  import '../hierarchical-view.js';
10
+ import '../../dropdown/dropdown-menu.js';
11
+ import '../../dropdown/dropdown-button.js';
12
+ import '../../menu/menu.js';
13
+ import '../../menu/menu-item.js';
14
+
10
15
  </script>
11
16
  <style>
12
17
  #view1, #view2a, #view2b, #view3, #view4 {
@@ -77,6 +82,30 @@
77
82
  <div class="buttons">
78
83
  <button id="btn-parent-view-2a">view 1 (parent)</button>
79
84
  <button id="btn-view-3">view 3</button>
85
+ <d2l-dropdown-button text="Open!" primary>
86
+ <d2l-dropdown-menu >
87
+ <d2l-menu label="Astronomy" root-view >
88
+ <d2l-menu-item text="Introduction"></d2l-menu-item>
89
+ <d2l-menu-item text="Searching for the Heavens "></d2l-menu-item>
90
+ <d2l-menu-item text="The Solar System">
91
+ <d2l-menu>
92
+ <d2l-menu-item text="Formation"></d2l-menu-item>
93
+ <d2l-menu-item text="Modern Solar System"></d2l-menu-item>
94
+ <d2l-menu-item text="Future Solar System"></d2l-menu-item>
95
+ <d2l-menu-item text="The Planets"></d2l-menu-item>
96
+ <d2l-menu-item text="The Sun"></d2l-menu-item>
97
+ <d2l-menu-item text="Solar &amp; Lunar Eclipses"></d2l-menu-item>
98
+ <d2l-menu-item text="Meteors &amp; Meteorites"></d2l-menu-item>
99
+ <d2l-menu-item text="Asteroids"></d2l-menu-item>
100
+ <d2l-menu-item text="Comets"></d2l-menu-item>
101
+ </d2l-menu>
102
+ </d2l-menu-item>
103
+ <d2l-menu-item text="Stars &amp; Galaxies"></d2l-menu-item>
104
+ <d2l-menu-item text="The Night Sky"></d2l-menu-item>
105
+ <d2l-menu-item text="The Universe"></d2l-menu-item>
106
+ </d2l-menu>
107
+ </d2l-dropdown-menu>
108
+ </d2l-dropdown-button>
80
109
  </div>
81
110
  view 2a
82
111
  <div class="info">min-height: 400</div>
@@ -14,15 +14,16 @@ export const HierarchicalViewMixin = superclass => class extends superclass {
14
14
  /**
15
15
  * @ignore
16
16
  */
17
- childView: { type: Boolean, reflect: true, attribute: 'child-view' },
17
+ hierarchicalView: { type: Boolean },
18
18
  /**
19
19
  * @ignore
20
20
  */
21
- hierarchicalView: { type: Boolean },
21
+ rootView: { type: Boolean, attribute: 'root-view' },
22
22
  /**
23
23
  * @ignore
24
24
  */
25
- shown: { type: Boolean, reflect: true }
25
+ shown: { type: Boolean, reflect: true },
26
+ _childView: { type: Boolean, reflect: true, attribute: 'child-view' },
26
27
  };
27
28
  }
28
29
 
@@ -97,10 +98,11 @@ export const HierarchicalViewMixin = superclass => class extends superclass {
97
98
  constructor() {
98
99
  super();
99
100
 
100
- /** @ignore */
101
- this.childView = false;
102
101
  /** @ignore */
103
102
  this.hierarchicalView = true;
103
+ /** @ignore */
104
+ this.rootView = false;
105
+ this._childView = false;
104
106
  this.__focusPrevious = false;
105
107
  this.__intersectionObserver = null;
106
108
  this.__isAutoSized = false;
@@ -111,7 +113,7 @@ export const HierarchicalViewMixin = superclass => class extends superclass {
111
113
  connectedCallback() {
112
114
  super.connectedCallback();
113
115
 
114
- this.__isChildView();
116
+ this.__updateRootView();
115
117
 
116
118
  if (typeof(IntersectionObserver) === 'function') {
117
119
  this.__intersectionObserver = new IntersectionObserver((entries) => {
@@ -135,7 +137,7 @@ export const HierarchicalViewMixin = superclass => class extends superclass {
135
137
  }
136
138
  this.__startResizeObserver();
137
139
 
138
- if (!this.childView) {
140
+ if (!this._childView) {
139
141
  this.addEventListener('focus', this.__focusCapture, true);
140
142
  this.addEventListener('focusout', this.__focusOutCapture, true);
141
143
  this.__onWindowResize = this.__onWindowResize.bind(this);
@@ -167,7 +169,7 @@ export const HierarchicalViewMixin = superclass => class extends superclass {
167
169
 
168
170
  const stopPropagation = e => {
169
171
  // only stop for child views, so that Esc from root view can close dropdown
170
- if (!this.childView) return;
172
+ if (!this._childView) return;
171
173
  e.stopPropagation();
172
174
  };
173
175
 
@@ -178,8 +180,14 @@ export const HierarchicalViewMixin = superclass => class extends superclass {
178
180
  this.addEventListener('keyup', stopPropagation);
179
181
  this.addEventListener('keypress', stopPropagation);
180
182
 
181
- this.__isChildView();
183
+ this.__updateRootView();
182
184
 
185
+ if (!this.rootView) return;
186
+ this.addEventListener('d2l-hierarchical-view-hide-complete', this.__stopPropagation);
187
+ this.addEventListener('d2l-hierarchical-view-hide-start', this.__stopPropagation);
188
+ this.addEventListener('d2l-hierarchical-view-show-complete', this.__stopPropagation);
189
+ this.addEventListener('d2l-hierarchical-view-show-start', this.__stopPropagation);
190
+ this.addEventListener('d2l-hierarchical-view-resize', this.__stopPropagation);
183
191
  }
184
192
 
185
193
  getActiveView() {
@@ -198,13 +206,13 @@ export const HierarchicalViewMixin = superclass => class extends superclass {
198
206
  }
199
207
 
200
208
  getRootView() {
201
- if (!this.childView) {
209
+ if (this.rootView || !this._childView) {
202
210
  return this;
203
211
  }
204
212
  const rootView = findComposedAncestor(
205
213
  this.parentNode,
206
214
  (node) => {
207
- return node.hierarchicalView && !node.childView;
215
+ return node.rootView;
208
216
  }
209
217
  );
210
218
  return rootView;
@@ -228,7 +236,7 @@ export const HierarchicalViewMixin = superclass => class extends superclass {
228
236
  }
229
237
 
230
238
  isActive() {
231
- if ((this.childView && !this.shown) || !this.shadowRoot) {
239
+ if ((this._childView && !this.shown) || !this.shadowRoot) {
232
240
  return false;
233
241
  } else {
234
242
  const content = this.shadowRoot.querySelector('.d2l-hierarchical-view-content');
@@ -289,7 +297,7 @@ export const HierarchicalViewMixin = superclass => class extends superclass {
289
297
  }
290
298
 
291
299
  __autoSize(view) {
292
- if (this.__isAutoSized || this.childView) return;
300
+ if (this.__isAutoSized || this._childView) return;
293
301
  requestAnimationFrame(() => {
294
302
 
295
303
  if (view.offsetParent === null) return;
@@ -420,17 +428,6 @@ export const HierarchicalViewMixin = superclass => class extends superclass {
420
428
  }
421
429
  }
422
430
 
423
- __isChildView() {
424
- const parentView = findComposedAncestor(
425
- this.parentNode,
426
- (node) => { return node.hierarchicalView; }
427
- );
428
-
429
- if (parentView) {
430
- this.childView = true;
431
- }
432
- }
433
-
434
431
  __onHideStart(e) {
435
432
  // re-enable focusable ancestor
436
433
  this.__resetAncestorTabIndicies(e.detail.sourceView);
@@ -484,7 +481,7 @@ export const HierarchicalViewMixin = superclass => class extends superclass {
484
481
  }
485
482
 
486
483
  __onKeyDown(e) {
487
- if (this.childView && e.keyCode === escapeKeyCode) {
484
+ if (this._childView && e.keyCode === escapeKeyCode) {
488
485
  e.stopPropagation();
489
486
  this.hide();
490
487
  return;
@@ -498,7 +495,7 @@ export const HierarchicalViewMixin = superclass => class extends superclass {
498
495
  const rootTarget = e.composedPath()[0];
499
496
  if (rootTarget === this || !rootTarget.hierarchicalView) return;
500
497
 
501
- if (this.childView && !this.shown) {
498
+ if (this._childView && !this.shown) {
502
499
  /* deep link scenario */
503
500
  this.show(e.detail.data, e.detail.sourceView);
504
501
  }
@@ -562,6 +559,10 @@ export const HierarchicalViewMixin = superclass => class extends superclass {
562
559
  this.__resizeObserver.observe(content);
563
560
  }
564
561
 
562
+ __stopPropagation(e) {
563
+ e.stopPropagation();
564
+ }
565
+
565
566
  __updateAncestorTabIndicies(view, sourceAttribute, targetAttribute) {
566
567
  const rootView = this.getRootView();
567
568
  let node = getComposedParent(view);
@@ -577,4 +578,15 @@ export const HierarchicalViewMixin = superclass => class extends superclass {
577
578
  }
578
579
  }
579
580
 
581
+ __updateRootView() {
582
+ if (!this.hasAttribute('root-view')) {
583
+ const parentView = findComposedAncestor(
584
+ this.parentNode,
585
+ (node) => { return node.hierarchicalView; }
586
+ );
587
+ this.rootView = !parentView;
588
+ }
589
+ this._childView = !this.rootView;
590
+ }
591
+
580
592
  };
@@ -373,7 +373,8 @@ class InputTime extends InputInlineHelpMixin(FocusMixin(LabelledMixin(SkeletonMi
373
373
  class="d2l-input-time-menu"
374
374
  @d2l-menu-item-change="${this._handleDropdownChange}"
375
375
  id="${this._dropdownId}"
376
- role="listbox">
376
+ role="listbox"
377
+ root-view>
377
378
  ${menuItems}
378
379
  </d2l-menu>
379
380
  <div class="d2l-input-time-timezone d2l-body-small" id="${dropdownIdTimezone}" slot="footer">${this._timezone}</div>
@@ -128,7 +128,7 @@ class Menu extends ThemeMixin(HierarchicalViewMixin(LitElement)) {
128
128
  changedProperties.forEach((oldValue, propName) => {
129
129
  if (propName === 'label') this._labelChanged();
130
130
 
131
- if (propName === 'childView' && this.childView) {
131
+ if (propName === 'rootView' && !this.rootView) {
132
132
  const items = this.shadowRoot.querySelector('.d2l-menu-items');
133
133
  items.insertBefore(this._createReturnItem(), items.childNodes[0]);
134
134
 
@@ -276,7 +276,7 @@ class Menu extends ThemeMixin(HierarchicalViewMixin(LitElement)) {
276
276
  return;
277
277
  }
278
278
 
279
- if (this.childView && e.keyCode === keyCodes.LEFT) {
279
+ if (!this.rootView && e.keyCode === keyCodes.LEFT) {
280
280
  e.stopPropagation();
281
281
  this.hide();
282
282
  return;
@@ -343,7 +343,7 @@ class Menu extends ThemeMixin(HierarchicalViewMixin(LitElement)) {
343
343
  }
344
344
 
345
345
  _onViewResize(e) {
346
- if (this.childView) return;
346
+ if (!this.rootView) return;
347
347
 
348
348
  const eventDetails = {
349
349
  bubbles: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightspace-ui/core",
3
- "version": "3.60.1",
3
+ "version": "3.61.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",