@brightspace-ui/labs 2.36.0 → 2.36.2

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/package.json CHANGED
@@ -114,5 +114,5 @@
114
114
  "resize-observer-polyfill": "^1",
115
115
  "webvtt-parser": "^2.1.2"
116
116
  },
117
- "version": "2.36.0"
117
+ "version": "2.36.2"
118
118
  }
@@ -1447,10 +1447,11 @@ class MediaPlayer extends LocalizeLabsElement(RtlMixin(LitElement)) {
1447
1447
  </div>
1448
1448
  `;
1449
1449
 
1450
- // format of the thumbnail is [url]/th<height>w<height>i<interval>-<hash>.[png|jpg]
1451
- const matches = this.thumbnails.match(/th(\d+)w(\d+)i(\d+)[^/]*$/i);
1452
- if (matches && matches.length !== 4) return; // no matches
1453
- const [ , thumbHeight, thumbWidth, interval] = matches;
1450
+ // format of the thumbnail is either [url]/timelineThumbnails-h<height>w<height>i<interval>-<hash>.[png|jpg]
1451
+ // or [url]/th<height>w<height>i<interval>-<hash>.[png|jpg]
1452
+ const matches = this.thumbnails.match(/(timelineThumbnails-|t)h(\d+)w(\d+)i(\d+)[^/]*$/i);
1453
+ if (matches && matches.length !== 5) return; // no matches
1454
+ const [ , , thumbHeight, thumbWidth, interval] = matches;
1454
1455
 
1455
1456
  const width = this._thumbnailsImage.width;
1456
1457
  const height = this._thumbnailsImage.height;
@@ -755,17 +755,20 @@ class TreeFilter extends LocalizeLabsElement(MobxLitElement) {
755
755
  _renderChildren(id, parentName, indentLevel = 0) {
756
756
  parentName = parentName || this.localize('components:ouFilter:treeFilter:nodeName:root');
757
757
 
758
- if (id === undefined || this.tree.getChildIdsForDisplay(id).length === 0) {
759
- return html`<d2l-empty-state-simple
760
- slot="tree"
761
- description="${this.localize('components:ouFilter:treeSelector:noFiltersAvailable')}"
762
- >
763
- </d2l-empty-state-simple>`;
758
+ const emptyState = html`<d2l-empty-state-simple
759
+ slot="tree"
760
+ description="${this.localize('components:ouFilter:treeSelector:noFiltersAvailable')}"
761
+ ></d2l-empty-state-simple>`;
762
+
763
+ if (id === undefined) {
764
+ return emptyState;
764
765
  }
765
766
 
766
767
  if (!this.tree.isPopulated(id)) {
767
768
  // request children; in the meantime we can render whatever we have
768
769
  this._requestChildren(id);
770
+ } else if (this.tree.getChildIdsForDisplay(id).length === 0) {
771
+ return emptyState;
769
772
  }
770
773
 
771
774
  return [
@@ -184,6 +184,15 @@ import { navigate } from '@brightspace-ui/labs/utilities/lit-router';
184
184
  navigate('/my-app/new-place');
185
185
  ```
186
186
 
187
+ navigate can also be used to pass data between views. This is useful for sharing state objects between views without needing to make additional server calls. If the data you are sharing with a view is part of the state of the next view consider using a search param instead.
188
+
189
+ ```js
190
+ import { navigate } from '@brightspace-ui/labs/utilities/lit-router';
191
+
192
+ navigate(`/users?userId=${userId}`, { data: { /* sharing the user object here so I don't need to fetch it again */ } });
193
+ ```
194
+
195
+
187
196
  To redirect to a page and replace the previous browser history item the new one, use `redirect(path)`:
188
197
 
189
198
  ```js
@@ -224,4 +233,4 @@ describe('Page Routing', () => {
224
233
 
225
234
  This issue is resolved by default but the fix can be bypassed (for backwards compatibility) by setting the `disableRouteOrderFix` option to `true`.
226
235
 
227
- Bypassing the fix causes a warning to appear in the dev console. To resolve the warning, remove the `disaableRouteOrderFix` option and thoroughly test your routing. If your routes contain wildcards (`*`, typically for 404s), you may need to register them last.
236
+ Bypassing the fix causes a warning to appear in the dev console. To resolve the warning, remove the `disaableRouteOrderFix` option and thoroughly test your routing. If your routes contain wildcards (`*`, typically for 404s), you may need to register them last.
@@ -3,6 +3,7 @@ import page from 'page';
3
3
  let activePage = page;
4
4
  let _lastOptions = {};
5
5
  let _lastContext = {};
6
+ let passedData = undefined;
6
7
 
7
8
  export const _createReducedContext = pageContext => ({
8
9
  params: pageContext.params,
@@ -12,7 +13,9 @@ export const _createReducedContext = pageContext => ({
12
13
  hash: pageContext.hash,
13
14
  route: pageContext.routePath,
14
15
  title: pageContext.title,
16
+ loaderData: pageContext.loaderData,
15
17
  options: {},
18
+ passedData,
16
19
  });
17
20
 
18
21
  const _storeCtx = () => {
@@ -27,7 +30,9 @@ const _handleRouteView = (context, next, r) => {
27
30
  const reducedContext = _createReducedContext(context);
28
31
  context.view = (host, options) => {
29
32
  reducedContext.options = options || {};
30
- return r.view.call(host, reducedContext);
33
+ const resultingView = r.view.call(host, reducedContext);
34
+ passedData = undefined;
35
+ return resultingView;
31
36
  };
32
37
  context.handled = true;
33
38
 
@@ -47,7 +52,7 @@ const _handleRouteLoader = r => (context, next) => {
47
52
  }
48
53
 
49
54
  if (r.loader) {
50
- r.loader().then(() => {
55
+ r.loader(context).then(() => {
51
56
  _handleRouteView(context, next, r);
52
57
  });
53
58
  } else if (r.pattern && r.to) {
@@ -118,7 +123,9 @@ const addMiddleware = callback => {
118
123
 
119
124
  // Triggers navigation to the specified route path.
120
125
  // Creates a new entry in the browser's history stack.
121
- export const navigate = path => {
126
+ // data in the options object is available to the next view in ctx.passedData
127
+ export const navigate = (path, options) => {
128
+ passedData = options?.data;
122
129
  activePage.show(path);
123
130
  };
124
131