@bagelink/blox 1.5.15 → 1.5.20

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 (107) hide show
  1. package/README.md +105 -1
  2. package/dist/blox.css +720 -68
  3. package/dist/components/base/Button.vue.d.ts.map +1 -1
  4. package/dist/components/base/Container.vue.d.ts.map +1 -1
  5. package/dist/components/base/Image.vue.d.ts.map +1 -1
  6. package/dist/components/base/Spacer.vue.d.ts.map +1 -1
  7. package/dist/components/base/Text.vue.d.ts.map +1 -1
  8. package/dist/components/base/Title.vue.d.ts.map +1 -1
  9. package/dist/components/blocks/BigImage.vue.d.ts +12 -0
  10. package/dist/components/blocks/BigImage.vue.d.ts.map +1 -0
  11. package/dist/components/blocks/BigQuote.vue.d.ts +14 -0
  12. package/dist/components/blocks/BigQuote.vue.d.ts.map +1 -0
  13. package/dist/components/blocks/BlockFooter.vue.d.ts +17 -0
  14. package/dist/components/blocks/BlockFooter.vue.d.ts.map +1 -0
  15. package/dist/components/blocks/BlockNav.vue.d.ts +22 -0
  16. package/dist/components/blocks/BlockNav.vue.d.ts.map +1 -0
  17. package/dist/components/blocks/Cards.vue.d.ts +18 -0
  18. package/dist/components/blocks/Cards.vue.d.ts.map +1 -0
  19. package/dist/components/blocks/Contact.vue.d.ts +22 -0
  20. package/dist/components/blocks/Contact.vue.d.ts.map +1 -0
  21. package/dist/components/blocks/CountDown.vue.d.ts +76 -0
  22. package/dist/components/blocks/CountDown.vue.d.ts.map +1 -0
  23. package/dist/components/blocks/Cta.vue.d.ts +15 -0
  24. package/dist/components/blocks/Cta.vue.d.ts.map +1 -0
  25. package/dist/components/blocks/Faq.vue.d.ts +20 -0
  26. package/dist/components/blocks/Faq.vue.d.ts.map +1 -0
  27. package/dist/components/blocks/Grid.vue.d.ts +24 -0
  28. package/dist/components/blocks/Grid.vue.d.ts.map +1 -0
  29. package/dist/components/blocks/Icons.vue.d.ts +16 -0
  30. package/dist/components/blocks/Icons.vue.d.ts.map +1 -0
  31. package/dist/components/blocks/IconsList.vue.d.ts +22 -0
  32. package/dist/components/blocks/IconsList.vue.d.ts.map +1 -0
  33. package/dist/components/blocks/ImageCarousel.vue.d.ts +16 -0
  34. package/dist/components/blocks/ImageCarousel.vue.d.ts.map +1 -0
  35. package/dist/components/blocks/ImageLinkBoxes.vue.d.ts +14 -0
  36. package/dist/components/blocks/ImageLinkBoxes.vue.d.ts.map +1 -0
  37. package/dist/components/blocks/Logos.vue.d.ts +17 -0
  38. package/dist/components/blocks/Logos.vue.d.ts.map +1 -0
  39. package/dist/components/blocks/PopUp.vue.d.ts +23 -0
  40. package/dist/components/blocks/PopUp.vue.d.ts.map +1 -0
  41. package/dist/components/blocks/PriceTable.vue.d.ts +24 -0
  42. package/dist/components/blocks/PriceTable.vue.d.ts.map +1 -0
  43. package/dist/components/blocks/Space.vue.d.ts +25 -0
  44. package/dist/components/blocks/Space.vue.d.ts.map +1 -0
  45. package/dist/components/blocks/Tabs.vue.d.ts +15 -0
  46. package/dist/components/blocks/Tabs.vue.d.ts.map +1 -0
  47. package/dist/components/blocks/Team.vue.d.ts +19 -0
  48. package/dist/components/blocks/Team.vue.d.ts.map +1 -0
  49. package/dist/components/blocks/Testimonials.vue.d.ts +18 -0
  50. package/dist/components/blocks/Testimonials.vue.d.ts.map +1 -0
  51. package/dist/components/blocks/Text.vue.d.ts +10 -0
  52. package/dist/components/blocks/Text.vue.d.ts.map +1 -0
  53. package/dist/components/blocks/TextImage.vue.d.ts +20 -0
  54. package/dist/components/blocks/TextImage.vue.d.ts.map +1 -0
  55. package/dist/components/blocks/TextSide.vue.d.ts +19 -0
  56. package/dist/components/blocks/TextSide.vue.d.ts.map +1 -0
  57. package/dist/components/blocks/Title.vue.d.ts +16 -0
  58. package/dist/components/blocks/Title.vue.d.ts.map +1 -0
  59. package/dist/components/blocks/TitleSide.vue.d.ts +21 -0
  60. package/dist/components/blocks/TitleSide.vue.d.ts.map +1 -0
  61. package/dist/components/blocks/VideoBox.vue.d.ts +15 -0
  62. package/dist/components/blocks/VideoBox.vue.d.ts.map +1 -0
  63. package/dist/components/blocks/blocks.d.ts +27 -0
  64. package/dist/components/blocks/blocks.d.ts.map +1 -0
  65. package/dist/components/index.d.ts +4 -3
  66. package/dist/components/index.d.ts.map +1 -1
  67. package/dist/config/baseComponents.d.ts +12 -2
  68. package/dist/config/baseComponents.d.ts.map +1 -1
  69. package/dist/config/blockComponents.d.ts +41 -0
  70. package/dist/config/blockComponents.d.ts.map +1 -0
  71. package/dist/core/communication.d.ts.map +1 -1
  72. package/dist/core/registry.d.ts.map +1 -1
  73. package/dist/core/renderer.d.ts.map +1 -1
  74. package/dist/core/types.d.ts.map +1 -1
  75. package/dist/index.cjs +9420 -480
  76. package/dist/index.d.ts +4 -1
  77. package/dist/index.d.ts.map +1 -1
  78. package/dist/index.mjs +9325 -478
  79. package/dist/setup.d.ts +114 -6
  80. package/dist/setup.d.ts.map +1 -1
  81. package/dist/utils/componentPreviewGenerator.d.ts +113 -0
  82. package/dist/utils/componentPreviewGenerator.d.ts.map +1 -0
  83. package/dist/utils/normalizer.d.ts.map +1 -1
  84. package/dist/utils/styles.d.ts.map +1 -1
  85. package/dist/views/ExternalPreview.vue.d.ts.map +1 -1
  86. package/dist/views/RenderPage.vue.d.ts.map +1 -1
  87. package/package.json +5 -2
  88. package/components/base/Button.vue +0 -140
  89. package/components/base/Container.vue +0 -64
  90. package/components/base/Image.vue +0 -75
  91. package/components/base/Spacer.vue +0 -33
  92. package/components/base/Text.vue +0 -37
  93. package/components/base/Title.vue +0 -55
  94. package/components/index.ts +0 -20
  95. package/config/baseComponents.ts +0 -342
  96. package/core/communication.ts +0 -140
  97. package/core/registry.ts +0 -108
  98. package/core/renderer.ts +0 -217
  99. package/core/types.ts +0 -148
  100. package/dist/vite.config.d.ts +0 -3
  101. package/dist/vite.config.d.ts.map +0 -1
  102. package/index.ts +0 -33
  103. package/setup.ts +0 -56
  104. package/utils/normalizer.ts +0 -74
  105. package/utils/styles.ts +0 -228
  106. package/views/ExternalPreview.vue +0 -420
  107. package/views/RenderPage.vue +0 -127
package/core/renderer.ts DELETED
@@ -1,217 +0,0 @@
1
- /**
2
- * Core Rendering Logic
3
- *
4
- * Handles the rendering of page components with proper style injection
5
- */
6
-
7
- import type { PageData, ComponentData } from './types'
8
- import { getResponsiveCSS } from '../utils/styles'
9
-
10
- /**
11
- * Inject responsive CSS into the page
12
- */
13
- export function injectResponsiveCSS(): void {
14
- // Check if already injected
15
- if (document.getElementById('blox-responsive-css')) {
16
- return
17
- }
18
-
19
- const style = document.createElement('style')
20
- style.id = 'blox-responsive-css'
21
- style.textContent = getResponsiveCSS()
22
- document.head.appendChild(style)
23
- }
24
-
25
- /**
26
- * Inject custom code into head or body
27
- */
28
- export function injectCode(code: string | undefined, target: 'head' | 'body'): void {
29
- if (!code) return
30
-
31
- const element = document.querySelector(target)
32
- if (element) {
33
- const div = document.createElement('div')
34
- div.innerHTML = code
35
- element.appendChild(div)
36
- }
37
- }
38
-
39
- /**
40
- * Load a Google Font
41
- */
42
- const loadedFonts = new Set<string>()
43
-
44
- export function loadGoogleFont(fontName: string): Promise<void> {
45
- if (!fontName || loadedFonts.has(fontName)) {
46
- return Promise.resolve()
47
- }
48
-
49
- return new Promise((resolve, reject) => {
50
- const cleanFontName = fontName.trim().replace(/\s+/g, '+')
51
- const fontUrl = `https://fonts.googleapis.com/css2?family=${cleanFontName}:wght@400;500;600;700&display=swap`
52
-
53
- const linkElement = document.createElement('link')
54
- linkElement.rel = 'stylesheet'
55
- linkElement.href = fontUrl
56
- linkElement.setAttribute('data-font-name', fontName)
57
-
58
- linkElement.onload = () => {
59
- console.log(`✅ Font loaded: ${fontName}`)
60
- loadedFonts.add(fontName)
61
- resolve()
62
- }
63
-
64
- linkElement.onerror = () => {
65
- console.error(`❌ Failed to load font: ${fontName}`)
66
- reject(new Error(`Failed to load font: ${fontName}`))
67
- }
68
-
69
- document.head.appendChild(linkElement)
70
- })
71
- }
72
-
73
- /**
74
- * Load all fonts used in components
75
- */
76
- export async function loadComponentFonts(components: ComponentData[]): Promise<void> {
77
- const fontsToLoad = new Set<string>()
78
-
79
- components.forEach((comp) => {
80
- if (comp.data?.fontFamily) {
81
- fontsToLoad.add(comp.data.fontFamily)
82
- }
83
- if (comp.data?.fontFamilyMobile) {
84
- fontsToLoad.add(comp.data.fontFamilyMobile)
85
- }
86
- })
87
-
88
- await Promise.all(Array.from(fontsToLoad).map(font => loadGoogleFont(font)))
89
- }
90
-
91
- /**
92
- * Apply global font to the page
93
- */
94
- export function applyGlobalFont(fontName: string): void {
95
- if (!fontName) return
96
-
97
- // Remove existing global font styles
98
- const existingStyle = document.getElementById('blox-global-font')
99
- if (existingStyle) {
100
- existingStyle.remove()
101
- }
102
-
103
- // Apply font globally
104
- const style = document.createElement('style')
105
- style.id = 'blox-global-font'
106
- style.textContent = `
107
- body {
108
- font-family: "${fontName}", sans-serif;
109
- }
110
- .blox-page-wrapper {
111
- font-family: "${fontName}", sans-serif !important;
112
- }
113
- .blox-page-wrapper * {
114
- font-family: inherit;
115
- }
116
- `
117
- document.head.appendChild(style)
118
-
119
- // Load the font
120
- loadGoogleFont(fontName)
121
- }
122
-
123
- /**
124
- * Apply page settings to the document
125
- */
126
- export function applyPageSettings(pageData: PageData): void {
127
- const { pageSettings } = pageData
128
-
129
- if (!pageSettings) return
130
-
131
- // Language and direction
132
- if (pageSettings.pageLanguage) {
133
- document.documentElement.lang = pageSettings.pageLanguage
134
- }
135
-
136
- if (pageSettings.pageDirection) {
137
- document.documentElement.dir = pageSettings.pageDirection
138
- document.body.dir = pageSettings.pageDirection
139
- }
140
-
141
- // Font
142
- if (pageSettings.selectedGoogleFont) {
143
- applyGlobalFont(pageSettings.selectedGoogleFont)
144
- }
145
-
146
- // Custom codes
147
- injectCode(pageSettings.additionalHeadCode, 'head')
148
- injectCode(pageSettings.additionalBodyCode, 'body')
149
-
150
- // Favicon
151
- if (pageSettings.customFavicon) {
152
- let faviconLink = document.querySelector('link[rel="icon"]') as HTMLLinkElement
153
- if (!faviconLink) {
154
- faviconLink = document.createElement('link')
155
- faviconLink.rel = 'icon'
156
- document.head.appendChild(faviconLink)
157
- }
158
- faviconLink.href = pageSettings.customFavicon
159
- }
160
-
161
- // Meta tags
162
- applyMetaTags(pageSettings)
163
- }
164
-
165
- /**
166
- * Apply meta tags
167
- */
168
- function applyMetaTags(settings: any): void {
169
- // OG Image
170
- if (settings.customOgImage) {
171
- updateOrCreateMeta('og:image', settings.customOgImage, 'property')
172
- }
173
-
174
- // Keywords
175
- if (settings.customKeywords) {
176
- updateOrCreateMeta('keywords', settings.customKeywords)
177
- }
178
-
179
- // Robots
180
- if (settings.customRobotsMeta) {
181
- updateOrCreateMeta('robots', settings.customRobotsMeta)
182
- }
183
- }
184
-
185
- /**
186
- * Helper to update or create meta tags
187
- */
188
- function updateOrCreateMeta(name: string, content: string, attribute: 'name' | 'property' = 'name'): void {
189
- const selector = `meta[${attribute}="${name}"]`
190
- let metaTag = document.querySelector(selector) as HTMLMetaElement
191
-
192
- if (!metaTag) {
193
- metaTag = document.createElement('meta')
194
- metaTag.setAttribute(attribute, name)
195
- document.head.appendChild(metaTag)
196
- }
197
-
198
- metaTag.content = content
199
- }
200
-
201
- /**
202
- * Initialize the page for rendering
203
- */
204
- export async function initializePage(pageData: PageData): Promise<void> {
205
- // Inject responsive CSS
206
- injectResponsiveCSS()
207
-
208
- // Apply page settings
209
- applyPageSettings(pageData)
210
-
211
- // Load component fonts
212
- await loadComponentFonts(pageData.components)
213
-
214
- // Inject header and body codes
215
- injectCode(pageData.header_code, 'head')
216
- injectCode(pageData.body_code, 'body')
217
- }
package/core/types.ts DELETED
@@ -1,148 +0,0 @@
1
- /**
2
- * Core type definitions for the Blox external preview library
3
- */
4
-
5
- // Component data structure
6
- export interface ComponentData {
7
- id: string
8
- type: string
9
- data: Record<string, any>
10
- }
11
-
12
- // Page structure
13
- export interface PageData {
14
- id?: string
15
- components: ComponentData[]
16
- pageSettings?: PageSettings
17
- header_code?: string
18
- body_code?: string
19
- language?: Record<string, any>
20
- }
21
-
22
- // Page settings
23
- export interface PageSettings {
24
- selectedGoogleFont?: string
25
- pageLanguage?: string
26
- pageDirection?: 'ltr' | 'rtl'
27
- additionalHeadCode?: string
28
- additionalBodyCode?: string
29
- customFavicon?: string
30
- customOgImage?: string
31
- customKeywords?: string
32
- customRobotsMeta?: string
33
- customAnalyticsCode?: string
34
- disableGlobalHeadCode?: boolean
35
- disableGlobalBodyCode?: boolean
36
- disableGoogleAnalytics?: boolean
37
- disableFacebookPixel?: boolean
38
- }
39
-
40
- // Global settings
41
- export interface GlobalSettings {
42
- selectedGoogleFont?: string
43
- pageLanguage?: string
44
- pageDirection?: 'ltr' | 'rtl'
45
- globalHeadCode?: string
46
- globalBodyCode?: string
47
- favicon?: string
48
- ogImage?: string
49
- siteKeywords?: string
50
- googleAnalyticsId?: string
51
- facebookPixelId?: string
52
- }
53
-
54
- // Message types for postMessage communication
55
- export type MessageType =
56
- | 'ready'
57
- | 'update'
58
- | 'focus'
59
- | 'highlight'
60
- | 'preview'
61
- | 'meta'
62
- | 'delete'
63
- | 'disableLinks'
64
- | 'newBlock'
65
-
66
- export interface EditorMessage {
67
- type: MessageType
68
- message?: any
69
- data?: any
70
- isMobile?: boolean
71
- }
72
-
73
- // Component props interface
74
- export interface BlockProps {
75
- isMobile?: boolean
76
- [key: string]: any
77
- }
78
-
79
- // Style configuration
80
- export interface StyleConfig {
81
- // Spacing
82
- marginTop?: number
83
- marginBottom?: number
84
- marginTopMobile?: number
85
- marginBottomMobile?: number
86
- padding?: number
87
- paddingMobile?: number
88
-
89
- // Width
90
- width?: number
91
- widthMobile?: number
92
- widthPercent?: number
93
- widthPercentMobile?: number
94
- fullWidth?: boolean
95
- fullWidthMobile?: boolean
96
-
97
- // Colors
98
- backgroundColor?: string
99
- backgroundColorMobile?: string
100
- textColor?: string
101
- textColorMobile?: string
102
-
103
- // Border
104
- borderWidth?: number
105
- borderWidthMobile?: number
106
- borderStyle?: string
107
- borderStyleMobile?: string
108
- borderColor?: string
109
- borderColorMobile?: string
110
- borderRadius?: number
111
- borderRadiusMobile?: number
112
-
113
- // Typography
114
- fontFamily?: string
115
- fontFamilyMobile?: string
116
- center?: boolean
117
- centerMobile?: boolean
118
-
119
- // Effects
120
- shadowType?: 'none' | 'sm' | 'md' | 'lg' | 'xl' | 'custom'
121
- shadowTypeMobile?: 'none' | 'sm' | 'md' | 'lg' | 'xl' | 'custom'
122
- zIndex?: number
123
- zIndexMobile?: number
124
-
125
- // Visibility
126
- showDesktop?: boolean
127
- showMobile?: boolean
128
-
129
- // Custom
130
- customId?: string
131
- customCSS?: string
132
- }
133
-
134
- // Registry types
135
- export type ComponentConstructor = any // Vue component constructor
136
-
137
- export interface ComponentRegistry {
138
- [key: string]: ComponentConstructor
139
- }
140
-
141
- // Renderer configuration
142
- export interface RendererConfig {
143
- components: ComponentRegistry
144
- pageData: PageData
145
- isMobile?: boolean
146
- previewMode?: boolean
147
- editorMode?: boolean
148
- }
@@ -1,3 +0,0 @@
1
- declare const _default: import('vite').UserConfigFnObject;
2
- export default _default;
3
- //# sourceMappingURL=vite.config.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"vite.config.d.ts","sourceRoot":"","sources":["../vite.config.ts"],"names":[],"mappings":";AASA,wBAoCG"}
package/index.ts DELETED
@@ -1,33 +0,0 @@
1
- /**
2
- * Blox External Preview Library
3
- * Main entry point
4
- */
5
-
6
- // Component exports
7
- export * from './components'
8
- // Configuration exports
9
- export * from './config/baseComponents'
10
- export * from './core/communication'
11
- export * from './core/registry'
12
-
13
- export * from './core/renderer'
14
- // Core exports
15
- export * from './core/types'
16
-
17
- // Setup and registration helpers
18
- export {
19
- createComponentConfig,
20
- getAllComponentConfigs,
21
- registerBaseComponents,
22
- registerCustomComponent,
23
- registerCustomComponents,
24
- } from './setup'
25
-
26
- export * from './utils/normalizer'
27
-
28
- // Utility exports
29
- export * from './utils/styles'
30
-
31
- // View exports
32
- export { default as ExternalPreview } from './views/ExternalPreview.vue'
33
- export { default as RenderPage } from './views/RenderPage.vue'
package/setup.ts DELETED
@@ -1,56 +0,0 @@
1
- /**
2
- * Blox Setup and Registration
3
- *
4
- * Handles automatic registration of base components and provides
5
- * configuration helpers for external projects.
6
- */
7
-
8
- import { baseComponentConfigs, type ComponentConfig } from './config/baseComponents'
9
- import { registerComponent, registerComponents } from './core/registry'
10
-
11
- /**
12
- * Register all base components from the library
13
- * Call this in your project's setup to make base components available
14
- */
15
- export function registerBaseComponents(): void {
16
- const componentMap: Record<string, any> = {}
17
-
18
- baseComponentConfigs.forEach((config) => {
19
- componentMap[config.id] = config.component
20
- })
21
-
22
- registerComponents(componentMap)
23
- console.log('✅ Registered base components:', Object.keys(componentMap))
24
- }
25
-
26
- /**
27
- * Get all component configurations (base + custom)
28
- * This returns both the Vue components and their editor schemas
29
- */
30
- export function getAllComponentConfigs(customConfigs: ComponentConfig[] = []): ComponentConfig[] {
31
- return [...baseComponentConfigs, ...customConfigs]
32
- }
33
-
34
- /**
35
- * Helper to create a custom component configuration
36
- */
37
- export function createComponentConfig(config: ComponentConfig): ComponentConfig {
38
- return config
39
- }
40
-
41
- /**
42
- * Register a single custom component
43
- */
44
- export function registerCustomComponent(config: ComponentConfig): void {
45
- registerComponent(config.id, config.component)
46
- console.log(`✅ Registered custom component: ${config.id}`)
47
- }
48
-
49
- /**
50
- * Register multiple custom components
51
- */
52
- export function registerCustomComponents(configs: ComponentConfig[]): void {
53
- configs.forEach((config) => {
54
- registerCustomComponent(config)
55
- })
56
- }
@@ -1,74 +0,0 @@
1
- /**
2
- * Data Normalization Utilities
3
- *
4
- * Normalizes component data for proper rendering
5
- */
6
-
7
- /**
8
- * Convert string values to proper types for component props
9
- */
10
- export function normalizeComponentData(data: Record<string, any>): Record<string, any> {
11
- const normalized: Record<string, any> = {}
12
-
13
- // Fields that should remain as strings even if they look like numbers
14
- const stringFields = ['title', 'subTitle', 'btnTxt', 'tag', 'customId', 'height', 'url', 'href']
15
-
16
- for (const [key, value] of Object.entries(data)) {
17
- if (typeof value === 'string') {
18
- // Convert string booleans to actual booleans
19
- if (value === 'true') {
20
- normalized[key] = true
21
- } else if (value === 'false') {
22
- normalized[key] = false
23
- } else if (!Number.isNaN(Number(value)) && value !== '' && !stringFields.includes(key)) {
24
- // Convert string numbers to numbers (but not for text fields)
25
- normalized[key] = Number(value)
26
- } else {
27
- normalized[key] = value
28
- }
29
- } else {
30
- normalized[key] = value
31
- }
32
- }
33
-
34
- // Provide default props to avoid Vue warnings for missing required props
35
- if (!normalized.items) {
36
- normalized.items = []
37
- }
38
-
39
- // Ensure height is always a string if it exists
40
- if (normalized.height !== undefined && typeof normalized.height === 'number') {
41
- normalized.height = String(normalized.height)
42
- }
43
-
44
- if (normalized.height === 'auto') {
45
- // Convert auto height strings to valid numbers for components that expect numbers
46
- delete normalized.height
47
- }
48
-
49
- return normalized
50
- }
51
-
52
- /**
53
- * Deep clone an object
54
- */
55
- export function deepClone<T>(obj: T): T {
56
- return JSON.parse(JSON.stringify(obj))
57
- }
58
-
59
- /**
60
- * Merge objects deeply
61
- */
62
- export function deepMerge(target: any, source: any): any {
63
- const result = { ...target }
64
-
65
- for (const key in source) {
66
- if (source[key] && typeof source[key] === 'object' && !Array.isArray(source[key])) {
67
- result[key] = deepMerge(result[key] || {}, source[key])
68
- } else {
69
- result[key] = source[key]
70
- }
71
- }
72
-
73
- return result
74
- }