funuicss 3.6.18 → 3.6.19

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/ui/theme/theme.js CHANGED
@@ -70,7 +70,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
70
70
  }
71
71
  };
72
72
  Object.defineProperty(exports, "__esModule", { value: true });
73
- exports.useGlobalConfig = exports.useColors = exports.useComponentConfig = exports.useThemeValue = exports.useVariant = exports.useTheme = void 0;
73
+ exports.useComponentVariant = exports.useTypographyValue = exports.useColor = exports.useProjectData = exports.useThemeConfig = exports.useTypography = exports.useColors = exports.useComponentConfig = exports.useThemeValue = exports.useVariant = exports.useTheme = void 0;
74
74
  var react_1 = __importStar(require("react"));
75
75
  var themes_1 = require("./themes");
76
76
  var darkenUtils_1 = require("./darkenUtils");
@@ -97,49 +97,7 @@ var useVariant = function () {
97
97
  };
98
98
  exports.useVariant = useVariant;
99
99
  /* -------------------------------------------------------------------------- */
100
- /* THEME CACHE & STORAGE */
101
- /* -------------------------------------------------------------------------- */
102
- var CACHE_KEY = 'funui_theme_cache';
103
- var CACHE_EXPIRY = 1000 * 60 * 60; // 1 hour
104
- var POLL_INTERVAL = 5 * 60 * 1000; // Check for updates every 5 minutes
105
- var getThemeFromCache = function (projectId) {
106
- if (typeof window === 'undefined')
107
- return null;
108
- try {
109
- var cached = localStorage.getItem("".concat(CACHE_KEY, "_").concat(projectId));
110
- if (!cached)
111
- return null;
112
- var parsed = JSON.parse(cached);
113
- var isExpired = Date.now() - parsed.timestamp > CACHE_EXPIRY;
114
- if (isExpired) {
115
- localStorage.removeItem("".concat(CACHE_KEY, "_").concat(projectId));
116
- return null;
117
- }
118
- return parsed.data;
119
- }
120
- catch (error) {
121
- console.error('Error reading theme cache:', error);
122
- return null;
123
- }
124
- };
125
- var saveThemeToCache = function (projectId, data) {
126
- if (typeof window === 'undefined')
127
- return;
128
- try {
129
- var cache = {
130
- projectId: projectId,
131
- data: data,
132
- timestamp: Date.now(),
133
- version: data.version || Date.now(),
134
- };
135
- localStorage.setItem("".concat(CACHE_KEY, "_").concat(projectId), JSON.stringify(cache));
136
- }
137
- catch (error) {
138
- console.error('Error saving theme cache:', error);
139
- }
140
- };
141
- /* -------------------------------------------------------------------------- */
142
- /* CDN THEME LOADER (NO TOKEN!) */
100
+ /* CDN THEME LOADER */
143
101
  /* -------------------------------------------------------------------------- */
144
102
  var loadThemeFromCDN = function (projectId) { return __awaiter(void 0, void 0, void 0, function () {
145
103
  var publicResponse, data, error_1, publicUrl, response, data, error_2;
@@ -175,7 +133,7 @@ var loadThemeFromCDN = function (projectId) { return __awaiter(void 0, void 0, v
175
133
  return [4 /*yield*/, response.json()];
176
134
  case 7:
177
135
  data = _a.sent();
178
- console.log('✅ Loaded theme from Firebase Storage (public CDN)');
136
+ console.log('✅ Loaded theme from Firebase Storage CDN');
179
137
  return [2 /*return*/, data];
180
138
  case 8:
181
139
  console.error('Firebase Storage fetch failed:', response.status, response.statusText);
@@ -190,6 +148,49 @@ var loadThemeFromCDN = function (projectId) { return __awaiter(void 0, void 0, v
190
148
  });
191
149
  }); };
192
150
  /* -------------------------------------------------------------------------- */
151
+ /* CSS VARIABLE APPLIER */
152
+ /* -------------------------------------------------------------------------- */
153
+ var applyTypographyVariables = function (typography, root) {
154
+ if (!typography)
155
+ return;
156
+ Object.entries(typography).forEach(function (_a) {
157
+ var key = _a[0], value = _a[1];
158
+ // Convert flat keys to CSS custom property format
159
+ var cssVarName = "--".concat(key.replace(/_/g, '-'));
160
+ root.style.setProperty(cssVarName, value);
161
+ });
162
+ };
163
+ var applyColorVariables = function (colors, root) {
164
+ if (!colors)
165
+ return;
166
+ Object.entries(colors).forEach(function (_a) {
167
+ var key = _a[0], value = _a[1];
168
+ // Convert flat keys to CSS custom property format
169
+ var cssVarName = "--".concat(key.replace(/_/g, '-'));
170
+ root.style.setProperty(cssVarName, value);
171
+ });
172
+ };
173
+ var applyThemeConfig = function (themeConfig, root) {
174
+ if (!themeConfig)
175
+ return;
176
+ // Apply colors if they exist
177
+ if (themeConfig.colors) {
178
+ applyColorVariables(themeConfig.colors, root);
179
+ }
180
+ // Apply typography if it exists
181
+ if (themeConfig.typography) {
182
+ applyTypographyVariables(themeConfig.typography, root);
183
+ }
184
+ // Apply any other theme config properties
185
+ Object.entries(themeConfig).forEach(function (_a) {
186
+ var key = _a[0], value = _a[1];
187
+ if (key !== 'colors' && key !== 'typography' && typeof value === 'string') {
188
+ var cssVarName = "--".concat(key.replace(/_/g, '-'));
189
+ root.style.setProperty(cssVarName, value);
190
+ }
191
+ });
192
+ };
193
+ /* -------------------------------------------------------------------------- */
193
194
  /* COMPONENT */
194
195
  /* -------------------------------------------------------------------------- */
195
196
  var ThemeProvider = function (_a) {
@@ -222,7 +223,7 @@ var ThemeProvider = function (_a) {
222
223
  });
223
224
  }
224
225
  }, [theme]);
225
- /* ---------------------- CDN Theme Sync (No Token!) ----------------------- */
226
+ /* ---------------------- CDN Theme Sync ----------------------- */
226
227
  (0, react_1.useEffect)(function () {
227
228
  if (typeof window === 'undefined' || !projectId) {
228
229
  setIsLoading(false);
@@ -231,15 +232,6 @@ var ThemeProvider = function (_a) {
231
232
  }
232
233
  var root = document.documentElement;
233
234
  var pollTimer;
234
- // Step 1: Load from cache immediately
235
- var cachedTheme = getThemeFromCache(projectId);
236
- if (cachedTheme) {
237
- applyThemeData(cachedTheme, root);
238
- setCurrentVersion(cachedTheme.version || null);
239
- setIsLoading(false);
240
- console.log('✅ Using cached theme');
241
- }
242
- // Step 2: Fetch from CDN
243
235
  var fetchFromCDN = function () { return __awaiter(void 0, void 0, void 0, function () {
244
236
  var cdnTheme, newVersion, err_1;
245
237
  return __generator(this, function (_a) {
@@ -252,8 +244,8 @@ var ThemeProvider = function (_a) {
252
244
  if (cdnTheme) {
253
245
  newVersion = cdnTheme.version || Date.now();
254
246
  if (!currentVersion || newVersion !== currentVersion) {
247
+ // Apply theme data to CSS variables and state
255
248
  applyThemeData(cdnTheme, root);
256
- saveThemeToCache(projectId, cdnTheme);
257
249
  setCurrentVersion(newVersion);
258
250
  console.log('✅ Theme updated from CDN');
259
251
  }
@@ -264,17 +256,13 @@ var ThemeProvider = function (_a) {
264
256
  }
265
257
  else {
266
258
  console.warn('⚠️ No theme found in CDN');
267
- if (!cachedTheme) {
268
- setError('Theme not found');
269
- }
259
+ setError('Theme not found in CDN');
270
260
  }
271
261
  return [3 /*break*/, 4];
272
262
  case 2:
273
263
  err_1 = _a.sent();
274
264
  console.error('Error loading theme from CDN:', err_1);
275
- if (!cachedTheme) {
276
- setError('Failed to load theme');
277
- }
265
+ setError('Failed to load theme from CDN');
278
266
  return [3 /*break*/, 4];
279
267
  case 3:
280
268
  setIsLoading(false);
@@ -284,32 +272,25 @@ var ThemeProvider = function (_a) {
284
272
  }
285
273
  });
286
274
  }); };
287
- if (!cachedTheme) {
288
- fetchFromCDN();
289
- }
290
- else {
291
- setTimeout(function () { return setIsInitialLoad(false); }, 100);
292
- fetchFromCDN();
293
- }
294
- // Step 3: Poll for updates every 5 minutes
275
+ // Initial load
276
+ fetchFromCDN();
277
+ // Poll for updates every 5 minutes
295
278
  pollTimer = setInterval(function () {
296
279
  fetchFromCDN();
297
- }, POLL_INTERVAL);
280
+ }, 5 * 60 * 1000);
298
281
  return function () {
299
282
  clearInterval(pollTimer);
300
283
  };
301
284
  }, [projectId, currentVersion]);
302
285
  var applyThemeData = function (data, root) {
303
286
  var _a;
304
- var config = (_a = data.theme_config) !== null && _a !== void 0 ? _a : {};
287
+ var themeConfig = (_a = data.theme_config) !== null && _a !== void 0 ? _a : {};
305
288
  var newVariant = data.default_variation || 'standard';
306
289
  setVariant(newVariant);
307
- setThemeConfig(config);
290
+ setThemeConfig(themeConfig);
308
291
  setProjectData(data);
309
- Object.entries(config).forEach(function (_a) {
310
- var key = _a[0], value = _a[1];
311
- root.style.setProperty(key.startsWith('--') ? key : "--".concat(key), String(value));
312
- });
292
+ // Apply all theme config to CSS variables
293
+ applyThemeConfig(themeConfig, root);
313
294
  };
314
295
  var contextValue = (0, react_1.useMemo)(function () { return ({
315
296
  variant: variant,
@@ -329,7 +310,9 @@ var ThemeProvider = function (_a) {
329
310
  } }, children)));
330
311
  };
331
312
  exports.default = ThemeProvider;
332
- // Helper hooks
313
+ /* -------------------------------------------------------------------------- */
314
+ /* HELPER HOOKS */
315
+ /* -------------------------------------------------------------------------- */
333
316
  var useThemeValue = function (key) {
334
317
  var themeConfig = (0, exports.useTheme)().themeConfig;
335
318
  return themeConfig[key];
@@ -342,12 +325,43 @@ var useComponentConfig = function (componentName) {
342
325
  };
343
326
  exports.useComponentConfig = useComponentConfig;
344
327
  var useColors = function () {
328
+ var _a;
345
329
  var projectData = (0, exports.useTheme)().projectData;
346
- return (projectData === null || projectData === void 0 ? void 0 : projectData.colors) || {};
330
+ return ((_a = projectData === null || projectData === void 0 ? void 0 : projectData.theme_config) === null || _a === void 0 ? void 0 : _a.colors) || {};
347
331
  };
348
332
  exports.useColors = useColors;
349
- var useGlobalConfig = function () {
333
+ var useTypography = function () {
334
+ var _a;
335
+ var projectData = (0, exports.useTheme)().projectData;
336
+ return ((_a = projectData === null || projectData === void 0 ? void 0 : projectData.theme_config) === null || _a === void 0 ? void 0 : _a.typography) || {};
337
+ };
338
+ exports.useTypography = useTypography;
339
+ var useThemeConfig = function () {
350
340
  var projectData = (0, exports.useTheme)().projectData;
351
- return (projectData === null || projectData === void 0 ? void 0 : projectData.global) || {};
341
+ return (projectData === null || projectData === void 0 ? void 0 : projectData.theme_config) || {};
342
+ };
343
+ exports.useThemeConfig = useThemeConfig;
344
+ var useProjectData = function () {
345
+ var projectData = (0, exports.useTheme)().projectData;
346
+ return projectData;
347
+ };
348
+ exports.useProjectData = useProjectData;
349
+ // Get specific color value
350
+ var useColor = function (colorName) {
351
+ var colors = (0, exports.useColors)();
352
+ return colors[colorName];
353
+ };
354
+ exports.useColor = useColor;
355
+ // Get specific typography value
356
+ var useTypographyValue = function (property) {
357
+ var typography = (0, exports.useTypography)();
358
+ return typography[property];
359
+ };
360
+ exports.useTypographyValue = useTypographyValue;
361
+ // Get component variant
362
+ var useComponentVariant = function (componentName, variantName) {
363
+ if (variantName === void 0) { variantName = 'default'; }
364
+ var componentConfig = (0, exports.useComponentConfig)(componentName);
365
+ return componentConfig[variantName] || {};
352
366
  };
353
- exports.useGlobalConfig = useGlobalConfig;
367
+ exports.useComponentVariant = useComponentVariant;
@@ -46,15 +46,15 @@ export interface UseComponentConfigReturn extends ComponentConfig {
46
46
  */
47
47
  export declare const getComponentConfig: (projectData: ProjectData | null | undefined, componentName: string, variantName?: string) => ComponentConfig;
48
48
  /**
49
- * Merge component config with local props - only applies config if variant exists
49
+ * Merge component config with local props - LOCAL PROPS OVERRIDE CONFIG
50
50
  *
51
51
  * @param config - Component configuration from getComponentConfig
52
- * @param localProps - Props passed directly to the component
52
+ * @param localProps - Props passed directly to the component (OVERRIDES CONFIG)
53
53
  * @returns Merged configuration with metadata
54
54
  */
55
55
  export declare const mergeComponentConfig: (config: ComponentConfig, localProps?: ComponentProps) => MergedConfig;
56
56
  /**
57
- * Hook for easy component config usage - only applies if variant is provided and exists
57
+ * Hook for easy component config usage with LOCAL PROP OVERRIDE
58
58
  * Uses useMemo to prevent unnecessary re-computation
59
59
  *
60
60
  * @param componentName - Name of the component
@@ -63,12 +63,15 @@ export declare const mergeComponentConfig: (config: ComponentConfig, localProps?
63
63
  */
64
64
  export declare const useComponentConfiguration: (componentName: string, variantName?: string) => UseComponentConfigReturn;
65
65
  /**
66
- * Utility function to check if a component variant exists
67
- * Useful for conditional rendering logic
66
+ * Hook that directly returns merged props with local override
67
+ * Perfect for direct use in components
68
+ */
69
+ export declare const useComponentProps: (componentName: string, variantName?: string, localProps?: ComponentProps) => ComponentProps;
70
+ /**
71
+ * Quick utility to check if a component variant exists
68
72
  */
69
73
  export declare const hasComponentVariant: (projectData: ProjectData | null | undefined, componentName: string, variantName: string) => boolean;
70
74
  /**
71
75
  * Get all available variants for a component
72
- * Useful for variant selectors/dropdowns
73
76
  */
74
77
  export declare const getAvailableVariants: (projectData: ProjectData | null | undefined, componentName: string) => string[];
@@ -1,5 +1,4 @@
1
1
  "use strict";
2
- // import { useTheme } from "../ui/theme/theme"
3
2
  var __assign = (this && this.__assign) || function () {
4
3
  __assign = Object.assign || function(t) {
5
4
  for (var s, i = 1, n = arguments.length; i < n; i++) {
@@ -12,154 +11,7 @@ var __assign = (this && this.__assign) || function () {
12
11
  return __assign.apply(this, arguments);
13
12
  };
14
13
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.getAvailableVariants = exports.hasComponentVariant = exports.useComponentConfiguration = exports.mergeComponentConfig = exports.getComponentConfig = void 0;
16
- // // utils/componentUtils.ts
17
- // // Type definitions
18
- // export interface ComponentProps {
19
- // [key: string]: any
20
- // }
21
- // export interface ComponentMetadata {
22
- // createdAt?: Date
23
- // updatedAt?: Date
24
- // isCustom?: boolean
25
- // baseVariant?: string
26
- // }
27
- // export interface ComponentVariant {
28
- // componentProps: ComponentProps
29
- // metadata?: ComponentMetadata
30
- // }
31
- // export interface ComponentConfig {
32
- // componentProps: ComponentProps
33
- // variantExists: boolean
34
- // actualVariant: string
35
- // availableVariants: string[]
36
- // metadata: ComponentMetadata
37
- // }
38
- // export interface ProjectData {
39
- // components?: {
40
- // [componentName: string]: {
41
- // [variantName: string]: ComponentVariant
42
- // }
43
- // }
44
- // }
45
- // export interface MergedConfig {
46
- // props: ComponentProps
47
- // variant: string
48
- // hasConfig: boolean
49
- // }
50
- // export interface UseComponentConfigReturn extends ComponentConfig {
51
- // mergeWithLocal: (localProps?: ComponentProps) => MergedConfig
52
- // getProp: <T = any>(propName: string, defaultValue?: T) => T
53
- // }
54
- // /**
55
- // * Universal component config getter
56
- // */
57
- // export const getComponentConfig = (
58
- // projectData: ProjectData | null | undefined,
59
- // componentName: string,
60
- // variantName: string = 'default'
61
- // ): ComponentConfig => {
62
- // if (!projectData?.components?.[componentName]) {
63
- // return {
64
- // componentProps: {},
65
- // variantExists: false,
66
- // actualVariant: variantName,
67
- // availableVariants: [],
68
- // metadata: {}
69
- // }
70
- // }
71
- // const component = projectData.components[componentName]
72
- // const availableVariants = Object.keys(component)
73
- // // Find the best variant match
74
- // let targetVariant = variantName
75
- // if (!availableVariants.includes(variantName)) {
76
- // if (availableVariants.includes('default')) {
77
- // targetVariant = 'default'
78
- // } else if (availableVariants.length > 0) {
79
- // targetVariant = availableVariants[0]
80
- // } else {
81
- // return {
82
- // componentProps: {},
83
- // variantExists: false,
84
- // actualVariant: variantName,
85
- // availableVariants: [],
86
- // metadata: {}
87
- // }
88
- // }
89
- // }
90
- // const variantData = component[targetVariant] || {}
91
- // return {
92
- // componentProps: variantData.componentProps || {},
93
- // variantExists: true,
94
- // actualVariant: targetVariant,
95
- // availableVariants,
96
- // metadata: variantData.metadata || {}
97
- // }
98
- // }
99
- // /**
100
- // * Merge component config with local props - only applies config if variant exists
101
- // */
102
- // export const mergeComponentConfig = (
103
- // config: ComponentConfig,
104
- // localProps: ComponentProps = {}
105
- // ): MergedConfig => {
106
- // // Only apply config if variant exists and has actual configuration
107
- // const hasValidConfig = config.variantExists && Object.keys(config.componentProps).length > 0
108
- // if (!hasValidConfig) {
109
- // return {
110
- // props: localProps,
111
- // variant: config.actualVariant,
112
- // hasConfig: false
113
- // }
114
- // }
115
- // return {
116
- // // Props: config overrides local only if variant exists
117
- // props: {
118
- // ...localProps,
119
- // ...config.componentProps
120
- // },
121
- // // Metadata
122
- // variant: config.actualVariant,
123
- // hasConfig: true
124
- // }
125
- // }
126
- // /**
127
- // * Hook for easy component config usage - only applies if variant is provided and exists
128
- // */
129
- // export const useComponentConfiguration = (
130
- // componentName: string,
131
- // variantName?: string // Make variantName optional
132
- // ): UseComponentConfigReturn => {
133
- // const { projectData } = useTheme()
134
- // // Only get config if variantName is provided
135
- // const config = variantName ? getComponentConfig(projectData, componentName, variantName) : {
136
- // componentProps: {},
137
- // variantExists: false,
138
- // actualVariant: '',
139
- // availableVariants: [],
140
- // metadata: {}
141
- // }
142
- // const mergeWithLocal = (
143
- // localProps: ComponentProps = {}
144
- // ): MergedConfig => {
145
- // // If no variant name was provided, return local props as-is
146
- // if (!variantName) {
147
- // return {
148
- // props: localProps,
149
- // variant: '',
150
- // hasConfig: false
151
- // }
152
- // }
153
- // return mergeComponentConfig(config, localProps)
154
- // }
155
- // const getProp = <T = any>(propName: string, defaultValue?: T): T =>
156
- // (config.componentProps[propName] ?? defaultValue) as T
157
- // return {
158
- // ...config,
159
- // mergeWithLocal,
160
- // getProp
161
- // }
162
- // }
14
+ exports.getAvailableVariants = exports.hasComponentVariant = exports.useComponentProps = exports.useComponentConfiguration = exports.mergeComponentConfig = exports.getComponentConfig = void 0;
163
15
  var theme_1 = require("../ui/theme/theme");
164
16
  var react_1 = require("react");
165
17
  /**
@@ -219,29 +71,37 @@ var getComponentConfig = function (projectData, componentName, variantName) {
219
71
  };
220
72
  exports.getComponentConfig = getComponentConfig;
221
73
  /**
222
- * Deep merge utility for nested objects
223
- * Config props override local props, but we preserve nested structure
74
+ * Smart merge utility - LOCAL PROPS OVERRIDE CONFIG PROPS
75
+ * If a prop exists in both local and config, local wins
224
76
  */
225
- var deepMerge = function (target, source) {
226
- var result = __assign({}, target);
227
- for (var key in source) {
228
- if (source[key] !== undefined) {
229
- // For objects, do shallow merge (we don't go too deep to avoid complexity)
230
- if (typeof source[key] === 'object' && !Array.isArray(source[key]) && source[key] !== null) {
231
- result[key] = __assign(__assign({}, (target[key] || {})), source[key]);
77
+ var smartMergeWithLocalOverride = function (configProps, localProps) {
78
+ var result = __assign({}, configProps);
79
+ // Apply local props - they override config props
80
+ for (var key in localProps) {
81
+ if (localProps[key] !== undefined) {
82
+ // For objects, do smart merge but local object properties still override
83
+ if (typeof localProps[key] === 'object' &&
84
+ !Array.isArray(localProps[key]) &&
85
+ localProps[key] !== null &&
86
+ typeof configProps[key] === 'object' &&
87
+ !Array.isArray(configProps[key]) &&
88
+ configProps[key] !== null) {
89
+ // Merge nested objects but local properties still win
90
+ result[key] = __assign(__assign({}, configProps[key]), localProps[key]);
232
91
  }
233
92
  else {
234
- result[key] = source[key];
93
+ // Primitive values or arrays - local always wins
94
+ result[key] = localProps[key];
235
95
  }
236
96
  }
237
97
  }
238
98
  return result;
239
99
  };
240
100
  /**
241
- * Merge component config with local props - only applies config if variant exists
101
+ * Merge component config with local props - LOCAL PROPS OVERRIDE CONFIG
242
102
  *
243
103
  * @param config - Component configuration from getComponentConfig
244
- * @param localProps - Props passed directly to the component
104
+ * @param localProps - Props passed directly to the component (OVERRIDES CONFIG)
245
105
  * @returns Merged configuration with metadata
246
106
  */
247
107
  var mergeComponentConfig = function (config, localProps) {
@@ -255,17 +115,16 @@ var mergeComponentConfig = function (config, localProps) {
255
115
  hasConfig: false
256
116
  };
257
117
  }
118
+ // LOCAL PROPS OVERRIDE CONFIG PROPS
258
119
  return {
259
- // Props: config overrides local, with deep merge for nested objects
260
- props: deepMerge(localProps, config.componentProps),
261
- // Metadata
120
+ props: smartMergeWithLocalOverride(config.componentProps, localProps),
262
121
  variant: config.actualVariant,
263
122
  hasConfig: true
264
123
  };
265
124
  };
266
125
  exports.mergeComponentConfig = mergeComponentConfig;
267
126
  /**
268
- * Hook for easy component config usage - only applies if variant is provided and exists
127
+ * Hook for easy component config usage with LOCAL PROP OVERRIDE
269
128
  * Uses useMemo to prevent unnecessary re-computation
270
129
  *
271
130
  * @param componentName - Name of the component
@@ -287,7 +146,7 @@ var useComponentConfiguration = function (componentName, variantName) {
287
146
  }
288
147
  return (0, exports.getComponentConfig)(projectData, componentName, variantName);
289
148
  }, [projectData, componentName, variantName]);
290
- // Memoize merge function
149
+ // Memoize merge function - LOCAL PROPS OVERRIDE CONFIG
291
150
  var mergeWithLocal = (0, react_1.useMemo)(function () {
292
151
  return function (localProps) {
293
152
  if (localProps === void 0) { localProps = {}; }
@@ -302,7 +161,7 @@ var useComponentConfiguration = function (componentName, variantName) {
302
161
  return (0, exports.mergeComponentConfig)(config, localProps);
303
162
  };
304
163
  }, [config, variantName]);
305
- // Memoize getProp function
164
+ // Memoize getProp function (gets from config only, not merged)
306
165
  var getProp = (0, react_1.useMemo)(function () {
307
166
  return function (propName, defaultValue) { var _a; return ((_a = config.componentProps[propName]) !== null && _a !== void 0 ? _a : defaultValue); };
308
167
  }, [config.componentProps]);
@@ -310,8 +169,22 @@ var useComponentConfiguration = function (componentName, variantName) {
310
169
  };
311
170
  exports.useComponentConfiguration = useComponentConfiguration;
312
171
  /**
313
- * Utility function to check if a component variant exists
314
- * Useful for conditional rendering logic
172
+ * Hook that directly returns merged props with local override
173
+ * Perfect for direct use in components
174
+ */
175
+ var useComponentProps = function (componentName, variantName, localProps) {
176
+ if (variantName === void 0) { variantName = 'default'; }
177
+ if (localProps === void 0) { localProps = {}; }
178
+ var projectData = (0, theme_1.useTheme)().projectData;
179
+ return (0, react_1.useMemo)(function () {
180
+ var config = (0, exports.getComponentConfig)(projectData, componentName, variantName);
181
+ var merged = (0, exports.mergeComponentConfig)(config, localProps);
182
+ return merged.props;
183
+ }, [projectData, componentName, variantName, localProps]);
184
+ };
185
+ exports.useComponentProps = useComponentProps;
186
+ /**
187
+ * Quick utility to check if a component variant exists
315
188
  */
316
189
  var hasComponentVariant = function (projectData, componentName, variantName) {
317
190
  var _a, _b;
@@ -320,7 +193,6 @@ var hasComponentVariant = function (projectData, componentName, variantName) {
320
193
  exports.hasComponentVariant = hasComponentVariant;
321
194
  /**
322
195
  * Get all available variants for a component
323
- * Useful for variant selectors/dropdowns
324
196
  */
325
197
  var getAvailableVariants = function (projectData, componentName) {
326
198
  var _a;
@@ -1,10 +0,0 @@
1
- export namespace Requests {
2
- export function getDocs(collectionName: any, docs_limit: any, extraQueries?: any[]): Promise<any>;
3
- export function getDoc(collectionName: any, id: any): Promise<any>;
4
- export function query(collectionName: any, queriesArr: any[] | undefined, docs_limit: any): Promise<any>;
5
- export function add_document(cName: any, data: any, dbCollection?: string): Promise<any>;
6
- export function set_doc(cName: any, doc_id: any, data: any): Promise<any>;
7
- export function update(cName: any, doc_id: any, data: any): Promise<any>;
8
- export function _delete(cName: any, doc_id: any): Promise<any>;
9
- export { _delete as delete };
10
- }