funuicss 3.6.9 → 3.6.11
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/css/fun.css +7 -21
- package/package.json +1 -1
- package/ui/accordion/Accordion.d.ts +1 -0
- package/ui/accordion/Accordion.js +4 -4
- package/ui/carousel/Carousel.d.ts +3 -1
- package/ui/carousel/Carousel.js +29 -5
- package/ui/input/Input.js +83 -20
- package/ui/theme/theme.d.ts +2 -0
- package/ui/theme/theme.js +9 -9
- package/ui/vista/Vista.d.ts +19 -0
- package/ui/vista/Vista.js +107 -42
- package/utils/componentUtils.d.ts +26 -0
- package/utils/componentUtils.js +244 -29
package/css/fun.css
CHANGED
|
@@ -1953,7 +1953,9 @@ link:hover {
|
|
|
1953
1953
|
.text-dark{
|
|
1954
1954
|
color: var(--dark) !important;
|
|
1955
1955
|
}
|
|
1956
|
-
|
|
1956
|
+
.text-default{
|
|
1957
|
+
color: var(--text-color) !important;
|
|
1958
|
+
}
|
|
1957
1959
|
.text-gradient,
|
|
1958
1960
|
.hover-text-gradient:hover {
|
|
1959
1961
|
background: -webkit-linear-gradient(var(--gradientColors));
|
|
@@ -1987,7 +1989,7 @@ body {
|
|
|
1987
1989
|
background-color: var(--page-bg) !important;
|
|
1988
1990
|
color: var(--text-color) !important;
|
|
1989
1991
|
}
|
|
1990
|
-
.bg{
|
|
1992
|
+
.bg, .page-bg{
|
|
1991
1993
|
background-color: var(--page-bg) !important;
|
|
1992
1994
|
}
|
|
1993
1995
|
|
|
@@ -3223,7 +3225,6 @@ border-radius: var(--borderRadius);
|
|
|
3223
3225
|
|
|
3224
3226
|
.main-content {
|
|
3225
3227
|
flex: 1;
|
|
3226
|
-
padding: 1rem 5px;
|
|
3227
3228
|
overflow-y: auto;
|
|
3228
3229
|
}
|
|
3229
3230
|
|
|
@@ -3491,7 +3492,6 @@ border-radius: var(--borderRadius);
|
|
|
3491
3492
|
}
|
|
3492
3493
|
|
|
3493
3494
|
|
|
3494
|
-
.button
|
|
3495
3495
|
/*inputs*/
|
|
3496
3496
|
.input {
|
|
3497
3497
|
padding: var(--inputPadding);
|
|
@@ -3557,17 +3557,6 @@ border-radius: var(--borderRadius);
|
|
|
3557
3557
|
display: none;
|
|
3558
3558
|
}
|
|
3559
3559
|
|
|
3560
|
-
.input.success-input{
|
|
3561
|
-
border-bottom:var(--inputBorder) solid var(--success) !important;
|
|
3562
|
-
}
|
|
3563
|
-
|
|
3564
|
-
|
|
3565
|
-
.input.warning-input{
|
|
3566
|
-
border-bottom:var(--inputBorder) solid var(--warning) !important;
|
|
3567
|
-
}
|
|
3568
|
-
.input.danger-input{
|
|
3569
|
-
border-bottom:var(--inputBorder) solid var(--danger) !important;
|
|
3570
|
-
}
|
|
3571
3560
|
.input.success-input ,
|
|
3572
3561
|
.warning-input,
|
|
3573
3562
|
.input.danger-input:focus
|
|
@@ -3576,8 +3565,7 @@ outline: none !important;
|
|
|
3576
3565
|
}
|
|
3577
3566
|
input , select {height: var(--inputButtonHeight); border-radius: var(--radius);}
|
|
3578
3567
|
textarea{border-radius: var(--radius) !important; height: fit-content !important;}
|
|
3579
|
-
.input.flat{border-radius: 0;}
|
|
3580
|
-
|
|
3568
|
+
.input.flat{border-radius: 0 !important;}
|
|
3581
3569
|
.input:focus {
|
|
3582
3570
|
border-bottom: var(--inputBorder) solid var(--primary);
|
|
3583
3571
|
}
|
|
@@ -3623,9 +3611,7 @@ background-color: rgba(var(--borderRgb), 0.3);
|
|
|
3623
3611
|
box-shadow: 0 0 0 3px rgba(var(--borderRgb), 0.1);
|
|
3624
3612
|
}
|
|
3625
3613
|
|
|
3626
|
-
.input.borderless {
|
|
3627
|
-
border: none;
|
|
3628
|
-
}
|
|
3614
|
+
.input.borderless {border: none !important;}
|
|
3629
3615
|
.input.borderless:focus {
|
|
3630
3616
|
border: none;
|
|
3631
3617
|
}
|
|
@@ -4669,6 +4655,7 @@ th {
|
|
|
4669
4655
|
|
|
4670
4656
|
.accordion {
|
|
4671
4657
|
width: 100%;
|
|
4658
|
+
overflow: visible !important;
|
|
4672
4659
|
}
|
|
4673
4660
|
|
|
4674
4661
|
.accordion-item {
|
|
@@ -4703,7 +4690,6 @@ cursor: pointer;
|
|
|
4703
4690
|
|
|
4704
4691
|
.accordion-content {
|
|
4705
4692
|
max-height: 0;
|
|
4706
|
-
overflow: hidden;
|
|
4707
4693
|
transition: max-height 1s ease-in-out, opacity 0.3s ease;
|
|
4708
4694
|
opacity: 0;
|
|
4709
4695
|
}
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "3.6.
|
|
2
|
+
"version": "3.6.11",
|
|
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",
|
|
@@ -59,14 +59,14 @@ var AccordionItem = function (_a) {
|
|
|
59
59
|
react_1.default.createElement("div", { className: "col fit" }, title)),
|
|
60
60
|
react_1.default.createElement("div", { style: { lineHeight: 0 }, className: "".concat(iconClass, " ").concat(isOpen ? 'accordion-rotated' : '') },
|
|
61
61
|
react_1.default.createElement(pi_1.PiCaretDown, null))),
|
|
62
|
-
react_1.default.createElement("div", { className: "accordion-content ".concat(contentClass, " ").concat(isOpen ? 'open' : '') },
|
|
62
|
+
react_1.default.createElement("div", { style: { overflow: isOpen ? 'visible' : 'hidden' }, className: "accordion-content ".concat(contentClass, " ").concat(isOpen ? 'open' : '') },
|
|
63
63
|
react_1.default.createElement("div", { className: "accordion-inner" }, content))));
|
|
64
64
|
};
|
|
65
65
|
exports.AccordionItem = AccordionItem;
|
|
66
66
|
var Accordion = function (_a) {
|
|
67
67
|
var _b;
|
|
68
|
-
var items = _a.items, _c = _a.allowMultiple, allowMultiple = _c === void 0 ? false : _c, _d = _a.defaultOpenIndexes, defaultOpenIndexes = _d === void 0 ? [] : _d, itemClass = _a.itemClass, titleClass = _a.titleClass, iconClass = _a.iconClass, contentClass = _a.contentClass, activeClass = _a.activeClass;
|
|
69
|
-
var
|
|
68
|
+
var items = _a.items, _c = _a.allowMultiple, allowMultiple = _c === void 0 ? false : _c, _d = _a.defaultOpenIndexes, defaultOpenIndexes = _d === void 0 ? [] : _d, itemClass = _a.itemClass, titleClass = _a.titleClass, iconClass = _a.iconClass, contentClass = _a.contentClass, activeClass = _a.activeClass, _e = _a.funcss, funcss = _e === void 0 ? '' : _e;
|
|
69
|
+
var _f = (0, react_1.useState)(allowMultiple ? defaultOpenIndexes : [(_b = defaultOpenIndexes[0]) !== null && _b !== void 0 ? _b : -1]), openIndexes = _f[0], setOpenIndexes = _f[1];
|
|
70
70
|
var toggleIndex = function (index) {
|
|
71
71
|
if (allowMultiple) {
|
|
72
72
|
if (openIndexes.includes(index)) {
|
|
@@ -80,6 +80,6 @@ var Accordion = function (_a) {
|
|
|
80
80
|
setOpenIndexes(openIndexes.includes(index) ? [] : [index]);
|
|
81
81
|
}
|
|
82
82
|
};
|
|
83
|
-
return (react_1.default.createElement("div", { className: "accordion" }, items.map(function (item, index) { return (react_1.default.createElement(exports.AccordionItem, { key: index, index: index, icon: item.icon, title: item.title, content: item.content, isOpen: openIndexes.includes(index), onToggle: function () { return toggleIndex(index); }, itemClass: itemClass, titleClass: titleClass, iconClass: iconClass, contentClass: contentClass, activeClass: activeClass })); })));
|
|
83
|
+
return (react_1.default.createElement("div", { className: "accordion ".concat(funcss) }, items.map(function (item, index) { return (react_1.default.createElement(exports.AccordionItem, { key: index, index: index, icon: item.icon, title: item.title, content: item.content, isOpen: openIndexes.includes(index), onToggle: function () { return toggleIndex(index); }, itemClass: itemClass, titleClass: titleClass, iconClass: iconClass, contentClass: contentClass, activeClass: activeClass })); })));
|
|
84
84
|
};
|
|
85
85
|
exports.default = Accordion;
|
|
@@ -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/input/Input.js
CHANGED
|
@@ -73,7 +73,7 @@ var generateInputClasses = function (_a) {
|
|
|
73
73
|
var bgClass = bg || '';
|
|
74
74
|
var flatClass = flat ? 'flat' : '';
|
|
75
75
|
var cornerClass = leftRounded ? 'leftRounded' : rightRounded ? 'rightRounded' : '';
|
|
76
|
-
var borderClass = bordered ? 'borderedInput' : borderless ? 'borderless' : '';
|
|
76
|
+
var borderClass = bordered ? 'borderedInput' : borderless ? 'borderless' : (!bordered && !borderless ? 'borderedInput' : '');
|
|
77
77
|
return "\n ".concat(statusClass, "\n ").concat(roundedClass, "\n ").concat(bgClass, "\n ").concat(funcss || '', "\n ").concat(flatClass, "\n ").concat(cornerClass, "\n ").concat(borderClass, "\n ").concat(additionalClasses, "\n input\n ").trim().replace(/\s+/g, ' ');
|
|
78
78
|
};
|
|
79
79
|
// Iconic Input Wrapper Component
|
|
@@ -95,8 +95,24 @@ var TextInput = function (_a) {
|
|
|
95
95
|
var id = _a.id, name = _a.name, value = _a.value, defaultValue = _a.defaultValue, onChange = _a.onChange, status = _a.status, funcss = _a.funcss, bg = _a.bg, _b = _a.fullWidth, fullWidth = _b === void 0 ? true : _b, flat = _a.flat, bordered = _a.bordered, borderless = _a.borderless, rounded = _a.rounded, leftRounded = _a.leftRounded, rightRounded = _a.rightRounded, startIcon = _a.startIcon, endIcon = _a.endIcon, iconicBg = _a.iconicBg, _c = _a.type, type = _c === void 0 ? 'text' : _c, label = _a.label, _d = _a.variant, variant = _d === void 0 ? '' : _d, rest = __rest(_a, ["id", "name", "value", "defaultValue", "onChange", "status", "funcss", "bg", "fullWidth", "flat", "bordered", "borderless", "rounded", "leftRounded", "rightRounded", "startIcon", "endIcon", "iconicBg", "type", "label", "variant"]);
|
|
96
96
|
// Use the component config hook
|
|
97
97
|
var mergeWithLocal = (0, componentUtils_1.useComponentConfiguration)('Input', variant).mergeWithLocal;
|
|
98
|
-
// Merge config with local props - local props
|
|
99
|
-
var mergedProps = mergeWithLocal(
|
|
98
|
+
// Merge config with local props - local props override config
|
|
99
|
+
var mergedProps = mergeWithLocal({
|
|
100
|
+
status: status,
|
|
101
|
+
funcss: funcss,
|
|
102
|
+
bg: bg,
|
|
103
|
+
fullWidth: fullWidth,
|
|
104
|
+
flat: flat,
|
|
105
|
+
bordered: bordered,
|
|
106
|
+
borderless: borderless,
|
|
107
|
+
rounded: rounded,
|
|
108
|
+
leftRounded: leftRounded,
|
|
109
|
+
rightRounded: rightRounded,
|
|
110
|
+
startIcon: startIcon,
|
|
111
|
+
endIcon: endIcon,
|
|
112
|
+
iconicBg: iconicBg,
|
|
113
|
+
}).props;
|
|
114
|
+
// Use theme variant for fallback
|
|
115
|
+
var themeVariant = (0, theme_1.useVariant)().variant;
|
|
100
116
|
var className = generateInputClasses({
|
|
101
117
|
status: mergedProps.status,
|
|
102
118
|
rounded: mergedProps.rounded,
|
|
@@ -106,10 +122,10 @@ var TextInput = function (_a) {
|
|
|
106
122
|
leftRounded: mergedProps.leftRounded,
|
|
107
123
|
rightRounded: mergedProps.rightRounded,
|
|
108
124
|
bordered: mergedProps.bordered,
|
|
109
|
-
borderless: mergedProps.borderless
|
|
125
|
+
borderless: mergedProps.borderless,
|
|
110
126
|
});
|
|
111
127
|
var style = mergedProps.fullWidth ? { width: '100%' } : undefined;
|
|
112
|
-
var inputElement = (react_1.default.createElement("input", __assign({ id: id, name: name, className: className, onChange: onChange, defaultValue: defaultValue, type: type, placeholder: label, style: style, value: value }, mergedProps)));
|
|
128
|
+
var inputElement = (react_1.default.createElement("input", __assign({ id: id, name: name, className: className, onChange: onChange, defaultValue: defaultValue, type: type, placeholder: label, style: style, value: value }, rest, mergedProps)));
|
|
113
129
|
return (react_1.default.createElement(IconicInputWrapper, { startIcon: mergedProps.startIcon, endIcon: mergedProps.endIcon, iconicBg: mergedProps.iconicBg, funcss: mergedProps.funcss }, inputElement));
|
|
114
130
|
};
|
|
115
131
|
exports.TextInput = TextInput;
|
|
@@ -118,8 +134,24 @@ var SelectInput = function (_a) {
|
|
|
118
134
|
var id = _a.id, name = _a.name, value = _a.value, defaultValue = _a.defaultValue, onChange = _a.onChange, status = _a.status, funcss = _a.funcss, bg = _a.bg, fullWidth = _a.fullWidth, flat = _a.flat, bordered = _a.bordered, borderless = _a.borderless, rounded = _a.rounded, leftRounded = _a.leftRounded, rightRounded = _a.rightRounded, startIcon = _a.startIcon, endIcon = _a.endIcon, iconicBg = _a.iconicBg, _b = _a.options, options = _b === void 0 ? [] : _b, _c = _a.variant, variant = _c === void 0 ? '' : _c, rest = __rest(_a, ["id", "name", "value", "defaultValue", "onChange", "status", "funcss", "bg", "fullWidth", "flat", "bordered", "borderless", "rounded", "leftRounded", "rightRounded", "startIcon", "endIcon", "iconicBg", "options", "variant"]);
|
|
119
135
|
// Use the component config hook
|
|
120
136
|
var mergeWithLocal = (0, componentUtils_1.useComponentConfiguration)('Input', variant).mergeWithLocal;
|
|
121
|
-
// Merge config with local props
|
|
122
|
-
var mergedProps = mergeWithLocal(
|
|
137
|
+
// Merge config with local props
|
|
138
|
+
var mergedProps = mergeWithLocal({
|
|
139
|
+
status: status,
|
|
140
|
+
funcss: funcss,
|
|
141
|
+
bg: bg,
|
|
142
|
+
fullWidth: fullWidth,
|
|
143
|
+
flat: flat,
|
|
144
|
+
bordered: bordered,
|
|
145
|
+
borderless: borderless,
|
|
146
|
+
rounded: rounded,
|
|
147
|
+
leftRounded: leftRounded,
|
|
148
|
+
rightRounded: rightRounded,
|
|
149
|
+
startIcon: startIcon,
|
|
150
|
+
endIcon: endIcon,
|
|
151
|
+
iconicBg: iconicBg,
|
|
152
|
+
}).props;
|
|
153
|
+
// Use theme variant for fallback
|
|
154
|
+
var themeVariant = (0, theme_1.useVariant)().variant;
|
|
123
155
|
var className = generateInputClasses({
|
|
124
156
|
status: mergedProps.status,
|
|
125
157
|
rounded: mergedProps.rounded,
|
|
@@ -129,10 +161,10 @@ var SelectInput = function (_a) {
|
|
|
129
161
|
leftRounded: mergedProps.leftRounded,
|
|
130
162
|
rightRounded: mergedProps.rightRounded,
|
|
131
163
|
bordered: mergedProps.bordered,
|
|
132
|
-
borderless: mergedProps.borderless
|
|
164
|
+
borderless: mergedProps.borderless,
|
|
133
165
|
});
|
|
134
166
|
var style = mergedProps.fullWidth ? { width: '100%' } : undefined;
|
|
135
|
-
var selectElement = (react_1.default.createElement("select", __assign({ id: id, name: name, className: className, onChange: onChange, defaultValue: defaultValue, value: value, style: style }, mergedProps), options.map(function (option) { return (react_1.default.createElement("option", { key: option.value, value: option.value }, option.text)); })));
|
|
167
|
+
var selectElement = (react_1.default.createElement("select", __assign({ id: id, name: name, className: className, onChange: onChange, defaultValue: defaultValue, value: value, style: style }, rest, mergedProps), options.map(function (option) { return (react_1.default.createElement("option", { key: option.value, value: option.value }, option.text)); })));
|
|
136
168
|
return (react_1.default.createElement(IconicInputWrapper, { startIcon: mergedProps.startIcon, endIcon: mergedProps.endIcon, iconicBg: mergedProps.iconicBg, funcss: mergedProps.funcss }, selectElement));
|
|
137
169
|
};
|
|
138
170
|
exports.SelectInput = SelectInput;
|
|
@@ -141,8 +173,24 @@ var TextareaInput = function (_a) {
|
|
|
141
173
|
var id = _a.id, name = _a.name, value = _a.value, defaultValue = _a.defaultValue, onChange = _a.onChange, status = _a.status, funcss = _a.funcss, bg = _a.bg, fullWidth = _a.fullWidth, flat = _a.flat, bordered = _a.bordered, borderless = _a.borderless, rounded = _a.rounded, leftRounded = _a.leftRounded, rightRounded = _a.rightRounded, startIcon = _a.startIcon, endIcon = _a.endIcon, iconicBg = _a.iconicBg, label = _a.label, _b = _a.rows, rows = _b === void 0 ? 2 : _b, _c = _a.variant, variant = _c === void 0 ? '' : _c, rest = __rest(_a, ["id", "name", "value", "defaultValue", "onChange", "status", "funcss", "bg", "fullWidth", "flat", "bordered", "borderless", "rounded", "leftRounded", "rightRounded", "startIcon", "endIcon", "iconicBg", "label", "rows", "variant"]);
|
|
142
174
|
// Use the component config hook
|
|
143
175
|
var mergeWithLocal = (0, componentUtils_1.useComponentConfiguration)('Input', variant).mergeWithLocal;
|
|
144
|
-
// Merge config with local props
|
|
145
|
-
var mergedProps = mergeWithLocal(
|
|
176
|
+
// Merge config with local props
|
|
177
|
+
var mergedProps = mergeWithLocal({
|
|
178
|
+
status: status,
|
|
179
|
+
funcss: funcss,
|
|
180
|
+
bg: bg,
|
|
181
|
+
fullWidth: fullWidth,
|
|
182
|
+
flat: flat,
|
|
183
|
+
bordered: bordered,
|
|
184
|
+
borderless: borderless,
|
|
185
|
+
rounded: rounded,
|
|
186
|
+
leftRounded: leftRounded,
|
|
187
|
+
rightRounded: rightRounded,
|
|
188
|
+
startIcon: startIcon,
|
|
189
|
+
endIcon: endIcon,
|
|
190
|
+
iconicBg: iconicBg,
|
|
191
|
+
}).props;
|
|
192
|
+
// Use theme variant for fallback
|
|
193
|
+
var themeVariant = (0, theme_1.useVariant)().variant;
|
|
146
194
|
var className = generateInputClasses({
|
|
147
195
|
status: mergedProps.status,
|
|
148
196
|
rounded: mergedProps.rounded,
|
|
@@ -152,10 +200,10 @@ var TextareaInput = function (_a) {
|
|
|
152
200
|
leftRounded: mergedProps.leftRounded,
|
|
153
201
|
rightRounded: mergedProps.rightRounded,
|
|
154
202
|
bordered: mergedProps.bordered,
|
|
155
|
-
borderless: mergedProps.borderless
|
|
203
|
+
borderless: mergedProps.borderless,
|
|
156
204
|
});
|
|
157
205
|
var style = mergedProps.fullWidth ? { width: '100%' } : undefined;
|
|
158
|
-
var textareaElement = (react_1.default.createElement("textarea", __assign({ id: id, name: name, className: className, onChange: onChange, defaultValue: defaultValue, placeholder: label, style: style, value: value, rows: rows }, mergedProps)));
|
|
206
|
+
var textareaElement = (react_1.default.createElement("textarea", __assign({ id: id, name: name, className: className, onChange: onChange, defaultValue: defaultValue, placeholder: label, style: style, value: value, rows: rows }, rest, mergedProps)));
|
|
159
207
|
return (react_1.default.createElement(IconicInputWrapper, { startIcon: mergedProps.startIcon, endIcon: mergedProps.endIcon, iconicBg: mergedProps.iconicBg, funcss: mergedProps.funcss }, textareaElement));
|
|
160
208
|
};
|
|
161
209
|
exports.TextareaInput = TextareaInput;
|
|
@@ -165,8 +213,24 @@ var FileInput = function (_a) {
|
|
|
165
213
|
var _e = (0, react_1.useState)(''), fileName = _e[0], setFileName = _e[1];
|
|
166
214
|
// Use the component config hook
|
|
167
215
|
var mergeWithLocal = (0, componentUtils_1.useComponentConfiguration)('Input', variant).mergeWithLocal;
|
|
168
|
-
// Merge config with local props
|
|
169
|
-
var mergedProps = mergeWithLocal(
|
|
216
|
+
// Merge config with local props
|
|
217
|
+
var mergedProps = mergeWithLocal({
|
|
218
|
+
status: status,
|
|
219
|
+
funcss: funcss,
|
|
220
|
+
bg: bg,
|
|
221
|
+
fullWidth: fullWidth,
|
|
222
|
+
flat: flat,
|
|
223
|
+
rounded: rounded,
|
|
224
|
+
leftRounded: leftRounded,
|
|
225
|
+
rightRounded: rightRounded,
|
|
226
|
+
startIcon: startIcon,
|
|
227
|
+
endIcon: endIcon,
|
|
228
|
+
iconicBg: iconicBg,
|
|
229
|
+
bordered: rest.bordered,
|
|
230
|
+
borderless: rest.borderless,
|
|
231
|
+
}).props;
|
|
232
|
+
// Use theme variant for fallback
|
|
233
|
+
var themeVariant = (0, theme_1.useVariant)().variant;
|
|
170
234
|
var handleChange = function (e) {
|
|
171
235
|
var _a;
|
|
172
236
|
var file = (_a = e.target.files) === null || _a === void 0 ? void 0 : _a[0];
|
|
@@ -192,7 +256,7 @@ var FileInput = function (_a) {
|
|
|
192
256
|
var style = mergedProps.fullWidth ? { width: '100%' } : undefined;
|
|
193
257
|
var fileInputElement = (react_1.default.createElement("div", { className: "fileInput" },
|
|
194
258
|
button || (react_1.default.createElement(Button_1.default, { funcss: mergedProps.funcss, startIcon: icon || react_1.default.createElement(pi_1.PiCloudArrowUp, null), bg: "primary", fullWidth: true, raised: true }, fileName || label)),
|
|
195
|
-
react_1.default.createElement("input", __assign({ id: id, name: name, className: className, onChange: handleChange, type: "file", style: style, value: value }, mergedProps))));
|
|
259
|
+
react_1.default.createElement("input", __assign({ id: id, name: name, className: className, onChange: handleChange, type: "file", style: style, value: value }, rest, mergedProps))));
|
|
196
260
|
return (react_1.default.createElement(IconicInputWrapper, { startIcon: mergedProps.startIcon, endIcon: mergedProps.endIcon, iconicBg: mergedProps.iconicBg, funcss: mergedProps.funcss }, fileInputElement));
|
|
197
261
|
}
|
|
198
262
|
var uploadElement = (react_1.default.createElement("div", { className: "_upload_container" },
|
|
@@ -206,7 +270,7 @@ var FileInput = function (_a) {
|
|
|
206
270
|
width: '100%',
|
|
207
271
|
} }, fileName || label),
|
|
208
272
|
extra && react_1.default.createElement("div", { className: "text-small opacity-3" }, extra)),
|
|
209
|
-
react_1.default.createElement("input", __assign({ onChange: handleChange, type: "file", id: id, className: "_upload_input" }, mergedProps))));
|
|
273
|
+
react_1.default.createElement("input", __assign({ onChange: handleChange, type: "file", id: id, className: "_upload_input" }, rest, mergedProps))));
|
|
210
274
|
return (react_1.default.createElement(IconicInputWrapper, { startIcon: mergedProps.startIcon, endIcon: mergedProps.endIcon, iconicBg: mergedProps.iconicBg, funcss: mergedProps.funcss }, uploadElement));
|
|
211
275
|
};
|
|
212
276
|
exports.FileInput = FileInput;
|
|
@@ -216,9 +280,8 @@ var Input = function (_a) {
|
|
|
216
280
|
var mergeWithLocal = (0, componentUtils_1.useComponentConfiguration)('Input', variant).mergeWithLocal;
|
|
217
281
|
// Merge config with local props
|
|
218
282
|
var mergedProps = mergeWithLocal(__assign(__assign({}, props), { startIcon: startIcon, endIcon: endIcon, iconicBg: iconicBg })).props;
|
|
219
|
-
// Handle legacy noBorder prop
|
|
220
|
-
var
|
|
221
|
-
var inputProps = __assign(__assign({}, mergedProps), { variant: variant, bordered: themeVariant === 'standard' ? true : mergedProps.bordered, borderless: themeVariant === 'minimal' ? true : noBorder || mergedProps.borderless });
|
|
283
|
+
// Handle legacy noBorder prop
|
|
284
|
+
var inputProps = __assign(__assign(__assign({}, props), mergedProps), { variant: variant, borderless: noBorder !== undefined ? noBorder : (props.borderless !== undefined ? props.borderless : mergedProps.borderless) });
|
|
222
285
|
if (select) {
|
|
223
286
|
return react_1.default.createElement(exports.SelectInput, __assign({}, inputProps));
|
|
224
287
|
}
|
package/ui/theme/theme.d.ts
CHANGED
package/ui/theme/theme.js
CHANGED
|
@@ -190,13 +190,13 @@ var subscribeToTheme = function (projectId, callback) {
|
|
|
190
190
|
/* COMPONENT */
|
|
191
191
|
/* -------------------------------------------------------------------------- */
|
|
192
192
|
var ThemeProvider = function (_a) {
|
|
193
|
-
var theme = _a.theme, children = _a.children, projectId = _a.projectId;
|
|
194
|
-
var
|
|
195
|
-
var
|
|
196
|
-
var
|
|
197
|
-
var
|
|
198
|
-
var
|
|
199
|
-
var
|
|
193
|
+
var theme = _a.theme, children = _a.children, _b = _a.funcss, funcss = _b === void 0 ? '' : _b, _c = _a.minHeight, minHeight = _c === void 0 ? '100vh' : _c, projectId = _a.projectId;
|
|
194
|
+
var _d = (0, react_1.useState)('standard'), variant = _d[0], setVariant = _d[1];
|
|
195
|
+
var _e = (0, react_1.useState)({}), themeConfig = _e[0], setThemeConfig = _e[1];
|
|
196
|
+
var _f = (0, react_1.useState)(null), projectData = _f[0], setProjectData = _f[1];
|
|
197
|
+
var _g = (0, react_1.useState)(true), isLoading = _g[0], setIsLoading = _g[1];
|
|
198
|
+
var _h = (0, react_1.useState)(true), isInitialLoad = _h[0], setIsInitialLoad = _h[1];
|
|
199
|
+
var _j = (0, react_1.useState)(null), error = _j[0], setError = _j[1];
|
|
200
200
|
/* -------------------------- Apply base theme --------------------------- */
|
|
201
201
|
(0, react_1.useEffect)(function () {
|
|
202
202
|
var root = document.documentElement;
|
|
@@ -303,10 +303,10 @@ var ThemeProvider = function (_a) {
|
|
|
303
303
|
}); }, [variant, themeConfig, projectData, isLoading, isInitialLoad, error]);
|
|
304
304
|
/* ------------------------------- Render ------------------------------- */
|
|
305
305
|
return (react_1.default.createElement(ThemeContext.Provider, { value: contextValue },
|
|
306
|
-
react_1.default.createElement("div", { className: "theme-".concat(theme), style: {
|
|
306
|
+
react_1.default.createElement("div", { className: "theme-".concat(theme, " ").concat(funcss), style: {
|
|
307
307
|
backgroundColor: 'var(--page-bg)',
|
|
308
308
|
color: 'var(--text-color)',
|
|
309
|
-
minHeight:
|
|
309
|
+
minHeight: minHeight,
|
|
310
310
|
// Smooth transition when theme changes
|
|
311
311
|
transition: isInitialLoad ? 'none' : 'background-color 0.3s ease, color 0.3s ease',
|
|
312
312
|
} }, children)));
|
package/ui/vista/Vista.d.ts
CHANGED
|
@@ -12,12 +12,30 @@ type VistaProps = {
|
|
|
12
12
|
blurry?: number;
|
|
13
13
|
opacity?: number;
|
|
14
14
|
heading?: React.ReactNode;
|
|
15
|
+
headingSize?: string;
|
|
16
|
+
headingWeight?: number;
|
|
17
|
+
headingColor?: string;
|
|
18
|
+
headingClass?: string;
|
|
15
19
|
subheading?: React.ReactNode;
|
|
20
|
+
subheadingSize?: string;
|
|
21
|
+
subheadingWeight?: number;
|
|
22
|
+
subheadingColor?: string;
|
|
23
|
+
subheadingClass?: string;
|
|
16
24
|
content?: React.ReactNode;
|
|
25
|
+
contentSize?: string;
|
|
26
|
+
contentWeight?: number;
|
|
27
|
+
contentColor?: string;
|
|
28
|
+
contentClass?: string;
|
|
17
29
|
image?: React.ReactNode;
|
|
30
|
+
imageUrl?: string;
|
|
31
|
+
imageAlt?: string;
|
|
32
|
+
imageClass?: string;
|
|
33
|
+
imageSize?: string;
|
|
18
34
|
cta?: React.ReactNode;
|
|
35
|
+
ctaClass?: string;
|
|
19
36
|
sectionClass?: string;
|
|
20
37
|
containerClass?: string;
|
|
38
|
+
gap?: string;
|
|
21
39
|
textWrapperClass?: string;
|
|
22
40
|
imageWrapperClass?: string;
|
|
23
41
|
children?: React.ReactNode;
|
|
@@ -30,6 +48,7 @@ type VistaProps = {
|
|
|
30
48
|
fadeRadial?: boolean;
|
|
31
49
|
fadeOverlayDarken?: number;
|
|
32
50
|
backgroundImage?: string;
|
|
51
|
+
variant?: string;
|
|
33
52
|
};
|
|
34
53
|
declare const Vista: React.FC<VistaProps>;
|
|
35
54
|
export default Vista;
|
package/ui/vista/Vista.js
CHANGED
|
@@ -18,28 +18,91 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
18
18
|
var react_1 = __importDefault(require("react"));
|
|
19
19
|
var ScrollInView_1 = __importDefault(require("../ScrollInView/ScrollInView"));
|
|
20
20
|
var getCssVariable_1 = require("../../utils/getCssVariable");
|
|
21
|
+
var componentUtils_1 = require("../../utils/componentUtils");
|
|
22
|
+
var Text_1 = __importDefault(require("../text/Text"));
|
|
23
|
+
var Col_1 = __importDefault(require("../grid/Col"));
|
|
21
24
|
var Vista = function (_a) {
|
|
22
|
-
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,
|
|
25
|
+
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
|
+
// Enhanced Content
|
|
27
|
+
heading = _a.heading, _l = _a.headingSize, headingSize = _l === void 0 ? '5xl' : _l, _m = _a.headingWeight, headingWeight = _m === void 0 ? 700 : _m, _o = _a.headingColor, headingColor = _o === void 0 ? '' : _o, _p = _a.headingClass, headingClass = _p === void 0 ? '' : _p, subheading = _a.subheading, _q = _a.subheadingSize, subheadingSize = _q === void 0 ? 'lg' : _q, _r = _a.subheadingWeight, subheadingWeight = _r === void 0 ? 400 : _r, _s = _a.subheadingColor, subheadingColor = _s === void 0 ? 'light' : _s, _t = _a.subheadingClass, subheadingClass = _t === void 0 ? '' : _t, content = _a.content, _u = _a.contentSize, contentSize = _u === void 0 ? 'base' : _u, _v = _a.contentWeight, contentWeight = _v === void 0 ? 400 : _v, _w = _a.contentColor, contentColor = _w === void 0 ? '' : _w, _x = _a.contentClass, contentClass = _x === void 0 ? '' : _x, image = _a.image, _y = _a.imageUrl, imageUrl = _y === void 0 ? '' : _y, _z = _a.imageAlt, imageAlt = _z === void 0 ? '' : _z, _0 = _a.imageClass, imageClass = _0 === void 0 ? '' : _0, _1 = _a.imageSize, imageSize = _1 === void 0 ? '100%' : _1, cta = _a.cta, _2 = _a.ctaClass, ctaClass = _2 === void 0 ? '' : _2, _3 = _a.sectionClass, sectionClass = _3 === void 0 ? '' : _3, _4 = _a.containerClass, containerClass = _4 === void 0 ? '' : _4, _5 = _a.textWrapperClass, textWrapperClass = _5 === void 0 ? '' : _5, _6 = _a.gap, gap = _6 === void 0 ? '2rem' : _6, _7 = _a.imageWrapperClass, imageWrapperClass = _7 === void 0 ? '' : _7, children = _a.children,
|
|
23
28
|
// Gradient Props
|
|
24
|
-
|
|
29
|
+
_8 = _a.showGradient,
|
|
25
30
|
// Gradient Props
|
|
26
|
-
showGradient =
|
|
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;
|
|
32
|
+
// Use the component config hook
|
|
33
|
+
var mergeWithLocal = (0, componentUtils_1.useComponentConfiguration)('Vista', variant).mergeWithLocal;
|
|
34
|
+
// Merge config with local props - local props should override config
|
|
35
|
+
var mergedProps = mergeWithLocal({
|
|
36
|
+
layout: layout,
|
|
37
|
+
reverse: reverse,
|
|
38
|
+
bg: bg,
|
|
39
|
+
padding: padding,
|
|
40
|
+
textAlign: textAlign,
|
|
41
|
+
imgPosition: imgPosition,
|
|
42
|
+
funcss: funcss,
|
|
43
|
+
pattern: pattern,
|
|
44
|
+
patternOpacity: patternOpacity,
|
|
45
|
+
showGradient: showGradient,
|
|
46
|
+
gradientPosition: gradientPosition,
|
|
47
|
+
gradientSize: gradientSize,
|
|
48
|
+
blurry: blurry,
|
|
49
|
+
opacity: opacity,
|
|
50
|
+
gradientColors: gradientColors,
|
|
51
|
+
fade: fade,
|
|
52
|
+
fadeDirection: fadeDirection,
|
|
53
|
+
fadeRadial: fadeRadial,
|
|
54
|
+
fadeOverlayDarken: fadeOverlayDarken,
|
|
55
|
+
backgroundImage: backgroundImage,
|
|
56
|
+
sectionClass: sectionClass,
|
|
57
|
+
containerClass: containerClass,
|
|
58
|
+
textWrapperClass: textWrapperClass,
|
|
59
|
+
imageWrapperClass: imageWrapperClass,
|
|
60
|
+
gap: gap,
|
|
61
|
+
// Enhanced content props
|
|
62
|
+
heading: heading,
|
|
63
|
+
headingSize: headingSize,
|
|
64
|
+
headingWeight: headingWeight,
|
|
65
|
+
headingColor: headingColor,
|
|
66
|
+
headingClass: headingClass,
|
|
67
|
+
subheading: subheading,
|
|
68
|
+
subheadingSize: subheadingSize,
|
|
69
|
+
subheadingWeight: subheadingWeight,
|
|
70
|
+
subheadingColor: subheadingColor,
|
|
71
|
+
subheadingClass: subheadingClass,
|
|
72
|
+
content: content,
|
|
73
|
+
contentSize: contentSize,
|
|
74
|
+
contentWeight: contentWeight,
|
|
75
|
+
contentColor: contentColor,
|
|
76
|
+
contentClass: contentClass,
|
|
77
|
+
image: image,
|
|
78
|
+
imageUrl: imageUrl,
|
|
79
|
+
imageSize: imageSize,
|
|
80
|
+
imageAlt: imageAlt,
|
|
81
|
+
imageClass: imageClass,
|
|
82
|
+
cta: cta,
|
|
83
|
+
ctaClass: ctaClass,
|
|
84
|
+
}).props;
|
|
27
85
|
var layoutClass = [
|
|
28
|
-
layout,
|
|
29
|
-
reverse ? 'reverse' : '',
|
|
30
|
-
"text-".concat(textAlign),
|
|
86
|
+
mergedProps.layout,
|
|
87
|
+
mergedProps.reverse ? 'reverse' : '',
|
|
88
|
+
"text-".concat(mergedProps.textAlign),
|
|
31
89
|
]
|
|
32
90
|
.filter(Boolean)
|
|
33
91
|
.join(' ');
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
var
|
|
42
|
-
|
|
92
|
+
// Enhanced Text Content with flexible styling
|
|
93
|
+
var TextContent = (react_1.default.createElement("div", { className: "vista-text ".concat(mergedProps.layout === 'centered' ? "text-center" : "", " ").concat(mergedProps.textWrapperClass) },
|
|
94
|
+
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)),
|
|
95
|
+
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)),
|
|
96
|
+
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)),
|
|
97
|
+
mergedProps.cta && (react_1.default.createElement("div", { className: "mt-6 ".concat(mergedProps.ctaClass) }, mergedProps.cta))));
|
|
98
|
+
// Enhanced Image Content - uses imageUrl if no image component provided
|
|
99
|
+
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: {
|
|
100
|
+
objectFit: 'cover',
|
|
101
|
+
maxWidth: mergedProps.imageSize,
|
|
102
|
+
borderRadius: 'inherit'
|
|
103
|
+
} }))));
|
|
104
|
+
var isCentered = mergedProps.layout === 'centered';
|
|
105
|
+
var isStacked = mergedProps.layout === 'stacked';
|
|
43
106
|
var positionStyles = {
|
|
44
107
|
'top-left': { top: '-100px', left: '-100px' },
|
|
45
108
|
'top-right': { top: '-100px', right: '-100px' },
|
|
@@ -49,59 +112,61 @@ var Vista = function (_a) {
|
|
|
49
112
|
};
|
|
50
113
|
var primaryColor = (0, getCssVariable_1.getCssVariableValue)('primary');
|
|
51
114
|
var secondaryColor = (0, getCssVariable_1.getCssVariableValue)('secondary');
|
|
52
|
-
var gradientStyle = __assign({ position: 'absolute', width: gradientSize, height: gradientSize, background: gradientColors || "radial-gradient(circle, ".concat(primaryColor, ", ").concat(secondaryColor, ")"), opacity: opacity, filter: "blur(".concat(blurry, "px)"), pointerEvents: 'none', zIndex: 0 }, positionStyles[gradientPosition]);
|
|
115
|
+
var gradientStyle = __assign({ position: 'absolute', width: mergedProps.gradientSize, height: mergedProps.gradientSize, background: mergedProps.gradientColors || "radial-gradient(circle, ".concat(primaryColor, ", ").concat(secondaryColor, ")"), opacity: mergedProps.opacity, filter: "blur(".concat(mergedProps.blurry, "px)"), pointerEvents: 'none', zIndex: 0 }, positionStyles[mergedProps.gradientPosition]);
|
|
53
116
|
return (react_1.default.createElement(ScrollInView_1.default, null,
|
|
54
|
-
react_1.default.createElement("div", { className: "vista \n ".concat(pattern === 'grid' ? 'grid-bg' :
|
|
55
|
-
pattern === 'dots' ? 'bg-pattern-dots' :
|
|
56
|
-
pattern === 'diagonal' ? 'bg-pattern-diagonal' :
|
|
57
|
-
pattern === 'checkerboard' ? 'bg-pattern-checkerboard' :
|
|
58
|
-
pattern === 'horizontal' ? 'bg-pattern-horizontal' :
|
|
59
|
-
pattern === 'vertical' ? 'bg-pattern-vertical' : '', " \n ").concat(bg, " ").concat(padding, " ").concat(layoutClass, " ").concat(sectionClass, " ").concat(funcss), style: {
|
|
117
|
+
react_1.default.createElement("div", { className: "vista \n ".concat(mergedProps.pattern === 'grid' ? 'grid-bg' :
|
|
118
|
+
mergedProps.pattern === 'dots' ? 'bg-pattern-dots' :
|
|
119
|
+
mergedProps.pattern === 'diagonal' ? 'bg-pattern-diagonal' :
|
|
120
|
+
mergedProps.pattern === 'checkerboard' ? 'bg-pattern-checkerboard' :
|
|
121
|
+
mergedProps.pattern === 'horizontal' ? 'bg-pattern-horizontal' :
|
|
122
|
+
mergedProps.pattern === 'vertical' ? 'bg-pattern-vertical' : '', " \n ").concat(mergedProps.bg, " p-").concat(mergedProps.padding, " ").concat(layoutClass, " ").concat(mergedProps.sectionClass, " ").concat(mergedProps.funcss), style: {
|
|
123
|
+
position: 'relative',
|
|
60
124
|
overflow: 'hidden',
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
125
|
+
minHeight: "90vh",
|
|
126
|
+
backgroundImage: mergedProps.pattern === 'grid' ? "linear-gradient(to right, rgba(var(--borderRgb), ".concat(mergedProps.patternOpacity, ") 1px, transparent 1px),\n linear-gradient(to bottom, rgba(var(--borderRgb), ").concat(mergedProps.patternOpacity, ") 1px, transparent 1px)") :
|
|
127
|
+
mergedProps.pattern === 'dots' ? "radial-gradient(rgba(var(--borderRgb), ".concat(mergedProps.patternOpacity, ") 1px, transparent 1px)") :
|
|
128
|
+
mergedProps.pattern === 'diagonal' ? "repeating-linear-gradient(45deg, rgba(var(--borderRgb), ".concat(mergedProps.patternOpacity, "), rgba(var(--borderRgb), ").concat(mergedProps.patternOpacity, ") 1px, transparent 1px, transparent 10px)") :
|
|
129
|
+
mergedProps.pattern === 'checkerboard' ? "linear-gradient(45deg, rgba(var(--borderRgb), ".concat(mergedProps.patternOpacity, ") 25%, transparent 25%), linear-gradient(-45deg, rgba(var(--borderRgb), ").concat(mergedProps.patternOpacity, ") 25%, transparent 25%), linear-gradient(45deg, transparent 75%, rgba(var(--borderRgb), ").concat(mergedProps.patternOpacity, ") 75%), linear-gradient(-45deg, transparent 75%, rgba(var(--borderRgb), ").concat(mergedProps.patternOpacity, ") 75%)") :
|
|
130
|
+
mergedProps.pattern === 'horizontal' ? "linear-gradient(to bottom, rgba(var(--borderRgb), ".concat(mergedProps.patternOpacity, ") 1px, transparent 1px)") :
|
|
131
|
+
mergedProps.pattern === 'vertical' ? "linear-gradient(to right, rgba(var(--borderRgb), ".concat(mergedProps.patternOpacity, ") 1px, transparent 1px)") : ''
|
|
67
132
|
} },
|
|
68
|
-
showGradient && react_1.default.createElement("div", { style: gradientStyle }),
|
|
69
|
-
react_1.default.createElement("div", { className: "vista-container ".concat(containerClass), style: { position: 'relative', zIndex: 1 } }, isCentered || isStacked ? (react_1.default.createElement(react_1.default.Fragment, null,
|
|
70
|
-
(imgPosition === 'top') && ImageContent,
|
|
133
|
+
mergedProps.showGradient && react_1.default.createElement("div", { style: gradientStyle }),
|
|
134
|
+
react_1.default.createElement("div", { className: "vista-container ".concat(mergedProps.containerClass), style: { position: 'relative', zIndex: 1, gap: mergedProps.gap || "2rem" } }, isCentered || isStacked ? (react_1.default.createElement(react_1.default.Fragment, null,
|
|
135
|
+
(mergedProps.imgPosition === 'top') && ImageContent,
|
|
71
136
|
TextContent,
|
|
72
|
-
(imgPosition === 'bottom') && ImageContent)) : reverse ? (react_1.default.createElement(react_1.default.Fragment, null,
|
|
137
|
+
(mergedProps.imgPosition === 'bottom') && ImageContent)) : mergedProps.reverse ? (react_1.default.createElement(react_1.default.Fragment, null,
|
|
73
138
|
ImageContent,
|
|
74
139
|
TextContent)) : (react_1.default.createElement(react_1.default.Fragment, null,
|
|
75
|
-
(layout === 'imageLeft') && ImageContent,
|
|
140
|
+
(mergedProps.layout === 'imageLeft') && react_1.default.createElement(Col_1.default, null, ImageContent),
|
|
76
141
|
TextContent,
|
|
77
|
-
(layout === 'imageRight') && ImageContent))),
|
|
78
|
-
fade && (react_1.default.createElement("div", { style: {
|
|
142
|
+
(mergedProps.layout === 'imageRight') && react_1.default.createElement(Col_1.default, null, ImageContent)))),
|
|
143
|
+
mergedProps.fade && (react_1.default.createElement("div", { style: {
|
|
79
144
|
position: 'absolute',
|
|
80
145
|
inset: 0,
|
|
81
146
|
width: '100%',
|
|
82
147
|
height: '100%',
|
|
83
|
-
background: fadeRadial
|
|
84
|
-
? "radial-gradient(circle, transparent 0%, ".concat((0, getCssVariable_1.getCssVariableValue)(bg || 'page-bg'), " 100%)")
|
|
85
|
-
: "linear-gradient(to ".concat(fadeDirection || 'bottom', ", ").concat((0, getCssVariable_1.getCssVariableValue)(bg || 'page-bg'), " 0%, transparent 100%)"),
|
|
148
|
+
background: mergedProps.fadeRadial
|
|
149
|
+
? "radial-gradient(circle, transparent 0%, ".concat((0, getCssVariable_1.getCssVariableValue)(mergedProps.bg || 'page-bg'), " 100%)")
|
|
150
|
+
: "linear-gradient(to ".concat(mergedProps.fadeDirection || 'bottom', ", ").concat((0, getCssVariable_1.getCssVariableValue)(mergedProps.bg || 'page-bg'), " 0%, transparent 100%)"),
|
|
86
151
|
zIndex: 0,
|
|
87
152
|
pointerEvents: 'none'
|
|
88
153
|
} })),
|
|
89
|
-
backgroundImage && (react_1.default.createElement("div", { style: {
|
|
154
|
+
mergedProps.backgroundImage && (react_1.default.createElement("div", { style: {
|
|
90
155
|
position: 'absolute',
|
|
91
156
|
inset: 0,
|
|
92
|
-
backgroundImage: "url(".concat(backgroundImage, ")"),
|
|
157
|
+
backgroundImage: "url(".concat(mergedProps.backgroundImage, ")"),
|
|
93
158
|
backgroundSize: 'cover',
|
|
94
159
|
backgroundPosition: 'center',
|
|
95
160
|
zIndex: -1,
|
|
96
161
|
width: '100%',
|
|
97
162
|
height: '100%',
|
|
98
163
|
} })),
|
|
99
|
-
backgroundImage && fadeOverlayDarken !== undefined && (react_1.default.createElement("div", { style: {
|
|
164
|
+
mergedProps.backgroundImage && mergedProps.fadeOverlayDarken !== undefined && (react_1.default.createElement("div", { style: {
|
|
100
165
|
position: 'absolute',
|
|
101
166
|
width: '100%',
|
|
102
167
|
height: '100%',
|
|
103
168
|
inset: 0,
|
|
104
|
-
backgroundColor: "rgba(0, 0, 0, ".concat(fadeOverlayDarken, ")"),
|
|
169
|
+
backgroundColor: "rgba(0, 0, 0, ".concat(mergedProps.fadeOverlayDarken, ")"),
|
|
105
170
|
zIndex: -1,
|
|
106
171
|
} })))));
|
|
107
172
|
};
|
|
@@ -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,8 +256,8 @@ var mergeComponentConfig = function (config, localProps) {
|
|
|
74
256
|
};
|
|
75
257
|
}
|
|
76
258
|
return {
|
|
77
|
-
// Props: config overrides local
|
|
78
|
-
props:
|
|
259
|
+
// Props: config overrides local, with deep merge for nested objects
|
|
260
|
+
props: deepMerge(localProps, config.componentProps),
|
|
79
261
|
// Metadata
|
|
80
262
|
variant: config.actualVariant,
|
|
81
263
|
hasConfig: true
|
|
@@ -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;
|