@dargmuesli/nuxt-vio 2.0.1 → 3.0.0-beta.10
Sign up to get free protection for your applications and to get access to all the features.
- package/app.config.ts +83 -40
- package/components/vio/_/VioApp.vue +92 -0
- package/components/{VioError.vue → vio/_/VioError.vue} +1 -1
- package/components/{VioLink.vue → vio/_/VioLink.vue} +2 -2
- package/components/vio/button/VioButtonColored.vue +52 -0
- package/components/vio/card/VioCard.vue +19 -0
- package/components/vio/card/state/VioCardState.vue +20 -0
- package/components/vio/card/state/VioCardStateAlert.vue +14 -0
- package/components/vio/form/VioForm.vue +84 -0
- package/components/vio/form/VioFormCheckbox.vue +27 -0
- package/components/vio/form/input/VioFormInput.vue +192 -0
- package/components/vio/form/input/VioFormInputIconWrapper.vue +7 -0
- package/components/vio/form/input/VioFormInputUrl.vue +54 -0
- package/components/vio/form/input/state/VioFormInputState.vue +5 -0
- package/components/vio/form/input/state/VioFormInputStateError.vue +32 -0
- package/components/vio/form/input/state/VioFormInputStateInfo.vue +32 -0
- package/components/vio/icon/IconArrowRight.vue +31 -0
- package/components/vio/icon/IconCalendar.vue +31 -0
- package/components/vio/icon/IconChatOutline.vue +27 -0
- package/components/vio/icon/IconChatSolid.vue +26 -0
- package/components/vio/icon/IconCheckCircle.vue +29 -0
- package/components/vio/icon/IconContainer.vue +15 -0
- package/components/vio/icon/IconDownload.vue +31 -0
- package/components/vio/icon/IconExclamationCircle.vue +29 -0
- package/components/vio/icon/IconHome.vue +31 -0
- package/components/vio/icon/IconHourglass.vue +32 -0
- package/components/vio/icon/IconLightbulb.vue +27 -0
- package/components/vio/icon/IconLogo.vue +17 -0
- package/components/vio/icon/IconMixcloud.vue +23 -0
- package/components/vio/icon/IconMusic.vue +27 -0
- package/components/vio/icon/IconPlay.vue +25 -0
- package/components/vio/icon/IconShare.vue +27 -0
- package/components/{VioLayout.vue → vio/layout/VioLayout.vue} +1 -1
- package/components/vio/layout/VioLayoutBreadcrumbs.vue +83 -0
- package/components/vio/layout/VioLayoutFooter.vue +40 -0
- package/components/vio/layout/VioLayoutFooterCategory.vue +17 -0
- package/components/vio/layout/VioLayoutHeader.vue +98 -0
- package/components/vio/layout/VioLayoutSpanList.vue +20 -0
- package/components/vio/loader/indicator/VioLoaderIndicator.vue +14 -0
- package/components/vio/loader/indicator/VioLoaderIndicatorPing.vue +12 -0
- package/components/vio/loader/indicator/VioLoaderIndicatorSpinner.vue +24 -0
- package/components/{VioLegalNotice.vue → vio/page/VioPageLegalNotice.vue} +10 -8
- package/components/{VioPrivacyPolicy.vue → vio/page/VioPagePrivacyPolicy.vue} +19 -12
- package/composables/useAppLayout.ts +12 -18
- package/composables/useDateTime.ts +17 -0
- package/composables/useFavicons.ts +5 -33
- package/composables/useFireError.ts +17 -0
- package/composables/useGetServiceHref.ts +21 -0
- package/composables/useHeadDefault.ts +21 -0
- package/composables/usePolyfills.ts +23 -0
- package/composables/useStrapiFetch.ts +10 -0
- package/error.vue +5 -2
- package/locales/de.json +7 -1
- package/locales/en.json +7 -1
- package/nuxt.config.ts +56 -10
- package/package.json +37 -25
- package/pages/legal-notice.vue +1 -1
- package/pages/privacy-policy.vue +1 -1
- package/plugins/dayjs.ts +34 -0
- package/plugins/gtag.client.ts +3 -0
- package/plugins/i18n.ts +5 -0
- package/plugins/marked.ts +9 -0
- package/server/middleware/headers.ts +41 -10
- package/server/tsconfig.json +1 -1
- package/server/utils/util.ts +2 -0
- package/store/auth.ts +32 -0
- package/tailwind.config.ts +131 -10
- package/types/api.d.ts +9 -0
- package/types/fetch.d.ts +8 -0
- package/types/modules/gql.d.ts +6 -0
- package/types/modules/graphql.d.ts +6 -0
- package/utils/constants.ts +10 -1
- package/utils/form.ts +19 -0
- package/utils/networking.ts +117 -0
- package/utils/text.ts +20 -0
- package/LICENSE +0 -674
- package/components/VioApp.vue +0 -59
- /package/components/{VioButton.vue → vio/button/VioButton.vue} +0 -0
- /package/components/{VioHr.vue → vio/layout/VioLayoutHr.vue} +0 -0
package/utils/form.ts
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
import type { ApiData } from '../types/api'
|
2
|
+
|
3
|
+
export const formPreSubmit = async (
|
4
|
+
api: ApiData,
|
5
|
+
v$: any,
|
6
|
+
isFormSent: Ref<boolean>,
|
7
|
+
): Promise<boolean> => {
|
8
|
+
api.value.errors = []
|
9
|
+
v$.value.$touch()
|
10
|
+
|
11
|
+
const isFormValid = await v$.value.$validate()
|
12
|
+
isFormSent.value = isFormValid
|
13
|
+
|
14
|
+
if (!isFormValid) {
|
15
|
+
throw new Error('Form is invalid!')
|
16
|
+
}
|
17
|
+
|
18
|
+
return isFormValid
|
19
|
+
}
|
package/utils/networking.ts
CHANGED
@@ -1,7 +1,124 @@
|
|
1
1
|
import { IncomingMessage } from 'node:http'
|
2
2
|
|
3
|
+
import { CombinedError } from '@urql/core'
|
4
|
+
import { H3Event, getCookie } from 'h3'
|
5
|
+
|
6
|
+
import { ofetch } from 'ofetch'
|
7
|
+
import { Ref } from 'vue'
|
8
|
+
|
9
|
+
import type { BackendError } from '../types/api'
|
10
|
+
import { TIMEZONE_COOKIE_NAME } from './constants'
|
11
|
+
|
12
|
+
export const getApiMeta = (
|
13
|
+
queries?: {
|
14
|
+
error: Ref<CombinedError | undefined>
|
15
|
+
fetching: Ref<boolean>
|
16
|
+
}[],
|
17
|
+
) => ({
|
18
|
+
errors: queries
|
19
|
+
? queries.reduce((p, c) => {
|
20
|
+
if (c.error.value) {
|
21
|
+
return [...p, c.error.value]
|
22
|
+
} else {
|
23
|
+
return p
|
24
|
+
}
|
25
|
+
}, [] as BackendError[])
|
26
|
+
: [],
|
27
|
+
isFetching: queries
|
28
|
+
? queries.reduce((p, c) => p || c.fetching.value, false)
|
29
|
+
: false,
|
30
|
+
})
|
31
|
+
|
32
|
+
export const getCombinedErrorMessages = (
|
33
|
+
errors: BackendError[],
|
34
|
+
pgIds?: Record<string, string>,
|
35
|
+
) => {
|
36
|
+
const errorMessages: string[] = []
|
37
|
+
|
38
|
+
for (const error of errors) {
|
39
|
+
if ('errcode' in error) {
|
40
|
+
const translation = pgIds && pgIds[`postgres${error.errcode}`]
|
41
|
+
|
42
|
+
if (translation) {
|
43
|
+
errorMessages.push(translation)
|
44
|
+
} else {
|
45
|
+
errorMessages.push(error.message)
|
46
|
+
}
|
47
|
+
} else {
|
48
|
+
const combinedError = error
|
49
|
+
|
50
|
+
if (combinedError.networkError) {
|
51
|
+
errorMessages.push(combinedError.message)
|
52
|
+
}
|
53
|
+
|
54
|
+
for (const graphqlError of combinedError.graphQLErrors) {
|
55
|
+
errorMessages.push(graphqlError.message)
|
56
|
+
}
|
57
|
+
}
|
58
|
+
}
|
59
|
+
|
60
|
+
return errorMessages
|
61
|
+
}
|
62
|
+
|
63
|
+
export const getDomainTldPort = (host: string) => {
|
64
|
+
const hostParts = host.split('.')
|
65
|
+
|
66
|
+
if (/^localhost(:[0-9]+)?$/.test(hostParts[hostParts.length - 1]))
|
67
|
+
return hostParts[hostParts.length - 1]
|
68
|
+
|
69
|
+
if (hostParts.length === 1) throw new Error('Host is too short!')
|
70
|
+
|
71
|
+
return `${hostParts[hostParts.length - 2]}.${hostParts[hostParts.length - 1]}`
|
72
|
+
}
|
73
|
+
|
3
74
|
export const getHost = (req: IncomingMessage) => {
|
4
75
|
if (!req.headers.host) throw new Error('Host header is not given!')
|
5
76
|
|
6
77
|
return req.headers.host
|
7
78
|
}
|
79
|
+
|
80
|
+
export const getServiceHref = ({
|
81
|
+
host,
|
82
|
+
isSsr = true,
|
83
|
+
name,
|
84
|
+
port,
|
85
|
+
stagingHost,
|
86
|
+
}: {
|
87
|
+
host: string
|
88
|
+
isSsr?: boolean
|
89
|
+
name?: string
|
90
|
+
port?: number
|
91
|
+
stagingHost?: string
|
92
|
+
}) => {
|
93
|
+
const nameSubdomain = name?.replaceAll('_', '-')
|
94
|
+
const nameSubdomainString = nameSubdomain ? `${nameSubdomain}.` : ''
|
95
|
+
const portString = port ? `:${port}` : ''
|
96
|
+
|
97
|
+
if (stagingHost) {
|
98
|
+
return `https://${nameSubdomainString}${stagingHost}`
|
99
|
+
} else if (isSsr && process.server) {
|
100
|
+
return `http://${name}${portString}`
|
101
|
+
} else {
|
102
|
+
return `https://${nameSubdomainString}${getDomainTldPort(host)}`
|
103
|
+
}
|
104
|
+
}
|
105
|
+
|
106
|
+
export const getTimezone = async (event: H3Event) => {
|
107
|
+
const timezoneCookie = getCookie(event, TIMEZONE_COOKIE_NAME)
|
108
|
+
|
109
|
+
if (timezoneCookie) {
|
110
|
+
return timezoneCookie
|
111
|
+
}
|
112
|
+
|
113
|
+
if (event.node.req.headers['x-real-ip']) {
|
114
|
+
const ipApiResult = await ofetch<{ timezone: string }>(
|
115
|
+
`http://ip-api.com/json/${event.node.req.headers['x-real-ip']}`,
|
116
|
+
).catch(() => {})
|
117
|
+
|
118
|
+
if (ipApiResult) {
|
119
|
+
return ipApiResult.timezone
|
120
|
+
}
|
121
|
+
}
|
122
|
+
|
123
|
+
return undefined
|
124
|
+
}
|
package/utils/text.ts
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
import Clipboard from 'clipboard'
|
2
|
+
|
3
|
+
export const copyText = (text: string) =>
|
4
|
+
new Promise((resolve, reject) => {
|
5
|
+
const fakeElement = document.createElement('button')
|
6
|
+
const clipboard = new Clipboard(fakeElement, {
|
7
|
+
text: () => text,
|
8
|
+
action: () => 'copy',
|
9
|
+
container: document.body,
|
10
|
+
})
|
11
|
+
clipboard.on('success', (e) => {
|
12
|
+
clipboard.destroy()
|
13
|
+
resolve(e)
|
14
|
+
})
|
15
|
+
clipboard.on('error', (e) => {
|
16
|
+
clipboard.destroy()
|
17
|
+
reject(e)
|
18
|
+
})
|
19
|
+
fakeElement.click()
|
20
|
+
})
|