@bothub-chat/ui 2.60.0-feat-documentizer-572ab853-c274-4ebd-a1b0-31c9be879fd7 → 2.60.0-feat-documentizer-17bf44ec-16cf-4633-a07a-b1dfbeaeaade
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useState as t,useCallback as e,useRef as n,useEffect as o}from"react";import"unified";import"remark-parse";import"remark-gfm";import"mdast-util-to-markdown";import"../../utils/colors/calculateGrayScale.js";import"../../utils/colors/calculateAccentColors.js";import{findNearestScrollableParent as r}from"../../utils/findNearestScrollableParent.js";import"tslib";const i=({value:i,multiple:l=!1,disabled:s=!1,placement:c="bottom-left",contentHeight:a,onClose:u,onSelectClick:d,onChange:m,onValueChange:w})=>{const[p,g]=t(!1),[f,h]=t(0),[v,b]=t(0),[y,E]=t(0),[L,C]=t(a),[k,A]=t(c),H=e(t=>{if(l&&Array.isArray(t)){const e=w,n=t;null==m||m(t),null==e||e(n.map(t=>"string"==typeof t?t:"string"==typeof t.value?t.value:"").filter(t=>!!t))}if(!l&&!Array.isArray(t)){null==m||m(t);const e=w;t?"string"==typeof t?null==e||e(t):"string"==typeof t.value&&(null==e||e(t.value)):null==e||e(null)}},[l,m,w]);let[R,X]=t(l?[]:null);void 0!==i&&([R,X]=[i,H]);const Y=n(!1),z=n(null),j=n(null);o(()=>{const t=()=>{const t=z.current;if(!t||!L||!a)return;let e=a;const{top:n,bottom:o}=t.getBoundingClientRect();e=k.includes("top")?n-20:window.innerHeight-o-20,"string"!=typeof a&&C(e<a?e:a)};return t(),window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)},[z.current,L,k,a,p]);const B=e(()=>{g(!1),null==u||u()},[]);o(()=>{if(!p||!z.current)return;const t=r(z.current);return t?(t.addEventListener("scroll",B),()=>t.removeEventListener("scroll",B)):void 0},[p]),o(()=>{if(!p)return;const t=t=>{if(!Y.current||"orientationchange"===t.type){if("mousedown"===t.type){const e=z.current,n=j.current;if(null===e||null===n)return;if(e.contains(t.target)||n.contains(t.target))return}B()}};return document.addEventListener("mousedown",t),document.addEventListener("scroll",t),window.addEventListener("resize",t),window.addEventListener("orientationchange",t),()=>{document.removeEventListener("mousedown",t),document.removeEventListener("scroll",t),window.removeEventListener("resize",t),window.removeEventListener("orientationchange",t)}},[p]);const S=e((t,e)=>{null==d||d();const n=z.current,o=j.current;if(!n||!o||s)return;t&&e.stopPropagation();const r=window.innerHeight||document.documentElement.clientHeight,{width:i,height:l,top:u,bottom:m,left:w,right:f}=n.getBoundingClientRect(),{width:v}=o.getBoundingClientRect();let y=k;y=u-186<0||"number"==typeof a&&a>u&&r-m>u?"bottom-center"===c?"bottom-center":"bottom-right"===c||"top-right"===c?"bottom-right":"bottom-left":m+186>r||"number"==typeof a&&a>r-m&&r-m<u?"top-right"===c||"bottom-right"===c?"top-right":"top-left":c;let L=0,C=0;switch(y){case"bottom-left":L=w+window.scrollX,C=u+window.scrollY+l;break;case"bottom-center":L=Math.floor((w+f)/2+window.scrollX-v/2),C=u+window.scrollY+l;break;case"bottom-right":L=w+window.scrollX+i,C=u+window.scrollY+l;break;case"top-left":L=w+window.scrollX,C=u+window.scrollY;break;case"top-right":L=w+window.scrollX+i,C=u+window.scrollY}h(L),b(C),E(i),A(y),g(!!t||!p)},[s,p,k,c,d,a]);return{x:f,y:v,width:y,isOpen:p,triggerRef:z,selectModalRef:j,placement:k,isKeyboardOpen:Y,value:R,disabled:s,multiple:l,contentHeight:L,handleInputClick:S,handleClose:B,setValue:t=>{X===H?X(t):(X(t),H(t))}}};export{i as useSelectField};
|
|
1
|
+
import{useState as t,useCallback as e,useRef as n,useEffect as o}from"react";import"unified";import"remark-parse";import"remark-gfm";import"mdast-util-to-markdown";import"../../utils/colors/calculateGrayScale.js";import"../../utils/colors/calculateAccentColors.js";import{findNearestScrollableParent as r}from"../../utils/findNearestScrollableParent.js";import"tslib";const i=({value:i,multiple:l=!1,disabled:s=!1,placement:c="bottom-left",contentHeight:a,onClose:u,onSelectClick:d,onChange:m,onValueChange:w})=>{const[p,g]=t(!1),[f,h]=t(0),[v,b]=t(0),[y,E]=t(0),[L,C]=t(a),[k,A]=t(c),H=e(t=>{if(l&&Array.isArray(t)){const e=w,n=t;null==m||m(t),null==e||e(n.map(t=>"string"==typeof t?t:"string"==typeof t.value?t.value:"").filter(t=>!!t))}if(!l&&!Array.isArray(t)){null==m||m(t);const e=w;t?"string"==typeof t?null==e||e(t):"string"==typeof t.value&&(null==e||e(t.value)):null==e||e(null)}},[l,m,w]);let[R,X]=t(l?[]:null);void 0!==i&&([R,X]=[i,H]);const Y=n(!1),z=n(null),j=n(null);o(()=>{const t=()=>{const t=z.current;if(!t||!L||!a)return;let e=a;const{top:n,bottom:o}=t.getBoundingClientRect();e=k.includes("top")?n-20:window.innerHeight-o-20,"string"!=typeof a&&C(e<a?e:a)};return t(),window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)},[z.current,L,k,a,p]);const B=e(()=>{g(!1),null==u||u()},[]);o(()=>{if(!p||!z.current)return;const t=r(z.current);return t?(t.addEventListener("scroll",B),()=>t.removeEventListener("scroll",B)):void 0},[p]),o(()=>{if(!p)return;const t=t=>{if(!Y.current||"orientationchange"===t.type){if("mousedown"===t.type){const e=z.current,n=j.current;if(null===e||null===n)return;if(e.contains(t.target)||n.contains(t.target))return}B()}};return document.addEventListener("mousedown",t),document.addEventListener("scroll",t),window.addEventListener("resize",t),window.addEventListener("orientationchange",t),()=>{document.removeEventListener("mousedown",t),document.removeEventListener("scroll",t),window.removeEventListener("resize",t),window.removeEventListener("orientationchange",t)}},[p]);const S=e((t,e)=>{null==d||d();const n=z.current,o=j.current;if(!n||!o||s)return;t&&e.stopPropagation();const r=window.innerHeight||document.documentElement.clientHeight,{width:i,height:l,top:u,bottom:m,left:w,right:f}=n.getBoundingClientRect(),{width:v}=o.getBoundingClientRect();let y=k;y=u-186<0||"number"==typeof a&&a>u&&r-m>u?"bottom-center"===c?"bottom-center":"bottom-right"===c||"top-right"===c?"bottom-right":"bottom-left":m+186>r||"number"==typeof a&&a>r-m&&r-m<u?"top-right"===c||"bottom-right"===c?"top-right":"top-left":c;let L=0,C=0;switch(y){case"bottom-left":L=w+window.scrollX,C=u+window.scrollY+l;break;case"bottom-center":L=Math.floor((w+f)/2+window.scrollX-v/2),C=u+window.scrollY+l;break;case"bottom-right":L=w+window.scrollX+i-v,C=u+window.scrollY+l;break;case"top-left":L=w+window.scrollX,C=u+window.scrollY;break;case"top-right":L=w+window.scrollX+i,C=u+window.scrollY}h(L),b(C),E(i),A(y),g(!!t||!p)},[s,p,k,c,d,a]);return{x:f,y:v,width:y,isOpen:p,triggerRef:z,selectModalRef:j,placement:k,isKeyboardOpen:Y,value:R,disabled:s,multiple:l,contentHeight:L,handleInputClick:S,handleClose:B,setValue:t=>{X===H?X(t):(X(t),H(t))}}};export{i as useSelectField};
|
package/package.json
CHANGED