@chatwidgetai/chat-widget 0.1.4 → 0.1.5
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/components/ChatWidget.d.ts +6 -0
- package/dist/components/ChatWidget.d.ts.map +1 -1
- package/dist/components/ChatWindow.d.ts.map +1 -1
- package/dist/components/FeedbackButtons.d.ts +1 -0
- package/dist/components/FeedbackButtons.d.ts.map +1 -1
- package/dist/components/Message.d.ts.map +1 -1
- package/dist/components/SuggestedQuestions.d.ts +1 -0
- package/dist/components/SuggestedQuestions.d.ts.map +1 -1
- package/dist/index.esm.js +491 -62
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +491 -62
- package/dist/index.js.map +1 -1
- package/dist/utils/autoThemeDetector.d.ts +27 -0
- package/dist/utils/autoThemeDetector.d.ts.map +1 -0
- package/dist/utils/colorUtils.d.ts +91 -0
- package/dist/utils/colorUtils.d.ts.map +1 -0
- package/dist/utils/generateThemeStyles.d.ts +23 -0
- package/dist/utils/generateThemeStyles.d.ts.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auto Theme Detector
|
|
3
|
+
* Detects whether the widget should use light or dark mode
|
|
4
|
+
* based on the background behind it
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Sample the background color behind an element
|
|
8
|
+
* Uses multiple sampling points for accuracy
|
|
9
|
+
*/
|
|
10
|
+
export declare function sampleBackgroundColor(element: HTMLElement): string;
|
|
11
|
+
/**
|
|
12
|
+
* Determine if the background is dark
|
|
13
|
+
*/
|
|
14
|
+
export declare function isBackgroundDark(backgroundColor: string): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Auto-detect theme based on background
|
|
17
|
+
*/
|
|
18
|
+
export declare function detectTheme(element: HTMLElement): 'light' | 'dark';
|
|
19
|
+
/**
|
|
20
|
+
* Check system preference for dark mode
|
|
21
|
+
*/
|
|
22
|
+
export declare function getSystemThemePreference(): 'light' | 'dark';
|
|
23
|
+
/**
|
|
24
|
+
* Create a MutationObserver to watch for theme changes
|
|
25
|
+
*/
|
|
26
|
+
export declare function createThemeObserver(element: HTMLElement, callback: (theme: 'light' | 'dark') => void): MutationObserver;
|
|
27
|
+
//# sourceMappingURL=autoThemeDetector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"autoThemeDetector.d.ts","sourceRoot":"","sources":["../../src/utils/autoThemeDetector.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,WAAW,GAAG,MAAM,CAgDlE;AAoBD;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO,CAGjE;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,GAAG,MAAM,CAGlE;AAED;;GAEG;AACH,wBAAgB,wBAAwB,IAAI,OAAO,GAAG,MAAM,CAG3D;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,WAAW,EACpB,QAAQ,EAAE,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,KAAK,IAAI,GAC1C,gBAAgB,CAmBlB"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Color Utilities for Widget Theme System
|
|
3
|
+
* Handles color manipulation and auto light/dark detection
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Parse hex color to RGB values
|
|
7
|
+
*/
|
|
8
|
+
export declare function hexToRgb(hex: string): {
|
|
9
|
+
r: number;
|
|
10
|
+
g: number;
|
|
11
|
+
b: number;
|
|
12
|
+
} | null;
|
|
13
|
+
/**
|
|
14
|
+
* Convert RGB to hex
|
|
15
|
+
*/
|
|
16
|
+
export declare function rgbToHex(r: number, g: number, b: number): string;
|
|
17
|
+
/**
|
|
18
|
+
* Calculate relative luminance of a color (0-1)
|
|
19
|
+
* Used to determine if a color is light or dark
|
|
20
|
+
*/
|
|
21
|
+
export declare function getLuminance(hex: string): number;
|
|
22
|
+
/**
|
|
23
|
+
* Determine if a color is considered "light" (luminance > 0.5)
|
|
24
|
+
*/
|
|
25
|
+
export declare function isLightColor(hex: string): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Lighten a color by a percentage
|
|
28
|
+
*/
|
|
29
|
+
export declare function lighten(hex: string, percent: number): string;
|
|
30
|
+
/**
|
|
31
|
+
* Darken a color by a percentage
|
|
32
|
+
*/
|
|
33
|
+
export declare function darken(hex: string, percent: number): string;
|
|
34
|
+
/**
|
|
35
|
+
* Create a color with alpha transparency
|
|
36
|
+
*/
|
|
37
|
+
export declare function withAlpha(hex: string, alpha: number): string;
|
|
38
|
+
/**
|
|
39
|
+
* Get contrasting text color (black or white) for a background
|
|
40
|
+
*/
|
|
41
|
+
export declare function getContrastText(backgroundColor: string): string;
|
|
42
|
+
/**
|
|
43
|
+
* Generate a complete color palette from an accent color for light mode
|
|
44
|
+
*/
|
|
45
|
+
export declare function generateLightPalette(accentColor: string): {
|
|
46
|
+
accent: string;
|
|
47
|
+
accentHover: string;
|
|
48
|
+
accentSubtle: string;
|
|
49
|
+
background: string;
|
|
50
|
+
backgroundSubtle: string;
|
|
51
|
+
backgroundMuted: string;
|
|
52
|
+
text: string;
|
|
53
|
+
textMuted: string;
|
|
54
|
+
textSubtle: string;
|
|
55
|
+
border: string;
|
|
56
|
+
borderSubtle: string;
|
|
57
|
+
userBubble: string;
|
|
58
|
+
userBubbleText: string;
|
|
59
|
+
assistantBubble: string;
|
|
60
|
+
assistantBubbleText: string;
|
|
61
|
+
inputBackground: string;
|
|
62
|
+
inputBorder: string;
|
|
63
|
+
inputBorderFocus: string;
|
|
64
|
+
shadow: string;
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Generate a complete color palette from an accent color for dark mode
|
|
68
|
+
*/
|
|
69
|
+
export declare function generateDarkPalette(accentColor: string): {
|
|
70
|
+
accent: string;
|
|
71
|
+
accentHover: string;
|
|
72
|
+
accentSubtle: string;
|
|
73
|
+
background: string;
|
|
74
|
+
backgroundSubtle: string;
|
|
75
|
+
backgroundMuted: string;
|
|
76
|
+
text: string;
|
|
77
|
+
textMuted: string;
|
|
78
|
+
textSubtle: string;
|
|
79
|
+
border: string;
|
|
80
|
+
borderSubtle: string;
|
|
81
|
+
userBubble: string;
|
|
82
|
+
userBubbleText: string;
|
|
83
|
+
assistantBubble: string;
|
|
84
|
+
assistantBubbleText: string;
|
|
85
|
+
inputBackground: string;
|
|
86
|
+
inputBorder: string;
|
|
87
|
+
inputBorderFocus: string;
|
|
88
|
+
shadow: string;
|
|
89
|
+
};
|
|
90
|
+
export type ColorPalette = ReturnType<typeof generateLightPalette>;
|
|
91
|
+
//# sourceMappingURL=colorUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"colorUtils.d.ts","sourceRoot":"","sources":["../../src/utils/colorUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAShF;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAKhE;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAWhD;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAEjD;AAED;;GAEG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAY5D;AAED;;GAEG;AACH,wBAAgB,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAY3D;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAI5D;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,eAAe,EAAE,MAAM,GAAG,MAAM,CAE/D;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;EAmCvD;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;EAsCtD;AAED,MAAM,MAAM,YAAY,GAAG,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generate Theme Styles
|
|
3
|
+
* Creates CSS custom properties from accent color and theme mode
|
|
4
|
+
*/
|
|
5
|
+
export interface SimpleWidgetAppearance {
|
|
6
|
+
accentColor: string;
|
|
7
|
+
position: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
|
|
8
|
+
size: 'small' | 'medium' | 'large';
|
|
9
|
+
welcomeTitle?: string;
|
|
10
|
+
welcomeMessage?: string;
|
|
11
|
+
placeholder?: string;
|
|
12
|
+
headerTitle?: string;
|
|
13
|
+
buttonIcon?: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Generate all CSS custom properties for the widget
|
|
17
|
+
*/
|
|
18
|
+
export declare function generateThemeStyles(appearance: SimpleWidgetAppearance, theme: 'light' | 'dark'): Record<string, string>;
|
|
19
|
+
/**
|
|
20
|
+
* Apply theme styles to an element
|
|
21
|
+
*/
|
|
22
|
+
export declare function applyThemeStyles(element: HTMLElement, appearance: SimpleWidgetAppearance, theme: 'light' | 'dark'): void;
|
|
23
|
+
//# sourceMappingURL=generateThemeStyles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateThemeStyles.d.ts","sourceRoot":"","sources":["../../src/utils/generateThemeStyles.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,MAAM,WAAW,sBAAsB;IACrC,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,cAAc,GAAG,aAAa,GAAG,WAAW,GAAG,UAAU,CAAC;IACpE,IAAI,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC;IACnC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,UAAU,EAAE,sBAAsB,EAClC,KAAK,EAAE,OAAO,GAAG,MAAM,GACtB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CA4HxB;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,WAAW,EACpB,UAAU,EAAE,sBAAsB,EAClC,KAAK,EAAE,OAAO,GAAG,MAAM,GACtB,IAAI,CAMN"}
|