@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
|
@@ -3,8 +3,7 @@
|
|
|
3
3
|
<div class="current-description-image-cell" aria-hidden="true">
|
|
4
4
|
<div
|
|
5
5
|
:class="`current-description-image warning-image symbol-image transform-rotate-${rotation} level-${input.severity} ${typeClass}`"
|
|
6
|
-
:aria-label="`${warningLevel} ${warningTitle.toLowerCase()}${warningDetails}`"
|
|
7
|
-
>
|
|
6
|
+
:aria-label="`${warningLevel} ${warningTitle.toLowerCase()}${warningDetails}`">
|
|
8
7
|
<span
|
|
9
8
|
:class="`symbol-text transform-rotate-${invertedRotation} region-warning-symbol-text`"
|
|
10
9
|
>{{ input.text }}</span
|
|
@@ -38,42 +37,68 @@
|
|
|
38
37
|
</div>
|
|
39
38
|
</template>
|
|
40
39
|
|
|
41
|
-
<script>
|
|
42
|
-
import
|
|
43
|
-
import
|
|
44
|
-
import
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
40
|
+
<script setup lang="ts">
|
|
41
|
+
import { computed, toRef } from 'vue'
|
|
42
|
+
import { useFields } from '@/composables/useFields'
|
|
43
|
+
import { useI18n } from '@/composables/useI18n'
|
|
44
|
+
import type { Warning, Language } from '@/types'
|
|
45
|
+
|
|
46
|
+
// Props
|
|
47
|
+
const props = defineProps<{
|
|
48
|
+
input: Warning
|
|
49
|
+
language?: Language | string
|
|
50
|
+
theme?: string
|
|
51
|
+
}>()
|
|
52
|
+
|
|
53
|
+
// Composables
|
|
54
|
+
const { typeClass, rotation, invertedRotation, severity } = useFields(
|
|
55
|
+
toRef(props, 'input')
|
|
56
|
+
)
|
|
57
|
+
const { t } = useI18n(toRef(props, 'language'))
|
|
58
|
+
|
|
59
|
+
// Expose for testing
|
|
60
|
+
defineExpose({
|
|
61
|
+
severity,
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
// Computed
|
|
65
|
+
const warningTitle = computed((): string => {
|
|
66
|
+
return t(props.input.type)
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
const warningLevel = computed((): string => {
|
|
70
|
+
return t(`warningLevel${props.input.severity}`)
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
const warningDetails = computed((): string => {
|
|
74
|
+
if (
|
|
75
|
+
props.input.text == null ||
|
|
76
|
+
props.input.text === '' ||
|
|
77
|
+
props.input.direction == null
|
|
78
|
+
) {
|
|
79
|
+
return ''
|
|
80
|
+
}
|
|
81
|
+
return ` (${props.input.text} m/s ${t('fromDirection')} ${
|
|
82
|
+
props.input.direction + 180
|
|
83
|
+
}°)`
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
const info = computed((): string => {
|
|
87
|
+
const lang = props.language as Language
|
|
88
|
+
return props.input.info[lang] ?? ''
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
const validText = computed((): string => {
|
|
92
|
+
return t('valid')
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
const linkHidden = computed((): boolean => {
|
|
96
|
+
return props.input.link == null || props.input.link.length === 0
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
const description = computed((): string => {
|
|
100
|
+
return t(`${props.input.type}DescriptionLevel${props.input.severity}`)
|
|
101
|
+
})
|
|
77
102
|
</script>
|
|
78
103
|
|
|
79
104
|
<style scoped lang="scss">
|
|
@@ -16,65 +16,69 @@
|
|
|
16
16
|
@click="toggleGrayScale"
|
|
17
17
|
@keydown.enter="toggleGrayScale"
|
|
18
18
|
@keydown.space="toggleGrayScale">
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
<span>
|
|
20
|
+
{{ toggleText }}
|
|
21
|
+
</span>
|
|
22
|
+
</div>
|
|
23
23
|
</div>
|
|
24
24
|
</div>
|
|
25
25
|
</template>
|
|
26
26
|
|
|
27
|
-
<script>
|
|
28
|
-
import
|
|
27
|
+
<script setup lang="ts">
|
|
28
|
+
import { computed, toRef } from 'vue'
|
|
29
|
+
import { useI18n } from '@/composables/useI18n'
|
|
29
30
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
31
|
+
// Props
|
|
32
|
+
const props = withDefaults(
|
|
33
|
+
defineProps<{
|
|
34
|
+
language?: string
|
|
35
|
+
grayScaleSelector?: boolean
|
|
36
|
+
theme?: string
|
|
37
|
+
}>(),
|
|
38
|
+
{
|
|
39
|
+
language: import.meta.env.VITE_LANGUAGE || 'fi',
|
|
40
|
+
grayScaleSelector: false,
|
|
41
|
+
theme: 'light-theme',
|
|
42
|
+
}
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
// Emits
|
|
46
|
+
const emit = defineEmits<{
|
|
47
|
+
themeChanged: [theme: string]
|
|
48
|
+
}>()
|
|
49
|
+
|
|
50
|
+
// Composables
|
|
51
|
+
const { t } = useI18n(toRef(props, 'language'))
|
|
52
|
+
|
|
53
|
+
// Computed
|
|
54
|
+
const grayScale = computed((): boolean => {
|
|
55
|
+
if (props.theme == null || props.theme.length === 0) {
|
|
56
|
+
return false
|
|
57
|
+
}
|
|
58
|
+
const themeParts = props.theme.split('-')
|
|
59
|
+
return themeParts.length > 1 && themeParts[1] === 'gray'
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
const grayScaleText = computed((): string => {
|
|
63
|
+
return t('grayScale')
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
const toggleText = computed((): string => {
|
|
67
|
+
return grayScale.value ? t('toggleOn') : t('toggleOff')
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
// Methods
|
|
71
|
+
function toggleGrayScale(event: Event): void {
|
|
72
|
+
event.preventDefault()
|
|
73
|
+
if (props.theme == null || props.theme.length === 0) {
|
|
74
|
+
return
|
|
75
|
+
}
|
|
76
|
+
const baseTheme = props.theme.split('-')[0] ?? 'light'
|
|
77
|
+
emit('themeChanged', grayScale.value ? baseTheme : `${baseTheme}-gray`)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function preventEvents(event: Event): void {
|
|
81
|
+
event.preventDefault()
|
|
78
82
|
}
|
|
79
83
|
</script>
|
|
80
84
|
|