@subiz/widget-v4 4.1.26 → 4.1.28
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/compiled_src/chatbox/Header.js +12 -7
- package/compiled_src/chatbox/Widget.js +12 -0
- package/compiled_src/chatbox/main.js +24 -2
- package/compiled_src/util/campaign.js +17 -8
- package/dist/132.js +52 -11
- package/dist/18754d60df1.132.js +1 -0
- package/dist/18754d60df1.441.js +1 -0
- package/dist/18754d60df1.app.js +1 -0
- package/dist/{186bfd5b9ef.index.html → 18754d60df1.index.html} +9 -2
- package/dist/{186bfd5b9ef.library.html → 18754d60df1.library.html} +9 -2
- package/dist/18754d60df1.library.js +1 -0
- package/dist/{186bfd5b9ef.preview.html → 18754d60df1.preview.html} +1 -1
- package/dist/18754d60df1.preview.js +1 -0
- package/dist/18754d60df1.screenshoot.js +1 -0
- package/dist/18754d60df1.webview.js +1 -0
- package/dist/441.js +216 -152
- package/dist/HASH +1 -1
- package/dist/screenshoot.html +1 -1
- package/dist/screenshoot.js +43 -15
- package/index.html +8 -0
- package/package.json +10 -10
- package/src/chatbox/Header.js +12 -9
- package/src/chatbox/Widget.js +14 -0
- package/src/chatbox/main.js +24 -1
- package/src/util/campaign.js +29 -8
- package/dist/186bfd5b9ef.132.js +0 -1
- package/dist/186bfd5b9ef.441.js +0 -1
- package/dist/186bfd5b9ef.app.js +0 -1
- package/dist/186bfd5b9ef.library.js +0 -1
- package/dist/186bfd5b9ef.preview.js +0 -1
- package/dist/186bfd5b9ef.screenshoot.js +0 -1
- package/dist/186bfd5b9ef.webview.js +0 -1
- /package/dist/{186bfd5b9ef.178.js → 18754d60df1.178.js} +0 -0
- /package/dist/{186bfd5b9ef.213.js → 18754d60df1.213.js} +0 -0
- /package/dist/{186bfd5b9ef.335.js → 18754d60df1.335.js} +0 -0
- /package/dist/{186bfd5b9ef.362.js → 18754d60df1.362.js} +0 -0
- /package/dist/{186bfd5b9ef.605.js → 18754d60df1.605.js} +0 -0
- /package/dist/{186bfd5b9ef.678.js → 18754d60df1.678.js} +0 -0
- /package/dist/{186bfd5b9ef.782.js → 18754d60df1.782.js} +0 -0
package/dist/screenshoot.js
CHANGED
|
@@ -1408,6 +1408,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
1408
1408
|
/* harmony export */ "norm": () => (/* binding */ norm),
|
|
1409
1409
|
/* harmony export */ "offsetToMin": () => (/* binding */ offsetToMin),
|
|
1410
1410
|
/* harmony export */ "orderBy": () => (/* binding */ orderBy),
|
|
1411
|
+
/* harmony export */ "orderByF": () => (/* binding */ orderByF),
|
|
1411
1412
|
/* harmony export */ "parseJSON": () => (/* binding */ parseJSON),
|
|
1412
1413
|
/* harmony export */ "preloadImg": () => (/* binding */ preloadImg),
|
|
1413
1414
|
/* harmony export */ "preloadWebfonts": () => (/* binding */ preloadWebfonts),
|
|
@@ -1706,6 +1707,18 @@ function orderBy(a, k, d) {
|
|
|
1706
1707
|
});
|
|
1707
1708
|
return clone;
|
|
1708
1709
|
}
|
|
1710
|
+
function orderByF(a, f, d) {
|
|
1711
|
+
var clone = [];
|
|
1712
|
+
each(a, v => clone.push(v));
|
|
1713
|
+
clone.sort((i, j) => {
|
|
1714
|
+
let ik = f(i);
|
|
1715
|
+
let jk = f(j);
|
|
1716
|
+
if (ik === jk) return 0;
|
|
1717
|
+
var r = ik < jk ? -1 : 1;
|
|
1718
|
+
return d === 'desc' ? -r : r;
|
|
1719
|
+
});
|
|
1720
|
+
return clone;
|
|
1721
|
+
}
|
|
1709
1722
|
function isPhone(phone) {
|
|
1710
1723
|
var re = /^[\+]?[(]?[0-9]{2,3}[)]?[-\s\.]?[0-9]{3,4}[-\s\.]?[0-9]{4,6}$/im;
|
|
1711
1724
|
return re.test(String(phone));
|
|
@@ -2599,14 +2612,7 @@ function trackAreaClicked(selector, cb) {
|
|
|
2599
2612
|
campaign_common.map(selector.split('\n'), selector => {
|
|
2600
2613
|
selector = campaign_common.trim(selector);
|
|
2601
2614
|
if (!selector) return;
|
|
2602
|
-
|
|
2603
|
-
try {
|
|
2604
|
-
doms = document.querySelectorAll(selector);
|
|
2605
|
-
} catch (e) {}
|
|
2606
|
-
campaign_common.map(doms, dom => {
|
|
2607
|
-
if (!dom) return;
|
|
2608
|
-
dom.addEventListener('click', cb, false);
|
|
2609
|
-
});
|
|
2615
|
+
on('click', selector, cb);
|
|
2610
2616
|
});
|
|
2611
2617
|
}
|
|
2612
2618
|
function trackInactivity(seconds = 0, cb) {
|
|
@@ -2644,6 +2650,22 @@ function trackTimeOnPage(seconds = 0, cb) {
|
|
|
2644
2650
|
campaign_common.clearInterval(timer);
|
|
2645
2651
|
}, 1000);
|
|
2646
2652
|
}
|
|
2653
|
+
function on(eventName, selector, fn) {
|
|
2654
|
+
document.addEventListener(eventName, function (event) {
|
|
2655
|
+
let possibleTargets = document.querySelectorAll(selector);
|
|
2656
|
+
let target = event.target;
|
|
2657
|
+
for (let i = 0, l = possibleTargets.length; i < l; i++) {
|
|
2658
|
+
let el = target;
|
|
2659
|
+
let p = possibleTargets[i];
|
|
2660
|
+
while (el && el !== document) {
|
|
2661
|
+
if (el === p) {
|
|
2662
|
+
return fn.call(p, event);
|
|
2663
|
+
}
|
|
2664
|
+
el = el.parentNode;
|
|
2665
|
+
}
|
|
2666
|
+
}
|
|
2667
|
+
});
|
|
2668
|
+
}
|
|
2647
2669
|
;// CONCATENATED MODULE: ./src/util/order.js
|
|
2648
2670
|
const op = __webpack_require__(6877);
|
|
2649
2671
|
const order_common = __webpack_require__(8733);
|
|
@@ -3086,14 +3108,14 @@ class Pubsub {
|
|
|
3086
3108
|
|
|
3087
3109
|
"use strict";
|
|
3088
3110
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
3089
|
-
/* harmony export */ "HY": () => (/* binding */
|
|
3090
|
-
/* harmony export */ "Vf": () => (/* binding */
|
|
3091
|
-
/* harmony export */ "h": () => (/* binding */
|
|
3092
|
-
/* harmony export */ "sY": () => (/* binding */
|
|
3093
|
-
/* harmony export */ "wA": () => (/* binding */
|
|
3111
|
+
/* harmony export */ "HY": () => (/* binding */ _),
|
|
3112
|
+
/* harmony export */ "Vf": () => (/* binding */ d),
|
|
3113
|
+
/* harmony export */ "h": () => (/* binding */ y),
|
|
3114
|
+
/* harmony export */ "sY": () => (/* binding */ B),
|
|
3115
|
+
/* harmony export */ "wA": () => (/* binding */ k)
|
|
3094
3116
|
/* harmony export */ });
|
|
3095
3117
|
/* unused harmony exports cloneElement, createContext, createElement, hydrate, isValidElement, options, toChildArray */
|
|
3096
|
-
var n,l,u,i,t,r,o,f,e={},c=[],s=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i;function a(n,l){for(var u in l)n[u]=l[u];return n}function h(n){var l=n.parentNode;l&&l.removeChild(n)}function v(l,u,i){var t,r,o,f={};for(o in u)"key"==o?t=u[o]:"ref"==o?r=u[o]:f[o]=u[o];if(arguments.length>2&&(f.children=arguments.length>3?n.call(arguments,2):i),"function"==typeof l&&null!=l.defaultProps)for(o in l.defaultProps)void 0===f[o]&&(f[o]=l.defaultProps[o]);return y(l,f,t,r,null)}function y(n,i,t,r,o){var f={type:n,props:i,key:t,ref:r,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,__h:null,constructor:void 0,__v:null==o?++u:o};return null==o&&null!=l.vnode&&l.vnode(f),f}function p(){return{current:null}}function d(n){return n.children}function _(n,l){this.props=n,this.context=l}function k(n,l){if(null==l)return n.__?k(n.__,n.__.__k.indexOf(n)+1):null;for(var u;l<n.__k.length;l++)if(null!=(u=n.__k[l])&&null!=u.__e)return u.__e;return"function"==typeof n.type?k(n):null}function b(n){var l,u;if(null!=(n=n.__)&&null!=n.__c){for(n.__e=n.__c.base=null,l=0;l<n.__k.length;l++)if(null!=(u=n.__k[l])&&null!=u.__e){n.__e=n.__c.base=u.__e;break}return b(n)}}function g(n){(!n.__d&&(n.__d=!0)&&t.push(n)&&!m.__r++||r!==l.debounceRendering)&&((r=l.debounceRendering)||o)(m)}function m(){var n,l,u,i,r,o,f,e;for(t.sort(function(n,l){return n.__v.__b-l.__v.__b});n=t.shift();)n.__d&&(l=t.length,i=void 0,r=void 0,f=(o=(u=n).__v).__e,(e=u.__P)&&(i=[],(r=a({},o)).__v=o.__v+1,z(e,o,r,u.__n,void 0!==e.ownerSVGElement,null!=o.__h?[f]:null,i,null==f?k(o):f,o.__h),L(i,o),o.__e!=f&&b(o)),t.length>l&&t.sort(function(n,l){return n.__v.__b-l.__v.__b}));m.__r=0}function w(n,l,u,i,t,r,o,f,s,a){var h,v,p,_,b,g,m,w=i&&i.__k||c,A=w.length;for(u.__k=[],h=0;h<l.length;h++)if(null!=(_=u.__k[h]=null==(_=l[h])||"boolean"==typeof _?null:"string"==typeof _||"number"==typeof _||"bigint"==typeof _?y(null,_,null,null,_):Array.isArray(_)?y(d,{children:_},null,null,null):_.__b>0?y(_.type,_.props,_.key,_.ref?_.ref:null,_.__v):_)){if(_.__=u,_.__b=u.__b+1,null===(p=w[h])||p&&_.key==p.key&&_.type===p.type)w[h]=void 0;else for(v=0;v<A;v++){if((p=w[v])&&_.key==p.key&&_.type===p.type){w[v]=void 0;break}p=null}z(n,_,p=p||e,t,r,o,f,s,a),b=_.__e,(v=_.ref)&&p.ref!=v&&(m||(m=[]),p.ref&&m.push(p.ref,null,_),m.push(v,_.__c||b,_)),null!=b?(null==g&&(g=b),"function"==typeof _.type&&_.__k===p.__k?_.__d=s=x(_,s,n):s=P(n,_,p,w,b,s),"function"==typeof u.type&&(u.__d=s)):s&&p.__e==s&&s.parentNode!=n&&(s=k(p))}for(u.__e=g,h=A;h--;)null!=w[h]&&("function"==typeof u.type&&null!=w[h].__e&&w[h].__e==u.__d&&(u.__d=C(i).nextSibling),O(w[h],w[h]));if(m)for(h=0;h<m.length;h++)N(m[h],m[++h],m[++h])}function x(n,l,u){for(var i,t=n.__k,r=0;t&&r<t.length;r++)(i=t[r])&&(i.__=n,l="function"==typeof i.type?x(i,l,u):P(u,i,i,t,i.__e,l));return l}function A(n,l){return l=l||[],null==n||"boolean"==typeof n||(Array.isArray(n)?n.some(function(n){A(n,l)}):l.push(n)),l}function P(n,l,u,i,t,r){var o,f,e;if(void 0!==l.__d)o=l.__d,l.__d=void 0;else if(null==u||t!=r||null==t.parentNode)n:if(null==r||r.parentNode!==n)n.appendChild(t),o=null;else{for(f=r,e=0;(f=f.nextSibling)&&e<i.length;e+=1)if(f==t)break n;n.insertBefore(t,r),o=r}return void 0!==o?o:t.nextSibling}function C(n){var l,u,i;if(null==n.type||"string"==typeof n.type)return n.__e;if(n.__k)for(l=n.__k.length-1;l>=0;l--)if((u=n.__k[l])&&(i=C(u)))return i;return null}function $(n,l,u,i,t){var r;for(r in u)"children"===r||"key"===r||r in l||I(n,r,null,u[r],i);for(r in l)t&&"function"!=typeof l[r]||"children"===r||"key"===r||"value"===r||"checked"===r||u[r]===l[r]||I(n,r,l[r],u[r],i)}function H(n,l,u){"-"===l[0]?n.setProperty(l,null==u?"":u):n[l]=null==u?"":"number"!=typeof u||s.test(l)?u:u+"px"}function I(n,l,u,i,t){var r;n:if("style"===l)if("string"==typeof u)n.style.cssText=u;else{if("string"==typeof i&&(n.style.cssText=i=""),i)for(l in i)u&&l in u||H(n.style,l,"");if(u)for(l in u)i&&u[l]===i[l]||H(n.style,l,u[l])}else if("o"===l[0]&&"n"===l[1])r=l!==(l=l.replace(/Capture$/,"")),l=l.toLowerCase()in n?l.toLowerCase().slice(2):l.slice(2),n.l||(n.l={}),n.l[l+r]=u,u?i||n.addEventListener(l,r?j:T,r):n.removeEventListener(l,r?j:T,r);else if("dangerouslySetInnerHTML"!==l){if(t)l=l.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if("width"!==l&&"height"!==l&&"href"!==l&&"list"!==l&&"form"!==l&&"tabIndex"!==l&&"download"!==l&&l in n)try{n[l]=null==u?"":u;break n}catch(n){}"function"==typeof u||(null==u||!1===u&&-1==l.indexOf("-")?n.removeAttribute(l):n.setAttribute(l,u))}}function T(n){return this.l[n.type+!1](l.event?l.event(n):n)}function j(n){return this.l[n.type+!0](l.event?l.event(n):n)}function z(n,u,i,t,r,o,f,e,c){var s,h,v,y,p,k,b,g,m,x,A,P,C,$,H,I=u.type;if(void 0!==u.constructor)return null;null!=i.__h&&(c=i.__h,e=u.__e=i.__e,u.__h=null,o=[e]),(s=l.__b)&&s(u);try{n:if("function"==typeof I){if(g=u.props,m=(s=I.contextType)&&t[s.__c],x=s?m?m.props.value:s.__:t,i.__c?b=(h=u.__c=i.__c).__=h.__E:("prototype"in I&&I.prototype.render?u.__c=h=new I(g,x):(u.__c=h=new _(g,x),h.constructor=I,h.render=S),m&&m.sub(h),h.props=g,h.state||(h.state={}),h.context=x,h.__n=t,v=h.__d=!0,h.__h=[],h._sb=[]),null==h.__s&&(h.__s=h.state),null!=I.getDerivedStateFromProps&&(h.__s==h.state&&(h.__s=a({},h.__s)),a(h.__s,I.getDerivedStateFromProps(g,h.__s))),y=h.props,p=h.state,h.__v=u,v)null==I.getDerivedStateFromProps&&null!=h.componentWillMount&&h.componentWillMount(),null!=h.componentDidMount&&h.__h.push(h.componentDidMount);else{if(null==I.getDerivedStateFromProps&&g!==y&&null!=h.componentWillReceiveProps&&h.componentWillReceiveProps(g,x),!h.__e&&null!=h.shouldComponentUpdate&&!1===h.shouldComponentUpdate(g,h.__s,x)||u.__v===i.__v){for(u.__v!==i.__v&&(h.props=g,h.state=h.__s,h.__d=!1),h.__e=!1,u.__e=i.__e,u.__k=i.__k,u.__k.forEach(function(n){n&&(n.__=u)}),A=0;A<h._sb.length;A++)h.__h.push(h._sb[A]);h._sb=[],h.__h.length&&f.push(h);break n}null!=h.componentWillUpdate&&h.componentWillUpdate(g,h.__s,x),null!=h.componentDidUpdate&&h.__h.push(function(){h.componentDidUpdate(y,p,k)})}if(h.context=x,h.props=g,h.__P=n,P=l.__r,C=0,"prototype"in I&&I.prototype.render){for(h.state=h.__s,h.__d=!1,P&&P(u),s=h.render(h.props,h.state,h.context),$=0;$<h._sb.length;$++)h.__h.push(h._sb[$]);h._sb=[]}else do{h.__d=!1,P&&P(u),s=h.render(h.props,h.state,h.context),h.state=h.__s}while(h.__d&&++C<25);h.state=h.__s,null!=h.getChildContext&&(t=a(a({},t),h.getChildContext())),v||null==h.getSnapshotBeforeUpdate||(k=h.getSnapshotBeforeUpdate(y,p)),H=null!=s&&s.type===d&&null==s.key?s.props.children:s,w(n,Array.isArray(H)?H:[H],u,i,t,r,o,f,e,c),h.base=u.__e,u.__h=null,h.__h.length&&f.push(h),b&&(h.__E=h.__=null),h.__e=!1}else null==o&&u.__v===i.__v?(u.__k=i.__k,u.__e=i.__e):u.__e=M(i.__e,u,i,t,r,o,f,c);(s=l.diffed)&&s(u)}catch(n){u.__v=null,(c||null!=o)&&(u.__e=e,u.__h=!!c,o[o.indexOf(e)]=null),l.__e(n,u,i)}}function L(n,u){l.__c&&l.__c(u,n),n.some(function(u){try{n=u.__h,u.__h=[],n.some(function(n){n.call(u)})}catch(n){l.__e(n,u.__v)}})}function M(l,u,i,t,r,o,f,c){var s,a,v,y=i.props,p=u.props,d=u.type,_=0;if("svg"===d&&(r=!0),null!=o)for(;_<o.length;_++)if((s=o[_])&&"setAttribute"in s==!!d&&(d?s.localName===d:3===s.nodeType)){l=s,o[_]=null;break}if(null==l){if(null===d)return document.createTextNode(p);l=r?document.createElementNS("http://www.w3.org/2000/svg",d):document.createElement(d,p.is&&p),o=null,c=!1}if(null===d)y===p||c&&l.data===p||(l.data=p);else{if(o=o&&n.call(l.childNodes),a=(y=i.props||e).dangerouslySetInnerHTML,v=p.dangerouslySetInnerHTML,!c){if(null!=o)for(y={},_=0;_<l.attributes.length;_++)y[l.attributes[_].name]=l.attributes[_].value;(v||a)&&(v&&(a&&v.__html==a.__html||v.__html===l.innerHTML)||(l.innerHTML=v&&v.__html||""))}if($(l,p,y,r,c),v)u.__k=[];else if(_=u.props.children,w(l,Array.isArray(_)?_:[_],u,i,t,r&&"foreignObject"!==d,o,f,o?o[0]:i.__k&&k(i,0),c),null!=o)for(_=o.length;_--;)null!=o[_]&&h(o[_]);c||("value"in p&&void 0!==(_=p.value)&&(_!==l.value||"progress"===d&&!_||"option"===d&&_!==y.value)&&I(l,"value",_,y.value,!1),"checked"in p&&void 0!==(_=p.checked)&&_!==l.checked&&I(l,"checked",_,y.checked,!1))}return l}function N(n,u,i){try{"function"==typeof n?n(u):n.current=u}catch(n){l.__e(n,i)}}function O(n,u,i){var t,r;if(l.unmount&&l.unmount(n),(t=n.ref)&&(t.current&&t.current!==n.__e||N(t,null,u)),null!=(t=n.__c)){if(t.componentWillUnmount)try{t.componentWillUnmount()}catch(n){l.__e(n,u)}t.base=t.__P=null,n.__c=void 0}if(t=n.__k)for(r=0;r<t.length;r++)t[r]&&O(t[r],u,i||"function"!=typeof n.type);i||null==n.__e||h(n.__e),n.__=n.__e=n.__d=void 0}function S(n,l,u){return this.constructor(n,u)}function q(u,i,t){var r,o,f;l.__&&l.__(u,i),o=(r="function"==typeof t)?null:t&&t.__k||i.__k,f=[],z(i,u=(!r&&t||i).__k=v(d,null,[u]),o||e,e,void 0!==i.ownerSVGElement,!r&&t?[t]:o?null:i.firstChild?n.call(i.childNodes):null,f,!r&&t?t:o?o.__e:i.firstChild,r),L(f,u)}function B(n,l){q(n,l,B)}function D(l,u,i){var t,r,o,f=a({},l.props);for(o in u)"key"==o?t=u[o]:"ref"==o?r=u[o]:f[o]=u[o];return arguments.length>2&&(f.children=arguments.length>3?n.call(arguments,2):i),y(l.type,f,t||l.key,r||l.ref,null)}function E(n,l){var u={__c:l="__cC"+f++,__:n,Consumer:function(n,l){return n.children(l)},Provider:function(n){var u,i;return this.getChildContext||(u=[],(i={})[l]=this,this.getChildContext=function(){return i},this.shouldComponentUpdate=function(n){this.props.value!==n.value&&u.some(function(n){n.__e=!0,g(n)})},this.sub=function(n){u.push(n);var l=n.componentWillUnmount;n.componentWillUnmount=function(){u.splice(u.indexOf(n),1),l&&l.call(n)}}),n.children}};return u.Provider.__=u.Consumer.contextType=u}n=c.slice,l={__e:function(n,l,u,i){for(var t,r,o;l=l.__;)if((t=l.__c)&&!t.__)try{if((r=t.constructor)&&null!=r.getDerivedStateFromError&&(t.setState(r.getDerivedStateFromError(n)),o=t.__d),null!=t.componentDidCatch&&(t.componentDidCatch(n,i||{}),o=t.__d),o)return t.__E=t}catch(l){n=l}throw n}},u=0,i=function(n){return null!=n&&void 0===n.constructor},_.prototype.setState=function(n,l){var u;u=null!=this.__s&&this.__s!==this.state?this.__s:this.__s=a({},this.state),"function"==typeof n&&(n=n(a({},u),this.props)),n&&a(u,n),null!=n&&this.__v&&(l&&this._sb.push(l),g(this))},_.prototype.forceUpdate=function(n){this.__v&&(this.__e=!0,n&&this.__h.push(n),g(this))},_.prototype.render=d,t=[],o="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,m.__r=0,f=0;
|
|
3118
|
+
var n,l,u,i,t,r,o,f,e,c={},s=[],a=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i;function h(n,l){for(var u in l)n[u]=l[u];return n}function v(n){var l=n.parentNode;l&&l.removeChild(n)}function y(l,u,i){var t,r,o,f={};for(o in u)"key"==o?t=u[o]:"ref"==o?r=u[o]:f[o]=u[o];if(arguments.length>2&&(f.children=arguments.length>3?n.call(arguments,2):i),"function"==typeof l&&null!=l.defaultProps)for(o in l.defaultProps)void 0===f[o]&&(f[o]=l.defaultProps[o]);return p(l,f,t,r,null)}function p(n,i,t,r,o){var f={type:n,props:i,key:t,ref:r,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,__h:null,constructor:void 0,__v:null==o?++u:o};return null==o&&null!=l.vnode&&l.vnode(f),f}function d(){return{current:null}}function _(n){return n.children}function k(n,l){this.props=n,this.context=l}function b(n,l){if(null==l)return n.__?b(n.__,n.__.__k.indexOf(n)+1):null;for(var u;l<n.__k.length;l++)if(null!=(u=n.__k[l])&&null!=u.__e)return u.__e;return"function"==typeof n.type?b(n):null}function g(n){var l,u;if(null!=(n=n.__)&&null!=n.__c){for(n.__e=n.__c.base=null,l=0;l<n.__k.length;l++)if(null!=(u=n.__k[l])&&null!=u.__e){n.__e=n.__c.base=u.__e;break}return g(n)}}function m(n){(!n.__d&&(n.__d=!0)&&t.push(n)&&!w.__r++||r!==l.debounceRendering)&&((r=l.debounceRendering)||o)(w)}function w(){var n,l,u,i,r,o,e,c;for(t.sort(f);n=t.shift();)n.__d&&(l=t.length,i=void 0,r=void 0,e=(o=(u=n).__v).__e,(c=u.__P)&&(i=[],(r=h({},o)).__v=o.__v+1,L(c,o,r,u.__n,void 0!==c.ownerSVGElement,null!=o.__h?[e]:null,i,null==e?b(o):e,o.__h),M(i,o),o.__e!=e&&g(o)),t.length>l&&t.sort(f));w.__r=0}function x(n,l,u,i,t,r,o,f,e,a){var h,v,y,d,k,g,m,w=i&&i.__k||s,x=w.length;for(u.__k=[],h=0;h<l.length;h++)if(null!=(d=u.__k[h]=null==(d=l[h])||"boolean"==typeof d||"function"==typeof d?null:"string"==typeof d||"number"==typeof d||"bigint"==typeof d?p(null,d,null,null,d):Array.isArray(d)?p(_,{children:d},null,null,null):d.__b>0?p(d.type,d.props,d.key,d.ref?d.ref:null,d.__v):d)){if(d.__=u,d.__b=u.__b+1,null===(y=w[h])||y&&d.key==y.key&&d.type===y.type)w[h]=void 0;else for(v=0;v<x;v++){if((y=w[v])&&d.key==y.key&&d.type===y.type){w[v]=void 0;break}y=null}L(n,d,y=y||c,t,r,o,f,e,a),k=d.__e,(v=d.ref)&&y.ref!=v&&(m||(m=[]),y.ref&&m.push(y.ref,null,d),m.push(v,d.__c||k,d)),null!=k?(null==g&&(g=k),"function"==typeof d.type&&d.__k===y.__k?d.__d=e=A(d,e,n):e=C(n,d,y,w,k,e),"function"==typeof u.type&&(u.__d=e)):e&&y.__e==e&&e.parentNode!=n&&(e=b(y))}for(u.__e=g,h=x;h--;)null!=w[h]&&("function"==typeof u.type&&null!=w[h].__e&&w[h].__e==u.__d&&(u.__d=$(i).nextSibling),S(w[h],w[h]));if(m)for(h=0;h<m.length;h++)O(m[h],m[++h],m[++h])}function A(n,l,u){for(var i,t=n.__k,r=0;t&&r<t.length;r++)(i=t[r])&&(i.__=n,l="function"==typeof i.type?A(i,l,u):C(u,i,i,t,i.__e,l));return l}function P(n,l){return l=l||[],null==n||"boolean"==typeof n||(Array.isArray(n)?n.some(function(n){P(n,l)}):l.push(n)),l}function C(n,l,u,i,t,r){var o,f,e;if(void 0!==l.__d)o=l.__d,l.__d=void 0;else if(null==u||t!=r||null==t.parentNode)n:if(null==r||r.parentNode!==n)n.appendChild(t),o=null;else{for(f=r,e=0;(f=f.nextSibling)&&e<i.length;e+=1)if(f==t)break n;n.insertBefore(t,r),o=r}return void 0!==o?o:t.nextSibling}function $(n){var l,u,i;if(null==n.type||"string"==typeof n.type)return n.__e;if(n.__k)for(l=n.__k.length-1;l>=0;l--)if((u=n.__k[l])&&(i=$(u)))return i;return null}function H(n,l,u,i,t){var r;for(r in u)"children"===r||"key"===r||r in l||T(n,r,null,u[r],i);for(r in l)t&&"function"!=typeof l[r]||"children"===r||"key"===r||"value"===r||"checked"===r||u[r]===l[r]||T(n,r,l[r],u[r],i)}function I(n,l,u){"-"===l[0]?n.setProperty(l,null==u?"":u):n[l]=null==u?"":"number"!=typeof u||a.test(l)?u:u+"px"}function T(n,l,u,i,t){var r;n:if("style"===l)if("string"==typeof u)n.style.cssText=u;else{if("string"==typeof i&&(n.style.cssText=i=""),i)for(l in i)u&&l in u||I(n.style,l,"");if(u)for(l in u)i&&u[l]===i[l]||I(n.style,l,u[l])}else if("o"===l[0]&&"n"===l[1])r=l!==(l=l.replace(/Capture$/,"")),l=l.toLowerCase()in n?l.toLowerCase().slice(2):l.slice(2),n.l||(n.l={}),n.l[l+r]=u,u?i||n.addEventListener(l,r?z:j,r):n.removeEventListener(l,r?z:j,r);else if("dangerouslySetInnerHTML"!==l){if(t)l=l.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if("width"!==l&&"height"!==l&&"href"!==l&&"list"!==l&&"form"!==l&&"tabIndex"!==l&&"download"!==l&&l in n)try{n[l]=null==u?"":u;break n}catch(n){}"function"==typeof u||(null==u||!1===u&&"-"!==l[4]?n.removeAttribute(l):n.setAttribute(l,u))}}function j(n){return this.l[n.type+!1](l.event?l.event(n):n)}function z(n){return this.l[n.type+!0](l.event?l.event(n):n)}function L(n,u,i,t,r,o,f,e,c){var s,a,v,y,p,d,b,g,m,w,A,P,C,$,H,I=u.type;if(void 0!==u.constructor)return null;null!=i.__h&&(c=i.__h,e=u.__e=i.__e,u.__h=null,o=[e]),(s=l.__b)&&s(u);try{n:if("function"==typeof I){if(g=u.props,m=(s=I.contextType)&&t[s.__c],w=s?m?m.props.value:s.__:t,i.__c?b=(a=u.__c=i.__c).__=a.__E:("prototype"in I&&I.prototype.render?u.__c=a=new I(g,w):(u.__c=a=new k(g,w),a.constructor=I,a.render=q),m&&m.sub(a),a.props=g,a.state||(a.state={}),a.context=w,a.__n=t,v=a.__d=!0,a.__h=[],a._sb=[]),null==a.__s&&(a.__s=a.state),null!=I.getDerivedStateFromProps&&(a.__s==a.state&&(a.__s=h({},a.__s)),h(a.__s,I.getDerivedStateFromProps(g,a.__s))),y=a.props,p=a.state,a.__v=u,v)null==I.getDerivedStateFromProps&&null!=a.componentWillMount&&a.componentWillMount(),null!=a.componentDidMount&&a.__h.push(a.componentDidMount);else{if(null==I.getDerivedStateFromProps&&g!==y&&null!=a.componentWillReceiveProps&&a.componentWillReceiveProps(g,w),!a.__e&&null!=a.shouldComponentUpdate&&!1===a.shouldComponentUpdate(g,a.__s,w)||u.__v===i.__v){for(u.__v!==i.__v&&(a.props=g,a.state=a.__s,a.__d=!1),a.__e=!1,u.__e=i.__e,u.__k=i.__k,u.__k.forEach(function(n){n&&(n.__=u)}),A=0;A<a._sb.length;A++)a.__h.push(a._sb[A]);a._sb=[],a.__h.length&&f.push(a);break n}null!=a.componentWillUpdate&&a.componentWillUpdate(g,a.__s,w),null!=a.componentDidUpdate&&a.__h.push(function(){a.componentDidUpdate(y,p,d)})}if(a.context=w,a.props=g,a.__P=n,P=l.__r,C=0,"prototype"in I&&I.prototype.render){for(a.state=a.__s,a.__d=!1,P&&P(u),s=a.render(a.props,a.state,a.context),$=0;$<a._sb.length;$++)a.__h.push(a._sb[$]);a._sb=[]}else do{a.__d=!1,P&&P(u),s=a.render(a.props,a.state,a.context),a.state=a.__s}while(a.__d&&++C<25);a.state=a.__s,null!=a.getChildContext&&(t=h(h({},t),a.getChildContext())),v||null==a.getSnapshotBeforeUpdate||(d=a.getSnapshotBeforeUpdate(y,p)),H=null!=s&&s.type===_&&null==s.key?s.props.children:s,x(n,Array.isArray(H)?H:[H],u,i,t,r,o,f,e,c),a.base=u.__e,u.__h=null,a.__h.length&&f.push(a),b&&(a.__E=a.__=null),a.__e=!1}else null==o&&u.__v===i.__v?(u.__k=i.__k,u.__e=i.__e):u.__e=N(i.__e,u,i,t,r,o,f,c);(s=l.diffed)&&s(u)}catch(n){u.__v=null,(c||null!=o)&&(u.__e=e,u.__h=!!c,o[o.indexOf(e)]=null),l.__e(n,u,i)}}function M(n,u){l.__c&&l.__c(u,n),n.some(function(u){try{n=u.__h,u.__h=[],n.some(function(n){n.call(u)})}catch(n){l.__e(n,u.__v)}})}function N(l,u,i,t,r,o,f,e){var s,a,h,y=i.props,p=u.props,d=u.type,_=0;if("svg"===d&&(r=!0),null!=o)for(;_<o.length;_++)if((s=o[_])&&"setAttribute"in s==!!d&&(d?s.localName===d:3===s.nodeType)){l=s,o[_]=null;break}if(null==l){if(null===d)return document.createTextNode(p);l=r?document.createElementNS("http://www.w3.org/2000/svg",d):document.createElement(d,p.is&&p),o=null,e=!1}if(null===d)y===p||e&&l.data===p||(l.data=p);else{if(o=o&&n.call(l.childNodes),a=(y=i.props||c).dangerouslySetInnerHTML,h=p.dangerouslySetInnerHTML,!e){if(null!=o)for(y={},_=0;_<l.attributes.length;_++)y[l.attributes[_].name]=l.attributes[_].value;(h||a)&&(h&&(a&&h.__html==a.__html||h.__html===l.innerHTML)||(l.innerHTML=h&&h.__html||""))}if(H(l,p,y,r,e),h)u.__k=[];else if(_=u.props.children,x(l,Array.isArray(_)?_:[_],u,i,t,r&&"foreignObject"!==d,o,f,o?o[0]:i.__k&&b(i,0),e),null!=o)for(_=o.length;_--;)null!=o[_]&&v(o[_]);e||("value"in p&&void 0!==(_=p.value)&&(_!==l.value||"progress"===d&&!_||"option"===d&&_!==y.value)&&T(l,"value",_,y.value,!1),"checked"in p&&void 0!==(_=p.checked)&&_!==l.checked&&T(l,"checked",_,y.checked,!1))}return l}function O(n,u,i){try{"function"==typeof n?n(u):n.current=u}catch(n){l.__e(n,i)}}function S(n,u,i){var t,r;if(l.unmount&&l.unmount(n),(t=n.ref)&&(t.current&&t.current!==n.__e||O(t,null,u)),null!=(t=n.__c)){if(t.componentWillUnmount)try{t.componentWillUnmount()}catch(n){l.__e(n,u)}t.base=t.__P=null,n.__c=void 0}if(t=n.__k)for(r=0;r<t.length;r++)t[r]&&S(t[r],u,i||"function"!=typeof n.type);i||null==n.__e||v(n.__e),n.__=n.__e=n.__d=void 0}function q(n,l,u){return this.constructor(n,u)}function B(u,i,t){var r,o,f;l.__&&l.__(u,i),o=(r="function"==typeof t)?null:t&&t.__k||i.__k,f=[],L(i,u=(!r&&t||i).__k=y(_,null,[u]),o||c,c,void 0!==i.ownerSVGElement,!r&&t?[t]:o?null:i.firstChild?n.call(i.childNodes):null,f,!r&&t?t:o?o.__e:i.firstChild,r),M(f,u)}function D(n,l){B(n,l,D)}function E(l,u,i){var t,r,o,f=h({},l.props);for(o in u)"key"==o?t=u[o]:"ref"==o?r=u[o]:f[o]=u[o];return arguments.length>2&&(f.children=arguments.length>3?n.call(arguments,2):i),p(l.type,f,t||l.key,r||l.ref,null)}function F(n,l){var u={__c:l="__cC"+e++,__:n,Consumer:function(n,l){return n.children(l)},Provider:function(n){var u,i;return this.getChildContext||(u=[],(i={})[l]=this,this.getChildContext=function(){return i},this.shouldComponentUpdate=function(n){this.props.value!==n.value&&u.some(function(n){n.__e=!0,m(n)})},this.sub=function(n){u.push(n);var l=n.componentWillUnmount;n.componentWillUnmount=function(){u.splice(u.indexOf(n),1),l&&l.call(n)}}),n.children}};return u.Provider.__=u.Consumer.contextType=u}n=s.slice,l={__e:function(n,l,u,i){for(var t,r,o;l=l.__;)if((t=l.__c)&&!t.__)try{if((r=t.constructor)&&null!=r.getDerivedStateFromError&&(t.setState(r.getDerivedStateFromError(n)),o=t.__d),null!=t.componentDidCatch&&(t.componentDidCatch(n,i||{}),o=t.__d),o)return t.__E=t}catch(l){n=l}throw n}},u=0,i=function(n){return null!=n&&void 0===n.constructor},k.prototype.setState=function(n,l){var u;u=null!=this.__s&&this.__s!==this.state?this.__s:this.__s=h({},this.state),"function"==typeof n&&(n=n(h({},u),this.props)),n&&h(u,n),null!=n&&this.__v&&(l&&this._sb.push(l),m(this))},k.prototype.forceUpdate=function(n){this.__v&&(this.__e=!0,n&&this.__h.push(n),m(this))},k.prototype.render=_,t=[],o="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,f=function(n,l){return n.__v.__b-l.__v.__b},w.__r=0,e=0;
|
|
3097
3119
|
//# sourceMappingURL=preact.module.js.map
|
|
3098
3120
|
|
|
3099
3121
|
|
|
@@ -3217,7 +3239,7 @@ var n,l,u,i,t,r,o,f,e={},c=[],s=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[c
|
|
|
3217
3239
|
/******/ script.parentNode && script.parentNode.removeChild(script);
|
|
3218
3240
|
/******/ doneFns && doneFns.forEach((fn) => (fn(event)));
|
|
3219
3241
|
/******/ if(prev) return prev(event);
|
|
3220
|
-
/******/ }
|
|
3242
|
+
/******/ }
|
|
3221
3243
|
/******/ var timeout = setTimeout(onScriptComplete.bind(null, undefined, { type: 'timeout', target: script }), 120000);
|
|
3222
3244
|
/******/ script.onerror = onScriptComplete.bind(null, script.onerror);
|
|
3223
3245
|
/******/ script.onload = onScriptComplete.bind(null, script.onload);
|
|
@@ -3417,6 +3439,7 @@ function jsonifyTextPlain(param, done) {
|
|
|
3417
3439
|
type: file.type
|
|
3418
3440
|
});
|
|
3419
3441
|
if (error) return {
|
|
3442
|
+
body: signed,
|
|
3420
3443
|
error
|
|
3421
3444
|
};
|
|
3422
3445
|
let contentType = file.type || 'application/octet-stream';
|
|
@@ -3434,6 +3457,7 @@ function jsonifyTextPlain(param, done) {
|
|
|
3434
3457
|
account_id: this.accid
|
|
3435
3458
|
}));
|
|
3436
3459
|
if (error) return {
|
|
3460
|
+
body,
|
|
3437
3461
|
error
|
|
3438
3462
|
};
|
|
3439
3463
|
return {
|
|
@@ -4776,9 +4800,13 @@ class Store {
|
|
|
4776
4800
|
await this.convoGate.entry();
|
|
4777
4801
|
await flow.map(files, 1, async att => {
|
|
4778
4802
|
const {
|
|
4803
|
+
body,
|
|
4779
4804
|
url,
|
|
4780
4805
|
error
|
|
4781
4806
|
} = await this.api.uploadToS3(att._file);
|
|
4807
|
+
if (util/* default.get */.Z.get(body, 'code') == 'invalid_field_size') {
|
|
4808
|
+
event._error_message = 'cannot_send_too_big_file';
|
|
4809
|
+
}
|
|
4782
4810
|
event._error = error;
|
|
4783
4811
|
att.url = url;
|
|
4784
4812
|
});
|
package/index.html
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
</head>
|
|
14
14
|
<body>
|
|
15
15
|
<h1>Subiz widget testing</h1>
|
|
16
|
+
<button id="test1">Test 1</button>
|
|
16
17
|
<script>
|
|
17
18
|
function getUrlParameter(name) {
|
|
18
19
|
name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]')
|
|
@@ -38,6 +39,13 @@
|
|
|
38
39
|
if (accid == 'acpxkgumifuoofoosble') {
|
|
39
40
|
window.subiz('setViewingProduct', {id: '220170', sku: 'ipx', source_id: 'IPHONE10'})
|
|
40
41
|
}
|
|
42
|
+
|
|
43
|
+
setTimeout(function () {
|
|
44
|
+
const button = document.createElement('button')
|
|
45
|
+
button.innerText = 'test2'
|
|
46
|
+
button.id = 'test2'
|
|
47
|
+
document.body.appendChild(button)
|
|
48
|
+
}, 2000)
|
|
41
49
|
</script>
|
|
42
50
|
</body>
|
|
43
51
|
</html>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@subiz/widget-v4",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.28",
|
|
4
4
|
"main": "./compiled_src/lib.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"dev": "npx webpack serve --config webpack.dev.js",
|
|
@@ -12,30 +12,30 @@
|
|
|
12
12
|
"@subiz/ajax": "^3.0.12",
|
|
13
13
|
"@subiz/flow": "^1.0.9",
|
|
14
14
|
"@subiz/storage": "0.0.8",
|
|
15
|
-
"@subiz/wsclient": "^4.0.
|
|
15
|
+
"@subiz/wsclient": "^4.0.14",
|
|
16
16
|
"cookie_js": "1.4.2",
|
|
17
|
-
"core-js": "^3.
|
|
17
|
+
"core-js": "^3.30.0",
|
|
18
18
|
"css-loader": "5.2.7",
|
|
19
19
|
"file-loader": "^6.2.0",
|
|
20
20
|
"less": "^4.1.3",
|
|
21
21
|
"less-loader": "^11.1.0",
|
|
22
|
-
"marked": "^4.
|
|
23
|
-
"preact": "^10.13.
|
|
22
|
+
"marked": "^4.3.0",
|
|
23
|
+
"preact": "^10.13.2"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@babel/cli": "^7.21.0",
|
|
27
|
-
"@babel/core": "^7.21.
|
|
27
|
+
"@babel/core": "^7.21.4",
|
|
28
28
|
"@babel/plugin-proposal-class-properties": "^7.18.6",
|
|
29
29
|
"@babel/plugin-transform-react-jsx": "^7.21.0",
|
|
30
|
-
"@babel/preset-env": "^7.
|
|
30
|
+
"@babel/preset-env": "^7.21.4",
|
|
31
31
|
"babel-loader": "^9.1.2",
|
|
32
32
|
"babel-plugin-syntax-jsx": "^6.18.0",
|
|
33
33
|
"html-webpack-plugin": "^5.5.0",
|
|
34
|
-
"prettier": "^2.8.
|
|
34
|
+
"prettier": "^2.8.7",
|
|
35
35
|
"puppeteer": "^19.7.3",
|
|
36
|
-
"webpack": "^5.
|
|
36
|
+
"webpack": "^5.78.0",
|
|
37
37
|
"webpack-bundle-analyzer": "^4.8.0",
|
|
38
38
|
"webpack-cli": "^5.0.1",
|
|
39
|
-
"webpack-dev-server": "^4.
|
|
39
|
+
"webpack-dev-server": "^4.13.2"
|
|
40
40
|
}
|
|
41
41
|
}
|
package/src/chatbox/Header.js
CHANGED
|
@@ -15,30 +15,29 @@ export default class Header extends Com {
|
|
|
15
15
|
let cls = 'widget-header'
|
|
16
16
|
let renderSocial = false
|
|
17
17
|
let renderTeam = false
|
|
18
|
-
let renderCollapsed = this.props.view !== 'list' && headerMode === 'collapsed'
|
|
19
|
-
|
|
20
18
|
// expaned header
|
|
21
19
|
let accSetting = this.props.plugin.chatbox || {}
|
|
22
20
|
let layout = sb.get(accSetting, 'header.layout')
|
|
21
|
+
let renderCollapsed = this.props.view !== 'list' && headerMode === 'collapsed'
|
|
22
|
+
let renderClassic = !renderCollapsed && layout === 'classic'
|
|
23
23
|
|
|
24
|
-
if (renderCollapsed) {
|
|
24
|
+
if (renderCollapsed || layout == 'classic') {
|
|
25
25
|
cls += ' widget-header--collapsed'
|
|
26
26
|
} else {
|
|
27
27
|
cls += ' widget-header--convo-expanded'
|
|
28
28
|
renderSocial = layout === 'social'
|
|
29
|
-
renderTeam = !renderSocial
|
|
29
|
+
renderTeam = !(renderSocial || renderClassic)
|
|
30
30
|
}
|
|
31
|
-
|
|
32
31
|
return (
|
|
33
32
|
<div class={cls}>
|
|
34
|
-
{this.renderCollapsedHeader(renderCollapsed)}
|
|
33
|
+
{this.renderCollapsedHeader(renderCollapsed || renderClassic, renderClassic)}
|
|
35
34
|
{this.renderSocial(renderSocial)}
|
|
36
35
|
{this.renderTeam(renderTeam)}
|
|
37
36
|
</div>
|
|
38
37
|
)
|
|
39
38
|
}
|
|
40
39
|
|
|
41
|
-
renderCollapsedHeader(show) {
|
|
40
|
+
renderCollapsedHeader(show, classic) {
|
|
42
41
|
let accSetting = this.props.plugin.chatbox || {}
|
|
43
42
|
let acc = this.props.store.matchAccount() || {}
|
|
44
43
|
let state = acc.is_online ? this.props.t('agent_online') : this.props.t('agent_offline')
|
|
@@ -48,9 +47,13 @@ export default class Header extends Com {
|
|
|
48
47
|
let cls = 'widget-header--inner widget-header--inner--collapsed'
|
|
49
48
|
if (!show) cls += ' widget-header--inner--hidden'
|
|
50
49
|
|
|
50
|
+
let $back = null
|
|
51
|
+
let style = ''
|
|
52
|
+
if (!classic) $back = this.renderBackButton()
|
|
53
|
+
else style = 'padding-bottom: 75px !important;'
|
|
51
54
|
return (
|
|
52
|
-
<div class={cls}>
|
|
53
|
-
{
|
|
55
|
+
<div class={cls} style={style}>
|
|
56
|
+
{$back}
|
|
54
57
|
<AgentsAvatar plugin={this.props.plugin} store={this.props.store} mode='secondary' agent_ids={agentIdsJoined} />
|
|
55
58
|
<div class='widget-header--title-container'>
|
|
56
59
|
<div class='widget-header--title'>{this.getTitle()}</div>
|
package/src/chatbox/Widget.js
CHANGED
|
@@ -25,6 +25,8 @@ export default class Widget extends Com {
|
|
|
25
25
|
constructor(props) {
|
|
26
26
|
super(props)
|
|
27
27
|
this.userSent = {}
|
|
28
|
+
// check user had input form
|
|
29
|
+
this.wasFormInputed = false
|
|
28
30
|
this.setState({
|
|
29
31
|
creating: false,
|
|
30
32
|
clickedJoin: false,
|
|
@@ -241,6 +243,7 @@ export default class Widget extends Com {
|
|
|
241
243
|
}
|
|
242
244
|
|
|
243
245
|
onBooleanChange(key, e) {
|
|
246
|
+
this.wasFormInputed = true
|
|
244
247
|
let formData = sb.cloneDeep(this.state.formData)
|
|
245
248
|
let field = sb.find(formData, (_, fkkey) => fkkey === key)
|
|
246
249
|
if (!field) return
|
|
@@ -250,6 +253,7 @@ export default class Widget extends Com {
|
|
|
250
253
|
}
|
|
251
254
|
|
|
252
255
|
onInputChange(key, val) {
|
|
256
|
+
this.wasFormInputed = true
|
|
253
257
|
let formData = sb.cloneDeep(this.state.formData)
|
|
254
258
|
let field = sb.find(formData, (_, fkkey) => fkkey === key)
|
|
255
259
|
if (!field) return
|
|
@@ -258,6 +262,7 @@ export default class Widget extends Com {
|
|
|
258
262
|
}
|
|
259
263
|
|
|
260
264
|
onListAddItem(key, val) {
|
|
265
|
+
this.wasFormInputed = true
|
|
261
266
|
let formData = sb.cloneDeep(this.state.formData)
|
|
262
267
|
let field = sb.find(formData, (_, fkkey) => fkkey === key)
|
|
263
268
|
if (!field) return
|
|
@@ -268,6 +273,7 @@ export default class Widget extends Com {
|
|
|
268
273
|
}
|
|
269
274
|
|
|
270
275
|
onListRemoveItem(key, index) {
|
|
276
|
+
this.wasFormInputed = true
|
|
271
277
|
let formData = sb.cloneDeep(this.state.formData)
|
|
272
278
|
let field = sb.find(formData, (_, fkkey) => fkkey === key)
|
|
273
279
|
if (!field) return
|
|
@@ -308,6 +314,7 @@ export default class Widget extends Com {
|
|
|
308
314
|
}
|
|
309
315
|
|
|
310
316
|
toggleCheckboxField(key, v) {
|
|
317
|
+
this.wasFormInputed = true
|
|
311
318
|
let formData = sb.cloneDeep(this.state.formData)
|
|
312
319
|
let field = sb.find(formData, (f, fkkey) => f.key === key)
|
|
313
320
|
if (!field) return
|
|
@@ -355,6 +362,7 @@ export default class Widget extends Com {
|
|
|
355
362
|
}
|
|
356
363
|
|
|
357
364
|
toggleRadioField(key, v) {
|
|
365
|
+
this.wasFormInputed = true
|
|
358
366
|
let formData = sb.cloneDeep(this.state.formData)
|
|
359
367
|
let field = sb.find(formData, (f, fkkey) => f.key === key)
|
|
360
368
|
if (!field) return
|
|
@@ -364,6 +372,7 @@ export default class Widget extends Com {
|
|
|
364
372
|
}
|
|
365
373
|
|
|
366
374
|
selectDropdownField(key, v) {
|
|
375
|
+
this.wasFormInputed = true
|
|
367
376
|
let formData = sb.cloneDeep(this.state.formData)
|
|
368
377
|
let field = sb.find(formData, (f, fkkey) => f.key === key)
|
|
369
378
|
if (!field) return
|
|
@@ -722,12 +731,17 @@ export default class Widget extends Com {
|
|
|
722
731
|
this.props.store.createPostback(this.props.cid, postback)
|
|
723
732
|
}
|
|
724
733
|
|
|
734
|
+
onChangeMessageInput() {
|
|
735
|
+
this.wasFormInputed = true
|
|
736
|
+
}
|
|
737
|
+
|
|
725
738
|
renderChat() {
|
|
726
739
|
let $input = (
|
|
727
740
|
<MessageInput
|
|
728
741
|
store={this.props.store}
|
|
729
742
|
ref={this.msgInput}
|
|
730
743
|
cid={this.props.cid}
|
|
744
|
+
onChange={this.onChangeMessageInput}
|
|
731
745
|
onSend={this.sendMessage}
|
|
732
746
|
t={this.props.t}
|
|
733
747
|
/>
|
package/src/chatbox/main.js
CHANGED
|
@@ -14,6 +14,7 @@ export default class Main extends Com {
|
|
|
14
14
|
constructor(props) {
|
|
15
15
|
super(props)
|
|
16
16
|
this.refButton = createRef()
|
|
17
|
+
this.refWidget = createRef()
|
|
17
18
|
}
|
|
18
19
|
|
|
19
20
|
async refreshCSS() {
|
|
@@ -49,7 +50,7 @@ export default class Main extends Com {
|
|
|
49
50
|
|
|
50
51
|
this.checkExpand()
|
|
51
52
|
this.props.store.onResetCSS(this, () => this.refreshCSS())
|
|
52
|
-
this.props.store.onConvoEvent(this, (
|
|
53
|
+
this.props.store.onConvoEvent(this, (ev) => this.onConvoEvent(ev))
|
|
53
54
|
this.props.store.onUpdate(this, (_) => this.checkExpand())
|
|
54
55
|
await this.refreshCSS()
|
|
55
56
|
this.setState({cssready: true})
|
|
@@ -89,11 +90,33 @@ export default class Main extends Com {
|
|
|
89
90
|
onClose={(a) => this.onWidgetClose(a)}
|
|
90
91
|
onGo={(a) => this.showWidget(a)}
|
|
91
92
|
t={this.props.t}
|
|
93
|
+
ref={this.refWidget}
|
|
92
94
|
/>
|
|
93
95
|
</div>
|
|
94
96
|
)
|
|
95
97
|
}
|
|
96
98
|
|
|
99
|
+
onConvoEvent(ev) {
|
|
100
|
+
this.checkExpand()
|
|
101
|
+
this.checkShowBotConvo(ev)
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
checkShowBotConvo(ev) {
|
|
105
|
+
let $widget = this.refWidget.current
|
|
106
|
+
if (!$widget) return
|
|
107
|
+
if ($widget.wasFormInputed) return
|
|
108
|
+
if (ev.type !== 'message_sent') return
|
|
109
|
+
if (!this.state.isShowWidget) return
|
|
110
|
+
|
|
111
|
+
let byType = sb.get(ev, 'by.type')
|
|
112
|
+
let byid = sb.get(ev, 'by.id') || ''
|
|
113
|
+
if (!byid.startsWith('bb') || byType !== 'agent') return
|
|
114
|
+
|
|
115
|
+
let cid = sb.get(ev, 'data.message.conversation_id')
|
|
116
|
+
if (!cid) return
|
|
117
|
+
this.showWidget({cid, view: 'chat'})
|
|
118
|
+
}
|
|
119
|
+
|
|
97
120
|
checkExpand() {
|
|
98
121
|
// run on desktop environment only
|
|
99
122
|
if (this.props.store.isMobile()) return
|
package/src/util/campaign.js
CHANGED
|
@@ -35,14 +35,15 @@ export function trackAreaClicked(selector, cb) {
|
|
|
35
35
|
common.map(selector.split('\n'), (selector) => {
|
|
36
36
|
selector = common.trim(selector)
|
|
37
37
|
if (!selector) return
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
38
|
+
on('click', selector, cb)
|
|
39
|
+
//let doms = []
|
|
40
|
+
//try {
|
|
41
|
+
//doms = document.querySelectorAll(selector)
|
|
42
|
+
//} catch (e) {}
|
|
43
|
+
//common.map(doms, (dom) => {
|
|
44
|
+
//if (!dom) return
|
|
45
|
+
//dom.addEventListener('click', cb, false)
|
|
46
|
+
//})
|
|
46
47
|
})
|
|
47
48
|
}
|
|
48
49
|
|
|
@@ -99,3 +100,23 @@ export function trackTimeOnPage(seconds = 0, cb) {
|
|
|
99
100
|
common.clearInterval(timer)
|
|
100
101
|
}, 1000)
|
|
101
102
|
}
|
|
103
|
+
|
|
104
|
+
function on(eventName, selector, fn) {
|
|
105
|
+
document.addEventListener(eventName, function (event) {
|
|
106
|
+
let possibleTargets = document.querySelectorAll(selector)
|
|
107
|
+
let target = event.target
|
|
108
|
+
|
|
109
|
+
for (let i = 0, l = possibleTargets.length; i < l; i++) {
|
|
110
|
+
let el = target
|
|
111
|
+
let p = possibleTargets[i]
|
|
112
|
+
|
|
113
|
+
while (el && el !== document) {
|
|
114
|
+
if (el === p) {
|
|
115
|
+
return fn.call(p, event)
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
el = el.parentNode
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
})
|
|
122
|
+
}
|