@woodsportal/hubspot-kit 1.0.3 → 1.0.5
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.
- package/dist/cli.js +24 -1
- package/dist/cli.js.map +1 -1
- package/examples/greenfield/module-hybrid-cdn/src/assets/css/main.dev.css +3 -0
- package/examples/greenfield/module-hybrid-cdn/src/defaultData.ts +7 -0
- package/examples/greenfield/module-hybrid-cdn/src/hubspot/types.ts +17 -0
- package/examples/greenfield/module-hybrid-cdn/src/main.tsx +4 -2
- package/examples/greenfield/module-monolith/src/defaultData.ts +7 -0
- package/package.json +5 -1
- package/src/dev/bootstrap-greenfield.tsx +51 -0
- package/src/dev/bootstrap.tsx +46 -0
- package/src/dev-module-config/__tests__/fixtures/fields.json +3014 -0
- package/src/dev-module-config/__tests__/fixtures/golden-module.fixture.ts +102 -0
- package/src/dev-module-config/__tests__/module-config-storage.test.ts +40 -0
- package/src/dev-module-config/__tests__/module-config-transform.test.ts +55 -0
- package/src/dev-module-config/__tests__/normalize-repeater-items.test.ts +46 -0
- package/src/dev-module-config/runtime/module-config-bridge.ts +27 -0
- package/src/dev-module-config/runtime/module-config-runtime.ts +185 -0
- package/src/dev-module-config/schema/build-default-item.ts +7 -0
- package/src/dev-module-config/schema/deep-merge.ts +27 -0
- package/src/dev-module-config/schema/extract-defaults.ts +62 -0
- package/src/dev-module-config/schema/normalize-choices.ts +18 -0
- package/src/dev-module-config/schema/normalize-repeater-items.ts +31 -0
- package/src/dev-module-config/schema/parse-fields-json.ts +2 -0
- package/src/dev-module-config/schema/types.ts +75 -0
- package/src/dev-module-config/schema/validate-module-config.ts +81 -0
- package/src/dev-module-config/schema/visibility.ts +130 -0
- package/src/dev-module-config/storage/config-json.ts +46 -0
- package/src/dev-module-config/storage/workspace-store.ts +139 -0
- package/src/dev-module-config/transform/build-hubspot-data.ts +409 -0
- package/src/dev-module-config/ui/FieldRenderer.tsx +353 -0
- package/src/dev-module-config/ui/ModuleConfigAnimatedPresence.tsx +72 -0
- package/src/dev-module-config/ui/ModuleConfigCollapsible.tsx +43 -0
- package/src/dev-module-config/ui/ModuleConfigDockSideIcon.tsx +27 -0
- package/src/dev-module-config/ui/ModuleConfigOverlay.tsx +134 -0
- package/src/dev-module-config/ui/ModuleConfigPersistenceStatus.tsx +89 -0
- package/src/dev-module-config/ui/ModuleConfigShell.tsx +354 -0
- package/src/dev-module-config/ui/ModuleConfigThemeToggle.tsx +32 -0
- package/src/dev-module-config/ui/ModuleConfigUiContext.tsx +65 -0
- package/src/dev-module-config/ui/editors/DeveloperOptionsEditor.tsx +61 -0
- package/src/dev-module-config/ui/editors/MenuOptionsEditor.tsx +103 -0
- package/src/dev-module-config/ui/hubspot/HsColorField.tsx +106 -0
- package/src/dev-module-config/ui/hubspot/HsColorPickerPopover.tsx +210 -0
- package/src/dev-module-config/ui/hubspot/HsFieldLabel.tsx +24 -0
- package/src/dev-module-config/ui/hubspot/HsFieldWidgets.tsx +248 -0
- package/src/dev-module-config/ui/hubspot/HsImageField.tsx +112 -0
- package/src/dev-module-config/ui/hubspot/HsOccurrenceGroupEditor.tsx +243 -0
- package/src/dev-module-config/ui/hubspot/HsRepeaterList.tsx +178 -0
- package/src/dev-module-config/ui/hubspot/HsSectionHeader.tsx +20 -0
- package/src/dev-module-config/ui/hubspot/HsToggle.tsx +39 -0
- package/src/dev-module-config/ui/hubspot/HsToggleRow.tsx +30 -0
- package/src/dev-module-config/ui/hubspot/hs-color-palette.ts +11 -0
- package/src/dev-module-config/ui/hubspot/module-config-typography.ts +26 -0
- package/src/dev-module-config/ui/module-config-motion.css +134 -0
- package/src/dev-module-config/ui/module-config-motion.ts +28 -0
- package/src/dev-module-config/ui/module-config-overlay-side.ts +29 -0
- package/src/dev-module-config/ui/module-config-surfaces.ts +27 -0
- package/src/dev-module-config/ui/module-config-theme.css +483 -0
- package/src/dev-module-config/ui/module-config-toolbar-theme.ts +35 -0
- package/src/dev-module-config/ui/navigation/ModuleConfigNavContext.tsx +188 -0
- package/src/dev-module-config/ui/use-dev-module-config-live-revision.ts +22 -0
- package/src/dev-module-config/ui/use-hubspot-live-exports.ts +27 -0
- package/src/dev-module-config/ui/use-module-config.ts +124 -0
- package/src/routing/build-api-routes.ts +37 -0
- package/src/routing/route-format.ts +19 -0
- package/templates/module-hybrid-cdn/index.html +12 -1
- package/templates/module-hybrid-cdn/package.json +1 -1
- package/templates/module-hybrid-cdn/src/assets/css/main.dev.css +3 -0
- package/templates/module-hybrid-cdn/src/defaultData.ts +7 -0
- package/templates/module-hybrid-cdn/src/hubspot/types.ts +17 -0
- package/templates/module-hybrid-cdn/src/main.tsx +4 -2
- package/templates/module-monolith/index.html +12 -0
- package/templates/module-monolith/package.json +1 -1
- package/templates/module-monolith/src/assets/css/main.dev.css +3 -0
- package/templates/module-monolith/src/defaultData.ts +7 -0
- package/templates/module-monolith/src/hubspot/types.ts +17 -0
- package/templates/module-monolith/src/main.tsx +4 -0
- package/templates/theme-starter/package.json +1 -1
- package/vite/vite.config.dev.mjs +7 -1
|
@@ -0,0 +1,409 @@
|
|
|
1
|
+
import type { ModuleFieldValues } from '../schema/types'
|
|
2
|
+
import { normalizeRepeaterItems } from '../schema/normalize-repeater-items'
|
|
3
|
+
|
|
4
|
+
type ColorValue = { color?: string; opacity?: number | string }
|
|
5
|
+
|
|
6
|
+
function colorHex(value: ColorValue | undefined): string {
|
|
7
|
+
return value?.color ?? ''
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function colorRgba(value: ColorValue | undefined): string {
|
|
11
|
+
if (!value?.color) return ''
|
|
12
|
+
const opacity = Number(value.opacity)
|
|
13
|
+
const alpha = Number.isFinite(opacity) ? opacity / 100 : 1
|
|
14
|
+
const hex = value.color.replace('#', '')
|
|
15
|
+
if (hex.length !== 6) return value.color
|
|
16
|
+
const r = parseInt(hex.slice(0, 2), 16)
|
|
17
|
+
const g = parseInt(hex.slice(2, 4), 16)
|
|
18
|
+
const b = parseInt(hex.slice(4, 6), 16)
|
|
19
|
+
return `rgba(${r}, ${g}, ${b}, ${alpha})`
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function hexWithAlphaSuffix(hex: string, suffix: string): string {
|
|
23
|
+
if (!hex) return ''
|
|
24
|
+
return `${hex}${suffix}`
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function getNested(module: ModuleFieldValues | undefined, path: string): unknown {
|
|
28
|
+
if (!module) return undefined
|
|
29
|
+
return path.split('.').reduce<unknown>((acc, key) => {
|
|
30
|
+
if (acc === null || acc === undefined || typeof acc !== 'object') return undefined
|
|
31
|
+
return (acc as Record<string, unknown>)[key]
|
|
32
|
+
}, module)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function imageSrc(value: unknown): string {
|
|
36
|
+
if (!value || typeof value !== 'object') return ''
|
|
37
|
+
const src = (value as { src?: string }).src
|
|
38
|
+
return src ?? ''
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function buildRouteLists(module: ModuleFieldValues) {
|
|
42
|
+
const iframeList: Array<Record<string, unknown>> = []
|
|
43
|
+
const dynamicSidebarList: Array<Record<string, unknown>> = []
|
|
44
|
+
const dynamicRouteList: Array<Record<string, unknown>> = []
|
|
45
|
+
|
|
46
|
+
const home = getNested(module, 'home') as ModuleFieldValues | undefined
|
|
47
|
+
const addHomeTab = Boolean(module.add_home_tab)
|
|
48
|
+
|
|
49
|
+
if (addHomeTab && home) {
|
|
50
|
+
const rightSidebarItems = normalizeRepeaterItems(home.right_sidebar_object)
|
|
51
|
+
if (home.add_right_sidebar && rightSidebarItems.length > 0) {
|
|
52
|
+
for (const item of rightSidebarItems) {
|
|
53
|
+
iframeList.push({
|
|
54
|
+
label: home.tab_name,
|
|
55
|
+
tabName: home.tab_name,
|
|
56
|
+
showIframe: item.show_iframe,
|
|
57
|
+
propertyName: item.property_name,
|
|
58
|
+
iframeProperties: item.iframe_properties,
|
|
59
|
+
hubspotObjectTypeId: item.object_type_id,
|
|
60
|
+
})
|
|
61
|
+
dynamicSidebarList.push({
|
|
62
|
+
label: item.list_object_name,
|
|
63
|
+
icon: item.icon_svg_code,
|
|
64
|
+
showIframe: item.show_iframe,
|
|
65
|
+
propertyName: item.property_name,
|
|
66
|
+
iframeProperties: item.iframe_properties,
|
|
67
|
+
listObjectName: item.list_object_name,
|
|
68
|
+
listObjectProperties: item.list_object_properties,
|
|
69
|
+
associateObjectName: item.association_object_name,
|
|
70
|
+
hubspotObjectId: item.association_object_type_id,
|
|
71
|
+
hubspotObjectTypeId: item.object_type_id,
|
|
72
|
+
associateObjectProperties: item.association_object_properties,
|
|
73
|
+
companyAsMediator: item.mediator_object_type_id,
|
|
74
|
+
pipeLineId: item.pipeline_id,
|
|
75
|
+
specPipeLine: item.add_specific_pipeline,
|
|
76
|
+
objectType: 'HUBSPOT_DEFINED',
|
|
77
|
+
})
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
dynamicRouteList.push({
|
|
82
|
+
tabName: home.tab_name,
|
|
83
|
+
homeCardsView: home.view,
|
|
84
|
+
icon: home.icon_svg_code,
|
|
85
|
+
})
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const menuOptions = getNested(module, 'menu_options') as ModuleFieldValues | undefined
|
|
89
|
+
const menuObjects = normalizeRepeaterItems(menuOptions?.objects)
|
|
90
|
+
if (menuOptions?.hubspot_defined_object && menuObjects.length > 0) {
|
|
91
|
+
for (const item of menuObjects) {
|
|
92
|
+
iframeList.push({
|
|
93
|
+
label: item.list_object_name,
|
|
94
|
+
tabName: item.tab_name,
|
|
95
|
+
showIframe: item.show_iframe,
|
|
96
|
+
propertyName: item.property_name,
|
|
97
|
+
iframeProperties: item.iframe_properties,
|
|
98
|
+
hubspotObjectTypeId: item.object_type_id,
|
|
99
|
+
})
|
|
100
|
+
dynamicRouteList.push({
|
|
101
|
+
label: item.list_object_name,
|
|
102
|
+
objectDescription: item.object_description,
|
|
103
|
+
objectUserProperties: item.properties,
|
|
104
|
+
objectUserPropertiesView: item.view,
|
|
105
|
+
icon: item.icon_svg_code,
|
|
106
|
+
showIframe: item.show_iframe,
|
|
107
|
+
propertyName: item.property_name,
|
|
108
|
+
iframeProperties: item.iframe_properties,
|
|
109
|
+
listObjectName: item.list_object_name,
|
|
110
|
+
listObjectProperties: item.list_object_properties,
|
|
111
|
+
associateObjectName: item.association_object_name,
|
|
112
|
+
hubspotObjectId: item.association_object_type_id,
|
|
113
|
+
hubspotObjectTypeId: item.object_type_id,
|
|
114
|
+
associateObjectProperties: item.association_object_properties,
|
|
115
|
+
companyAsMediator: item.mediator_object_type_id,
|
|
116
|
+
pipeLineId: item.pipeline_id,
|
|
117
|
+
specPipeLine: item.add_specific_pipeline,
|
|
118
|
+
objectType: 'HUBSPOT_DEFINED',
|
|
119
|
+
})
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const customMenuObjects = normalizeRepeaterItems(menuOptions?.hubspot_custom_objects)
|
|
124
|
+
if (menuOptions?.hubspot_custom_object && customMenuObjects.length > 0) {
|
|
125
|
+
for (const item of customMenuObjects) {
|
|
126
|
+
iframeList.push({
|
|
127
|
+
label: item.list_object_name,
|
|
128
|
+
tabName: item.tab_name,
|
|
129
|
+
showIframe: item.show_iframe,
|
|
130
|
+
propertyName: item.property_name,
|
|
131
|
+
iframeProperties: item.iframe_properties,
|
|
132
|
+
hubspotObjectTypeId: item.object_type_id,
|
|
133
|
+
})
|
|
134
|
+
dynamicRouteList.push({
|
|
135
|
+
label: item.list_object_name,
|
|
136
|
+
objectDescription: item.object_description,
|
|
137
|
+
objectUserProperties: item.properties,
|
|
138
|
+
objectUserPropertiesView: item.view,
|
|
139
|
+
icon: item.icon_svg_code,
|
|
140
|
+
showIframe: item.show_iframe,
|
|
141
|
+
propertyName: item.property_name,
|
|
142
|
+
iframeProperties: item.iframe_properties,
|
|
143
|
+
listObjectName: item.list_object_name,
|
|
144
|
+
listObjectProperties: item.list_object_properties,
|
|
145
|
+
associateObjectName: item.association_object_name,
|
|
146
|
+
hubspotObjectId: item.association_object_type_id,
|
|
147
|
+
hubspotObjectTypeId: item.object_type_id,
|
|
148
|
+
associateObjectProperties: item.association_object_properties,
|
|
149
|
+
companyAsMediator: item.mediator_object_type_id,
|
|
150
|
+
pipeLineId: item.pipeline_id,
|
|
151
|
+
specPipeLine: item.add_specific_pipeline,
|
|
152
|
+
objectType: 'USER_DEFINED',
|
|
153
|
+
})
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
return { iframeList, dynamicSidebarList, dynamicRouteList }
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function buildModuleStylesOptions(module: ModuleFieldValues) {
|
|
161
|
+
const style = getNested(module, 'style') as ModuleFieldValues | undefined
|
|
162
|
+
const homeTab = getNested(style, 'home_tab_styles') as ModuleFieldValues | undefined
|
|
163
|
+
const buttonStyles = getNested(homeTab, 'button_styles') as ModuleFieldValues | undefined
|
|
164
|
+
const sidebar = getNested(style, 'sidebar_styles') as ModuleFieldValues | undefined
|
|
165
|
+
const listPage = getNested(style, 'list_page_styles') as ModuleFieldValues | undefined
|
|
166
|
+
const details = getNested(style, 'details_page_styles') as ModuleFieldValues | undefined
|
|
167
|
+
const banner = getNested(details, 'banner_background_options') as ModuleFieldValues | undefined
|
|
168
|
+
const createBtn = getNested(style, 'table_record_creation_button') as ModuleFieldValues | undefined
|
|
169
|
+
const rightTables = getNested(style, 'd_h_sidebar') as ModuleFieldValues | undefined
|
|
170
|
+
const notes = getNested(style, 'note_cards') as ModuleFieldValues | undefined
|
|
171
|
+
|
|
172
|
+
return {
|
|
173
|
+
homeTabStyles: {
|
|
174
|
+
headingColor: colorHex(homeTab?.home_tab_banner_text_color as ColorValue),
|
|
175
|
+
descriptionColor: colorHex(homeTab?.description_color as ColorValue),
|
|
176
|
+
buttonStyles: {
|
|
177
|
+
backgroundColor: colorHex(buttonStyles?.background_color as ColorValue),
|
|
178
|
+
textColor: colorHex(buttonStyles?.text_color as ColorValue),
|
|
179
|
+
},
|
|
180
|
+
overlayer: {
|
|
181
|
+
color: colorHex(homeTab?.banner_overlayer_color as ColorValue),
|
|
182
|
+
opacity: String((homeTab?.banner_overlayer_color as ColorValue)?.opacity ?? ''),
|
|
183
|
+
},
|
|
184
|
+
svgColor: {
|
|
185
|
+
color: colorHex(homeTab?.user_card_svg_color as ColorValue),
|
|
186
|
+
opacity: String((homeTab?.user_card_svg_color as ColorValue)?.opacity ?? ''),
|
|
187
|
+
},
|
|
188
|
+
},
|
|
189
|
+
sidebarStyles: {
|
|
190
|
+
textColor: colorHex(sidebar?.text_color as ColorValue),
|
|
191
|
+
backgroundColor: colorHex(sidebar?.sidebar_background_color as ColorValue),
|
|
192
|
+
},
|
|
193
|
+
listPageStyles: {
|
|
194
|
+
textColor: colorHex(listPage?.heading_color as ColorValue),
|
|
195
|
+
},
|
|
196
|
+
detailsPageStyles: {
|
|
197
|
+
textColor: colorHex(details?.text_color as ColorValue),
|
|
198
|
+
bannerColors: {
|
|
199
|
+
color1: colorHex(banner?.banner_color_1 as ColorValue),
|
|
200
|
+
color2: colorHex(banner?.banner_color_2 as ColorValue),
|
|
201
|
+
},
|
|
202
|
+
},
|
|
203
|
+
creatButtonStyles: {
|
|
204
|
+
backgroundColor: colorHex(createBtn?.background_color as ColorValue),
|
|
205
|
+
textColor: colorHex(createBtn?.text_color as ColorValue),
|
|
206
|
+
},
|
|
207
|
+
rightTables: {
|
|
208
|
+
backgroundColor: colorRgba(rightTables?.background_color as ColorValue),
|
|
209
|
+
cardBackgroundColor: colorRgba(rightTables?.card_background_color as ColorValue),
|
|
210
|
+
textColor: colorRgba(rightTables?.text_color as ColorValue),
|
|
211
|
+
},
|
|
212
|
+
noteStyle: {
|
|
213
|
+
hsBg: colorHex(notes?.hs_note_card_bg_color as ColorValue),
|
|
214
|
+
hsText: colorHex(notes?.hs_note_ts_text_color as ColorValue),
|
|
215
|
+
wpBg: colorHex(notes?.wp_note_card_bg_color as ColorValue),
|
|
216
|
+
wpText: colorHex(notes?.wp_note_ts_text_color as ColorValue),
|
|
217
|
+
},
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
function buildSidebarCtaStyles(module: ModuleFieldValues) {
|
|
222
|
+
const style = getNested(module, 'style') as ModuleFieldValues | undefined
|
|
223
|
+
const sidebarCta = getNested(style, 'sidebar_cta') as ModuleFieldValues | undefined
|
|
224
|
+
return {
|
|
225
|
+
backgroundColor: colorRgba(sidebarCta?.background_color as ColorValue),
|
|
226
|
+
textColor: colorRgba(sidebarCta?.text_color as ColorValue),
|
|
227
|
+
buttonBackgroundColor: colorHex(sidebarCta?.button_background_color as ColorValue),
|
|
228
|
+
buttonTextColor: colorRgba(sidebarCta?.button_text_color as ColorValue),
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
function buildBaseCompanyOptions(module: ModuleFieldValues) {
|
|
233
|
+
const other = getNested(module, 'other_options') as ModuleFieldValues | undefined
|
|
234
|
+
const company = getNested(other, 'company_options') as ModuleFieldValues | undefined
|
|
235
|
+
const createLink = getNested(other, 'create_an_account_link') as ModuleFieldValues | undefined
|
|
236
|
+
const href = (createLink?.url as { href?: string })?.href ?? '#'
|
|
237
|
+
|
|
238
|
+
return {
|
|
239
|
+
logoImg: imageSrc(company?.logo),
|
|
240
|
+
companyName: String(company?.company_name ?? ''),
|
|
241
|
+
smallLogo: imageSrc(company?.small_logo),
|
|
242
|
+
authPopupFormLogo: imageSrc(company?.auth_popup_form_logo),
|
|
243
|
+
welcomeMessage: String(other?.welcome_message ?? ''),
|
|
244
|
+
createAccountBool: Boolean(other?.show_create_an_account_link),
|
|
245
|
+
createAccountLink: `<a href="${href}" target="_blank" rel="noopener noreferrer">Sign up</a>`,
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
export type BuiltHubSpotData = {
|
|
250
|
+
dataSourceSet: boolean
|
|
251
|
+
apiBaseUrlOption: string
|
|
252
|
+
showCompanyNameOption: boolean
|
|
253
|
+
showSidebarCtaOption: boolean
|
|
254
|
+
addHomeTabOption: boolean
|
|
255
|
+
sidebarMenuOptions: Array<Record<string, unknown>>
|
|
256
|
+
moduleIframeListOptions: Array<Record<string, unknown>>
|
|
257
|
+
sidebarListDataOption: Array<Record<string, unknown>>
|
|
258
|
+
showSidebarListDataOption: boolean
|
|
259
|
+
sidebarCtaDetails: unknown
|
|
260
|
+
baseCompanyOptions: ReturnType<typeof buildBaseCompanyOptions>
|
|
261
|
+
enableDashboardCards: boolean
|
|
262
|
+
dashboardCards: Array<unknown>
|
|
263
|
+
homeTabsDataTypeFilter: unknown
|
|
264
|
+
moduleStylesOptions: ReturnType<typeof buildModuleStylesOptions>
|
|
265
|
+
recorBtnCustom: boolean
|
|
266
|
+
sidebarCtaStyles: ReturnType<typeof buildSidebarCtaStyles>
|
|
267
|
+
developerModeModule: boolean
|
|
268
|
+
developerOptionTempUrl: string
|
|
269
|
+
developerOption: boolean
|
|
270
|
+
ssoButtonsCustomizeOptions: unknown
|
|
271
|
+
primarycolor: string
|
|
272
|
+
secondarycolor: string
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
/** TypeScript port of public/module.html HubL assembly (lines 1–270). */
|
|
276
|
+
export function buildHubSpotDataFromFields(
|
|
277
|
+
module: ModuleFieldValues,
|
|
278
|
+
): BuiltHubSpotData {
|
|
279
|
+
const { iframeList, dynamicSidebarList, dynamicRouteList } = buildRouteLists(module)
|
|
280
|
+
const moduleStylesOptions = buildModuleStylesOptions(module)
|
|
281
|
+
const style = getNested(module, 'style') as ModuleFieldValues | undefined
|
|
282
|
+
const globals = getNested(style, 'module_global_colors') as ModuleFieldValues | undefined
|
|
283
|
+
const home = getNested(module, 'home') as ModuleFieldValues | undefined
|
|
284
|
+
const other = getNested(module, 'other_options') as ModuleFieldValues | undefined
|
|
285
|
+
const devOptions = getNested(module, 'developer_options') as ModuleFieldValues | undefined
|
|
286
|
+
|
|
287
|
+
const creatBg = moduleStylesOptions.creatButtonStyles.backgroundColor
|
|
288
|
+
const creatText = moduleStylesOptions.creatButtonStyles.textColor
|
|
289
|
+
|
|
290
|
+
return {
|
|
291
|
+
dataSourceSet: false,
|
|
292
|
+
apiBaseUrlOption: String(module.backend_server_url ?? ''),
|
|
293
|
+
showCompanyNameOption: Boolean(getNested(other, 'company_options.show_company_name')),
|
|
294
|
+
showSidebarCtaOption: Boolean(other?.show_sidebar_cta),
|
|
295
|
+
addHomeTabOption: Boolean(module.add_home_tab),
|
|
296
|
+
sidebarMenuOptions: dynamicRouteList,
|
|
297
|
+
moduleIframeListOptions: iframeList,
|
|
298
|
+
sidebarListDataOption: dynamicSidebarList,
|
|
299
|
+
showSidebarListDataOption: Boolean(home?.add_right_sidebar),
|
|
300
|
+
sidebarCtaDetails: other?.sidebar_cta_details ?? {},
|
|
301
|
+
baseCompanyOptions: buildBaseCompanyOptions(module),
|
|
302
|
+
enableDashboardCards: Boolean(home?.enable_dashboard_cards),
|
|
303
|
+
dashboardCards: normalizeRepeaterItems(home?.dashboard_cards),
|
|
304
|
+
homeTabsDataTypeFilter: home?.tabs_data_type ?? {},
|
|
305
|
+
moduleStylesOptions,
|
|
306
|
+
recorBtnCustom: Boolean(creatBg && creatText),
|
|
307
|
+
sidebarCtaStyles: buildSidebarCtaStyles(module),
|
|
308
|
+
developerModeModule: Boolean(module.developerMode),
|
|
309
|
+
developerOptionTempUrl: String(devOptions?.temp_backend_url ?? ''),
|
|
310
|
+
developerOption: Boolean(module.developer_option),
|
|
311
|
+
ssoButtonsCustomizeOptions: module.sso_buttons_customize_options ?? {},
|
|
312
|
+
primarycolor: colorHex(globals?.primary_color as ColorValue),
|
|
313
|
+
secondarycolor: colorHex(globals?.secondary_color as ColorValue),
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
export function buildCssVarsFromFields(module: ModuleFieldValues): Record<string, string> {
|
|
318
|
+
const built = buildHubSpotDataFromFields(module)
|
|
319
|
+
const styles = built.moduleStylesOptions
|
|
320
|
+
const primary = built.primarycolor
|
|
321
|
+
const secondary = built.secondarycolor
|
|
322
|
+
const globals = getNested(getNested(module, 'style') as ModuleFieldValues, 'module_global_colors') as ModuleFieldValues
|
|
323
|
+
const buttonText = colorHex(globals?.button_text_color as ColorValue)
|
|
324
|
+
|
|
325
|
+
const homeOverlayerColor =
|
|
326
|
+
styles.homeTabStyles.overlayer.color !== ''
|
|
327
|
+
? colorRgba({
|
|
328
|
+
color: styles.homeTabStyles.overlayer.color,
|
|
329
|
+
opacity: styles.homeTabStyles.overlayer.opacity,
|
|
330
|
+
})
|
|
331
|
+
: ''
|
|
332
|
+
|
|
333
|
+
return {
|
|
334
|
+
'--primary-color': primary,
|
|
335
|
+
'--secondary-color': secondary,
|
|
336
|
+
'--button-text-color': buttonText,
|
|
337
|
+
'--primary-color-hover-bg': hexWithAlphaSuffix(primary, '30'),
|
|
338
|
+
'--secondary-color-hover-bg': hexWithAlphaSuffix(secondary, '10'),
|
|
339
|
+
'--banner-overlayer-color': hexWithAlphaSuffix(primary, '10'),
|
|
340
|
+
'--home-tab-heading-color': styles.homeTabStyles.headingColor,
|
|
341
|
+
'--home-tab-description-color': styles.homeTabStyles.descriptionColor,
|
|
342
|
+
'--home-tab-button-background-color': styles.homeTabStyles.buttonStyles.backgroundColor,
|
|
343
|
+
'--home-tab-button-text-color': styles.homeTabStyles.buttonStyles.textColor,
|
|
344
|
+
'--home-tab-overlayer-color': homeOverlayerColor,
|
|
345
|
+
'--home-tab-overlayer-opacity': styles.homeTabStyles.overlayer.opacity,
|
|
346
|
+
'--home-tab-svg-color': styles.homeTabStyles.svgColor.color,
|
|
347
|
+
'--home-tab-svg-opacity': styles.homeTabStyles.svgColor.opacity,
|
|
348
|
+
'--sidebar-text-color': styles.sidebarStyles.textColor,
|
|
349
|
+
'--sidebar-background-color': styles.sidebarStyles.backgroundColor,
|
|
350
|
+
'--list-page-heading-color': styles.listPageStyles.textColor,
|
|
351
|
+
'--details-page-text-color': styles.detailsPageStyles.textColor,
|
|
352
|
+
'--details-page-banner-color1': styles.detailsPageStyles.bannerColors.color1,
|
|
353
|
+
'--details-page-banner-color2': styles.detailsPageStyles.bannerColors.color2,
|
|
354
|
+
'--right-tables-background-color': styles.rightTables.backgroundColor,
|
|
355
|
+
'--right-tables-card-background-color': styles.rightTables.cardBackgroundColor,
|
|
356
|
+
'--right-tables-text-color': styles.rightTables.textColor,
|
|
357
|
+
'--note-hs-bg': styles.noteStyle.hsBg,
|
|
358
|
+
'--note-hs-text': styles.noteStyle.hsText,
|
|
359
|
+
'--note-wp-bg': styles.noteStyle.wpBg,
|
|
360
|
+
'--note-wp-text': styles.noteStyle.wpText,
|
|
361
|
+
'--sidebarCta-background-color': built.sidebarCtaStyles.backgroundColor,
|
|
362
|
+
'--sidebarCta-text-color': built.sidebarCtaStyles.textColor,
|
|
363
|
+
'--sidebarCta-button-background-color': built.sidebarCtaStyles.buttonBackgroundColor,
|
|
364
|
+
'--sidebarCta-button-text-color': built.sidebarCtaStyles.buttonTextColor,
|
|
365
|
+
'--rt-color-white': '#fff',
|
|
366
|
+
'--rt-color-dark': '#222',
|
|
367
|
+
'--rt-color-success': '#8dc572',
|
|
368
|
+
'--rt-color-error': '#be6464',
|
|
369
|
+
'--rt-color-warning': '#f0ad4e',
|
|
370
|
+
'--rt-color-info': '#337ab7',
|
|
371
|
+
'--rt-opacity': '0.9',
|
|
372
|
+
'--rt-transition-show-delay': '0.15s',
|
|
373
|
+
'--rt-transition-closing-delay': '0.15s',
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
const CREATE_BUTTON_STYLE_ID = 'woodsportal-module-create-button-styles'
|
|
378
|
+
|
|
379
|
+
export function applyCssVarsToDocument(vars: Record<string, string>): void {
|
|
380
|
+
if (typeof document === 'undefined') return
|
|
381
|
+
for (const [name, value] of Object.entries(vars)) {
|
|
382
|
+
document.documentElement.style.setProperty(name, value)
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
export function applyCreateButtonStyles(module: ModuleFieldValues): void {
|
|
387
|
+
if (typeof document === 'undefined') return
|
|
388
|
+
const built = buildHubSpotDataFromFields(module)
|
|
389
|
+
const { backgroundColor, textColor } = built.moduleStylesOptions.creatButtonStyles
|
|
390
|
+
let styleEl = document.getElementById(CREATE_BUTTON_STYLE_ID) as HTMLStyleElement | null
|
|
391
|
+
|
|
392
|
+
if (!built.recorBtnCustom || !backgroundColor || !textColor) {
|
|
393
|
+
styleEl?.remove()
|
|
394
|
+
return
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
const css = `
|
|
398
|
+
.CUSTOM-create-button-background-color { background-color: ${backgroundColor}; }
|
|
399
|
+
.CUSTOM-create-button-text-color { color: ${textColor} !important; }
|
|
400
|
+
.CUSTOM-create-button-background-color:hover { background-color: ${hexWithAlphaSuffix(backgroundColor, '80')}; }
|
|
401
|
+
`.trim()
|
|
402
|
+
|
|
403
|
+
if (!styleEl) {
|
|
404
|
+
styleEl = document.createElement('style')
|
|
405
|
+
styleEl.id = CREATE_BUTTON_STYLE_ID
|
|
406
|
+
document.head.appendChild(styleEl)
|
|
407
|
+
}
|
|
408
|
+
styleEl.textContent = css
|
|
409
|
+
}
|