@commversion/libs 0.18.10 → 0.18.12
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 +1 -0
- package/dist/lc-privacy-notice.js +1 -0
- package/global.d.ts +34 -0
- package/package.json +3 -1
package/README.md
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(){var e=/^(?:https?:|mailto:)/i;function t(t){return e.test(t.trim())}function n(e,t){return!Number.isFinite(t)||t<=0||e.length<=t?{text:e,truncated:!1}:{text:`${e.slice(0,t).trimEnd()}…`,truncated:!0}}var r=`By chatting here, you agree we and authorized partners may process, monitor, and record this chat and your data in line with our`,i=`Privacy Policy`,a=600,o=`102px`,s=`60px`,c=`28px`,l=`36px`,u=500,d=`8px`,f=`cv-privacy-notice-dismissed`,ee=`chat-widget-container`,p=`data-lc-privacy-notice`,m=Symbol.for(`lc-privacy-notice:cleanup`);function h(e,t){for(let[n,r]of Object.entries(t))e.style.setProperty(n,r)}function g(e){return typeof e==`string`?e.trim():``}function _(e){try{return window.sessionStorage.getItem(e)===`1`}catch(e){return!1}}function v(e){try{window.sessionStorage.setItem(e,`1`)}catch(e){}}function y(e,t,n,r){let i=document.createElement(`span`);h(i,{flex:`1`,"min-width":`0`,"overflow-wrap":`anywhere`}),i.appendChild(document.createTextNode(`${e} `));let a=document.createElement(`a`);return a.textContent=t,a.href=n,a.target=`_blank`,a.rel=`noopener noreferrer`,h(a,{color:r,"text-decoration":`underline`,"font-weight":`600`}),i.appendChild(a),i}function b(e){let t=document.createElement(`button`);return t.type=`button`,t.textContent=`✕`,t.setAttribute(`aria-label`,`Dismiss privacy notice`),h(t,{flex:`0 0 auto`,border:`none`,background:`transparent`,color:`#9ca3af`,cursor:`pointer`,"font-size":`14px`,"line-height":`1`,padding:`0`}),t.addEventListener(`click`,e),t}function x(e,{state:x}){var S,C,w,T,E,D,O,k;let A=e.privacyNoticeConfig;if(!(A!=null&&A.enabled))return;let j=g(A.linkUrl);if(!t(j)){j.length>0&&console.warn(`[lc-privacy-notice] linkUrl is not a supported http/https/mailto URL; notice not shown: ${j}`);return}let M=g(A.linkText)||i,N=`${f}:${(S=e.clientId)==null?`default`:S}`,P=A.dismissible!==!1;if(P&&_(N))return;let F=document.getElementById(ee);if(!F)return;let I=document;(C=I[m])==null||C.call(I),(w=F.querySelector(`[${p}]`))==null||w.remove();let L=g(A.message)||r,R=typeof A.maxLength==`number`?A.maxLength:a,{text:te,truncated:z}=n(L,R);z&&console.warn(`[lc-privacy-notice] message exceeded ${R} characters and was truncated.`);let B=(T=A.theme)==null?{}:T,V=typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches?`none`:`translateY(${d})`,H=e.theme===`modern`?c:l,U=(E=A.bottomOffset)==null?e.theme===`modern`?s:o:E,W=document.createElement(`div`);W.setAttribute(p,``),W.setAttribute(`role`,`note`),W.setAttribute(`aria-label`,`Privacy notice`),W.setAttribute(`aria-live`,`polite`),h(W,{position:`absolute`,left:H,right:H,bottom:U,"z-index":`2147483000`,opacity:`0`,transform:V,"pointer-events":`none`,transition:`opacity 240ms ease, transform 240ms ease`,"box-sizing":`border-box`});let G=document.createElement(`div`);h(G,{display:`flex`,"align-items":`flex-start`,gap:`8px`,background:(D=B.background)==null?`#f7f7f7`:D,color:(O=B.textColor)==null?`#4b5563`:O,"border-radius":e.theme===`modern`?`4px`:`12px`,border:`1px solid rgba(0, 0, 0, 0.08)`,"box-shadow":`0 4px 16px rgba(0, 0, 0, 0.12)`,padding:`12px 14px`,"font-size":`12px`,"line-height":`1.4`,"font-family":`-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif`,"max-height":`40vh`,"overflow-y":`auto`}),G.appendChild(y(te,M,j,(k=B.linkColor)==null?`#111827`:k));let K,q=()=>{h(W,{opacity:`1`,transform:`translateY(0)`,"pointer-events":`auto`})},J=()=>{clearTimeout(K),h(W,{opacity:`0`,transform:V,"pointer-events":`none`})},Y=()=>{clearTimeout(K),K=setTimeout(q,u)},X=({visibility:e})=>{e===`maximized`?Y():J()},Z=new MutationObserver(()=>{!W.isConnected&&!_(N)&&F.appendChild(W)}),Q=()=>{clearTimeout(K),Z.disconnect(),window.LiveChatWidget.off(`visibility_changed`,X),W.remove(),I[m]=void 0};P&&G.appendChild(b(()=>{v(N),Q()}));let ne=W.attachShadow({mode:`open`}),$=document.createElement(`style`);$.textContent=`:host { all: initial; }`,ne.append($,G),F.appendChild(W),(x==null?void 0:x.visibility)===`maximized`?Y():J(),window.LiveChatWidget.on(`visibility_changed`,X),Z.observe(F,{childList:!0}),I[m]=Q}var S=e=>t=>{try{x(e,t)}catch(e){console.warn(`[lc-privacy-notice] failed to render the notice.`,e)}};window.commversion=window.commversion||{};var C=window.LiveChatWidget;C&&C.once(`ready`,S(window.commversion))})();
|
package/global.d.ts
CHANGED
|
@@ -27,8 +27,41 @@ interface ChannelMessageConfig {
|
|
|
27
27
|
readonly buttonMessages?: Readonly<Record<string, string>>;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
interface PrivacyNoticeTheme {
|
|
31
|
+
readonly background?: string;
|
|
32
|
+
readonly textColor?: string;
|
|
33
|
+
readonly linkColor?: string;
|
|
34
|
+
readonly borderRadius?: string;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
interface PrivacyNoticeConfig {
|
|
38
|
+
/** Must be `true` for the notice to render. mastercdn omits/disables this per client. */
|
|
39
|
+
readonly enabled?: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Consent copy shown before the link, as plain text. The privacy-policy link
|
|
42
|
+
* is appended after it. Omit to fall back to the built-in standard message.
|
|
43
|
+
*/
|
|
44
|
+
readonly message?: string;
|
|
45
|
+
/**
|
|
46
|
+
* URL of the client's privacy policy. **Required** — without a safe
|
|
47
|
+
* (`http`/`https`/`mailto`) URL the notice renders nothing at all.
|
|
48
|
+
*/
|
|
49
|
+
readonly linkUrl?: string;
|
|
50
|
+
/** Label for the privacy-policy link. Defaults to `"Privacy Policy"`. */
|
|
51
|
+
readonly linkText?: string;
|
|
52
|
+
/** Max characters before the message is truncated. Defaults to 600. */
|
|
53
|
+
readonly maxLength?: number;
|
|
54
|
+
/** When `false`, the notice has no ✕ and is always shown. Defaults to `true`. */
|
|
55
|
+
readonly dismissible?: boolean;
|
|
56
|
+
/** Distance above the widget's bottom edge, e.g. `"102px"`. Sits above the composer. */
|
|
57
|
+
readonly bottomOffset?: string;
|
|
58
|
+
readonly theme?: PrivacyNoticeTheme;
|
|
59
|
+
}
|
|
60
|
+
|
|
30
61
|
interface CommversionConfiguration {
|
|
31
62
|
readonly clientId: string;
|
|
63
|
+
/** Shared layout theme (also read by `lc-powered-by`). `"modern"` squares the privacy-notice corners to 4px. */
|
|
64
|
+
readonly theme?: "modern" | "smooth";
|
|
32
65
|
readonly attributionUrl?: string;
|
|
33
66
|
readonly exitIntentDebounceMs?: number;
|
|
34
67
|
readonly exitIntentMargin?: number;
|
|
@@ -39,6 +72,7 @@ interface CommversionConfiguration {
|
|
|
39
72
|
readonly whatsappConfig?: ChannelMessageConfig;
|
|
40
73
|
readonly smsConfig?: ChannelMessageConfig;
|
|
41
74
|
readonly facebookConfig?: ChannelMessageConfig;
|
|
75
|
+
readonly privacyNoticeConfig?: PrivacyNoticeConfig;
|
|
42
76
|
}
|
|
43
77
|
|
|
44
78
|
namespace LiveChat {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commversion/libs",
|
|
3
|
-
"version": "0.18.
|
|
3
|
+
"version": "0.18.12",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"author": "Commversion",
|
|
6
6
|
"type": "module",
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
"build:lc-open-on-button-click": "vite build -c scripts/lc-open-on-button-click/vite.config.js",
|
|
29
29
|
"build:lc-pause-on-url": "vite build -c scripts/lc-pause-on-url/vite.config.js",
|
|
30
30
|
"build:lc-powered-by": "vite build -c scripts/lc-powered-by/vite.config.js",
|
|
31
|
+
"build:lc-privacy-notice": "vite build -c scripts/lc-privacy-notice/vite.config.ts",
|
|
31
32
|
"build:lc-show-by-selector": "vite build -c scripts/lc-show-by-selector/vite.config.js",
|
|
32
33
|
"build:lc-show-hide": "vite build -c scripts/lc-show-hide/vite.config.js",
|
|
33
34
|
"build:lc-utm-params": "vite build -c scripts/lc-utm-params/vite.config.js",
|
|
@@ -54,6 +55,7 @@
|
|
|
54
55
|
"dev:lc-open-on-button-click": "vite serve scripts/lc-open-on-button-click/src/",
|
|
55
56
|
"dev:lc-pause-on-url": "vite serve scripts/lc-pause-on-url/src/",
|
|
56
57
|
"dev:lc-powered-by": "vite serve scripts/lc-powered-by/src/",
|
|
58
|
+
"dev:lc-privacy-notice": "vite serve scripts/lc-privacy-notice/src/",
|
|
57
59
|
"dev:lc-show-by-selector": "vite serve scripts/lc-show-by-selector/src/",
|
|
58
60
|
"dev:lc-show-hide": "vite serve scripts/lc-show-hide/src/",
|
|
59
61
|
"dev:lc-utm-params": "vite serve scripts/lc-utm-params/src/",
|