@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.
Files changed (79) hide show
  1. package/app.config.ts +83 -40
  2. package/components/vio/_/VioApp.vue +92 -0
  3. package/components/{VioError.vue → vio/_/VioError.vue} +1 -1
  4. package/components/{VioLink.vue → vio/_/VioLink.vue} +2 -2
  5. package/components/vio/button/VioButtonColored.vue +52 -0
  6. package/components/vio/card/VioCard.vue +19 -0
  7. package/components/vio/card/state/VioCardState.vue +20 -0
  8. package/components/vio/card/state/VioCardStateAlert.vue +14 -0
  9. package/components/vio/form/VioForm.vue +84 -0
  10. package/components/vio/form/VioFormCheckbox.vue +27 -0
  11. package/components/vio/form/input/VioFormInput.vue +192 -0
  12. package/components/vio/form/input/VioFormInputIconWrapper.vue +7 -0
  13. package/components/vio/form/input/VioFormInputUrl.vue +54 -0
  14. package/components/vio/form/input/state/VioFormInputState.vue +5 -0
  15. package/components/vio/form/input/state/VioFormInputStateError.vue +32 -0
  16. package/components/vio/form/input/state/VioFormInputStateInfo.vue +32 -0
  17. package/components/vio/icon/IconArrowRight.vue +31 -0
  18. package/components/vio/icon/IconCalendar.vue +31 -0
  19. package/components/vio/icon/IconChatOutline.vue +27 -0
  20. package/components/vio/icon/IconChatSolid.vue +26 -0
  21. package/components/vio/icon/IconCheckCircle.vue +29 -0
  22. package/components/vio/icon/IconContainer.vue +15 -0
  23. package/components/vio/icon/IconDownload.vue +31 -0
  24. package/components/vio/icon/IconExclamationCircle.vue +29 -0
  25. package/components/vio/icon/IconHome.vue +31 -0
  26. package/components/vio/icon/IconHourglass.vue +32 -0
  27. package/components/vio/icon/IconLightbulb.vue +27 -0
  28. package/components/vio/icon/IconLogo.vue +17 -0
  29. package/components/vio/icon/IconMixcloud.vue +23 -0
  30. package/components/vio/icon/IconMusic.vue +27 -0
  31. package/components/vio/icon/IconPlay.vue +25 -0
  32. package/components/vio/icon/IconShare.vue +27 -0
  33. package/components/{VioLayout.vue → vio/layout/VioLayout.vue} +1 -1
  34. package/components/vio/layout/VioLayoutBreadcrumbs.vue +83 -0
  35. package/components/vio/layout/VioLayoutFooter.vue +40 -0
  36. package/components/vio/layout/VioLayoutFooterCategory.vue +17 -0
  37. package/components/vio/layout/VioLayoutHeader.vue +98 -0
  38. package/components/vio/layout/VioLayoutSpanList.vue +20 -0
  39. package/components/vio/loader/indicator/VioLoaderIndicator.vue +14 -0
  40. package/components/vio/loader/indicator/VioLoaderIndicatorPing.vue +12 -0
  41. package/components/vio/loader/indicator/VioLoaderIndicatorSpinner.vue +24 -0
  42. package/components/{VioLegalNotice.vue → vio/page/VioPageLegalNotice.vue} +10 -8
  43. package/components/{VioPrivacyPolicy.vue → vio/page/VioPagePrivacyPolicy.vue} +19 -12
  44. package/composables/useAppLayout.ts +12 -18
  45. package/composables/useDateTime.ts +17 -0
  46. package/composables/useFavicons.ts +5 -33
  47. package/composables/useFireError.ts +17 -0
  48. package/composables/useGetServiceHref.ts +21 -0
  49. package/composables/useHeadDefault.ts +21 -0
  50. package/composables/usePolyfills.ts +23 -0
  51. package/composables/useStrapiFetch.ts +10 -0
  52. package/error.vue +5 -2
  53. package/locales/de.json +7 -1
  54. package/locales/en.json +7 -1
  55. package/nuxt.config.ts +56 -10
  56. package/package.json +37 -25
  57. package/pages/legal-notice.vue +1 -1
  58. package/pages/privacy-policy.vue +1 -1
  59. package/plugins/dayjs.ts +34 -0
  60. package/plugins/gtag.client.ts +3 -0
  61. package/plugins/i18n.ts +5 -0
  62. package/plugins/marked.ts +9 -0
  63. package/server/middleware/headers.ts +41 -10
  64. package/server/tsconfig.json +1 -1
  65. package/server/utils/util.ts +2 -0
  66. package/store/auth.ts +32 -0
  67. package/tailwind.config.ts +131 -10
  68. package/types/api.d.ts +9 -0
  69. package/types/fetch.d.ts +8 -0
  70. package/types/modules/gql.d.ts +6 -0
  71. package/types/modules/graphql.d.ts +6 -0
  72. package/utils/constants.ts +10 -1
  73. package/utils/form.ts +19 -0
  74. package/utils/networking.ts +117 -0
  75. package/utils/text.ts +20 -0
  76. package/LICENSE +0 -674
  77. package/components/VioApp.vue +0 -59
  78. /package/components/{VioButton.vue → vio/button/VioButton.vue} +0 -0
  79. /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
+ }
@@ -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
+ })