hypercrm 1.0.5 → 1.0.7

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/assets/widget.js CHANGED
@@ -80,8 +80,6 @@
80
80
  --hypercrm-radius-sm: 12px;
81
81
  --hypercrm-offset-bottom: 0px;
82
82
  --hypercrm-offset-side: 0px;
83
- --hypercrm-offset-bottom-mobile: 0px;
84
- --hypercrm-offset-side-mobile: 0px;
85
83
  color-scheme: light;
86
84
  -webkit-font-smoothing: antialiased;
87
85
  }
@@ -132,11 +130,17 @@
132
130
  justify-content: center;
133
131
  }
134
132
 
133
+ #hypercrm-toggle-inner.hypercrm-custom-icon {
134
+ background: #ffffff;
135
+ border-radius: 50%;
136
+ }
137
+
135
138
  #hypercrm-toggle-inner img.hypercrm-toggle-avatar {
136
139
  width: 100%;
137
140
  height: 100%;
138
141
  object-fit: cover;
139
142
  border-radius: 50%;
143
+ background: #ffffff;
140
144
  display: block;
141
145
  }
142
146
 
@@ -1295,19 +1299,15 @@
1295
1299
 
1296
1300
  @media (max-width: 640px) {
1297
1301
  .hypercrm-widget-container {
1298
- bottom: calc(16px + var(--hypercrm-offset-bottom-mobile, 0px));
1299
- right: calc(16px + var(--hypercrm-offset-side-mobile, 0px));
1302
+ bottom: calc(16px + var(--hypercrm-offset-bottom, 0px));
1303
+ right: calc(16px + var(--hypercrm-offset-side, 0px));
1300
1304
  }
1301
1305
 
1302
1306
  .hypercrm-widget-container.hypercrm-position-left {
1303
- left: calc(16px + var(--hypercrm-offset-side-mobile, 0px));
1307
+ left: calc(16px + var(--hypercrm-offset-side, 0px));
1304
1308
  right: auto;
1305
1309
  }
1306
1310
 
1307
- .hypercrm-widget-container.hypercrm-mobile-disabled {
1308
- display: none;
1309
- }
1310
-
1311
1311
  .hypercrm-toggle-btn {
1312
1312
  width: 56px;
1313
1313
  height: 56px;
@@ -1340,9 +1340,6 @@
1340
1340
  this.colorModePreference = this.options.colorMode || 'light';
1341
1341
  this.position = this.normalizePosition(this.options.position);
1342
1342
  this.offset = this.normalizeOffsets(this.options.offset);
1343
- const mobileOptions = this.options && typeof this.options.mobile === 'object' ? this.options.mobile : {};
1344
- this.mobileEnabled = mobileOptions?.enabled !== false;
1345
- this.mobileOffset = this.normalizeOffsets(mobileOptions?.offset);
1346
1343
  this.mediaColorQuery = null;
1347
1344
  this.systemColorListener = null;
1348
1345
  this.systemColorListenerAttached = false;
@@ -1445,16 +1442,8 @@
1445
1442
  applyOffsets() {
1446
1443
  if (!this.container) return;
1447
1444
  const offset = this.offset || { bottom: 0, side: 0 };
1448
- const mobileOffset = this.mobileOffset || { bottom: 0, side: 0 };
1449
1445
  this.container.style.setProperty('--hypercrm-offset-bottom', `${offset.bottom}px`);
1450
1446
  this.container.style.setProperty('--hypercrm-offset-side', `${offset.side}px`);
1451
- this.container.style.setProperty('--hypercrm-offset-bottom-mobile', `${mobileOffset.bottom}px`);
1452
- this.container.style.setProperty('--hypercrm-offset-side-mobile', `${mobileOffset.side}px`);
1453
- }
1454
-
1455
- applyMobileVisibility() {
1456
- if (!this.container) return;
1457
- this.container.classList.toggle('hypercrm-mobile-disabled', this.mobileEnabled === false);
1458
1447
  }
1459
1448
 
1460
1449
  setOffset(offset) {
@@ -1463,20 +1452,6 @@
1463
1452
  this.applyOffsets();
1464
1453
  }
1465
1454
 
1466
- setMobileOffset(offset) {
1467
- this.mobileOffset = this.normalizeOffsets(offset);
1468
- const current = this.options.mobile && typeof this.options.mobile === 'object' ? this.options.mobile : {};
1469
- this.options.mobile = { ...current, offset: this.mobileOffset };
1470
- this.applyOffsets();
1471
- }
1472
-
1473
- setMobileEnabled(enabled) {
1474
- this.mobileEnabled = enabled !== false;
1475
- const current = this.options.mobile && typeof this.options.mobile === 'object' ? this.options.mobile : {};
1476
- this.options.mobile = { ...current, enabled: this.mobileEnabled };
1477
- this.applyMobileVisibility();
1478
- }
1479
-
1480
1455
  absUrl(url) {
1481
1456
  if (!url) return url;
1482
1457
  if (/^https?:/i.test(url)) return url;
@@ -1682,7 +1657,6 @@
1682
1657
  this.container = container;
1683
1658
  this.applyPosition();
1684
1659
  this.applyOffsets();
1685
- this.applyMobileVisibility();
1686
1660
 
1687
1661
  // Lightbox overlay
1688
1662
  const lightbox = document.createElement('div');
@@ -2440,13 +2414,6 @@
2440
2414
  if (!this.options.offset && orgOffset) {
2441
2415
  this.setOffset(orgOffset);
2442
2416
  }
2443
- const orgMobile = this.orgInfo?.widget?.mobile || {};
2444
- if (typeof this.options.mobile?.enabled !== 'boolean' && typeof orgMobile.enabled === 'boolean') {
2445
- this.setMobileEnabled(orgMobile.enabled);
2446
- }
2447
- if (!this.options.mobile?.offset && orgMobile.offset) {
2448
- this.setMobileOffset(orgMobile.offset);
2449
- }
2450
2417
  const iconUrl = this.orgInfo?.widget?.iconUrl;
2451
2418
  this.orgIconUrl = iconUrl ? this.absUrl(iconUrl) : null;
2452
2419
  this.updateHeaderIcons();
@@ -2487,8 +2454,10 @@
2487
2454
  const { toggleInner } = this.elements;
2488
2455
  if (!toggleInner) return;
2489
2456
  if (iconUrl) {
2457
+ toggleInner.classList.add('hypercrm-custom-icon');
2490
2458
  toggleInner.innerHTML = `<img src="${iconUrl}" alt="Chat" class="hypercrm-toggle-avatar" />`;
2491
2459
  } else {
2460
+ toggleInner.classList.remove('hypercrm-custom-icon');
2492
2461
  toggleInner.innerHTML = this.renderIcon(this.iconUrls?.chat, '', 'hypercrm-icon-img large');
2493
2462
  }
2494
2463
  }
@@ -3033,12 +3002,6 @@
3033
3002
  setOffset(offset) {
3034
3003
  if (activeWidget) activeWidget.setOffset(offset);
3035
3004
  },
3036
- setMobileOffset(offset) {
3037
- if (activeWidget) activeWidget.setMobileOffset(offset);
3038
- },
3039
- setMobileEnabled(enabled) {
3040
- if (activeWidget) activeWidget.setMobileEnabled(enabled);
3041
- },
3042
3005
  open() {
3043
3006
  if (activeWidget) activeWidget.openWidget();
3044
3007
  },
package/dist/index.d.ts CHANGED
@@ -10,13 +10,6 @@ export interface WidgetOptions {
10
10
  bottom?: number;
11
11
  side?: number;
12
12
  };
13
- mobile?: {
14
- enabled?: boolean;
15
- offset?: {
16
- bottom?: number;
17
- side?: number;
18
- };
19
- };
20
13
  autoOpen?: boolean;
21
14
  debug?: boolean;
22
15
  scriptUrl?: string;
@@ -30,11 +23,6 @@ export declare const setWidgetOffset: (offset: {
30
23
  bottom?: number;
31
24
  side?: number;
32
25
  }) => Promise<void>;
33
- export declare const setWidgetMobileOffset: (offset: {
34
- bottom?: number;
35
- side?: number;
36
- }) => Promise<void>;
37
- export declare const setWidgetMobileEnabled: (enabled: boolean) => Promise<void>;
38
26
  declare const _default: {
39
27
  init: (options?: WidgetOptions) => Promise<any>;
40
28
  destroy: () => void;
@@ -45,11 +33,6 @@ declare const _default: {
45
33
  bottom?: number;
46
34
  side?: number;
47
35
  }) => Promise<void>;
48
- setMobileOffset: (offset: {
49
- bottom?: number;
50
- side?: number;
51
- }) => Promise<void>;
52
- setMobileEnabled: (enabled: boolean) => Promise<void>;
53
36
  };
54
37
  export default _default;
55
38
  declare global {
@@ -64,11 +47,6 @@ declare global {
64
47
  bottom?: number;
65
48
  side?: number;
66
49
  }) => void;
67
- setMobileOffset: (offset: {
68
- bottom?: number;
69
- side?: number;
70
- }) => void;
71
- setMobileEnabled: (enabled: boolean) => void;
72
50
  open: () => void;
73
51
  close: () => void;
74
52
  toggle: () => void;
package/dist/index.js CHANGED
@@ -99,14 +99,6 @@ export const setWidgetOffset = async (offset) => {
99
99
  await ensureScriptLoaded();
100
100
  window.HyperCRMWidget.setOffset(offset || {});
101
101
  };
102
- export const setWidgetMobileOffset = async (offset) => {
103
- await ensureScriptLoaded();
104
- window.HyperCRMWidget.setMobileOffset(offset || {});
105
- };
106
- export const setWidgetMobileEnabled = async (enabled) => {
107
- await ensureScriptLoaded();
108
- window.HyperCRMWidget.setMobileEnabled(enabled);
109
- };
110
102
  export default {
111
103
  init: initWidget,
112
104
  destroy: destroyWidget,
@@ -114,6 +106,4 @@ export default {
114
106
  setColorMode: setWidgetColorMode,
115
107
  setPosition: setWidgetPosition,
116
108
  setOffset: setWidgetOffset,
117
- setMobileOffset: setWidgetMobileOffset,
118
- setMobileEnabled: setWidgetMobileEnabled,
119
109
  };
package/dist/react.js CHANGED
@@ -1,12 +1,12 @@
1
1
  import { useEffect, useRef } from 'react';
2
- import { initWidget, destroyWidget, setWidgetTheme, setWidgetColorMode, setWidgetPosition, setWidgetOffset, setWidgetMobileOffset, setWidgetMobileEnabled, } from './index';
2
+ import { initWidget, destroyWidget, setWidgetTheme, setWidgetColorMode, setWidgetPosition, setWidgetOffset, } from './index';
3
3
  export const useHyperCRMWidget = (options = {}) => {
4
- const { apiUrl, apiKey, orgId, mount, theme, colorMode, position, offset, mobile, autoOpen, debug, scriptUrl, } = options;
4
+ const { apiUrl, apiKey, orgId, mount, theme, colorMode, position, offset, autoOpen, debug, scriptUrl, } = options;
5
5
  const readyRef = useRef(false);
6
- const latestRef = useRef({ theme, colorMode, position, offset, mobile });
6
+ const latestRef = useRef({ theme, colorMode, position, offset });
7
7
  useEffect(() => {
8
- latestRef.current = { theme, colorMode, position, offset, mobile };
9
- }, [theme, colorMode, position, offset, mobile]);
8
+ latestRef.current = { theme, colorMode, position, offset };
9
+ }, [theme, colorMode, position, offset]);
10
10
  useEffect(() => {
11
11
  let cancelled = false;
12
12
  readyRef.current = false;
@@ -19,13 +19,11 @@ export const useHyperCRMWidget = (options = {}) => {
19
19
  colorMode: latestRef.current.colorMode,
20
20
  position: latestRef.current.position,
21
21
  offset: latestRef.current.offset,
22
- mobile: latestRef.current.mobile,
23
22
  autoOpen,
24
23
  debug,
25
24
  scriptUrl,
26
25
  })
27
26
  .then(() => {
28
- var _a, _b;
29
27
  if (cancelled)
30
28
  return;
31
29
  readyRef.current = true;
@@ -37,10 +35,6 @@ export const useHyperCRMWidget = (options = {}) => {
37
35
  setWidgetPosition(latest.position);
38
36
  if (latest.offset)
39
37
  setWidgetOffset(latest.offset);
40
- if ((_a = latest.mobile) === null || _a === void 0 ? void 0 : _a.offset)
41
- setWidgetMobileOffset(latest.mobile.offset);
42
- if (typeof ((_b = latest.mobile) === null || _b === void 0 ? void 0 : _b.enabled) === 'boolean')
43
- setWidgetMobileEnabled(latest.mobile.enabled);
44
38
  })
45
39
  .catch((err) => {
46
40
  if (debug)
@@ -72,14 +66,6 @@ export const useHyperCRMWidget = (options = {}) => {
72
66
  return;
73
67
  setWidgetOffset(offset);
74
68
  }, [offset]);
75
- useEffect(() => {
76
- if (!readyRef.current)
77
- return;
78
- if (mobile === null || mobile === void 0 ? void 0 : mobile.offset)
79
- setWidgetMobileOffset(mobile.offset);
80
- if (typeof (mobile === null || mobile === void 0 ? void 0 : mobile.enabled) === 'boolean')
81
- setWidgetMobileEnabled(mobile.enabled);
82
- }, [mobile]);
83
69
  };
84
70
  export const HyperCRMWidget = (props) => {
85
71
  useHyperCRMWidget(props);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hypercrm",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "description": "HyperCRM widget loader with optional React component.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",