@ttoss/geovis-workspace 0.1.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/LICENSE +21 -0
- package/README.md +154 -0
- package/dist/index.cjs +691 -0
- package/dist/index.d.cts +164 -0
- package/dist/index.d.mts +164 -0
- package/dist/index.mjs +674 -0
- package/package.json +62 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { VisualizationSpec } from "@ttoss/geovis";
|
|
4
|
+
|
|
5
|
+
//#region src/context/GeovisWorkspaceContext.d.ts
|
|
6
|
+
interface GeovisWorkspaceMenuItem {
|
|
7
|
+
/** Value reported through selection and onSelect when this item is active. */
|
|
8
|
+
value: string;
|
|
9
|
+
/** Text shown for the item in the sidebar menu. */
|
|
10
|
+
label: string;
|
|
11
|
+
}
|
|
12
|
+
interface GeovisWorkspaceMenu {
|
|
13
|
+
/** Unique identifier of the menu group. */
|
|
14
|
+
id: string;
|
|
15
|
+
/** Title displayed above the group's items. */
|
|
16
|
+
title: string;
|
|
17
|
+
/** Selectable items within the group. */
|
|
18
|
+
items: GeovisWorkspaceMenuItem[];
|
|
19
|
+
/** Value of the item selected by default in this group. */
|
|
20
|
+
defaultValue?: string;
|
|
21
|
+
}
|
|
22
|
+
interface GeovisWorkspaceLeftSidebar {
|
|
23
|
+
/** Menu groups rendered in the left sidebar. */
|
|
24
|
+
menus: GeovisWorkspaceMenu[];
|
|
25
|
+
}
|
|
26
|
+
interface GeovisWorkspaceLegendItem {
|
|
27
|
+
/** Swatch fill color (any CSS color string or theme color token). */
|
|
28
|
+
color: string;
|
|
29
|
+
/** Text shown next to the swatch, e.g. a value range like "0% – 5%". */
|
|
30
|
+
label: string;
|
|
31
|
+
}
|
|
32
|
+
interface GeovisWorkspaceLegend {
|
|
33
|
+
/** Optional heading rendered above the legend swatches. */
|
|
34
|
+
title?: string;
|
|
35
|
+
/** One entry per legend class. */
|
|
36
|
+
items: GeovisWorkspaceLegendItem[];
|
|
37
|
+
}
|
|
38
|
+
interface GeovisWorkspaceSource {
|
|
39
|
+
/** Source description text. */
|
|
40
|
+
label: string;
|
|
41
|
+
/** Optional URL — when set, the label becomes an external link. */
|
|
42
|
+
href?: string;
|
|
43
|
+
}
|
|
44
|
+
interface GeovisWorkspaceSources {
|
|
45
|
+
/** Optional heading rendered above the source list. */
|
|
46
|
+
title?: string;
|
|
47
|
+
/** One entry per data source. */
|
|
48
|
+
items: GeovisWorkspaceSource[];
|
|
49
|
+
}
|
|
50
|
+
interface GeovisWorkspaceLegendWithColor {
|
|
51
|
+
/** Descriptive paragraph rendered under the right sidebar title. */
|
|
52
|
+
description?: string;
|
|
53
|
+
/** Color legend (a swatch and label per class). */
|
|
54
|
+
legend?: GeovisWorkspaceLegend;
|
|
55
|
+
/** Data sources, each optionally rendered as an external link. */
|
|
56
|
+
sources?: GeovisWorkspaceSources;
|
|
57
|
+
}
|
|
58
|
+
interface GeovisWorkspaceRightSidebar {
|
|
59
|
+
/** Title displayed at the top of the right sidebar. */
|
|
60
|
+
title?: string;
|
|
61
|
+
/** Color legend panel: description, class swatches and data sources. */
|
|
62
|
+
legendWithColor?: GeovisWorkspaceLegendWithColor;
|
|
63
|
+
}
|
|
64
|
+
interface GeovisWorkspaceConfig {
|
|
65
|
+
/** Configuration for the left sidebar. Omit to hide it entirely. */
|
|
66
|
+
leftSidebar?: GeovisWorkspaceLeftSidebar;
|
|
67
|
+
/** Configuration for the right sidebar. Omit to hide it entirely. */
|
|
68
|
+
rightSidebar?: GeovisWorkspaceRightSidebar;
|
|
69
|
+
}
|
|
70
|
+
/** Active item value per menu group, keyed by menu id. */
|
|
71
|
+
type GeovisWorkspaceSelection = Record<string, string | undefined>;
|
|
72
|
+
interface GeovisWorkspaceContextValue {
|
|
73
|
+
/** The config that drives the sidebars. */
|
|
74
|
+
config: GeovisWorkspaceConfig;
|
|
75
|
+
/** Active item value per menu group, keyed by menu id. */
|
|
76
|
+
selection: GeovisWorkspaceSelection;
|
|
77
|
+
/** Sets the active item for a given menu group. */
|
|
78
|
+
setSelection: ({
|
|
79
|
+
menuId,
|
|
80
|
+
value
|
|
81
|
+
}: {
|
|
82
|
+
menuId: string;
|
|
83
|
+
value: string;
|
|
84
|
+
}) => void;
|
|
85
|
+
/** Whether the left sidebar is currently open. */
|
|
86
|
+
isLeftSidebarOpen: boolean;
|
|
87
|
+
/** Opens or closes the left sidebar. */
|
|
88
|
+
setLeftSidebarOpen: ({
|
|
89
|
+
open
|
|
90
|
+
}: {
|
|
91
|
+
open: boolean;
|
|
92
|
+
}) => void;
|
|
93
|
+
/** Whether the right sidebar is currently open. */
|
|
94
|
+
isRightSidebarOpen: boolean;
|
|
95
|
+
/** Opens or closes the right sidebar. */
|
|
96
|
+
setRightSidebarOpen: ({
|
|
97
|
+
open
|
|
98
|
+
}: {
|
|
99
|
+
open: boolean;
|
|
100
|
+
}) => void;
|
|
101
|
+
}
|
|
102
|
+
//#endregion
|
|
103
|
+
//#region src/GeovisWorkspace.d.ts
|
|
104
|
+
interface GeovisWorkspaceProps {
|
|
105
|
+
config: GeovisWorkspaceConfig;
|
|
106
|
+
visualizationSpec: VisualizationSpec;
|
|
107
|
+
variables?: GeovisWorkspaceSelection;
|
|
108
|
+
onVariableChange?: (variables: GeovisWorkspaceSelection) => void;
|
|
109
|
+
}
|
|
110
|
+
declare const GeovisWorkspace: ({
|
|
111
|
+
config,
|
|
112
|
+
visualizationSpec,
|
|
113
|
+
variables,
|
|
114
|
+
onVariableChange
|
|
115
|
+
}: GeovisWorkspaceProps) => import("react/jsx-runtime").JSX.Element;
|
|
116
|
+
//#endregion
|
|
117
|
+
//#region src/GeovisWorkspaceProvider.d.ts
|
|
118
|
+
interface GeovisWorkspaceProviderProps {
|
|
119
|
+
/** Content to render inside the provider. */
|
|
120
|
+
children: React.ReactNode;
|
|
121
|
+
/** Config describing the sidebars. */
|
|
122
|
+
config: GeovisWorkspaceConfig;
|
|
123
|
+
/**
|
|
124
|
+
* Active item value per menu group, keyed by menu id. Provide it to control
|
|
125
|
+
* the selection from the parent. Omit it to let the provider manage the
|
|
126
|
+
* selection internally (seeded from each menu's `defaultValue`).
|
|
127
|
+
*/
|
|
128
|
+
selection?: GeovisWorkspaceSelection;
|
|
129
|
+
/**
|
|
130
|
+
* Called with the full next selection whenever an item in a menu group is
|
|
131
|
+
* selected. Use it to rebuild the `visualizationSpec` in the parent.
|
|
132
|
+
*/
|
|
133
|
+
onSelectionChange?: (selection: GeovisWorkspaceSelection) => void;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Builds the initial selection by reading the `defaultValue` of every menu
|
|
137
|
+
* group in the config. Use it to seed the parent's selection state when
|
|
138
|
+
* controlling the workspace.
|
|
139
|
+
*/
|
|
140
|
+
declare const getInitialSelection: ({
|
|
141
|
+
config
|
|
142
|
+
}: {
|
|
143
|
+
config: GeovisWorkspaceConfig;
|
|
144
|
+
}) => GeovisWorkspaceSelection;
|
|
145
|
+
/**
|
|
146
|
+
* Provides shared state for GeovisWorkspace and all internal components.
|
|
147
|
+
* Manages the per-group selection (controlled or uncontrolled) and the sidebar
|
|
148
|
+
* open state, exposing them via useGeovisWorkspace.
|
|
149
|
+
*/
|
|
150
|
+
declare const GeovisWorkspaceProvider: ({
|
|
151
|
+
children,
|
|
152
|
+
config,
|
|
153
|
+
selection,
|
|
154
|
+
onSelectionChange
|
|
155
|
+
}: GeovisWorkspaceProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
156
|
+
//#endregion
|
|
157
|
+
//#region src/hooks/useGeovisWorkspace.d.ts
|
|
158
|
+
/**
|
|
159
|
+
* Consumes the GeovisWorkspace context.
|
|
160
|
+
* Must be used inside a GeovisWorkspaceProvider.
|
|
161
|
+
*/
|
|
162
|
+
declare const useGeovisWorkspace: () => GeovisWorkspaceContextValue;
|
|
163
|
+
//#endregion
|
|
164
|
+
export { GeovisWorkspace, type GeovisWorkspaceConfig, type GeovisWorkspaceContextValue, type GeovisWorkspaceLeftSidebar, type GeovisWorkspaceLegend, type GeovisWorkspaceLegendItem, type GeovisWorkspaceLegendWithColor, type GeovisWorkspaceMenu, type GeovisWorkspaceMenuItem, type GeovisWorkspaceProps, GeovisWorkspaceProvider, type GeovisWorkspaceProviderProps, type GeovisWorkspaceRightSidebar, type GeovisWorkspaceSelection, type GeovisWorkspaceSource, type GeovisWorkspaceSources, getInitialSelection, useGeovisWorkspace };
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
|
|
2
|
+
import { VisualizationSpec } from "@ttoss/geovis";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
|
|
5
|
+
//#region src/context/GeovisWorkspaceContext.d.ts
|
|
6
|
+
interface GeovisWorkspaceMenuItem {
|
|
7
|
+
/** Value reported through selection and onSelect when this item is active. */
|
|
8
|
+
value: string;
|
|
9
|
+
/** Text shown for the item in the sidebar menu. */
|
|
10
|
+
label: string;
|
|
11
|
+
}
|
|
12
|
+
interface GeovisWorkspaceMenu {
|
|
13
|
+
/** Unique identifier of the menu group. */
|
|
14
|
+
id: string;
|
|
15
|
+
/** Title displayed above the group's items. */
|
|
16
|
+
title: string;
|
|
17
|
+
/** Selectable items within the group. */
|
|
18
|
+
items: GeovisWorkspaceMenuItem[];
|
|
19
|
+
/** Value of the item selected by default in this group. */
|
|
20
|
+
defaultValue?: string;
|
|
21
|
+
}
|
|
22
|
+
interface GeovisWorkspaceLeftSidebar {
|
|
23
|
+
/** Menu groups rendered in the left sidebar. */
|
|
24
|
+
menus: GeovisWorkspaceMenu[];
|
|
25
|
+
}
|
|
26
|
+
interface GeovisWorkspaceLegendItem {
|
|
27
|
+
/** Swatch fill color (any CSS color string or theme color token). */
|
|
28
|
+
color: string;
|
|
29
|
+
/** Text shown next to the swatch, e.g. a value range like "0% – 5%". */
|
|
30
|
+
label: string;
|
|
31
|
+
}
|
|
32
|
+
interface GeovisWorkspaceLegend {
|
|
33
|
+
/** Optional heading rendered above the legend swatches. */
|
|
34
|
+
title?: string;
|
|
35
|
+
/** One entry per legend class. */
|
|
36
|
+
items: GeovisWorkspaceLegendItem[];
|
|
37
|
+
}
|
|
38
|
+
interface GeovisWorkspaceSource {
|
|
39
|
+
/** Source description text. */
|
|
40
|
+
label: string;
|
|
41
|
+
/** Optional URL — when set, the label becomes an external link. */
|
|
42
|
+
href?: string;
|
|
43
|
+
}
|
|
44
|
+
interface GeovisWorkspaceSources {
|
|
45
|
+
/** Optional heading rendered above the source list. */
|
|
46
|
+
title?: string;
|
|
47
|
+
/** One entry per data source. */
|
|
48
|
+
items: GeovisWorkspaceSource[];
|
|
49
|
+
}
|
|
50
|
+
interface GeovisWorkspaceLegendWithColor {
|
|
51
|
+
/** Descriptive paragraph rendered under the right sidebar title. */
|
|
52
|
+
description?: string;
|
|
53
|
+
/** Color legend (a swatch and label per class). */
|
|
54
|
+
legend?: GeovisWorkspaceLegend;
|
|
55
|
+
/** Data sources, each optionally rendered as an external link. */
|
|
56
|
+
sources?: GeovisWorkspaceSources;
|
|
57
|
+
}
|
|
58
|
+
interface GeovisWorkspaceRightSidebar {
|
|
59
|
+
/** Title displayed at the top of the right sidebar. */
|
|
60
|
+
title?: string;
|
|
61
|
+
/** Color legend panel: description, class swatches and data sources. */
|
|
62
|
+
legendWithColor?: GeovisWorkspaceLegendWithColor;
|
|
63
|
+
}
|
|
64
|
+
interface GeovisWorkspaceConfig {
|
|
65
|
+
/** Configuration for the left sidebar. Omit to hide it entirely. */
|
|
66
|
+
leftSidebar?: GeovisWorkspaceLeftSidebar;
|
|
67
|
+
/** Configuration for the right sidebar. Omit to hide it entirely. */
|
|
68
|
+
rightSidebar?: GeovisWorkspaceRightSidebar;
|
|
69
|
+
}
|
|
70
|
+
/** Active item value per menu group, keyed by menu id. */
|
|
71
|
+
type GeovisWorkspaceSelection = Record<string, string | undefined>;
|
|
72
|
+
interface GeovisWorkspaceContextValue {
|
|
73
|
+
/** The config that drives the sidebars. */
|
|
74
|
+
config: GeovisWorkspaceConfig;
|
|
75
|
+
/** Active item value per menu group, keyed by menu id. */
|
|
76
|
+
selection: GeovisWorkspaceSelection;
|
|
77
|
+
/** Sets the active item for a given menu group. */
|
|
78
|
+
setSelection: ({
|
|
79
|
+
menuId,
|
|
80
|
+
value
|
|
81
|
+
}: {
|
|
82
|
+
menuId: string;
|
|
83
|
+
value: string;
|
|
84
|
+
}) => void;
|
|
85
|
+
/** Whether the left sidebar is currently open. */
|
|
86
|
+
isLeftSidebarOpen: boolean;
|
|
87
|
+
/** Opens or closes the left sidebar. */
|
|
88
|
+
setLeftSidebarOpen: ({
|
|
89
|
+
open
|
|
90
|
+
}: {
|
|
91
|
+
open: boolean;
|
|
92
|
+
}) => void;
|
|
93
|
+
/** Whether the right sidebar is currently open. */
|
|
94
|
+
isRightSidebarOpen: boolean;
|
|
95
|
+
/** Opens or closes the right sidebar. */
|
|
96
|
+
setRightSidebarOpen: ({
|
|
97
|
+
open
|
|
98
|
+
}: {
|
|
99
|
+
open: boolean;
|
|
100
|
+
}) => void;
|
|
101
|
+
}
|
|
102
|
+
//#endregion
|
|
103
|
+
//#region src/GeovisWorkspace.d.ts
|
|
104
|
+
interface GeovisWorkspaceProps {
|
|
105
|
+
config: GeovisWorkspaceConfig;
|
|
106
|
+
visualizationSpec: VisualizationSpec;
|
|
107
|
+
variables?: GeovisWorkspaceSelection;
|
|
108
|
+
onVariableChange?: (variables: GeovisWorkspaceSelection) => void;
|
|
109
|
+
}
|
|
110
|
+
declare const GeovisWorkspace: ({
|
|
111
|
+
config,
|
|
112
|
+
visualizationSpec,
|
|
113
|
+
variables,
|
|
114
|
+
onVariableChange
|
|
115
|
+
}: GeovisWorkspaceProps) => import("react/jsx-runtime").JSX.Element;
|
|
116
|
+
//#endregion
|
|
117
|
+
//#region src/GeovisWorkspaceProvider.d.ts
|
|
118
|
+
interface GeovisWorkspaceProviderProps {
|
|
119
|
+
/** Content to render inside the provider. */
|
|
120
|
+
children: React.ReactNode;
|
|
121
|
+
/** Config describing the sidebars. */
|
|
122
|
+
config: GeovisWorkspaceConfig;
|
|
123
|
+
/**
|
|
124
|
+
* Active item value per menu group, keyed by menu id. Provide it to control
|
|
125
|
+
* the selection from the parent. Omit it to let the provider manage the
|
|
126
|
+
* selection internally (seeded from each menu's `defaultValue`).
|
|
127
|
+
*/
|
|
128
|
+
selection?: GeovisWorkspaceSelection;
|
|
129
|
+
/**
|
|
130
|
+
* Called with the full next selection whenever an item in a menu group is
|
|
131
|
+
* selected. Use it to rebuild the `visualizationSpec` in the parent.
|
|
132
|
+
*/
|
|
133
|
+
onSelectionChange?: (selection: GeovisWorkspaceSelection) => void;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Builds the initial selection by reading the `defaultValue` of every menu
|
|
137
|
+
* group in the config. Use it to seed the parent's selection state when
|
|
138
|
+
* controlling the workspace.
|
|
139
|
+
*/
|
|
140
|
+
declare const getInitialSelection: ({
|
|
141
|
+
config
|
|
142
|
+
}: {
|
|
143
|
+
config: GeovisWorkspaceConfig;
|
|
144
|
+
}) => GeovisWorkspaceSelection;
|
|
145
|
+
/**
|
|
146
|
+
* Provides shared state for GeovisWorkspace and all internal components.
|
|
147
|
+
* Manages the per-group selection (controlled or uncontrolled) and the sidebar
|
|
148
|
+
* open state, exposing them via useGeovisWorkspace.
|
|
149
|
+
*/
|
|
150
|
+
declare const GeovisWorkspaceProvider: ({
|
|
151
|
+
children,
|
|
152
|
+
config,
|
|
153
|
+
selection,
|
|
154
|
+
onSelectionChange
|
|
155
|
+
}: GeovisWorkspaceProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
156
|
+
//#endregion
|
|
157
|
+
//#region src/hooks/useGeovisWorkspace.d.ts
|
|
158
|
+
/**
|
|
159
|
+
* Consumes the GeovisWorkspace context.
|
|
160
|
+
* Must be used inside a GeovisWorkspaceProvider.
|
|
161
|
+
*/
|
|
162
|
+
declare const useGeovisWorkspace: () => GeovisWorkspaceContextValue;
|
|
163
|
+
//#endregion
|
|
164
|
+
export { GeovisWorkspace, type GeovisWorkspaceConfig, type GeovisWorkspaceContextValue, type GeovisWorkspaceLeftSidebar, type GeovisWorkspaceLegend, type GeovisWorkspaceLegendItem, type GeovisWorkspaceLegendWithColor, type GeovisWorkspaceMenu, type GeovisWorkspaceMenuItem, type GeovisWorkspaceProps, GeovisWorkspaceProvider, type GeovisWorkspaceProviderProps, type GeovisWorkspaceRightSidebar, type GeovisWorkspaceSelection, type GeovisWorkspaceSource, type GeovisWorkspaceSources, getInitialSelection, useGeovisWorkspace };
|