@bothub-chat/ui 2.41.0 → 2.41.1
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.
|
@@ -36,5 +36,5 @@ export declare const useSelectField: <TriggerType extends HTMLElement = HTMLDivE
|
|
|
36
36
|
contentHeight: number | undefined;
|
|
37
37
|
handleInputClick: (native: boolean, event: React.MouseEvent<HTMLElement>) => void;
|
|
38
38
|
handleClose: () => void;
|
|
39
|
-
setValue: (
|
|
39
|
+
setValue: (value: ValueType) => void;
|
|
40
40
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useState as e,
|
|
1
|
+
import{useState as e,useCallback as t,useRef as n,useEffect as o}from"react";const r=({value:r,multiple:l=!1,disabled:i=!1,placement:s="bottom-left",contentHeight:c,onClose:u,onSelectClick:d,onChange:a,onValueChange:w})=>{const[g,m]=e(!1),[p,f]=e(0),[h,v]=e(0),[b,y]=e(0),[E,L]=e(c),[C,k]=e(s),H=t((e=>{if(l&&Array.isArray(e)){const t=w,n=e;null==a||a(e),null==t||t(n.map((e=>"string"==typeof e?e:"string"==typeof e.value?e.value:"")).filter((e=>!!e)))}if(!l&&!Array.isArray(e)){null==a||a(e);const t=w;e?"string"==typeof e?null==t||t(e):"string"==typeof e.value&&(null==t||t(e.value)):null==t||t(null)}}),[l,a,w]);let[R,z]=e(l?[]:null);void 0!==r&&([R,z]=[r,H]);const A=n(!1),X=n(null),Y=n(null);o((()=>{const e=()=>{const e=X.current;if(!e||!E||!c)return;let t=c;const{top:n,bottom:o}=e.getBoundingClientRect();t=C.includes("top")?n-20:window.innerHeight-o-20,L(t<c?t:c)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)}),[X.current,E,C,c,g]),o((()=>{if(!g)return;const e=e=>{if(!A.current||"orientationchange"===e.type){if("mousedown"===e.type){const t=X.current,n=Y.current;if(null===t||null===n)return;if(t.contains(e.target)||n.contains(e.target))return}x()}};return document.addEventListener("mousedown",e),document.addEventListener("scroll",e),window.addEventListener("resize",e),window.addEventListener("orientationchange",e),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("scroll",e),window.removeEventListener("resize",e),window.removeEventListener("orientationchange",e)}}),[g]);const B=t(((e,t)=>{null==d||d();const n=X.current,o=Y.current;if(!n||!o||i)return;e&&t.stopPropagation();const r=window.innerHeight||document.documentElement.clientHeight,{width:l,height:c,top:u,bottom:a,left:w,right:p}=n.getBoundingClientRect(),{width:h}=o.getBoundingClientRect();let b=C;b=u-186<0?"bottom-left"===b?"bottom-left":"bottom-center":a+186>r?"top-right"===s?"top-right":"top-left":s;let E=0,L=0;switch(b){case"bottom-left":E=w+window.scrollX,L=u+window.scrollY+c;break;case"bottom-center":E=Math.floor((w+p)/2+window.scrollX-h/2),L=u+window.scrollY+c;break;case"top-left":E=w+window.scrollX,L=u+window.scrollY;break;case"top-right":E=w+window.scrollX+l,L=u+window.scrollY}f(E),v(L),y(l),k(b),m(!!e||!g)}),[i,g,C,s,d]),x=t((()=>{m(!1),null==u||u()}),[]);return{x:p,y:h,width:b,isOpen:g,triggerRef:X,selectModalRef:Y,placement:C,isKeyboardOpen:A,value:R,disabled:i,multiple:l,contentHeight:E,handleInputClick:B,handleClose:x,setValue:e=>{z(e),H(e)}}};export{r as useSelectField};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{unified as e}from"unified";import n from"remark-parse";import
|
|
1
|
+
import{unified as e}from"unified";import n from"remark-parse";import i from"remark-gfm";import{defaultHandlers as t,toMarkdown as a}from"mdast-util-to-markdown";const r=t=>{try{const a=t.trim();if(!a)return"";const r=e().use(n).use(i).parse(a);return l(r)}catch(e){return t}},l=e=>{const n=Object.assign(Object.assign({},t),{blockquote:(e,n,i,t)=>e.children.map((n=>i.handle(n,e,Object.assign(Object.assign({},i),{stack:i.stack.concat("emphasis")}),t))).join("").split("\n").map((e=>e.trim()?`__${e}__`:"")).join("\n"),heading:(e,n,i,t)=>`**${e.children.map((n=>i.handle(n,e,i,t))).join("")}**`,link:e=>e.url,image:e=>e.url,code:e=>`\`\`\`${e.lang||""}\n${e.value}\n\`\`\``,inlineCode:(e,n,i)=>"heading"===(null==n?void 0:n.type)||i.stack.find((e=>"heading"===e))?e.value:`\`${e.value}\``,thematicBreak:()=>"",strong:(e,n,i,t)=>"emphasis"===(null==n?void 0:n.type)||"heading"===(null==n?void 0:n.type)||i.stack.find((e=>"emphasis"===e||"strong"===e||"heading"===e))?e.children.map((n=>i.handle(n,e,i,t))).join(""):`**${e.children.map((n=>i.handle(n,e,i,t))).join("")}**`,emphasis:(e,n,i,t)=>"strong"===(null==n?void 0:n.type)||"heading"===(null==n?void 0:n.type)||i.stack.find((e=>"emphasis"===e||"strong"===e||"heading"===e))?e.children.map((n=>i.handle(n,e,i,t))).join(""):`__${e.children.map((n=>i.handle(n,e,i,t))).join("")}__`,list:(e,n,i,t)=>i.containerFlow(Object.assign(Object.assign({},e),{ordered:!1}),t),listItem:(e,n,i,a)=>{if(!0===e.checked||!1===e.checked){const n=e.children.map((n=>i.handle(n,e,i,a))).join("").split("\n"),t=e.checked?"[x] ":"[ ] ",r=i.bulletCurrent||"-",l=`${r} ${t}${n[0]}`,s=" ".repeat(r.length+1+t.length);return[l,...n.slice(1).map((e=>s+e))].join("\n")}return t.listItem(e,n,Object.assign(Object.assign({},i),{bulletCurrent:"-"}),a)},table:(e,n,i,t)=>(e.children||[]).map((e=>(e.children||[]).map((e=>i.containerPhrasing(e,t))).join(" "))).join("\n"),delete:(e,n,i,t)=>`~~${i.containerPhrasing(e,t)}~~`,text:e=>e.value,break:()=>"\n"});return a(e,{bullet:"-",bulletOrdered:null,bulletOther:"-",incrementListMarker:!1,listItemIndent:"one",tightDefinitions:!0,extensions:[{handlers:n}]}).replaceAll(/\n{3,}/g,"\n\n").replace(/\n$/,"")};export{r as getTgMarkdown};
|