@genesislcap/foundation-react-utils 15.39.0 → 15.40.0-FUI-2628.1
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 +41 -0
- package/dist/custom-elements.json +64 -0
- package/dist/dts/index.d.ts +1 -0
- package/dist/dts/index.d.ts.map +1 -1
- package/dist/dts/workspace/index.d.ts +19 -0
- package/dist/dts/workspace/index.d.ts.map +1 -0
- package/dist/dts/workspace/use-workspace-filter.d.ts +31 -0
- package/dist/dts/workspace/use-workspace-filter.d.ts.map +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/workspace/index.js +18 -0
- package/dist/esm/workspace/use-workspace-filter.js +48 -0
- package/package.json +21 -13
package/README.md
CHANGED
|
@@ -47,6 +47,47 @@ resolving a second copy of the library, which breaks the `instanceof` checks `fl
|
|
|
47
47
|
relies on internally; the entry point logs a warning when the version it loads differs from the one
|
|
48
48
|
the theme was generated against.
|
|
49
49
|
|
|
50
|
+
## foundation-workspace
|
|
51
|
+
|
|
52
|
+
Workspaces (save/load of layouts, grid column state and filters) work in React through the element
|
|
53
|
+
wrappers `@genesislcap/foundation-workspace/react` already ships, plus one hook for filter state:
|
|
54
|
+
|
|
55
|
+
```tsx
|
|
56
|
+
import { registerFactory } from '@genesislcap/foundation-layout';
|
|
57
|
+
import { reactFactory } from '@genesislcap/foundation-react-utils';
|
|
58
|
+
import { useWorkspaceFilter } from '@genesislcap/foundation-react-utils/workspace';
|
|
59
|
+
import { GridRegister, LayoutWrapper, WorkspaceManager } from '@genesislcap/foundation-workspace/react';
|
|
60
|
+
|
|
61
|
+
const PositionsPanel = () => {
|
|
62
|
+
const [search, setSearch] = useState('');
|
|
63
|
+
useWorkspaceFilter('positions-search', search, setSearch);
|
|
64
|
+
return (
|
|
65
|
+
<GridRegister gridKey="positions">
|
|
66
|
+
<RapidGridPro persistColumnStateKey="positions">…</RapidGridPro>
|
|
67
|
+
</GridRegister>
|
|
68
|
+
);
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
registerFactory('positions', reactFactory(PositionsPanel));
|
|
72
|
+
|
|
73
|
+
<LayoutWrapper layoutKey="my-layout">
|
|
74
|
+
<rapid-layout auto-save-key="my-layout">
|
|
75
|
+
<rapid-layout-region>
|
|
76
|
+
<rapid-layout-item registration="positions" title="Positions" />
|
|
77
|
+
</rapid-layout-region>
|
|
78
|
+
</rapid-layout>
|
|
79
|
+
</LayoutWrapper>
|
|
80
|
+
|
|
81
|
+
<WorkspaceManager />
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
- Register `workspaceComponents` from `@genesislcap/foundation-workspace` with your design system.
|
|
85
|
+
- Render layout panes through `registerFactory` + `reactFactory`, not as JSX children of
|
|
86
|
+
`rapid-layout-item`. Loading a saved layout rebuilds the panes, and cloned DOM loses React-set
|
|
87
|
+
properties such as `gridOptions`.
|
|
88
|
+
- `useWorkspaceFilter` also applies the current workspace's saved value on mount, so a filter
|
|
89
|
+
inside a pane that is recreated by a layout load still picks up its saved value.
|
|
90
|
+
|
|
50
91
|
## License
|
|
51
92
|
|
|
52
93
|
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.
|
|
@@ -531,6 +531,70 @@
|
|
|
531
531
|
}
|
|
532
532
|
}
|
|
533
533
|
]
|
|
534
|
+
},
|
|
535
|
+
{
|
|
536
|
+
"kind": "javascript-module",
|
|
537
|
+
"path": "src/workspace/index.ts",
|
|
538
|
+
"declarations": [],
|
|
539
|
+
"exports": [
|
|
540
|
+
{
|
|
541
|
+
"kind": "js",
|
|
542
|
+
"name": "useWorkspaceFilter",
|
|
543
|
+
"declaration": {
|
|
544
|
+
"name": "useWorkspaceFilter",
|
|
545
|
+
"module": "./use-workspace-filter"
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
]
|
|
549
|
+
},
|
|
550
|
+
{
|
|
551
|
+
"kind": "javascript-module",
|
|
552
|
+
"path": "src/workspace/use-workspace-filter.ts",
|
|
553
|
+
"declarations": [
|
|
554
|
+
{
|
|
555
|
+
"kind": "function",
|
|
556
|
+
"name": "useWorkspaceFilter",
|
|
557
|
+
"return": {
|
|
558
|
+
"type": {
|
|
559
|
+
"text": "void"
|
|
560
|
+
}
|
|
561
|
+
},
|
|
562
|
+
"parameters": [
|
|
563
|
+
{
|
|
564
|
+
"name": "filterKey",
|
|
565
|
+
"type": {
|
|
566
|
+
"text": "string"
|
|
567
|
+
},
|
|
568
|
+
"description": "Unique key the value is saved under. An empty key skips registration."
|
|
569
|
+
},
|
|
570
|
+
{
|
|
571
|
+
"name": "value",
|
|
572
|
+
"type": {
|
|
573
|
+
"text": "string"
|
|
574
|
+
},
|
|
575
|
+
"description": "Current filter value."
|
|
576
|
+
},
|
|
577
|
+
{
|
|
578
|
+
"name": "setValue",
|
|
579
|
+
"type": {
|
|
580
|
+
"text": "(value: string) => void"
|
|
581
|
+
},
|
|
582
|
+
"description": "Called with the saved value when a workspace is loaded."
|
|
583
|
+
}
|
|
584
|
+
],
|
|
585
|
+
"description": "Registers a piece of React filter state with the foundation-workspace `FilterRegistry`, so\n`<workspace-manager>` saves it with the workspace and restores it on load."
|
|
586
|
+
}
|
|
587
|
+
],
|
|
588
|
+
"exports": [
|
|
589
|
+
{
|
|
590
|
+
"kind": "js",
|
|
591
|
+
"name": "useWorkspaceFilter",
|
|
592
|
+
"declaration": {
|
|
593
|
+
"name": "useWorkspaceFilter",
|
|
594
|
+
"module": "src/workspace/use-workspace-filter.ts"
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
]
|
|
534
598
|
}
|
|
535
599
|
]
|
|
536
600
|
}
|
package/dist/dts/index.d.ts
CHANGED
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
* Rapid Design System theme for it installed on import. Import from there rather than adding
|
|
19
19
|
* `flexlayout-react` to an app's own dependencies.
|
|
20
20
|
* - `./router` — route table helpers (`renderAppRoutes` and friends).
|
|
21
|
+
* - `./workspace` — foundation-workspace helpers (`useWorkspaceFilter`).
|
|
21
22
|
*/
|
|
22
23
|
export { reactFactory, reactFactoryWithProvider } from './react-layout-factory';
|
|
23
24
|
export { createReactRenderer } from './create-react-renderer';
|
package/dist/dts/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,YAAY,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAChF,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAC;AAC5E,OAAO,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAC1E,YAAY,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACzE,YAAY,EACV,0BAA0B,EAC1B,wBAAwB,EACxB,wBAAwB,GACzB,MAAM,iCAAiC,CAAC;AACzC,YAAY,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@genesislcap/foundation-react-utils/workspace`
|
|
3
|
+
*
|
|
4
|
+
* React helpers for `@genesislcap/foundation-workspace` (save/load of layouts, grid column state
|
|
5
|
+
* and filters).
|
|
6
|
+
*
|
|
7
|
+
* Exposed as a subpath (`/workspace`) rather than from the package root so that consumers which
|
|
8
|
+
* don't use workspaces don't load foundation-workspace (and the grid-pro graph behind it).
|
|
9
|
+
*
|
|
10
|
+
* Grids, layouts and the save/load UI need no hook: use the element wrappers from
|
|
11
|
+
* `@genesislcap/foundation-workspace/react` (`GridRegister`, `LayoutWrapper`, `WorkspaceManager`).
|
|
12
|
+
* Inside a `rapid-layout`, render panes through `registerFactory` + `reactFactory` rather than as
|
|
13
|
+
* JSX children, because loading a saved layout rebuilds panes and cloned DOM loses React state.
|
|
14
|
+
*
|
|
15
|
+
* Key exports:
|
|
16
|
+
* - `useWorkspaceFilter` — register React filter state so workspaces save and restore it.
|
|
17
|
+
*/
|
|
18
|
+
export { useWorkspaceFilter } from './use-workspace-filter';
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/workspace/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Registers a piece of React filter state with the foundation-workspace `FilterRegistry`, so
|
|
3
|
+
* `<workspace-manager>` saves it with the workspace and restores it on load.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* Grids and layouts are covered by the `GridRegister` / `LayoutWrapper` elements; filters have no
|
|
7
|
+
* element wrapper because their value lives in app state, so this hook is the React equivalent.
|
|
8
|
+
*
|
|
9
|
+
* - Registers on mount and unregisters on unmount (or when `filterKey` changes).
|
|
10
|
+
* - The registry always reads the latest `value` and calls the latest `setValue`, so neither needs
|
|
11
|
+
* to be memoised.
|
|
12
|
+
* - On mount, the registry applies its stored value for `filterKey` (if any): the loaded
|
|
13
|
+
* workspace's value, or this filter's last value from earlier in the session. This covers a
|
|
14
|
+
* filter that wasn't mounted when the workspace loaded (e.g. on another route), and a filter
|
|
15
|
+
* inside a layout pane that a layout reload remounts.
|
|
16
|
+
* - On unmount, the registry keeps the last value, so saving a workspace while the filter isn't
|
|
17
|
+
* mounted still includes it.
|
|
18
|
+
*
|
|
19
|
+
* @param filterKey - Unique key the value is saved under. An empty key skips registration.
|
|
20
|
+
* @param value - Current filter value.
|
|
21
|
+
* @param setValue - Called with the saved value when a workspace is loaded.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```tsx
|
|
25
|
+
* const [instrument, setInstrument] = useState('');
|
|
26
|
+
* useWorkspaceFilter('positions-instrument', instrument, setInstrument);
|
|
27
|
+
* ```
|
|
28
|
+
* @alpha
|
|
29
|
+
*/
|
|
30
|
+
export declare function useWorkspaceFilter(filterKey: string, value: string, setValue: (value: string) => void): void;
|
|
31
|
+
//# sourceMappingURL=use-workspace-filter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-workspace-filter.d.ts","sourceRoot":"","sources":["../../../src/workspace/use-workspace-filter.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,GAChC,IAAI,CAwBN"}
|
package/dist/esm/index.js
CHANGED
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
* Rapid Design System theme for it installed on import. Import from there rather than adding
|
|
19
19
|
* `flexlayout-react` to an app's own dependencies.
|
|
20
20
|
* - `./router` — route table helpers (`renderAppRoutes` and friends).
|
|
21
|
+
* - `./workspace` — foundation-workspace helpers (`useWorkspaceFilter`).
|
|
21
22
|
*/
|
|
22
23
|
export { reactFactory, reactFactoryWithProvider } from './react-layout-factory';
|
|
23
24
|
export { createReactRenderer } from './create-react-renderer';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@genesislcap/foundation-react-utils/workspace`
|
|
3
|
+
*
|
|
4
|
+
* React helpers for `@genesislcap/foundation-workspace` (save/load of layouts, grid column state
|
|
5
|
+
* and filters).
|
|
6
|
+
*
|
|
7
|
+
* Exposed as a subpath (`/workspace`) rather than from the package root so that consumers which
|
|
8
|
+
* don't use workspaces don't load foundation-workspace (and the grid-pro graph behind it).
|
|
9
|
+
*
|
|
10
|
+
* Grids, layouts and the save/load UI need no hook: use the element wrappers from
|
|
11
|
+
* `@genesislcap/foundation-workspace/react` (`GridRegister`, `LayoutWrapper`, `WorkspaceManager`).
|
|
12
|
+
* Inside a `rapid-layout`, render panes through `registerFactory` + `reactFactory` rather than as
|
|
13
|
+
* JSX children, because loading a saved layout rebuilds panes and cloned DOM loses React state.
|
|
14
|
+
*
|
|
15
|
+
* Key exports:
|
|
16
|
+
* - `useWorkspaceFilter` — register React filter state so workspaces save and restore it.
|
|
17
|
+
*/
|
|
18
|
+
export { useWorkspaceFilter } from './use-workspace-filter';
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { FilterRegistry } from '@genesislcap/foundation-workspace';
|
|
2
|
+
import { DI } from '@genesislcap/web-core';
|
|
3
|
+
import { useEffect, useLayoutEffect, useRef } from 'react';
|
|
4
|
+
/**
|
|
5
|
+
* Registers a piece of React filter state with the foundation-workspace `FilterRegistry`, so
|
|
6
|
+
* `<workspace-manager>` saves it with the workspace and restores it on load.
|
|
7
|
+
*
|
|
8
|
+
* @remarks
|
|
9
|
+
* Grids and layouts are covered by the `GridRegister` / `LayoutWrapper` elements; filters have no
|
|
10
|
+
* element wrapper because their value lives in app state, so this hook is the React equivalent.
|
|
11
|
+
*
|
|
12
|
+
* - Registers on mount and unregisters on unmount (or when `filterKey` changes).
|
|
13
|
+
* - The registry always reads the latest `value` and calls the latest `setValue`, so neither needs
|
|
14
|
+
* to be memoised.
|
|
15
|
+
* - On mount, the registry applies its stored value for `filterKey` (if any): the loaded
|
|
16
|
+
* workspace's value, or this filter's last value from earlier in the session. This covers a
|
|
17
|
+
* filter that wasn't mounted when the workspace loaded (e.g. on another route), and a filter
|
|
18
|
+
* inside a layout pane that a layout reload remounts.
|
|
19
|
+
* - On unmount, the registry keeps the last value, so saving a workspace while the filter isn't
|
|
20
|
+
* mounted still includes it.
|
|
21
|
+
*
|
|
22
|
+
* @param filterKey - Unique key the value is saved under. An empty key skips registration.
|
|
23
|
+
* @param value - Current filter value.
|
|
24
|
+
* @param setValue - Called with the saved value when a workspace is loaded.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```tsx
|
|
28
|
+
* const [instrument, setInstrument] = useState('');
|
|
29
|
+
* useWorkspaceFilter('positions-instrument', instrument, setInstrument);
|
|
30
|
+
* ```
|
|
31
|
+
* @alpha
|
|
32
|
+
*/
|
|
33
|
+
export function useWorkspaceFilter(filterKey, value, setValue) {
|
|
34
|
+
const latest = useRef({ value, setValue });
|
|
35
|
+
useLayoutEffect(() => {
|
|
36
|
+
latest.current = { value, setValue };
|
|
37
|
+
});
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
if (!filterKey) {
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
42
|
+
const filterRegistry = DI.getOrCreateDOMContainer().get(FilterRegistry);
|
|
43
|
+
filterRegistry.registerFilter(filterKey, () => ({ filterKey, value: latest.current.value }), (savedValue) => latest.current.setValue(savedValue));
|
|
44
|
+
return () => {
|
|
45
|
+
filterRegistry.unregisterFilter(filterKey);
|
|
46
|
+
};
|
|
47
|
+
}, [filterKey]);
|
|
48
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@genesislcap/foundation-react-utils",
|
|
3
3
|
"description": "Genesis Foundation React Utils",
|
|
4
|
-
"version": "15.
|
|
4
|
+
"version": "15.40.0-FUI-2628.1",
|
|
5
5
|
"sideEffects": [
|
|
6
6
|
"./dist/esm/flexlayout/index.js"
|
|
7
7
|
],
|
|
@@ -21,6 +21,10 @@
|
|
|
21
21
|
"types": "./dist/dts/flexlayout/index.d.ts",
|
|
22
22
|
"default": "./dist/esm/flexlayout/index.js"
|
|
23
23
|
},
|
|
24
|
+
"./workspace": {
|
|
25
|
+
"types": "./dist/dts/workspace/index.d.ts",
|
|
26
|
+
"default": "./dist/esm/workspace/index.js"
|
|
27
|
+
},
|
|
24
28
|
"./package.json": "./package.json"
|
|
25
29
|
},
|
|
26
30
|
"typesVersions": {
|
|
@@ -30,6 +34,9 @@
|
|
|
30
34
|
],
|
|
31
35
|
"flexlayout": [
|
|
32
36
|
"./dist/dts/flexlayout/index.d.ts"
|
|
37
|
+
],
|
|
38
|
+
"workspace": [
|
|
39
|
+
"./dist/dts/workspace/index.d.ts"
|
|
33
40
|
]
|
|
34
41
|
}
|
|
35
42
|
},
|
|
@@ -56,13 +63,13 @@
|
|
|
56
63
|
}
|
|
57
64
|
},
|
|
58
65
|
"devDependencies": {
|
|
59
|
-
"@genesislcap/foundation-testing": "15.
|
|
60
|
-
"@genesislcap/genx": "15.
|
|
61
|
-
"@genesislcap/rollup-builder": "15.
|
|
62
|
-
"@genesislcap/ts-builder": "15.
|
|
63
|
-
"@genesislcap/uvu-playwright-builder": "15.
|
|
64
|
-
"@genesislcap/vite-builder": "15.
|
|
65
|
-
"@genesislcap/webpack-builder": "15.
|
|
66
|
+
"@genesislcap/foundation-testing": "15.40.0-FUI-2628.1",
|
|
67
|
+
"@genesislcap/genx": "15.40.0-FUI-2628.1",
|
|
68
|
+
"@genesislcap/rollup-builder": "15.40.0-FUI-2628.1",
|
|
69
|
+
"@genesislcap/ts-builder": "15.40.0-FUI-2628.1",
|
|
70
|
+
"@genesislcap/uvu-playwright-builder": "15.40.0-FUI-2628.1",
|
|
71
|
+
"@genesislcap/vite-builder": "15.40.0-FUI-2628.1",
|
|
72
|
+
"@genesislcap/webpack-builder": "15.40.0-FUI-2628.1",
|
|
66
73
|
"react-router-dom": "^7.1.3"
|
|
67
74
|
},
|
|
68
75
|
"peerDependencies": {
|
|
@@ -76,11 +83,12 @@
|
|
|
76
83
|
}
|
|
77
84
|
},
|
|
78
85
|
"dependencies": {
|
|
79
|
-
"@genesislcap/foundation-forms": "15.
|
|
80
|
-
"@genesislcap/foundation-layout": "15.
|
|
81
|
-
"@genesislcap/foundation-logger": "15.
|
|
82
|
-
"@genesislcap/
|
|
83
|
-
"@genesislcap/
|
|
86
|
+
"@genesislcap/foundation-forms": "15.40.0-FUI-2628.1",
|
|
87
|
+
"@genesislcap/foundation-layout": "15.40.0-FUI-2628.1",
|
|
88
|
+
"@genesislcap/foundation-logger": "15.40.0-FUI-2628.1",
|
|
89
|
+
"@genesislcap/foundation-workspace": "15.40.0-FUI-2628.1",
|
|
90
|
+
"@genesislcap/rapid-design-system": "15.40.0-FUI-2628.1",
|
|
91
|
+
"@genesislcap/web-core": "15.40.0-FUI-2628.1",
|
|
84
92
|
"@jsonforms/core": "^3.2.1",
|
|
85
93
|
"@r2wc/core": "1.3.1",
|
|
86
94
|
"@r2wc/react-to-web-component": "^2.0.2",
|