@genesislcap/foundation-layout 14.138.0 → 14.138.1-beta.ce4b104.1
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +35 -33
- package/package.json +7 -7
package/README.md
CHANGED
@@ -125,8 +125,8 @@ with a tab for each child. The tabs are ordered according to which child the lay
|
|
125
125
|
|
126
126
|
### [Layout Item `<foundation-layout-item>`](./docs/api/foundation-layout.foundationlayoutitem.md)
|
127
127
|
|
128
|
-
Wrapper component that lives inside a layout section and wraps the client content. All content must be inside a layout item
|
129
|
-
otherwise a runtime error will be thrown when the layout attempts to render itself on screen.
|
128
|
+
Wrapper component that lives inside a layout section and wraps the client content. All content must be inside a layout item;
|
129
|
+
otherwise, a runtime error will be thrown when the layout attempts to render itself on screen.
|
130
130
|
|
131
131
|
- **title**: string defining the title of the pane that contains the content. Defaults to `Item x`, where `x` is the pane number.
|
132
132
|
- **closable**: boolean defining whether this element is closable - Default false.
|
@@ -171,7 +171,7 @@ Add an item or items that have previously been registered with the layout.
|
|
171
171
|
|
172
172
|
#### [Remove Items](./docs/api/foundation-layout.foundationlayout.removeitems.md)
|
173
173
|
|
174
|
-
Dynamically remove items from the layout. See
|
174
|
+
Dynamically remove items from the layout. See the API documentation (link above) for side effects and options.
|
175
175
|
|
176
176
|
#### [Layout Required Registrations](./docs/api/foundation-layout.foundationlayout.layoutrequiredregistrations.md)
|
177
177
|
|
@@ -187,8 +187,8 @@ Use this function over `.layoutRequiredRegistrations(layout: SerialisedLayout)`
|
|
187
187
|
|
188
188
|
### Serialising layout
|
189
189
|
|
190
|
-
The JavaScript API can be used to
|
191
|
-
To enable autosaving the layout see [here](#autosaving-layout).
|
190
|
+
The JavaScript API can be used to save and load layout states manually. This only describes the state of the dynamic layout itself. It is the responsibility of each component within the layout to serialise its own state, if required.
|
191
|
+
To enable autosaving the layout, see [here](#autosaving-layout).
|
192
192
|
|
193
193
|
#### [Get Layout](./docs/api/foundation-layout.foundationlayout.getlayout.md)
|
194
194
|
|
@@ -204,11 +204,12 @@ Loads a serialised layout. All items that are described in the config to load mu
|
|
204
204
|
|
205
205
|
### [Emitted Events](./docs/api/foundation-layout.layoutemitevents.md)
|
206
206
|
|
207
|
-
Certain actions that are performed by the user interacting with the layout emit events. See the API document
|
207
|
+
Certain actions that are performed by the user interacting with the layout emit events. See the API document (in the link above) for the events and when they're emitted. Interacting with these events allows your client code to interact dynamically with the layout, such as enabling/disabling buttons to add items to the layout when they're removed/added.
|
208
208
|
|
209
209
|
### [Received Events](./docs/api/foundation-layout.layoutreceiveevents.md)
|
210
210
|
|
211
|
-
Certain events are listened to by the container for each component, enabling the component to interact with the layout. For example, a component could emit an event to change the title of the containing window
|
211
|
+
Certain events are listened to by the container for each component, enabling the component to interact with the layout. For example, a component could emit an event to change the title of the containing window:
|
212
|
+
|
212
213
|
```typescript
|
213
214
|
this.$emit(eventType, eventDetail)
|
214
215
|
```
|
@@ -216,9 +217,9 @@ Each event requires a certain detail to process the event - see [the map of even
|
|
216
217
|
|
217
218
|
## Customising header buttons
|
218
219
|
|
219
|
-
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
|
220
|
+
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.
|
220
221
|
|
221
|
-
* The `svg` parameter controls the icon that your button
|
222
|
+
* The `svg` parameter controls the icon that is displayed for your button. The format must be a base64 image definition. See the format (as explained in the linked api document above), and then replace the text around the `<< >>` part with a base64 encoded definition of the svg you wish to use.
|
222
223
|
* 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.
|
223
224
|
|
224
225
|
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.
|
@@ -240,11 +241,11 @@ layout.customButtons = buttonDefinition;
|
|
240
241
|
|
241
242
|
### Renaming example
|
242
243
|
|
243
|
-
See [
|
244
|
+
See this example of [creating a custom button](#custom-item-renaming-header-button), which enables the user to rename an item.
|
244
245
|
|
245
246
|
## Autosaving layout
|
246
247
|
|
247
|
-
|
248
|
+
You can set the layout to autosave in local storage as the user interacts with it. To do this, set the `auto-save-key` attribute to a unique string on the root element; 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:
|
248
249
|
|
249
250
|
- adding an item
|
250
251
|
- removing an item
|
@@ -255,10 +256,10 @@ When you have enabled autosave, you are still able to use the manual [serialisin
|
|
255
256
|
|
256
257
|
### Reloading the layout
|
257
258
|
|
258
|
-
The
|
259
|
+
The function [tryLoadLayoutFromLocalStorage()](./docs/api/foundation-layout.foundationlayout.tryloadlayoutfromlocalstorage.md) is used to rehydrate the layout from local storage, when `auto-save-key` is enabled.
|
259
260
|
If you are using the declarative API, then this function is called for you automatically.
|
260
261
|
|
261
|
-
If you are manually registering items (too) using the JavaScript API, you must call this function manually
|
262
|
+
If you are manually registering items (too) using the JavaScript API, you must [call this function manually](#contained-example) immediately after you have finished registering all the items.
|
262
263
|
|
263
264
|
### Layout placeholder
|
264
265
|
|
@@ -300,7 +301,7 @@ At the very least, you must run `super` calls to the lifecycle methods, or else
|
|
300
301
|
:::
|
301
302
|
|
302
303
|
### Resource-intensive components
|
303
|
-
|
304
|
+
You do not need to de-register a component that is registered in the layout while it is not in use. However, if you have a component that is extremely resource-intensive, then you can use this lifecycle control method to ensure that it only consumes resources when it is in use.
|
304
305
|
|
305
306
|
- When the element is part of the layout registry, then `shouldRunConnect` will be false and you can use this to ensure that your component isn't doing unnecessary work while part of the cache.
|
306
307
|
|
@@ -315,7 +316,7 @@ You can implement the [LayoutComponentWithState](./docs/api/foundation-layout.la
|
|
315
316
|
Usage of this interface is optional; if you do not need to manage the state for your components in this way, then simply do not implement the interface.
|
316
317
|
|
317
318
|
:::warning
|
318
|
-
The layout system
|
319
|
+
The layout system only interacts with the immediately contained items - so if you have components that contain other components, each top-level component must interact with the contained components to manage their states.
|
319
320
|
:::
|
320
321
|
|
321
322
|
:::danger
|
@@ -333,7 +334,8 @@ As a general rule, if you need to have elements with FAST bindings inside the la
|
|
333
334
|
:::
|
334
335
|
|
335
336
|
If you are writing your own custom element that needs to work inside the layout, follow these steps.
|
336
|
-
|
337
|
+
|
338
|
+
1. In the `@genesislcap/foundation-utils` package, there is a mix-in class `LifecycleMixin`, which overrides the `cloneNode` API.
|
337
339
|
|
338
340
|
```typescript
|
339
341
|
// Make a call to `deepClone` and manually clone children
|
@@ -355,7 +357,8 @@ deepClone(): Node {
|
|
355
357
|
}
|
356
358
|
```
|
357
359
|
|
358
|
-
You can then extend the cloning functionality for your specific requirements. For example, our charts component needs to copy over `config` and `data` parameters.
|
360
|
+
2. You can then extend the cloning functionality for your specific requirements. For example, our charts component needs to copy over `config` and `data` parameters.
|
361
|
+
|
359
362
|
```typescript
|
360
363
|
export class G2PlotChart extends LifecycleMixin(FoundationElement) {
|
361
364
|
...
|
@@ -495,7 +498,7 @@ This would render the following:
|
|
495
498
|
| | |
|
496
499
|
+-------------+---------------------------------------+
|
497
500
|
```
|
498
|
-
Component 1 has a Close button. Component 1 takes up 25% of the initial width. Components 2,3,4 take up a third of the _remaining_ width between them
|
501
|
+
Component 1 has a **Close** button. Component 1 takes up 25% of the initial width. Components 2,3,4 take up a third of the _remaining_ width between them
|
499
502
|
(default behaviour) and 5 and 6 are tabbed.
|
500
503
|
|
501
504
|
### `repeat` directive
|
@@ -584,9 +587,8 @@ You would see both items rendered like this:
|
|
584
587
|
If you had `showIndexFunds = false;` then only the `Stocks Chart` would be rendered.
|
585
588
|
|
586
589
|
:::danger
|
587
|
-
Directives are for initialising the layout only and should *not* be used with changing `@observable` attributes which would cause the
|
588
|
-
layout to reinitialise incorrectly - this will duplicate the panels. For example, you can use the
|
589
|
-
`when` directive to conditionally render a pane during initialisation, but not to toggle whether to show/hide the pane afterwards.
|
590
|
+
Directives are for initialising the layout only and should *not* be used with changing `@observable` attributes, which would cause the
|
591
|
+
layout to reinitialise incorrectly - this will duplicate the panels. For example, you can use the `when` directive to conditionally render a pane during initialisation, but not to toggle whether to show/hide the pane afterwards.
|
590
592
|
See [this example](#observables-with-directives).
|
591
593
|
:::
|
592
594
|
|
@@ -638,9 +640,9 @@ This is just an example; you could have more than two layouts on a page or style
|
|
638
640
|
|
639
641
|
### Adding items dynamically
|
640
642
|
|
641
|
-
This is an example of using the JavaScript API to add items
|
643
|
+
This is an example of using the JavaScript API to add items to the layout at runtime. Before reading this example, you should familiarise yourself with the [API Section](#javascript-api).
|
642
644
|
|
643
|
-
Say you want the user to be able to choose between three different types of item
|
645
|
+
Say you want the user to be able to choose between three different types of item that can be put onto the layout - a profile-management table, a pie chart, and a column chart.
|
644
646
|
|
645
647
|
```typescript
|
646
648
|
// Can either create an element and initialise it completely using JavaScript
|
@@ -829,7 +831,7 @@ layout.registerItem(test, [element]);
|
|
829
831
|
```
|
830
832
|
|
831
833
|
:::info
|
832
|
-
Only items _missing_ from the `requiredRegistrations`
|
834
|
+
Only items _missing_ from the `requiredRegistrations` are an issue. If there are items in the `currentRegistrations` that are not in `requiredRegistrations`, this is *not* an issue - because these will simply be unused registrations.
|
833
835
|
:::
|
834
836
|
|
835
837
|
:::warning
|
@@ -838,7 +840,7 @@ If you are calling `registerItem` manually and are using the autosave feature, [
|
|
838
840
|
|
839
841
|
### Custom item renaming header button
|
840
842
|
|
841
|
-
Here is an example of creating a custom button for the layout
|
843
|
+
Here is an example of creating a custom button for the layout. When the button is clicked, it prompts the user for a name, and will rename the item in the layout.
|
842
844
|
|
843
845
|
```typescript
|
844
846
|
export const layoutCustomButtons: CustomButton[] = [
|
@@ -1023,7 +1025,7 @@ var template = html<Analytics>`
|
|
1023
1025
|
`;
|
1024
1026
|
```
|
1025
1027
|
|
1026
|
-
Initially you will see both items correctly rendered like this:
|
1028
|
+
Initially, you will see both items correctly rendered like this:
|
1027
1029
|
```
|
1028
1030
|
+---------------------------------------------+
|
1029
1031
|
| Stocks Chart |
|
@@ -1117,10 +1119,10 @@ The user of your layout will move things around and this will cache the layout.
|
|
1117
1119
|
</foundation-layout>
|
1118
1120
|
```
|
1119
1121
|
|
1120
|
-
You and the user will only see the first two items
|
1121
|
-
new item. To fix this you must [invalidate the cache](#invalidating-the-cache).
|
1122
|
+
You and the user will still only see the first two items. This is because the cached layout is being loaded, which does not contain the
|
1123
|
+
new item. To fix this, you must [invalidate the cache](#invalidating-the-cache).
|
1122
1124
|
|
1123
|
-
### Resource
|
1125
|
+
### Resource-intensive component resetting in layout
|
1124
1126
|
|
1125
1127
|
Say you have a component which has to initialise a resource-heavy or long-awaited asynchronous task, such as the following:
|
1126
1128
|
```typescript
|
@@ -1144,7 +1146,7 @@ export class MockConnected extends FASTElement {
|
|
1144
1146
|
|
1145
1147
|
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.
|
1146
1148
|
|
1147
|
-
Use `LifecycleMixin` to access properties on the class, which can be used to run lifecycle functionality more thoughtfully. In the following example,
|
1149
|
+
Use `LifecycleMixin` to access properties on the class, which can be used to run lifecycle functionality more thoughtfully. In the following example, the resource-intensive tasks are called conditionally - only when needed.
|
1148
1150
|
|
1149
1151
|
```typescript
|
1150
1152
|
@customElement({
|
@@ -1179,10 +1181,10 @@ export class MockConnected extends LifecycleMixin(FASTElement) {
|
|
1179
1181
|
}
|
1180
1182
|
```
|
1181
1183
|
|
1182
|
-
The above is quite a comprehensive example, but it doesn't necessarily have to be so complicated. You
|
1184
|
+
The above is quite a comprehensive example, but it doesn't necessarily have to be so complicated. You might 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.
|
1183
1185
|
|
1184
1186
|
:::warning
|
1185
|
-
|
1187
|
+
It is important to capture the parameter in the example above (e.g. `const shouldRunDisconnect = shouldRunDisconnect`) so that the information is cached 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.
|
1186
1188
|
:::
|
1187
1189
|
|
1188
1190
|
### Consuming lifecycle value multiple times
|
@@ -1250,7 +1252,7 @@ The same limitation applies if you're checking the variable multiple times becau
|
|
1250
1252
|
|
1251
1253
|
### Custom components to handle bindings and event listeners
|
1252
1254
|
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
|
1253
|
-
components. This section is a technical explanation for why this is
|
1255
|
+
components. This section is a technical explanation for why this is necessary. It is required that we make use of `cloneNode` to allow the layout to add multiple instances
|
1254
1256
|
of a registered component.
|
1255
1257
|
|
1256
1258
|
Consider the following, which is the order of events for loading the layout when using html that includes bindings.
|
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.138.
|
4
|
+
"version": "14.138.1-beta.ce4b104.1",
|
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.138.
|
31
|
-
"@genesislcap/genx": "14.138.
|
30
|
+
"@genesislcap/foundation-testing": "14.138.1-beta.ce4b104.1",
|
31
|
+
"@genesislcap/genx": "14.138.1-beta.ce4b104.1",
|
32
32
|
"rimraf": "^3.0.2"
|
33
33
|
},
|
34
34
|
"dependencies": {
|
35
35
|
"@genesis-community/golden-layout": "^2.11.0",
|
36
|
-
"@genesislcap/foundation-comms": "14.138.
|
37
|
-
"@genesislcap/foundation-logger": "14.138.
|
38
|
-
"@genesislcap/foundation-utils": "14.138.
|
36
|
+
"@genesislcap/foundation-comms": "14.138.1-beta.ce4b104.1",
|
37
|
+
"@genesislcap/foundation-logger": "14.138.1-beta.ce4b104.1",
|
38
|
+
"@genesislcap/foundation-utils": "14.138.1-beta.ce4b104.1",
|
39
39
|
"@microsoft/fast-components": "^2.30.6",
|
40
40
|
"@microsoft/fast-element": "^1.12.0",
|
41
41
|
"@microsoft/fast-foundation": "^2.49.4",
|
@@ -50,5 +50,5 @@
|
|
50
50
|
"access": "public"
|
51
51
|
},
|
52
52
|
"customElements": "dist/custom-elements.json",
|
53
|
-
"gitHead": "
|
53
|
+
"gitHead": "77ba0250b83ac3dd8e7f75570354d6f4954bd995"
|
54
54
|
}
|