@myissue/vue-website-page-builder 3.0.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.
Files changed (95) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +470 -0
  3. package/dist/android-chrome-192x192.png +0 -0
  4. package/dist/android-chrome-512x512.png +0 -0
  5. package/dist/apple-touch-icon.png +0 -0
  6. package/dist/browserconfig.xml +9 -0
  7. package/dist/components.json +36 -0
  8. package/dist/favicon-16x16.png +0 -0
  9. package/dist/favicon-32x32.png +0 -0
  10. package/dist/favicon.ico +0 -0
  11. package/dist/home/features.jpg +0 -0
  12. package/dist/home/page-builder-example.jpg +0 -0
  13. package/dist/logo/logo.svg +49 -0
  14. package/dist/mstile-310x150.png +0 -0
  15. package/dist/mstile-310x310.png +0 -0
  16. package/dist/page-builder/2-images-text-top.png +0 -0
  17. package/dist/page-builder/2-images.png +0 -0
  18. package/dist/page-builder/3-images.png +0 -0
  19. package/dist/page-builder/6-images.png +0 -0
  20. package/dist/page-builder/image.png +0 -0
  21. package/dist/page-builder/placeholder.jpg +0 -0
  22. package/dist/page-builder/two-vertical-images.png +0 -0
  23. package/dist/placeholder_image.jpg +0 -0
  24. package/dist/robots.txt +2 -0
  25. package/dist/vue-website-page-builder.css +1 -0
  26. package/dist/vue-website-page-builder.js +24794 -0
  27. package/dist/vue-website-page-builder.umd.cjs +195 -0
  28. package/package.json +99 -0
  29. package/src/App.vue +122 -0
  30. package/src/Components/Homepage/Footer.vue +42 -0
  31. package/src/Components/Homepage/HomeSection.vue +540 -0
  32. package/src/Components/Homepage/Navbar.vue +30 -0
  33. package/src/Components/Layouts/FullWidthElement.vue +34 -0
  34. package/src/Components/Loaders/FullScreenSpinner.vue +13 -0
  35. package/src/Components/Loaders/SmallUniversalSpinner.vue +26 -0
  36. package/src/Components/MediaLibrary/SidebarUnsplash.vue +40 -0
  37. package/src/Components/MediaLibrary/Unsplash.vue +306 -0
  38. package/src/Components/Modals/DynamicModal.vue +476 -0
  39. package/src/Components/Modals/MediaLibraryModal.vue +418 -0
  40. package/src/Components/Modals/Modal.vue +102 -0
  41. package/src/Components/Modals/PageBuilderModal.vue +233 -0
  42. package/src/Components/Modals/PageBuilderPreviewModal.vue +123 -0
  43. package/src/Components/PageBuilder/DropdownsPlusToggles/OptionsDropdown.vue +202 -0
  44. package/src/Components/PageBuilder/DropdownsPlusToggles/SaveDesign.vue +7 -0
  45. package/src/Components/PageBuilder/EditorMenu/Editables/BackgroundColorEditor.vue +91 -0
  46. package/src/Components/PageBuilder/EditorMenu/Editables/BorderRadius.vue +163 -0
  47. package/src/Components/PageBuilder/EditorMenu/Editables/Borders.vue +164 -0
  48. package/src/Components/PageBuilder/EditorMenu/Editables/ClassEditor.vue +80 -0
  49. package/src/Components/PageBuilder/EditorMenu/Editables/ComponentTopMenu.vue +93 -0
  50. package/src/Components/PageBuilder/EditorMenu/Editables/DeleteElement.vue +42 -0
  51. package/src/Components/PageBuilder/EditorMenu/Editables/EditGetElement.vue +338 -0
  52. package/src/Components/PageBuilder/EditorMenu/Editables/ElementEditor.vue +58 -0
  53. package/src/Components/PageBuilder/EditorMenu/Editables/ImageEditor.vue +82 -0
  54. package/src/Components/PageBuilder/EditorMenu/Editables/LinkEditor.vue +301 -0
  55. package/src/Components/PageBuilder/EditorMenu/Editables/ManageBackgroundOpacity.vue +109 -0
  56. package/src/Components/PageBuilder/EditorMenu/Editables/ManageOpacity.vue +107 -0
  57. package/src/Components/PageBuilder/EditorMenu/Editables/OpacityEditor.vue +16 -0
  58. package/src/Components/PageBuilder/EditorMenu/Editables/PaddingPlusMargin.vue +134 -0
  59. package/src/Components/PageBuilder/EditorMenu/Editables/TextColorEditor.vue +91 -0
  60. package/src/Components/PageBuilder/EditorMenu/Editables/Typography.vue +199 -0
  61. package/src/Components/PageBuilder/EditorMenu/EditorAccordion.vue +42 -0
  62. package/src/Components/PageBuilder/EditorMenu/RightSidebarEditor.vue +113 -0
  63. package/src/Components/PageBuilder/Settings/AdvancedPageBuilderSettings.vue +229 -0
  64. package/src/Components/PageBuilder/Settings/PageBuilderSettings.vue +101 -0
  65. package/src/Components/PageBuilder/Slidebars/SlideOverRight.vue +91 -0
  66. package/src/Components/PageBuilder/Slidebars/SlideOverRightParent.vue +91 -0
  67. package/src/Components/Search/SearchComponents.vue +259 -0
  68. package/src/Components/TipTap/TipTap.vue +32 -0
  69. package/src/Components/TipTap/TipTapInput.vue +325 -0
  70. package/src/PageBuilder/PageBuilder.vue +347 -0
  71. package/src/PageBuilder/Preview.vue +24 -0
  72. package/src/composables/PageBuilder.ts +1483 -0
  73. package/src/composables/delay.ts +5 -0
  74. package/src/composables/extract-text-content-html.ts +34 -0
  75. package/src/composables/isObject.ts +6 -0
  76. package/src/composables/usePromise.ts +10 -0
  77. package/src/composables/vueFetch.ts +278 -0
  78. package/src/css/app.css +614 -0
  79. package/src/index.ts +16 -0
  80. package/src/main.ts +11 -0
  81. package/src/stores/media-library.ts +34 -0
  82. package/src/stores/page-builder-state.ts +461 -0
  83. package/src/stores/unsplash.ts +107 -0
  84. package/src/stores/user.ts +30 -0
  85. package/src/types/global.d.ts +49 -0
  86. package/src/utils/builder/compiledCSS.ts +2205 -0
  87. package/src/utils/builder/html-doc-declaration-with-components.ts +7 -0
  88. package/src/utils/builder/html-elements/componentHelpers.ts +101 -0
  89. package/src/utils/builder/tailwaind-colors.ts +503 -0
  90. package/src/utils/builder/tailwind-border-radius.ts +67 -0
  91. package/src/utils/builder/tailwind-border-style-width-color.ts +272 -0
  92. package/src/utils/builder/tailwind-font-sizes.ts +76 -0
  93. package/src/utils/builder/tailwind-font-styles.ts +24 -0
  94. package/src/utils/builder/tailwind-opacities.ts +45 -0
  95. package/src/utils/builder/tailwind-padding-margin.ts +159 -0
@@ -0,0 +1,461 @@
1
+ import { defineStore } from 'pinia'
2
+ import { vueFetch } from '@/composables/vueFetch'
3
+
4
+ interface ComponentObject {
5
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
6
+ [key: string]: any
7
+ }
8
+
9
+ interface FetchedComponentsResponse {
10
+ components: ComponentObject[]
11
+ // Add other properties that might exist in the response
12
+ [key: string]: unknown
13
+ }
14
+
15
+ interface PageBuilderState {
16
+ componentArrayAddMethod: string | null
17
+ localStorageItemName: string | null
18
+ localStorageItemNameUpdate: string | null
19
+ showModalTipTap: boolean
20
+ menuRight: boolean
21
+ borderStyle: string | null
22
+ borderWidth: string | null
23
+ borderColor: string | null
24
+ borderRadiusGlobal: string | null
25
+ borderRadiusTopLeft: string | null
26
+ borderRadiusTopRight: string | null
27
+ borderRadiusBottomleft: string | null
28
+ borderRadiusBottomRight: string | null
29
+ elementContainsHyperlink: boolean | null
30
+ hyperlinkAbility: boolean | null
31
+ hyperlinkInput: string | null
32
+ hyperlinkMessage: string | null
33
+ hyperlinkError: string | null
34
+ hyberlinkEnable: boolean
35
+ openHyperlinkinkInNewTab: boolean | null
36
+ opacity: string | null
37
+ backgroundOpacity: string | null
38
+ textAreaVueModel: string | null
39
+ nextSibling: HTMLElement | null
40
+ parentElement: HTMLElement | null
41
+ restoredElement: string | null
42
+ currentClasses: string[]
43
+ fontVerticalPadding: string | null
44
+ fontHorizontalPadding: string | null
45
+ fontVerticalMargin: string | null
46
+ fontHorizontalMargin: string | null
47
+ fontStyle: string | null
48
+ fontFamily: string | null
49
+ fontWeight: string | null
50
+ fontBase: string | null
51
+ fontDesktop: string | null
52
+ fontTablet: string | null
53
+ fontMobile: string | null
54
+ backgroundColor: string | null
55
+ textColor: string | null
56
+ element: HTMLElement | null
57
+ component: ComponentObject | null
58
+ components: ComponentObject[]
59
+ basePrimaryImage: string | null
60
+ fetchedComponents: FetchedComponentsResponse | null
61
+ }
62
+
63
+ interface SetPushComponentsPayload {
64
+ componentArrayAddMethod?: string
65
+ component: ComponentObject
66
+ }
67
+
68
+ interface LoadComponentsData {
69
+ search_query?: string
70
+ page?: string | number
71
+ }
72
+
73
+ // get components
74
+ const {
75
+ handleData: handlefetchComponents,
76
+ fetchedData: fetchedComponents,
77
+ isLoading,
78
+ isError,
79
+ error,
80
+ } = vueFetch()
81
+
82
+ export const usePageBuilderStateStore = defineStore('pageBuilderState', {
83
+ state: (): PageBuilderState => ({
84
+ componentArrayAddMethod: null,
85
+ localStorageItemName: null,
86
+ localStorageItemNameUpdate: null,
87
+ showModalTipTap: false,
88
+ menuRight: true,
89
+ borderStyle: null,
90
+ borderWidth: null,
91
+ borderColor: null,
92
+ borderRadiusGlobal: null,
93
+ borderRadiusTopLeft: null,
94
+ borderRadiusTopRight: null,
95
+ borderRadiusBottomleft: null,
96
+ borderRadiusBottomRight: null,
97
+ elementContainsHyperlink: null,
98
+ hyperlinkAbility: null,
99
+ hyperlinkInput: null,
100
+ hyperlinkMessage: null,
101
+ hyperlinkError: null,
102
+ hyberlinkEnable: false,
103
+ openHyperlinkinkInNewTab: null,
104
+ opacity: null,
105
+ backgroundOpacity: null,
106
+ textAreaVueModel: null,
107
+ nextSibling: null,
108
+ parentElement: null,
109
+ restoredElement: null,
110
+ currentClasses: [],
111
+ fontVerticalPadding: null,
112
+ fontHorizontalPadding: null,
113
+ fontVerticalMargin: null,
114
+ fontHorizontalMargin: null,
115
+ fontStyle: null,
116
+ fontFamily: null,
117
+ fontWeight: null,
118
+ fontBase: null,
119
+ fontDesktop: null,
120
+ fontTablet: null,
121
+ fontMobile: null,
122
+ backgroundColor: null,
123
+ textColor: null,
124
+ element: null,
125
+ component: null,
126
+ components: [],
127
+ basePrimaryImage: null,
128
+ fetchedComponents: null,
129
+ }),
130
+ getters: {
131
+ getComponentArrayAddMethod(state: PageBuilderState): string | null {
132
+ return state.componentArrayAddMethod
133
+ },
134
+ getLocalStorageItemName(state: PageBuilderState): string | null {
135
+ return state.localStorageItemName
136
+ },
137
+ getLocalStorageItemNameUpdate(state: PageBuilderState): string | null {
138
+ return state.localStorageItemNameUpdate
139
+ },
140
+ getShowModalTipTap(state: PageBuilderState): boolean {
141
+ return state.showModalTipTap
142
+ },
143
+ getMenuRight(state: PageBuilderState): boolean {
144
+ return state.menuRight
145
+ },
146
+ getBorderStyle(state: PageBuilderState): string | null {
147
+ return state.borderStyle
148
+ },
149
+ getBorderWidth(state: PageBuilderState): string | null {
150
+ return state.borderWidth
151
+ },
152
+ getBorderColor(state: PageBuilderState): string | null {
153
+ return state.borderColor
154
+ },
155
+ getBorderRadiusGlobal(state: PageBuilderState): string | null {
156
+ return state.borderRadiusGlobal
157
+ },
158
+ getBorderRadiusTopLeft(state: PageBuilderState): string | null {
159
+ return state.borderRadiusTopLeft
160
+ },
161
+ getBorderRadiusTopRight(state: PageBuilderState): string | null {
162
+ return state.borderRadiusTopRight
163
+ },
164
+ getBorderRadiusBottomleft(state: PageBuilderState): string | null {
165
+ return state.borderRadiusBottomleft
166
+ },
167
+ getBorderRadiusBottomRight(state: PageBuilderState): string | null {
168
+ return state.borderRadiusBottomRight
169
+ },
170
+ getElementContainsHyperlink(state: PageBuilderState): boolean | null {
171
+ return state.elementContainsHyperlink
172
+ },
173
+ getHyperlinkAbility(state: PageBuilderState): boolean | null {
174
+ return state.hyperlinkAbility
175
+ },
176
+ getHyperlinkInput(state: PageBuilderState): string | null {
177
+ return state.hyperlinkInput
178
+ },
179
+ getHyperlinkMessage(state: PageBuilderState): string | null {
180
+ return state.hyperlinkMessage
181
+ },
182
+ getHyperlinkError(state: PageBuilderState): string | null {
183
+ return state.hyperlinkError
184
+ },
185
+ getHyberlinkEnable(state: PageBuilderState): boolean {
186
+ return state.hyberlinkEnable
187
+ },
188
+ getOpenHyperlinkInNewTab(state: PageBuilderState): boolean | null {
189
+ return state.openHyperlinkinkInNewTab
190
+ },
191
+ getOpacity(state: PageBuilderState): string | null {
192
+ return state.opacity
193
+ },
194
+ getBackgroundOpacity(state: PageBuilderState): string | null {
195
+ return state.backgroundOpacity
196
+ },
197
+ getTextAreaVueModel(state: PageBuilderState): string | null {
198
+ return state.textAreaVueModel
199
+ },
200
+ getNextSibling(state: PageBuilderState): HTMLElement | null {
201
+ return state.nextSibling
202
+ },
203
+ getParentElement(state: PageBuilderState): HTMLElement | null {
204
+ return state.parentElement
205
+ },
206
+ getRestoredElement(state: PageBuilderState): string | null {
207
+ return state.restoredElement
208
+ },
209
+ getCurrentClasses(state: PageBuilderState): string[] {
210
+ return state.currentClasses
211
+ },
212
+ getFontStyle(state: PageBuilderState): string | null {
213
+ return state.fontStyle
214
+ },
215
+ getFontVerticalPadding(state: PageBuilderState): string | null {
216
+ return state.fontVerticalPadding
217
+ },
218
+ getFontHorizontalPadding(state: PageBuilderState): string | null {
219
+ return state.fontHorizontalPadding
220
+ },
221
+ getFontVerticalMargin(state: PageBuilderState): string | null {
222
+ return state.fontVerticalMargin
223
+ },
224
+ getFontHorizontalMargin(state: PageBuilderState): string | null {
225
+ return state.fontHorizontalMargin
226
+ },
227
+ getFontFamily(state: PageBuilderState): string | null {
228
+ return state.fontFamily
229
+ },
230
+ getFontWeight(state: PageBuilderState): string | null {
231
+ return state.fontWeight
232
+ },
233
+ getFontBase(state: PageBuilderState): string | null {
234
+ return state.fontBase
235
+ },
236
+ getFontDesktop(state: PageBuilderState): string | null {
237
+ return state.fontDesktop
238
+ },
239
+ getFontTablet(state: PageBuilderState): string | null {
240
+ return state.fontTablet
241
+ },
242
+ getFontMobile(state: PageBuilderState): string | null {
243
+ return state.fontMobile
244
+ },
245
+ getBackgroundColor(state: PageBuilderState): string | null {
246
+ return state.backgroundColor
247
+ },
248
+ getTextColor(state: PageBuilderState): string | null {
249
+ return state.textColor
250
+ },
251
+ getElement(state: PageBuilderState): HTMLElement | null {
252
+ return state.element
253
+ },
254
+ getComponent(state: PageBuilderState): ComponentObject | null {
255
+ return state.component
256
+ },
257
+ getComponents(state: PageBuilderState): ComponentObject[] {
258
+ return state.components
259
+ },
260
+ getBasePrimaryImage(state: PageBuilderState): string | null {
261
+ return state.basePrimaryImage
262
+ },
263
+ getFetchedComponents(): {
264
+ isLoading: boolean
265
+ isError: boolean
266
+ error: string | null
267
+ fetchedData: unknown
268
+ } {
269
+ return {
270
+ isLoading: isLoading.value,
271
+ isError: isError.value,
272
+ error: error.value,
273
+ fetchedData: fetchedComponents.value,
274
+ }
275
+ },
276
+ getFetchedComponentsData(state: PageBuilderState): FetchedComponentsResponse | null {
277
+ return state.fetchedComponents
278
+ },
279
+ },
280
+ actions: {
281
+ setComponentArrayAddMethod(payload: string | null): void {
282
+ this.componentArrayAddMethod = payload
283
+ },
284
+ setLocalStorageItemName(payload: string | null): void {
285
+ this.localStorageItemName = payload
286
+ },
287
+ setLocalStorageItemNameUpdate(payload: string | null): void {
288
+ this.localStorageItemNameUpdate = payload
289
+ },
290
+ setShowModalTipTap(payload: boolean): void {
291
+ this.showModalTipTap = payload
292
+ },
293
+ setMenuRight(payload: boolean): void {
294
+ this.menuRight = payload
295
+ },
296
+ setBorderStyle(payload: string | null): void {
297
+ this.borderStyle = payload
298
+ },
299
+ setBorderWidth(payload: string | null): void {
300
+ this.borderWidth = payload
301
+ },
302
+ setBorderColor(payload: string | null): void {
303
+ this.borderColor = payload
304
+ },
305
+ setBorderRadiusGlobal(payload: string | null): void {
306
+ this.borderRadiusGlobal = payload
307
+ },
308
+ setBorderRadiusTopLeft(payload: string | null): void {
309
+ this.borderRadiusTopLeft = payload
310
+ },
311
+ setBorderRadiusTopRight(payload: string | null): void {
312
+ this.borderRadiusTopRight = payload
313
+ },
314
+ setBorderRadiusBottomleft(payload: string | null): void {
315
+ this.borderRadiusBottomleft = payload
316
+ },
317
+ setBorderRadiusBottomRight(payload: string | null): void {
318
+ this.borderRadiusBottomRight = payload
319
+ },
320
+ setElementContainsHyperlink(payload: boolean | null): void {
321
+ this.elementContainsHyperlink = payload
322
+ },
323
+ setHyperlinkAbility(payload: boolean | null): void {
324
+ this.hyperlinkAbility = payload
325
+ },
326
+ setHyperlinkInput(payload: string | null): void {
327
+ this.hyperlinkInput = payload
328
+ },
329
+ setHyperlinkMessage(payload: string | null): void {
330
+ this.hyperlinkMessage = payload
331
+ },
332
+ setHyperlinkError(payload: string | null): void {
333
+ this.hyperlinkError = payload
334
+ },
335
+ setHyberlinkEnable(payload: boolean): void {
336
+ this.hyberlinkEnable = payload
337
+ },
338
+ setOpenHyperlinkInNewTab(payload: boolean | null): void {
339
+ this.openHyperlinkinkInNewTab = payload
340
+ },
341
+ setOpacity(payload: string | null): void {
342
+ this.opacity = payload
343
+ },
344
+ setBackgroundOpacity(payload: string | null): void {
345
+ this.backgroundOpacity = payload
346
+ },
347
+ setTextAreaVueModel(payload: string | null): void {
348
+ this.textAreaVueModel = payload
349
+ },
350
+ setNextSibling(payload: HTMLElement | null): void {
351
+ this.nextSibling = payload
352
+ },
353
+ setParentElement(payload: HTMLElement | null): void {
354
+ this.parentElement = payload
355
+ },
356
+ setRestoredElement(payload: string | null): void {
357
+ this.restoredElement = payload
358
+ },
359
+ setClass(payload: string): void {
360
+ this.currentClasses = [...this.currentClasses, payload]
361
+ },
362
+ removeClass(payload: string): void {
363
+ this.currentClasses = this.currentClasses.filter((cls) => cls !== payload)
364
+ },
365
+ setCurrentClasses(payload: string[] | ArrayLike<string>): void {
366
+ this.currentClasses = Array.from(payload)
367
+ },
368
+ setFontVerticalPadding(payload: string | null): void {
369
+ this.fontVerticalPadding = payload
370
+ },
371
+ setFontHorizontalPadding(payload: string | null): void {
372
+ this.fontHorizontalPadding = payload
373
+ },
374
+ setFontVerticalMargin(payload: string | null): void {
375
+ this.fontVerticalMargin = payload
376
+ },
377
+ setFontHorizontalMargin(payload: string | null): void {
378
+ this.fontHorizontalMargin = payload
379
+ },
380
+ setFontStyle(payload: string | null): void {
381
+ this.fontStyle = payload
382
+ },
383
+ setFontFamily(payload: string | null): void {
384
+ this.fontFamily = payload
385
+ },
386
+ setFontWeight(payload: string | null): void {
387
+ this.fontWeight = payload
388
+ },
389
+ setFontBase(payload: string | null): void {
390
+ this.fontBase = payload
391
+ },
392
+ setFontDesktop(payload: string | null): void {
393
+ this.fontDesktop = payload
394
+ },
395
+ setFontTablet(payload: string | null): void {
396
+ this.fontTablet = payload
397
+ },
398
+ setFontMobile(payload: string | null): void {
399
+ this.fontMobile = payload
400
+ },
401
+ setBackgroundColor(payload: string | null): void {
402
+ this.backgroundColor = payload
403
+ },
404
+ setTextColor(payload: string | null): void {
405
+ this.textColor = payload
406
+ },
407
+ setElement(payload: HTMLElement | null): void {
408
+ this.element = payload || null
409
+ },
410
+ setComponent(payload: ComponentObject | null): void {
411
+ if (!payload) {
412
+ this.element = null
413
+ this.component = null
414
+ // Note: pageBuilder.removeHoveredAndSelected(null) removed as pageBuilder is not available in store scope
415
+ return
416
+ }
417
+ this.component = payload || null
418
+ },
419
+ setComponents(payload: ComponentObject[] | null): void {
420
+ this.components = payload || []
421
+ },
422
+ setPushComponents(payload: SetPushComponentsPayload): void {
423
+ const method = payload.componentArrayAddMethod || 'push'
424
+ if (method === 'push') {
425
+ this.components.push(payload.component)
426
+ } else if (method === 'unshift') {
427
+ this.components.unshift(payload.component)
428
+ }
429
+ },
430
+ setBasePrimaryImage(payload: string | null): void {
431
+ // Note: element manipulation removed as it should be handled by component logic
432
+ this.basePrimaryImage = payload
433
+ },
434
+ setCurrentLayoutPreview(payload: string): void {
435
+ localStorage.setItem('preview', payload)
436
+ },
437
+ setFetchedComponents(payload: FetchedComponentsResponse | null): void {
438
+ this.fetchedComponents = payload
439
+ },
440
+
441
+ async setLoadComponents(_data: LoadComponentsData): Promise<void> {
442
+ this.setFetchedComponents(null)
443
+
444
+ try {
445
+ await handlefetchComponents('/components.json', {}, { additionalCallTime: 500 })
446
+ } catch (err) {
447
+ console.log(`Error: ${err}`)
448
+ }
449
+
450
+ // fetchedComponents.value is an object containing a components property
451
+ this.setFetchedComponents(
452
+ fetchedComponents &&
453
+ fetchedComponents.value &&
454
+ typeof fetchedComponents.value === 'object' &&
455
+ 'components' in fetchedComponents.value
456
+ ? (fetchedComponents.value as FetchedComponentsResponse)
457
+ : null,
458
+ )
459
+ },
460
+ },
461
+ })
@@ -0,0 +1,107 @@
1
+ import { defineStore } from 'pinia'
2
+ import { vueFetch } from '@/composables/vueFetch.ts'
3
+
4
+ interface UnsplashState {
5
+ unsplashImages: UnsplashImagesData | null
6
+ searchTerm: string
7
+ currentPageNumber: number
8
+ orientationValue: string | null
9
+ }
10
+
11
+ interface UnsplashImagesData {
12
+ fetchedMedia: unknown
13
+ isError: boolean | null
14
+ error: unknown
15
+ errors: unknown
16
+ isLoading: boolean | null
17
+ isSuccess: boolean | null
18
+ }
19
+
20
+ interface LoadUnsplashImagesPayload {
21
+ orientation?: string
22
+ currentPage: number
23
+ searchTerm?: string
24
+ }
25
+
26
+ // get images
27
+ const {
28
+ handleData: handleGetImages,
29
+ fetchedData: fetchedMedia,
30
+ isError: isErrorImages,
31
+ error: errorImages,
32
+ errors: errorsImages,
33
+ isLoading: isLoadingImages,
34
+ isSuccess: isSuccessImages,
35
+ } = vueFetch()
36
+
37
+ export const useUnsplashStore = defineStore('unsplash', {
38
+ state: (): UnsplashState => ({
39
+ unsplashImages: null,
40
+ searchTerm: '',
41
+ currentPageNumber: 1,
42
+ orientationValue: null,
43
+ }),
44
+ getters: {
45
+ getUnsplashImages: (state: UnsplashState): UnsplashImagesData | null => {
46
+ return state.unsplashImages
47
+ },
48
+ getSearchTerm: (state: UnsplashState): string => state.searchTerm,
49
+ getCurrentPageNumber: (state: UnsplashState): number => state.currentPageNumber,
50
+ getOrientationValue: (state: UnsplashState): string | null => state.orientationValue,
51
+ },
52
+ actions: {
53
+ setUnsplashImages(payload: UnsplashImagesData | null): void {
54
+ this.unsplashImages = payload
55
+ },
56
+ setSearchTerm(payload: string): void {
57
+ this.searchTerm = payload
58
+ },
59
+ setCurrentPageNumber(payload: number): void {
60
+ this.currentPageNumber = payload
61
+ },
62
+ setOrientationValue(payload: string | null): void {
63
+ this.orientationValue = payload
64
+ },
65
+
66
+ // Load Unsplash images
67
+ async setLoadUnsplashImages(payload: LoadUnsplashImagesPayload): Promise<void> {
68
+ this.setUnsplashImages({
69
+ fetchedMedia: null,
70
+ isError: null,
71
+ error: null,
72
+ errors: null,
73
+ isLoading: true,
74
+ isSuccess: null,
75
+ })
76
+
77
+ const orientationType = payload.orientation ? `&orientation=${payload.orientation}` : ''
78
+
79
+ const unsplashKey = import.meta.env.VITE_UNSPLASH_KEY as string
80
+
81
+ try {
82
+ await handleGetImages(
83
+ `https://api.unsplash.com/search/photos?page=${payload.currentPage}&per_page=24&query=${payload.searchTerm || 'a'}${orientationType}`,
84
+ {
85
+ headers: {
86
+ 'Accept-Version': 'v1',
87
+ Authorization: unsplashKey,
88
+ },
89
+ },
90
+ { additionalCallTime: 500 },
91
+ )
92
+ } catch (err) {
93
+ console.log(`Error: ${err}`)
94
+ }
95
+
96
+ // Update state directly instead of committing mutations
97
+ this.setUnsplashImages({
98
+ fetchedMedia: fetchedMedia.value,
99
+ isError: isErrorImages.value,
100
+ error: errorImages.value,
101
+ errors: errorsImages.value,
102
+ isLoading: isLoadingImages.value,
103
+ isSuccess: isSuccessImages.value,
104
+ })
105
+ },
106
+ },
107
+ })
@@ -0,0 +1,30 @@
1
+ import { defineStore } from 'pinia'
2
+
3
+ interface UserState {
4
+ isLoading: boolean
5
+ userSettings: Record<string, unknown> | null
6
+ }
7
+
8
+ interface UserSettings {
9
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
10
+ [key: string]: any
11
+ }
12
+
13
+ export const useUserStore = defineStore('user', {
14
+ state: (): UserState => ({
15
+ isLoading: false,
16
+ userSettings: null,
17
+ }),
18
+ getters: {
19
+ getIsLoading: (state: UserState): boolean => state.isLoading,
20
+ getUserSettings: (state: UserState): UserSettings | null => state.userSettings,
21
+ },
22
+ actions: {
23
+ setIsLoading(payload: boolean): void {
24
+ this.isLoading = payload
25
+ },
26
+ setUserSettings(payload: UserSettings | null): void {
27
+ this.userSettings = payload
28
+ },
29
+ },
30
+ })
@@ -0,0 +1,49 @@
1
+ // Global type declarations for utility modules
2
+ declare module '@/utils/builder/tailwaind-colors' {
3
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
4
+ const tailwindColors: any
5
+ export default tailwindColors
6
+ }
7
+
8
+ declare module '@/utils/builder/tailwind-opacities' {
9
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
10
+ const tailwindOpacities: any
11
+ export default tailwindOpacities
12
+ }
13
+
14
+ declare module '@/utils/builder/tailwind-font-sizes' {
15
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
16
+ const tailwindFontSizes: any
17
+ export default tailwindFontSizes
18
+ }
19
+
20
+ declare module '@/utils/builder/tailwind-font-styles' {
21
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
22
+ const tailwindFontStyles: any
23
+ export default tailwindFontStyles
24
+ }
25
+
26
+ declare module '@/utils/builder/tailwind-padding-margin' {
27
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
28
+ const tailwindPaddingAndMargin: any
29
+ export default tailwindPaddingAndMargin
30
+ }
31
+
32
+ declare module '@/utils/builder/tailwind-border-radius' {
33
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
34
+ const tailwindBorderRadius: any
35
+ export default tailwindBorderRadius
36
+ }
37
+
38
+ declare module '@/utils/builder/tailwind-border-style-width-color' {
39
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
40
+ const tailwindBorderStyleWidthPlusColor: any
41
+ export default tailwindBorderStyleWidthPlusColor
42
+ }
43
+
44
+ declare module '*.vue' {
45
+ import type { DefineComponent } from 'vue'
46
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
47
+ const component: DefineComponent<Record<string, unknown>, Record<string, unknown>, any>
48
+ export default component
49
+ }