igloo-d2c-components 1.0.6 → 1.0.8

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/esm/index.js CHANGED
@@ -1,2 +1,479 @@
1
- import{jsx as t,jsxs as e}from"react/jsx-runtime";import{createContext as r,useMemo as n,useContext as a}from"react";import{Button as o,Card as i,CardHeader as c,CardContent as p,CardActions as l,Box as d,Typography as m}from"@mui/material";const s=r(void 0);function y({children:e,tenantId:r,theme:a}){const o=n(()=>({tenantId:r,theme:a}),[r,a]);return t(s.Provider,{value:o,children:e})}function h(){const t=a(s);if(void 0===t)throw new Error("useTenantTheme must be used within a TenantThemeProvider");return t}function u(){const{tenantId:t}=h();return t}function f(t){const{tenantId:e}=h();return e===t}function g({tenantColored:e=!1,variant:r="contained",sx:n,color:a,...i}){const{theme:c}=h(),p=e?{backgroundColor:c.palette.primary?.main,color:"#fff","&:hover":{backgroundColor:c.palette.primary?.dark||c.palette.primary?.main},...n}:n;return t(o,{variant:r,color:e?void 0:a,sx:p,...i})}function x({title:r,headerAction:n,content:a,actions:o,tenantAccent:d=!1,sx:m,children:s,...y}){const{theme:u}=h(),f=d?{borderTop:`4px solid ${u.palette.primary?.main}`,...m}:m;return e(i,{sx:f,...y,children:[r&&t(c,{title:r,action:n}),(a||s)&&t(p,{children:a||s}),o&&t(l,{children:o})]})}function b({title:r,description:n,action:a,gradient:o=!0,sx:i,...c}){const{theme:p}=h(),l=o?`linear-gradient(135deg, ${p.palette.primary?.main} 0%, ${p.palette.primary?.light||p.palette.primary?.main} 100%)`:p.palette.primary?.main;return e(d,{sx:{background:l,color:"white",padding:"32px",borderRadius:"12px",textAlign:"center",...i},...c,children:[t(m,{variant:"h4",component:"h2",gutterBottom:!0,fontWeight:"bold",children:r}),n&&t(m,{variant:"body1",sx:{opacity:.95,mb:a?2:0},children:n}),a&&t(d,{sx:{mt:2},children:a})]})}function v(t,e,r="#000000"){const n=e.split(".");let a=t.palette;for(const t of n){if(!a||"object"!=typeof a||!(t in a))return r;a=a[t]}return"string"==typeof a?a:r}function $(t,e){return{...t,palette:{...t.palette,...e.palette,primary:{...t.palette?.primary||{},...e.palette.primary||{}},secondary:{...t.palette?.secondary||{},...e.palette.secondary||{}}},typography:{...t.typography,...e.typography}}}function T(t,e="--tenant"){const r={};return t.palette.primary&&Object.entries(t.palette.primary).forEach(([t,n])=>{"string"==typeof n&&(r[`${e}-primary-${t}`]=n)}),t.palette.secondary&&Object.entries(t.palette.secondary).forEach(([t,n])=>{"string"==typeof n&&(r[`${e}-secondary-${t}`]=n)}),t.typography?.fontFamily&&(r[`${e}-font-family`]=t.typography.fontFamily),r}export{b as Banner,g as Button,x as Card,y as TenantThemeProvider,T as createThemeCSSVariables,v as getThemeColor,$ as mergeTenantTheme,f as useIsTenant,u as useTenantId,h as useTenantTheme};
2
- //# sourceMappingURL=index.js.map
1
+ "use client"
2
+ import { jsx, jsxs } from 'react/jsx-runtime';
3
+ import { createContext, useMemo, useContext } from 'react';
4
+ import { Button as Button$1, Card as Card$1, CardHeader, CardContent, CardActions, Box, Typography } from '@mui/material';
5
+
6
+ const TenantThemeContext = createContext(undefined);
7
+ /**
8
+ * TenantThemeProvider
9
+ * Wraps components to provide tenant-specific theming
10
+ *
11
+ * @example
12
+ * ```tsx
13
+ * <TenantThemeProvider
14
+ * tenantId="cimb"
15
+ * theme={cimbTheme}
16
+ * >
17
+ * <App />
18
+ * </TenantThemeProvider>
19
+ * ```
20
+ */
21
+ function TenantThemeProvider({ children, tenantId, theme, }) {
22
+ const value = useMemo(() => ({
23
+ tenantId,
24
+ theme,
25
+ }), [tenantId, theme]);
26
+ return (jsx(TenantThemeContext.Provider, Object.assign({ value: value }, { children: children })));
27
+ }
28
+ /**
29
+ * Hook to access tenant theme configuration
30
+ * @throws Error if used outside TenantThemeProvider
31
+ */
32
+ function useTenantTheme() {
33
+ const context = useContext(TenantThemeContext);
34
+ if (context === undefined) {
35
+ throw new Error('useTenantTheme must be used within a TenantThemeProvider');
36
+ }
37
+ return context;
38
+ }
39
+ /**
40
+ * Hook to get tenant ID
41
+ */
42
+ function useTenantId() {
43
+ const { tenantId } = useTenantTheme();
44
+ return tenantId;
45
+ }
46
+ /**
47
+ * Hook to check if current tenant matches given tenant ID
48
+ */
49
+ function useIsTenant(checkTenantId) {
50
+ const { tenantId } = useTenantTheme();
51
+ return tenantId === checkTenantId;
52
+ }
53
+
54
+ /**
55
+ * Tenant Theme Configurations
56
+ * Centralized theme definitions for all tenants
57
+ */
58
+ /**
59
+ * Igloo Theme Configuration
60
+ */
61
+ const iglooTheme = {
62
+ palette: {
63
+ primary: {
64
+ dark: '#1300A9',
65
+ main: '#5656F6',
66
+ light: '#8183FF',
67
+ bright: '#C1C1FF',
68
+ plain: '#E1DFFF',
69
+ border: '#5656F6',
70
+ },
71
+ secondary: {
72
+ dim: '#650713',
73
+ dark: '#C55153',
74
+ main: '#FF7D7D',
75
+ bright: '#FF7378',
76
+ mediumBright: '#FF7062',
77
+ light: '#FFB3B1',
78
+ lighter: '#FFEBEB',
79
+ },
80
+ tertiary: {
81
+ dim: '#C5C6CF',
82
+ dark: '#E1E2EB',
83
+ main: '#F5F5FF',
84
+ light: '#FEFBFF',
85
+ bright: '#F9F9F9',
86
+ },
87
+ natural: {
88
+ dim: '#13131B',
89
+ dark: '#5F5E62',
90
+ main: '#929094',
91
+ light: '#C8C5CA',
92
+ bright: '#fff',
93
+ granite: '#666',
94
+ },
95
+ motor: {
96
+ main: '#00CCFF',
97
+ light: 'rgba(0, 208, 255, 0.10)',
98
+ bright: '#DFF9FF',
99
+ },
100
+ car: {
101
+ main: '#00CCFF',
102
+ light: 'rgba(0, 208, 255, 0.10)',
103
+ darkAI: '#06BDCE',
104
+ },
105
+ travel: {
106
+ main: '#00E08B',
107
+ light: 'rgba(0, 228, 130, 0.10)',
108
+ },
109
+ health: {
110
+ main: '#FD72E7',
111
+ },
112
+ life: {
113
+ main: '#C3214B',
114
+ light: 'rgba(195, 33, 75, 0.10)',
115
+ },
116
+ pet: {
117
+ main: '#F3A100',
118
+ },
119
+ },
120
+ typography: {
121
+ fontFamily: '"Manrope", "Roboto", "Helvetica", "Arial", sans-serif',
122
+ },
123
+ logo: '/assets/igloo_nobeta.svg',
124
+ favicon: 'https://static.iglooinsure.com/icons/favicon.ico',
125
+ };
126
+ /**
127
+ * CIMB Theme Configuration
128
+ */
129
+ const cimbTheme = {
130
+ palette: {
131
+ paCimb: {
132
+ main: '#C3214B',
133
+ light: 'rgba(195, 33, 75, 0.10)',
134
+ bright: '#EE0500',
135
+ buttonBg: 'linear-gradient(90deg, color(display-p3 0.6941 0.1961 0.3059) 0%, color(display-p3 0.8941 0.2745 0.1843) 100%)',
136
+ },
137
+ primary: {
138
+ dark: '#A01B3D',
139
+ main: '#C3214B',
140
+ light: '#D04C6F',
141
+ bright: '#E07A92',
142
+ plain: '#F5E6EA',
143
+ border: '#C3214B',
144
+ },
145
+ secondary: {
146
+ dim: '#B71C1C',
147
+ dark: '#D32F2F',
148
+ main: '#EE0500',
149
+ bright: '#F44336',
150
+ mediumBright: '#EF5350',
151
+ light: '#FFCDD2',
152
+ lighter: '#FFEBEE',
153
+ },
154
+ tertiary: {
155
+ dim: '#C5C6CF',
156
+ dark: '#E1E2EB',
157
+ main: '#F5F5FF',
158
+ light: '#FEFBFF',
159
+ bright: '#F9F9F9',
160
+ },
161
+ natural: {
162
+ dim: '#13131B',
163
+ dark: '#5F5E62',
164
+ main: '#929094',
165
+ light: '#C8C5CA',
166
+ bright: '#fff',
167
+ granite: '#666',
168
+ },
169
+ motor: {
170
+ main: '#C3214B',
171
+ light: 'rgba(195, 33, 75, 0.10)',
172
+ bright: '#F5E6EA',
173
+ },
174
+ car: {
175
+ main: '#C3214B',
176
+ light: 'rgba(195, 33, 75, 0.10)',
177
+ darkAI: '#A01B3D',
178
+ },
179
+ travel: {
180
+ main: '#EE0500',
181
+ light: 'rgba(238, 5, 0, 0.10)',
182
+ },
183
+ health: {
184
+ main: '#E91E63',
185
+ light: 'rgba(233, 30, 99, 0.10)',
186
+ },
187
+ life: {
188
+ main: '#C3214B',
189
+ light: 'rgba(195, 33, 75, 0.10)',
190
+ },
191
+ pet: {
192
+ main: '#F3A100',
193
+ },
194
+ },
195
+ typography: {
196
+ fontFamily: '"CIMB Sans", "Roboto", "Helvetica", "Arial", sans-serif',
197
+ },
198
+ logo: '/assets/cimb/cimb-logo.svg',
199
+ favicon: 'https://static.iglooinsure.com/icons/favicon.ico',
200
+ };
201
+ /**
202
+ * Ammetlife Theme Configuration
203
+ */
204
+ const ammetlifeTheme = {
205
+ palette: {
206
+ primary: {
207
+ dark: '#0D47A1',
208
+ main: '#1976D2',
209
+ light: '#42A5F5',
210
+ bright: '#90CAF9',
211
+ plain: '#E3F2FD',
212
+ border: '#1976D2',
213
+ },
214
+ secondary: {
215
+ dim: '#E65100',
216
+ dark: '#EF6C00',
217
+ main: '#FFA726',
218
+ bright: '#FFB74D',
219
+ mediumBright: '#FFCC80',
220
+ light: '#FFE0B2',
221
+ lighter: '#FFF3E0',
222
+ },
223
+ tertiary: {
224
+ dim: '#B0BEC5',
225
+ dark: '#CFD8DC',
226
+ main: '#ECEFF1',
227
+ light: '#FAFAFA',
228
+ bright: '#FFFFFF',
229
+ },
230
+ natural: {
231
+ dim: '#263238',
232
+ dark: '#546E7A',
233
+ main: '#78909C',
234
+ light: '#B0BEC5',
235
+ bright: '#fff',
236
+ granite: '#666',
237
+ },
238
+ motor: {
239
+ main: '#1976D2',
240
+ light: 'rgba(25, 118, 210, 0.10)',
241
+ bright: '#E3F2FD',
242
+ },
243
+ car: {
244
+ main: '#1976D2',
245
+ light: 'rgba(25, 118, 210, 0.10)',
246
+ darkAI: '#1565C0',
247
+ },
248
+ travel: {
249
+ main: '#00C853',
250
+ light: 'rgba(0, 200, 83, 0.10)',
251
+ },
252
+ health: {
253
+ main: '#E91E63',
254
+ light: 'rgba(233, 30, 99, 0.10)',
255
+ },
256
+ life: {
257
+ main: '#9C27B0',
258
+ light: 'rgba(156, 39, 176, 0.10)',
259
+ },
260
+ pet: {
261
+ main: '#FF9800',
262
+ },
263
+ },
264
+ typography: {
265
+ fontFamily: '"Open Sans", "Roboto", "Helvetica", "Arial", sans-serif',
266
+ },
267
+ logo: '/assets/ammetlife/logo-AmMetLife.svg',
268
+ favicon: 'https://static.iglooinsure.com/icons/favicon.ico',
269
+ };
270
+ /**
271
+ * Theme Registry
272
+ * Map of tenant IDs to their theme configurations
273
+ */
274
+ const tenantThemes = {
275
+ igloo: iglooTheme,
276
+ cimb: cimbTheme,
277
+ ammetlife: ammetlifeTheme,
278
+ };
279
+ /**
280
+ * Get theme configuration by tenant ID
281
+ * @param tenantId - The tenant identifier
282
+ * @returns Theme configuration for the specified tenant
283
+ * @throws Error if tenant ID is not found
284
+ */
285
+ function getTenantTheme(tenantId) {
286
+ const theme = tenantThemes[tenantId];
287
+ if (!theme) {
288
+ throw new Error(`Theme not found for tenant: ${tenantId}. Available tenants: ${Object.keys(tenantThemes).join(', ')}`);
289
+ }
290
+ return theme;
291
+ }
292
+ /**
293
+ * Check if a tenant ID is valid
294
+ * @param tenantId - The tenant identifier to validate
295
+ * @returns True if the tenant ID is valid
296
+ */
297
+ function isValidTenantId(tenantId) {
298
+ return tenantId in tenantThemes;
299
+ }
300
+ /**
301
+ * Get all available tenant IDs
302
+ * @returns Array of all registered tenant IDs
303
+ */
304
+ function getAvailableTenants() {
305
+ return Object.keys(tenantThemes);
306
+ }
307
+
308
+ /******************************************************************************
309
+ Copyright (c) Microsoft Corporation.
310
+
311
+ Permission to use, copy, modify, and/or distribute this software for any
312
+ purpose with or without fee is hereby granted.
313
+
314
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
315
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
316
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
317
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
318
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
319
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
320
+ PERFORMANCE OF THIS SOFTWARE.
321
+ ***************************************************************************** */
322
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
323
+
324
+
325
+ function __rest(s, e) {
326
+ var t = {};
327
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
328
+ t[p] = s[p];
329
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
330
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
331
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
332
+ t[p[i]] = s[p[i]];
333
+ }
334
+ return t;
335
+ }
336
+
337
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
338
+ var e = new Error(message);
339
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
340
+ };
341
+
342
+ /**
343
+ * Button component with tenant theme support
344
+ *
345
+ * @example
346
+ * ```tsx
347
+ * // Uses tenant primary color
348
+ * <Button tenantColored>Click Me</Button>
349
+ *
350
+ * // Uses MUI default color
351
+ * <Button color="primary">Click Me</Button>
352
+ * ```
353
+ */
354
+ function Button(_a) {
355
+ var _b, _c, _d;
356
+ var { tenantColored = false, variant = 'contained', sx, color } = _a, props = __rest(_a, ["tenantColored", "variant", "sx", "color"]);
357
+ const { theme } = useTenantTheme();
358
+ const buttonSx = tenantColored
359
+ ? Object.assign({ backgroundColor: (_b = theme.palette.primary) === null || _b === void 0 ? void 0 : _b.main, color: '#fff', '&:hover': {
360
+ backgroundColor: ((_c = theme.palette.primary) === null || _c === void 0 ? void 0 : _c.dark) || ((_d = theme.palette.primary) === null || _d === void 0 ? void 0 : _d.main),
361
+ } }, sx) : sx;
362
+ return (jsx(Button$1, Object.assign({ variant: variant, color: tenantColored ? undefined : color, sx: buttonSx }, props)));
363
+ }
364
+
365
+ /**
366
+ * Card component with tenant theme support
367
+ *
368
+ * @example
369
+ * ```tsx
370
+ * <Card
371
+ * title="My Card"
372
+ * content="Card content"
373
+ * actions={<Button>Action</Button>}
374
+ * tenantAccent
375
+ * />
376
+ * ```
377
+ */
378
+ function Card(_a) {
379
+ var _b;
380
+ var { title, headerAction, content, actions, tenantAccent = false, sx, children } = _a, props = __rest(_a, ["title", "headerAction", "content", "actions", "tenantAccent", "sx", "children"]);
381
+ const { theme } = useTenantTheme();
382
+ const cardSx = tenantAccent
383
+ ? Object.assign({ borderTop: `4px solid ${(_b = theme.palette.primary) === null || _b === void 0 ? void 0 : _b.main}` }, sx) : sx;
384
+ return (jsxs(Card$1, Object.assign({ sx: cardSx }, props, { children: [title && jsx(CardHeader, { title: title, action: headerAction }), (content || children) && (jsx(CardContent, { children: content || children })), actions && jsx(CardActions, { children: actions })] })));
385
+ }
386
+
387
+ /**
388
+ * Banner component with tenant theme support
389
+ *
390
+ * @example
391
+ * ```tsx
392
+ * <Banner
393
+ * title="Welcome to Our Platform"
394
+ * description="Get started today"
395
+ * action={<Button>Get Started</Button>}
396
+ * gradient
397
+ * />
398
+ * ```
399
+ */
400
+ function Banner(_a) {
401
+ var _b, _c, _d, _e;
402
+ var { title, description, action, gradient = true, sx } = _a, props = __rest(_a, ["title", "description", "action", "gradient", "sx"]);
403
+ const { theme } = useTenantTheme();
404
+ const background = gradient
405
+ ? `linear-gradient(135deg, ${(_b = theme.palette.primary) === null || _b === void 0 ? void 0 : _b.main} 0%, ${((_c = theme.palette.primary) === null || _c === void 0 ? void 0 : _c.light) || ((_d = theme.palette.primary) === null || _d === void 0 ? void 0 : _d.main)} 100%)`
406
+ : (_e = theme.palette.primary) === null || _e === void 0 ? void 0 : _e.main;
407
+ return (jsxs(Box, Object.assign({ sx: Object.assign({ background, color: 'white', padding: '32px', borderRadius: '12px', textAlign: 'center' }, sx) }, props, { children: [jsx(Typography, Object.assign({ variant: "h4", component: "h2", gutterBottom: true, fontWeight: "bold" }, { children: title })), description && (jsx(Typography, Object.assign({ variant: "body1", sx: { opacity: 0.95, mb: action ? 2 : 0 } }, { children: description }))), action && jsx(Box, Object.assign({ sx: { mt: 2 } }, { children: action }))] })));
408
+ }
409
+
410
+ /**
411
+ * Theme Utility Functions
412
+ * Helper functions for working with tenant themes
413
+ */
414
+ /**
415
+ * Get color value from theme palette path
416
+ * @param theme - Tenant theme configuration
417
+ * @param path - Dot-notation path to color (e.g., 'primary.main')
418
+ * @param defaultColor - Fallback color if path not found
419
+ * @returns Color string
420
+ */
421
+ function getThemeColor(theme, path, defaultColor = '#000000') {
422
+ const keys = path.split('.');
423
+ let value = theme.palette;
424
+ for (const key of keys) {
425
+ if (value && typeof value === 'object' && key in value) {
426
+ value = value[key];
427
+ }
428
+ else {
429
+ return defaultColor;
430
+ }
431
+ }
432
+ return typeof value === 'string' ? value : defaultColor;
433
+ }
434
+ /**
435
+ * Merge tenant theme with base MUI theme
436
+ * @param baseTheme - Base MUI theme
437
+ * @param tenantTheme - Tenant-specific theme configuration
438
+ * @returns Merged theme
439
+ */
440
+ function mergeTenantTheme(baseTheme, tenantTheme) {
441
+ var _a, _b;
442
+ return Object.assign(Object.assign({}, baseTheme), { palette: Object.assign(Object.assign(Object.assign({}, baseTheme.palette), tenantTheme.palette), {
443
+ // Deep merge for nested objects
444
+ primary: Object.assign(Object.assign({}, (((_a = baseTheme.palette) === null || _a === void 0 ? void 0 : _a.primary) || {})), (tenantTheme.palette.primary || {})), secondary: Object.assign(Object.assign({}, (((_b = baseTheme.palette) === null || _b === void 0 ? void 0 : _b.secondary) || {})), (tenantTheme.palette.secondary || {})) }), typography: Object.assign(Object.assign({}, baseTheme.typography), tenantTheme.typography) });
445
+ }
446
+ /**
447
+ * Create CSS variables from tenant theme
448
+ * Useful for using theme values in CSS
449
+ * @param theme - Tenant theme configuration
450
+ * @param prefix - Prefix for CSS variable names
451
+ * @returns Object with CSS variable definitions
452
+ */
453
+ function createThemeCSSVariables(theme, prefix = '--tenant') {
454
+ var _a;
455
+ const variables = {};
456
+ // Add primary colors
457
+ if (theme.palette.primary) {
458
+ Object.entries(theme.palette.primary).forEach(([key, value]) => {
459
+ if (typeof value === 'string') {
460
+ variables[`${prefix}-primary-${key}`] = value;
461
+ }
462
+ });
463
+ }
464
+ // Add secondary colors
465
+ if (theme.palette.secondary) {
466
+ Object.entries(theme.palette.secondary).forEach(([key, value]) => {
467
+ if (typeof value === 'string') {
468
+ variables[`${prefix}-secondary-${key}`] = value;
469
+ }
470
+ });
471
+ }
472
+ // Add font family
473
+ if ((_a = theme.typography) === null || _a === void 0 ? void 0 : _a.fontFamily) {
474
+ variables[`${prefix}-font-family`] = theme.typography.fontFamily;
475
+ }
476
+ return variables;
477
+ }
478
+
479
+ export { Banner, Button, Card, TenantThemeProvider, ammetlifeTheme, cimbTheme, createThemeCSSVariables, getAvailableTenants, getTenantTheme, getThemeColor, iglooTheme, isValidTenantId, mergeTenantTheme, tenantThemes, useIsTenant, useTenantId, useTenantTheme };
@@ -4,7 +4,8 @@
4
4
  */
5
5
  export { TenantThemeProvider, useTenantTheme, useTenantId, useIsTenant, } from './context/TenantThemeContext';
6
6
  export type { TenantThemeProviderProps } from './context/TenantThemeContext';
7
- export type { TenantPalette, TenantTypography, TenantThemeConfig, TenantContextValue, } from './types/tenant';
7
+ export type { ColorShade, TenantPalette, TenantTypography, TenantThemeConfig, TenantContextValue, TenantId, } from './types/tenant';
8
+ export { iglooTheme, cimbTheme, ammetlifeTheme, tenantThemes, getTenantTheme, isValidTenantId, getAvailableTenants, } from './themes';
8
9
  export { Button } from './components/Button';
9
10
  export type { ButtonProps } from './components/Button';
10
11
  export { Card } from './components/Card';
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Tenant Theme Configurations
3
+ * Centralized theme definitions for all tenants
4
+ */
5
+ import { TenantThemeConfig, TenantId } from '../types/tenant';
6
+ /**
7
+ * Igloo Theme Configuration
8
+ */
9
+ export declare const iglooTheme: TenantThemeConfig;
10
+ /**
11
+ * CIMB Theme Configuration
12
+ */
13
+ export declare const cimbTheme: TenantThemeConfig;
14
+ /**
15
+ * Ammetlife Theme Configuration
16
+ */
17
+ export declare const ammetlifeTheme: TenantThemeConfig;
18
+ /**
19
+ * Theme Registry
20
+ * Map of tenant IDs to their theme configurations
21
+ */
22
+ export declare const tenantThemes: Record<TenantId, TenantThemeConfig>;
23
+ /**
24
+ * Get theme configuration by tenant ID
25
+ * @param tenantId - The tenant identifier
26
+ * @returns Theme configuration for the specified tenant
27
+ * @throws Error if tenant ID is not found
28
+ */
29
+ export declare function getTenantTheme(tenantId: TenantId): TenantThemeConfig;
30
+ /**
31
+ * Check if a tenant ID is valid
32
+ * @param tenantId - The tenant identifier to validate
33
+ * @returns True if the tenant ID is valid
34
+ */
35
+ export declare function isValidTenantId(tenantId: string): tenantId is TenantId;
36
+ /**
37
+ * Get all available tenant IDs
38
+ * @returns Array of all registered tenant IDs
39
+ */
40
+ export declare function getAvailableTenants(): TenantId[];
@@ -2,24 +2,32 @@
2
2
  * Tenant Theme Configuration Types
3
3
  * These interfaces define the structure for tenant-specific theming
4
4
  */
5
+ export interface ColorShade {
6
+ main: string;
7
+ dark?: string;
8
+ light?: string;
9
+ bright?: string;
10
+ plain?: string;
11
+ border?: string;
12
+ dim?: string;
13
+ mediumBright?: string;
14
+ lighter?: string;
15
+ darkAI?: string;
16
+ buttonBg?: string;
17
+ granite?: string;
18
+ }
5
19
  export interface TenantPalette {
6
- primary?: {
7
- main: string;
8
- dark?: string;
9
- light?: string;
10
- bright?: string;
11
- plain?: string;
12
- border?: string;
13
- };
14
- secondary?: {
15
- dim?: string;
16
- dark?: string;
17
- main: string;
18
- bright?: string;
19
- mediumBright?: string;
20
- light?: string;
21
- lighter?: string;
22
- };
20
+ paCimb?: ColorShade;
21
+ primary?: ColorShade;
22
+ secondary?: ColorShade;
23
+ tertiary?: ColorShade;
24
+ natural?: ColorShade;
25
+ motor?: ColorShade;
26
+ car?: ColorShade;
27
+ travel?: ColorShade;
28
+ health?: ColorShade;
29
+ life?: ColorShade;
30
+ pet?: ColorShade;
23
31
  [key: string]: any;
24
32
  }
25
33
  export interface TenantTypography {
@@ -29,6 +37,8 @@ export interface TenantTypography {
29
37
  export interface TenantThemeConfig {
30
38
  palette: TenantPalette;
31
39
  typography?: TenantTypography;
40
+ logo?: string;
41
+ favicon?: string;
32
42
  }
33
43
  /**
34
44
  * Tenant Context Value
@@ -38,3 +48,7 @@ export interface TenantContextValue {
38
48
  tenantId: string;
39
49
  theme: TenantThemeConfig;
40
50
  }
51
+ /**
52
+ * Supported Tenant IDs
53
+ */
54
+ export type TenantId = 'igloo' | 'cimb' | 'ammetlife';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "igloo-d2c-components",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "description": "Reusable component library with tenant-aware theming for B2C applications",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -72,13 +72,17 @@
72
72
  "eslint-plugin-react-hooks": "^4.6.0",
73
73
  "react": "^17.0.0",
74
74
  "react-dom": "^17.0.0",
75
- "rimraf": "^5.0.0",
75
+ "rimraf": "^4.4.1",
76
76
  "rollup": "^3.29.5",
77
77
  "rollup-plugin-peer-deps-external": "^2.2.4",
78
78
  "tslib": "^2.8.1",
79
79
  "typescript": "^4.9.0",
80
80
  "vite": "4.3.9"
81
81
  },
82
+ "resolutions": {
83
+ "minimatch": "^5.1.6",
84
+ "glob": "^8.1.0"
85
+ },
82
86
  "publishConfig": {
83
87
  "access": "public",
84
88
  "registry": "https://registry.npmjs.org/"
@@ -87,4 +91,4 @@
87
91
  "url": "https://gitlab.iglooinsure.com/axinan/fe/d2c-component-library/-/issues"
88
92
  },
89
93
  "homepage": "https://gitlab.iglooinsure.com/axinan/fe/d2c-component-library#readme"
90
- }
94
+ }
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sources":["../../src/context/TenantThemeContext.tsx","../../src/components/Banner/Banner.tsx","../../src/components/Button/Button.tsx","../../src/components/Card/Card.tsx","../../src/utils/theme.ts"],"sourcesContent":[null,null,null,null,null],"names":["TenantThemeContext","createContext","undefined","useTenantTheme","context","useContext","Error","title","description","action","gradient","sx","props","theme","background","palette","primary","main","light","_jsxs","jsxs","Box","color","padding","borderRadius","textAlign","children","_jsx","jsx","Typography","variant","component","gutterBottom","fontWeight","opacity","mb","mt","tenantColored","buttonSx","backgroundColor","dark","MuiButton","Button","headerAction","content","actions","tenantAccent","cardSx","borderTop","MuiCard","CardHeader","CardContent","CardActions","tenantId","value","useMemo","Provider","prefix","variables","Object","entries","forEach","key","secondary","typography","fontFamily","path","defaultColor","keys","split","baseTheme","tenantTheme","checkTenantId"],"mappings":"8FAQA,MAAMA,EAAqBC,EAAAA,mBAA8CC,YA8CzDC,IACf,MAAMC,EAAUC,aAAWL,GAE3B,QAAgBE,IAAZE,EACH,MAAM,IAAIE,MAAM,4DAGjB,OAAOF,CACR,0BCtBuBG,MACtBA,EAAKC,YACLA,EAAWC,OACXA,EAAMC,SACNA,GAAW,EAAIC,GACfA,KACGC,IAEH,MAAMC,MAAEA,GAAUV,IAEZW,EAAaJ,EAChB,2BAA2BG,EAAME,QAAQC,SAASC,YAClDJ,EAAME,QAAQC,SAASE,OAASL,EAAME,QAAQC,SAASC,aAEvDJ,EAAME,QAAQC,SAASC,KAE1B,OACCE,EAAAC,KAACC,MAAG,CACHV,GAAI,CACHG,aACAQ,MAAO,QACPC,QAAS,OACTC,aAAc,OACdC,UAAW,YACRd,MAEAC,EAAKc,SAAA,CAETC,EAACC,IAAAC,cAAWC,QAAQ,KAAKC,UAAU,KAAKC,gBAAaC,WAAW,OAAMP,SACpEnB,IAEDC,GACAmB,MAACE,EAAAA,WAAU,CAACC,QAAQ,QAAQnB,GAAI,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,2CI0BCb,EACA4C,EAAS,YAET,MAAMC,EAAoC,CAAA,EAyB1C,OAtBI7C,EAAME,QAAQC,SACjB2C,OAAOC,QAAQ/C,EAAME,QAAQC,SAAS6C,QAAQ,EAAEC,EAAKR,MAC/B,iBAAVA,IACVI,EAAU,GAAGD,aAAkBK,KAASR,KAMvCzC,EAAME,QAAQgD,WACjBJ,OAAOC,QAAQ/C,EAAME,QAAQgD,WAAWF,QAAQ,EAAEC,EAAKR,MACjC,iBAAVA,IACVI,EAAU,GAAGD,eAAoBK,KAASR,KAMzCzC,EAAMmD,YAAYC,aACrBP,EAAU,GAAGD,iBAAwB5C,EAAMmD,WAAWC,YAGhDP,CACR,wBAxFM,SACL7C,EACAqD,EACAC,EAAe,WAEf,MAAMC,EAAOF,EAAKG,MAAM,KACxB,IAAIf,EAAazC,EAAME,QAEvB,IAAK,MAAM+C,KAAOM,EAAM,CACvB,IAAId,GAA0B,iBAAVA,KAAsBQ,KAAOR,GAGhD,OAAOa,EAFPb,EAAQA,EAAMQ,EAIf,CAED,MAAwB,iBAAVR,EAAqBA,EAAQa,CAC5C,2BAQgB,SACfG,EACAC,GAEA,MAAO,IACHD,EACHvD,QAAS,IACLuD,EAAUvD,WACVwD,EAAYxD,QAEfC,QAAS,IACJsD,EAAUvD,SAASC,SAAW,MAC9BuD,EAAYxD,QAAQC,SAAW,IAEpC+C,UAAW,IACNO,EAAUvD,SAASgD,WAAa,MAChCQ,EAAYxD,QAAQgD,WAAa,KAGvCC,WAAY,IACRM,EAAUN,cACVO,EAAYP,YAGlB,sBJWM,SAAsBQ,GAC3B,MAAMnB,SAAEA,GAAalD,IACrB,OAAOkD,IAAamB,CACrB,iCAVC,MAAMnB,SAAEA,GAAalD,IACrB,OAAOkD,CACR"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sources":["../../src/context/TenantThemeContext.tsx","../../src/components/Button/Button.tsx","../../src/components/Card/Card.tsx","../../src/components/Banner/Banner.tsx","../../src/utils/theme.ts"],"sourcesContent":[null,null,null,null,null],"names":["TenantThemeContext","createContext","undefined","TenantThemeProvider","children","tenantId","theme","value","useMemo","_jsx","Provider","useTenantTheme","context","useContext","Error","useTenantId","useIsTenant","checkTenantId","Button","tenantColored","variant","sx","color","props","buttonSx","backgroundColor","palette","primary","main","dark","MuiButton","Card","title","headerAction","content","actions","tenantAccent","cardSx","borderTop","_jsxs","MuiCard","CardHeader","action","CardContent","CardActions","Banner","description","gradient","background","light","Box","padding","borderRadius","textAlign","Typography","component","gutterBottom","fontWeight","opacity","mb","mt","getThemeColor","path","defaultColor","keys","split","key","mergeTenantTheme","baseTheme","tenantTheme","secondary","typography","createThemeCSSVariables","prefix","variables","Object","entries","forEach","fontFamily"],"mappings":"iPAQA,MAAMA,EAAqBC,OAA8CC,GAsBnE,SAAUC,GAAoBC,SACnCA,EAAQC,SACRA,EAAQC,MACRA,IAEA,MAAMC,EAAQC,EACb,KAAO,CACNH,WACAC,UAED,CAACD,EAAUC,IAGZ,OACCG,EAACT,EAAmBU,SAAQ,CAACH,MAAOA,EAAKH,SACvCA,GAGJ,UAMgBO,IACf,MAAMC,EAAUC,EAAWb,GAE3B,QAAgBE,IAAZU,EACH,MAAM,IAAIE,MAAM,4DAGjB,OAAOF,CACR,UAKgBG,IACf,MAAMV,SAAEA,GAAaM,IACrB,OAAON,CACR,CAKM,SAAUW,EAAYC,GAC3B,MAAMZ,SAAEA,GAAaM,IACrB,OAAON,IAAaY,CACrB,UC3CgBC,GAAOC,cACtBA,GAAgB,EAAKC,QACrBA,EAAU,YAAWC,GACrBA,EAAEC,MACFA,KACGC,IAEH,MAAMjB,MAAEA,GAAUK,IAEZa,EAAWL,EACd,CACAM,gBAAiBnB,EAAMoB,QAAQC,SAASC,KACxCN,MAAO,OACP,UAAW,CACVG,gBAAiBnB,EAAMoB,QAAQC,SAASE,MAAQvB,EAAMoB,QAAQC,SAASC,SAErEP,GAEHA,EAEH,OACCZ,EAACqB,EACA,CAAAV,QAASA,EACTE,MAA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