@adamosuiteservices/ui 2.14.1 → 2.15.0
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 +7 -1
- package/dist/components/ui/date-picker-selector/date-picker-selector.d.ts +75 -1
- package/dist/components/ui/file-upload/file-upload.d.ts +3 -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 +81 -78
- package/dist/field.cjs +2 -2
- package/dist/field.js +2 -2
- package/dist/file-upload.cjs +5 -3
- package/dist/file-upload.js +178 -149
- 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 +100 -0
- package/docs/components/ui/date-picker-selector.md +147 -28
- package/docs/components/ui/file-upload.md +241 -94
- 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-B8HMlZy6.js +0 -601
- package/dist/combobox-Btj-hiBy.cjs +0 -40
|
@@ -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
|
@@ -167,6 +167,12 @@ type ComboboxProps = Readonly<{
|
|
|
167
167
|
valuePosition?: "left" | "right";
|
|
168
168
|
/** Render prop functions for customizing component rendering */
|
|
169
169
|
renders?: ComboboxRenderProps;
|
|
170
|
+
/** Ref to be forwarded to the trigger button element */
|
|
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;
|
|
170
176
|
}>;
|
|
171
177
|
/**
|
|
172
178
|
* A flexible combobox component with support for single/multiple selection, search, and extensive customization.
|
|
@@ -221,5 +227,5 @@ type ComboboxProps = Readonly<{
|
|
|
221
227
|
* />
|
|
222
228
|
* ```
|
|
223
229
|
*/
|
|
224
|
-
declare function Combobox({ searchable, multiple, icon, value: controlledValue, onValueChange, labels, options, classNames, selectedFeedback, alwaysShowPlaceholder, valuePosition, renders, }: 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;
|
|
225
231
|
export { Combobox };
|
|
@@ -2,20 +2,94 @@ import { Calendar } from '../calendar';
|
|
|
2
2
|
import { Combobox } from '../combobox';
|
|
3
3
|
import { ComponentProps } from 'react';
|
|
4
4
|
import { DateRange } from 'react-day-picker';
|
|
5
|
+
/**
|
|
6
|
+
* Labels for customizing text displayed in the DatePickerSelector component.
|
|
7
|
+
*/
|
|
5
8
|
export type DatePickerSelectorLabels = {
|
|
9
|
+
/** Label for "Last 30 days" option */
|
|
6
10
|
last30Days?: string;
|
|
11
|
+
/** Label for "Last 7 days" option */
|
|
7
12
|
last7Days?: string;
|
|
13
|
+
/** Label for "Last 90 days" option */
|
|
8
14
|
last90Days?: string;
|
|
15
|
+
/** Label for "Custom" option that opens the calendar */
|
|
9
16
|
custom?: string;
|
|
17
|
+
/** Placeholder text shown in the combobox */
|
|
10
18
|
placeholder?: string;
|
|
19
|
+
/** Cancel button text in the calendar popover */
|
|
11
20
|
cancel?: string;
|
|
21
|
+
/** Apply button text in the calendar popover */
|
|
12
22
|
apply?: string;
|
|
13
23
|
};
|
|
24
|
+
/**
|
|
25
|
+
* Props for the DatePickerSelector component.
|
|
26
|
+
*/
|
|
14
27
|
export type DatePickerSelectorProps = Readonly<{
|
|
28
|
+
/** Current date range selection */
|
|
15
29
|
dateRange: DateRange;
|
|
30
|
+
/** Callback fired when the date range changes */
|
|
16
31
|
onDateRangeChange: (dateRange: DateRange) => void;
|
|
32
|
+
/** Custom labels for all text in the component */
|
|
17
33
|
labels?: DatePickerSelectorLabels;
|
|
34
|
+
/** Props to pass to the internal Combobox component (excluding 'options') */
|
|
18
35
|
combobox?: Omit<ComponentProps<typeof Combobox>, "options">;
|
|
36
|
+
/** Props to pass to the internal Calendar component (excluding 'mode', 'selected', 'onSelected') */
|
|
19
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;
|
|
20
42
|
}>;
|
|
21
|
-
|
|
43
|
+
/**
|
|
44
|
+
* A date range picker component that combines a combobox with preset options and a custom calendar picker.
|
|
45
|
+
*
|
|
46
|
+
* @remarks
|
|
47
|
+
* This component manages two independent Popovers:
|
|
48
|
+
* 1. The Combobox's internal Popover - Shows preset date range options (7/30/90 days, Custom)
|
|
49
|
+
* 2. The Calendar Popover - Shows when "Custom" is selected, allows picking a custom date range
|
|
50
|
+
*
|
|
51
|
+
* **Cancellation behavior:**
|
|
52
|
+
* - Selecting "Custom" opens the calendar and saves the previous selection
|
|
53
|
+
* - Cancel button, clicking outside, or applying without a complete range restores the previous selection
|
|
54
|
+
* - Only a successfully applied custom range will keep "Custom" as the selected option
|
|
55
|
+
* - This ensures users never end up with "Custom" selected without a valid date range
|
|
56
|
+
*
|
|
57
|
+
* @architecture
|
|
58
|
+
* The component uses Radix UI's `virtualRef` pattern to position the Calendar Popover relative to the Combobox:
|
|
59
|
+
*
|
|
60
|
+
* **How it works:**
|
|
61
|
+
* 1. A ref is passed to the Combobox via the `ref` prop
|
|
62
|
+
* 2. The Combobox forwards this ref to its trigger button element
|
|
63
|
+
* 3. The Calendar Popover uses `PopoverAnchor` with `virtualRef` pointing to this ref
|
|
64
|
+
* 4. Radix positions the calendar by calling `getBoundingClientRect()` on the referenced element
|
|
65
|
+
*
|
|
66
|
+
* **Why this approach:**
|
|
67
|
+
* - No wrapper elements needed - cleaner DOM structure
|
|
68
|
+
* - Direct reference to the actual trigger button for accurate positioning
|
|
69
|
+
* - The Combobox can be both a PopoverTrigger (for its options) and a positioning anchor (for the calendar)
|
|
70
|
+
* - Type-safe with the `Measurable` type (any element with `getBoundingClientRect()`)
|
|
71
|
+
*
|
|
72
|
+
* **Key implementation details:**
|
|
73
|
+
* - `comboboxRef` is typed as `RefObject<Measurable | null>` for Radix compatibility
|
|
74
|
+
* - Callback ref `(node) => { comboboxRef.current = node }` captures the button element
|
|
75
|
+
* - Type assertion `as React.RefObject<Measurable>` satisfies Radix's non-nullable requirement
|
|
76
|
+
* - This ensures the Calendar always positions correctly relative to the Combobox
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* ```tsx
|
|
80
|
+
* const [dateRange, setDateRange] = useState<DateRange>({
|
|
81
|
+
* from: subDays(new Date(), 30),
|
|
82
|
+
* to: new Date()
|
|
83
|
+
* });
|
|
84
|
+
*
|
|
85
|
+
* <DatePickerSelector
|
|
86
|
+
* dateRange={dateRange}
|
|
87
|
+
* onDateRangeChange={setDateRange}
|
|
88
|
+
* labels={{
|
|
89
|
+
* placeholder: "Select date range",
|
|
90
|
+
* custom: "Custom range"
|
|
91
|
+
* }}
|
|
92
|
+
* />
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
95
|
+
export declare function DatePickerSelector({ dateRange, onDateRangeChange, labels, combobox, calendar, "aria-invalid": ariaInvalid, disabled, }: DatePickerSelectorProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -17,6 +17,8 @@ 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;
|
|
21
23
|
}>;
|
|
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;
|
|
24
|
+
export declare function FileUpload({ className, selectedFile, selectedFiles, onFileSelect, onFilesSelect, onInvalidFile, acceptedExtensions, maxSizeInMB, maxFiles, multiple, filesPosition, invalid, disabled, "aria-invalid": ariaInvalid, labels, ...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,38 +1,54 @@
|
|
|
1
|
-
import { j as
|
|
2
|
-
import { B as
|
|
3
|
-
import { b, C as
|
|
4
|
-
import { C } from "./combobox-
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
return b(l, -o, n);
|
|
1
|
+
import { j as e } from "./jsx-runtime-BzflLqGi.js";
|
|
2
|
+
import { B as h } from "./button-B0lWuG-D.js";
|
|
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);
|
|
10
9
|
}
|
|
11
|
-
function
|
|
12
|
-
|
|
13
|
-
|
|
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 = { ...{
|
|
14
20
|
last7Days: "Last 7 days",
|
|
21
|
+
last30Days: "Last 30 days",
|
|
15
22
|
last90Days: "Last 90 days",
|
|
16
23
|
custom: "Custom",
|
|
17
24
|
placeholder: "Date",
|
|
18
25
|
cancel: "Cancel",
|
|
19
26
|
apply: "Apply"
|
|
20
|
-
}, ...
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
}, ...c }, R = (a) => {
|
|
28
|
+
const y = O(/* @__PURE__ */ new Date()), f = {
|
|
29
|
+
"7_days": 7,
|
|
30
|
+
"30_days": 30,
|
|
31
|
+
"90_days": 90
|
|
32
|
+
}[a];
|
|
33
|
+
return f ? { from: M(y, f), to: y } : { from: void 0, to: void 0 };
|
|
34
|
+
}, p = (a) => {
|
|
35
|
+
t(d.current), l(!1);
|
|
36
|
+
}, k = (a) => {
|
|
37
|
+
if (a === "custom") {
|
|
38
|
+
d.current = i, t(a), l(!0);
|
|
39
|
+
return;
|
|
31
40
|
}
|
|
41
|
+
t(a), o(R(a));
|
|
42
|
+
}, L = () => {
|
|
43
|
+
if (r?.from && r?.to) {
|
|
44
|
+
o(r), t("custom"), l(!1);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
t(d.current), l(!1);
|
|
32
48
|
};
|
|
33
|
-
return /* @__PURE__ */
|
|
34
|
-
/* @__PURE__ */
|
|
35
|
-
|
|
49
|
+
return /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
|
|
50
|
+
/* @__PURE__ */ e.jsx(
|
|
51
|
+
S,
|
|
36
52
|
{
|
|
37
53
|
alwaysShowPlaceholder: !0,
|
|
38
54
|
selectedFeedback: "check",
|
|
@@ -43,62 +59,49 @@ function B({ dateRange: l, onDateRangeChange: o, labels: n, combobox: p, calenda
|
|
|
43
59
|
{ label: s.last90Days, value: "90_days" },
|
|
44
60
|
{ label: s.custom, value: "custom" }
|
|
45
61
|
],
|
|
46
|
-
value: f,
|
|
47
|
-
onValueChange: (t) => {
|
|
48
|
-
if (typeof t == "string")
|
|
49
|
-
if (t === "custom")
|
|
50
|
-
r(!0);
|
|
51
|
-
else {
|
|
52
|
-
const e = D(t);
|
|
53
|
-
o(e), m(void 0);
|
|
54
|
-
}
|
|
55
|
-
h(t);
|
|
56
|
-
},
|
|
57
62
|
labels: { placeholder: s.placeholder },
|
|
58
|
-
|
|
63
|
+
value: i,
|
|
64
|
+
onValueChange: k,
|
|
65
|
+
"aria-invalid": C,
|
|
66
|
+
disabled: D,
|
|
67
|
+
ref: (a) => {
|
|
68
|
+
m.current = a;
|
|
69
|
+
},
|
|
70
|
+
...b
|
|
59
71
|
}
|
|
60
72
|
),
|
|
61
|
-
/* @__PURE__ */
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
children: s.cancel
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
onClick: () => {
|
|
92
|
-
c && o(c), r(!1);
|
|
93
|
-
},
|
|
94
|
-
children: s.apply
|
|
95
|
-
}
|
|
96
|
-
)
|
|
97
|
-
] })
|
|
98
|
-
] })
|
|
99
|
-
] })
|
|
73
|
+
/* @__PURE__ */ e.jsxs(
|
|
74
|
+
A,
|
|
75
|
+
{
|
|
76
|
+
open: j,
|
|
77
|
+
onOpenChange: (a) => {
|
|
78
|
+
!a && i === "custom" && p();
|
|
79
|
+
},
|
|
80
|
+
children: [
|
|
81
|
+
/* @__PURE__ */ e.jsx(B, { virtualRef: m }),
|
|
82
|
+
/* @__PURE__ */ e.jsxs(F, { align: "start", children: [
|
|
83
|
+
/* @__PURE__ */ e.jsx(
|
|
84
|
+
P,
|
|
85
|
+
{
|
|
86
|
+
required: !0,
|
|
87
|
+
mode: "range",
|
|
88
|
+
selected: r,
|
|
89
|
+
onSelect: g,
|
|
90
|
+
captionLayout: "dropdown",
|
|
91
|
+
classNames: { root: "adm:p-0!" },
|
|
92
|
+
...x
|
|
93
|
+
}
|
|
94
|
+
),
|
|
95
|
+
/* @__PURE__ */ e.jsxs("div", { className: "adm:mt-2 adm:flex adm:justify-end adm:gap-2", children: [
|
|
96
|
+
/* @__PURE__ */ e.jsx(h, { variant: "link", onClick: () => p(), children: s.cancel }),
|
|
97
|
+
/* @__PURE__ */ e.jsx(h, { variant: "link", onClick: L, children: s.apply })
|
|
98
|
+
] })
|
|
99
|
+
] })
|
|
100
|
+
]
|
|
101
|
+
}
|
|
102
|
+
)
|
|
100
103
|
] });
|
|
101
104
|
}
|
|
102
105
|
export {
|
|
103
|
-
|
|
106
|
+
H as DatePickerSelector
|
|
104
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"),z=require("./button-DVrteFz9.cjs"),k=require("./icon-DPMQJBkA.cjs"),v=require("./typography-Bj8oEDuE.cjs"),h=require("./index-DoxiiusW.cjs"),D=require("react");function K({isDragging:a,isMultiple:o,invalid:r,disabled:t,accept:d,acceptedExtensions:l,maxSizeInMB:c,maxFiles:u,labels:x,onDragOver:N,onDragLeave:R,onDrop:C,onFileChange:w}){return e.jsxRuntimeExports.jsxs("div",{onDragOver:t?void 0:N,onDragLeave:t?void 0:R,onDrop:t?void 0:C,className:h.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":r&&!
|
|
4
|
+
`,"adm:border-dashed adm:bg-background adm:p-6 adm:transition-colors",{"adm:border-primary":a&&!r&&!t,"adm:border-destructive":r&&!t,"adm:border-input":!a&&!r,"adm:cursor-not-allowed adm:opacity-50":t}),children:[e.jsxRuntimeExports.jsx("div",{className:h.cn("adm:flex adm:items-center adm:justify-center adm:rounded-xl adm:p-2.5",r&&!t?"adm:bg-destructive/10":"adm:bg-primary-50"),children:e.jsxRuntimeExports.jsx(k.Icon,{symbol:"text_snippet",className:r&&!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(v.Typography,{color:r&&!t?"destructive":void 0,children:x?.dragDrop||(o?"Drag and drop your files here or":"Drag and drop your file here or")}),e.jsxRuntimeExports.jsxs("label",{htmlFor:"file-upload",children:[e.jsxRuntimeExports.jsx("input",{id:"file-upload",type:"file",accept:d,multiple:o,onChange:w,disabled:t,className:"adm:hidden"}),e.jsxRuntimeExports.jsx(z.Button,{asChild:!0,type:"button",variant:"link",className:h.cn("adm:cursor-pointer",t&&`
|
|
5
|
+
adm:pointer-events-none
|
|
6
|
+
`),disabled:t,children:e.jsxRuntimeExports.jsx("span",{children:x?.selectFile||(o?"Select files":"Select the file")})})]})]}),e.jsxRuntimeExports.jsx(v.Typography,{className:"adm:text-center",color:r&&!t?"destructive":"muted",children:x?.fileRequirements||`Allowed files: ${l.join(", ")}. Maximum size ${c} MB${o?`. Up to ${u} files`:""}.`})]})}function P({file:a,invalid:o,onRemove:r}){return e.jsxRuntimeExports.jsxs("div",{className:h.cn("adm:flex adm:items-center adm:gap-4 adm:rounded-2xl adm:border adm:p-6",o?"adm:border-destructive adm:bg-destructive/5":"adm:border-input adm:bg-muted"),children:[e.jsxRuntimeExports.jsx("div",{className:h.cn("adm:flex adm:items-center adm:justify-center adm:rounded-xl adm:p-2.5",o?"adm:bg-destructive/10":"adm:bg-primary-50"),children:e.jsxRuntimeExports.jsx(k.Icon,{symbol:"text_snippet",className:o?"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(v.Typography,{className:"adm:truncate adm:font-semibold",children:a.name})}),e.jsxRuntimeExports.jsxs(v.Typography,{className:"adm:shrink-0",color:"muted",children:[(a.size/1024/1024).toFixed(1)," MB"]})]}),e.jsxRuntimeExports.jsx(z.Button,{variant:"destructive-medium",onClick:r,type:"button",children:e.jsxRuntimeExports.jsx(k.Icon,{symbol:"delete",className:"adm:text-destructive"})})]})}function q({files:a,isMultiple:o,invalid:r,labels:t,onRemoveFile:d,onClearAll:l}){return a.length===0?null:e.jsxRuntimeExports.jsxs("div",{className:"adm:flex adm:flex-col adm:gap-3",children:[o&&a.length>1&&e.jsxRuntimeExports.jsxs("div",{className:"adm:flex adm:items-center adm:justify-between",children:[e.jsxRuntimeExports.jsx(v.Typography,{className:"adm:text-sm adm:font-medium",color:r?"destructive":void 0,children:t?.filesSelected?.(a.length)||`${a.length} file${a.length!==1?"s":""} selected`}),e.jsxRuntimeExports.jsx(z.Button,{variant:"ghost",size:"sm",onClick:l,type:"button",children:"Clear all"})]}),a.map((c,u)=>e.jsxRuntimeExports.jsx(P,{file:c,invalid:r,onRemove:()=>d(u)},`${c.name}-${u}`))]})}function Q({className:a,selectedFile:o,selectedFiles:r,onFileSelect:t,onFilesSelect:d,onInvalidFile:l,acceptedExtensions:c=[".xls",".xlsx",".numbers"],maxSizeInMB:u=50,maxFiles:x=10,multiple:N=!1,filesPosition:R="below",invalid:C=!1,disabled:w=!1,"aria-invalid":I,labels:y,...O}){const[B,A]=D.useState(!1),[L,U]=D.useState(!1),g=D.useRef(null);D.useEffect(()=>{const s=()=>{if(g.current){const i=g.current.closest("fieldset");U(i?.disabled??!1)}};s();const n=new MutationObserver(s);if(g.current){const i=g.current.closest("fieldset");i&&n.observe(i,{attributes:!0,attributeFilter:["disabled"]})}return()=>n.disconnect()},[]);const V=c.join(","),_=u*1024*1024,m=N||r!==void 0||d!==void 0,f=m?r||[]:o?[o]:[],E=C||I,p=w||L,M=s=>{p||(s.preventDefault(),A(!0))},G=s=>{p||(s.preventDefault(),A(!1))},H=s=>{if(!p)if(s.preventDefault(),A(!1),m){const i=Array.from(s.dataTransfer.files).filter(b);if(i.length>0){const $=[...r||[],...i].slice(0,x);d&&d($)}}else{const n=s.dataTransfer.files[0];n&&b(n)&&t&&t(n)}},J=s=>{if(!p){if(m){const i=(s.target.files?Array.from(s.target.files):[]).filter(b);if(i.length>0){const $=[...r||[],...i].slice(0,x);d&&d($)}}else{const n=s.target.files?.[0];n&&b(n)&&t&&t(n)}s.target.value=""}},F=s=>{if(!p)if(m){const n=f.filter((i,j)=>j!==s);d&&d(n)}else t&&t(null)},b=s=>{const n=s.name.substring(s.name.lastIndexOf(".")),i=c.includes(n.toLowerCase()),j=s.size<=_;return!i&&l?l(s,"extension"):!j&&l&&l(s,"size"),i&&j},T=()=>{p||(m?d&&d([]):t&&t(null))};return e.jsxRuntimeExports.jsxs("div",{ref:g,className:h.cn("adm:flex adm:flex-col adm:gap-4",a),...O,children:[m&&R==="above"&&e.jsxRuntimeExports.jsx(q,{files:f,isMultiple:m,invalid:E,labels:y,onRemoveFile:F,onClearAll:T}),(m||f.length===0)&&e.jsxRuntimeExports.jsx(K,{isDragging:B,isMultiple:m,invalid:E,disabled:p,accept:V,acceptedExtensions:c,maxSizeInMB:u,maxFiles:x,labels:y,onDragOver:M,onDragLeave:G,onDrop:H,onFileChange:J}),!m&&f.length>0&&e.jsxRuntimeExports.jsx(q,{files:f,isMultiple:m,invalid:E,labels:y,onRemoveFile:F,onClearAll:T}),m&&R==="below"&&e.jsxRuntimeExports.jsx(q,{files:f,isMultiple:m,invalid:E,labels:y,onRemoveFile:F,onClearAll:T})]})}exports.FileUpload=Q;
|