@tekkare/romulus 0.1.369 → 0.1.371
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/dist/module.json
CHANGED
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
| `results` | - | prop morte : aucune carte ne la lisait |
|
|
35
35
|
-->
|
|
36
36
|
<script setup lang="ts">
|
|
37
|
-
import { computed, onBeforeUnmount, ref, watch } from 'vue'
|
|
37
|
+
import { computed, nextTick, onBeforeUnmount, ref, watch } from 'vue'
|
|
38
38
|
import { RM_GEOGRAPHIES, type RmGeoShape } from '../internal/geo'
|
|
39
39
|
import { useChartTheme } from '../composables/useChartTheme'
|
|
40
40
|
|
|
@@ -64,6 +64,12 @@ const props = withDefaults(
|
|
|
64
64
|
reverseColors?: boolean
|
|
65
65
|
/** Resserre le cadrage sur la partie continentale. */
|
|
66
66
|
compact?: boolean
|
|
67
|
+
/**
|
|
68
|
+
* Zones a cadrer, nommees comme la geographie les nomme (les departements
|
|
69
|
+
* d'une region, par exemple). La carte se resserre sur leur emprise ; les
|
|
70
|
+
* autres zones restent dessinees autour. Vide ou absent : tout le pays.
|
|
71
|
+
*/
|
|
72
|
+
focus?: string[] | null
|
|
67
73
|
/** Hauteur du dessin, en pixels. */
|
|
68
74
|
height?: number
|
|
69
75
|
lang?: 'fr' | 'en'
|
|
@@ -79,6 +85,7 @@ const props = withDefaults(
|
|
|
79
85
|
source: null,
|
|
80
86
|
reverseColors: false,
|
|
81
87
|
compact: false,
|
|
88
|
+
focus: null,
|
|
82
89
|
height: 500,
|
|
83
90
|
lang: 'fr',
|
|
84
91
|
valueFormatter: undefined,
|
|
@@ -115,10 +122,51 @@ watch(
|
|
|
115
122
|
{ immediate: true },
|
|
116
123
|
)
|
|
117
124
|
|
|
118
|
-
const
|
|
125
|
+
const baseViewBox = computed(() =>
|
|
119
126
|
(props.compact ? geography.value?.compactViewBox : null) ?? geography.value?.viewBox ?? '0 0 100 100',
|
|
120
127
|
)
|
|
121
128
|
|
|
129
|
+
/**
|
|
130
|
+
* Cadrage sur `focus` : l'emprise des zones nommees, lue sur les traces une
|
|
131
|
+
* fois dessines (getBBox), avec une marge. Le trait garde son epaisseur a
|
|
132
|
+
* l'ecran : il est reduit dans le rapport du zoom.
|
|
133
|
+
*/
|
|
134
|
+
const svgRef = ref<SVGSVGElement | null>(null)
|
|
135
|
+
const focusBox = ref<{ x: number; y: number; w: number; h: number } | null>(null)
|
|
136
|
+
|
|
137
|
+
async function frameFocus() {
|
|
138
|
+
focusBox.value = null
|
|
139
|
+
const names = new Set((props.focus ?? []).map(n => n.normalize('NFC')))
|
|
140
|
+
if (!names.size || loading.value) return
|
|
141
|
+
await nextTick()
|
|
142
|
+
const svg = svgRef.value
|
|
143
|
+
if (!svg) return
|
|
144
|
+
let x0 = Infinity, y0 = Infinity, x1 = -Infinity, y1 = -Infinity
|
|
145
|
+
for (const el of svg.querySelectorAll<SVGPathElement>('path[data-name]')) {
|
|
146
|
+
if (!names.has(String(el.dataset.name).normalize('NFC'))) continue
|
|
147
|
+
const b = el.getBBox()
|
|
148
|
+
x0 = Math.min(x0, b.x); y0 = Math.min(y0, b.y)
|
|
149
|
+
x1 = Math.max(x1, b.x + b.width); y1 = Math.max(y1, b.y + b.height)
|
|
150
|
+
}
|
|
151
|
+
if (x0 === Infinity) return
|
|
152
|
+
const pad = Math.max(x1 - x0, y1 - y0) * 0.06
|
|
153
|
+
focusBox.value = { x: x0 - pad, y: y0 - pad, w: x1 - x0 + 2 * pad, h: y1 - y0 + 2 * pad }
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
watch([() => (props.focus ?? []).join('|'), loading, () => props.geography], frameFocus, { immediate: true })
|
|
157
|
+
|
|
158
|
+
const viewBox = computed(() => {
|
|
159
|
+
const f = focusBox.value
|
|
160
|
+
return f ? `${f.x} ${f.y} ${f.w} ${f.h}` : baseViewBox.value
|
|
161
|
+
})
|
|
162
|
+
|
|
163
|
+
const strokeWidth = computed(() => {
|
|
164
|
+
const f = focusBox.value
|
|
165
|
+
if (!f) return 1
|
|
166
|
+
const baseWidth = Number(baseViewBox.value.split(/\s+/)[2]) || f.w
|
|
167
|
+
return Math.max(f.w, f.h) / baseWidth
|
|
168
|
+
})
|
|
169
|
+
|
|
122
170
|
const values = computed(() =>
|
|
123
171
|
props.data.filter(d => d.value !== null && d.value !== undefined).map(d => Number(d.value)),
|
|
124
172
|
)
|
|
@@ -243,14 +291,15 @@ const fmt = computed(() =>
|
|
|
243
291
|
|
|
244
292
|
<div class="rm-choro__plot" :style="{ height: `${height}px` }">
|
|
245
293
|
<RmSkeleton v-if="loading" height="100%" />
|
|
246
|
-
<svg v-else class="rm-choro__svg" :viewBox="viewBox" preserveAspectRatio="xMidYMid meet">
|
|
294
|
+
<svg v-else ref="svgRef" class="rm-choro__svg" :viewBox="viewBox" preserveAspectRatio="xMidYMid meet">
|
|
247
295
|
<path
|
|
248
296
|
v-for="(shape, name) in shapes"
|
|
249
297
|
:key="name"
|
|
298
|
+
:data-name="name"
|
|
250
299
|
:d="shape.path"
|
|
251
300
|
:fill="colorOf(String(name))"
|
|
252
301
|
:stroke="colorOf(String(name)) === NO_DATA ? 'var(--border-default)' : colorOf(String(name))"
|
|
253
|
-
stroke-width="
|
|
302
|
+
:stroke-width="strokeWidth"
|
|
254
303
|
class="rm-choro__shape"
|
|
255
304
|
:class="{ 'rm-choro__shape--dimmed': hovered !== null && hovered !== name }"
|
|
256
305
|
@mouseenter="onEnter(String(name), $event)"
|
|
@@ -87,6 +87,12 @@ const props = withDefaults(
|
|
|
87
87
|
* ranger, `active` pour l'entree ouverte).
|
|
88
88
|
*/
|
|
89
89
|
subPart?: { label: string; to: string; menu?: { label: string; to: string; icon?: string; group?: string; active?: boolean }[] } | null;
|
|
90
|
+
/**
|
|
91
|
+
* false : le fil s'arrete a la partie (ou au sous-maillon), sans la page
|
|
92
|
+
* ouverte ni la page d'origine. Pour une partie ou l'on ne choisit que le
|
|
93
|
+
* sous-maillon (un theme), la barre gauche portant les pages.
|
|
94
|
+
*/
|
|
95
|
+
pageCrumbs?: boolean;
|
|
90
96
|
/** Sections de la barre gauche depliees par defaut. */
|
|
91
97
|
navDefaultOpen?: boolean;
|
|
92
98
|
/** Remplace app.config.oip.home quand le maillon pays est dynamique. */
|
|
@@ -117,7 +123,7 @@ const props = withDefaults(
|
|
|
117
123
|
*/
|
|
118
124
|
panelProps?: Partial<Record<OipRailTileKey, Record<string, unknown>>>;
|
|
119
125
|
}>(),
|
|
120
|
-
{ flag: "fr", appKey: "", part: null, partLinks: () => ({}), partMenu: null, subPart: null, navDefaultOpen: false, home: undefined, tiles: () => ({}), superAdmin: false, userName: "", hideTabs: false, panelProps: () => ({}) },
|
|
126
|
+
{ flag: "fr", appKey: "", part: null, partLinks: () => ({}), partMenu: null, subPart: null, pageCrumbs: true, navDefaultOpen: false, home: undefined, tiles: () => ({}), superAdmin: false, userName: "", hideTabs: false, panelProps: () => ({}) },
|
|
121
127
|
);
|
|
122
128
|
|
|
123
129
|
/** Tuile ouverte, ou null quand la toolbar est fermee. */
|
|
@@ -315,10 +321,10 @@ const crumbs = computed(() => {
|
|
|
315
321
|
? [{ label: props.subPart.label, to: props.subPart.to, ...(props.subPart.menu?.length ? { menu: props.subPart.menu } : {}) }]
|
|
316
322
|
: []),
|
|
317
323
|
// Sur une fiche, la page d'origine reste dans le fil avant elle.
|
|
318
|
-
...(activeItem.value || !originPage.value || !props.sections.length
|
|
324
|
+
...(!props.pageCrumbs || activeItem.value || !originPage.value || !props.sections.length
|
|
319
325
|
? []
|
|
320
326
|
: [{ label: originPage.value.label, to: originPage.value.to, menu: pageMenu.value }]),
|
|
321
|
-
...(props.sections.length && activeLabel.value
|
|
327
|
+
...(props.pageCrumbs && props.sections.length && activeLabel.value
|
|
322
328
|
? [{ label: activeLabel.value, ...(activeItem.value ? { menu: pageMenu.value } : {}) }]
|
|
323
329
|
: []),
|
|
324
330
|
];
|