@brightspace-ui/labs 2.11.4 → 2.11.6
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 +1 -1
- package/src/components/navigation/README.md +8 -8
- package/src/utilities/reactive-store/constants.js +1 -0
- package/src/utilities/reactive-store/context-controllers.js +3 -2
- package/src/utilities/reactive-store/reactive-store.js +16 -7
- package/src/utilities/reactive-store/store-consumer.js +2 -1
- package/src/utilities/reactive-store/store-reactor.js +3 -1
package/package.json
CHANGED
|
@@ -8,9 +8,9 @@ Add the `d2l-labs-navigation` component, and provide sub elements `d2l-labs-navi
|
|
|
8
8
|
|
|
9
9
|
```html
|
|
10
10
|
<script type="module">
|
|
11
|
-
import '@brightspace-ui/labs/navigation/navigation.js';
|
|
12
|
-
import '@brightspace-ui/labs/navigation/navigation-main-header.js';
|
|
13
|
-
import '@brightspace-ui/labs/navigation/navigation-main-footer.js';
|
|
11
|
+
import '@brightspace-ui/labs/components/navigation/navigation.js';
|
|
12
|
+
import '@brightspace-ui/labs/components/navigation/navigation-main-header.js';
|
|
13
|
+
import '@brightspace-ui/labs/components/navigation/navigation-main-footer.js';
|
|
14
14
|
</script>
|
|
15
15
|
|
|
16
16
|
<d2l-labs-navigation>
|
|
@@ -35,7 +35,7 @@ Please note that overridding the `left` slot will prevent the Back link from dis
|
|
|
35
35
|
|
|
36
36
|
```html
|
|
37
37
|
<script type="module">
|
|
38
|
-
import '@brightspace-ui/labs/navigation/navigation-immersive.js';
|
|
38
|
+
import '@brightspace-ui/labs/components/navigation/navigation-immersive.js';
|
|
39
39
|
</script>
|
|
40
40
|
|
|
41
41
|
<d2l-labs-navigation-immersive back-link-href="https://www.d2l.com" back-link-text="Back to D2L">
|
|
@@ -63,7 +63,7 @@ Optionally:
|
|
|
63
63
|
|
|
64
64
|
```html
|
|
65
65
|
<script type="module">
|
|
66
|
-
import '@brightspace-ui/labs/navigation/navigation-band.js';
|
|
66
|
+
import '@brightspace-ui/labs/components/navigation/navigation-band.js';
|
|
67
67
|
</script>
|
|
68
68
|
|
|
69
69
|
<d2l-labs-navigation-band></d2l-labs-navigation-band>
|
|
@@ -83,7 +83,7 @@ Add the `d2l-labs-navigation-main-header` component, and provide elements for th
|
|
|
83
83
|
|
|
84
84
|
```html
|
|
85
85
|
<script type="module">
|
|
86
|
-
import '@brightspace-ui/labs/navigation/navigation-main-header.js';
|
|
86
|
+
import '@brightspace-ui/labs/components/navigation/navigation-main-header.js';
|
|
87
87
|
</script>
|
|
88
88
|
|
|
89
89
|
<d2l-labs-navigation-main-header>
|
|
@@ -105,7 +105,7 @@ Add the `d2l-labs-navigation-main-footer` component, and provide elements for th
|
|
|
105
105
|
|
|
106
106
|
```html
|
|
107
107
|
<script type="module">
|
|
108
|
-
import '@brightspace-ui/labs/navigation/navigation-main-footer.js';
|
|
108
|
+
import '@brightspace-ui/labs/components/navigation/navigation-main-footer.js';
|
|
109
109
|
</script>
|
|
110
110
|
|
|
111
111
|
<d2l-labs-navigation-main-footer>
|
|
@@ -164,7 +164,7 @@ Similar to `<d2l-labs-navigation-button-icon>`, a link that comes with an icon a
|
|
|
164
164
|
|
|
165
165
|
```html
|
|
166
166
|
<script type="module">
|
|
167
|
-
import '@brightspace-ui/labs/navigation/navigation-iterator.js';
|
|
167
|
+
import '@brightspace-ui/labs/components/navigation/navigation-iterator.js';
|
|
168
168
|
</script>
|
|
169
169
|
|
|
170
170
|
<d2l-labs-navigation-iterator></d2l-labs-navigation-iterator>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const combinedPropertiesSymbol = Symbol('combinedProperties');
|
|
@@ -3,11 +3,12 @@ import {
|
|
|
3
3
|
ContextConsumer as LitContextConsumer,
|
|
4
4
|
ContextProvider as LitContextProvider
|
|
5
5
|
} from '@lit/context';
|
|
6
|
+
import { combinedPropertiesSymbol } from './constants.js';
|
|
6
7
|
import StoreReactor from './store-reactor.js';
|
|
7
8
|
|
|
8
9
|
export class ContextProvider {
|
|
9
10
|
constructor(host, StoreClass, store = new StoreClass()) {
|
|
10
|
-
const
|
|
11
|
+
const properties = StoreClass[combinedPropertiesSymbol];
|
|
11
12
|
const storeReactor = new StoreReactor(host, store, properties);
|
|
12
13
|
new LitContextProvider(host, {
|
|
13
14
|
context: createContext(StoreClass),
|
|
@@ -31,7 +32,7 @@ export class ContextProvider {
|
|
|
31
32
|
}
|
|
32
33
|
export class ContextConsumer {
|
|
33
34
|
constructor(host, StoreClass) {
|
|
34
|
-
const
|
|
35
|
+
const properties = StoreClass[combinedPropertiesSymbol];
|
|
35
36
|
const target = {
|
|
36
37
|
store: {},
|
|
37
38
|
storeReactor: {},
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { combinedPropertiesSymbol } from './constants.js';
|
|
1
2
|
import { createContextControllers } from './context-controllers.js';
|
|
2
3
|
import PubSub from '../pub-sub/pub-sub.js';
|
|
3
4
|
import StoreConsumer from './store-consumer.js';
|
|
@@ -13,7 +14,11 @@ export default class ReactiveStore {
|
|
|
13
14
|
this._pubSub = new PubSub();
|
|
14
15
|
this._state = {};
|
|
15
16
|
|
|
16
|
-
this.#defineProperties(
|
|
17
|
+
this.#defineProperties();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
static get [combinedPropertiesSymbol]() {
|
|
21
|
+
return getCombinedProperties(this.prototype);
|
|
17
22
|
}
|
|
18
23
|
|
|
19
24
|
createConsumer() {
|
|
@@ -37,12 +42,8 @@ export default class ReactiveStore {
|
|
|
37
42
|
this._pubSub.unsubscribe(callback);
|
|
38
43
|
}
|
|
39
44
|
|
|
40
|
-
#defineProperties(
|
|
41
|
-
|
|
42
|
-
this.#defineProperties(Object.getPrototypeOf(proto));
|
|
43
|
-
|
|
44
|
-
const { properties } = proto.constructor;
|
|
45
|
-
if (!properties) return;
|
|
45
|
+
#defineProperties() {
|
|
46
|
+
const properties = this.constructor[combinedPropertiesSymbol];
|
|
46
47
|
|
|
47
48
|
Object.keys(properties).forEach((property) => {
|
|
48
49
|
Object.defineProperty(this, property, {
|
|
@@ -62,3 +63,11 @@ export default class ReactiveStore {
|
|
|
62
63
|
});
|
|
63
64
|
}
|
|
64
65
|
}
|
|
66
|
+
|
|
67
|
+
function getCombinedProperties(proto) {
|
|
68
|
+
if (!(proto instanceof ReactiveStore)) return {};
|
|
69
|
+
return {
|
|
70
|
+
...getCombinedProperties(Object.getPrototypeOf(proto)),
|
|
71
|
+
...(proto.constructor.properties ?? {})
|
|
72
|
+
};
|
|
73
|
+
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { combinedPropertiesSymbol } from './constants.js';
|
|
1
2
|
import StoreReactor from './store-reactor.js';
|
|
2
3
|
|
|
3
4
|
export default class StoreConsumer {
|
|
4
|
-
constructor(host, store, properties = store.constructor
|
|
5
|
+
constructor(host, store, properties = store.constructor[combinedPropertiesSymbol]) {
|
|
5
6
|
const storeReactor = new StoreReactor(host, store, properties);
|
|
6
7
|
|
|
7
8
|
return new Proxy(store, {
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { combinedPropertiesSymbol } from './constants.js';
|
|
2
|
+
|
|
1
3
|
export default class StoreReactor {
|
|
2
4
|
changedProperties;
|
|
3
5
|
|
|
4
|
-
constructor(host, store, properties = store.constructor
|
|
6
|
+
constructor(host, store, properties = store.constructor[combinedPropertiesSymbol]) {
|
|
5
7
|
this.#host = host;
|
|
6
8
|
this.#host.addController(this);
|
|
7
9
|
this.#store = store;
|