caplink-saas-ui-shared-component-library 0.2.3 → 0.2.4
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/src/index.css +1222 -1
- package/dist/src/index.css.map +1 -1
- package/dist/src/index.js +3582 -12
- package/dist/src/index.js.map +1 -1
- package/package.json +3 -2
package/dist/src/index.js
CHANGED
|
@@ -1,24 +1,3594 @@
|
|
|
1
|
+
import './index.css';
|
|
1
2
|
import { nanoid } from 'nanoid';
|
|
2
|
-
import * as
|
|
3
|
-
import { createContext, useState, useCallback, useMemo
|
|
3
|
+
import * as React4 from 'react';
|
|
4
|
+
import { createContext, forwardRef, Children, isValidElement, createElement, cloneElement, useRef, useEffect, Fragment, useState, useCallback, useMemo as useMemo$1, useId as useId$1, useContext } from 'react';
|
|
4
5
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
5
6
|
import { clsx } from 'clsx';
|
|
6
7
|
import { twMerge } from 'tailwind-merge';
|
|
7
|
-
import
|
|
8
|
-
import
|
|
8
|
+
import $01b9c$babelruntimehelpersesmextends from '@babel/runtime/helpers/esm/extends';
|
|
9
|
+
import { composeEventHandlers } from '@radix-ui/primitive';
|
|
10
|
+
import { composeRefs, useComposedRefs } from '@radix-ui/react-compose-refs';
|
|
11
|
+
import { createContextScope } from '@radix-ui/react-context';
|
|
12
|
+
import { DismissableLayer } from '@radix-ui/react-dismissable-layer';
|
|
13
|
+
import { useId } from '@radix-ui/react-id';
|
|
14
|
+
import { createPopperScope, Content, Anchor, Root as Root$3 } from '@radix-ui/react-popper';
|
|
15
|
+
import { Portal } from '@radix-ui/react-portal';
|
|
16
|
+
import { Presence } from '@radix-ui/react-presence';
|
|
17
|
+
import { Primitive } from '@radix-ui/react-primitive';
|
|
18
|
+
import { useControllableState } from '@radix-ui/react-use-controllable-state';
|
|
19
|
+
import { VisuallyHidden, Root as Root$1 } from '@radix-ui/react-visually-hidden';
|
|
9
20
|
import { CaretSortIcon, ChevronUpIcon, ChevronDownIcon, CheckIcon, ChevronRightIcon, DotFilledIcon, TextIcon, QuestionMarkCircledIcon } from '@radix-ui/react-icons';
|
|
10
21
|
import { ChevronDown, CalendarIcon, CopyCheckIcon, ListTodoIcon, DivideIcon, DollarSignIcon, PercentIcon } from 'lucide-react';
|
|
11
|
-
import
|
|
22
|
+
import { createPortal } from 'react-dom';
|
|
23
|
+
import { clamp } from '@radix-ui/number';
|
|
24
|
+
import { createCollection } from '@radix-ui/react-collection';
|
|
25
|
+
import { useDirection } from '@radix-ui/react-direction';
|
|
26
|
+
import { useFocusGuards } from '@radix-ui/react-focus-guards';
|
|
27
|
+
import { FocusScope } from '@radix-ui/react-focus-scope';
|
|
28
|
+
import { useCallbackRef } from '@radix-ui/react-use-callback-ref';
|
|
29
|
+
import { useLayoutEffect } from '@radix-ui/react-use-layout-effect';
|
|
30
|
+
import { usePrevious } from '@radix-ui/react-use-previous';
|
|
31
|
+
import { hideOthers } from 'aria-hidden';
|
|
32
|
+
import { RemoveScroll } from 'react-remove-scroll';
|
|
12
33
|
import { NumericFormat } from 'react-number-format';
|
|
13
|
-
import { Slot } from '@radix-ui/react-slot';
|
|
14
34
|
import { cva } from 'class-variance-authority';
|
|
15
|
-
import
|
|
35
|
+
import { createMenuScope, Portal as Portal$1, Content as Content$1, Label, Item, CheckboxItem, RadioItem, ItemIndicator, Separator, SubTrigger, SubContent, Root as Root$2, Anchor as Anchor$1 } from '@radix-ui/react-menu';
|
|
16
36
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
Linha N\xB0 ${f+1} at\xE9 N\xB0 ${M+1}`:`Voc\xEA ir\xE1 excluir a linha N\xB0 ${f+1}, deseja continuar?`;if(!confirm(O))return;let U=n.filter((Le,ce)=>ce<f||ce>M);b(null),h(U),R(U);}},[n,d,a,W,R]),K=useCallback((f,M)=>{if(d&&M&&M.shiftKey){let D=f<d.start.row?f:d.start.row,O=f<d.start.row?d.start.row:f;return b({start:{row:D,column:0},end:{row:O,column:w}})}b({start:{row:f,column:0},end:{row:f,column:w}});},[w,d]),q=useCallback(f=>{f.row===d?.start.row&&f.column===d.start.column||b({start:f,end:f});},[d?.start.row,d?.start.column]),ne=useCallback(f=>!!(d&&nt(d,f)),[d]),x=useCallback(f=>{let{columnId:M,width:D}=f,O=D;D>320&&(O=320),D<160&&(O=160),y(ie=>ie.map(U=>U.id===M?{...U,width:O}:U));},[]),V=useCallback(()=>{if(a)return;let f=[...structuredClone(n),new Array(w).fill("")];h(f),R(f),L();},[a,n,w,L,R]),_=useCallback(()=>{let f={column:0,row:0},M={column:S.columns,row:S.rows-1};b({start:f,end:M});},[S]),G=useCallback(f=>{y(M=>M.map(D=>D.id===f?{...D,visible:!D.visible}:D));},[]);useEffect(()=>{h(r);},[r]),useEffect(()=>{y(()=>ct(o));},[o]);let co=useMemo(()=>({size:S,matrix:n,columns:l,emptySize:g,staticRows:a,hasSomeEntireRow:W,highlightLastRow:E,pointRange:d,setPointRange:b,containerDimensions:v,setContainerDimensions:k,onPaste:j,onChange:F,onRemoveRow:A,onSelectRow:K,onSelectCell:q,isCellSelected:ne,onInsertNewRow:V,onColumnResize:x,onSelectSpreadsheet:_,onColumnVisibilityChange:G}),[S,n,l,g,a,W,E,d,v,j,F,A,K,q,ne,V,x,_,G]);return jsx(He.Provider,{value:co,children:t})}function ct(e){return e.map((t,o)=>({...t,id:`spreadsheet__column__id__${nanoid()}`,alphabetLetter:Ae(o+1),position:o,width:t.width||160,visible:!0}))}function N(){let e=useContext(He);if(!e)throw new Error("useSpreadsheet has to be used within <SpreadsheetContext.Provider>");return e}function s(...e){return twMerge(clsx(e))}function mt(e){let{children:t,className:o}=e,{size:r,staticRows:a,setContainerDimensions:i}=N(),n=useRef(null),h=useMemo(()=>r.rows*26+36,[r.rows]);return useEffect(()=>{let l=n.current;if(!l)return;let y=new ResizeObserver(d=>{let b=d[0];if(b){let v=b.contentRect.width,k=b.contentRect.height;i({height:k,width:v});}});return y.observe(l),()=>{y.disconnect();}},[i]),jsx("div",{ref:n,className:s("relative w-full border border-t-0 border-r-0",r.rows>=7?"border-b-0":"border-b",a?`${h}px border-b-0`:"min-h-[260px]",o),children:t})}function ut(e){let{children:t,className:o}=e,{setPointRange:r}=N(),a=useRef(null);return useClickAway(a,()=>r(null)),jsx("div",{ref:a,className:s("min-w-[640px]",o),children:t})}var We={Matrix:mt,Root:ut};function ft(e){let{className:t,...o}=e;return jsx("button",{draggable:!0,className:s("h-9 w-1.5 cursor-col-resize rounded-sm bg-neutral-400 drop-shadow-md",t),...o,children:jsxs("div",{className:"relative",children:[jsx("span",{className:"-translate-y-1/2 absolute top-1/2 right-2.5 h-3 w-1 rounded-full bg-neutral-300"}),jsx("span",{className:"-translate-y-1/2 absolute top-1/2 left-2.5 h-3 w-1 rounded-full bg-neutral-300"})]})})}function wt(e){let{className:t,column:o,children:r}=e,{id:a,width:i,position:n,visible:h,alphabetLetter:l}=o,{matrix:y,pointRange:d,containerDimensions:b,onColumnResize:v}=N(),k=useRef(null),E=useMemo(()=>(b?.height||0)+32,[b?.height]),[P,L]=useState(!1),[w,S]=useState(0),[g,W]=useState(0),R=useMemo(()=>P?g-w:0,[P,g,w]),j=useCallback(x=>{S(x.clientX),L(!0);},[]),F=useCallback(x=>{let V=k.current;if(!V)return;let _=x.clientX-w,G=i+_;G>320&&(G=320),G<160&&(G=160),V.style.left=`${G}px`,W(x.clientX);},[w,i]),A=useCallback(x=>{let V=x.clientX-w,_=i+V;v({width:_,columnId:a}),L(!1);},[w,i,a,v]),K=useCallback(()=>{if(P)return `bg-neutral-100 font-bold text-neutral-700 ${t}`;if(d&&!P){let{start:x,end:V}=d,_=me({matrix:y,pointRange:d}),G=n>=x.column&&n<=V.column;if(_)return `bg-[#0085FF] font-bold text-white ${t}`;if(G)return `bg-blue-100 font-bold text-blue-700 ${t}`}return t},[P,t,y,d,n]),q=useCallback(()=>{let x=i+R;return x>320&&(x=320),x<160&&(x=160),`${x}px`},[i,R]),ne=useMemo(()=>({onDragStart:j,onDrag:F,onDragEnd:A}),[j,F,A]);return useEffect(()=>{let x=k.current;x&&(x.style.left=`${i}px`);},[i]),h?jsxs("div",{style:{width:i},className:s("relative flex h-7 w-32 shrink-0 items-center justify-center border border-t-0 border-l-0 text-[#8E8EA9] text-xs",K()),children:[jsx(ft,{...ne,className:s("-right-[3px] -top-1 absolute z-50 opacity-0 hover:opacity-100",P&&"opacity-0")}),jsx("div",{ref:k,style:{height:E},className:s("-top-4 pointer-events-none absolute z-50 h-full w-1.5 rounded-full bg-blue-400 shadow-lg outline outline-sky-100",P?"opacity-100":"opacity-0"),children:jsx("span",{className:"-translate-y-1/2 relative top-8 left-4 z-50 select-none rounded-md border bg-white p-1 font-semibold drop-shadow-md",children:q()})}),jsx("span",{children:r||l})]}):null}function gt(e){return jsx("svg",{stroke:"currentColor",fill:"currentColor",strokeWidth:"0",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",...e,children:jsx("path",{d:"M13.003 7.754a.75.75 0 0 1 .75-.75h5.232a.75.75 0 0 1 .53 1.28l-2.776 2.777c.55.097 1.057.253 1.492.483.905.477 1.504 1.284 1.504 2.418 0 .966-.471 1.75-1.172 2.27-.687.511-1.587.77-2.521.77-1.367 0-2.274-.528-2.667-.756a.75.75 0 0 1 .755-1.297c.331.193.953.553 1.912.553.673 0 1.243-.188 1.627-.473.37-.275.566-.635.566-1.067 0-.5-.219-.836-.703-1.091-.538-.284-1.375-.443-2.471-.443a.75.75 0 0 1-.53-1.28l2.643-2.644h-3.421a.75.75 0 0 1-.75-.75ZM7.88 15.215a1.4 1.4 0 0 0-1.446.83.75.75 0 0 1-1.37-.61 2.899 2.899 0 0 1 2.986-1.71c.589.06 1.139.323 1.557.743.434.446.685 1.058.685 1.778 0 1.641-1.254 2.437-2.12 2.986-.538.341-1.18.694-1.495 1.273H9.75a.75.75 0 0 1 0 1.5h-4a.75.75 0 0 1-.75-.75c0-1.799 1.337-2.63 2.243-3.21 1.032-.659 1.55-1.031 1.55-1.8 0-.355-.116-.584-.26-.732a1.071 1.071 0 0 0-.652-.298Zm.234-13.121a.75.75 0 0 1 .386.656V9h1.252a.75.75 0 0 1 0 1.5H5.75a.75.75 0 0 1 0-1.5H7V4.103l-.853.533a.749.749 0 1 1-.795-1.272l2-1.25a.749.749 0 0 1 .762-.02Z"})})}var Pe=Z.Provider,Ne=Z.Root,Me=Z.Trigger,he=Q.forwardRef(({className:e,sideOffset:t=4,...o},r)=>jsx(Z.Content,{ref:r,sideOffset:t,className:s("fade-in-0 zoom-in-95 data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 animate-in overflow-hidden rounded-md bg-primary px-3 py-1.5 text-primary-foreground text-xs data-[state=closed]:animate-out",e),...o}));he.displayName=Z.Content.displayName;function xt({column:e}){let{width:t,name:o,visible:r,dataEditorType:a,description:i}=e;return r?jsxs("div",{className:"flex h-9 w-32 shrink-0 items-center border border-t-0 border-l-0 bg-[#F6F6F9] px-2",style:{width:t,height:36},children:[jsxs("div",{className:"mr-2 w-4 shrink-0 text-[#8E8EA9]",children:[a==="String"&&jsx(TextIcon,{className:"h-4 w-4"}),a==="Date"&&jsx(CalendarIcon,{className:"h-4 w-4"}),a==="Boolean"&&jsx(CopyCheckIcon,{className:"h-4 w-4"}),a==="Select"&&jsx(ListTodoIcon,{className:"h-4 w-4"}),a==="Float"&&jsx(DivideIcon,{className:"h-4 w-4"}),a==="Decimal"&&jsx(DivideIcon,{className:"h-4 w-4"}),a==="Integer"&&jsx(gt,{className:"h-4 w-4"}),a==="Currency"&&jsx(DollarSignIcon,{className:"h-4 w-4"}),a==="Percentage"&&jsx(PercentIcon,{className:"h-4 w-4"})]}),jsx("p",{title:o,className:"mr-2 line-clamp-2 w-full break-words font-semibold text-[#4A4A6A] text-xs",children:o}),i?jsx(Pe,{children:jsxs(Ne,{delayDuration:100,children:[jsx(Me,{children:jsx(QuestionMarkCircledIcon,{className:"h-4 w-4 text-[#4A4A6A]"})}),jsx(he,{className:"max-w-[240px]",children:jsx("p",{children:i})})]})}):jsx("div",{className:"w-4 shrink-0"})]}):null}function St({className:e}){let{emptySize:t,onSelectSpreadsheet:o}=N();return jsxs("button",{disabled:t,className:s("relative flex h-7 w-12 shrink-0 items-center justify-center border border-l border-t bg-white text-xs",e),onClick:o,children:[jsx("span",{className:"absolute right-0 top-0 h-full w-0.5 bg-gray-300"}),jsx("span",{className:"absolute bottom-0 left-0 h-0.5 w-full bg-gray-300"})]})}function Ct(){let{columns:e}=N();return jsxs("div",{className:"sticky top-[58px] z-50",children:[jsxs("div",{className:"relative flex items-center bg-white",children:[jsx(St,{className:"border-t-0 border-l-0"}),e.map(t=>jsx(wt,{column:t},`spreadsheet__column__indicator__key__${t.name}__${t.position}`))]}),jsxs("div",{className:"flex items-center",children:[jsx("div",{className:"h-9 w-12 shrink-0 cursor-default border border-t-0 border-l-0 bg-[#F6F6F9]"}),e.map(t=>jsx(xt,{column:t},`spreadsheet__column__header__key__${t.name}__${t.position}`))]})]})}var Ee=m.Root;var Re=m.Value,ge=Q.forwardRef(({className:e,children:t,...o},r)=>jsxs(m.Trigger,{ref:r,className:s("flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent py-2 pr-px pl-3 text-sm shadow-sm ring-offset-background [&>span]:line-clamp-1 disabled:cursor-not-allowed placeholder:text-muted-foreground disabled:opacity-50 focus:outline-none focus:ring-1 focus:ring-ring",e),...o,children:[t,jsx(m.Icon,{asChild:!0,children:jsx(CaretSortIcon,{className:"h-4 w-4 opacity-50"})})]}));ge.displayName=m.Trigger.displayName;var kt=Q.forwardRef(({className:e,...t},o)=>jsx(m.ScrollUpButton,{ref:o,className:s("flex cursor-default items-center justify-center py-1",e),...t,children:jsx(ChevronUpIcon,{})}));kt.displayName=m.ScrollUpButton.displayName;var Pt=Q.forwardRef(({className:e,...t},o)=>jsx(m.ScrollDownButton,{ref:o,className:s("flex cursor-default items-center justify-center py-1",e),...t,children:jsx(ChevronDownIcon,{})}));Pt.displayName=m.ScrollDownButton.displayName;var be=Q.forwardRef(({className:e,children:t,position:o="popper",...r},a)=>jsx(m.Portal,{children:jsxs(m.Content,{ref:a,className:s("data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=closed]:animate-out data-[state=open]:animate-in",o==="popper"&&"data-[side=left]:-translate-x-1 data-[side=top]:-translate-y-1 data-[side=right]:translate-x-1 data-[side=bottom]:translate-y-1",e),position:o,...r,children:[jsx(kt,{}),jsx(m.Viewport,{className:s("p-1",o==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),jsx(Pt,{})]})}));be.displayName=m.Content.displayName;var Go=Q.forwardRef(({className:e,...t},o)=>jsx(m.Label,{ref:o,className:s("px-2 py-1.5 font-semibold text-sm",e),...t}));Go.displayName=m.Label.displayName;var se=Q.forwardRef(({className:e,children:t,...o},r)=>jsxs(m.Item,{ref:r,className:s("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pr-8 pl-2 text-sm outline-none data-[disabled]:pointer-events-none focus:bg-accent focus:text-accent-foreground data-[disabled]:opacity-50",e),...o,children:[jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:jsx(m.ItemIndicator,{children:jsx(CheckIcon,{className:"h-4 w-4"})})}),jsx(m.ItemText,{children:t})]}));se.displayName=m.Item.displayName;var Xo=Q.forwardRef(({className:e,...t},o)=>jsx(m.Separator,{ref:o,className:s("-mx-1 my-1 h-px bg-muted",e),...t}));Xo.displayName=m.Separator.displayName;function Nt(e){let{value:t,onBlur:o,onChange:r,onPaste:a}=e,i=useCallback(n=>{n.preventDefault(),a?.();},[a]);return jsxs(Ee,{value:t,onValueChange:n=>r?.({data:n}),defaultOpen:!0,children:[jsx(ge,{onBlur:o,onPaste:i,className:s("h-full w-full rounded-none border-none pl-1 text-xs outline-none focus:ring-0"),autoFocus:!0,children:jsx(Re,{placeholder:"Selecionar"})}),jsxs(be,{children:[jsx(se,{className:"text-xs",value:"true",children:"Sim"}),jsx(se,{className:"text-xs",value:"false",children:"N\xE3o"})]})]})}function Mt({value:e}){return jsxs("div",{className:"flex h-full w-full items-center justify-between pr-px pl-1",children:[jsx("p",{className:"line-clamp-1 text-xs",children:e===""?"Selecionar":e==="true"?"Sim":"N\xE3o"}),jsx(CaretSortIcon,{className:"h-4 w-4 opacity-50"})]})}function Dt(e){let{value:t,onBlur:o,onChange:r,onPaste:a}=e,i=useCallback(n=>{n.preventDefault(),a?.();},[a]);return jsx("input",{type:"date",onBlur:o,onPaste:i,value:t,onChange:n=>r?.({data:n.target.value}),className:s("h-full w-full bg-transparent pl-1 text-xs outline-none"),autoFocus:!0})}function Et(e){let{value:t}=e,o=Intl.DateTimeFormat("pt-BR",{dateStyle:"short"}),r=t?o.format(new Date(t)):"dd/mm/yyyy";return jsx("div",{className:"flex h-full w-full items-center",children:jsx("p",{className:"line-clamp-1 pl-1 text-xs",children:r})})}function qe(e){let{className:t,dataEditorType:o,onFocus:r,onBlur:a,onChange:i,onClick:n,onPaste:h,settings:l,testid:y,value:d,disabled:b,dataCypress:v,tabIndex:k}=e,E=".",P=",",L=Jo({dataEditorType:o,decimalScale:l?.numeric?.decimalPlaces}),w=l?.numeric?.allowNegative,S=l?.numeric?.min,g=l?.numeric?.max,W=o.toLocaleLowerCase()==="currency"?"R$ ":"",R=o.toLocaleLowerCase()==="percentage"?"%":"",[j,F]=useState(d),[A,K]=useState(!1),q=({value:x})=>{F(x),i?.(x);},ne=()=>{let x=!1,V=Number(d),_=d;typeof S=="number"&&V<S&&(_=S.toString()),typeof g=="number"&&V>g&&(_=g.toString()),_!==d&&(x=!0,i?.(_),F(_),K(x)),x||a?.();};return useEffect(()=>{A&&(a?.(),K(!1));},[a,A]),useEffect(()=>{F(d);},[d]),jsx(NumericFormat,{tabIndex:k,value:j,onPaste:h,prefix:W,suffix:R,fixedDecimalScale:!0,onBlur:ne,"data-testid":y,valueIsNumericString:!0,onFocus:r,onClick:n,decimalScale:L,onValueChange:q,allowNegative:w,decimalSeparator:P,thousandSeparator:E,className:s("h-full w-full rounded-none bg-transparent pl-1 text-xs outline-none",t),disabled:b,"data-cypress":v,autoFocus:!0})}var qo=2;function Jo(e){let{dataEditorType:t,decimalScale:o}=e,r=o;return t.toLowerCase()==="percentage"&&(o?r=o>2?o-qo:0:r=0),o||(t.toLowerCase()==="decimal"&&(r=2),t.toLowerCase()==="float"&&(r=2),t.toLowerCase()==="integer"&&(r=0),t.toLowerCase()==="currency"&&(r=2)),r}function Lt(e){let{value:t,onBlur:o,onChange:r,onPaste:a,setMode:i,column:n}=e,h=useCallback(y=>{y.preventDefault(),a?.();},[a]),l=useCallback(()=>{o?.(),i?.("view");},[o,i]);return jsx(qe,{dataEditorType:n.dataEditorType,value:t,onPaste:h,onBlur:l,onChange:y=>r?.({data:y}),settings:n.settings})}function _t(e){let{value:t,column:o}=e;return jsx(qe,{dataEditorType:o.dataEditorType,value:t,settings:o.settings,disabled:!0,className:"pointer-events-none"})}function Ft(e){let{value:t,onBlur:o,onChange:r,onPaste:a,items:i}=e,n=useCallback(h=>{h.preventDefault(),a?.();},[a]);return jsxs(Ee,{value:t,onValueChange:h=>r?.({data:h}),defaultOpen:!0,children:[jsx(ge,{onBlur:o,onPaste:n,className:s("h-full w-full rounded-none border-none pl-1 text-xs outline-none focus:ring-0"),children:jsx(Re,{placeholder:"Selecionar"})}),jsx(be,{children:i.map(({value:h,text:l})=>jsx(se,{className:"text-xs",value:h,children:l},h))})]})}function Vt(e){let{value:t,items:o}=e,r=useMemo(()=>o.find(i=>i.value===t),[o,t]),a=useMemo(()=>r?r.text:"Selecionar",[r]);return jsxs("div",{className:"flex h-full w-full items-center justify-between pr-px pl-1",children:[jsx("p",{className:"line-clamp-1 text-xs",children:a}),jsx(CaretSortIcon,{className:"h-4 w-4 opacity-50"})]})}function Bt(e){e.selectionStart=e.selectionEnd=e.value.length;}var tr="text/plain";function Wt(e){return window.clipboardData?.getData?window.clipboardData.getData("Text"):e.clipboardData?.getData?e.clipboardData.getData(tr):""}var ar=6,Ot=200;function Gt(e){let{value:t,onBlur:o,onChange:r,onPaste:a,setMode:i,column:n,selected:h}=e,l=t,y=useRef(null),[d,b]=useState(0),v=useMemo(()=>$t(l,n.width),[l,n.width]),k=useCallback(w=>{let S=Wt(w);nr(S)||(w.preventDefault(),a?.());},[a]),E=useCallback(()=>{o?.(),i?.("view");},[o,i]),P=useCallback(()=>{let w=y.current;if(!w)return;let S=w.scrollHeight;w.style.height=`${S}px`,b(S);},[]),L=useCallback(w=>{r?.({data:w.target.value}),P();},[P,r]);return v?jsx("div",{style:{height:d},className:s("-left-0.5 -top-0.5 absolute z-40 h-fit w-fit border bg-white shadow-lg outline outline-2 outline-blue-500",h?"bg-blue-50":"bg-white"),children:jsx("div",{style:{height:d-1},className:"h-full w-full outline outline-[3px] outline-sky-200 outline-offset-2",children:jsx("textarea",{ref:y,onBlur:E,onPaste:k,value:l,onChange:L,className:s("resize-none break-all rounded-none bg-transparent py-1.5 pr-3 pl-1 text-xs outline-none"),onFocus:w=>Bt(w.target),maxLength:Ot,style:{width:n.width},autoFocus:!0})})}):jsx("input",{onBlur:o,onPaste:k,value:l,maxLength:Ot,onChange:L,className:s("h-full w-full bg-transparent pl-1 text-xs outline-none"),autoFocus:!0})}function Xt(e){let{value:t,column:o,selected:r}=e,a=t;return useMemo(()=>$t(a,o.width),[a,o.width])?jsx(Pe,{delayDuration:0,children:jsxs(Ne,{children:[jsx(Me,{className:"w-full",children:jsx("div",{className:"flex h-full w-full items-center overflow-hidden",children:jsx("p",{className:"line-clamp-1 break-all pl-1 text-left text-xs",children:a})})}),jsx(he,{align:"start",side:"bottom",alignOffset:-2,sideOffset:-26,className:s("h-fit w-full break-all rounded-none border bg-white pl-1 text-black shadow-lg","data-[state=closed]:transform-none data-[side=bottom]:animate-none data-[state=closed]:animate-none data-[state=closed]:transition-none",r?"bg-blue-50":"bg-white"),style:{width:o.width},children:jsx("p",{children:a})})]})}):jsx("div",{className:"flex h-full w-full items-center overflow-hidden",children:jsx("p",{className:"line-clamp-1 break-all pl-1 text-left text-xs",title:a,children:a})})}function $t(e,t){return ar*e?.length>t}function nr(e){return [" ",`
|
|
20
|
-
`,"\r"].every(t=>!e.includes(t))}var X={Date:Dt,Text:Gt,Boolean:Nt,Numeric:Lt,Select:Ft},$={Date:Et,Text:Xt,Boolean:Mt,Numeric:_t,Select:Vt};function Yt(e){let{value:t,coordinates:o}=e,{columns:r,isCellSelected:a,onChange:i,onPaste:n,onSelectCell:h}=N(),{dataEditorType:l,readonly:y,width:d,visible:b,settings:v}=r[o.column],[k,E]=useState(y?"readonly":"view"),P=useRef(null),L=useMemo(()=>r[o.column],[r,o.column]),w=useMemo(()=>a(o),[o,a]),S=useMemo(()=>v?.select?.items||[],[v?.select?.items]),g=useMemo(()=>({dataEditor:{value:t,column:L,setMode:E,selected:w,onPaste:()=>n(o),onChange:({data:A})=>i({data:A,point:o})},dataViewer:{value:t,column:L,selected:w}}),[o,t,L,w,n,i]),W=useMemo(()=>({Date:jsx(X.Date,{...g.dataEditor}),String:jsx(X.Text,{...g.dataEditor}),Currency:jsx(X.Numeric,{...g.dataEditor}),Decimal:jsx(X.Numeric,{...g.dataEditor}),Float:jsx(X.Numeric,{...g.dataEditor}),Integer:jsx(X.Numeric,{...g.dataEditor}),Percentage:jsx(X.Numeric,{...g.dataEditor}),Boolean:jsx(X.Boolean,{...g.dataEditor}),Select:jsx(X.Select,{...g.dataEditor,items:S})}),[g.dataEditor,S]),R=useMemo(()=>({Date:jsx($.Date,{...g.dataViewer}),String:jsx($.Text,{...g.dataViewer}),Currency:jsx($.Numeric,{...g.dataViewer}),Decimal:jsx($.Numeric,{...g.dataViewer}),Float:jsx($.Numeric,{...g.dataViewer}),Integer:jsx($.Numeric,{...g.dataViewer}),Percentage:jsx($.Numeric,{...g.dataViewer}),Boolean:jsx($.Boolean,{...g.dataViewer}),Select:jsx($.Select,{...g.dataViewer,items:S})}),[g.dataViewer,S]),j=useMemo(()=>l?W[l]:null,[l,W]),F=useMemo(()=>l?R[l]:null,[l,R]);return useEffect(()=>{let A=K=>{let q=K.code==="Enter";q&&w&&k==="view"&&E("edit"),q&&w&&k==="edit"&&E("view");};return window.addEventListener("keydown",A),()=>window.removeEventListener("keydown",A)},[w,k]),useClickAway(P,()=>E("view")),b?k==="readonly"?jsx("div",{onClick:()=>h(o),className:s("flex h-7 shrink-0 cursor-default select-none border border-t-transparent border-l-transparent bg-[#F6F6F9]",w&&"bg-[#EAF5FF]"),style:{width:d,height:26},children:F}):k==="view"?jsx("div",{onClick:()=>h(o),onDoubleClick:()=>E("edit"),className:s("relative flex h-7 shrink-0 cursor-default select-none border border-t-transparent border-l-transparent",w&&"bg-[#EAF5FF]"),style:{width:d,height:26},children:F}):jsx("div",{ref:P,"data-testid":"cell__testid",className:"relative h-7 w-32 shrink-0 border border-l-transparent border-t-transparent bg-[#EAF5FF] shadow-lg outline outline-2 outline-blue-500",style:{width:d,height:26,top:o.row===0?"4px":"0px"},children:jsx("div",{className:"h-full w-full outline outline-[3px] outline-offset-2 outline-sky-200",children:j})}):null}function Kt({row:e}){let{onSelectRow:t,pointRange:o,matrix:r}=N(),a=useMemo(()=>o&&e>=o.start.row&&e<=o.end.row,[o,e]),i=useMemo(()=>!!(o&&it({matrix:r,pointRange:o,row:e})),[r,o,e]);return jsx("div",{className:s("flex h-7 w-12 shrink-0 cursor-default select-none items-center justify-center border-r border-b text-[#8E8EA9] text-xs",a&&"bg-blue-100 font-bold text-blue-700",i&&"bg-[#0085FF] font-bold text-white"),onClick:n=>t(e,n),style:{height:26},children:e+1})}function qt(){let e=useId(),{highlightLastRow:t,matrix:o}=N();return jsx("div",{className:"relative",children:o.map((r,a)=>jsxs("div",{className:s("flex items-center transition-all ease-linear",a===o.length-1&&t&&"bg-blue-50"),children:[jsx(Kt,{row:a}),r.map((i,n)=>jsx(Yt,{value:i,coordinates:{column:n,row:a}},`spreadsheet__cell__key__${e}__${a}__${n}`))]},`spreadsheet__row__key__${e}__${a}}`))})}function Jt({className:e}){let{staticRows:t,emptySize:o,onInsertNewRow:r}=N();return t?null:jsx("div",{className:s("pointer-events-none mt-[calc(28px+36px)] flex h-[calc(100%-28px-28px)] w-full items-center justify-center",o&&"pointer-events-auto bg-white/25 backdrop-blur-sm",e),children:o&&jsxs("p",{className:"text-neutral-500",children:[jsx("span",{children:"Clique "}),jsx("button",{type:"button",onClick:r,className:"font-bold",children:"AQUI"}),jsx("span",{children:" para come\xE7ar a preencher a tabela."})]})})}function Qt(e){return jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",fill:"none",viewBox:"0 0 20 20",...e,children:jsx("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.5",d:"M10 6.667v6.666M6.667 10h6.666M6.5 17.5h7c1.4 0 2.1 0 2.635-.273a2.5 2.5 0 001.092-1.092c.273-.535.273-1.235.273-2.635v-7c0-1.4 0-2.1-.273-2.635a2.5 2.5 0 00-1.092-1.093C15.6 2.5 14.9 2.5 13.5 2.5h-7c-1.4 0-2.1 0-2.635.272a2.5 2.5 0 00-1.093 1.093C2.5 4.4 2.5 5.1 2.5 6.5v7c0 1.4 0 2.1.272 2.635a2.5 2.5 0 001.093 1.092C4.4 17.5 5.1 17.5 6.5 17.5z"})})}function to(e){return jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",fill:"none",viewBox:"0 0 20 20",...e,children:jsx("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.5",d:"M13.333 5v-.667c0-.933 0-1.4-.181-1.756a1.667 1.667 0 00-.729-.729c-.356-.181-.823-.181-1.756-.181H9.333c-.933 0-1.4 0-1.756.181-.314.16-.569.415-.729.729-.181.356-.181.823-.181 1.756V5m1.666 4.583v4.167m3.334-4.167v4.167M2.5 5h15m-1.667 0v9.333c0 1.4 0 2.1-.272 2.635a2.5 2.5 0 01-1.093 1.093c-.534.272-1.235.272-2.635.272H8.167c-1.4 0-2.1 0-2.635-.272a2.5 2.5 0 01-1.093-1.093c-.272-.535-.272-1.235-.272-2.635V5"})})}var gr=cva("inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50",{variants:{variant:{default:"bg-primary text-primary-foreground shadow hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",outline:"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-md px-3 text-xs",lg:"h-10 rounded-md px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),ve=Q.forwardRef(({className:e,variant:t,size:o,asChild:r=!1,...a},i)=>jsx(r?Slot:"button",{className:s(gr({variant:t,size:o,className:e})),ref:i,...a}));ve.displayName="Button";var ro=u.Root,ao=u.Trigger;var Sr=Q.forwardRef(({className:e,inset:t,children:o,...r},a)=>jsxs(u.SubTrigger,{ref:a,className:s("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[state=open]:bg-accent focus:bg-accent",t&&"pl-8",e),...r,children:[o,jsx(ChevronRightIcon,{className:"ml-auto h-4 w-4"})]}));Sr.displayName=u.SubTrigger.displayName;var Cr=Q.forwardRef(({className:e,...t},o)=>jsx(u.SubContent,{ref:o,className:s("data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=closed]:animate-out data-[state=open]:animate-in",e),...t}));Cr.displayName=u.SubContent.displayName;var Ze=Q.forwardRef(({className:e,sideOffset:t=4,...o},r)=>jsx(u.Portal,{children:jsx(u.Content,{ref:r,sideOffset:t,className:s("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md","data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=open]:animate-in",e),...o})}));Ze.displayName=u.Content.displayName;var kr=Q.forwardRef(({className:e,inset:t,...o},r)=>jsx(u.Item,{ref:r,className:s("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors data-[disabled]:pointer-events-none focus:bg-accent focus:text-accent-foreground data-[disabled]:opacity-50",t&&"pl-8",e),...o}));kr.displayName=u.Item.displayName;var Qe=Q.forwardRef(({className:e,children:t,checked:o,...r},a)=>jsxs(u.CheckboxItem,{ref:a,className:s("relative flex cursor-default select-none items-center rounded-sm py-1.5 pr-2 pl-8 text-sm outline-none transition-colors data-[disabled]:pointer-events-none focus:bg-accent focus:text-accent-foreground data-[disabled]:opacity-50",e),checked:o,...r,children:[jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:jsx(u.ItemIndicator,{children:jsx(CheckIcon,{className:"h-4 w-4"})})}),t]}));Qe.displayName=u.CheckboxItem.displayName;var Pr=Q.forwardRef(({className:e,children:t,...o},r)=>jsxs(u.RadioItem,{ref:r,className:s("relative flex cursor-default select-none items-center rounded-sm py-1.5 pr-2 pl-8 text-sm outline-none transition-colors data-[disabled]:pointer-events-none focus:bg-accent focus:text-accent-foreground data-[disabled]:opacity-50",e),...o,children:[jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:jsx(u.ItemIndicator,{children:jsx(DotFilledIcon,{className:"h-4 w-4 fill-current"})})}),t]}));Pr.displayName=u.RadioItem.displayName;var Nr=Q.forwardRef(({className:e,inset:t,...o},r)=>jsx(u.Label,{ref:r,className:s("px-2 py-1.5 font-semibold text-sm",t&&"pl-8",e),...o}));Nr.displayName=u.Label.displayName;var Mr=Q.forwardRef(({className:e,...t},o)=>jsx(u.Separator,{ref:o,className:s("-mx-1 my-1 h-px bg-muted",e),...t}));Mr.displayName=u.Separator.displayName;function io(){let{hasSomeEntireRow:e,emptySize:t,staticRows:o,columns:r,onInsertNewRow:a,onRemoveRow:i,onColumnVisibilityChange:n}=N(),h=useMemo(()=>r.filter(({visible:v})=>v),[r]),l=useMemo(()=>r.length===h.length,[r.length,h.length]),y="Exibindo todas as colunas",d=`Exibindo ${h.length} de ${r.length} colunas`;return jsxs("div",{className:"sticky top-0 z-50 flex w-full items-center justify-between rounded-t-md border bg-[#EAF5FF] px-4 py-2.5",children:[jsxs("div",{className:"flex items-center gap-6",children:[jsx(ve,{disabled:o,size:"icon",variant:"ghost",onClick:a,className:"text-[#4A4A6A] transition-none active:bg-[#0085FF] hover:bg-[#8FD6FF] active:text-white",children:jsx(Qt,{})}),jsx(ve,{disabled:o||t||!e,size:"icon",variant:"ghost",onClick:i,className:"text-[#4A4A6A] transition-none active:bg-[#0085FF] hover:bg-[#8FD6FF] active:text-white",children:jsx(to,{})})]}),jsxs(ro,{children:[jsx(ao,{asChild:!0,className:"w-56",children:jsxs(ve,{variant:"outline",className:"justify-between px-2",children:[jsx("span",{className:"text-xs",children:l?y:d}),jsx(ChevronDown,{className:"h-4 w-4"})]})}),jsx(Ze,{className:"w-56",children:r.map(({name:v,id:k,alphabetLetter:E,visible:P})=>jsxs(Qe,{checked:P,onCheckedChange:()=>n(k),className:"justify-between text-xs",children:[jsx("span",{children:v}),jsx("span",{className:"text-[10px] text-neutral-500",children:E})]},`spreadsheet__column__dropdown_checkbox__key__${nanoid()}`))})]})]})}function lo(e){let{className:t,...o}=e;return jsx(pt,{...o,children:jsxs(We.Root,{className:t,children:[jsx(io,{}),jsxs(We.Matrix,{children:[jsx(Jt,{className:"absolute z-50"}),jsx(Ct,{}),jsx(qt,{})]})]})})}var xs={Spreadsheet:lo};
|
|
37
|
+
// src/components/spreadsheet/lib/indexed-alphabet.ts
|
|
38
|
+
function indexedAlphabet(columns) {
|
|
39
|
+
if (columns <= 0) {
|
|
40
|
+
return "";
|
|
41
|
+
}
|
|
42
|
+
const asciiA = "A".charCodeAt(0);
|
|
43
|
+
const remainder = (columns - 1) % 26;
|
|
44
|
+
const quotient = Math.floor((columns - 1) / 26);
|
|
45
|
+
return indexedAlphabet(quotient) + String.fromCharCode(asciiA + remainder);
|
|
46
|
+
}
|
|
21
47
|
|
|
22
|
-
|
|
48
|
+
// src/components/spreadsheet/lib/matrix-output.ts
|
|
49
|
+
function matrixConverter(params) {
|
|
50
|
+
const { columns, matrix } = params;
|
|
51
|
+
return matrix.map(
|
|
52
|
+
(rowValue) => rowValue.map((columnValue, column) => {
|
|
53
|
+
const dataEditorType = columns[column].dataEditorType;
|
|
54
|
+
columns[column].settings?.select?.items || [];
|
|
55
|
+
const newColumn = { value: columnValue, dataEditorType };
|
|
56
|
+
if (dataEditorType === "Boolean") {
|
|
57
|
+
newColumn.convertedValue = { Boolean: JSON.parse(columnValue) };
|
|
58
|
+
}
|
|
59
|
+
if (dataEditorType === "Integer") {
|
|
60
|
+
newColumn.convertedValue = { Integer: Number(columnValue) };
|
|
61
|
+
}
|
|
62
|
+
if (dataEditorType === "Currency") {
|
|
63
|
+
newColumn.convertedValue = { Currency: Number(columnValue) };
|
|
64
|
+
}
|
|
65
|
+
if (dataEditorType === "Decimal") {
|
|
66
|
+
newColumn.convertedValue = { Decimal: Number(columnValue) };
|
|
67
|
+
}
|
|
68
|
+
if (dataEditorType === "Float") {
|
|
69
|
+
newColumn.convertedValue = { Float: Number(columnValue) };
|
|
70
|
+
}
|
|
71
|
+
if (dataEditorType === "Percentage") {
|
|
72
|
+
newColumn.convertedValue = { Percentage: Number(columnValue) };
|
|
73
|
+
}
|
|
74
|
+
if (dataEditorType === "Date") {
|
|
75
|
+
newColumn.convertedValue = { Date: Number(columnValue) };
|
|
76
|
+
}
|
|
77
|
+
if (dataEditorType === "Select") {
|
|
78
|
+
newColumn.convertedValue = { Select: columnValue };
|
|
79
|
+
}
|
|
80
|
+
return newColumn;
|
|
81
|
+
})
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// src/components/spreadsheet/lib/date-formatter.ts
|
|
86
|
+
function dateFormatter(value) {
|
|
87
|
+
try {
|
|
88
|
+
if (value.includes("/"))
|
|
89
|
+
return new Date(value.split("/").reverse().join("-")).toISOString().split("T")[0].replace("+", "");
|
|
90
|
+
return new Date(value).toISOString().split("T")[0].replace("+", "");
|
|
91
|
+
} catch (error) {
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// src/components/spreadsheet/model/spreadsheet.ts
|
|
97
|
+
var COLUMN_INITIAL_WIDTH = 160;
|
|
98
|
+
var COLUMN_MAX_WIDTH = 320;
|
|
99
|
+
var COLUMN_MIN_WIDTH = 160;
|
|
100
|
+
var COLUMN_TITLE_INITIAL_HEIGHT = 36;
|
|
101
|
+
var CELL_INITIAL_HEIGHT = 26;
|
|
102
|
+
var NUMERIC_DATA_EDITOR_TYPES = [
|
|
103
|
+
"Decimal",
|
|
104
|
+
"Float",
|
|
105
|
+
"Integer",
|
|
106
|
+
"Percentage",
|
|
107
|
+
"Currency"
|
|
108
|
+
];
|
|
109
|
+
|
|
110
|
+
// src/components/spreadsheet/lib/normalize-value.ts
|
|
111
|
+
function normalizeValue(params) {
|
|
112
|
+
const { value, dataEditorType } = params;
|
|
113
|
+
if (dataEditorType === "Date") {
|
|
114
|
+
return dateFormatter(value) || "";
|
|
115
|
+
}
|
|
116
|
+
if (dataEditorType === "Boolean") {
|
|
117
|
+
return value === true ? "true" : "false";
|
|
118
|
+
}
|
|
119
|
+
const isNumeric = NUMERIC_DATA_EDITOR_TYPES.includes(dataEditorType);
|
|
120
|
+
if (isNumeric) {
|
|
121
|
+
return Number.isNaN(Number(value)) ? "" : value;
|
|
122
|
+
}
|
|
123
|
+
return value;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// src/components/spreadsheet/model/matrix.ts
|
|
127
|
+
function createEmpty(size, fill) {
|
|
128
|
+
return new Array(size.rows).fill(void 0).map(() => new Array(size.columns).fill(fill));
|
|
129
|
+
}
|
|
130
|
+
function getRowsCount(matrix) {
|
|
131
|
+
return matrix?.length;
|
|
132
|
+
}
|
|
133
|
+
function getColumnsCount(matrix) {
|
|
134
|
+
const firstRow = matrix?.[0];
|
|
135
|
+
return firstRow ? firstRow.length : 0;
|
|
136
|
+
}
|
|
137
|
+
function getSize(matrix) {
|
|
138
|
+
return {
|
|
139
|
+
columns: getColumnsCount(matrix),
|
|
140
|
+
rows: getRowsCount(matrix)
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
function hasPointInRange(pointRange, point) {
|
|
144
|
+
return point.row >= pointRange.start.row && point.column >= pointRange.start.column && point.row <= pointRange.end.row && point.column <= pointRange.end.column;
|
|
145
|
+
}
|
|
146
|
+
function hasEntireColumns(params) {
|
|
147
|
+
const { matrix, pointRange } = params;
|
|
148
|
+
return pointRange.start.column === 0 && pointRange.end.column === getColumnsCount(matrix);
|
|
149
|
+
}
|
|
150
|
+
function hasEntireRows(params) {
|
|
151
|
+
const { matrix, pointRange, row } = params;
|
|
152
|
+
return row >= pointRange.start.row && row <= pointRange.end.row && hasEntireColumns({ matrix, pointRange });
|
|
153
|
+
}
|
|
154
|
+
function parseString(value) {
|
|
155
|
+
return value.split("\n").map((row) => row.split(" "));
|
|
156
|
+
}
|
|
157
|
+
function overlap(params) {
|
|
158
|
+
const { mA, mB, point = { column: 0, row: 0 } } = params;
|
|
159
|
+
const mASize = getSize(mA);
|
|
160
|
+
const mBSize = getSize(mB);
|
|
161
|
+
const fillRows = point.row + mBSize.rows > mASize.rows;
|
|
162
|
+
const fillColumns = point.column + mBSize.columns > mBSize.columns;
|
|
163
|
+
const rows = fillRows ? point.row + mBSize.rows : mASize.rows;
|
|
164
|
+
const columns = fillColumns ? point.column + mBSize.columns : mASize.columns;
|
|
165
|
+
const mC = createEmpty({ rows, columns });
|
|
166
|
+
for (let y = 0; y < mASize.rows; y += 1) {
|
|
167
|
+
for (let x = 0; x < mASize.columns; x += 1) {
|
|
168
|
+
mC[y][x] = mA[y][x];
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
for (let y = 0; y < mBSize.rows; y += 1) {
|
|
172
|
+
for (let x = 0; x < mBSize.columns; x += 1) {
|
|
173
|
+
mC[y + point.row][x + point.column] = mB[y][x];
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
return mC;
|
|
177
|
+
}
|
|
178
|
+
var timeoutId;
|
|
179
|
+
var SpreadsheetContext = createContext(null);
|
|
180
|
+
function SpreadsheetContextProvider(props) {
|
|
181
|
+
const {
|
|
182
|
+
children,
|
|
183
|
+
startingColumns,
|
|
184
|
+
matrix: startingMatrix = [],
|
|
185
|
+
staticRows,
|
|
186
|
+
onMatrixChange
|
|
187
|
+
} = props;
|
|
188
|
+
const [matrix, setMatrix] = useState(startingMatrix);
|
|
189
|
+
const [columns, setColumns] = useState(() => setupColumns(startingColumns));
|
|
190
|
+
const [pointRange, setPointRange] = useState(null);
|
|
191
|
+
const [containerDimensions, setContainerDimensions] = useState({
|
|
192
|
+
height: 0,
|
|
193
|
+
width: 0
|
|
194
|
+
});
|
|
195
|
+
const [highlightLastRow, setHighlightLastRow] = useState(false);
|
|
196
|
+
const highlight = useCallback((ms = 2e3) => {
|
|
197
|
+
setHighlightLastRow(true);
|
|
198
|
+
if (timeoutId) {
|
|
199
|
+
clearTimeout(timeoutId);
|
|
200
|
+
}
|
|
201
|
+
timeoutId = setTimeout(() => setHighlightLastRow(false), ms);
|
|
202
|
+
}, []);
|
|
203
|
+
const columnsCount = useMemo$1(
|
|
204
|
+
() => getColumnsCount(matrix) || columns.length,
|
|
205
|
+
[matrix, columns.length]
|
|
206
|
+
);
|
|
207
|
+
const size = useMemo$1(() => getSize(matrix), [matrix]);
|
|
208
|
+
const emptySize = useMemo$1(() => size.rows === 0, [size.rows]);
|
|
209
|
+
const hasSomeEntireRow = useMemo$1(
|
|
210
|
+
() => !!(pointRange && hasEntireColumns({ matrix, pointRange })),
|
|
211
|
+
[pointRange, matrix]
|
|
212
|
+
);
|
|
213
|
+
const onConvertedMatrixChange = useCallback(
|
|
214
|
+
(matrix2) => {
|
|
215
|
+
if (onMatrixChange) {
|
|
216
|
+
const newMatrix = matrixConverter({ columns, matrix: matrix2 });
|
|
217
|
+
onMatrixChange(newMatrix);
|
|
218
|
+
}
|
|
219
|
+
},
|
|
220
|
+
[onMatrixChange, columns]
|
|
221
|
+
);
|
|
222
|
+
const onPaste = useCallback(
|
|
223
|
+
async (point) => {
|
|
224
|
+
const { state } = await navigator.permissions.query({
|
|
225
|
+
name: "clipboard-read"
|
|
226
|
+
});
|
|
227
|
+
if (state === "denied") {
|
|
228
|
+
console.log("denied");
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
const value2 = await navigator.clipboard.readText();
|
|
232
|
+
const mB = parseString(value2);
|
|
233
|
+
const overlapped = overlap({ mA: matrix, mB, point }).map(
|
|
234
|
+
(row) => row.map((columnValue, column) => columns[column]?.readonly ? "" : columnValue)
|
|
235
|
+
);
|
|
236
|
+
const normalized = overlapped.map(
|
|
237
|
+
(row) => row.map(
|
|
238
|
+
(columnValue, column) => normalizeValue({ value: columnValue, dataEditorType: columns[column]?.dataEditorType })
|
|
239
|
+
)
|
|
240
|
+
);
|
|
241
|
+
const nextColumns = normalized.map((row) => row.slice(0, startingColumns.length));
|
|
242
|
+
const nextMatrix = staticRows ? nextColumns.slice(0, matrix.length) : nextColumns;
|
|
243
|
+
setMatrix(nextMatrix);
|
|
244
|
+
onConvertedMatrixChange(nextMatrix);
|
|
245
|
+
},
|
|
246
|
+
[columns, matrix, startingColumns.length, onConvertedMatrixChange, staticRows]
|
|
247
|
+
);
|
|
248
|
+
const onChange = useCallback(
|
|
249
|
+
(params) => {
|
|
250
|
+
const { data, point } = params;
|
|
251
|
+
const { column, row } = point;
|
|
252
|
+
const nextMatrix = structuredClone(matrix);
|
|
253
|
+
nextMatrix[row][column] = data;
|
|
254
|
+
setMatrix(nextMatrix);
|
|
255
|
+
onConvertedMatrixChange(nextMatrix);
|
|
256
|
+
},
|
|
257
|
+
[matrix, onConvertedMatrixChange]
|
|
258
|
+
);
|
|
259
|
+
const onRemoveRow = useCallback(() => {
|
|
260
|
+
if (pointRange && !staticRows) {
|
|
261
|
+
const rowStart = pointRange.start.row;
|
|
262
|
+
const rowEnd = pointRange.end.row;
|
|
263
|
+
const delta = rowEnd - rowStart + 1;
|
|
264
|
+
if (!hasSomeEntireRow)
|
|
265
|
+
return;
|
|
266
|
+
const confirmedMessage = delta > 1 ? `Voc\xEA ir\xE1 excluir ${delta} linhas, deseja continuar?
|
|
267
|
+
Linha N\xB0 ${rowStart + 1} at\xE9 N\xB0 ${rowEnd + 1}` : `Voc\xEA ir\xE1 excluir a linha N\xB0 ${rowStart + 1}, deseja continuar?`;
|
|
268
|
+
const confirmed = confirm(confirmedMessage);
|
|
269
|
+
if (!confirmed)
|
|
270
|
+
return;
|
|
271
|
+
const nextMatrix = matrix.filter((row, index) => index < rowStart || index > rowEnd);
|
|
272
|
+
setPointRange(null);
|
|
273
|
+
setMatrix(nextMatrix);
|
|
274
|
+
onConvertedMatrixChange(nextMatrix);
|
|
275
|
+
}
|
|
276
|
+
}, [matrix, pointRange, staticRows, hasSomeEntireRow, onConvertedMatrixChange]);
|
|
277
|
+
const onSelectRow = useCallback(
|
|
278
|
+
(row, event) => {
|
|
279
|
+
if (pointRange && event && event.shiftKey) {
|
|
280
|
+
const normalizedStart = row < pointRange.start.row ? row : pointRange.start.row;
|
|
281
|
+
const normalizedEnd = row < pointRange.start.row ? pointRange.start.row : row;
|
|
282
|
+
const newPointRange = {
|
|
283
|
+
start: { row: normalizedStart, column: 0 },
|
|
284
|
+
end: { row: normalizedEnd, column: columnsCount }
|
|
285
|
+
};
|
|
286
|
+
return setPointRange(newPointRange);
|
|
287
|
+
}
|
|
288
|
+
setPointRange({ start: { row, column: 0 }, end: { row, column: columnsCount } });
|
|
289
|
+
},
|
|
290
|
+
[columnsCount, pointRange]
|
|
291
|
+
);
|
|
292
|
+
const onSelectCell = useCallback(
|
|
293
|
+
(point) => {
|
|
294
|
+
if (point.row === pointRange?.start.row && point.column === pointRange.start.column)
|
|
295
|
+
return;
|
|
296
|
+
setPointRange({ start: point, end: point });
|
|
297
|
+
},
|
|
298
|
+
[pointRange?.start.row, pointRange?.start.column]
|
|
299
|
+
);
|
|
300
|
+
const isCellSelected = useCallback(
|
|
301
|
+
(point) => {
|
|
302
|
+
return !!(pointRange && hasPointInRange(pointRange, point));
|
|
303
|
+
},
|
|
304
|
+
[pointRange]
|
|
305
|
+
);
|
|
306
|
+
const onColumnResize = useCallback((params) => {
|
|
307
|
+
const { columnId, width } = params;
|
|
308
|
+
let newWidth = width;
|
|
309
|
+
if (width > COLUMN_MAX_WIDTH) {
|
|
310
|
+
newWidth = COLUMN_MAX_WIDTH;
|
|
311
|
+
}
|
|
312
|
+
if (width < COLUMN_MIN_WIDTH) {
|
|
313
|
+
newWidth = COLUMN_MIN_WIDTH;
|
|
314
|
+
}
|
|
315
|
+
setColumns(
|
|
316
|
+
(previous) => previous.map((column) => column.id === columnId ? { ...column, width: newWidth } : column)
|
|
317
|
+
);
|
|
318
|
+
}, []);
|
|
319
|
+
const onInsertNewRow = useCallback(() => {
|
|
320
|
+
if (staticRows)
|
|
321
|
+
return;
|
|
322
|
+
const nextMatrix = [...structuredClone(matrix), new Array(columnsCount).fill("")];
|
|
323
|
+
setMatrix(nextMatrix);
|
|
324
|
+
onConvertedMatrixChange(nextMatrix);
|
|
325
|
+
highlight();
|
|
326
|
+
}, [staticRows, matrix, columnsCount, highlight, onConvertedMatrixChange]);
|
|
327
|
+
const onSelectSpreadsheet = useCallback(() => {
|
|
328
|
+
const start = { column: 0, row: 0 };
|
|
329
|
+
const end = { column: size.columns, row: size.rows - 1 };
|
|
330
|
+
setPointRange({ start, end });
|
|
331
|
+
}, [size]);
|
|
332
|
+
const onColumnVisibilityChange = useCallback((columnId) => {
|
|
333
|
+
setColumns(
|
|
334
|
+
(previous) => previous.map(
|
|
335
|
+
(column) => column.id === columnId ? { ...column, visible: !column.visible } : column
|
|
336
|
+
)
|
|
337
|
+
);
|
|
338
|
+
}, []);
|
|
339
|
+
useEffect(() => {
|
|
340
|
+
setMatrix(startingMatrix);
|
|
341
|
+
}, [startingMatrix]);
|
|
342
|
+
useEffect(() => {
|
|
343
|
+
setColumns(() => setupColumns(startingColumns));
|
|
344
|
+
}, [startingColumns]);
|
|
345
|
+
const value = useMemo$1(
|
|
346
|
+
() => ({
|
|
347
|
+
size,
|
|
348
|
+
matrix,
|
|
349
|
+
columns,
|
|
350
|
+
emptySize,
|
|
351
|
+
staticRows,
|
|
352
|
+
hasSomeEntireRow,
|
|
353
|
+
highlightLastRow,
|
|
354
|
+
pointRange,
|
|
355
|
+
setPointRange,
|
|
356
|
+
containerDimensions,
|
|
357
|
+
setContainerDimensions,
|
|
358
|
+
onPaste,
|
|
359
|
+
onChange,
|
|
360
|
+
onRemoveRow,
|
|
361
|
+
onSelectRow,
|
|
362
|
+
onSelectCell,
|
|
363
|
+
isCellSelected,
|
|
364
|
+
onInsertNewRow,
|
|
365
|
+
onColumnResize,
|
|
366
|
+
onSelectSpreadsheet,
|
|
367
|
+
onColumnVisibilityChange
|
|
368
|
+
}),
|
|
369
|
+
[
|
|
370
|
+
size,
|
|
371
|
+
matrix,
|
|
372
|
+
columns,
|
|
373
|
+
emptySize,
|
|
374
|
+
staticRows,
|
|
375
|
+
hasSomeEntireRow,
|
|
376
|
+
highlightLastRow,
|
|
377
|
+
pointRange,
|
|
378
|
+
containerDimensions,
|
|
379
|
+
onPaste,
|
|
380
|
+
onChange,
|
|
381
|
+
onRemoveRow,
|
|
382
|
+
onSelectRow,
|
|
383
|
+
onSelectCell,
|
|
384
|
+
isCellSelected,
|
|
385
|
+
onInsertNewRow,
|
|
386
|
+
onColumnResize,
|
|
387
|
+
onSelectSpreadsheet,
|
|
388
|
+
onColumnVisibilityChange
|
|
389
|
+
]
|
|
390
|
+
);
|
|
391
|
+
return /* @__PURE__ */ jsx(SpreadsheetContext.Provider, { value, children });
|
|
392
|
+
}
|
|
393
|
+
function setupColumns(columns) {
|
|
394
|
+
return columns.map((column, index) => ({
|
|
395
|
+
...column,
|
|
396
|
+
id: `spreadsheet__column__id__${nanoid()}`,
|
|
397
|
+
alphabetLetter: indexedAlphabet(index + 1),
|
|
398
|
+
position: index,
|
|
399
|
+
width: column.width || COLUMN_INITIAL_WIDTH,
|
|
400
|
+
visible: true
|
|
401
|
+
}));
|
|
402
|
+
}
|
|
403
|
+
function useSpreadsheet() {
|
|
404
|
+
const context = useContext(SpreadsheetContext);
|
|
405
|
+
if (!context) {
|
|
406
|
+
throw new Error("useSpreadsheet has to be used within <SpreadsheetContext.Provider>");
|
|
407
|
+
}
|
|
408
|
+
return context;
|
|
409
|
+
}
|
|
410
|
+
function cn(...inputs) {
|
|
411
|
+
return twMerge(clsx(inputs));
|
|
412
|
+
}
|
|
413
|
+
function Matrix(props) {
|
|
414
|
+
const { children, className } = props;
|
|
415
|
+
const { size, staticRows, setContainerDimensions } = useSpreadsheet();
|
|
416
|
+
const containerRef = useRef(null);
|
|
417
|
+
const height = useMemo$1(
|
|
418
|
+
() => size.rows * CELL_INITIAL_HEIGHT + COLUMN_TITLE_INITIAL_HEIGHT,
|
|
419
|
+
[size.rows]
|
|
420
|
+
);
|
|
421
|
+
useEffect(() => {
|
|
422
|
+
const containerElement = containerRef.current;
|
|
423
|
+
if (!containerElement)
|
|
424
|
+
return;
|
|
425
|
+
const resizeObserver = new ResizeObserver((entries) => {
|
|
426
|
+
const entry = entries[0];
|
|
427
|
+
if (entry) {
|
|
428
|
+
const width = entry.contentRect.width;
|
|
429
|
+
const height2 = entry.contentRect.height;
|
|
430
|
+
setContainerDimensions({ height: height2, width });
|
|
431
|
+
}
|
|
432
|
+
});
|
|
433
|
+
resizeObserver.observe(containerElement);
|
|
434
|
+
return () => {
|
|
435
|
+
resizeObserver.disconnect();
|
|
436
|
+
};
|
|
437
|
+
}, [setContainerDimensions]);
|
|
438
|
+
return /* @__PURE__ */ jsx(
|
|
439
|
+
"div",
|
|
440
|
+
{
|
|
441
|
+
ref: containerRef,
|
|
442
|
+
className: cn(
|
|
443
|
+
"relative w-full border border-t-0 border-r-0",
|
|
444
|
+
size.rows >= 7 ? "border-b-0" : "border-b",
|
|
445
|
+
staticRows ? `${height}px border-b-0` : "min-h-[260px]",
|
|
446
|
+
className
|
|
447
|
+
),
|
|
448
|
+
children
|
|
449
|
+
}
|
|
450
|
+
);
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
// node_modules/react-use/esm/misc/util.js
|
|
454
|
+
function on(obj) {
|
|
455
|
+
var args = [];
|
|
456
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
457
|
+
args[_i - 1] = arguments[_i];
|
|
458
|
+
}
|
|
459
|
+
if (obj && obj.addEventListener) {
|
|
460
|
+
obj.addEventListener.apply(obj, args);
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
function off(obj) {
|
|
464
|
+
var args = [];
|
|
465
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
466
|
+
args[_i - 1] = arguments[_i];
|
|
467
|
+
}
|
|
468
|
+
if (obj && obj.removeEventListener) {
|
|
469
|
+
obj.removeEventListener.apply(obj, args);
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
var defaultEvents = ["mousedown", "touchstart"];
|
|
473
|
+
var useClickAway = function(ref, onClickAway, events) {
|
|
474
|
+
if (events === void 0) {
|
|
475
|
+
events = defaultEvents;
|
|
476
|
+
}
|
|
477
|
+
var savedCallback = useRef(onClickAway);
|
|
478
|
+
useEffect(function() {
|
|
479
|
+
savedCallback.current = onClickAway;
|
|
480
|
+
}, [onClickAway]);
|
|
481
|
+
useEffect(function() {
|
|
482
|
+
var handler = function(event) {
|
|
483
|
+
var el = ref.current;
|
|
484
|
+
el && !el.contains(event.target) && savedCallback.current(event);
|
|
485
|
+
};
|
|
486
|
+
for (var _i = 0, events_1 = events; _i < events_1.length; _i++) {
|
|
487
|
+
var eventName = events_1[_i];
|
|
488
|
+
on(document, eventName, handler);
|
|
489
|
+
}
|
|
490
|
+
return function() {
|
|
491
|
+
for (var _i2 = 0, events_2 = events; _i2 < events_2.length; _i2++) {
|
|
492
|
+
var eventName2 = events_2[_i2];
|
|
493
|
+
off(document, eventName2, handler);
|
|
494
|
+
}
|
|
495
|
+
};
|
|
496
|
+
}, [events, ref]);
|
|
497
|
+
};
|
|
498
|
+
var useClickAway_default = useClickAway;
|
|
499
|
+
function Root(props) {
|
|
500
|
+
const { children, className } = props;
|
|
501
|
+
const { setPointRange } = useSpreadsheet();
|
|
502
|
+
const rootRef = useRef(null);
|
|
503
|
+
useClickAway_default(rootRef, () => setPointRange(null));
|
|
504
|
+
return /* @__PURE__ */ jsx("div", { ref: rootRef, className: cn("min-w-[640px]", className), children });
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
// src/components/spreadsheet/ui/containers/index.ts
|
|
508
|
+
var Container = {
|
|
509
|
+
Matrix,
|
|
510
|
+
Root
|
|
511
|
+
};
|
|
512
|
+
function DragIndicator(props) {
|
|
513
|
+
const { className, ...rest } = props;
|
|
514
|
+
return /* @__PURE__ */ jsx(
|
|
515
|
+
"button",
|
|
516
|
+
{
|
|
517
|
+
draggable: true,
|
|
518
|
+
className: cn(
|
|
519
|
+
"h-9 w-1.5 cursor-col-resize rounded-sm bg-neutral-400 drop-shadow-md",
|
|
520
|
+
className
|
|
521
|
+
),
|
|
522
|
+
...rest,
|
|
523
|
+
children: /* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
524
|
+
/* @__PURE__ */ jsx("span", { className: "-translate-y-1/2 absolute top-1/2 right-2.5 h-3 w-1 rounded-full bg-neutral-300" }),
|
|
525
|
+
/* @__PURE__ */ jsx("span", { className: "-translate-y-1/2 absolute top-1/2 left-2.5 h-3 w-1 rounded-full bg-neutral-300" })
|
|
526
|
+
] })
|
|
527
|
+
}
|
|
528
|
+
);
|
|
529
|
+
}
|
|
530
|
+
function ColumnIndicator(props) {
|
|
531
|
+
const { className, column, children } = props;
|
|
532
|
+
const { id, width, position, visible, alphabetLetter } = column;
|
|
533
|
+
const { matrix, pointRange, containerDimensions, onColumnResize } = useSpreadsheet();
|
|
534
|
+
const rulerIndicatorRef = useRef(null);
|
|
535
|
+
const rulerIndicatorHeight = useMemo$1(
|
|
536
|
+
() => (containerDimensions?.height || 0) + 32,
|
|
537
|
+
[containerDimensions?.height]
|
|
538
|
+
);
|
|
539
|
+
const [dragging, setDragging] = useState(false);
|
|
540
|
+
const [startClientX, setStartClientX] = useState(0);
|
|
541
|
+
const [clientX, setClientX] = useState(0);
|
|
542
|
+
const difference = useMemo$1(
|
|
543
|
+
() => dragging ? clientX - startClientX : 0,
|
|
544
|
+
[dragging, clientX, startClientX]
|
|
545
|
+
);
|
|
546
|
+
const onDragStart = useCallback((e) => {
|
|
547
|
+
setStartClientX(e.clientX);
|
|
548
|
+
setDragging(true);
|
|
549
|
+
}, []);
|
|
550
|
+
const onDrag = useCallback(
|
|
551
|
+
(e) => {
|
|
552
|
+
const rulerIndicatorElement = rulerIndicatorRef.current;
|
|
553
|
+
if (!rulerIndicatorElement)
|
|
554
|
+
return;
|
|
555
|
+
const difference2 = e.clientX - startClientX;
|
|
556
|
+
let newWidth = width + difference2;
|
|
557
|
+
if (newWidth > COLUMN_MAX_WIDTH)
|
|
558
|
+
newWidth = COLUMN_MAX_WIDTH;
|
|
559
|
+
if (newWidth < COLUMN_MIN_WIDTH)
|
|
560
|
+
newWidth = COLUMN_MIN_WIDTH;
|
|
561
|
+
rulerIndicatorElement.style.left = `${newWidth}px`;
|
|
562
|
+
setClientX(e.clientX);
|
|
563
|
+
},
|
|
564
|
+
[startClientX, width]
|
|
565
|
+
);
|
|
566
|
+
const onDragEnd = useCallback(
|
|
567
|
+
(e) => {
|
|
568
|
+
const difference2 = e.clientX - startClientX;
|
|
569
|
+
const nextWidth = width + difference2;
|
|
570
|
+
onColumnResize({ width: nextWidth, columnId: id });
|
|
571
|
+
setDragging(false);
|
|
572
|
+
},
|
|
573
|
+
[startClientX, width, id, onColumnResize]
|
|
574
|
+
);
|
|
575
|
+
const createClassName = useCallback(() => {
|
|
576
|
+
if (dragging)
|
|
577
|
+
return `bg-neutral-100 font-bold text-neutral-700 ${className}`;
|
|
578
|
+
if (pointRange && !dragging) {
|
|
579
|
+
const { start, end } = pointRange;
|
|
580
|
+
const hasEntireColumns2 = hasEntireColumns({ matrix, pointRange });
|
|
581
|
+
const columnInRange = position >= start.column && position <= end.column;
|
|
582
|
+
if (hasEntireColumns2)
|
|
583
|
+
return `bg-[#0085FF] font-bold text-white ${className}`;
|
|
584
|
+
if (columnInRange)
|
|
585
|
+
return `bg-blue-100 font-bold text-blue-700 ${className}`;
|
|
586
|
+
}
|
|
587
|
+
return className;
|
|
588
|
+
}, [dragging, className, matrix, pointRange, position]);
|
|
589
|
+
const rulerIndicatorToPx = useCallback(() => {
|
|
590
|
+
let newWidth = width + difference;
|
|
591
|
+
if (newWidth > COLUMN_MAX_WIDTH)
|
|
592
|
+
newWidth = COLUMN_MAX_WIDTH;
|
|
593
|
+
if (newWidth < COLUMN_MIN_WIDTH)
|
|
594
|
+
newWidth = COLUMN_MIN_WIDTH;
|
|
595
|
+
return `${newWidth}px`;
|
|
596
|
+
}, [width, difference]);
|
|
597
|
+
const dragEventListeners = useMemo$1(
|
|
598
|
+
() => ({ onDragStart, onDrag, onDragEnd }),
|
|
599
|
+
[onDragStart, onDrag, onDragEnd]
|
|
600
|
+
);
|
|
601
|
+
useEffect(() => {
|
|
602
|
+
const rulerIndicatorElement = rulerIndicatorRef.current;
|
|
603
|
+
if (!rulerIndicatorElement)
|
|
604
|
+
return;
|
|
605
|
+
rulerIndicatorElement.style.left = `${width}px`;
|
|
606
|
+
}, [width]);
|
|
607
|
+
if (!visible)
|
|
608
|
+
return null;
|
|
609
|
+
return /* @__PURE__ */ jsxs(
|
|
610
|
+
"div",
|
|
611
|
+
{
|
|
612
|
+
style: { width },
|
|
613
|
+
className: cn(
|
|
614
|
+
"relative flex h-7 w-32 shrink-0 items-center justify-center border border-t-0 border-l-0 text-[#8E8EA9] text-xs",
|
|
615
|
+
createClassName()
|
|
616
|
+
),
|
|
617
|
+
children: [
|
|
618
|
+
/* @__PURE__ */ jsx(
|
|
619
|
+
DragIndicator,
|
|
620
|
+
{
|
|
621
|
+
...dragEventListeners,
|
|
622
|
+
className: cn(
|
|
623
|
+
"-right-[3px] -top-1 absolute z-50 opacity-0 hover:opacity-100",
|
|
624
|
+
dragging && "opacity-0"
|
|
625
|
+
)
|
|
626
|
+
}
|
|
627
|
+
),
|
|
628
|
+
/* @__PURE__ */ jsx(
|
|
629
|
+
"div",
|
|
630
|
+
{
|
|
631
|
+
ref: rulerIndicatorRef,
|
|
632
|
+
style: { height: rulerIndicatorHeight },
|
|
633
|
+
className: cn(
|
|
634
|
+
"-top-4 pointer-events-none absolute z-50 h-full w-1.5 rounded-full bg-blue-400 shadow-lg outline outline-sky-100",
|
|
635
|
+
dragging ? "opacity-100" : "opacity-0"
|
|
636
|
+
),
|
|
637
|
+
children: /* @__PURE__ */ jsx("span", { className: "-translate-y-1/2 relative top-8 left-4 z-50 select-none rounded-md border bg-white p-1 font-semibold drop-shadow-md", children: rulerIndicatorToPx() })
|
|
638
|
+
}
|
|
639
|
+
),
|
|
640
|
+
/* @__PURE__ */ jsx("span", { children: children || alphabetLetter })
|
|
641
|
+
]
|
|
642
|
+
}
|
|
643
|
+
);
|
|
644
|
+
}
|
|
645
|
+
function IntegerIcon(props) {
|
|
646
|
+
return /* @__PURE__ */ jsxs(
|
|
647
|
+
"svg",
|
|
648
|
+
{
|
|
649
|
+
stroke: "currentColor",
|
|
650
|
+
fill: "currentColor",
|
|
651
|
+
strokeWidth: "0",
|
|
652
|
+
viewBox: "0 0 24 24",
|
|
653
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
654
|
+
...props,
|
|
655
|
+
children: [
|
|
656
|
+
/* @__PURE__ */ jsx("title", { children: "Integer" }),
|
|
657
|
+
/* @__PURE__ */ jsx("path", { d: "M13.003 7.754a.75.75 0 0 1 .75-.75h5.232a.75.75 0 0 1 .53 1.28l-2.776 2.777c.55.097 1.057.253 1.492.483.905.477 1.504 1.284 1.504 2.418 0 .966-.471 1.75-1.172 2.27-.687.511-1.587.77-2.521.77-1.367 0-2.274-.528-2.667-.756a.75.75 0 0 1 .755-1.297c.331.193.953.553 1.912.553.673 0 1.243-.188 1.627-.473.37-.275.566-.635.566-1.067 0-.5-.219-.836-.703-1.091-.538-.284-1.375-.443-2.471-.443a.75.75 0 0 1-.53-1.28l2.643-2.644h-3.421a.75.75 0 0 1-.75-.75ZM7.88 15.215a1.4 1.4 0 0 0-1.446.83.75.75 0 0 1-1.37-.61 2.899 2.899 0 0 1 2.986-1.71c.589.06 1.139.323 1.557.743.434.446.685 1.058.685 1.778 0 1.641-1.254 2.437-2.12 2.986-.538.341-1.18.694-1.495 1.273H9.75a.75.75 0 0 1 0 1.5h-4a.75.75 0 0 1-.75-.75c0-1.799 1.337-2.63 2.243-3.21 1.032-.659 1.55-1.031 1.55-1.8 0-.355-.116-.584-.26-.732a1.071 1.071 0 0 0-.652-.298Zm.234-13.121a.75.75 0 0 1 .386.656V9h1.252a.75.75 0 0 1 0 1.5H5.75a.75.75 0 0 1 0-1.5H7V4.103l-.853.533a.749.749 0 1 1-.795-1.272l2-1.25a.749.749 0 0 1 .762-.02Z" })
|
|
658
|
+
]
|
|
659
|
+
}
|
|
660
|
+
);
|
|
661
|
+
}
|
|
662
|
+
var $5e63c961fc1ce211$export$8c6ed5c666ac1360 = /* @__PURE__ */ forwardRef((props, forwardedRef) => {
|
|
663
|
+
const { children, ...slotProps } = props;
|
|
664
|
+
const childrenArray = Children.toArray(children);
|
|
665
|
+
const slottable = childrenArray.find($5e63c961fc1ce211$var$isSlottable);
|
|
666
|
+
if (slottable) {
|
|
667
|
+
const newElement = slottable.props.children;
|
|
668
|
+
const newChildren = childrenArray.map((child) => {
|
|
669
|
+
if (child === slottable) {
|
|
670
|
+
if (Children.count(newElement) > 1)
|
|
671
|
+
return Children.only(null);
|
|
672
|
+
return /* @__PURE__ */ isValidElement(newElement) ? newElement.props.children : null;
|
|
673
|
+
} else
|
|
674
|
+
return child;
|
|
675
|
+
});
|
|
676
|
+
return /* @__PURE__ */ createElement($5e63c961fc1ce211$var$SlotClone, $01b9c$babelruntimehelpersesmextends({}, slotProps, {
|
|
677
|
+
ref: forwardedRef
|
|
678
|
+
}), /* @__PURE__ */ isValidElement(newElement) ? /* @__PURE__ */ cloneElement(newElement, void 0, newChildren) : null);
|
|
679
|
+
}
|
|
680
|
+
return /* @__PURE__ */ createElement($5e63c961fc1ce211$var$SlotClone, $01b9c$babelruntimehelpersesmextends({}, slotProps, {
|
|
681
|
+
ref: forwardedRef
|
|
682
|
+
}), children);
|
|
683
|
+
});
|
|
684
|
+
$5e63c961fc1ce211$export$8c6ed5c666ac1360.displayName = "Slot";
|
|
685
|
+
var $5e63c961fc1ce211$var$SlotClone = /* @__PURE__ */ forwardRef((props, forwardedRef) => {
|
|
686
|
+
const { children, ...slotProps } = props;
|
|
687
|
+
if (/* @__PURE__ */ isValidElement(children))
|
|
688
|
+
return /* @__PURE__ */ cloneElement(children, {
|
|
689
|
+
...$5e63c961fc1ce211$var$mergeProps(slotProps, children.props),
|
|
690
|
+
ref: forwardedRef ? composeRefs(forwardedRef, children.ref) : children.ref
|
|
691
|
+
});
|
|
692
|
+
return Children.count(children) > 1 ? Children.only(null) : null;
|
|
693
|
+
});
|
|
694
|
+
$5e63c961fc1ce211$var$SlotClone.displayName = "SlotClone";
|
|
695
|
+
var $5e63c961fc1ce211$export$d9f1ccf0bdb05d45 = ({ children }) => {
|
|
696
|
+
return /* @__PURE__ */ createElement(Fragment, null, children);
|
|
697
|
+
};
|
|
698
|
+
function $5e63c961fc1ce211$var$isSlottable(child) {
|
|
699
|
+
return /* @__PURE__ */ isValidElement(child) && child.type === $5e63c961fc1ce211$export$d9f1ccf0bdb05d45;
|
|
700
|
+
}
|
|
701
|
+
function $5e63c961fc1ce211$var$mergeProps(slotProps, childProps) {
|
|
702
|
+
const overrideProps = {
|
|
703
|
+
...childProps
|
|
704
|
+
};
|
|
705
|
+
for (const propName in childProps) {
|
|
706
|
+
const slotPropValue = slotProps[propName];
|
|
707
|
+
const childPropValue = childProps[propName];
|
|
708
|
+
const isHandler = /^on[A-Z]/.test(propName);
|
|
709
|
+
if (isHandler) {
|
|
710
|
+
if (slotPropValue && childPropValue)
|
|
711
|
+
overrideProps[propName] = (...args) => {
|
|
712
|
+
childPropValue(...args);
|
|
713
|
+
slotPropValue(...args);
|
|
714
|
+
};
|
|
715
|
+
else if (slotPropValue)
|
|
716
|
+
overrideProps[propName] = slotPropValue;
|
|
717
|
+
} else if (propName === "style")
|
|
718
|
+
overrideProps[propName] = {
|
|
719
|
+
...slotPropValue,
|
|
720
|
+
...childPropValue
|
|
721
|
+
};
|
|
722
|
+
else if (propName === "className")
|
|
723
|
+
overrideProps[propName] = [
|
|
724
|
+
slotPropValue,
|
|
725
|
+
childPropValue
|
|
726
|
+
].filter(Boolean).join(" ");
|
|
727
|
+
}
|
|
728
|
+
return {
|
|
729
|
+
...slotProps,
|
|
730
|
+
...overrideProps
|
|
731
|
+
};
|
|
732
|
+
}
|
|
733
|
+
var [$a093c7e1ec25a057$var$createTooltipContext, $a093c7e1ec25a057$export$1c540a2224f0d865] = createContextScope("Tooltip", [
|
|
734
|
+
createPopperScope
|
|
735
|
+
]);
|
|
736
|
+
var $a093c7e1ec25a057$var$usePopperScope = createPopperScope();
|
|
737
|
+
var $a093c7e1ec25a057$var$PROVIDER_NAME = "TooltipProvider";
|
|
738
|
+
var $a093c7e1ec25a057$var$DEFAULT_DELAY_DURATION = 700;
|
|
739
|
+
var $a093c7e1ec25a057$var$TOOLTIP_OPEN = "tooltip.open";
|
|
740
|
+
var [$a093c7e1ec25a057$var$TooltipProviderContextProvider, $a093c7e1ec25a057$var$useTooltipProviderContext] = $a093c7e1ec25a057$var$createTooltipContext($a093c7e1ec25a057$var$PROVIDER_NAME);
|
|
741
|
+
var $a093c7e1ec25a057$export$f78649fb9ca566b8 = (props) => {
|
|
742
|
+
const { __scopeTooltip, delayDuration = $a093c7e1ec25a057$var$DEFAULT_DELAY_DURATION, skipDelayDuration = 300, disableHoverableContent = false, children } = props;
|
|
743
|
+
const [isOpenDelayed, setIsOpenDelayed] = useState(true);
|
|
744
|
+
const isPointerInTransitRef = useRef(false);
|
|
745
|
+
const skipDelayTimerRef = useRef(0);
|
|
746
|
+
useEffect(() => {
|
|
747
|
+
const skipDelayTimer = skipDelayTimerRef.current;
|
|
748
|
+
return () => window.clearTimeout(skipDelayTimer);
|
|
749
|
+
}, []);
|
|
750
|
+
return /* @__PURE__ */ createElement($a093c7e1ec25a057$var$TooltipProviderContextProvider, {
|
|
751
|
+
scope: __scopeTooltip,
|
|
752
|
+
isOpenDelayed,
|
|
753
|
+
delayDuration,
|
|
754
|
+
onOpen: useCallback(() => {
|
|
755
|
+
window.clearTimeout(skipDelayTimerRef.current);
|
|
756
|
+
setIsOpenDelayed(false);
|
|
757
|
+
}, []),
|
|
758
|
+
onClose: useCallback(() => {
|
|
759
|
+
window.clearTimeout(skipDelayTimerRef.current);
|
|
760
|
+
skipDelayTimerRef.current = window.setTimeout(
|
|
761
|
+
() => setIsOpenDelayed(true),
|
|
762
|
+
skipDelayDuration
|
|
763
|
+
);
|
|
764
|
+
}, [
|
|
765
|
+
skipDelayDuration
|
|
766
|
+
]),
|
|
767
|
+
isPointerInTransitRef,
|
|
768
|
+
onPointerInTransitChange: useCallback((inTransit) => {
|
|
769
|
+
isPointerInTransitRef.current = inTransit;
|
|
770
|
+
}, []),
|
|
771
|
+
disableHoverableContent
|
|
772
|
+
}, children);
|
|
773
|
+
};
|
|
774
|
+
var $a093c7e1ec25a057$var$TOOLTIP_NAME = "Tooltip";
|
|
775
|
+
var [$a093c7e1ec25a057$var$TooltipContextProvider, $a093c7e1ec25a057$var$useTooltipContext] = $a093c7e1ec25a057$var$createTooltipContext($a093c7e1ec25a057$var$TOOLTIP_NAME);
|
|
776
|
+
var $a093c7e1ec25a057$export$28c660c63b792dea = (props) => {
|
|
777
|
+
const { __scopeTooltip, children, open: openProp, defaultOpen = false, onOpenChange, disableHoverableContent: disableHoverableContentProp, delayDuration: delayDurationProp } = props;
|
|
778
|
+
const providerContext = $a093c7e1ec25a057$var$useTooltipProviderContext($a093c7e1ec25a057$var$TOOLTIP_NAME, props.__scopeTooltip);
|
|
779
|
+
const popperScope = $a093c7e1ec25a057$var$usePopperScope(__scopeTooltip);
|
|
780
|
+
const [trigger, setTrigger] = useState(null);
|
|
781
|
+
const contentId = useId();
|
|
782
|
+
const openTimerRef = useRef(0);
|
|
783
|
+
const disableHoverableContent = disableHoverableContentProp !== null && disableHoverableContentProp !== void 0 ? disableHoverableContentProp : providerContext.disableHoverableContent;
|
|
784
|
+
const delayDuration = delayDurationProp !== null && delayDurationProp !== void 0 ? delayDurationProp : providerContext.delayDuration;
|
|
785
|
+
const wasOpenDelayedRef = useRef(false);
|
|
786
|
+
const [open1 = false, setOpen] = useControllableState({
|
|
787
|
+
prop: openProp,
|
|
788
|
+
defaultProp: defaultOpen,
|
|
789
|
+
onChange: (open) => {
|
|
790
|
+
if (open) {
|
|
791
|
+
providerContext.onOpen();
|
|
792
|
+
document.dispatchEvent(new CustomEvent($a093c7e1ec25a057$var$TOOLTIP_OPEN));
|
|
793
|
+
} else
|
|
794
|
+
providerContext.onClose();
|
|
795
|
+
onOpenChange === null || onOpenChange === void 0 || onOpenChange(open);
|
|
796
|
+
}
|
|
797
|
+
});
|
|
798
|
+
const stateAttribute = useMemo$1(() => {
|
|
799
|
+
return open1 ? wasOpenDelayedRef.current ? "delayed-open" : "instant-open" : "closed";
|
|
800
|
+
}, [
|
|
801
|
+
open1
|
|
802
|
+
]);
|
|
803
|
+
const handleOpen = useCallback(() => {
|
|
804
|
+
window.clearTimeout(openTimerRef.current);
|
|
805
|
+
wasOpenDelayedRef.current = false;
|
|
806
|
+
setOpen(true);
|
|
807
|
+
}, [
|
|
808
|
+
setOpen
|
|
809
|
+
]);
|
|
810
|
+
const handleClose = useCallback(() => {
|
|
811
|
+
window.clearTimeout(openTimerRef.current);
|
|
812
|
+
setOpen(false);
|
|
813
|
+
}, [
|
|
814
|
+
setOpen
|
|
815
|
+
]);
|
|
816
|
+
const handleDelayedOpen = useCallback(() => {
|
|
817
|
+
window.clearTimeout(openTimerRef.current);
|
|
818
|
+
openTimerRef.current = window.setTimeout(() => {
|
|
819
|
+
wasOpenDelayedRef.current = true;
|
|
820
|
+
setOpen(true);
|
|
821
|
+
}, delayDuration);
|
|
822
|
+
}, [
|
|
823
|
+
delayDuration,
|
|
824
|
+
setOpen
|
|
825
|
+
]);
|
|
826
|
+
useEffect(() => {
|
|
827
|
+
return () => window.clearTimeout(openTimerRef.current);
|
|
828
|
+
}, []);
|
|
829
|
+
return /* @__PURE__ */ createElement(Root$3, popperScope, /* @__PURE__ */ createElement($a093c7e1ec25a057$var$TooltipContextProvider, {
|
|
830
|
+
scope: __scopeTooltip,
|
|
831
|
+
contentId,
|
|
832
|
+
open: open1,
|
|
833
|
+
stateAttribute,
|
|
834
|
+
trigger,
|
|
835
|
+
onTriggerChange: setTrigger,
|
|
836
|
+
onTriggerEnter: useCallback(() => {
|
|
837
|
+
if (providerContext.isOpenDelayed)
|
|
838
|
+
handleDelayedOpen();
|
|
839
|
+
else
|
|
840
|
+
handleOpen();
|
|
841
|
+
}, [
|
|
842
|
+
providerContext.isOpenDelayed,
|
|
843
|
+
handleDelayedOpen,
|
|
844
|
+
handleOpen
|
|
845
|
+
]),
|
|
846
|
+
onTriggerLeave: useCallback(() => {
|
|
847
|
+
if (disableHoverableContent)
|
|
848
|
+
handleClose();
|
|
849
|
+
else
|
|
850
|
+
window.clearTimeout(openTimerRef.current);
|
|
851
|
+
}, [
|
|
852
|
+
handleClose,
|
|
853
|
+
disableHoverableContent
|
|
854
|
+
]),
|
|
855
|
+
onOpen: handleOpen,
|
|
856
|
+
onClose: handleClose,
|
|
857
|
+
disableHoverableContent
|
|
858
|
+
}, children));
|
|
859
|
+
};
|
|
860
|
+
var $a093c7e1ec25a057$var$TRIGGER_NAME = "TooltipTrigger";
|
|
861
|
+
var $a093c7e1ec25a057$export$8c610744efcf8a1d = /* @__PURE__ */ forwardRef((props, forwardedRef) => {
|
|
862
|
+
const { __scopeTooltip, ...triggerProps } = props;
|
|
863
|
+
const context = $a093c7e1ec25a057$var$useTooltipContext($a093c7e1ec25a057$var$TRIGGER_NAME, __scopeTooltip);
|
|
864
|
+
const providerContext = $a093c7e1ec25a057$var$useTooltipProviderContext($a093c7e1ec25a057$var$TRIGGER_NAME, __scopeTooltip);
|
|
865
|
+
const popperScope = $a093c7e1ec25a057$var$usePopperScope(__scopeTooltip);
|
|
866
|
+
const ref = useRef(null);
|
|
867
|
+
const composedRefs = useComposedRefs(forwardedRef, ref, context.onTriggerChange);
|
|
868
|
+
const isPointerDownRef = useRef(false);
|
|
869
|
+
const hasPointerMoveOpenedRef = useRef(false);
|
|
870
|
+
const handlePointerUp = useCallback(
|
|
871
|
+
() => isPointerDownRef.current = false,
|
|
872
|
+
[]
|
|
873
|
+
);
|
|
874
|
+
useEffect(() => {
|
|
875
|
+
return () => document.removeEventListener("pointerup", handlePointerUp);
|
|
876
|
+
}, [
|
|
877
|
+
handlePointerUp
|
|
878
|
+
]);
|
|
879
|
+
return /* @__PURE__ */ createElement(Anchor, $01b9c$babelruntimehelpersesmextends({
|
|
880
|
+
asChild: true
|
|
881
|
+
}, popperScope), /* @__PURE__ */ createElement(Primitive.button, $01b9c$babelruntimehelpersesmextends({
|
|
882
|
+
// We purposefully avoid adding `type=button` here because tooltip triggers are also
|
|
883
|
+
// commonly anchors and the anchor `type` attribute signifies MIME type.
|
|
884
|
+
"aria-describedby": context.open ? context.contentId : void 0,
|
|
885
|
+
"data-state": context.stateAttribute
|
|
886
|
+
}, triggerProps, {
|
|
887
|
+
ref: composedRefs,
|
|
888
|
+
onPointerMove: composeEventHandlers(props.onPointerMove, (event) => {
|
|
889
|
+
if (event.pointerType === "touch")
|
|
890
|
+
return;
|
|
891
|
+
if (!hasPointerMoveOpenedRef.current && !providerContext.isPointerInTransitRef.current) {
|
|
892
|
+
context.onTriggerEnter();
|
|
893
|
+
hasPointerMoveOpenedRef.current = true;
|
|
894
|
+
}
|
|
895
|
+
}),
|
|
896
|
+
onPointerLeave: composeEventHandlers(props.onPointerLeave, () => {
|
|
897
|
+
context.onTriggerLeave();
|
|
898
|
+
hasPointerMoveOpenedRef.current = false;
|
|
899
|
+
}),
|
|
900
|
+
onPointerDown: composeEventHandlers(props.onPointerDown, () => {
|
|
901
|
+
isPointerDownRef.current = true;
|
|
902
|
+
document.addEventListener("pointerup", handlePointerUp, {
|
|
903
|
+
once: true
|
|
904
|
+
});
|
|
905
|
+
}),
|
|
906
|
+
onFocus: composeEventHandlers(props.onFocus, () => {
|
|
907
|
+
if (!isPointerDownRef.current)
|
|
908
|
+
context.onOpen();
|
|
909
|
+
}),
|
|
910
|
+
onBlur: composeEventHandlers(props.onBlur, context.onClose),
|
|
911
|
+
onClick: composeEventHandlers(props.onClick, context.onClose)
|
|
912
|
+
})));
|
|
913
|
+
});
|
|
914
|
+
var $a093c7e1ec25a057$var$PORTAL_NAME = "TooltipPortal";
|
|
915
|
+
var [$a093c7e1ec25a057$var$PortalProvider, $a093c7e1ec25a057$var$usePortalContext] = $a093c7e1ec25a057$var$createTooltipContext($a093c7e1ec25a057$var$PORTAL_NAME, {
|
|
916
|
+
forceMount: void 0
|
|
917
|
+
});
|
|
918
|
+
var $a093c7e1ec25a057$var$CONTENT_NAME = "TooltipContent";
|
|
919
|
+
var $a093c7e1ec25a057$export$e9003e2be37ec060 = /* @__PURE__ */ forwardRef((props, forwardedRef) => {
|
|
920
|
+
const portalContext = $a093c7e1ec25a057$var$usePortalContext($a093c7e1ec25a057$var$CONTENT_NAME, props.__scopeTooltip);
|
|
921
|
+
const { forceMount = portalContext.forceMount, side = "top", ...contentProps } = props;
|
|
922
|
+
const context = $a093c7e1ec25a057$var$useTooltipContext($a093c7e1ec25a057$var$CONTENT_NAME, props.__scopeTooltip);
|
|
923
|
+
return /* @__PURE__ */ createElement(Presence, {
|
|
924
|
+
present: forceMount || context.open
|
|
925
|
+
}, context.disableHoverableContent ? /* @__PURE__ */ createElement($a093c7e1ec25a057$var$TooltipContentImpl, $01b9c$babelruntimehelpersesmextends({
|
|
926
|
+
side
|
|
927
|
+
}, contentProps, {
|
|
928
|
+
ref: forwardedRef
|
|
929
|
+
})) : /* @__PURE__ */ createElement($a093c7e1ec25a057$var$TooltipContentHoverable, $01b9c$babelruntimehelpersesmextends({
|
|
930
|
+
side
|
|
931
|
+
}, contentProps, {
|
|
932
|
+
ref: forwardedRef
|
|
933
|
+
})));
|
|
934
|
+
});
|
|
935
|
+
var $a093c7e1ec25a057$var$TooltipContentHoverable = /* @__PURE__ */ forwardRef((props, forwardedRef) => {
|
|
936
|
+
const context = $a093c7e1ec25a057$var$useTooltipContext($a093c7e1ec25a057$var$CONTENT_NAME, props.__scopeTooltip);
|
|
937
|
+
const providerContext = $a093c7e1ec25a057$var$useTooltipProviderContext($a093c7e1ec25a057$var$CONTENT_NAME, props.__scopeTooltip);
|
|
938
|
+
const ref = useRef(null);
|
|
939
|
+
const composedRefs = useComposedRefs(forwardedRef, ref);
|
|
940
|
+
const [pointerGraceArea, setPointerGraceArea] = useState(null);
|
|
941
|
+
const { trigger, onClose } = context;
|
|
942
|
+
const content = ref.current;
|
|
943
|
+
const { onPointerInTransitChange } = providerContext;
|
|
944
|
+
const handleRemoveGraceArea = useCallback(() => {
|
|
945
|
+
setPointerGraceArea(null);
|
|
946
|
+
onPointerInTransitChange(false);
|
|
947
|
+
}, [
|
|
948
|
+
onPointerInTransitChange
|
|
949
|
+
]);
|
|
950
|
+
const handleCreateGraceArea = useCallback((event, hoverTarget) => {
|
|
951
|
+
const currentTarget = event.currentTarget;
|
|
952
|
+
const exitPoint = {
|
|
953
|
+
x: event.clientX,
|
|
954
|
+
y: event.clientY
|
|
955
|
+
};
|
|
956
|
+
const exitSide = $a093c7e1ec25a057$var$getExitSideFromRect(exitPoint, currentTarget.getBoundingClientRect());
|
|
957
|
+
const paddedExitPoints = $a093c7e1ec25a057$var$getPaddedExitPoints(exitPoint, exitSide);
|
|
958
|
+
const hoverTargetPoints = $a093c7e1ec25a057$var$getPointsFromRect(hoverTarget.getBoundingClientRect());
|
|
959
|
+
const graceArea = $a093c7e1ec25a057$var$getHull([
|
|
960
|
+
...paddedExitPoints,
|
|
961
|
+
...hoverTargetPoints
|
|
962
|
+
]);
|
|
963
|
+
setPointerGraceArea(graceArea);
|
|
964
|
+
onPointerInTransitChange(true);
|
|
965
|
+
}, [
|
|
966
|
+
onPointerInTransitChange
|
|
967
|
+
]);
|
|
968
|
+
useEffect(() => {
|
|
969
|
+
return () => handleRemoveGraceArea();
|
|
970
|
+
}, [
|
|
971
|
+
handleRemoveGraceArea
|
|
972
|
+
]);
|
|
973
|
+
useEffect(() => {
|
|
974
|
+
if (trigger && content) {
|
|
975
|
+
const handleTriggerLeave = (event) => handleCreateGraceArea(event, content);
|
|
976
|
+
const handleContentLeave = (event) => handleCreateGraceArea(event, trigger);
|
|
977
|
+
trigger.addEventListener("pointerleave", handleTriggerLeave);
|
|
978
|
+
content.addEventListener("pointerleave", handleContentLeave);
|
|
979
|
+
return () => {
|
|
980
|
+
trigger.removeEventListener("pointerleave", handleTriggerLeave);
|
|
981
|
+
content.removeEventListener("pointerleave", handleContentLeave);
|
|
982
|
+
};
|
|
983
|
+
}
|
|
984
|
+
}, [
|
|
985
|
+
trigger,
|
|
986
|
+
content,
|
|
987
|
+
handleCreateGraceArea,
|
|
988
|
+
handleRemoveGraceArea
|
|
989
|
+
]);
|
|
990
|
+
useEffect(() => {
|
|
991
|
+
if (pointerGraceArea) {
|
|
992
|
+
const handleTrackPointerGrace = (event) => {
|
|
993
|
+
const target = event.target;
|
|
994
|
+
const pointerPosition = {
|
|
995
|
+
x: event.clientX,
|
|
996
|
+
y: event.clientY
|
|
997
|
+
};
|
|
998
|
+
const hasEnteredTarget = (trigger === null || trigger === void 0 ? void 0 : trigger.contains(target)) || (content === null || content === void 0 ? void 0 : content.contains(target));
|
|
999
|
+
const isPointerOutsideGraceArea = !$a093c7e1ec25a057$var$isPointInPolygon(pointerPosition, pointerGraceArea);
|
|
1000
|
+
if (hasEnteredTarget)
|
|
1001
|
+
handleRemoveGraceArea();
|
|
1002
|
+
else if (isPointerOutsideGraceArea) {
|
|
1003
|
+
handleRemoveGraceArea();
|
|
1004
|
+
onClose();
|
|
1005
|
+
}
|
|
1006
|
+
};
|
|
1007
|
+
document.addEventListener("pointermove", handleTrackPointerGrace);
|
|
1008
|
+
return () => document.removeEventListener("pointermove", handleTrackPointerGrace);
|
|
1009
|
+
}
|
|
1010
|
+
}, [
|
|
1011
|
+
trigger,
|
|
1012
|
+
content,
|
|
1013
|
+
pointerGraceArea,
|
|
1014
|
+
onClose,
|
|
1015
|
+
handleRemoveGraceArea
|
|
1016
|
+
]);
|
|
1017
|
+
return /* @__PURE__ */ createElement($a093c7e1ec25a057$var$TooltipContentImpl, $01b9c$babelruntimehelpersesmextends({}, props, {
|
|
1018
|
+
ref: composedRefs
|
|
1019
|
+
}));
|
|
1020
|
+
});
|
|
1021
|
+
var [$a093c7e1ec25a057$var$VisuallyHiddenContentContextProvider, $a093c7e1ec25a057$var$useVisuallyHiddenContentContext] = $a093c7e1ec25a057$var$createTooltipContext($a093c7e1ec25a057$var$TOOLTIP_NAME, {
|
|
1022
|
+
isInside: false
|
|
1023
|
+
});
|
|
1024
|
+
var $a093c7e1ec25a057$var$TooltipContentImpl = /* @__PURE__ */ forwardRef((props, forwardedRef) => {
|
|
1025
|
+
const { __scopeTooltip, children, "aria-label": ariaLabel, onEscapeKeyDown, onPointerDownOutside, ...contentProps } = props;
|
|
1026
|
+
const context = $a093c7e1ec25a057$var$useTooltipContext($a093c7e1ec25a057$var$CONTENT_NAME, __scopeTooltip);
|
|
1027
|
+
const popperScope = $a093c7e1ec25a057$var$usePopperScope(__scopeTooltip);
|
|
1028
|
+
const { onClose } = context;
|
|
1029
|
+
useEffect(() => {
|
|
1030
|
+
document.addEventListener($a093c7e1ec25a057$var$TOOLTIP_OPEN, onClose);
|
|
1031
|
+
return () => document.removeEventListener($a093c7e1ec25a057$var$TOOLTIP_OPEN, onClose);
|
|
1032
|
+
}, [
|
|
1033
|
+
onClose
|
|
1034
|
+
]);
|
|
1035
|
+
useEffect(() => {
|
|
1036
|
+
if (context.trigger) {
|
|
1037
|
+
const handleScroll = (event) => {
|
|
1038
|
+
const target = event.target;
|
|
1039
|
+
if (target !== null && target !== void 0 && target.contains(context.trigger))
|
|
1040
|
+
onClose();
|
|
1041
|
+
};
|
|
1042
|
+
window.addEventListener("scroll", handleScroll, {
|
|
1043
|
+
capture: true
|
|
1044
|
+
});
|
|
1045
|
+
return () => window.removeEventListener("scroll", handleScroll, {
|
|
1046
|
+
capture: true
|
|
1047
|
+
});
|
|
1048
|
+
}
|
|
1049
|
+
}, [
|
|
1050
|
+
context.trigger,
|
|
1051
|
+
onClose
|
|
1052
|
+
]);
|
|
1053
|
+
return /* @__PURE__ */ createElement(DismissableLayer, {
|
|
1054
|
+
asChild: true,
|
|
1055
|
+
disableOutsidePointerEvents: false,
|
|
1056
|
+
onEscapeKeyDown,
|
|
1057
|
+
onPointerDownOutside,
|
|
1058
|
+
onFocusOutside: (event) => event.preventDefault(),
|
|
1059
|
+
onDismiss: onClose
|
|
1060
|
+
}, /* @__PURE__ */ createElement(Content, $01b9c$babelruntimehelpersesmextends({
|
|
1061
|
+
"data-state": context.stateAttribute
|
|
1062
|
+
}, popperScope, contentProps, {
|
|
1063
|
+
ref: forwardedRef,
|
|
1064
|
+
style: {
|
|
1065
|
+
...contentProps.style,
|
|
1066
|
+
"--radix-tooltip-content-transform-origin": "var(--radix-popper-transform-origin)",
|
|
1067
|
+
"--radix-tooltip-content-available-width": "var(--radix-popper-available-width)",
|
|
1068
|
+
"--radix-tooltip-content-available-height": "var(--radix-popper-available-height)",
|
|
1069
|
+
"--radix-tooltip-trigger-width": "var(--radix-popper-anchor-width)",
|
|
1070
|
+
"--radix-tooltip-trigger-height": "var(--radix-popper-anchor-height)"
|
|
1071
|
+
}
|
|
1072
|
+
}), /* @__PURE__ */ createElement($5e63c961fc1ce211$export$d9f1ccf0bdb05d45, null, children), /* @__PURE__ */ createElement($a093c7e1ec25a057$var$VisuallyHiddenContentContextProvider, {
|
|
1073
|
+
scope: __scopeTooltip,
|
|
1074
|
+
isInside: true
|
|
1075
|
+
}, /* @__PURE__ */ createElement(Root$1, {
|
|
1076
|
+
id: context.contentId,
|
|
1077
|
+
role: "tooltip"
|
|
1078
|
+
}, ariaLabel || children))));
|
|
1079
|
+
});
|
|
1080
|
+
function $a093c7e1ec25a057$var$getExitSideFromRect(point, rect) {
|
|
1081
|
+
const top = Math.abs(rect.top - point.y);
|
|
1082
|
+
const bottom = Math.abs(rect.bottom - point.y);
|
|
1083
|
+
const right = Math.abs(rect.right - point.x);
|
|
1084
|
+
const left = Math.abs(rect.left - point.x);
|
|
1085
|
+
switch (Math.min(top, bottom, right, left)) {
|
|
1086
|
+
case left:
|
|
1087
|
+
return "left";
|
|
1088
|
+
case right:
|
|
1089
|
+
return "right";
|
|
1090
|
+
case top:
|
|
1091
|
+
return "top";
|
|
1092
|
+
case bottom:
|
|
1093
|
+
return "bottom";
|
|
1094
|
+
default:
|
|
1095
|
+
throw new Error("unreachable");
|
|
1096
|
+
}
|
|
1097
|
+
}
|
|
1098
|
+
function $a093c7e1ec25a057$var$getPaddedExitPoints(exitPoint, exitSide, padding = 5) {
|
|
1099
|
+
const paddedExitPoints = [];
|
|
1100
|
+
switch (exitSide) {
|
|
1101
|
+
case "top":
|
|
1102
|
+
paddedExitPoints.push({
|
|
1103
|
+
x: exitPoint.x - padding,
|
|
1104
|
+
y: exitPoint.y + padding
|
|
1105
|
+
}, {
|
|
1106
|
+
x: exitPoint.x + padding,
|
|
1107
|
+
y: exitPoint.y + padding
|
|
1108
|
+
});
|
|
1109
|
+
break;
|
|
1110
|
+
case "bottom":
|
|
1111
|
+
paddedExitPoints.push({
|
|
1112
|
+
x: exitPoint.x - padding,
|
|
1113
|
+
y: exitPoint.y - padding
|
|
1114
|
+
}, {
|
|
1115
|
+
x: exitPoint.x + padding,
|
|
1116
|
+
y: exitPoint.y - padding
|
|
1117
|
+
});
|
|
1118
|
+
break;
|
|
1119
|
+
case "left":
|
|
1120
|
+
paddedExitPoints.push({
|
|
1121
|
+
x: exitPoint.x + padding,
|
|
1122
|
+
y: exitPoint.y - padding
|
|
1123
|
+
}, {
|
|
1124
|
+
x: exitPoint.x + padding,
|
|
1125
|
+
y: exitPoint.y + padding
|
|
1126
|
+
});
|
|
1127
|
+
break;
|
|
1128
|
+
case "right":
|
|
1129
|
+
paddedExitPoints.push({
|
|
1130
|
+
x: exitPoint.x - padding,
|
|
1131
|
+
y: exitPoint.y - padding
|
|
1132
|
+
}, {
|
|
1133
|
+
x: exitPoint.x - padding,
|
|
1134
|
+
y: exitPoint.y + padding
|
|
1135
|
+
});
|
|
1136
|
+
break;
|
|
1137
|
+
}
|
|
1138
|
+
return paddedExitPoints;
|
|
1139
|
+
}
|
|
1140
|
+
function $a093c7e1ec25a057$var$getPointsFromRect(rect) {
|
|
1141
|
+
const { top, right, bottom, left } = rect;
|
|
1142
|
+
return [
|
|
1143
|
+
{
|
|
1144
|
+
x: left,
|
|
1145
|
+
y: top
|
|
1146
|
+
},
|
|
1147
|
+
{
|
|
1148
|
+
x: right,
|
|
1149
|
+
y: top
|
|
1150
|
+
},
|
|
1151
|
+
{
|
|
1152
|
+
x: right,
|
|
1153
|
+
y: bottom
|
|
1154
|
+
},
|
|
1155
|
+
{
|
|
1156
|
+
x: left,
|
|
1157
|
+
y: bottom
|
|
1158
|
+
}
|
|
1159
|
+
];
|
|
1160
|
+
}
|
|
1161
|
+
function $a093c7e1ec25a057$var$isPointInPolygon(point, polygon) {
|
|
1162
|
+
const { x, y } = point;
|
|
1163
|
+
let inside = false;
|
|
1164
|
+
for (let i = 0, j = polygon.length - 1; i < polygon.length; j = i++) {
|
|
1165
|
+
const xi = polygon[i].x;
|
|
1166
|
+
const yi = polygon[i].y;
|
|
1167
|
+
const xj = polygon[j].x;
|
|
1168
|
+
const yj = polygon[j].y;
|
|
1169
|
+
const intersect = yi > y !== yj > y && x < (xj - xi) * (y - yi) / (yj - yi) + xi;
|
|
1170
|
+
if (intersect)
|
|
1171
|
+
inside = !inside;
|
|
1172
|
+
}
|
|
1173
|
+
return inside;
|
|
1174
|
+
}
|
|
1175
|
+
function $a093c7e1ec25a057$var$getHull(points) {
|
|
1176
|
+
const newPoints = points.slice();
|
|
1177
|
+
newPoints.sort((a, b) => {
|
|
1178
|
+
if (a.x < b.x)
|
|
1179
|
+
return -1;
|
|
1180
|
+
else if (a.x > b.x)
|
|
1181
|
+
return 1;
|
|
1182
|
+
else if (a.y < b.y)
|
|
1183
|
+
return -1;
|
|
1184
|
+
else if (a.y > b.y)
|
|
1185
|
+
return 1;
|
|
1186
|
+
else
|
|
1187
|
+
return 0;
|
|
1188
|
+
});
|
|
1189
|
+
return $a093c7e1ec25a057$var$getHullPresorted(newPoints);
|
|
1190
|
+
}
|
|
1191
|
+
function $a093c7e1ec25a057$var$getHullPresorted(points) {
|
|
1192
|
+
if (points.length <= 1)
|
|
1193
|
+
return points.slice();
|
|
1194
|
+
const upperHull = [];
|
|
1195
|
+
for (let i = 0; i < points.length; i++) {
|
|
1196
|
+
const p = points[i];
|
|
1197
|
+
while (upperHull.length >= 2) {
|
|
1198
|
+
const q = upperHull[upperHull.length - 1];
|
|
1199
|
+
const r = upperHull[upperHull.length - 2];
|
|
1200
|
+
if ((q.x - r.x) * (p.y - r.y) >= (q.y - r.y) * (p.x - r.x))
|
|
1201
|
+
upperHull.pop();
|
|
1202
|
+
else
|
|
1203
|
+
break;
|
|
1204
|
+
}
|
|
1205
|
+
upperHull.push(p);
|
|
1206
|
+
}
|
|
1207
|
+
upperHull.pop();
|
|
1208
|
+
const lowerHull = [];
|
|
1209
|
+
for (let i1 = points.length - 1; i1 >= 0; i1--) {
|
|
1210
|
+
const p = points[i1];
|
|
1211
|
+
while (lowerHull.length >= 2) {
|
|
1212
|
+
const q = lowerHull[lowerHull.length - 1];
|
|
1213
|
+
const r = lowerHull[lowerHull.length - 2];
|
|
1214
|
+
if ((q.x - r.x) * (p.y - r.y) >= (q.y - r.y) * (p.x - r.x))
|
|
1215
|
+
lowerHull.pop();
|
|
1216
|
+
else
|
|
1217
|
+
break;
|
|
1218
|
+
}
|
|
1219
|
+
lowerHull.push(p);
|
|
1220
|
+
}
|
|
1221
|
+
lowerHull.pop();
|
|
1222
|
+
if (upperHull.length === 1 && lowerHull.length === 1 && upperHull[0].x === lowerHull[0].x && upperHull[0].y === lowerHull[0].y)
|
|
1223
|
+
return upperHull;
|
|
1224
|
+
else
|
|
1225
|
+
return upperHull.concat(lowerHull);
|
|
1226
|
+
}
|
|
1227
|
+
var $a093c7e1ec25a057$export$2881499e37b75b9a = $a093c7e1ec25a057$export$f78649fb9ca566b8;
|
|
1228
|
+
var $a093c7e1ec25a057$export$be92b6f5f03c0fe9 = $a093c7e1ec25a057$export$28c660c63b792dea;
|
|
1229
|
+
var $a093c7e1ec25a057$export$41fb9f06171c75f4 = $a093c7e1ec25a057$export$8c610744efcf8a1d;
|
|
1230
|
+
var $a093c7e1ec25a057$export$7c6e2c02157bb7d2 = $a093c7e1ec25a057$export$e9003e2be37ec060;
|
|
1231
|
+
var TooltipProvider = $a093c7e1ec25a057$export$2881499e37b75b9a;
|
|
1232
|
+
var Tooltip = $a093c7e1ec25a057$export$be92b6f5f03c0fe9;
|
|
1233
|
+
var TooltipTrigger = $a093c7e1ec25a057$export$41fb9f06171c75f4;
|
|
1234
|
+
var TooltipContent = React4.forwardRef(({ className, sideOffset = 4, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
1235
|
+
$a093c7e1ec25a057$export$7c6e2c02157bb7d2,
|
|
1236
|
+
{
|
|
1237
|
+
ref,
|
|
1238
|
+
sideOffset,
|
|
1239
|
+
className: cn(
|
|
1240
|
+
"fade-in-0 zoom-in-95 data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 animate-in overflow-hidden rounded-md bg-primary px-3 py-1.5 text-primary-foreground text-xs data-[state=closed]:animate-out",
|
|
1241
|
+
className
|
|
1242
|
+
),
|
|
1243
|
+
...props
|
|
1244
|
+
}
|
|
1245
|
+
));
|
|
1246
|
+
TooltipContent.displayName = $a093c7e1ec25a057$export$7c6e2c02157bb7d2.displayName;
|
|
1247
|
+
function ColumnTitleIndicator({ column }) {
|
|
1248
|
+
const { width, name, visible, dataEditorType, description } = column;
|
|
1249
|
+
if (!visible)
|
|
1250
|
+
return null;
|
|
1251
|
+
return /* @__PURE__ */ jsxs(
|
|
1252
|
+
"div",
|
|
1253
|
+
{
|
|
1254
|
+
className: "flex h-9 w-32 shrink-0 items-center border border-t-0 border-l-0 bg-[#F6F6F9] px-2",
|
|
1255
|
+
style: {
|
|
1256
|
+
width,
|
|
1257
|
+
height: COLUMN_TITLE_INITIAL_HEIGHT
|
|
1258
|
+
},
|
|
1259
|
+
children: [
|
|
1260
|
+
/* @__PURE__ */ jsxs("div", { className: "mr-2 w-4 shrink-0 text-[#8E8EA9]", children: [
|
|
1261
|
+
dataEditorType === "String" && /* @__PURE__ */ jsx(TextIcon, { className: "h-4 w-4" }),
|
|
1262
|
+
dataEditorType === "Date" && /* @__PURE__ */ jsx(CalendarIcon, { className: "h-4 w-4" }),
|
|
1263
|
+
dataEditorType === "Boolean" && /* @__PURE__ */ jsx(CopyCheckIcon, { className: "h-4 w-4" }),
|
|
1264
|
+
dataEditorType === "Select" && /* @__PURE__ */ jsx(ListTodoIcon, { className: "h-4 w-4" }),
|
|
1265
|
+
dataEditorType === "Float" && /* @__PURE__ */ jsx(DivideIcon, { className: "h-4 w-4" }),
|
|
1266
|
+
dataEditorType === "Decimal" && /* @__PURE__ */ jsx(DivideIcon, { className: "h-4 w-4" }),
|
|
1267
|
+
dataEditorType === "Integer" && /* @__PURE__ */ jsx(IntegerIcon, { className: "h-4 w-4" }),
|
|
1268
|
+
dataEditorType === "Currency" && /* @__PURE__ */ jsx(DollarSignIcon, { className: "h-4 w-4" }),
|
|
1269
|
+
dataEditorType === "Percentage" && /* @__PURE__ */ jsx(PercentIcon, { className: "h-4 w-4" })
|
|
1270
|
+
] }),
|
|
1271
|
+
/* @__PURE__ */ jsx(
|
|
1272
|
+
"p",
|
|
1273
|
+
{
|
|
1274
|
+
title: name,
|
|
1275
|
+
className: "mr-2 line-clamp-2 w-full break-words font-semibold text-[#4A4A6A] text-xs",
|
|
1276
|
+
children: name
|
|
1277
|
+
}
|
|
1278
|
+
),
|
|
1279
|
+
description ? /* @__PURE__ */ jsx(TooltipProvider, { children: /* @__PURE__ */ jsxs(Tooltip, { delayDuration: 100, children: [
|
|
1280
|
+
/* @__PURE__ */ jsx(TooltipTrigger, { children: /* @__PURE__ */ jsx(QuestionMarkCircledIcon, { className: "h-4 w-4 text-[#4A4A6A]" }) }),
|
|
1281
|
+
/* @__PURE__ */ jsx(TooltipContent, { className: "max-w-[240px]", children: /* @__PURE__ */ jsx("p", { children: description }) })
|
|
1282
|
+
] }) }) : /* @__PURE__ */ jsx("div", { className: "w-4 shrink-0" })
|
|
1283
|
+
]
|
|
1284
|
+
}
|
|
1285
|
+
);
|
|
1286
|
+
}
|
|
1287
|
+
function CornerIndicator({ className }) {
|
|
1288
|
+
const { emptySize, onSelectSpreadsheet } = useSpreadsheet();
|
|
1289
|
+
return /* @__PURE__ */ jsxs(
|
|
1290
|
+
"button",
|
|
1291
|
+
{
|
|
1292
|
+
type: "button",
|
|
1293
|
+
disabled: emptySize,
|
|
1294
|
+
className: cn(
|
|
1295
|
+
"relative flex h-7 w-12 shrink-0 items-center justify-center border border-t border-l bg-white text-xs",
|
|
1296
|
+
className
|
|
1297
|
+
),
|
|
1298
|
+
onClick: onSelectSpreadsheet,
|
|
1299
|
+
children: [
|
|
1300
|
+
/* @__PURE__ */ jsx("span", { className: "absolute top-0 right-0 h-full w-0.5 bg-gray-300" }),
|
|
1301
|
+
/* @__PURE__ */ jsx("span", { className: "absolute bottom-0 left-0 h-0.5 w-full bg-gray-300" })
|
|
1302
|
+
]
|
|
1303
|
+
}
|
|
1304
|
+
);
|
|
1305
|
+
}
|
|
1306
|
+
function Header() {
|
|
1307
|
+
const { columns } = useSpreadsheet();
|
|
1308
|
+
return /* @__PURE__ */ jsxs("div", { className: "sticky top-[58px] z-50", children: [
|
|
1309
|
+
/* @__PURE__ */ jsxs("div", { className: "relative flex items-center bg-white", children: [
|
|
1310
|
+
/* @__PURE__ */ jsx(CornerIndicator, { className: "border-t-0 border-l-0" }),
|
|
1311
|
+
columns.map((column) => /* @__PURE__ */ jsx(
|
|
1312
|
+
ColumnIndicator,
|
|
1313
|
+
{
|
|
1314
|
+
column
|
|
1315
|
+
},
|
|
1316
|
+
`spreadsheet__column__indicator__key__${column.name}__${column.position}`
|
|
1317
|
+
))
|
|
1318
|
+
] }),
|
|
1319
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
|
|
1320
|
+
/* @__PURE__ */ jsx("div", { className: "h-9 w-12 shrink-0 cursor-default border border-t-0 border-l-0 bg-[#F6F6F9]" }),
|
|
1321
|
+
columns.map((column) => /* @__PURE__ */ jsx(
|
|
1322
|
+
ColumnTitleIndicator,
|
|
1323
|
+
{
|
|
1324
|
+
column
|
|
1325
|
+
},
|
|
1326
|
+
`spreadsheet__column__header__key__${column.name}__${column.position}`
|
|
1327
|
+
))
|
|
1328
|
+
] })
|
|
1329
|
+
] });
|
|
1330
|
+
}
|
|
1331
|
+
var $cc7e05a45900e73f$var$OPEN_KEYS = [
|
|
1332
|
+
" ",
|
|
1333
|
+
"Enter",
|
|
1334
|
+
"ArrowUp",
|
|
1335
|
+
"ArrowDown"
|
|
1336
|
+
];
|
|
1337
|
+
var $cc7e05a45900e73f$var$SELECTION_KEYS = [
|
|
1338
|
+
" ",
|
|
1339
|
+
"Enter"
|
|
1340
|
+
];
|
|
1341
|
+
var $cc7e05a45900e73f$var$SELECT_NAME = "Select";
|
|
1342
|
+
var [$cc7e05a45900e73f$var$Collection, $cc7e05a45900e73f$var$useCollection, $cc7e05a45900e73f$var$createCollectionScope] = createCollection($cc7e05a45900e73f$var$SELECT_NAME);
|
|
1343
|
+
var [$cc7e05a45900e73f$var$createSelectContext, $cc7e05a45900e73f$export$286727a75dc039bd] = createContextScope($cc7e05a45900e73f$var$SELECT_NAME, [
|
|
1344
|
+
$cc7e05a45900e73f$var$createCollectionScope,
|
|
1345
|
+
createPopperScope
|
|
1346
|
+
]);
|
|
1347
|
+
var $cc7e05a45900e73f$var$usePopperScope = createPopperScope();
|
|
1348
|
+
var [$cc7e05a45900e73f$var$SelectProvider, $cc7e05a45900e73f$var$useSelectContext] = $cc7e05a45900e73f$var$createSelectContext($cc7e05a45900e73f$var$SELECT_NAME);
|
|
1349
|
+
var [$cc7e05a45900e73f$var$SelectNativeOptionsProvider, $cc7e05a45900e73f$var$useSelectNativeOptionsContext] = $cc7e05a45900e73f$var$createSelectContext($cc7e05a45900e73f$var$SELECT_NAME);
|
|
1350
|
+
var $cc7e05a45900e73f$export$ef9b1a59e592288f = (props) => {
|
|
1351
|
+
const { __scopeSelect, children, open: openProp, defaultOpen, onOpenChange, value: valueProp, defaultValue, onValueChange, dir, name, autoComplete, disabled, required } = props;
|
|
1352
|
+
const popperScope = $cc7e05a45900e73f$var$usePopperScope(__scopeSelect);
|
|
1353
|
+
const [trigger, setTrigger] = useState(null);
|
|
1354
|
+
const [valueNode, setValueNode] = useState(null);
|
|
1355
|
+
const [valueNodeHasChildren, setValueNodeHasChildren] = useState(false);
|
|
1356
|
+
const direction = useDirection(dir);
|
|
1357
|
+
const [open = false, setOpen] = useControllableState({
|
|
1358
|
+
prop: openProp,
|
|
1359
|
+
defaultProp: defaultOpen,
|
|
1360
|
+
onChange: onOpenChange
|
|
1361
|
+
});
|
|
1362
|
+
const [value, setValue] = useControllableState({
|
|
1363
|
+
prop: valueProp,
|
|
1364
|
+
defaultProp: defaultValue,
|
|
1365
|
+
onChange: onValueChange
|
|
1366
|
+
});
|
|
1367
|
+
const triggerPointerDownPosRef = useRef(null);
|
|
1368
|
+
const isFormControl = trigger ? Boolean(trigger.closest("form")) : true;
|
|
1369
|
+
const [nativeOptionsSet, setNativeOptionsSet] = useState(/* @__PURE__ */ new Set());
|
|
1370
|
+
const nativeSelectKey = Array.from(nativeOptionsSet).map(
|
|
1371
|
+
(option) => option.props.value
|
|
1372
|
+
).join(";");
|
|
1373
|
+
return /* @__PURE__ */ createElement(Root$3, popperScope, /* @__PURE__ */ createElement($cc7e05a45900e73f$var$SelectProvider, {
|
|
1374
|
+
required,
|
|
1375
|
+
scope: __scopeSelect,
|
|
1376
|
+
trigger,
|
|
1377
|
+
onTriggerChange: setTrigger,
|
|
1378
|
+
valueNode,
|
|
1379
|
+
onValueNodeChange: setValueNode,
|
|
1380
|
+
valueNodeHasChildren,
|
|
1381
|
+
onValueNodeHasChildrenChange: setValueNodeHasChildren,
|
|
1382
|
+
contentId: useId(),
|
|
1383
|
+
value,
|
|
1384
|
+
onValueChange: setValue,
|
|
1385
|
+
open,
|
|
1386
|
+
onOpenChange: setOpen,
|
|
1387
|
+
dir: direction,
|
|
1388
|
+
triggerPointerDownPosRef,
|
|
1389
|
+
disabled
|
|
1390
|
+
}, /* @__PURE__ */ createElement($cc7e05a45900e73f$var$Collection.Provider, {
|
|
1391
|
+
scope: __scopeSelect
|
|
1392
|
+
}, /* @__PURE__ */ createElement($cc7e05a45900e73f$var$SelectNativeOptionsProvider, {
|
|
1393
|
+
scope: props.__scopeSelect,
|
|
1394
|
+
onNativeOptionAdd: useCallback((option) => {
|
|
1395
|
+
setNativeOptionsSet(
|
|
1396
|
+
(prev) => new Set(prev).add(option)
|
|
1397
|
+
);
|
|
1398
|
+
}, []),
|
|
1399
|
+
onNativeOptionRemove: useCallback((option) => {
|
|
1400
|
+
setNativeOptionsSet((prev) => {
|
|
1401
|
+
const optionsSet = new Set(prev);
|
|
1402
|
+
optionsSet.delete(option);
|
|
1403
|
+
return optionsSet;
|
|
1404
|
+
});
|
|
1405
|
+
}, [])
|
|
1406
|
+
}, children)), isFormControl ? /* @__PURE__ */ createElement($cc7e05a45900e73f$var$BubbleSelect, {
|
|
1407
|
+
key: nativeSelectKey,
|
|
1408
|
+
"aria-hidden": true,
|
|
1409
|
+
required,
|
|
1410
|
+
tabIndex: -1,
|
|
1411
|
+
name,
|
|
1412
|
+
autoComplete,
|
|
1413
|
+
value,
|
|
1414
|
+
onChange: (event) => setValue(event.target.value),
|
|
1415
|
+
disabled
|
|
1416
|
+
}, value === void 0 ? /* @__PURE__ */ createElement("option", {
|
|
1417
|
+
value: ""
|
|
1418
|
+
}) : null, Array.from(nativeOptionsSet)) : null));
|
|
1419
|
+
};
|
|
1420
|
+
var $cc7e05a45900e73f$var$TRIGGER_NAME = "SelectTrigger";
|
|
1421
|
+
var $cc7e05a45900e73f$export$3ac1e88a1c0b9f1 = /* @__PURE__ */ forwardRef((props, forwardedRef) => {
|
|
1422
|
+
const { __scopeSelect, disabled = false, ...triggerProps } = props;
|
|
1423
|
+
const popperScope = $cc7e05a45900e73f$var$usePopperScope(__scopeSelect);
|
|
1424
|
+
const context = $cc7e05a45900e73f$var$useSelectContext($cc7e05a45900e73f$var$TRIGGER_NAME, __scopeSelect);
|
|
1425
|
+
const isDisabled = context.disabled || disabled;
|
|
1426
|
+
const composedRefs = useComposedRefs(forwardedRef, context.onTriggerChange);
|
|
1427
|
+
const getItems = $cc7e05a45900e73f$var$useCollection(__scopeSelect);
|
|
1428
|
+
const [searchRef, handleTypeaheadSearch, resetTypeahead] = $cc7e05a45900e73f$var$useTypeaheadSearch((search) => {
|
|
1429
|
+
const enabledItems = getItems().filter(
|
|
1430
|
+
(item) => !item.disabled
|
|
1431
|
+
);
|
|
1432
|
+
const currentItem = enabledItems.find(
|
|
1433
|
+
(item) => item.value === context.value
|
|
1434
|
+
);
|
|
1435
|
+
const nextItem = $cc7e05a45900e73f$var$findNextItem(enabledItems, search, currentItem);
|
|
1436
|
+
if (nextItem !== void 0)
|
|
1437
|
+
context.onValueChange(nextItem.value);
|
|
1438
|
+
});
|
|
1439
|
+
const handleOpen = () => {
|
|
1440
|
+
if (!isDisabled) {
|
|
1441
|
+
context.onOpenChange(true);
|
|
1442
|
+
resetTypeahead();
|
|
1443
|
+
}
|
|
1444
|
+
};
|
|
1445
|
+
return /* @__PURE__ */ createElement(Anchor, $01b9c$babelruntimehelpersesmextends({
|
|
1446
|
+
asChild: true
|
|
1447
|
+
}, popperScope), /* @__PURE__ */ createElement(Primitive.button, $01b9c$babelruntimehelpersesmextends({
|
|
1448
|
+
type: "button",
|
|
1449
|
+
role: "combobox",
|
|
1450
|
+
"aria-controls": context.contentId,
|
|
1451
|
+
"aria-expanded": context.open,
|
|
1452
|
+
"aria-required": context.required,
|
|
1453
|
+
"aria-autocomplete": "none",
|
|
1454
|
+
dir: context.dir,
|
|
1455
|
+
"data-state": context.open ? "open" : "closed",
|
|
1456
|
+
disabled: isDisabled,
|
|
1457
|
+
"data-disabled": isDisabled ? "" : void 0,
|
|
1458
|
+
"data-placeholder": $cc7e05a45900e73f$var$shouldShowPlaceholder(context.value) ? "" : void 0
|
|
1459
|
+
}, triggerProps, {
|
|
1460
|
+
ref: composedRefs,
|
|
1461
|
+
onClick: composeEventHandlers(triggerProps.onClick, (event) => {
|
|
1462
|
+
event.currentTarget.focus();
|
|
1463
|
+
}),
|
|
1464
|
+
onPointerDown: composeEventHandlers(triggerProps.onPointerDown, (event) => {
|
|
1465
|
+
const target = event.target;
|
|
1466
|
+
if (target.hasPointerCapture(event.pointerId))
|
|
1467
|
+
target.releasePointerCapture(event.pointerId);
|
|
1468
|
+
if (event.button === 0 && event.ctrlKey === false) {
|
|
1469
|
+
handleOpen();
|
|
1470
|
+
context.triggerPointerDownPosRef.current = {
|
|
1471
|
+
x: Math.round(event.pageX),
|
|
1472
|
+
y: Math.round(event.pageY)
|
|
1473
|
+
};
|
|
1474
|
+
event.preventDefault();
|
|
1475
|
+
}
|
|
1476
|
+
}),
|
|
1477
|
+
onKeyDown: composeEventHandlers(triggerProps.onKeyDown, (event) => {
|
|
1478
|
+
const isTypingAhead = searchRef.current !== "";
|
|
1479
|
+
const isModifierKey = event.ctrlKey || event.altKey || event.metaKey;
|
|
1480
|
+
if (!isModifierKey && event.key.length === 1)
|
|
1481
|
+
handleTypeaheadSearch(event.key);
|
|
1482
|
+
if (isTypingAhead && event.key === " ")
|
|
1483
|
+
return;
|
|
1484
|
+
if ($cc7e05a45900e73f$var$OPEN_KEYS.includes(event.key)) {
|
|
1485
|
+
handleOpen();
|
|
1486
|
+
event.preventDefault();
|
|
1487
|
+
}
|
|
1488
|
+
})
|
|
1489
|
+
})));
|
|
1490
|
+
});
|
|
1491
|
+
var $cc7e05a45900e73f$var$VALUE_NAME = "SelectValue";
|
|
1492
|
+
var $cc7e05a45900e73f$export$e288731fd71264f0 = /* @__PURE__ */ forwardRef((props, forwardedRef) => {
|
|
1493
|
+
const { __scopeSelect, className, style, children, placeholder = "", ...valueProps } = props;
|
|
1494
|
+
const context = $cc7e05a45900e73f$var$useSelectContext($cc7e05a45900e73f$var$VALUE_NAME, __scopeSelect);
|
|
1495
|
+
const { onValueNodeHasChildrenChange } = context;
|
|
1496
|
+
const hasChildren = children !== void 0;
|
|
1497
|
+
const composedRefs = useComposedRefs(forwardedRef, context.onValueNodeChange);
|
|
1498
|
+
useLayoutEffect(() => {
|
|
1499
|
+
onValueNodeHasChildrenChange(hasChildren);
|
|
1500
|
+
}, [
|
|
1501
|
+
onValueNodeHasChildrenChange,
|
|
1502
|
+
hasChildren
|
|
1503
|
+
]);
|
|
1504
|
+
return /* @__PURE__ */ createElement(Primitive.span, $01b9c$babelruntimehelpersesmextends({}, valueProps, {
|
|
1505
|
+
ref: composedRefs,
|
|
1506
|
+
style: {
|
|
1507
|
+
pointerEvents: "none"
|
|
1508
|
+
}
|
|
1509
|
+
}), $cc7e05a45900e73f$var$shouldShowPlaceholder(context.value) ? /* @__PURE__ */ createElement(Fragment, null, placeholder) : children);
|
|
1510
|
+
});
|
|
1511
|
+
var $cc7e05a45900e73f$export$99b400cabb58c515 = /* @__PURE__ */ forwardRef((props, forwardedRef) => {
|
|
1512
|
+
const { __scopeSelect, children, ...iconProps } = props;
|
|
1513
|
+
return /* @__PURE__ */ createElement(Primitive.span, $01b9c$babelruntimehelpersesmextends({
|
|
1514
|
+
"aria-hidden": true
|
|
1515
|
+
}, iconProps, {
|
|
1516
|
+
ref: forwardedRef
|
|
1517
|
+
}), children || "\u25BC");
|
|
1518
|
+
});
|
|
1519
|
+
var $cc7e05a45900e73f$export$b2af6c9944296213 = (props) => {
|
|
1520
|
+
return /* @__PURE__ */ createElement(Portal, $01b9c$babelruntimehelpersesmextends({
|
|
1521
|
+
asChild: true
|
|
1522
|
+
}, props));
|
|
1523
|
+
};
|
|
1524
|
+
var $cc7e05a45900e73f$var$CONTENT_NAME = "SelectContent";
|
|
1525
|
+
var $cc7e05a45900e73f$export$c973a4b3cb86a03d = /* @__PURE__ */ forwardRef((props, forwardedRef) => {
|
|
1526
|
+
const context = $cc7e05a45900e73f$var$useSelectContext($cc7e05a45900e73f$var$CONTENT_NAME, props.__scopeSelect);
|
|
1527
|
+
const [fragment, setFragment] = useState();
|
|
1528
|
+
useLayoutEffect(() => {
|
|
1529
|
+
setFragment(new DocumentFragment());
|
|
1530
|
+
}, []);
|
|
1531
|
+
if (!context.open) {
|
|
1532
|
+
const frag = fragment;
|
|
1533
|
+
return frag ? /* @__PURE__ */ createPortal(/* @__PURE__ */ createElement($cc7e05a45900e73f$var$SelectContentProvider, {
|
|
1534
|
+
scope: props.__scopeSelect
|
|
1535
|
+
}, /* @__PURE__ */ createElement($cc7e05a45900e73f$var$Collection.Slot, {
|
|
1536
|
+
scope: props.__scopeSelect
|
|
1537
|
+
}, /* @__PURE__ */ createElement("div", null, props.children))), frag) : null;
|
|
1538
|
+
}
|
|
1539
|
+
return /* @__PURE__ */ createElement($cc7e05a45900e73f$var$SelectContentImpl, $01b9c$babelruntimehelpersesmextends({}, props, {
|
|
1540
|
+
ref: forwardedRef
|
|
1541
|
+
}));
|
|
1542
|
+
});
|
|
1543
|
+
var $cc7e05a45900e73f$var$CONTENT_MARGIN = 10;
|
|
1544
|
+
var [$cc7e05a45900e73f$var$SelectContentProvider, $cc7e05a45900e73f$var$useSelectContentContext] = $cc7e05a45900e73f$var$createSelectContext($cc7e05a45900e73f$var$CONTENT_NAME);
|
|
1545
|
+
var $cc7e05a45900e73f$var$SelectContentImpl = /* @__PURE__ */ forwardRef((props, forwardedRef) => {
|
|
1546
|
+
const {
|
|
1547
|
+
__scopeSelect,
|
|
1548
|
+
position = "item-aligned",
|
|
1549
|
+
onCloseAutoFocus,
|
|
1550
|
+
onEscapeKeyDown,
|
|
1551
|
+
onPointerDownOutside,
|
|
1552
|
+
side,
|
|
1553
|
+
sideOffset,
|
|
1554
|
+
align,
|
|
1555
|
+
alignOffset,
|
|
1556
|
+
arrowPadding,
|
|
1557
|
+
collisionBoundary,
|
|
1558
|
+
collisionPadding,
|
|
1559
|
+
sticky,
|
|
1560
|
+
hideWhenDetached,
|
|
1561
|
+
avoidCollisions,
|
|
1562
|
+
//
|
|
1563
|
+
...contentProps
|
|
1564
|
+
} = props;
|
|
1565
|
+
const context = $cc7e05a45900e73f$var$useSelectContext($cc7e05a45900e73f$var$CONTENT_NAME, __scopeSelect);
|
|
1566
|
+
const [content, setContent] = useState(null);
|
|
1567
|
+
const [viewport, setViewport] = useState(null);
|
|
1568
|
+
const composedRefs = useComposedRefs(
|
|
1569
|
+
forwardedRef,
|
|
1570
|
+
(node) => setContent(node)
|
|
1571
|
+
);
|
|
1572
|
+
const [selectedItem, setSelectedItem] = useState(null);
|
|
1573
|
+
const [selectedItemText, setSelectedItemText] = useState(null);
|
|
1574
|
+
const getItems = $cc7e05a45900e73f$var$useCollection(__scopeSelect);
|
|
1575
|
+
const [isPositioned, setIsPositioned] = useState(false);
|
|
1576
|
+
const firstValidItemFoundRef = useRef(false);
|
|
1577
|
+
useEffect(() => {
|
|
1578
|
+
if (content)
|
|
1579
|
+
return hideOthers(content);
|
|
1580
|
+
}, [
|
|
1581
|
+
content
|
|
1582
|
+
]);
|
|
1583
|
+
useFocusGuards();
|
|
1584
|
+
const focusFirst = useCallback((candidates) => {
|
|
1585
|
+
const [firstItem, ...restItems] = getItems().map(
|
|
1586
|
+
(item) => item.ref.current
|
|
1587
|
+
);
|
|
1588
|
+
const [lastItem] = restItems.slice(-1);
|
|
1589
|
+
const PREVIOUSLY_FOCUSED_ELEMENT = document.activeElement;
|
|
1590
|
+
for (const candidate of candidates) {
|
|
1591
|
+
if (candidate === PREVIOUSLY_FOCUSED_ELEMENT)
|
|
1592
|
+
return;
|
|
1593
|
+
candidate === null || candidate === void 0 || candidate.scrollIntoView({
|
|
1594
|
+
block: "nearest"
|
|
1595
|
+
});
|
|
1596
|
+
if (candidate === firstItem && viewport)
|
|
1597
|
+
viewport.scrollTop = 0;
|
|
1598
|
+
if (candidate === lastItem && viewport)
|
|
1599
|
+
viewport.scrollTop = viewport.scrollHeight;
|
|
1600
|
+
candidate === null || candidate === void 0 || candidate.focus();
|
|
1601
|
+
if (document.activeElement !== PREVIOUSLY_FOCUSED_ELEMENT)
|
|
1602
|
+
return;
|
|
1603
|
+
}
|
|
1604
|
+
}, [
|
|
1605
|
+
getItems,
|
|
1606
|
+
viewport
|
|
1607
|
+
]);
|
|
1608
|
+
const focusSelectedItem = useCallback(
|
|
1609
|
+
() => focusFirst([
|
|
1610
|
+
selectedItem,
|
|
1611
|
+
content
|
|
1612
|
+
]),
|
|
1613
|
+
[
|
|
1614
|
+
focusFirst,
|
|
1615
|
+
selectedItem,
|
|
1616
|
+
content
|
|
1617
|
+
]
|
|
1618
|
+
);
|
|
1619
|
+
useEffect(() => {
|
|
1620
|
+
if (isPositioned)
|
|
1621
|
+
focusSelectedItem();
|
|
1622
|
+
}, [
|
|
1623
|
+
isPositioned,
|
|
1624
|
+
focusSelectedItem
|
|
1625
|
+
]);
|
|
1626
|
+
const { onOpenChange, triggerPointerDownPosRef } = context;
|
|
1627
|
+
useEffect(() => {
|
|
1628
|
+
if (content) {
|
|
1629
|
+
let pointerMoveDelta = {
|
|
1630
|
+
x: 0,
|
|
1631
|
+
y: 0
|
|
1632
|
+
};
|
|
1633
|
+
const handlePointerMove = (event) => {
|
|
1634
|
+
var _triggerPointerDownPo, _triggerPointerDownPo2, _triggerPointerDownPo3, _triggerPointerDownPo4;
|
|
1635
|
+
pointerMoveDelta = {
|
|
1636
|
+
x: Math.abs(Math.round(event.pageX) - ((_triggerPointerDownPo = (_triggerPointerDownPo2 = triggerPointerDownPosRef.current) === null || _triggerPointerDownPo2 === void 0 ? void 0 : _triggerPointerDownPo2.x) !== null && _triggerPointerDownPo !== void 0 ? _triggerPointerDownPo : 0)),
|
|
1637
|
+
y: Math.abs(Math.round(event.pageY) - ((_triggerPointerDownPo3 = (_triggerPointerDownPo4 = triggerPointerDownPosRef.current) === null || _triggerPointerDownPo4 === void 0 ? void 0 : _triggerPointerDownPo4.y) !== null && _triggerPointerDownPo3 !== void 0 ? _triggerPointerDownPo3 : 0))
|
|
1638
|
+
};
|
|
1639
|
+
};
|
|
1640
|
+
const handlePointerUp = (event) => {
|
|
1641
|
+
if (pointerMoveDelta.x <= 10 && pointerMoveDelta.y <= 10)
|
|
1642
|
+
event.preventDefault();
|
|
1643
|
+
else if (!content.contains(event.target))
|
|
1644
|
+
onOpenChange(false);
|
|
1645
|
+
document.removeEventListener("pointermove", handlePointerMove);
|
|
1646
|
+
triggerPointerDownPosRef.current = null;
|
|
1647
|
+
};
|
|
1648
|
+
if (triggerPointerDownPosRef.current !== null) {
|
|
1649
|
+
document.addEventListener("pointermove", handlePointerMove);
|
|
1650
|
+
document.addEventListener("pointerup", handlePointerUp, {
|
|
1651
|
+
capture: true,
|
|
1652
|
+
once: true
|
|
1653
|
+
});
|
|
1654
|
+
}
|
|
1655
|
+
return () => {
|
|
1656
|
+
document.removeEventListener("pointermove", handlePointerMove);
|
|
1657
|
+
document.removeEventListener("pointerup", handlePointerUp, {
|
|
1658
|
+
capture: true
|
|
1659
|
+
});
|
|
1660
|
+
};
|
|
1661
|
+
}
|
|
1662
|
+
}, [
|
|
1663
|
+
content,
|
|
1664
|
+
onOpenChange,
|
|
1665
|
+
triggerPointerDownPosRef
|
|
1666
|
+
]);
|
|
1667
|
+
useEffect(() => {
|
|
1668
|
+
const close = () => onOpenChange(false);
|
|
1669
|
+
window.addEventListener("blur", close);
|
|
1670
|
+
window.addEventListener("resize", close);
|
|
1671
|
+
return () => {
|
|
1672
|
+
window.removeEventListener("blur", close);
|
|
1673
|
+
window.removeEventListener("resize", close);
|
|
1674
|
+
};
|
|
1675
|
+
}, [
|
|
1676
|
+
onOpenChange
|
|
1677
|
+
]);
|
|
1678
|
+
const [searchRef, handleTypeaheadSearch] = $cc7e05a45900e73f$var$useTypeaheadSearch((search) => {
|
|
1679
|
+
const enabledItems = getItems().filter(
|
|
1680
|
+
(item) => !item.disabled
|
|
1681
|
+
);
|
|
1682
|
+
const currentItem = enabledItems.find(
|
|
1683
|
+
(item) => item.ref.current === document.activeElement
|
|
1684
|
+
);
|
|
1685
|
+
const nextItem = $cc7e05a45900e73f$var$findNextItem(enabledItems, search, currentItem);
|
|
1686
|
+
if (nextItem)
|
|
1687
|
+
setTimeout(
|
|
1688
|
+
() => nextItem.ref.current.focus()
|
|
1689
|
+
);
|
|
1690
|
+
});
|
|
1691
|
+
const itemRefCallback = useCallback((node, value, disabled) => {
|
|
1692
|
+
const isFirstValidItem = !firstValidItemFoundRef.current && !disabled;
|
|
1693
|
+
const isSelectedItem = context.value !== void 0 && context.value === value;
|
|
1694
|
+
if (isSelectedItem || isFirstValidItem) {
|
|
1695
|
+
setSelectedItem(node);
|
|
1696
|
+
if (isFirstValidItem)
|
|
1697
|
+
firstValidItemFoundRef.current = true;
|
|
1698
|
+
}
|
|
1699
|
+
}, [
|
|
1700
|
+
context.value
|
|
1701
|
+
]);
|
|
1702
|
+
const handleItemLeave = useCallback(
|
|
1703
|
+
() => content === null || content === void 0 ? void 0 : content.focus(),
|
|
1704
|
+
[
|
|
1705
|
+
content
|
|
1706
|
+
]
|
|
1707
|
+
);
|
|
1708
|
+
const itemTextRefCallback = useCallback((node, value, disabled) => {
|
|
1709
|
+
const isFirstValidItem = !firstValidItemFoundRef.current && !disabled;
|
|
1710
|
+
const isSelectedItem = context.value !== void 0 && context.value === value;
|
|
1711
|
+
if (isSelectedItem || isFirstValidItem)
|
|
1712
|
+
setSelectedItemText(node);
|
|
1713
|
+
}, [
|
|
1714
|
+
context.value
|
|
1715
|
+
]);
|
|
1716
|
+
const SelectPosition = position === "popper" ? $cc7e05a45900e73f$var$SelectPopperPosition : $cc7e05a45900e73f$var$SelectItemAlignedPosition;
|
|
1717
|
+
const popperContentProps = SelectPosition === $cc7e05a45900e73f$var$SelectPopperPosition ? {
|
|
1718
|
+
side,
|
|
1719
|
+
sideOffset,
|
|
1720
|
+
align,
|
|
1721
|
+
alignOffset,
|
|
1722
|
+
arrowPadding,
|
|
1723
|
+
collisionBoundary,
|
|
1724
|
+
collisionPadding,
|
|
1725
|
+
sticky,
|
|
1726
|
+
hideWhenDetached,
|
|
1727
|
+
avoidCollisions
|
|
1728
|
+
} : {};
|
|
1729
|
+
return /* @__PURE__ */ createElement($cc7e05a45900e73f$var$SelectContentProvider, {
|
|
1730
|
+
scope: __scopeSelect,
|
|
1731
|
+
content,
|
|
1732
|
+
viewport,
|
|
1733
|
+
onViewportChange: setViewport,
|
|
1734
|
+
itemRefCallback,
|
|
1735
|
+
selectedItem,
|
|
1736
|
+
onItemLeave: handleItemLeave,
|
|
1737
|
+
itemTextRefCallback,
|
|
1738
|
+
focusSelectedItem,
|
|
1739
|
+
selectedItemText,
|
|
1740
|
+
position,
|
|
1741
|
+
isPositioned,
|
|
1742
|
+
searchRef
|
|
1743
|
+
}, /* @__PURE__ */ createElement(RemoveScroll, {
|
|
1744
|
+
as: $5e63c961fc1ce211$export$8c6ed5c666ac1360,
|
|
1745
|
+
allowPinchZoom: true
|
|
1746
|
+
}, /* @__PURE__ */ createElement(FocusScope, {
|
|
1747
|
+
asChild: true,
|
|
1748
|
+
trapped: context.open,
|
|
1749
|
+
onMountAutoFocus: (event) => {
|
|
1750
|
+
event.preventDefault();
|
|
1751
|
+
},
|
|
1752
|
+
onUnmountAutoFocus: composeEventHandlers(onCloseAutoFocus, (event) => {
|
|
1753
|
+
var _context$trigger;
|
|
1754
|
+
(_context$trigger = context.trigger) === null || _context$trigger === void 0 || _context$trigger.focus({
|
|
1755
|
+
preventScroll: true
|
|
1756
|
+
});
|
|
1757
|
+
event.preventDefault();
|
|
1758
|
+
})
|
|
1759
|
+
}, /* @__PURE__ */ createElement(DismissableLayer, {
|
|
1760
|
+
asChild: true,
|
|
1761
|
+
disableOutsidePointerEvents: true,
|
|
1762
|
+
onEscapeKeyDown,
|
|
1763
|
+
onPointerDownOutside,
|
|
1764
|
+
onFocusOutside: (event) => event.preventDefault(),
|
|
1765
|
+
onDismiss: () => context.onOpenChange(false)
|
|
1766
|
+
}, /* @__PURE__ */ createElement(SelectPosition, $01b9c$babelruntimehelpersesmextends({
|
|
1767
|
+
role: "listbox",
|
|
1768
|
+
id: context.contentId,
|
|
1769
|
+
"data-state": context.open ? "open" : "closed",
|
|
1770
|
+
dir: context.dir,
|
|
1771
|
+
onContextMenu: (event) => event.preventDefault()
|
|
1772
|
+
}, contentProps, popperContentProps, {
|
|
1773
|
+
onPlaced: () => setIsPositioned(true),
|
|
1774
|
+
ref: composedRefs,
|
|
1775
|
+
style: {
|
|
1776
|
+
// flex layout so we can place the scroll buttons properly
|
|
1777
|
+
display: "flex",
|
|
1778
|
+
flexDirection: "column",
|
|
1779
|
+
// reset the outline by default as the content MAY get focused
|
|
1780
|
+
outline: "none",
|
|
1781
|
+
...contentProps.style
|
|
1782
|
+
},
|
|
1783
|
+
onKeyDown: composeEventHandlers(contentProps.onKeyDown, (event) => {
|
|
1784
|
+
const isModifierKey = event.ctrlKey || event.altKey || event.metaKey;
|
|
1785
|
+
if (event.key === "Tab")
|
|
1786
|
+
event.preventDefault();
|
|
1787
|
+
if (!isModifierKey && event.key.length === 1)
|
|
1788
|
+
handleTypeaheadSearch(event.key);
|
|
1789
|
+
if ([
|
|
1790
|
+
"ArrowUp",
|
|
1791
|
+
"ArrowDown",
|
|
1792
|
+
"Home",
|
|
1793
|
+
"End"
|
|
1794
|
+
].includes(event.key)) {
|
|
1795
|
+
const items = getItems().filter(
|
|
1796
|
+
(item) => !item.disabled
|
|
1797
|
+
);
|
|
1798
|
+
let candidateNodes = items.map(
|
|
1799
|
+
(item) => item.ref.current
|
|
1800
|
+
);
|
|
1801
|
+
if ([
|
|
1802
|
+
"ArrowUp",
|
|
1803
|
+
"End"
|
|
1804
|
+
].includes(event.key))
|
|
1805
|
+
candidateNodes = candidateNodes.slice().reverse();
|
|
1806
|
+
if ([
|
|
1807
|
+
"ArrowUp",
|
|
1808
|
+
"ArrowDown"
|
|
1809
|
+
].includes(event.key)) {
|
|
1810
|
+
const currentElement = event.target;
|
|
1811
|
+
const currentIndex = candidateNodes.indexOf(currentElement);
|
|
1812
|
+
candidateNodes = candidateNodes.slice(currentIndex + 1);
|
|
1813
|
+
}
|
|
1814
|
+
setTimeout(
|
|
1815
|
+
() => focusFirst(candidateNodes)
|
|
1816
|
+
);
|
|
1817
|
+
event.preventDefault();
|
|
1818
|
+
}
|
|
1819
|
+
})
|
|
1820
|
+
}))))));
|
|
1821
|
+
});
|
|
1822
|
+
var $cc7e05a45900e73f$var$SelectItemAlignedPosition = /* @__PURE__ */ forwardRef((props, forwardedRef) => {
|
|
1823
|
+
const { __scopeSelect, onPlaced, ...popperProps } = props;
|
|
1824
|
+
const context = $cc7e05a45900e73f$var$useSelectContext($cc7e05a45900e73f$var$CONTENT_NAME, __scopeSelect);
|
|
1825
|
+
const contentContext = $cc7e05a45900e73f$var$useSelectContentContext($cc7e05a45900e73f$var$CONTENT_NAME, __scopeSelect);
|
|
1826
|
+
const [contentWrapper, setContentWrapper] = useState(null);
|
|
1827
|
+
const [content, setContent] = useState(null);
|
|
1828
|
+
const composedRefs = useComposedRefs(
|
|
1829
|
+
forwardedRef,
|
|
1830
|
+
(node) => setContent(node)
|
|
1831
|
+
);
|
|
1832
|
+
const getItems = $cc7e05a45900e73f$var$useCollection(__scopeSelect);
|
|
1833
|
+
const shouldExpandOnScrollRef = useRef(false);
|
|
1834
|
+
const shouldRepositionRef = useRef(true);
|
|
1835
|
+
const { viewport, selectedItem, selectedItemText, focusSelectedItem } = contentContext;
|
|
1836
|
+
const position = useCallback(() => {
|
|
1837
|
+
if (context.trigger && context.valueNode && contentWrapper && content && viewport && selectedItem && selectedItemText) {
|
|
1838
|
+
const triggerRect = context.trigger.getBoundingClientRect();
|
|
1839
|
+
const contentRect = content.getBoundingClientRect();
|
|
1840
|
+
const valueNodeRect = context.valueNode.getBoundingClientRect();
|
|
1841
|
+
const itemTextRect = selectedItemText.getBoundingClientRect();
|
|
1842
|
+
if (context.dir !== "rtl") {
|
|
1843
|
+
const itemTextOffset = itemTextRect.left - contentRect.left;
|
|
1844
|
+
const left = valueNodeRect.left - itemTextOffset;
|
|
1845
|
+
const leftDelta = triggerRect.left - left;
|
|
1846
|
+
const minContentWidth = triggerRect.width + leftDelta;
|
|
1847
|
+
const contentWidth = Math.max(minContentWidth, contentRect.width);
|
|
1848
|
+
const rightEdge = window.innerWidth - $cc7e05a45900e73f$var$CONTENT_MARGIN;
|
|
1849
|
+
const clampedLeft = clamp(left, [
|
|
1850
|
+
$cc7e05a45900e73f$var$CONTENT_MARGIN,
|
|
1851
|
+
rightEdge - contentWidth
|
|
1852
|
+
]);
|
|
1853
|
+
contentWrapper.style.minWidth = minContentWidth + "px";
|
|
1854
|
+
contentWrapper.style.left = clampedLeft + "px";
|
|
1855
|
+
} else {
|
|
1856
|
+
const itemTextOffset = contentRect.right - itemTextRect.right;
|
|
1857
|
+
const right = window.innerWidth - valueNodeRect.right - itemTextOffset;
|
|
1858
|
+
const rightDelta = window.innerWidth - triggerRect.right - right;
|
|
1859
|
+
const minContentWidth = triggerRect.width + rightDelta;
|
|
1860
|
+
const contentWidth = Math.max(minContentWidth, contentRect.width);
|
|
1861
|
+
const leftEdge = window.innerWidth - $cc7e05a45900e73f$var$CONTENT_MARGIN;
|
|
1862
|
+
const clampedRight = clamp(right, [
|
|
1863
|
+
$cc7e05a45900e73f$var$CONTENT_MARGIN,
|
|
1864
|
+
leftEdge - contentWidth
|
|
1865
|
+
]);
|
|
1866
|
+
contentWrapper.style.minWidth = minContentWidth + "px";
|
|
1867
|
+
contentWrapper.style.right = clampedRight + "px";
|
|
1868
|
+
}
|
|
1869
|
+
const items = getItems();
|
|
1870
|
+
const availableHeight = window.innerHeight - $cc7e05a45900e73f$var$CONTENT_MARGIN * 2;
|
|
1871
|
+
const itemsHeight = viewport.scrollHeight;
|
|
1872
|
+
const contentStyles = window.getComputedStyle(content);
|
|
1873
|
+
const contentBorderTopWidth = parseInt(contentStyles.borderTopWidth, 10);
|
|
1874
|
+
const contentPaddingTop = parseInt(contentStyles.paddingTop, 10);
|
|
1875
|
+
const contentBorderBottomWidth = parseInt(contentStyles.borderBottomWidth, 10);
|
|
1876
|
+
const contentPaddingBottom = parseInt(contentStyles.paddingBottom, 10);
|
|
1877
|
+
const fullContentHeight = contentBorderTopWidth + contentPaddingTop + itemsHeight + contentPaddingBottom + contentBorderBottomWidth;
|
|
1878
|
+
const minContentHeight = Math.min(selectedItem.offsetHeight * 5, fullContentHeight);
|
|
1879
|
+
const viewportStyles = window.getComputedStyle(viewport);
|
|
1880
|
+
const viewportPaddingTop = parseInt(viewportStyles.paddingTop, 10);
|
|
1881
|
+
const viewportPaddingBottom = parseInt(viewportStyles.paddingBottom, 10);
|
|
1882
|
+
const topEdgeToTriggerMiddle = triggerRect.top + triggerRect.height / 2 - $cc7e05a45900e73f$var$CONTENT_MARGIN;
|
|
1883
|
+
const triggerMiddleToBottomEdge = availableHeight - topEdgeToTriggerMiddle;
|
|
1884
|
+
const selectedItemHalfHeight = selectedItem.offsetHeight / 2;
|
|
1885
|
+
const itemOffsetMiddle = selectedItem.offsetTop + selectedItemHalfHeight;
|
|
1886
|
+
const contentTopToItemMiddle = contentBorderTopWidth + contentPaddingTop + itemOffsetMiddle;
|
|
1887
|
+
const itemMiddleToContentBottom = fullContentHeight - contentTopToItemMiddle;
|
|
1888
|
+
const willAlignWithoutTopOverflow = contentTopToItemMiddle <= topEdgeToTriggerMiddle;
|
|
1889
|
+
if (willAlignWithoutTopOverflow) {
|
|
1890
|
+
const isLastItem = selectedItem === items[items.length - 1].ref.current;
|
|
1891
|
+
contentWrapper.style.bottom = "0px";
|
|
1892
|
+
const viewportOffsetBottom = content.clientHeight - viewport.offsetTop - viewport.offsetHeight;
|
|
1893
|
+
const clampedTriggerMiddleToBottomEdge = Math.max(triggerMiddleToBottomEdge, selectedItemHalfHeight + (isLastItem ? viewportPaddingBottom : 0) + viewportOffsetBottom + contentBorderBottomWidth);
|
|
1894
|
+
const height = contentTopToItemMiddle + clampedTriggerMiddleToBottomEdge;
|
|
1895
|
+
contentWrapper.style.height = height + "px";
|
|
1896
|
+
} else {
|
|
1897
|
+
const isFirstItem = selectedItem === items[0].ref.current;
|
|
1898
|
+
contentWrapper.style.top = "0px";
|
|
1899
|
+
const clampedTopEdgeToTriggerMiddle = Math.max(topEdgeToTriggerMiddle, contentBorderTopWidth + viewport.offsetTop + (isFirstItem ? viewportPaddingTop : 0) + selectedItemHalfHeight);
|
|
1900
|
+
const height = clampedTopEdgeToTriggerMiddle + itemMiddleToContentBottom;
|
|
1901
|
+
contentWrapper.style.height = height + "px";
|
|
1902
|
+
viewport.scrollTop = contentTopToItemMiddle - topEdgeToTriggerMiddle + viewport.offsetTop;
|
|
1903
|
+
}
|
|
1904
|
+
contentWrapper.style.margin = `${$cc7e05a45900e73f$var$CONTENT_MARGIN}px 0`;
|
|
1905
|
+
contentWrapper.style.minHeight = minContentHeight + "px";
|
|
1906
|
+
contentWrapper.style.maxHeight = availableHeight + "px";
|
|
1907
|
+
onPlaced === null || onPlaced === void 0 || onPlaced();
|
|
1908
|
+
requestAnimationFrame(
|
|
1909
|
+
() => shouldExpandOnScrollRef.current = true
|
|
1910
|
+
);
|
|
1911
|
+
}
|
|
1912
|
+
}, [
|
|
1913
|
+
getItems,
|
|
1914
|
+
context.trigger,
|
|
1915
|
+
context.valueNode,
|
|
1916
|
+
contentWrapper,
|
|
1917
|
+
content,
|
|
1918
|
+
viewport,
|
|
1919
|
+
selectedItem,
|
|
1920
|
+
selectedItemText,
|
|
1921
|
+
context.dir,
|
|
1922
|
+
onPlaced
|
|
1923
|
+
]);
|
|
1924
|
+
useLayoutEffect(
|
|
1925
|
+
() => position(),
|
|
1926
|
+
[
|
|
1927
|
+
position
|
|
1928
|
+
]
|
|
1929
|
+
);
|
|
1930
|
+
const [contentZIndex, setContentZIndex] = useState();
|
|
1931
|
+
useLayoutEffect(() => {
|
|
1932
|
+
if (content)
|
|
1933
|
+
setContentZIndex(window.getComputedStyle(content).zIndex);
|
|
1934
|
+
}, [
|
|
1935
|
+
content
|
|
1936
|
+
]);
|
|
1937
|
+
const handleScrollButtonChange = useCallback((node) => {
|
|
1938
|
+
if (node && shouldRepositionRef.current === true) {
|
|
1939
|
+
position();
|
|
1940
|
+
focusSelectedItem === null || focusSelectedItem === void 0 || focusSelectedItem();
|
|
1941
|
+
shouldRepositionRef.current = false;
|
|
1942
|
+
}
|
|
1943
|
+
}, [
|
|
1944
|
+
position,
|
|
1945
|
+
focusSelectedItem
|
|
1946
|
+
]);
|
|
1947
|
+
return /* @__PURE__ */ createElement($cc7e05a45900e73f$var$SelectViewportProvider, {
|
|
1948
|
+
scope: __scopeSelect,
|
|
1949
|
+
contentWrapper,
|
|
1950
|
+
shouldExpandOnScrollRef,
|
|
1951
|
+
onScrollButtonChange: handleScrollButtonChange
|
|
1952
|
+
}, /* @__PURE__ */ createElement("div", {
|
|
1953
|
+
ref: setContentWrapper,
|
|
1954
|
+
style: {
|
|
1955
|
+
display: "flex",
|
|
1956
|
+
flexDirection: "column",
|
|
1957
|
+
position: "fixed",
|
|
1958
|
+
zIndex: contentZIndex
|
|
1959
|
+
}
|
|
1960
|
+
}, /* @__PURE__ */ createElement(Primitive.div, $01b9c$babelruntimehelpersesmextends({}, popperProps, {
|
|
1961
|
+
ref: composedRefs,
|
|
1962
|
+
style: {
|
|
1963
|
+
// When we get the height of the content, it includes borders. If we were to set
|
|
1964
|
+
// the height without having `boxSizing: 'border-box'` it would be too big.
|
|
1965
|
+
boxSizing: "border-box",
|
|
1966
|
+
// We need to ensure the content doesn't get taller than the wrapper
|
|
1967
|
+
maxHeight: "100%",
|
|
1968
|
+
...popperProps.style
|
|
1969
|
+
}
|
|
1970
|
+
}))));
|
|
1971
|
+
});
|
|
1972
|
+
var $cc7e05a45900e73f$var$SelectPopperPosition = /* @__PURE__ */ forwardRef((props, forwardedRef) => {
|
|
1973
|
+
const { __scopeSelect, align = "start", collisionPadding = $cc7e05a45900e73f$var$CONTENT_MARGIN, ...popperProps } = props;
|
|
1974
|
+
const popperScope = $cc7e05a45900e73f$var$usePopperScope(__scopeSelect);
|
|
1975
|
+
return /* @__PURE__ */ createElement(Content, $01b9c$babelruntimehelpersesmextends({}, popperScope, popperProps, {
|
|
1976
|
+
ref: forwardedRef,
|
|
1977
|
+
align,
|
|
1978
|
+
collisionPadding,
|
|
1979
|
+
style: {
|
|
1980
|
+
// Ensure border-box for floating-ui calculations
|
|
1981
|
+
boxSizing: "border-box",
|
|
1982
|
+
...popperProps.style,
|
|
1983
|
+
"--radix-select-content-transform-origin": "var(--radix-popper-transform-origin)",
|
|
1984
|
+
"--radix-select-content-available-width": "var(--radix-popper-available-width)",
|
|
1985
|
+
"--radix-select-content-available-height": "var(--radix-popper-available-height)",
|
|
1986
|
+
"--radix-select-trigger-width": "var(--radix-popper-anchor-width)",
|
|
1987
|
+
"--radix-select-trigger-height": "var(--radix-popper-anchor-height)"
|
|
1988
|
+
}
|
|
1989
|
+
}));
|
|
1990
|
+
});
|
|
1991
|
+
var [$cc7e05a45900e73f$var$SelectViewportProvider, $cc7e05a45900e73f$var$useSelectViewportContext] = $cc7e05a45900e73f$var$createSelectContext($cc7e05a45900e73f$var$CONTENT_NAME, {});
|
|
1992
|
+
var $cc7e05a45900e73f$var$VIEWPORT_NAME = "SelectViewport";
|
|
1993
|
+
var $cc7e05a45900e73f$export$9ed6e7b40248d36d = /* @__PURE__ */ forwardRef((props, forwardedRef) => {
|
|
1994
|
+
const { __scopeSelect, ...viewportProps } = props;
|
|
1995
|
+
const contentContext = $cc7e05a45900e73f$var$useSelectContentContext($cc7e05a45900e73f$var$VIEWPORT_NAME, __scopeSelect);
|
|
1996
|
+
const viewportContext = $cc7e05a45900e73f$var$useSelectViewportContext($cc7e05a45900e73f$var$VIEWPORT_NAME, __scopeSelect);
|
|
1997
|
+
const composedRefs = useComposedRefs(forwardedRef, contentContext.onViewportChange);
|
|
1998
|
+
const prevScrollTopRef = useRef(0);
|
|
1999
|
+
return /* @__PURE__ */ createElement(Fragment, null, /* @__PURE__ */ createElement("style", {
|
|
2000
|
+
dangerouslySetInnerHTML: {
|
|
2001
|
+
__html: `[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}`
|
|
2002
|
+
}
|
|
2003
|
+
}), /* @__PURE__ */ createElement($cc7e05a45900e73f$var$Collection.Slot, {
|
|
2004
|
+
scope: __scopeSelect
|
|
2005
|
+
}, /* @__PURE__ */ createElement(Primitive.div, $01b9c$babelruntimehelpersesmextends({
|
|
2006
|
+
"data-radix-select-viewport": "",
|
|
2007
|
+
role: "presentation"
|
|
2008
|
+
}, viewportProps, {
|
|
2009
|
+
ref: composedRefs,
|
|
2010
|
+
style: {
|
|
2011
|
+
// we use position: 'relative' here on the `viewport` so that when we call
|
|
2012
|
+
// `selectedItem.offsetTop` in calculations, the offset is relative to the viewport
|
|
2013
|
+
// (independent of the scrollUpButton).
|
|
2014
|
+
position: "relative",
|
|
2015
|
+
flex: 1,
|
|
2016
|
+
overflow: "auto",
|
|
2017
|
+
...viewportProps.style
|
|
2018
|
+
},
|
|
2019
|
+
onScroll: composeEventHandlers(viewportProps.onScroll, (event) => {
|
|
2020
|
+
const viewport = event.currentTarget;
|
|
2021
|
+
const { contentWrapper, shouldExpandOnScrollRef } = viewportContext;
|
|
2022
|
+
if (shouldExpandOnScrollRef !== null && shouldExpandOnScrollRef !== void 0 && shouldExpandOnScrollRef.current && contentWrapper) {
|
|
2023
|
+
const scrolledBy = Math.abs(prevScrollTopRef.current - viewport.scrollTop);
|
|
2024
|
+
if (scrolledBy > 0) {
|
|
2025
|
+
const availableHeight = window.innerHeight - $cc7e05a45900e73f$var$CONTENT_MARGIN * 2;
|
|
2026
|
+
const cssMinHeight = parseFloat(contentWrapper.style.minHeight);
|
|
2027
|
+
const cssHeight = parseFloat(contentWrapper.style.height);
|
|
2028
|
+
const prevHeight = Math.max(cssMinHeight, cssHeight);
|
|
2029
|
+
if (prevHeight < availableHeight) {
|
|
2030
|
+
const nextHeight = prevHeight + scrolledBy;
|
|
2031
|
+
const clampedNextHeight = Math.min(availableHeight, nextHeight);
|
|
2032
|
+
const heightDiff = nextHeight - clampedNextHeight;
|
|
2033
|
+
contentWrapper.style.height = clampedNextHeight + "px";
|
|
2034
|
+
if (contentWrapper.style.bottom === "0px") {
|
|
2035
|
+
viewport.scrollTop = heightDiff > 0 ? heightDiff : 0;
|
|
2036
|
+
contentWrapper.style.justifyContent = "flex-end";
|
|
2037
|
+
}
|
|
2038
|
+
}
|
|
2039
|
+
}
|
|
2040
|
+
}
|
|
2041
|
+
prevScrollTopRef.current = viewport.scrollTop;
|
|
2042
|
+
})
|
|
2043
|
+
}))));
|
|
2044
|
+
});
|
|
2045
|
+
var $cc7e05a45900e73f$var$GROUP_NAME = "SelectGroup";
|
|
2046
|
+
var [$cc7e05a45900e73f$var$SelectGroupContextProvider, $cc7e05a45900e73f$var$useSelectGroupContext] = $cc7e05a45900e73f$var$createSelectContext($cc7e05a45900e73f$var$GROUP_NAME);
|
|
2047
|
+
var $cc7e05a45900e73f$var$LABEL_NAME = "SelectLabel";
|
|
2048
|
+
var $cc7e05a45900e73f$export$f67338d29bd972f8 = /* @__PURE__ */ forwardRef((props, forwardedRef) => {
|
|
2049
|
+
const { __scopeSelect, ...labelProps } = props;
|
|
2050
|
+
const groupContext = $cc7e05a45900e73f$var$useSelectGroupContext($cc7e05a45900e73f$var$LABEL_NAME, __scopeSelect);
|
|
2051
|
+
return /* @__PURE__ */ createElement(Primitive.div, $01b9c$babelruntimehelpersesmextends({
|
|
2052
|
+
id: groupContext.id
|
|
2053
|
+
}, labelProps, {
|
|
2054
|
+
ref: forwardedRef
|
|
2055
|
+
}));
|
|
2056
|
+
});
|
|
2057
|
+
var $cc7e05a45900e73f$var$ITEM_NAME = "SelectItem";
|
|
2058
|
+
var [$cc7e05a45900e73f$var$SelectItemContextProvider, $cc7e05a45900e73f$var$useSelectItemContext] = $cc7e05a45900e73f$var$createSelectContext($cc7e05a45900e73f$var$ITEM_NAME);
|
|
2059
|
+
var $cc7e05a45900e73f$export$13ef48a934230896 = /* @__PURE__ */ forwardRef((props, forwardedRef) => {
|
|
2060
|
+
const { __scopeSelect, value, disabled = false, textValue: textValueProp, ...itemProps } = props;
|
|
2061
|
+
const context = $cc7e05a45900e73f$var$useSelectContext($cc7e05a45900e73f$var$ITEM_NAME, __scopeSelect);
|
|
2062
|
+
const contentContext = $cc7e05a45900e73f$var$useSelectContentContext($cc7e05a45900e73f$var$ITEM_NAME, __scopeSelect);
|
|
2063
|
+
const isSelected = context.value === value;
|
|
2064
|
+
const [textValue, setTextValue] = useState(textValueProp !== null && textValueProp !== void 0 ? textValueProp : "");
|
|
2065
|
+
const [isFocused, setIsFocused] = useState(false);
|
|
2066
|
+
const composedRefs = useComposedRefs(forwardedRef, (node) => {
|
|
2067
|
+
var _contentContext$itemR;
|
|
2068
|
+
return (_contentContext$itemR = contentContext.itemRefCallback) === null || _contentContext$itemR === void 0 ? void 0 : _contentContext$itemR.call(contentContext, node, value, disabled);
|
|
2069
|
+
});
|
|
2070
|
+
const textId = useId();
|
|
2071
|
+
const handleSelect = () => {
|
|
2072
|
+
if (!disabled) {
|
|
2073
|
+
context.onValueChange(value);
|
|
2074
|
+
context.onOpenChange(false);
|
|
2075
|
+
}
|
|
2076
|
+
};
|
|
2077
|
+
if (value === "")
|
|
2078
|
+
throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");
|
|
2079
|
+
return /* @__PURE__ */ createElement($cc7e05a45900e73f$var$SelectItemContextProvider, {
|
|
2080
|
+
scope: __scopeSelect,
|
|
2081
|
+
value,
|
|
2082
|
+
disabled,
|
|
2083
|
+
textId,
|
|
2084
|
+
isSelected,
|
|
2085
|
+
onItemTextChange: useCallback((node) => {
|
|
2086
|
+
setTextValue((prevTextValue) => {
|
|
2087
|
+
var _node$textContent;
|
|
2088
|
+
return prevTextValue || ((_node$textContent = node === null || node === void 0 ? void 0 : node.textContent) !== null && _node$textContent !== void 0 ? _node$textContent : "").trim();
|
|
2089
|
+
});
|
|
2090
|
+
}, [])
|
|
2091
|
+
}, /* @__PURE__ */ createElement($cc7e05a45900e73f$var$Collection.ItemSlot, {
|
|
2092
|
+
scope: __scopeSelect,
|
|
2093
|
+
value,
|
|
2094
|
+
disabled,
|
|
2095
|
+
textValue
|
|
2096
|
+
}, /* @__PURE__ */ createElement(Primitive.div, $01b9c$babelruntimehelpersesmextends({
|
|
2097
|
+
role: "option",
|
|
2098
|
+
"aria-labelledby": textId,
|
|
2099
|
+
"data-highlighted": isFocused ? "" : void 0,
|
|
2100
|
+
"aria-selected": isSelected && isFocused,
|
|
2101
|
+
"data-state": isSelected ? "checked" : "unchecked",
|
|
2102
|
+
"aria-disabled": disabled || void 0,
|
|
2103
|
+
"data-disabled": disabled ? "" : void 0,
|
|
2104
|
+
tabIndex: disabled ? void 0 : -1
|
|
2105
|
+
}, itemProps, {
|
|
2106
|
+
ref: composedRefs,
|
|
2107
|
+
onFocus: composeEventHandlers(
|
|
2108
|
+
itemProps.onFocus,
|
|
2109
|
+
() => setIsFocused(true)
|
|
2110
|
+
),
|
|
2111
|
+
onBlur: composeEventHandlers(
|
|
2112
|
+
itemProps.onBlur,
|
|
2113
|
+
() => setIsFocused(false)
|
|
2114
|
+
),
|
|
2115
|
+
onPointerUp: composeEventHandlers(itemProps.onPointerUp, handleSelect),
|
|
2116
|
+
onPointerMove: composeEventHandlers(itemProps.onPointerMove, (event) => {
|
|
2117
|
+
if (disabled) {
|
|
2118
|
+
var _contentContext$onIte;
|
|
2119
|
+
(_contentContext$onIte = contentContext.onItemLeave) === null || _contentContext$onIte === void 0 || _contentContext$onIte.call(contentContext);
|
|
2120
|
+
} else
|
|
2121
|
+
event.currentTarget.focus({
|
|
2122
|
+
preventScroll: true
|
|
2123
|
+
});
|
|
2124
|
+
}),
|
|
2125
|
+
onPointerLeave: composeEventHandlers(itemProps.onPointerLeave, (event) => {
|
|
2126
|
+
if (event.currentTarget === document.activeElement) {
|
|
2127
|
+
var _contentContext$onIte2;
|
|
2128
|
+
(_contentContext$onIte2 = contentContext.onItemLeave) === null || _contentContext$onIte2 === void 0 || _contentContext$onIte2.call(contentContext);
|
|
2129
|
+
}
|
|
2130
|
+
}),
|
|
2131
|
+
onKeyDown: composeEventHandlers(itemProps.onKeyDown, (event) => {
|
|
2132
|
+
var _contentContext$searc;
|
|
2133
|
+
const isTypingAhead = ((_contentContext$searc = contentContext.searchRef) === null || _contentContext$searc === void 0 ? void 0 : _contentContext$searc.current) !== "";
|
|
2134
|
+
if (isTypingAhead && event.key === " ")
|
|
2135
|
+
return;
|
|
2136
|
+
if ($cc7e05a45900e73f$var$SELECTION_KEYS.includes(event.key))
|
|
2137
|
+
handleSelect();
|
|
2138
|
+
if (event.key === " ")
|
|
2139
|
+
event.preventDefault();
|
|
2140
|
+
})
|
|
2141
|
+
}))));
|
|
2142
|
+
});
|
|
2143
|
+
var $cc7e05a45900e73f$var$ITEM_TEXT_NAME = "SelectItemText";
|
|
2144
|
+
var $cc7e05a45900e73f$export$3572fb0fb821ff49 = /* @__PURE__ */ forwardRef((props, forwardedRef) => {
|
|
2145
|
+
const { __scopeSelect, className, style, ...itemTextProps } = props;
|
|
2146
|
+
const context = $cc7e05a45900e73f$var$useSelectContext($cc7e05a45900e73f$var$ITEM_TEXT_NAME, __scopeSelect);
|
|
2147
|
+
const contentContext = $cc7e05a45900e73f$var$useSelectContentContext($cc7e05a45900e73f$var$ITEM_TEXT_NAME, __scopeSelect);
|
|
2148
|
+
const itemContext = $cc7e05a45900e73f$var$useSelectItemContext($cc7e05a45900e73f$var$ITEM_TEXT_NAME, __scopeSelect);
|
|
2149
|
+
const nativeOptionsContext = $cc7e05a45900e73f$var$useSelectNativeOptionsContext($cc7e05a45900e73f$var$ITEM_TEXT_NAME, __scopeSelect);
|
|
2150
|
+
const [itemTextNode, setItemTextNode] = useState(null);
|
|
2151
|
+
const composedRefs = useComposedRefs(
|
|
2152
|
+
forwardedRef,
|
|
2153
|
+
(node) => setItemTextNode(node),
|
|
2154
|
+
itemContext.onItemTextChange,
|
|
2155
|
+
(node) => {
|
|
2156
|
+
var _contentContext$itemT;
|
|
2157
|
+
return (_contentContext$itemT = contentContext.itemTextRefCallback) === null || _contentContext$itemT === void 0 ? void 0 : _contentContext$itemT.call(contentContext, node, itemContext.value, itemContext.disabled);
|
|
2158
|
+
}
|
|
2159
|
+
);
|
|
2160
|
+
const textContent = itemTextNode === null || itemTextNode === void 0 ? void 0 : itemTextNode.textContent;
|
|
2161
|
+
const nativeOption = useMemo$1(
|
|
2162
|
+
() => /* @__PURE__ */ createElement("option", {
|
|
2163
|
+
key: itemContext.value,
|
|
2164
|
+
value: itemContext.value,
|
|
2165
|
+
disabled: itemContext.disabled
|
|
2166
|
+
}, textContent),
|
|
2167
|
+
[
|
|
2168
|
+
itemContext.disabled,
|
|
2169
|
+
itemContext.value,
|
|
2170
|
+
textContent
|
|
2171
|
+
]
|
|
2172
|
+
);
|
|
2173
|
+
const { onNativeOptionAdd, onNativeOptionRemove } = nativeOptionsContext;
|
|
2174
|
+
useLayoutEffect(() => {
|
|
2175
|
+
onNativeOptionAdd(nativeOption);
|
|
2176
|
+
return () => onNativeOptionRemove(nativeOption);
|
|
2177
|
+
}, [
|
|
2178
|
+
onNativeOptionAdd,
|
|
2179
|
+
onNativeOptionRemove,
|
|
2180
|
+
nativeOption
|
|
2181
|
+
]);
|
|
2182
|
+
return /* @__PURE__ */ createElement(Fragment, null, /* @__PURE__ */ createElement(Primitive.span, $01b9c$babelruntimehelpersesmextends({
|
|
2183
|
+
id: itemContext.textId
|
|
2184
|
+
}, itemTextProps, {
|
|
2185
|
+
ref: composedRefs
|
|
2186
|
+
})), itemContext.isSelected && context.valueNode && !context.valueNodeHasChildren ? /* @__PURE__ */ createPortal(itemTextProps.children, context.valueNode) : null);
|
|
2187
|
+
});
|
|
2188
|
+
var $cc7e05a45900e73f$var$ITEM_INDICATOR_NAME = "SelectItemIndicator";
|
|
2189
|
+
var $cc7e05a45900e73f$export$6b9198de19accfe6 = /* @__PURE__ */ forwardRef((props, forwardedRef) => {
|
|
2190
|
+
const { __scopeSelect, ...itemIndicatorProps } = props;
|
|
2191
|
+
const itemContext = $cc7e05a45900e73f$var$useSelectItemContext($cc7e05a45900e73f$var$ITEM_INDICATOR_NAME, __scopeSelect);
|
|
2192
|
+
return itemContext.isSelected ? /* @__PURE__ */ createElement(Primitive.span, $01b9c$babelruntimehelpersesmextends({
|
|
2193
|
+
"aria-hidden": true
|
|
2194
|
+
}, itemIndicatorProps, {
|
|
2195
|
+
ref: forwardedRef
|
|
2196
|
+
})) : null;
|
|
2197
|
+
});
|
|
2198
|
+
var $cc7e05a45900e73f$var$SCROLL_UP_BUTTON_NAME = "SelectScrollUpButton";
|
|
2199
|
+
var $cc7e05a45900e73f$export$d8117927658af6d7 = /* @__PURE__ */ forwardRef((props, forwardedRef) => {
|
|
2200
|
+
const contentContext = $cc7e05a45900e73f$var$useSelectContentContext($cc7e05a45900e73f$var$SCROLL_UP_BUTTON_NAME, props.__scopeSelect);
|
|
2201
|
+
const viewportContext = $cc7e05a45900e73f$var$useSelectViewportContext($cc7e05a45900e73f$var$SCROLL_UP_BUTTON_NAME, props.__scopeSelect);
|
|
2202
|
+
const [canScrollUp1, setCanScrollUp] = useState(false);
|
|
2203
|
+
const composedRefs = useComposedRefs(forwardedRef, viewportContext.onScrollButtonChange);
|
|
2204
|
+
useLayoutEffect(() => {
|
|
2205
|
+
if (contentContext.viewport && contentContext.isPositioned) {
|
|
2206
|
+
let handleScroll2 = function() {
|
|
2207
|
+
const canScrollUp = viewport.scrollTop > 0;
|
|
2208
|
+
setCanScrollUp(canScrollUp);
|
|
2209
|
+
};
|
|
2210
|
+
const viewport = contentContext.viewport;
|
|
2211
|
+
handleScroll2();
|
|
2212
|
+
viewport.addEventListener("scroll", handleScroll2);
|
|
2213
|
+
return () => viewport.removeEventListener("scroll", handleScroll2);
|
|
2214
|
+
}
|
|
2215
|
+
}, [
|
|
2216
|
+
contentContext.viewport,
|
|
2217
|
+
contentContext.isPositioned
|
|
2218
|
+
]);
|
|
2219
|
+
return canScrollUp1 ? /* @__PURE__ */ createElement($cc7e05a45900e73f$var$SelectScrollButtonImpl, $01b9c$babelruntimehelpersesmextends({}, props, {
|
|
2220
|
+
ref: composedRefs,
|
|
2221
|
+
onAutoScroll: () => {
|
|
2222
|
+
const { viewport, selectedItem } = contentContext;
|
|
2223
|
+
if (viewport && selectedItem)
|
|
2224
|
+
viewport.scrollTop = viewport.scrollTop - selectedItem.offsetHeight;
|
|
2225
|
+
}
|
|
2226
|
+
})) : null;
|
|
2227
|
+
});
|
|
2228
|
+
var $cc7e05a45900e73f$var$SCROLL_DOWN_BUTTON_NAME = "SelectScrollDownButton";
|
|
2229
|
+
var $cc7e05a45900e73f$export$ff951e476c12189 = /* @__PURE__ */ forwardRef((props, forwardedRef) => {
|
|
2230
|
+
const contentContext = $cc7e05a45900e73f$var$useSelectContentContext($cc7e05a45900e73f$var$SCROLL_DOWN_BUTTON_NAME, props.__scopeSelect);
|
|
2231
|
+
const viewportContext = $cc7e05a45900e73f$var$useSelectViewportContext($cc7e05a45900e73f$var$SCROLL_DOWN_BUTTON_NAME, props.__scopeSelect);
|
|
2232
|
+
const [canScrollDown1, setCanScrollDown] = useState(false);
|
|
2233
|
+
const composedRefs = useComposedRefs(forwardedRef, viewportContext.onScrollButtonChange);
|
|
2234
|
+
useLayoutEffect(() => {
|
|
2235
|
+
if (contentContext.viewport && contentContext.isPositioned) {
|
|
2236
|
+
let handleScroll2 = function() {
|
|
2237
|
+
const maxScroll = viewport.scrollHeight - viewport.clientHeight;
|
|
2238
|
+
const canScrollDown = Math.ceil(viewport.scrollTop) < maxScroll;
|
|
2239
|
+
setCanScrollDown(canScrollDown);
|
|
2240
|
+
};
|
|
2241
|
+
const viewport = contentContext.viewport;
|
|
2242
|
+
handleScroll2();
|
|
2243
|
+
viewport.addEventListener("scroll", handleScroll2);
|
|
2244
|
+
return () => viewport.removeEventListener("scroll", handleScroll2);
|
|
2245
|
+
}
|
|
2246
|
+
}, [
|
|
2247
|
+
contentContext.viewport,
|
|
2248
|
+
contentContext.isPositioned
|
|
2249
|
+
]);
|
|
2250
|
+
return canScrollDown1 ? /* @__PURE__ */ createElement($cc7e05a45900e73f$var$SelectScrollButtonImpl, $01b9c$babelruntimehelpersesmextends({}, props, {
|
|
2251
|
+
ref: composedRefs,
|
|
2252
|
+
onAutoScroll: () => {
|
|
2253
|
+
const { viewport, selectedItem } = contentContext;
|
|
2254
|
+
if (viewport && selectedItem)
|
|
2255
|
+
viewport.scrollTop = viewport.scrollTop + selectedItem.offsetHeight;
|
|
2256
|
+
}
|
|
2257
|
+
})) : null;
|
|
2258
|
+
});
|
|
2259
|
+
var $cc7e05a45900e73f$var$SelectScrollButtonImpl = /* @__PURE__ */ forwardRef((props, forwardedRef) => {
|
|
2260
|
+
const { __scopeSelect, onAutoScroll, ...scrollIndicatorProps } = props;
|
|
2261
|
+
const contentContext = $cc7e05a45900e73f$var$useSelectContentContext("SelectScrollButton", __scopeSelect);
|
|
2262
|
+
const autoScrollTimerRef = useRef(null);
|
|
2263
|
+
const getItems = $cc7e05a45900e73f$var$useCollection(__scopeSelect);
|
|
2264
|
+
const clearAutoScrollTimer = useCallback(() => {
|
|
2265
|
+
if (autoScrollTimerRef.current !== null) {
|
|
2266
|
+
window.clearInterval(autoScrollTimerRef.current);
|
|
2267
|
+
autoScrollTimerRef.current = null;
|
|
2268
|
+
}
|
|
2269
|
+
}, []);
|
|
2270
|
+
useEffect(() => {
|
|
2271
|
+
return () => clearAutoScrollTimer();
|
|
2272
|
+
}, [
|
|
2273
|
+
clearAutoScrollTimer
|
|
2274
|
+
]);
|
|
2275
|
+
useLayoutEffect(() => {
|
|
2276
|
+
var _activeItem$ref$curre;
|
|
2277
|
+
const activeItem = getItems().find(
|
|
2278
|
+
(item) => item.ref.current === document.activeElement
|
|
2279
|
+
);
|
|
2280
|
+
activeItem === null || activeItem === void 0 || (_activeItem$ref$curre = activeItem.ref.current) === null || _activeItem$ref$curre === void 0 || _activeItem$ref$curre.scrollIntoView({
|
|
2281
|
+
block: "nearest"
|
|
2282
|
+
});
|
|
2283
|
+
}, [
|
|
2284
|
+
getItems
|
|
2285
|
+
]);
|
|
2286
|
+
return /* @__PURE__ */ createElement(Primitive.div, $01b9c$babelruntimehelpersesmextends({
|
|
2287
|
+
"aria-hidden": true
|
|
2288
|
+
}, scrollIndicatorProps, {
|
|
2289
|
+
ref: forwardedRef,
|
|
2290
|
+
style: {
|
|
2291
|
+
flexShrink: 0,
|
|
2292
|
+
...scrollIndicatorProps.style
|
|
2293
|
+
},
|
|
2294
|
+
onPointerDown: composeEventHandlers(scrollIndicatorProps.onPointerDown, () => {
|
|
2295
|
+
if (autoScrollTimerRef.current === null)
|
|
2296
|
+
autoScrollTimerRef.current = window.setInterval(onAutoScroll, 50);
|
|
2297
|
+
}),
|
|
2298
|
+
onPointerMove: composeEventHandlers(scrollIndicatorProps.onPointerMove, () => {
|
|
2299
|
+
var _contentContext$onIte3;
|
|
2300
|
+
(_contentContext$onIte3 = contentContext.onItemLeave) === null || _contentContext$onIte3 === void 0 || _contentContext$onIte3.call(contentContext);
|
|
2301
|
+
if (autoScrollTimerRef.current === null)
|
|
2302
|
+
autoScrollTimerRef.current = window.setInterval(onAutoScroll, 50);
|
|
2303
|
+
}),
|
|
2304
|
+
onPointerLeave: composeEventHandlers(scrollIndicatorProps.onPointerLeave, () => {
|
|
2305
|
+
clearAutoScrollTimer();
|
|
2306
|
+
})
|
|
2307
|
+
}));
|
|
2308
|
+
});
|
|
2309
|
+
var $cc7e05a45900e73f$export$eba4b1df07cb1d3 = /* @__PURE__ */ forwardRef((props, forwardedRef) => {
|
|
2310
|
+
const { __scopeSelect, ...separatorProps } = props;
|
|
2311
|
+
return /* @__PURE__ */ createElement(Primitive.div, $01b9c$babelruntimehelpersesmextends({
|
|
2312
|
+
"aria-hidden": true
|
|
2313
|
+
}, separatorProps, {
|
|
2314
|
+
ref: forwardedRef
|
|
2315
|
+
}));
|
|
2316
|
+
});
|
|
2317
|
+
function $cc7e05a45900e73f$var$shouldShowPlaceholder(value) {
|
|
2318
|
+
return value === "" || value === void 0;
|
|
2319
|
+
}
|
|
2320
|
+
var $cc7e05a45900e73f$var$BubbleSelect = /* @__PURE__ */ forwardRef((props, forwardedRef) => {
|
|
2321
|
+
const { value, ...selectProps } = props;
|
|
2322
|
+
const ref = useRef(null);
|
|
2323
|
+
const composedRefs = useComposedRefs(forwardedRef, ref);
|
|
2324
|
+
const prevValue = usePrevious(value);
|
|
2325
|
+
useEffect(() => {
|
|
2326
|
+
const select = ref.current;
|
|
2327
|
+
const selectProto = window.HTMLSelectElement.prototype;
|
|
2328
|
+
const descriptor = Object.getOwnPropertyDescriptor(selectProto, "value");
|
|
2329
|
+
const setValue = descriptor.set;
|
|
2330
|
+
if (prevValue !== value && setValue) {
|
|
2331
|
+
const event = new Event("change", {
|
|
2332
|
+
bubbles: true
|
|
2333
|
+
});
|
|
2334
|
+
setValue.call(select, value);
|
|
2335
|
+
select.dispatchEvent(event);
|
|
2336
|
+
}
|
|
2337
|
+
}, [
|
|
2338
|
+
prevValue,
|
|
2339
|
+
value
|
|
2340
|
+
]);
|
|
2341
|
+
return /* @__PURE__ */ createElement(VisuallyHidden, {
|
|
2342
|
+
asChild: true
|
|
2343
|
+
}, /* @__PURE__ */ createElement("select", $01b9c$babelruntimehelpersesmextends({}, selectProps, {
|
|
2344
|
+
ref: composedRefs,
|
|
2345
|
+
defaultValue: value
|
|
2346
|
+
})));
|
|
2347
|
+
});
|
|
2348
|
+
$cc7e05a45900e73f$var$BubbleSelect.displayName = "BubbleSelect";
|
|
2349
|
+
function $cc7e05a45900e73f$var$useTypeaheadSearch(onSearchChange) {
|
|
2350
|
+
const handleSearchChange = useCallbackRef(onSearchChange);
|
|
2351
|
+
const searchRef = useRef("");
|
|
2352
|
+
const timerRef = useRef(0);
|
|
2353
|
+
const handleTypeaheadSearch = useCallback((key) => {
|
|
2354
|
+
const search = searchRef.current + key;
|
|
2355
|
+
handleSearchChange(search);
|
|
2356
|
+
(function updateSearch(value) {
|
|
2357
|
+
searchRef.current = value;
|
|
2358
|
+
window.clearTimeout(timerRef.current);
|
|
2359
|
+
if (value !== "")
|
|
2360
|
+
timerRef.current = window.setTimeout(
|
|
2361
|
+
() => updateSearch(""),
|
|
2362
|
+
1e3
|
|
2363
|
+
);
|
|
2364
|
+
})(search);
|
|
2365
|
+
}, [
|
|
2366
|
+
handleSearchChange
|
|
2367
|
+
]);
|
|
2368
|
+
const resetTypeahead = useCallback(() => {
|
|
2369
|
+
searchRef.current = "";
|
|
2370
|
+
window.clearTimeout(timerRef.current);
|
|
2371
|
+
}, []);
|
|
2372
|
+
useEffect(() => {
|
|
2373
|
+
return () => window.clearTimeout(timerRef.current);
|
|
2374
|
+
}, []);
|
|
2375
|
+
return [
|
|
2376
|
+
searchRef,
|
|
2377
|
+
handleTypeaheadSearch,
|
|
2378
|
+
resetTypeahead
|
|
2379
|
+
];
|
|
2380
|
+
}
|
|
2381
|
+
function $cc7e05a45900e73f$var$findNextItem(items, search, currentItem) {
|
|
2382
|
+
const isRepeated = search.length > 1 && Array.from(search).every(
|
|
2383
|
+
(char) => char === search[0]
|
|
2384
|
+
);
|
|
2385
|
+
const normalizedSearch = isRepeated ? search[0] : search;
|
|
2386
|
+
const currentItemIndex = currentItem ? items.indexOf(currentItem) : -1;
|
|
2387
|
+
let wrappedItems = $cc7e05a45900e73f$var$wrapArray(items, Math.max(currentItemIndex, 0));
|
|
2388
|
+
const excludeCurrentItem = normalizedSearch.length === 1;
|
|
2389
|
+
if (excludeCurrentItem)
|
|
2390
|
+
wrappedItems = wrappedItems.filter(
|
|
2391
|
+
(v) => v !== currentItem
|
|
2392
|
+
);
|
|
2393
|
+
const nextItem = wrappedItems.find(
|
|
2394
|
+
(item) => item.textValue.toLowerCase().startsWith(normalizedSearch.toLowerCase())
|
|
2395
|
+
);
|
|
2396
|
+
return nextItem !== currentItem ? nextItem : void 0;
|
|
2397
|
+
}
|
|
2398
|
+
function $cc7e05a45900e73f$var$wrapArray(array, startIndex) {
|
|
2399
|
+
return array.map(
|
|
2400
|
+
(_, index) => array[(startIndex + index) % array.length]
|
|
2401
|
+
);
|
|
2402
|
+
}
|
|
2403
|
+
var $cc7e05a45900e73f$export$be92b6f5f03c0fe9 = $cc7e05a45900e73f$export$ef9b1a59e592288f;
|
|
2404
|
+
var $cc7e05a45900e73f$export$41fb9f06171c75f4 = $cc7e05a45900e73f$export$3ac1e88a1c0b9f1;
|
|
2405
|
+
var $cc7e05a45900e73f$export$4c8d1a57a761ef94 = $cc7e05a45900e73f$export$e288731fd71264f0;
|
|
2406
|
+
var $cc7e05a45900e73f$export$f04a61298a47a40f = $cc7e05a45900e73f$export$99b400cabb58c515;
|
|
2407
|
+
var $cc7e05a45900e73f$export$602eac185826482c = $cc7e05a45900e73f$export$b2af6c9944296213;
|
|
2408
|
+
var $cc7e05a45900e73f$export$7c6e2c02157bb7d2 = $cc7e05a45900e73f$export$c973a4b3cb86a03d;
|
|
2409
|
+
var $cc7e05a45900e73f$export$d5c6c08dc2d3ca7 = $cc7e05a45900e73f$export$9ed6e7b40248d36d;
|
|
2410
|
+
var $cc7e05a45900e73f$export$b04be29aa201d4f5 = $cc7e05a45900e73f$export$f67338d29bd972f8;
|
|
2411
|
+
var $cc7e05a45900e73f$export$6d08773d2e66f8f2 = $cc7e05a45900e73f$export$13ef48a934230896;
|
|
2412
|
+
var $cc7e05a45900e73f$export$d6e5bf9c43ea9319 = $cc7e05a45900e73f$export$3572fb0fb821ff49;
|
|
2413
|
+
var $cc7e05a45900e73f$export$c3468e2714d175fa = $cc7e05a45900e73f$export$6b9198de19accfe6;
|
|
2414
|
+
var $cc7e05a45900e73f$export$2f60d3ec9ad468f2 = $cc7e05a45900e73f$export$d8117927658af6d7;
|
|
2415
|
+
var $cc7e05a45900e73f$export$bf1aedc3039c8d63 = $cc7e05a45900e73f$export$ff951e476c12189;
|
|
2416
|
+
var $cc7e05a45900e73f$export$1ff3c3f08ae963c0 = $cc7e05a45900e73f$export$eba4b1df07cb1d3;
|
|
2417
|
+
var Select = $cc7e05a45900e73f$export$be92b6f5f03c0fe9;
|
|
2418
|
+
var SelectValue = $cc7e05a45900e73f$export$4c8d1a57a761ef94;
|
|
2419
|
+
var SelectTrigger = React4.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs(
|
|
2420
|
+
$cc7e05a45900e73f$export$41fb9f06171c75f4,
|
|
2421
|
+
{
|
|
2422
|
+
ref,
|
|
2423
|
+
className: cn(
|
|
2424
|
+
"flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent py-2 pr-px pl-3 text-sm shadow-sm ring-offset-background [&>span]:line-clamp-1 disabled:cursor-not-allowed placeholder:text-muted-foreground disabled:opacity-50 focus:outline-none focus:ring-1 focus:ring-ring",
|
|
2425
|
+
className
|
|
2426
|
+
),
|
|
2427
|
+
...props,
|
|
2428
|
+
children: [
|
|
2429
|
+
children,
|
|
2430
|
+
/* @__PURE__ */ jsx($cc7e05a45900e73f$export$f04a61298a47a40f, { asChild: true, children: /* @__PURE__ */ jsx(CaretSortIcon, { className: "h-4 w-4 opacity-50" }) })
|
|
2431
|
+
]
|
|
2432
|
+
}
|
|
2433
|
+
));
|
|
2434
|
+
SelectTrigger.displayName = $cc7e05a45900e73f$export$41fb9f06171c75f4.displayName;
|
|
2435
|
+
var SelectScrollUpButton = React4.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
2436
|
+
$cc7e05a45900e73f$export$2f60d3ec9ad468f2,
|
|
2437
|
+
{
|
|
2438
|
+
ref,
|
|
2439
|
+
className: cn("flex cursor-default items-center justify-center py-1", className),
|
|
2440
|
+
...props,
|
|
2441
|
+
children: /* @__PURE__ */ jsx(ChevronUpIcon, {})
|
|
2442
|
+
}
|
|
2443
|
+
));
|
|
2444
|
+
SelectScrollUpButton.displayName = $cc7e05a45900e73f$export$2f60d3ec9ad468f2.displayName;
|
|
2445
|
+
var SelectScrollDownButton = React4.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
2446
|
+
$cc7e05a45900e73f$export$bf1aedc3039c8d63,
|
|
2447
|
+
{
|
|
2448
|
+
ref,
|
|
2449
|
+
className: cn("flex cursor-default items-center justify-center py-1", className),
|
|
2450
|
+
...props,
|
|
2451
|
+
children: /* @__PURE__ */ jsx(ChevronDownIcon, {})
|
|
2452
|
+
}
|
|
2453
|
+
));
|
|
2454
|
+
SelectScrollDownButton.displayName = $cc7e05a45900e73f$export$bf1aedc3039c8d63.displayName;
|
|
2455
|
+
var SelectContent = React4.forwardRef(({ className, children, position = "popper", ...props }, ref) => /* @__PURE__ */ jsx($cc7e05a45900e73f$export$602eac185826482c, { children: /* @__PURE__ */ jsxs(
|
|
2456
|
+
$cc7e05a45900e73f$export$7c6e2c02157bb7d2,
|
|
2457
|
+
{
|
|
2458
|
+
ref,
|
|
2459
|
+
className: cn(
|
|
2460
|
+
"data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=closed]:animate-out data-[state=open]:animate-in",
|
|
2461
|
+
position === "popper" && "data-[side=left]:-translate-x-1 data-[side=top]:-translate-y-1 data-[side=right]:translate-x-1 data-[side=bottom]:translate-y-1",
|
|
2462
|
+
className
|
|
2463
|
+
),
|
|
2464
|
+
position,
|
|
2465
|
+
...props,
|
|
2466
|
+
children: [
|
|
2467
|
+
/* @__PURE__ */ jsx(SelectScrollUpButton, {}),
|
|
2468
|
+
/* @__PURE__ */ jsx(
|
|
2469
|
+
$cc7e05a45900e73f$export$d5c6c08dc2d3ca7,
|
|
2470
|
+
{
|
|
2471
|
+
className: cn(
|
|
2472
|
+
"p-1",
|
|
2473
|
+
position === "popper" && "h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"
|
|
2474
|
+
),
|
|
2475
|
+
children
|
|
2476
|
+
}
|
|
2477
|
+
),
|
|
2478
|
+
/* @__PURE__ */ jsx(SelectScrollDownButton, {})
|
|
2479
|
+
]
|
|
2480
|
+
}
|
|
2481
|
+
) }));
|
|
2482
|
+
SelectContent.displayName = $cc7e05a45900e73f$export$7c6e2c02157bb7d2.displayName;
|
|
2483
|
+
var SelectLabel = React4.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
2484
|
+
$cc7e05a45900e73f$export$b04be29aa201d4f5,
|
|
2485
|
+
{
|
|
2486
|
+
ref,
|
|
2487
|
+
className: cn("px-2 py-1.5 font-semibold text-sm", className),
|
|
2488
|
+
...props
|
|
2489
|
+
}
|
|
2490
|
+
));
|
|
2491
|
+
SelectLabel.displayName = $cc7e05a45900e73f$export$b04be29aa201d4f5.displayName;
|
|
2492
|
+
var SelectItem = React4.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs(
|
|
2493
|
+
$cc7e05a45900e73f$export$6d08773d2e66f8f2,
|
|
2494
|
+
{
|
|
2495
|
+
ref,
|
|
2496
|
+
className: cn(
|
|
2497
|
+
"relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pr-8 pl-2 text-sm outline-none data-[disabled]:pointer-events-none focus:bg-accent focus:text-accent-foreground data-[disabled]:opacity-50",
|
|
2498
|
+
className
|
|
2499
|
+
),
|
|
2500
|
+
...props,
|
|
2501
|
+
children: [
|
|
2502
|
+
/* @__PURE__ */ jsx("span", { className: "absolute right-2 flex h-3.5 w-3.5 items-center justify-center", children: /* @__PURE__ */ jsx($cc7e05a45900e73f$export$c3468e2714d175fa, { children: /* @__PURE__ */ jsx(CheckIcon, { className: "h-4 w-4" }) }) }),
|
|
2503
|
+
/* @__PURE__ */ jsx($cc7e05a45900e73f$export$d6e5bf9c43ea9319, { children })
|
|
2504
|
+
]
|
|
2505
|
+
}
|
|
2506
|
+
));
|
|
2507
|
+
SelectItem.displayName = $cc7e05a45900e73f$export$6d08773d2e66f8f2.displayName;
|
|
2508
|
+
var SelectSeparator = React4.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
2509
|
+
$cc7e05a45900e73f$export$1ff3c3f08ae963c0,
|
|
2510
|
+
{
|
|
2511
|
+
ref,
|
|
2512
|
+
className: cn("-mx-1 my-1 h-px bg-muted", className),
|
|
2513
|
+
...props
|
|
2514
|
+
}
|
|
2515
|
+
));
|
|
2516
|
+
SelectSeparator.displayName = $cc7e05a45900e73f$export$1ff3c3f08ae963c0.displayName;
|
|
2517
|
+
function BooleanDataEditor(props) {
|
|
2518
|
+
const { value, onBlur, onChange, onPaste } = props;
|
|
2519
|
+
const _onPaste = useCallback(
|
|
2520
|
+
(e) => {
|
|
2521
|
+
e.preventDefault();
|
|
2522
|
+
onPaste?.();
|
|
2523
|
+
},
|
|
2524
|
+
[onPaste]
|
|
2525
|
+
);
|
|
2526
|
+
return /* @__PURE__ */ jsxs(Select, { value, onValueChange: (data) => onChange?.({ data }), defaultOpen: true, children: [
|
|
2527
|
+
/* @__PURE__ */ jsx(
|
|
2528
|
+
SelectTrigger,
|
|
2529
|
+
{
|
|
2530
|
+
onBlur,
|
|
2531
|
+
onPaste: _onPaste,
|
|
2532
|
+
className: cn(
|
|
2533
|
+
"h-full w-full rounded-none border-none pl-1 text-xs outline-none focus:ring-0"
|
|
2534
|
+
),
|
|
2535
|
+
autoFocus: true,
|
|
2536
|
+
children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Selecionar" })
|
|
2537
|
+
}
|
|
2538
|
+
),
|
|
2539
|
+
/* @__PURE__ */ jsxs(SelectContent, { children: [
|
|
2540
|
+
/* @__PURE__ */ jsx(SelectItem, { className: "text-xs", value: "true", children: "Sim" }),
|
|
2541
|
+
/* @__PURE__ */ jsx(SelectItem, { className: "text-xs", value: "false", children: "N\xE3o" })
|
|
2542
|
+
] })
|
|
2543
|
+
] });
|
|
2544
|
+
}
|
|
2545
|
+
function BooleanDataViewer({ value }) {
|
|
2546
|
+
const empty = value === "";
|
|
2547
|
+
const displayValue = empty ? "Selecionar" : value === "true" ? "Sim" : "N\xE3o";
|
|
2548
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex h-full w-full items-center justify-between pr-px pl-1", children: [
|
|
2549
|
+
/* @__PURE__ */ jsx("p", { className: "line-clamp-1 text-xs", children: displayValue }),
|
|
2550
|
+
/* @__PURE__ */ jsx(CaretSortIcon, { className: "h-4 w-4 opacity-50" })
|
|
2551
|
+
] });
|
|
2552
|
+
}
|
|
2553
|
+
function DateDataEditor(props) {
|
|
2554
|
+
const { value, onBlur, onChange, onPaste } = props;
|
|
2555
|
+
const _onPaste = useCallback(
|
|
2556
|
+
(e) => {
|
|
2557
|
+
e.preventDefault();
|
|
2558
|
+
onPaste?.();
|
|
2559
|
+
},
|
|
2560
|
+
[onPaste]
|
|
2561
|
+
);
|
|
2562
|
+
return /* @__PURE__ */ jsx(
|
|
2563
|
+
"input",
|
|
2564
|
+
{
|
|
2565
|
+
type: "date",
|
|
2566
|
+
onBlur,
|
|
2567
|
+
onPaste: _onPaste,
|
|
2568
|
+
value,
|
|
2569
|
+
onChange: (e) => onChange?.({ data: e.target.value }),
|
|
2570
|
+
className: cn("h-full w-full bg-transparent pl-1 text-xs outline-none"),
|
|
2571
|
+
autoFocus: true
|
|
2572
|
+
}
|
|
2573
|
+
);
|
|
2574
|
+
}
|
|
2575
|
+
function DateDataViewer(props) {
|
|
2576
|
+
const { value } = props;
|
|
2577
|
+
const formatter = Intl.DateTimeFormat("pt-BR", { dateStyle: "short" });
|
|
2578
|
+
const formatted = value ? formatter.format(new Date(value)) : "dd/mm/yyyy";
|
|
2579
|
+
return /* @__PURE__ */ jsx("div", { className: "flex h-full w-full items-center", children: /* @__PURE__ */ jsx("p", { className: "line-clamp-1 pl-1 text-xs", children: formatted }) });
|
|
2580
|
+
}
|
|
2581
|
+
function NumericField(props) {
|
|
2582
|
+
const {
|
|
2583
|
+
className,
|
|
2584
|
+
dataEditorType,
|
|
2585
|
+
onFocus,
|
|
2586
|
+
onBlur,
|
|
2587
|
+
onChange,
|
|
2588
|
+
onClick,
|
|
2589
|
+
onPaste,
|
|
2590
|
+
settings,
|
|
2591
|
+
testid,
|
|
2592
|
+
value,
|
|
2593
|
+
disabled,
|
|
2594
|
+
dataCypress,
|
|
2595
|
+
tabIndex
|
|
2596
|
+
} = props;
|
|
2597
|
+
const thousandSeparator = ".";
|
|
2598
|
+
const decimalSeparator = ",";
|
|
2599
|
+
const decimalScale = getDecimalScale({
|
|
2600
|
+
dataEditorType,
|
|
2601
|
+
decimalScale: settings?.numeric?.decimalPlaces
|
|
2602
|
+
});
|
|
2603
|
+
const allowNegative = settings?.numeric?.allowNegative;
|
|
2604
|
+
const min = settings?.numeric?.min;
|
|
2605
|
+
const max = settings?.numeric?.max;
|
|
2606
|
+
const prefix = dataEditorType.toLocaleLowerCase() === "currency" ? "R$ " : "";
|
|
2607
|
+
const suffix = dataEditorType.toLocaleLowerCase() === "percentage" ? "%" : "";
|
|
2608
|
+
const [strValue, setStrValue] = useState(value);
|
|
2609
|
+
const [waitCapToOnBlur, setWaitCapToOnBlur] = useState(false);
|
|
2610
|
+
const onValueChange = ({ value: value2 }) => {
|
|
2611
|
+
setStrValue(value2);
|
|
2612
|
+
onChange?.(value2);
|
|
2613
|
+
};
|
|
2614
|
+
const _onBlur = () => {
|
|
2615
|
+
let waitCapToOnBlur2 = false;
|
|
2616
|
+
const numValue = Number(value);
|
|
2617
|
+
let newStrValue = value;
|
|
2618
|
+
if (typeof min === "number") {
|
|
2619
|
+
if (numValue < min)
|
|
2620
|
+
newStrValue = min.toString();
|
|
2621
|
+
}
|
|
2622
|
+
if (typeof max === "number") {
|
|
2623
|
+
if (numValue > max)
|
|
2624
|
+
newStrValue = max.toString();
|
|
2625
|
+
}
|
|
2626
|
+
if (newStrValue !== value) {
|
|
2627
|
+
waitCapToOnBlur2 = true;
|
|
2628
|
+
onChange?.(newStrValue);
|
|
2629
|
+
setStrValue(newStrValue);
|
|
2630
|
+
setWaitCapToOnBlur(waitCapToOnBlur2);
|
|
2631
|
+
}
|
|
2632
|
+
if (!waitCapToOnBlur2)
|
|
2633
|
+
onBlur?.();
|
|
2634
|
+
};
|
|
2635
|
+
useEffect(() => {
|
|
2636
|
+
if (waitCapToOnBlur) {
|
|
2637
|
+
onBlur?.();
|
|
2638
|
+
setWaitCapToOnBlur(false);
|
|
2639
|
+
}
|
|
2640
|
+
}, [onBlur, waitCapToOnBlur]);
|
|
2641
|
+
useEffect(() => {
|
|
2642
|
+
setStrValue(value);
|
|
2643
|
+
}, [value]);
|
|
2644
|
+
return /* @__PURE__ */ jsx(
|
|
2645
|
+
NumericFormat,
|
|
2646
|
+
{
|
|
2647
|
+
tabIndex,
|
|
2648
|
+
value: strValue,
|
|
2649
|
+
onPaste,
|
|
2650
|
+
prefix,
|
|
2651
|
+
suffix,
|
|
2652
|
+
fixedDecimalScale: true,
|
|
2653
|
+
onBlur: _onBlur,
|
|
2654
|
+
"data-testid": testid,
|
|
2655
|
+
valueIsNumericString: true,
|
|
2656
|
+
onFocus,
|
|
2657
|
+
onClick,
|
|
2658
|
+
decimalScale,
|
|
2659
|
+
onValueChange,
|
|
2660
|
+
allowNegative,
|
|
2661
|
+
decimalSeparator,
|
|
2662
|
+
thousandSeparator,
|
|
2663
|
+
className: cn(
|
|
2664
|
+
"h-full w-full rounded-none bg-transparent pl-1 text-xs outline-none",
|
|
2665
|
+
className
|
|
2666
|
+
),
|
|
2667
|
+
disabled,
|
|
2668
|
+
"data-cypress": dataCypress,
|
|
2669
|
+
autoFocus: true
|
|
2670
|
+
}
|
|
2671
|
+
);
|
|
2672
|
+
}
|
|
2673
|
+
var percentageScaleToBeDisregarded = 2;
|
|
2674
|
+
function getDecimalScale(params) {
|
|
2675
|
+
const { dataEditorType, decimalScale } = params;
|
|
2676
|
+
let newDecimalScale = decimalScale;
|
|
2677
|
+
if (dataEditorType.toLowerCase() === "percentage") {
|
|
2678
|
+
if (decimalScale) {
|
|
2679
|
+
newDecimalScale = decimalScale > 2 ? decimalScale - percentageScaleToBeDisregarded : 0;
|
|
2680
|
+
} else {
|
|
2681
|
+
newDecimalScale = 0;
|
|
2682
|
+
}
|
|
2683
|
+
}
|
|
2684
|
+
if (!decimalScale) {
|
|
2685
|
+
if (dataEditorType.toLowerCase() === "decimal")
|
|
2686
|
+
newDecimalScale = 2;
|
|
2687
|
+
if (dataEditorType.toLowerCase() === "float")
|
|
2688
|
+
newDecimalScale = 2;
|
|
2689
|
+
if (dataEditorType.toLowerCase() === "integer")
|
|
2690
|
+
newDecimalScale = 0;
|
|
2691
|
+
if (dataEditorType.toLowerCase() === "currency")
|
|
2692
|
+
newDecimalScale = 2;
|
|
2693
|
+
}
|
|
2694
|
+
return newDecimalScale;
|
|
2695
|
+
}
|
|
2696
|
+
function NumericEditor(props) {
|
|
2697
|
+
const { value, onBlur, onChange, onPaste, setMode, column } = props;
|
|
2698
|
+
const _onPaste = useCallback(
|
|
2699
|
+
(e) => {
|
|
2700
|
+
e.preventDefault();
|
|
2701
|
+
onPaste?.();
|
|
2702
|
+
},
|
|
2703
|
+
[onPaste]
|
|
2704
|
+
);
|
|
2705
|
+
const _onBlur = useCallback(() => {
|
|
2706
|
+
onBlur?.();
|
|
2707
|
+
setMode?.("view");
|
|
2708
|
+
}, [onBlur, setMode]);
|
|
2709
|
+
return /* @__PURE__ */ jsx(
|
|
2710
|
+
NumericField,
|
|
2711
|
+
{
|
|
2712
|
+
dataEditorType: column.dataEditorType,
|
|
2713
|
+
value,
|
|
2714
|
+
onPaste: _onPaste,
|
|
2715
|
+
onBlur: _onBlur,
|
|
2716
|
+
onChange: (value2) => onChange?.({ data: value2 }),
|
|
2717
|
+
settings: column.settings
|
|
2718
|
+
}
|
|
2719
|
+
);
|
|
2720
|
+
}
|
|
2721
|
+
function NumericDataViewer(props) {
|
|
2722
|
+
const { value, column } = props;
|
|
2723
|
+
return /* @__PURE__ */ jsx(
|
|
2724
|
+
NumericField,
|
|
2725
|
+
{
|
|
2726
|
+
dataEditorType: column.dataEditorType,
|
|
2727
|
+
value,
|
|
2728
|
+
settings: column.settings,
|
|
2729
|
+
disabled: true,
|
|
2730
|
+
className: "pointer-events-none"
|
|
2731
|
+
}
|
|
2732
|
+
);
|
|
2733
|
+
}
|
|
2734
|
+
function SelectDataEditor(props) {
|
|
2735
|
+
const { value, onBlur, onChange, onPaste, items } = props;
|
|
2736
|
+
const _onPaste = useCallback(
|
|
2737
|
+
(e) => {
|
|
2738
|
+
e.preventDefault();
|
|
2739
|
+
onPaste?.();
|
|
2740
|
+
},
|
|
2741
|
+
[onPaste]
|
|
2742
|
+
);
|
|
2743
|
+
return /* @__PURE__ */ jsxs(Select, { value, onValueChange: (data) => onChange?.({ data }), defaultOpen: true, children: [
|
|
2744
|
+
/* @__PURE__ */ jsx(
|
|
2745
|
+
SelectTrigger,
|
|
2746
|
+
{
|
|
2747
|
+
onBlur,
|
|
2748
|
+
onPaste: _onPaste,
|
|
2749
|
+
className: cn(
|
|
2750
|
+
"h-full w-full rounded-none border-none pl-1 text-xs outline-none focus:ring-0"
|
|
2751
|
+
),
|
|
2752
|
+
children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Selecionar" })
|
|
2753
|
+
}
|
|
2754
|
+
),
|
|
2755
|
+
/* @__PURE__ */ jsx(SelectContent, { children: items.map(({ value: value2, text }) => /* @__PURE__ */ jsx(SelectItem, { className: "text-xs", value: value2, children: text }, value2)) })
|
|
2756
|
+
] });
|
|
2757
|
+
}
|
|
2758
|
+
function SelectDataViewer(props) {
|
|
2759
|
+
const { value, items } = props;
|
|
2760
|
+
const selected = useMemo(() => items.find((item) => item.value === value), [items, value]);
|
|
2761
|
+
const displayValue = useMemo(() => selected ? selected.text : "Selecionar", [selected]);
|
|
2762
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex h-full w-full items-center justify-between pr-px pl-1", children: [
|
|
2763
|
+
/* @__PURE__ */ jsx("p", { className: "line-clamp-1 text-xs", children: displayValue }),
|
|
2764
|
+
/* @__PURE__ */ jsx(CaretSortIcon, { className: "h-4 w-4 opacity-50" })
|
|
2765
|
+
] });
|
|
2766
|
+
}
|
|
2767
|
+
|
|
2768
|
+
// src/shared/lib/move-input-cursor-to-end.ts
|
|
2769
|
+
function moveInputCursorToEnd(element) {
|
|
2770
|
+
element.selectionStart = element.selectionEnd = element.value.length;
|
|
2771
|
+
}
|
|
2772
|
+
|
|
2773
|
+
// src/shared/lib/read-text-from-clipboard.ts
|
|
2774
|
+
var PLAIN_TEXT_MIME = "text/plain";
|
|
2775
|
+
function readTextFromClipboard(event) {
|
|
2776
|
+
if (window.clipboardData?.getData) {
|
|
2777
|
+
return window.clipboardData.getData("Text");
|
|
2778
|
+
}
|
|
2779
|
+
if (event.clipboardData?.getData) {
|
|
2780
|
+
return event.clipboardData.getData(PLAIN_TEXT_MIME);
|
|
2781
|
+
}
|
|
2782
|
+
return "";
|
|
2783
|
+
}
|
|
2784
|
+
var CHAR_WIDTH = 6;
|
|
2785
|
+
var INPUT_MAX_LENGTH = 200;
|
|
2786
|
+
function TextDataEditor(props) {
|
|
2787
|
+
const { value, onBlur, onChange, onPaste, setMode, column, selected } = props;
|
|
2788
|
+
const valueAsString = value;
|
|
2789
|
+
const textareaRef = useRef(null);
|
|
2790
|
+
const [textareaHeight, setTextareaHeight] = useState(0);
|
|
2791
|
+
const overflow = useMemo$1(
|
|
2792
|
+
() => charOverflow(valueAsString, column.width),
|
|
2793
|
+
[valueAsString, column.width]
|
|
2794
|
+
);
|
|
2795
|
+
const _onPaste = useCallback(
|
|
2796
|
+
(e) => {
|
|
2797
|
+
const clipboard = readTextFromClipboard(e);
|
|
2798
|
+
const singleLine = oneLineString(clipboard);
|
|
2799
|
+
if (!singleLine) {
|
|
2800
|
+
e.preventDefault();
|
|
2801
|
+
onPaste?.();
|
|
2802
|
+
}
|
|
2803
|
+
},
|
|
2804
|
+
[onPaste]
|
|
2805
|
+
);
|
|
2806
|
+
const _onBlur = useCallback(() => {
|
|
2807
|
+
onBlur?.();
|
|
2808
|
+
setMode?.("view");
|
|
2809
|
+
}, [onBlur, setMode]);
|
|
2810
|
+
const updateTextareaHeight = useCallback(() => {
|
|
2811
|
+
const element = textareaRef.current;
|
|
2812
|
+
if (!element)
|
|
2813
|
+
return;
|
|
2814
|
+
const scrollHeight = element.scrollHeight;
|
|
2815
|
+
element.style.height = `${scrollHeight}px`;
|
|
2816
|
+
setTextareaHeight(scrollHeight);
|
|
2817
|
+
}, []);
|
|
2818
|
+
const _onChange = useCallback(
|
|
2819
|
+
(e) => {
|
|
2820
|
+
onChange?.({ data: e.target.value });
|
|
2821
|
+
updateTextareaHeight();
|
|
2822
|
+
},
|
|
2823
|
+
[updateTextareaHeight, onChange]
|
|
2824
|
+
);
|
|
2825
|
+
if (overflow) {
|
|
2826
|
+
return /* @__PURE__ */ jsx(
|
|
2827
|
+
"div",
|
|
2828
|
+
{
|
|
2829
|
+
style: { height: textareaHeight },
|
|
2830
|
+
className: cn(
|
|
2831
|
+
"-left-0.5 -top-0.5 absolute z-40 h-fit w-fit border bg-white shadow-lg outline outline-2 outline-blue-500",
|
|
2832
|
+
selected ? "bg-blue-50" : "bg-white"
|
|
2833
|
+
),
|
|
2834
|
+
children: /* @__PURE__ */ jsx(
|
|
2835
|
+
"div",
|
|
2836
|
+
{
|
|
2837
|
+
style: { height: textareaHeight - 1 },
|
|
2838
|
+
className: "h-full w-full outline outline-[3px] outline-sky-200 outline-offset-2",
|
|
2839
|
+
children: /* @__PURE__ */ jsx(
|
|
2840
|
+
"textarea",
|
|
2841
|
+
{
|
|
2842
|
+
ref: textareaRef,
|
|
2843
|
+
onBlur: _onBlur,
|
|
2844
|
+
onPaste: _onPaste,
|
|
2845
|
+
value: valueAsString,
|
|
2846
|
+
onChange: _onChange,
|
|
2847
|
+
className: cn(
|
|
2848
|
+
"resize-none break-all rounded-none bg-transparent py-1.5 pr-3 pl-1 text-xs outline-none"
|
|
2849
|
+
),
|
|
2850
|
+
onFocus: (e) => moveInputCursorToEnd(e.target),
|
|
2851
|
+
maxLength: INPUT_MAX_LENGTH,
|
|
2852
|
+
style: { width: column.width },
|
|
2853
|
+
autoFocus: true
|
|
2854
|
+
}
|
|
2855
|
+
)
|
|
2856
|
+
}
|
|
2857
|
+
)
|
|
2858
|
+
}
|
|
2859
|
+
);
|
|
2860
|
+
}
|
|
2861
|
+
return /* @__PURE__ */ jsx(
|
|
2862
|
+
"input",
|
|
2863
|
+
{
|
|
2864
|
+
onBlur,
|
|
2865
|
+
onPaste: _onPaste,
|
|
2866
|
+
value: valueAsString,
|
|
2867
|
+
maxLength: INPUT_MAX_LENGTH,
|
|
2868
|
+
onChange: _onChange,
|
|
2869
|
+
className: cn("h-full w-full bg-transparent pl-1 text-xs outline-none"),
|
|
2870
|
+
autoFocus: true
|
|
2871
|
+
}
|
|
2872
|
+
);
|
|
2873
|
+
}
|
|
2874
|
+
function TextDataViewer(props) {
|
|
2875
|
+
const { value, column, selected } = props;
|
|
2876
|
+
const valueAsString = value;
|
|
2877
|
+
const overflow = useMemo$1(
|
|
2878
|
+
() => charOverflow(valueAsString, column.width),
|
|
2879
|
+
[valueAsString, column.width]
|
|
2880
|
+
);
|
|
2881
|
+
if (overflow) {
|
|
2882
|
+
return /* @__PURE__ */ jsx(TooltipProvider, { delayDuration: 0, children: /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
2883
|
+
/* @__PURE__ */ jsx(TooltipTrigger, { className: "w-full", children: /* @__PURE__ */ jsx("div", { className: "flex h-full w-full items-center overflow-hidden", children: /* @__PURE__ */ jsx("p", { className: "line-clamp-1 break-all pl-1 text-left text-xs", children: valueAsString }) }) }),
|
|
2884
|
+
/* @__PURE__ */ jsx(
|
|
2885
|
+
TooltipContent,
|
|
2886
|
+
{
|
|
2887
|
+
align: "start",
|
|
2888
|
+
side: "bottom",
|
|
2889
|
+
alignOffset: -2,
|
|
2890
|
+
sideOffset: -CELL_INITIAL_HEIGHT,
|
|
2891
|
+
className: cn(
|
|
2892
|
+
"h-fit w-full break-all rounded-none border bg-white pl-1 text-black shadow-lg",
|
|
2893
|
+
"data-[state=closed]:transform-none data-[side=bottom]:animate-none data-[state=closed]:animate-none data-[state=closed]:transition-none",
|
|
2894
|
+
selected ? "bg-blue-50" : "bg-white"
|
|
2895
|
+
),
|
|
2896
|
+
style: { width: column.width },
|
|
2897
|
+
children: /* @__PURE__ */ jsx("p", { children: valueAsString })
|
|
2898
|
+
}
|
|
2899
|
+
)
|
|
2900
|
+
] }) });
|
|
2901
|
+
}
|
|
2902
|
+
return /* @__PURE__ */ jsx("div", { className: "flex h-full w-full items-center overflow-hidden", children: /* @__PURE__ */ jsx("p", { className: "line-clamp-1 break-all pl-1 text-left text-xs", title: valueAsString, children: valueAsString }) });
|
|
2903
|
+
}
|
|
2904
|
+
function charOverflow(string, width) {
|
|
2905
|
+
return CHAR_WIDTH * string?.length > width;
|
|
2906
|
+
}
|
|
2907
|
+
function oneLineString(value) {
|
|
2908
|
+
return [" ", "\n", "\r"].every((regex) => !value.includes(regex));
|
|
2909
|
+
}
|
|
2910
|
+
|
|
2911
|
+
// src/components/spreadsheet/ui/data-editor/index.tsx
|
|
2912
|
+
var DataEditor = {
|
|
2913
|
+
Date: DateDataEditor,
|
|
2914
|
+
Text: TextDataEditor,
|
|
2915
|
+
Boolean: BooleanDataEditor,
|
|
2916
|
+
Numeric: NumericEditor,
|
|
2917
|
+
Select: SelectDataEditor
|
|
2918
|
+
};
|
|
2919
|
+
var DataViewer = {
|
|
2920
|
+
Date: DateDataViewer,
|
|
2921
|
+
Text: TextDataViewer,
|
|
2922
|
+
Boolean: BooleanDataViewer,
|
|
2923
|
+
Numeric: NumericDataViewer,
|
|
2924
|
+
Select: SelectDataViewer
|
|
2925
|
+
};
|
|
2926
|
+
function Cell(props) {
|
|
2927
|
+
const { value, coordinates } = props;
|
|
2928
|
+
const { columns, isCellSelected, onChange, onPaste, onSelectCell } = useSpreadsheet();
|
|
2929
|
+
const { dataEditorType, readonly, width, visible, settings } = columns[coordinates.column];
|
|
2930
|
+
const [mode, setMode] = useState(readonly ? "readonly" : "view");
|
|
2931
|
+
const dataEditorContainerRef = useRef(null);
|
|
2932
|
+
const column = useMemo$1(() => columns[coordinates.column], [columns, coordinates.column]);
|
|
2933
|
+
const selected = useMemo$1(() => isCellSelected(coordinates), [coordinates, isCellSelected]);
|
|
2934
|
+
const selectItems = useMemo$1(() => settings?.select?.items || [], [settings?.select?.items]);
|
|
2935
|
+
const common = useMemo$1(
|
|
2936
|
+
() => ({
|
|
2937
|
+
dataEditor: {
|
|
2938
|
+
value,
|
|
2939
|
+
column,
|
|
2940
|
+
setMode,
|
|
2941
|
+
selected,
|
|
2942
|
+
onPaste: () => onPaste(coordinates),
|
|
2943
|
+
onChange: ({ data }) => onChange({ data, point: coordinates })
|
|
2944
|
+
},
|
|
2945
|
+
dataViewer: {
|
|
2946
|
+
value,
|
|
2947
|
+
column,
|
|
2948
|
+
selected
|
|
2949
|
+
}
|
|
2950
|
+
}),
|
|
2951
|
+
[coordinates, value, column, selected, onPaste, onChange]
|
|
2952
|
+
);
|
|
2953
|
+
const dataEditorElementMap = useMemo$1(
|
|
2954
|
+
() => ({
|
|
2955
|
+
Date: /* @__PURE__ */ jsx(DataEditor.Date, { ...common.dataEditor }),
|
|
2956
|
+
String: /* @__PURE__ */ jsx(DataEditor.Text, { ...common.dataEditor }),
|
|
2957
|
+
Currency: /* @__PURE__ */ jsx(DataEditor.Numeric, { ...common.dataEditor }),
|
|
2958
|
+
Decimal: /* @__PURE__ */ jsx(DataEditor.Numeric, { ...common.dataEditor }),
|
|
2959
|
+
Float: /* @__PURE__ */ jsx(DataEditor.Numeric, { ...common.dataEditor }),
|
|
2960
|
+
Integer: /* @__PURE__ */ jsx(DataEditor.Numeric, { ...common.dataEditor }),
|
|
2961
|
+
Percentage: /* @__PURE__ */ jsx(DataEditor.Numeric, { ...common.dataEditor }),
|
|
2962
|
+
Boolean: /* @__PURE__ */ jsx(DataEditor.Boolean, { ...common.dataEditor }),
|
|
2963
|
+
Select: /* @__PURE__ */ jsx(DataEditor.Select, { ...common.dataEditor, items: selectItems })
|
|
2964
|
+
}),
|
|
2965
|
+
[common.dataEditor, selectItems]
|
|
2966
|
+
);
|
|
2967
|
+
const dataViewerElementMap = useMemo$1(
|
|
2968
|
+
() => ({
|
|
2969
|
+
Date: /* @__PURE__ */ jsx(DataViewer.Date, { ...common.dataViewer }),
|
|
2970
|
+
String: /* @__PURE__ */ jsx(DataViewer.Text, { ...common.dataViewer }),
|
|
2971
|
+
Currency: /* @__PURE__ */ jsx(DataViewer.Numeric, { ...common.dataViewer }),
|
|
2972
|
+
Decimal: /* @__PURE__ */ jsx(DataViewer.Numeric, { ...common.dataViewer }),
|
|
2973
|
+
Float: /* @__PURE__ */ jsx(DataViewer.Numeric, { ...common.dataViewer }),
|
|
2974
|
+
Integer: /* @__PURE__ */ jsx(DataViewer.Numeric, { ...common.dataViewer }),
|
|
2975
|
+
Percentage: /* @__PURE__ */ jsx(DataViewer.Numeric, { ...common.dataViewer }),
|
|
2976
|
+
Boolean: /* @__PURE__ */ jsx(DataViewer.Boolean, { ...common.dataViewer }),
|
|
2977
|
+
Select: /* @__PURE__ */ jsx(DataViewer.Select, { ...common.dataViewer, items: selectItems })
|
|
2978
|
+
}),
|
|
2979
|
+
[common.dataViewer, selectItems]
|
|
2980
|
+
);
|
|
2981
|
+
const dataEditorElement = useMemo$1(
|
|
2982
|
+
() => dataEditorType ? dataEditorElementMap[dataEditorType] : null,
|
|
2983
|
+
[dataEditorType, dataEditorElementMap]
|
|
2984
|
+
);
|
|
2985
|
+
const dataViewerElement = useMemo$1(
|
|
2986
|
+
() => dataEditorType ? dataViewerElementMap[dataEditorType] : null,
|
|
2987
|
+
[dataEditorType, dataViewerElementMap]
|
|
2988
|
+
);
|
|
2989
|
+
useEffect(() => {
|
|
2990
|
+
const enterEditMode = (e) => {
|
|
2991
|
+
const enterKey = e.code === "Enter";
|
|
2992
|
+
if (enterKey && selected && mode === "view") {
|
|
2993
|
+
setMode("edit");
|
|
2994
|
+
}
|
|
2995
|
+
if (enterKey && selected && mode === "edit") {
|
|
2996
|
+
setMode("view");
|
|
2997
|
+
}
|
|
2998
|
+
};
|
|
2999
|
+
window.addEventListener("keydown", enterEditMode);
|
|
3000
|
+
return () => window.removeEventListener("keydown", enterEditMode);
|
|
3001
|
+
}, [selected, mode]);
|
|
3002
|
+
useClickAway_default(dataEditorContainerRef, () => setMode("view"));
|
|
3003
|
+
if (!visible)
|
|
3004
|
+
return null;
|
|
3005
|
+
if (mode === "readonly") {
|
|
3006
|
+
return /* @__PURE__ */ jsx(
|
|
3007
|
+
"div",
|
|
3008
|
+
{
|
|
3009
|
+
onClick: () => onSelectCell(coordinates),
|
|
3010
|
+
className: cn(
|
|
3011
|
+
"flex h-7 shrink-0 cursor-default select-none border border-t-transparent border-l-transparent bg-[#F6F6F9]",
|
|
3012
|
+
selected && "bg-[#EAF5FF]"
|
|
3013
|
+
),
|
|
3014
|
+
style: { width, height: CELL_INITIAL_HEIGHT },
|
|
3015
|
+
children: dataViewerElement
|
|
3016
|
+
}
|
|
3017
|
+
);
|
|
3018
|
+
}
|
|
3019
|
+
if (mode === "view") {
|
|
3020
|
+
return /* @__PURE__ */ jsx(
|
|
3021
|
+
"div",
|
|
3022
|
+
{
|
|
3023
|
+
onClick: () => onSelectCell(coordinates),
|
|
3024
|
+
onDoubleClick: () => setMode("edit"),
|
|
3025
|
+
className: cn(
|
|
3026
|
+
"relative flex h-7 shrink-0 cursor-default select-none border border-t-transparent border-l-transparent",
|
|
3027
|
+
selected && "bg-[#EAF5FF]"
|
|
3028
|
+
),
|
|
3029
|
+
style: { width, height: CELL_INITIAL_HEIGHT },
|
|
3030
|
+
children: dataViewerElement
|
|
3031
|
+
}
|
|
3032
|
+
);
|
|
3033
|
+
}
|
|
3034
|
+
return /* @__PURE__ */ jsx(
|
|
3035
|
+
"div",
|
|
3036
|
+
{
|
|
3037
|
+
ref: dataEditorContainerRef,
|
|
3038
|
+
"data-testid": "cell__testid",
|
|
3039
|
+
className: "relative h-7 w-32 shrink-0 border border-l-transparent border-t-transparent bg-[#EAF5FF] shadow-lg outline outline-2 outline-blue-500",
|
|
3040
|
+
style: {
|
|
3041
|
+
width,
|
|
3042
|
+
height: CELL_INITIAL_HEIGHT,
|
|
3043
|
+
top: coordinates.row === 0 ? "4px" : "0px"
|
|
3044
|
+
},
|
|
3045
|
+
children: /* @__PURE__ */ jsx("div", { className: "h-full w-full outline outline-[3px] outline-offset-2 outline-sky-200", children: dataEditorElement })
|
|
3046
|
+
}
|
|
3047
|
+
);
|
|
3048
|
+
}
|
|
3049
|
+
function RowIndicator({ row }) {
|
|
3050
|
+
const { onSelectRow, pointRange, matrix } = useSpreadsheet();
|
|
3051
|
+
const isRowInRange = useMemo$1(
|
|
3052
|
+
() => pointRange && row >= pointRange.start.row && row <= pointRange.end.row,
|
|
3053
|
+
[pointRange, row]
|
|
3054
|
+
);
|
|
3055
|
+
const isEntireRowSelected = useMemo$1(
|
|
3056
|
+
() => !!(pointRange && hasEntireRows({ matrix, pointRange, row })),
|
|
3057
|
+
[matrix, pointRange, row]
|
|
3058
|
+
);
|
|
3059
|
+
return /* @__PURE__ */ jsx(
|
|
3060
|
+
"div",
|
|
3061
|
+
{
|
|
3062
|
+
className: cn(
|
|
3063
|
+
"flex h-7 w-12 shrink-0 cursor-default select-none items-center justify-center border-r border-b text-[#8E8EA9] text-xs",
|
|
3064
|
+
isRowInRange && "bg-blue-100 font-bold text-blue-700",
|
|
3065
|
+
isEntireRowSelected && "bg-[#0085FF] font-bold text-white"
|
|
3066
|
+
),
|
|
3067
|
+
onClick: (e) => onSelectRow(row, e),
|
|
3068
|
+
style: {
|
|
3069
|
+
height: CELL_INITIAL_HEIGHT
|
|
3070
|
+
},
|
|
3071
|
+
children: row + 1
|
|
3072
|
+
}
|
|
3073
|
+
);
|
|
3074
|
+
}
|
|
3075
|
+
function Rows() {
|
|
3076
|
+
const id = useId$1();
|
|
3077
|
+
const { highlightLastRow, matrix } = useSpreadsheet();
|
|
3078
|
+
return /* @__PURE__ */ jsx("div", { className: "relative", children: matrix.map((rowValue, row) => /* @__PURE__ */ jsxs(
|
|
3079
|
+
"div",
|
|
3080
|
+
{
|
|
3081
|
+
className: cn(
|
|
3082
|
+
"flex items-center transition-all ease-linear",
|
|
3083
|
+
row === matrix.length - 1 && highlightLastRow && "bg-blue-50"
|
|
3084
|
+
),
|
|
3085
|
+
children: [
|
|
3086
|
+
/* @__PURE__ */ jsx(RowIndicator, { row }),
|
|
3087
|
+
rowValue.map((columnValue, column) => /* @__PURE__ */ jsx(
|
|
3088
|
+
Cell,
|
|
3089
|
+
{
|
|
3090
|
+
value: columnValue,
|
|
3091
|
+
coordinates: { column, row }
|
|
3092
|
+
},
|
|
3093
|
+
`spreadsheet__cell__key__${id}__${row}__${column}`
|
|
3094
|
+
))
|
|
3095
|
+
]
|
|
3096
|
+
},
|
|
3097
|
+
`spreadsheet__row__key__${id}__${row}}`
|
|
3098
|
+
)) });
|
|
3099
|
+
}
|
|
3100
|
+
function Start({ className }) {
|
|
3101
|
+
const { staticRows, emptySize, onInsertNewRow } = useSpreadsheet();
|
|
3102
|
+
if (staticRows)
|
|
3103
|
+
return null;
|
|
3104
|
+
return /* @__PURE__ */ jsx(
|
|
3105
|
+
"div",
|
|
3106
|
+
{
|
|
3107
|
+
className: cn(
|
|
3108
|
+
"pointer-events-none mt-[calc(28px+36px)] flex h-[calc(100%-28px-28px)] w-full items-center justify-center",
|
|
3109
|
+
emptySize && "pointer-events-auto bg-white/25 backdrop-blur-sm",
|
|
3110
|
+
className
|
|
3111
|
+
),
|
|
3112
|
+
children: emptySize && /* @__PURE__ */ jsxs("p", { className: "text-neutral-500", children: [
|
|
3113
|
+
/* @__PURE__ */ jsx("span", { children: "Clique " }),
|
|
3114
|
+
/* @__PURE__ */ jsx("button", { type: "button", onClick: onInsertNewRow, className: "font-bold", children: "AQUI" }),
|
|
3115
|
+
/* @__PURE__ */ jsx("span", { children: " para come\xE7ar a preencher a tabela." })
|
|
3116
|
+
] })
|
|
3117
|
+
}
|
|
3118
|
+
);
|
|
3119
|
+
}
|
|
3120
|
+
function AddRowIcon(props) {
|
|
3121
|
+
return /* @__PURE__ */ jsxs(
|
|
3122
|
+
"svg",
|
|
3123
|
+
{
|
|
3124
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
3125
|
+
width: "20",
|
|
3126
|
+
height: "20",
|
|
3127
|
+
fill: "none",
|
|
3128
|
+
viewBox: "0 0 20 20",
|
|
3129
|
+
...props,
|
|
3130
|
+
children: [
|
|
3131
|
+
/* @__PURE__ */ jsx("title", { children: "Add Row" }),
|
|
3132
|
+
/* @__PURE__ */ jsx(
|
|
3133
|
+
"path",
|
|
3134
|
+
{
|
|
3135
|
+
stroke: "currentColor",
|
|
3136
|
+
strokeLinecap: "round",
|
|
3137
|
+
strokeLinejoin: "round",
|
|
3138
|
+
strokeWidth: "1.5",
|
|
3139
|
+
d: "M10 6.667v6.666M6.667 10h6.666M6.5 17.5h7c1.4 0 2.1 0 2.635-.273a2.5 2.5 0 001.092-1.092c.273-.535.273-1.235.273-2.635v-7c0-1.4 0-2.1-.273-2.635a2.5 2.5 0 00-1.092-1.093C15.6 2.5 14.9 2.5 13.5 2.5h-7c-1.4 0-2.1 0-2.635.272a2.5 2.5 0 00-1.093 1.093C2.5 4.4 2.5 5.1 2.5 6.5v7c0 1.4 0 2.1.272 2.635a2.5 2.5 0 001.093 1.092C4.4 17.5 5.1 17.5 6.5 17.5z"
|
|
3140
|
+
}
|
|
3141
|
+
)
|
|
3142
|
+
]
|
|
3143
|
+
}
|
|
3144
|
+
);
|
|
3145
|
+
}
|
|
3146
|
+
function RemoveRowIcon(props) {
|
|
3147
|
+
return /* @__PURE__ */ jsxs(
|
|
3148
|
+
"svg",
|
|
3149
|
+
{
|
|
3150
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
3151
|
+
width: "20",
|
|
3152
|
+
height: "20",
|
|
3153
|
+
fill: "none",
|
|
3154
|
+
viewBox: "0 0 20 20",
|
|
3155
|
+
...props,
|
|
3156
|
+
children: [
|
|
3157
|
+
/* @__PURE__ */ jsx("title", { children: "Remove Row" }),
|
|
3158
|
+
/* @__PURE__ */ jsx(
|
|
3159
|
+
"path",
|
|
3160
|
+
{
|
|
3161
|
+
stroke: "currentColor",
|
|
3162
|
+
strokeLinecap: "round",
|
|
3163
|
+
strokeLinejoin: "round",
|
|
3164
|
+
strokeWidth: "1.5",
|
|
3165
|
+
d: "M13.333 5v-.667c0-.933 0-1.4-.181-1.756a1.667 1.667 0 00-.729-.729c-.356-.181-.823-.181-1.756-.181H9.333c-.933 0-1.4 0-1.756.181-.314.16-.569.415-.729.729-.181.356-.181.823-.181 1.756V5m1.666 4.583v4.167m3.334-4.167v4.167M2.5 5h15m-1.667 0v9.333c0 1.4 0 2.1-.272 2.635a2.5 2.5 0 01-1.093 1.093c-.534.272-1.235.272-2.635.272H8.167c-1.4 0-2.1 0-2.635-.272a2.5 2.5 0 01-1.093-1.093c-.272-.535-.272-1.235-.272-2.635V5"
|
|
3166
|
+
}
|
|
3167
|
+
)
|
|
3168
|
+
]
|
|
3169
|
+
}
|
|
3170
|
+
);
|
|
3171
|
+
}
|
|
3172
|
+
var buttonVariants = cva(
|
|
3173
|
+
"inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50",
|
|
3174
|
+
{
|
|
3175
|
+
variants: {
|
|
3176
|
+
variant: {
|
|
3177
|
+
default: "bg-primary text-primary-foreground shadow hover:bg-primary/90",
|
|
3178
|
+
destructive: "bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",
|
|
3179
|
+
outline: "border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",
|
|
3180
|
+
secondary: "bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",
|
|
3181
|
+
ghost: "hover:bg-accent hover:text-accent-foreground",
|
|
3182
|
+
link: "text-primary underline-offset-4 hover:underline"
|
|
3183
|
+
},
|
|
3184
|
+
size: {
|
|
3185
|
+
default: "h-9 px-4 py-2",
|
|
3186
|
+
sm: "h-8 rounded-md px-3 text-xs",
|
|
3187
|
+
lg: "h-10 rounded-md px-8",
|
|
3188
|
+
icon: "h-9 w-9"
|
|
3189
|
+
}
|
|
3190
|
+
},
|
|
3191
|
+
defaultVariants: {
|
|
3192
|
+
variant: "default",
|
|
3193
|
+
size: "default"
|
|
3194
|
+
}
|
|
3195
|
+
}
|
|
3196
|
+
);
|
|
3197
|
+
var Button = React4.forwardRef(
|
|
3198
|
+
({ className, variant, size, asChild = false, ...props }, ref) => {
|
|
3199
|
+
const Comp = asChild ? $5e63c961fc1ce211$export$8c6ed5c666ac1360 : "button";
|
|
3200
|
+
return /* @__PURE__ */ jsx(Comp, { className: cn(buttonVariants({ variant, size, className })), ref, ...props });
|
|
3201
|
+
}
|
|
3202
|
+
);
|
|
3203
|
+
Button.displayName = "Button";
|
|
3204
|
+
var $d08ef79370b62062$var$DROPDOWN_MENU_NAME = "DropdownMenu";
|
|
3205
|
+
var [$d08ef79370b62062$var$createDropdownMenuContext, $d08ef79370b62062$export$c0623cd925aeb687] = createContextScope($d08ef79370b62062$var$DROPDOWN_MENU_NAME, [
|
|
3206
|
+
createMenuScope
|
|
3207
|
+
]);
|
|
3208
|
+
var $d08ef79370b62062$var$useMenuScope = createMenuScope();
|
|
3209
|
+
var [$d08ef79370b62062$var$DropdownMenuProvider, $d08ef79370b62062$var$useDropdownMenuContext] = $d08ef79370b62062$var$createDropdownMenuContext($d08ef79370b62062$var$DROPDOWN_MENU_NAME);
|
|
3210
|
+
var $d08ef79370b62062$export$e44a253a59704894 = (props) => {
|
|
3211
|
+
const { __scopeDropdownMenu, children, dir, open: openProp, defaultOpen, onOpenChange, modal = true } = props;
|
|
3212
|
+
const menuScope = $d08ef79370b62062$var$useMenuScope(__scopeDropdownMenu);
|
|
3213
|
+
const triggerRef = useRef(null);
|
|
3214
|
+
const [open = false, setOpen] = useControllableState({
|
|
3215
|
+
prop: openProp,
|
|
3216
|
+
defaultProp: defaultOpen,
|
|
3217
|
+
onChange: onOpenChange
|
|
3218
|
+
});
|
|
3219
|
+
return /* @__PURE__ */ createElement($d08ef79370b62062$var$DropdownMenuProvider, {
|
|
3220
|
+
scope: __scopeDropdownMenu,
|
|
3221
|
+
triggerId: useId(),
|
|
3222
|
+
triggerRef,
|
|
3223
|
+
contentId: useId(),
|
|
3224
|
+
open,
|
|
3225
|
+
onOpenChange: setOpen,
|
|
3226
|
+
onOpenToggle: useCallback(
|
|
3227
|
+
() => setOpen(
|
|
3228
|
+
(prevOpen) => !prevOpen
|
|
3229
|
+
),
|
|
3230
|
+
[
|
|
3231
|
+
setOpen
|
|
3232
|
+
]
|
|
3233
|
+
),
|
|
3234
|
+
modal
|
|
3235
|
+
}, /* @__PURE__ */ createElement(Root$2, $01b9c$babelruntimehelpersesmextends({}, menuScope, {
|
|
3236
|
+
open,
|
|
3237
|
+
onOpenChange: setOpen,
|
|
3238
|
+
dir,
|
|
3239
|
+
modal
|
|
3240
|
+
}), children));
|
|
3241
|
+
};
|
|
3242
|
+
var $d08ef79370b62062$var$TRIGGER_NAME = "DropdownMenuTrigger";
|
|
3243
|
+
var $d08ef79370b62062$export$d2469213b3befba9 = /* @__PURE__ */ forwardRef((props, forwardedRef) => {
|
|
3244
|
+
const { __scopeDropdownMenu, disabled = false, ...triggerProps } = props;
|
|
3245
|
+
const context = $d08ef79370b62062$var$useDropdownMenuContext($d08ef79370b62062$var$TRIGGER_NAME, __scopeDropdownMenu);
|
|
3246
|
+
const menuScope = $d08ef79370b62062$var$useMenuScope(__scopeDropdownMenu);
|
|
3247
|
+
return /* @__PURE__ */ createElement(Anchor$1, $01b9c$babelruntimehelpersesmextends({
|
|
3248
|
+
asChild: true
|
|
3249
|
+
}, menuScope), /* @__PURE__ */ createElement(Primitive.button, $01b9c$babelruntimehelpersesmextends({
|
|
3250
|
+
type: "button",
|
|
3251
|
+
id: context.triggerId,
|
|
3252
|
+
"aria-haspopup": "menu",
|
|
3253
|
+
"aria-expanded": context.open,
|
|
3254
|
+
"aria-controls": context.open ? context.contentId : void 0,
|
|
3255
|
+
"data-state": context.open ? "open" : "closed",
|
|
3256
|
+
"data-disabled": disabled ? "" : void 0,
|
|
3257
|
+
disabled
|
|
3258
|
+
}, triggerProps, {
|
|
3259
|
+
ref: composeRefs(forwardedRef, context.triggerRef),
|
|
3260
|
+
onPointerDown: composeEventHandlers(props.onPointerDown, (event) => {
|
|
3261
|
+
if (!disabled && event.button === 0 && event.ctrlKey === false) {
|
|
3262
|
+
context.onOpenToggle();
|
|
3263
|
+
if (!context.open)
|
|
3264
|
+
event.preventDefault();
|
|
3265
|
+
}
|
|
3266
|
+
}),
|
|
3267
|
+
onKeyDown: composeEventHandlers(props.onKeyDown, (event) => {
|
|
3268
|
+
if (disabled)
|
|
3269
|
+
return;
|
|
3270
|
+
if ([
|
|
3271
|
+
"Enter",
|
|
3272
|
+
" "
|
|
3273
|
+
].includes(event.key))
|
|
3274
|
+
context.onOpenToggle();
|
|
3275
|
+
if (event.key === "ArrowDown")
|
|
3276
|
+
context.onOpenChange(true);
|
|
3277
|
+
if ([
|
|
3278
|
+
"Enter",
|
|
3279
|
+
" ",
|
|
3280
|
+
"ArrowDown"
|
|
3281
|
+
].includes(event.key))
|
|
3282
|
+
event.preventDefault();
|
|
3283
|
+
})
|
|
3284
|
+
})));
|
|
3285
|
+
});
|
|
3286
|
+
var $d08ef79370b62062$export$cd369b4d4d54efc9 = (props) => {
|
|
3287
|
+
const { __scopeDropdownMenu, ...portalProps } = props;
|
|
3288
|
+
const menuScope = $d08ef79370b62062$var$useMenuScope(__scopeDropdownMenu);
|
|
3289
|
+
return /* @__PURE__ */ createElement(Portal$1, $01b9c$babelruntimehelpersesmextends({}, menuScope, portalProps));
|
|
3290
|
+
};
|
|
3291
|
+
var $d08ef79370b62062$var$CONTENT_NAME = "DropdownMenuContent";
|
|
3292
|
+
var $d08ef79370b62062$export$6e76d93a37c01248 = /* @__PURE__ */ forwardRef((props, forwardedRef) => {
|
|
3293
|
+
const { __scopeDropdownMenu, ...contentProps } = props;
|
|
3294
|
+
const context = $d08ef79370b62062$var$useDropdownMenuContext($d08ef79370b62062$var$CONTENT_NAME, __scopeDropdownMenu);
|
|
3295
|
+
const menuScope = $d08ef79370b62062$var$useMenuScope(__scopeDropdownMenu);
|
|
3296
|
+
const hasInteractedOutsideRef = useRef(false);
|
|
3297
|
+
return /* @__PURE__ */ createElement(Content$1, $01b9c$babelruntimehelpersesmextends({
|
|
3298
|
+
id: context.contentId,
|
|
3299
|
+
"aria-labelledby": context.triggerId
|
|
3300
|
+
}, menuScope, contentProps, {
|
|
3301
|
+
ref: forwardedRef,
|
|
3302
|
+
onCloseAutoFocus: composeEventHandlers(props.onCloseAutoFocus, (event) => {
|
|
3303
|
+
var _context$triggerRef$c;
|
|
3304
|
+
if (!hasInteractedOutsideRef.current)
|
|
3305
|
+
(_context$triggerRef$c = context.triggerRef.current) === null || _context$triggerRef$c === void 0 || _context$triggerRef$c.focus();
|
|
3306
|
+
hasInteractedOutsideRef.current = false;
|
|
3307
|
+
event.preventDefault();
|
|
3308
|
+
}),
|
|
3309
|
+
onInteractOutside: composeEventHandlers(props.onInteractOutside, (event) => {
|
|
3310
|
+
const originalEvent = event.detail.originalEvent;
|
|
3311
|
+
const ctrlLeftClick = originalEvent.button === 0 && originalEvent.ctrlKey === true;
|
|
3312
|
+
const isRightClick = originalEvent.button === 2 || ctrlLeftClick;
|
|
3313
|
+
if (!context.modal || isRightClick)
|
|
3314
|
+
hasInteractedOutsideRef.current = true;
|
|
3315
|
+
}),
|
|
3316
|
+
style: {
|
|
3317
|
+
...props.style,
|
|
3318
|
+
"--radix-dropdown-menu-content-transform-origin": "var(--radix-popper-transform-origin)",
|
|
3319
|
+
"--radix-dropdown-menu-content-available-width": "var(--radix-popper-available-width)",
|
|
3320
|
+
"--radix-dropdown-menu-content-available-height": "var(--radix-popper-available-height)",
|
|
3321
|
+
"--radix-dropdown-menu-trigger-width": "var(--radix-popper-anchor-width)",
|
|
3322
|
+
"--radix-dropdown-menu-trigger-height": "var(--radix-popper-anchor-height)"
|
|
3323
|
+
}
|
|
3324
|
+
}));
|
|
3325
|
+
});
|
|
3326
|
+
var $d08ef79370b62062$export$76e48c5b57f24495 = /* @__PURE__ */ forwardRef((props, forwardedRef) => {
|
|
3327
|
+
const { __scopeDropdownMenu, ...labelProps } = props;
|
|
3328
|
+
const menuScope = $d08ef79370b62062$var$useMenuScope(__scopeDropdownMenu);
|
|
3329
|
+
return /* @__PURE__ */ createElement(Label, $01b9c$babelruntimehelpersesmextends({}, menuScope, labelProps, {
|
|
3330
|
+
ref: forwardedRef
|
|
3331
|
+
}));
|
|
3332
|
+
});
|
|
3333
|
+
var $d08ef79370b62062$export$ed97964d1871885d = /* @__PURE__ */ forwardRef((props, forwardedRef) => {
|
|
3334
|
+
const { __scopeDropdownMenu, ...itemProps } = props;
|
|
3335
|
+
const menuScope = $d08ef79370b62062$var$useMenuScope(__scopeDropdownMenu);
|
|
3336
|
+
return /* @__PURE__ */ createElement(Item, $01b9c$babelruntimehelpersesmextends({}, menuScope, itemProps, {
|
|
3337
|
+
ref: forwardedRef
|
|
3338
|
+
}));
|
|
3339
|
+
});
|
|
3340
|
+
var $d08ef79370b62062$export$53a69729da201fa9 = /* @__PURE__ */ forwardRef((props, forwardedRef) => {
|
|
3341
|
+
const { __scopeDropdownMenu, ...checkboxItemProps } = props;
|
|
3342
|
+
const menuScope = $d08ef79370b62062$var$useMenuScope(__scopeDropdownMenu);
|
|
3343
|
+
return /* @__PURE__ */ createElement(CheckboxItem, $01b9c$babelruntimehelpersesmextends({}, menuScope, checkboxItemProps, {
|
|
3344
|
+
ref: forwardedRef
|
|
3345
|
+
}));
|
|
3346
|
+
});
|
|
3347
|
+
var $d08ef79370b62062$export$e4f69b41b1637536 = /* @__PURE__ */ forwardRef((props, forwardedRef) => {
|
|
3348
|
+
const { __scopeDropdownMenu, ...radioItemProps } = props;
|
|
3349
|
+
const menuScope = $d08ef79370b62062$var$useMenuScope(__scopeDropdownMenu);
|
|
3350
|
+
return /* @__PURE__ */ createElement(RadioItem, $01b9c$babelruntimehelpersesmextends({}, menuScope, radioItemProps, {
|
|
3351
|
+
ref: forwardedRef
|
|
3352
|
+
}));
|
|
3353
|
+
});
|
|
3354
|
+
var $d08ef79370b62062$export$42355ae145153fb6 = /* @__PURE__ */ forwardRef((props, forwardedRef) => {
|
|
3355
|
+
const { __scopeDropdownMenu, ...itemIndicatorProps } = props;
|
|
3356
|
+
const menuScope = $d08ef79370b62062$var$useMenuScope(__scopeDropdownMenu);
|
|
3357
|
+
return /* @__PURE__ */ createElement(ItemIndicator, $01b9c$babelruntimehelpersesmextends({}, menuScope, itemIndicatorProps, {
|
|
3358
|
+
ref: forwardedRef
|
|
3359
|
+
}));
|
|
3360
|
+
});
|
|
3361
|
+
var $d08ef79370b62062$export$da160178fd3bc7e9 = /* @__PURE__ */ forwardRef((props, forwardedRef) => {
|
|
3362
|
+
const { __scopeDropdownMenu, ...separatorProps } = props;
|
|
3363
|
+
const menuScope = $d08ef79370b62062$var$useMenuScope(__scopeDropdownMenu);
|
|
3364
|
+
return /* @__PURE__ */ createElement(Separator, $01b9c$babelruntimehelpersesmextends({}, menuScope, separatorProps, {
|
|
3365
|
+
ref: forwardedRef
|
|
3366
|
+
}));
|
|
3367
|
+
});
|
|
3368
|
+
var $d08ef79370b62062$export$21dcb7ec56f874cf = /* @__PURE__ */ forwardRef((props, forwardedRef) => {
|
|
3369
|
+
const { __scopeDropdownMenu, ...subTriggerProps } = props;
|
|
3370
|
+
const menuScope = $d08ef79370b62062$var$useMenuScope(__scopeDropdownMenu);
|
|
3371
|
+
return /* @__PURE__ */ createElement(SubTrigger, $01b9c$babelruntimehelpersesmextends({}, menuScope, subTriggerProps, {
|
|
3372
|
+
ref: forwardedRef
|
|
3373
|
+
}));
|
|
3374
|
+
});
|
|
3375
|
+
var $d08ef79370b62062$export$f34ec8bc2482cc5f = /* @__PURE__ */ forwardRef((props, forwardedRef) => {
|
|
3376
|
+
const { __scopeDropdownMenu, ...subContentProps } = props;
|
|
3377
|
+
const menuScope = $d08ef79370b62062$var$useMenuScope(__scopeDropdownMenu);
|
|
3378
|
+
return /* @__PURE__ */ createElement(SubContent, $01b9c$babelruntimehelpersesmextends({}, menuScope, subContentProps, {
|
|
3379
|
+
ref: forwardedRef,
|
|
3380
|
+
style: {
|
|
3381
|
+
...props.style,
|
|
3382
|
+
"--radix-dropdown-menu-content-transform-origin": "var(--radix-popper-transform-origin)",
|
|
3383
|
+
"--radix-dropdown-menu-content-available-width": "var(--radix-popper-available-width)",
|
|
3384
|
+
"--radix-dropdown-menu-content-available-height": "var(--radix-popper-available-height)",
|
|
3385
|
+
"--radix-dropdown-menu-trigger-width": "var(--radix-popper-anchor-width)",
|
|
3386
|
+
"--radix-dropdown-menu-trigger-height": "var(--radix-popper-anchor-height)"
|
|
3387
|
+
}
|
|
3388
|
+
}));
|
|
3389
|
+
});
|
|
3390
|
+
var $d08ef79370b62062$export$be92b6f5f03c0fe9 = $d08ef79370b62062$export$e44a253a59704894;
|
|
3391
|
+
var $d08ef79370b62062$export$41fb9f06171c75f4 = $d08ef79370b62062$export$d2469213b3befba9;
|
|
3392
|
+
var $d08ef79370b62062$export$602eac185826482c = $d08ef79370b62062$export$cd369b4d4d54efc9;
|
|
3393
|
+
var $d08ef79370b62062$export$7c6e2c02157bb7d2 = $d08ef79370b62062$export$6e76d93a37c01248;
|
|
3394
|
+
var $d08ef79370b62062$export$b04be29aa201d4f5 = $d08ef79370b62062$export$76e48c5b57f24495;
|
|
3395
|
+
var $d08ef79370b62062$export$6d08773d2e66f8f2 = $d08ef79370b62062$export$ed97964d1871885d;
|
|
3396
|
+
var $d08ef79370b62062$export$16ce288f89fa631c = $d08ef79370b62062$export$53a69729da201fa9;
|
|
3397
|
+
var $d08ef79370b62062$export$371ab307eab489c0 = $d08ef79370b62062$export$e4f69b41b1637536;
|
|
3398
|
+
var $d08ef79370b62062$export$c3468e2714d175fa = $d08ef79370b62062$export$42355ae145153fb6;
|
|
3399
|
+
var $d08ef79370b62062$export$1ff3c3f08ae963c0 = $d08ef79370b62062$export$da160178fd3bc7e9;
|
|
3400
|
+
var $d08ef79370b62062$export$2ea8a7a591ac5eac = $d08ef79370b62062$export$21dcb7ec56f874cf;
|
|
3401
|
+
var $d08ef79370b62062$export$6d4de93b380beddf = $d08ef79370b62062$export$f34ec8bc2482cc5f;
|
|
3402
|
+
var DropdownMenu = $d08ef79370b62062$export$be92b6f5f03c0fe9;
|
|
3403
|
+
var DropdownMenuTrigger = $d08ef79370b62062$export$41fb9f06171c75f4;
|
|
3404
|
+
var DropdownMenuSubTrigger = React4.forwardRef(({ className, inset, children, ...props }, ref) => /* @__PURE__ */ jsxs(
|
|
3405
|
+
$d08ef79370b62062$export$2ea8a7a591ac5eac,
|
|
3406
|
+
{
|
|
3407
|
+
ref,
|
|
3408
|
+
className: cn(
|
|
3409
|
+
"flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[state=open]:bg-accent focus:bg-accent",
|
|
3410
|
+
inset && "pl-8",
|
|
3411
|
+
className
|
|
3412
|
+
),
|
|
3413
|
+
...props,
|
|
3414
|
+
children: [
|
|
3415
|
+
children,
|
|
3416
|
+
/* @__PURE__ */ jsx(ChevronRightIcon, { className: "ml-auto h-4 w-4" })
|
|
3417
|
+
]
|
|
3418
|
+
}
|
|
3419
|
+
));
|
|
3420
|
+
DropdownMenuSubTrigger.displayName = $d08ef79370b62062$export$2ea8a7a591ac5eac.displayName;
|
|
3421
|
+
var DropdownMenuSubContent = React4.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
3422
|
+
$d08ef79370b62062$export$6d4de93b380beddf,
|
|
3423
|
+
{
|
|
3424
|
+
ref,
|
|
3425
|
+
className: cn(
|
|
3426
|
+
"data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=closed]:animate-out data-[state=open]:animate-in",
|
|
3427
|
+
className
|
|
3428
|
+
),
|
|
3429
|
+
...props
|
|
3430
|
+
}
|
|
3431
|
+
));
|
|
3432
|
+
DropdownMenuSubContent.displayName = $d08ef79370b62062$export$6d4de93b380beddf.displayName;
|
|
3433
|
+
var DropdownMenuContent = React4.forwardRef(({ className, sideOffset = 4, ...props }, ref) => /* @__PURE__ */ jsx($d08ef79370b62062$export$602eac185826482c, { children: /* @__PURE__ */ jsx(
|
|
3434
|
+
$d08ef79370b62062$export$7c6e2c02157bb7d2,
|
|
3435
|
+
{
|
|
3436
|
+
ref,
|
|
3437
|
+
sideOffset,
|
|
3438
|
+
className: cn(
|
|
3439
|
+
"z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md",
|
|
3440
|
+
"data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=open]:animate-in",
|
|
3441
|
+
className
|
|
3442
|
+
),
|
|
3443
|
+
...props
|
|
3444
|
+
}
|
|
3445
|
+
) }));
|
|
3446
|
+
DropdownMenuContent.displayName = $d08ef79370b62062$export$7c6e2c02157bb7d2.displayName;
|
|
3447
|
+
var DropdownMenuItem = React4.forwardRef(({ className, inset, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
3448
|
+
$d08ef79370b62062$export$6d08773d2e66f8f2,
|
|
3449
|
+
{
|
|
3450
|
+
ref,
|
|
3451
|
+
className: cn(
|
|
3452
|
+
"relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors data-[disabled]:pointer-events-none focus:bg-accent focus:text-accent-foreground data-[disabled]:opacity-50",
|
|
3453
|
+
inset && "pl-8",
|
|
3454
|
+
className
|
|
3455
|
+
),
|
|
3456
|
+
...props
|
|
3457
|
+
}
|
|
3458
|
+
));
|
|
3459
|
+
DropdownMenuItem.displayName = $d08ef79370b62062$export$6d08773d2e66f8f2.displayName;
|
|
3460
|
+
var DropdownMenuCheckboxItem = React4.forwardRef(({ className, children, checked, ...props }, ref) => /* @__PURE__ */ jsxs(
|
|
3461
|
+
$d08ef79370b62062$export$16ce288f89fa631c,
|
|
3462
|
+
{
|
|
3463
|
+
ref,
|
|
3464
|
+
className: cn(
|
|
3465
|
+
"relative flex cursor-default select-none items-center rounded-sm py-1.5 pr-2 pl-8 text-sm outline-none transition-colors data-[disabled]:pointer-events-none focus:bg-accent focus:text-accent-foreground data-[disabled]:opacity-50",
|
|
3466
|
+
className
|
|
3467
|
+
),
|
|
3468
|
+
checked,
|
|
3469
|
+
...props,
|
|
3470
|
+
children: [
|
|
3471
|
+
/* @__PURE__ */ jsx("span", { className: "absolute left-2 flex h-3.5 w-3.5 items-center justify-center", children: /* @__PURE__ */ jsx($d08ef79370b62062$export$c3468e2714d175fa, { children: /* @__PURE__ */ jsx(CheckIcon, { className: "h-4 w-4" }) }) }),
|
|
3472
|
+
children
|
|
3473
|
+
]
|
|
3474
|
+
}
|
|
3475
|
+
));
|
|
3476
|
+
DropdownMenuCheckboxItem.displayName = $d08ef79370b62062$export$16ce288f89fa631c.displayName;
|
|
3477
|
+
var DropdownMenuRadioItem = React4.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs(
|
|
3478
|
+
$d08ef79370b62062$export$371ab307eab489c0,
|
|
3479
|
+
{
|
|
3480
|
+
ref,
|
|
3481
|
+
className: cn(
|
|
3482
|
+
"relative flex cursor-default select-none items-center rounded-sm py-1.5 pr-2 pl-8 text-sm outline-none transition-colors data-[disabled]:pointer-events-none focus:bg-accent focus:text-accent-foreground data-[disabled]:opacity-50",
|
|
3483
|
+
className
|
|
3484
|
+
),
|
|
3485
|
+
...props,
|
|
3486
|
+
children: [
|
|
3487
|
+
/* @__PURE__ */ jsx("span", { className: "absolute left-2 flex h-3.5 w-3.5 items-center justify-center", children: /* @__PURE__ */ jsx($d08ef79370b62062$export$c3468e2714d175fa, { children: /* @__PURE__ */ jsx(DotFilledIcon, { className: "h-4 w-4 fill-current" }) }) }),
|
|
3488
|
+
children
|
|
3489
|
+
]
|
|
3490
|
+
}
|
|
3491
|
+
));
|
|
3492
|
+
DropdownMenuRadioItem.displayName = $d08ef79370b62062$export$371ab307eab489c0.displayName;
|
|
3493
|
+
var DropdownMenuLabel = React4.forwardRef(({ className, inset, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
3494
|
+
$d08ef79370b62062$export$b04be29aa201d4f5,
|
|
3495
|
+
{
|
|
3496
|
+
ref,
|
|
3497
|
+
className: cn("px-2 py-1.5 font-semibold text-sm", inset && "pl-8", className),
|
|
3498
|
+
...props
|
|
3499
|
+
}
|
|
3500
|
+
));
|
|
3501
|
+
DropdownMenuLabel.displayName = $d08ef79370b62062$export$b04be29aa201d4f5.displayName;
|
|
3502
|
+
var DropdownMenuSeparator = React4.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
3503
|
+
$d08ef79370b62062$export$1ff3c3f08ae963c0,
|
|
3504
|
+
{
|
|
3505
|
+
ref,
|
|
3506
|
+
className: cn("-mx-1 my-1 h-px bg-muted", className),
|
|
3507
|
+
...props
|
|
3508
|
+
}
|
|
3509
|
+
));
|
|
3510
|
+
DropdownMenuSeparator.displayName = $d08ef79370b62062$export$1ff3c3f08ae963c0.displayName;
|
|
3511
|
+
function Toolbar() {
|
|
3512
|
+
const {
|
|
3513
|
+
hasSomeEntireRow,
|
|
3514
|
+
emptySize,
|
|
3515
|
+
staticRows,
|
|
3516
|
+
columns,
|
|
3517
|
+
onInsertNewRow,
|
|
3518
|
+
onRemoveRow,
|
|
3519
|
+
onColumnVisibilityChange
|
|
3520
|
+
} = useSpreadsheet();
|
|
3521
|
+
const visibleColumns = useMemo$1(() => columns.filter(({ visible }) => visible), [columns]);
|
|
3522
|
+
const allVisible = useMemo$1(
|
|
3523
|
+
() => columns.length === visibleColumns.length,
|
|
3524
|
+
[columns.length, visibleColumns.length]
|
|
3525
|
+
);
|
|
3526
|
+
const allVisibleLabel = "Exibindo todas as colunas";
|
|
3527
|
+
const visibleColumnsLabel = `Exibindo ${visibleColumns.length} de ${columns.length} colunas`;
|
|
3528
|
+
const columnVisibilityLabel = allVisible ? allVisibleLabel : visibleColumnsLabel;
|
|
3529
|
+
return /* @__PURE__ */ jsxs("div", { className: "sticky top-0 z-50 flex w-full items-center justify-between rounded-t-md border bg-[#EAF5FF] px-4 py-2.5", children: [
|
|
3530
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-6", children: [
|
|
3531
|
+
/* @__PURE__ */ jsx(
|
|
3532
|
+
Button,
|
|
3533
|
+
{
|
|
3534
|
+
disabled: staticRows,
|
|
3535
|
+
size: "icon",
|
|
3536
|
+
variant: "ghost",
|
|
3537
|
+
onClick: onInsertNewRow,
|
|
3538
|
+
className: "text-[#4A4A6A] transition-none active:bg-[#0085FF] hover:bg-[#8FD6FF] active:text-white",
|
|
3539
|
+
children: /* @__PURE__ */ jsx(AddRowIcon, {})
|
|
3540
|
+
}
|
|
3541
|
+
),
|
|
3542
|
+
/* @__PURE__ */ jsx(
|
|
3543
|
+
Button,
|
|
3544
|
+
{
|
|
3545
|
+
disabled: staticRows || emptySize || !hasSomeEntireRow,
|
|
3546
|
+
size: "icon",
|
|
3547
|
+
variant: "ghost",
|
|
3548
|
+
onClick: onRemoveRow,
|
|
3549
|
+
className: "text-[#4A4A6A] transition-none active:bg-[#0085FF] hover:bg-[#8FD6FF] active:text-white",
|
|
3550
|
+
children: /* @__PURE__ */ jsx(RemoveRowIcon, {})
|
|
3551
|
+
}
|
|
3552
|
+
)
|
|
3553
|
+
] }),
|
|
3554
|
+
/* @__PURE__ */ jsxs(DropdownMenu, { children: [
|
|
3555
|
+
/* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: true, className: "w-56", children: /* @__PURE__ */ jsxs(Button, { variant: "outline", className: "justify-between px-2", children: [
|
|
3556
|
+
/* @__PURE__ */ jsx("span", { className: "text-xs", children: columnVisibilityLabel }),
|
|
3557
|
+
/* @__PURE__ */ jsx(ChevronDown, { className: "h-4 w-4" })
|
|
3558
|
+
] }) }),
|
|
3559
|
+
/* @__PURE__ */ jsx(DropdownMenuContent, { className: "w-56", children: columns.map(({ name, id, alphabetLetter, visible }) => /* @__PURE__ */ jsxs(
|
|
3560
|
+
DropdownMenuCheckboxItem,
|
|
3561
|
+
{
|
|
3562
|
+
checked: visible,
|
|
3563
|
+
onCheckedChange: () => onColumnVisibilityChange(id),
|
|
3564
|
+
className: "justify-between text-xs",
|
|
3565
|
+
children: [
|
|
3566
|
+
/* @__PURE__ */ jsx("span", { children: name }),
|
|
3567
|
+
/* @__PURE__ */ jsx("span", { className: "text-[10px] text-neutral-500", children: alphabetLetter })
|
|
3568
|
+
]
|
|
3569
|
+
},
|
|
3570
|
+
`spreadsheet__column__dropdown_checkbox__key__${nanoid()}`
|
|
3571
|
+
)) })
|
|
3572
|
+
] })
|
|
3573
|
+
] });
|
|
3574
|
+
}
|
|
3575
|
+
function Spreadsheet(props) {
|
|
3576
|
+
const { className, ...rest } = props;
|
|
3577
|
+
return /* @__PURE__ */ jsx(SpreadsheetContextProvider, { ...rest, children: /* @__PURE__ */ jsxs(Container.Root, { className, children: [
|
|
3578
|
+
/* @__PURE__ */ jsx(Toolbar, {}),
|
|
3579
|
+
/* @__PURE__ */ jsxs(Container.Matrix, { children: [
|
|
3580
|
+
/* @__PURE__ */ jsx(Start, { className: "absolute z-50" }),
|
|
3581
|
+
/* @__PURE__ */ jsx(Header, {}),
|
|
3582
|
+
/* @__PURE__ */ jsx(Rows, {})
|
|
3583
|
+
] })
|
|
3584
|
+
] }) });
|
|
3585
|
+
}
|
|
3586
|
+
|
|
3587
|
+
// src/index.ts
|
|
3588
|
+
var CapLink = {
|
|
3589
|
+
Spreadsheet
|
|
3590
|
+
};
|
|
3591
|
+
|
|
3592
|
+
export { CapLink };
|
|
23
3593
|
//# sourceMappingURL=out.js.map
|
|
24
3594
|
//# sourceMappingURL=index.js.map
|