@yartsun/chat-widget-types 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +183 -0
- package/dist/config.types.d.ts +93 -0
- package/dist/config.types.d.ts.map +1 -0
- package/dist/config.types.js +67 -0
- package/dist/config.types.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/utils.d.ts +12 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +126 -0
- package/dist/utils.js.map +1 -0
- package/package.json +42 -0
- package/src/config.types.ts +183 -0
- package/src/index.ts +2 -0
- package/src/utils.ts +141 -0
package/README.md
ADDED
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
# @hypershadow/chat-widget-types
|
|
2
|
+
|
|
3
|
+
TypeScript definitions for HyperShadow Chat Widget. Shared types package for Module Federation architecture.
|
|
4
|
+
|
|
5
|
+
## 🚀 Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @hypershadow/chat-widget-types
|
|
9
|
+
# or
|
|
10
|
+
yarn add @hypershadow/chat-widget-types
|
|
11
|
+
# or
|
|
12
|
+
pnpm add @hypershadow/chat-widget-types
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## 📖 Usage
|
|
16
|
+
|
|
17
|
+
### Basic Types Import
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
import type {
|
|
21
|
+
WidgetConfig,
|
|
22
|
+
GeneralSettings,
|
|
23
|
+
EmittedColorElement,
|
|
24
|
+
FontSettings,
|
|
25
|
+
ShapesSettings,
|
|
26
|
+
} from '@hypershadow/chat-widget-types'
|
|
27
|
+
|
|
28
|
+
// Use the types in your components
|
|
29
|
+
const config: WidgetConfig = {
|
|
30
|
+
general: {
|
|
31
|
+
title: 'My Chat',
|
|
32
|
+
subtitle: 'How can we help?',
|
|
33
|
+
placeholder: 'Type here...',
|
|
34
|
+
launchView: 'medium',
|
|
35
|
+
showBranding: true,
|
|
36
|
+
position: 'bottom-right',
|
|
37
|
+
},
|
|
38
|
+
// ... other config
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Default Configuration
|
|
43
|
+
|
|
44
|
+
```typescript
|
|
45
|
+
import { DEFAULT_CONFIG } from '@hypershadow/chat-widget-types'
|
|
46
|
+
|
|
47
|
+
// Use default config as base
|
|
48
|
+
const myConfig = {
|
|
49
|
+
...DEFAULT_CONFIG,
|
|
50
|
+
general: {
|
|
51
|
+
...DEFAULT_CONFIG.general,
|
|
52
|
+
title: 'Custom Title',
|
|
53
|
+
},
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Utilities
|
|
58
|
+
|
|
59
|
+
```typescript
|
|
60
|
+
import {
|
|
61
|
+
extractSettings,
|
|
62
|
+
buildWidgetConfig,
|
|
63
|
+
mergeConfig,
|
|
64
|
+
validateConfig,
|
|
65
|
+
createCSSVariables,
|
|
66
|
+
} from '@hypershadow/chat-widget-types/utils'
|
|
67
|
+
|
|
68
|
+
// Extract settings from config
|
|
69
|
+
const settings = extractSettings(widgetConfig)
|
|
70
|
+
|
|
71
|
+
// Build config from separate settings
|
|
72
|
+
const newConfig = buildWidgetConfig(generalSettings, shapesSettings, colorsSettings, fontSettings)
|
|
73
|
+
|
|
74
|
+
// Merge configurations
|
|
75
|
+
const mergedConfig = mergeConfig(baseConfig, updates)
|
|
76
|
+
|
|
77
|
+
// Validate configuration
|
|
78
|
+
const errors = validateConfig(config)
|
|
79
|
+
if (errors.length > 0) {
|
|
80
|
+
console.error('Config validation errors:', errors)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Create CSS variables
|
|
84
|
+
const cssVars = createCSSVariables(config.colors)
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## 🏗️ Module Federation Usage
|
|
88
|
+
|
|
89
|
+
### Host Application
|
|
90
|
+
|
|
91
|
+
```typescript
|
|
92
|
+
// In your host app components
|
|
93
|
+
import type { WidgetConfig } from '@hypershadow/chat-widget-types'
|
|
94
|
+
import { DEFAULT_CONFIG } from '@hypershadow/chat-widget-types'
|
|
95
|
+
|
|
96
|
+
const ChatWrapper: React.FC = () => {
|
|
97
|
+
const [config, setConfig] = useState<WidgetConfig>(DEFAULT_CONFIG)
|
|
98
|
+
|
|
99
|
+
return (
|
|
100
|
+
<RemoteChatComponent
|
|
101
|
+
configWidget={config}
|
|
102
|
+
isPreview={true}
|
|
103
|
+
/>
|
|
104
|
+
)
|
|
105
|
+
}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Remote Application
|
|
109
|
+
|
|
110
|
+
```typescript
|
|
111
|
+
// In your remote app
|
|
112
|
+
import type { ChatComponentProps, WidgetConfig } from '@hypershadow/chat-widget-types'
|
|
113
|
+
|
|
114
|
+
interface Props extends ChatComponentProps {
|
|
115
|
+
// Additional props
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const ChatComponent: React.FC<Props> = ({ configWidget, isEmbedded, isPreview }) => {
|
|
119
|
+
// Component implementation
|
|
120
|
+
}
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## 📦 Type Definitions
|
|
124
|
+
|
|
125
|
+
### Core Types
|
|
126
|
+
|
|
127
|
+
- `WidgetConfig` - Main widget configuration
|
|
128
|
+
- `GeneralSettings` - General widget settings
|
|
129
|
+
- `EmittedColorElement` - Color configuration
|
|
130
|
+
- `FontSettings` - Typography settings
|
|
131
|
+
- `ShapesSettings` - Shape and border settings
|
|
132
|
+
|
|
133
|
+
### Utility Types
|
|
134
|
+
|
|
135
|
+
- `LaunchView` - Widget launch modes
|
|
136
|
+
- `BorderRadius` - Border radius options
|
|
137
|
+
- `BtnType` - Button type variants
|
|
138
|
+
- `WidgetPosition` - Widget positioning
|
|
139
|
+
- `DeepPartial<T>` - Deep partial utility type
|
|
140
|
+
|
|
141
|
+
### Component Types
|
|
142
|
+
|
|
143
|
+
- `ChatComponentProps` - Props for chat components
|
|
144
|
+
- `TraceEvent` - Event tracing interface
|
|
145
|
+
|
|
146
|
+
## 🔧 Development
|
|
147
|
+
|
|
148
|
+
### Building
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
npm run build
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### Publishing
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
npm run prepublishOnly
|
|
158
|
+
npm publish
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
## 📋 Version Compatibility
|
|
162
|
+
|
|
163
|
+
| Package Version | Widget Version | Breaking Changes |
|
|
164
|
+
| --------------- | -------------- | ---------------- |
|
|
165
|
+
| 1.x.x | 1.x.x | Initial release |
|
|
166
|
+
|
|
167
|
+
## 🤝 Contributing
|
|
168
|
+
|
|
169
|
+
1. Fork the repository
|
|
170
|
+
2. Create your feature branch
|
|
171
|
+
3. Add/update types with proper JSDoc comments
|
|
172
|
+
4. Update version in package.json
|
|
173
|
+
5. Submit a pull request
|
|
174
|
+
|
|
175
|
+
## 📄 License
|
|
176
|
+
|
|
177
|
+
MIT License - see LICENSE file for details.
|
|
178
|
+
|
|
179
|
+
## 🔗 Links
|
|
180
|
+
|
|
181
|
+
- [GitHub Repository](https://github.com/hypershadow/chat-widget-types)
|
|
182
|
+
- [npm Package](https://www.npmjs.com/package/@hypershadow/chat-widget-types)
|
|
183
|
+
- [Documentation](https://docs.hypershadow.io/widget-types)
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Типы для конфигурации виджета чата
|
|
3
|
+
*/
|
|
4
|
+
export type Size = 'sm' | 'md' | 'lg';
|
|
5
|
+
export type BorderRadius = '0' | 'sm' | 'md' | 'lg';
|
|
6
|
+
export type BtnType = 'icon' | 'text' | 'both';
|
|
7
|
+
export type LaunchView = 'closed' | 'compact' | 'open';
|
|
8
|
+
export interface ColorItems {
|
|
9
|
+
color?: string;
|
|
10
|
+
bgColor?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface UIElement {
|
|
13
|
+
color: string;
|
|
14
|
+
bgColor?: string;
|
|
15
|
+
type?: BtnType;
|
|
16
|
+
}
|
|
17
|
+
export interface SectionParams {
|
|
18
|
+
size: Size;
|
|
19
|
+
}
|
|
20
|
+
export interface WidgetSettings {
|
|
21
|
+
widgetTitle: string;
|
|
22
|
+
welcomeMessage: string;
|
|
23
|
+
bgChat: string;
|
|
24
|
+
gapMessageLine: number;
|
|
25
|
+
paddingChat: number;
|
|
26
|
+
fontFamily: string;
|
|
27
|
+
borderRadius: BorderRadius;
|
|
28
|
+
launchView: LaunchView;
|
|
29
|
+
letterSpacing: number;
|
|
30
|
+
}
|
|
31
|
+
export interface TopSection {
|
|
32
|
+
params: SectionParams;
|
|
33
|
+
chipWidgetTitle: UIElement;
|
|
34
|
+
btnClose: UIElement;
|
|
35
|
+
}
|
|
36
|
+
export interface InsideSection {
|
|
37
|
+
params: SectionParams;
|
|
38
|
+
messageUser: UIElement;
|
|
39
|
+
messageBot: UIElement;
|
|
40
|
+
welcomeMessage: UIElement;
|
|
41
|
+
}
|
|
42
|
+
export interface BottomSection {
|
|
43
|
+
params: SectionParams;
|
|
44
|
+
inputSend: UIElement;
|
|
45
|
+
btnSend: UIElement;
|
|
46
|
+
activeBtn: UIElement;
|
|
47
|
+
}
|
|
48
|
+
export interface WidgetSections {
|
|
49
|
+
top: TopSection;
|
|
50
|
+
inside: InsideSection;
|
|
51
|
+
bottom: BottomSection;
|
|
52
|
+
}
|
|
53
|
+
export interface WidgetConfig {
|
|
54
|
+
settings: WidgetSettings;
|
|
55
|
+
sections: WidgetSections;
|
|
56
|
+
}
|
|
57
|
+
export type PartialWidgetConfig = Partial<WidgetConfig>;
|
|
58
|
+
export type PartialWidgetSettings = Partial<WidgetSettings>;
|
|
59
|
+
export type PartialWidgetSections = Partial<WidgetSections>;
|
|
60
|
+
export type ConfigKey = keyof WidgetConfig;
|
|
61
|
+
export type SettingsKey = keyof WidgetSettings;
|
|
62
|
+
export type SectionsKey = keyof WidgetSections;
|
|
63
|
+
export interface ConfigValidationResult {
|
|
64
|
+
isValid: boolean;
|
|
65
|
+
errors: string[];
|
|
66
|
+
}
|
|
67
|
+
export type GeneralSettings = Pick<WidgetSettings, 'widgetTitle' | 'welcomeMessage' | 'launchView'>;
|
|
68
|
+
export type ShapesSettings = Pick<WidgetSettings, 'gapMessageLine' | 'paddingChat' | 'fontFamily' | 'borderRadius'> & {
|
|
69
|
+
bottomSize: WidgetConfig['sections']['bottom']['params']['size'];
|
|
70
|
+
sendButtonType: BtnType;
|
|
71
|
+
headerSize: WidgetConfig['sections']['top']['params']['size'];
|
|
72
|
+
messageSize: WidgetConfig['sections']['inside']['params']['size'];
|
|
73
|
+
};
|
|
74
|
+
export type EmittedColorElement = {
|
|
75
|
+
bgChat: ColorItems;
|
|
76
|
+
chipWidgetTitle: ColorItems;
|
|
77
|
+
btnClose: ColorItems;
|
|
78
|
+
messageUser: ColorItems;
|
|
79
|
+
messageBot: ColorItems;
|
|
80
|
+
inputSend: ColorItems;
|
|
81
|
+
btnSend: ColorItems;
|
|
82
|
+
activeBtn: ColorItems;
|
|
83
|
+
welcomeMessage: ColorItems;
|
|
84
|
+
};
|
|
85
|
+
export interface FontSettings {
|
|
86
|
+
fontFamily: string;
|
|
87
|
+
letterSpacing: number;
|
|
88
|
+
}
|
|
89
|
+
export declare const DEFAULT_CONFIG: WidgetConfig;
|
|
90
|
+
export type DeepPartial<T> = {
|
|
91
|
+
[P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
|
|
92
|
+
};
|
|
93
|
+
//# sourceMappingURL=config.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.types.d.ts","sourceRoot":"","sources":["../src/config.types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,MAAM,MAAM,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAA;AAC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B,GAAG;IAChC,MAAM,EAAE,UAAU,CAAA;IAClB,eAAe,EAAE,UAAU,CAAA;IAC3B,QAAQ,EAAE,UAAU,CAAA;IACpB,WAAW,EAAE,UAAU,CAAA;IACvB,UAAU,EAAE,UAAU,CAAA;IACtB,SAAS,EAAE,UAAU,CAAA;IACrB,OAAO,EAAE,UAAU,CAAA;IACnB,SAAS,EAAE,UAAU,CAAA;IACrB,cAAc,EAAE,UAAU,CAAA;CAC3B,CAAA;AACD,MAAM,WAAW,YAAY;IAC3B,UAAU,EAAE,MAAM,CAAA;IAClB,aAAa,EAAE,MAAM,CAAA;CACtB;AAGD,eAAO,MAAM,cAAc,EAAE,YA8D5B,CAAA;AAGD,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI;KAC1B,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,MAAM,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAChE,CAAA"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Типы для конфигурации виджета чата
|
|
3
|
+
*/
|
|
4
|
+
// Экспорт дефолтной конфигурации (для типизации)
|
|
5
|
+
export const DEFAULT_CONFIG = {
|
|
6
|
+
settings: {
|
|
7
|
+
widgetTitle: 'HyperShadow',
|
|
8
|
+
welcomeMessage: '🖖 Hi there — I’m your assistant for finding documents, tracking access, and making sense of your files. \n\nHow can I help?',
|
|
9
|
+
bgChat: 'rgba(47, 47, 49, 0.90)',
|
|
10
|
+
gapMessageLine: 12,
|
|
11
|
+
paddingChat: 8,
|
|
12
|
+
fontFamily: 'MacPaw Fixel',
|
|
13
|
+
borderRadius: 'lg',
|
|
14
|
+
launchView: 'closed',
|
|
15
|
+
letterSpacing: 0,
|
|
16
|
+
},
|
|
17
|
+
sections: {
|
|
18
|
+
top: {
|
|
19
|
+
params: {
|
|
20
|
+
size: 'md',
|
|
21
|
+
},
|
|
22
|
+
chipWidgetTitle: {
|
|
23
|
+
color: '#BEB6E9',
|
|
24
|
+
bgColor: '#5E4AC6',
|
|
25
|
+
},
|
|
26
|
+
btnClose: {
|
|
27
|
+
color: '#BBBBBD',
|
|
28
|
+
bgColor: '#2F2F31',
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
inside: {
|
|
32
|
+
params: {
|
|
33
|
+
size: 'md',
|
|
34
|
+
},
|
|
35
|
+
messageUser: {
|
|
36
|
+
color: '#F9F8F8',
|
|
37
|
+
bgColor: '#F8F8F933',
|
|
38
|
+
},
|
|
39
|
+
messageBot: {
|
|
40
|
+
color: '#fff',
|
|
41
|
+
bgColor: '#5E4AC6',
|
|
42
|
+
},
|
|
43
|
+
welcomeMessage: {
|
|
44
|
+
color: '#fff',
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
bottom: {
|
|
48
|
+
params: {
|
|
49
|
+
size: 'sm',
|
|
50
|
+
},
|
|
51
|
+
inputSend: {
|
|
52
|
+
color: '#EEECEC',
|
|
53
|
+
bgColor: '#1E1E1E',
|
|
54
|
+
},
|
|
55
|
+
btnSend: {
|
|
56
|
+
color: '#1E1E1E',
|
|
57
|
+
bgColor: 'rgba(255, 255, 255, 0.50)',
|
|
58
|
+
type: 'both',
|
|
59
|
+
},
|
|
60
|
+
activeBtn: {
|
|
61
|
+
color: '#fff',
|
|
62
|
+
bgColor: '#F8F8F933',
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
//# sourceMappingURL=config.types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.types.js","sourceRoot":"","sources":["../src/config.types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAgHH,iDAAiD;AACjD,MAAM,CAAC,MAAM,cAAc,GAAiB;IAC1C,QAAQ,EAAE;QACR,WAAW,EAAE,aAAa;QAC1B,cAAc,EACZ,8HAA8H;QAChI,MAAM,EAAE,wBAAwB;QAChC,cAAc,EAAE,EAAE;QAClB,WAAW,EAAE,CAAC;QACd,UAAU,EAAE,cAAc;QAC1B,YAAY,EAAE,IAAI;QAClB,UAAU,EAAE,QAAQ;QACpB,aAAa,EAAE,CAAC;KACjB;IACD,QAAQ,EAAE;QACR,GAAG,EAAE;YACH,MAAM,EAAE;gBACN,IAAI,EAAE,IAAI;aACX;YACD,eAAe,EAAE;gBACf,KAAK,EAAE,SAAS;gBAChB,OAAO,EAAE,SAAS;aACnB;YACD,QAAQ,EAAE;gBACR,KAAK,EAAE,SAAS;gBAChB,OAAO,EAAE,SAAS;aACnB;SACF;QACD,MAAM,EAAE;YACN,MAAM,EAAE;gBACN,IAAI,EAAE,IAAI;aACX;YACD,WAAW,EAAE;gBACX,KAAK,EAAE,SAAS;gBAChB,OAAO,EAAE,WAAW;aACrB;YACD,UAAU,EAAE;gBACV,KAAK,EAAE,MAAM;gBACb,OAAO,EAAE,SAAS;aACnB;YACD,cAAc,EAAE;gBACd,KAAK,EAAE,MAAM;aACd;SACF;QACD,MAAM,EAAE;YACN,MAAM,EAAE;gBACN,IAAI,EAAE,IAAI;aACX;YACD,SAAS,EAAE;gBACT,KAAK,EAAE,SAAS;gBAChB,OAAO,EAAE,SAAS;aACnB;YACD,OAAO,EAAE;gBACP,KAAK,EAAE,SAAS;gBAChB,OAAO,EAAE,2BAA2B;gBACpC,IAAI,EAAE,MAAM;aACb;YACD,SAAS,EAAE;gBACT,KAAK,EAAE,MAAM;gBACb,OAAO,EAAE,WAAW;aACrB;SACF;KACF;CACF,CAAA"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,cAAc,SAAS,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,cAAc,SAAS,CAAA"}
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { EmittedColorElement, FontSettings, GeneralSettings, ShapesSettings, WidgetConfig } from "./config.types";
|
|
2
|
+
export declare const extractSettings: (config: WidgetConfig) => {
|
|
3
|
+
general: GeneralSettings;
|
|
4
|
+
shapes: ShapesSettings;
|
|
5
|
+
colors: EmittedColorElement;
|
|
6
|
+
font: FontSettings;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Функция для сборки полного конфига из отдельных частей
|
|
10
|
+
*/
|
|
11
|
+
export declare function buildWidgetConfig(general: GeneralSettings, shapes: ShapesSettings, colors: EmittedColorElement, fonts: FontSettings): WidgetConfig;
|
|
12
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,mBAAmB,EAAE,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,YAAY,EAAkB,MAAM,gBAAgB,CAAA;AAE1I,eAAO,MAAM,eAAe,GAAI,QAAQ,YAAY,KAAG;IACrD,OAAO,EAAE,eAAe,CAAA;IACxB,MAAM,EAAE,cAAc,CAAA;IACtB,MAAM,EAAE,mBAAmB,CAAA;IAC3B,IAAI,EAAE,YAAY,CAAA;CA4DlB,CAAA;AAGF;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,eAAe,EACxB,MAAM,EAAE,cAAc,EACtB,MAAM,EAAE,mBAAmB,EAC3B,KAAK,EAAE,YAAY,GAClB,YAAY,CA+Dd"}
|
package/dist/utils.js
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { DEFAULT_CONFIG } from "./config.types";
|
|
2
|
+
export const extractSettings = (config) => ({
|
|
3
|
+
// Общие настройки
|
|
4
|
+
general: {
|
|
5
|
+
widgetTitle: config.settings.widgetTitle,
|
|
6
|
+
welcomeMessage: config.settings.welcomeMessage,
|
|
7
|
+
launchView: config.settings.launchView,
|
|
8
|
+
},
|
|
9
|
+
// Настройки форм и размеров
|
|
10
|
+
shapes: {
|
|
11
|
+
gapMessageLine: config.settings.gapMessageLine,
|
|
12
|
+
paddingChat: config.settings.paddingChat,
|
|
13
|
+
fontFamily: config.settings.fontFamily,
|
|
14
|
+
borderRadius: config.settings.borderRadius,
|
|
15
|
+
bottomSize: config.sections.bottom.params.size,
|
|
16
|
+
sendButtonType: config.sections.bottom.btnSend.type,
|
|
17
|
+
headerSize: config.sections.top.params.size,
|
|
18
|
+
messageSize: config.sections.inside.params.size,
|
|
19
|
+
},
|
|
20
|
+
// Настройки цветов
|
|
21
|
+
colors: {
|
|
22
|
+
bgChat: { bgColor: config.settings.bgChat },
|
|
23
|
+
welcomeMessage: { color: config.sections.inside?.welcomeMessage?.color || '#fff' },
|
|
24
|
+
chipWidgetTitle: {
|
|
25
|
+
color: config.sections.top.chipWidgetTitle.color,
|
|
26
|
+
bgColor: config.sections.top.chipWidgetTitle.bgColor,
|
|
27
|
+
},
|
|
28
|
+
btnClose: {
|
|
29
|
+
color: config.sections.top.btnClose.color,
|
|
30
|
+
bgColor: config.sections.top.btnClose.bgColor,
|
|
31
|
+
},
|
|
32
|
+
messageUser: {
|
|
33
|
+
color: config.sections.inside.messageUser.color,
|
|
34
|
+
bgColor: config.sections.inside.messageUser.bgColor,
|
|
35
|
+
},
|
|
36
|
+
messageBot: {
|
|
37
|
+
color: config.sections.inside.messageBot.color,
|
|
38
|
+
bgColor: config.sections.inside.messageBot.bgColor,
|
|
39
|
+
},
|
|
40
|
+
inputSend: {
|
|
41
|
+
color: config.sections.bottom.inputSend.color,
|
|
42
|
+
bgColor: config.sections.bottom.inputSend.bgColor,
|
|
43
|
+
},
|
|
44
|
+
btnSend: {
|
|
45
|
+
color: config.sections.bottom.btnSend.color,
|
|
46
|
+
bgColor: config.sections.bottom.btnSend.bgColor,
|
|
47
|
+
},
|
|
48
|
+
activeBtn: {
|
|
49
|
+
color: config.sections.bottom.activeBtn.color,
|
|
50
|
+
bgColor: config.sections.bottom.activeBtn.bgColor,
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
// Шрифт отдельно
|
|
54
|
+
font: {
|
|
55
|
+
fontFamily: config.settings.fontFamily,
|
|
56
|
+
letterSpacing: config.settings.letterSpacing,
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
/**
|
|
60
|
+
* Функция для сборки полного конфига из отдельных частей
|
|
61
|
+
*/
|
|
62
|
+
export function buildWidgetConfig(general, shapes, colors, fonts) {
|
|
63
|
+
return {
|
|
64
|
+
settings: {
|
|
65
|
+
widgetTitle: general.widgetTitle,
|
|
66
|
+
welcomeMessage: general.welcomeMessage,
|
|
67
|
+
launchView: general.launchView,
|
|
68
|
+
bgChat: colors.bgChat.bgColor || colors.bgChat.color || DEFAULT_CONFIG.settings.bgChat,
|
|
69
|
+
gapMessageLine: shapes.gapMessageLine,
|
|
70
|
+
paddingChat: shapes.paddingChat,
|
|
71
|
+
borderRadius: shapes.borderRadius,
|
|
72
|
+
fontFamily: fonts.fontFamily,
|
|
73
|
+
letterSpacing: fonts.letterSpacing,
|
|
74
|
+
},
|
|
75
|
+
sections: {
|
|
76
|
+
top: {
|
|
77
|
+
params: {
|
|
78
|
+
size: shapes.headerSize,
|
|
79
|
+
},
|
|
80
|
+
chipWidgetTitle: {
|
|
81
|
+
color: colors.chipWidgetTitle.color || DEFAULT_CONFIG.sections.top.chipWidgetTitle.color,
|
|
82
|
+
bgColor: colors.chipWidgetTitle.bgColor || DEFAULT_CONFIG.sections.top.chipWidgetTitle.bgColor,
|
|
83
|
+
},
|
|
84
|
+
btnClose: {
|
|
85
|
+
color: colors.btnClose.color || DEFAULT_CONFIG.sections.top.btnClose.color,
|
|
86
|
+
bgColor: colors.btnClose.bgColor || DEFAULT_CONFIG.sections.top.btnClose.bgColor,
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
inside: {
|
|
90
|
+
params: {
|
|
91
|
+
size: shapes.messageSize,
|
|
92
|
+
},
|
|
93
|
+
messageUser: {
|
|
94
|
+
color: colors.messageUser.color || DEFAULT_CONFIG.sections.inside.messageUser.color,
|
|
95
|
+
bgColor: colors.messageUser.bgColor || DEFAULT_CONFIG.sections.inside.messageUser.bgColor,
|
|
96
|
+
},
|
|
97
|
+
messageBot: {
|
|
98
|
+
color: colors.messageBot.color || DEFAULT_CONFIG.sections.inside.messageBot.color,
|
|
99
|
+
bgColor: colors.messageBot.bgColor || DEFAULT_CONFIG.sections.inside.messageBot.bgColor,
|
|
100
|
+
},
|
|
101
|
+
welcomeMessage: {
|
|
102
|
+
color: colors.welcomeMessage.color || DEFAULT_CONFIG.sections.inside.welcomeMessage.color,
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
bottom: {
|
|
106
|
+
params: {
|
|
107
|
+
size: shapes.bottomSize,
|
|
108
|
+
},
|
|
109
|
+
inputSend: {
|
|
110
|
+
color: colors.inputSend.color || DEFAULT_CONFIG.sections.bottom.inputSend.color,
|
|
111
|
+
bgColor: colors.inputSend.bgColor || DEFAULT_CONFIG.sections.bottom.inputSend.bgColor,
|
|
112
|
+
},
|
|
113
|
+
btnSend: {
|
|
114
|
+
color: colors.btnSend.color || DEFAULT_CONFIG.sections.bottom.btnSend.color,
|
|
115
|
+
bgColor: colors.btnSend.bgColor || DEFAULT_CONFIG.sections.bottom.btnSend.bgColor,
|
|
116
|
+
type: shapes.sendButtonType,
|
|
117
|
+
},
|
|
118
|
+
activeBtn: {
|
|
119
|
+
color: colors.activeBtn.color || DEFAULT_CONFIG.sections.bottom.activeBtn.color,
|
|
120
|
+
bgColor: colors.activeBtn.bgColor || DEFAULT_CONFIG.sections.bottom.activeBtn.bgColor,
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
},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AAC,OAAO,IAAI,cAAc,CAAC,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO;oBACjF,IAAI,EAAE,MAAM,CAAC,cAAc;iBAC5B;gBACD,SAAS,EAAE;oBACT,KAAK,EAAE,MAAM,CAAC,SAAS,CAAC,KAAK,IAAI,cAAc,CAAC,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK;oBAC/E,OAAO,EAAE,MAAM,CAAC,SAAS,CAAC,OAAO,IAAI,cAAc,CAAC,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,OAAO;iBACtF;aACF;SACF;KACF,CAAA;AACH,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@yartsun/chat-widget-types",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "TypeScript definitions for HyperShadow Chat Widget",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist/**/*",
|
|
9
|
+
"src/**/*"
|
|
10
|
+
],
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "tsc",
|
|
13
|
+
"build:watch": "tsc --watch",
|
|
14
|
+
"clean": "rm -rf dist",
|
|
15
|
+
"prepublishOnly": "npm run clean && npm run build"
|
|
16
|
+
},
|
|
17
|
+
"keywords": [
|
|
18
|
+
"typescript",
|
|
19
|
+
"types",
|
|
20
|
+
"chat",
|
|
21
|
+
"widget",
|
|
22
|
+
"microfrontend",
|
|
23
|
+
"module-federation"
|
|
24
|
+
],
|
|
25
|
+
"author": "HyperShadow Team",
|
|
26
|
+
"license": "MIT",
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@types/node": "^24.0.13",
|
|
29
|
+
"typescript": "^5.8.3"
|
|
30
|
+
},
|
|
31
|
+
"repository": {
|
|
32
|
+
"type": "git",
|
|
33
|
+
"url": "git+https://github.com/yartsun/chat-widget-types.git"
|
|
34
|
+
},
|
|
35
|
+
"publishConfig": {
|
|
36
|
+
"access": "public"
|
|
37
|
+
},
|
|
38
|
+
"bugs": {
|
|
39
|
+
"url": "https://github.com/yartsun/chat-widget-types/issues"
|
|
40
|
+
},
|
|
41
|
+
"homepage": "https://github.com/yartsun/chat-widget-types#readme"
|
|
42
|
+
}
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Типы для конфигурации виджета чата
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
// Базовые типы
|
|
6
|
+
export type Size = 'sm' | 'md' | 'lg'
|
|
7
|
+
export type BorderRadius = '0' | 'sm' | 'md' | 'lg'
|
|
8
|
+
export type BtnType = 'icon' | 'text' | 'both'
|
|
9
|
+
export type LaunchView = 'closed' | 'compact' | 'open'
|
|
10
|
+
export interface ColorItems {
|
|
11
|
+
color?: string
|
|
12
|
+
bgColor?: string
|
|
13
|
+
}
|
|
14
|
+
// Типы для элементов интерфейса
|
|
15
|
+
export interface UIElement {
|
|
16
|
+
color: string
|
|
17
|
+
bgColor?: string
|
|
18
|
+
type?: BtnType
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface SectionParams {
|
|
22
|
+
size: Size
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Типы для настроек
|
|
26
|
+
export interface WidgetSettings {
|
|
27
|
+
widgetTitle: string
|
|
28
|
+
welcomeMessage: string
|
|
29
|
+
bgChat: string
|
|
30
|
+
gapMessageLine: number
|
|
31
|
+
paddingChat: number
|
|
32
|
+
fontFamily: string
|
|
33
|
+
borderRadius: BorderRadius
|
|
34
|
+
launchView: LaunchView
|
|
35
|
+
letterSpacing: number
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Типы для секций
|
|
39
|
+
export interface TopSection {
|
|
40
|
+
params: SectionParams
|
|
41
|
+
chipWidgetTitle: UIElement
|
|
42
|
+
btnClose: UIElement
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface InsideSection {
|
|
46
|
+
params: SectionParams
|
|
47
|
+
messageUser: UIElement
|
|
48
|
+
messageBot: UIElement
|
|
49
|
+
welcomeMessage: UIElement
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export interface BottomSection {
|
|
53
|
+
params: SectionParams
|
|
54
|
+
inputSend: UIElement
|
|
55
|
+
btnSend: UIElement
|
|
56
|
+
activeBtn: UIElement
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export interface WidgetSections {
|
|
60
|
+
top: TopSection
|
|
61
|
+
inside: InsideSection
|
|
62
|
+
bottom: BottomSection
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Основной тип конфигурации
|
|
66
|
+
export interface WidgetConfig {
|
|
67
|
+
settings: WidgetSettings
|
|
68
|
+
sections: WidgetSections
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Типы для частичного обновления конфигурации
|
|
72
|
+
export type PartialWidgetConfig = Partial<WidgetConfig>
|
|
73
|
+
export type PartialWidgetSettings = Partial<WidgetSettings>
|
|
74
|
+
export type PartialWidgetSections = Partial<WidgetSections>
|
|
75
|
+
|
|
76
|
+
// Утилитарные типы
|
|
77
|
+
export type ConfigKey = keyof WidgetConfig
|
|
78
|
+
export type SettingsKey = keyof WidgetSettings
|
|
79
|
+
export type SectionsKey = keyof WidgetSections
|
|
80
|
+
|
|
81
|
+
// Типы для валидации
|
|
82
|
+
export interface ConfigValidationResult {
|
|
83
|
+
isValid: boolean
|
|
84
|
+
errors: string[]
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
export type GeneralSettings = Pick<WidgetSettings, 'widgetTitle' | 'welcomeMessage' | 'launchView'>
|
|
89
|
+
|
|
90
|
+
export type ShapesSettings = Pick<
|
|
91
|
+
WidgetSettings,
|
|
92
|
+
'gapMessageLine' | 'paddingChat' | 'fontFamily' | 'borderRadius'
|
|
93
|
+
> & {
|
|
94
|
+
bottomSize: WidgetConfig['sections']['bottom']['params']['size']
|
|
95
|
+
sendButtonType: BtnType
|
|
96
|
+
headerSize: WidgetConfig['sections']['top']['params']['size']
|
|
97
|
+
messageSize: WidgetConfig['sections']['inside']['params']['size']
|
|
98
|
+
}
|
|
99
|
+
export type EmittedColorElement = {
|
|
100
|
+
bgChat: ColorItems
|
|
101
|
+
chipWidgetTitle: ColorItems
|
|
102
|
+
btnClose: ColorItems
|
|
103
|
+
messageUser: ColorItems
|
|
104
|
+
messageBot: ColorItems
|
|
105
|
+
inputSend: ColorItems
|
|
106
|
+
btnSend: ColorItems
|
|
107
|
+
activeBtn: ColorItems
|
|
108
|
+
welcomeMessage: ColorItems
|
|
109
|
+
}
|
|
110
|
+
export interface FontSettings {
|
|
111
|
+
fontFamily: string
|
|
112
|
+
letterSpacing: number
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// Экспорт дефолтной конфигурации (для типизации)
|
|
116
|
+
export const DEFAULT_CONFIG: WidgetConfig = {
|
|
117
|
+
settings: {
|
|
118
|
+
widgetTitle: 'HyperShadow',
|
|
119
|
+
welcomeMessage:
|
|
120
|
+
'🖖 Hi there — I’m your assistant for finding documents, tracking access, and making sense of your files. \n\nHow can I help?',
|
|
121
|
+
bgChat: 'rgba(47, 47, 49, 0.90)',
|
|
122
|
+
gapMessageLine: 12,
|
|
123
|
+
paddingChat: 8,
|
|
124
|
+
fontFamily: 'MacPaw Fixel',
|
|
125
|
+
borderRadius: 'lg',
|
|
126
|
+
launchView: 'closed',
|
|
127
|
+
letterSpacing: 0,
|
|
128
|
+
},
|
|
129
|
+
sections: {
|
|
130
|
+
top: {
|
|
131
|
+
params: {
|
|
132
|
+
size: 'md',
|
|
133
|
+
},
|
|
134
|
+
chipWidgetTitle: {
|
|
135
|
+
color: '#BEB6E9',
|
|
136
|
+
bgColor: '#5E4AC6',
|
|
137
|
+
},
|
|
138
|
+
btnClose: {
|
|
139
|
+
color: '#BBBBBD',
|
|
140
|
+
bgColor: '#2F2F31',
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
inside: {
|
|
144
|
+
params: {
|
|
145
|
+
size: 'md',
|
|
146
|
+
},
|
|
147
|
+
messageUser: {
|
|
148
|
+
color: '#F9F8F8',
|
|
149
|
+
bgColor: '#F8F8F933',
|
|
150
|
+
},
|
|
151
|
+
messageBot: {
|
|
152
|
+
color: '#fff',
|
|
153
|
+
bgColor: '#5E4AC6',
|
|
154
|
+
},
|
|
155
|
+
welcomeMessage: {
|
|
156
|
+
color: '#fff',
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
bottom: {
|
|
160
|
+
params: {
|
|
161
|
+
size: 'sm',
|
|
162
|
+
},
|
|
163
|
+
inputSend: {
|
|
164
|
+
color: '#EEECEC',
|
|
165
|
+
bgColor: '#1E1E1E',
|
|
166
|
+
},
|
|
167
|
+
btnSend: {
|
|
168
|
+
color: '#1E1E1E',
|
|
169
|
+
bgColor: 'rgba(255, 255, 255, 0.50)',
|
|
170
|
+
type: 'both',
|
|
171
|
+
},
|
|
172
|
+
activeBtn: {
|
|
173
|
+
color: '#fff',
|
|
174
|
+
bgColor: '#F8F8F933',
|
|
175
|
+
},
|
|
176
|
+
},
|
|
177
|
+
},
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// Утилитарный тип для глубоких частичных объектов
|
|
181
|
+
export type DeepPartial<T> = {
|
|
182
|
+
[P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P]
|
|
183
|
+
}
|
package/src/index.ts
ADDED
package/src/utils.ts
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { BtnType, EmittedColorElement, FontSettings, GeneralSettings, ShapesSettings, WidgetConfig, DEFAULT_CONFIG } from "./config.types"
|
|
2
|
+
|
|
3
|
+
export const extractSettings = (config: WidgetConfig): {
|
|
4
|
+
general: GeneralSettings
|
|
5
|
+
shapes: ShapesSettings
|
|
6
|
+
colors: EmittedColorElement
|
|
7
|
+
font: FontSettings
|
|
8
|
+
} => ({
|
|
9
|
+
// Общие настройки
|
|
10
|
+
general: {
|
|
11
|
+
widgetTitle: config.settings.widgetTitle,
|
|
12
|
+
welcomeMessage: config.settings.welcomeMessage,
|
|
13
|
+
launchView: config.settings.launchView,
|
|
14
|
+
} as GeneralSettings,
|
|
15
|
+
|
|
16
|
+
// Настройки форм и размеров
|
|
17
|
+
shapes: {
|
|
18
|
+
gapMessageLine: config.settings.gapMessageLine,
|
|
19
|
+
paddingChat: config.settings.paddingChat,
|
|
20
|
+
fontFamily: config.settings.fontFamily,
|
|
21
|
+
borderRadius: config.settings.borderRadius,
|
|
22
|
+
bottomSize: config.sections.bottom.params.size,
|
|
23
|
+
sendButtonType: config.sections.bottom.btnSend.type as BtnType,
|
|
24
|
+
headerSize: config.sections.top.params.size,
|
|
25
|
+
messageSize: config.sections.inside.params.size,
|
|
26
|
+
} as ShapesSettings,
|
|
27
|
+
|
|
28
|
+
// Настройки цветов
|
|
29
|
+
colors: {
|
|
30
|
+
bgChat: { bgColor: config.settings.bgChat },
|
|
31
|
+
welcomeMessage: { color: config.sections.inside?.welcomeMessage?.color || '#fff' },
|
|
32
|
+
chipWidgetTitle: {
|
|
33
|
+
color: config.sections.top.chipWidgetTitle.color,
|
|
34
|
+
bgColor: config.sections.top.chipWidgetTitle.bgColor,
|
|
35
|
+
},
|
|
36
|
+
btnClose: {
|
|
37
|
+
color: config.sections.top.btnClose.color,
|
|
38
|
+
bgColor: config.sections.top.btnClose.bgColor,
|
|
39
|
+
},
|
|
40
|
+
messageUser: {
|
|
41
|
+
color: config.sections.inside.messageUser.color,
|
|
42
|
+
bgColor: config.sections.inside.messageUser.bgColor,
|
|
43
|
+
},
|
|
44
|
+
messageBot: {
|
|
45
|
+
color: config.sections.inside.messageBot.color,
|
|
46
|
+
bgColor: config.sections.inside.messageBot.bgColor,
|
|
47
|
+
},
|
|
48
|
+
inputSend: {
|
|
49
|
+
color: config.sections.bottom.inputSend.color,
|
|
50
|
+
bgColor: config.sections.bottom.inputSend.bgColor,
|
|
51
|
+
},
|
|
52
|
+
btnSend: {
|
|
53
|
+
color: config.sections.bottom.btnSend.color,
|
|
54
|
+
bgColor: config.sections.bottom.btnSend.bgColor,
|
|
55
|
+
},
|
|
56
|
+
activeBtn: {
|
|
57
|
+
color: config.sections.bottom.activeBtn.color,
|
|
58
|
+
bgColor: config.sections.bottom.activeBtn.bgColor,
|
|
59
|
+
},
|
|
60
|
+
} as EmittedColorElement,
|
|
61
|
+
|
|
62
|
+
// Шрифт отдельно
|
|
63
|
+
font: {
|
|
64
|
+
fontFamily: config.settings.fontFamily,
|
|
65
|
+
letterSpacing: config.settings.letterSpacing,
|
|
66
|
+
} as FontSettings,
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Функция для сборки полного конфига из отдельных частей
|
|
72
|
+
*/
|
|
73
|
+
export function buildWidgetConfig(
|
|
74
|
+
general: GeneralSettings,
|
|
75
|
+
shapes: ShapesSettings,
|
|
76
|
+
colors: EmittedColorElement,
|
|
77
|
+
fonts: FontSettings
|
|
78
|
+
): WidgetConfig {
|
|
79
|
+
return {
|
|
80
|
+
settings: {
|
|
81
|
+
widgetTitle: general.widgetTitle,
|
|
82
|
+
welcomeMessage: general.welcomeMessage,
|
|
83
|
+
launchView: general.launchView,
|
|
84
|
+
bgChat: colors.bgChat.bgColor || colors.bgChat.color || DEFAULT_CONFIG.settings.bgChat,
|
|
85
|
+
gapMessageLine: shapes.gapMessageLine,
|
|
86
|
+
paddingChat: shapes.paddingChat,
|
|
87
|
+
borderRadius: shapes.borderRadius,
|
|
88
|
+
fontFamily: fonts.fontFamily,
|
|
89
|
+
letterSpacing: fonts.letterSpacing,
|
|
90
|
+
},
|
|
91
|
+
sections: {
|
|
92
|
+
top: {
|
|
93
|
+
params: {
|
|
94
|
+
size: shapes.headerSize,
|
|
95
|
+
},
|
|
96
|
+
chipWidgetTitle: {
|
|
97
|
+
color: colors.chipWidgetTitle.color || DEFAULT_CONFIG.sections.top.chipWidgetTitle.color,
|
|
98
|
+
bgColor: colors.chipWidgetTitle.bgColor || DEFAULT_CONFIG.sections.top.chipWidgetTitle.bgColor,
|
|
99
|
+
},
|
|
100
|
+
btnClose: {
|
|
101
|
+
color: colors.btnClose.color || DEFAULT_CONFIG.sections.top.btnClose.color,
|
|
102
|
+
bgColor: colors.btnClose.bgColor || DEFAULT_CONFIG.sections.top.btnClose.bgColor,
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
inside: {
|
|
106
|
+
params: {
|
|
107
|
+
size: shapes.messageSize,
|
|
108
|
+
},
|
|
109
|
+
messageUser: {
|
|
110
|
+
color: colors.messageUser.color || DEFAULT_CONFIG.sections.inside.messageUser.color,
|
|
111
|
+
bgColor: colors.messageUser.bgColor || DEFAULT_CONFIG.sections.inside.messageUser.bgColor,
|
|
112
|
+
},
|
|
113
|
+
messageBot: {
|
|
114
|
+
color: colors.messageBot.color || DEFAULT_CONFIG.sections.inside.messageBot.color,
|
|
115
|
+
bgColor: colors.messageBot.bgColor || DEFAULT_CONFIG.sections.inside.messageBot.bgColor,
|
|
116
|
+
},
|
|
117
|
+
welcomeMessage: {
|
|
118
|
+
color: colors.welcomeMessage.color || DEFAULT_CONFIG.sections.inside.welcomeMessage.color,
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
bottom: {
|
|
122
|
+
params: {
|
|
123
|
+
size: shapes.bottomSize,
|
|
124
|
+
},
|
|
125
|
+
inputSend: {
|
|
126
|
+
color: colors.inputSend.color || DEFAULT_CONFIG.sections.bottom.inputSend.color,
|
|
127
|
+
bgColor: colors.inputSend.bgColor || DEFAULT_CONFIG.sections.bottom.inputSend.bgColor,
|
|
128
|
+
},
|
|
129
|
+
btnSend: {
|
|
130
|
+
color: colors.btnSend.color || DEFAULT_CONFIG.sections.bottom.btnSend.color,
|
|
131
|
+
bgColor: colors.btnSend.bgColor || DEFAULT_CONFIG.sections.bottom.btnSend.bgColor,
|
|
132
|
+
type: shapes.sendButtonType,
|
|
133
|
+
},
|
|
134
|
+
activeBtn: {
|
|
135
|
+
color: colors.activeBtn.color || DEFAULT_CONFIG.sections.bottom.activeBtn.color,
|
|
136
|
+
bgColor: colors.activeBtn.bgColor || DEFAULT_CONFIG.sections.bottom.activeBtn.bgColor,
|
|
137
|
+
},
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
}
|
|
141
|
+
}
|