funuicss 3.6.10 → 3.6.12
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/package.json +1 -1
- package/ui/button/Button.d.ts +2 -1
- package/ui/button/Button.js +2 -2
- package/ui/carousel/Carousel.d.ts +3 -1
- package/ui/carousel/Carousel.js +29 -5
- package/ui/vista/Vista.d.ts +14 -0
- package/ui/vista/Vista.js +45 -9
- package/utils/componentUtils.d.ts +26 -0
- package/utils/componentUtils.js +245 -30
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "3.6.
|
|
2
|
+
"version": "3.6.12",
|
|
3
3
|
"name": "funuicss",
|
|
4
4
|
"description": "React and Next.js component UI Library for creating Easy and good looking websites with fewer lines of code. Elevate your web development experience with our cutting-edge React/Next.js component UI Library. Craft stunning websites effortlessly, boasting both seamless functionality and aesthetic appeal—all achieved with minimal lines of code. Unleash the power of simplicity and style in your projects!",
|
|
5
5
|
"main": "index.js",
|
package/ui/button/Button.d.ts
CHANGED
|
@@ -30,10 +30,11 @@ interface ButtonProps {
|
|
|
30
30
|
outlineSize?: number;
|
|
31
31
|
isLoading?: boolean;
|
|
32
32
|
variant?: string;
|
|
33
|
+
url?: string;
|
|
33
34
|
status?: 'success' | 'warning' | 'info' | 'danger';
|
|
34
35
|
children?: React.ReactNode;
|
|
35
36
|
style?: React.CSSProperties;
|
|
36
37
|
onClick?: (event: MouseEvent<HTMLButtonElement>) => void;
|
|
37
38
|
}
|
|
38
|
-
export default function Button({ variant, color, bg, funcss, startIcon, endIcon, text, rounded, raised, height, width, float, hoverUp, fullWidth, outlined, small, hoverless, smaller, big, bigger, jumbo, flat, hoverNone, fillAnimation, fillDirection, fillTextColor, outlineSize, isLoading, status, children, bold, style, onClick, ...rest }: ButtonProps): React.JSX.Element;
|
|
39
|
+
export default function Button({ variant, color, bg, funcss, startIcon, endIcon, text, rounded, raised, height, width, float, hoverUp, fullWidth, outlined, small, hoverless, smaller, big, bigger, jumbo, flat, hoverNone, fillAnimation, fillDirection, fillTextColor, outlineSize, isLoading, status, children, bold, style, url, onClick, ...rest }: ButtonProps): React.JSX.Element;
|
|
39
40
|
export {};
|
package/ui/button/Button.js
CHANGED
|
@@ -31,7 +31,7 @@ var react_1 = __importDefault(require("react"));
|
|
|
31
31
|
var pi_1 = require("react-icons/pi");
|
|
32
32
|
var componentUtils_1 = require("../../utils/componentUtils");
|
|
33
33
|
function Button(_a) {
|
|
34
|
-
var _b = _a.variant, variant = _b === void 0 ? '' : _b, color = _a.color, bg = _a.bg, funcss = _a.funcss, startIcon = _a.startIcon, endIcon = _a.endIcon, text = _a.text, rounded = _a.rounded, raised = _a.raised, height = _a.height, width = _a.width, float = _a.float, hoverUp = _a.hoverUp, fullWidth = _a.fullWidth, outlined = _a.outlined, small = _a.small, hoverless = _a.hoverless, smaller = _a.smaller, big = _a.big, bigger = _a.bigger, jumbo = _a.jumbo, flat = _a.flat, hoverNone = _a.hoverNone, fillAnimation = _a.fillAnimation, fillDirection = _a.fillDirection, fillTextColor = _a.fillTextColor, outlineSize = _a.outlineSize, isLoading = _a.isLoading, status = _a.status, children = _a.children, bold = _a.bold, style = _a.style, onClick = _a.onClick, rest = __rest(_a, ["variant", "color", "bg", "funcss", "startIcon", "endIcon", "text", "rounded", "raised", "height", "width", "float", "hoverUp", "fullWidth", "outlined", "small", "hoverless", "smaller", "big", "bigger", "jumbo", "flat", "hoverNone", "fillAnimation", "fillDirection", "fillTextColor", "outlineSize", "isLoading", "status", "children", "bold", "style", "onClick"]);
|
|
34
|
+
var _b = _a.variant, variant = _b === void 0 ? '' : _b, color = _a.color, bg = _a.bg, funcss = _a.funcss, startIcon = _a.startIcon, endIcon = _a.endIcon, text = _a.text, rounded = _a.rounded, raised = _a.raised, height = _a.height, width = _a.width, float = _a.float, hoverUp = _a.hoverUp, fullWidth = _a.fullWidth, outlined = _a.outlined, small = _a.small, hoverless = _a.hoverless, smaller = _a.smaller, big = _a.big, bigger = _a.bigger, jumbo = _a.jumbo, flat = _a.flat, hoverNone = _a.hoverNone, fillAnimation = _a.fillAnimation, fillDirection = _a.fillDirection, fillTextColor = _a.fillTextColor, outlineSize = _a.outlineSize, isLoading = _a.isLoading, status = _a.status, children = _a.children, bold = _a.bold, style = _a.style, url = _a.url, onClick = _a.onClick, rest = __rest(_a, ["variant", "color", "bg", "funcss", "startIcon", "endIcon", "text", "rounded", "raised", "height", "width", "float", "hoverUp", "fullWidth", "outlined", "small", "hoverless", "smaller", "big", "bigger", "jumbo", "flat", "hoverNone", "fillAnimation", "fillDirection", "fillTextColor", "outlineSize", "isLoading", "status", "children", "bold", "style", "url", "onClick"]);
|
|
35
35
|
// Use the component config hook
|
|
36
36
|
var mergeWithLocal = (0, componentUtils_1.useComponentConfiguration)('Button', variant).mergeWithLocal;
|
|
37
37
|
// Merge config with local props - local props should override config
|
|
@@ -109,7 +109,7 @@ function Button(_a) {
|
|
|
109
109
|
"".concat(finalFillAnimation ? "".concat(finalFillTextColor ? "hover-text-".concat(finalFillTextColor) : '', " button-fill fill-").concat(finalFillDirection || 'left') : '')
|
|
110
110
|
].join(' ');
|
|
111
111
|
return (react_1.default.createElement("span", null,
|
|
112
|
-
react_1.default.createElement("button", __assign({ className: "".concat(classNames, " ").concat(startIcon || endIcon || finalStatus || finalIsLoading ? 'iconic' : ''), style: __assign({ height: mergedProps.height || '', width: mergedProps.fullWidth ? '100%' : mergedProps.width || '', borderRadius: finalFlat ? '0rem' : '' }, style), onClick: onClick }, mergedProps),
|
|
112
|
+
react_1.default.createElement("button", __assign({ className: "".concat(classNames, " ").concat(startIcon || endIcon || finalStatus || finalIsLoading ? 'iconic' : ''), style: __assign({ height: mergedProps.height || '', width: mergedProps.fullWidth ? '100%' : mergedProps.width || '', borderRadius: finalFlat ? '0rem' : '' }, style), onClick: onClick || (url ? function () { return window.location.href = url; } : undefined) }, mergedProps),
|
|
113
113
|
finalIsLoading && (react_1.default.createElement("span", { className: 'rotate btn_left_icon', style: { lineHeight: "0" } },
|
|
114
114
|
react_1.default.createElement(pi_1.PiSpinner, null))),
|
|
115
115
|
finalStatus && (react_1.default.createElement("span", { className: 'btn_left_icon', style: { lineHeight: "0" } },
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import React, { ReactNode } from 'react';
|
|
2
|
-
interface CarouselProps {
|
|
2
|
+
interface CarouselProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
3
3
|
scrollNumber?: number;
|
|
4
4
|
gap?: number;
|
|
5
5
|
funcss?: string;
|
|
6
6
|
children: ReactNode;
|
|
7
7
|
showDashes?: boolean;
|
|
8
|
+
allowVerticalOverflow?: boolean;
|
|
9
|
+
itemPadding?: string;
|
|
8
10
|
}
|
|
9
11
|
declare const Carousel: React.FC<CarouselProps>;
|
|
10
12
|
export default Carousel;
|
package/ui/carousel/Carousel.js
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
'use client';
|
|
3
|
+
var __assign = (this && this.__assign) || function () {
|
|
4
|
+
__assign = Object.assign || function(t) {
|
|
5
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
6
|
+
s = arguments[i];
|
|
7
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
8
|
+
t[p] = s[p];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
return __assign.apply(this, arguments);
|
|
13
|
+
};
|
|
3
14
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
15
|
if (k2 === undefined) k2 = k;
|
|
5
16
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -33,6 +44,17 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
44
|
return result;
|
|
34
45
|
};
|
|
35
46
|
})();
|
|
47
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
48
|
+
var t = {};
|
|
49
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
50
|
+
t[p] = s[p];
|
|
51
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
52
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
53
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
54
|
+
t[p[i]] = s[p[i]];
|
|
55
|
+
}
|
|
56
|
+
return t;
|
|
57
|
+
};
|
|
36
58
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
59
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
60
|
};
|
|
@@ -43,11 +65,11 @@ var Circle_1 = __importDefault(require("../specials/Circle"));
|
|
|
43
65
|
var RowFlex_1 = __importDefault(require("../specials/RowFlex"));
|
|
44
66
|
var Functions_1 = require("../../utils/Functions");
|
|
45
67
|
var Carousel = function (_a) {
|
|
46
|
-
var _b = _a.scrollNumber, scrollNumber = _b === void 0 ? 320 : _b, _c = _a.gap, gap = _c === void 0 ? 0.5 : _c, _d = _a.funcss, funcss = _d === void 0 ? '' : _d, _e = _a.showDashes, showDashes = _e === void 0 ? true : _e, children = _a.children;
|
|
68
|
+
var _b = _a.scrollNumber, scrollNumber = _b === void 0 ? 320 : _b, _c = _a.gap, gap = _c === void 0 ? 0.5 : _c, _d = _a.funcss, funcss = _d === void 0 ? '' : _d, _e = _a.showDashes, showDashes = _e === void 0 ? true : _e, _f = _a.allowVerticalOverflow, allowVerticalOverflow = _f === void 0 ? false : _f, _g = _a.itemPadding, itemPadding = _g === void 0 ? '0rem' : _g, children = _a.children, rest = __rest(_a, ["scrollNumber", "gap", "funcss", "showDashes", "allowVerticalOverflow", "itemPadding", "children"]);
|
|
47
69
|
var scrollRef = (0, react_1.useRef)(null);
|
|
48
|
-
var
|
|
49
|
-
var
|
|
50
|
-
var
|
|
70
|
+
var _h = (0, react_1.useState)('start'), scrollPosition = _h[0], setScrollPosition = _h[1];
|
|
71
|
+
var _j = (0, react_1.useState)(false), isPhone = _j[0], setIsPhone = _j[1];
|
|
72
|
+
var _k = (0, react_1.useState)(false), isScrollable = _k[0], setIsScrollable = _k[1];
|
|
51
73
|
var checkScrollable = function () {
|
|
52
74
|
var container = scrollRef.current;
|
|
53
75
|
if (container) {
|
|
@@ -100,7 +122,7 @@ var Carousel = function (_a) {
|
|
|
100
122
|
return function () { return container.removeEventListener('scroll', handleScroll); };
|
|
101
123
|
}
|
|
102
124
|
}, []);
|
|
103
|
-
return (react_1.default.createElement("div", { className: "carousel-wrapper ".concat(funcss) },
|
|
125
|
+
return (react_1.default.createElement("div", __assign({ className: "carousel-wrapper ".concat(funcss) }, rest),
|
|
104
126
|
react_1.default.createElement(RowFlex_1.default, { gap: 1, wrap: "nowrap", alignItems: "center" },
|
|
105
127
|
!isPhone && isScrollable && (react_1.default.createElement("div", null,
|
|
106
128
|
react_1.default.createElement(Circle_1.default, { onClick: function () { return scroll('left'); } },
|
|
@@ -109,10 +131,12 @@ var Carousel = function (_a) {
|
|
|
109
131
|
width: '100%',
|
|
110
132
|
gap: gap + 'rem',
|
|
111
133
|
overflowX: 'auto',
|
|
134
|
+
overflowY: 'visible',
|
|
112
135
|
display: 'flex',
|
|
113
136
|
justifyItems: (isScrollable || isPhone) ? 'flex-start' : 'center',
|
|
114
137
|
scrollSnapType: 'x mandatory',
|
|
115
138
|
scrollBehavior: 'smooth',
|
|
139
|
+
padding: itemPadding || "0.5rem"
|
|
116
140
|
} }, react_1.default.Children.map(children, function (child) { return (react_1.default.createElement("div", { className: "carousel-item", style: { flexShrink: 0 } },
|
|
117
141
|
react_1.default.createElement("div", { className: "carousel-card" }, child))); })),
|
|
118
142
|
!isPhone && isScrollable && (react_1.default.createElement("div", null,
|
package/ui/vista/Vista.d.ts
CHANGED
|
@@ -49,6 +49,20 @@ type VistaProps = {
|
|
|
49
49
|
fadeOverlayDarken?: number;
|
|
50
50
|
backgroundImage?: string;
|
|
51
51
|
variant?: string;
|
|
52
|
+
showPrimaryCTA?: boolean;
|
|
53
|
+
showSecondaryCTA?: boolean;
|
|
54
|
+
showAccentCTA?: boolean;
|
|
55
|
+
primaryButtonOutlined?: boolean;
|
|
56
|
+
secondaryButtonOutlined?: boolean;
|
|
57
|
+
accentButtonOutlined?: boolean;
|
|
58
|
+
ctaPrimaryUrl?: string;
|
|
59
|
+
ctaSecondaryUrl?: string;
|
|
60
|
+
ctaAccentUrl?: string;
|
|
61
|
+
ctaPrimaryText?: string;
|
|
62
|
+
ctaSecondaryText?: string;
|
|
63
|
+
ctaAccentText?: string;
|
|
64
|
+
ctaGap?: string;
|
|
65
|
+
ctaFlexJustify?: 'flex-start' | 'center' | 'flex-end' | 'space-between' | 'space-around';
|
|
52
66
|
};
|
|
53
67
|
declare const Vista: React.FC<VistaProps>;
|
|
54
68
|
export default Vista;
|
package/ui/vista/Vista.js
CHANGED
|
@@ -21,6 +21,8 @@ var getCssVariable_1 = require("../../utils/getCssVariable");
|
|
|
21
21
|
var componentUtils_1 = require("../../utils/componentUtils");
|
|
22
22
|
var Text_1 = __importDefault(require("../text/Text"));
|
|
23
23
|
var Col_1 = __importDefault(require("../grid/Col"));
|
|
24
|
+
var Button_1 = __importDefault(require("../button/Button")); // Import your Button component
|
|
25
|
+
var Flex_1 = __importDefault(require("../flex/Flex")); // Import your Flex component
|
|
24
26
|
var Vista = function (_a) {
|
|
25
27
|
var _b = _a.layout, layout = _b === void 0 ? 'imageRight' : _b, _c = _a.reverse, reverse = _c === void 0 ? false : _c, _d = _a.bg, bg = _d === void 0 ? '' : _d, _e = _a.padding, padding = _e === void 0 ? 'padding-lg' : _e, _f = _a.textAlign, textAlign = _f === void 0 ? 'left' : _f, _g = _a.imgPosition, imgPosition = _g === void 0 ? 'top' : _g, _h = _a.funcss, funcss = _h === void 0 ? '' : _h, _j = _a.pattern, pattern = _j === void 0 ? '' : _j, _k = _a.patternOpacity, patternOpacity = _k === void 0 ? pattern === 'grid' ? 0.15 : pattern === 'dots' ? 0.4 : pattern === 'diagonal' ? 0.2 : pattern === 'checkerboard' ? 0.2 : pattern === 'horizontal' ? 0.2 : pattern === 'vertical' ? 0.2 : 0.1 : _k,
|
|
26
28
|
// Enhanced Content
|
|
@@ -28,7 +30,11 @@ var Vista = function (_a) {
|
|
|
28
30
|
// Gradient Props
|
|
29
31
|
_8 = _a.showGradient,
|
|
30
32
|
// Gradient Props
|
|
31
|
-
showGradient = _8 === void 0 ? false : _8, _9 = _a.gradientPosition, gradientPosition = _9 === void 0 ? 'bottom-right' : _9, _10 = _a.gradientSize, gradientSize = _10 === void 0 ? '300px' : _10, _11 = _a.blurry, blurry = _11 === void 0 ? 100 : _11, _12 = _a.opacity, opacity = _12 === void 0 ? 0.4 : _12, gradientColors = _a.gradientColors, _13 = _a.fade, fade = _13 === void 0 ? false : _13, _14 = _a.fadeDirection, fadeDirection = _14 === void 0 ? 'bottom' : _14, _15 = _a.fadeRadial, fadeRadial = _15 === void 0 ? false : _15, _16 = _a.fadeOverlayDarken, fadeOverlayDarken = _16 === void 0 ? 0.5 : _16, _17 = _a.backgroundImage, backgroundImage = _17 === void 0 ? '' : _17, _18 = _a.variant, variant = _18 === void 0 ? '' : _18
|
|
33
|
+
showGradient = _8 === void 0 ? false : _8, _9 = _a.gradientPosition, gradientPosition = _9 === void 0 ? 'bottom-right' : _9, _10 = _a.gradientSize, gradientSize = _10 === void 0 ? '300px' : _10, _11 = _a.blurry, blurry = _11 === void 0 ? 100 : _11, _12 = _a.opacity, opacity = _12 === void 0 ? 0.4 : _12, gradientColors = _a.gradientColors, _13 = _a.fade, fade = _13 === void 0 ? false : _13, _14 = _a.fadeDirection, fadeDirection = _14 === void 0 ? 'bottom' : _14, _15 = _a.fadeRadial, fadeRadial = _15 === void 0 ? false : _15, _16 = _a.fadeOverlayDarken, fadeOverlayDarken = _16 === void 0 ? 0.5 : _16, _17 = _a.backgroundImage, backgroundImage = _17 === void 0 ? '' : _17, _18 = _a.variant, variant = _18 === void 0 ? '' : _18,
|
|
34
|
+
// New CTA Button Props
|
|
35
|
+
_19 = _a.showPrimaryCTA,
|
|
36
|
+
// New CTA Button Props
|
|
37
|
+
showPrimaryCTA = _19 === void 0 ? false : _19, _20 = _a.showSecondaryCTA, showSecondaryCTA = _20 === void 0 ? false : _20, _21 = _a.showAccentCTA, showAccentCTA = _21 === void 0 ? false : _21, _22 = _a.primaryButtonOutlined, primaryButtonOutlined = _22 === void 0 ? false : _22, _23 = _a.secondaryButtonOutlined, secondaryButtonOutlined = _23 === void 0 ? false : _23, _24 = _a.accentButtonOutlined, accentButtonOutlined = _24 === void 0 ? false : _24, _25 = _a.ctaPrimaryUrl, ctaPrimaryUrl = _25 === void 0 ? '' : _25, _26 = _a.ctaSecondaryUrl, ctaSecondaryUrl = _26 === void 0 ? '' : _26, _27 = _a.ctaAccentUrl, ctaAccentUrl = _27 === void 0 ? '' : _27, _28 = _a.ctaPrimaryText, ctaPrimaryText = _28 === void 0 ? 'Primary Action' : _28, _29 = _a.ctaSecondaryText, ctaSecondaryText = _29 === void 0 ? 'Secondary Action' : _29, _30 = _a.ctaAccentText, ctaAccentText = _30 === void 0 ? 'Accent Action' : _30, _31 = _a.ctaGap, ctaGap = _31 === void 0 ? '1rem' : _31, _32 = _a.ctaFlexJustify, ctaFlexJustify = _32 === void 0 ? 'center' : _32;
|
|
32
38
|
// Use the component config hook
|
|
33
39
|
var mergeWithLocal = (0, componentUtils_1.useComponentConfiguration)('Vista', variant).mergeWithLocal;
|
|
34
40
|
// Merge config with local props - local props should override config
|
|
@@ -57,25 +63,45 @@ var Vista = function (_a) {
|
|
|
57
63
|
containerClass: containerClass,
|
|
58
64
|
textWrapperClass: textWrapperClass,
|
|
59
65
|
imageWrapperClass: imageWrapperClass,
|
|
66
|
+
gap: gap,
|
|
60
67
|
// Enhanced content props
|
|
68
|
+
heading: heading,
|
|
61
69
|
headingSize: headingSize,
|
|
62
70
|
headingWeight: headingWeight,
|
|
63
71
|
headingColor: headingColor,
|
|
64
72
|
headingClass: headingClass,
|
|
73
|
+
subheading: subheading,
|
|
65
74
|
subheadingSize: subheadingSize,
|
|
66
75
|
subheadingWeight: subheadingWeight,
|
|
67
76
|
subheadingColor: subheadingColor,
|
|
68
77
|
subheadingClass: subheadingClass,
|
|
78
|
+
content: content,
|
|
69
79
|
contentSize: contentSize,
|
|
70
80
|
contentWeight: contentWeight,
|
|
71
81
|
contentColor: contentColor,
|
|
72
82
|
contentClass: contentClass,
|
|
83
|
+
image: image,
|
|
73
84
|
imageUrl: imageUrl,
|
|
74
85
|
imageSize: imageSize,
|
|
75
86
|
imageAlt: imageAlt,
|
|
76
87
|
imageClass: imageClass,
|
|
77
|
-
|
|
78
|
-
ctaClass: ctaClass
|
|
88
|
+
cta: cta,
|
|
89
|
+
ctaClass: ctaClass,
|
|
90
|
+
// CTA Button props
|
|
91
|
+
showPrimaryCTA: showPrimaryCTA,
|
|
92
|
+
showSecondaryCTA: showSecondaryCTA,
|
|
93
|
+
showAccentCTA: showAccentCTA,
|
|
94
|
+
primaryButtonOutlined: primaryButtonOutlined,
|
|
95
|
+
secondaryButtonOutlined: secondaryButtonOutlined,
|
|
96
|
+
accentButtonOutlined: accentButtonOutlined,
|
|
97
|
+
ctaPrimaryUrl: ctaPrimaryUrl,
|
|
98
|
+
ctaSecondaryUrl: ctaSecondaryUrl,
|
|
99
|
+
ctaAccentUrl: ctaAccentUrl,
|
|
100
|
+
ctaPrimaryText: ctaPrimaryText,
|
|
101
|
+
ctaSecondaryText: ctaSecondaryText,
|
|
102
|
+
ctaAccentText: ctaAccentText,
|
|
103
|
+
ctaGap: ctaGap,
|
|
104
|
+
ctaFlexJustify: ctaFlexJustify,
|
|
79
105
|
}).props;
|
|
80
106
|
var layoutClass = [
|
|
81
107
|
mergedProps.layout,
|
|
@@ -84,16 +110,26 @@ var Vista = function (_a) {
|
|
|
84
110
|
]
|
|
85
111
|
.filter(Boolean)
|
|
86
112
|
.join(' ');
|
|
113
|
+
// CTA Buttons Component
|
|
114
|
+
var CTAButtons = function () {
|
|
115
|
+
var hasCTAs = mergedProps.showPrimaryCTA || mergedProps.showSecondaryCTA || mergedProps.showAccentCTA;
|
|
116
|
+
if (!hasCTAs)
|
|
117
|
+
return null;
|
|
118
|
+
return (react_1.default.createElement(Flex_1.default, { gap: mergedProps.ctaGap, justify: mergedProps.ctaFlexJustify, className: "mt-6 ".concat(mergedProps.ctaClass), wrap: "wrap" },
|
|
119
|
+
mergedProps.showPrimaryCTA && (react_1.default.createElement(Button_1.default, { bg: mergedProps.primaryButtonOutlined ? undefined : "primary", outlined: mergedProps.primaryButtonOutlined, color: mergedProps.primaryButtonOutlined ? "primary" : undefined, onClick: function () { return window.location.href = mergedProps.ctaPrimaryUrl; } }, mergedProps.ctaPrimaryText)),
|
|
120
|
+
mergedProps.showSecondaryCTA && (react_1.default.createElement(Button_1.default, { bg: mergedProps.secondaryButtonOutlined ? undefined : "secondary", outlined: mergedProps.secondaryButtonOutlined, color: mergedProps.secondaryButtonOutlined ? "secondary" : undefined, onClick: function () { return window.location.href = mergedProps.ctaSecondaryUrl; } }, mergedProps.ctaSecondaryText)),
|
|
121
|
+
mergedProps.showAccentCTA && (react_1.default.createElement(Button_1.default, { bg: mergedProps.accentButtonOutlined ? undefined : "accent", outlined: mergedProps.accentButtonOutlined, color: mergedProps.accentButtonOutlined ? "accent" : undefined, onClick: function () { return window.location.href = mergedProps.ctaAccentUrl; } }, mergedProps.ctaAccentText))));
|
|
122
|
+
};
|
|
87
123
|
// Enhanced Text Content with flexible styling
|
|
88
124
|
var TextContent = (react_1.default.createElement("div", { className: "vista-text ".concat(mergedProps.layout === 'centered' ? "text-center" : "", " ").concat(mergedProps.textWrapperClass) },
|
|
89
|
-
heading && (react_1.default.createElement(Text_1.default, { block: true, size: mergedProps.headingSize, weight: mergedProps.headingWeight, color: mergedProps.headingColor, funcss: mergedProps.headingClass }, heading)),
|
|
90
|
-
subheading && (react_1.default.createElement(Text_1.default, { block: true, size: mergedProps.subheadingSize, weight: mergedProps.subheadingWeight, color: mergedProps.subheadingColor, funcss: "mt-2 ".concat(mergedProps.subheadingClass) }, subheading)),
|
|
91
|
-
content && (react_1.default.createElement(Text_1.default, { block: true, size: mergedProps.contentSize, weight: mergedProps.contentWeight, color: mergedProps.contentColor, funcss: "mt-4 ".concat(mergedProps.contentClass), article: true }, content || children)),
|
|
92
|
-
cta
|
|
125
|
+
mergedProps.heading && (react_1.default.createElement(Text_1.default, { block: true, size: mergedProps.headingSize, weight: mergedProps.headingWeight, color: mergedProps.headingColor, funcss: mergedProps.headingClass }, mergedProps.heading)),
|
|
126
|
+
mergedProps.subheading && (react_1.default.createElement(Text_1.default, { block: true, size: mergedProps.subheadingSize, weight: mergedProps.subheadingWeight, color: mergedProps.subheadingColor, funcss: "mt-2 ".concat(mergedProps.subheadingClass) }, mergedProps.subheading)),
|
|
127
|
+
mergedProps.content && (react_1.default.createElement(Text_1.default, { block: true, size: mergedProps.contentSize, weight: mergedProps.contentWeight, color: mergedProps.contentColor, funcss: "mt-4 ".concat(mergedProps.contentClass), article: true }, mergedProps.content || children)),
|
|
128
|
+
mergedProps.cta ? (react_1.default.createElement("div", { className: "mt-6 ".concat(mergedProps.ctaClass) }, mergedProps.cta)) : (react_1.default.createElement(CTAButtons, null))));
|
|
93
129
|
// Enhanced Image Content - uses imageUrl if no image component provided
|
|
94
|
-
var ImageContent = (image || mergedProps.imageUrl) && (react_1.default.createElement("div", { className: "vista-image ".concat(mergedProps.imageWrapperClass) }, image ? (image) : (react_1.default.createElement("img", { src: mergedProps.imageUrl, alt: mergedProps.imageAlt || 'Vista image', className: "".concat(mergedProps.imageClass), style: {
|
|
130
|
+
var ImageContent = (mergedProps.image || mergedProps.imageUrl) && (react_1.default.createElement("div", { className: "vista-image ".concat(mergedProps.imageWrapperClass) }, mergedProps.image ? (mergedProps.image) : (react_1.default.createElement("img", { src: mergedProps.imageUrl, alt: mergedProps.imageAlt || 'Vista image', className: "".concat(mergedProps.imageClass), style: {
|
|
95
131
|
objectFit: 'cover',
|
|
96
|
-
maxWidth: imageSize,
|
|
132
|
+
maxWidth: mergedProps.imageSize,
|
|
97
133
|
borderRadius: 'inherit'
|
|
98
134
|
} }))));
|
|
99
135
|
var isCentered = mergedProps.layout === 'centered';
|
|
@@ -33,16 +33,42 @@ export interface MergedConfig {
|
|
|
33
33
|
export interface UseComponentConfigReturn extends ComponentConfig {
|
|
34
34
|
mergeWithLocal: (localProps?: ComponentProps) => MergedConfig;
|
|
35
35
|
getProp: <T = any>(propName: string, defaultValue?: T) => T;
|
|
36
|
+
hasVariant: boolean;
|
|
37
|
+
isDefaultVariant: boolean;
|
|
36
38
|
}
|
|
37
39
|
/**
|
|
38
40
|
* Universal component config getter
|
|
41
|
+
*
|
|
42
|
+
* @param projectData - The project configuration data
|
|
43
|
+
* @param componentName - Name of the component to get config for
|
|
44
|
+
* @param variantName - Name of the variant (defaults to 'default')
|
|
45
|
+
* @returns Component configuration with metadata
|
|
39
46
|
*/
|
|
40
47
|
export declare const getComponentConfig: (projectData: ProjectData | null | undefined, componentName: string, variantName?: string) => ComponentConfig;
|
|
41
48
|
/**
|
|
42
49
|
* Merge component config with local props - only applies config if variant exists
|
|
50
|
+
*
|
|
51
|
+
* @param config - Component configuration from getComponentConfig
|
|
52
|
+
* @param localProps - Props passed directly to the component
|
|
53
|
+
* @returns Merged configuration with metadata
|
|
43
54
|
*/
|
|
44
55
|
export declare const mergeComponentConfig: (config: ComponentConfig, localProps?: ComponentProps) => MergedConfig;
|
|
45
56
|
/**
|
|
46
57
|
* Hook for easy component config usage - only applies if variant is provided and exists
|
|
58
|
+
* Uses useMemo to prevent unnecessary re-computation
|
|
59
|
+
*
|
|
60
|
+
* @param componentName - Name of the component
|
|
61
|
+
* @param variantName - Optional variant name
|
|
62
|
+
* @returns Configuration object with helper methods
|
|
47
63
|
*/
|
|
48
64
|
export declare const useComponentConfiguration: (componentName: string, variantName?: string) => UseComponentConfigReturn;
|
|
65
|
+
/**
|
|
66
|
+
* Utility function to check if a component variant exists
|
|
67
|
+
* Useful for conditional rendering logic
|
|
68
|
+
*/
|
|
69
|
+
export declare const hasComponentVariant: (projectData: ProjectData | null | undefined, componentName: string, variantName: string) => boolean;
|
|
70
|
+
/**
|
|
71
|
+
* Get all available variants for a component
|
|
72
|
+
* Useful for variant selectors/dropdowns
|
|
73
|
+
*/
|
|
74
|
+
export declare const getAvailableVariants: (projectData: ProjectData | null | undefined, componentName: string) => string[];
|
package/utils/componentUtils.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
// import { useTheme } from "../ui/theme/theme"
|
|
2
3
|
var __assign = (this && this.__assign) || function () {
|
|
3
4
|
__assign = Object.assign || function(t) {
|
|
4
5
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
@@ -11,14 +12,168 @@ var __assign = (this && this.__assign) || function () {
|
|
|
11
12
|
return __assign.apply(this, arguments);
|
|
12
13
|
};
|
|
13
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.useComponentConfiguration = exports.mergeComponentConfig = exports.getComponentConfig = void 0;
|
|
15
|
+
exports.getAvailableVariants = exports.hasComponentVariant = exports.useComponentConfiguration = exports.mergeComponentConfig = exports.getComponentConfig = void 0;
|
|
16
|
+
// // utils/componentUtils.ts
|
|
17
|
+
// // Type definitions
|
|
18
|
+
// export interface ComponentProps {
|
|
19
|
+
// [key: string]: any
|
|
20
|
+
// }
|
|
21
|
+
// export interface ComponentMetadata {
|
|
22
|
+
// createdAt?: Date
|
|
23
|
+
// updatedAt?: Date
|
|
24
|
+
// isCustom?: boolean
|
|
25
|
+
// baseVariant?: string
|
|
26
|
+
// }
|
|
27
|
+
// export interface ComponentVariant {
|
|
28
|
+
// componentProps: ComponentProps
|
|
29
|
+
// metadata?: ComponentMetadata
|
|
30
|
+
// }
|
|
31
|
+
// export interface ComponentConfig {
|
|
32
|
+
// componentProps: ComponentProps
|
|
33
|
+
// variantExists: boolean
|
|
34
|
+
// actualVariant: string
|
|
35
|
+
// availableVariants: string[]
|
|
36
|
+
// metadata: ComponentMetadata
|
|
37
|
+
// }
|
|
38
|
+
// export interface ProjectData {
|
|
39
|
+
// components?: {
|
|
40
|
+
// [componentName: string]: {
|
|
41
|
+
// [variantName: string]: ComponentVariant
|
|
42
|
+
// }
|
|
43
|
+
// }
|
|
44
|
+
// }
|
|
45
|
+
// export interface MergedConfig {
|
|
46
|
+
// props: ComponentProps
|
|
47
|
+
// variant: string
|
|
48
|
+
// hasConfig: boolean
|
|
49
|
+
// }
|
|
50
|
+
// export interface UseComponentConfigReturn extends ComponentConfig {
|
|
51
|
+
// mergeWithLocal: (localProps?: ComponentProps) => MergedConfig
|
|
52
|
+
// getProp: <T = any>(propName: string, defaultValue?: T) => T
|
|
53
|
+
// }
|
|
54
|
+
// /**
|
|
55
|
+
// * Universal component config getter
|
|
56
|
+
// */
|
|
57
|
+
// export const getComponentConfig = (
|
|
58
|
+
// projectData: ProjectData | null | undefined,
|
|
59
|
+
// componentName: string,
|
|
60
|
+
// variantName: string = 'default'
|
|
61
|
+
// ): ComponentConfig => {
|
|
62
|
+
// if (!projectData?.components?.[componentName]) {
|
|
63
|
+
// return {
|
|
64
|
+
// componentProps: {},
|
|
65
|
+
// variantExists: false,
|
|
66
|
+
// actualVariant: variantName,
|
|
67
|
+
// availableVariants: [],
|
|
68
|
+
// metadata: {}
|
|
69
|
+
// }
|
|
70
|
+
// }
|
|
71
|
+
// const component = projectData.components[componentName]
|
|
72
|
+
// const availableVariants = Object.keys(component)
|
|
73
|
+
// // Find the best variant match
|
|
74
|
+
// let targetVariant = variantName
|
|
75
|
+
// if (!availableVariants.includes(variantName)) {
|
|
76
|
+
// if (availableVariants.includes('default')) {
|
|
77
|
+
// targetVariant = 'default'
|
|
78
|
+
// } else if (availableVariants.length > 0) {
|
|
79
|
+
// targetVariant = availableVariants[0]
|
|
80
|
+
// } else {
|
|
81
|
+
// return {
|
|
82
|
+
// componentProps: {},
|
|
83
|
+
// variantExists: false,
|
|
84
|
+
// actualVariant: variantName,
|
|
85
|
+
// availableVariants: [],
|
|
86
|
+
// metadata: {}
|
|
87
|
+
// }
|
|
88
|
+
// }
|
|
89
|
+
// }
|
|
90
|
+
// const variantData = component[targetVariant] || {}
|
|
91
|
+
// return {
|
|
92
|
+
// componentProps: variantData.componentProps || {},
|
|
93
|
+
// variantExists: true,
|
|
94
|
+
// actualVariant: targetVariant,
|
|
95
|
+
// availableVariants,
|
|
96
|
+
// metadata: variantData.metadata || {}
|
|
97
|
+
// }
|
|
98
|
+
// }
|
|
99
|
+
// /**
|
|
100
|
+
// * Merge component config with local props - only applies config if variant exists
|
|
101
|
+
// */
|
|
102
|
+
// export const mergeComponentConfig = (
|
|
103
|
+
// config: ComponentConfig,
|
|
104
|
+
// localProps: ComponentProps = {}
|
|
105
|
+
// ): MergedConfig => {
|
|
106
|
+
// // Only apply config if variant exists and has actual configuration
|
|
107
|
+
// const hasValidConfig = config.variantExists && Object.keys(config.componentProps).length > 0
|
|
108
|
+
// if (!hasValidConfig) {
|
|
109
|
+
// return {
|
|
110
|
+
// props: localProps,
|
|
111
|
+
// variant: config.actualVariant,
|
|
112
|
+
// hasConfig: false
|
|
113
|
+
// }
|
|
114
|
+
// }
|
|
115
|
+
// return {
|
|
116
|
+
// // Props: config overrides local only if variant exists
|
|
117
|
+
// props: {
|
|
118
|
+
// ...localProps,
|
|
119
|
+
// ...config.componentProps
|
|
120
|
+
// },
|
|
121
|
+
// // Metadata
|
|
122
|
+
// variant: config.actualVariant,
|
|
123
|
+
// hasConfig: true
|
|
124
|
+
// }
|
|
125
|
+
// }
|
|
126
|
+
// /**
|
|
127
|
+
// * Hook for easy component config usage - only applies if variant is provided and exists
|
|
128
|
+
// */
|
|
129
|
+
// export const useComponentConfiguration = (
|
|
130
|
+
// componentName: string,
|
|
131
|
+
// variantName?: string // Make variantName optional
|
|
132
|
+
// ): UseComponentConfigReturn => {
|
|
133
|
+
// const { projectData } = useTheme()
|
|
134
|
+
// // Only get config if variantName is provided
|
|
135
|
+
// const config = variantName ? getComponentConfig(projectData, componentName, variantName) : {
|
|
136
|
+
// componentProps: {},
|
|
137
|
+
// variantExists: false,
|
|
138
|
+
// actualVariant: '',
|
|
139
|
+
// availableVariants: [],
|
|
140
|
+
// metadata: {}
|
|
141
|
+
// }
|
|
142
|
+
// const mergeWithLocal = (
|
|
143
|
+
// localProps: ComponentProps = {}
|
|
144
|
+
// ): MergedConfig => {
|
|
145
|
+
// // If no variant name was provided, return local props as-is
|
|
146
|
+
// if (!variantName) {
|
|
147
|
+
// return {
|
|
148
|
+
// props: localProps,
|
|
149
|
+
// variant: '',
|
|
150
|
+
// hasConfig: false
|
|
151
|
+
// }
|
|
152
|
+
// }
|
|
153
|
+
// return mergeComponentConfig(config, localProps)
|
|
154
|
+
// }
|
|
155
|
+
// const getProp = <T = any>(propName: string, defaultValue?: T): T =>
|
|
156
|
+
// (config.componentProps[propName] ?? defaultValue) as T
|
|
157
|
+
// return {
|
|
158
|
+
// ...config,
|
|
159
|
+
// mergeWithLocal,
|
|
160
|
+
// getProp
|
|
161
|
+
// }
|
|
162
|
+
// }
|
|
15
163
|
var theme_1 = require("../ui/theme/theme");
|
|
164
|
+
var react_1 = require("react");
|
|
16
165
|
/**
|
|
17
166
|
* Universal component config getter
|
|
167
|
+
*
|
|
168
|
+
* @param projectData - The project configuration data
|
|
169
|
+
* @param componentName - Name of the component to get config for
|
|
170
|
+
* @param variantName - Name of the variant (defaults to 'default')
|
|
171
|
+
* @returns Component configuration with metadata
|
|
18
172
|
*/
|
|
19
173
|
var getComponentConfig = function (projectData, componentName, variantName) {
|
|
20
174
|
var _a;
|
|
21
175
|
if (variantName === void 0) { variantName = 'default'; }
|
|
176
|
+
// Early return if no component exists
|
|
22
177
|
if (!((_a = projectData === null || projectData === void 0 ? void 0 : projectData.components) === null || _a === void 0 ? void 0 : _a[componentName])) {
|
|
23
178
|
return {
|
|
24
179
|
componentProps: {},
|
|
@@ -30,14 +185,18 @@ var getComponentConfig = function (projectData, componentName, variantName) {
|
|
|
30
185
|
}
|
|
31
186
|
var component = projectData.components[componentName];
|
|
32
187
|
var availableVariants = Object.keys(component);
|
|
33
|
-
// Find the best variant match
|
|
188
|
+
// Find the best variant match with fallback chain
|
|
34
189
|
var targetVariant = variantName;
|
|
35
|
-
|
|
190
|
+
var variantExists = availableVariants.includes(variantName);
|
|
191
|
+
if (!variantExists) {
|
|
192
|
+
// Fallback priority: default → first available → none
|
|
36
193
|
if (availableVariants.includes('default')) {
|
|
37
194
|
targetVariant = 'default';
|
|
195
|
+
variantExists = true;
|
|
38
196
|
}
|
|
39
197
|
else if (availableVariants.length > 0) {
|
|
40
198
|
targetVariant = availableVariants[0];
|
|
199
|
+
variantExists = true;
|
|
41
200
|
}
|
|
42
201
|
else {
|
|
43
202
|
return {
|
|
@@ -49,18 +208,41 @@ var getComponentConfig = function (projectData, componentName, variantName) {
|
|
|
49
208
|
};
|
|
50
209
|
}
|
|
51
210
|
}
|
|
52
|
-
var variantData = component[targetVariant]
|
|
211
|
+
var variantData = component[targetVariant];
|
|
53
212
|
return {
|
|
54
|
-
componentProps: variantData.componentProps || {},
|
|
55
|
-
variantExists:
|
|
213
|
+
componentProps: (variantData === null || variantData === void 0 ? void 0 : variantData.componentProps) || {},
|
|
214
|
+
variantExists: variantExists,
|
|
56
215
|
actualVariant: targetVariant,
|
|
57
216
|
availableVariants: availableVariants,
|
|
58
|
-
metadata: variantData.metadata || {}
|
|
217
|
+
metadata: (variantData === null || variantData === void 0 ? void 0 : variantData.metadata) || {}
|
|
59
218
|
};
|
|
60
219
|
};
|
|
61
220
|
exports.getComponentConfig = getComponentConfig;
|
|
221
|
+
/**
|
|
222
|
+
* Deep merge utility for nested objects
|
|
223
|
+
* Config props override local props, but we preserve nested structure
|
|
224
|
+
*/
|
|
225
|
+
var deepMerge = function (target, source) {
|
|
226
|
+
var result = __assign({}, target);
|
|
227
|
+
for (var key in source) {
|
|
228
|
+
if (source[key] !== undefined) {
|
|
229
|
+
// For objects, do shallow merge (we don't go too deep to avoid complexity)
|
|
230
|
+
if (typeof source[key] === 'object' && !Array.isArray(source[key]) && source[key] !== null) {
|
|
231
|
+
result[key] = __assign(__assign({}, (target[key] || {})), source[key]);
|
|
232
|
+
}
|
|
233
|
+
else {
|
|
234
|
+
result[key] = source[key];
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
return result;
|
|
239
|
+
};
|
|
62
240
|
/**
|
|
63
241
|
* Merge component config with local props - only applies config if variant exists
|
|
242
|
+
*
|
|
243
|
+
* @param config - Component configuration from getComponentConfig
|
|
244
|
+
* @param localProps - Props passed directly to the component
|
|
245
|
+
* @returns Merged configuration with metadata
|
|
64
246
|
*/
|
|
65
247
|
var mergeComponentConfig = function (config, localProps) {
|
|
66
248
|
if (localProps === void 0) { localProps = {}; }
|
|
@@ -74,9 +256,9 @@ var mergeComponentConfig = function (config, localProps) {
|
|
|
74
256
|
};
|
|
75
257
|
}
|
|
76
258
|
return {
|
|
77
|
-
//
|
|
78
|
-
props:
|
|
79
|
-
|
|
259
|
+
// Props: config overrides local, with deep merge for nested objects
|
|
260
|
+
props: deepMerge(localProps, config.componentProps),
|
|
261
|
+
// Metadata
|
|
80
262
|
variant: config.actualVariant,
|
|
81
263
|
hasConfig: true
|
|
82
264
|
};
|
|
@@ -84,31 +266,64 @@ var mergeComponentConfig = function (config, localProps) {
|
|
|
84
266
|
exports.mergeComponentConfig = mergeComponentConfig;
|
|
85
267
|
/**
|
|
86
268
|
* Hook for easy component config usage - only applies if variant is provided and exists
|
|
269
|
+
* Uses useMemo to prevent unnecessary re-computation
|
|
270
|
+
*
|
|
271
|
+
* @param componentName - Name of the component
|
|
272
|
+
* @param variantName - Optional variant name
|
|
273
|
+
* @returns Configuration object with helper methods
|
|
87
274
|
*/
|
|
88
|
-
var useComponentConfiguration = function (componentName, variantName
|
|
89
|
-
) {
|
|
275
|
+
var useComponentConfiguration = function (componentName, variantName) {
|
|
90
276
|
var projectData = (0, theme_1.useTheme)().projectData;
|
|
91
|
-
//
|
|
92
|
-
var config =
|
|
93
|
-
componentProps: {},
|
|
94
|
-
variantExists: false,
|
|
95
|
-
actualVariant: '',
|
|
96
|
-
availableVariants: [],
|
|
97
|
-
metadata: {}
|
|
98
|
-
};
|
|
99
|
-
var mergeWithLocal = function (localProps) {
|
|
100
|
-
if (localProps === void 0) { localProps = {}; }
|
|
101
|
-
// If no variant name was provided, return local props as-is
|
|
277
|
+
// Memoize config computation - only recompute when dependencies change
|
|
278
|
+
var config = (0, react_1.useMemo)(function () {
|
|
102
279
|
if (!variantName) {
|
|
103
280
|
return {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
281
|
+
componentProps: {},
|
|
282
|
+
variantExists: false,
|
|
283
|
+
actualVariant: '',
|
|
284
|
+
availableVariants: [],
|
|
285
|
+
metadata: {}
|
|
107
286
|
};
|
|
108
287
|
}
|
|
109
|
-
return (0, exports.
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
|
|
288
|
+
return (0, exports.getComponentConfig)(projectData, componentName, variantName);
|
|
289
|
+
}, [projectData, componentName, variantName]);
|
|
290
|
+
// Memoize merge function
|
|
291
|
+
var mergeWithLocal = (0, react_1.useMemo)(function () {
|
|
292
|
+
return function (localProps) {
|
|
293
|
+
if (localProps === void 0) { localProps = {}; }
|
|
294
|
+
// If no variant name was provided, return local props as-is
|
|
295
|
+
if (!variantName) {
|
|
296
|
+
return {
|
|
297
|
+
props: localProps,
|
|
298
|
+
variant: '',
|
|
299
|
+
hasConfig: false
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
return (0, exports.mergeComponentConfig)(config, localProps);
|
|
303
|
+
};
|
|
304
|
+
}, [config, variantName]);
|
|
305
|
+
// Memoize getProp function
|
|
306
|
+
var getProp = (0, react_1.useMemo)(function () {
|
|
307
|
+
return function (propName, defaultValue) { var _a; return ((_a = config.componentProps[propName]) !== null && _a !== void 0 ? _a : defaultValue); };
|
|
308
|
+
}, [config.componentProps]);
|
|
309
|
+
return __assign(__assign({}, config), { mergeWithLocal: mergeWithLocal, getProp: getProp, hasVariant: config.variantExists, isDefaultVariant: config.actualVariant === 'default' });
|
|
113
310
|
};
|
|
114
311
|
exports.useComponentConfiguration = useComponentConfiguration;
|
|
312
|
+
/**
|
|
313
|
+
* Utility function to check if a component variant exists
|
|
314
|
+
* Useful for conditional rendering logic
|
|
315
|
+
*/
|
|
316
|
+
var hasComponentVariant = function (projectData, componentName, variantName) {
|
|
317
|
+
var _a, _b;
|
|
318
|
+
return !!((_b = (_a = projectData === null || projectData === void 0 ? void 0 : projectData.components) === null || _a === void 0 ? void 0 : _a[componentName]) === null || _b === void 0 ? void 0 : _b[variantName]);
|
|
319
|
+
};
|
|
320
|
+
exports.hasComponentVariant = hasComponentVariant;
|
|
321
|
+
/**
|
|
322
|
+
* Get all available variants for a component
|
|
323
|
+
* Useful for variant selectors/dropdowns
|
|
324
|
+
*/
|
|
325
|
+
var getAvailableVariants = function (projectData, componentName) {
|
|
326
|
+
var _a;
|
|
327
|
+
return Object.keys(((_a = projectData === null || projectData === void 0 ? void 0 : projectData.components) === null || _a === void 0 ? void 0 : _a[componentName]) || {});
|
|
328
|
+
};
|
|
329
|
+
exports.getAvailableVariants = getAvailableVariants;
|