PluginProbe
The Innovative Form Builder – IvyForms / 1.0
The Innovative Form Builder – IvyForms v1.0
1.5.1 1.5 1.4.1 1.4 trunk 0.1.2 0.2 0.2.1 0.3 0.3.1 0.4 0.5 0.6 0.6.1 0.6.1-backup 0.6.1.1 0.7 0.8 0.8.1 0.8.2 0.9 0.9.1 1.0 1.1 1.1.1 All 27 releases
ivyforms / frontend / src / utils / form-styles / selectors.ts

selectors.ts in The Innovative Form Builder – IvyForms 1.0, at frontend/src/utils/form-styles/selectors.ts

44 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { parseCssClassList } from '@/utils/form-styles/classParser'
2
3 export interface FormStyleSelectors {
4 formSelector: string
5 wrapperSelector: string
6 customClassName: string
7 customClass: string
8 baseSelector: string
9 }
10
11 export function normalizeFormScopeToken(formId: string | number): string {
12 const normalized = String(formId)
13 .trim()
14 .replace(/[^a-zA-Z0-9_-]+/g, '-')
15 .replace(/-+/g, '-')
16 .replace(/^-|-$/g, '')
17
18 return normalized || 'default'
19 }
20
21 export function buildFormPopperScopeClass(formId: string | number): string {
22 return `ivyforms-form-popper-${normalizeFormScopeToken(formId)}`
23 }
24
25 export function buildFormStyleSelectors(
26 formId: string | number,
27 customCssClass?: string,
28 ): FormStyleSelectors {
29 const normalizedFormId = normalizeFormScopeToken(formId)
30 const formSelector = `.ivyforms-form-${normalizedFormId}`
31 const wrapperSelector = `.ivyforms-form-wrapper-${normalizedFormId}`
32 const customClassName = parseCssClassList(customCssClass)[0] || ''
33 const customClass = customClassName ? `.${customClassName}` : ''
34 const baseSelector = customClass ? `${wrapperSelector}${customClass}` : wrapperSelector
35
36 return {
37 formSelector,
38 wrapperSelector,
39 customClassName,
40 customClass,
41 baseSelector,
42 }
43 }
44