@strata-ds/core 2.1.0
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/README.md +438 -0
- package/dist/components/DynamicComponentDebug.d.ts +3 -0
- package/dist/components/DynamicComponentDebug.d.ts.map +1 -0
- package/dist/components/DynamicComponents.d.ts +12 -0
- package/dist/components/DynamicComponents.d.ts.map +1 -0
- package/dist/components/card-ui/Card.d.ts +40 -0
- package/dist/components/card-ui/Card.d.ts.map +1 -0
- package/dist/components/card-ui/DefaultCard.d.ts +3 -0
- package/dist/components/card-ui/DefaultCard.d.ts.map +1 -0
- package/dist/components/index.d.ts +4 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/data/index.d.ts +2 -0
- package/dist/data/index.d.ts.map +1 -0
- package/dist/data/mock.types.d.ts +70 -0
- package/dist/data/mock.types.d.ts.map +1 -0
- package/dist/hook/useCardData.d.ts +371 -0
- package/dist/hook/useCardData.d.ts.map +1 -0
- package/dist/hook/useComponent.d.ts +4 -0
- package/dist/hook/useComponent.d.ts.map +1 -0
- package/dist/hook/useComponents.d.ts +2 -0
- package/dist/hook/useComponents.d.ts.map +1 -0
- package/dist/hook/useDesignSystemSync.d.ts +1 -0
- package/dist/hook/useDesignSystemSync.d.ts.map +1 -0
- package/dist/hook/useDynamicComponents.d.ts +3 -0
- package/dist/hook/useDynamicComponents.d.ts.map +1 -0
- package/dist/index.d.ts +440 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.esm.js +3049 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.js +3062 -0
- package/dist/index.js.map +1 -0
- package/dist/providers/StrataProvider.d.ts +60 -0
- package/dist/providers/StrataProvider.d.ts.map +1 -0
- package/dist/providers/index.d.ts +2 -0
- package/dist/providers/index.d.ts.map +1 -0
- package/dist/registry/ComponentFactory.d.ts +39 -0
- package/dist/registry/ComponentFactory.d.ts.map +1 -0
- package/dist/registry/ComponentRegistry.d.ts +29 -0
- package/dist/registry/ComponentRegistry.d.ts.map +1 -0
- package/dist/types/card-types.d.ts +185 -0
- package/dist/types/card-types.d.ts.map +1 -0
- package/package.json +74 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,3062 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var React = require('react');
|
|
5
|
+
var react = require('@chakra-ui/react');
|
|
6
|
+
|
|
7
|
+
function _arrayLikeToArray(r, a) {
|
|
8
|
+
(null == a || a > r.length) && (a = r.length);
|
|
9
|
+
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
|
10
|
+
return n;
|
|
11
|
+
}
|
|
12
|
+
function _arrayWithHoles(r) {
|
|
13
|
+
if (Array.isArray(r)) return r;
|
|
14
|
+
}
|
|
15
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) {
|
|
16
|
+
try {
|
|
17
|
+
var i = n[a](c),
|
|
18
|
+
u = i.value;
|
|
19
|
+
} catch (n) {
|
|
20
|
+
return void e(n);
|
|
21
|
+
}
|
|
22
|
+
i.done ? t(u) : Promise.resolve(u).then(r, o);
|
|
23
|
+
}
|
|
24
|
+
function _asyncToGenerator(n) {
|
|
25
|
+
return function () {
|
|
26
|
+
var t = this,
|
|
27
|
+
e = arguments;
|
|
28
|
+
return new Promise(function (r, o) {
|
|
29
|
+
var a = n.apply(t, e);
|
|
30
|
+
function _next(n) {
|
|
31
|
+
asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
|
|
32
|
+
}
|
|
33
|
+
function _throw(n) {
|
|
34
|
+
asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
|
|
35
|
+
}
|
|
36
|
+
_next(void 0);
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
function _classCallCheck(a, n) {
|
|
41
|
+
if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
|
|
42
|
+
}
|
|
43
|
+
function _defineProperties(e, r) {
|
|
44
|
+
for (var t = 0; t < r.length; t++) {
|
|
45
|
+
var o = r[t];
|
|
46
|
+
o.enumerable = o.enumerable || false, o.configurable = true, "value" in o && (o.writable = true), Object.defineProperty(e, _toPropertyKey(o.key), o);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function _createClass(e, r, t) {
|
|
50
|
+
return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", {
|
|
51
|
+
writable: false
|
|
52
|
+
}), e;
|
|
53
|
+
}
|
|
54
|
+
function _defineProperty(e, r, t) {
|
|
55
|
+
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
56
|
+
value: t,
|
|
57
|
+
enumerable: true,
|
|
58
|
+
configurable: true,
|
|
59
|
+
writable: true
|
|
60
|
+
}) : e[r] = t, e;
|
|
61
|
+
}
|
|
62
|
+
function _iterableToArrayLimit(r, l) {
|
|
63
|
+
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
64
|
+
if (null != t) {
|
|
65
|
+
var e,
|
|
66
|
+
n,
|
|
67
|
+
i,
|
|
68
|
+
u,
|
|
69
|
+
a = [],
|
|
70
|
+
f = true,
|
|
71
|
+
o = false;
|
|
72
|
+
try {
|
|
73
|
+
if (i = (t = t.call(r)).next, 0 === l) {
|
|
74
|
+
if (Object(t) !== t) return;
|
|
75
|
+
f = !1;
|
|
76
|
+
} else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
|
|
77
|
+
} catch (r) {
|
|
78
|
+
o = true, n = r;
|
|
79
|
+
} finally {
|
|
80
|
+
try {
|
|
81
|
+
if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
|
|
82
|
+
} finally {
|
|
83
|
+
if (o) throw n;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return a;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
function _nonIterableRest() {
|
|
90
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
91
|
+
}
|
|
92
|
+
function ownKeys(e, r) {
|
|
93
|
+
var t = Object.keys(e);
|
|
94
|
+
if (Object.getOwnPropertySymbols) {
|
|
95
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
96
|
+
r && (o = o.filter(function (r) {
|
|
97
|
+
return Object.getOwnPropertyDescriptor(e, r).enumerable;
|
|
98
|
+
})), t.push.apply(t, o);
|
|
99
|
+
}
|
|
100
|
+
return t;
|
|
101
|
+
}
|
|
102
|
+
function _objectSpread2(e) {
|
|
103
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
104
|
+
var t = null != arguments[r] ? arguments[r] : {};
|
|
105
|
+
r % 2 ? ownKeys(Object(t), true).forEach(function (r) {
|
|
106
|
+
_defineProperty(e, r, t[r]);
|
|
107
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
|
|
108
|
+
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
return e;
|
|
112
|
+
}
|
|
113
|
+
function _objectWithoutProperties(e, t) {
|
|
114
|
+
if (null == e) return {};
|
|
115
|
+
var o,
|
|
116
|
+
r,
|
|
117
|
+
i = _objectWithoutPropertiesLoose(e, t);
|
|
118
|
+
if (Object.getOwnPropertySymbols) {
|
|
119
|
+
var n = Object.getOwnPropertySymbols(e);
|
|
120
|
+
for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
|
|
121
|
+
}
|
|
122
|
+
return i;
|
|
123
|
+
}
|
|
124
|
+
function _objectWithoutPropertiesLoose(r, e) {
|
|
125
|
+
if (null == r) return {};
|
|
126
|
+
var t = {};
|
|
127
|
+
for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
|
|
128
|
+
if (-1 !== e.indexOf(n)) continue;
|
|
129
|
+
t[n] = r[n];
|
|
130
|
+
}
|
|
131
|
+
return t;
|
|
132
|
+
}
|
|
133
|
+
function _regenerator() {
|
|
134
|
+
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
|
|
135
|
+
var e,
|
|
136
|
+
t,
|
|
137
|
+
r = "function" == typeof Symbol ? Symbol : {},
|
|
138
|
+
n = r.iterator || "@@iterator",
|
|
139
|
+
o = r.toStringTag || "@@toStringTag";
|
|
140
|
+
function i(r, n, o, i) {
|
|
141
|
+
var c = n && n.prototype instanceof Generator ? n : Generator,
|
|
142
|
+
u = Object.create(c.prototype);
|
|
143
|
+
return _regeneratorDefine(u, "_invoke", function (r, n, o) {
|
|
144
|
+
var i,
|
|
145
|
+
c,
|
|
146
|
+
u,
|
|
147
|
+
f = 0,
|
|
148
|
+
p = o || [],
|
|
149
|
+
y = false,
|
|
150
|
+
G = {
|
|
151
|
+
p: 0,
|
|
152
|
+
n: 0,
|
|
153
|
+
v: e,
|
|
154
|
+
a: d,
|
|
155
|
+
f: d.bind(e, 4),
|
|
156
|
+
d: function (t, r) {
|
|
157
|
+
return i = t, c = 0, u = e, G.n = r, a;
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
function d(r, n) {
|
|
161
|
+
for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) {
|
|
162
|
+
var o,
|
|
163
|
+
i = p[t],
|
|
164
|
+
d = G.p,
|
|
165
|
+
l = i[2];
|
|
166
|
+
r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0));
|
|
167
|
+
}
|
|
168
|
+
if (o || r > 1) return a;
|
|
169
|
+
throw y = true, n;
|
|
170
|
+
}
|
|
171
|
+
return function (o, p, l) {
|
|
172
|
+
if (f > 1) throw TypeError("Generator is already running");
|
|
173
|
+
for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) {
|
|
174
|
+
i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u);
|
|
175
|
+
try {
|
|
176
|
+
if (f = 2, i) {
|
|
177
|
+
if (c || (o = "next"), t = i[o]) {
|
|
178
|
+
if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object");
|
|
179
|
+
if (!t.done) return t;
|
|
180
|
+
u = t.value, c < 2 && (c = 0);
|
|
181
|
+
} else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1);
|
|
182
|
+
i = e;
|
|
183
|
+
} else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break;
|
|
184
|
+
} catch (t) {
|
|
185
|
+
i = e, c = 1, u = t;
|
|
186
|
+
} finally {
|
|
187
|
+
f = 1;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
return {
|
|
191
|
+
value: t,
|
|
192
|
+
done: y
|
|
193
|
+
};
|
|
194
|
+
};
|
|
195
|
+
}(r, o, i), true), u;
|
|
196
|
+
}
|
|
197
|
+
var a = {};
|
|
198
|
+
function Generator() {}
|
|
199
|
+
function GeneratorFunction() {}
|
|
200
|
+
function GeneratorFunctionPrototype() {}
|
|
201
|
+
t = Object.getPrototypeOf;
|
|
202
|
+
var c = [][n] ? t(t([][n]())) : (_regeneratorDefine(t = {}, n, function () {
|
|
203
|
+
return this;
|
|
204
|
+
}), t),
|
|
205
|
+
u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c);
|
|
206
|
+
function f(e) {
|
|
207
|
+
return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e;
|
|
208
|
+
}
|
|
209
|
+
return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine(u), _regeneratorDefine(u, o, "Generator"), _regeneratorDefine(u, n, function () {
|
|
210
|
+
return this;
|
|
211
|
+
}), _regeneratorDefine(u, "toString", function () {
|
|
212
|
+
return "[object Generator]";
|
|
213
|
+
}), (_regenerator = function () {
|
|
214
|
+
return {
|
|
215
|
+
w: i,
|
|
216
|
+
m: f
|
|
217
|
+
};
|
|
218
|
+
})();
|
|
219
|
+
}
|
|
220
|
+
function _regeneratorDefine(e, r, n, t) {
|
|
221
|
+
var i = Object.defineProperty;
|
|
222
|
+
try {
|
|
223
|
+
i({}, "", {});
|
|
224
|
+
} catch (e) {
|
|
225
|
+
i = 0;
|
|
226
|
+
}
|
|
227
|
+
_regeneratorDefine = function (e, r, n, t) {
|
|
228
|
+
function o(r, n) {
|
|
229
|
+
_regeneratorDefine(e, r, function (e) {
|
|
230
|
+
return this._invoke(r, n, e);
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
r ? i ? i(e, r, {
|
|
234
|
+
value: n,
|
|
235
|
+
enumerable: !t,
|
|
236
|
+
configurable: !t,
|
|
237
|
+
writable: !t
|
|
238
|
+
}) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2));
|
|
239
|
+
}, _regeneratorDefine(e, r, n, t);
|
|
240
|
+
}
|
|
241
|
+
function _slicedToArray(r, e) {
|
|
242
|
+
return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
|
|
243
|
+
}
|
|
244
|
+
function _toPrimitive(t, r) {
|
|
245
|
+
if ("object" != typeof t || !t) return t;
|
|
246
|
+
var e = t[Symbol.toPrimitive];
|
|
247
|
+
if (void 0 !== e) {
|
|
248
|
+
var i = e.call(t, r);
|
|
249
|
+
if ("object" != typeof i) return i;
|
|
250
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
251
|
+
}
|
|
252
|
+
return (String )(t);
|
|
253
|
+
}
|
|
254
|
+
function _toPropertyKey(t) {
|
|
255
|
+
var i = _toPrimitive(t, "string");
|
|
256
|
+
return "symbol" == typeof i ? i : i + "";
|
|
257
|
+
}
|
|
258
|
+
function _typeof(o) {
|
|
259
|
+
"@babel/helpers - typeof";
|
|
260
|
+
|
|
261
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
|
|
262
|
+
return typeof o;
|
|
263
|
+
} : function (o) {
|
|
264
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
265
|
+
}, _typeof(o);
|
|
266
|
+
}
|
|
267
|
+
function _unsupportedIterableToArray(r, a) {
|
|
268
|
+
if (r) {
|
|
269
|
+
if ("string" == typeof r) return _arrayLikeToArray(r, a);
|
|
270
|
+
var t = {}.toString.call(r).slice(8, -1);
|
|
271
|
+
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
var _excluded$2 = ["children", "style", "className"],
|
|
276
|
+
_excluded2$2 = ["children", "style", "className"],
|
|
277
|
+
_excluded3$1 = ["key", "ref", "children", "style", "className"];
|
|
278
|
+
var StrataComponentFactory = /*#__PURE__*/function () {
|
|
279
|
+
function StrataComponentFactory() {
|
|
280
|
+
_classCallCheck(this, StrataComponentFactory);
|
|
281
|
+
}
|
|
282
|
+
return _createClass(StrataComponentFactory, null, [{
|
|
283
|
+
key: "createComponent",
|
|
284
|
+
value:
|
|
285
|
+
// Create component with enhanced attribute handling
|
|
286
|
+
function createComponent(componentName, componentData, designSystem) {
|
|
287
|
+
var _this = this;
|
|
288
|
+
var Component = function Component(_ref) {
|
|
289
|
+
var children = _ref.children,
|
|
290
|
+
style = _ref.style,
|
|
291
|
+
className = _ref.className,
|
|
292
|
+
props = _objectWithoutProperties(_ref, _excluded$2);
|
|
293
|
+
var componentStyle = _this.resolveComponentStyles(componentData, designSystem);
|
|
294
|
+
var mergedStyle = _objectSpread2(_objectSpread2({}, componentStyle), style);
|
|
295
|
+
// Determine the HTML tag - use linkedElement or infer from component name
|
|
296
|
+
var htmlTag = _this.determineHtmlTag(componentData, componentName);
|
|
297
|
+
// Process ALL attributes including linked ones and passed props
|
|
298
|
+
var allAttributes = _this.processAllAttributes(props, componentData.linkedElement, htmlTag, designSystem);
|
|
299
|
+
return /*#__PURE__*/React.createElement(htmlTag, _objectSpread2({
|
|
300
|
+
style: mergedStyle,
|
|
301
|
+
className: _this.mergeClassNames(className, allAttributes["class"])
|
|
302
|
+
}, _this.cleanAttributes(allAttributes)), children || componentData.textContent);
|
|
303
|
+
};
|
|
304
|
+
Component.displayName = componentName;
|
|
305
|
+
return Component;
|
|
306
|
+
}
|
|
307
|
+
// Create sub-component with same enhanced attribute handling
|
|
308
|
+
}, {
|
|
309
|
+
key: "createSubComponent",
|
|
310
|
+
value: function createSubComponent(componentName, componentData, designSystem) {
|
|
311
|
+
var _this2 = this;
|
|
312
|
+
var SubComponent = function SubComponent(_ref2) {
|
|
313
|
+
var children = _ref2.children,
|
|
314
|
+
style = _ref2.style,
|
|
315
|
+
className = _ref2.className,
|
|
316
|
+
props = _objectWithoutProperties(_ref2, _excluded2$2);
|
|
317
|
+
var componentStyle = _this2.resolveComponentStyles(componentData, designSystem);
|
|
318
|
+
var mergedStyle = _objectSpread2(_objectSpread2({}, componentStyle), style);
|
|
319
|
+
var htmlTag = _this2.determineHtmlTag(componentData, componentName);
|
|
320
|
+
var allAttributes = _this2.processAllAttributes(props, componentData.linkedElement, htmlTag, designSystem);
|
|
321
|
+
return /*#__PURE__*/React.createElement(htmlTag, _objectSpread2({
|
|
322
|
+
style: mergedStyle,
|
|
323
|
+
className: _this2.mergeClassNames(className, allAttributes["class"])
|
|
324
|
+
}, _this2.cleanAttributes(allAttributes)), children || componentData.textContent);
|
|
325
|
+
};
|
|
326
|
+
SubComponent.displayName = componentName;
|
|
327
|
+
return SubComponent;
|
|
328
|
+
}
|
|
329
|
+
// Process both linked attributes and passed props
|
|
330
|
+
}, {
|
|
331
|
+
key: "processAllAttributes",
|
|
332
|
+
value: function processAllAttributes(props, linkedElement, htmlTag, designSystem) {
|
|
333
|
+
// Start with linked element attributes
|
|
334
|
+
var linkedAttributes = (linkedElement === null || linkedElement === void 0 ? void 0 : linkedElement.attributes) || {};
|
|
335
|
+
// Resolve CSS variables in linked attributes
|
|
336
|
+
var resolvedLinkedAttributes = this.resolveAttributesWithVariables(linkedAttributes, designSystem);
|
|
337
|
+
// Merge with passed props (props take precedence)
|
|
338
|
+
var mergedAttributes = _objectSpread2(_objectSpread2({}, resolvedLinkedAttributes), props);
|
|
339
|
+
// Clean and process the merged attributes
|
|
340
|
+
return this.processHtmlAttributes(mergedAttributes, htmlTag, designSystem);
|
|
341
|
+
}
|
|
342
|
+
// Resolve CSS variables in attribute values
|
|
343
|
+
}, {
|
|
344
|
+
key: "resolveAttributesWithVariables",
|
|
345
|
+
value: function resolveAttributesWithVariables(attributes, designSystem) {
|
|
346
|
+
var _this3 = this;
|
|
347
|
+
var resolved = {};
|
|
348
|
+
Object.entries(attributes).forEach(function (_ref3) {
|
|
349
|
+
var _ref4 = _slicedToArray(_ref3, 2),
|
|
350
|
+
key = _ref4[0],
|
|
351
|
+
value = _ref4[1];
|
|
352
|
+
if (typeof value === 'string') {
|
|
353
|
+
resolved[key] = _this3.resolveCssVariables(value, designSystem);
|
|
354
|
+
} else {
|
|
355
|
+
resolved[key] = value;
|
|
356
|
+
}
|
|
357
|
+
});
|
|
358
|
+
return resolved;
|
|
359
|
+
}
|
|
360
|
+
// Enhanced CSS variable resolution
|
|
361
|
+
}, {
|
|
362
|
+
key: "resolveCssVariables",
|
|
363
|
+
value: function resolveCssVariables(value, designSystem) {
|
|
364
|
+
return value.replace(/var\(--([^)]+)\)/g, function (match, varName) {
|
|
365
|
+
var variable = designSystem.variables["--".concat(varName)];
|
|
366
|
+
if (variable) {
|
|
367
|
+
return variable.value + (variable.unit || '');
|
|
368
|
+
}
|
|
369
|
+
return match; // Return original if variable not found
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
// Enhanced HTML attribute processing with type-specific validation
|
|
373
|
+
}, {
|
|
374
|
+
key: "processHtmlAttributes",
|
|
375
|
+
value: function processHtmlAttributes(attributes, htmlTag, designSystem) {
|
|
376
|
+
attributes.key;
|
|
377
|
+
attributes.ref;
|
|
378
|
+
attributes.children;
|
|
379
|
+
attributes.style;
|
|
380
|
+
attributes.className;
|
|
381
|
+
var cleanProps = _objectWithoutProperties(attributes, _excluded3$1);
|
|
382
|
+
var processed = _objectSpread2({}, cleanProps);
|
|
383
|
+
// Element-specific attribute processing
|
|
384
|
+
switch (htmlTag) {
|
|
385
|
+
case 'img':
|
|
386
|
+
this.processImageAttributes(processed);
|
|
387
|
+
break;
|
|
388
|
+
case 'input':
|
|
389
|
+
this.processInputAttributes(processed);
|
|
390
|
+
break;
|
|
391
|
+
case 'button':
|
|
392
|
+
this.processButtonAttributes(processed);
|
|
393
|
+
break;
|
|
394
|
+
case 'a':
|
|
395
|
+
this.processLinkAttributes(processed);
|
|
396
|
+
break;
|
|
397
|
+
case 'textarea':
|
|
398
|
+
this.processTextareaAttributes(processed);
|
|
399
|
+
break;
|
|
400
|
+
case 'video':
|
|
401
|
+
this.processVideoAttributes(processed);
|
|
402
|
+
break;
|
|
403
|
+
case 'audio':
|
|
404
|
+
this.processAudioAttributes(processed);
|
|
405
|
+
break;
|
|
406
|
+
case 'form':
|
|
407
|
+
this.processFormAttributes(processed);
|
|
408
|
+
break;
|
|
409
|
+
case 'select':
|
|
410
|
+
this.processSelectAttributes(processed);
|
|
411
|
+
break;
|
|
412
|
+
case 'svg':
|
|
413
|
+
this.processSvgAttributes(processed);
|
|
414
|
+
break;
|
|
415
|
+
case 'canvas':
|
|
416
|
+
this.processCanvasAttributes(processed);
|
|
417
|
+
break;
|
|
418
|
+
}
|
|
419
|
+
// Remove any undefined or null values
|
|
420
|
+
Object.keys(processed).forEach(function (key) {
|
|
421
|
+
if (processed[key] === undefined || processed[key] === null) {
|
|
422
|
+
delete processed[key];
|
|
423
|
+
}
|
|
424
|
+
});
|
|
425
|
+
return processed;
|
|
426
|
+
}
|
|
427
|
+
// Specific attribute processors for different HTML elements
|
|
428
|
+
}, {
|
|
429
|
+
key: "processInputAttributes",
|
|
430
|
+
value: function processInputAttributes(attrs) {
|
|
431
|
+
if (!attrs.type) {
|
|
432
|
+
var name = (attrs.name || '').toLowerCase();
|
|
433
|
+
if (name.includes('email')) attrs.type = 'email';else if (name.includes('password')) attrs.type = 'password';else if (name.includes('number') || name.includes('tel')) attrs.type = 'number';else if (name.includes('url')) attrs.type = 'url';else if (name.includes('search')) attrs.type = 'search';else if (name.includes('file')) attrs.type = 'file';else if (name.includes('checkbox')) attrs.type = 'checkbox';else if (name.includes('radio')) attrs.type = 'radio';else attrs.type = 'text';
|
|
434
|
+
}
|
|
435
|
+
// Add placeholder if missing for text-like inputs
|
|
436
|
+
if (!attrs.placeholder && ['text', 'email', 'password', 'search', 'url'].includes(attrs.type)) {
|
|
437
|
+
attrs.placeholder = "Enter ".concat(attrs.name || 'text');
|
|
438
|
+
}
|
|
439
|
+
// Ensure name attribute for form inputs
|
|
440
|
+
if (!attrs.name && attrs.id) {
|
|
441
|
+
attrs.name = attrs.id;
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
}, {
|
|
445
|
+
key: "processButtonAttributes",
|
|
446
|
+
value: function processButtonAttributes(attrs) {
|
|
447
|
+
if (!attrs.type) {
|
|
448
|
+
attrs.type = 'button';
|
|
449
|
+
}
|
|
450
|
+
// Add accessible default if no text content
|
|
451
|
+
if (!attrs['aria-label'] && !attrs.children) {
|
|
452
|
+
attrs['aria-label'] = 'Button';
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
}, {
|
|
456
|
+
key: "processImageAttributes",
|
|
457
|
+
value: function processImageAttributes(attrs) {
|
|
458
|
+
if (!attrs.alt) {
|
|
459
|
+
attrs.alt = 'Image';
|
|
460
|
+
}
|
|
461
|
+
if (!attrs.loading) {
|
|
462
|
+
attrs.loading = 'lazy';
|
|
463
|
+
}
|
|
464
|
+
// Handle missing or invalid src
|
|
465
|
+
if (attrs.src && !attrs.src.startsWith('http') && !attrs.src.startsWith('/') && !attrs.src.startsWith('data:')) {
|
|
466
|
+
// Provide a fallback placeholder image
|
|
467
|
+
attrs.src = "https://via.placeholder.com/200x150?text=Image+Placeholder";
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
}, {
|
|
471
|
+
key: "processLinkAttributes",
|
|
472
|
+
value: function processLinkAttributes(attrs) {
|
|
473
|
+
if (!attrs.href && attrs.onClick) {
|
|
474
|
+
attrs.href = '#';
|
|
475
|
+
}
|
|
476
|
+
if (attrs.target === '_blank' && !attrs.rel) {
|
|
477
|
+
attrs.rel = 'noopener noreferrer';
|
|
478
|
+
}
|
|
479
|
+
// Ensure href has a value
|
|
480
|
+
if (!attrs.href) {
|
|
481
|
+
attrs.href = '#';
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
}, {
|
|
485
|
+
key: "processTextareaAttributes",
|
|
486
|
+
value: function processTextareaAttributes(attrs) {
|
|
487
|
+
if (!attrs.rows) attrs.rows = '4';
|
|
488
|
+
if (!attrs.cols) attrs.cols = '50';
|
|
489
|
+
if (!attrs.placeholder) {
|
|
490
|
+
attrs.placeholder = 'Enter your text here...';
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
}, {
|
|
494
|
+
key: "processVideoAttributes",
|
|
495
|
+
value: function processVideoAttributes(attrs) {
|
|
496
|
+
if (!attrs.controls) attrs.controls = true;
|
|
497
|
+
if (!attrs.preload) attrs.preload = 'metadata';
|
|
498
|
+
}
|
|
499
|
+
}, {
|
|
500
|
+
key: "processAudioAttributes",
|
|
501
|
+
value: function processAudioAttributes(attrs) {
|
|
502
|
+
if (!attrs.controls) attrs.controls = true;
|
|
503
|
+
if (!attrs.preload) attrs.preload = 'metadata';
|
|
504
|
+
}
|
|
505
|
+
}, {
|
|
506
|
+
key: "processFormAttributes",
|
|
507
|
+
value: function processFormAttributes(attrs) {
|
|
508
|
+
if (!attrs.method) attrs.method = 'post';
|
|
509
|
+
if (!attrs.action) attrs.action = '#';
|
|
510
|
+
}
|
|
511
|
+
}, {
|
|
512
|
+
key: "processSelectAttributes",
|
|
513
|
+
value: function processSelectAttributes(attrs) {
|
|
514
|
+
if (!attrs.name) attrs.name = 'select-field';
|
|
515
|
+
}
|
|
516
|
+
}, {
|
|
517
|
+
key: "processSvgAttributes",
|
|
518
|
+
value: function processSvgAttributes(attrs) {
|
|
519
|
+
if (!attrs.viewBox && !attrs.width && !attrs.height) {
|
|
520
|
+
attrs.viewBox = '0 0 24 24';
|
|
521
|
+
}
|
|
522
|
+
if (!attrs.role) {
|
|
523
|
+
attrs.role = 'img';
|
|
524
|
+
}
|
|
525
|
+
if (!attrs['aria-hidden'] && !attrs['aria-label']) {
|
|
526
|
+
attrs['aria-hidden'] = 'true';
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
}, {
|
|
530
|
+
key: "processCanvasAttributes",
|
|
531
|
+
value: function processCanvasAttributes(attrs) {
|
|
532
|
+
if (!attrs.width) attrs.width = '300';
|
|
533
|
+
if (!attrs.height) attrs.height = '150';
|
|
534
|
+
}
|
|
535
|
+
// Helper to merge class names
|
|
536
|
+
}, {
|
|
537
|
+
key: "mergeClassNames",
|
|
538
|
+
value: function mergeClassNames() {
|
|
539
|
+
for (var _len = arguments.length, classes = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
540
|
+
classes[_key] = arguments[_key];
|
|
541
|
+
}
|
|
542
|
+
return classes.filter(Boolean).join(' ').trim();
|
|
543
|
+
}
|
|
544
|
+
// Helper to clean attributes for React
|
|
545
|
+
}, {
|
|
546
|
+
key: "cleanAttributes",
|
|
547
|
+
value: function cleanAttributes(attrs) {
|
|
548
|
+
var cleaned = _objectSpread2({}, attrs);
|
|
549
|
+
// Remove class if it's empty after processing
|
|
550
|
+
if (cleaned["class"] === '') {
|
|
551
|
+
delete cleaned["class"];
|
|
552
|
+
}
|
|
553
|
+
// Convert boolean strings to actual booleans
|
|
554
|
+
Object.keys(cleaned).forEach(function (key) {
|
|
555
|
+
if (cleaned[key] === 'true') cleaned[key] = true;
|
|
556
|
+
if (cleaned[key] === 'false') cleaned[key] = false;
|
|
557
|
+
if (cleaned[key] === '') delete cleaned[key]; // Remove empty strings
|
|
558
|
+
});
|
|
559
|
+
// Remove React-specific props that shouldn't be passed to DOM
|
|
560
|
+
var reactProps = ['key', 'ref', 'children', 'style', 'className'];
|
|
561
|
+
reactProps.forEach(function (prop) {
|
|
562
|
+
delete cleaned[prop];
|
|
563
|
+
});
|
|
564
|
+
return cleaned;
|
|
565
|
+
}
|
|
566
|
+
// Determine HTML tag based on linkedElement or component name
|
|
567
|
+
}, {
|
|
568
|
+
key: "determineHtmlTag",
|
|
569
|
+
value: function determineHtmlTag(componentData, componentName) {
|
|
570
|
+
var _componentData$linked;
|
|
571
|
+
if ((_componentData$linked = componentData.linkedElement) !== null && _componentData$linked !== void 0 && _componentData$linked.htmlTag) {
|
|
572
|
+
return componentData.linkedElement.htmlTag;
|
|
573
|
+
}
|
|
574
|
+
var lowerName = componentName.toLowerCase();
|
|
575
|
+
// Comprehensive tag inference
|
|
576
|
+
if (lowerName.includes('input') || lowerName.includes('textfield') || lowerName.includes('textinput')) return 'input';
|
|
577
|
+
if (lowerName.includes('textarea') || lowerName.includes('textbox')) return 'textarea';
|
|
578
|
+
if (lowerName.includes('button') || lowerName.includes('btn')) return 'button';
|
|
579
|
+
if (lowerName.includes('form')) return 'form';
|
|
580
|
+
if (lowerName.includes('img') || lowerName.includes('image')) return 'img';
|
|
581
|
+
if (lowerName.includes('link') || lowerName.includes('anchor')) return 'a';
|
|
582
|
+
if (lowerName.includes('video')) return 'video';
|
|
583
|
+
if (lowerName.includes('audio')) return 'audio';
|
|
584
|
+
if (lowerName.includes('select') || lowerName.includes('dropdown')) return 'select';
|
|
585
|
+
if (lowerName.includes('list') || lowerName.includes('ul')) return 'ul';
|
|
586
|
+
if (lowerName.includes('listitem') || lowerName.includes('li')) return 'li';
|
|
587
|
+
if (lowerName.includes('table')) return 'table';
|
|
588
|
+
if (lowerName.includes('row') || lowerName.includes('tr')) return 'tr';
|
|
589
|
+
if (lowerName.includes('cell') || lowerName.includes('td')) return 'td';
|
|
590
|
+
if (lowerName.includes('header') || lowerName.includes('th')) return 'th';
|
|
591
|
+
if (lowerName.includes('heading') || lowerName.includes('h1')) return 'h1';
|
|
592
|
+
if (lowerName.includes('h2')) return 'h2';
|
|
593
|
+
if (lowerName.includes('h3')) return 'h3';
|
|
594
|
+
if (lowerName.includes('h4')) return 'h4';
|
|
595
|
+
if (lowerName.includes('h5')) return 'h5';
|
|
596
|
+
if (lowerName.includes('h6')) return 'h6';
|
|
597
|
+
if (lowerName.includes('paragraph') || lowerName.includes('p')) return 'p';
|
|
598
|
+
if (lowerName.includes('span')) return 'span';
|
|
599
|
+
if (lowerName.includes('div')) return 'div';
|
|
600
|
+
if (lowerName.includes('section')) return 'section';
|
|
601
|
+
if (lowerName.includes('article')) return 'article';
|
|
602
|
+
if (lowerName.includes('header')) return 'header';
|
|
603
|
+
if (lowerName.includes('footer')) return 'footer';
|
|
604
|
+
if (lowerName.includes('nav')) return 'nav';
|
|
605
|
+
if (lowerName.includes('main')) return 'main';
|
|
606
|
+
if (lowerName.includes('aside')) return 'aside';
|
|
607
|
+
if (lowerName.includes('svg')) return 'svg';
|
|
608
|
+
if (lowerName.includes('canvas')) return 'canvas';
|
|
609
|
+
return 'div'; // Default fallback
|
|
610
|
+
}
|
|
611
|
+
// Resolve component styles from properties and design system variables
|
|
612
|
+
}, {
|
|
613
|
+
key: "resolveComponentStyles",
|
|
614
|
+
value: function resolveComponentStyles(componentData, designSystem) {
|
|
615
|
+
var _this4 = this;
|
|
616
|
+
var styles = {};
|
|
617
|
+
if (componentData.properties) {
|
|
618
|
+
Object.entries(componentData.properties).forEach(function (_ref5) {
|
|
619
|
+
var _ref6 = _slicedToArray(_ref5, 2),
|
|
620
|
+
prop = _ref6[0],
|
|
621
|
+
value = _ref6[1];
|
|
622
|
+
var cssProperty = _this4.kebabToCamelCase(prop);
|
|
623
|
+
var resolvedValue = value.value;
|
|
624
|
+
// Resolve CSS variables
|
|
625
|
+
if (typeof resolvedValue === 'string' && resolvedValue.startsWith('var(')) {
|
|
626
|
+
var _resolvedValue$match;
|
|
627
|
+
var varName = (_resolvedValue$match = resolvedValue.match(/var\((--[^)]+)\)/)) === null || _resolvedValue$match === void 0 ? void 0 : _resolvedValue$match[1];
|
|
628
|
+
if (varName && designSystem.variables[varName]) {
|
|
629
|
+
var varData = designSystem.variables[varName];
|
|
630
|
+
resolvedValue = varData.value + (varData.unit || '');
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
// Add unit if value is numeric and unit is specified
|
|
634
|
+
if (value.unit && /^-?\d*\.?\d+$/.test(resolvedValue)) {
|
|
635
|
+
resolvedValue = resolvedValue + value.unit;
|
|
636
|
+
}
|
|
637
|
+
// Handle special CSS properties
|
|
638
|
+
if (cssProperty === 'boxShadow' && resolvedValue.includes('var(')) {
|
|
639
|
+
// Resolve shadow variables
|
|
640
|
+
resolvedValue = _this4.resolveCssVariables(resolvedValue, designSystem);
|
|
641
|
+
}
|
|
642
|
+
// Set the style property
|
|
643
|
+
styles[cssProperty] = resolvedValue;
|
|
644
|
+
});
|
|
645
|
+
}
|
|
646
|
+
return styles;
|
|
647
|
+
}
|
|
648
|
+
// Convert kebab-case to camelCase for CSS properties
|
|
649
|
+
}, {
|
|
650
|
+
key: "kebabToCamelCase",
|
|
651
|
+
value: function kebabToCamelCase(str) {
|
|
652
|
+
return str.replace(/-([a-z])/g, function (g) {
|
|
653
|
+
return g[1].toUpperCase();
|
|
654
|
+
});
|
|
655
|
+
}
|
|
656
|
+
// Convert camelCase to kebab-case (useful for HTML attributes)
|
|
657
|
+
}, {
|
|
658
|
+
key: "camelToKebabCase",
|
|
659
|
+
value: function camelToKebabCase(str) {
|
|
660
|
+
return str.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, '$1-$2').toLowerCase();
|
|
661
|
+
}
|
|
662
|
+
// Validate that the component can be safely rendered
|
|
663
|
+
}, {
|
|
664
|
+
key: "validateComponent",
|
|
665
|
+
value: function validateComponent(componentData) {
|
|
666
|
+
var errors = [];
|
|
667
|
+
// Check for required linked element attributes
|
|
668
|
+
if (componentData.linkedElement) {
|
|
669
|
+
var _componentData$linked2 = componentData.linkedElement,
|
|
670
|
+
htmlTag = _componentData$linked2.htmlTag,
|
|
671
|
+
attributes = _componentData$linked2.attributes,
|
|
672
|
+
requiredAttributes = _componentData$linked2.requiredAttributes;
|
|
673
|
+
if (requiredAttributes) {
|
|
674
|
+
requiredAttributes.forEach(function (attr) {
|
|
675
|
+
if (!attributes || !attributes[attr]) {
|
|
676
|
+
errors.push("Required attribute \"".concat(attr, "\" is missing for <").concat(htmlTag, "> element"));
|
|
677
|
+
}
|
|
678
|
+
});
|
|
679
|
+
}
|
|
680
|
+
// Validate specific element types
|
|
681
|
+
if (htmlTag === 'img' && attributes) {
|
|
682
|
+
if (!attributes.src) {
|
|
683
|
+
errors.push('Image element requires "src" attribute');
|
|
684
|
+
}
|
|
685
|
+
if (!attributes.alt) {
|
|
686
|
+
errors.push('Image element should have "alt" attribute for accessibility');
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
if (htmlTag === 'a' && attributes && !attributes.href) {
|
|
690
|
+
errors.push('Anchor element requires "href" attribute');
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
// Validate that properties have valid values
|
|
694
|
+
if (componentData.properties) {
|
|
695
|
+
Object.entries(componentData.properties).forEach(function (_ref7) {
|
|
696
|
+
var _ref8 = _slicedToArray(_ref7, 2),
|
|
697
|
+
prop = _ref8[0],
|
|
698
|
+
value = _ref8[1];
|
|
699
|
+
if (!value.value && value.value !== '') {
|
|
700
|
+
errors.push("Property \"".concat(prop, "\" has invalid value"));
|
|
701
|
+
}
|
|
702
|
+
});
|
|
703
|
+
}
|
|
704
|
+
return {
|
|
705
|
+
isValid: errors.length === 0,
|
|
706
|
+
errors: errors
|
|
707
|
+
};
|
|
708
|
+
}
|
|
709
|
+
// Create a debug version of the component that shows validation errors
|
|
710
|
+
}, {
|
|
711
|
+
key: "createDebugComponent",
|
|
712
|
+
value: function createDebugComponent(componentName, componentData, designSystem) {
|
|
713
|
+
var _this5 = this;
|
|
714
|
+
var validation = this.validateComponent(componentData);
|
|
715
|
+
var Component = function Component(props) {
|
|
716
|
+
if (!validation.isValid) {
|
|
717
|
+
console.warn("Component \"".concat(componentName, "\" validation errors:"), validation.errors);
|
|
718
|
+
// Return a debug element that shows errors in development
|
|
719
|
+
if (process.env.NODE_ENV === 'development') {
|
|
720
|
+
return /*#__PURE__*/React.createElement('div', {
|
|
721
|
+
style: {
|
|
722
|
+
border: '2px solid red',
|
|
723
|
+
padding: '8px',
|
|
724
|
+
margin: '4px',
|
|
725
|
+
backgroundColor: '#fff0f0'
|
|
726
|
+
},
|
|
727
|
+
title: validation.errors.join('\n')
|
|
728
|
+
}, "[DEBUG: ".concat(componentName, "] ").concat(validation.errors.join(', ')));
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
// Use the normal component factory for production
|
|
732
|
+
var NormalComponent = _this5.createComponent(componentName, componentData, designSystem);
|
|
733
|
+
return /*#__PURE__*/React.createElement(NormalComponent, props);
|
|
734
|
+
};
|
|
735
|
+
Component.displayName = "Debug".concat(componentName);
|
|
736
|
+
return Component;
|
|
737
|
+
}
|
|
738
|
+
}]);
|
|
739
|
+
}();
|
|
740
|
+
|
|
741
|
+
var ComponentRegistryService = /*#__PURE__*/function () {
|
|
742
|
+
function ComponentRegistryService() {
|
|
743
|
+
_classCallCheck(this, ComponentRegistryService);
|
|
744
|
+
this.registry = {};
|
|
745
|
+
this.listeners = [];
|
|
746
|
+
this.originalToPascalMap = new Map();
|
|
747
|
+
}
|
|
748
|
+
// UNIVERSAL PascalCase conversion - handles ALL component names
|
|
749
|
+
return _createClass(ComponentRegistryService, [{
|
|
750
|
+
key: "formatComponentName",
|
|
751
|
+
value: function formatComponentName(name) {
|
|
752
|
+
if (!name || typeof name !== 'string') {
|
|
753
|
+
console.warn("\u26A0\uFE0F Invalid component name:", name);
|
|
754
|
+
return "UnknownComponent";
|
|
755
|
+
}
|
|
756
|
+
console.log("\uD83D\uDD0D formatComponentName INPUT: \"".concat(name, "\""));
|
|
757
|
+
// Remove any file extensions
|
|
758
|
+
var cleanName = name.replace(/\.[^/.]+$/, "");
|
|
759
|
+
// Handle various naming conventions and convert to PascalCase
|
|
760
|
+
var pascalCaseName = cleanName
|
|
761
|
+
// Split by common separators: space, hyphen, underscore, dot, slash, camelCase boundary
|
|
762
|
+
.split(/[\s\-_\.\/]+|(?=[A-Z])/)
|
|
763
|
+
// Remove empty strings and filter out non-alphanumeric parts
|
|
764
|
+
.filter(function (part) {
|
|
765
|
+
return part.length > 0 && /[a-zA-Z0-9]/.test(part);
|
|
766
|
+
})
|
|
767
|
+
// Capitalize the first letter of each part
|
|
768
|
+
.map(function (part) {
|
|
769
|
+
// Handle edge cases like "2xl", "3xs" etc.
|
|
770
|
+
if (/^\d+[a-zA-Z]+$/.test(part)) {
|
|
771
|
+
return part.charAt(0) + part.slice(1).charAt(0).toUpperCase() + part.slice(2);
|
|
772
|
+
}
|
|
773
|
+
return part.charAt(0).toUpperCase() + part.slice(1).toLowerCase();
|
|
774
|
+
}).join("");
|
|
775
|
+
// Final validation and cleanup
|
|
776
|
+
var result = pascalCaseName;
|
|
777
|
+
// Ensure it starts with a letter (not a number)
|
|
778
|
+
if (/^\d/.test(result)) {
|
|
779
|
+
result = "Component" + result;
|
|
780
|
+
}
|
|
781
|
+
// Remove any remaining non-alphanumeric characters (except letters and numbers)
|
|
782
|
+
result = result.replace(/[^a-zA-Z0-9]/g, "");
|
|
783
|
+
// If result is empty, provide a fallback
|
|
784
|
+
if (!result) {
|
|
785
|
+
result = "UnknownComponent";
|
|
786
|
+
}
|
|
787
|
+
console.log("\uD83D\uDCDD FINAL CONVERSION: \"".concat(name, "\" \u2192 \"").concat(result, "\""));
|
|
788
|
+
return result;
|
|
789
|
+
}
|
|
790
|
+
// Test method to verify PascalCase conversion
|
|
791
|
+
}, {
|
|
792
|
+
key: "testPascalCaseConversion",
|
|
793
|
+
value: function testPascalCaseConversion() {
|
|
794
|
+
var _this = this;
|
|
795
|
+
var testCases = ["header", "main-content", "user_profile", "buttonPrimary", "form.input.email", "card-body", "nav menu", "footer-bottom", "3xs-text", "2xl-container", "userProfileCard", "roboform", "mailcard", "miscbutton", "random-component_name", "SomeAlreadyPascalCase", "multiple-words-component", "path/to/component", "component.v2", "component_v3_final"];
|
|
796
|
+
console.log("🧪 TESTING PASCAL CASE CONVERSION:");
|
|
797
|
+
testCases.forEach(function (testCase) {
|
|
798
|
+
var result = _this.formatComponentName(testCase);
|
|
799
|
+
console.log(" \"".concat(testCase, "\" \u2192 \"").concat(result, "\""));
|
|
800
|
+
});
|
|
801
|
+
}
|
|
802
|
+
// Register a new component dynamically
|
|
803
|
+
}, {
|
|
804
|
+
key: "registerComponent",
|
|
805
|
+
value: function registerComponent(componentName, componentData, designSystem) {
|
|
806
|
+
var _this2 = this;
|
|
807
|
+
console.log("\uD83D\uDD04 REGISTER COMPONENT CALLED with: \"".concat(componentName, "\""));
|
|
808
|
+
// Use PascalCase for the main component name
|
|
809
|
+
var pascalCaseName = this.formatComponentName(componentName);
|
|
810
|
+
// Store mapping for debugging and reverse lookup
|
|
811
|
+
this.originalToPascalMap.set(componentName, pascalCaseName);
|
|
812
|
+
console.log("\uD83D\uDCDD MAPPING STORED: \"".concat(componentName, "\" \u2192 \"").concat(pascalCaseName, "\""));
|
|
813
|
+
// Create the main component
|
|
814
|
+
var MainComponent = StrataComponentFactory.createComponent(pascalCaseName, componentData, designSystem);
|
|
815
|
+
// Create sub-components recursively with proper PascalCase
|
|
816
|
+
if (componentData.children) {
|
|
817
|
+
Object.entries(componentData.children).forEach(function (_ref) {
|
|
818
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
819
|
+
childName = _ref2[0],
|
|
820
|
+
childData = _ref2[1];
|
|
821
|
+
var childComponentName = _this2.formatComponentName(childName);
|
|
822
|
+
console.log("\uD83D\uDCDD Nested conversion: \"".concat(childName, "\" \u2192 \"").concat(childComponentName, "\""));
|
|
823
|
+
// Store nested component mapping
|
|
824
|
+
_this2.originalToPascalMap.set("".concat(componentName, ".").concat(childName), "".concat(pascalCaseName, ".").concat(childComponentName));
|
|
825
|
+
MainComponent[childComponentName] = StrataComponentFactory.createSubComponent(childComponentName, childData, designSystem);
|
|
826
|
+
// Recursively add nested sub-components
|
|
827
|
+
_this2.addNestedComponents(MainComponent[childComponentName], childData, designSystem, childComponentName, "".concat(componentName, ".").concat(childName));
|
|
828
|
+
});
|
|
829
|
+
}
|
|
830
|
+
// Register with PascalCase name only for cleaner API
|
|
831
|
+
this.registry[pascalCaseName] = MainComponent;
|
|
832
|
+
console.log("\u2705 Registered: \"".concat(pascalCaseName, "\""));
|
|
833
|
+
console.log("\uD83D\uDCCA Current registry:", Object.keys(this.registry));
|
|
834
|
+
this.notifyListeners();
|
|
835
|
+
}
|
|
836
|
+
// Recursively add nested components with mapping
|
|
837
|
+
}, {
|
|
838
|
+
key: "addNestedComponents",
|
|
839
|
+
value: function addNestedComponents(parentComponent, componentData, designSystem, parentPascalPath, parentOriginalPath) {
|
|
840
|
+
var _this3 = this;
|
|
841
|
+
if (componentData.children) {
|
|
842
|
+
Object.entries(componentData.children).forEach(function (_ref3) {
|
|
843
|
+
var _ref4 = _slicedToArray(_ref3, 2),
|
|
844
|
+
childName = _ref4[0],
|
|
845
|
+
childData = _ref4[1];
|
|
846
|
+
var childComponentName = _this3.formatComponentName(childName);
|
|
847
|
+
var fullPascalPath = "".concat(parentPascalPath, ".").concat(childComponentName);
|
|
848
|
+
var fullOriginalPath = "".concat(parentOriginalPath, ".").concat(childName);
|
|
849
|
+
// Store mapping for nested components
|
|
850
|
+
_this3.originalToPascalMap.set(fullOriginalPath, fullPascalPath);
|
|
851
|
+
parentComponent[childComponentName] = StrataComponentFactory.createSubComponent(childComponentName, childData, designSystem);
|
|
852
|
+
// Continue recursion
|
|
853
|
+
_this3.addNestedComponents(parentComponent[childComponentName], childData, designSystem, fullPascalPath, fullOriginalPath);
|
|
854
|
+
});
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
// Get all registered components
|
|
858
|
+
}, {
|
|
859
|
+
key: "getRegistry",
|
|
860
|
+
value: function getRegistry() {
|
|
861
|
+
return _objectSpread2({}, this.registry);
|
|
862
|
+
}
|
|
863
|
+
// Get the mapping for debugging
|
|
864
|
+
}, {
|
|
865
|
+
key: "getComponentMapping",
|
|
866
|
+
value: function getComponentMapping() {
|
|
867
|
+
return new Map(this.originalToPascalMap);
|
|
868
|
+
}
|
|
869
|
+
// Check if component exists (supports both original and PascalCase names)
|
|
870
|
+
}, {
|
|
871
|
+
key: "hasComponent",
|
|
872
|
+
value: function hasComponent(componentName) {
|
|
873
|
+
// Try direct PascalCase first
|
|
874
|
+
if (componentName in this.registry) {
|
|
875
|
+
return true;
|
|
876
|
+
}
|
|
877
|
+
// Try to convert and check
|
|
878
|
+
var pascalName = this.formatComponentName(componentName);
|
|
879
|
+
return pascalName in this.registry;
|
|
880
|
+
}
|
|
881
|
+
// Get component by name (supports both original and PascalCase)
|
|
882
|
+
}, {
|
|
883
|
+
key: "getComponent",
|
|
884
|
+
value: function getComponent(componentName) {
|
|
885
|
+
// Try direct access first
|
|
886
|
+
if (this.registry[componentName]) {
|
|
887
|
+
return this.registry[componentName];
|
|
888
|
+
}
|
|
889
|
+
// Try converted name
|
|
890
|
+
var pascalName = this.formatComponentName(componentName);
|
|
891
|
+
return this.registry[pascalName] || null;
|
|
892
|
+
}
|
|
893
|
+
// Clear all components and re-register with new design system
|
|
894
|
+
}, {
|
|
895
|
+
key: "syncWithDesignSystem",
|
|
896
|
+
value: function syncWithDesignSystem(designSystem) {
|
|
897
|
+
var _this4 = this;
|
|
898
|
+
console.log("🔄 SYNC WITH DESIGN SYSTEM CALLED");
|
|
899
|
+
console.log("🔍 Design system components:", Object.keys(designSystem.components));
|
|
900
|
+
// Test PascalCase conversion before proceeding
|
|
901
|
+
this.testPascalCaseConversion();
|
|
902
|
+
// Clear existing registry and mappings
|
|
903
|
+
this.registry = {};
|
|
904
|
+
this.originalToPascalMap.clear();
|
|
905
|
+
// Register all components
|
|
906
|
+
Object.entries(designSystem.components).forEach(function (_ref5) {
|
|
907
|
+
var _ref6 = _slicedToArray(_ref5, 2),
|
|
908
|
+
componentName = _ref6[0],
|
|
909
|
+
componentData = _ref6[1];
|
|
910
|
+
console.log("\uD83D\uDD04 Processing component from design system: \"".concat(componentName, "\""));
|
|
911
|
+
_this4.registerComponent(componentName, componentData, designSystem);
|
|
912
|
+
});
|
|
913
|
+
console.log("✅ Sync completed. Final registry:", Object.keys(this.registry));
|
|
914
|
+
console.log("🗺️ Component mapping:", Array.from(this.originalToPascalMap.entries()));
|
|
915
|
+
this.notifyListeners();
|
|
916
|
+
}
|
|
917
|
+
// Subscribe to registry changes
|
|
918
|
+
}, {
|
|
919
|
+
key: "subscribe",
|
|
920
|
+
value: function subscribe(listener) {
|
|
921
|
+
var _this5 = this;
|
|
922
|
+
this.listeners.push(listener);
|
|
923
|
+
return function () {
|
|
924
|
+
_this5.listeners = _this5.listeners.filter(function (l) {
|
|
925
|
+
return l !== listener;
|
|
926
|
+
});
|
|
927
|
+
};
|
|
928
|
+
}
|
|
929
|
+
}, {
|
|
930
|
+
key: "notifyListeners",
|
|
931
|
+
value: function notifyListeners() {
|
|
932
|
+
var currentRegistry = this.getRegistry();
|
|
933
|
+
console.log("📋 FINAL REGISTRY STATE:", Object.keys(currentRegistry));
|
|
934
|
+
this.listeners.forEach(function (listener) {
|
|
935
|
+
return listener(currentRegistry);
|
|
936
|
+
});
|
|
937
|
+
}
|
|
938
|
+
// Clear all components (useful for testing)
|
|
939
|
+
}, {
|
|
940
|
+
key: "clear",
|
|
941
|
+
value: function clear() {
|
|
942
|
+
this.registry = {};
|
|
943
|
+
this.originalToPascalMap.clear();
|
|
944
|
+
this.notifyListeners();
|
|
945
|
+
}
|
|
946
|
+
// Utility method to get PascalCase name without registering
|
|
947
|
+
}, {
|
|
948
|
+
key: "getPascalCaseName",
|
|
949
|
+
value: function getPascalCaseName(originalName) {
|
|
950
|
+
return this.formatComponentName(originalName);
|
|
951
|
+
}
|
|
952
|
+
}]);
|
|
953
|
+
}();
|
|
954
|
+
var strataRegistry = new ComponentRegistryService();
|
|
955
|
+
// Optionally run test when module loads in development, behind explicit debug flag
|
|
956
|
+
var shouldRunPascalCaseTest = typeof process !== "undefined" && process.env && process.env.NODE_ENV === "development" && process.env.STRATA_DEBUG_PASCAL_CASE_TEST === "true";
|
|
957
|
+
if (shouldRunPascalCaseTest) {
|
|
958
|
+
setTimeout(function () {
|
|
959
|
+
strataRegistry.testPascalCaseConversion();
|
|
960
|
+
}, 1000);
|
|
961
|
+
}
|
|
962
|
+
|
|
963
|
+
var StrataContext = /*#__PURE__*/React.createContext(undefined);
|
|
964
|
+
var useStrata = function useStrata() {
|
|
965
|
+
var context = React.useContext(StrataContext);
|
|
966
|
+
if (!context) {
|
|
967
|
+
throw new Error("useStrata must be used within a StrataProvider");
|
|
968
|
+
}
|
|
969
|
+
return context;
|
|
970
|
+
};
|
|
971
|
+
var StrataProvider = function StrataProvider(_ref) {
|
|
972
|
+
var _designSystem$variabl, _designSystem$variabl2, _designSystem$variabl3, _designSystem$variabl4, _designSystem$variabl5, _designSystem$variabl6, _designSystem$variabl7, _designSystem$variabl8, _designSystem$variabl9, _designSystem$variabl0, _designSystem$variabl1, _designSystem$variabl10, _designSystem$variabl11, _designSystem$variabl12, _designSystem$variabl13, _designSystem$variabl14, _designSystem$variabl15, _designSystem$variabl16, _designSystem$variabl17, _designSystem$variabl18, _designSystem$variabl19, _designSystem$variabl20, _designSystem$variabl21, _designSystem$variabl22, _designSystem$variabl23, _designSystem$variabl24;
|
|
973
|
+
var children = _ref.children,
|
|
974
|
+
initialData = _ref.initialData,
|
|
975
|
+
userDesignSystem = _ref.userDesignSystem,
|
|
976
|
+
_ref$syncEnabled = _ref.syncEnabled,
|
|
977
|
+
syncEnabled = _ref$syncEnabled === void 0 ? false : _ref$syncEnabled,
|
|
978
|
+
_ref$syncUrl = _ref.syncUrl,
|
|
979
|
+
syncUrl = _ref$syncUrl === void 0 ? "http://localhost:4000" : _ref$syncUrl,
|
|
980
|
+
_ref$syncInterval = _ref.syncInterval,
|
|
981
|
+
syncInterval = _ref$syncInterval === void 0 ? 3000 : _ref$syncInterval,
|
|
982
|
+
syncToken = _ref.syncToken,
|
|
983
|
+
snapshotCdnBase = _ref.snapshotCdnBase,
|
|
984
|
+
projectId = _ref.projectId,
|
|
985
|
+
onSyncError = _ref.onSyncError,
|
|
986
|
+
onSyncSuccess = _ref.onSyncSuccess;
|
|
987
|
+
var _useState = React.useState(userDesignSystem || initialData || {
|
|
988
|
+
variables: {},
|
|
989
|
+
components: {},
|
|
990
|
+
custom: {
|
|
991
|
+
variables: {},
|
|
992
|
+
components: {}
|
|
993
|
+
}
|
|
994
|
+
}),
|
|
995
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
996
|
+
designSystem = _useState2[0],
|
|
997
|
+
setDesignSystem = _useState2[1];
|
|
998
|
+
var _useState3 = React.useState("idle"),
|
|
999
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
1000
|
+
syncStatus = _useState4[0],
|
|
1001
|
+
setSyncStatus = _useState4[1];
|
|
1002
|
+
var _useState5 = React.useState(null),
|
|
1003
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
1004
|
+
lastSynced = _useState6[0],
|
|
1005
|
+
setLastSynced = _useState6[1];
|
|
1006
|
+
var _useState7 = React.useState(0),
|
|
1007
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
1008
|
+
syncVersion = _useState8[0],
|
|
1009
|
+
setSyncVersion = _useState8[1];
|
|
1010
|
+
// Ref that tracks the JSON string of the last successfully synced payload so
|
|
1011
|
+
// that syncDesignSystem does not need to close over the designSystem state
|
|
1012
|
+
// value. This keeps the callback stable and prevents the polling interval
|
|
1013
|
+
// from being continuously reset after each successful sync.
|
|
1014
|
+
var lastSyncedStringRef = React.useRef(null);
|
|
1015
|
+
// Derive the CDN snapshot URL once — used in both syncDesignSystem and the
|
|
1016
|
+
// polling effect so the condition is computed in a single place.
|
|
1017
|
+
var snapshotUrl = React.useMemo(function () {
|
|
1018
|
+
return snapshotCdnBase && projectId ? "".concat(snapshotCdnBase, "/snapshots/").concat(projectId, "/strata.json") : null;
|
|
1019
|
+
}, [snapshotCdnBase, projectId]);
|
|
1020
|
+
var syncDesignSystem = React.useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
1021
|
+
var headers, remoteData, res, data, _yield$Promise$all, _yield$Promise$all2, variablesRes, componentsRes, customRes, _yield$Promise$all3, _yield$Promise$all4, variables, components, custom, newDataString, _t;
|
|
1022
|
+
return _regenerator().w(function (_context) {
|
|
1023
|
+
while (1) switch (_context.p = _context.n) {
|
|
1024
|
+
case 0:
|
|
1025
|
+
if (!(!syncEnabled || !snapshotUrl && !syncUrl)) {
|
|
1026
|
+
_context.n = 1;
|
|
1027
|
+
break;
|
|
1028
|
+
}
|
|
1029
|
+
return _context.a(2);
|
|
1030
|
+
case 1:
|
|
1031
|
+
setSyncStatus("syncing");
|
|
1032
|
+
_context.p = 2;
|
|
1033
|
+
console.log("🔄 Starting design system sync...");
|
|
1034
|
+
headers = syncToken ? {
|
|
1035
|
+
Authorization: "Bearer ".concat(syncToken)
|
|
1036
|
+
} : {};
|
|
1037
|
+
if (!snapshotUrl) {
|
|
1038
|
+
_context.n = 8;
|
|
1039
|
+
break;
|
|
1040
|
+
}
|
|
1041
|
+
_context.n = 3;
|
|
1042
|
+
return fetch(snapshotUrl, {
|
|
1043
|
+
headers: headers
|
|
1044
|
+
});
|
|
1045
|
+
case 3:
|
|
1046
|
+
res = _context.v;
|
|
1047
|
+
if (!(!res.ok && res.status >= 400 && res.status < 500)) {
|
|
1048
|
+
_context.n = 4;
|
|
1049
|
+
break;
|
|
1050
|
+
}
|
|
1051
|
+
setSyncStatus("error");
|
|
1052
|
+
onSyncError === null || onSyncError === void 0 || onSyncError({
|
|
1053
|
+
code: res.status,
|
|
1054
|
+
message: "CDN fetch failed: ".concat(res.status, " ").concat(res.statusText),
|
|
1055
|
+
source: "cdn"
|
|
1056
|
+
});
|
|
1057
|
+
return _context.a(2);
|
|
1058
|
+
case 4:
|
|
1059
|
+
if (res.ok) {
|
|
1060
|
+
_context.n = 5;
|
|
1061
|
+
break;
|
|
1062
|
+
}
|
|
1063
|
+
throw new Error("Snapshot fetch failed: ".concat(res.status));
|
|
1064
|
+
case 5:
|
|
1065
|
+
_context.n = 6;
|
|
1066
|
+
return res.json();
|
|
1067
|
+
case 6:
|
|
1068
|
+
data = _context.v;
|
|
1069
|
+
if (!(!data || _typeof(data) !== "object" || Array.isArray(data) || _typeof(data.variables) !== "object" || data.variables === null || Array.isArray(data.variables) || _typeof(data.components) !== "object" || data.components === null || Array.isArray(data.components))) {
|
|
1070
|
+
_context.n = 7;
|
|
1071
|
+
break;
|
|
1072
|
+
}
|
|
1073
|
+
console.warn("[strata] Invalid snapshot shape received from CDN — skipping update.");
|
|
1074
|
+
setSyncStatus("error");
|
|
1075
|
+
onSyncError === null || onSyncError === void 0 || onSyncError({
|
|
1076
|
+
code: 0,
|
|
1077
|
+
message: "Invalid snapshot shape: missing variables or components",
|
|
1078
|
+
source: "cdn"
|
|
1079
|
+
});
|
|
1080
|
+
return _context.a(2);
|
|
1081
|
+
case 7:
|
|
1082
|
+
remoteData = {
|
|
1083
|
+
variables: data.variables,
|
|
1084
|
+
components: data.components,
|
|
1085
|
+
custom: data.custom || {
|
|
1086
|
+
variables: {},
|
|
1087
|
+
components: {}
|
|
1088
|
+
}
|
|
1089
|
+
};
|
|
1090
|
+
_context.n = 14;
|
|
1091
|
+
break;
|
|
1092
|
+
case 8:
|
|
1093
|
+
_context.n = 9;
|
|
1094
|
+
return Promise.all([fetch("".concat(syncUrl, "/variables"), {
|
|
1095
|
+
headers: headers
|
|
1096
|
+
}), fetch("".concat(syncUrl, "/components"), {
|
|
1097
|
+
headers: headers
|
|
1098
|
+
}), fetch("".concat(syncUrl, "/custom"), {
|
|
1099
|
+
headers: headers
|
|
1100
|
+
})]);
|
|
1101
|
+
case 9:
|
|
1102
|
+
_yield$Promise$all = _context.v;
|
|
1103
|
+
_yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 3);
|
|
1104
|
+
variablesRes = _yield$Promise$all2[0];
|
|
1105
|
+
componentsRes = _yield$Promise$all2[1];
|
|
1106
|
+
customRes = _yield$Promise$all2[2];
|
|
1107
|
+
if (variablesRes.ok) {
|
|
1108
|
+
_context.n = 10;
|
|
1109
|
+
break;
|
|
1110
|
+
}
|
|
1111
|
+
throw new Error("Variables fetch failed: ".concat(variablesRes.status));
|
|
1112
|
+
case 10:
|
|
1113
|
+
if (componentsRes.ok) {
|
|
1114
|
+
_context.n = 11;
|
|
1115
|
+
break;
|
|
1116
|
+
}
|
|
1117
|
+
throw new Error("Components fetch failed: ".concat(componentsRes.status));
|
|
1118
|
+
case 11:
|
|
1119
|
+
if (customRes.ok) {
|
|
1120
|
+
_context.n = 12;
|
|
1121
|
+
break;
|
|
1122
|
+
}
|
|
1123
|
+
throw new Error("Custom fetch failed: ".concat(customRes.status));
|
|
1124
|
+
case 12:
|
|
1125
|
+
_context.n = 13;
|
|
1126
|
+
return Promise.all([variablesRes.json(), componentsRes.json(), customRes.json()]);
|
|
1127
|
+
case 13:
|
|
1128
|
+
_yield$Promise$all3 = _context.v;
|
|
1129
|
+
_yield$Promise$all4 = _slicedToArray(_yield$Promise$all3, 3);
|
|
1130
|
+
variables = _yield$Promise$all4[0];
|
|
1131
|
+
components = _yield$Promise$all4[1];
|
|
1132
|
+
custom = _yield$Promise$all4[2];
|
|
1133
|
+
remoteData = {
|
|
1134
|
+
variables: variables || {},
|
|
1135
|
+
components: components || {},
|
|
1136
|
+
custom: custom || {
|
|
1137
|
+
variables: {},
|
|
1138
|
+
components: {}
|
|
1139
|
+
}
|
|
1140
|
+
};
|
|
1141
|
+
case 14:
|
|
1142
|
+
// Only update if data actually changed (compared against the last synced
|
|
1143
|
+
// snapshot via ref, so this callback stays stable across renders).
|
|
1144
|
+
newDataString = JSON.stringify(remoteData);
|
|
1145
|
+
if (lastSyncedStringRef.current !== newDataString) {
|
|
1146
|
+
console.log("🔄 Design system data changed, updating...");
|
|
1147
|
+
lastSyncedStringRef.current = newDataString;
|
|
1148
|
+
setDesignSystem(remoteData);
|
|
1149
|
+
Object.entries(remoteData.components).forEach(function (_ref3) {
|
|
1150
|
+
var _ref4 = _slicedToArray(_ref3, 2),
|
|
1151
|
+
componentName = _ref4[0],
|
|
1152
|
+
componentData = _ref4[1];
|
|
1153
|
+
if (!strataRegistry.hasComponent(componentName)) {
|
|
1154
|
+
strataRegistry.registerComponent(componentName, componentData, remoteData);
|
|
1155
|
+
}
|
|
1156
|
+
});
|
|
1157
|
+
setSyncVersion(function (prev) {
|
|
1158
|
+
return prev + 1;
|
|
1159
|
+
});
|
|
1160
|
+
setSyncStatus("success");
|
|
1161
|
+
setLastSynced(new Date());
|
|
1162
|
+
onSyncSuccess === null || onSyncSuccess === void 0 || onSyncSuccess(remoteData);
|
|
1163
|
+
console.log("✅ Design system synced successfully");
|
|
1164
|
+
console.log("📊 Components available:", Object.keys(remoteData.components));
|
|
1165
|
+
console.log("🎨 Variables available:", Object.keys(remoteData.variables));
|
|
1166
|
+
} else {
|
|
1167
|
+
setSyncStatus("idle");
|
|
1168
|
+
console.log("⚡ Design system already up to date");
|
|
1169
|
+
}
|
|
1170
|
+
_context.n = 16;
|
|
1171
|
+
break;
|
|
1172
|
+
case 15:
|
|
1173
|
+
_context.p = 15;
|
|
1174
|
+
_t = _context.v;
|
|
1175
|
+
console.error("❌ Sync failed:", _t);
|
|
1176
|
+
setSyncStatus("error");
|
|
1177
|
+
onSyncError === null || onSyncError === void 0 || onSyncError({
|
|
1178
|
+
code: 0,
|
|
1179
|
+
message: _t instanceof Error ? _t.message : String(_t),
|
|
1180
|
+
source: snapshotUrl ? "cdn" : "sync"
|
|
1181
|
+
});
|
|
1182
|
+
case 16:
|
|
1183
|
+
return _context.a(2);
|
|
1184
|
+
}
|
|
1185
|
+
}, _callee, null, [[2, 15]]);
|
|
1186
|
+
})), [syncEnabled, syncUrl, syncToken, snapshotUrl, onSyncSuccess, onSyncError]);
|
|
1187
|
+
// Force sync function for manual triggering
|
|
1188
|
+
var forceSync = React.useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
|
|
1189
|
+
return _regenerator().w(function (_context2) {
|
|
1190
|
+
while (1) switch (_context2.n) {
|
|
1191
|
+
case 0:
|
|
1192
|
+
_context2.n = 1;
|
|
1193
|
+
return syncDesignSystem();
|
|
1194
|
+
case 1:
|
|
1195
|
+
return _context2.a(2);
|
|
1196
|
+
}
|
|
1197
|
+
}, _callee2);
|
|
1198
|
+
})), [syncDesignSystem]);
|
|
1199
|
+
// Polling for real-time updates
|
|
1200
|
+
React.useEffect(function () {
|
|
1201
|
+
if (!syncEnabled || !snapshotUrl && !syncUrl) return;
|
|
1202
|
+
console.log("🔄 Starting sync polling...");
|
|
1203
|
+
var interval = setInterval(syncDesignSystem, syncInterval);
|
|
1204
|
+
// Initial sync
|
|
1205
|
+
syncDesignSystem();
|
|
1206
|
+
return function () {
|
|
1207
|
+
console.log("🔄 Stopping sync polling...");
|
|
1208
|
+
clearInterval(interval);
|
|
1209
|
+
};
|
|
1210
|
+
}, [syncEnabled, syncUrl, snapshotUrl, syncInterval, syncDesignSystem]);
|
|
1211
|
+
// Convert design tokens to Chakra UI theme with enhanced resolution
|
|
1212
|
+
var theme = react.extendTheme({
|
|
1213
|
+
colors: Object.entries(designSystem.variables).reduce(function (acc, _ref6) {
|
|
1214
|
+
var _ref7 = _slicedToArray(_ref6, 2),
|
|
1215
|
+
key = _ref7[0],
|
|
1216
|
+
value = _ref7[1];
|
|
1217
|
+
if (value.type === "color" && key.startsWith("--")) {
|
|
1218
|
+
var colorName = key.replace("--", "").replace(/-color/g, "");
|
|
1219
|
+
acc[colorName] = value.value;
|
|
1220
|
+
}
|
|
1221
|
+
return acc;
|
|
1222
|
+
}, {}),
|
|
1223
|
+
fonts: {
|
|
1224
|
+
body: ((_designSystem$variabl = designSystem.variables["--font-family-sans"]) === null || _designSystem$variabl === void 0 ? void 0 : _designSystem$variabl.value) || "system-ui, sans-serif",
|
|
1225
|
+
heading: ((_designSystem$variabl2 = designSystem.variables["--font-family-sans"]) === null || _designSystem$variabl2 === void 0 ? void 0 : _designSystem$variabl2.value) || "system-ui, sans-serif",
|
|
1226
|
+
mono: ((_designSystem$variabl3 = designSystem.variables["--font-family-mono"]) === null || _designSystem$variabl3 === void 0 ? void 0 : _designSystem$variabl3.value) || "monospace"
|
|
1227
|
+
},
|
|
1228
|
+
fontSizes: {
|
|
1229
|
+
xs: ((_designSystem$variabl4 = designSystem.variables["--font-size-xs"]) === null || _designSystem$variabl4 === void 0 ? void 0 : _designSystem$variabl4.value) || "0.75rem",
|
|
1230
|
+
sm: ((_designSystem$variabl5 = designSystem.variables["--font-size-sm"]) === null || _designSystem$variabl5 === void 0 ? void 0 : _designSystem$variabl5.value) || "0.875rem",
|
|
1231
|
+
md: ((_designSystem$variabl6 = designSystem.variables["--font-size-base"]) === null || _designSystem$variabl6 === void 0 ? void 0 : _designSystem$variabl6.value) || "1rem",
|
|
1232
|
+
lg: ((_designSystem$variabl7 = designSystem.variables["--font-size-lg"]) === null || _designSystem$variabl7 === void 0 ? void 0 : _designSystem$variabl7.value) || "1.125rem",
|
|
1233
|
+
xl: ((_designSystem$variabl8 = designSystem.variables["--text-xl"]) === null || _designSystem$variabl8 === void 0 ? void 0 : _designSystem$variabl8.value) || "1.25rem",
|
|
1234
|
+
"2xl": ((_designSystem$variabl9 = designSystem.variables["--text-2xl"]) === null || _designSystem$variabl9 === void 0 ? void 0 : _designSystem$variabl9.value) || "1.5rem"
|
|
1235
|
+
},
|
|
1236
|
+
space: {
|
|
1237
|
+
1: ((_designSystem$variabl0 = designSystem.variables["--spacing-1"]) === null || _designSystem$variabl0 === void 0 ? void 0 : _designSystem$variabl0.value) || "0.25rem",
|
|
1238
|
+
2: ((_designSystem$variabl1 = designSystem.variables["--spacing-2"]) === null || _designSystem$variabl1 === void 0 ? void 0 : _designSystem$variabl1.value) || "0.5rem",
|
|
1239
|
+
3: ((_designSystem$variabl10 = designSystem.variables["--spacing-3"]) === null || _designSystem$variabl10 === void 0 ? void 0 : _designSystem$variabl10.value) || "0.75rem",
|
|
1240
|
+
4: ((_designSystem$variabl11 = designSystem.variables["--spacing-4"]) === null || _designSystem$variabl11 === void 0 ? void 0 : _designSystem$variabl11.value) || "1rem",
|
|
1241
|
+
6: ((_designSystem$variabl12 = designSystem.variables["--spacing-6"]) === null || _designSystem$variabl12 === void 0 ? void 0 : _designSystem$variabl12.value) || "1.5rem",
|
|
1242
|
+
8: ((_designSystem$variabl13 = designSystem.variables["--spacing-8"]) === null || _designSystem$variabl13 === void 0 ? void 0 : _designSystem$variabl13.value) || "2rem"
|
|
1243
|
+
},
|
|
1244
|
+
radii: {
|
|
1245
|
+
none: "0",
|
|
1246
|
+
sm: ((_designSystem$variabl14 = designSystem.variables["--border-radius-sm"]) === null || _designSystem$variabl14 === void 0 ? void 0 : _designSystem$variabl14.value) || "0.125rem",
|
|
1247
|
+
md: ((_designSystem$variabl15 = designSystem.variables["--border-radius-md"]) === null || _designSystem$variabl15 === void 0 ? void 0 : _designSystem$variabl15.value) || "0.375rem",
|
|
1248
|
+
lg: ((_designSystem$variabl16 = designSystem.variables["--border-radius-lg"]) === null || _designSystem$variabl16 === void 0 ? void 0 : _designSystem$variabl16.value) || "0.5rem",
|
|
1249
|
+
xl: ((_designSystem$variabl17 = designSystem.variables["--border-radius-xl"]) === null || _designSystem$variabl17 === void 0 ? void 0 : _designSystem$variabl17.value) || "0.75rem",
|
|
1250
|
+
"2xl": ((_designSystem$variabl18 = designSystem.variables["--border-radius-2xl"]) === null || _designSystem$variabl18 === void 0 ? void 0 : _designSystem$variabl18.value) || "1rem",
|
|
1251
|
+
"3xl": ((_designSystem$variabl19 = designSystem.variables["--border-radius-3xl"]) === null || _designSystem$variabl19 === void 0 ? void 0 : _designSystem$variabl19.value) || "1.5rem",
|
|
1252
|
+
full: ((_designSystem$variabl20 = designSystem.variables["--border-radius-full"]) === null || _designSystem$variabl20 === void 0 ? void 0 : _designSystem$variabl20.value) || "9999px"
|
|
1253
|
+
},
|
|
1254
|
+
shadows: {
|
|
1255
|
+
sm: ((_designSystem$variabl21 = designSystem.variables["--shadow-sm"]) === null || _designSystem$variabl21 === void 0 ? void 0 : _designSystem$variabl21.value) || "0 1px 2px 0 rgba(0, 0, 0, 0.05)",
|
|
1256
|
+
md: ((_designSystem$variabl22 = designSystem.variables["--shadow-md"]) === null || _designSystem$variabl22 === void 0 ? void 0 : _designSystem$variabl22.value) || "0 4px 6px -1px rgba(0, 0, 0, 0.1)",
|
|
1257
|
+
lg: ((_designSystem$variabl23 = designSystem.variables["--shadow-lg"]) === null || _designSystem$variabl23 === void 0 ? void 0 : _designSystem$variabl23.value) || "0 10px 15px -3px rgba(0, 0, 0, 0.1)",
|
|
1258
|
+
xl: ((_designSystem$variabl24 = designSystem.variables["--shadow-xl"]) === null || _designSystem$variabl24 === void 0 ? void 0 : _designSystem$variabl24.value) || "0 20px 25px -5px rgba(0, 0, 0, 0.1)"
|
|
1259
|
+
}
|
|
1260
|
+
});
|
|
1261
|
+
var updateDesignSystem = function updateDesignSystem(newData) {
|
|
1262
|
+
setDesignSystem(newData);
|
|
1263
|
+
setSyncVersion(function (prev) {
|
|
1264
|
+
return prev + 1;
|
|
1265
|
+
});
|
|
1266
|
+
if (!syncEnabled) {
|
|
1267
|
+
localStorage.setItem("designSystemData", JSON.stringify(newData));
|
|
1268
|
+
}
|
|
1269
|
+
};
|
|
1270
|
+
var contextValue = {
|
|
1271
|
+
designSystem: designSystem,
|
|
1272
|
+
updateDesignSystem: updateDesignSystem,
|
|
1273
|
+
syncStatus: syncStatus,
|
|
1274
|
+
lastSynced: lastSynced,
|
|
1275
|
+
forceSync: forceSync,
|
|
1276
|
+
syncVersion: syncVersion,
|
|
1277
|
+
syncUrl: syncUrl,
|
|
1278
|
+
syncEnabled: syncEnabled,
|
|
1279
|
+
syncInterval: syncInterval,
|
|
1280
|
+
syncToken: syncToken,
|
|
1281
|
+
snapshotCdnBase: snapshotCdnBase,
|
|
1282
|
+
projectId: projectId
|
|
1283
|
+
};
|
|
1284
|
+
return jsxRuntime.jsx(StrataContext.Provider, {
|
|
1285
|
+
value: contextValue,
|
|
1286
|
+
children: jsxRuntime.jsx(react.ChakraProvider, {
|
|
1287
|
+
theme: theme,
|
|
1288
|
+
cssVarsRoot: ":root",
|
|
1289
|
+
children: children
|
|
1290
|
+
})
|
|
1291
|
+
});
|
|
1292
|
+
};
|
|
1293
|
+
|
|
1294
|
+
var useComponentData = function useComponentData() {
|
|
1295
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1296
|
+
var _options$componentNam = options.componentName,
|
|
1297
|
+
componentName = _options$componentNam === void 0 ? 'card' : _options$componentNam,
|
|
1298
|
+
_options$fallbackToDe = options.fallbackToDefault,
|
|
1299
|
+
fallbackToDefault = _options$fallbackToDe === void 0 ? true : _options$fallbackToDe;
|
|
1300
|
+
var _useStrata = useStrata(),
|
|
1301
|
+
designSystem = _useStrata.designSystem,
|
|
1302
|
+
syncVersion = _useStrata.syncVersion;
|
|
1303
|
+
// Enhanced helper function to safely access nested properties
|
|
1304
|
+
var safeGet = function safeGet(obj, path, defaultValue) {
|
|
1305
|
+
return path.split('.').reduce(function (acc, key) {
|
|
1306
|
+
if (acc && _typeof(acc) === 'object' && key in acc) {
|
|
1307
|
+
return acc[key];
|
|
1308
|
+
}
|
|
1309
|
+
return defaultValue;
|
|
1310
|
+
}, obj);
|
|
1311
|
+
};
|
|
1312
|
+
// Advanced CSS variable resolution with recursion protection
|
|
1313
|
+
var _resolveValue = function resolveValue(value) {
|
|
1314
|
+
var unit = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
1315
|
+
var visited = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : new Set();
|
|
1316
|
+
if (!value) return '';
|
|
1317
|
+
var resolvedValue = value;
|
|
1318
|
+
// Resolve CSS variables recursively with cycle detection
|
|
1319
|
+
if (resolvedValue.startsWith('var(')) {
|
|
1320
|
+
var _resolvedValue$match;
|
|
1321
|
+
var varName = (_resolvedValue$match = resolvedValue.match(/var\((--[^)]+)\)/)) === null || _resolvedValue$match === void 0 ? void 0 : _resolvedValue$match[1];
|
|
1322
|
+
if (varName) {
|
|
1323
|
+
if (visited.has(varName)) {
|
|
1324
|
+
console.warn("Circular reference detected for variable: ".concat(varName));
|
|
1325
|
+
return resolvedValue;
|
|
1326
|
+
}
|
|
1327
|
+
visited.add(varName);
|
|
1328
|
+
var varData = designSystem.variables[varName];
|
|
1329
|
+
if (varData) {
|
|
1330
|
+
resolvedValue = _resolveValue(varData.value, varData.unit, visited);
|
|
1331
|
+
}
|
|
1332
|
+
}
|
|
1333
|
+
}
|
|
1334
|
+
// Add unit if missing and value is numeric
|
|
1335
|
+
if (unit && /^-?\d*\.?\d+$/.test(resolvedValue)) {
|
|
1336
|
+
return resolvedValue + unit;
|
|
1337
|
+
}
|
|
1338
|
+
return resolvedValue;
|
|
1339
|
+
};
|
|
1340
|
+
// Get property value with enhanced resolution
|
|
1341
|
+
var getPropertyValue = function getPropertyValue(node, property) {
|
|
1342
|
+
var _node$properties;
|
|
1343
|
+
if (!(node !== null && node !== void 0 && (_node$properties = node.properties) !== null && _node$properties !== void 0 && _node$properties[property])) {
|
|
1344
|
+
return '';
|
|
1345
|
+
}
|
|
1346
|
+
var prop = node.properties[property];
|
|
1347
|
+
return _resolveValue(prop.value, prop.unit);
|
|
1348
|
+
};
|
|
1349
|
+
// Get text content with safe access
|
|
1350
|
+
var getTextContent = function getTextContent(node) {
|
|
1351
|
+
return (node === null || node === void 0 ? void 0 : node.textContent) || '';
|
|
1352
|
+
};
|
|
1353
|
+
// Get linked element attributes
|
|
1354
|
+
var getLinkedElementAttr = function getLinkedElementAttr(node, attr) {
|
|
1355
|
+
var _node$linkedElement;
|
|
1356
|
+
if (!(node !== null && node !== void 0 && (_node$linkedElement = node.linkedElement) !== null && _node$linkedElement !== void 0 && (_node$linkedElement = _node$linkedElement.attributes) !== null && _node$linkedElement !== void 0 && _node$linkedElement[attr])) {
|
|
1357
|
+
return '';
|
|
1358
|
+
}
|
|
1359
|
+
return node.linkedElement.attributes[attr];
|
|
1360
|
+
};
|
|
1361
|
+
// Enhanced component data extraction that matches your design system structure
|
|
1362
|
+
var _extractComponentData = function extractComponentData(componentName) {
|
|
1363
|
+
var componentData = designSystem.components[componentName];
|
|
1364
|
+
if (!componentData) {
|
|
1365
|
+
if (fallbackToDefault && componentName !== 'card') {
|
|
1366
|
+
console.warn("Component \"".concat(componentName, "\" not found, falling back to default card"));
|
|
1367
|
+
return _extractComponentData('card');
|
|
1368
|
+
}
|
|
1369
|
+
console.warn("Component \"".concat(componentName, "\" not found in design system"));
|
|
1370
|
+
return null;
|
|
1371
|
+
}
|
|
1372
|
+
console.log("\uD83D\uDCE6 Extracting data for component: ".concat(componentName), componentData);
|
|
1373
|
+
// Extract card data based on your actual design system structure
|
|
1374
|
+
var extractedData = {
|
|
1375
|
+
// Main card properties
|
|
1376
|
+
card: {
|
|
1377
|
+
width: getPropertyValue(componentData, 'width') || '100%',
|
|
1378
|
+
maxWidth: getPropertyValue(componentData, 'max-width') || '32rem',
|
|
1379
|
+
backgroundColor: getPropertyValue(componentData, 'background-color') || '#f9fafb',
|
|
1380
|
+
fontFamily: getPropertyValue(componentData, 'font-family') || 'Inter, system-ui, sans-serif'
|
|
1381
|
+
},
|
|
1382
|
+
// Card container (from children.card-container)
|
|
1383
|
+
container: {
|
|
1384
|
+
width: getPropertyValue(safeGet(componentData, 'children.card-container', undefined), 'width') || '100%',
|
|
1385
|
+
maxWidth: getPropertyValue(safeGet(componentData, 'children.card-container', undefined), 'max-width') || '32rem',
|
|
1386
|
+
backgroundColor: getPropertyValue(safeGet(componentData, 'children.card-container', undefined), 'background-color') || '#ffffff',
|
|
1387
|
+
borderRadius: getPropertyValue(safeGet(componentData, 'children.card-container', undefined), 'border-radius') || '1.5rem',
|
|
1388
|
+
boxShadow: getPropertyValue(safeGet(componentData, 'children.card-container', undefined), 'box-shadow') || '0 10px 15px -3px rgba(0, 0, 0, 0.1)',
|
|
1389
|
+
overflow: getPropertyValue(safeGet(componentData, 'children.card-container', undefined), 'overflow') || 'hidden'
|
|
1390
|
+
},
|
|
1391
|
+
// Card header (nested structure)
|
|
1392
|
+
header: {
|
|
1393
|
+
padding: getPropertyValue(safeGet(componentData, 'children.card-container.children.card-header', undefined), 'padding') || '1.5rem',
|
|
1394
|
+
borderBottom: getPropertyValue(safeGet(componentData, 'children.card-container.children.card-header', undefined), 'border-bottom-width') || '1px',
|
|
1395
|
+
borderColor: getPropertyValue(safeGet(componentData, 'children.card-container.children.card-header', undefined), 'border-bottom-color') || '#e5e7eb'
|
|
1396
|
+
},
|
|
1397
|
+
headerContent: {
|
|
1398
|
+
display: getPropertyValue(safeGet(componentData, 'children.card-container.children.card-header.children.card-header-content', undefined), 'display') || 'flex',
|
|
1399
|
+
justifyContent: getPropertyValue(safeGet(componentData, 'children.card-container.children.card-header.children.card-header-content', undefined), 'justify-content') || 'space-between',
|
|
1400
|
+
alignItems: getPropertyValue(safeGet(componentData, 'children.card-container.children.card-header.children.card-header-content', undefined), 'align-items') || 'center'
|
|
1401
|
+
},
|
|
1402
|
+
headerTitle: {
|
|
1403
|
+
text: getTextContent(safeGet(componentData, 'children.card-container.children.card-header.children.card-header-content.children.card-header-title', undefined)) || 'Arrived in',
|
|
1404
|
+
fontSize: getPropertyValue(safeGet(componentData, 'children.card-container.children.card-header.children.card-header-content.children.card-header-title', undefined), 'font-size') || '1.25rem',
|
|
1405
|
+
fontWeight: getPropertyValue(safeGet(componentData, 'children.card-container.children.card-header.children.card-header-content.children.card-header-title', undefined), 'font-weight') || '600',
|
|
1406
|
+
color: getPropertyValue(safeGet(componentData, 'children.card-container.children.card-header.children.card-header-content.children.card-header-title', undefined), 'color') || '#111827'
|
|
1407
|
+
},
|
|
1408
|
+
headerTimer: {
|
|
1409
|
+
text: getTextContent(safeGet(componentData, 'children.card-container.children.card-header.children.card-header-content.children.card-header-timer', undefined)) || '00:05:20',
|
|
1410
|
+
fontSize: getPropertyValue(safeGet(componentData, 'children.card-container.children.card-header.children.card-header-content.children.card-header-timer', undefined), 'font-size') || '1.25rem',
|
|
1411
|
+
fontFamily: getPropertyValue(safeGet(componentData, 'children.card-container.children.card-header.children.card-header-content.children.card-header-timer', undefined), 'font-family') || 'monospace',
|
|
1412
|
+
color: getPropertyValue(safeGet(componentData, 'children.card-container.children.card-header.children.card-header-content.children.card-header-timer', undefined), 'color') || '#1f2937'
|
|
1413
|
+
},
|
|
1414
|
+
// Card body
|
|
1415
|
+
body: {
|
|
1416
|
+
padding: getPropertyValue(safeGet(componentData, 'children.card-container.children.card-body', undefined), 'padding') || '1.5rem'
|
|
1417
|
+
},
|
|
1418
|
+
bodyDriver: {
|
|
1419
|
+
backgroundColor: getPropertyValue(safeGet(componentData, 'children.card-container.children.card-body.children.card-body-driver', undefined), 'background-color') || '#f9fafb',
|
|
1420
|
+
borderRadius: getPropertyValue(safeGet(componentData, 'children.card-container.children.card-body.children.card-body-driver', undefined), 'border-radius') || '0.75rem',
|
|
1421
|
+
padding: getPropertyValue(safeGet(componentData, 'children.card-container.children.card-body.children.card-body-driver', undefined), 'padding') || '1rem',
|
|
1422
|
+
display: getPropertyValue(safeGet(componentData, 'children.card-container.children.card-body.children.card-body-driver', undefined), 'display') || 'flex',
|
|
1423
|
+
alignItems: getPropertyValue(safeGet(componentData, 'children.card-container.children.card-body.children.card-body-driver', undefined), 'align-items') || 'center',
|
|
1424
|
+
gap: getPropertyValue(safeGet(componentData, 'children.card-container.children.card-body.children.card-body-driver', undefined), 'gap') || '1rem'
|
|
1425
|
+
},
|
|
1426
|
+
bodyImage: {
|
|
1427
|
+
src: getLinkedElementAttr(safeGet(componentData, 'children.card-container.children.card-body.children.card-body-driver.children.card-body-img', undefined), 'src') || 'https://plus.unsplash.com/premium_photo-1689977927774-401b12d137d6?w=900&auto=format&fit=crop&q=60&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxzZWFyY2h8OXx8bWFufGVufDB8fDB8fHww',
|
|
1428
|
+
alt: getLinkedElementAttr(safeGet(componentData, 'children.card-container.children.card-body.children.card-body-driver.children.card-body-img', undefined), 'alt') || 'Driver',
|
|
1429
|
+
width: getPropertyValue(safeGet(componentData, 'children.card-container.children.card-body.children.card-body-driver.children.card-body-img', undefined), 'width') || '3.5rem',
|
|
1430
|
+
height: getPropertyValue(safeGet(componentData, 'children.card-container.children.card-body.children.card-body-driver.children.card-body-img', undefined), 'height') || '3.5rem',
|
|
1431
|
+
borderRadius: getPropertyValue(safeGet(componentData, 'children.card-container.children.card-body.children.card-body-driver.children.card-body-img', undefined), 'border-radius') || '50%',
|
|
1432
|
+
objectFit: getPropertyValue(safeGet(componentData, 'children.card-container.children.card-body.children.card-body-driver.children.card-body-img', undefined), 'object-fit') || 'cover'
|
|
1433
|
+
},
|
|
1434
|
+
bodyInfo: {
|
|
1435
|
+
flexGrow: getPropertyValue(safeGet(componentData, 'children.card-container.children.card-body.children.card-body-driver.children.card-body-info', undefined), 'flex-grow') || '1'
|
|
1436
|
+
},
|
|
1437
|
+
bodyName: {
|
|
1438
|
+
text: getTextContent(safeGet(componentData, 'children.card-container.children.card-body.children.card-body-driver.children.card-body-info.children.card-body-name', undefined)) || 'Jacob Jones',
|
|
1439
|
+
fontWeight: getPropertyValue(safeGet(componentData, 'children.card-container.children.card-body.children.card-body-driver.children.card-body-info.children.card-body-name', undefined), 'font-weight') || '600',
|
|
1440
|
+
color: getPropertyValue(safeGet(componentData, 'children.card-container.children.card-body.children.card-body-driver.children.card-body-info.children.card-body-name', undefined), 'color') || '#111827'
|
|
1441
|
+
},
|
|
1442
|
+
bodySpan: {
|
|
1443
|
+
text: getTextContent(safeGet(componentData, 'children.card-container.children.card-body.children.card-body-driver.children.card-body-info.children.card-body-span', undefined)) || 'Omnitrans • SPX-8328',
|
|
1444
|
+
fontSize: getPropertyValue(safeGet(componentData, 'children.card-container.children.card-body.children.card-body-driver.children.card-body-info.children.card-body-span', undefined), 'font-size') || '0.875rem',
|
|
1445
|
+
color: getPropertyValue(safeGet(componentData, 'children.card-container.children.card-body.children.card-body-driver.children.card-body-info.children.card-body-span', undefined), 'color') || '#6b7280'
|
|
1446
|
+
},
|
|
1447
|
+
bodyActions: {
|
|
1448
|
+
gap: getPropertyValue(safeGet(componentData, 'children.card-container.children.card-body.children.card-body-driver.children.card-body-actions', undefined), 'gap') || '0.5rem'
|
|
1449
|
+
},
|
|
1450
|
+
// Route section
|
|
1451
|
+
route: {
|
|
1452
|
+
paddingX: getPropertyValue(safeGet(componentData, 'children.card-container.children.card-route', undefined), 'padding-left') || '1.5rem',
|
|
1453
|
+
paddingBottom: getPropertyValue(safeGet(componentData, 'children.card-container.children.card-route', undefined), 'padding-bottom') || '1.5rem'
|
|
1454
|
+
},
|
|
1455
|
+
routeContainer: {
|
|
1456
|
+
gap: getPropertyValue(safeGet(componentData, 'children.card-container.children.card-route.children.card-route-container', undefined), 'gap') || '1.5rem'
|
|
1457
|
+
},
|
|
1458
|
+
// Payment section
|
|
1459
|
+
payment: {
|
|
1460
|
+
paddingX: getPropertyValue(safeGet(componentData, 'children.card-container.children.card-payment', undefined), 'padding-left') || '1.5rem',
|
|
1461
|
+
paddingBottom: getPropertyValue(safeGet(componentData, 'children.card-container.children.card-payment', undefined), 'padding-bottom') || '1.5rem'
|
|
1462
|
+
},
|
|
1463
|
+
paymentContainer: {
|
|
1464
|
+
backgroundColor: getPropertyValue(safeGet(componentData, 'children.card-container.children.card-payment.children.card-payment-container', undefined), 'background-color') || '#111827',
|
|
1465
|
+
borderRadius: getPropertyValue(safeGet(componentData, 'children.card-container.children.card-payment.children.card-payment-container', undefined), 'border-radius') || '0.75rem',
|
|
1466
|
+
padding: getPropertyValue(safeGet(componentData, 'children.card-container.children.card-payment.children.card-payment-container', undefined), 'padding') || '1rem'
|
|
1467
|
+
},
|
|
1468
|
+
cardNumber: {
|
|
1469
|
+
text: getTextContent(safeGet(componentData, 'children.card-container.children.card-payment.children.card-payment-container.children.card-payment-content.children.card-payment-details.children.card-number', undefined)) || '**** 7493',
|
|
1470
|
+
color: getPropertyValue(safeGet(componentData, 'children.card-container.children.card-payment.children.card-payment-container.children.card-payment-content.children.card-payment-details.children.card-number', undefined), 'color') || '#ffffff',
|
|
1471
|
+
fontWeight: getPropertyValue(safeGet(componentData, 'children.card-container.children.card-payment.children.card-payment-container.children.card-payment-content.children.card-payment-details.children.card-number', undefined), 'font-weight') || '500',
|
|
1472
|
+
fontSize: getPropertyValue(safeGet(componentData, 'children.card-container.children.card-payment.children.card-payment-container.children.card-payment-content.children.card-payment-details.children.card-number', undefined), 'font-size') || '1.125rem'
|
|
1473
|
+
},
|
|
1474
|
+
cardType: {
|
|
1475
|
+
text: getTextContent(safeGet(componentData, 'children.card-container.children.card-payment.children.card-payment-container.children.card-payment-content.children.card-payment-details.children.card-type', undefined)) || 'Credit card',
|
|
1476
|
+
fontSize: getPropertyValue(safeGet(componentData, 'children.card-container.children.card-payment.children.card-payment-container.children.card-payment-content.children.card-payment-details.children.card-type', undefined), 'font-size') || '0.875rem',
|
|
1477
|
+
color: getPropertyValue(safeGet(componentData, 'children.card-container.children.card-payment.children.card-payment-container.children.card-payment-content.children.card-payment-details.children.card-type', undefined), 'color') || '#d1d5db'
|
|
1478
|
+
},
|
|
1479
|
+
// Total section
|
|
1480
|
+
totalSection: {
|
|
1481
|
+
paddingX: getPropertyValue(safeGet(componentData, 'children.card-container.children.card-total-section', undefined), 'padding-left') || '1.5rem',
|
|
1482
|
+
paddingY: getPropertyValue(safeGet(componentData, 'children.card-container.children.card-total-section', undefined), 'padding-top') || '1.5rem'
|
|
1483
|
+
},
|
|
1484
|
+
totalLabel: {
|
|
1485
|
+
text: getTextContent(safeGet(componentData, 'children.card-container.children.card-total-section.children.card-total-content.children.card-total-label', undefined)) || 'Total orders',
|
|
1486
|
+
color: getPropertyValue(safeGet(componentData, 'children.card-container.children.card-total-section.children.card-total-content.children.card-total-label', undefined), 'color') || '#111827',
|
|
1487
|
+
fontWeight: getPropertyValue(safeGet(componentData, 'children.card-container.children.card-total-section.children.card-total-content.children.card-total-label', undefined), 'font-weight') || '500'
|
|
1488
|
+
},
|
|
1489
|
+
totalAmount: {
|
|
1490
|
+
text: getTextContent(safeGet(componentData, 'children.card-container.children.card-total-section.children.card-total-content.children.card-total-amount', undefined)) || '$5.75',
|
|
1491
|
+
fontSize: getPropertyValue(safeGet(componentData, 'children.card-container.children.card-total-section.children.card-total-content.children.card-total-amount', undefined), 'font-size') || '1.25rem',
|
|
1492
|
+
fontWeight: getPropertyValue(safeGet(componentData, 'children.card-container.children.card-total-section.children.card-total-content.children.card-total-amount', undefined), 'font-weight') || '700',
|
|
1493
|
+
color: getPropertyValue(safeGet(componentData, 'children.card-container.children.card-total-section.children.card-total-content.children.card-total-amount', undefined), 'color') || '#111827'
|
|
1494
|
+
}
|
|
1495
|
+
};
|
|
1496
|
+
console.log("\u2705 Extracted data for ".concat(componentName, ":"), extractedData);
|
|
1497
|
+
return extractedData;
|
|
1498
|
+
};
|
|
1499
|
+
var componentData = _extractComponentData(componentName);
|
|
1500
|
+
return {
|
|
1501
|
+
data: componentData,
|
|
1502
|
+
hasData: !!componentData,
|
|
1503
|
+
componentName: componentName,
|
|
1504
|
+
syncVersion: syncVersion
|
|
1505
|
+
};
|
|
1506
|
+
};
|
|
1507
|
+
// Backward compatibility alias
|
|
1508
|
+
var useCardData = function useCardData() {
|
|
1509
|
+
return useComponentData({
|
|
1510
|
+
componentName: 'card'
|
|
1511
|
+
});
|
|
1512
|
+
};
|
|
1513
|
+
|
|
1514
|
+
// "use client";
|
|
1515
|
+
// import * as React from "react";
|
|
1516
|
+
// import {
|
|
1517
|
+
// Box,
|
|
1518
|
+
// Flex,
|
|
1519
|
+
// Text,
|
|
1520
|
+
// Image,
|
|
1521
|
+
// Button,
|
|
1522
|
+
// VStack,
|
|
1523
|
+
// HStack,
|
|
1524
|
+
// } from "@chakra-ui/react";
|
|
1525
|
+
// import { useCardData } from "../../hook/useCardData";
|
|
1526
|
+
// // Card Container
|
|
1527
|
+
// const CardContainer = ({ children, width, maxWidth }: any) => {
|
|
1528
|
+
// const cardData = useCardData();
|
|
1529
|
+
// if (!cardData) return null;
|
|
1530
|
+
// return (
|
|
1531
|
+
// <Box
|
|
1532
|
+
// width={width || cardData.container.width}
|
|
1533
|
+
// maxWidth={maxWidth || cardData.container.maxWidth}
|
|
1534
|
+
// mx="auto"
|
|
1535
|
+
// bg={cardData.container.backgroundColor}
|
|
1536
|
+
// borderRadius={cardData.container.borderRadius}
|
|
1537
|
+
// boxShadow={cardData.container.boxShadow}
|
|
1538
|
+
// overflow={cardData.container.overflow}
|
|
1539
|
+
// >
|
|
1540
|
+
// {children}
|
|
1541
|
+
// </Box>
|
|
1542
|
+
// );
|
|
1543
|
+
// };
|
|
1544
|
+
// // Card Header
|
|
1545
|
+
// const CardHeader = ({ children, padding }: any) => {
|
|
1546
|
+
// const cardData = useCardData();
|
|
1547
|
+
// if (!cardData) return null;
|
|
1548
|
+
// return (
|
|
1549
|
+
// <Box
|
|
1550
|
+
// p={padding || cardData.header.padding}
|
|
1551
|
+
// borderBottom={`${cardData.header.borderBottom} solid ${cardData.header.borderColor}`}
|
|
1552
|
+
// >
|
|
1553
|
+
// {children}
|
|
1554
|
+
// </Box>
|
|
1555
|
+
// );
|
|
1556
|
+
// };
|
|
1557
|
+
// const CardHeaderContent = ({ children }: any) => {
|
|
1558
|
+
// const cardData = useCardData();
|
|
1559
|
+
// if (!cardData) return null;
|
|
1560
|
+
// return (
|
|
1561
|
+
// <Flex
|
|
1562
|
+
// display={cardData.headerContent.display}
|
|
1563
|
+
// justifyContent={cardData.headerContent.justifyContent}
|
|
1564
|
+
// alignItems={cardData.headerContent.alignItems}
|
|
1565
|
+
// >
|
|
1566
|
+
// {children}
|
|
1567
|
+
// </Flex>
|
|
1568
|
+
// );
|
|
1569
|
+
// };
|
|
1570
|
+
// const CardHeaderTitle = ({ children, fontSize, fontWeight, color }: any) => {
|
|
1571
|
+
// const cardData = useCardData();
|
|
1572
|
+
// if (!cardData) return null;
|
|
1573
|
+
// return (
|
|
1574
|
+
// <Text
|
|
1575
|
+
// fontSize={fontSize || cardData.headerTitle.fontSize}
|
|
1576
|
+
// fontWeight={fontWeight || cardData.headerTitle.fontWeight}
|
|
1577
|
+
// color={color || cardData.headerTitle.color}
|
|
1578
|
+
// >
|
|
1579
|
+
// {children || cardData.headerTitle.text}
|
|
1580
|
+
// </Text>
|
|
1581
|
+
// );
|
|
1582
|
+
// };
|
|
1583
|
+
// const CardHeaderTimer = ({ children, fontSize, fontFamily, color }: any) => {
|
|
1584
|
+
// const cardData = useCardData();
|
|
1585
|
+
// if (!cardData) return null;
|
|
1586
|
+
// return (
|
|
1587
|
+
// <Text
|
|
1588
|
+
// fontSize={fontSize || cardData.headerTimer.fontSize}
|
|
1589
|
+
// fontFamily={fontFamily || cardData.headerTimer.fontFamily}
|
|
1590
|
+
// color={color || cardData.headerTimer.color}
|
|
1591
|
+
// >
|
|
1592
|
+
// {children || cardData.headerTimer.text}
|
|
1593
|
+
// </Text>
|
|
1594
|
+
// );
|
|
1595
|
+
// };
|
|
1596
|
+
// // Card Body
|
|
1597
|
+
// const CardBody = ({ children, padding }: any) => {
|
|
1598
|
+
// const cardData = useCardData();
|
|
1599
|
+
// if (!cardData) return null;
|
|
1600
|
+
// return <Box p={padding || cardData.body.padding}>{children}</Box>;
|
|
1601
|
+
// };
|
|
1602
|
+
// const CardBodyDriver = ({
|
|
1603
|
+
// children,
|
|
1604
|
+
// backgroundColor,
|
|
1605
|
+
// borderRadius,
|
|
1606
|
+
// padding,
|
|
1607
|
+
// }: any) => {
|
|
1608
|
+
// const cardData = useCardData();
|
|
1609
|
+
// if (!cardData) return null;
|
|
1610
|
+
// return (
|
|
1611
|
+
// <Flex
|
|
1612
|
+
// bg={backgroundColor || cardData.bodyDriver.backgroundColor}
|
|
1613
|
+
// borderRadius={borderRadius || cardData.bodyDriver.borderRadius}
|
|
1614
|
+
// p={padding || cardData.bodyDriver.padding}
|
|
1615
|
+
// display={cardData.bodyDriver.display}
|
|
1616
|
+
// alignItems={cardData.bodyDriver.alignItems}
|
|
1617
|
+
// gap={cardData.bodyDriver.gap}
|
|
1618
|
+
// >
|
|
1619
|
+
// {children}
|
|
1620
|
+
// </Flex>
|
|
1621
|
+
// );
|
|
1622
|
+
// };
|
|
1623
|
+
// const CardBodyImage = ({ src, alt, width, height, borderRadius }: any) => {
|
|
1624
|
+
// const cardData = useCardData();
|
|
1625
|
+
// if (!cardData) return null;
|
|
1626
|
+
// return (
|
|
1627
|
+
// <Image
|
|
1628
|
+
// src={src || cardData.bodyImage.src}
|
|
1629
|
+
// alt={alt || cardData.bodyImage.alt}
|
|
1630
|
+
// width={width || cardData.bodyImage.width}
|
|
1631
|
+
// height={height || cardData.bodyImage.height}
|
|
1632
|
+
// borderRadius={borderRadius || cardData.bodyImage.borderRadius}
|
|
1633
|
+
// objectFit={cardData.bodyImage.objectFit as any}
|
|
1634
|
+
// />
|
|
1635
|
+
// );
|
|
1636
|
+
// };
|
|
1637
|
+
// const CardBodyInfo = ({ children, flexGrow }: any) => {
|
|
1638
|
+
// const cardData = useCardData();
|
|
1639
|
+
// if (!cardData) return null;
|
|
1640
|
+
// return <Box flex={flexGrow || cardData.bodyInfo.flexGrow}>{children}</Box>;
|
|
1641
|
+
// };
|
|
1642
|
+
// const CardBodyName = ({ children, fontWeight, color }: any) => {
|
|
1643
|
+
// const cardData = useCardData();
|
|
1644
|
+
// if (!cardData) return null;
|
|
1645
|
+
// return (
|
|
1646
|
+
// <Text
|
|
1647
|
+
// fontWeight={fontWeight || cardData.bodyName.fontWeight}
|
|
1648
|
+
// color={color || cardData.bodyName.color}
|
|
1649
|
+
// >
|
|
1650
|
+
// {children || cardData.bodyName.text}
|
|
1651
|
+
// </Text>
|
|
1652
|
+
// );
|
|
1653
|
+
// };
|
|
1654
|
+
// const CardBodySpan = ({ children, fontSize, color }: any) => {
|
|
1655
|
+
// const cardData = useCardData();
|
|
1656
|
+
// if (!cardData) return null;
|
|
1657
|
+
// return (
|
|
1658
|
+
// <Text
|
|
1659
|
+
// fontSize={fontSize || cardData.bodySpan.fontSize}
|
|
1660
|
+
// color={color || cardData.bodySpan.color}
|
|
1661
|
+
// >
|
|
1662
|
+
// {children || cardData.bodySpan.text}
|
|
1663
|
+
// </Text>
|
|
1664
|
+
// );
|
|
1665
|
+
// };
|
|
1666
|
+
// const CardBodyActions = ({ children }: any) => {
|
|
1667
|
+
// const cardData = useCardData();
|
|
1668
|
+
// if (!cardData) return null;
|
|
1669
|
+
// return <Flex gap={cardData.bodyActions.gap}>{children}</Flex>;
|
|
1670
|
+
// };
|
|
1671
|
+
// // Action Button Components - FIXED to match design system exactly
|
|
1672
|
+
// const CardBodyActionButton = ({
|
|
1673
|
+
// children,
|
|
1674
|
+
// variant = "outline",
|
|
1675
|
+
// backgroundColor,
|
|
1676
|
+
// color,
|
|
1677
|
+
// hoverBackgroundColor,
|
|
1678
|
+
// border,
|
|
1679
|
+
// padding = 2,
|
|
1680
|
+
// borderRadius = "full",
|
|
1681
|
+
// onClick,
|
|
1682
|
+
// }: any) => {
|
|
1683
|
+
// const cardData = useCardData();
|
|
1684
|
+
// if (!cardData) return null;
|
|
1685
|
+
// // Use custom props if provided, otherwise use variant-based styles
|
|
1686
|
+
// const getButtonStyles = () => {
|
|
1687
|
+
// // If custom props are provided, use them
|
|
1688
|
+
// if (backgroundColor || color || hoverBackgroundColor || border) {
|
|
1689
|
+
// return {
|
|
1690
|
+
// bg: backgroundColor,
|
|
1691
|
+
// color: color,
|
|
1692
|
+
// border: border,
|
|
1693
|
+
// borderColor: border === "none" ? "transparent" : "gray.300",
|
|
1694
|
+
// _hover: {
|
|
1695
|
+
// bg: hoverBackgroundColor,
|
|
1696
|
+
// },
|
|
1697
|
+
// };
|
|
1698
|
+
// }
|
|
1699
|
+
// // Otherwise use variant-based styles
|
|
1700
|
+
// if (variant === "solid") {
|
|
1701
|
+
// return {
|
|
1702
|
+
// bg: "#1f2937", // gray-800
|
|
1703
|
+
// color: "white",
|
|
1704
|
+
// border: "none",
|
|
1705
|
+
// _hover: {
|
|
1706
|
+
// bg: "#374151", // gray-700
|
|
1707
|
+
// },
|
|
1708
|
+
// };
|
|
1709
|
+
// } else {
|
|
1710
|
+
// return {
|
|
1711
|
+
// bg: "transparent",
|
|
1712
|
+
// color: "gray.600",
|
|
1713
|
+
// border: "1px solid",
|
|
1714
|
+
// borderColor: "gray.300",
|
|
1715
|
+
// _hover: {
|
|
1716
|
+
// bg: "gray.100",
|
|
1717
|
+
// },
|
|
1718
|
+
// };
|
|
1719
|
+
// }
|
|
1720
|
+
// };
|
|
1721
|
+
// const styles = getButtonStyles();
|
|
1722
|
+
// return (
|
|
1723
|
+
// <Button
|
|
1724
|
+
// p={padding}
|
|
1725
|
+
// borderRadius={borderRadius}
|
|
1726
|
+
// bg={styles.bg}
|
|
1727
|
+
// color={styles.color}
|
|
1728
|
+
// border={styles.border}
|
|
1729
|
+
// borderColor={styles.borderColor}
|
|
1730
|
+
// transition="all 0.2s"
|
|
1731
|
+
// _hover={styles._hover}
|
|
1732
|
+
// onClick={onClick}
|
|
1733
|
+
// minW="auto"
|
|
1734
|
+
// h="auto"
|
|
1735
|
+
// display="flex"
|
|
1736
|
+
// alignItems="center"
|
|
1737
|
+
// justifyContent="center"
|
|
1738
|
+
// >
|
|
1739
|
+
// {children}
|
|
1740
|
+
// </Button>
|
|
1741
|
+
// );
|
|
1742
|
+
// };
|
|
1743
|
+
// const CardBodyActionIcon = ({
|
|
1744
|
+
// children,
|
|
1745
|
+
// width = 5,
|
|
1746
|
+
// height = 5,
|
|
1747
|
+
// color,
|
|
1748
|
+
// }: any) => {
|
|
1749
|
+
// return (
|
|
1750
|
+
// <Box
|
|
1751
|
+
// width={width}
|
|
1752
|
+
// height={height}
|
|
1753
|
+
// color={color}
|
|
1754
|
+
// display="flex"
|
|
1755
|
+
// alignItems="center"
|
|
1756
|
+
// justifyContent="center"
|
|
1757
|
+
// >
|
|
1758
|
+
// {children}
|
|
1759
|
+
// </Box>
|
|
1760
|
+
// );
|
|
1761
|
+
// };
|
|
1762
|
+
// // Card Route
|
|
1763
|
+
// const CardRoute = ({ children, paddingX, paddingBottom }: any) => {
|
|
1764
|
+
// const cardData = useCardData();
|
|
1765
|
+
// if (!cardData) return null;
|
|
1766
|
+
// return (
|
|
1767
|
+
// <Box
|
|
1768
|
+
// px={paddingX || cardData.route.paddingX}
|
|
1769
|
+
// pb={paddingBottom || cardData.route.paddingBottom}
|
|
1770
|
+
// >
|
|
1771
|
+
// {children}
|
|
1772
|
+
// </Box>
|
|
1773
|
+
// );
|
|
1774
|
+
// };
|
|
1775
|
+
// const CardRouteContainer = ({ children, gap }: any) => {
|
|
1776
|
+
// const cardData = useCardData();
|
|
1777
|
+
// if (!cardData) return null;
|
|
1778
|
+
// return (
|
|
1779
|
+
// <VStack spacing={gap || cardData.routeContainer.gap} align="stretch">
|
|
1780
|
+
// {children}
|
|
1781
|
+
// </VStack>
|
|
1782
|
+
// );
|
|
1783
|
+
// };
|
|
1784
|
+
// // FIXED: CardRouteItem with proper spacing to match design system
|
|
1785
|
+
// // const CardRouteItem = ({
|
|
1786
|
+
// // children,
|
|
1787
|
+
// // icon,
|
|
1788
|
+
// // iconBackgroundColor = "blue.50",
|
|
1789
|
+
// // title,
|
|
1790
|
+
// // subtitle,
|
|
1791
|
+
// // }: {
|
|
1792
|
+
// // children?: React.ReactNode;
|
|
1793
|
+
// // icon?: React.ReactNode;
|
|
1794
|
+
// // iconBackgroundColor?: string;
|
|
1795
|
+
// // title?: string;
|
|
1796
|
+
// // subtitle?: string;
|
|
1797
|
+
// // }) => {
|
|
1798
|
+
// // return (
|
|
1799
|
+
// // <HStack align="flex-start" spacing={4}>
|
|
1800
|
+
// // <Box mt={0.5} flexShrink={0}>
|
|
1801
|
+
// // <Flex
|
|
1802
|
+
// // width={8}
|
|
1803
|
+
// // height={8}
|
|
1804
|
+
// // borderRadius="full"
|
|
1805
|
+
// // backgroundColor={iconBackgroundColor}
|
|
1806
|
+
// // align="center"
|
|
1807
|
+
// // justify="center"
|
|
1808
|
+
// // >
|
|
1809
|
+
// // {icon}
|
|
1810
|
+
// // </Flex>
|
|
1811
|
+
// // </Box>
|
|
1812
|
+
// // <Box flex="1">
|
|
1813
|
+
// // {children || (
|
|
1814
|
+
// // <>
|
|
1815
|
+
// // <Text
|
|
1816
|
+
// // fontWeight="semibold"
|
|
1817
|
+
// // color="gray.900"
|
|
1818
|
+
// // fontSize="md"
|
|
1819
|
+
// // lineHeight="short"
|
|
1820
|
+
// // mb={1} // Added margin bottom for proper spacing
|
|
1821
|
+
// // >
|
|
1822
|
+
// // {title}
|
|
1823
|
+
// // </Text>
|
|
1824
|
+
// // <Text fontSize="sm" color="gray.500" lineHeight="short">
|
|
1825
|
+
// // {subtitle}
|
|
1826
|
+
// // </Text>
|
|
1827
|
+
// // </>
|
|
1828
|
+
// // )}
|
|
1829
|
+
// // </Box>
|
|
1830
|
+
// // </HStack>
|
|
1831
|
+
// // );
|
|
1832
|
+
// // };
|
|
1833
|
+
// const CardRouteItem = ({
|
|
1834
|
+
// children,
|
|
1835
|
+
// icon,
|
|
1836
|
+
// iconBackgroundColor = "blue.50",
|
|
1837
|
+
// title,
|
|
1838
|
+
// subtitle,
|
|
1839
|
+
// }: {
|
|
1840
|
+
// children?: React.ReactNode;
|
|
1841
|
+
// icon?: React.ReactNode;
|
|
1842
|
+
// iconBackgroundColor?: string;
|
|
1843
|
+
// title?: string;
|
|
1844
|
+
// subtitle?: string;
|
|
1845
|
+
// }) => {
|
|
1846
|
+
// return (
|
|
1847
|
+
// <HStack align="flex-start" spacing={4}>
|
|
1848
|
+
// <Box mt={0.5} flexShrink={0}>
|
|
1849
|
+
// <Flex
|
|
1850
|
+
// width={8}
|
|
1851
|
+
// height={8}
|
|
1852
|
+
// borderRadius="full"
|
|
1853
|
+
// backgroundColor={iconBackgroundColor}
|
|
1854
|
+
// align="center"
|
|
1855
|
+
// justify="center"
|
|
1856
|
+
// >
|
|
1857
|
+
// {icon}
|
|
1858
|
+
// </Flex>
|
|
1859
|
+
// </Box>
|
|
1860
|
+
// <Box flex="1">
|
|
1861
|
+
// {children || (
|
|
1862
|
+
// <>
|
|
1863
|
+
// <Text
|
|
1864
|
+
// fontWeight="semibold"
|
|
1865
|
+
// color="gray.900"
|
|
1866
|
+
// fontSize="md"
|
|
1867
|
+
// lineHeight="short"
|
|
1868
|
+
// mb={1}
|
|
1869
|
+
// >
|
|
1870
|
+
// {title}
|
|
1871
|
+
// </Text>
|
|
1872
|
+
// <Text fontSize="sm" color="gray.500" lineHeight="short">
|
|
1873
|
+
// {subtitle}
|
|
1874
|
+
// </Text>
|
|
1875
|
+
// </>
|
|
1876
|
+
// )}
|
|
1877
|
+
// </Box>
|
|
1878
|
+
// </HStack>
|
|
1879
|
+
// );
|
|
1880
|
+
// };
|
|
1881
|
+
// // Card Payment
|
|
1882
|
+
// const CardPayment = ({ children, paddingX, paddingBottom }: any) => {
|
|
1883
|
+
// const cardData = useCardData();
|
|
1884
|
+
// if (!cardData) return null;
|
|
1885
|
+
// return (
|
|
1886
|
+
// <Box
|
|
1887
|
+
// px={paddingX || cardData.payment.paddingX}
|
|
1888
|
+
// pb={paddingBottom || cardData.payment.paddingBottom}
|
|
1889
|
+
// >
|
|
1890
|
+
// {children}
|
|
1891
|
+
// </Box>
|
|
1892
|
+
// );
|
|
1893
|
+
// };
|
|
1894
|
+
// const CardPaymentContainer = ({
|
|
1895
|
+
// children,
|
|
1896
|
+
// backgroundColor,
|
|
1897
|
+
// borderRadius,
|
|
1898
|
+
// padding,
|
|
1899
|
+
// }: any) => {
|
|
1900
|
+
// const cardData = useCardData();
|
|
1901
|
+
// if (!cardData) return null;
|
|
1902
|
+
// return (
|
|
1903
|
+
// <Box
|
|
1904
|
+
// bg={backgroundColor || cardData.paymentContainer.backgroundColor}
|
|
1905
|
+
// borderRadius={borderRadius || cardData.paymentContainer.borderRadius}
|
|
1906
|
+
// p={padding || cardData.paymentContainer.padding}
|
|
1907
|
+
// >
|
|
1908
|
+
// {children}
|
|
1909
|
+
// </Box>
|
|
1910
|
+
// );
|
|
1911
|
+
// };
|
|
1912
|
+
// const CardPaymentContent = ({ children }: any) => {
|
|
1913
|
+
// return (
|
|
1914
|
+
// <Flex align="center" gap={4}>
|
|
1915
|
+
// {children}
|
|
1916
|
+
// </Flex>
|
|
1917
|
+
// );
|
|
1918
|
+
// };
|
|
1919
|
+
// const CardPaymentIconContainer = ({
|
|
1920
|
+
// children,
|
|
1921
|
+
// width = 12,
|
|
1922
|
+
// height = 12,
|
|
1923
|
+
// backgroundColor = "gray.800",
|
|
1924
|
+
// }: any) => {
|
|
1925
|
+
// return (
|
|
1926
|
+
// <Flex
|
|
1927
|
+
// width={width}
|
|
1928
|
+
// height={height}
|
|
1929
|
+
// borderRadius="full"
|
|
1930
|
+
// backgroundColor={backgroundColor}
|
|
1931
|
+
// align="center"
|
|
1932
|
+
// justify="center"
|
|
1933
|
+
// >
|
|
1934
|
+
// {children}
|
|
1935
|
+
// </Flex>
|
|
1936
|
+
// );
|
|
1937
|
+
// };
|
|
1938
|
+
// const CardPaymentDetails = ({ children }: any) => {
|
|
1939
|
+
// return <Box>{children}</Box>;
|
|
1940
|
+
// };
|
|
1941
|
+
// const CardNumber = ({ children, color, fontWeight, fontSize }: any) => {
|
|
1942
|
+
// const cardData = useCardData();
|
|
1943
|
+
// if (!cardData) return null;
|
|
1944
|
+
// return (
|
|
1945
|
+
// <Text
|
|
1946
|
+
// color={color || cardData.cardNumber.color}
|
|
1947
|
+
// fontWeight={fontWeight || cardData.cardNumber.fontWeight}
|
|
1948
|
+
// fontSize={fontSize || cardData.cardNumber.fontSize}
|
|
1949
|
+
// >
|
|
1950
|
+
// {children || cardData.cardNumber.text}
|
|
1951
|
+
// </Text>
|
|
1952
|
+
// );
|
|
1953
|
+
// };
|
|
1954
|
+
// const CardType = ({ children, fontSize, color }: any) => {
|
|
1955
|
+
// const cardData = useCardData();
|
|
1956
|
+
// if (!cardData) return null;
|
|
1957
|
+
// return (
|
|
1958
|
+
// <Text
|
|
1959
|
+
// fontSize={fontSize || cardData.cardType.fontSize}
|
|
1960
|
+
// color={color || cardData.cardType.color}
|
|
1961
|
+
// >
|
|
1962
|
+
// {children || cardData.cardType.text}
|
|
1963
|
+
// </Text>
|
|
1964
|
+
// );
|
|
1965
|
+
// };
|
|
1966
|
+
// // Card Total Section
|
|
1967
|
+
// const CardTotalSection = ({
|
|
1968
|
+
// children,
|
|
1969
|
+
// paddingX,
|
|
1970
|
+
// paddingY,
|
|
1971
|
+
// borderTop = "1px",
|
|
1972
|
+
// borderColor = "gray.200",
|
|
1973
|
+
// }: any) => {
|
|
1974
|
+
// const cardData = useCardData();
|
|
1975
|
+
// if (!cardData) return null;
|
|
1976
|
+
// return (
|
|
1977
|
+
// <Box
|
|
1978
|
+
// px={paddingX || cardData.totalSection.paddingX}
|
|
1979
|
+
// py={paddingY || cardData.totalSection.paddingY}
|
|
1980
|
+
// borderTop={borderTop}
|
|
1981
|
+
// borderColor={borderColor}
|
|
1982
|
+
// >
|
|
1983
|
+
// {children}
|
|
1984
|
+
// </Box>
|
|
1985
|
+
// );
|
|
1986
|
+
// };
|
|
1987
|
+
// const CardTotalContent = ({ children }: any) => {
|
|
1988
|
+
// return (
|
|
1989
|
+
// <Flex justify="space-between" align="center">
|
|
1990
|
+
// {children}
|
|
1991
|
+
// </Flex>
|
|
1992
|
+
// );
|
|
1993
|
+
// };
|
|
1994
|
+
// const CardTotalLabel = ({ children, color, fontWeight }: any) => {
|
|
1995
|
+
// const cardData = useCardData();
|
|
1996
|
+
// if (!cardData) return null;
|
|
1997
|
+
// return (
|
|
1998
|
+
// <Text
|
|
1999
|
+
// color={color || cardData.totalLabel.color}
|
|
2000
|
+
// fontWeight={fontWeight || cardData.totalLabel.fontWeight}
|
|
2001
|
+
// >
|
|
2002
|
+
// {children || cardData.totalLabel.text}
|
|
2003
|
+
// </Text>
|
|
2004
|
+
// );
|
|
2005
|
+
// };
|
|
2006
|
+
// const CardTotalAmount = ({ children, fontSize, fontWeight, color }: any) => {
|
|
2007
|
+
// const cardData = useCardData();
|
|
2008
|
+
// if (!cardData) return null;
|
|
2009
|
+
// return (
|
|
2010
|
+
// <Text
|
|
2011
|
+
// fontSize={fontSize || cardData.totalAmount.fontSize}
|
|
2012
|
+
// fontWeight={fontWeight || cardData.totalAmount.fontWeight}
|
|
2013
|
+
// color={color || cardData.totalAmount.color}
|
|
2014
|
+
// >
|
|
2015
|
+
// {children || cardData.totalAmount.text}
|
|
2016
|
+
// </Text>
|
|
2017
|
+
// );
|
|
2018
|
+
// };
|
|
2019
|
+
// // Main Card component
|
|
2020
|
+
// const Card = ({ children, width, maxWidth, fontFamily }: any) => {
|
|
2021
|
+
// const cardData = useCardData();
|
|
2022
|
+
// if (!cardData) return null;
|
|
2023
|
+
// return (
|
|
2024
|
+
// <Box
|
|
2025
|
+
// width={width || cardData.card.width}
|
|
2026
|
+
// maxWidth={maxWidth || cardData.card.maxWidth}
|
|
2027
|
+
// fontFamily={fontFamily || cardData.card.fontFamily}
|
|
2028
|
+
// >
|
|
2029
|
+
// {children}
|
|
2030
|
+
// </Box>
|
|
2031
|
+
// );
|
|
2032
|
+
// };
|
|
2033
|
+
// // Attach all subcomponents to Card
|
|
2034
|
+
// Card.Container = CardContainer;
|
|
2035
|
+
// Card.Header = CardHeader;
|
|
2036
|
+
// Card.HeaderContent = CardHeaderContent;
|
|
2037
|
+
// Card.HeaderTitle = CardHeaderTitle;
|
|
2038
|
+
// Card.HeaderTimer = CardHeaderTimer;
|
|
2039
|
+
// Card.Body = CardBody;
|
|
2040
|
+
// Card.BodyDriver = CardBodyDriver;
|
|
2041
|
+
// Card.BodyImage = CardBodyImage;
|
|
2042
|
+
// Card.BodyInfo = CardBodyInfo;
|
|
2043
|
+
// Card.BodyName = CardBodyName;
|
|
2044
|
+
// Card.BodySpan = CardBodySpan;
|
|
2045
|
+
// Card.BodyActions = CardBodyActions;
|
|
2046
|
+
// Card.BodyActionButton = CardBodyActionButton;
|
|
2047
|
+
// Card.BodyActionIcon = CardBodyActionIcon;
|
|
2048
|
+
// Card.Route = CardRoute;
|
|
2049
|
+
// Card.RouteContainer = CardRouteContainer;
|
|
2050
|
+
// Card.RouteItem = CardRouteItem;
|
|
2051
|
+
// Card.Payment = CardPayment;
|
|
2052
|
+
// Card.PaymentContainer = CardPaymentContainer;
|
|
2053
|
+
// Card.PaymentContent = CardPaymentContent;
|
|
2054
|
+
// Card.PaymentIconContainer = CardPaymentIconContainer;
|
|
2055
|
+
// Card.PaymentDetails = CardPaymentDetails;
|
|
2056
|
+
// Card.Number = CardNumber;
|
|
2057
|
+
// Card.Type = CardType;
|
|
2058
|
+
// Card.TotalSection = CardTotalSection;
|
|
2059
|
+
// Card.TotalContent = CardTotalContent;
|
|
2060
|
+
// Card.TotalLabel = CardTotalLabel;
|
|
2061
|
+
// Card.TotalAmount = CardTotalAmount;
|
|
2062
|
+
// export default Card;
|
|
2063
|
+
///ddeeeeeeeeeeppeeepeppepepepepeep
|
|
2064
|
+
// components/Card/Card.tsx
|
|
2065
|
+
var _excluded$1 = ["children", "width", "maxWidth"],
|
|
2066
|
+
_excluded2$1 = ["children", "padding"],
|
|
2067
|
+
_excluded3 = ["children"],
|
|
2068
|
+
_excluded4 = ["children", "fontSize", "fontWeight", "color"],
|
|
2069
|
+
_excluded5 = ["children", "fontSize", "fontFamily", "color"],
|
|
2070
|
+
_excluded6 = ["children", "padding"],
|
|
2071
|
+
_excluded7 = ["children", "backgroundColor", "borderRadius", "padding"],
|
|
2072
|
+
_excluded8 = ["src", "alt", "width", "height", "borderRadius"],
|
|
2073
|
+
_excluded9 = ["children", "flexGrow"],
|
|
2074
|
+
_excluded0 = ["children", "fontWeight", "color"],
|
|
2075
|
+
_excluded1 = ["children", "fontSize", "color"],
|
|
2076
|
+
_excluded10 = ["children"],
|
|
2077
|
+
_excluded11 = ["children", "variant", "backgroundColor", "color", "hoverBackgroundColor", "border", "padding", "borderRadius", "onClick"],
|
|
2078
|
+
_excluded12 = ["children", "width", "height", "color"],
|
|
2079
|
+
_excluded13 = ["children", "paddingX", "paddingBottom"],
|
|
2080
|
+
_excluded14 = ["children", "gap"],
|
|
2081
|
+
_excluded15 = ["children", "icon", "iconBackgroundColor", "title", "subtitle"],
|
|
2082
|
+
_excluded16 = ["children", "paddingX", "paddingBottom"],
|
|
2083
|
+
_excluded17 = ["children", "backgroundColor", "borderRadius", "padding"],
|
|
2084
|
+
_excluded18 = ["children"],
|
|
2085
|
+
_excluded19 = ["children", "width", "height", "backgroundColor"],
|
|
2086
|
+
_excluded20 = ["children"],
|
|
2087
|
+
_excluded21 = ["children", "color", "fontWeight", "fontSize"],
|
|
2088
|
+
_excluded22 = ["children", "fontSize", "color"],
|
|
2089
|
+
_excluded23 = ["children", "paddingX", "paddingY", "borderTop", "borderColor"],
|
|
2090
|
+
_excluded24 = ["children"],
|
|
2091
|
+
_excluded25 = ["children", "color", "fontWeight"],
|
|
2092
|
+
_excluded26 = ["children", "fontSize", "fontWeight", "color"],
|
|
2093
|
+
_excluded27 = ["children", "width", "maxWidth", "fontFamily"];
|
|
2094
|
+
// Helper function to safely access nested properties
|
|
2095
|
+
var safeGet = function safeGet(obj, path) {
|
|
2096
|
+
var defaultValue = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
|
|
2097
|
+
return path.split('.').reduce(function (acc, key) {
|
|
2098
|
+
if (acc && _typeof(acc) === 'object' && key in acc) {
|
|
2099
|
+
return acc[key];
|
|
2100
|
+
}
|
|
2101
|
+
return defaultValue;
|
|
2102
|
+
}, obj);
|
|
2103
|
+
};
|
|
2104
|
+
// Card Container
|
|
2105
|
+
var CardContainer = function CardContainer(_ref) {
|
|
2106
|
+
var children = _ref.children,
|
|
2107
|
+
width = _ref.width,
|
|
2108
|
+
maxWidth = _ref.maxWidth,
|
|
2109
|
+
props = _objectWithoutProperties(_ref, _excluded$1);
|
|
2110
|
+
var _useCardData = useCardData(),
|
|
2111
|
+
cardData = _useCardData.data;
|
|
2112
|
+
if (!cardData) return null;
|
|
2113
|
+
return jsxRuntime.jsx(react.Box, _objectSpread2(_objectSpread2({
|
|
2114
|
+
width: width || safeGet(cardData, 'container.width', '100%'),
|
|
2115
|
+
maxWidth: maxWidth || safeGet(cardData, 'container.maxWidth', '32rem'),
|
|
2116
|
+
mx: "auto",
|
|
2117
|
+
bg: safeGet(cardData, 'container.backgroundColor', '#ffffff'),
|
|
2118
|
+
borderRadius: safeGet(cardData, 'container.borderRadius', '1.5rem'),
|
|
2119
|
+
boxShadow: safeGet(cardData, 'container.boxShadow', '0 10px 15px -3px rgba(0, 0, 0, 0.1)'),
|
|
2120
|
+
overflow: safeGet(cardData, 'container.overflow', 'hidden')
|
|
2121
|
+
}, props), {}, {
|
|
2122
|
+
children: children
|
|
2123
|
+
}));
|
|
2124
|
+
};
|
|
2125
|
+
// Card Header
|
|
2126
|
+
var CardHeader = function CardHeader(_ref2) {
|
|
2127
|
+
var children = _ref2.children,
|
|
2128
|
+
padding = _ref2.padding,
|
|
2129
|
+
props = _objectWithoutProperties(_ref2, _excluded2$1);
|
|
2130
|
+
var _useCardData2 = useCardData(),
|
|
2131
|
+
cardData = _useCardData2.data;
|
|
2132
|
+
if (!cardData) return null;
|
|
2133
|
+
return jsxRuntime.jsx(react.Box, _objectSpread2(_objectSpread2({
|
|
2134
|
+
p: padding || safeGet(cardData, 'header.padding', '1.5rem'),
|
|
2135
|
+
borderBottom: "".concat(safeGet(cardData, 'header.borderBottom', '1px'), " solid ").concat(safeGet(cardData, 'header.borderColor', '#e5e7eb'))
|
|
2136
|
+
}, props), {}, {
|
|
2137
|
+
children: children
|
|
2138
|
+
}));
|
|
2139
|
+
};
|
|
2140
|
+
var CardHeaderContent = function CardHeaderContent(_ref3) {
|
|
2141
|
+
var children = _ref3.children,
|
|
2142
|
+
props = _objectWithoutProperties(_ref3, _excluded3);
|
|
2143
|
+
var _useCardData3 = useCardData(),
|
|
2144
|
+
cardData = _useCardData3.data;
|
|
2145
|
+
if (!cardData) return null;
|
|
2146
|
+
return jsxRuntime.jsx(react.Flex, _objectSpread2(_objectSpread2({
|
|
2147
|
+
display: safeGet(cardData, 'headerContent.display', 'flex'),
|
|
2148
|
+
justifyContent: safeGet(cardData, 'headerContent.justifyContent', 'space-between'),
|
|
2149
|
+
alignItems: safeGet(cardData, 'headerContent.alignItems', 'center')
|
|
2150
|
+
}, props), {}, {
|
|
2151
|
+
children: children
|
|
2152
|
+
}));
|
|
2153
|
+
};
|
|
2154
|
+
var CardHeaderTitle = function CardHeaderTitle(_ref4) {
|
|
2155
|
+
var children = _ref4.children,
|
|
2156
|
+
fontSize = _ref4.fontSize,
|
|
2157
|
+
fontWeight = _ref4.fontWeight,
|
|
2158
|
+
color = _ref4.color,
|
|
2159
|
+
props = _objectWithoutProperties(_ref4, _excluded4);
|
|
2160
|
+
var _useCardData4 = useCardData(),
|
|
2161
|
+
cardData = _useCardData4.data;
|
|
2162
|
+
if (!cardData) return null;
|
|
2163
|
+
return jsxRuntime.jsx(react.Text, _objectSpread2(_objectSpread2({
|
|
2164
|
+
fontSize: fontSize || safeGet(cardData, 'headerTitle.fontSize', '1.25rem'),
|
|
2165
|
+
fontWeight: fontWeight || safeGet(cardData, 'headerTitle.fontWeight', '600'),
|
|
2166
|
+
color: color || safeGet(cardData, 'headerTitle.color', '#111827')
|
|
2167
|
+
}, props), {}, {
|
|
2168
|
+
children: children || safeGet(cardData, 'headerTitle.text', 'Arrived in')
|
|
2169
|
+
}));
|
|
2170
|
+
};
|
|
2171
|
+
var CardHeaderTimer = function CardHeaderTimer(_ref5) {
|
|
2172
|
+
var children = _ref5.children,
|
|
2173
|
+
fontSize = _ref5.fontSize,
|
|
2174
|
+
fontFamily = _ref5.fontFamily,
|
|
2175
|
+
color = _ref5.color,
|
|
2176
|
+
props = _objectWithoutProperties(_ref5, _excluded5);
|
|
2177
|
+
var _useCardData5 = useCardData(),
|
|
2178
|
+
cardData = _useCardData5.data;
|
|
2179
|
+
if (!cardData) return null;
|
|
2180
|
+
return jsxRuntime.jsx(react.Text, _objectSpread2(_objectSpread2({
|
|
2181
|
+
fontSize: fontSize || safeGet(cardData, 'headerTimer.fontSize', '1.25rem'),
|
|
2182
|
+
fontFamily: fontFamily || safeGet(cardData, 'headerTimer.fontFamily', 'monospace'),
|
|
2183
|
+
color: color || safeGet(cardData, 'headerTimer.color', '#1f2937')
|
|
2184
|
+
}, props), {}, {
|
|
2185
|
+
children: children || safeGet(cardData, 'headerTimer.text', '00:05:20')
|
|
2186
|
+
}));
|
|
2187
|
+
};
|
|
2188
|
+
// Card Body
|
|
2189
|
+
var CardBody = function CardBody(_ref6) {
|
|
2190
|
+
var children = _ref6.children,
|
|
2191
|
+
padding = _ref6.padding,
|
|
2192
|
+
props = _objectWithoutProperties(_ref6, _excluded6);
|
|
2193
|
+
var _useCardData6 = useCardData(),
|
|
2194
|
+
cardData = _useCardData6.data;
|
|
2195
|
+
if (!cardData) return null;
|
|
2196
|
+
return jsxRuntime.jsx(react.Box, _objectSpread2(_objectSpread2({
|
|
2197
|
+
p: padding || safeGet(cardData, 'body.padding', '1.5rem')
|
|
2198
|
+
}, props), {}, {
|
|
2199
|
+
children: children
|
|
2200
|
+
}));
|
|
2201
|
+
};
|
|
2202
|
+
var CardBodyDriver = function CardBodyDriver(_ref7) {
|
|
2203
|
+
var children = _ref7.children,
|
|
2204
|
+
backgroundColor = _ref7.backgroundColor,
|
|
2205
|
+
borderRadius = _ref7.borderRadius,
|
|
2206
|
+
padding = _ref7.padding,
|
|
2207
|
+
props = _objectWithoutProperties(_ref7, _excluded7);
|
|
2208
|
+
var _useCardData7 = useCardData(),
|
|
2209
|
+
cardData = _useCardData7.data;
|
|
2210
|
+
if (!cardData) return null;
|
|
2211
|
+
return jsxRuntime.jsx(react.Flex, _objectSpread2(_objectSpread2({
|
|
2212
|
+
bg: backgroundColor || safeGet(cardData, 'bodyDriver.backgroundColor', '#f9fafb'),
|
|
2213
|
+
borderRadius: borderRadius || safeGet(cardData, 'bodyDriver.borderRadius', '0.75rem'),
|
|
2214
|
+
p: padding || safeGet(cardData, 'bodyDriver.padding', '1rem'),
|
|
2215
|
+
display: safeGet(cardData, 'bodyDriver.display', 'flex'),
|
|
2216
|
+
alignItems: safeGet(cardData, 'bodyDriver.alignItems', 'center'),
|
|
2217
|
+
gap: safeGet(cardData, 'bodyDriver.gap', '1rem')
|
|
2218
|
+
}, props), {}, {
|
|
2219
|
+
children: children
|
|
2220
|
+
}));
|
|
2221
|
+
};
|
|
2222
|
+
var CardBodyImage = function CardBodyImage(_ref8) {
|
|
2223
|
+
var src = _ref8.src,
|
|
2224
|
+
alt = _ref8.alt,
|
|
2225
|
+
width = _ref8.width,
|
|
2226
|
+
height = _ref8.height,
|
|
2227
|
+
borderRadius = _ref8.borderRadius,
|
|
2228
|
+
props = _objectWithoutProperties(_ref8, _excluded8);
|
|
2229
|
+
var _useCardData8 = useCardData(),
|
|
2230
|
+
cardData = _useCardData8.data;
|
|
2231
|
+
if (!cardData) return null;
|
|
2232
|
+
return jsxRuntime.jsx(react.Image, _objectSpread2({
|
|
2233
|
+
src: src || safeGet(cardData, 'bodyImage.src', 'https://plus.unsplash.com/premium_photo-1689977927774-401b12d137d6?w=900&auto=format&fit=crop&q=60&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxzZWFyY2h8OXx8bWFufGVufDB8fDB8fHww'),
|
|
2234
|
+
alt: alt || safeGet(cardData, 'bodyImage.alt', 'Driver'),
|
|
2235
|
+
width: width || safeGet(cardData, 'bodyImage.width', '3.5rem'),
|
|
2236
|
+
height: height || safeGet(cardData, 'bodyImage.height', '3.5rem'),
|
|
2237
|
+
borderRadius: borderRadius || safeGet(cardData, 'bodyImage.borderRadius', '50%'),
|
|
2238
|
+
objectFit: safeGet(cardData, 'bodyImage.objectFit', 'cover')
|
|
2239
|
+
}, props));
|
|
2240
|
+
};
|
|
2241
|
+
var CardBodyInfo = function CardBodyInfo(_ref9) {
|
|
2242
|
+
var children = _ref9.children,
|
|
2243
|
+
flexGrow = _ref9.flexGrow,
|
|
2244
|
+
props = _objectWithoutProperties(_ref9, _excluded9);
|
|
2245
|
+
var _useCardData9 = useCardData(),
|
|
2246
|
+
cardData = _useCardData9.data;
|
|
2247
|
+
if (!cardData) return null;
|
|
2248
|
+
return jsxRuntime.jsx(react.Box, _objectSpread2(_objectSpread2({
|
|
2249
|
+
flex: flexGrow || safeGet(cardData, 'bodyInfo.flexGrow', '1')
|
|
2250
|
+
}, props), {}, {
|
|
2251
|
+
children: children
|
|
2252
|
+
}));
|
|
2253
|
+
};
|
|
2254
|
+
var CardBodyName = function CardBodyName(_ref0) {
|
|
2255
|
+
var children = _ref0.children,
|
|
2256
|
+
fontWeight = _ref0.fontWeight,
|
|
2257
|
+
color = _ref0.color,
|
|
2258
|
+
props = _objectWithoutProperties(_ref0, _excluded0);
|
|
2259
|
+
var _useCardData0 = useCardData(),
|
|
2260
|
+
cardData = _useCardData0.data;
|
|
2261
|
+
if (!cardData) return null;
|
|
2262
|
+
return jsxRuntime.jsx(react.Text, _objectSpread2(_objectSpread2({
|
|
2263
|
+
fontWeight: fontWeight || safeGet(cardData, 'bodyName.fontWeight', '600'),
|
|
2264
|
+
color: color || safeGet(cardData, 'bodyName.color', '#111827')
|
|
2265
|
+
}, props), {}, {
|
|
2266
|
+
children: children || safeGet(cardData, 'bodyName.text', 'Jacob Jones')
|
|
2267
|
+
}));
|
|
2268
|
+
};
|
|
2269
|
+
var CardBodySpan = function CardBodySpan(_ref1) {
|
|
2270
|
+
var children = _ref1.children,
|
|
2271
|
+
fontSize = _ref1.fontSize,
|
|
2272
|
+
color = _ref1.color,
|
|
2273
|
+
props = _objectWithoutProperties(_ref1, _excluded1);
|
|
2274
|
+
var _useCardData1 = useCardData(),
|
|
2275
|
+
cardData = _useCardData1.data;
|
|
2276
|
+
if (!cardData) return null;
|
|
2277
|
+
return jsxRuntime.jsx(react.Text, _objectSpread2(_objectSpread2({
|
|
2278
|
+
fontSize: fontSize || safeGet(cardData, 'bodySpan.fontSize', '0.875rem'),
|
|
2279
|
+
color: color || safeGet(cardData, 'bodySpan.color', '#6b7280')
|
|
2280
|
+
}, props), {}, {
|
|
2281
|
+
children: children || safeGet(cardData, 'bodySpan.text', 'Omnitrans • SPX-8328')
|
|
2282
|
+
}));
|
|
2283
|
+
};
|
|
2284
|
+
var CardBodyActions = function CardBodyActions(_ref10) {
|
|
2285
|
+
var children = _ref10.children,
|
|
2286
|
+
props = _objectWithoutProperties(_ref10, _excluded10);
|
|
2287
|
+
var _useCardData10 = useCardData(),
|
|
2288
|
+
cardData = _useCardData10.data;
|
|
2289
|
+
if (!cardData) return null;
|
|
2290
|
+
return jsxRuntime.jsx(react.Flex, _objectSpread2(_objectSpread2({
|
|
2291
|
+
gap: safeGet(cardData, 'bodyActions.gap', '0.5rem')
|
|
2292
|
+
}, props), {}, {
|
|
2293
|
+
children: children
|
|
2294
|
+
}));
|
|
2295
|
+
};
|
|
2296
|
+
// Action Button Components
|
|
2297
|
+
var CardBodyActionButton = function CardBodyActionButton(_ref11) {
|
|
2298
|
+
var children = _ref11.children,
|
|
2299
|
+
_ref11$variant = _ref11.variant,
|
|
2300
|
+
variant = _ref11$variant === void 0 ? "outline" : _ref11$variant,
|
|
2301
|
+
backgroundColor = _ref11.backgroundColor,
|
|
2302
|
+
color = _ref11.color,
|
|
2303
|
+
hoverBackgroundColor = _ref11.hoverBackgroundColor,
|
|
2304
|
+
border = _ref11.border,
|
|
2305
|
+
_ref11$padding = _ref11.padding,
|
|
2306
|
+
padding = _ref11$padding === void 0 ? 2 : _ref11$padding,
|
|
2307
|
+
_ref11$borderRadius = _ref11.borderRadius,
|
|
2308
|
+
borderRadius = _ref11$borderRadius === void 0 ? "full" : _ref11$borderRadius,
|
|
2309
|
+
onClick = _ref11.onClick,
|
|
2310
|
+
props = _objectWithoutProperties(_ref11, _excluded11);
|
|
2311
|
+
var _useCardData11 = useCardData(),
|
|
2312
|
+
cardData = _useCardData11.data;
|
|
2313
|
+
if (!cardData) return null;
|
|
2314
|
+
// Use custom props if provided, otherwise use variant-based styles
|
|
2315
|
+
var getButtonStyles = function getButtonStyles() {
|
|
2316
|
+
// If custom props are provided, use them
|
|
2317
|
+
if (backgroundColor || color || hoverBackgroundColor || border) {
|
|
2318
|
+
return {
|
|
2319
|
+
bg: backgroundColor,
|
|
2320
|
+
color: color,
|
|
2321
|
+
border: border,
|
|
2322
|
+
borderColor: border === "none" ? "transparent" : "gray.300",
|
|
2323
|
+
_hover: {
|
|
2324
|
+
bg: hoverBackgroundColor
|
|
2325
|
+
}
|
|
2326
|
+
};
|
|
2327
|
+
}
|
|
2328
|
+
// Otherwise use variant-based styles
|
|
2329
|
+
if (variant === "solid") {
|
|
2330
|
+
return {
|
|
2331
|
+
bg: "#1f2937",
|
|
2332
|
+
// gray-800
|
|
2333
|
+
color: "white",
|
|
2334
|
+
border: "none",
|
|
2335
|
+
_hover: {
|
|
2336
|
+
bg: "#374151" // gray-700
|
|
2337
|
+
}
|
|
2338
|
+
};
|
|
2339
|
+
} else {
|
|
2340
|
+
return {
|
|
2341
|
+
bg: "transparent",
|
|
2342
|
+
color: "gray.600",
|
|
2343
|
+
border: "1px solid",
|
|
2344
|
+
borderColor: "gray.300",
|
|
2345
|
+
_hover: {
|
|
2346
|
+
bg: "gray.100"
|
|
2347
|
+
}
|
|
2348
|
+
};
|
|
2349
|
+
}
|
|
2350
|
+
};
|
|
2351
|
+
var styles = getButtonStyles();
|
|
2352
|
+
return jsxRuntime.jsx(react.Button, _objectSpread2(_objectSpread2({
|
|
2353
|
+
p: padding,
|
|
2354
|
+
borderRadius: borderRadius,
|
|
2355
|
+
bg: styles.bg,
|
|
2356
|
+
color: styles.color,
|
|
2357
|
+
border: styles.border,
|
|
2358
|
+
borderColor: styles.borderColor,
|
|
2359
|
+
transition: "all 0.2s",
|
|
2360
|
+
_hover: styles._hover,
|
|
2361
|
+
onClick: onClick,
|
|
2362
|
+
minW: "auto",
|
|
2363
|
+
h: "auto",
|
|
2364
|
+
display: "flex",
|
|
2365
|
+
alignItems: "center",
|
|
2366
|
+
justifyContent: "center"
|
|
2367
|
+
}, props), {}, {
|
|
2368
|
+
children: children
|
|
2369
|
+
}));
|
|
2370
|
+
};
|
|
2371
|
+
var CardBodyActionIcon = function CardBodyActionIcon(_ref12) {
|
|
2372
|
+
var children = _ref12.children,
|
|
2373
|
+
_ref12$width = _ref12.width,
|
|
2374
|
+
width = _ref12$width === void 0 ? 5 : _ref12$width,
|
|
2375
|
+
_ref12$height = _ref12.height,
|
|
2376
|
+
height = _ref12$height === void 0 ? 5 : _ref12$height,
|
|
2377
|
+
color = _ref12.color,
|
|
2378
|
+
props = _objectWithoutProperties(_ref12, _excluded12);
|
|
2379
|
+
return jsxRuntime.jsx(react.Box, _objectSpread2(_objectSpread2({
|
|
2380
|
+
width: width,
|
|
2381
|
+
height: height,
|
|
2382
|
+
color: color,
|
|
2383
|
+
display: "flex",
|
|
2384
|
+
alignItems: "center",
|
|
2385
|
+
justifyContent: "center"
|
|
2386
|
+
}, props), {}, {
|
|
2387
|
+
children: children
|
|
2388
|
+
}));
|
|
2389
|
+
};
|
|
2390
|
+
// Card Route
|
|
2391
|
+
var CardRoute = function CardRoute(_ref13) {
|
|
2392
|
+
var children = _ref13.children,
|
|
2393
|
+
paddingX = _ref13.paddingX,
|
|
2394
|
+
paddingBottom = _ref13.paddingBottom,
|
|
2395
|
+
props = _objectWithoutProperties(_ref13, _excluded13);
|
|
2396
|
+
var _useCardData12 = useCardData(),
|
|
2397
|
+
cardData = _useCardData12.data;
|
|
2398
|
+
if (!cardData) return null;
|
|
2399
|
+
return jsxRuntime.jsx(react.Box, _objectSpread2(_objectSpread2({
|
|
2400
|
+
px: paddingX || safeGet(cardData, 'route.paddingX', '1.5rem'),
|
|
2401
|
+
pb: paddingBottom || safeGet(cardData, 'route.paddingBottom', '1.5rem')
|
|
2402
|
+
}, props), {}, {
|
|
2403
|
+
children: children
|
|
2404
|
+
}));
|
|
2405
|
+
};
|
|
2406
|
+
var CardRouteContainer = function CardRouteContainer(_ref14) {
|
|
2407
|
+
var children = _ref14.children,
|
|
2408
|
+
gap = _ref14.gap,
|
|
2409
|
+
props = _objectWithoutProperties(_ref14, _excluded14);
|
|
2410
|
+
var _useCardData13 = useCardData(),
|
|
2411
|
+
cardData = _useCardData13.data;
|
|
2412
|
+
if (!cardData) return null;
|
|
2413
|
+
return jsxRuntime.jsx(react.VStack, _objectSpread2(_objectSpread2({
|
|
2414
|
+
spacing: gap || safeGet(cardData, 'routeContainer.gap', '1.5rem'),
|
|
2415
|
+
align: "stretch"
|
|
2416
|
+
}, props), {}, {
|
|
2417
|
+
children: children
|
|
2418
|
+
}));
|
|
2419
|
+
};
|
|
2420
|
+
var CardRouteItem = function CardRouteItem(_ref15) {
|
|
2421
|
+
var children = _ref15.children,
|
|
2422
|
+
icon = _ref15.icon,
|
|
2423
|
+
_ref15$iconBackground = _ref15.iconBackgroundColor,
|
|
2424
|
+
iconBackgroundColor = _ref15$iconBackground === void 0 ? "blue.50" : _ref15$iconBackground,
|
|
2425
|
+
title = _ref15.title,
|
|
2426
|
+
subtitle = _ref15.subtitle,
|
|
2427
|
+
props = _objectWithoutProperties(_ref15, _excluded15);
|
|
2428
|
+
var _useCardData14 = useCardData(),
|
|
2429
|
+
cardData = _useCardData14.data;
|
|
2430
|
+
if (!cardData) return null;
|
|
2431
|
+
return jsxRuntime.jsxs(react.HStack, _objectSpread2(_objectSpread2({
|
|
2432
|
+
align: "flex-start",
|
|
2433
|
+
spacing: 4
|
|
2434
|
+
}, props), {}, {
|
|
2435
|
+
children: [jsxRuntime.jsx(react.Box, {
|
|
2436
|
+
mt: 0.5,
|
|
2437
|
+
flexShrink: 0,
|
|
2438
|
+
children: jsxRuntime.jsx(react.Flex, {
|
|
2439
|
+
width: 8,
|
|
2440
|
+
height: 8,
|
|
2441
|
+
borderRadius: "full",
|
|
2442
|
+
backgroundColor: iconBackgroundColor,
|
|
2443
|
+
align: "center",
|
|
2444
|
+
justify: "center",
|
|
2445
|
+
children: icon
|
|
2446
|
+
})
|
|
2447
|
+
}), jsxRuntime.jsx(react.Box, {
|
|
2448
|
+
flex: "1",
|
|
2449
|
+
children: children || jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
2450
|
+
children: [jsxRuntime.jsx(react.Text, {
|
|
2451
|
+
fontWeight: "semibold",
|
|
2452
|
+
color: "gray.900",
|
|
2453
|
+
fontSize: "md",
|
|
2454
|
+
lineHeight: "short",
|
|
2455
|
+
mb: 1,
|
|
2456
|
+
children: title || safeGet(cardData, 'pickup.title', '456 Elm Street, Springfield')
|
|
2457
|
+
}), jsxRuntime.jsx(react.Text, {
|
|
2458
|
+
fontSize: "sm",
|
|
2459
|
+
color: "gray.500",
|
|
2460
|
+
lineHeight: "short",
|
|
2461
|
+
children: subtitle || safeGet(cardData, 'pickup.subtitle', 'Pickup point')
|
|
2462
|
+
})]
|
|
2463
|
+
})
|
|
2464
|
+
})]
|
|
2465
|
+
}));
|
|
2466
|
+
};
|
|
2467
|
+
// Card Payment
|
|
2468
|
+
var CardPayment = function CardPayment(_ref16) {
|
|
2469
|
+
var children = _ref16.children,
|
|
2470
|
+
paddingX = _ref16.paddingX,
|
|
2471
|
+
paddingBottom = _ref16.paddingBottom,
|
|
2472
|
+
props = _objectWithoutProperties(_ref16, _excluded16);
|
|
2473
|
+
var _useCardData15 = useCardData(),
|
|
2474
|
+
cardData = _useCardData15.data;
|
|
2475
|
+
if (!cardData) return null;
|
|
2476
|
+
return jsxRuntime.jsx(react.Box, _objectSpread2(_objectSpread2({
|
|
2477
|
+
px: paddingX || safeGet(cardData, 'payment.paddingX', '1.5rem'),
|
|
2478
|
+
pb: paddingBottom || safeGet(cardData, 'payment.paddingBottom', '1.5rem')
|
|
2479
|
+
}, props), {}, {
|
|
2480
|
+
children: children
|
|
2481
|
+
}));
|
|
2482
|
+
};
|
|
2483
|
+
var CardPaymentContainer = function CardPaymentContainer(_ref17) {
|
|
2484
|
+
var children = _ref17.children,
|
|
2485
|
+
backgroundColor = _ref17.backgroundColor,
|
|
2486
|
+
borderRadius = _ref17.borderRadius,
|
|
2487
|
+
padding = _ref17.padding,
|
|
2488
|
+
props = _objectWithoutProperties(_ref17, _excluded17);
|
|
2489
|
+
var _useCardData16 = useCardData(),
|
|
2490
|
+
cardData = _useCardData16.data;
|
|
2491
|
+
if (!cardData) return null;
|
|
2492
|
+
return jsxRuntime.jsx(react.Box, _objectSpread2(_objectSpread2({
|
|
2493
|
+
bg: backgroundColor || safeGet(cardData, 'paymentContainer.backgroundColor', '#111827'),
|
|
2494
|
+
borderRadius: borderRadius || safeGet(cardData, 'paymentContainer.borderRadius', '0.75rem'),
|
|
2495
|
+
p: padding || safeGet(cardData, 'paymentContainer.padding', '1rem')
|
|
2496
|
+
}, props), {}, {
|
|
2497
|
+
children: children
|
|
2498
|
+
}));
|
|
2499
|
+
};
|
|
2500
|
+
var CardPaymentContent = function CardPaymentContent(_ref18) {
|
|
2501
|
+
var children = _ref18.children,
|
|
2502
|
+
props = _objectWithoutProperties(_ref18, _excluded18);
|
|
2503
|
+
return jsxRuntime.jsx(react.Flex, _objectSpread2(_objectSpread2({
|
|
2504
|
+
align: "center",
|
|
2505
|
+
gap: 4
|
|
2506
|
+
}, props), {}, {
|
|
2507
|
+
children: children
|
|
2508
|
+
}));
|
|
2509
|
+
};
|
|
2510
|
+
var CardPaymentIconContainer = function CardPaymentIconContainer(_ref19) {
|
|
2511
|
+
var children = _ref19.children,
|
|
2512
|
+
_ref19$width = _ref19.width,
|
|
2513
|
+
width = _ref19$width === void 0 ? 12 : _ref19$width,
|
|
2514
|
+
_ref19$height = _ref19.height,
|
|
2515
|
+
height = _ref19$height === void 0 ? 12 : _ref19$height,
|
|
2516
|
+
_ref19$backgroundColo = _ref19.backgroundColor,
|
|
2517
|
+
backgroundColor = _ref19$backgroundColo === void 0 ? "gray.800" : _ref19$backgroundColo,
|
|
2518
|
+
props = _objectWithoutProperties(_ref19, _excluded19);
|
|
2519
|
+
return jsxRuntime.jsx(react.Flex, _objectSpread2(_objectSpread2({
|
|
2520
|
+
width: width,
|
|
2521
|
+
height: height,
|
|
2522
|
+
borderRadius: "full",
|
|
2523
|
+
backgroundColor: backgroundColor,
|
|
2524
|
+
align: "center",
|
|
2525
|
+
justify: "center"
|
|
2526
|
+
}, props), {}, {
|
|
2527
|
+
children: children
|
|
2528
|
+
}));
|
|
2529
|
+
};
|
|
2530
|
+
var CardPaymentDetails = function CardPaymentDetails(_ref20) {
|
|
2531
|
+
var children = _ref20.children,
|
|
2532
|
+
props = _objectWithoutProperties(_ref20, _excluded20);
|
|
2533
|
+
return jsxRuntime.jsx(react.Box, _objectSpread2(_objectSpread2({}, props), {}, {
|
|
2534
|
+
children: children
|
|
2535
|
+
}));
|
|
2536
|
+
};
|
|
2537
|
+
var CardNumber = function CardNumber(_ref21) {
|
|
2538
|
+
var children = _ref21.children,
|
|
2539
|
+
color = _ref21.color,
|
|
2540
|
+
fontWeight = _ref21.fontWeight,
|
|
2541
|
+
fontSize = _ref21.fontSize,
|
|
2542
|
+
props = _objectWithoutProperties(_ref21, _excluded21);
|
|
2543
|
+
var _useCardData17 = useCardData(),
|
|
2544
|
+
cardData = _useCardData17.data;
|
|
2545
|
+
if (!cardData) return null;
|
|
2546
|
+
return jsxRuntime.jsx(react.Text, _objectSpread2(_objectSpread2({
|
|
2547
|
+
color: color || safeGet(cardData, 'cardNumber.color', '#ffffff'),
|
|
2548
|
+
fontWeight: fontWeight || safeGet(cardData, 'cardNumber.fontWeight', '500'),
|
|
2549
|
+
fontSize: fontSize || safeGet(cardData, 'cardNumber.fontSize', '1.125rem')
|
|
2550
|
+
}, props), {}, {
|
|
2551
|
+
children: children || safeGet(cardData, 'cardNumber.text', '**** 7493')
|
|
2552
|
+
}));
|
|
2553
|
+
};
|
|
2554
|
+
var CardType = function CardType(_ref22) {
|
|
2555
|
+
var children = _ref22.children,
|
|
2556
|
+
fontSize = _ref22.fontSize,
|
|
2557
|
+
color = _ref22.color,
|
|
2558
|
+
props = _objectWithoutProperties(_ref22, _excluded22);
|
|
2559
|
+
var _useCardData18 = useCardData(),
|
|
2560
|
+
cardData = _useCardData18.data;
|
|
2561
|
+
if (!cardData) return null;
|
|
2562
|
+
return jsxRuntime.jsx(react.Text, _objectSpread2(_objectSpread2({
|
|
2563
|
+
fontSize: fontSize || safeGet(cardData, 'cardType.fontSize', '0.875rem'),
|
|
2564
|
+
color: color || safeGet(cardData, 'cardType.color', '#d1d5db')
|
|
2565
|
+
}, props), {}, {
|
|
2566
|
+
children: children || safeGet(cardData, 'cardType.text', 'Credit card')
|
|
2567
|
+
}));
|
|
2568
|
+
};
|
|
2569
|
+
// Card Total Section
|
|
2570
|
+
var CardTotalSection = function CardTotalSection(_ref23) {
|
|
2571
|
+
var children = _ref23.children,
|
|
2572
|
+
paddingX = _ref23.paddingX,
|
|
2573
|
+
paddingY = _ref23.paddingY,
|
|
2574
|
+
_ref23$borderTop = _ref23.borderTop,
|
|
2575
|
+
borderTop = _ref23$borderTop === void 0 ? "1px" : _ref23$borderTop,
|
|
2576
|
+
_ref23$borderColor = _ref23.borderColor,
|
|
2577
|
+
borderColor = _ref23$borderColor === void 0 ? "gray.200" : _ref23$borderColor,
|
|
2578
|
+
props = _objectWithoutProperties(_ref23, _excluded23);
|
|
2579
|
+
var _useCardData19 = useCardData(),
|
|
2580
|
+
cardData = _useCardData19.data;
|
|
2581
|
+
if (!cardData) return null;
|
|
2582
|
+
return jsxRuntime.jsx(react.Box, _objectSpread2(_objectSpread2({
|
|
2583
|
+
px: paddingX || safeGet(cardData, 'totalSection.paddingX', '1.5rem'),
|
|
2584
|
+
py: paddingY || safeGet(cardData, 'totalSection.paddingY', '1.5rem'),
|
|
2585
|
+
borderTop: borderTop,
|
|
2586
|
+
borderColor: borderColor
|
|
2587
|
+
}, props), {}, {
|
|
2588
|
+
children: children
|
|
2589
|
+
}));
|
|
2590
|
+
};
|
|
2591
|
+
var CardTotalContent = function CardTotalContent(_ref24) {
|
|
2592
|
+
var children = _ref24.children,
|
|
2593
|
+
props = _objectWithoutProperties(_ref24, _excluded24);
|
|
2594
|
+
return jsxRuntime.jsx(react.Flex, _objectSpread2(_objectSpread2({
|
|
2595
|
+
justify: "space-between",
|
|
2596
|
+
align: "center"
|
|
2597
|
+
}, props), {}, {
|
|
2598
|
+
children: children
|
|
2599
|
+
}));
|
|
2600
|
+
};
|
|
2601
|
+
var CardTotalLabel = function CardTotalLabel(_ref25) {
|
|
2602
|
+
var children = _ref25.children,
|
|
2603
|
+
color = _ref25.color,
|
|
2604
|
+
fontWeight = _ref25.fontWeight,
|
|
2605
|
+
props = _objectWithoutProperties(_ref25, _excluded25);
|
|
2606
|
+
var _useCardData20 = useCardData(),
|
|
2607
|
+
cardData = _useCardData20.data;
|
|
2608
|
+
if (!cardData) return null;
|
|
2609
|
+
return jsxRuntime.jsx(react.Text, _objectSpread2(_objectSpread2({
|
|
2610
|
+
color: color || safeGet(cardData, 'totalLabel.color', '#111827'),
|
|
2611
|
+
fontWeight: fontWeight || safeGet(cardData, 'totalLabel.fontWeight', '500')
|
|
2612
|
+
}, props), {}, {
|
|
2613
|
+
children: children || safeGet(cardData, 'totalLabel.text', 'Total orders')
|
|
2614
|
+
}));
|
|
2615
|
+
};
|
|
2616
|
+
var CardTotalAmount = function CardTotalAmount(_ref26) {
|
|
2617
|
+
var children = _ref26.children,
|
|
2618
|
+
fontSize = _ref26.fontSize,
|
|
2619
|
+
fontWeight = _ref26.fontWeight,
|
|
2620
|
+
color = _ref26.color,
|
|
2621
|
+
props = _objectWithoutProperties(_ref26, _excluded26);
|
|
2622
|
+
var _useCardData21 = useCardData(),
|
|
2623
|
+
cardData = _useCardData21.data;
|
|
2624
|
+
if (!cardData) return null;
|
|
2625
|
+
return jsxRuntime.jsx(react.Text, _objectSpread2(_objectSpread2({
|
|
2626
|
+
fontSize: fontSize || safeGet(cardData, 'totalAmount.fontSize', '1.25rem'),
|
|
2627
|
+
fontWeight: fontWeight || safeGet(cardData, 'totalAmount.fontWeight', '700'),
|
|
2628
|
+
color: color || safeGet(cardData, 'totalAmount.color', '#111827')
|
|
2629
|
+
}, props), {}, {
|
|
2630
|
+
children: children || safeGet(cardData, 'totalAmount.text', '$5.75')
|
|
2631
|
+
}));
|
|
2632
|
+
};
|
|
2633
|
+
// Main Card component
|
|
2634
|
+
var Card = function Card(_ref27) {
|
|
2635
|
+
var children = _ref27.children,
|
|
2636
|
+
width = _ref27.width,
|
|
2637
|
+
maxWidth = _ref27.maxWidth,
|
|
2638
|
+
fontFamily = _ref27.fontFamily,
|
|
2639
|
+
props = _objectWithoutProperties(_ref27, _excluded27);
|
|
2640
|
+
var _useCardData22 = useCardData(),
|
|
2641
|
+
cardData = _useCardData22.data;
|
|
2642
|
+
if (!cardData) return null;
|
|
2643
|
+
return jsxRuntime.jsx(react.Box, _objectSpread2(_objectSpread2({
|
|
2644
|
+
width: width || safeGet(cardData, 'card.width', '100%'),
|
|
2645
|
+
maxWidth: maxWidth || safeGet(cardData, 'card.maxWidth', '32rem'),
|
|
2646
|
+
fontFamily: fontFamily || safeGet(cardData, 'card.fontFamily', 'Inter, system-ui, sans-serif')
|
|
2647
|
+
}, props), {}, {
|
|
2648
|
+
children: children
|
|
2649
|
+
}));
|
|
2650
|
+
};
|
|
2651
|
+
// Attach all subcomponents to Card
|
|
2652
|
+
Card.Container = CardContainer;
|
|
2653
|
+
Card.Header = CardHeader;
|
|
2654
|
+
Card.HeaderContent = CardHeaderContent;
|
|
2655
|
+
Card.HeaderTitle = CardHeaderTitle;
|
|
2656
|
+
Card.HeaderTimer = CardHeaderTimer;
|
|
2657
|
+
Card.Body = CardBody;
|
|
2658
|
+
Card.BodyDriver = CardBodyDriver;
|
|
2659
|
+
Card.BodyImage = CardBodyImage;
|
|
2660
|
+
Card.BodyInfo = CardBodyInfo;
|
|
2661
|
+
Card.BodyName = CardBodyName;
|
|
2662
|
+
Card.BodySpan = CardBodySpan;
|
|
2663
|
+
Card.BodyActions = CardBodyActions;
|
|
2664
|
+
Card.BodyActionButton = CardBodyActionButton;
|
|
2665
|
+
Card.BodyActionIcon = CardBodyActionIcon;
|
|
2666
|
+
Card.Route = CardRoute;
|
|
2667
|
+
Card.RouteContainer = CardRouteContainer;
|
|
2668
|
+
Card.RouteItem = CardRouteItem;
|
|
2669
|
+
Card.Payment = CardPayment;
|
|
2670
|
+
Card.PaymentContainer = CardPaymentContainer;
|
|
2671
|
+
Card.PaymentContent = CardPaymentContent;
|
|
2672
|
+
Card.PaymentIconContainer = CardPaymentIconContainer;
|
|
2673
|
+
Card.PaymentDetails = CardPaymentDetails;
|
|
2674
|
+
Card.Number = CardNumber;
|
|
2675
|
+
Card.Type = CardType;
|
|
2676
|
+
Card.TotalSection = CardTotalSection;
|
|
2677
|
+
Card.TotalContent = CardTotalContent;
|
|
2678
|
+
Card.TotalLabel = CardTotalLabel;
|
|
2679
|
+
Card.TotalAmount = CardTotalAmount;
|
|
2680
|
+
|
|
2681
|
+
var DefaultCard = function DefaultCard() {
|
|
2682
|
+
return jsxRuntime.jsx(Card, {
|
|
2683
|
+
children: jsxRuntime.jsxs(Card.Container, {
|
|
2684
|
+
children: [jsxRuntime.jsx(Card.Header, {
|
|
2685
|
+
children: jsxRuntime.jsxs(Card.HeaderContent, {
|
|
2686
|
+
children: [jsxRuntime.jsx(Card.HeaderTitle, {
|
|
2687
|
+
children: "Arrived in"
|
|
2688
|
+
}), jsxRuntime.jsx(Card.HeaderTimer, {
|
|
2689
|
+
children: "00:05:20"
|
|
2690
|
+
})]
|
|
2691
|
+
})
|
|
2692
|
+
}), jsxRuntime.jsx(Card.Body, {
|
|
2693
|
+
children: jsxRuntime.jsxs(Card.BodyDriver, {
|
|
2694
|
+
children: [jsxRuntime.jsx(Card.BodyImage, {}), jsxRuntime.jsxs(Card.BodyInfo, {
|
|
2695
|
+
children: [jsxRuntime.jsx(Card.BodyName, {
|
|
2696
|
+
children: "Jacob Jones"
|
|
2697
|
+
}), jsxRuntime.jsx(Card.BodySpan, {
|
|
2698
|
+
children: "Omnitrans \u2022 SPX-8328"
|
|
2699
|
+
})]
|
|
2700
|
+
}), jsxRuntime.jsxs(Card.BodyActions, {
|
|
2701
|
+
children: [jsxRuntime.jsx(Card.BodyActionButton, {
|
|
2702
|
+
children: jsxRuntime.jsx(Card.BodyActionIcon, {
|
|
2703
|
+
children: jsxRuntime.jsx("svg", {
|
|
2704
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
2705
|
+
className: "h-5 w-5 text-gray-600",
|
|
2706
|
+
viewBox: "0 0 20 20",
|
|
2707
|
+
fill: "currentColor",
|
|
2708
|
+
children: jsxRuntime.jsx("path", {
|
|
2709
|
+
d: "M2 3a1 1 0 011-1h2.153a1 1 0 01.986.836l.74 4.435a1 1 0 01-.54 1.06l-1.548.773a11.041 11.041 0 006.105 6.105l.774-1.548a1 1 0 011.059-.54l4.435.74a1 1 0 01.836.986V17a1 1 0 01-1 1h-2C9.083 18 3 11.917 3 6V3z"
|
|
2710
|
+
})
|
|
2711
|
+
})
|
|
2712
|
+
})
|
|
2713
|
+
}), jsxRuntime.jsx(Card.BodyActionButton, {
|
|
2714
|
+
backgroundColor: "gray.800",
|
|
2715
|
+
color: "white",
|
|
2716
|
+
hoverBackgroundColor: "gray.700",
|
|
2717
|
+
border: "none",
|
|
2718
|
+
children: jsxRuntime.jsx(Card.BodyActionIcon, {
|
|
2719
|
+
color: "white",
|
|
2720
|
+
children: jsxRuntime.jsx("svg", {
|
|
2721
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
2722
|
+
className: "h-5 w-5",
|
|
2723
|
+
viewBox: "0 0 20 20",
|
|
2724
|
+
fill: "currentColor",
|
|
2725
|
+
children: jsxRuntime.jsx("path", {
|
|
2726
|
+
fillRule: "evenodd",
|
|
2727
|
+
d: "M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2H9.5v-3a1 1 0 00-1-1z",
|
|
2728
|
+
clipRule: "evenodd"
|
|
2729
|
+
})
|
|
2730
|
+
})
|
|
2731
|
+
})
|
|
2732
|
+
})]
|
|
2733
|
+
})]
|
|
2734
|
+
})
|
|
2735
|
+
}), jsxRuntime.jsx(Card.Route, {
|
|
2736
|
+
children: jsxRuntime.jsxs(Card.RouteContainer, {
|
|
2737
|
+
children: [jsxRuntime.jsx(Card.RouteItem, {
|
|
2738
|
+
icon: jsxRuntime.jsx("svg", {
|
|
2739
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
2740
|
+
className: "h-4 w-4 text-blue-600",
|
|
2741
|
+
viewBox: "0 0 20 20",
|
|
2742
|
+
fill: "currentColor",
|
|
2743
|
+
children: jsxRuntime.jsx("path", {
|
|
2744
|
+
fillRule: "evenodd",
|
|
2745
|
+
d: "M10 18a8 8 0 100-16 8 8 0 000 16zm1-11a1 1 0 10-2 0v2a1 1 0 00.293.707l2.828 2.829a1 1 0 101.414-1.414L11 9.586V7z",
|
|
2746
|
+
clipRule: "evenodd"
|
|
2747
|
+
})
|
|
2748
|
+
}),
|
|
2749
|
+
iconBackgroundColor: "blue.50",
|
|
2750
|
+
title: "456 Elm Street, Springfield",
|
|
2751
|
+
subtitle: "Pickup point"
|
|
2752
|
+
}), jsxRuntime.jsx(Card.RouteItem, {
|
|
2753
|
+
icon: jsxRuntime.jsx("svg", {
|
|
2754
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
2755
|
+
className: "h-4 w-4 text-gray-600",
|
|
2756
|
+
viewBox: "0 0 20 20",
|
|
2757
|
+
fill: "currentColor",
|
|
2758
|
+
children: jsxRuntime.jsx("path", {
|
|
2759
|
+
fillRule: "evenodd",
|
|
2760
|
+
d: "M5.05 4.05a7 7 0 119.9 9.9L10 18.9l-4.95-4.95a7 7 0 010-9.9zM10 11a2 2 0 100-4 2 2 0 000 4z",
|
|
2761
|
+
clipRule: "evenodd"
|
|
2762
|
+
})
|
|
2763
|
+
}),
|
|
2764
|
+
iconBackgroundColor: "gray.50",
|
|
2765
|
+
title: "739 Main Street, Springfield",
|
|
2766
|
+
subtitle: "Destination"
|
|
2767
|
+
})]
|
|
2768
|
+
})
|
|
2769
|
+
}), jsxRuntime.jsx(Card.Payment, {
|
|
2770
|
+
children: jsxRuntime.jsx(Card.PaymentContainer, {
|
|
2771
|
+
children: jsxRuntime.jsxs(Card.PaymentContent, {
|
|
2772
|
+
children: [jsxRuntime.jsx(Card.PaymentIconContainer, {
|
|
2773
|
+
children: jsxRuntime.jsx(Card.BodyActionIcon, {
|
|
2774
|
+
width: 6,
|
|
2775
|
+
height: 6,
|
|
2776
|
+
color: "gray.300",
|
|
2777
|
+
children: jsxRuntime.jsx("svg", {
|
|
2778
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
2779
|
+
className: "h-6 w-6 text-gray-300",
|
|
2780
|
+
viewBox: "0 0 20 20",
|
|
2781
|
+
fill: "currentColor",
|
|
2782
|
+
children: jsxRuntime.jsx("path", {
|
|
2783
|
+
d: "M4 4a2 2 0 00-2 2v8a2 2 0 002 2h12a2 2 0 002-2V6a2 2 0 00-2-2H4zm1 4h10v2H5V8zm0 4h10v2H5v-2z"
|
|
2784
|
+
})
|
|
2785
|
+
})
|
|
2786
|
+
})
|
|
2787
|
+
}), jsxRuntime.jsxs(Card.PaymentDetails, {
|
|
2788
|
+
children: [jsxRuntime.jsx(Card.Number, {
|
|
2789
|
+
children: "**** 7493"
|
|
2790
|
+
}), jsxRuntime.jsx(Card.Type, {
|
|
2791
|
+
children: "Credit card"
|
|
2792
|
+
})]
|
|
2793
|
+
})]
|
|
2794
|
+
})
|
|
2795
|
+
})
|
|
2796
|
+
}), jsxRuntime.jsx(Card.TotalSection, {
|
|
2797
|
+
children: jsxRuntime.jsxs(Card.TotalContent, {
|
|
2798
|
+
children: [jsxRuntime.jsx(Card.TotalLabel, {
|
|
2799
|
+
children: "Total orders"
|
|
2800
|
+
}), jsxRuntime.jsx(Card.TotalAmount, {
|
|
2801
|
+
children: "$5.75"
|
|
2802
|
+
})]
|
|
2803
|
+
})
|
|
2804
|
+
})]
|
|
2805
|
+
})
|
|
2806
|
+
});
|
|
2807
|
+
};
|
|
2808
|
+
|
|
2809
|
+
var useDynamicComponents = function useDynamicComponents() {
|
|
2810
|
+
var _useStrata = useStrata(),
|
|
2811
|
+
designSystem = _useStrata.designSystem,
|
|
2812
|
+
syncVersion = _useStrata.syncVersion;
|
|
2813
|
+
var _useState = React.useState(strataRegistry.getRegistry()),
|
|
2814
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
2815
|
+
registry = _useState2[0],
|
|
2816
|
+
setRegistry = _useState2[1];
|
|
2817
|
+
var _useState3 = React.useState(false),
|
|
2818
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
2819
|
+
isInitialized = _useState4[0],
|
|
2820
|
+
setIsInitialized = _useState4[1];
|
|
2821
|
+
// Sync components when design system changes
|
|
2822
|
+
React.useEffect(function () {
|
|
2823
|
+
console.log('🔄 useDynamicComponents: Design system changed', {
|
|
2824
|
+
components: Object.keys(designSystem.components),
|
|
2825
|
+
syncVersion: syncVersion
|
|
2826
|
+
});
|
|
2827
|
+
if (Object.keys(designSystem.components).length > 0) {
|
|
2828
|
+
console.log('🔄 Syncing registry with design system...');
|
|
2829
|
+
// Sync the entire registry with the current design system
|
|
2830
|
+
strataRegistry.syncWithDesignSystem(designSystem);
|
|
2831
|
+
setIsInitialized(true);
|
|
2832
|
+
}
|
|
2833
|
+
}, [designSystem, syncVersion]);
|
|
2834
|
+
// Subscribe to registry changes
|
|
2835
|
+
React.useEffect(function () {
|
|
2836
|
+
console.log('🔄 useDynamicComponents: Subscribing to registry changes');
|
|
2837
|
+
var unsubscribe = strataRegistry.subscribe(function (newRegistry) {
|
|
2838
|
+
console.log('🔄 Registry updated:', Object.keys(newRegistry));
|
|
2839
|
+
setRegistry(newRegistry);
|
|
2840
|
+
});
|
|
2841
|
+
return unsubscribe;
|
|
2842
|
+
}, []);
|
|
2843
|
+
console.log('📋 useDynamicComponents returning registry:', {
|
|
2844
|
+
registryKeys: Object.keys(registry),
|
|
2845
|
+
isInitialized: isInitialized,
|
|
2846
|
+
hasRoboForm: 'RoboForm' in registry
|
|
2847
|
+
});
|
|
2848
|
+
return registry;
|
|
2849
|
+
};
|
|
2850
|
+
|
|
2851
|
+
// This hook provides direct access to all components in PascalCase
|
|
2852
|
+
var useComponents = function useComponents() {
|
|
2853
|
+
var dynamicComponents = useDynamicComponents();
|
|
2854
|
+
console.log('🔄 useComponents returning:', {
|
|
2855
|
+
componentCount: Object.keys(dynamicComponents).length,
|
|
2856
|
+
componentNames: Object.keys(dynamicComponents)
|
|
2857
|
+
});
|
|
2858
|
+
return dynamicComponents;
|
|
2859
|
+
};
|
|
2860
|
+
|
|
2861
|
+
var StrataDebug = function StrataDebug() {
|
|
2862
|
+
var components = useComponents();
|
|
2863
|
+
var _useStrata = useStrata(),
|
|
2864
|
+
designSystem = _useStrata.designSystem,
|
|
2865
|
+
syncStatus = _useStrata.syncStatus,
|
|
2866
|
+
lastSynced = _useStrata.lastSynced,
|
|
2867
|
+
syncUrl = _useStrata.syncUrl,
|
|
2868
|
+
syncEnabled = _useStrata.syncEnabled,
|
|
2869
|
+
syncInterval = _useStrata.syncInterval,
|
|
2870
|
+
syncToken = _useStrata.syncToken,
|
|
2871
|
+
snapshotCdnBase = _useStrata.snapshotCdnBase,
|
|
2872
|
+
projectId = _useStrata.projectId;
|
|
2873
|
+
var isCdnMode = !!(snapshotCdnBase && projectId);
|
|
2874
|
+
var isLegacyMode = !isCdnMode && !!syncUrl;
|
|
2875
|
+
var syncModeLabel;
|
|
2876
|
+
if (!syncEnabled) {
|
|
2877
|
+
syncModeLabel = '❌ Disabled';
|
|
2878
|
+
} else if (isCdnMode) {
|
|
2879
|
+
syncModeLabel = '✅ CDN Snapshot';
|
|
2880
|
+
} else {
|
|
2881
|
+
syncModeLabel = '⚠️ Legacy (3 requests/poll)';
|
|
2882
|
+
}
|
|
2883
|
+
return jsxRuntime.jsxs("div", {
|
|
2884
|
+
style: {
|
|
2885
|
+
padding: '20px',
|
|
2886
|
+
border: '1px solid #ccc',
|
|
2887
|
+
margin: '10px'
|
|
2888
|
+
},
|
|
2889
|
+
children: [jsxRuntime.jsx("h3", {
|
|
2890
|
+
children: "Dynamic Components Debug"
|
|
2891
|
+
}), jsxRuntime.jsxs("p", {
|
|
2892
|
+
children: [jsxRuntime.jsx("strong", {
|
|
2893
|
+
children: "Sync Status:"
|
|
2894
|
+
}), " ", syncStatus]
|
|
2895
|
+
}), jsxRuntime.jsxs("p", {
|
|
2896
|
+
children: [jsxRuntime.jsx("strong", {
|
|
2897
|
+
children: "Sync Mode:"
|
|
2898
|
+
}), " ", syncModeLabel]
|
|
2899
|
+
}), syncEnabled && isCdnMode && jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
2900
|
+
children: [jsxRuntime.jsxs("p", {
|
|
2901
|
+
children: [jsxRuntime.jsx("strong", {
|
|
2902
|
+
children: "Project ID:"
|
|
2903
|
+
}), " ", projectId]
|
|
2904
|
+
}), jsxRuntime.jsxs("p", {
|
|
2905
|
+
children: [jsxRuntime.jsx("strong", {
|
|
2906
|
+
children: "Snapshot URL:"
|
|
2907
|
+
}), " ", "".concat(snapshotCdnBase, "/snapshots/").concat(projectId, "/strata.json")]
|
|
2908
|
+
}), jsxRuntime.jsxs("p", {
|
|
2909
|
+
children: [jsxRuntime.jsx("strong", {
|
|
2910
|
+
children: "Token auth:"
|
|
2911
|
+
}), " ", syncToken ? '✅ Present' : '❌ None']
|
|
2912
|
+
}), jsxRuntime.jsxs("p", {
|
|
2913
|
+
children: [jsxRuntime.jsx("strong", {
|
|
2914
|
+
children: "Sync interval:"
|
|
2915
|
+
}), " ", syncInterval, "ms"]
|
|
2916
|
+
})]
|
|
2917
|
+
}), syncEnabled && isLegacyMode && jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
2918
|
+
children: [jsxRuntime.jsxs("p", {
|
|
2919
|
+
children: [jsxRuntime.jsx("strong", {
|
|
2920
|
+
children: "Sync URL:"
|
|
2921
|
+
}), " ", syncUrl]
|
|
2922
|
+
}), jsxRuntime.jsxs("p", {
|
|
2923
|
+
children: [jsxRuntime.jsx("strong", {
|
|
2924
|
+
children: "Token auth:"
|
|
2925
|
+
}), " ", syncToken ? '✅ Present' : '❌ None']
|
|
2926
|
+
}), jsxRuntime.jsxs("p", {
|
|
2927
|
+
children: [jsxRuntime.jsx("strong", {
|
|
2928
|
+
children: "Sync interval:"
|
|
2929
|
+
}), " ", syncInterval, "ms"]
|
|
2930
|
+
})]
|
|
2931
|
+
}), jsxRuntime.jsxs("p", {
|
|
2932
|
+
children: [jsxRuntime.jsx("strong", {
|
|
2933
|
+
children: "Last Synced:"
|
|
2934
|
+
}), " ", (lastSynced === null || lastSynced === void 0 ? void 0 : lastSynced.toLocaleTimeString()) || 'Never']
|
|
2935
|
+
}), jsxRuntime.jsxs("p", {
|
|
2936
|
+
children: [jsxRuntime.jsx("strong", {
|
|
2937
|
+
children: "Raw Components in Design System:"
|
|
2938
|
+
}), " ", Object.keys(designSystem.components).join(', ') || 'None']
|
|
2939
|
+
}), jsxRuntime.jsxs("p", {
|
|
2940
|
+
children: [jsxRuntime.jsx("strong", {
|
|
2941
|
+
children: "Components in Registry (PascalCase):"
|
|
2942
|
+
}), " ", Object.keys(components).join(', ') || 'None']
|
|
2943
|
+
}), jsxRuntime.jsxs("div", {
|
|
2944
|
+
style: {
|
|
2945
|
+
marginTop: '10px',
|
|
2946
|
+
padding: '10px',
|
|
2947
|
+
backgroundColor: '#f5f5f5'
|
|
2948
|
+
},
|
|
2949
|
+
children: [jsxRuntime.jsx("h4", {
|
|
2950
|
+
children: "Component Conversion Map:"
|
|
2951
|
+
}), jsxRuntime.jsx("ul", {
|
|
2952
|
+
children: Object.keys(designSystem.components).map(function (originalName) {
|
|
2953
|
+
var pascalName = Object.keys(components).find(function (key) {
|
|
2954
|
+
return key.toLowerCase() === originalName.toLowerCase().replace(/[-_]/g, '');
|
|
2955
|
+
});
|
|
2956
|
+
return jsxRuntime.jsxs("li", {
|
|
2957
|
+
children: [jsxRuntime.jsx("code", {
|
|
2958
|
+
children: originalName
|
|
2959
|
+
}), " \u2192 ", jsxRuntime.jsx("code", {
|
|
2960
|
+
children: pascalName || 'Not converted'
|
|
2961
|
+
})]
|
|
2962
|
+
}, originalName);
|
|
2963
|
+
})
|
|
2964
|
+
})]
|
|
2965
|
+
}), Object.keys(components).length === 0 && jsxRuntime.jsx("div", {
|
|
2966
|
+
style: {
|
|
2967
|
+
color: 'orange'
|
|
2968
|
+
},
|
|
2969
|
+
children: "No components in registry. Check if sync is working."
|
|
2970
|
+
})]
|
|
2971
|
+
});
|
|
2972
|
+
};
|
|
2973
|
+
|
|
2974
|
+
//working
|
|
2975
|
+
// "use client";
|
|
2976
|
+
// import { useDynamicComponents } from './useDynamicComponents';
|
|
2977
|
+
// export const useComponent = (componentName: string) => {
|
|
2978
|
+
// const dynamicComponents = useDynamicComponents();
|
|
2979
|
+
// // Try exact match first
|
|
2980
|
+
// if (dynamicComponents[componentName]) {
|
|
2981
|
+
// return dynamicComponents[componentName];
|
|
2982
|
+
// }
|
|
2983
|
+
// // Try PascalCase
|
|
2984
|
+
// const pascalCaseName = componentName
|
|
2985
|
+
// .split('-')
|
|
2986
|
+
// .map(part => part.charAt(0).toUpperCase() + part.slice(1))
|
|
2987
|
+
// .join('');
|
|
2988
|
+
// if (dynamicComponents[pascalCaseName]) {
|
|
2989
|
+
// return dynamicComponents[pascalCaseName];
|
|
2990
|
+
// }
|
|
2991
|
+
// // Try camelCase
|
|
2992
|
+
// const camelCaseName = componentName
|
|
2993
|
+
// .split('-')
|
|
2994
|
+
// .map((part, index) => index === 0 ? part : part.charAt(0).toUpperCase() + part.slice(1))
|
|
2995
|
+
// .join('');
|
|
2996
|
+
// return dynamicComponents[camelCaseName];
|
|
2997
|
+
// };
|
|
2998
|
+
// working
|
|
2999
|
+
var useComponent = function useComponent(componentName) {
|
|
3000
|
+
var dynamicComponents = useDynamicComponents();
|
|
3001
|
+
// Try exact match first
|
|
3002
|
+
if (dynamicComponents[componentName]) {
|
|
3003
|
+
return dynamicComponents[componentName];
|
|
3004
|
+
}
|
|
3005
|
+
// Try PascalCase conversion
|
|
3006
|
+
var toPascalCase = function toPascalCase(str) {
|
|
3007
|
+
return str.split(/[-_]/).map(function (part) {
|
|
3008
|
+
return part.charAt(0).toUpperCase() + part.slice(1).toLowerCase();
|
|
3009
|
+
}).join('');
|
|
3010
|
+
};
|
|
3011
|
+
var pascalCaseName = toPascalCase(componentName);
|
|
3012
|
+
if (dynamicComponents[pascalCaseName]) {
|
|
3013
|
+
return dynamicComponents[pascalCaseName];
|
|
3014
|
+
}
|
|
3015
|
+
console.warn("Component \"".concat(componentName, "\" not found. Available:"), Object.keys(dynamicComponents));
|
|
3016
|
+
return null;
|
|
3017
|
+
};
|
|
3018
|
+
|
|
3019
|
+
var _excluded = ["name", "children"],
|
|
3020
|
+
_excluded2 = ["formName", "children"];
|
|
3021
|
+
// This component automatically imports and renders any dynamic component
|
|
3022
|
+
var DynamicComponent = function DynamicComponent(_ref) {
|
|
3023
|
+
var name = _ref.name,
|
|
3024
|
+
children = _ref.children,
|
|
3025
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
3026
|
+
var components = useComponents();
|
|
3027
|
+
var Component = components[name];
|
|
3028
|
+
if (!Component) {
|
|
3029
|
+
console.warn("Component \"".concat(name, "\" not found in registry. Available: ").concat(Object.keys(components).join(', ')));
|
|
3030
|
+
return null;
|
|
3031
|
+
}
|
|
3032
|
+
return /*#__PURE__*/React.createElement(Component, props, children);
|
|
3033
|
+
};
|
|
3034
|
+
// Helper component for common patterns
|
|
3035
|
+
var AutoForm = function AutoForm(_ref2) {
|
|
3036
|
+
var _ref2$formName = _ref2.formName,
|
|
3037
|
+
formName = _ref2$formName === void 0 ? 'Form' : _ref2$formName,
|
|
3038
|
+
children = _ref2.children,
|
|
3039
|
+
props = _objectWithoutProperties(_ref2, _excluded2);
|
|
3040
|
+
var components = useComponents();
|
|
3041
|
+
var FormComponent = components[formName] || components['Form'];
|
|
3042
|
+
if (!FormComponent) {
|
|
3043
|
+
return jsxRuntime.jsxs("div", {
|
|
3044
|
+
children: ["Form component \"", formName, "\" not found"]
|
|
3045
|
+
});
|
|
3046
|
+
}
|
|
3047
|
+
return /*#__PURE__*/React.createElement(FormComponent, props, children);
|
|
3048
|
+
};
|
|
3049
|
+
|
|
3050
|
+
exports.AutoForm = AutoForm;
|
|
3051
|
+
exports.Card = Card;
|
|
3052
|
+
exports.DefaultCard = DefaultCard;
|
|
3053
|
+
exports.DynamicComponent = DynamicComponent;
|
|
3054
|
+
exports.StrataComponentFactory = StrataComponentFactory;
|
|
3055
|
+
exports.StrataDebug = StrataDebug;
|
|
3056
|
+
exports.StrataProvider = StrataProvider;
|
|
3057
|
+
exports.strataRegistry = strataRegistry;
|
|
3058
|
+
exports.useComponent = useComponent;
|
|
3059
|
+
exports.useComponents = useComponents;
|
|
3060
|
+
exports.useDynamicComponents = useDynamicComponents;
|
|
3061
|
+
exports.useStrata = useStrata;
|
|
3062
|
+
//# sourceMappingURL=index.js.map
|