@adamosuiteservices/ui 2.14.2 → 2.15.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/combobox-DGuQtXjP.js +608 -0
- package/dist/combobox-hTCtPMUL.cjs +40 -0
- package/dist/combobox.cjs +1 -1
- package/dist/combobox.js +1 -1
- package/dist/components/ui/combobox/combobox.d.ts +5 -1
- package/dist/components/ui/date-picker-selector/date-picker-selector.d.ts +5 -1
- package/dist/components/ui/file-upload/file-upload.d.ts +4 -1
- package/dist/components/ui/slider/slider.d.ts +1 -1
- package/dist/components/ui/switch/switch.d.ts +1 -1
- package/dist/date-picker-selector.cjs +1 -1
- package/dist/date-picker-selector.js +38 -28
- package/dist/field.cjs +2 -2
- package/dist/field.js +2 -2
- package/dist/file-upload.cjs +5 -3
- package/dist/file-upload.js +191 -150
- package/dist/slider.cjs +5 -5
- package/dist/slider.js +196 -177
- package/dist/styles.css +1 -1
- package/dist/switch.cjs +3 -3
- package/dist/switch.js +105 -85
- package/docs/components/ui/accordion-rounded.md +2 -6
- package/docs/components/ui/avatar.md +3 -1
- package/docs/components/ui/button.md +22 -16
- package/docs/components/ui/card.md +49 -31
- package/docs/components/ui/checkbox.md +44 -8
- package/docs/components/ui/combobox.md +62 -4
- package/docs/components/ui/date-picker-selector.md +90 -26
- package/docs/components/ui/file-upload.md +364 -95
- package/docs/components/ui/icon.md +1 -1
- package/docs/components/ui/input.md +4 -1
- package/docs/components/ui/radio-group.md +1 -1
- package/docs/components/ui/select.md +51 -34
- package/docs/components/ui/sheet.md +3 -9
- package/docs/components/ui/slider.md +120 -99
- package/docs/components/ui/switch.md +408 -408
- package/docs/components/ui/textarea.md +37 -22
- package/docs/components/ui/tooltip.md +5 -2
- package/docs/components/ui/typography.md +63 -39
- package/package.json +1 -1
- package/dist/combobox-CCJGIMFQ.cjs +0 -40
- package/dist/combobox-Cj-GEp-T.js +0 -604
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use client";"use strict";const x=require("./jsx-runtime-BB_1_6y_.cjs"),Ce=require("./button-DVrteFz9.cjs"),Ae=require("./checkbox-DHFt3l5c.cjs"),Q=require("./icon-DPMQJBkA.cjs"),N=require("./index-DoxiiusW.cjs"),ue=require("react"),oe=require("./index-Ca99LLZF.cjs"),$=require("./index-CocSS1YK.cjs"),W=require("./index-WIv2ndLu.cjs"),Z=require("./index-_XxjJPRD.cjs"),de=require("./popover-cGp_rNLg.cjs");function Ne(e){const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const p=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(a,r,p.get?p:{enumerable:!0,get:()=>e[r]})}}return a.default=e,Object.freeze(a)}const l=Ne(ue);var he=1,Pe=.9,qe=.8,Me=.17,ce=.1,me=.999,$e=.9999,De=.99,Le=/[\\\/_+.#"@\[\(\{&]/,Oe=/[\\\/_+.#"@\[\(\{&]/g,Fe=/[\s-]/,ye=/[\s-]/g;function pe(e,a,r,p,o,d,f){if(d===a.length)return o===e.length?he:De;var m=`${o},${d}`;if(f[m]!==void 0)return f[m];for(var b=p.charAt(d),u=r.indexOf(b,o),g=0,s,E,k,C;u>=0;)s=pe(e,a,r,p,u+1,d+1,f),s>g&&(u===o?s*=he:Le.test(e.charAt(u-1))?(s*=qe,k=e.slice(o,u-1).match(Oe),k&&o>0&&(s*=Math.pow(me,k.length))):Fe.test(e.charAt(u-1))?(s*=Pe,C=e.slice(o,u-1).match(ye),C&&o>0&&(s*=Math.pow(me,C.length))):(s*=Me,o>0&&(s*=Math.pow(me,u-o))),e.charAt(u)!==a.charAt(d)&&(s*=$e)),(s<ce&&r.charAt(u-1)===p.charAt(d+1)||p.charAt(d+1)===p.charAt(d)&&r.charAt(u-1)!==p.charAt(d))&&(E=pe(e,a,r,p,u+1,d+2,f),E*ce>s&&(s=E*ce)),s>g&&(g=s),u=r.indexOf(b,u+1);return f[m]=g,g}function ge(e){return e.toLowerCase().replace(ye," ")}function Te(e,a,r){return e=r&&r.length>0?`${e+" "+r.join(" ")}`:e,pe(e,a,ge(e),ge(a),0,0,{})}var Y='[cmdk-group=""]',fe='[cmdk-group-items=""]',Ve='[cmdk-group-heading=""]',je='[cmdk-item=""]',be=`${je}:not([aria-disabled="true"])`,xe="cmdk-item-select",z="data-value",Ke=(e,a,r)=>Te(e,a,r),Ee=l.createContext(void 0),ee=()=>l.useContext(Ee),Re=l.createContext(void 0),ve=()=>l.useContext(Re),ke=l.createContext(void 0),Ie=l.forwardRef((e,a)=>{let r=B(()=>{var t,n;return{search:"",value:(n=(t=e.value)!=null?t:e.defaultValue)!=null?n:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),p=B(()=>new Set),o=B(()=>new Map),d=B(()=>new Map),f=B(()=>new Set),m=we(e),{label:b,children:u,value:g,onValueChange:s,filter:E,shouldFilter:k,loop:C,disablePointerSelection:T=!1,vimBindings:S=!0,...D}=e,U=W.useId(),te=W.useId(),y=W.useId(),P=l.useRef(null),h=Qe();F(()=>{if(g!==void 0){let t=g.trim();r.current.value=t,R.emit()}},[g]),F(()=>{h(6,J)},[]);let R=l.useMemo(()=>({subscribe:t=>(f.current.add(t),()=>f.current.delete(t)),snapshot:()=>r.current,setState:(t,n,c)=>{var i,v,j,w;if(!Object.is(r.current[t],n)){if(r.current[t]=n,t==="search")K(),V(),h(1,H);else if(t==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let I=document.getElementById(y);I?I.focus():(i=document.getElementById(U))==null||i.focus()}if(h(7,()=>{var I;r.current.selectedItemId=(I=A())==null?void 0:I.id,R.emit()}),c||h(5,J),((v=m.current)==null?void 0:v.value)!==void 0){let I=n??"";(w=(j=m.current).onValueChange)==null||w.call(j,I);return}}R.emit()}},emit:()=>{f.current.forEach(t=>t())}}),[]),L=l.useMemo(()=>({value:(t,n,c)=>{var i;n!==((i=d.current.get(t))==null?void 0:i.value)&&(d.current.set(t,{value:n,keywords:c}),r.current.filtered.items.set(t,q(n,c)),h(2,()=>{V(),R.emit()}))},item:(t,n)=>(p.current.add(t),n&&(o.current.has(n)?o.current.get(n).add(t):o.current.set(n,new Set([t]))),h(3,()=>{K(),V(),r.current.value||H(),R.emit()}),()=>{d.current.delete(t),p.current.delete(t),r.current.filtered.items.delete(t);let c=A();h(4,()=>{K(),c?.getAttribute("id")===t&&H(),R.emit()})}),group:t=>(o.current.has(t)||o.current.set(t,new Set),()=>{d.current.delete(t),o.current.delete(t)}),filter:()=>m.current.shouldFilter,label:b||e["aria-label"],getDisablePointerSelection:()=>m.current.disablePointerSelection,listId:U,inputId:y,labelId:te,listInnerRef:P}),[]);function q(t,n){var c,i;let v=(i=(c=m.current)==null?void 0:c.filter)!=null?i:Ke;return t?v(t,r.current.search,n):0}function V(){if(!r.current.search||m.current.shouldFilter===!1)return;let t=r.current.filtered.items,n=[];r.current.filtered.groups.forEach(i=>{let v=o.current.get(i),j=0;v.forEach(w=>{let I=t.get(w);j=Math.max(I,j)}),n.push([i,j])});let c=P.current;O().sort((i,v)=>{var j,w;let I=i.getAttribute("id"),ie=v.getAttribute("id");return((j=t.get(ie))!=null?j:0)-((w=t.get(I))!=null?w:0)}).forEach(i=>{let v=i.closest(fe);v?v.appendChild(i.parentElement===v?i:i.closest(`${fe} > *`)):c.appendChild(i.parentElement===c?i:i.closest(`${fe} > *`))}),n.sort((i,v)=>v[1]-i[1]).forEach(i=>{var v;let j=(v=P.current)==null?void 0:v.querySelector(`${Y}[${z}="${encodeURIComponent(i[0])}"]`);j?.parentElement.appendChild(j)})}function H(){let t=O().find(c=>c.getAttribute("aria-disabled")!=="true"),n=t?.getAttribute(z);R.setState("value",n||void 0)}function K(){var t,n,c,i;if(!r.current.search||m.current.shouldFilter===!1){r.current.filtered.count=p.current.size;return}r.current.filtered.groups=new Set;let v=0;for(let j of p.current){let w=(n=(t=d.current.get(j))==null?void 0:t.value)!=null?n:"",I=(i=(c=d.current.get(j))==null?void 0:c.keywords)!=null?i:[],ie=q(w,I);r.current.filtered.items.set(j,ie),ie>0&&v++}for(let[j,w]of o.current)for(let I of w)if(r.current.filtered.items.get(I)>0){r.current.filtered.groups.add(j);break}r.current.filtered.count=v}function J(){var t,n,c;let i=A();i&&(((t=i.parentElement)==null?void 0:t.firstChild)===i&&((c=(n=i.closest(Y))==null?void 0:n.querySelector(Ve))==null||c.scrollIntoView({block:"nearest"})),i.scrollIntoView({block:"nearest"}))}function A(){var t;return(t=P.current)==null?void 0:t.querySelector(`${je}[aria-selected="true"]`)}function O(){var t;return Array.from(((t=P.current)==null?void 0:t.querySelectorAll(be))||[])}function _(t){let n=O()[t];n&&R.setState("value",n.getAttribute(z))}function X(t){var n;let c=A(),i=O(),v=i.findIndex(w=>w===c),j=i[v+t];(n=m.current)!=null&&n.loop&&(j=v+t<0?i[i.length-1]:v+t===i.length?i[0]:i[v+t]),j&&R.setState("value",j.getAttribute(z))}function re(t){let n=A(),c=n?.closest(Y),i;for(;c&&!i;)c=t>0?Xe(c,Y):Ye(c,Y),i=c?.querySelector(be);i?R.setState("value",i.getAttribute(z)):X(t)}let ne=()=>_(O().length-1),ae=t=>{t.preventDefault(),t.metaKey?ne():t.altKey?re(1):X(1)},le=t=>{t.preventDefault(),t.metaKey?_(0):t.altKey?re(-1):X(-1)};return l.createElement($.Primitive.div,{ref:a,tabIndex:-1,...D,"cmdk-root":"",onKeyDown:t=>{var n;(n=D.onKeyDown)==null||n.call(D,t);let c=t.nativeEvent.isComposing||t.keyCode===229;if(!(t.defaultPrevented||c))switch(t.key){case"n":case"j":{S&&t.ctrlKey&&ae(t);break}case"ArrowDown":{ae(t);break}case"p":case"k":{S&&t.ctrlKey&&le(t);break}case"ArrowUp":{le(t);break}case"Home":{t.preventDefault(),_(0);break}case"End":{t.preventDefault(),ne();break}case"Enter":{t.preventDefault();let i=A();if(i){let v=new Event(xe);i.dispatchEvent(v)}}}}},l.createElement("label",{"cmdk-label":"",htmlFor:L.inputId,id:L.labelId,style:et},b),se(e,t=>l.createElement(Re.Provider,{value:R},l.createElement(Ee.Provider,{value:L},t))))}),_e=l.forwardRef((e,a)=>{var r,p;let o=W.useId(),d=l.useRef(null),f=l.useContext(ke),m=ee(),b=we(e),u=(p=(r=b.current)==null?void 0:r.forceMount)!=null?p:f?.forceMount;F(()=>{if(!u)return m.item(o,f?.id)},[u]);let g=Se(o,d,[e.value,e.children,d],e.keywords),s=ve(),E=M(h=>h.value&&h.value===g.current),k=M(h=>u||m.filter()===!1?!0:h.search?h.filtered.items.get(o)>0:!0);l.useEffect(()=>{let h=d.current;if(!(!h||e.disabled))return h.addEventListener(xe,C),()=>h.removeEventListener(xe,C)},[k,e.onSelect,e.disabled]);function C(){var h,R;T(),(R=(h=b.current).onSelect)==null||R.call(h,g.current)}function T(){s.setState("value",g.current,!0)}if(!k)return null;let{disabled:S,value:D,onSelect:U,forceMount:te,keywords:y,...P}=e;return l.createElement($.Primitive.div,{ref:Z.composeRefs(d,a),...P,id:o,"cmdk-item":"",role:"option","aria-disabled":!!S,"aria-selected":!!E,"data-disabled":!!S,"data-selected":!!E,onPointerMove:S||m.getDisablePointerSelection()?void 0:T,onClick:S?void 0:C},e.children)}),ze=l.forwardRef((e,a)=>{let{heading:r,children:p,forceMount:o,...d}=e,f=W.useId(),m=l.useRef(null),b=l.useRef(null),u=W.useId(),g=ee(),s=M(k=>o||g.filter()===!1?!0:k.search?k.filtered.groups.has(f):!0);F(()=>g.group(f),[]),Se(f,m,[e.value,e.heading,b]);let E=l.useMemo(()=>({id:f,forceMount:o}),[o]);return l.createElement($.Primitive.div,{ref:Z.composeRefs(m,a),...d,"cmdk-group":"",role:"presentation",hidden:s?void 0:!0},r&&l.createElement("div",{ref:b,"cmdk-group-heading":"","aria-hidden":!0,id:u},r),se(e,k=>l.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":r?u:void 0},l.createElement(ke.Provider,{value:E},k))))}),Be=l.forwardRef((e,a)=>{let{alwaysRender:r,...p}=e,o=l.useRef(null),d=M(f=>!f.search);return!r&&!d?null:l.createElement($.Primitive.div,{ref:Z.composeRefs(o,a),...p,"cmdk-separator":"",role:"separator"})}),We=l.forwardRef((e,a)=>{let{onValueChange:r,...p}=e,o=e.value!=null,d=ve(),f=M(u=>u.search),m=M(u=>u.selectedItemId),b=ee();return l.useEffect(()=>{e.value!=null&&d.setState("search",e.value)},[e.value]),l.createElement($.Primitive.input,{ref:a,...p,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":b.listId,"aria-labelledby":b.labelId,"aria-activedescendant":m,id:b.inputId,type:"text",value:o?e.value:f,onChange:u=>{o||d.setState("search",u.target.value),r?.(u.target.value)}})}),Ge=l.forwardRef((e,a)=>{let{children:r,label:p="Suggestions",...o}=e,d=l.useRef(null),f=l.useRef(null),m=M(u=>u.selectedItemId),b=ee();return l.useEffect(()=>{if(f.current&&d.current){let u=f.current,g=d.current,s,E=new ResizeObserver(()=>{s=requestAnimationFrame(()=>{let k=u.offsetHeight;g.style.setProperty("--cmdk-list-height",k.toFixed(1)+"px")})});return E.observe(u),()=>{cancelAnimationFrame(s),E.unobserve(u)}}},[]),l.createElement($.Primitive.div,{ref:Z.composeRefs(d,a),...o,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":m,"aria-label":p,id:b.listId},se(e,u=>l.createElement("div",{ref:Z.composeRefs(f,b.listInnerRef),"cmdk-list-sizer":""},u)))}),Ue=l.forwardRef((e,a)=>{let{open:r,onOpenChange:p,overlayClassName:o,contentClassName:d,container:f,...m}=e;return l.createElement(oe.Root,{open:r,onOpenChange:p},l.createElement(oe.Portal,{container:f},l.createElement(oe.Overlay,{"cmdk-overlay":"",className:o}),l.createElement(oe.Content,{"aria-label":e.label,"cmdk-dialog":"",className:d},l.createElement(Ie,{ref:a,...m}))))}),He=l.forwardRef((e,a)=>M(r=>r.filtered.count===0)?l.createElement($.Primitive.div,{ref:a,...e,"cmdk-empty":"",role:"presentation"}):null),Je=l.forwardRef((e,a)=>{let{progress:r,children:p,label:o="Loading...",...d}=e;return l.createElement($.Primitive.div,{ref:a,...d,"cmdk-loading":"",role:"progressbar","aria-valuenow":r,"aria-valuemin":0,"aria-valuemax":100,"aria-label":o},se(e,f=>l.createElement("div",{"aria-hidden":!0},f)))}),G=Object.assign(Ie,{List:Ge,Item:_e,Input:We,Group:ze,Separator:Be,Dialog:Ue,Empty:He,Loading:Je});function Xe(e,a){let r=e.nextElementSibling;for(;r;){if(r.matches(a))return r;r=r.nextElementSibling}}function Ye(e,a){let r=e.previousElementSibling;for(;r;){if(r.matches(a))return r;r=r.previousElementSibling}}function we(e){let a=l.useRef(e);return F(()=>{a.current=e}),a}var F=typeof window>"u"?l.useEffect:l.useLayoutEffect;function B(e){let a=l.useRef();return a.current===void 0&&(a.current=e()),a}function M(e){let a=ve(),r=()=>e(a.snapshot());return l.useSyncExternalStore(a.subscribe,r,r)}function Se(e,a,r,p=[]){let o=l.useRef(),d=ee();return F(()=>{var f;let m=(()=>{var u;for(let g of r){if(typeof g=="string")return g.trim();if(typeof g=="object"&&"current"in g)return g.current?(u=g.current.textContent)==null?void 0:u.trim():o.current}})(),b=p.map(u=>u.trim());d.value(e,m,b),(f=a.current)==null||f.setAttribute(z,m),o.current=m}),o}var Qe=()=>{let[e,a]=l.useState(),r=B(()=>new Map);return F(()=>{r.current.forEach(p=>p()),r.current=new Map},[e]),(p,o)=>{r.current.set(p,o),a({})}};function Ze(e){let a=e.type;return typeof a=="function"?a(e.props):"render"in a?a.render(e.props):e}function se({asChild:e,children:a},r){return e&&l.isValidElement(a)?l.cloneElement(Ze(a),{ref:a.ref},r(a.props.children)):r(a)}var et={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};function tt({className:e,...a}){return x.jsxRuntimeExports.jsx(G,{"data-slot":"command",className:N.cn(`
|
|
2
|
+
adm:flex adm:h-full adm:w-full adm:flex-col adm:overflow-hidden
|
|
3
|
+
adm:rounded-md adm:bg-popover adm:text-popover-foreground
|
|
4
|
+
`,e),...a})}function rt({className:e,...a}){return x.jsxRuntimeExports.jsxs("div",{"data-slot":"command-input-wrapper",className:`
|
|
5
|
+
adm:flex adm:h-10 adm:items-center adm:gap-2
|
|
6
|
+
adm:rounded-t-[calc(var(--radius)-1px)] adm:border-b adm:px-3
|
|
7
|
+
adm:*:data-[slot=icon]:shrink-0 adm:*:data-[slot=icon]:text-lg
|
|
8
|
+
adm:*:data-[slot=icon]:opacity-50
|
|
9
|
+
`,children:[x.jsxRuntimeExports.jsx(Q.Icon,{symbol:"search"}),x.jsxRuntimeExports.jsx(G.Input,{"data-slot":"command-input",className:N.cn(`
|
|
10
|
+
adm:flex adm:h-10 adm:w-full adm:rounded-md adm:bg-transparent
|
|
11
|
+
adm:py-3 adm:text-sm adm:outline-hidden
|
|
12
|
+
adm:placeholder:text-muted-foreground
|
|
13
|
+
adm:disabled:cursor-not-allowed adm:disabled:opacity-50
|
|
14
|
+
`,e),...a})]})}function nt({className:e,...a}){return x.jsxRuntimeExports.jsx(G.List,{"data-slot":"command-list",className:N.cn(`
|
|
15
|
+
adm:max-h-[300px] adm:scroll-py-1 adm:overflow-x-hidden
|
|
16
|
+
adm:overflow-y-auto
|
|
17
|
+
`,e),...a})}function at({className:e,...a}){return x.jsxRuntimeExports.jsx(G.Empty,{"data-slot":"command-empty",className:N.cn("adm:py-6 adm:text-center adm:text-sm",e),...a})}function lt({className:e,...a}){return x.jsxRuntimeExports.jsx(G.Group,{"data-slot":"command-group",className:N.cn(`
|
|
18
|
+
adm:overflow-hidden adm:text-foreground
|
|
19
|
+
adm:**:**:**:**:**:**:[&_[cmdk-group-heading]]:px-2
|
|
20
|
+
adm:**:**:**:**:**:**:[&_[cmdk-group-heading]]:py-1.5
|
|
21
|
+
adm:**:**:**:**:**:**:[&_[cmdk-group-heading]]:text-xs
|
|
22
|
+
adm:**:**:**:**:**:**:[&_[cmdk-group-heading]]:font-medium
|
|
23
|
+
adm:**:**:**:**:**:**:[&_[cmdk-group-heading]]:text-muted-foreground
|
|
24
|
+
adm:[&_[data-slot=command-item]:last-of-type]:rounded-b-[calc(var(--radius)-1px)]
|
|
25
|
+
adm:[&_[data-slot=command-item]:last-of-type]:border-b-0
|
|
26
|
+
`,e),...a})}function it({className:e,...a}){return x.jsxRuntimeExports.jsx(G.Item,{"data-slot":"command-item",className:N.cn(`
|
|
27
|
+
adm:relative adm:flex adm:h-10 adm:cursor-default adm:items-center
|
|
28
|
+
adm:gap-2 adm:border-b adm:px-3 adm:text-sm adm:outline-hidden
|
|
29
|
+
adm:select-none
|
|
30
|
+
adm:data-[disabled=true]:pointer-events-none
|
|
31
|
+
adm:data-[disabled=true]:opacity-50
|
|
32
|
+
adm:data-[selected=true]:bg-accent
|
|
33
|
+
adm:data-[selected=true]:text-accent-foreground
|
|
34
|
+
adm:[&_svg]:pointer-events-none adm:[&_svg]:shrink-0
|
|
35
|
+
adm:[&_svg:not([class*=size-])]:size-4
|
|
36
|
+
adm:[&_svg:not([class*=text-])]:text-muted-foreground
|
|
37
|
+
`,e),...a})}function ot({searchable:e,multiple:a,icon:r,value:p,onValueChange:o,labels:d,options:f,classNames:m,selectedFeedback:b="checkbox",alwaysShowPlaceholder:u=!1,valuePosition:g="right",renders:s,ref:E,"aria-invalid":k,disabled:C}){const T=ue.useRef(null),[S,D]=ue.useState(!1),[U,te]=ue.useState(a?[]:""),y=p!==void 0?p:U,h={...{placeholder:"Select options...",searchPlaceholder:"Search options...",noItemsFound:"No options found.",multipleSelected:n=>`${n} options selected`},...d},R=n=>{o?o(n):te(n)},L=()=>a&&Array.isArray(y)?y.length===0?null:y.length===1?f.find(n=>n.value===y[0])?.label:h.multipleSelected?.(y.length)||`${y.length} options selected`:!a&&typeof y=="string"&&y?f.find(n=>n.value===y)?.label:null,q=()=>a&&Array.isArray(y)?y.length>0:typeof y=="string"&&y!=="",V=n=>a&&Array.isArray(y)?y.includes(n):y===n,H=n=>{if(a){const c=Array.isArray(y)?y:[],i=c.includes(n)?c.filter(v=>v!==n):[...c,n];R(i)}else R(n===y?"":n),D(!1)},K=n=>{const c=V(n),i=f.find(v=>v.value===n);return s?.selectedFeedback?s.selectedFeedback({option:i,isSelected:c,type:b}):b==="check"?x.jsxRuntimeExports.jsx("span",{className:N.cn(`
|
|
38
|
+
adm:absolute adm:right-2 adm:flex adm:size-3.5 adm:items-center
|
|
39
|
+
adm:justify-center
|
|
40
|
+
`,m?.check),children:c&&x.jsxRuntimeExports.jsx(Q.Icon,{symbol:"check",className:"adm:text-lg"})}):x.jsxRuntimeExports.jsx(Ae.Checkbox,{checked:c,className:m?.checkbox})},J=()=>s?.placeholder?s.placeholder({text:h.placeholder||"",hasValue:q()}):x.jsxRuntimeExports.jsx("span",{className:"adm:opacity-70",children:h.placeholder}),A=()=>s?.displayValue?s.displayValue({text:L()??null,value:y}):x.jsxRuntimeExports.jsx("span",{children:L()}),O=()=>u?x.jsxRuntimeExports.jsxs("span",{className:"adm:flex adm:items-center adm:gap-2",children:[r&&x.jsxRuntimeExports.jsx(Q.Icon,{symbol:r,className:"adm:opacity-50"}),J(),q()&&g==="left"&&A()]}):x.jsxRuntimeExports.jsxs("span",{className:"adm:flex adm:items-center adm:gap-2",children:[r&&x.jsxRuntimeExports.jsx(Q.Icon,{symbol:r,className:"adm:opacity-50"}),q()?A():J()]}),_=()=>s?.triggerIcon?s.triggerIcon({open:S}):x.jsxRuntimeExports.jsx(Q.Icon,{symbol:"expand_more",className:"adm:opacity-50"}),X=()=>u&&q()&&g==="right"?x.jsxRuntimeExports.jsxs("span",{className:"adm:flex adm:items-center adm:gap-2",children:[A(),_()]}):x.jsxRuntimeExports.jsx("span",{className:"adm:flex adm:items-center adm:gap-2",children:_()}),re=()=>s?.trigger?s.trigger({open:S,value:y,displayText:L()||"",placeholder:h.placeholder||"",hasValue:q(),icon:r}):x.jsxRuntimeExports.jsxs(Ce.Button,{ref:n=>{T.current=n,E&&(typeof E=="function"?E(n):E.current=n)},variant:"outline",role:"combobox","aria-expanded":S,"aria-invalid":k,disabled:C,className:N.cn("adm:justify-between adm:rounded-md adm:font-normal",m?.trigger),children:[O(),X()]}),ne=()=>e?s?.searchInput?s.searchInput({placeholder:h.searchPlaceholder||""}):x.jsxRuntimeExports.jsx(rt,{placeholder:h.searchPlaceholder,className:m?.input}):null,ae=()=>s?.empty?s.empty({text:h.noItemsFound||""}):x.jsxRuntimeExports.jsx(x.jsxRuntimeExports.Fragment,{children:h.noItemsFound}),le=n=>s?.optionLabel?s.optionLabel({option:n}):x.jsxRuntimeExports.jsx(x.jsxRuntimeExports.Fragment,{children:n.label}),t=n=>s?.option?x.jsxRuntimeExports.jsx("div",{children:s.option({option:n,isSelected:V(n.value),selectedFeedback:b})},n.value):x.jsxRuntimeExports.jsxs(it,{value:n.value,onSelect:H,disabled:n.disabled,className:N.cn(m?.item,b==="check"&&"adm:pr-10"),children:[b==="checkbox"&&K(n.value),le(n),b==="check"&&K(n.value)]},n.value);return x.jsxRuntimeExports.jsxs(de.Popover,{open:S,onOpenChange:D,children:[x.jsxRuntimeExports.jsx(de.PopoverTrigger,{asChild:!0,children:re()}),x.jsxRuntimeExports.jsx(de.PopoverContent,{align:"start",className:N.cn("adm:p-0",m?.popover),style:{minWidth:T.current?.offsetWidth},children:x.jsxRuntimeExports.jsxs(tt,{className:m?.command,children:[ne(),x.jsxRuntimeExports.jsxs(nt,{className:m?.list,children:[x.jsxRuntimeExports.jsx(at,{className:m?.empty,children:ae()}),x.jsxRuntimeExports.jsx(lt,{className:m?.group,children:f.map(n=>t(n))})]})]})})]})}exports.Combobox=ot;
|
package/dist/combobox.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./combobox-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./combobox-hTCtPMUL.cjs");exports.Combobox=o.Combobox;
|
package/dist/combobox.js
CHANGED
|
@@ -169,6 +169,10 @@ type ComboboxProps = Readonly<{
|
|
|
169
169
|
renders?: ComboboxRenderProps;
|
|
170
170
|
/** Ref to be forwarded to the trigger button element */
|
|
171
171
|
ref?: React.Ref<HTMLButtonElement>;
|
|
172
|
+
/** Indicates if the combobox has invalid input */
|
|
173
|
+
"aria-invalid"?: "true" | "false" | boolean;
|
|
174
|
+
/** Standard disabled prop */
|
|
175
|
+
disabled?: boolean;
|
|
172
176
|
}>;
|
|
173
177
|
/**
|
|
174
178
|
* A flexible combobox component with support for single/multiple selection, search, and extensive customization.
|
|
@@ -223,5 +227,5 @@ type ComboboxProps = Readonly<{
|
|
|
223
227
|
* />
|
|
224
228
|
* ```
|
|
225
229
|
*/
|
|
226
|
-
declare function Combobox({ searchable, multiple, icon, value: controlledValue, onValueChange, labels, options, classNames, selectedFeedback, alwaysShowPlaceholder, valuePosition, renders, ref, }: ComboboxProps): import("react/jsx-runtime").JSX.Element;
|
|
230
|
+
declare function Combobox({ searchable, multiple, icon, value: controlledValue, onValueChange, labels, options, classNames, selectedFeedback, alwaysShowPlaceholder, valuePosition, renders, ref, "aria-invalid": ariaInvalid, disabled, }: ComboboxProps): import("react/jsx-runtime").JSX.Element;
|
|
227
231
|
export { Combobox };
|
|
@@ -35,6 +35,10 @@ export type DatePickerSelectorProps = Readonly<{
|
|
|
35
35
|
combobox?: Omit<ComponentProps<typeof Combobox>, "options">;
|
|
36
36
|
/** Props to pass to the internal Calendar component (excluding 'mode', 'selected', 'onSelected') */
|
|
37
37
|
calendar?: Omit<ComponentProps<typeof Calendar>, "mode" | "selected" | "onSelected">;
|
|
38
|
+
/** Indicates if the date picker has invalid input */
|
|
39
|
+
"aria-invalid"?: "true" | "false" | boolean;
|
|
40
|
+
/** Standard disabled prop */
|
|
41
|
+
disabled?: boolean;
|
|
38
42
|
}>;
|
|
39
43
|
/**
|
|
40
44
|
* A date range picker component that combines a combobox with preset options and a custom calendar picker.
|
|
@@ -88,4 +92,4 @@ export type DatePickerSelectorProps = Readonly<{
|
|
|
88
92
|
* />
|
|
89
93
|
* ```
|
|
90
94
|
*/
|
|
91
|
-
export declare function DatePickerSelector({ dateRange, onDateRangeChange, labels, combobox, calendar }: DatePickerSelectorProps): import("react/jsx-runtime").JSX.Element;
|
|
95
|
+
export declare function DatePickerSelector({ dateRange, onDateRangeChange, labels, combobox, calendar, "aria-invalid": ariaInvalid, disabled, }: DatePickerSelectorProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -17,6 +17,9 @@ export type FileUploadProps = ComponentProps<"div"> & Readonly<{
|
|
|
17
17
|
multiple?: boolean;
|
|
18
18
|
filesPosition?: "above" | "below";
|
|
19
19
|
invalid?: boolean;
|
|
20
|
+
disabled?: boolean;
|
|
21
|
+
"aria-invalid"?: boolean;
|
|
20
22
|
labels?: FileUploadLabels;
|
|
23
|
+
input?: ComponentProps<"input">;
|
|
21
24
|
}>;
|
|
22
|
-
export declare function FileUpload({ className, selectedFile, selectedFiles, onFileSelect, onFilesSelect, onInvalidFile, acceptedExtensions, maxSizeInMB, maxFiles, multiple, filesPosition, invalid, labels, ...props }: FileUploadProps): import("react/jsx-runtime").JSX.Element;
|
|
25
|
+
export declare function FileUpload({ className, selectedFile, selectedFiles, onFileSelect, onFilesSelect, onInvalidFile, acceptedExtensions, maxSizeInMB, maxFiles, multiple, filesPosition, invalid, disabled, "aria-invalid": ariaInvalid, labels, input, ...props }: FileUploadProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -6,5 +6,5 @@ type SliderProps = React.ComponentProps<typeof SliderPrimitive.Root> & {
|
|
|
6
6
|
theme?: Theme;
|
|
7
7
|
colorSlide?: SliderColorProp;
|
|
8
8
|
};
|
|
9
|
-
declare function Slider({ className, defaultValue, value, min, max, theme, colorSlide: color, ...props }: SliderProps): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
declare function Slider({ className, defaultValue, value, min, max, theme, colorSlide: color, disabled, ...props }: SliderProps): import("react/jsx-runtime").JSX.Element;
|
|
10
10
|
export { Slider };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import * as SwitchPrimitive from "@radix-ui/react-switch";
|
|
2
2
|
import * as React from "react";
|
|
3
|
-
declare function Switch({ className, ...props }: React.ComponentProps<typeof SwitchPrimitive.Root>): import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
declare function Switch({ className, disabled, ...props }: React.ComponentProps<typeof SwitchPrimitive.Root>): import("react/jsx-runtime").JSX.Element;
|
|
4
4
|
export { Switch };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./jsx-runtime-BB_1_6y_.cjs"),j=require("./button-DVrteFz9.cjs"),m=require("./calendar-CpUN6BGK.cjs"),q=require("./combobox-hTCtPMUL.cjs"),p=require("./popover-cGp_rNLg.cjs"),o=require("react");function L(c,n,u){return m.addDays(c,-n,u)}function P({dateRange:c,onDateRangeChange:n,labels:u,combobox:R,calendar:v,"aria-invalid":h,disabled:D}){const x=o.useRef(null),d=o.useRef(void 0),[i,s]=o.useState(void 0),[g,r]=o.useState(!1),[l,C]=o.useState(c),t={...{last7Days:"Last 7 days",last30Days:"Last 30 days",last90Days:"Last 90 days",custom:"Custom",placeholder:"Date",cancel:"Cancel",apply:"Apply"},...u},E=e=>{const f=m.startOfDay(new Date),b={"7_days":7,"30_days":30,"90_days":90}[e];return b?{from:L(f,b),to:f}:{from:void 0,to:void 0}},y=e=>{s(d.current),r(!1)},S=e=>{if(e==="custom"){d.current=i,s(e),r(!0);return}s(e),n(E(e))},k=()=>{if(l?.from&&l?.to){n(l),s("custom"),r(!1);return}s(d.current),r(!1)};return a.jsxRuntimeExports.jsxs(a.jsxRuntimeExports.Fragment,{children:[a.jsxRuntimeExports.jsx(q.Combobox,{alwaysShowPlaceholder:!0,selectedFeedback:"check",icon:"calendar_today",options:[{label:t.last7Days,value:"7_days"},{label:t.last30Days,value:"30_days"},{label:t.last90Days,value:"90_days"},{label:t.custom,value:"custom"}],labels:{placeholder:t.placeholder},value:i,onValueChange:S,"aria-invalid":h,disabled:D,ref:e=>{x.current=e},...R}),a.jsxRuntimeExports.jsxs(p.Popover,{open:g,onOpenChange:e=>{!e&&i==="custom"&&y()},children:[a.jsxRuntimeExports.jsx(p.PopoverAnchor,{virtualRef:x}),a.jsxRuntimeExports.jsxs(p.PopoverContent,{align:"start",children:[a.jsxRuntimeExports.jsx(m.Calendar,{required:!0,mode:"range",selected:l,onSelect:C,captionLayout:"dropdown",classNames:{root:"adm:p-0!"},...v}),a.jsxRuntimeExports.jsxs("div",{className:"adm:mt-2 adm:flex adm:justify-end adm:gap-2",children:[a.jsxRuntimeExports.jsx(j.Button,{variant:"link",onClick:()=>y(),children:t.cancel}),a.jsxRuntimeExports.jsx(j.Button,{variant:"link",onClick:k,children:t.apply})]})]})]})]})}exports.DatePickerSelector=P;
|
|
@@ -1,14 +1,22 @@
|
|
|
1
1
|
import { j as e } from "./jsx-runtime-BzflLqGi.js";
|
|
2
2
|
import { B as h } from "./button-B0lWuG-D.js";
|
|
3
|
-
import { b as
|
|
4
|
-
import { C as
|
|
5
|
-
import { P as
|
|
6
|
-
import { useRef as
|
|
7
|
-
function
|
|
8
|
-
return
|
|
3
|
+
import { b as _, C as P, s as O } from "./calendar-CfqtuOWv.js";
|
|
4
|
+
import { C as S } from "./combobox-DGuQtXjP.js";
|
|
5
|
+
import { P as A, c as B, b as F } from "./popover-DcQ18EVl.js";
|
|
6
|
+
import { useRef as v, useState as u } from "react";
|
|
7
|
+
function M(n, o, c) {
|
|
8
|
+
return _(n, -o, c);
|
|
9
9
|
}
|
|
10
|
-
function
|
|
11
|
-
|
|
10
|
+
function H({
|
|
11
|
+
dateRange: n,
|
|
12
|
+
onDateRangeChange: o,
|
|
13
|
+
labels: c,
|
|
14
|
+
combobox: b,
|
|
15
|
+
calendar: x,
|
|
16
|
+
"aria-invalid": C,
|
|
17
|
+
disabled: D
|
|
18
|
+
}) {
|
|
19
|
+
const m = v(null), d = v(void 0), [i, t] = u(void 0), [j, l] = u(!1), [r, g] = u(n), s = { ...{
|
|
12
20
|
last7Days: "Last 7 days",
|
|
13
21
|
last30Days: "Last 30 days",
|
|
14
22
|
last90Days: "Last 90 days",
|
|
@@ -16,22 +24,22 @@ function z({ dateRange: n, onDateRangeChange: o, labels: c, combobox: v, calenda
|
|
|
16
24
|
placeholder: "Date",
|
|
17
25
|
cancel: "Cancel",
|
|
18
26
|
apply: "Apply"
|
|
19
|
-
}, ...c },
|
|
20
|
-
const y =
|
|
27
|
+
}, ...c }, R = (a) => {
|
|
28
|
+
const y = O(/* @__PURE__ */ new Date()), f = {
|
|
21
29
|
"7_days": 7,
|
|
22
30
|
"30_days": 30,
|
|
23
31
|
"90_days": 90
|
|
24
32
|
}[a];
|
|
25
|
-
return f ? { from:
|
|
33
|
+
return f ? { from: M(y, f), to: y } : { from: void 0, to: void 0 };
|
|
26
34
|
}, p = (a) => {
|
|
27
35
|
t(d.current), l(!1);
|
|
28
|
-
},
|
|
36
|
+
}, k = (a) => {
|
|
29
37
|
if (a === "custom") {
|
|
30
|
-
d.current =
|
|
38
|
+
d.current = i, t(a), l(!0);
|
|
31
39
|
return;
|
|
32
40
|
}
|
|
33
|
-
t(a), o(
|
|
34
|
-
},
|
|
41
|
+
t(a), o(R(a));
|
|
42
|
+
}, L = () => {
|
|
35
43
|
if (r?.from && r?.to) {
|
|
36
44
|
o(r), t("custom"), l(!1);
|
|
37
45
|
return;
|
|
@@ -40,7 +48,7 @@ function z({ dateRange: n, onDateRangeChange: o, labels: c, combobox: v, calenda
|
|
|
40
48
|
};
|
|
41
49
|
return /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
|
|
42
50
|
/* @__PURE__ */ e.jsx(
|
|
43
|
-
|
|
51
|
+
S,
|
|
44
52
|
{
|
|
45
53
|
alwaysShowPlaceholder: !0,
|
|
46
54
|
selectedFeedback: "check",
|
|
@@ -52,31 +60,33 @@ function z({ dateRange: n, onDateRangeChange: o, labels: c, combobox: v, calenda
|
|
|
52
60
|
{ label: s.custom, value: "custom" }
|
|
53
61
|
],
|
|
54
62
|
labels: { placeholder: s.placeholder },
|
|
55
|
-
value:
|
|
56
|
-
onValueChange:
|
|
63
|
+
value: i,
|
|
64
|
+
onValueChange: k,
|
|
65
|
+
"aria-invalid": C,
|
|
66
|
+
disabled: D,
|
|
57
67
|
ref: (a) => {
|
|
58
68
|
m.current = a;
|
|
59
69
|
},
|
|
60
|
-
...
|
|
70
|
+
...b
|
|
61
71
|
}
|
|
62
72
|
),
|
|
63
73
|
/* @__PURE__ */ e.jsxs(
|
|
64
|
-
|
|
74
|
+
A,
|
|
65
75
|
{
|
|
66
|
-
open:
|
|
76
|
+
open: j,
|
|
67
77
|
onOpenChange: (a) => {
|
|
68
|
-
!a &&
|
|
78
|
+
!a && i === "custom" && p();
|
|
69
79
|
},
|
|
70
80
|
children: [
|
|
71
|
-
/* @__PURE__ */ e.jsx(
|
|
72
|
-
/* @__PURE__ */ e.jsxs(
|
|
81
|
+
/* @__PURE__ */ e.jsx(B, { virtualRef: m }),
|
|
82
|
+
/* @__PURE__ */ e.jsxs(F, { align: "start", children: [
|
|
73
83
|
/* @__PURE__ */ e.jsx(
|
|
74
|
-
|
|
84
|
+
P,
|
|
75
85
|
{
|
|
76
86
|
required: !0,
|
|
77
87
|
mode: "range",
|
|
78
88
|
selected: r,
|
|
79
|
-
onSelect:
|
|
89
|
+
onSelect: g,
|
|
80
90
|
captionLayout: "dropdown",
|
|
81
91
|
classNames: { root: "adm:p-0!" },
|
|
82
92
|
...x
|
|
@@ -84,7 +94,7 @@ function z({ dateRange: n, onDateRangeChange: o, labels: c, combobox: v, calenda
|
|
|
84
94
|
),
|
|
85
95
|
/* @__PURE__ */ e.jsxs("div", { className: "adm:mt-2 adm:flex adm:justify-end adm:gap-2", children: [
|
|
86
96
|
/* @__PURE__ */ e.jsx(h, { variant: "link", onClick: () => p(), children: s.cancel }),
|
|
87
|
-
/* @__PURE__ */ e.jsx(h, { variant: "link", onClick:
|
|
97
|
+
/* @__PURE__ */ e.jsx(h, { variant: "link", onClick: L, children: s.apply })
|
|
88
98
|
] })
|
|
89
99
|
] })
|
|
90
100
|
]
|
|
@@ -93,5 +103,5 @@ function z({ dateRange: n, onDateRangeChange: o, labels: c, combobox: v, calenda
|
|
|
93
103
|
] });
|
|
94
104
|
}
|
|
95
105
|
export {
|
|
96
|
-
|
|
106
|
+
H as DatePickerSelector
|
|
97
107
|
};
|
package/dist/field.cjs
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
adm:group/field-group adm:@container/field-group adm:flex adm:w-full
|
|
6
6
|
adm:flex-col adm:gap-4
|
|
7
7
|
adm:data-[slot=checkbox-group]:gap-3
|
|
8
|
-
adm
|
|
8
|
+
adm:*:data-[slot=field-group]:gap-4
|
|
9
9
|
`,e),...a})}const b=c.cva(`
|
|
10
10
|
adm:group/field adm:flex adm:w-full adm:gap-2
|
|
11
11
|
adm:data-[invalid=true]:text-destructive
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
`,e),...a})}function E({className:e,...a}){return t.jsxRuntimeExports.jsx("p",{"data-slot":"field-description",className:d.cn(`
|
|
50
50
|
adm:text-sm adm:leading-normal adm:font-normal
|
|
51
51
|
adm:text-muted-foreground
|
|
52
|
-
adm:group-has-
|
|
52
|
+
adm:group-has-data-[orientation=horizontal]/field:text-balance
|
|
53
53
|
`,`
|
|
54
54
|
adm:last:mt-0
|
|
55
55
|
adm:nth-last-2:-mt-1
|
package/dist/field.js
CHANGED
|
@@ -52,7 +52,7 @@ function k({ className: e, ...a }) {
|
|
|
52
52
|
adm:group/field-group adm:@container/field-group adm:flex adm:w-full
|
|
53
53
|
adm:flex-col adm:gap-4
|
|
54
54
|
adm:data-[slot=checkbox-group]:gap-3
|
|
55
|
-
adm
|
|
55
|
+
adm:*:data-[slot=field-group]:gap-4
|
|
56
56
|
`,
|
|
57
57
|
e
|
|
58
58
|
),
|
|
@@ -192,7 +192,7 @@ function E({ className: e, ...a }) {
|
|
|
192
192
|
`
|
|
193
193
|
adm:text-sm adm:leading-normal adm:font-normal
|
|
194
194
|
adm:text-muted-foreground
|
|
195
|
-
adm:group-has-
|
|
195
|
+
adm:group-has-data-[orientation=horizontal]/field:text-balance
|
|
196
196
|
`,
|
|
197
197
|
`
|
|
198
198
|
adm:last:mt-0
|
package/dist/file-upload.cjs
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./jsx-runtime-BB_1_6y_.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./jsx-runtime-BB_1_6y_.cjs"),I=require("./button-DVrteFz9.cjs"),z=require("./icon-DPMQJBkA.cjs"),R=require("./typography-Bj8oEDuE.cjs"),g=require("./index-DoxiiusW.cjs"),N=require("react");function Q({isDragging:a,isMultiple:i,invalid:s,disabled:t,accept:m,acceptedExtensions:l,maxSizeInMB:c,maxFiles:f,labels:u,input:y,onDragOver:b,onDragLeave:$,onDrop:w,onFileChange:C}){const p=y?.id||`file-upload-${Math.random().toString(36).substring(2,11)}`;return e.jsxRuntimeExports.jsxs("div",{onDragOver:t?void 0:b,onDragLeave:t?void 0:$,onDrop:t?void 0:w,className:g.cn(`
|
|
2
2
|
adm:flex adm:flex-col adm:items-center adm:gap-6 adm:rounded-2xl
|
|
3
3
|
adm:border-2
|
|
4
|
-
`,"adm:border-dashed adm:bg-background adm:p-6 adm:transition-colors",{"adm:border-primary":
|
|
4
|
+
`,"adm:border-dashed adm:bg-background adm:p-6 adm:transition-colors",{"adm:border-primary":a&&!s&&!t,"adm:border-destructive":s&&!t,"adm:border-input":!a&&!s,"adm:cursor-not-allowed adm:opacity-50":t}),children:[e.jsxRuntimeExports.jsx("div",{className:g.cn("adm:flex adm:items-center adm:justify-center adm:rounded-xl adm:p-2.5",s&&!t?"adm:bg-destructive/10":"adm:bg-primary-50"),children:e.jsxRuntimeExports.jsx(z.Icon,{symbol:"text_snippet",className:s&&!t?"adm:text-destructive":"adm:text-primary"})}),e.jsxRuntimeExports.jsxs("div",{className:"adm:flex adm:flex-col adm:items-center adm:gap-2",children:[e.jsxRuntimeExports.jsx(R.Typography,{color:s&&!t?"destructive":void 0,children:u?.dragDrop||(i?"Drag and drop your files here or":"Drag and drop your file here or")}),e.jsxRuntimeExports.jsxs("label",{htmlFor:p,children:[e.jsxRuntimeExports.jsx("input",{...y,id:p,type:"file",accept:m,multiple:i,onChange:C,disabled:t,className:"adm:hidden"}),e.jsxRuntimeExports.jsx(I.Button,{asChild:!0,type:"button",variant:"link",className:g.cn("adm:cursor-pointer",t&&`
|
|
5
|
+
adm:pointer-events-none
|
|
6
|
+
`),disabled:t,children:e.jsxRuntimeExports.jsx("span",{children:u?.selectFile||(i?"Select files":"Select the file")})})]})]}),e.jsxRuntimeExports.jsx(R.Typography,{className:"adm:text-center",color:s&&!t?"destructive":"muted",children:u?.fileRequirements||(l&&l.length>0?`Allowed files: ${l.join(", ")}. Maximum size ${c} MB${i?`. Up to ${f} files`:""}.`:`Maximum size ${c} MB${i?`. Up to ${f} files`:""}.`)})]})}function W({file:a,invalid:i,disabled:s,onRemove:t}){return e.jsxRuntimeExports.jsxs("div",{className:g.cn("adm:flex adm:items-center adm:gap-4 adm:rounded-2xl adm:border adm:p-6",i&&!s?"adm:border-destructive adm:bg-destructive/5":"adm:border-input adm:bg-muted",s&&"adm:cursor-not-allowed adm:opacity-50"),children:[e.jsxRuntimeExports.jsx("div",{className:g.cn("adm:flex adm:items-center adm:justify-center adm:rounded-xl adm:p-2.5",i&&!s?"adm:bg-destructive/10":"adm:bg-primary-50"),children:e.jsxRuntimeExports.jsx(z.Icon,{symbol:"text_snippet",className:i&&!s?"adm:text-destructive":"adm:text-primary"})}),e.jsxRuntimeExports.jsxs("div",{className:`
|
|
5
7
|
adm:flex adm:min-w-0 adm:flex-1 adm:items-start adm:gap-3
|
|
6
|
-
`,children:[e.jsxRuntimeExports.jsx("div",{className:"adm:min-w-0 adm:flex-1",children:e.jsxRuntimeExports.jsx(
|
|
8
|
+
`,children:[e.jsxRuntimeExports.jsx("div",{className:"adm:min-w-0 adm:flex-1",children:e.jsxRuntimeExports.jsx(R.Typography,{className:"adm:truncate adm:font-semibold",children:a.name})}),e.jsxRuntimeExports.jsxs(R.Typography,{className:"adm:shrink-0",color:"muted",children:[(a.size/1024/1024).toFixed(1)," MB"]})]}),e.jsxRuntimeExports.jsx(I.Button,{variant:"destructive-medium",onClick:t,type:"button",disabled:s,children:e.jsxRuntimeExports.jsx(z.Icon,{symbol:"delete",className:"adm:text-destructive"})})]})}function k({files:a,isMultiple:i,invalid:s,disabled:t,labels:m,onRemoveFile:l,onClearAll:c}){return a.length===0?null:e.jsxRuntimeExports.jsxs("div",{className:"adm:flex adm:flex-col adm:gap-3",children:[i&&a.length>1&&e.jsxRuntimeExports.jsxs("div",{className:"adm:flex adm:items-center adm:justify-between",children:[e.jsxRuntimeExports.jsx(R.Typography,{className:"adm:text-sm adm:font-medium",color:s&&!t?"destructive":void 0,children:m?.filesSelected?.(a.length)||`${a.length} file${a.length!==1?"s":""} selected`}),e.jsxRuntimeExports.jsx(I.Button,{variant:"ghost",size:"sm",onClick:c,type:"button",disabled:t,children:"Clear all"})]}),a.map((f,u)=>e.jsxRuntimeExports.jsx(W,{file:f,invalid:s,disabled:t,onRemove:()=>l(u)},`${f.name}-${u}`))]})}function X({className:a,selectedFile:i,selectedFiles:s,onFileSelect:t,onFilesSelect:m,onInvalidFile:l,acceptedExtensions:c,maxSizeInMB:f=50,maxFiles:u=10,multiple:y=!1,filesPosition:b="below",invalid:$=!1,disabled:w=!1,"aria-invalid":C,labels:p,input:O,...B}){const[L,A]=N.useState(!1),[U,M]=N.useState(!1),v=N.useRef(null);N.useEffect(()=>{const r=()=>{if(v.current){const o=v.current.closest("fieldset");M(o?.disabled??!1)}};r();const n=new MutationObserver(r);if(v.current){const o=v.current.closest("fieldset");o&&n.observe(o,{attributes:!0,attributeFilter:["disabled"]})}return()=>n.disconnect()},[]);const V=c?.join(",")||"",_=f*1024*1024,d=y||s!==void 0||m!==void 0,j=d?s||[]:i?[i]:[],E=$||C,x=w||U,G=r=>{x||(r.preventDefault(),A(!0))},H=r=>{x||(r.preventDefault(),A(!1))},J=r=>{if(!x)if(r.preventDefault(),A(!1),d){const o=Array.from(r.dataTransfer.files).filter(D);if(o.length>0){const F=[...s||[],...o].slice(0,u);m&&m(F)}}else{const n=r.dataTransfer.files[0];n&&D(n)&&t&&t(n)}},K=r=>{if(!x){if(d){const o=(r.target.files?Array.from(r.target.files):[]).filter(D);if(o.length>0){const F=[...s||[],...o].slice(0,u);m&&m(F)}}else{const n=r.target.files?.[0];n&&D(n)&&t&&t(n)}r.target.value=""}},T=r=>{if(!x)if(d){const n=j.filter((o,h)=>h!==r);m&&m(n)}else t&&t(null)},D=r=>{const n=r.name.substring(r.name.lastIndexOf(".")),o=!c||c.length===0||c.includes(n.toLowerCase()),h=r.size<=_;return!o&&l?l(r,"extension"):!h&&l&&l(r,"size"),o&&h},q=()=>{x||(d?m&&m([]):t&&t(null))};return e.jsxRuntimeExports.jsxs("div",{ref:v,className:g.cn("adm:flex adm:flex-col adm:gap-4",a),...B,children:[d&&b==="above"&&e.jsxRuntimeExports.jsx(k,{files:j,isMultiple:d,invalid:E,disabled:x,labels:p,onRemoveFile:T,onClearAll:q}),(d||j.length===0)&&e.jsxRuntimeExports.jsx(Q,{isDragging:L,isMultiple:d,invalid:E,disabled:x,accept:V,acceptedExtensions:c,maxSizeInMB:f,maxFiles:u,labels:p,input:O,onDragOver:G,onDragLeave:H,onDrop:J,onFileChange:K}),!d&&j.length>0&&e.jsxRuntimeExports.jsx(k,{files:j,isMultiple:d,invalid:E,disabled:x,labels:p,onRemoveFile:T,onClearAll:q}),d&&b==="below"&&e.jsxRuntimeExports.jsx(k,{files:j,isMultiple:d,invalid:E,disabled:x,labels:p,onRemoveFile:T,onClearAll:q})]})}exports.FileUpload=X;
|