@marvalt/wadapter 2.3.21 → 2.3.22
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/index.d.ts +51 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +132 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +136 -0
- package/dist/index.js.map +1 -1
- package/dist/utils/theme-styles.d.ts +50 -0
- package/dist/utils/theme-styles.d.ts.map +1 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2745,6 +2745,138 @@ function validateFormData(formData, rules) {
|
|
|
2745
2745
|
return { isValid, errors };
|
|
2746
2746
|
}
|
|
2747
2747
|
|
|
2748
|
+
/**
|
|
2749
|
+
* @license GPL-3.0-or-later
|
|
2750
|
+
*
|
|
2751
|
+
* This file is part of the MarVAlt Open SDK.
|
|
2752
|
+
* Copyright (c) 2025 Vibune Pty Ltd.
|
|
2753
|
+
*
|
|
2754
|
+
* This program is free software: you can redistribute it and/or modify
|
|
2755
|
+
* it under the terms of the GNU General Public License as published by
|
|
2756
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
2757
|
+
* (at your option) any later version.
|
|
2758
|
+
*
|
|
2759
|
+
* This program is distributed in the hope that it will be useful,
|
|
2760
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
2761
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
2762
|
+
* See the GNU General Public License for more details.
|
|
2763
|
+
*/
|
|
2764
|
+
/**
|
|
2765
|
+
* List of popular Google Fonts (for detection and validation)
|
|
2766
|
+
*/
|
|
2767
|
+
const GOOGLE_FONTS = [
|
|
2768
|
+
'Montserrat',
|
|
2769
|
+
'Open Sans',
|
|
2770
|
+
'Roboto',
|
|
2771
|
+
'Lato',
|
|
2772
|
+
'Poppins',
|
|
2773
|
+
'Source Sans Pro',
|
|
2774
|
+
'Raleway',
|
|
2775
|
+
'Oswald',
|
|
2776
|
+
'Playfair Display',
|
|
2777
|
+
'Merriweather',
|
|
2778
|
+
'Ubuntu',
|
|
2779
|
+
'Nunito',
|
|
2780
|
+
'Inter',
|
|
2781
|
+
'Work Sans',
|
|
2782
|
+
'Crimson Text',
|
|
2783
|
+
'Libre Baskerville',
|
|
2784
|
+
'PT Sans',
|
|
2785
|
+
'PT Serif',
|
|
2786
|
+
'Dancing Script',
|
|
2787
|
+
'Bebas Neue',
|
|
2788
|
+
'Fira Sans',
|
|
2789
|
+
'Noto Sans',
|
|
2790
|
+
'Noto Serif',
|
|
2791
|
+
'Rubik',
|
|
2792
|
+
'Mukta',
|
|
2793
|
+
'Cabin',
|
|
2794
|
+
'Dosis',
|
|
2795
|
+
'Arimo',
|
|
2796
|
+
'Titillium Web',
|
|
2797
|
+
];
|
|
2798
|
+
/**
|
|
2799
|
+
* Sanitize font name - removes "family" prefix and cleans the name
|
|
2800
|
+
*
|
|
2801
|
+
* @param fontName - Font name to sanitize
|
|
2802
|
+
* @returns Sanitized font name
|
|
2803
|
+
*/
|
|
2804
|
+
function sanitizeFontName(fontName) {
|
|
2805
|
+
if (!fontName)
|
|
2806
|
+
return '';
|
|
2807
|
+
// Remove "family" prefix if present (case insensitive)
|
|
2808
|
+
let cleaned = fontName.replace(/^family\s*/i, '').trim();
|
|
2809
|
+
return cleaned;
|
|
2810
|
+
}
|
|
2811
|
+
/**
|
|
2812
|
+
* Format font-family CSS value with quotes and fallback
|
|
2813
|
+
*
|
|
2814
|
+
* @param fontName - Font name to format
|
|
2815
|
+
* @param fallback - Fallback font (default: 'sans-serif')
|
|
2816
|
+
* @returns Formatted font-family CSS value
|
|
2817
|
+
*/
|
|
2818
|
+
function formatFontFamily(fontName, fallback = 'sans-serif') {
|
|
2819
|
+
if (!fontName)
|
|
2820
|
+
return fallback;
|
|
2821
|
+
const cleaned = sanitizeFontName(fontName);
|
|
2822
|
+
if (!cleaned)
|
|
2823
|
+
return fallback;
|
|
2824
|
+
// If font name contains spaces, wrap in quotes
|
|
2825
|
+
const quotedFont = cleaned.includes(' ') ? `"${cleaned}"` : cleaned;
|
|
2826
|
+
return `${quotedFont}, ${fallback}`;
|
|
2827
|
+
}
|
|
2828
|
+
/**
|
|
2829
|
+
* Load Google Font dynamically via link tag
|
|
2830
|
+
*
|
|
2831
|
+
* @param fontName - Google Font name to load
|
|
2832
|
+
* @param weights - Font weights to load (default: 400, 500, 600, 700)
|
|
2833
|
+
*/
|
|
2834
|
+
function loadGoogleFont(fontName, weights = [400, 500, 600, 700]) {
|
|
2835
|
+
if (typeof document === 'undefined') {
|
|
2836
|
+
// Server-side rendering - skip
|
|
2837
|
+
return;
|
|
2838
|
+
}
|
|
2839
|
+
if (!fontName)
|
|
2840
|
+
return;
|
|
2841
|
+
const cleaned = sanitizeFontName(fontName);
|
|
2842
|
+
if (!cleaned)
|
|
2843
|
+
return;
|
|
2844
|
+
// Check if it's a Google Font
|
|
2845
|
+
const isGoogleFont = GOOGLE_FONTS.some(font => font.toLowerCase() === cleaned.toLowerCase());
|
|
2846
|
+
if (!isGoogleFont) {
|
|
2847
|
+
// Not a Google Font, assume it's a system font or custom font
|
|
2848
|
+
return;
|
|
2849
|
+
}
|
|
2850
|
+
// Check if font is already loaded
|
|
2851
|
+
const fontId = `wp-google-font-${cleaned.toLowerCase().replace(/\s+/g, '-')}`;
|
|
2852
|
+
if (document.getElementById(fontId)) {
|
|
2853
|
+
return; // Already loaded
|
|
2854
|
+
}
|
|
2855
|
+
// Create link element for Google Fonts
|
|
2856
|
+
const link = document.createElement('link');
|
|
2857
|
+
link.id = fontId;
|
|
2858
|
+
link.rel = 'stylesheet';
|
|
2859
|
+
// Build Google Fonts URL with weights
|
|
2860
|
+
const weightsParam = weights.join(';');
|
|
2861
|
+
link.href = `https://fonts.googleapis.com/css2?family=${encodeURIComponent(cleaned)}:wght@${weightsParam}&display=swap`;
|
|
2862
|
+
document.head.appendChild(link);
|
|
2863
|
+
}
|
|
2864
|
+
/**
|
|
2865
|
+
* Check if a font name is a Google Font
|
|
2866
|
+
*
|
|
2867
|
+
* @param fontName - Font name to check
|
|
2868
|
+
* @returns True if the font is a Google Font
|
|
2869
|
+
*/
|
|
2870
|
+
function isGoogleFont(fontName) {
|
|
2871
|
+
if (!fontName)
|
|
2872
|
+
return false;
|
|
2873
|
+
const cleaned = sanitizeFontName(fontName);
|
|
2874
|
+
if (!cleaned)
|
|
2875
|
+
return false;
|
|
2876
|
+
return GOOGLE_FONTS.some(font => font.toLowerCase() === cleaned.toLowerCase());
|
|
2877
|
+
}
|
|
2878
|
+
|
|
2879
|
+
exports.GOOGLE_FONTS = GOOGLE_FONTS;
|
|
2748
2880
|
exports.GravityForm = GravityForm;
|
|
2749
2881
|
exports.GravityFormsClient = GravityFormsClient;
|
|
2750
2882
|
exports.GravityFormsProvider = GravityFormsProvider;
|
|
@@ -2758,6 +2890,7 @@ exports.createGravityFormsConfig = createGravityFormsConfig;
|
|
|
2758
2890
|
exports.createWordPressConfig = createWordPressConfig;
|
|
2759
2891
|
exports.findPageById = findPageById;
|
|
2760
2892
|
exports.findPageBySlug = findPageBySlug;
|
|
2893
|
+
exports.formatFontFamily = formatFontFamily;
|
|
2761
2894
|
exports.getActiveForms = getActiveForms;
|
|
2762
2895
|
exports.getChildPages = getChildPages;
|
|
2763
2896
|
exports.getFormById = getFormById;
|
|
@@ -2775,8 +2908,11 @@ exports.getWordPressPosts = getWordPressPosts;
|
|
|
2775
2908
|
exports.getWordPressTags = getWordPressTags;
|
|
2776
2909
|
exports.hasGravityFormsStatic = hasGravityFormsStatic;
|
|
2777
2910
|
exports.hasWordPressStatic = hasWordPressStatic;
|
|
2911
|
+
exports.isGoogleFont = isGoogleFont;
|
|
2912
|
+
exports.loadGoogleFont = loadGoogleFont;
|
|
2778
2913
|
exports.loadGravityFormsData = loadGravityFormsData;
|
|
2779
2914
|
exports.loadWordPressData = loadWordPressData;
|
|
2915
|
+
exports.sanitizeFontName = sanitizeFontName;
|
|
2780
2916
|
exports.sanitizeHtml = sanitizeHtml;
|
|
2781
2917
|
exports.transformWordPressMedia = transformWordPressMedia;
|
|
2782
2918
|
exports.transformWordPressMediaItems = transformWordPressMediaItems;
|