@genesislcap/foundation-layout 13.5.0 → 13.7.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.
- package/README.md +31 -0
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -255,6 +255,11 @@ To enable you to add multiple items from the same `registration`, the layout sys
|
|
|
255
255
|
This is the case both when items are added with `.addItem()`, and when they are added using the declarative API. Under the hood, this uses the Node [cloneNode](https://developer.mozilla.org/en-US/docs/Web/API/Node/cloneNode) api.
|
|
256
256
|
There are certain limitations to this function, especially when using custom elements with the shadow DOM. [See troubleshooting example](#binding-events-inline-in-the-declarative-api).
|
|
257
257
|
|
|
258
|
+
:::tip
|
|
259
|
+
As a general rule, if you need to have elements with FAST bindings inside of the layout, wrap them in custom elements.
|
|
260
|
+
:::
|
|
261
|
+
|
|
262
|
+
If you are writing your own custom element which needs to work inside of the layout follow these steps.
|
|
258
263
|
In the `@genesislcap/foundation-utils` package, there is a mix-in class `LifecycleMixin` which overrides the `cloneNode` API.
|
|
259
264
|
|
|
260
265
|
```typescript
|
|
@@ -944,6 +949,8 @@ You can then use the custom component in the layout:
|
|
|
944
949
|
</foundation-layout>
|
|
945
950
|
```
|
|
946
951
|
|
|
952
|
+
See [here](#custom-components-to-handle-bindings-and-event-listeners) for a thorough technical explanation.
|
|
953
|
+
|
|
947
954
|
### New layout item not displaying
|
|
948
955
|
Say you have the following layout, [the simple example](#simple-example), with autosave enabled.
|
|
949
956
|
```html
|
|
@@ -979,6 +986,30 @@ The user of your layout will move things around and this will cache the layout.
|
|
|
979
986
|
You and the user will only see the first two items like before. This is because the cached layout is being loaded, which does not contain the
|
|
980
987
|
new item. To fix this you must [invalidate the cache](#invalidating-the-cache).
|
|
981
988
|
|
|
989
|
+
## Supplementary information
|
|
990
|
+
|
|
991
|
+
### Custom components to handle bindings and event listeners
|
|
992
|
+
As shown in [this example](#binding-events-inline-in-the-declarative-api) you need to wrap html that uses fast bindings and event listeners into their own custom
|
|
993
|
+
components. This section is a technical explanation for why this is the case. It is required we make use of `cloneNode` to allow the layout to add multiple instances
|
|
994
|
+
of a registered component.
|
|
995
|
+
|
|
996
|
+
Consider the following which is the order of events of loading the layout when using html that includes bindings.
|
|
997
|
+
|
|
998
|
+
1. As the DOM is parsed the elements inside of the layout are created. At this point the bindings are attached and the event listeners are created, and the `connectedCallback` lifecycle method executes.
|
|
999
|
+
2. Once all of the layout’s contained elements are created, the layout itself initialises\*.
|
|
1000
|
+
3. As part of the initialisation process it moves the element from the DOM and puts it internally into a document fragment as part of the layout registration cache.
|
|
1001
|
+
4. We then load golden layout with the layout config and the registered items, where the registered items create a clone of the items in the document fragment.
|
|
1002
|
+
|
|
1003
|
+
The issue occurs during step four - the clone from `cloneNode` doesn't have the event listeners, so the new copy (which is the one you see on the layout) has no event listeners. Compare this with the similar but different process if you've wrapped up the html into its own custom component.
|
|
1004
|
+
|
|
1005
|
+
1. As the DOM is parsed the elements inside of the layout are created. At this point the bindings are attached and the event listeners are created, and the `connectedCallback` lifecycle method executes.
|
|
1006
|
+
2. Once all of the layout’s contained elements are created, the layout itself initialises\*.
|
|
1007
|
+
3. As part of the initialisation process it moves the element from the DOM and puts it internally into a document fragment as part of the layout registration cache. This is just a tag such as `<filtered-chart></filtered-chart>` instead of a definition that includes bindings or event listeners.
|
|
1008
|
+
4. We then load golden layout with the layout config and the registered items, where the registered items create a clone of the items in the document fragment.
|
|
1009
|
+
5. When that clone is put on the DOM, because it is a custom element it calls the lifecycle method again `connectedCallback` as well as other initialisation methods which include attaching the event listener to the component as required.
|
|
1010
|
+
|
|
1011
|
+
>>\* It initialises after the timeout specified by the `reload-buffer` attribute if using the declarative HTML API, or steps `3` and `4` occur during calls to `registerItem` and `addItem` respectively.
|
|
1012
|
+
|
|
982
1013
|
## License
|
|
983
1014
|
|
|
984
1015
|
Note: this project provides front end dependencies and uses licensed components listed in the next section, thus licenses for those components are required during development. Contact [Genesis Global](https://genesis.global/contact-us/) for more details.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@genesislcap/foundation-layout",
|
|
3
3
|
"description": "Genesis Foundation UI App Layout",
|
|
4
|
-
"version": "13.
|
|
4
|
+
"version": "13.7.0",
|
|
5
5
|
"license": "SEE LICENSE IN license.txt",
|
|
6
6
|
"main": "dist/esm/index.js",
|
|
7
7
|
"types": "dist/foundation-layout.d.ts",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"test:unit:watch": "watchlist src test -- npm run test:unit"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@genesislcap/foundation-testing": "^13.
|
|
40
|
+
"@genesislcap/foundation-testing": "^13.7.0",
|
|
41
41
|
"@module-federation/dashboard-plugin": "2.3.0",
|
|
42
42
|
"@pixability-ui/federated-types": "^0.2.0",
|
|
43
43
|
"@playwright/test": "^1.18.1",
|
|
@@ -77,8 +77,8 @@
|
|
|
77
77
|
},
|
|
78
78
|
"dependencies": {
|
|
79
79
|
"@genesis-community/golden-layout": "^2.9.3",
|
|
80
|
-
"@genesislcap/foundation-comms": "^13.
|
|
81
|
-
"@genesislcap/foundation-utils": "^13.
|
|
80
|
+
"@genesislcap/foundation-comms": "^13.7.0",
|
|
81
|
+
"@genesislcap/foundation-utils": "^13.7.0",
|
|
82
82
|
"@microsoft/fast-components": "^2.21.3",
|
|
83
83
|
"@microsoft/fast-element": "^1.7.0",
|
|
84
84
|
"@microsoft/fast-foundation": "^2.33.2",
|
|
@@ -88,5 +88,5 @@
|
|
|
88
88
|
"publishConfig": {
|
|
89
89
|
"access": "public"
|
|
90
90
|
},
|
|
91
|
-
"gitHead": "
|
|
91
|
+
"gitHead": "0d725fd8628d9e35f7ac36f15f1e65aac897ddae"
|
|
92
92
|
}
|