@christianriedl/utils 1.0.83 → 1.0.85
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/package.json
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@christianriedl/utils",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.85",
|
|
4
4
|
"description": "Interfaces, local storage, service worker, configuration, application state",
|
|
5
|
-
|
|
6
5
|
"main": "dist/index.js",
|
|
7
6
|
"types": "dist/index.d.ts",
|
|
8
|
-
|
|
9
7
|
"files": [
|
|
10
8
|
"/dist",
|
|
11
9
|
"src/**/*.vue",
|
|
12
10
|
"package.json"
|
|
13
|
-
],
|
|
11
|
+
],
|
|
14
12
|
"scripts": {
|
|
15
13
|
"build": "tsc",
|
|
16
14
|
"clean": "tsc --build --clean"
|
|
@@ -18,11 +16,11 @@
|
|
|
18
16
|
"author": "Christian Riedl",
|
|
19
17
|
"license": "ISC",
|
|
20
18
|
"dependencies": {
|
|
21
|
-
"vue": "^3.2.
|
|
19
|
+
"vue": "^3.2.47"
|
|
22
20
|
},
|
|
23
21
|
"devDependencies": {
|
|
24
|
-
"@
|
|
22
|
+
"@types/node": "^18.11.18",
|
|
25
23
|
"typescript": "^4.9.4",
|
|
26
|
-
"@types
|
|
24
|
+
"@babel/types": "^7.17.0"
|
|
27
25
|
}
|
|
28
26
|
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { inject, ref, onUnmounted, onMounted, watch } from 'vue';
|
|
3
|
+
import { Helper, EDirection, IAppState, appStateSymbol } from '@christianriedl/utils';
|
|
4
|
+
|
|
5
|
+
const props = defineProps<{ modelValue: Date, utc?: boolean }>();
|
|
6
|
+
const emits = defineEmits<{ (e: 'update:modelValue', value: Date): void }>();
|
|
7
|
+
|
|
8
|
+
const appState = inject(appStateSymbol)!;
|
|
9
|
+
const dateFormatted = ref('');
|
|
10
|
+
|
|
11
|
+
let now: Date;
|
|
12
|
+
|
|
13
|
+
onMounted(() => { appState.navigate.value = onNavigate; });
|
|
14
|
+
onUnmounted(() => { appState.navigate.value = null });
|
|
15
|
+
watch(props, () => init());
|
|
16
|
+
|
|
17
|
+
init ();
|
|
18
|
+
|
|
19
|
+
function init () {
|
|
20
|
+
const date = props.modelValue ? props.modelValue : new Date();
|
|
21
|
+
if (props.utc)
|
|
22
|
+
date.setUTCHours(0, 0, 0, 0);
|
|
23
|
+
else
|
|
24
|
+
date.setHours(0, 0, 0, 0);
|
|
25
|
+
setCurrent(date);
|
|
26
|
+
}
|
|
27
|
+
function setCurrent(date: Date) {
|
|
28
|
+
if (now.getTime() != date.getTime()) {
|
|
29
|
+
now = date;
|
|
30
|
+
dateFormatted.value = props.utc ? Helper.formatUtcDate(now, '-') : Helper.formatDate(now, '-');
|
|
31
|
+
emits('update:modelValue', props.utc ? now : Helper.toLocal(now));
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
function onDateChange() {
|
|
35
|
+
setCurrent (new Date(dateFormatted.value));
|
|
36
|
+
}
|
|
37
|
+
function onNext() {
|
|
38
|
+
setCurrent (new Date(now.getTime() + 24 * 60 * 60 * 1000));
|
|
39
|
+
}
|
|
40
|
+
function onPrevious() {
|
|
41
|
+
setCurrent (new Date(now.getTime() - 24 * 60 * 60 * 1000));
|
|
42
|
+
}
|
|
43
|
+
function onNavigate(direction: EDirection): void {
|
|
44
|
+
if (direction === EDirection.Left)
|
|
45
|
+
onPrevious();
|
|
46
|
+
if (direction === EDirection.Right)
|
|
47
|
+
onNext();
|
|
48
|
+
}
|
|
49
|
+
</script>
|
|
50
|
+
|
|
51
|
+
<template>
|
|
52
|
+
<v-text-field v-model="dateFormatted" type="date" prepend-icon="$prev" append-icon="$next"
|
|
53
|
+
@update:modelValue="onDateChange" @click:prepend="onPrevious" @click:append="onNext">
|
|
54
|
+
</v-text-field>
|
|
55
|
+
</template>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { inject, computed, ref, nextTick, onBeforeUnmount } from 'vue';
|
|
2
|
+
import { inject, computed, ref, nextTick, onBeforeUnmount, StyleValue } from 'vue';
|
|
3
3
|
import { onBeforeRouteLeave } from 'vue-router'
|
|
4
4
|
import { IAppConfig, IConfigItem, IAppState, appStateSymbol, appConfigSymbol } from '@christianriedl/utils'
|
|
5
5
|
import SettingsLine from '../components/SettingsLine.vue';
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
const emits = defineEmits<{ (e: 'configchange', item: IConfigItem): void }>();
|
|
8
8
|
const appState = inject(appStateSymbol)!;
|
|
9
9
|
const appConfig = inject(appConfigSymbol)!;
|
|
10
|
-
const heightStyle = computed(() => { return { height: appState.bodyHeight.value + 'px', overflowY: 'auto' } });
|
|
10
|
+
const heightStyle = computed<StyleValue>(() => { return { height: appState.bodyHeight.value + 'px', overflowY: 'auto' } });
|
|
11
11
|
const scopes = ref(appState.scopes);
|
|
12
12
|
|
|
13
13
|
let changed = false;
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
if (changed) {
|
|
31
31
|
const useServerWait = appConfig.items['smartHomeUseServerWait'].value;
|
|
32
32
|
appConfig.save();
|
|
33
|
-
if (subscribePushNotifications && subscribePushNotifications.value != wasSubscribed) {
|
|
33
|
+
if (appConfig.subscribePush && subscribePushNotifications && subscribePushNotifications.value != wasSubscribed) {
|
|
34
34
|
console.log(`Subscribe changed to ${subscribePushNotifications.value}`)
|
|
35
35
|
if (subscribePushNotifications.value) {
|
|
36
36
|
await appConfig.subscribePush.subscribeUser();
|