@dargmuesli/nuxt-vio 20.1.1 → 21.0.0-beta.1
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.
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<span v-if="url" class="flex items-center gap-2">
|
|
3
3
|
<slot />
|
|
4
|
-
<VioButtonColored :aria-label="t('share')" @click="
|
|
4
|
+
<VioButtonColored :aria-label="t('share')" @click="copy2(url)">
|
|
5
5
|
<template #prefix>
|
|
6
6
|
<VioIconShare />
|
|
7
7
|
</template>
|
|
@@ -19,17 +19,21 @@ interface Props {
|
|
|
19
19
|
withDefaults(defineProps<Props>(), {})
|
|
20
20
|
|
|
21
21
|
const { t } = useI18n()
|
|
22
|
+
const { copy } = useCopy()
|
|
23
|
+
const alertError = useAlertError()
|
|
22
24
|
|
|
23
25
|
// methods
|
|
24
|
-
const
|
|
26
|
+
const copy2 = async (string: string) => {
|
|
25
27
|
if (typeof window === 'undefined') return
|
|
26
28
|
|
|
27
29
|
try {
|
|
28
|
-
await
|
|
30
|
+
await copy(string)
|
|
29
31
|
toast.success(t('donationUrlCopySuccess'))
|
|
30
32
|
} catch (error: unknown) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
+
alertError({
|
|
34
|
+
...(error instanceof Error ? { error } : {}),
|
|
35
|
+
messageI18n: t('donationUrlCopyError'),
|
|
36
|
+
})
|
|
33
37
|
}
|
|
34
38
|
}
|
|
35
39
|
</script>
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { useNow as useNowVueUse, syncRef } from '@vueuse/core'
|
|
2
|
+
|
|
1
3
|
export const useTimeZone = () =>
|
|
2
4
|
useNuxtApp().ssrContext?.event.context.$timeZone ||
|
|
3
5
|
useCookie(TIMEZONE_COOKIE_NAME, {
|
|
@@ -9,15 +11,47 @@ export const useTimeZone = () =>
|
|
|
9
11
|
? Intl.DateTimeFormat().resolvedOptions().timeZone
|
|
10
12
|
: undefined)
|
|
11
13
|
|
|
12
|
-
|
|
14
|
+
// TODO: evaluate custom scheduler (https://github.com/vueuse/vueuse/pull/5129)
|
|
15
|
+
export const useNow = (options?: { live?: boolean }) => {
|
|
16
|
+
const { live = true } = options || {}
|
|
17
|
+
|
|
18
|
+
const nowState = useState(STATE_KEY_NOW, () => new Date())
|
|
19
|
+
|
|
20
|
+
if (live) {
|
|
21
|
+
const now = useNowVueUse()
|
|
22
|
+
syncRef(now, nowState, { direction: 'ltr', immediate: false })
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return nowState
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// TODO: import from vueuse once reactive locale can be passed in (no issue or PR created yet)
|
|
29
|
+
export const useTimeAgoIntl = (options: {
|
|
30
|
+
live?: boolean
|
|
31
|
+
to: MaybeRef<Date>
|
|
32
|
+
}) => {
|
|
33
|
+
const { live = true, to } = options
|
|
34
|
+
|
|
35
|
+
const { locale } = useI18n({ useScope: 'global' })
|
|
36
|
+
const now = useNow({ live })
|
|
37
|
+
|
|
38
|
+
const formatter = computed(
|
|
39
|
+
() =>
|
|
40
|
+
new Intl.RelativeTimeFormat(locale.value, {
|
|
41
|
+
numeric: 'auto',
|
|
42
|
+
}),
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
const toAsRef = toRef(to)
|
|
46
|
+
const fromTo = computed(() =>
|
|
47
|
+
getFromTo(now.value, toAsRef.value, formatter.value),
|
|
48
|
+
)
|
|
13
49
|
|
|
14
|
-
|
|
15
|
-
const { locale } = useI18n()
|
|
16
|
-
const now = useNow()
|
|
50
|
+
const fromToState = useState(STATE_KEY_FROM_TO, () => fromTo)
|
|
17
51
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
52
|
+
if (live) {
|
|
53
|
+
syncRef(fromTo, fromToState, { direction: 'ltr', immediate: false })
|
|
54
|
+
}
|
|
21
55
|
|
|
22
|
-
return
|
|
56
|
+
return fromToState
|
|
23
57
|
}
|
package/package.json
CHANGED
|
@@ -23,7 +23,6 @@
|
|
|
23
23
|
"@vuelidate/validators": "2.0.4",
|
|
24
24
|
"@vueuse/core": "14.1.0",
|
|
25
25
|
"class-variance-authority": "0.7.1",
|
|
26
|
-
"clipboardy": "5.0.1",
|
|
27
26
|
"clsx": "2.1.1",
|
|
28
27
|
"eslint": "9.39.1",
|
|
29
28
|
"eslint-config-prettier": "10.1.8",
|
|
@@ -32,12 +31,12 @@
|
|
|
32
31
|
"eslint-plugin-yml": "1.19.0",
|
|
33
32
|
"globals": "16.5.0",
|
|
34
33
|
"jiti": "2.6.1",
|
|
35
|
-
"jose": "6.1.
|
|
34
|
+
"jose": "6.1.2",
|
|
36
35
|
"lucide-vue-next": "0.555.0",
|
|
37
36
|
"nuxt-gtag": "4.1.0",
|
|
38
37
|
"nuxt-security": "2.5.0",
|
|
39
|
-
"reka-ui": "2.6.
|
|
40
|
-
"shadcn-nuxt": "2.
|
|
38
|
+
"reka-ui": "2.6.0",
|
|
39
|
+
"shadcn-nuxt": "2.3.3",
|
|
41
40
|
"tailwind-merge": "3.4.0",
|
|
42
41
|
"tw-animate-css": "1.4.0",
|
|
43
42
|
"vue-sonner": "2.0.9",
|
|
@@ -54,11 +53,11 @@
|
|
|
54
53
|
"lodash-es": "4.17.21",
|
|
55
54
|
"nuxt": "4.2.1",
|
|
56
55
|
"pinia": "3.0.4",
|
|
57
|
-
"prettier": "3.7.
|
|
58
|
-
"prettier-plugin-tailwindcss": "0.7.
|
|
56
|
+
"prettier": "3.7.1",
|
|
57
|
+
"prettier-plugin-tailwindcss": "0.7.1",
|
|
59
58
|
"serve": "14.2.5",
|
|
60
59
|
"sharp": "0.34.5",
|
|
61
|
-
"stylelint": "16.26.
|
|
60
|
+
"stylelint": "16.26.0",
|
|
62
61
|
"stylelint-config-recommended-vue": "1.6.1",
|
|
63
62
|
"stylelint-config-standard": "39.0.1",
|
|
64
63
|
"stylelint-no-unsupported-browser-features": "8.0.5",
|
|
@@ -114,5 +113,5 @@
|
|
|
114
113
|
"start:static": "serve playground/.output/public --ssl-cert ./.config/certificates/ssl.crt --ssl-key ./.config/certificates/ssl.key"
|
|
115
114
|
},
|
|
116
115
|
"type": "module",
|
|
117
|
-
"version": "
|
|
116
|
+
"version": "21.0.0-beta.1"
|
|
118
117
|
}
|
|
@@ -157,6 +157,7 @@ export const POLYFILLS = [
|
|
|
157
157
|
export const REGEX_UUID =
|
|
158
158
|
/^[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}$/
|
|
159
159
|
export const STATE_KEY_NOW = 'dateTimeNow'
|
|
160
|
+
export const STATE_KEY_FROM_TO = 'dateTimeFromTo'
|
|
160
161
|
export const TESTING_COOKIE_NAME = 'vio_is-testing'
|
|
161
162
|
export const TIMEZONE_COOKIE_NAME = [COOKIE_PREFIX, 'tz'].join(COOKIE_SEPARATOR)
|
|
162
163
|
export const TIMEZONE_HEADER_KEY = `X-${VIO_SITE_NAME}-Timezone`
|
package/shared/utils/text.ts
DELETED