@rovela-ai/sdk 0.4.0 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/checkout/server/create-checkout-session.d.ts +10 -1
- package/dist/checkout/server/create-checkout-session.d.ts.map +1 -1
- package/dist/checkout/server/create-checkout-session.js +28 -17
- package/dist/checkout/server/create-checkout-session.js.map +1 -1
- package/dist/checkout/server/handle-webhook.js +22 -2
- package/dist/checkout/server/handle-webhook.js.map +1 -1
- package/dist/checkout/server/order-service.d.ts +7 -1
- package/dist/checkout/server/order-service.d.ts.map +1 -1
- package/dist/checkout/server/order-service.js +59 -12
- package/dist/checkout/server/order-service.js.map +1 -1
- package/dist/core/db/queries.d.ts +6 -6
- package/dist/core/db/schema.d.ts +4 -4
- package/package.json +2 -2
- package/dist/admin/api/auth.d.ts +0 -32
- package/dist/admin/api/auth.d.ts.map +0 -1
- package/dist/admin/api/auth.js +0 -37
- package/dist/admin/api/auth.js.map +0 -1
- package/dist/admin/components/AdminSetupForm.d.ts +0 -28
- package/dist/admin/components/AdminSetupForm.d.ts.map +0 -1
- package/dist/admin/components/AdminSetupForm.js +0 -85
- package/dist/admin/components/AdminSetupForm.js.map +0 -1
- package/dist/auth/api/auth.d.ts +0 -9
- package/dist/auth/api/auth.d.ts.map +0 -1
- package/dist/auth/api/auth.js +0 -9
- package/dist/auth/api/auth.js.map +0 -1
- package/dist/auth/server/email-sender.d.ts +0 -64
- package/dist/auth/server/email-sender.d.ts.map +0 -1
- package/dist/auth/server/email-sender.js +0 -106
- package/dist/auth/server/email-sender.js.map +0 -1
- package/dist/products/components/CategoryNav.d.ts +0 -51
- package/dist/products/components/CategoryNav.d.ts.map +0 -1
- package/dist/products/components/CategoryNav.js +0 -110
- package/dist/products/components/CategoryNav.js.map +0 -1
- package/dist/products/components/ProductBreadcrumb.d.ts +0 -52
- package/dist/products/components/ProductBreadcrumb.d.ts.map +0 -1
- package/dist/products/components/ProductBreadcrumb.js +0 -73
- package/dist/products/components/ProductBreadcrumb.js.map +0 -1
- package/dist/products/components/ProductFilters.d.ts +0 -70
- package/dist/products/components/ProductFilters.d.ts.map +0 -1
- package/dist/products/components/ProductFilters.js +0 -125
- package/dist/products/components/ProductFilters.js.map +0 -1
- package/dist/products/hooks/useCategories.d.ts +0 -56
- package/dist/products/hooks/useCategories.d.ts.map +0 -1
- package/dist/products/hooks/useCategories.js +0 -126
- package/dist/products/hooks/useCategories.js.map +0 -1
- package/dist/products/hooks/useProductAttributes.d.ts +0 -59
- package/dist/products/hooks/useProductAttributes.d.ts.map +0 -1
- package/dist/products/hooks/useProductAttributes.js +0 -125
- package/dist/products/hooks/useProductAttributes.js.map +0 -1
- package/dist/theme/ThemeProvider.d.ts +0 -70
- package/dist/theme/ThemeProvider.d.ts.map +0 -1
- package/dist/theme/ThemeProvider.js +0 -75
- package/dist/theme/ThemeProvider.js.map +0 -1
- package/dist/theme/hooks.d.ts +0 -110
- package/dist/theme/hooks.d.ts.map +0 -1
- package/dist/theme/hooks.js +0 -101
- package/dist/theme/hooks.js.map +0 -1
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
/**
|
|
3
|
-
* @rovela/sdk/products/hooks/useProductAttributes
|
|
4
|
-
*
|
|
5
|
-
* Hook for extracting available filter attributes from products.
|
|
6
|
-
* Used to build dynamic filter UI based on variant attributes.
|
|
7
|
-
*/
|
|
8
|
-
import { useState, useEffect, useCallback, useMemo } from 'react';
|
|
9
|
-
// =============================================================================
|
|
10
|
-
// Hook
|
|
11
|
-
// =============================================================================
|
|
12
|
-
/**
|
|
13
|
-
* Hook for extracting available product attributes for filtering.
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* ```tsx
|
|
17
|
-
* import { useProductAttributes } from '@rovela/sdk/products'
|
|
18
|
-
*
|
|
19
|
-
* function ProductFilters({ categoryId }: { categoryId?: string }) {
|
|
20
|
-
* const { attributes, priceRange, isLoading } = useProductAttributes({
|
|
21
|
-
* categoryId,
|
|
22
|
-
* })
|
|
23
|
-
*
|
|
24
|
-
* if (isLoading) return <div>Loading filters...</div>
|
|
25
|
-
*
|
|
26
|
-
* return (
|
|
27
|
-
* <div>
|
|
28
|
-
* {attributes.map(attr => (
|
|
29
|
-
* <FilterGroup key={attr.name} name={attr.name} values={attr.values} />
|
|
30
|
-
* ))}
|
|
31
|
-
* {priceRange && (
|
|
32
|
-
* <PriceSlider min={priceRange.min} max={priceRange.max} />
|
|
33
|
-
* )}
|
|
34
|
-
* </div>
|
|
35
|
-
* )
|
|
36
|
-
* }
|
|
37
|
-
* ```
|
|
38
|
-
*/
|
|
39
|
-
export function useProductAttributes(options = {}) {
|
|
40
|
-
const { categoryId, endpoint = '/api/products', skip = false, } = options;
|
|
41
|
-
const [products, setProducts] = useState([]);
|
|
42
|
-
const [isLoading, setIsLoading] = useState(!skip);
|
|
43
|
-
const [error, setError] = useState(null);
|
|
44
|
-
// Fetch products to extract attributes
|
|
45
|
-
const fetchProducts = useCallback(async () => {
|
|
46
|
-
if (skip)
|
|
47
|
-
return;
|
|
48
|
-
setIsLoading(true);
|
|
49
|
-
setError(null);
|
|
50
|
-
try {
|
|
51
|
-
const params = new URLSearchParams();
|
|
52
|
-
params.set('limit', '100'); // Get enough products for attribute extraction
|
|
53
|
-
params.set('status', 'active');
|
|
54
|
-
if (categoryId) {
|
|
55
|
-
params.set('category', categoryId);
|
|
56
|
-
}
|
|
57
|
-
const response = await fetch(`${endpoint}?${params}`);
|
|
58
|
-
if (!response.ok) {
|
|
59
|
-
const errorData = await response.json().catch(() => ({}));
|
|
60
|
-
throw new Error(errorData.error || `HTTP ${response.status}`);
|
|
61
|
-
}
|
|
62
|
-
const data = await response.json();
|
|
63
|
-
setProducts(data.data || []);
|
|
64
|
-
// For products with variants, we'd need to fetch variants
|
|
65
|
-
// In production, this would be a separate endpoint or included in products response
|
|
66
|
-
// For now, we extract what we can from product data
|
|
67
|
-
}
|
|
68
|
-
catch (err) {
|
|
69
|
-
setError(err instanceof Error ? err : new Error('Failed to fetch products'));
|
|
70
|
-
}
|
|
71
|
-
finally {
|
|
72
|
-
setIsLoading(false);
|
|
73
|
-
}
|
|
74
|
-
}, [categoryId, endpoint, skip]);
|
|
75
|
-
// Fetch on mount and when category/endpoint change. fetchProducts already
|
|
76
|
-
// closes over those via its own useCallback deps.
|
|
77
|
-
useEffect(() => {
|
|
78
|
-
fetchProducts();
|
|
79
|
-
}, [fetchProducts]);
|
|
80
|
-
// Extract attributes from variants (no variant fetch implemented yet —
|
|
81
|
-
// returns empty array; the products dead chain in PR 4 retires this whole hook).
|
|
82
|
-
const attributes = useMemo(() => {
|
|
83
|
-
const result = [];
|
|
84
|
-
return result;
|
|
85
|
-
}, []);
|
|
86
|
-
// Calculate price range
|
|
87
|
-
const priceRange = useMemo(() => {
|
|
88
|
-
if (products.length === 0)
|
|
89
|
-
return null;
|
|
90
|
-
let min = Infinity;
|
|
91
|
-
let max = -Infinity;
|
|
92
|
-
products.forEach((product) => {
|
|
93
|
-
const price = typeof product.price === 'string'
|
|
94
|
-
? parseFloat(product.price)
|
|
95
|
-
: product.price;
|
|
96
|
-
if (price < min)
|
|
97
|
-
min = price;
|
|
98
|
-
if (price > max)
|
|
99
|
-
max = price;
|
|
100
|
-
});
|
|
101
|
-
// Include compare prices in range
|
|
102
|
-
products.forEach((product) => {
|
|
103
|
-
if (product.comparePrice) {
|
|
104
|
-
const comparePrice = typeof product.comparePrice === 'string'
|
|
105
|
-
? parseFloat(product.comparePrice)
|
|
106
|
-
: product.comparePrice;
|
|
107
|
-
if (comparePrice < min)
|
|
108
|
-
min = comparePrice;
|
|
109
|
-
if (comparePrice > max)
|
|
110
|
-
max = comparePrice;
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
if (min === Infinity || max === -Infinity)
|
|
114
|
-
return null;
|
|
115
|
-
return { min, max };
|
|
116
|
-
}, [products]);
|
|
117
|
-
return {
|
|
118
|
-
attributes,
|
|
119
|
-
priceRange,
|
|
120
|
-
isLoading,
|
|
121
|
-
error,
|
|
122
|
-
refresh: fetchProducts,
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
//# sourceMappingURL=useProductAttributes.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useProductAttributes.js","sourceRoot":"","sources":["../../../src/products/hooks/useProductAttributes.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;AAEZ;;;;;GAKG;AAEH,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAyCjE,gFAAgF;AAChF,OAAO;AACP,gFAAgF;AAEhF;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,UAAU,oBAAoB,CAClC,UAAuC,EAAE;IAEzC,MAAM,EACJ,UAAU,EACV,QAAQ,GAAG,eAAe,EAC1B,IAAI,GAAG,KAAK,GACb,GAAG,OAAO,CAAA;IAEX,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAAY,EAAE,CAAC,CAAA;IACvD,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAA;IACjD,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAe,IAAI,CAAC,CAAA;IAEtD,uCAAuC;IACvC,MAAM,aAAa,GAAG,WAAW,CAAC,KAAK,IAAI,EAAE;QAC3C,IAAI,IAAI;YAAE,OAAM;QAEhB,YAAY,CAAC,IAAI,CAAC,CAAA;QAClB,QAAQ,CAAC,IAAI,CAAC,CAAA;QAEd,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,IAAI,eAAe,EAAE,CAAA;YACpC,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA,CAAC,+CAA+C;YAC1E,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAA;Y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IAEd,OAAO;QACL,UAAU;QACV,UAAU;QACV,SAAS;QACT,KAAK;QACL,OAAO,EAAE,aAAa;KACvB,CAAA;AACH,CAAC"}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @rovela/sdk/theme/ThemeProvider
|
|
3
|
-
*
|
|
4
|
-
* Runtime theme provider for accessing blueprint theme data in React components.
|
|
5
|
-
* Provides theme context to all child components.
|
|
6
|
-
*/
|
|
7
|
-
import { type ReactNode } from 'react';
|
|
8
|
-
import type { BlueprintTheme } from '../core/config';
|
|
9
|
-
interface ThemeContextValue {
|
|
10
|
-
theme: BlueprintTheme;
|
|
11
|
-
colors: BlueprintTheme['colors'];
|
|
12
|
-
typography: BlueprintTheme['typography'];
|
|
13
|
-
spacing: BlueprintTheme['spacing'];
|
|
14
|
-
borders: BlueprintTheme['borders'];
|
|
15
|
-
effects: BlueprintTheme['effects'];
|
|
16
|
-
}
|
|
17
|
-
declare const ThemeContext: import("react").Context<ThemeContextValue | null>;
|
|
18
|
-
interface ThemeProviderProps {
|
|
19
|
-
/**
|
|
20
|
-
* Theme configuration from blueprint.
|
|
21
|
-
* Pass the blueprint.theme object here.
|
|
22
|
-
*/
|
|
23
|
-
theme: BlueprintTheme;
|
|
24
|
-
/**
|
|
25
|
-
* Child components that will have access to the theme.
|
|
26
|
-
*/
|
|
27
|
-
children: ReactNode;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* ThemeProvider component that makes theme configuration available
|
|
31
|
-
* to all child components via React context.
|
|
32
|
-
*
|
|
33
|
-
* @example
|
|
34
|
-
* // In app/layout.tsx:
|
|
35
|
-
* import { ThemeProvider } from '@rovela/sdk/theme'
|
|
36
|
-
* import { getTheme } from '@rovela/sdk/core'
|
|
37
|
-
*
|
|
38
|
-
* export default function RootLayout({ children }) {
|
|
39
|
-
* const theme = getTheme()
|
|
40
|
-
* return (
|
|
41
|
-
* <html>
|
|
42
|
-
* <body>
|
|
43
|
-
* <ThemeProvider theme={theme}>
|
|
44
|
-
* {children}
|
|
45
|
-
* </ThemeProvider>
|
|
46
|
-
* </body>
|
|
47
|
-
* </html>
|
|
48
|
-
* )
|
|
49
|
-
* }
|
|
50
|
-
*/
|
|
51
|
-
export declare function ThemeProvider({ theme, children }: ThemeProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
52
|
-
/**
|
|
53
|
-
* Hook to access the theme context.
|
|
54
|
-
* Must be used within a ThemeProvider.
|
|
55
|
-
*
|
|
56
|
-
* @returns Theme context value
|
|
57
|
-
* @throws Error if used outside ThemeProvider
|
|
58
|
-
*
|
|
59
|
-
* @example
|
|
60
|
-
* import { useThemeContext } from '@rovela/sdk/theme'
|
|
61
|
-
*
|
|
62
|
-
* function MyComponent() {
|
|
63
|
-
* const { colors, typography } = useThemeContext()
|
|
64
|
-
* return <div style={{ color: colors.primary[500] }}>...</div>
|
|
65
|
-
* }
|
|
66
|
-
*/
|
|
67
|
-
export declare function useThemeContext(): ThemeContextValue;
|
|
68
|
-
export { ThemeContext };
|
|
69
|
-
export type { ThemeContextValue, ThemeProviderProps };
|
|
70
|
-
//# sourceMappingURL=ThemeProvider.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ThemeProvider.d.ts","sourceRoot":"","sources":["../../src/theme/ThemeProvider.tsx"],"names":[],"mappings":"AAEA;;;;;GAKG;AAEH,OAAO,EAAsC,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AAC1E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAMpD,UAAU,iBAAiB;IACzB,KAAK,EAAE,cAAc,CAAA;IACrB,MAAM,EAAE,cAAc,CAAC,QAAQ,CAAC,CAAA;IAChC,UAAU,EAAE,cAAc,CAAC,YAAY,CAAC,CAAA;IACxC,OAAO,EAAE,cAAc,CAAC,SAAS,CAAC,CAAA;IAClC,OAAO,EAAE,cAAc,CAAC,SAAS,CAAC,CAAA;IAClC,OAAO,EAAE,cAAc,CAAC,SAAS,CAAC,CAAA;CACnC;AAED,QAAA,MAAM,YAAY,mDAAgD,CAAA;AAMlE,UAAU,kBAAkB;IAC1B;;;OAGG;IACH,KAAK,EAAE,cAAc,CAAA;IACrB;;OAEG;IACH,QAAQ,EAAE,SAAS,CAAA;CACpB;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,aAAa,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,kBAAkB,2CAepE;AAMD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,eAAe,IAAI,iBAAiB,CAWnD;AAMD,OAAO,EAAE,YAAY,EAAE,CAAA;AACvB,YAAY,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,CAAA"}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
/**
|
|
4
|
-
* @rovela/sdk/theme/ThemeProvider
|
|
5
|
-
*
|
|
6
|
-
* Runtime theme provider for accessing blueprint theme data in React components.
|
|
7
|
-
* Provides theme context to all child components.
|
|
8
|
-
*/
|
|
9
|
-
import { createContext, useContext, useMemo } from 'react';
|
|
10
|
-
const ThemeContext = createContext(null);
|
|
11
|
-
/**
|
|
12
|
-
* ThemeProvider component that makes theme configuration available
|
|
13
|
-
* to all child components via React context.
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* // In app/layout.tsx:
|
|
17
|
-
* import { ThemeProvider } from '@rovela/sdk/theme'
|
|
18
|
-
* import { getTheme } from '@rovela/sdk/core'
|
|
19
|
-
*
|
|
20
|
-
* export default function RootLayout({ children }) {
|
|
21
|
-
* const theme = getTheme()
|
|
22
|
-
* return (
|
|
23
|
-
* <html>
|
|
24
|
-
* <body>
|
|
25
|
-
* <ThemeProvider theme={theme}>
|
|
26
|
-
* {children}
|
|
27
|
-
* </ThemeProvider>
|
|
28
|
-
* </body>
|
|
29
|
-
* </html>
|
|
30
|
-
* )
|
|
31
|
-
* }
|
|
32
|
-
*/
|
|
33
|
-
export function ThemeProvider({ theme, children }) {
|
|
34
|
-
// Memoize context value to prevent unnecessary re-renders
|
|
35
|
-
const value = useMemo(() => ({
|
|
36
|
-
theme,
|
|
37
|
-
colors: theme.colors,
|
|
38
|
-
typography: theme.typography,
|
|
39
|
-
spacing: theme.spacing,
|
|
40
|
-
borders: theme.borders,
|
|
41
|
-
effects: theme.effects,
|
|
42
|
-
}), [theme]);
|
|
43
|
-
return _jsx(ThemeContext.Provider, { value: value, children: children });
|
|
44
|
-
}
|
|
45
|
-
// =============================================================================
|
|
46
|
-
// Context Hook
|
|
47
|
-
// =============================================================================
|
|
48
|
-
/**
|
|
49
|
-
* Hook to access the theme context.
|
|
50
|
-
* Must be used within a ThemeProvider.
|
|
51
|
-
*
|
|
52
|
-
* @returns Theme context value
|
|
53
|
-
* @throws Error if used outside ThemeProvider
|
|
54
|
-
*
|
|
55
|
-
* @example
|
|
56
|
-
* import { useThemeContext } from '@rovela/sdk/theme'
|
|
57
|
-
*
|
|
58
|
-
* function MyComponent() {
|
|
59
|
-
* const { colors, typography } = useThemeContext()
|
|
60
|
-
* return <div style={{ color: colors.primary[500] }}>...</div>
|
|
61
|
-
* }
|
|
62
|
-
*/
|
|
63
|
-
export function useThemeContext() {
|
|
64
|
-
const context = useContext(ThemeContext);
|
|
65
|
-
if (!context) {
|
|
66
|
-
throw new Error('useThemeContext must be used within a ThemeProvider. ' +
|
|
67
|
-
'Make sure to wrap your app with <ThemeProvider theme={...}>.');
|
|
68
|
-
}
|
|
69
|
-
return context;
|
|
70
|
-
}
|
|
71
|
-
// =============================================================================
|
|
72
|
-
// Exports
|
|
73
|
-
// =============================================================================
|
|
74
|
-
export { ThemeContext };
|
|
75
|
-
//# sourceMappingURL=ThemeProvider.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ThemeProvider.js","sourceRoot":"","sources":["../../src/theme/ThemeProvider.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ;;;;;GAKG;AAEH,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,OAAO,EAAkB,MAAM,OAAO,CAAA;AAgB1E,MAAM,YAAY,GAAG,aAAa,CAA2B,IAAI,CAAC,CAAA;AAkBlE;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,UAAU,aAAa,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAsB;IACnE,0DAA0D;IAC1D,MAAM,KAAK,GAAG,OAAO,CACnB,GAAG,EAAE,CAAC,CAAC;QACL,KAAK;QACL,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,UAAU,EAAE,KAAK,CAAC,UAAU;QAC5B,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,OAAO,EAAE,KAAK,CAAC,OAAO;KACvB,CAAC,EACF,CAAC,KAAK,CAAC,CACR,CAAA;IAED,OAAO,KAAC,YAAY,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,YAAG,QAAQ,GAAyB,CAAA;AAChF,CAAC;AAED,gFAAgF;AAChF,eAAe;AACf,gFAAgF;AAEhF;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,eAAe;IAC7B,MAAM,OAAO,GAAG,UAAU,CAAC,YAAY,CAAC,CAAA;IAExC,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CACb,uDAAuD;YACrD,8DAA8D,CACjE,CAAA;IACH,CAAC;IAED,OAAO,OAAO,CAAA;AAChB,CAAC;AAED,gFAAgF;AAChF,UAAU;AACV,gFAAgF;AAEhF,OAAO,EAAE,YAAY,EAAE,CAAA"}
|
package/dist/theme/hooks.d.ts
DELETED
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import type { ColorScale } from '../core/config';
|
|
2
|
-
/**
|
|
3
|
-
* Hook for convenient access to theme values with helper functions.
|
|
4
|
-
*
|
|
5
|
-
* @returns Theme data and helper functions
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* import { useTheme } from '@rovela/sdk/theme'
|
|
9
|
-
*
|
|
10
|
-
* function ProductCard() {
|
|
11
|
-
* const { colors, getPrimaryColor, getAccentColor } = useTheme()
|
|
12
|
-
*
|
|
13
|
-
* return (
|
|
14
|
-
* <div style={{ borderColor: getPrimaryColor() }}>
|
|
15
|
-
* <span style={{ color: getAccentColor() }}>Sale!</span>
|
|
16
|
-
* </div>
|
|
17
|
-
* )
|
|
18
|
-
* }
|
|
19
|
-
*/
|
|
20
|
-
export declare function useTheme(): {
|
|
21
|
-
theme: import("../core/config").BlueprintTheme;
|
|
22
|
-
colors: {
|
|
23
|
-
primary: ColorScale;
|
|
24
|
-
secondary: ColorScale;
|
|
25
|
-
accent: ColorScale;
|
|
26
|
-
neutral: ColorScale;
|
|
27
|
-
semantic: import("../core/config").SemanticColors;
|
|
28
|
-
gradients?: import("../core/config").ColorGradient[];
|
|
29
|
-
semanticMappings?: Record<string, {
|
|
30
|
-
dark: string;
|
|
31
|
-
light: string;
|
|
32
|
-
}>;
|
|
33
|
-
};
|
|
34
|
-
typography: {
|
|
35
|
-
heading: import("../core/config").FontConfig;
|
|
36
|
-
body: import("../core/config").FontConfig;
|
|
37
|
-
mono: import("../core/config").FontConfig;
|
|
38
|
-
} | undefined;
|
|
39
|
-
spacing: "cozy" | "balanced" | "spacious" | undefined;
|
|
40
|
-
borders: {
|
|
41
|
-
radius: Record<string, string>;
|
|
42
|
-
width: Record<string, string>;
|
|
43
|
-
} | undefined;
|
|
44
|
-
effects: {
|
|
45
|
-
shadows: Record<string, string>;
|
|
46
|
-
blurs: Record<string, string>;
|
|
47
|
-
overlays: Record<string, string>;
|
|
48
|
-
gradients?: import("../core/config").ColorGradient[];
|
|
49
|
-
} | undefined;
|
|
50
|
-
getPrimaryColor: (shade?: keyof ColorScale) => string;
|
|
51
|
-
getSecondaryColor: (shade?: keyof ColorScale) => string;
|
|
52
|
-
getAccentColor: (shade?: keyof ColorScale) => string;
|
|
53
|
-
getNeutralColor: (shade?: keyof ColorScale) => string;
|
|
54
|
-
getSuccessColor: () => string;
|
|
55
|
-
getErrorColor: () => string;
|
|
56
|
-
getWarningColor: () => string;
|
|
57
|
-
getInfoColor: () => string;
|
|
58
|
-
getHeadingFont: () => string;
|
|
59
|
-
getBodyFont: () => string;
|
|
60
|
-
getMonoFont: () => string;
|
|
61
|
-
getBorderRadius: (size?: "sm" | "md" | "lg" | "xl" | "2xl" | "3xl" | "full") => string;
|
|
62
|
-
getShadow: (size?: "sm" | "md" | "lg" | "xl" | "2xl") => string;
|
|
63
|
-
getInspiration: () => import("../core/config").Inspiration | undefined;
|
|
64
|
-
getPersonality: () => {
|
|
65
|
-
x: number;
|
|
66
|
-
y: number;
|
|
67
|
-
} | undefined;
|
|
68
|
-
};
|
|
69
|
-
/**
|
|
70
|
-
* Hook for accessing just the color system.
|
|
71
|
-
* Lighter weight than useTheme when you only need colors.
|
|
72
|
-
*
|
|
73
|
-
* @returns Color scales and helpers
|
|
74
|
-
*/
|
|
75
|
-
export declare function useThemeColors(): {
|
|
76
|
-
colors: {
|
|
77
|
-
primary: ColorScale;
|
|
78
|
-
secondary: ColorScale;
|
|
79
|
-
accent: ColorScale;
|
|
80
|
-
neutral: ColorScale;
|
|
81
|
-
semantic: import("../core/config").SemanticColors;
|
|
82
|
-
gradients?: import("../core/config").ColorGradient[];
|
|
83
|
-
semanticMappings?: Record<string, {
|
|
84
|
-
dark: string;
|
|
85
|
-
light: string;
|
|
86
|
-
}>;
|
|
87
|
-
};
|
|
88
|
-
primary: ColorScale;
|
|
89
|
-
secondary: ColorScale;
|
|
90
|
-
accent: ColorScale;
|
|
91
|
-
neutral: ColorScale;
|
|
92
|
-
semantic: import("../core/config").SemanticColors;
|
|
93
|
-
};
|
|
94
|
-
/**
|
|
95
|
-
* Hook for accessing just the typography system.
|
|
96
|
-
* Lighter weight than useTheme when you only need fonts.
|
|
97
|
-
*
|
|
98
|
-
* @returns Typography configuration
|
|
99
|
-
*/
|
|
100
|
-
export declare function useThemeTypography(): {
|
|
101
|
-
typography: {
|
|
102
|
-
heading: import("../core/config").FontConfig;
|
|
103
|
-
body: import("../core/config").FontConfig;
|
|
104
|
-
mono: import("../core/config").FontConfig;
|
|
105
|
-
} | undefined;
|
|
106
|
-
heading: import("../core/config").FontConfig | undefined;
|
|
107
|
-
body: import("../core/config").FontConfig | undefined;
|
|
108
|
-
mono: import("../core/config").FontConfig | undefined;
|
|
109
|
-
};
|
|
110
|
-
//# sourceMappingURL=hooks.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../src/theme/hooks.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAMhD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8BAcO,MAAM,UAAU;gCAEd,MAAM,UAAU;6BAEnB,MAAM,UAAU;8BAEf,MAAM,UAAU;;;;;;;;6BAkBjB,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,KAAK,GAAG,KAAK,GAAG,MAAM;uBAIxD,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,KAAK;;;;;;EASxD;AAMD;;;;;GAKG;AACH,wBAAgB,cAAc;;;;;;;;;;;;;;;;;;EAc7B;AAMD;;;;;GAKG;AACH,wBAAgB,kBAAkB;;;;;;;;;EAYjC"}
|
package/dist/theme/hooks.js
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
/**
|
|
3
|
-
* @rovela/sdk/theme/hooks
|
|
4
|
-
*
|
|
5
|
-
* React hooks for accessing theme data.
|
|
6
|
-
*/
|
|
7
|
-
import { useMemo } from 'react';
|
|
8
|
-
import { useThemeContext } from './ThemeProvider';
|
|
9
|
-
// =============================================================================
|
|
10
|
-
// useTheme Hook
|
|
11
|
-
// =============================================================================
|
|
12
|
-
/**
|
|
13
|
-
* Hook for convenient access to theme values with helper functions.
|
|
14
|
-
*
|
|
15
|
-
* @returns Theme data and helper functions
|
|
16
|
-
*
|
|
17
|
-
* @example
|
|
18
|
-
* import { useTheme } from '@rovela/sdk/theme'
|
|
19
|
-
*
|
|
20
|
-
* function ProductCard() {
|
|
21
|
-
* const { colors, getPrimaryColor, getAccentColor } = useTheme()
|
|
22
|
-
*
|
|
23
|
-
* return (
|
|
24
|
-
* <div style={{ borderColor: getPrimaryColor() }}>
|
|
25
|
-
* <span style={{ color: getAccentColor() }}>Sale!</span>
|
|
26
|
-
* </div>
|
|
27
|
-
* )
|
|
28
|
-
* }
|
|
29
|
-
*/
|
|
30
|
-
export function useTheme() {
|
|
31
|
-
const { theme, colors, typography, spacing, borders, effects } = useThemeContext();
|
|
32
|
-
return useMemo(() => ({
|
|
33
|
-
// Raw theme data
|
|
34
|
-
theme,
|
|
35
|
-
colors,
|
|
36
|
-
typography,
|
|
37
|
-
spacing,
|
|
38
|
-
borders,
|
|
39
|
-
effects,
|
|
40
|
-
// Color helpers
|
|
41
|
-
getPrimaryColor: (shade = 500) => colors?.primary?.[shade] ?? '#3b82f6',
|
|
42
|
-
getSecondaryColor: (shade = 500) => colors?.secondary?.[shade] ?? '#64748b',
|
|
43
|
-
getAccentColor: (shade = 500) => colors?.accent?.[shade] ?? '#10b981',
|
|
44
|
-
getNeutralColor: (shade = 500) => colors?.neutral?.[shade] ?? '#71717a',
|
|
45
|
-
// Semantic color helpers
|
|
46
|
-
getSuccessColor: () => colors?.semantic?.success ?? '#22c55e',
|
|
47
|
-
getErrorColor: () => colors?.semantic?.error ?? '#ef4444',
|
|
48
|
-
getWarningColor: () => colors?.semantic?.warning ?? '#f59e0b',
|
|
49
|
-
getInfoColor: () => colors?.semantic?.info ?? '#3b82f6',
|
|
50
|
-
// Typography helpers
|
|
51
|
-
getHeadingFont: () => typography?.heading?.name ?? 'Inter',
|
|
52
|
-
getBodyFont: () => typography?.body?.name ?? 'Inter',
|
|
53
|
-
getMonoFont: () => typography?.mono?.name ?? 'JetBrains Mono',
|
|
54
|
-
// Border radius helpers
|
|
55
|
-
getBorderRadius: (size = 'md') => borders?.radius?.[size] ?? '0.375rem',
|
|
56
|
-
// Shadow helpers
|
|
57
|
-
getShadow: (size = 'md') => effects?.shadows?.[size] ?? '0 4px 6px -1px rgb(0 0 0 / 0.1)',
|
|
58
|
-
// Inspiration and personality
|
|
59
|
-
getInspiration: () => theme.inspiration,
|
|
60
|
-
getPersonality: () => theme.personality,
|
|
61
|
-
}), [theme, colors, typography, spacing, borders, effects]);
|
|
62
|
-
}
|
|
63
|
-
// =============================================================================
|
|
64
|
-
// useThemeColors Hook
|
|
65
|
-
// =============================================================================
|
|
66
|
-
/**
|
|
67
|
-
* Hook for accessing just the color system.
|
|
68
|
-
* Lighter weight than useTheme when you only need colors.
|
|
69
|
-
*
|
|
70
|
-
* @returns Color scales and helpers
|
|
71
|
-
*/
|
|
72
|
-
export function useThemeColors() {
|
|
73
|
-
const { colors } = useThemeContext();
|
|
74
|
-
return useMemo(() => ({
|
|
75
|
-
colors,
|
|
76
|
-
primary: colors?.primary,
|
|
77
|
-
secondary: colors?.secondary,
|
|
78
|
-
accent: colors?.accent,
|
|
79
|
-
neutral: colors?.neutral,
|
|
80
|
-
semantic: colors?.semantic,
|
|
81
|
-
}), [colors]);
|
|
82
|
-
}
|
|
83
|
-
// =============================================================================
|
|
84
|
-
// useThemeTypography Hook
|
|
85
|
-
// =============================================================================
|
|
86
|
-
/**
|
|
87
|
-
* Hook for accessing just the typography system.
|
|
88
|
-
* Lighter weight than useTheme when you only need fonts.
|
|
89
|
-
*
|
|
90
|
-
* @returns Typography configuration
|
|
91
|
-
*/
|
|
92
|
-
export function useThemeTypography() {
|
|
93
|
-
const { typography } = useThemeContext();
|
|
94
|
-
return useMemo(() => ({
|
|
95
|
-
typography,
|
|
96
|
-
heading: typography?.heading,
|
|
97
|
-
body: typography?.body,
|
|
98
|
-
mono: typography?.mono,
|
|
99
|
-
}), [typography]);
|
|
100
|
-
}
|
|
101
|
-
//# sourceMappingURL=hooks.js.map
|
package/dist/theme/hooks.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.js","sourceRoot":"","sources":["../../src/theme/hooks.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;AAEZ;;;;GAIG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAC/B,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAGjD,gFAAgF;AAChF,gBAAgB;AAChB,gFAAgF;AAEhF;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,QAAQ;IACtB,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,eAAe,EAAE,CAAA;IAElF,OAAO,OAAO,CACZ,GAAG,EAAE,CAAC,CAAC;QACL,iBAAiB;QACjB,KAAK;QACL,MAAM;QACN,UAAU;QACV,OAAO;QACP,OAAO;QACP,OAAO;QAEP,gBAAgB;QAChB,eAAe,EAAE,CAAC,QAA0B,GAAG,EAAE,EAAE,CACjD,MAAM,EAAE,OAAO,EAAE,CAAC,KAAK,CAAC,IAAI,SAAS;QACvC,iBAAiB,EAAE,CAAC,QAA0B,GAAG,EAAE,EAAE,CACnD,MAAM,EAAE,SAAS,EAAE,CAAC,KAAK,CAAC,IAAI,SAAS;QACzC,cAAc,EAAE,CAAC,QAA0B,GAAG,EAAE,EAAE,CAChD,MAAM,EAAE,MAAM,EAAE,CAAC,KAAK,CAAC,IAAI,SAAS;QACtC,eAAe,EAAE,CAAC,QAA0B,GAAG,EAAE,EAAE,CACjD,MAAM,EAAE,OAAO,EAAE,CAAC,KAAK,CAAC,IAAI,SAAS;QAEvC,yBAAyB;QACzB,eAAe,EAAE,GA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