@crmchatreactcomponent/quick-messages 0.0.9 → 0.0.10
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/dist/index.es.js +482 -450
- package/dist/index.umd.js +41 -13
- package/package.json +1 -1
package/dist/index.umd.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
(function(f,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("react/jsx-runtime"),require("react"),require("antd"),require("emoji-picker-react"),require("react-i18next"),require("lodash-es"),require("styled-components"),require("@ant-design/icons"),require("react-use"),require("color"),require("i18next")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","antd","emoji-picker-react","react-i18next","lodash-es","styled-components","@ant-design/icons","react-use","color","i18next"],o):(f=typeof globalThis<"u"?globalThis:f||self,o(f.quickmessages={},f.jsxRuntime,f.react,f.antd,f.EmojiPicker,f.reactI18next,f.lodashEs,f.styled,f.icons,f.reactUse,f.Color,f.i18n))})(this,function(f,o,
|
|
2
|
-
`).trim(),type:v.PLAIN};if(t.querySelector("img")){const n=t.querySelector("img");return{value:{src:n.src,title:(r=n.title)!=null?r:""},type:v.IMAGE}}return{value:t.innerText,type:v.PLAIN}}}const
|
|
3
|
-
`:""}),r}getHtmlData(t){var r;let n="";if(t.length===1&&t[0].length===1){const{type:a,value:
|
|
1
|
+
(function(f,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("react/jsx-runtime"),require("react"),require("antd"),require("emoji-picker-react"),require("react-i18next"),require("lodash-es"),require("styled-components"),require("@ant-design/icons"),require("react-use"),require("color"),require("i18next")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","antd","emoji-picker-react","react-i18next","lodash-es","styled-components","@ant-design/icons","react-use","color","i18next"],o):(f=typeof globalThis<"u"?globalThis:f||self,o(f.quickmessages={},f.jsxRuntime,f.react,f.antd,f.EmojiPicker,f.reactI18next,f.lodashEs,f.styled,f.icons,f.reactUse,f.Color,f.i18n))})(this,function(f,o,b,l,G,k,bt,S,L,yt,vt,mt){"use strict";function Z(){const{theme:e}=b.useContext(l.ConfigProvider.ConfigContext);return b.useMemo(()=>(e==null?void 0:e.algorithm)===l.theme.darkAlgorithm,[e])}const Ct=G.EmojiStyle.FACEBOOK,xt=({children:e,disabled:t=!1,onSelect:r=()=>{},onOpenChange:n=()=>{}})=>{const[a,i]=b.useState(!1),d=Z();b.useEffect(()=>{n(a)},[a]);function g(s){r(s.emoji),i(!1)}function u(s){t||i(s)}return o.jsx(l.Popover,{title:"",open:a,onOpenChange:u,overlayInnerStyle:{backgroundColor:"transparent",padding:0},trigger:["click"],content:o.jsx(l.Space,{direction:"vertical",size:12,children:o.jsx(G,{skinTonesDisabled:!0,onEmojiClick:g,emojiStyle:Ct,lazyLoadEmojis:!1,theme:d?G.Theme.DARK:G.Theme.LIGHT})}),destroyTooltipOnHide:!0,children:e})};function Tt(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){const t=Math.random()*16|0;return(e=="x"?t:t&3|8).toString(16)})}function R(e,t){return e.length>t?e.substring(0,t)+"…":e}const z=b.createContext(null);function St(e){const[t,r]=l.message.useMessage(),[n,a]=l.Modal.useModal();return o.jsxs(z.Provider,{value:{messageApi:t,modalApi:n},children:[r,a,e.children]})}class $t{constructor(){this.type=v.PLAIN}toText(t){return t}toHtml(t){return t}parse(t){return t}}var jt=typeof global=="object"&&global&&global.Object===Object&&global,ee=jt,wt=typeof self=="object"&&self&&self.Object===Object&&self,At=ee||wt||Function("return this")(),w=At,kt=w.Symbol,H=kt,te=Object.prototype,Mt=te.hasOwnProperty,Pt=te.toString,D=H?H.toStringTag:void 0;function Ot(e){var t=Mt.call(e,D),r=e[D];try{e[D]=void 0;var n=!0}catch{}var a=Pt.call(e);return n&&(t?e[D]=r:delete e[D]),a}var Dt=Object.prototype,Et=Dt.toString;function It(e){return Et.call(e)}var Nt="[object Null]",Gt="[object Undefined]",re=H?H.toStringTag:void 0;function M(e){return e==null?e===void 0?Gt:Nt:re&&re in Object(e)?Ot(e):It(e)}function E(e){return e!=null&&typeof e=="object"}var Lt=Array.isArray,$=Lt;function ne(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var Ht="[object AsyncFunction]",_t="[object Function]",Ft="[object GeneratorFunction]",zt="[object Proxy]";function oe(e){if(!ne(e))return!1;var t=M(e);return t==_t||t==Ft||t==Ht||t==zt}var Bt=w["__core-js_shared__"],B=Bt,ae=function(){var e=/[^.]+$/.exec(B&&B.keys&&B.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function qt(e){return!!ae&&ae in e}var Wt=Function.prototype,Kt=Wt.toString;function P(e){if(e!=null){try{return Kt.call(e)}catch{}try{return e+""}catch{}}return""}var Ut=/[\\^$.*+?()[\]{}|]/g,Vt=/^\[object .+?Constructor\]$/,Yt=Function.prototype,Jt=Object.prototype,Xt=Yt.toString,Qt=Jt.hasOwnProperty,Zt=RegExp("^"+Xt.call(Qt).replace(Ut,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Rt(e){if(!ne(e)||qt(e))return!1;var t=oe(e)?Zt:Vt;return t.test(P(e))}function er(e,t){return e==null?void 0:e[t]}function I(e,t){var r=er(e,t);return Rt(r)?r:void 0}var tr=I(w,"WeakMap"),q=tr,rr=9007199254740991;function ie(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=rr}function nr(e){return e!=null&&ie(e.length)&&!oe(e)}var or=Object.prototype;function se(e){var t=e&&e.constructor,r=typeof t=="function"&&t.prototype||or;return e===r}var ar="[object Arguments]";function le(e){return E(e)&&M(e)==ar}var ce=Object.prototype,ir=ce.hasOwnProperty,sr=ce.propertyIsEnumerable,lr=le(function(){return arguments}())?le:function(e){return E(e)&&ir.call(e,"callee")&&!sr.call(e,"callee")},cr=lr;function ur(){return!1}var ue=typeof f=="object"&&f&&!f.nodeType&&f,de=ue&&typeof module=="object"&&module&&!module.nodeType&&module,dr=de&&de.exports===ue,pe=dr?w.Buffer:void 0,pr=pe?pe.isBuffer:void 0,fr=pr||ur,gr=fr,hr="[object Arguments]",br="[object Array]",yr="[object Boolean]",vr="[object Date]",mr="[object Error]",Cr="[object Function]",xr="[object Map]",Tr="[object Number]",Sr="[object Object]",$r="[object RegExp]",jr="[object Set]",wr="[object String]",Ar="[object WeakMap]",kr="[object ArrayBuffer]",Mr="[object DataView]",Pr="[object Float32Array]",Or="[object Float64Array]",Dr="[object Int8Array]",Er="[object Int16Array]",Ir="[object Int32Array]",Nr="[object Uint8Array]",Gr="[object Uint8ClampedArray]",Lr="[object Uint16Array]",Hr="[object Uint32Array]",y={};y[Pr]=y[Or]=y[Dr]=y[Er]=y[Ir]=y[Nr]=y[Gr]=y[Lr]=y[Hr]=!0,y[hr]=y[br]=y[kr]=y[yr]=y[Mr]=y[vr]=y[mr]=y[Cr]=y[xr]=y[Tr]=y[Sr]=y[$r]=y[jr]=y[wr]=y[Ar]=!1;function _r(e){return E(e)&&ie(e.length)&&!!y[M(e)]}function Fr(e){return function(t){return e(t)}}var fe=typeof f=="object"&&f&&!f.nodeType&&f,N=fe&&typeof module=="object"&&module&&!module.nodeType&&module,zr=N&&N.exports===fe,W=zr&&ee.process,Br=function(){try{var e=N&&N.require&&N.require("util").types;return e||W&&W.binding&&W.binding("util")}catch{}}(),ge=Br,he=ge&&ge.isTypedArray,qr=he?Fr(he):_r,Wr=qr;function be(e,t){return function(r){return e(t(r))}}var Kr=be(Object.keys,Object),Ur=Kr,Vr=Object.prototype,Yr=Vr.hasOwnProperty;function Jr(e){if(!se(e))return Ur(e);var t=[];for(var r in Object(e))Yr.call(e,r)&&r!="constructor"&&t.push(r);return t}var Xr=I(w,"Map"),K=Xr,Qr=be(Object.getPrototypeOf,Object),Zr=Qr,Rr="[object Object]",en=Function.prototype,tn=Object.prototype,ye=en.toString,rn=tn.hasOwnProperty,nn=ye.call(Object);function U(e){if(!E(e)||M(e)!=Rr)return!1;var t=Zr(e);if(t===null)return!0;var r=rn.call(t,"constructor")&&t.constructor;return typeof r=="function"&&r instanceof r&&ye.call(r)==nn}var on=I(w,"DataView"),V=on,an=I(w,"Promise"),Y=an,sn=I(w,"Set"),J=sn,ve="[object Map]",ln="[object Object]",me="[object Promise]",Ce="[object Set]",xe="[object WeakMap]",Te="[object DataView]",cn=P(V),un=P(K),dn=P(Y),pn=P(J),fn=P(q),O=M;(V&&O(new V(new ArrayBuffer(1)))!=Te||K&&O(new K)!=ve||Y&&O(Y.resolve())!=me||J&&O(new J)!=Ce||q&&O(new q)!=xe)&&(O=function(e){var t=M(e),r=t==ln?e.constructor:void 0,n=r?P(r):"";if(n)switch(n){case cn:return Te;case un:return ve;case dn:return me;case pn:return Ce;case fn:return xe}return t});var gn=O,hn="[object String]";function X(e){return typeof e=="string"||!$(e)&&E(e)&&M(e)==hn}var bn="[object Map]",yn="[object Set]",vn=Object.prototype,mn=vn.hasOwnProperty;function Cn(e){if(e==null)return!0;if(nr(e)&&($(e)||typeof e=="string"||typeof e.splice=="function"||gr(e)||Wr(e)||cr(e)))return!e.length;var t=gn(e);if(t==bn||t==yn)return!e.size;if(se(e))return!Jr(e).length;for(var r in e)if(mn.call(e,r))return!1;return!0}function Se(e){return e.every(t=>$(t))}function _(e){return!!(!$(e)||e.length===0||$(e[0])&&e[0].length===0)}function $e(e){let t="";return Object.keys(e).map(r=>{t+=` ${r}="${e[r].replace(/"/g,'\\"')}"`}),t}class xn{constructor(){this.type=v.IMAGE}toText(t){var r;return(r=t.title)!=null?r:""}toHtml(t){var r;return`<img src="${t.src}" alt="${t.title}" ${$e((r=t.attrs)!=null?r:{})}>`}parse(t){var r,n;return t.title=(r=t.title)!=null?r:"",t.attrs=(n=t.attrs)!=null?n:{},t}}class Tn{constructor(){this.type=v.HYPERLINK}toText(t){var r;return(r=t.title)!=null?r:""}toHtml(t){return`<a href="${t.link}" target="_blank" ${$e(t.attrs)}>${t.title}</a>`}parse(t){var r,n;return t.title=(r=t.title)!=null?r:"",t.attrs=(n=t.attrs)!=null?n:{},t}}class Sn{constructor(){this.type=v.RICH_TEXT}toText(t){return t.plain}toHtml(t){return t.value}parse(t){return t}}var v=(e=>(e.PLAIN="gs-plain-text",e.IMAGE="gs-image",e.HYPERLINK="gs-hyperlink",e.RICH_TEXT="gs-rich-text",e))(v||{});const $n=[new $t,new xn,new Tn,new Sn];var j=(e=>(e.PLAIN="text/plain",e.HTML="text/html",e))(j||{});class jn{detectRule(t){return!!~t.indexOf("google-sheets-html-origin")}parser(t){const r=document.createElement("div");return r.innerHTML=t,[...r.querySelector("table").querySelector("tbody").childNodes].map(a=>[...a.childNodes].map(i=>this.parseTd(i)))}getSheetsValue(t){try{const r=JSON.parse(t);return r[r[1]]?r[r[1]].replaceAll(" "," "):""}catch{return""}}parseTd(t){var r;if(t.dataset.sheetsHyperlink)return{value:{title:this.getSheetsValue(t.dataset.sheetsValue),link:t.dataset.sheetsHyperlink},type:v.HYPERLINK};if(t.dataset.sheetsTextstyleruns)return{value:{plain:this.getSheetsValue(t.dataset.sheetsValue),value:t.innerHTML},type:v.RICH_TEXT};if(t.dataset.sheetsValue)return{value:t.innerHTML.replace(/\<br\>/g,`
|
|
2
|
+
`).trim(),type:v.PLAIN};if(t.querySelector("img")){const n=t.querySelector("img");return{value:{src:n.src,title:(r=n.title)!=null?r:""},type:v.IMAGE}}return{value:t.innerText,type:v.PLAIN}}}const Q=[new jn];function wn(e){for(let t=0;t<Q.length;t++)if(Q[t].detectRule(e)){const r=Q[t].parser(e);if(!_(r))return r}return[]}class An{static parse(t){const r=document.createElement("div");r.innerHTML=t;const n=r.childNodes[0];if(!n)return!1;if(n.dataset.sheetsHyperlink)return{value:{link:n.dataset.sheetsHyperlink,title:n.innerText},type:v.HYPERLINK};if(n.tagName==="A")return{value:{link:n.getAttribute("href"),title:n.innerText},type:v.HYPERLINK};const a=n.childNodes[0];return a&&n.childNodes.length===1&&a.tagName==="IMG"?{value:{link:a.getAttribute("src"),title:a.title},type:v.IMAGE}:n.tagName==="IMG"?{value:{link:n.getAttribute("src"),title:n.title},type:v.IMAGE}:!1}}class kn{constructor(){this.handles={},this.props={},this.evenHandles={}}destroy(){this.handles={}}registerHandler(t){[...t,...$n].map(r=>{this.handles[r.type]=r})}formatSetCopyData(t){return X(t)?[[{value:t,payload:void 0,type:this.handles[v.PLAIN].type}]]:U(t)?[[t]]:$(t)?(Se(t)||(t=[t.map(r=>X(r)?{value:r,payload:"",type:this.handles[v.PLAIN].type}:r)]),t=t.map(r=>r.map(n=>X(n)?{value:n,type:this.handles[v.PLAIN].type,payload:""}:n)),t):(console.error("unknown data type",t),[])}getTextData(t){let r="";return t.map((n,a)=>{n.map((i,d)=>{var g;const{value:u,type:s,payload:m}=i;r+=((g=this.handles[s])!=null?g:this.handles[v.PLAIN]).toText(u,m),r+=d<n.length-1?" ":""}),r+=a<t.length-1?`
|
|
3
|
+
`:""}),r}getHtmlData(t){var r;let n="";if(t.length===1&&t[0].length===1){const{type:a,value:i,payload:d}=t[0][0];return((r=this.handles[a])!=null?r:this.handles[v.PLAIN]).toHtml(i,d)}return t.map((a,i)=>{n+="<tr>",a.map((d,g)=>{var u;const{value:s,type:m,payload:x}=d;n+=`<td>${((u=this.handles[m])!=null?u:this.handles[v.PLAIN]).toHtml(s,x)}</td>`}),n+="</tr>"}),`<table id="gs-clipboard-table"><tbody>${n}</tbody></table>`}async formatClipboardData(t){const r={text:"",html:"",clipboardType:[]};if(!t.types.includes(j.HTML)){const m=await(await t.getType(j.PLAIN)).text();return r.text=m,r.html=m,r.clipboardType=[[{value:m,type:this.handles[v.PLAIN].type}]],r}const n=await t.getType(j.HTML),a=await t.getType(j.PLAIN),i=await n.text(),d=await a.text(),g=document.createElement("div");g.innerHTML=i;const u=g.querySelector("#original-data");if(g.querySelector("#gs-clipboard-table")||u)r.text=d,r.html=i,r.clipboardType=JSON.parse(decodeURIComponent(u.dataset.data));else if(g.querySelector("table")){r.text=d,r.html=i;let s=[];if(this.props.tableParsers.length>0){for(let m=0;m<this.props.tableParsers.length;m++)if(this.props.tableParsers[m].detectRule(i)){const x=this.props.tableParsers[m].parser(i);if(!_(x)){s=x;break}}}(Cn(s)||_(s))&&(s=wn(i)),r.clipboardType=s}else{let s=null;this.props.unknownHtmlParser&&(s=this.props.unknownHtmlParser(i)),s=s||An.parse(i),s||(s={value:d,type:this.handles[v.PLAIN].type}),r.text=d,r.html=i,U(s)&&(r.clipboardType=[[s]]),$(s)&&(Se(s)?r.clipboardType=s:r.clipboardType=[s])}return r}getClipboardTypeData(t){return t}on(t,r){return $(this.evenHandles[t])||(this.evenHandles[t]=[]),this.evenHandles[t].push(r),()=>{this.evenHandles[t].splice(this.evenHandles[t].indexOf(r),1)}}trigger(t,...r){if($(this.evenHandles[t]))for(let n=0;n<this.evenHandles[t].length;n++){const a=this.evenHandles[t][n];a(...r)}}}const Mn={handlers:[],tableParsers:[]};class Pn extends kn{constructor(t={}){var r,n;if(super(),(n=(r=window.navigator)==null?void 0:r.clipboard)!=null&&n.read)this.props=Object.assign(Mn,t),this.registerHandler(this.props.handlers);else throw new Error("You browser didn't support clipboard api!")}async getDataFromClipboard(){return new Promise((t,r)=>{window.navigator.clipboard.read().then(async n=>{const a=n[0];t(this.transformClipboardData(await this.formatClipboardData(a)))},n=>r(n))})}setCopy(t){return this.setCopyData(this.formatSetCopyData(t),!1)}formatCopyData(t){return this.setCopyData(this.formatSetCopyData(t),!0)}transformClipboardData(t){return _(t.clipboardType)||t.clipboardType.map(r=>{$(r)?r.map(n=>{n.value=this.handles[n.type]?this.handles[n.type].parse(n.value):n.value}):U(r)&&(r.value=this.handles[r.type]?this.handles[r.type].parse(r.value):r.value)}),t}setCopyData(t,r=!1){const n={text:this.getTextData(t),html:this.getHtmlData(t),clipboardType:this.getClipboardTypeData(t)};if(r)return n;this.trigger("beforeCopy",n);const a=[new ClipboardItem({[j.PLAIN]:new Blob([n.text],{type:j.PLAIN}),[j.HTML]:new Blob([n.html+`<div id="original-data" data-data="${encodeURIComponent(JSON.stringify(n.clipboardType))}"></div>`],{type:j.HTML})})];return window.navigator.clipboard.write(a).then(()=>this.trigger("copySucceeded",a),i=>this.trigger("copyFailed",i)),n}}const On=new Pn,je=({data:e=[],onChange:t=()=>{},tableHeight:r="460px",limitation:n={}})=>{const{messageApi:a}=b.useContext(z),{title:i=15,content:d=2e3}=n,{t:g}=k.useTranslation();function u(c){const h=e.findIndex(p=>p.label===c.label);e[h]=c,t([...e])}function s(){const c=[{label:`#${e.length+1}`,content:""},...e];t(c),a.success(g("createSuccessfully"))}function m(c){const h=e.filter(p=>p.label!==c);t(h)}async function x(){const p=[...(await On.getDataFromClipboard()).clipboardType.map(C=>{var A,F;return{label:((A=C==null?void 0:C[0])==null?void 0:A.value)??"",content:((F=C==null?void 0:C[1])==null?void 0:F.value)??""}}).filter(C=>C.label&&C.content),...e];t(bt.uniqBy(p,"label"))}return o.jsxs(l.Table,{bordered:!0,dataSource:e,pagination:!1,rowKey:"label",size:"small",scroll:{y:r,x:"max-content"},locale:{emptyText:()=>o.jsxs(l.Space,{direction:"vertical",size:24,style:{width:"100%",textAlign:"center",padding:"62px 0px"},children:[o.jsx(l.Empty,{}),o.jsx(l.Button,{type:"primary",onClick:s,children:g("create")})]})},footer:()=>o.jsxs(l.Flex,{style:{width:"100%"},justify:"space-between",children:[o.jsx(l.Space,{children:o.jsx("div",{})}),o.jsxs(l.Space,{size:12,children:[o.jsx(l.Button,{block:!0,type:"text",onClick:x,children:g("importFromClipboard")}),o.jsx(l.Button,{type:"primary",onClick:s,children:g("create")})]})]}),children:[o.jsx(l.Table.Column,{title:g("titleFieldName"),dataIndex:"label",width:400,render:(c,h)=>o.jsx(we,{maxLength:i,type:"input",value:c,onChange:p=>{if(h.label!==p){if(e.find(C=>C.label===p)){a.error(g("cannotSavedMessageCuzLabelExisted"));return}if(p.trim()===""){a.error(g("cannotSavedMessageCuzLabelEmpty"));return}h.label=p,u(h)}}})},"label"),o.jsx(l.Table.Column,{title:g("content"),dataIndex:"content",width:400,render:(c,h)=>o.jsx(we,{maxLength:d,type:"textarea",value:c,onChange:p=>{if(p.trim()===""){a.error(g("cannotSavedMessageCuzContentEmpty"));return}h.content=p,u(h)}})},"content"),o.jsx(l.Table.Column,{title:"操作",dataIndex:"id",width:120,render:(c,h)=>o.jsx(l.Space,{size:4,children:o.jsx(l.Button,{size:"small",type:"text",danger:!0,onClick:()=>m(h.label),children:g("delete")})})},"id")]})},Dn=S.div`
|
|
4
4
|
border: 1px solid transparent;
|
|
5
5
|
padding: 0 4px;
|
|
6
6
|
margin: 0 -4px;
|
|
@@ -10,28 +10,38 @@
|
|
|
10
10
|
&:hover {
|
|
11
11
|
border-color: ${e=>e.$isDark?"#4d4848":"#c0bbbb"};
|
|
12
12
|
}
|
|
13
|
-
`;function
|
|
13
|
+
`;function we(e){const[t,r]=b.useState(!1),n=b.useRef(null),a=Z();b.useEffect(()=>{t&&n.current&&(e.type==="input"?n.current.select():n.current.focus())},[t,e.type]);function i(){r(!0)}function d(u){r(!1),e.onChange(u)}function g(u){e.onChange(u),n.current.blur()}if(t){if(e.type==="textarea")return o.jsx("div",{style:{paddingBottom:18},children:o.jsx(l.Input.TextArea,{showCount:!0,maxLength:e.maxLength,defaultValue:e.value,ref:n,size:"small",style:{width:"100%"},autoSize:{minRows:4,maxRows:4},onBlur:u=>d(u.target.value),onKeyDown:u=>{if(u.key==="Enter"){if(u.shiftKey||u.ctrlKey||u.metaKey)return;{u.preventDefault();const s=u.target;return g(s.value),!1}}}})});if(e.type==="input")return o.jsx(l.Input,{showCount:!0,maxLength:e.maxLength,defaultValue:e.value,ref:n,size:"small",style:{width:"100%"},onBlur:u=>d(u.target.value),onPressEnter:u=>{const s=u.target;g(s.value)}})}return o.jsx(Dn,{onClick:i,$isDark:a,children:o.jsx("div",{style:{minHeight:22},dangerouslySetInnerHTML:{__html:e.value.trim().split(`
|
|
14
14
|
`).slice(0,4).join("<br/>")+(e.value.trim().split(`
|
|
15
|
-
`).length>4?"...":"")}})})}const
|
|
15
|
+
`).length>4?"...":"")}})})}const En=S.div``,In=S.div`
|
|
16
16
|
min-height: 380px;
|
|
17
|
-
`,
|
|
17
|
+
`,Nn=S.span`
|
|
18
18
|
font-size: 12px;
|
|
19
|
-
`,
|
|
19
|
+
`,Gn=S.div`
|
|
20
20
|
&:hover {
|
|
21
|
+
/* inline-flex 而非 block:保留 antd 按钮内部的居中布局,避免宿主页样式破坏对齐 */
|
|
21
22
|
.ant-btn {
|
|
22
|
-
display:
|
|
23
|
+
display: inline-flex !important;
|
|
23
24
|
}
|
|
24
25
|
}
|
|
25
26
|
.ant-btn {
|
|
26
27
|
display: none;
|
|
28
|
+
/* 强制覆盖宿主页可能注入的 line-height(如 max.ru 的 line-height:40px),否则图标会被压偏 */
|
|
29
|
+
line-height: 1 !important;
|
|
30
|
+
vertical-align: middle !important;
|
|
31
|
+
align-items: center !important;
|
|
32
|
+
justify-content: center !important;
|
|
27
33
|
}
|
|
28
|
-
|
|
34
|
+
.ant-btn .anticon {
|
|
35
|
+
line-height: 1 !important;
|
|
36
|
+
vertical-align: middle !important;
|
|
37
|
+
}
|
|
38
|
+
`,Ln=S.div`
|
|
29
39
|
background-color: ${e=>e.$color};
|
|
30
40
|
width: 12px;
|
|
31
41
|
height: 12px;
|
|
32
42
|
border: 1px solid #fff;
|
|
33
43
|
border-radius: 4px;
|
|
34
|
-
`,Ae=({data:e=[],onChange:t=()=>{},...r})=>{const[n,a]=
|
|
44
|
+
`,Ae=({data:e=[],onChange:t=()=>{},...r})=>{const[n,a]=b.useState([]),{t:i}=k.useTranslation();b.useEffect(()=>{e.length>0&&a([e[0].id])},[]);const d=b.useMemo(()=>e.map(c=>({key:c.id,label:o.jsx(Gn,{children:o.jsxs(l.Flex,{justify:"space-between",align:"center",children:[o.jsxs(l.Space,{children:[o.jsx("span",{children:c.title}),c.data.length?o.jsxs(Nn,{children:["(",c.data.length,")"]}):null]}),o.jsxs(l.Space,{size:8,children:[o.jsx(Ln,{$color:c.color}),o.jsx(Hn,{data:c,onSaved:h=>u(c.id,h)}),o.jsx(l.Popconfirm,{title:i("confirmDelete"),onConfirm:()=>s(c.id),children:o.jsx(l.Button,{danger:!0,size:"small",icon:o.jsx(L.DeleteOutlined,{}),type:"text"})})]})]})})})),[e]),g=b.useMemo(()=>{const c=n[0];if(c){const h=e.find(p=>p.id===c);if(h)return h.data}return!1},[n,e]);function u(c,h){const p=[...e],C=p.findIndex(A=>A.id===c);~C&&(p[C]={...p[C],...h}),t(p)}function s(c){const h=[...e].filter(p=>p.id!==c);t(h)}function m(c){const h=[...e],p=n[0];if(p){const C=h.find(A=>A.id===p);C&&(C.data=c)}t(h)}function x(c){const h=Tt(),p=[...e];p.push({id:h,color:c.color,title:c.title,data:[]}),t(p),a([h])}return d.length===0?o.jsxs(l.Flex,{vertical:!0,align:"center",gap:8,children:[o.jsx(l.Empty,{description:i("noData")}),o.jsx(ke,{onCreate:x})]}):o.jsx(En,{children:o.jsxs(l.Flex,{gap:16,children:[o.jsxs(l.Space,{direction:"vertical",children:[o.jsx(In,{children:o.jsx(l.Menu,{items:d,style:{width:300},selectedKeys:n,onSelect:({key:c})=>{a([c])}})}),o.jsx(ke,{onCreate:x,block:!0})]}),o.jsx("div",{style:{flex:1,minWidth:0},children:g?o.jsx(je,{data:g,onChange:m,...r},n[0]):o.jsx(l.Alert,{type:"info",message:i("selectAGroupFirst"),style:{height:60,minWidth:400}})})]})})};function Hn(e){const[t,r]=b.useState({title:"",color:""});return o.jsx(Me,{isEdit:!1,onCompleteChange:e.onSaved,data:t,onOpenChange:n=>{n&&r(e.data)},onDataChange:n=>r(n),children:o.jsx(l.Button,{size:"small",icon:o.jsx(L.EditOutlined,{}),type:"text"})})}function ke(e){const{t}=k.useTranslation(),r={title:"",color:"#1677FF"},[n,a]=b.useState({...r});return o.jsx(Me,{isEdit:!1,onCompleteChange:e.onCreate,data:n,onOpenChange:i=>{i&&a({...r})},onDataChange:i=>a(i),children:o.jsx(l.Button,{block:!!e.block,icon:o.jsx(L.PlusOutlined,{}),children:t("addNewGroup")})})}function Me(e){const[t,r]=b.useState(!1),[n,a]=b.useState(""),i=b.useRef(null),{t:d}=k.useTranslation();b.useEffect(()=>{e.onOpenChange(t)},[t]),b.useEffect(()=>{t?(a(e.data.color),setTimeout(()=>{var s;(s=i.current)==null||s.focus()},300)):a("")},[e.data]);function g(){e.data.title.trim().length!==0&&(e.onCompleteChange({title:e.data.title.trim(),color:e.data.color}),r(!1))}function u(s,m){e.onDataChange({...e.data,[s]:m})}return o.jsx(o.Fragment,{children:o.jsx(l.Popover,{title:e.isEdit?d("editGroup"):d("createGroup"),open:t,onOpenChange:r,trigger:["click"],content:o.jsxs(l.Space,{direction:"vertical",size:16,children:[o.jsxs(l.Space,{size:16,children:[o.jsxs("span",{children:[d("titleFieldName"),":"]}),o.jsx(l.Input,{ref:i,showCount:!0,maxLength:20,value:e.data.title,onChange:s=>u("title",s.target.value)})]}),o.jsxs(l.Space,{size:16,children:[o.jsxs("span",{children:[d("colorFieldName"),":"]}),n&&o.jsx(l.ColorPicker,{value:n,onChange:s=>a(`#${s.toHex()}`),showText:!0,onChangeComplete:s=>{u("color",`#${s.toHex()}`)}})]}),o.jsx(l.Button,{block:!0,type:"primary",onClick:g,children:e.isEdit?d("create"):d("save")})]}),children:e.children})})}const Pe=({open:e,onOpenChange:t=()=>{},children:r,...n})=>{const[a,i]=b.useState(e),{t:d}=k.useTranslation();return b.useEffect(()=>{i(!!e)},[e]),o.jsxs(o.Fragment,{children:[o.jsx(l.Modal,{title:d("quickMessageConfigs"),open:a,onCancel:()=>{i(!1),t(!1)},width:980,footer:null,children:o.jsx(Ae,{...n})}),o.jsx("span",{onClick:()=>{i(!0),t(!0)},children:r})]})},_n=S.div`
|
|
35
45
|
font-size: 14px;
|
|
36
46
|
background: #dae5f8;
|
|
37
47
|
padding: 0 4px;
|
|
@@ -49,9 +59,22 @@
|
|
|
49
59
|
&:active {
|
|
50
60
|
background-color: #9dbcf3;
|
|
51
61
|
}
|
|
52
|
-
`,
|
|
62
|
+
`,Fn=S.div`
|
|
53
63
|
min-height: 18px;
|
|
54
|
-
`,
|
|
64
|
+
`,Oe=S.div`
|
|
65
|
+
display: flex;
|
|
66
|
+
flex-wrap: wrap;
|
|
67
|
+
align-items: center;
|
|
68
|
+
gap: 8px;
|
|
69
|
+
`,zn=S.div`
|
|
70
|
+
display: ${e=>e.$columns?"grid":"flex"};
|
|
71
|
+
${e=>e.$columns?`grid-template-columns: repeat(${Math.min(e.$columns,e.$count)}, minmax(0, max-content));`:"flex-wrap: wrap;"}
|
|
72
|
+
align-items: center;
|
|
73
|
+
justify-items: start;
|
|
74
|
+
justify-content: start;
|
|
75
|
+
gap: 8px;
|
|
76
|
+
max-width: 100%;
|
|
77
|
+
`,Bn=({data:e=[],onChange:t,tableHeight:r,limitation:n,displayTitleMaxLength:a=10,displayMaxLength:i,SlotContentPrefixSlot:d,SlotContentSuffixSlot:g,onSelect:u=()=>{}})=>{const[s,m]=b.useState(!1),[x,c]=yt.useLocalStorage("__activeGroupId",""),{t:h}=k.useTranslation(),p=b.useMemo(()=>e.find(T=>T.id===x),[x,e]),C=b.useMemo(()=>p?p.data:[],[p,e]),A=b.useMemo(()=>e.length===0,[e]),F=typeof i=="number"&&Number.isFinite(i)&&i>0?Math.floor(i):void 0;return o.jsxs(o.Fragment,{children:[A?o.jsx(l.Button,{size:"small",type:"primary",onClick:()=>m(!0),children:h("create")}):o.jsxs(l.Space,{size:2,direction:"vertical",children:[o.jsx(Fn,{children:o.jsx(Oe,{children:C.map(T=>o.jsx(l.Tooltip,{title:o.jsx("span",{style:{fontSize:12},children:T.label}),destroyTooltipOnHide:!0,children:o.jsxs(_n,{onClick:Vn=>{Vn.target.closest("bdi")||u(T)},children:[d&&o.jsx("bdi",{children:o.jsx(d,{group:p,message:T})}),R(T.label,a),g&&o.jsxs("bdi",{children:[o.jsx(g,{group:p,message:T})," "]})]})},T.label))})}),o.jsxs(Oe,{children:[o.jsx(zn,{$columns:F,$count:e.length,children:e.map(T=>o.jsx(Wn,{data:T,active:x===T.id,displayTitleMaxLength:a,onClick:()=>{c(x===T.id?"":T.id)}},T.id))}),o.jsx(l.Button,{size:"small",type:"text",onClick:()=>m(!0),children:o.jsx(L.SettingOutlined,{})})]})]}),o.jsx(Pe,{open:s,onOpenChange:m,data:e,onChange:t,tableHeight:r,limitation:n})]})},qn=S.div`
|
|
55
78
|
background-color: ${e=>e.$backgroundColor};
|
|
56
79
|
color: ${e=>e.$textColor};
|
|
57
80
|
border: 1px solid transparent;
|
|
@@ -62,10 +85,15 @@
|
|
|
62
85
|
cursor: pointer;
|
|
63
86
|
min-width: 20px;
|
|
64
87
|
user-select: none;
|
|
88
|
+
/* grid 列收窄时(宿主页过窄)裁剪标题而非撑破布局,彻底杜绝横向溢出 */
|
|
89
|
+
max-width: 100%;
|
|
90
|
+
overflow: hidden;
|
|
91
|
+
text-overflow: ellipsis;
|
|
92
|
+
white-space: nowrap;
|
|
65
93
|
&:hover {
|
|
66
94
|
background-color: ${e=>e.$hoverColor};
|
|
67
95
|
}
|
|
68
96
|
&:active {
|
|
69
97
|
opacity: 0.6;
|
|
70
98
|
}
|
|
71
|
-
`;function
|
|
99
|
+
`;function Wn(e){const t=b.useMemo(()=>{var i,d;const r=vt(e.data.color),n=r.isDark(),a=n?(i=r.lighten(.2))==null?void 0:i.hex():(d=r.darken(.15))==null?void 0:d.hex();return{$textColor:n?"#fff":"#333",$backgroundColor:e.data.color,$hoverColor:a}},[e.data.color]);return o.jsx(qn,{...t,$active:e.active,"data-id":e.data.id,onClick:e.onClick,title:e.data.title,children:R(e.data.title,e.displayTitleMaxLength)})}/*! This file was generated by vite-i18n-gen-resources-type check https://github.com/CRMChatReactComponent/vite-i18n-gen-resources-type. Please do not modify. */var De=(e=>(e.ZH_CN="zh-CN",e.EN_US="en-US",e))(De||{});const Ee="Are you sure to delete it?",Ie="No data available",Ne="Select a Group first",Ge="Create a Group",Le="Edit Group",He="Create Group",_e="Title",Fe="Color",ze="Save",Be="Create",qe="Quick Messages Configs",We="Created Successfully",Ke="Cannot be saved: title already existing",Ue="Cannot be saved: title is empty",Ve="Cannot be saved: content is empty",Ye="Content",Je="Import from Clipboard",Kn=Object.freeze(Object.defineProperty({__proto__:null,addNewGroup:Ge,cannotSavedMessageCuzContentEmpty:Ve,cannotSavedMessageCuzLabelEmpty:Ue,cannotSavedMessageCuzLabelExisted:Ke,colorFieldName:Fe,confirmDelete:Ee,content:Ye,create:Be,createGroup:He,createSuccessfully:We,default:{confirmDelete:Ee,noData:Ie,selectAGroupFirst:Ne,addNewGroup:Ge,editGroup:Le,createGroup:He,titleFieldName:_e,colorFieldName:Fe,save:ze,create:Be,quickMessageConfigs:qe,createSuccessfully:We,cannotSavedMessageCuzLabelExisted:Ke,cannotSavedMessageCuzLabelEmpty:Ue,cannotSavedMessageCuzContentEmpty:Ve,content:Ye,delete:"Delete",importFromClipboard:Je},editGroup:Le,importFromClipboard:Je,noData:Ie,quickMessageConfigs:qe,save:ze,selectAGroupFirst:Ne,titleFieldName:_e},Symbol.toStringTag,{value:"Module"})),Xe="确定删除吗?",Qe="没有数据",Ze="请在左侧选择一个分组",Re="添加一个分组",et="编辑分组",tt="新建分组",rt="标题",nt="颜色",ot="保存",at="创建",it="快捷消息配置",st="创建成功",lt="无法保存: 标题重复",ct="无法保存: 标题不能为空",ut="无法保存: 内容不能为空",dt="内容",pt="从剪切板导入",ft=Object.entries(Object.assign({"./locales/en-US/common.json":Kn,"./locales/zh-CN/common.json":Object.freeze(Object.defineProperty({__proto__:null,addNewGroup:Re,cannotSavedMessageCuzContentEmpty:ut,cannotSavedMessageCuzLabelEmpty:ct,cannotSavedMessageCuzLabelExisted:lt,colorFieldName:nt,confirmDelete:Xe,content:dt,create:at,createGroup:tt,createSuccessfully:st,default:{confirmDelete:Xe,noData:Qe,selectAGroupFirst:Ze,addNewGroup:Re,editGroup:et,createGroup:tt,titleFieldName:rt,colorFieldName:nt,save:ot,create:at,quickMessageConfigs:it,createSuccessfully:st,cannotSavedMessageCuzLabelExisted:lt,cannotSavedMessageCuzLabelEmpty:ct,cannotSavedMessageCuzContentEmpty:ut,content:dt,delete:"删除",importFromClipboard:pt},editGroup:et,importFromClipboard:pt,noData:Qe,quickMessageConfigs:it,save:ot,selectAGroupFirst:Ze,titleFieldName:rt},Symbol.toStringTag,{value:"Module"}))})).reduce((e,t)=>{const[r,n]=t,a=r.match(/\/locales\/([\w-]+)\//),i=r.match(/\/([\w-_]+)\.json$/);return i&&a?(e[a[1]]=e[a[1]]||{},e[a[1]][i[1]]=n.default):console.error(`无法解析文件名称 path:${r}`),e},{}),gt=mt.createInstance();gt.init({lng:De.ZH_CN,debug:!1,ns:Object.keys(ft),resources:ft});const ht=b.createContext(null);function Un(e){return o.jsx(k.I18nextProvider,{i18n:e.i18n||gt,defaultNS:"common",children:o.jsx(ht.Provider,{value:{},children:e.children})})}f.AntdApiContext=z,f.AntdApiContextProviderCmp=St,f.EmojiPickerWrapper=xt,f.I18nContext=ht,f.I18nContextCmp=Un,f.MessageConfigsPanel=Ae,f.MessageConfigsPanelModalWrapper=Pe,f.MessagesEditTable=je,f.QuickMessages=Bn,Object.defineProperty(f,Symbol.toStringTag,{value:"Module"})});
|