@product7/product7-js 0.1.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 +1025 -0
- package/dist/README.md +1025 -0
- package/dist/product7-js.js +14658 -0
- package/dist/product7-js.js.map +1 -0
- package/dist/product7-js.min.js +2 -0
- package/dist/product7-js.min.js.map +1 -0
- package/package.json +114 -0
- package/src/api/mock-data/index.js +360 -0
- package/src/api/services/ChangelogService.js +28 -0
- package/src/api/services/FeedbackService.js +44 -0
- package/src/api/services/HelpService.js +50 -0
- package/src/api/services/MessengerService.js +279 -0
- package/src/api/services/SurveyService.js +127 -0
- package/src/api/utils/helpers.js +30 -0
- package/src/core/APIService.js +303 -0
- package/src/core/BaseAPIService.js +298 -0
- package/src/core/EventBus.js +54 -0
- package/src/core/Product7.js +812 -0
- package/src/core/WebSocketService.js +275 -0
- package/src/docs/api.md +226 -0
- package/src/docs/example.md +461 -0
- package/src/docs/framework-integrations.md +714 -0
- package/src/docs/installation.md +281 -0
- package/src/index.js +894 -0
- package/src/styles/base.js +50 -0
- package/src/styles/changelog.js +665 -0
- package/src/styles/components.js +553 -0
- package/src/styles/design-tokens.js +124 -0
- package/src/styles/feedback.js +325 -0
- package/src/styles/messenger-components.js +632 -0
- package/src/styles/messenger-core.js +233 -0
- package/src/styles/messenger-features.js +169 -0
- package/src/styles/messenger-views.js +877 -0
- package/src/styles/messenger.js +17 -0
- package/src/styles/messengerCustomStyles.js +114 -0
- package/src/styles/styles.js +26 -0
- package/src/styles/survey.js +894 -0
- package/src/utils/errors.js +142 -0
- package/src/utils/helpers.js +219 -0
- package/src/widgets/BaseWidget.js +548 -0
- package/src/widgets/ButtonWidget.js +104 -0
- package/src/widgets/ChangelogWidget.js +615 -0
- package/src/widgets/InlineWidget.js +148 -0
- package/src/widgets/MessengerWidget.js +979 -0
- package/src/widgets/SurveyWidget.js +1325 -0
- package/src/widgets/TabWidget.js +45 -0
- package/src/widgets/WidgetFactory.js +70 -0
- package/src/widgets/messenger/MessengerState.js +323 -0
- package/src/widgets/messenger/components/MessengerLauncher.js +124 -0
- package/src/widgets/messenger/components/MessengerPanel.js +111 -0
- package/src/widgets/messenger/components/NavigationTabs.js +130 -0
- package/src/widgets/messenger/views/ChangelogView.js +167 -0
- package/src/widgets/messenger/views/ChatView.js +592 -0
- package/src/widgets/messenger/views/ConversationsView.js +244 -0
- package/src/widgets/messenger/views/HelpView.js +239 -0
- package/src/widgets/messenger/views/HomeView.js +300 -0
- package/src/widgets/messenger/views/PreChatFormView.js +109 -0
- package/types/index.d.ts +341 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { messengerComponentsStyles } from './messenger-components.js';
|
|
2
|
+
import { messengerCoreStyles } from './messenger-core.js';
|
|
3
|
+
import { messengerFeaturesStyles } from './messenger-features.js';
|
|
4
|
+
import { messengerViewsStyles } from './messenger-views.js';
|
|
5
|
+
|
|
6
|
+
export const messengerStyles =
|
|
7
|
+
messengerCoreStyles +
|
|
8
|
+
messengerViewsStyles +
|
|
9
|
+
messengerComponentsStyles +
|
|
10
|
+
messengerFeaturesStyles;
|
|
11
|
+
|
|
12
|
+
export {
|
|
13
|
+
messengerComponentsStyles,
|
|
14
|
+
messengerCoreStyles,
|
|
15
|
+
messengerFeaturesStyles,
|
|
16
|
+
messengerViewsStyles,
|
|
17
|
+
};
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
export function applyMessengerCustomStyles(options = {}) {
|
|
2
|
+
const {
|
|
3
|
+
primaryColor = '#155EEF',
|
|
4
|
+
textColor = '#1d1d1f',
|
|
5
|
+
backgroundColor = '#ffffff',
|
|
6
|
+
theme = 'light',
|
|
7
|
+
} = options;
|
|
8
|
+
|
|
9
|
+
let styleElement = document.getElementById(
|
|
10
|
+
'product7-messenger-custom-styles'
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
if (!styleElement) {
|
|
14
|
+
styleElement = document.createElement('style');
|
|
15
|
+
styleElement.id = 'product7-messenger-custom-styles';
|
|
16
|
+
document.head.appendChild(styleElement);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const adjustColor = (hex, percent, alpha = 1) => {
|
|
20
|
+
const normalized = String(hex || '').trim();
|
|
21
|
+
if (!/^#?[0-9a-fA-F]{6}$/.test(normalized)) {
|
|
22
|
+
return normalized || '#000000';
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const num = parseInt(normalized.replace('#', ''), 16);
|
|
26
|
+
const r = Math.max(0, Math.min(255, (num >> 16) + percent));
|
|
27
|
+
const g = Math.max(0, Math.min(255, ((num >> 8) & 0x00ff) + percent));
|
|
28
|
+
const b = Math.max(0, Math.min(255, (num & 0x0000ff) + percent));
|
|
29
|
+
|
|
30
|
+
if (alpha < 1) {
|
|
31
|
+
return `rgba(${r}, ${g}, ${b}, ${alpha})`;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return '#' + ((r << 16) | (g << 8) | b).toString(16).padStart(6, '0');
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const darkSurface = adjustColor(backgroundColor, 12);
|
|
38
|
+
const darkSurfaceAlt = adjustColor(backgroundColor, 20);
|
|
39
|
+
const darkBorder = adjustColor(backgroundColor, 34);
|
|
40
|
+
|
|
41
|
+
styleElement.textContent = `
|
|
42
|
+
#product7-messenger-widget {
|
|
43
|
+
--color-primary: ${primaryColor} !important;
|
|
44
|
+
--color-primary-hover: ${adjustColor(primaryColor, -10)} !important;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.messenger-launcher-btn {
|
|
48
|
+
background: ${primaryColor} !important;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.messenger-launcher-btn:hover {
|
|
52
|
+
box-shadow: 0 8px 24px ${adjustColor(primaryColor, 0, 0.3)} !important;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.sdk-btn-primary {
|
|
56
|
+
background: ${primaryColor} !important;
|
|
57
|
+
border-color: ${primaryColor} !important;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.sdk-btn-primary:hover {
|
|
61
|
+
background: ${adjustColor(primaryColor, -10)} !important;
|
|
62
|
+
border-color: ${adjustColor(primaryColor, -10)} !important;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.messenger-compose-send:hover:not(:disabled) {
|
|
66
|
+
background: ${primaryColor} !important;
|
|
67
|
+
border-color: ${primaryColor} !important;
|
|
68
|
+
color: #FFFFFF !important;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.messenger-nav-tab.active .messenger-nav-icon,
|
|
72
|
+
.messenger-nav-tab.active .messenger-nav-label {
|
|
73
|
+
color: ${primaryColor} !important;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.messenger-home-view::before {
|
|
77
|
+
background: radial-gradient(circle, ${adjustColor(primaryColor, 0, 0.08)} 0%, transparent 70%) !important;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
${
|
|
81
|
+
backgroundColor !== '#ffffff'
|
|
82
|
+
? `
|
|
83
|
+
.messenger-panel-content {
|
|
84
|
+
background: ${backgroundColor} !important;
|
|
85
|
+
}
|
|
86
|
+
`
|
|
87
|
+
: ''
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
${
|
|
91
|
+
textColor !== '#1d1d1f'
|
|
92
|
+
? `
|
|
93
|
+
.messenger-panel-content,
|
|
94
|
+
.messenger-view {
|
|
95
|
+
color: ${textColor} !important;
|
|
96
|
+
}
|
|
97
|
+
`
|
|
98
|
+
: ''
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/* Dark theme is now handled by CSS custom properties in messenger-core.js */
|
|
102
|
+
`;
|
|
103
|
+
|
|
104
|
+
console.log('✅ Custom messenger styles applied:', { primaryColor, theme });
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export function removeMessengerCustomStyles() {
|
|
108
|
+
const styleElement = document.getElementById(
|
|
109
|
+
'product7-messenger-custom-styles'
|
|
110
|
+
);
|
|
111
|
+
if (styleElement && styleElement.parentNode) {
|
|
112
|
+
styleElement.parentNode.removeChild(styleElement);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { baseStyles } from './base.js';
|
|
2
|
+
import { changelogStyles } from './changelog.js';
|
|
3
|
+
import { componentsStyles } from './components.js';
|
|
4
|
+
import { designTokens } from './design-tokens.js';
|
|
5
|
+
import { feedbackStyles } from './feedback.js';
|
|
6
|
+
import { messengerStyles } from './messenger.js';
|
|
7
|
+
import { surveyStyles } from './survey.js';
|
|
8
|
+
|
|
9
|
+
export const CSS_STYLES =
|
|
10
|
+
designTokens +
|
|
11
|
+
baseStyles +
|
|
12
|
+
componentsStyles +
|
|
13
|
+
feedbackStyles +
|
|
14
|
+
changelogStyles +
|
|
15
|
+
surveyStyles +
|
|
16
|
+
messengerStyles;
|
|
17
|
+
|
|
18
|
+
export {
|
|
19
|
+
baseStyles,
|
|
20
|
+
changelogStyles,
|
|
21
|
+
componentsStyles,
|
|
22
|
+
designTokens,
|
|
23
|
+
feedbackStyles,
|
|
24
|
+
messengerStyles,
|
|
25
|
+
surveyStyles,
|
|
26
|
+
};
|