@vcmap/ui 5.1.8 → 5.2.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/build/buildTypes.js +9 -0
- package/config/base.config.json +33 -2
- package/config/dev.config.json +22 -2
- package/dist/assets/cesium.js +1 -1
- package/dist/assets/{core.45041e.js → core.627882.js} +4160 -4041
- package/dist/assets/core.js +1 -1
- package/dist/assets/index-76acacac.js +1 -0
- package/dist/assets/ol.js +1 -1
- package/dist/assets/{ui.74ba2a.css → ui.895896.css} +2 -2
- package/dist/assets/{ui.74ba2a.js → ui.895896.js} +8628 -7657
- package/dist/assets/ui.js +1 -1
- package/dist/assets/vue.js +2 -2
- package/dist/assets/{vuetify.72ace9.js → vuetify.1621f3.js} +1 -1
- package/dist/assets/vuetify.js +2 -2
- package/dist/index.html +1 -1
- package/index.d.ts +16 -0
- package/index.js +23 -0
- package/package.json +2 -2
- package/plugins/@vcmap-show-case/collection-manager-example/src/CollectionManagerExample.vue +110 -37
- package/plugins/@vcmap-show-case/collection-manager-example/src/index.js +4 -0
- package/plugins/@vcmap-show-case/form-inputs-example/src/FormInputsExample.vue +10 -3
- package/plugins/@vcmap-show-case/panel-tester/README.md +3 -0
- package/plugins/@vcmap-show-case/panel-tester/package.json +5 -0
- package/plugins/@vcmap-show-case/panel-tester/src/IframePanelExample.vue +15 -0
- package/plugins/@vcmap-show-case/panel-tester/src/ImgPanelExample.vue +19 -0
- package/plugins/@vcmap-show-case/panel-tester/src/PanelExample.vue +128 -0
- package/plugins/@vcmap-show-case/panel-tester/src/TextPanelExample.vue +34 -0
- package/plugins/@vcmap-show-case/panel-tester/src/index.js +63 -0
- package/src/actions/actionHelper.js +1 -1
- package/src/actions/flightActions.d.ts +38 -2
- package/src/actions/flightActions.js +257 -6
- package/src/application/VcsApp.vue +4 -104
- package/src/application/VcsApp.vue.d.ts +0 -6
- package/src/application/VcsContainer.vue +105 -0
- package/src/application/VcsContainer.vue.d.ts +14 -0
- package/src/application/VcsMainMap.vue +68 -0
- package/src/application/VcsMainMap.vue.d.ts +9 -0
- package/src/application/markdownHelper.d.ts +7 -0
- package/src/application/markdownHelper.js +57 -1
- package/src/components/form-inputs-controls/VcsRadioGrid.vue +27 -42
- package/src/contentTree/LayerTree.vue +40 -14
- package/src/downloadHelper.d.ts +0 -2
- package/src/downloadHelper.js +2 -4
- package/src/featureInfo/BalloonComponent.vue +31 -3
- package/src/featureInfo/BalloonComponent.vue.d.ts +1 -0
- package/src/featureInfo/MarkdownBalloonComponent.vue +24 -0
- package/src/featureInfo/MarkdownBalloonComponent.vue.d.ts +12 -0
- package/src/featureInfo/abstractFeatureInfoView.js +54 -22
- package/src/featureInfo/addressBalloonFeatureInfoView.d.ts +2 -2
- package/src/featureInfo/addressBalloonFeatureInfoView.js +1 -1
- package/src/featureInfo/balloonFeatureInfoView.js +1 -1
- package/src/featureInfo/balloonHelper.js +16 -9
- package/src/featureInfo/featureInfo.js +10 -0
- package/src/featureInfo/markdownBalloonFeatureInfoView.d.ts +47 -0
- package/src/featureInfo/markdownBalloonFeatureInfoView.js +81 -0
- package/src/featureInfo/markdownFeatureInfoView.d.ts +47 -0
- package/src/featureInfo/markdownFeatureInfoView.js +95 -0
- package/src/i18n/de.d.ts +8 -3
- package/src/i18n/de.js +3 -0
- package/src/i18n/en.d.ts +32 -26
- package/src/i18n/en.js +4 -1
- package/src/manager/collectionManager/CollectionComponent.vue +12 -49
- package/src/manager/collectionManager/CollectionComponent.vue.d.ts +5 -9
- package/src/manager/collectionManager/CollectionComponentContent.vue +102 -0
- package/src/manager/collectionManager/CollectionComponentContent.vue.d.ts +17 -0
- package/src/manager/collectionManager/CollectionComponentList.vue +10 -2
- package/src/manager/collectionManager/CollectionComponentList.vue.d.ts +9 -0
- package/src/manager/collectionManager/CollectionComponentStandalone.vue +91 -0
- package/src/manager/collectionManager/CollectionComponentStandalone.vue.d.ts +9 -0
- package/src/manager/collectionManager/collectionManager.d.ts +2 -2
- package/src/manager/collectionManager/collectionManager.js +21 -19
- package/src/manager/panel/PanelComponent.vue +110 -0
- package/src/manager/panel/PanelComponent.vue.d.ts +19 -0
- package/src/manager/panel/PanelManagerComponent.vue +224 -0
- package/src/manager/panel/PanelManagerComponent.vue.d.ts +36 -0
- package/src/manager/panel/panelHelper.d.ts +83 -0
- package/src/manager/panel/panelHelper.js +272 -0
- package/src/manager/panel/panelManager.d.ts +338 -0
- package/src/manager/panel/panelManager.js +381 -0
- package/src/manager/window/WindowManager.vue +14 -0
- package/src/manager/window/windowHelper.js +1 -1
- package/src/search/ResultItem.vue +1 -1
- package/src/search/search.d.ts +2 -2
- package/src/search/search.js +2 -2
- package/src/vcsUiApp.d.ts +14 -0
- package/src/vcsUiApp.js +18 -0
- package/dist/assets/index-3cd5a3f3.js +0 -1
- /package/dist/assets/{cesium.035e3a.js → cesium.9e39f4.js} +0 -0
- /package/dist/assets/{ol.eb3bee.js → ol.fe8c0e.js} +0 -0
- /package/dist/assets/{vue.17a8fa.js → vue.4b3319.js} +0 -0
- /package/dist/assets/{vuetify.72ace9.css → vuetify.1621f3.css} +0 -0
@@ -0,0 +1,224 @@
|
|
1
|
+
<template>
|
2
|
+
<div
|
3
|
+
class="vcs-panel-frame"
|
4
|
+
@mouseup="setResizing(undefined)"
|
5
|
+
ref="panelFrameRef"
|
6
|
+
>
|
7
|
+
<PanelComponent
|
8
|
+
:panel-state="mainPanel.state"
|
9
|
+
:style="getPosition(mainPanel)"
|
10
|
+
class="overflow-auto"
|
11
|
+
>
|
12
|
+
<VcsMainMap />
|
13
|
+
</PanelComponent>
|
14
|
+
<PanelComponent
|
15
|
+
v-for="id in componentIds"
|
16
|
+
:key="id"
|
17
|
+
:panel-state="getState(id)"
|
18
|
+
:style="getStyles(id).value"
|
19
|
+
:class="getState(id).classes"
|
20
|
+
class="overflow-auto"
|
21
|
+
@resize="setResizing"
|
22
|
+
>
|
23
|
+
<component
|
24
|
+
:is="getComponent(id)"
|
25
|
+
:panel-state="getState(id)"
|
26
|
+
v-bind="getProps(id)"
|
27
|
+
@close="close(id)"
|
28
|
+
/>
|
29
|
+
</PanelComponent>
|
30
|
+
</div>
|
31
|
+
</template>
|
32
|
+
|
33
|
+
<style scoped lang="scss">
|
34
|
+
.vcs-panel-frame {
|
35
|
+
position: absolute;
|
36
|
+
top: 0;
|
37
|
+
left: 0;
|
38
|
+
right: 0;
|
39
|
+
bottom: 0;
|
40
|
+
}
|
41
|
+
.vcs-panel-border {
|
42
|
+
padding: 5px;
|
43
|
+
}
|
44
|
+
</style>
|
45
|
+
|
46
|
+
<script>
|
47
|
+
import {
|
48
|
+
computed,
|
49
|
+
getCurrentInstance,
|
50
|
+
inject,
|
51
|
+
reactive,
|
52
|
+
ref,
|
53
|
+
watch,
|
54
|
+
} from 'vue';
|
55
|
+
import VcsMainMap from '../../application/VcsMainMap.vue';
|
56
|
+
import { vcsAppSymbol } from '../../pluginHelper.js';
|
57
|
+
import { updatePanelSizes, DefaultMainPanelPosition } from './panelHelper.js';
|
58
|
+
import {
|
59
|
+
getPanelPosition,
|
60
|
+
PanelLocation,
|
61
|
+
panelLocationSymbol,
|
62
|
+
panelPositionSymbol,
|
63
|
+
setPanelPosition,
|
64
|
+
} from './panelManager.js';
|
65
|
+
import PanelComponent from './PanelComponent.vue';
|
66
|
+
|
67
|
+
/**
|
68
|
+
* @returns {Partial<import("./panelManager.js").PanelComponent>}
|
69
|
+
*/
|
70
|
+
export function createMainPanel() {
|
71
|
+
const id = 'vcs-main';
|
72
|
+
return {
|
73
|
+
id,
|
74
|
+
[panelPositionSymbol]: reactive({ ...DefaultMainPanelPosition }),
|
75
|
+
state: reactive({
|
76
|
+
id,
|
77
|
+
owner: vcsAppSymbol,
|
78
|
+
location: 'vcs-main',
|
79
|
+
}),
|
80
|
+
};
|
81
|
+
}
|
82
|
+
|
83
|
+
/**
|
84
|
+
* @description PanelManager rendering all Panels
|
85
|
+
*/
|
86
|
+
export default {
|
87
|
+
name: 'VcsPanelManager',
|
88
|
+
components: { VcsMainMap, PanelComponent },
|
89
|
+
setup() {
|
90
|
+
const app = inject('vcsApp');
|
91
|
+
/** @type {PanelManager} */
|
92
|
+
const { panelManager } = app;
|
93
|
+
const { componentIds } = panelManager;
|
94
|
+
const panelFrameRef = ref();
|
95
|
+
const resizing = ref(undefined);
|
96
|
+
let resizingFunction = () => {};
|
97
|
+
|
98
|
+
/**
|
99
|
+
* @param {string} id
|
100
|
+
* @returns {PanelState}
|
101
|
+
*/
|
102
|
+
const getState = (id) => {
|
103
|
+
return panelManager.get(id)?.state;
|
104
|
+
};
|
105
|
+
/**
|
106
|
+
* @param {string} id
|
107
|
+
* @returns {Object}
|
108
|
+
*/
|
109
|
+
const getProps = (id) => {
|
110
|
+
return panelManager.get(id)?.props ?? {};
|
111
|
+
};
|
112
|
+
/**
|
113
|
+
* @param {PanelComponent} panelComponent
|
114
|
+
* @returns {PanelPosition|null}
|
115
|
+
*/
|
116
|
+
const getPosition = (panelComponent) => {
|
117
|
+
return getPanelPosition(panelComponent);
|
118
|
+
};
|
119
|
+
/**
|
120
|
+
* @param {string} id
|
121
|
+
* @returns {import("vue").ComputedRef<Object>}
|
122
|
+
*/
|
123
|
+
const getStyles = (id) =>
|
124
|
+
computed(() => {
|
125
|
+
const panelComponent = panelManager.get(id);
|
126
|
+
return {
|
127
|
+
...getPosition(panelComponent),
|
128
|
+
...(panelComponent?.state?.styles || {}),
|
129
|
+
};
|
130
|
+
});
|
131
|
+
|
132
|
+
const mainPanel = createMainPanel();
|
133
|
+
|
134
|
+
const resize = (panel, e) => {
|
135
|
+
if (panel) {
|
136
|
+
let resizeKey;
|
137
|
+
if (panel[panelLocationSymbol] === PanelLocation.BOTTOM) {
|
138
|
+
const height =
|
139
|
+
((panelFrameRef.value.offsetTop + e.y) /
|
140
|
+
panelFrameRef.value.parentElement.offsetHeight) *
|
141
|
+
100;
|
142
|
+
setPanelPosition(panel, { height: `${Math.round(100 - height)}%` });
|
143
|
+
} else {
|
144
|
+
const width =
|
145
|
+
((panelFrameRef.value.offsetLeft + e.x) /
|
146
|
+
panelFrameRef.value.parentElement.offsetWidth) *
|
147
|
+
100;
|
148
|
+
if (panel[panelLocationSymbol] === PanelLocation.LEFT) {
|
149
|
+
setPanelPosition(panel, { width: `${width}%` });
|
150
|
+
resizeKey = 'left';
|
151
|
+
} else if (panel[panelLocationSymbol] === PanelLocation.RIGHT) {
|
152
|
+
setPanelPosition(panel, { width: `${Math.round(100 - width)}%` });
|
153
|
+
resizeKey = 'right';
|
154
|
+
}
|
155
|
+
}
|
156
|
+
updatePanelSizes(
|
157
|
+
panelManager,
|
158
|
+
mainPanel,
|
159
|
+
panelFrameRef.value.getBoundingClientRect(),
|
160
|
+
resizeKey,
|
161
|
+
);
|
162
|
+
}
|
163
|
+
};
|
164
|
+
|
165
|
+
const setResizing = (id) => {
|
166
|
+
if (id) {
|
167
|
+
resizing.value = id;
|
168
|
+
resizingFunction = (e) => {
|
169
|
+
e.preventDefault();
|
170
|
+
resize(panelManager.get(id), e);
|
171
|
+
};
|
172
|
+
panelFrameRef.value.addEventListener(
|
173
|
+
'mousemove',
|
174
|
+
resizingFunction,
|
175
|
+
false,
|
176
|
+
);
|
177
|
+
} else {
|
178
|
+
resizing.value = undefined;
|
179
|
+
panelFrameRef.value.removeEventListener(
|
180
|
+
'mousemove',
|
181
|
+
resizingFunction,
|
182
|
+
false,
|
183
|
+
);
|
184
|
+
}
|
185
|
+
};
|
186
|
+
|
187
|
+
const componentIdRef = ref(componentIds);
|
188
|
+
watch(
|
189
|
+
() => [...componentIdRef.value],
|
190
|
+
() => {
|
191
|
+
updatePanelSizes(
|
192
|
+
panelManager,
|
193
|
+
mainPanel,
|
194
|
+
panelFrameRef.value.getBoundingClientRect(),
|
195
|
+
);
|
196
|
+
},
|
197
|
+
);
|
198
|
+
|
199
|
+
const addMobileClass = computed(() => {
|
200
|
+
return (
|
201
|
+
getCurrentInstance().proxy.$vuetify.breakpoint.xs &&
|
202
|
+
componentIdRef.value.length > 0
|
203
|
+
);
|
204
|
+
});
|
205
|
+
|
206
|
+
return {
|
207
|
+
mainPanel,
|
208
|
+
componentIds: componentIdRef,
|
209
|
+
getComponent: (id) => panelManager.get(id).component,
|
210
|
+
getPosition,
|
211
|
+
getStyles,
|
212
|
+
getState,
|
213
|
+
getProps,
|
214
|
+
panelFrameRef,
|
215
|
+
setResizing,
|
216
|
+
resizingFunction,
|
217
|
+
close: (id) => {
|
218
|
+
panelManager.remove(id);
|
219
|
+
},
|
220
|
+
addMobileClass,
|
221
|
+
};
|
222
|
+
},
|
223
|
+
};
|
224
|
+
</script>
|
@@ -0,0 +1,36 @@
|
|
1
|
+
/**
|
2
|
+
* @returns {Partial<import("./panelManager.js").PanelComponent>}
|
3
|
+
*/
|
4
|
+
export function createMainPanel(): Partial<import("./panelManager.js").PanelComponent>;
|
5
|
+
declare const _default: import("vue").DefineComponent<{}, {
|
6
|
+
mainPanel: Partial<import("./panelManager.js").PanelComponent>;
|
7
|
+
componentIds: PanelManager;
|
8
|
+
getComponent: (id: any) => any;
|
9
|
+
getPosition: (panelComponent: import("vue").DefineComponent<{
|
10
|
+
panelState: {
|
11
|
+
type: ObjectConstructor;
|
12
|
+
required: true;
|
13
|
+
};
|
14
|
+
}, {
|
15
|
+
appIsDark: import("vue").ComputedRef<any>;
|
16
|
+
isLeft: import("vue").ComputedRef<boolean>;
|
17
|
+
isRight: import("vue").ComputedRef<boolean>;
|
18
|
+
isBottom: import("vue").ComputedRef<boolean>;
|
19
|
+
startResize(e: any): void;
|
20
|
+
stopResize(): void;
|
21
|
+
}, {}, {}, {}, import("vue/types/v3-component-options.js").ComponentOptionsMixin, import("vue/types/v3-component-options.js").ComponentOptionsMixin, {}, string, Readonly<import("vue").ExtractPropTypes<{
|
22
|
+
panelState: {
|
23
|
+
type: ObjectConstructor;
|
24
|
+
required: true;
|
25
|
+
};
|
26
|
+
}>>, {}>) => PanelPosition | null;
|
27
|
+
getStyles: (id: string) => import("vue").ComputedRef<Object>;
|
28
|
+
getState: (id: string) => PanelState;
|
29
|
+
getProps: (id: string) => Object;
|
30
|
+
panelFrameRef: import("vue").Ref<any>;
|
31
|
+
setResizing: (id: any) => void;
|
32
|
+
resizingFunction: () => void;
|
33
|
+
close: (id: any) => void;
|
34
|
+
addMobileClass: import("vue").ComputedRef<any>;
|
35
|
+
}, {}, {}, {}, import("vue/types/v3-component-options.js").ComponentOptionsMixin, import("vue/types/v3-component-options.js").ComponentOptionsMixin, {}, string, Readonly<import("vue").ExtractPropTypes<{}>>, {}>;
|
36
|
+
export default _default;
|
@@ -0,0 +1,83 @@
|
|
1
|
+
/**
|
2
|
+
* @typedef {Object} NumberPanelPosition
|
3
|
+
* @property {number?} left - The left CSS property participates in specifying the horizontal position of a panel.
|
4
|
+
* @property {number?} top - The top CSS property participates in specifying the vertical position of a panel.
|
5
|
+
* @property {number?} right - The right CSS property participates in specifying the horizontal position of a panel.
|
6
|
+
* @property {number?} bottom - The bottom CSS property participates in specifying the vertical position of a panel.
|
7
|
+
* @property {number} width - The width CSS property sets an element's width.
|
8
|
+
* @property {number} height - The height CSS property sets an element's height.
|
9
|
+
* @property {number} maxHeight - The maxHeight CSS property sets an element's maximal height.
|
10
|
+
* @property {number} maxWidth - The maxWidth CSS property sets an element's maximal width.
|
11
|
+
* @property {number} minHeight - The minHeight CSS property sets an element's minimal height.
|
12
|
+
* @property {number} minWidth - The minWidth CSS property sets an element's minimal width.
|
13
|
+
*/
|
14
|
+
/**
|
15
|
+
* Parses a position to numeric percentage value (0-100). Non-numeric values return undefined.
|
16
|
+
* @param {string|number|undefined} pos
|
17
|
+
* @param {string} key - one of PanelPosition keys
|
18
|
+
* @param {DOMRect} targetSize - size of the current target
|
19
|
+
* @returns {number|undefined}
|
20
|
+
*/
|
21
|
+
export function posToRelativeTarget(pos: string | number | undefined, key: string, targetSize: DOMRect): number | undefined;
|
22
|
+
/**
|
23
|
+
* Parses CSS position string properties to percentage numeric position properties
|
24
|
+
* @param {Partial<import("./panelManager.js").PanelPosition>} panelPosition
|
25
|
+
* @param {DOMRect} targetSize - the map's target size
|
26
|
+
* @returns {NumberPanelPosition}
|
27
|
+
*/
|
28
|
+
export function percentageFromPanelOptions(panelPosition: Partial<import("./panelManager.js").PanelPosition>, targetSize: DOMRect): NumberPanelPosition;
|
29
|
+
/**
|
30
|
+
* Updates size of main panel according to other active panels
|
31
|
+
* @param {import("./panelManager.js").default} panelManager
|
32
|
+
* @param {Partial<import("./panelManager.js").PanelComponent>} mainPanel
|
33
|
+
* @param {DOMRect} targetSize
|
34
|
+
* @param {string|undefined} resizeKey
|
35
|
+
*/
|
36
|
+
export function updatePanelSizes(panelManager: import("./panelManager.js").default, mainPanel: Partial<import("./panelManager.js").PanelComponent>, targetSize: DOMRect, resizeKey?: string | undefined): void;
|
37
|
+
/**
|
38
|
+
*
|
39
|
+
* @type {Partial<import("./panelManager.js").PanelPosition>}
|
40
|
+
*/
|
41
|
+
export const DefaultMainPanelPosition: Partial<import("./panelManager.js").PanelPosition>;
|
42
|
+
export type NumberPanelPosition = {
|
43
|
+
/**
|
44
|
+
* - The left CSS property participates in specifying the horizontal position of a panel.
|
45
|
+
*/
|
46
|
+
left: number | null;
|
47
|
+
/**
|
48
|
+
* - The top CSS property participates in specifying the vertical position of a panel.
|
49
|
+
*/
|
50
|
+
top: number | null;
|
51
|
+
/**
|
52
|
+
* - The right CSS property participates in specifying the horizontal position of a panel.
|
53
|
+
*/
|
54
|
+
right: number | null;
|
55
|
+
/**
|
56
|
+
* - The bottom CSS property participates in specifying the vertical position of a panel.
|
57
|
+
*/
|
58
|
+
bottom: number | null;
|
59
|
+
/**
|
60
|
+
* - The width CSS property sets an element's width.
|
61
|
+
*/
|
62
|
+
width: number;
|
63
|
+
/**
|
64
|
+
* - The height CSS property sets an element's height.
|
65
|
+
*/
|
66
|
+
height: number;
|
67
|
+
/**
|
68
|
+
* - The maxHeight CSS property sets an element's maximal height.
|
69
|
+
*/
|
70
|
+
maxHeight: number;
|
71
|
+
/**
|
72
|
+
* - The maxWidth CSS property sets an element's maximal width.
|
73
|
+
*/
|
74
|
+
maxWidth: number;
|
75
|
+
/**
|
76
|
+
* - The minHeight CSS property sets an element's minimal height.
|
77
|
+
*/
|
78
|
+
minHeight: number;
|
79
|
+
/**
|
80
|
+
* - The minWidth CSS property sets an element's minimal width.
|
81
|
+
*/
|
82
|
+
minWidth: number;
|
83
|
+
};
|
@@ -0,0 +1,272 @@
|
|
1
|
+
import {
|
2
|
+
PanelLocation,
|
3
|
+
getPanelPosition,
|
4
|
+
setPanelPosition,
|
5
|
+
DefaultPanelPositions,
|
6
|
+
} from './panelManager.js';
|
7
|
+
|
8
|
+
/**
|
9
|
+
*
|
10
|
+
* @type {Partial<import("./panelManager.js").PanelPosition>}
|
11
|
+
*/
|
12
|
+
export const DefaultMainPanelPosition = {
|
13
|
+
top: '0px',
|
14
|
+
left: '0px',
|
15
|
+
right: '0px',
|
16
|
+
bottom: '0px',
|
17
|
+
width: '100%',
|
18
|
+
minWidth: '10%',
|
19
|
+
minHeight: '25%',
|
20
|
+
};
|
21
|
+
|
22
|
+
/**
|
23
|
+
* @typedef {Object} NumberPanelPosition
|
24
|
+
* @property {number?} left - The left CSS property participates in specifying the horizontal position of a panel.
|
25
|
+
* @property {number?} top - The top CSS property participates in specifying the vertical position of a panel.
|
26
|
+
* @property {number?} right - The right CSS property participates in specifying the horizontal position of a panel.
|
27
|
+
* @property {number?} bottom - The bottom CSS property participates in specifying the vertical position of a panel.
|
28
|
+
* @property {number} width - The width CSS property sets an element's width.
|
29
|
+
* @property {number} height - The height CSS property sets an element's height.
|
30
|
+
* @property {number} maxHeight - The maxHeight CSS property sets an element's maximal height.
|
31
|
+
* @property {number} maxWidth - The maxWidth CSS property sets an element's maximal width.
|
32
|
+
* @property {number} minHeight - The minHeight CSS property sets an element's minimal height.
|
33
|
+
* @property {number} minWidth - The minWidth CSS property sets an element's minimal width.
|
34
|
+
*/
|
35
|
+
/**
|
36
|
+
* Parses a position to numeric percentage value (0-100). Non-numeric values return undefined.
|
37
|
+
* @param {string|number|undefined} pos
|
38
|
+
* @param {string} key - one of PanelPosition keys
|
39
|
+
* @param {DOMRect} targetSize - size of the current target
|
40
|
+
* @returns {number|undefined}
|
41
|
+
*/
|
42
|
+
export function posToRelativeTarget(pos, key, targetSize) {
|
43
|
+
if (typeof pos === 'string') {
|
44
|
+
if (pos.match(/^-?\d+\.?\d*px$/)) {
|
45
|
+
const scalar = [
|
46
|
+
'bottom',
|
47
|
+
'top',
|
48
|
+
'height',
|
49
|
+
'minHeight',
|
50
|
+
'maxHeight',
|
51
|
+
].includes(key)
|
52
|
+
? targetSize?.height
|
53
|
+
: targetSize?.width;
|
54
|
+
return (parseInt(pos, 10) / scalar) * 100;
|
55
|
+
} else if (targetSize && pos.match(/^-?\d+\.?\d*%$/)) {
|
56
|
+
return parseInt(pos, 10);
|
57
|
+
}
|
58
|
+
return undefined;
|
59
|
+
}
|
60
|
+
return pos;
|
61
|
+
}
|
62
|
+
|
63
|
+
/**
|
64
|
+
* Parses CSS position string properties to percentage numeric position properties
|
65
|
+
* @param {Partial<import("./panelManager.js").PanelPosition>} panelPosition
|
66
|
+
* @param {DOMRect} targetSize - the map's target size
|
67
|
+
* @returns {NumberPanelPosition}
|
68
|
+
*/
|
69
|
+
export function percentageFromPanelOptions(panelPosition, targetSize) {
|
70
|
+
const options = {};
|
71
|
+
Object.keys(panelPosition).forEach((key) => {
|
72
|
+
if (panelPosition[key] !== undefined) {
|
73
|
+
options[key] = posToRelativeTarget(panelPosition[key], key, targetSize);
|
74
|
+
}
|
75
|
+
});
|
76
|
+
return options;
|
77
|
+
}
|
78
|
+
|
79
|
+
/**
|
80
|
+
* Returns the maximum permitted width of a panel as a function of the main panel minWidth and other active side panel width
|
81
|
+
* @param {Partial<import("./panelManager.js").PanelPosition>} main
|
82
|
+
* @param {Partial<import("./panelManager.js").PanelPosition>} side
|
83
|
+
* @param {DOMRect} targetSize
|
84
|
+
* @returns {number}
|
85
|
+
*/
|
86
|
+
function getMaxWidth(main, side, targetSize) {
|
87
|
+
const maxWidth =
|
88
|
+
100 - posToRelativeTarget(main.minWidth, 'minWidth', targetSize);
|
89
|
+
if (side) {
|
90
|
+
return maxWidth - posToRelativeTarget(side.width, 'width', targetSize);
|
91
|
+
}
|
92
|
+
return maxWidth;
|
93
|
+
}
|
94
|
+
|
95
|
+
/**
|
96
|
+
* Updates side panel width and height
|
97
|
+
* Sets new main panel width depending on side panel
|
98
|
+
* @param {'left'|'right'} key
|
99
|
+
* @param {Partial<import("./panelManager.js").PanelComponent>} panel
|
100
|
+
* @param {Partial<NumberPanelPosition>} main
|
101
|
+
* @param {Partial<NumberPanelPosition>} side
|
102
|
+
* @param {DOMRect} targetSize
|
103
|
+
* @returns {Partial<import("./panelManager.js").PanelPosition>}
|
104
|
+
*/
|
105
|
+
function handleSidePanel(key, panel, main, side, targetSize) {
|
106
|
+
const toUpdate = {};
|
107
|
+
if (panel.state.resizable) {
|
108
|
+
const position = percentageFromPanelOptions(
|
109
|
+
getPanelPosition(panel),
|
110
|
+
targetSize,
|
111
|
+
);
|
112
|
+
if (side.maxWidth !== position.maxWidth) {
|
113
|
+
position.maxWidth = side.maxWidth;
|
114
|
+
toUpdate.maxWidth = `${side.maxWidth}%`;
|
115
|
+
}
|
116
|
+
|
117
|
+
const width = Math.max(
|
118
|
+
position.minWidth,
|
119
|
+
Math.min(position.width, position.maxWidth),
|
120
|
+
);
|
121
|
+
main.width -= width;
|
122
|
+
main[key] = width;
|
123
|
+
|
124
|
+
if (width !== position.width) {
|
125
|
+
toUpdate.width = `${width}%`;
|
126
|
+
}
|
127
|
+
if (position.height !== side.height) {
|
128
|
+
toUpdate.height = `${side.height}%`;
|
129
|
+
}
|
130
|
+
}
|
131
|
+
return toUpdate;
|
132
|
+
}
|
133
|
+
|
134
|
+
/**
|
135
|
+
* Updates size of main panel according to other active panels
|
136
|
+
* @param {import("./panelManager.js").default} panelManager
|
137
|
+
* @param {Partial<import("./panelManager.js").PanelComponent>} mainPanel
|
138
|
+
* @param {DOMRect} targetSize
|
139
|
+
* @param {string|undefined} resizeKey
|
140
|
+
*/
|
141
|
+
export function updatePanelSizes(
|
142
|
+
panelManager,
|
143
|
+
mainPanel,
|
144
|
+
targetSize,
|
145
|
+
resizeKey = undefined,
|
146
|
+
) {
|
147
|
+
const defaultMain = percentageFromPanelOptions(
|
148
|
+
DefaultMainPanelPosition,
|
149
|
+
targetSize,
|
150
|
+
);
|
151
|
+
const defaultSide = {
|
152
|
+
height: 100,
|
153
|
+
};
|
154
|
+
|
155
|
+
if (panelManager.hasLocation(PanelLocation.BOTTOM)) {
|
156
|
+
const bottomPanelPosition = getPanelPosition(
|
157
|
+
panelManager.getLocation(PanelLocation.BOTTOM),
|
158
|
+
);
|
159
|
+
const bottomHeight = Math.max(
|
160
|
+
posToRelativeTarget(
|
161
|
+
bottomPanelPosition.minHeight,
|
162
|
+
'minHeight',
|
163
|
+
targetSize,
|
164
|
+
),
|
165
|
+
Math.min(
|
166
|
+
posToRelativeTarget(bottomPanelPosition.height, 'height', targetSize),
|
167
|
+
posToRelativeTarget(
|
168
|
+
bottomPanelPosition.maxHeight,
|
169
|
+
'maxHeight',
|
170
|
+
targetSize,
|
171
|
+
),
|
172
|
+
),
|
173
|
+
);
|
174
|
+
defaultMain.bottom += bottomHeight;
|
175
|
+
defaultSide.height -= bottomHeight;
|
176
|
+
}
|
177
|
+
|
178
|
+
const leftPanel = panelManager.getLocation(PanelLocation.LEFT);
|
179
|
+
const leftWidth =
|
180
|
+
posToRelativeTarget(
|
181
|
+
getPanelPosition(leftPanel)?.width,
|
182
|
+
'width',
|
183
|
+
targetSize,
|
184
|
+
) || 0;
|
185
|
+
|
186
|
+
const rightPanel = panelManager.getLocation(PanelLocation.RIGHT);
|
187
|
+
const rightWidth =
|
188
|
+
posToRelativeTarget(
|
189
|
+
getPanelPosition(rightPanel)?.width,
|
190
|
+
'width',
|
191
|
+
targetSize,
|
192
|
+
) || 0;
|
193
|
+
|
194
|
+
const left = {
|
195
|
+
maxWidth: DefaultPanelPositions[PanelLocation.LEFT].maxWidth,
|
196
|
+
};
|
197
|
+
|
198
|
+
const right = {
|
199
|
+
maxWidth: DefaultPanelPositions[PanelLocation.RIGHT].maxWidth,
|
200
|
+
};
|
201
|
+
|
202
|
+
const maxWidth = getMaxWidth(defaultMain, undefined, targetSize);
|
203
|
+
if (
|
204
|
+
panelManager.hasLocation(PanelLocation.LEFT) &&
|
205
|
+
panelManager.hasLocation(PanelLocation.RIGHT) &&
|
206
|
+
leftWidth + rightWidth > maxWidth
|
207
|
+
) {
|
208
|
+
if (leftWidth > maxWidth / 2 && rightWidth > maxWidth / 2) {
|
209
|
+
left.maxWidth = maxWidth / 2;
|
210
|
+
right.maxWidth = maxWidth / 2;
|
211
|
+
} else if (leftWidth > maxWidth / 2) {
|
212
|
+
left.maxWidth = maxWidth - rightWidth;
|
213
|
+
right.maxWidth = rightWidth;
|
214
|
+
} else if (rightWidth > maxWidth / 2) {
|
215
|
+
right.maxWidth = maxWidth - leftWidth;
|
216
|
+
left.maxWidth = leftWidth;
|
217
|
+
}
|
218
|
+
} else {
|
219
|
+
left.maxWidth = getMaxWidth(
|
220
|
+
defaultMain,
|
221
|
+
getPanelPosition(rightPanel),
|
222
|
+
targetSize,
|
223
|
+
);
|
224
|
+
right.maxWidth = getMaxWidth(
|
225
|
+
defaultMain,
|
226
|
+
getPanelPosition(leftPanel),
|
227
|
+
targetSize,
|
228
|
+
);
|
229
|
+
}
|
230
|
+
|
231
|
+
if (panelManager.hasLocation(PanelLocation.LEFT) && resizeKey !== 'right') {
|
232
|
+
const updatedLeft = handleSidePanel(
|
233
|
+
'left',
|
234
|
+
leftPanel,
|
235
|
+
defaultMain,
|
236
|
+
{
|
237
|
+
...defaultSide,
|
238
|
+
...left,
|
239
|
+
},
|
240
|
+
targetSize,
|
241
|
+
);
|
242
|
+
setPanelPosition(leftPanel, updatedLeft);
|
243
|
+
}
|
244
|
+
if (panelManager.hasLocation(PanelLocation.RIGHT) && resizeKey !== 'left') {
|
245
|
+
const updatedRight = handleSidePanel(
|
246
|
+
'right',
|
247
|
+
rightPanel,
|
248
|
+
defaultMain,
|
249
|
+
{
|
250
|
+
...defaultSide,
|
251
|
+
...right,
|
252
|
+
},
|
253
|
+
targetSize,
|
254
|
+
);
|
255
|
+
setPanelPosition(rightPanel, updatedRight);
|
256
|
+
}
|
257
|
+
|
258
|
+
const main = percentageFromPanelOptions(
|
259
|
+
getPanelPosition(mainPanel),
|
260
|
+
targetSize,
|
261
|
+
);
|
262
|
+
|
263
|
+
const toUpdate = Object.keys(defaultMain).reduce((acc, key) => {
|
264
|
+
if (defaultMain[key] !== main[key]) {
|
265
|
+
acc[key] = `${defaultMain[key]}%`;
|
266
|
+
}
|
267
|
+
return acc;
|
268
|
+
}, {});
|
269
|
+
if (Object.keys(toUpdate).length > 0) {
|
270
|
+
setPanelPosition(mainPanel, toUpdate);
|
271
|
+
}
|
272
|
+
}
|