@fmidev/smartmet-alert-client 4.4.19 → 4.7.0-beta.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/.eslintignore +2 -14
- package/.github/workflows/test.yaml +26 -0
- package/.nvmrc +1 -0
- package/AGENTS.md +26 -0
- package/index.html +1 -1
- package/package.json +80 -22
- package/src/AlertClientVue.vue +160 -0
- package/src/App.vue +154 -296
- package/src/assets/img/ui/arrow-down.svg +4 -11
- package/src/assets/img/ui/arrow-up.svg +4 -11
- package/src/assets/img/ui/clear.svg +7 -21
- package/src/assets/img/ui/close.svg +4 -15
- package/src/assets/img/ui/toggle-selected.svg +5 -6
- package/src/assets/img/ui/toggle-unselected.svg +5 -6
- package/src/assets/img/warning/cold-weather.svg +3 -6
- package/src/assets/img/warning/flood-level-3.svg +4 -7
- package/src/assets/img/warning/forest-fire-weather.svg +2 -6
- package/src/assets/img/warning/grass-fire-weather.svg +2 -6
- package/src/assets/img/warning/hot-weather.svg +3 -6
- package/src/assets/img/warning/pedestrian-safety.svg +3 -7
- package/src/assets/img/warning/rain.svg +2 -7
- package/src/assets/img/warning/sea-icing.svg +2 -6
- package/src/assets/img/warning/sea-thunder-storm.svg +2 -5
- package/src/assets/img/warning/sea-water-height-high-water.svg +3 -8
- package/src/assets/img/warning/sea-water-height-shallow-water.svg +3 -7
- package/src/assets/img/warning/sea-wave-height.svg +4 -7
- package/src/assets/img/warning/sea-wind-legend.svg +2 -5
- package/src/assets/img/warning/sea-wind.svg +2 -5
- package/src/assets/img/warning/several.svg +2 -5
- package/src/assets/img/warning/thunder-storm.svg +2 -5
- package/src/assets/img/warning/traffic-weather.svg +2 -6
- package/src/assets/img/warning/uv-note.svg +2 -6
- package/src/assets/img/warning/wind.svg +2 -5
- package/src/components/AlertClient.vue +330 -251
- package/src/components/CollapsiblePanel.vue +281 -0
- package/src/components/DayLarge.vue +146 -110
- package/src/components/DaySmall.vue +97 -81
- package/src/components/Days.vue +229 -159
- package/src/components/DescriptionWarning.vue +63 -38
- package/src/components/GrayScaleToggle.vue +58 -54
- package/src/components/Legend.vue +102 -325
- package/src/components/MapLarge.vue +574 -351
- package/src/components/MapSmall.vue +137 -122
- package/src/components/PopupRow.vue +24 -12
- package/src/components/Region.vue +168 -118
- package/src/components/RegionWarning.vue +40 -33
- package/src/components/Regions.vue +189 -105
- package/src/components/Warning.vue +70 -45
- package/src/components/Warnings.vue +136 -72
- package/src/composables/useAlertClient.ts +360 -0
- package/src/composables/useConfig.ts +573 -0
- package/src/composables/useFields.ts +66 -0
- package/src/composables/useI18n.ts +62 -0
- package/src/composables/useKeyCodes.ts +16 -0
- package/src/composables/useMapPaths.ts +477 -0
- package/src/composables/useUtils.ts +683 -0
- package/src/composables/useWarningsProcessor.ts +1007 -0
- package/src/data/geometries.json +993 -0
- package/src/{main.js → main.ts} +1 -0
- package/src/mixins/geojsonsvg.d.ts +57 -0
- package/src/mixins/geojsonsvg.js +5 -3
- package/src/plugins/index.ts +5 -0
- package/src/scss/_utilities.scss +193 -0
- package/src/scss/constants.scss +2 -1
- package/src/scss/warningImages.scss +8 -3
- package/src/types/index.ts +509 -0
- package/src/vite-env.d.ts +23 -0
- package/src/vue.ts +41 -0
- package/svgo.config.js +45 -0
- package/tests/README.md +430 -0
- package/tests/fixtures/mockWarningData.ts +152 -0
- package/tests/integration/warning-flow.spec.ts +445 -0
- package/tests/setup.ts +41 -0
- package/tests/unit/components/AlertClient.spec.ts +701 -0
- package/tests/unit/components/DayLarge.spec.ts +348 -0
- package/tests/unit/components/DaySmall.spec.ts +352 -0
- package/tests/unit/components/Days.spec.ts +548 -0
- package/tests/unit/components/DescriptionWarning.spec.ts +385 -0
- package/tests/unit/components/GrayScaleToggle.spec.ts +318 -0
- package/tests/unit/components/Legend.spec.ts +295 -0
- package/tests/unit/components/MapLarge.spec.ts +448 -0
- package/tests/unit/components/MapSmall.spec.ts +367 -0
- package/tests/unit/components/PopupRow.spec.ts +270 -0
- package/tests/unit/components/Region.spec.ts +373 -0
- package/tests/unit/components/RegionWarning.snapshot.spec.ts +361 -0
- package/tests/unit/components/RegionWarning.spec.ts +381 -0
- package/tests/unit/components/Regions.spec.ts +503 -0
- package/tests/unit/components/Warning.snapshot.spec.ts +483 -0
- package/tests/unit/components/Warning.spec.ts +489 -0
- package/tests/unit/components/Warnings.spec.ts +343 -0
- package/tests/unit/components/__snapshots__/RegionWarning.snapshot.spec.ts.snap +41 -0
- package/tests/unit/components/__snapshots__/Warning.snapshot.spec.ts.snap +433 -0
- package/tests/unit/composables/useConfig.spec.ts +279 -0
- package/tests/unit/composables/useI18n.spec.ts +116 -0
- package/tests/unit/composables/useKeyCodes.spec.ts +27 -0
- package/tests/unit/composables/useUtils.spec.ts +213 -0
- package/tsconfig.json +43 -0
- package/tsconfig.node.json +11 -0
- package/vite.config.js +96 -26
- package/vitest.config.js +40 -0
- package/dist/favicon.ico +0 -0
- package/dist/index.dark.html +0 -20
- package/dist/index.en.html +0 -15
- package/dist/index.fi.html +0 -15
- package/dist/index.html +0 -15
- package/dist/index.js +0 -281
- package/dist/index.mjs +0 -281
- package/dist/index.mjs.map +0 -1
- package/dist/index.relative.html +0 -19
- package/dist/index.start.html +0 -20
- package/dist/index.sv.html +0 -15
- package/playwright.config.ts +0 -18
- package/public/index.relative.html +0 -19
- package/public/index.start.html +0 -20
- package/src/mixins/config.js +0 -1378
- package/src/mixins/fields.js +0 -26
- package/src/mixins/i18n.js +0 -25
- package/src/mixins/keycodes.js +0 -10
- package/src/mixins/panzoom.js +0 -900
- package/src/mixins/utils.js +0 -900
- package/src/plugins/index.js +0 -3
- package/test/snapshot.test.ts +0 -126
- package/vitest.config.ts +0 -6
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
:opacity="path.opacity" />
|
|
22
22
|
<path
|
|
23
23
|
v-for="path in seaBorders"
|
|
24
|
-
class="border-path"
|
|
25
24
|
:key="path.key"
|
|
25
|
+
class="border-path"
|
|
26
26
|
:stroke="strokeColor"
|
|
27
27
|
:stroke-width="path.strokeWidth"
|
|
28
28
|
:d="path.d"
|
|
@@ -95,10 +95,10 @@
|
|
|
95
95
|
fill-opacity="0" />
|
|
96
96
|
<path
|
|
97
97
|
v-for="path in landBorders"
|
|
98
|
-
class="border-path"
|
|
99
98
|
:key="path.key"
|
|
99
|
+
class="border-path"
|
|
100
100
|
:stroke="strokeColor"
|
|
101
|
-
:stroke-width="1.5*path.strokeWidth"
|
|
101
|
+
:stroke-width="1.5 * Number(path.strokeWidth)"
|
|
102
102
|
:d="path.d"
|
|
103
103
|
fill-opacity="0" />
|
|
104
104
|
<path
|
|
@@ -115,126 +115,141 @@
|
|
|
115
115
|
</div>
|
|
116
116
|
</template>
|
|
117
117
|
|
|
118
|
-
<script>
|
|
119
|
-
import { onMounted, onUnmounted,
|
|
120
|
-
|
|
121
|
-
import
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
if (
|
|
210
|
-
options.severity == null ||
|
|
211
|
-
visualization.severity === options.severity
|
|
212
|
-
) {
|
|
213
|
-
regions.push({
|
|
214
|
-
key: `${regionId}${this.size}${this.index}Path`,
|
|
215
|
-
fill: this.loading
|
|
216
|
-
? this.colors[this.theme].missing
|
|
217
|
-
: visualization.color,
|
|
218
|
-
d: visualization.geom.pathSmall,
|
|
219
|
-
opacity: visualization.visible ? '1' : '0',
|
|
220
|
-
strokeWidth:
|
|
221
|
-
this.geometries[this.geometryId][regionId].type === 'sea' &&
|
|
222
|
-
this.geometries[this.geometryId][regionId].subType !==
|
|
223
|
-
'lake'
|
|
224
|
-
? this.strokeWidth
|
|
225
|
-
: 0,
|
|
226
|
-
})
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
return regions
|
|
230
|
-
}, [])
|
|
231
|
-
: []
|
|
232
|
-
},
|
|
233
|
-
isFullMode() {
|
|
234
|
-
return true;
|
|
235
|
-
},
|
|
236
|
-
},
|
|
118
|
+
<script setup lang="ts">
|
|
119
|
+
import { ref, computed, watch, onMounted, onUnmounted, toRef } from 'vue'
|
|
120
|
+
import type { DayRegions, WarningsMap, Theme } from '@/types'
|
|
121
|
+
import { useMapPaths } from '@/composables/useMapPaths'
|
|
122
|
+
|
|
123
|
+
// ============================================================================
|
|
124
|
+
// Props
|
|
125
|
+
// ============================================================================
|
|
126
|
+
|
|
127
|
+
const props = withDefaults(
|
|
128
|
+
defineProps<{
|
|
129
|
+
index?: number
|
|
130
|
+
input?: DayRegions
|
|
131
|
+
visibleWarnings?: string[]
|
|
132
|
+
warnings?: WarningsMap | null
|
|
133
|
+
geometryId?: number
|
|
134
|
+
loading?: boolean
|
|
135
|
+
theme?: Theme | string
|
|
136
|
+
}>(),
|
|
137
|
+
{
|
|
138
|
+
index: 0,
|
|
139
|
+
input: () => ({}) as DayRegions,
|
|
140
|
+
visibleWarnings: () => [],
|
|
141
|
+
warnings: null,
|
|
142
|
+
geometryId: 2021,
|
|
143
|
+
loading: true,
|
|
144
|
+
theme: 'light-theme',
|
|
145
|
+
}
|
|
146
|
+
)
|
|
147
|
+
|
|
148
|
+
// ============================================================================
|
|
149
|
+
// Local State
|
|
150
|
+
// ============================================================================
|
|
151
|
+
|
|
152
|
+
const windowWidth = ref<number>(
|
|
153
|
+
typeof window !== 'undefined' ? window.innerWidth : 0
|
|
154
|
+
)
|
|
155
|
+
const pathsNeeded = ref<boolean>(false)
|
|
156
|
+
const strokeWidthValue = ref<number>(0.6)
|
|
157
|
+
|
|
158
|
+
// ============================================================================
|
|
159
|
+
// Computed refs for composable
|
|
160
|
+
// ============================================================================
|
|
161
|
+
|
|
162
|
+
const size = computed<'Large' | 'Small'>(() => 'Small')
|
|
163
|
+
const indexRef = toRef(props, 'index')
|
|
164
|
+
const inputRef = toRef(props, 'input')
|
|
165
|
+
const warningsRef = toRef(props, 'warnings')
|
|
166
|
+
const visibleWarningsRef = toRef(props, 'visibleWarnings')
|
|
167
|
+
const geometryIdRef = toRef(props, 'geometryId')
|
|
168
|
+
const themeRef = toRef(props, 'theme')
|
|
169
|
+
const loadingRef = toRef(props, 'loading')
|
|
170
|
+
|
|
171
|
+
// ============================================================================
|
|
172
|
+
// Composables
|
|
173
|
+
// ============================================================================
|
|
174
|
+
|
|
175
|
+
const {
|
|
176
|
+
strokeColor,
|
|
177
|
+
bluePaths,
|
|
178
|
+
greenPaths,
|
|
179
|
+
yellowPaths,
|
|
180
|
+
orangePaths,
|
|
181
|
+
redPaths,
|
|
182
|
+
overlayPaths,
|
|
183
|
+
landBorders,
|
|
184
|
+
seaBorders,
|
|
185
|
+
yellowCoverages,
|
|
186
|
+
orangeCoverages,
|
|
187
|
+
redCoverages,
|
|
188
|
+
overlayCoverages,
|
|
189
|
+
coverageRegions,
|
|
190
|
+
coverageWarnings,
|
|
191
|
+
} = useMapPaths({
|
|
192
|
+
size,
|
|
193
|
+
index: indexRef,
|
|
194
|
+
input: inputRef,
|
|
195
|
+
warnings: warningsRef,
|
|
196
|
+
visibleWarnings: visibleWarningsRef,
|
|
197
|
+
geometryId: geometryIdRef,
|
|
198
|
+
theme: themeRef,
|
|
199
|
+
loading: loadingRef,
|
|
200
|
+
strokeWidth: strokeWidthValue,
|
|
201
|
+
})
|
|
202
|
+
|
|
203
|
+
// ============================================================================
|
|
204
|
+
// Methods
|
|
205
|
+
// ============================================================================
|
|
206
|
+
|
|
207
|
+
function updateWidth(): void {
|
|
208
|
+
windowWidth.value = window.innerWidth
|
|
237
209
|
}
|
|
210
|
+
|
|
211
|
+
function isFullMode(): boolean {
|
|
212
|
+
return true
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// ============================================================================
|
|
216
|
+
// Watchers
|
|
217
|
+
// ============================================================================
|
|
218
|
+
|
|
219
|
+
watch(windowWidth, () => {
|
|
220
|
+
pathsNeeded.value = isFullMode()
|
|
221
|
+
})
|
|
222
|
+
|
|
223
|
+
watch(
|
|
224
|
+
() => props.input,
|
|
225
|
+
() => {
|
|
226
|
+
coverageRegions.value = {}
|
|
227
|
+
coverageWarnings.value = []
|
|
228
|
+
}
|
|
229
|
+
)
|
|
230
|
+
|
|
231
|
+
// ============================================================================
|
|
232
|
+
// Lifecycle
|
|
233
|
+
// ============================================================================
|
|
234
|
+
|
|
235
|
+
onMounted(() => {
|
|
236
|
+
window.addEventListener('resize', updateWidth)
|
|
237
|
+
pathsNeeded.value = isFullMode()
|
|
238
|
+
})
|
|
239
|
+
|
|
240
|
+
onUnmounted(() => {
|
|
241
|
+
window.removeEventListener('resize', updateWidth)
|
|
242
|
+
})
|
|
243
|
+
|
|
244
|
+
// ============================================================================
|
|
245
|
+
// Expose for testing
|
|
246
|
+
// ============================================================================
|
|
247
|
+
|
|
248
|
+
defineExpose({
|
|
249
|
+
size,
|
|
250
|
+
strokeWidth: strokeWidthValue,
|
|
251
|
+
pathsNeeded,
|
|
252
|
+
})
|
|
238
253
|
</script>
|
|
239
254
|
|
|
240
255
|
<style scoped lang="scss">
|
|
@@ -26,19 +26,31 @@
|
|
|
26
26
|
</div>
|
|
27
27
|
</template>
|
|
28
28
|
|
|
29
|
-
<script>
|
|
30
|
-
import
|
|
29
|
+
<script setup lang="ts">
|
|
30
|
+
import { toRef } from 'vue'
|
|
31
|
+
import { useFields } from '@/composables/useFields'
|
|
32
|
+
import type { PopupRowInput } from '@/types'
|
|
31
33
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
34
|
+
// Props
|
|
35
|
+
const props = withDefaults(
|
|
36
|
+
defineProps<{
|
|
37
|
+
input?: PopupRowInput
|
|
38
|
+
}>(),
|
|
39
|
+
{
|
|
40
|
+
input: () => ({
|
|
41
|
+
type: '',
|
|
42
|
+
severity: 0,
|
|
43
|
+
direction: 0,
|
|
44
|
+
text: '',
|
|
45
|
+
interval: '',
|
|
46
|
+
}),
|
|
47
|
+
}
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
// Composables
|
|
51
|
+
const { typeClass, rotation, invertedRotation, severity } = useFields(
|
|
52
|
+
toRef(props, 'input')
|
|
53
|
+
)
|
|
42
54
|
</script>
|
|
43
55
|
|
|
44
56
|
<style scoped lang="scss">
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<h3>
|
|
3
3
|
<button
|
|
4
|
+
:id="`accordion-${code}`"
|
|
4
5
|
type="button"
|
|
5
6
|
:aria-expanded="open"
|
|
6
7
|
:class="['accordion-trigger', 'focus-ring', open ? '' : 'collapsed']"
|
|
7
8
|
:aria-controls="`accordion-section-${code}`"
|
|
8
|
-
:id="`accordion-${code}`"
|
|
9
9
|
:aria-label="ariaButton"
|
|
10
10
|
@click="onRegionToggle">
|
|
11
11
|
<div class="region-header">
|
|
@@ -15,15 +15,13 @@
|
|
|
15
15
|
<div>
|
|
16
16
|
<RegionWarning
|
|
17
17
|
v-for="warning in warningsSummary"
|
|
18
|
-
:key="warning.
|
|
18
|
+
:key="warning.id"
|
|
19
19
|
:input="warning"
|
|
20
20
|
:language="language">
|
|
21
21
|
</RegionWarning>
|
|
22
22
|
</div>
|
|
23
23
|
</div>
|
|
24
|
-
<div
|
|
25
|
-
block
|
|
26
|
-
:class="['current-warning-toggle', open ? '' : 'collapsed']" />
|
|
24
|
+
<div block :class="['current-warning-toggle', open ? '' : 'collapsed']" />
|
|
27
25
|
</button>
|
|
28
26
|
</h3>
|
|
29
27
|
<div
|
|
@@ -32,128 +30,161 @@
|
|
|
32
30
|
:aria-labelledby="`accordion-${code}`"
|
|
33
31
|
:aria-expanded="open"
|
|
34
32
|
class="accordion-panel"
|
|
35
|
-
:hidden="open ?
|
|
36
|
-
>
|
|
33
|
+
:hidden="open ? undefined : ''">
|
|
37
34
|
<div class="current-description">
|
|
38
35
|
<div class="current-description-table">
|
|
39
36
|
<DescriptionWarning
|
|
40
37
|
v-for="warning in reducedWarnings"
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
/>
|
|
38
|
+
:key="warning.id"
|
|
39
|
+
:input="warning"
|
|
40
|
+
:theme="theme"
|
|
41
|
+
:language="language" />
|
|
46
42
|
</div>
|
|
47
43
|
</div>
|
|
48
44
|
</div>
|
|
49
45
|
</template>
|
|
50
46
|
|
|
51
|
-
<script>
|
|
52
|
-
import
|
|
53
|
-
import
|
|
47
|
+
<script setup lang="ts">
|
|
48
|
+
import { ref, computed, toRef } from 'vue'
|
|
49
|
+
import { useI18n } from '@/composables/useI18n'
|
|
50
|
+
import { useConfig } from '@/composables/useConfig'
|
|
54
51
|
import DescriptionWarning from './DescriptionWarning.vue'
|
|
55
52
|
import RegionWarning from './RegionWarning.vue'
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
53
|
+
import type {
|
|
54
|
+
Warning,
|
|
55
|
+
WarningsMap,
|
|
56
|
+
RegionWarningItem,
|
|
57
|
+
Theme,
|
|
58
|
+
Language,
|
|
59
|
+
} from '@/types'
|
|
60
|
+
|
|
61
|
+
// ============================================================================
|
|
62
|
+
// Props
|
|
63
|
+
// ============================================================================
|
|
64
|
+
|
|
65
|
+
const props = withDefaults(
|
|
66
|
+
defineProps<{
|
|
67
|
+
type?: string
|
|
68
|
+
code?: string
|
|
69
|
+
name?: string
|
|
70
|
+
input?: RegionWarningItem[]
|
|
71
|
+
warnings?: WarningsMap | null
|
|
72
|
+
theme?: Theme | string
|
|
73
|
+
language?: Language
|
|
74
|
+
}>(),
|
|
75
|
+
{
|
|
76
|
+
type: undefined,
|
|
77
|
+
code: undefined,
|
|
78
|
+
name: undefined,
|
|
79
|
+
input: () => [],
|
|
80
|
+
warnings: null,
|
|
81
|
+
theme: 'light-theme',
|
|
82
|
+
language: undefined,
|
|
83
|
+
}
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
// ============================================================================
|
|
87
|
+
// Composables
|
|
88
|
+
// ============================================================================
|
|
89
|
+
|
|
90
|
+
const { t } = useI18n(toRef(() => props.language))
|
|
91
|
+
const { coverageCriterion } = useConfig()
|
|
92
|
+
|
|
93
|
+
// ============================================================================
|
|
94
|
+
// State
|
|
95
|
+
// ============================================================================
|
|
96
|
+
|
|
97
|
+
const open = ref<boolean>(false)
|
|
98
|
+
|
|
99
|
+
// ============================================================================
|
|
100
|
+
// Computed Properties
|
|
101
|
+
// ============================================================================
|
|
102
|
+
|
|
103
|
+
const identifier = computed<string>(() => {
|
|
104
|
+
return `accordion-item-${props.code}`
|
|
105
|
+
})
|
|
106
|
+
|
|
107
|
+
const regionName = computed<string>(() => {
|
|
108
|
+
return t(props.name)
|
|
109
|
+
})
|
|
110
|
+
|
|
111
|
+
const warningsSummary = computed<Warning[]>(() => {
|
|
112
|
+
return props.input.reduce((summaryWarnings: Warning[], warningInfo) => {
|
|
113
|
+
const firstIdentifier = warningInfo?.identifiers?.[0]
|
|
114
|
+
if (
|
|
115
|
+
warningInfo != null &&
|
|
116
|
+
firstIdentifier != null &&
|
|
117
|
+
warningInfo.coverage >= coverageCriterion
|
|
118
|
+
) {
|
|
119
|
+
const warning = props.warnings?.[firstIdentifier]
|
|
120
|
+
if (warning != null) {
|
|
121
|
+
summaryWarnings.push(warning)
|
|
122
|
+
}
|
|
90
123
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
if (warning != null) {
|
|
109
|
-
summaryWarnings.push(warning)
|
|
124
|
+
return summaryWarnings
|
|
125
|
+
}, [])
|
|
126
|
+
})
|
|
127
|
+
|
|
128
|
+
const reducedWarnings = computed<Warning[]>(() => {
|
|
129
|
+
return props.input.reduce(
|
|
130
|
+
(allWarnings: Warning[], warningInfo) =>
|
|
131
|
+
allWarnings.concat(
|
|
132
|
+
warningInfo.identifiers.reduce((identifiers: Warning[], identifier) => {
|
|
133
|
+
const warning = props.warnings?.[identifier]
|
|
134
|
+
if (
|
|
135
|
+
warning != null &&
|
|
136
|
+
warningsSummary.value.some(
|
|
137
|
+
(summaryWarning) => summaryWarning.type === warning.type
|
|
138
|
+
)
|
|
139
|
+
) {
|
|
140
|
+
identifiers.push(warning)
|
|
110
141
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
}
|
|
142
|
+
return identifiers
|
|
143
|
+
}, [])
|
|
144
|
+
),
|
|
145
|
+
[]
|
|
146
|
+
)
|
|
147
|
+
})
|
|
148
|
+
|
|
149
|
+
const ariaButton = computed<string>(() => {
|
|
150
|
+
return `${
|
|
151
|
+
open.value
|
|
152
|
+
? t('infoButtonAriaLabelCloseRegion')
|
|
153
|
+
: t('infoButtonAriaLabelShowRegion')
|
|
154
|
+
} ${regionName.value} ${t('infoButtonAriaLabelValidWarnings')}`
|
|
155
|
+
})
|
|
156
|
+
|
|
157
|
+
const ariaInfo = computed<string[]>(() => {
|
|
158
|
+
return reducedWarnings.value.map(
|
|
159
|
+
(warning, index) =>
|
|
160
|
+
`${index > 0 ? ' ' : ''}${t(warning.type)}: ${t(
|
|
161
|
+
`warningLevel${warning.severity}`
|
|
162
|
+
)}.`
|
|
163
|
+
)
|
|
164
|
+
})
|
|
165
|
+
|
|
166
|
+
// ============================================================================
|
|
167
|
+
// Methods
|
|
168
|
+
// ============================================================================
|
|
169
|
+
|
|
170
|
+
const onRegionToggle = (): void => {
|
|
171
|
+
open.value = !open.value
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// ============================================================================
|
|
175
|
+
// Expose for tests
|
|
176
|
+
// ============================================================================
|
|
177
|
+
|
|
178
|
+
defineExpose({
|
|
179
|
+
open,
|
|
180
|
+
identifier,
|
|
181
|
+
regionName,
|
|
182
|
+
warningsSummary,
|
|
183
|
+
reducedWarnings,
|
|
184
|
+
ariaButton,
|
|
185
|
+
ariaInfo,
|
|
186
|
+
onRegionToggle,
|
|
187
|
+
})
|
|
157
188
|
</script>
|
|
158
189
|
|
|
159
190
|
<style scoped lang="scss">
|
|
@@ -192,6 +223,7 @@ export default {
|
|
|
192
223
|
|
|
193
224
|
button {
|
|
194
225
|
border: none;
|
|
226
|
+
cursor: pointer;
|
|
195
227
|
&:focus:not(:focus-visible) {
|
|
196
228
|
box-shadow: none;
|
|
197
229
|
}
|
|
@@ -366,7 +398,10 @@ h3 {
|
|
|
366
398
|
border-radius: 0;
|
|
367
399
|
}
|
|
368
400
|
|
|
369
|
-
.accordion
|
|
401
|
+
.accordion
|
|
402
|
+
> div:first-child:last-child
|
|
403
|
+
.accordion-trigger.collapsed
|
|
404
|
+
> .region-header {
|
|
370
405
|
border-radius: 0;
|
|
371
406
|
}
|
|
372
407
|
|
|
@@ -398,15 +433,30 @@ h3 {
|
|
|
398
433
|
border-radius: 0;
|
|
399
434
|
}
|
|
400
435
|
|
|
401
|
-
.accordion
|
|
436
|
+
.accordion
|
|
437
|
+
> div:last-child
|
|
438
|
+
> div
|
|
439
|
+
> h3
|
|
440
|
+
> button
|
|
441
|
+
> div.current-warning-toggle.collapsed {
|
|
402
442
|
border-radius: 0;
|
|
403
443
|
}
|
|
404
444
|
|
|
405
|
-
.accordion
|
|
445
|
+
.accordion
|
|
446
|
+
> div:first-child:last-child
|
|
447
|
+
> div
|
|
448
|
+
> h3
|
|
449
|
+
> button
|
|
450
|
+
> div.current-warning-toggle {
|
|
406
451
|
border-radius: 0;
|
|
407
452
|
}
|
|
408
453
|
|
|
409
|
-
.accordion
|
|
454
|
+
.accordion
|
|
455
|
+
> div:first-child:last-child
|
|
456
|
+
> div
|
|
457
|
+
> h3
|
|
458
|
+
> button
|
|
459
|
+
> div.current-warning-toggle.collapsed {
|
|
410
460
|
border-radius: 0;
|
|
411
461
|
}
|
|
412
462
|
|