@geogirafe/lib-geoportal 0.4.0-1168862803
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/CONTRIBUTING.md +101 -0
- package/LICENSE +201 -0
- package/README.md +180 -0
- package/base/GirafeDraggableElement.d.ts +21 -0
- package/base/GirafeDraggableElement.js +148 -0
- package/base/GirafeHTMLElement.d.ts +52 -0
- package/base/GirafeHTMLElement.js +166 -0
- package/base/GirafeResizableElement.d.ts +21 -0
- package/base/GirafeResizableElement.js +265 -0
- package/base/GirafeSingleton.d.ts +10 -0
- package/base/GirafeSingleton.js +44 -0
- package/base/main.d.ts +4 -0
- package/base/main.js +4 -0
- package/buildtools/lib-inline.js +17 -0
- package/buildtools/tools.js +94 -0
- package/buildtools/vite-inline-templates-plugin.js +18 -0
- package/buildtools/vite-restart-plugin.js +14 -0
- package/components/about/component.d.ts +16 -0
- package/components/about/component.js +166 -0
- package/components/about/images/logo.png +0 -0
- package/components/basemap/component.d.ts +16 -0
- package/components/basemap/component.js +84 -0
- package/components/button/component.d.ts +23 -0
- package/components/button/component.js +338 -0
- package/components/colorswitcher/component.d.ts +24 -0
- package/components/colorswitcher/component.js +205 -0
- package/components/coordinate/component.d.ts +14 -0
- package/components/coordinate/component.js +88 -0
- package/components/globe/component.d.ts +11 -0
- package/components/globe/component.js +59 -0
- package/components/help/component.d.ts +20 -0
- package/components/help/component.js +230 -0
- package/components/help/images/arrow_black.png +0 -0
- package/components/help/images/arrow_black.webp +0 -0
- package/components/help/images/arrow_white.png +0 -0
- package/components/help/images/arrow_white.webp +0 -0
- package/components/language/component.d.ts +15 -0
- package/components/language/component.js +87 -0
- package/components/main.d.ts +24 -0
- package/components/main.js +24 -0
- package/components/map/component.d.ts +116 -0
- package/components/map/component.js +1002 -0
- package/components/map/tools/localfilemanager.d.ts +29 -0
- package/components/map/tools/localfilemanager.js +153 -0
- package/components/map/tools/osmmanager.d.ts +12 -0
- package/components/map/tools/osmmanager.js +41 -0
- package/components/map/tools/swipemanager.d.ts +29 -0
- package/components/map/tools/swipemanager.js +170 -0
- package/components/map/tools/vectortilesmanager.d.ts +12 -0
- package/components/map/tools/vectortilesmanager.js +40 -0
- package/components/map/tools/viewmanager.d.ts +30 -0
- package/components/map/tools/viewmanager.js +186 -0
- package/components/map/tools/wmsmanager.d.ts +34 -0
- package/components/map/tools/wmsmanager.js +284 -0
- package/components/map/tools/wmtsmanager.d.ts +20 -0
- package/components/map/tools/wmtsmanager.js +146 -0
- package/components/menubutton/component.d.ts +22 -0
- package/components/menubutton/component.js +313 -0
- package/components/navigation/Bookmark.d.ts +7 -0
- package/components/navigation/Bookmark.js +27 -0
- package/components/navigation/navbookmarks/component.d.ts +12 -0
- package/components/navigation/navbookmarks/component.js +101 -0
- package/components/navigation/navhelper/component.d.ts +21 -0
- package/components/navigation/navhelper/component.js +205 -0
- package/components/print/component.d.ts +194 -0
- package/components/print/component.js +876 -0
- package/components/print/tools/printMaskLayer.d.ts +19 -0
- package/components/print/tools/printMaskLayer.js +99 -0
- package/components/print/tools/printMaskManager.d.ts +33 -0
- package/components/print/tools/printMaskManager.js +86 -0
- package/components/projection/component.d.ts +15 -0
- package/components/projection/component.js +90 -0
- package/components/querybuilder/component.d.ts +21 -0
- package/components/querybuilder/component.js +226 -0
- package/components/querybuilder/tools/filterhelper.d.ts +16 -0
- package/components/querybuilder/tools/filterhelper.js +74 -0
- package/components/redlining/component.d.ts +28 -0
- package/components/redlining/component.js +456 -0
- package/components/scale/component.d.ts +14 -0
- package/components/scale/component.js +120 -0
- package/components/search/component.d.ts +28 -0
- package/components/search/component.js +296 -0
- package/components/selectiongrid/component.d.ts +21 -0
- package/components/selectiongrid/component.js +417 -0
- package/components/selectionwindow/component.d.ts +17 -0
- package/components/selectionwindow/component.js +207 -0
- package/components/themes/component.d.ts +16 -0
- package/components/themes/component.js +163 -0
- package/components/treeview/component.d.ts +23 -0
- package/components/treeview/component.js +322 -0
- package/components/treeviewgroup/component.d.ts +20 -0
- package/components/treeviewgroup/component.js +240 -0
- package/components/treeviewitem/component.d.ts +26 -0
- package/components/treeviewitem/component.js +469 -0
- package/components/videorecord/component.d.ts +15 -0
- package/components/videorecord/component.js +135 -0
- package/decs.d.ts +4 -0
- package/main.lib.d.ts +7 -0
- package/main.lib.js +1 -0
- package/models/basemap.d.ts +12 -0
- package/models/basemap.js +35 -0
- package/models/events.d.ts +6 -0
- package/models/events.js +7 -0
- package/models/gmf.d.ts +62 -0
- package/models/gmf.js +4 -0
- package/models/layers/baselayer.d.ts +23 -0
- package/models/layers/baselayer.js +66 -0
- package/models/layers/grouplayer.d.ts +20 -0
- package/models/layers/grouplayer.js +51 -0
- package/models/layers/ilayerwithfilter.d.ts +5 -0
- package/models/layers/ilayerwithfilter.js +1 -0
- package/models/layers/ilayerwithlegend.d.ts +5 -0
- package/models/layers/ilayerwithlegend.js +1 -0
- package/models/layers/layer.d.ts +20 -0
- package/models/layers/layer.js +49 -0
- package/models/layers/layerlocalfile.d.ts +21 -0
- package/models/layers/layerlocalfile.js +62 -0
- package/models/layers/layerosm.d.ts +12 -0
- package/models/layers/layerosm.js +26 -0
- package/models/layers/layervectortiles.d.ts +16 -0
- package/models/layers/layervectortiles.js +35 -0
- package/models/layers/layerwms.d.ts +34 -0
- package/models/layers/layerwms.js +159 -0
- package/models/layers/layerwmts.d.ts +17 -0
- package/models/layers/layerwmts.js +44 -0
- package/models/main.d.ts +12 -0
- package/models/main.js +12 -0
- package/models/searchresult.d.ts +12 -0
- package/models/searchresult.js +31 -0
- package/models/serverwfs.d.ts +13 -0
- package/models/serverwfs.js +47 -0
- package/models/theme.d.ts +18 -0
- package/models/theme.js +48 -0
- package/package.json +121 -0
- package/public/about.json +1 -0
- package/public/android-chrome-192x192.png +0 -0
- package/public/android-chrome-512x512.png +0 -0
- package/public/apple-touch-icon.png +0 -0
- package/public/favicon-16x16.png +0 -0
- package/public/favicon-32x32.png +0 -0
- package/public/favicon.ico +0 -0
- package/public/images/girafe.png +0 -0
- package/public/images/logo.png +0 -0
- package/public/images/logo_black.png +0 -0
- package/public/images/logo_black_small.png +0 -0
- package/public/images/logo_black_small.webp +0 -0
- package/public/images/logo_small.png +0 -0
- package/public/images/logo_small.webp +0 -0
- package/public/lib/fontawesome/css/all.min.css +6 -0
- package/public/lib/fontawesome/webfonts/fa-brands-400.ttf +0 -0
- package/public/lib/fontawesome/webfonts/fa-brands-400.woff2 +0 -0
- package/public/lib/fontawesome/webfonts/fa-regular-400.ttf +0 -0
- package/public/lib/fontawesome/webfonts/fa-regular-400.woff2 +0 -0
- package/public/lib/fontawesome/webfonts/fa-solid-900.ttf +0 -0
- package/public/lib/fontawesome/webfonts/fa-solid-900.woff2 +0 -0
- package/public/lib/fontawesome/webfonts/fa-v4compatibility.ttf +0 -0
- package/public/lib/fontawesome/webfonts/fa-v4compatibility.woff2 +0 -0
- package/public/site.webmanifest +19 -0
- package/tools/configuration/configmanager.d.ts +9 -0
- package/tools/configuration/configmanager.js +45 -0
- package/tools/configuration/configmanager.spec.d.ts +1 -0
- package/tools/configuration/configmanager.spec.js +60 -0
- package/tools/configuration/girafeconfig.d.ts +97 -0
- package/tools/configuration/girafeconfig.js +237 -0
- package/tools/geoconsts.d.ts +7 -0
- package/tools/geoconsts.js +36 -0
- package/tools/geometrytools.d.ts +1 -0
- package/tools/geometrytools.js +5 -0
- package/tools/i18nmanager.d.ts +36 -0
- package/tools/i18nmanager.js +98 -0
- package/tools/layermanager.d.ts +29 -0
- package/tools/layermanager.js +240 -0
- package/tools/main.d.ts +13 -0
- package/tools/main.js +13 -0
- package/tools/messagemanager.d.ts +13 -0
- package/tools/messagemanager.js +29 -0
- package/tools/olUtils.d.ts +5 -0
- package/tools/olUtils.js +7 -0
- package/tools/state/mapposition.d.ts +9 -0
- package/tools/state/mapposition.js +38 -0
- package/tools/state/redliningfeature.d.ts +18 -0
- package/tools/state/redliningfeature.js +50 -0
- package/tools/state/state.d.ts +84 -0
- package/tools/state/state.js +190 -0
- package/tools/state/statemanager.d.ts +25 -0
- package/tools/state/statemanager.js +199 -0
- package/tools/state/statemanager.spec.d.ts +1 -0
- package/tools/state/statemanager.spec.js +364 -0
- package/tools/tests/mockhelper.d.ts +24 -0
- package/tools/tests/mockhelper.js +37 -0
- package/tools/tests/testhelper.d.ts +4 -0
- package/tools/tests/testhelper.js +26 -0
- package/tools/themesmanager.d.ts +44 -0
- package/tools/themesmanager.js +263 -0
- package/tools/urlmanager.d.ts +4 -0
- package/tools/urlmanager.js +8 -0
- package/tools/wfsmanager.d.ts +27 -0
- package/tools/wfsmanager.js +263 -0
- package/typings/uhtml.d.ts +34 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/// <reference path="../../lib-src-inline/decs.d.ts" />
|
|
2
|
+
import { Renderable } from '../typings/uhtml';
|
|
3
|
+
import tippy from 'tippy.js';
|
|
4
|
+
import MessageManager from '../tools/messagemanager';
|
|
5
|
+
import ConfigManager from '../tools/configuration/configmanager';
|
|
6
|
+
import StateManager from '../tools/state/statemanager';
|
|
7
|
+
type TippyType = typeof tippy;
|
|
8
|
+
declare class GirafeHTMLElement extends HTMLElement {
|
|
9
|
+
templateUrl: string | null;
|
|
10
|
+
styleUrl: string | null;
|
|
11
|
+
template?: Renderable | (() => Renderable);
|
|
12
|
+
component: string;
|
|
13
|
+
shadow: ShadowRoot;
|
|
14
|
+
activeTooltips: TippyType[];
|
|
15
|
+
messageManager: MessageManager;
|
|
16
|
+
configManager: ConfigManager;
|
|
17
|
+
stateManager: StateManager;
|
|
18
|
+
get state(): import("../tools/state/state").default;
|
|
19
|
+
constructor(component: string);
|
|
20
|
+
loadConfig(): Promise<void>;
|
|
21
|
+
girafeTranslate(): void;
|
|
22
|
+
/**
|
|
23
|
+
* NOTE REG: We cannot just use truthy here, because javascript comparaison table is really problematic.
|
|
24
|
+
* For example:
|
|
25
|
+
* 0 == false
|
|
26
|
+
* [] == false
|
|
27
|
+
* "" == false
|
|
28
|
+
* And there are cases where we want to check null or undefined, because 0 can be a right value.
|
|
29
|
+
* More here : https://dorey.github.io/JavaScript-Equality-Table/
|
|
30
|
+
* @param val
|
|
31
|
+
* @returns
|
|
32
|
+
*/
|
|
33
|
+
isNullOrUndefined(val: unknown): boolean;
|
|
34
|
+
isNullOrUndefinedOrBlank(val: unknown): boolean;
|
|
35
|
+
delayed(functionToWatch: () => boolean, functionToExecute: () => void): void;
|
|
36
|
+
getParentOfType(parentNodeName: string, elem: Node | null): Node | null;
|
|
37
|
+
activateTooltips(arrow: boolean, delay: [number, number], defaultPlacement: string): void;
|
|
38
|
+
/**
|
|
39
|
+
* Render the component's template.
|
|
40
|
+
*/
|
|
41
|
+
render(): void;
|
|
42
|
+
/**
|
|
43
|
+
* Renders a hidden span with the name of the component.
|
|
44
|
+
* Useful to render a placeholder for not visible component.
|
|
45
|
+
*/
|
|
46
|
+
renderEmpty(): void;
|
|
47
|
+
/**
|
|
48
|
+
* Hide the component (display: none).
|
|
49
|
+
*/
|
|
50
|
+
hide(): void;
|
|
51
|
+
}
|
|
52
|
+
export default GirafeHTMLElement;
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { render as uRender, html as uHtml } from 'uhtml';
|
|
2
|
+
import tippy from 'tippy.js';
|
|
3
|
+
import I18nManager from '../tools/i18nmanager';
|
|
4
|
+
import MessageManager from '../tools/messagemanager';
|
|
5
|
+
import ConfigManager from '../tools/configuration/configmanager';
|
|
6
|
+
import StateManager from '../tools/state/statemanager';
|
|
7
|
+
class GirafeHTMLElement extends HTMLElement {
|
|
8
|
+
get state() {
|
|
9
|
+
return this.stateManager.state;
|
|
10
|
+
}
|
|
11
|
+
constructor(component) {
|
|
12
|
+
super();
|
|
13
|
+
Object.defineProperty(this, "templateUrl", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
configurable: true,
|
|
16
|
+
writable: true,
|
|
17
|
+
value: null
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(this, "styleUrl", {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
configurable: true,
|
|
22
|
+
writable: true,
|
|
23
|
+
value: null
|
|
24
|
+
});
|
|
25
|
+
Object.defineProperty(this, "template", {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
configurable: true,
|
|
28
|
+
writable: true,
|
|
29
|
+
value: void 0
|
|
30
|
+
});
|
|
31
|
+
Object.defineProperty(this, "component", {
|
|
32
|
+
enumerable: true,
|
|
33
|
+
configurable: true,
|
|
34
|
+
writable: true,
|
|
35
|
+
value: void 0
|
|
36
|
+
});
|
|
37
|
+
Object.defineProperty(this, "shadow", {
|
|
38
|
+
enumerable: true,
|
|
39
|
+
configurable: true,
|
|
40
|
+
writable: true,
|
|
41
|
+
value: void 0
|
|
42
|
+
});
|
|
43
|
+
Object.defineProperty(this, "activeTooltips", {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
configurable: true,
|
|
46
|
+
writable: true,
|
|
47
|
+
value: []
|
|
48
|
+
});
|
|
49
|
+
Object.defineProperty(this, "messageManager", {
|
|
50
|
+
enumerable: true,
|
|
51
|
+
configurable: true,
|
|
52
|
+
writable: true,
|
|
53
|
+
value: void 0
|
|
54
|
+
});
|
|
55
|
+
Object.defineProperty(this, "configManager", {
|
|
56
|
+
enumerable: true,
|
|
57
|
+
configurable: true,
|
|
58
|
+
writable: true,
|
|
59
|
+
value: void 0
|
|
60
|
+
});
|
|
61
|
+
Object.defineProperty(this, "stateManager", {
|
|
62
|
+
enumerable: true,
|
|
63
|
+
configurable: true,
|
|
64
|
+
writable: true,
|
|
65
|
+
value: void 0
|
|
66
|
+
});
|
|
67
|
+
this.component = component;
|
|
68
|
+
this.configManager = ConfigManager.getInstance();
|
|
69
|
+
this.messageManager = MessageManager.getInstance();
|
|
70
|
+
this.stateManager = StateManager.getInstance();
|
|
71
|
+
this.shadow = this.attachShadow({ mode: 'open' });
|
|
72
|
+
this.stateManager.subscribe('language', (_oldLanguage, _newLanguage) => this.girafeTranslate());
|
|
73
|
+
}
|
|
74
|
+
async loadConfig() {
|
|
75
|
+
await this.configManager.loadConfig();
|
|
76
|
+
}
|
|
77
|
+
girafeTranslate() {
|
|
78
|
+
I18nManager.getInstance().translate(this.shadow);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* NOTE REG: We cannot just use truthy here, because javascript comparaison table is really problematic.
|
|
82
|
+
* For example:
|
|
83
|
+
* 0 == false
|
|
84
|
+
* [] == false
|
|
85
|
+
* "" == false
|
|
86
|
+
* And there are cases where we want to check null or undefined, because 0 can be a right value.
|
|
87
|
+
* More here : https://dorey.github.io/JavaScript-Equality-Table/
|
|
88
|
+
* @param val
|
|
89
|
+
* @returns
|
|
90
|
+
*/
|
|
91
|
+
isNullOrUndefined(val) {
|
|
92
|
+
return val === undefined || val === null;
|
|
93
|
+
}
|
|
94
|
+
isNullOrUndefinedOrBlank(val) {
|
|
95
|
+
return val === undefined || val === null || val === '';
|
|
96
|
+
}
|
|
97
|
+
delayed(functionToWatch, functionToExecute) {
|
|
98
|
+
const observer = new MutationObserver((_mutations, obs) => {
|
|
99
|
+
if (functionToWatch()) {
|
|
100
|
+
functionToExecute();
|
|
101
|
+
obs.disconnect();
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
observer.observe(this.shadow, { childList: true, subtree: true });
|
|
105
|
+
}
|
|
106
|
+
getParentOfType(parentNodeName, elem) {
|
|
107
|
+
// Stop case : we found null or an object of the right type
|
|
108
|
+
if (elem === null || elem.nodeName === parentNodeName) {
|
|
109
|
+
return elem;
|
|
110
|
+
}
|
|
111
|
+
// Otherwise, we try to find a parent recursively
|
|
112
|
+
let parent = null;
|
|
113
|
+
if (elem instanceof ShadowRoot) {
|
|
114
|
+
parent = elem.host;
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
parent = elem.parentNode;
|
|
118
|
+
}
|
|
119
|
+
return this.getParentOfType(parentNodeName, parent);
|
|
120
|
+
}
|
|
121
|
+
activateTooltips(arrow, delay, defaultPlacement) {
|
|
122
|
+
// First, deactivate all existing tooltips
|
|
123
|
+
for (const tooltip of this.activeTooltips) {
|
|
124
|
+
tooltip.destroy();
|
|
125
|
+
}
|
|
126
|
+
this.activeTooltips = [];
|
|
127
|
+
const elementsWithTooltip = Array.from(this.shadow.querySelectorAll('[tip]'));
|
|
128
|
+
elementsWithTooltip.forEach((el) => {
|
|
129
|
+
const tooltipText = el.getAttribute('tip');
|
|
130
|
+
if (tooltipText !== '') {
|
|
131
|
+
const placement = el.getAttribute('tip-placement') ?? defaultPlacement;
|
|
132
|
+
const theme = el.getAttribute('tip-theme') ?? '';
|
|
133
|
+
const tooltip = tippy(el, {
|
|
134
|
+
arrow: arrow,
|
|
135
|
+
delay: delay,
|
|
136
|
+
placement: placement,
|
|
137
|
+
theme: theme,
|
|
138
|
+
//animateFill: false,
|
|
139
|
+
//animation: 'scale-with-inertia',
|
|
140
|
+
content: el.getAttribute('tip')
|
|
141
|
+
});
|
|
142
|
+
this.activeTooltips.push(tooltip);
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Render the component's template.
|
|
148
|
+
*/
|
|
149
|
+
render() {
|
|
150
|
+
uRender(this.shadow, this.template);
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Renders a hidden span with the name of the component.
|
|
154
|
+
* Useful to render a placeholder for not visible component.
|
|
155
|
+
*/
|
|
156
|
+
renderEmpty() {
|
|
157
|
+
uRender(this.shadow, uHtml `<span style="display: none">${this.component}</span>`);
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Hide the component (display: none).
|
|
161
|
+
*/
|
|
162
|
+
hide() {
|
|
163
|
+
this.style.display = 'none';
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
export default GirafeHTMLElement;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import GirafeHTMLElement from './GirafeHTMLElement';
|
|
2
|
+
declare class GirafeResizableElement extends GirafeHTMLElement {
|
|
3
|
+
#private;
|
|
4
|
+
panel?: HTMLElement;
|
|
5
|
+
panelRect?: DOMRect;
|
|
6
|
+
gutter?: HTMLElement;
|
|
7
|
+
hideButton?: HTMLElement;
|
|
8
|
+
closeButton?: HTMLElement;
|
|
9
|
+
dock: string;
|
|
10
|
+
prevX: number;
|
|
11
|
+
prevY: number;
|
|
12
|
+
toggleWidth?: number;
|
|
13
|
+
lastWidth: number;
|
|
14
|
+
hideWidth: number;
|
|
15
|
+
get host(): HTMLElement;
|
|
16
|
+
constructor(component: string);
|
|
17
|
+
render(): void;
|
|
18
|
+
makeResizable(): void;
|
|
19
|
+
closePanel(): void;
|
|
20
|
+
}
|
|
21
|
+
export default GirafeResizableElement;
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
2
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
3
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
4
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
5
|
+
};
|
|
6
|
+
var _GirafeResizableElement_instances, _GirafeResizableElement_mousedown, _GirafeResizableElement_togglePanel, _GirafeResizableElement_togglePanelVertically, _GirafeResizableElement_togglePanelHorizontally, _GirafeResizableElement_mousemove, _GirafeResizableElement_mouseup;
|
|
7
|
+
import GirafeHTMLElement from './GirafeHTMLElement';
|
|
8
|
+
/*
|
|
9
|
+
Minimal template for a draggable object :
|
|
10
|
+
It must have 2 divs :
|
|
11
|
+
- One for the whole panel (id="panel"). Attribute dock is mandatory and can have the values "left" or "right"
|
|
12
|
+
- One for the gutter (id="gutter"). This is where the panel can be resized.
|
|
13
|
+
|
|
14
|
+
Example:
|
|
15
|
+
|
|
16
|
+
<div id="panel" dock="left">
|
|
17
|
+
<div id="gutter"></div>
|
|
18
|
+
<div id="hide">
|
|
19
|
+
<i class="fa-solid"></i>
|
|
20
|
+
</div>
|
|
21
|
+
<div id="close">
|
|
22
|
+
<i class="fa-solid"></i>
|
|
23
|
+
</div>
|
|
24
|
+
</div>
|
|
25
|
+
|
|
26
|
+
Then in order to make an component resizable,
|
|
27
|
+
the base method makeResizable() must be called after rendering the template.
|
|
28
|
+
|
|
29
|
+
That's it.
|
|
30
|
+
|
|
31
|
+
*/
|
|
32
|
+
class GirafeResizableElement extends GirafeHTMLElement {
|
|
33
|
+
get host() {
|
|
34
|
+
return this.shadow.getRootNode().host;
|
|
35
|
+
}
|
|
36
|
+
constructor(component) {
|
|
37
|
+
super(component);
|
|
38
|
+
_GirafeResizableElement_instances.add(this);
|
|
39
|
+
Object.defineProperty(this, "panel", {
|
|
40
|
+
enumerable: true,
|
|
41
|
+
configurable: true,
|
|
42
|
+
writable: true,
|
|
43
|
+
value: void 0
|
|
44
|
+
});
|
|
45
|
+
Object.defineProperty(this, "panelRect", {
|
|
46
|
+
enumerable: true,
|
|
47
|
+
configurable: true,
|
|
48
|
+
writable: true,
|
|
49
|
+
value: void 0
|
|
50
|
+
});
|
|
51
|
+
Object.defineProperty(this, "gutter", {
|
|
52
|
+
enumerable: true,
|
|
53
|
+
configurable: true,
|
|
54
|
+
writable: true,
|
|
55
|
+
value: void 0
|
|
56
|
+
});
|
|
57
|
+
Object.defineProperty(this, "hideButton", {
|
|
58
|
+
enumerable: true,
|
|
59
|
+
configurable: true,
|
|
60
|
+
writable: true,
|
|
61
|
+
value: void 0
|
|
62
|
+
});
|
|
63
|
+
Object.defineProperty(this, "closeButton", {
|
|
64
|
+
enumerable: true,
|
|
65
|
+
configurable: true,
|
|
66
|
+
writable: true,
|
|
67
|
+
value: void 0
|
|
68
|
+
});
|
|
69
|
+
// TODO: why not use an enum?
|
|
70
|
+
Object.defineProperty(this, "dock", {
|
|
71
|
+
enumerable: true,
|
|
72
|
+
configurable: true,
|
|
73
|
+
writable: true,
|
|
74
|
+
value: void 0
|
|
75
|
+
});
|
|
76
|
+
Object.defineProperty(this, "prevX", {
|
|
77
|
+
enumerable: true,
|
|
78
|
+
configurable: true,
|
|
79
|
+
writable: true,
|
|
80
|
+
value: 0
|
|
81
|
+
});
|
|
82
|
+
Object.defineProperty(this, "prevY", {
|
|
83
|
+
enumerable: true,
|
|
84
|
+
configurable: true,
|
|
85
|
+
writable: true,
|
|
86
|
+
value: 0
|
|
87
|
+
});
|
|
88
|
+
Object.defineProperty(this, "toggleWidth", {
|
|
89
|
+
enumerable: true,
|
|
90
|
+
configurable: true,
|
|
91
|
+
writable: true,
|
|
92
|
+
value: void 0
|
|
93
|
+
});
|
|
94
|
+
Object.defineProperty(this, "lastWidth", {
|
|
95
|
+
enumerable: true,
|
|
96
|
+
configurable: true,
|
|
97
|
+
writable: true,
|
|
98
|
+
value: 0
|
|
99
|
+
});
|
|
100
|
+
Object.defineProperty(this, "hideWidth", {
|
|
101
|
+
enumerable: true,
|
|
102
|
+
configurable: true,
|
|
103
|
+
writable: true,
|
|
104
|
+
value: 0
|
|
105
|
+
});
|
|
106
|
+
this.dock = this.getAttribute('dock') ?? 'right';
|
|
107
|
+
}
|
|
108
|
+
render() {
|
|
109
|
+
super.render();
|
|
110
|
+
this.makeResizable();
|
|
111
|
+
}
|
|
112
|
+
makeResizable() {
|
|
113
|
+
this.panel = this.shadow.querySelector('#panel');
|
|
114
|
+
this.gutter = this.shadow.querySelector('#gutter');
|
|
115
|
+
this.gutter.onmousedown = (e) => __classPrivateFieldGet(this, _GirafeResizableElement_instances, "m", _GirafeResizableElement_mousedown).call(this, e);
|
|
116
|
+
this.gutter.ondblclick = () => __classPrivateFieldGet(this, _GirafeResizableElement_instances, "m", _GirafeResizableElement_togglePanel).call(this);
|
|
117
|
+
this.hideButton = this.shadow.getElementById('hide');
|
|
118
|
+
if (this.hideButton) {
|
|
119
|
+
this.hideButton.onclick = () => __classPrivateFieldGet(this, _GirafeResizableElement_instances, "m", _GirafeResizableElement_togglePanel).call(this);
|
|
120
|
+
}
|
|
121
|
+
this.closeButton = this.shadow.getElementById('close');
|
|
122
|
+
if (this.closeButton) {
|
|
123
|
+
this.closeButton.onclick = () => this.closePanel();
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
closePanel() {
|
|
127
|
+
throw new Error('This function must be overriden to close the associated panel');
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
_GirafeResizableElement_instances = new WeakSet(), _GirafeResizableElement_mousedown = function _GirafeResizableElement_mousedown(e) {
|
|
131
|
+
e.preventDefault();
|
|
132
|
+
document.onmousemove = (e) => __classPrivateFieldGet(this, _GirafeResizableElement_instances, "m", _GirafeResizableElement_mousemove).call(this, e);
|
|
133
|
+
document.onmouseup = () => __classPrivateFieldGet(this, _GirafeResizableElement_instances, "m", _GirafeResizableElement_mouseup).call(this);
|
|
134
|
+
this.prevX = e.x;
|
|
135
|
+
this.prevY = e.y;
|
|
136
|
+
this.panelRect = this.panel.getBoundingClientRect();
|
|
137
|
+
if (this.hideButton) {
|
|
138
|
+
this.hideWidth = this.hideButton.getBoundingClientRect().width;
|
|
139
|
+
}
|
|
140
|
+
}, _GirafeResizableElement_togglePanel = function _GirafeResizableElement_togglePanel() {
|
|
141
|
+
if (this.dock === 'left' || this.dock === 'right') {
|
|
142
|
+
__classPrivateFieldGet(this, _GirafeResizableElement_instances, "m", _GirafeResizableElement_togglePanelVertically).call(this);
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
__classPrivateFieldGet(this, _GirafeResizableElement_instances, "m", _GirafeResizableElement_togglePanelHorizontally).call(this);
|
|
146
|
+
}
|
|
147
|
+
}, _GirafeResizableElement_togglePanelVertically = function _GirafeResizableElement_togglePanelVertically() {
|
|
148
|
+
if (!this.panel || !this.gutter) {
|
|
149
|
+
throw new Error('GirafeResizableElement.makeResizable() must be called before togglePanelVertically()');
|
|
150
|
+
}
|
|
151
|
+
this.toggleWidth = this.gutter.getBoundingClientRect().width;
|
|
152
|
+
const width = this.panel.getBoundingClientRect().width;
|
|
153
|
+
if (width <= this.toggleWidth) {
|
|
154
|
+
// Panel is already hidden.
|
|
155
|
+
// => We reset it to the last width
|
|
156
|
+
this.panel.style.width = this.lastWidth + 'px';
|
|
157
|
+
this.host.style.width = this.lastWidth + 'px';
|
|
158
|
+
this.panel.style.minWidth = '';
|
|
159
|
+
this.host.style.minWidth = '';
|
|
160
|
+
if (this.hideButton) {
|
|
161
|
+
this.hideButton.classList.remove('closed');
|
|
162
|
+
if (this.dock === 'left') {
|
|
163
|
+
this.hideButton.style.left = this.panel.getBoundingClientRect().width + 'px';
|
|
164
|
+
}
|
|
165
|
+
else if (this.dock === 'right') {
|
|
166
|
+
this.hideButton.style.right = this.panel.getBoundingClientRect().width + 'px';
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
// Hide the panel
|
|
172
|
+
this.lastWidth = width;
|
|
173
|
+
this.panel.style.width = this.toggleWidth + 'px';
|
|
174
|
+
this.host.style.width = this.toggleWidth + 'px';
|
|
175
|
+
this.panel.style.minWidth = '0';
|
|
176
|
+
this.panel.style.overflow = 'hidden';
|
|
177
|
+
this.host.style.minWidth = '0';
|
|
178
|
+
if (this.hideButton) {
|
|
179
|
+
this.hideButton.classList.add('closed');
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}, _GirafeResizableElement_togglePanelHorizontally = function _GirafeResizableElement_togglePanelHorizontally() {
|
|
183
|
+
if (!this.panel || !this.gutter) {
|
|
184
|
+
throw new Error('GirafeResizableElement.makeResizable() must be called before togglePanelHorizontally()');
|
|
185
|
+
}
|
|
186
|
+
this.toggleWidth = this.gutter.getBoundingClientRect().height;
|
|
187
|
+
const height = this.panel.getBoundingClientRect().height;
|
|
188
|
+
if (height <= this.toggleWidth) {
|
|
189
|
+
// Panel is already hidden.
|
|
190
|
+
// => We reset it to the last width
|
|
191
|
+
this.panel.style.height = this.lastWidth + 'px';
|
|
192
|
+
this.host.style.height = this.lastWidth + 'px';
|
|
193
|
+
this.panel.style.minHeight = '';
|
|
194
|
+
this.host.style.minHeight = '';
|
|
195
|
+
if (this.hideButton) {
|
|
196
|
+
this.hideButton.classList.remove('closed');
|
|
197
|
+
if (this.dock === 'bottom') {
|
|
198
|
+
this.hideButton.style.bottom = this.panel.getBoundingClientRect().height + 'px';
|
|
199
|
+
}
|
|
200
|
+
// else if (this.dock === 'right') {
|
|
201
|
+
// this.hideButton.style.right = this.panel.getBoundingClientRect().width + "px";
|
|
202
|
+
// }
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
else {
|
|
206
|
+
// Hide the panel
|
|
207
|
+
this.lastWidth = height;
|
|
208
|
+
this.panel.style.height = this.toggleWidth + 'px';
|
|
209
|
+
this.host.style.height = this.toggleWidth + 'px';
|
|
210
|
+
this.panel.style.minHeight = '0';
|
|
211
|
+
this.panel.style.overflow = 'hidden';
|
|
212
|
+
this.host.style.minHeight = '0';
|
|
213
|
+
if (this.hideButton) {
|
|
214
|
+
this.hideButton.classList.add('closed');
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}, _GirafeResizableElement_mousemove = function _GirafeResizableElement_mousemove(e) {
|
|
218
|
+
if (!this.panel || !this.panelRect) {
|
|
219
|
+
throw new Error('GirafeResizableElement.makeResizable() must be called before this mousemove()');
|
|
220
|
+
}
|
|
221
|
+
e.preventDefault();
|
|
222
|
+
const newX = this.prevX - e.x;
|
|
223
|
+
const newY = this.prevY - e.y;
|
|
224
|
+
if (this.dock === 'left') {
|
|
225
|
+
const newWidth = this.panelRect.width - newX;
|
|
226
|
+
if (this.hideButton) {
|
|
227
|
+
this.hideButton.style.left = this.panel.getBoundingClientRect().width + 'px';
|
|
228
|
+
}
|
|
229
|
+
if (this.closeButton) {
|
|
230
|
+
this.closeButton.style.left = this.panel.getBoundingClientRect().width + 'px';
|
|
231
|
+
}
|
|
232
|
+
this.panel.style.width = newWidth + 'px';
|
|
233
|
+
this.host.style.width = newWidth + 'px';
|
|
234
|
+
}
|
|
235
|
+
else if (this.dock === 'right') {
|
|
236
|
+
const newWidth = this.panelRect.width + newX;
|
|
237
|
+
if (this.hideButton) {
|
|
238
|
+
this.hideButton.style.right = this.panel.getBoundingClientRect().width + 'px';
|
|
239
|
+
}
|
|
240
|
+
if (this.closeButton) {
|
|
241
|
+
this.closeButton.style.right = this.panel.getBoundingClientRect().width + 'px';
|
|
242
|
+
}
|
|
243
|
+
this.panel.style.width = newWidth + 'px';
|
|
244
|
+
this.host.style.width = newWidth + 'px';
|
|
245
|
+
}
|
|
246
|
+
else if (this.dock === 'bottom') {
|
|
247
|
+
const newHeight = this.panelRect.height + newY;
|
|
248
|
+
/*if (!this.isNullOrUndefined(this.hideButton)) {
|
|
249
|
+
this.hideButton.style.bottom = this.panel.getBoundingClientRect().width + "px";
|
|
250
|
+
}*/
|
|
251
|
+
/*if (!this.isNullOrUndefined(this.closeButton)) {
|
|
252
|
+
this.closeButton.style.right = this.panel.getBoundingClientRect().width + "px";
|
|
253
|
+
}*/
|
|
254
|
+
this.panel.style.height = newHeight + 'px';
|
|
255
|
+
this.host.style.height = newHeight + 'px';
|
|
256
|
+
}
|
|
257
|
+
if (this.hideButton) {
|
|
258
|
+
this.hideButton.classList.remove('closed');
|
|
259
|
+
}
|
|
260
|
+
}, _GirafeResizableElement_mouseup = function _GirafeResizableElement_mouseup() {
|
|
261
|
+
// stop moving when mouse button is released:
|
|
262
|
+
document.onmouseup = null;
|
|
263
|
+
document.onmousemove = null;
|
|
264
|
+
};
|
|
265
|
+
export default GirafeResizableElement;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
type Constructor<T> = new (type: string) => T;
|
|
2
|
+
declare class GirafeSingleton {
|
|
3
|
+
private static instances;
|
|
4
|
+
private static initializingSingletons;
|
|
5
|
+
constructor(type: string);
|
|
6
|
+
static getInstance<T>(this: Constructor<T>): T;
|
|
7
|
+
isNullOrUndefined(val: unknown): boolean;
|
|
8
|
+
isNullOrUndefinedOrBlank(val: unknown): boolean;
|
|
9
|
+
}
|
|
10
|
+
export default GirafeSingleton;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
class GirafeSingleton {
|
|
2
|
+
constructor(type) {
|
|
3
|
+
if (!(type in GirafeSingleton.initializingSingletons) || !GirafeSingleton.initializingSingletons[type]) {
|
|
4
|
+
throw new Error('This is a singleton. Please use the getInstance() method.');
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
static getInstance() {
|
|
8
|
+
const type = this.name;
|
|
9
|
+
if (!(type in GirafeSingleton.instances)) {
|
|
10
|
+
// Singleton do not exists
|
|
11
|
+
// => create it
|
|
12
|
+
GirafeSingleton.initializingSingletons[type] = true;
|
|
13
|
+
try {
|
|
14
|
+
// Get the child constructor, and create and instance of the child
|
|
15
|
+
console.log(`Creating Singleton ${type}`);
|
|
16
|
+
const singleton = new this(type);
|
|
17
|
+
GirafeSingleton.instances[type] = singleton;
|
|
18
|
+
}
|
|
19
|
+
finally {
|
|
20
|
+
GirafeSingleton.initializingSingletons[type] = false;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return GirafeSingleton.instances[type];
|
|
24
|
+
}
|
|
25
|
+
isNullOrUndefined(val) {
|
|
26
|
+
return val === undefined || val === null;
|
|
27
|
+
}
|
|
28
|
+
isNullOrUndefinedOrBlank(val) {
|
|
29
|
+
return val === undefined || val === null || val === '';
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
Object.defineProperty(GirafeSingleton, "instances", {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
configurable: true,
|
|
35
|
+
writable: true,
|
|
36
|
+
value: {}
|
|
37
|
+
});
|
|
38
|
+
Object.defineProperty(GirafeSingleton, "initializingSingletons", {
|
|
39
|
+
enumerable: true,
|
|
40
|
+
configurable: true,
|
|
41
|
+
writable: true,
|
|
42
|
+
value: {}
|
|
43
|
+
});
|
|
44
|
+
export default GirafeSingleton;
|
package/base/main.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { default as GirafeDraggableElement } from './GirafeDraggableElement';
|
|
2
|
+
export { default as GirafeHTMLElement } from './GirafeHTMLElement';
|
|
3
|
+
export { default as GirafeResizableElement } from './GirafeResizableElement';
|
|
4
|
+
export { default as GirafeSingleton } from './GirafeSingleton';
|
package/base/main.js
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { default as GirafeDraggableElement } from './GirafeDraggableElement';
|
|
2
|
+
export { default as GirafeHTMLElement } from './GirafeHTMLElement';
|
|
3
|
+
export { default as GirafeResizableElement } from './GirafeResizableElement';
|
|
4
|
+
export { default as GirafeSingleton } from './GirafeSingleton';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { findFilesRecursive, inlineTemplate } from './tools.js';
|
|
4
|
+
|
|
5
|
+
function main() {
|
|
6
|
+
const fileList = findFilesRecursive(path.resolve('src', 'components'), ['.ts', '.js']);
|
|
7
|
+
for (const filepath of fileList) {
|
|
8
|
+
console.info(`Integrating inline HTML for file ${filepath}`);
|
|
9
|
+
const newCode = inlineTemplate(filepath);
|
|
10
|
+
const newFilePath = filepath.replace('src', path.join('dist', 'lib-src-inline'));
|
|
11
|
+
|
|
12
|
+
fs.mkdirSync(path.dirname(newFilePath), { recursive: true });
|
|
13
|
+
fs.writeFileSync(newFilePath, newCode, 'utf-8');
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
main();
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import MagicString from 'magic-string';
|
|
2
|
+
import fs from 'fs-extra';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
|
|
5
|
+
export function findFilesRecursive(sourceDir, allowedExtensions, fileList = []) {
|
|
6
|
+
const childs = fs.readdirSync(sourceDir);
|
|
7
|
+
|
|
8
|
+
childs.forEach((filename) => {
|
|
9
|
+
const src = path.join(sourceDir, filename);
|
|
10
|
+
|
|
11
|
+
if (fs.statSync(src).isDirectory()) {
|
|
12
|
+
findFilesRecursive(src, allowedExtensions, fileList);
|
|
13
|
+
} else {
|
|
14
|
+
const extension = path.extname(filename).toLowerCase();
|
|
15
|
+
if (allowedExtensions.includes(extension)) {
|
|
16
|
+
fileList.push(src);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
return fileList;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function deleteDirectory(sourceDir) {
|
|
25
|
+
if (fs.existsSync(sourceDir)) {
|
|
26
|
+
fs.rmSync(sourceDir, { recursive: true });
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function copy(filename, sourceDir, targetDir) {
|
|
31
|
+
const source = path.join(sourceDir, filename);
|
|
32
|
+
const target = path.join(targetDir, filename);
|
|
33
|
+
|
|
34
|
+
if (fs.existsSync(source)) {
|
|
35
|
+
// First create destination directory
|
|
36
|
+
if (!fs.existsSync(targetDir)) {
|
|
37
|
+
fs.mkdirSync(targetDir);
|
|
38
|
+
}
|
|
39
|
+
// Then copy file
|
|
40
|
+
console.info(`Copying ${filename} to ${target}`);
|
|
41
|
+
fs.copySync(source, target);
|
|
42
|
+
} else {
|
|
43
|
+
console.error(`{source} does not exist.`);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function inlineTemplate(filename) {
|
|
48
|
+
// Read the file
|
|
49
|
+
const code = fs.readFileSync(filename, 'utf8');
|
|
50
|
+
const magicString = new MagicString(code);
|
|
51
|
+
|
|
52
|
+
// Find the HTML template
|
|
53
|
+
const htmlRegex = /templateUrl *= *['"](.*)['"] *;?/;
|
|
54
|
+
if (htmlRegex.test(code)) {
|
|
55
|
+
// Verify if there is a CSS file
|
|
56
|
+
let styleCode = '';
|
|
57
|
+
const styleRegex = /styleUrl *= *['"](.*)['"] *;?/;
|
|
58
|
+
if (styleRegex.test(code)) {
|
|
59
|
+
// Read the CSS file
|
|
60
|
+
const styleFound = code.match(styleRegex);
|
|
61
|
+
const styleFilePath = path.join(path.dirname(filename), styleFound[1]);
|
|
62
|
+
try {
|
|
63
|
+
const styleFileContent = fs.readFileSync(styleFilePath, 'utf8');
|
|
64
|
+
// Convert css notation (for ex \002a) to javascript notation (\u002a)
|
|
65
|
+
styleCode = styleFileContent.replace(/\\([0-9a-fA-F]{4})/g, '\\u$1');
|
|
66
|
+
styleCode = `<style>\n${styleCode}\n</style>`;
|
|
67
|
+
magicString.overwrite(styleFound.index, styleFound.index + styleFound[0].length, '');
|
|
68
|
+
} catch (error) {
|
|
69
|
+
console.error(`Error reading style file for ${filename}: ${error}`);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// Read HTML template
|
|
74
|
+
const htmlFound = code.match(htmlRegex);
|
|
75
|
+
const htmlFilePath = path.join(path.dirname(filename), htmlFound[1]);
|
|
76
|
+
try {
|
|
77
|
+
const htmlFileContent = fs.readFileSync(htmlFilePath, 'utf8');
|
|
78
|
+
const htmlCode = `template = () => { return uHtml\`${styleCode}\n${htmlFileContent}\`; }`;
|
|
79
|
+
magicString.overwrite(htmlFound.index, htmlFound.index + htmlFound[0].length, htmlCode);
|
|
80
|
+
} catch (error) {
|
|
81
|
+
console.error(`Error reading HTML file for ${filename}: ${error}`);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// Add missing import (uHtml)
|
|
85
|
+
magicString.prepend(`import { html as uHtml } from 'uhtml';\n`);
|
|
86
|
+
|
|
87
|
+
// Return the new code with inline HTML template
|
|
88
|
+
const newCode = magicString.toString();
|
|
89
|
+
return newCode;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// No template to integrate, just return the initial content
|
|
93
|
+
return code;
|
|
94
|
+
}
|