@epam/statgpt-ui-components 0.4.0-rc.16 → 0.4.0-rc.18

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.
@@ -10,5 +10,7 @@ export interface InputProps {
10
10
  readonly?: boolean;
11
11
  onChange?: (value: string) => void;
12
12
  onKeyDown?: (value: KeyboardEvent<HTMLInputElement>) => void;
13
+ onFocus?: () => void;
14
+ onBlur?: () => void;
13
15
  }
14
16
  export declare const Input: FC<InputProps>;
package/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),f=require("react"),m=require("classnames"),k=require("@tabler/icons-react"),le=require("tailwind-merge"),ae=require("react-flatpickr"),T=require("@epam/statgpt-shared-toolkit"),N=require("@floating-ui/react"),L=require("@dnd-kit/core"),M=require("@dnd-kit/sortable"),ie=require("@dnd-kit/utilities");function ce(e){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const s in e)if(s!=="default"){const r=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(n,s,r.get?r:{enumerable:!0,get:()=>e[s]})}}return n.default=e,Object.freeze(n)}const oe=ce(f),W=()=>t.jsx("div",{className:"flex h-full items-center justify-center",children:t.jsx("div",{className:"loader"})}),U=({title:e,btnClassNames:n,iconWidth:s,iconHeight:r,onClick:l})=>t.jsx("button",{type:"button","aria-label":"button",className:n,title:e,onClick:l,children:t.jsx(k.IconX,{height:r||20,width:s||20})});var A=(e=>(e.ERROR="error",e.SUCCESS="success",e.IN_PROGRESS="in_progress",e))(A||{});const de=({alertDetails:e,successIcon:n,errorIcon:s,onClose:r,closeButtonTitle:l})=>{const a=()=>e?.type===A.IN_PROGRESS?"alert-in-progress":e?.type===A.SUCCESS?"alert-success":"alert-error";return f.useEffect(()=>{e?.type!==A.IN_PROGRESS&&setTimeout(()=>{r?.()},5e3)},[e?.type,r]),t.jsx("div",{className:m("alert alert-shadow fixed bottom-3 right-3 z-10",a()),children:t.jsxs("div",{className:"alert-content flex items-start",children:[t.jsx("div",{className:"alert-icon",children:e?.type===A.IN_PROGRESS?t.jsx(W,{}):e?.type===A.SUCCESS?n:s}),t.jsxs("div",{className:"flex max-w-[300px] flex-col gap-2",children:[t.jsx("h3",{className:"truncate",children:e?.title}),e?.text&&t.jsx("div",{className:"alert-text truncate",title:e?.text,children:e?.text})]}),t.jsx(U,{title:l,onClick:r})]})})},ue=le.extendTailwindMerge({extend:{classGroups:{typography:["h1","h2","h3","h4","h5","body-1","body-2","body-3","caption"]}}});function O(...e){return ue(m(...e))}const V=({buttonClassName:e,textClassName:n,isLoading:s=!1,title:r,disabled:l,iconAfter:a,iconBefore:o,onClick:d,isSmallButton:x})=>{const u=O([x?"font-semibold":"",a?"mr-2":"",o?"ml-2":"",n]);return t.jsxs("button",{type:"button",className:m("base-button",e,x?"small-button":""),disabled:l||s,"aria-label":"button",onClick:h=>d?.(h),title:r,children:[o,s&&t.jsx(W,{}),r?x?t.jsx("h4",{className:u,children:r}):t.jsx("h3",{className:u,children:r}):null,a]})};function K(e=719){const[n,s]=f.useState(()=>typeof window<"u"?window.innerWidth<e:!1);return f.useEffect(()=>{const r=window.matchMedia(`(max-width: ${e}px)`),l=a=>{s(a.matches)};return s(r.matches),r.addEventListener("change",l),()=>r.removeEventListener("change",l)},[e]),n}function xe(e,n){const s=f.useRef(null);return f.useCallback((...l)=>{s.current&&clearTimeout(s.current),s.current=setTimeout(()=>{e(...l)},n)},[e,n])}const me=24,he=24,z=1e3,Q=24,fe=({label:e,onChange:n,value:s,options:r,calendarResolution:l=T.CalendarResolution.DAY,id:a,icon:o,isEndDate:d})=>{const x=f.useRef(null),u=K();f.useEffect(()=>{const b=x?.current;b&&b.querySelector("input")?.setAttribute("aria-label",e)},[e]);const h={...r,disableMobile:!0,defaultDate:l===T.CalendarResolution.MONTH?new Date(s.getFullYear(),s.getMonth()):s},g=(b,j,p)=>{const c=`calendar__${l===T.CalendarResolution.MONTH?"month":"day"}`;p.calendarContainer&&p.calendarContainer.classList.add(c)},w=(b,j,p)=>{if(l===T.CalendarResolution.MONTH&&b.length>0){const c=r.minDate,i=r.maxDate,y=b[0].getFullYear(),I=p.calendarContainer,E="flatpickr-disabled",v=I.querySelectorAll(".flatpickr-monthSelect-month"),C=I.querySelectorAll(".flatpickr-next-month")[0],R=I.querySelectorAll(".flatpickr-prev-month")[0];y===i.getFullYear()&&C.classList.add(E),y===c.getFullYear()&&R.classList.add(E),(y===c.getFullYear()||y===i.getFullYear())&&v.forEach(D=>{D.classList.remove(E);const S=new Date(D.getAttribute("aria-label")),_=S.getFullYear()===c.getFullYear()&&S.getMonth()===c.getMonth(),B=S.getFullYear()===i.getFullYear()&&S.getMonth()===i.getMonth();_||B||(S<c||S>i)&&D.classList.add(E)})}setTimeout(()=>{const c=p.calendarContainer,i=p._input?.getBoundingClientRect();c&&(c.style.top=`${i.top-c.offsetHeight-8}px`,c.style.width=`${c.style.width}px`,d?(c.style.right=`${window.innerWidth-i.right-(u?Q:0)}px`,c.style.left="auto"):c.style.left=`${i.left}px`)},0)};return t.jsxs("div",{className:"calendar relative",ref:x,children:[t.jsx("div",{className:"calendar-title mb-1",children:e}),t.jsx("label",{htmlFor:a,className:"absolute right-[11px] top-[29px] cursor-pointer",children:o||t.jsx(k.IconCalendarEvent,{})}),t.jsx(ae,{defaultValue:(l===T.CalendarResolution.MONTH?new Date(s.getFullYear(),s.getMonth()):s)?.toDateString(),options:h,onChange:b=>{n(b[0])},onOpen:[w],onReady:[g],id:a})]})},H=({label:e,id:n,checked:s,checkboxIcon:r,onChange:l,disabled:a=!1,className:o,stopPropagation:d=!0})=>{const x=f.useCallback(g=>{d&&g.stopPropagation()},[d]),u=f.useCallback(g=>{d&&g.stopPropagation(),l?.(n,g.target.checked)},[l,n,d]),h=()=>{if(s)return r||t.jsx(k.IconSquareCheckFilled,{className:"absolute size-4"})};return t.jsxs("label",{htmlFor:n,onClick:x,className:O("flex min-w-0 items-center py-1",a?"cursor-not-allowed opacity-50":"cursor-pointer",o),children:[t.jsx("span",{className:m("checkbox-button relative flex size-[14px] items-center justify-center"),"aria-hidden":!0,children:h()}),e?t.jsx("p",{className:m("checkbox-button-text text-neutrals-1000 min-w-0 ml-2 flex-1 truncate pr-2"),title:e,children:e}):null,t.jsx("input",{id:n,type:"checkbox",checked:s,disabled:a,onChange:u,className:"hidden"})]})},pe=({title:e,icon:n,children:s,value:r})=>{const[l,a]=f.useState(!1);return t.jsxs("div",{className:`collapsible-block flex flex-col border-t-2 border-neutrals-600 ${l?"collapsible-block-open":""}`,children:[t.jsxs("div",{className:"collapsible-block-title flex cursor-pointer items-center py-4",onClick:()=>a(!l),children:[t.jsx("div",{className:`${l?"rotate-180":""} transition-transform`,children:n||t.jsx(k.IconChevronDown,{className:"mr-3 size-5"})}),t.jsxs("div",{className:"flex flex-1 items-center justify-between",children:[t.jsx("span",{children:e}),r&&t.jsx("p",{className:"body-1 text-neutrals-800",children:r})]})]}),l&&t.jsx("div",{className:"collapsible-block-content pb-4",children:s})]})},ge=({text:e,highlightText:n})=>{const s=f.useMemo(()=>{const r=[];if(!n)return[{id:0,text:e,highlight:!1}];const l=n?.toLowerCase()||"",a=e?.toLowerCase()?.split(l)||"";for(let o=0,d=0;o<a?.length;o++){const x=a?.[o],u=x.length;x!==""&&r.push({id:r.length,highlight:!1,text:e?.substring(d,d+u)}),d+=u,o!==a?.length-1&&(r.push({id:r.length,highlight:!0,text:e?.substring(d,d+n.length)}),d+=n.length)}return r},[n,e]);return t.jsx(t.Fragment,{children:s.map(r=>t.jsx("span",{className:m(r?.highlight&&"bg-highlight"),children:r?.text},r?.id))})},be=({icon:e,onClick:n,buttonClassName:s,disabled:r,title:l,isBaseIconStyles:a=!0})=>t.jsx("button",{type:"button",className:m(a&&"base-icon-button",s),onClick:o=>n?.(o),disabled:r,title:l,"aria-label":"button",children:e}),Z=({value:e,inputId:n,placeholder:s="",cssClass:r="",type:l="text",disabled:a,readonly:o,onChange:d,onKeyDown:x})=>{const u=m("truncate outline-none shadow-none body-1",r,o?"pointer-events-none":"");return t.jsx("input",{type:l,autoComplete:"off",id:n,placeholder:s,value:e||"",title:e?String(e):"",disabled:a,className:u,onKeyDown:x,onChange:h=>d?.(h.currentTarget.value)})},je=({iconBeforeInput:e,iconAfterInput:n,containerClasses:s,cssClass:r,...l})=>t.jsxs("div",{className:m("input w-full flex flex-row",s),children:[e,t.jsx(Z,{cssClass:m("border-0 bg-transparent p-0 h-full shadow-none flex-1 min-w-0 rounded-none",r),...l}),n]}),Ne=({url:e,title:n,linkClassName:s="",iconBefore:r,iconAfter:l})=>{const a=m(l?"mr-2":"",r?"ml-2":"");return t.jsxs("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:m("base-link",s),title:n,children:[r,t.jsx("span",{className:a,children:n}),l]})},Ce=({title:e,text:n,disabled:s,onClick:r})=>t.jsx("button",{type:"button",className:m("tag flex items-center justify-center","disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:bg-neutrals-100"),disabled:s,onClick:()=>r?.(n||e),"aria-label":"button",children:t.jsx("h4",{children:e})}),ye=({label:e,id:n,checked:s,radioIcon:r,description:l,onChange:a})=>{const o=f.useCallback(d=>{d.stopPropagation(),a?.(n,d.target.checked)},[a,n]);return t.jsxs("label",{className:"flex min-w-0 cursor-pointer flex-col py-[6px]",htmlFor:n,children:[t.jsxs("p",{className:"radio-label flex min-w-0 items-center",children:[t.jsx("span",{className:m("flex justify-center items-center w-4 h-4 mr-2 relative","radio-button",s?"radio-button-active":""),children:s&&r}),e&&t.jsx("span",{className:"radio-title body-1 min-w-0 flex-1 truncate pr-2 text-neutrals-1000",title:e,children:e})]}),l&&t.jsx("span",{className:"radio-description body-2 ml-6 flex w-auto items-center text-neutrals-800",title:l,children:l}),t.jsx("input",{type:"radio",onChange:o,id:n,checked:s,className:"hidden"})]})};var P=(e=>(e.Closed="Closed",e.Opened="Opened",e))(P||{}),q=(e=>(e.LG="Large",e.SM="Small",e))(q||{});const ve=({portalId:e,state:n=P.Opened,heading:s,size:r,onClose:l,children:a,overlayClassName:o,containerClassName:d,dividers:x=!0,closeButtonTitle:u})=>{const{refs:h,context:g}=N.useFloating({open:n!==P.Closed&&!!n,onOpenChange:l}),w=N.useRole(g,{role:"dialog"}),b=N.useDismiss(g,{outsidePress:!0}),{getFloatingProps:j}=N.useInteractions([w,b]),p=f.useCallback(c=>{c?.preventDefault(),c?.stopPropagation(),l()},[l]);return t.jsx(N.FloatingPortal,{id:e,children:n!==P.Closed&&t.jsx(N.FloatingOverlay,{className:m("z-modal flex items-center justify-center bg-blackout p-4",o),children:t.jsx(N.FloatingFocusManager,{context:g,children:t.jsxs("div",{className:m("relative max-h-full modal rounded bg-white flex flex-col shadow w-full",r===q.LG&&"max-w-[65%]",r===q.SM&&"max-w-[30%]",x&&"divide-neutrals-400 divide-y",d,"sm:w-full sm:max-w-full sm:px-4 sm:py-6"),ref:h.setFloating,...j({onClick(c){c.stopPropagation()}}),children:[t.jsxs("div",{className:"modal-heading mb-2 flex flex-row items-center justify-between px-6 py-3 sm:p-0 sm:pb-2",children:[s&&(typeof s=="string"?t.jsx("h2",{className:"modal-heading-title sm:h3 mr-3 min-w-0 flex-1",children:s}):s),t.jsx(U,{title:u,onClick:p,btnClassNames:"sm:h-[24px] sm:w-[24px] sm:top-4"})]}),a.map(c=>c)]})})})})},we=e=>e.state===P.Closed?null:t.jsx(ve,{...e}),Ee=({triggerButton:e,options:n,content:s,selectedOption:r,disabled:l,containerClassName:a,openedClassName:o,onOptionSelect:d})=>{const[x,u]=f.useState(!1),{refs:h,floatingStyles:g,context:w}=N.useFloating({open:x,onOpenChange:l?void 0:u,placement:"bottom-end",middleware:[N.offset(8),N.flip(),N.shift()],whileElementsMounted:N.autoUpdate}),b=N.useClick(w),j=N.useDismiss(w,{outsidePress:!0}),{getReferenceProps:p,getFloatingProps:c}=N.useInteractions([b,j]);return t.jsxs(t.Fragment,{children:[t.jsx("div",{ref:h.setReference,...p({onClick(i){i.stopPropagation()}}),className:m(a,x&&o),children:e}),x&&t.jsxs("div",{ref:h.setFloating,style:g,className:"dropdown-menu-shadow dropdown-container z-10 flex flex-col rounded bg-white",...c(),children:[s&&s,n&&n.map(i=>t.jsx("div",{onClick:y=>{y.stopPropagation(),d?.(i.key),u(!1)},className:m("text-neutrals-900 body-3 cursor-pointer dropdown-item min-w-[200px]",r===i.key&&"bg-hues-100"),children:t.jsxs("div",{className:"dropdown-item-text flex h-full items-center gap-x-2 p-2 hover:bg-hues-100",title:i.title,children:[i.icon?i.icon:null,t.jsx("p",{children:i?.title})]})},i.key))]})]})},Ie=({limitMessages:e,query:n})=>t.jsxs("div",{className:"flex flex-wrap items-center justify-between bg-hues-100 px-2 py-1",children:[t.jsx("div",{className:"flex gap-x-[4px]",children:t.jsx("div",{className:"flex flex-col",children:t.jsxs("div",{className:"flex gap-x-[4px]",children:[t.jsxs("span",{className:"h5 text-primary",children:[e?.excelFormatTitle," "]}),t.jsx("span",{className:"body-3 text-neutrals-800",children:e?.excelFormatText})]})})}),t.jsx("a",{href:n,target:"_blank",rel:"noreferrer",children:t.jsxs("span",{className:"body-3 flex cursor-pointer items-center gap-x-[4px]",children:[e?.dataExplorerIcon,e?.dataExplorer]})})]}),Se=({limitMessages:e,isDownload:n,showAdvancedViewButton:s,onAdvancedViewClick:r,query:l})=>t.jsxs("div",{className:m("bg-semantic-warning-light px-2 py-1 flex justify-between flex-wrap items-center",e?.containerClassName),children:[t.jsxs("div",{className:"flex items-center gap-x-2",children:[t.jsx("span",{children:e?.warningIcon}),t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsxs("div",{className:"flex gap-x-[4px]",children:[t.jsxs("span",{className:m("text-primary h5",e?.largeQueryClassName),children:[e?.largeQuery,":"," "]}),t.jsx("span",{className:m("text-neutrals-800 body-3",e?.limitMessageClassName),children:n?e?.downloadMessage?.(z):e?.showingLimit?.(z)})]}),n&&t.jsx("span",{className:m("text-neutrals-800 body-3",e?.limitMessageClassName),children:e?.fullLimitMessage})]})]}),s&&t.jsxs("span",{onClick:()=>r?.(),className:"h4 flex cursor-pointer items-center gap-x-[4px] text-primary",children:[e?.editIcon,e?.refineInAdvancedView]}),n&&t.jsx("a",{href:l||"",target:"_blank",rel:"noreferrer",children:t.jsxs("span",{className:"body-3 flex cursor-pointer items-center gap-x-[4px]",children:[e?.dataExplorerIcon,e?.dataExplorer]})})]}),X=f.createContext(null);function ke({value:e,children:n}){const s=f.useMemo(()=>e??{},[e]);return t.jsx(X.Provider,{value:s,children:n})}function Re(){return f.useContext(X)}var F=(e=>(e.Info="info",e.Error="error",e.Warning="warning",e))(F||{});const De={[F.Info]:"border-neutrals-800 bg-neutrals-300 text-neutrals-1000",[F.Error]:"border-semantic-error bg-semantic-error-light text-neutrals-1000",[F.Warning]:"border-semantic-warning bg-semantic-warning-light text-neutrals-1000"},Ae="shrink-0",Oe="min-w-0 body-2",_e="flex items-start gap-2 min-w-0 border-l-2 rounded py-2 px-4 items-center";function Le({type:e,icon:n,children:s,className:r,contentClassName:l}){const a=Re(),o=n??a?.icons?.[e],d=a?.classes?.container??_e,x=a?.classes?.types?.[e]??De[e],u=O(d,x,r),h=O(Ae,a?.classes?.icon),g=O(Oe,a?.classes?.content,l);return t.jsxs("div",{"data-type":e,className:u,children:[o?t.jsx("span",{className:h,children:o}):null,s?t.jsx("div",{className:g,children:s}):null]})}const Pe=({title:e,copiedTitle:n,tooltip:s,icon:r,copiedIcon:l,className:a,buttonTextClassName:o,onClick:d})=>{const[x,u]=f.useState(!1),h=f.useRef(null),g=()=>{d(),u(!0),h.current&&clearTimeout(h.current),h.current=setTimeout(()=>{u(!1)},1e3)};return f.useEffect(()=>()=>{h.current&&clearTimeout(h.current)},[]),t.jsxs("div",{className:"relative w-fit",children:[t.jsx(V,{title:x?n:e,isSmallButton:!0,disabled:x,buttonClassName:O(["text-button-tertiary small-icon-button !h-6 !p-0",a]),textClassName:O(["ml-1",o]),onClick:g,iconBefore:x?l:r}),s&&x&&t.jsx("div",{className:"h4 absolute left-1/2 top-full z-50 mt-1 -translate-x-1/2 whitespace-nowrap rounded border border-neutrals-400 bg-white px-3 py-4 text-neutrals-900 shadow",children:s})]})};function Te({id:e,label:n,hasChildren:s,showDragHandle:r,showCheckbox:l,isChecked:a,isExpanded:o}){return t.jsxs("div",{className:"relative cursor-grabbing rounded bg-neutrals-200 shadow",children:[t.jsx("div",{className:"absolute -left-[0.5px] top-0.5 h-5 w-0.5 rounded-full bg-gradients-light"}),t.jsxs("div",{className:"flex items-stretch overflow-hidden rounded",children:[r?t.jsx("div",{className:"flex w-6 items-center justify-center",children:t.jsx("span",{"aria-hidden":!0,className:"rounded p-1",children:t.jsx(k.IconGripVertical,{size:16})})}):null,t.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2 p-1",children:[l?t.jsx(H,{id:e,checked:!!a,className:"p-0"}):null,t.jsx("span",{className:"body-3 truncate",children:n})]}),s?t.jsx("div",{className:"flex w-8 items-center justify-center",children:t.jsx("span",{"aria-hidden":!0,className:m("transition-transform",o?"rotate-90":"rotate-0"),children:t.jsx(k.IconChevronRight,{size:16})})}):null]})]})}function J(e,n){return`i:${[...e,n].join("/")}`}function G(e){if(!e.startsWith("i:"))return null;const s=e.slice(2).split("/").filter(Boolean);return s.length?{parentPath:s.slice(0,-1),itemId:s[s.length-1]}:null}function Fe(e,n,s){const r=te(e,n);return r?r.find(l=>l.id===s)??null:null}function ee(e,n){if(n.length===0)return e;const[s,...r]=n,l=e.find(a=>a.id===s);return l?.items?ee(l.items,r):null}function te(e,n){const s=ee(e,n);return s?s.filter(r=>r.type==="item"):null}function ne(e,n,s){if(n.length===0)return s(e);const[r,...l]=n;return e.map(a=>a.id!==r||!a.items?a:{...a,items:ne(a.items,l,s)})}function Me({parentPath:e,item:n,showDragHandle:s,showCheckbox:r,renderLabel:l,onItemClick:a,onToggleExpanded:o,onToggleChecked:d}){const x=!!n.items?.length,u=!!n.isExpanded,h=n.isDisabled?!1:n.draggable??!0,g=n.isDisabled?!1:n.checkable??!0,w=J(e,n.id),{attributes:b,listeners:j,setNodeRef:p,setActivatorNodeRef:c,transform:i,transition:y,isDragging:I}=M.useSortable({id:w,disabled:!h}),E={transform:ie.CSS.Transform.toString(i),transition:y,opacity:I?.6:void 0},v=!!n.isDisabled,C=[...e,n.id];return t.jsxs("div",{ref:p,style:E,className:m(["group flex items-stretch overflow-hidden rounded bg-white","select-none",v?"opacity-50":""]),children:[s?t.jsx("div",{className:m(["group/drag-handle flex w-6 items-center justify-center rounded",v?"":"hover:bg-neutrals-100 cursor-grab"]),children:t.jsx("span",{ref:c,"aria-hidden":!0,className:m(["rounded p-1",h?"cursor-grab":"cursor-default","transition-opacity"]),...h?j:{},...h?b:{},children:t.jsx(k.IconGripVertical,{size:16,className:"text-neutrals-800 group-hover/drag-handle:text-primary"})})}):null,t.jsxs("button",{type:"button",disabled:v,onClick:R=>a?.({itemId:n.id,path:C,nativeEvent:R}),className:m(["flex min-w-0 flex-1 items-center gap-2 p-1 text-left rounded",v?"":"hover:bg-neutrals-100",v?"":"hover:text-blue-700","focus:outline-none"]),children:[r?t.jsx(H,{id:`draggable-list-${C.join("-")}`,checked:!!n.isChecked,disabled:!g,className:"p-0",stopPropagation:!0,onChange:(R,D)=>d?.({itemId:n.id,path:C,nextChecked:!!D})}):null,t.jsx("span",{className:"body-3 truncate text-neutrals-800",children:l?l(n):n.label})]}),x?t.jsx("button",{type:"button",disabled:v,onClick:R=>{R.stopPropagation(),o?.({itemId:n.id,path:C,nextExpanded:!u})},"aria-label":u?"Collapse":"Expand",className:m(["flex w-8 items-center justify-center rounded",v?"":"hover:bg-neutrals-100","focus:outline-none"]),children:t.jsx("span",{"aria-hidden":!0,className:m("transition-transform duration-150 ease-out",u?"rotate-90":"rotate-0"),children:t.jsx(k.IconChevronRight,{size:16})})}):null]})}function qe({items:e,showDragHandle:n=!0,showCheckbox:s=!0,onItemsChange:r,onToggleExpanded:l,onToggleChecked:a,onItemClick:o,renderLabel:d}){const x=L.useSensors(L.useSensor(L.PointerSensor,{activationConstraint:{distance:6}})),[u,h]=oe.useState(null),g=j=>{const p=String(j.active.id),c=G(p);if(!c)return;const i=Fe(e,c.parentPath,c.itemId);!i||i.type!=="item"||h({id:p,label:i.label,hasChildren:!!i.items?.length,isChecked:i.isChecked,isExpanded:i.isExpanded})},w=j=>{h(null);const p=j.over;if(!p)return;const c=G(String(j.active.id)),i=G(String(p.id));if(!c||!i||c.parentPath.join("/")!==i.parentPath.join("/"))return;const y=te(e,c.parentPath);if(!y)return;const I=y.findIndex(C=>C.id===c.itemId),E=y.findIndex(C=>C.id===i.itemId);if(I===-1||E===-1||I===E)return;const v=ne(e,c.parentPath,C=>{const R=C.filter(_=>_.type==="item"),D=M.arrayMove(R,I,E);let S=0;return C.map(_=>{if(_.type!=="item")return _;const B=D[S];return S+=1,B})});r(v)},b=(j,p=[])=>{const c=j.filter(i=>i.type==="item").map(i=>J(p,i.id));return t.jsx(M.SortableContext,{items:c,strategy:M.verticalListSortingStrategy,children:t.jsx("ul",{className:"m-0 flex list-none flex-col gap-2 p-0",children:j.map(i=>i.type==="group"?t.jsxs("li",{className:"m-0 mt-2 flex flex-col gap-2 p-0 first:mt-0",children:[t.jsxs("div",{className:"h5 flex items-center gap-2 py-1 text-neutrals-1000",children:[t.jsx(k.IconDatabase,{size:12,className:"shrink-0"}),i.label]}),t.jsx("div",{className:"border-l border-neutrals-600 pl-2",children:b(i.items,[...p,i.id])})]},i.id):t.jsxs("li",{className:"m-0 flex flex-col gap-2 p-0",children:[t.jsx(Me,{parentPath:p,item:i,showDragHandle:n,showCheckbox:s,renderLabel:d,onItemClick:o,onToggleExpanded:l,onToggleChecked:a}),i.items?.length&&i.isExpanded?t.jsx("div",{className:"pl-7",children:b(i.items,[...p,i.id])}):null]},i.id))})})};return t.jsxs(L.DndContext,{sensors:x,collisionDetection:L.closestCenter,onDragStart:g,onDragEnd:w,children:[t.jsx("div",{className:"flex flex-col",children:b(e)}),t.jsx(L.DragOverlay,{children:u?t.jsx(Te,{id:u.id,label:u.label,hasChildren:u.hasChildren,showDragHandle:n,showCheckbox:s,isChecked:u.isChecked,isExpanded:u.isExpanded}):null})]})}const Ye=(e,n)=>e.label.toLowerCase().includes(n);function Be(e,n,s={}){const r=ze(n);if(!r)return e;const{expandMatchedBranches:l=!0,includeGroupDescendantsOnMatch:a=!0,includeItemDescendantsOnMatch:o=!1,match:d=Ye}=s;return $(e,r,{expandMatchedBranches:l,includeGroupDescendantsOnMatch:a,includeItemDescendantsOnMatch:o,match:d})??[]}function $(e,n,s){const r=[];for(const l of e){const a=Ge(l,n,s);a&&r.push(a)}return r.length?r:null}function Ge(e,n,s){const r=s.match(e,n);if(e.type==="group"){if(r&&s.includeGroupDescendantsOnMatch)return Y(e,s.expandMatchedBranches);const o=e.items?.length?$(e.items,n,s):null;return!r&&!o?null:{...e,items:o??[]}}const l=e.items?.length?$(e.items,n,s):null;if(r&&s.includeItemDescendantsOnMatch)return Y(e,s.expandMatchedBranches);if(!r&&!l)return null;const a={...e};return l?(a.items=l,s.expandMatchedBranches&&(a.isExpanded=!0)):delete a.items,a}function Y(e,n){return e.type==="group"?{...e,items:e.items.map(s=>Y(s,n))}:{...e,isExpanded:n&&e.items?.length?!0:e.isExpanded,items:e.items?.map(s=>Y(s,n))}}function ze(e){return e.trim().toLowerCase()}var se=(e=>(e.Enter="Enter",e))(se||{});const re=f.createContext(null);function $e({children:e,isAgentAvailable:n}){const s=f.useMemo(()=>({isAgentAvailable:n}),[n]);return t.jsx(re.Provider,{value:s,children:e})}function We(){const e=f.useContext(re);if(!e)throw new Error("useAgentAvailability must be used within AgentAvailabilityProvider");return e}exports.AgentAvailabilityProvider=$e;exports.Alert=de;exports.AlertType=A;exports.Button=V;exports.CALENDAR_MOBILE_PADDING=Q;exports.Calendar=fe;exports.Checkbox=H;exports.CloseButton=U;exports.CollapsibleBlock=pe;exports.CopyButton=Pe;exports.DownloadFormatMessage=Ie;exports.DraggableList=qe;exports.Dropdown=Ee;exports.HighlightText=ge;exports.IconButton=be;exports.InlineAlert=Le;exports.InlineAlertProvider=ke;exports.InlineAlertType=F;exports.Input=Z;exports.InputWithIcon=je;exports.KeyboardKey=se;exports.Link=Ne;exports.Loader=W;exports.PopUpSize=q;exports.PopUpState=P;exports.Popup=we;exports.Radio=ye;exports.RequestLimitMessage=Se;exports.SERIES_LIMIT=z;exports.TREE_NODE_ARROW_SIZE=me;exports.TREE_NODE_PADDING=he;exports.Tag=Ce;exports.filterDraggableListNodes=Be;exports.useAgentAvailability=We;exports.useDebounce=xe;exports.useIsMobile=K;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),f=require("react"),m=require("classnames"),k=require("@tabler/icons-react"),le=require("tailwind-merge"),ae=require("react-flatpickr"),T=require("@epam/statgpt-shared-toolkit"),N=require("@floating-ui/react"),L=require("@dnd-kit/core"),M=require("@dnd-kit/sortable"),ie=require("@dnd-kit/utilities");function ce(e){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const s in e)if(s!=="default"){const r=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(n,s,r.get?r:{enumerable:!0,get:()=>e[s]})}}return n.default=e,Object.freeze(n)}const oe=ce(f),W=()=>t.jsx("div",{className:"flex h-full items-center justify-center",children:t.jsx("div",{className:"loader"})}),U=({title:e,btnClassNames:n,iconWidth:s,iconHeight:r,onClick:l})=>t.jsx("button",{type:"button","aria-label":"button",className:n,title:e,onClick:l,children:t.jsx(k.IconX,{height:r||20,width:s||20})});var A=(e=>(e.ERROR="error",e.SUCCESS="success",e.IN_PROGRESS="in_progress",e))(A||{});const de=({alertDetails:e,successIcon:n,errorIcon:s,onClose:r,closeButtonTitle:l})=>{const a=()=>e?.type===A.IN_PROGRESS?"alert-in-progress":e?.type===A.SUCCESS?"alert-success":"alert-error";return f.useEffect(()=>{e?.type!==A.IN_PROGRESS&&setTimeout(()=>{r?.()},5e3)},[e?.type,r]),t.jsx("div",{className:m("alert alert-shadow fixed bottom-3 right-3 z-10",a()),children:t.jsxs("div",{className:"alert-content flex items-start",children:[t.jsx("div",{className:"alert-icon",children:e?.type===A.IN_PROGRESS?t.jsx(W,{}):e?.type===A.SUCCESS?n:s}),t.jsxs("div",{className:"flex max-w-[300px] flex-col gap-2",children:[t.jsx("h3",{className:"truncate",children:e?.title}),e?.text&&t.jsx("div",{className:"alert-text truncate",title:e?.text,children:e?.text})]}),t.jsx(U,{title:l,onClick:r})]})})},ue=le.extendTailwindMerge({extend:{classGroups:{typography:["h1","h2","h3","h4","h5","body-1","body-2","body-3","caption"]}}});function O(...e){return ue(m(...e))}const V=({buttonClassName:e,textClassName:n,isLoading:s=!1,title:r,disabled:l,iconAfter:a,iconBefore:o,onClick:d,isSmallButton:x})=>{const u=O([x?"font-semibold":"",a?"mr-2":"",o?"ml-2":"",n]);return t.jsxs("button",{type:"button",className:m("base-button",e,x?"small-button":""),disabled:l||s,"aria-label":"button",onClick:h=>d?.(h),title:r,children:[o,s&&t.jsx(W,{}),r?x?t.jsx("h4",{className:u,children:r}):t.jsx("h3",{className:u,children:r}):null,a]})};function K(e=719){const[n,s]=f.useState(()=>typeof window<"u"?window.innerWidth<e:!1);return f.useEffect(()=>{const r=window.matchMedia(`(max-width: ${e}px)`),l=a=>{s(a.matches)};return s(r.matches),r.addEventListener("change",l),()=>r.removeEventListener("change",l)},[e]),n}function xe(e,n){const s=f.useRef(null);return f.useCallback((...l)=>{s.current&&clearTimeout(s.current),s.current=setTimeout(()=>{e(...l)},n)},[e,n])}const me=24,he=24,z=1e3,Q=24,fe=({label:e,onChange:n,value:s,options:r,calendarResolution:l=T.CalendarResolution.DAY,id:a,icon:o,isEndDate:d})=>{const x=f.useRef(null),u=K();f.useEffect(()=>{const b=x?.current;b&&b.querySelector("input")?.setAttribute("aria-label",e)},[e]);const h={...r,disableMobile:!0,defaultDate:l===T.CalendarResolution.MONTH?new Date(s.getFullYear(),s.getMonth()):s},g=(b,j,p)=>{const c=`calendar__${l===T.CalendarResolution.MONTH?"month":"day"}`;p.calendarContainer&&p.calendarContainer.classList.add(c)},y=(b,j,p)=>{if(l===T.CalendarResolution.MONTH&&b.length>0){const c=r.minDate,i=r.maxDate,v=b[0].getFullYear(),I=p.calendarContainer,E="flatpickr-disabled",w=I.querySelectorAll(".flatpickr-monthSelect-month"),C=I.querySelectorAll(".flatpickr-next-month")[0],R=I.querySelectorAll(".flatpickr-prev-month")[0];v===i.getFullYear()&&C.classList.add(E),v===c.getFullYear()&&R.classList.add(E),(v===c.getFullYear()||v===i.getFullYear())&&w.forEach(D=>{D.classList.remove(E);const S=new Date(D.getAttribute("aria-label")),_=S.getFullYear()===c.getFullYear()&&S.getMonth()===c.getMonth(),B=S.getFullYear()===i.getFullYear()&&S.getMonth()===i.getMonth();_||B||(S<c||S>i)&&D.classList.add(E)})}setTimeout(()=>{const c=p.calendarContainer,i=p._input?.getBoundingClientRect();c&&(c.style.top=`${i.top-c.offsetHeight-8}px`,c.style.width=`${c.style.width}px`,d?(c.style.right=`${window.innerWidth-i.right-(u?Q:0)}px`,c.style.left="auto"):c.style.left=`${i.left}px`)},0)};return t.jsxs("div",{className:"calendar relative",ref:x,children:[t.jsx("div",{className:"calendar-title mb-1",children:e}),t.jsx("label",{htmlFor:a,className:"absolute right-[11px] top-[29px] cursor-pointer",children:o||t.jsx(k.IconCalendarEvent,{})}),t.jsx(ae,{defaultValue:(l===T.CalendarResolution.MONTH?new Date(s.getFullYear(),s.getMonth()):s)?.toDateString(),options:h,onChange:b=>{n(b[0])},onOpen:[y],onReady:[g],id:a})]})},H=({label:e,id:n,checked:s,checkboxIcon:r,onChange:l,disabled:a=!1,className:o,stopPropagation:d=!0})=>{const x=f.useCallback(g=>{d&&g.stopPropagation()},[d]),u=f.useCallback(g=>{d&&g.stopPropagation(),l?.(n,g.target.checked)},[l,n,d]),h=()=>{if(s)return r||t.jsx(k.IconSquareCheckFilled,{className:"absolute size-4"})};return t.jsxs("label",{htmlFor:n,onClick:x,className:O("flex min-w-0 items-center py-1",a?"cursor-not-allowed opacity-50":"cursor-pointer",o),children:[t.jsx("span",{className:m("checkbox-button relative flex size-[14px] items-center justify-center"),"aria-hidden":!0,children:h()}),e?t.jsx("p",{className:m("checkbox-button-text text-neutrals-1000 min-w-0 ml-2 flex-1 truncate pr-2"),title:e,children:e}):null,t.jsx("input",{id:n,type:"checkbox",checked:s,disabled:a,onChange:u,className:"hidden"})]})},pe=({title:e,icon:n,children:s,value:r})=>{const[l,a]=f.useState(!1);return t.jsxs("div",{className:`collapsible-block flex flex-col border-t-2 border-neutrals-600 ${l?"collapsible-block-open":""}`,children:[t.jsxs("div",{className:"collapsible-block-title flex cursor-pointer items-center py-4",onClick:()=>a(!l),children:[t.jsx("div",{className:`${l?"rotate-180":""} transition-transform`,children:n||t.jsx(k.IconChevronDown,{className:"mr-3 size-5"})}),t.jsxs("div",{className:"flex flex-1 items-center justify-between",children:[t.jsx("span",{children:e}),r&&t.jsx("p",{className:"body-1 text-neutrals-800",children:r})]})]}),l&&t.jsx("div",{className:"collapsible-block-content pb-4",children:s})]})},ge=({text:e,highlightText:n})=>{const s=f.useMemo(()=>{const r=[];if(!n)return[{id:0,text:e,highlight:!1}];const l=n?.toLowerCase()||"",a=e?.toLowerCase()?.split(l)||"";for(let o=0,d=0;o<a?.length;o++){const x=a?.[o],u=x.length;x!==""&&r.push({id:r.length,highlight:!1,text:e?.substring(d,d+u)}),d+=u,o!==a?.length-1&&(r.push({id:r.length,highlight:!0,text:e?.substring(d,d+n.length)}),d+=n.length)}return r},[n,e]);return t.jsx(t.Fragment,{children:s.map(r=>t.jsx("span",{className:m(r?.highlight&&"bg-highlight"),children:r?.text},r?.id))})},be=({icon:e,onClick:n,buttonClassName:s,disabled:r,title:l,isBaseIconStyles:a=!0})=>t.jsx("button",{type:"button",className:m(a&&"base-icon-button",s),onClick:o=>n?.(o),disabled:r,title:l,"aria-label":"button",children:e}),Z=({value:e,inputId:n,placeholder:s="",cssClass:r="",type:l="text",disabled:a,readonly:o,onChange:d,onKeyDown:x,onFocus:u,onBlur:h})=>{const g=m("truncate outline-none shadow-none body-1",r,o?"pointer-events-none":"");return t.jsx("input",{type:l,autoComplete:"off",id:n,placeholder:s,value:e||"",title:e?String(e):"",disabled:a,className:g,onKeyDown:x,onFocus:u,onBlur:h,onChange:y=>d?.(y.currentTarget.value)})},je=({iconBeforeInput:e,iconAfterInput:n,containerClasses:s,cssClass:r,...l})=>t.jsxs("div",{className:m("input w-full flex flex-row",s),children:[e,t.jsx(Z,{cssClass:m("border-0 bg-transparent p-0 h-full shadow-none flex-1 min-w-0 rounded-none",r),...l}),n]}),Ne=({url:e,title:n,linkClassName:s="",iconBefore:r,iconAfter:l})=>{const a=m(l?"mr-2":"",r?"ml-2":"");return t.jsxs("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:m("base-link",s),title:n,children:[r,t.jsx("span",{className:a,children:n}),l]})},Ce=({title:e,text:n,disabled:s,onClick:r})=>t.jsx("button",{type:"button",className:m("tag flex items-center justify-center","disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:bg-neutrals-100"),disabled:s,onClick:()=>r?.(n||e),"aria-label":"button",children:t.jsx("h4",{children:e})}),ye=({label:e,id:n,checked:s,radioIcon:r,description:l,onChange:a})=>{const o=f.useCallback(d=>{d.stopPropagation(),a?.(n,d.target.checked)},[a,n]);return t.jsxs("label",{className:"flex min-w-0 cursor-pointer flex-col py-[6px]",htmlFor:n,children:[t.jsxs("p",{className:"radio-label flex min-w-0 items-center",children:[t.jsx("span",{className:m("flex justify-center items-center w-4 h-4 mr-2 relative","radio-button",s?"radio-button-active":""),children:s&&r}),e&&t.jsx("span",{className:"radio-title body-1 min-w-0 flex-1 truncate pr-2 text-neutrals-1000",title:e,children:e})]}),l&&t.jsx("span",{className:"radio-description body-2 ml-6 flex w-auto items-center text-neutrals-800",title:l,children:l}),t.jsx("input",{type:"radio",onChange:o,id:n,checked:s,className:"hidden"})]})};var P=(e=>(e.Closed="Closed",e.Opened="Opened",e))(P||{}),q=(e=>(e.LG="Large",e.SM="Small",e))(q||{});const ve=({portalId:e,state:n=P.Opened,heading:s,size:r,onClose:l,children:a,overlayClassName:o,containerClassName:d,dividers:x=!0,closeButtonTitle:u})=>{const{refs:h,context:g}=N.useFloating({open:n!==P.Closed&&!!n,onOpenChange:l}),y=N.useRole(g,{role:"dialog"}),b=N.useDismiss(g,{outsidePress:!0}),{getFloatingProps:j}=N.useInteractions([y,b]),p=f.useCallback(c=>{c?.preventDefault(),c?.stopPropagation(),l()},[l]);return t.jsx(N.FloatingPortal,{id:e,children:n!==P.Closed&&t.jsx(N.FloatingOverlay,{className:m("z-modal flex items-center justify-center bg-blackout p-4",o),children:t.jsx(N.FloatingFocusManager,{context:g,children:t.jsxs("div",{className:m("relative max-h-full modal rounded bg-white flex flex-col shadow w-full",r===q.LG&&"max-w-[65%]",r===q.SM&&"max-w-[30%]",x&&"divide-neutrals-400 divide-y",d,"sm:w-full sm:max-w-full sm:px-4 sm:py-6"),ref:h.setFloating,...j({onClick(c){c.stopPropagation()}}),children:[t.jsxs("div",{className:"modal-heading mb-2 flex flex-row items-center justify-between px-6 py-3 sm:p-0 sm:pb-2",children:[s&&(typeof s=="string"?t.jsx("h2",{className:"modal-heading-title sm:h3 mr-3 min-w-0 flex-1",children:s}):s),t.jsx(U,{title:u,onClick:p,btnClassNames:"sm:h-[24px] sm:w-[24px] sm:top-4"})]}),a.map(c=>c)]})})})})},we=e=>e.state===P.Closed?null:t.jsx(ve,{...e}),Ee=({triggerButton:e,options:n,content:s,selectedOption:r,disabled:l,containerClassName:a,openedClassName:o,onOptionSelect:d})=>{const[x,u]=f.useState(!1),{refs:h,floatingStyles:g,context:y}=N.useFloating({open:x,onOpenChange:l?void 0:u,placement:"bottom-end",middleware:[N.offset(8),N.flip(),N.shift()],whileElementsMounted:N.autoUpdate}),b=N.useClick(y),j=N.useDismiss(y,{outsidePress:!0}),{getReferenceProps:p,getFloatingProps:c}=N.useInteractions([b,j]);return t.jsxs(t.Fragment,{children:[t.jsx("div",{ref:h.setReference,...p({onClick(i){i.stopPropagation()}}),className:m(a,x&&o),children:e}),x&&t.jsxs("div",{ref:h.setFloating,style:g,className:"dropdown-menu-shadow dropdown-container z-10 flex flex-col rounded bg-white",...c(),children:[s&&s,n&&n.map(i=>t.jsx("div",{onClick:v=>{v.stopPropagation(),d?.(i.key),u(!1)},className:m("text-neutrals-900 body-3 cursor-pointer dropdown-item min-w-[200px]",r===i.key&&"bg-hues-100"),children:t.jsxs("div",{className:"dropdown-item-text flex h-full items-center gap-x-2 p-2 hover:bg-hues-100",title:i.title,children:[i.icon?i.icon:null,t.jsx("p",{children:i?.title})]})},i.key))]})]})},Ie=({limitMessages:e,query:n})=>t.jsxs("div",{className:"flex flex-wrap items-center justify-between bg-hues-100 px-2 py-1",children:[t.jsx("div",{className:"flex gap-x-[4px]",children:t.jsx("div",{className:"flex flex-col",children:t.jsxs("div",{className:"flex gap-x-[4px]",children:[t.jsxs("span",{className:"h5 text-primary",children:[e?.excelFormatTitle," "]}),t.jsx("span",{className:"body-3 text-neutrals-800",children:e?.excelFormatText})]})})}),t.jsx("a",{href:n,target:"_blank",rel:"noreferrer",children:t.jsxs("span",{className:"body-3 flex cursor-pointer items-center gap-x-[4px]",children:[e?.dataExplorerIcon,e?.dataExplorer]})})]}),Se=({limitMessages:e,isDownload:n,showAdvancedViewButton:s,onAdvancedViewClick:r,query:l})=>t.jsxs("div",{className:m("bg-semantic-warning-light px-2 py-1 flex justify-between flex-wrap items-center",e?.containerClassName),children:[t.jsxs("div",{className:"flex items-center gap-x-2",children:[t.jsx("span",{children:e?.warningIcon}),t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsxs("div",{className:"flex gap-x-[4px]",children:[t.jsxs("span",{className:m("text-primary h5",e?.largeQueryClassName),children:[e?.largeQuery,":"," "]}),t.jsx("span",{className:m("text-neutrals-800 body-3",e?.limitMessageClassName),children:n?e?.downloadMessage?.(z):e?.showingLimit?.(z)})]}),n&&t.jsx("span",{className:m("text-neutrals-800 body-3",e?.limitMessageClassName),children:e?.fullLimitMessage})]})]}),s&&t.jsxs("span",{onClick:()=>r?.(),className:"h4 flex cursor-pointer items-center gap-x-[4px] text-primary",children:[e?.editIcon,e?.refineInAdvancedView]}),n&&t.jsx("a",{href:l||"",target:"_blank",rel:"noreferrer",children:t.jsxs("span",{className:"body-3 flex cursor-pointer items-center gap-x-[4px]",children:[e?.dataExplorerIcon,e?.dataExplorer]})})]}),X=f.createContext(null);function ke({value:e,children:n}){const s=f.useMemo(()=>e??{},[e]);return t.jsx(X.Provider,{value:s,children:n})}function Re(){return f.useContext(X)}var F=(e=>(e.Info="info",e.Error="error",e.Warning="warning",e))(F||{});const De={[F.Info]:"border-neutrals-800 bg-neutrals-300 text-neutrals-1000",[F.Error]:"border-semantic-error bg-semantic-error-light text-neutrals-1000",[F.Warning]:"border-semantic-warning bg-semantic-warning-light text-neutrals-1000"},Ae="shrink-0",Oe="min-w-0 body-2",_e="flex items-start gap-2 min-w-0 border-l-2 rounded py-2 px-4 items-center";function Le({type:e,icon:n,children:s,className:r,contentClassName:l}){const a=Re(),o=n??a?.icons?.[e],d=a?.classes?.container??_e,x=a?.classes?.types?.[e]??De[e],u=O(d,x,r),h=O(Ae,a?.classes?.icon),g=O(Oe,a?.classes?.content,l);return t.jsxs("div",{"data-type":e,className:u,children:[o?t.jsx("span",{className:h,children:o}):null,s?t.jsx("div",{className:g,children:s}):null]})}const Pe=({title:e,copiedTitle:n,tooltip:s,icon:r,copiedIcon:l,className:a,buttonTextClassName:o,onClick:d})=>{const[x,u]=f.useState(!1),h=f.useRef(null),g=()=>{d(),u(!0),h.current&&clearTimeout(h.current),h.current=setTimeout(()=>{u(!1)},1e3)};return f.useEffect(()=>()=>{h.current&&clearTimeout(h.current)},[]),t.jsxs("div",{className:"relative w-fit",children:[t.jsx(V,{title:x?n:e,isSmallButton:!0,disabled:x,buttonClassName:O(["text-button-tertiary small-icon-button !h-6 !p-0",a]),textClassName:O(["ml-1",o]),onClick:g,iconBefore:x?l:r}),s&&x&&t.jsx("div",{className:"h4 absolute left-1/2 top-full z-50 mt-1 -translate-x-1/2 whitespace-nowrap rounded border border-neutrals-400 bg-white px-3 py-4 text-neutrals-900 shadow",children:s})]})};function Te({id:e,label:n,hasChildren:s,showDragHandle:r,showCheckbox:l,isChecked:a,isExpanded:o}){return t.jsxs("div",{className:"relative cursor-grabbing rounded bg-neutrals-200 shadow",children:[t.jsx("div",{className:"absolute -left-[0.5px] top-0.5 h-5 w-0.5 rounded-full bg-gradients-light"}),t.jsxs("div",{className:"flex items-stretch overflow-hidden rounded",children:[r?t.jsx("div",{className:"flex w-6 items-center justify-center",children:t.jsx("span",{"aria-hidden":!0,className:"rounded p-1",children:t.jsx(k.IconGripVertical,{size:16})})}):null,t.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2 p-1",children:[l?t.jsx(H,{id:e,checked:!!a,className:"p-0"}):null,t.jsx("span",{className:"body-3 truncate",children:n})]}),s?t.jsx("div",{className:"flex w-8 items-center justify-center",children:t.jsx("span",{"aria-hidden":!0,className:m("transition-transform",o?"rotate-90":"rotate-0"),children:t.jsx(k.IconChevronRight,{size:16})})}):null]})]})}function J(e,n){return`i:${[...e,n].join("/")}`}function G(e){if(!e.startsWith("i:"))return null;const s=e.slice(2).split("/").filter(Boolean);return s.length?{parentPath:s.slice(0,-1),itemId:s[s.length-1]}:null}function Fe(e,n,s){const r=te(e,n);return r?r.find(l=>l.id===s)??null:null}function ee(e,n){if(n.length===0)return e;const[s,...r]=n,l=e.find(a=>a.id===s);return l?.items?ee(l.items,r):null}function te(e,n){const s=ee(e,n);return s?s.filter(r=>r.type==="item"):null}function ne(e,n,s){if(n.length===0)return s(e);const[r,...l]=n;return e.map(a=>a.id!==r||!a.items?a:{...a,items:ne(a.items,l,s)})}function Me({parentPath:e,item:n,showDragHandle:s,showCheckbox:r,renderLabel:l,onItemClick:a,onToggleExpanded:o,onToggleChecked:d}){const x=!!n.items?.length,u=!!n.isExpanded,h=n.isDisabled?!1:n.draggable??!0,g=n.isDisabled?!1:n.checkable??!0,y=J(e,n.id),{attributes:b,listeners:j,setNodeRef:p,setActivatorNodeRef:c,transform:i,transition:v,isDragging:I}=M.useSortable({id:y,disabled:!h}),E={transform:ie.CSS.Transform.toString(i),transition:v,opacity:I?.6:void 0},w=!!n.isDisabled,C=[...e,n.id];return t.jsxs("div",{ref:p,style:E,className:m(["group flex items-stretch overflow-hidden rounded bg-white","select-none",w?"opacity-50":""]),children:[s?t.jsx("div",{className:m(["group/drag-handle flex w-6 items-center justify-center rounded",w?"":"hover:bg-neutrals-100 cursor-grab"]),children:t.jsx("span",{ref:c,"aria-hidden":!0,className:m(["rounded p-1",h?"cursor-grab":"cursor-default","transition-opacity"]),...h?j:{},...h?b:{},children:t.jsx(k.IconGripVertical,{size:16,className:"text-neutrals-800 group-hover/drag-handle:text-primary"})})}):null,t.jsxs("button",{type:"button",disabled:w,onClick:R=>a?.({itemId:n.id,path:C,nativeEvent:R}),className:m(["flex min-w-0 flex-1 items-center gap-2 p-1 text-left rounded",w?"":"hover:bg-neutrals-100",w?"":"hover:text-blue-700","focus:outline-none"]),children:[r?t.jsx(H,{id:`draggable-list-${C.join("-")}`,checked:!!n.isChecked,disabled:!g,className:"p-0",stopPropagation:!0,onChange:(R,D)=>d?.({itemId:n.id,path:C,nextChecked:!!D})}):null,t.jsx("span",{className:"body-3 truncate text-neutrals-800",children:l?l(n):n.label})]}),x?t.jsx("button",{type:"button",disabled:w,onClick:R=>{R.stopPropagation(),o?.({itemId:n.id,path:C,nextExpanded:!u})},"aria-label":u?"Collapse":"Expand",className:m(["flex w-8 items-center justify-center rounded",w?"":"hover:bg-neutrals-100","focus:outline-none"]),children:t.jsx("span",{"aria-hidden":!0,className:m("transition-transform duration-150 ease-out",u?"rotate-90":"rotate-0"),children:t.jsx(k.IconChevronRight,{size:16})})}):null]})}function qe({items:e,showDragHandle:n=!0,showCheckbox:s=!0,onItemsChange:r,onToggleExpanded:l,onToggleChecked:a,onItemClick:o,renderLabel:d}){const x=L.useSensors(L.useSensor(L.PointerSensor,{activationConstraint:{distance:6}})),[u,h]=oe.useState(null),g=j=>{const p=String(j.active.id),c=G(p);if(!c)return;const i=Fe(e,c.parentPath,c.itemId);!i||i.type!=="item"||h({id:p,label:i.label,hasChildren:!!i.items?.length,isChecked:i.isChecked,isExpanded:i.isExpanded})},y=j=>{h(null);const p=j.over;if(!p)return;const c=G(String(j.active.id)),i=G(String(p.id));if(!c||!i||c.parentPath.join("/")!==i.parentPath.join("/"))return;const v=te(e,c.parentPath);if(!v)return;const I=v.findIndex(C=>C.id===c.itemId),E=v.findIndex(C=>C.id===i.itemId);if(I===-1||E===-1||I===E)return;const w=ne(e,c.parentPath,C=>{const R=C.filter(_=>_.type==="item"),D=M.arrayMove(R,I,E);let S=0;return C.map(_=>{if(_.type!=="item")return _;const B=D[S];return S+=1,B})});r(w)},b=(j,p=[])=>{const c=j.filter(i=>i.type==="item").map(i=>J(p,i.id));return t.jsx(M.SortableContext,{items:c,strategy:M.verticalListSortingStrategy,children:t.jsx("ul",{className:"m-0 flex list-none flex-col gap-2 p-0",children:j.map(i=>i.type==="group"?t.jsxs("li",{className:"m-0 mt-2 flex flex-col gap-2 p-0 first:mt-0",children:[t.jsxs("div",{className:"h5 flex items-center gap-2 py-1 text-neutrals-1000",children:[t.jsx(k.IconDatabase,{size:12,className:"shrink-0"}),i.label]}),t.jsx("div",{className:"border-l border-neutrals-600 pl-2",children:b(i.items,[...p,i.id])})]},i.id):t.jsxs("li",{className:"m-0 flex flex-col gap-2 p-0",children:[t.jsx(Me,{parentPath:p,item:i,showDragHandle:n,showCheckbox:s,renderLabel:d,onItemClick:o,onToggleExpanded:l,onToggleChecked:a}),i.items?.length&&i.isExpanded?t.jsx("div",{className:"pl-7",children:b(i.items,[...p,i.id])}):null]},i.id))})})};return t.jsxs(L.DndContext,{sensors:x,collisionDetection:L.closestCenter,onDragStart:g,onDragEnd:y,children:[t.jsx("div",{className:"flex flex-col",children:b(e)}),t.jsx(L.DragOverlay,{children:u?t.jsx(Te,{id:u.id,label:u.label,hasChildren:u.hasChildren,showDragHandle:n,showCheckbox:s,isChecked:u.isChecked,isExpanded:u.isExpanded}):null})]})}const Ye=(e,n)=>e.label.toLowerCase().includes(n);function Be(e,n,s={}){const r=ze(n);if(!r)return e;const{expandMatchedBranches:l=!0,includeGroupDescendantsOnMatch:a=!0,includeItemDescendantsOnMatch:o=!1,match:d=Ye}=s;return $(e,r,{expandMatchedBranches:l,includeGroupDescendantsOnMatch:a,includeItemDescendantsOnMatch:o,match:d})??[]}function $(e,n,s){const r=[];for(const l of e){const a=Ge(l,n,s);a&&r.push(a)}return r.length?r:null}function Ge(e,n,s){const r=s.match(e,n);if(e.type==="group"){if(r&&s.includeGroupDescendantsOnMatch)return Y(e,s.expandMatchedBranches);const o=e.items?.length?$(e.items,n,s):null;return!r&&!o?null:{...e,items:o??[]}}const l=e.items?.length?$(e.items,n,s):null;if(r&&s.includeItemDescendantsOnMatch)return Y(e,s.expandMatchedBranches);if(!r&&!l)return null;const a={...e};return l?(a.items=l,s.expandMatchedBranches&&(a.isExpanded=!0)):delete a.items,a}function Y(e,n){return e.type==="group"?{...e,items:e.items.map(s=>Y(s,n))}:{...e,isExpanded:n&&e.items?.length?!0:e.isExpanded,items:e.items?.map(s=>Y(s,n))}}function ze(e){return e.trim().toLowerCase()}var se=(e=>(e.Enter="Enter",e))(se||{});const re=f.createContext(null);function $e({children:e,isAgentAvailable:n}){const s=f.useMemo(()=>({isAgentAvailable:n}),[n]);return t.jsx(re.Provider,{value:s,children:e})}function We(){const e=f.useContext(re);if(!e)throw new Error("useAgentAvailability must be used within AgentAvailabilityProvider");return e}exports.AgentAvailabilityProvider=$e;exports.Alert=de;exports.AlertType=A;exports.Button=V;exports.CALENDAR_MOBILE_PADDING=Q;exports.Calendar=fe;exports.Checkbox=H;exports.CloseButton=U;exports.CollapsibleBlock=pe;exports.CopyButton=Pe;exports.DownloadFormatMessage=Ie;exports.DraggableList=qe;exports.Dropdown=Ee;exports.HighlightText=ge;exports.IconButton=be;exports.InlineAlert=Le;exports.InlineAlertProvider=ke;exports.InlineAlertType=F;exports.Input=Z;exports.InputWithIcon=je;exports.KeyboardKey=se;exports.Link=Ne;exports.Loader=W;exports.PopUpSize=q;exports.PopUpState=P;exports.Popup=we;exports.Radio=ye;exports.RequestLimitMessage=Se;exports.SERIES_LIMIT=z;exports.TREE_NODE_ARROW_SIZE=me;exports.TREE_NODE_PADDING=he;exports.Tag=Ce;exports.filterDraggableListNodes=Be;exports.useAgentAvailability=We;exports.useDebounce=xe;exports.useIsMobile=K;
package/index.mjs CHANGED
@@ -160,16 +160,16 @@ const ft = 24, pt = 24, q = 1e3, Ge = 24, gt = ({
160
160
  }, x = (b, N, g) => {
161
161
  const c = `calendar__${l === O.MONTH ? "month" : "day"}`;
162
162
  g.calendarContainer && g.calendarContainer.classList.add(c);
163
- }, w = (b, N, g) => {
163
+ }, v = (b, N, g) => {
164
164
  if (l === O.MONTH && b.length > 0) {
165
- const c = s.minDate, i = s.maxDate, v = b[0].getFullYear(), S = g.calendarContainer, E = "flatpickr-disabled", y = S.querySelectorAll(
165
+ const c = s.minDate, i = s.maxDate, y = b[0].getFullYear(), S = g.calendarContainer, E = "flatpickr-disabled", w = S.querySelectorAll(
166
166
  ".flatpickr-monthSelect-month"
167
167
  ), C = S.querySelectorAll(
168
168
  ".flatpickr-next-month"
169
169
  )[0], k = S.querySelectorAll(
170
170
  ".flatpickr-prev-month"
171
171
  )[0];
172
- v === i.getFullYear() && C.classList.add(E), v === c.getFullYear() && k.classList.add(E), (v === c.getFullYear() || v === i.getFullYear()) && y.forEach((D) => {
172
+ y === i.getFullYear() && C.classList.add(E), y === c.getFullYear() && k.classList.add(E), (y === c.getFullYear() || y === i.getFullYear()) && w.forEach((D) => {
173
173
  D.classList.remove(E);
174
174
  const I = new Date(D.getAttribute("aria-label")), R = I.getFullYear() === c.getFullYear() && I.getMonth() === c.getMonth(), Y = I.getFullYear() === i.getFullYear() && I.getMonth() === i.getMonth();
175
175
  R || Y || (I < c || I > i) && D.classList.add(E);
@@ -198,7 +198,7 @@ const ft = 24, pt = 24, q = 1e3, Ge = 24, gt = ({
198
198
  onChange: (b) => {
199
199
  t(b[0]);
200
200
  },
201
- onOpen: [w],
201
+ onOpen: [v],
202
202
  onReady: [x],
203
203
  id: a
204
204
  }
@@ -367,9 +367,11 @@ const ft = 24, pt = 24, q = 1e3, Ge = 24, gt = ({
367
367
  disabled: a,
368
368
  readonly: d,
369
369
  onChange: u,
370
- onKeyDown: h
370
+ onKeyDown: h,
371
+ onFocus: m,
372
+ onBlur: p
371
373
  }) => {
372
- const m = f(
374
+ const x = f(
373
375
  "truncate outline-none shadow-none body-1",
374
376
  s,
375
377
  d ? "pointer-events-none" : ""
@@ -384,9 +386,11 @@ const ft = 24, pt = 24, q = 1e3, Ge = 24, gt = ({
384
386
  value: e || "",
385
387
  title: e ? String(e) : "",
386
388
  disabled: a,
387
- className: m,
389
+ className: x,
388
390
  onKeyDown: h,
389
- onChange: (p) => u?.(p.currentTarget.value)
391
+ onFocus: m,
392
+ onBlur: p,
393
+ onChange: (v) => u?.(v.currentTarget.value)
390
394
  }
391
395
  );
392
396
  }, Ct = ({
@@ -526,7 +530,7 @@ const $e = ({
526
530
  const { refs: p, context: x } = X({
527
531
  open: t !== A.Closed && !!t,
528
532
  onOpenChange: l
529
- }), w = xe(x, { role: "dialog" }), b = Z(x, { outsidePress: !0 }), { getFloatingProps: N } = J([w, b]), g = _(
533
+ }), v = xe(x, { role: "dialog" }), b = Z(x, { outsidePress: !0 }), { getFloatingProps: N } = J([v, b]), g = _(
530
534
  (c) => {
531
535
  c?.preventDefault(), c?.stopPropagation(), l();
532
536
  },
@@ -584,13 +588,13 @@ const $e = ({
584
588
  openedClassName: d,
585
589
  onOptionSelect: u
586
590
  }) => {
587
- const [h, m] = j(!1), { refs: p, floatingStyles: x, context: w } = X({
591
+ const [h, m] = j(!1), { refs: p, floatingStyles: x, context: v } = X({
588
592
  open: h,
589
593
  onOpenChange: l ? void 0 : m,
590
594
  placement: "bottom-end",
591
595
  middleware: [ye(8), we(), Ee()],
592
596
  whileElementsMounted: ve
593
- }), b = Se(w), N = Z(w, { outsidePress: !0 }), { getReferenceProps: g, getFloatingProps: c } = J([
597
+ }), b = Se(v), N = Z(v, { outsidePress: !0 }), { getReferenceProps: g, getFloatingProps: c } = J([
594
598
  b,
595
599
  N
596
600
  ]);
@@ -620,8 +624,8 @@ const $e = ({
620
624
  t && t.map((i) => /* @__PURE__ */ r(
621
625
  "div",
622
626
  {
623
- onClick: (v) => {
624
- v.stopPropagation(), u?.(i.key), m(!1);
627
+ onClick: (y) => {
628
+ y.stopPropagation(), u?.(i.key), m(!1);
625
629
  },
626
630
  className: f(
627
631
  "text-neutrals-900 body-3 cursor-pointer dropdown-item min-w-[200px]",
@@ -875,19 +879,19 @@ function Ke({
875
879
  onToggleExpanded: d,
876
880
  onToggleChecked: u
877
881
  }) {
878
- const h = !!t.items?.length, m = !!t.isExpanded, p = t.isDisabled ? !1 : t.draggable ?? !0, x = t.isDisabled ? !1 : t.checkable ?? !0, w = se(e, t.id), {
882
+ const h = !!t.items?.length, m = !!t.isExpanded, p = t.isDisabled ? !1 : t.draggable ?? !0, x = t.isDisabled ? !1 : t.checkable ?? !0, v = se(e, t.id), {
879
883
  attributes: b,
880
884
  listeners: N,
881
885
  setNodeRef: g,
882
886
  setActivatorNodeRef: c,
883
887
  transform: i,
884
- transition: v,
888
+ transition: y,
885
889
  isDragging: S
886
- } = Oe({ id: w, disabled: !p }), E = {
890
+ } = Oe({ id: v, disabled: !p }), E = {
887
891
  transform: Te.Transform.toString(i),
888
- transition: v,
892
+ transition: y,
889
893
  opacity: S ? 0.6 : void 0
890
- }, y = !!t.isDisabled, C = [...e, t.id];
894
+ }, w = !!t.isDisabled, C = [...e, t.id];
891
895
  return /* @__PURE__ */ o(
892
896
  "div",
893
897
  {
@@ -896,7 +900,7 @@ function Ke({
896
900
  className: f([
897
901
  "group flex items-stretch overflow-hidden rounded bg-white",
898
902
  "select-none",
899
- y ? "opacity-50" : ""
903
+ w ? "opacity-50" : ""
900
904
  ]),
901
905
  children: [
902
906
  n ? /* @__PURE__ */ r(
@@ -904,7 +908,7 @@ function Ke({
904
908
  {
905
909
  className: f([
906
910
  "group/drag-handle flex w-6 items-center justify-center rounded",
907
- y ? "" : "hover:bg-neutrals-100 cursor-grab"
911
+ w ? "" : "hover:bg-neutrals-100 cursor-grab"
908
912
  ]),
909
913
  children: /* @__PURE__ */ r(
910
914
  "span",
@@ -933,7 +937,7 @@ function Ke({
933
937
  "button",
934
938
  {
935
939
  type: "button",
936
- disabled: y,
940
+ disabled: w,
937
941
  onClick: (k) => a?.({
938
942
  itemId: t.id,
939
943
  path: C,
@@ -941,8 +945,8 @@ function Ke({
941
945
  }),
942
946
  className: f([
943
947
  "flex min-w-0 flex-1 items-center gap-2 p-1 text-left rounded",
944
- y ? "" : "hover:bg-neutrals-100",
945
- y ? "" : "hover:text-blue-700",
948
+ w ? "" : "hover:bg-neutrals-100",
949
+ w ? "" : "hover:text-blue-700",
946
950
  "focus:outline-none"
947
951
  ]),
948
952
  children: [
@@ -969,7 +973,7 @@ function Ke({
969
973
  "button",
970
974
  {
971
975
  type: "button",
972
- disabled: y,
976
+ disabled: w,
973
977
  onClick: (k) => {
974
978
  k.stopPropagation(), d?.({
975
979
  itemId: t.id,
@@ -980,7 +984,7 @@ function Ke({
980
984
  "aria-label": m ? "Collapse" : "Expand",
981
985
  className: f([
982
986
  "flex w-8 items-center justify-center rounded",
983
- y ? "" : "hover:bg-neutrals-100",
987
+ w ? "" : "hover:bg-neutrals-100",
984
988
  "focus:outline-none"
985
989
  ]),
986
990
  children: /* @__PURE__ */ r(
@@ -1023,17 +1027,17 @@ function Ft({
1023
1027
  isChecked: i.isChecked,
1024
1028
  isExpanded: i.isExpanded
1025
1029
  });
1026
- }, w = (N) => {
1030
+ }, v = (N) => {
1027
1031
  p(null);
1028
1032
  const g = N.over;
1029
1033
  if (!g) return;
1030
1034
  const c = G(String(N.active.id)), i = G(String(g.id));
1031
1035
  if (!c || !i || c.parentPath.join("/") !== i.parentPath.join("/")) return;
1032
- const v = ae(e, c.parentPath);
1033
- if (!v) return;
1034
- const S = v.findIndex((C) => C.id === c.itemId), E = v.findIndex((C) => C.id === i.itemId);
1036
+ const y = ae(e, c.parentPath);
1037
+ if (!y) return;
1038
+ const S = y.findIndex((C) => C.id === c.itemId), E = y.findIndex((C) => C.id === i.itemId);
1035
1039
  if (S === -1 || E === -1 || S === E) return;
1036
- const y = ie(e, c.parentPath, (C) => {
1040
+ const w = ie(e, c.parentPath, (C) => {
1037
1041
  const k = C.filter(
1038
1042
  (R) => R.type === "item"
1039
1043
  ), D = Pe(k, S, E);
@@ -1044,7 +1048,7 @@ function Ft({
1044
1048
  return I += 1, Y;
1045
1049
  });
1046
1050
  });
1047
- s(y);
1051
+ s(w);
1048
1052
  }, b = (N, g = []) => {
1049
1053
  const c = N.filter((i) => i.type === "item").map((i) => se(g, i.id));
1050
1054
  return /* @__PURE__ */ r(
@@ -1090,7 +1094,7 @@ function Ft({
1090
1094
  sensors: h,
1091
1095
  collisionDetection: Re,
1092
1096
  onDragStart: x,
1093
- onDragEnd: w,
1097
+ onDragEnd: v,
1094
1098
  children: [
1095
1099
  /* @__PURE__ */ r("div", { className: "flex flex-col", children: b(e) }),
1096
1100
  /* @__PURE__ */ r(Fe, { children: m ? /* @__PURE__ */ r(
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@epam/statgpt-ui-components",
3
- "version": "0.4.0-rc.16",
3
+ "version": "0.4.0-rc.18",
4
4
  "license": "MIT",
5
5
  "dependencies": {
6
6
  "react-flatpickr": "^4.0.11",
7
7
  "classnames": "^2.5.1",
8
- "@epam/statgpt-shared-toolkit": "0.4.0-rc.16",
8
+ "@epam/statgpt-shared-toolkit": "0.4.0-rc.18",
9
9
  "@tabler/icons-react": "^3.34.1",
10
10
  "@floating-ui/react": "^0.27.14",
11
11
  "tailwind-merge": "^3.4.0",