@genesislcap/foundation-layout 14.83.5 → 14.83.6
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +42 -37
- package/package.json +7 -7
package/README.md
CHANGED
@@ -48,7 +48,7 @@ The following example shows the usage of the declarative API with `zero-charts`
|
|
48
48
|
|
49
49
|
To enable this module in your application, follow the steps below.
|
50
50
|
|
51
|
-
1. Add `@genesislcap/foundation-layout` as a dependency in your **package.json** file. Whenever you change the dependencies of your project, ensure you run the `$ npm run bootstrap` command again. You can find more information in the [package.json basics](
|
51
|
+
1. Add `@genesislcap/foundation-layout` as a dependency in your **package.json** file. Whenever you change the dependencies of your project, ensure you run the `$ npm run bootstrap` command again. You can find more information in the [package.json basics](../../../web/basics/package-json-basics/) page.
|
52
52
|
|
53
53
|
```javascript
|
54
54
|
{
|
@@ -211,16 +211,16 @@ Each event requires a certain detail to process the event - see [the map of even
|
|
211
211
|
|
212
212
|
## Customising header buttons
|
213
213
|
|
214
|
-
You can add custom buttons on layout items, and then control their behaviour. See [the custom button API](./docs/api/foundation-layout.custombutton.md)
|
214
|
+
You can add custom buttons on layout items, and then control their behaviour. See [the custom button API](./docs/api/foundation-layout.custombutton.md) for the full definition. Setting this is optional. If you do define it, you must define it as an array, which enables you to add multiple custom buttons if you wish.
|
215
215
|
|
216
|
-
* The `svg` parameter controls the icon
|
217
|
-
* The `onClick` parameter will register a callback with the button. When the user clicks the button, your callback will be called. The callback receives a reference to the clicked button element, and the element
|
216
|
+
* The `svg` parameter controls the icon that your button displays. The format must be a base64 image definition. See the format as explained on the linked api document, and then replace the text around the `<< >>` part with a base64 encoded definition of the svg you wish to use.
|
217
|
+
* The `onClick` parameter will register a callback with the button. When the user clicks the button, your callback will be called. The callback receives a reference to the clicked button element, and to the element that is contained in the layout item associated with the clicked button.
|
218
218
|
|
219
|
-
Different layout instances can have their own custom buttons, or share definitions. You are not able to have fine-grained control over each layout item though
|
219
|
+
Different layout instances can have their own custom buttons, or they can share definitions. You are not able to have fine-grained control over each layout item, though; so if a layout has a custom button, then every item that it contains will have the button.
|
220
220
|
|
221
221
|
### Applying the custom button
|
222
222
|
|
223
|
-
To ensure that every item gets the button as expected, you need to ensure that you apply the custom button definitions as early as possible. If you are using the html API then you'll
|
223
|
+
To ensure that every item gets the button as expected, you need to ensure that you apply the custom button definitions as early as possible. If you are using the html API then you'll probably want to apply the definitions in the template.
|
224
224
|
|
225
225
|
```html
|
226
226
|
<foundation-layout :customButtons=${() => buttonDefinition}>
|
@@ -235,32 +235,37 @@ layout.customButtons = buttonDefinition;
|
|
235
235
|
|
236
236
|
### Renaming example
|
237
237
|
|
238
|
-
See [here](#custom-item-renaming-header-button)
|
238
|
+
See [here](#custom-item-renaming-header-button) for an example of creating a custom button to allow the user to rename an item.
|
239
239
|
|
240
240
|
## Autosaving layout
|
241
241
|
|
242
|
-
There is opt-in functionality provided in the layout to autosave the layout in local storage as the user interacts with it. Set the `auto-save-key` attribute to a unique string on the root element to enable the feature
|
242
|
+
There is opt-in functionality provided in the layout to autosave the layout in local storage as the user interacts with it. Set the `auto-save-key` attribute to a unique string on the root element to enable the feature; the layout will be saved in this key. The layout will be saved for later recall in local storage whenever the user performs the following actions:
|
243
243
|
|
244
|
-
|
244
|
+
- adding an item
|
245
|
+
- removing an item
|
246
|
+
- resizing items using the divider
|
247
|
+
- dragging items around the layout
|
248
|
+
|
249
|
+
When you have enabled autosave, you are still able to use the manual [serialising commands](#serialising-layout).
|
245
250
|
|
246
251
|
### Reloading the layout
|
247
252
|
|
248
253
|
The provided function [tryLoadLayoutFromLocalStorage()](./docs/api/foundation-layout.foundationlayout.tryloadlayoutfromlocalstorage.md) is used to rehydrate the layout from local storage, if `auto-save-key` is enabled.
|
249
|
-
If you are using the declarative API then this function is
|
254
|
+
If you are using the declarative API, then this function is called for you automatically.
|
250
255
|
|
251
|
-
If you are manually registering items (too) using the JavaScript API you must
|
256
|
+
If you are manually registering items (too) using the JavaScript API, you must call this function manually, immediately after you have finished registering all the items. For an example [see here](#contained-example).
|
252
257
|
|
253
258
|
### Layout placeholder
|
254
259
|
|
255
260
|
If the layout is auto-loaded with items that are missing from the registration, then a placeholder item is displayed instead. Additionally, the close option is added to the pane. This accounts for you removing an item from a layout that a user has autosaved in their config.
|
256
261
|
|
257
|
-
You can change the text of the placeholder using the observable binding `:missingItemPlaceholder`. This is a function
|
262
|
+
You can change the text of the placeholder using the observable binding `:missingItemPlaceholder`. This is a function that takes a string (the missing registration name) and returns the string to use as the placeholder. A default is set, but you can override it. See the override implementation [in this example](#contained-example).
|
258
263
|
|
259
264
|
### Invalidating the cache
|
260
265
|
|
261
|
-
As explained in the previous section, a placeholder item is added if an item is no longer registered for the auto-loaded layout. This accounts for removing an item. However, there is the reverse issue
|
266
|
+
As explained in the previous section, a placeholder item is added if an item is no longer registered for the auto-loaded layout. This accounts for removing an item. However, there is the reverse issue if you are only using the declarative API; if you add a new item and the user already has an autosaved layout, then that will be loaded - which effectively hides the new item you've added.
|
262
267
|
|
263
|
-
In this case you must invalidate the autosaved layout cache. The cleanest and easiest implementation
|
268
|
+
In this case, you must invalidate the autosaved layout cache. The cleanest and easiest implementation is to add a hash onto the end of your `auto-save-key`, which will start a new autosave for this table (and reload the default, containing your new layout item).
|
264
269
|
|
265
270
|
## Contained elements
|
266
271
|
|
@@ -834,7 +839,7 @@ export const layoutCustomButtons: CustomButton[] = [
|
|
834
839
|
You can import `LAYOUT_ICONS`, `CustomButton`, `LayoutReceiveEvents`, and `LayoutReceiveEventsDetail` from the foundation-layout package, to get strong typing.
|
835
840
|
|
836
841
|
:::warning
|
837
|
-
You'll
|
842
|
+
You'll probably want to improve this callback function to handle cases where the user doesn't enter a prompt value.
|
838
843
|
:::
|
839
844
|
|
840
845
|
## Incorrect examples
|
@@ -1090,12 +1095,12 @@ The user of your layout will move things around and this will cache the layout.
|
|
1090
1095
|
</foundation-layout>
|
1091
1096
|
```
|
1092
1097
|
|
1093
|
-
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
|
1098
|
+
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
|
1094
1099
|
new item. To fix this you must [invalidate the cache](#invalidating-the-cache).
|
1095
1100
|
|
1096
1101
|
### Resource intensive component resetting in layout
|
1097
1102
|
|
1098
|
-
Say you have a component which has to initialise a resource
|
1103
|
+
Say you have a component which has to initialise a resource-heavy or long-awaited asynchronous task, such as the following:
|
1099
1104
|
```typescript
|
1100
1105
|
@customElement({
|
1101
1106
|
name: 'mock-connected',
|
@@ -1117,7 +1122,7 @@ export class MockConnected extends FASTElement {
|
|
1117
1122
|
|
1118
1123
|
As explained in the [lifecycle info section](#element-lifecycle), this component may have its `disconnectedCallback` and `connectedCallback` lifecycle at unnecessary times, effectively wasting time re-initialising a potentially heavy resource.
|
1119
1124
|
|
1120
|
-
Use
|
1125
|
+
Use `LifecycleMixin` to access properties on the class, which can be used to run lifecycle functionality more thoughtfully. In the following example, we split out the resource-intensive work and conditionally call them when needed.
|
1121
1126
|
|
1122
1127
|
```typescript
|
1123
1128
|
@customElement({
|
@@ -1152,15 +1157,15 @@ export class MockConnected extends LifecycleMixin(FASTElement) {
|
|
1152
1157
|
}
|
1153
1158
|
```
|
1154
1159
|
|
1155
|
-
The above is quite a comprehensive example, it doesn't necessarily have to be so complicated. You may just want to exit early from the connected callback without using the `DOM.queueUpdate` functionality. However,
|
1160
|
+
The above is quite a comprehensive example, but it doesn't necessarily have to be so complicated. You may just want to exit early from the connected callback without using the `DOM.queueUpdate` functionality. However, it is useful for handling the `async` setup process properly.
|
1156
1161
|
|
1157
1162
|
:::warning
|
1158
|
-
The requirement to capture the parameter in the example above (e.g. `const shouldRunDisconnect = shouldRunDisconnect`) is to cache the information at the time of the lifecycle change, for use when the `DOM.queueUpdate` work is performed. This is not required if you run your lifecycle methods synchronously,
|
1163
|
+
The requirement to capture the parameter in the example above (e.g. `const shouldRunDisconnect = shouldRunDisconnect`) is to cache the information at the time of the lifecycle change, for use when the `DOM.queueUpdate` work is performed. This is not required if you run your lifecycle methods synchronously; however, if you follow the pattern above, you need to schedule the `async` functionality to run after the layout considers the relevant lifecycle-gating functionality (such as dragging) to be complete.
|
1159
1164
|
:::
|
1160
1165
|
|
1161
1166
|
### Consuming lifecycle value multiple times
|
1162
1167
|
|
1163
|
-
Consider the following example where
|
1168
|
+
Consider the following example, where multiple bits of functionality are being gated with `shouldRunConnect`:
|
1164
1169
|
```typescript
|
1165
1170
|
@customElement({
|
1166
1171
|
name: 'mock-connected',
|
@@ -1184,11 +1189,11 @@ export class MockConnected extends LifecycleMixin(FASTElement) {
|
|
1184
1189
|
}
|
1185
1190
|
```
|
1186
1191
|
|
1187
|
-
In this example when you have this item inside
|
1192
|
+
In this example, when you have this item inside the layout, the functionality will not correctly be gated when you add or remove other items as intended.
|
1188
1193
|
|
1189
|
-
This is because `shouldRunConnect` (and `shouldRunDisconnect`) perform a check to see whether the layout has performed an event
|
1194
|
+
This is because `shouldRunConnect` (and `shouldRunDisconnect`) perform a check to see whether the layout has performed an event that should gate functionality; reading the value multiple times will incorrectly signal that there hasn't been another lifecycle event upon subsequent reads during the same cycle. The mental model you can use here is thinking of consuming the check when you read the variable.
|
1190
1195
|
|
1191
|
-
Therefore, if you want to use the value multiple times in the `connectedCallback` and `disconnectedCallback` functions you should cache the variable.
|
1196
|
+
Therefore, if you want to use the value multiple times in the `connectedCallback` and `disconnectedCallback` functions, you should cache the variable.
|
1192
1197
|
|
1193
1198
|
** You should only read the variables `this.shouldRunConnect` and `this.shouldRunDisconnect` once per `shouldRunConnect` and `shouldRunDisconnect` cycle respectively. **
|
1194
1199
|
|
@@ -1216,36 +1221,36 @@ Therefore, if you want to use the value multiple times in the `connectedCallback
|
|
1216
1221
|
```
|
1217
1222
|
|
1218
1223
|
:::danger
|
1219
|
-
The same limitation applies if you're checking the variable multiple times
|
1224
|
+
The same limitation applies if you're checking the variable multiple times because you have a hierarchy of extending classes. Again, you should cache the variable for checking in this case.
|
1220
1225
|
:::
|
1221
1226
|
|
1222
1227
|
## Supplementary information
|
1223
1228
|
|
1224
1229
|
### Custom components to handle bindings and event listeners
|
1225
|
-
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
|
1226
|
-
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
|
1230
|
+
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
|
1231
|
+
components. This section is a technical explanation for why this is the case. It is required that we make use of `cloneNode` to allow the layout to add multiple instances
|
1227
1232
|
of a registered component.
|
1228
1233
|
|
1229
|
-
Consider the following which is the order of events
|
1234
|
+
Consider the following, which is the order of events for loading the layout when using html that includes bindings.
|
1230
1235
|
|
1231
|
-
1. As the DOM is parsed the elements inside
|
1232
|
-
2. Once all
|
1233
|
-
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.
|
1236
|
+
1. As the DOM is parsed, the elements inside the layout are created. At this point, the bindings are attached and the event listeners are created, and the `connectedCallback` lifecycle method executes.
|
1237
|
+
2. Once all the elements contained in the layout have been created, the layout itself initialises\*.
|
1238
|
+
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.
|
1234
1239
|
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.
|
1235
1240
|
|
1236
1241
|
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.
|
1237
1242
|
|
1238
|
-
1. As the DOM is parsed the elements inside
|
1239
|
-
2. Once all
|
1240
|
-
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
|
1243
|
+
1. As the DOM is parsed, the elements inside the layout are created. At this point, the bindings are attached and the event listeners are created, and the `connectedCallback` lifecycle method executes.
|
1244
|
+
2. Once all the elements contained in the layout have been created, the layout itself initialises\*.
|
1245
|
+
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>`, not a definition that includes bindings or event listeners.
|
1241
1246
|
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.
|
1242
|
-
5. When that clone is put on the DOM,
|
1247
|
+
5. When that clone is put on the DOM, it is a custom element. And so it calls the lifecycle method again `connectedCallback` as well as other initialisation methods that include attaching the event listener to the component as required.
|
1243
1248
|
|
1244
|
-
>>\* 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.
|
1249
|
+
>>\* It initialises after the timeout specified by the `reload-buffer` attribute if using the declarative HTML API, or if steps `3` and `4` occur during calls to `registerItem` and `addItem` respectively.
|
1245
1250
|
|
1246
1251
|
## License
|
1247
1252
|
|
1248
|
-
Note: this project provides front
|
1253
|
+
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.
|
1249
1254
|
|
1250
1255
|
### Licensed components
|
1251
1256
|
Genesis low-code platform
|
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": "14.83.
|
4
|
+
"version": "14.83.6",
|
5
5
|
"license": "SEE LICENSE IN license.txt",
|
6
6
|
"main": "dist/esm/index.js",
|
7
7
|
"types": "dist/foundation-layout.d.ts",
|
@@ -27,15 +27,15 @@
|
|
27
27
|
"test:debug": "genx test --debug"
|
28
28
|
},
|
29
29
|
"devDependencies": {
|
30
|
-
"@genesislcap/foundation-testing": "14.83.
|
31
|
-
"@genesislcap/genx": "14.83.
|
30
|
+
"@genesislcap/foundation-testing": "14.83.6",
|
31
|
+
"@genesislcap/genx": "14.83.6",
|
32
32
|
"rimraf": "^3.0.2"
|
33
33
|
},
|
34
34
|
"dependencies": {
|
35
35
|
"@genesis-community/golden-layout": "^2.10.1",
|
36
|
-
"@genesislcap/foundation-comms": "14.83.
|
37
|
-
"@genesislcap/foundation-logger": "14.83.
|
38
|
-
"@genesislcap/foundation-utils": "14.83.
|
36
|
+
"@genesislcap/foundation-comms": "14.83.6",
|
37
|
+
"@genesislcap/foundation-logger": "14.83.6",
|
38
|
+
"@genesislcap/foundation-utils": "14.83.6",
|
39
39
|
"@microsoft/fast-components": "^2.21.3",
|
40
40
|
"@microsoft/fast-element": "^1.7.0",
|
41
41
|
"@microsoft/fast-foundation": "^2.33.2",
|
@@ -50,5 +50,5 @@
|
|
50
50
|
"access": "public"
|
51
51
|
},
|
52
52
|
"customElements": "dist/custom-elements.json",
|
53
|
-
"gitHead": "
|
53
|
+
"gitHead": "b894d957705f2fdcf5df38f509790437a597a80f"
|
54
54
|
}
|