@spark-ui/components 17.0.0 → 17.0.1-beta.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.
Files changed (68) hide show
  1. package/dist/{Button-FZceRWG2.js → Button-CXL2NOrq.js} +2 -2
  2. package/dist/{Button-FZceRWG2.js.map → Button-CXL2NOrq.js.map} +1 -1
  3. package/dist/{Button-1M9DcZl0.mjs → Button-CcIRizse.mjs} +2 -2
  4. package/dist/{Button-1M9DcZl0.mjs.map → Button-CcIRizse.mjs.map} +1 -1
  5. package/dist/{IconButton-DdB3Pq13.mjs → IconButton-CP4JbWsI.mjs} +14 -14
  6. package/dist/IconButton-CP4JbWsI.mjs.map +1 -0
  7. package/dist/IconButton-JFDGiOOn.js +2 -0
  8. package/dist/IconButton-JFDGiOOn.js.map +1 -0
  9. package/dist/avatar/index.js +1 -1
  10. package/dist/avatar/index.mjs +1 -1
  11. package/dist/button/index.js +1 -1
  12. package/dist/button/index.mjs +1 -1
  13. package/dist/carousel/index.js +1 -1
  14. package/dist/carousel/index.mjs +1 -1
  15. package/dist/chip/index.js +1 -1
  16. package/dist/chip/index.js.map +1 -1
  17. package/dist/chip/index.mjs +1 -1
  18. package/dist/chip/index.mjs.map +1 -1
  19. package/dist/combobox/index.js +1 -1
  20. package/dist/combobox/index.js.map +1 -1
  21. package/dist/combobox/index.mjs +39 -39
  22. package/dist/combobox/index.mjs.map +1 -1
  23. package/dist/dialog/index.js +1 -1
  24. package/dist/dialog/index.mjs +1 -1
  25. package/dist/drawer/index.js +1 -1
  26. package/dist/drawer/index.mjs +1 -1
  27. package/dist/dropdown/index.js +1 -1
  28. package/dist/dropdown/index.js.map +1 -1
  29. package/dist/dropdown/index.mjs +1 -1
  30. package/dist/dropdown/index.mjs.map +1 -1
  31. package/dist/file-upload/index.js +1 -1
  32. package/dist/file-upload/index.mjs +2 -2
  33. package/dist/icon-button/index.js +1 -1
  34. package/dist/icon-button/index.mjs +1 -1
  35. package/dist/input/index.js +1 -1
  36. package/dist/input/index.js.map +1 -1
  37. package/dist/input/index.mjs +6 -6
  38. package/dist/input/index.mjs.map +1 -1
  39. package/dist/pagination/index.js +1 -1
  40. package/dist/pagination/index.mjs +2 -2
  41. package/dist/popover/index.js +1 -1
  42. package/dist/popover/index.mjs +1 -1
  43. package/dist/scrolling-list/index.js +1 -1
  44. package/dist/scrolling-list/index.mjs +2 -2
  45. package/dist/select/index.js +1 -1
  46. package/dist/select/index.js.map +1 -1
  47. package/dist/select/index.mjs +1 -1
  48. package/dist/select/index.mjs.map +1 -1
  49. package/dist/snackbar/index.js +1 -1
  50. package/dist/snackbar/index.mjs +2 -2
  51. package/dist/stepper/index.js +1 -1
  52. package/dist/stepper/index.mjs +1 -1
  53. package/dist/tabs/index.js +1 -1
  54. package/dist/tabs/index.mjs +2 -2
  55. package/dist/tag/index.js +1 -1
  56. package/dist/tag/index.js.map +1 -1
  57. package/dist/tag/index.mjs +6 -6
  58. package/dist/tag/index.mjs.map +1 -1
  59. package/dist/textarea/index.js +1 -1
  60. package/dist/textarea/index.js.map +1 -1
  61. package/dist/textarea/index.mjs +10 -14
  62. package/dist/textarea/index.mjs.map +1 -1
  63. package/dist/toast/index.js +1 -1
  64. package/dist/toast/index.mjs +2 -2
  65. package/package.json +4 -4
  66. package/dist/IconButton-BR1bJSQA.js +0 -2
  67. package/dist/IconButton-BR1bJSQA.js.map +0 -1
  68. package/dist/IconButton-DdB3Pq13.mjs.map +0 -1
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),i=require("radix-ui"),c=require("react"),l=require("class-variance-authority"),V=require("@spark-ui/icons/Close"),E=require("../Icon-C-cNTnzd.js"),S=require("../IconButton-BR1bJSQA.js"),y=c.createContext(null),W=":popover",$=({children:e,intent:o})=>{const[r,t]=c.useState(null);return a.jsx(y.Provider,{value:{headerId:r,setHeaderId:t,intent:o},children:e})},u=()=>{const e=c.useContext(y);if(!e)throw Error("usePopover must be used within a Popover provider");return e},N=({children:e,intent:o="surface",modal:r=!1,...t})=>a.jsx($,{intent:o,children:a.jsx(i.Popover.Root,{"data-spark-component":"popover",modal:r,...t,children:e})});N.displayName="Popover";const v=({asChild:e=!1,children:o,ref:r,...t})=>a.jsx(i.Popover.Anchor,{"data-spark-component":"popover-anchor",ref:r,asChild:e,...t,children:o});v.displayName="Popover.Anchor";const f=({asChild:e=!1,width:o=16,height:r=8,className:t,ref:n,...s})=>{const{intent:p}=u(),d=l.cva("visible",{variants:{intent:{surface:"fill-surface",main:"fill-main-container",support:"fill-support-container",accent:"fill-accent-container",success:"fill-success-container",alert:"fill-alert-container",danger:"fill-error-container",info:"fill-info-container",neutral:"fill-neutral-container"}},defaultVariants:{intent:"surface"}});return a.jsx(i.Popover.Arrow,{"data-spark-component":"popover-arrow",ref:n,className:d({intent:p,className:t}),asChild:e,width:o,height:r,...s})};f.displayName="Popover.Arrow";const m=({"aria-label":e,className:o,ref:r,...t})=>a.jsx(i.Popover.Close,{"data-spark-component":"popover-close-button",ref:r,className:l.cx("right-lg top-md absolute",o),asChild:!0,...t,children:a.jsx(S.IconButton,{size:"sm",intent:"neutral",design:"ghost","aria-label":e,children:a.jsx(E.Icon,{children:a.jsx(V.Close,{})})})});m.displayName="Popover.CloseButton";const O=l.cva(["rounded-md","shadow-sm","focus-visible:outline-hidden focus-visible:u-outline","max-h-(--radix-popper-available-height) overflow-y-auto"],{variants:{intent:{surface:"bg-surface text-on-surface",main:"bg-main-container text-on-main-container",support:"bg-support-container text-on-support-container",accent:"bg-accent-container text-on-accent-container",success:"bg-success-container text-on-success-container",alert:"bg-alert-container text-on-alert-container",danger:"bg-error-container text-on-error-container",info:"bg-info-container text-on-info-container",neutral:"bg-neutral-container text-on-neutral-container"},matchTriggerWidth:{true:"w-(--radix-popper-anchor-width)"},enforceBoundaries:{true:["max-w-(--radix-popper-available-width)"]},inset:{true:"overflow-hidden",false:"p-lg"},elevation:{dropdown:"z-dropdown",popover:"z-popover"}},compoundVariants:[{inset:!1,class:"has-data-[spark-component=popover-close-button]:pr-3xl"},{enforceBoundaries:!1,matchTriggerWidth:!1,class:"max-w-[min(var(--spacing-sz-384),100vw)]"}],defaultVariants:{matchTriggerWidth:!1,enforceBoundaries:!1,inset:!1,intent:"surface",elevation:"popover"}}),P=({className:e,children:o,matchTriggerWidth:r=!1,align:t="center",arrowPadding:n=16,asChild:s=!1,avoidCollisions:p=!0,"aria-labelledby":d,collisionBoundary:b,collisionPadding:j=0,hideWhenDetached:C=!1,side:I="bottom",sideOffset:A=8,sticky:B="partial",inset:T=!1,elevation:k="popover",ref:q,...H})=>{const{headerId:z,intent:R}=u();return a.jsx(i.Popover.Content,{"aria-labelledby":z||d,className:O({enforceBoundaries:!!b,matchTriggerWidth:r,inset:T,elevation:k,intent:R,className:e}),"data-spark-component":"popover-content",ref:q,align:t,arrowPadding:n,asChild:s,avoidCollisions:p,collisionBoundary:b,collisionPadding:j,hideWhenDetached:C,side:I,sideOffset:A,sticky:B,...H,children:o})};P.displayName="Popover.Content";const x=({children:e,className:o,ref:r,...t})=>{const n=`${W}-header-${c.useId()}`,{setHeaderId:s}=u();return c.useLayoutEffect(()=>(s(n),()=>s(null)),[n,s]),a.jsx("header",{id:n,ref:r,className:l.cx("mb-md text-headline-2",o),...t,children:e})};x.displayName="Popover.Header";const g=({children:e,...o})=>a.jsx(i.Popover.Portal,{...o,children:e});g.displayName="Popover.Portal";const h=({asChild:e=!1,children:o,ref:r,...t})=>a.jsx(i.Popover.Trigger,{"data-spark-component":"popover-trigger",ref:r,asChild:e,...t,children:o});h.displayName="Popover.Trigger";const w=Object.assign(N,{Anchor:v,Arrow:f,CloseButton:m,Content:P,Header:x,Portal:g,Trigger:h});w.displayName="Popover";v.displayName="Popover.Anchor";f.displayName="Popover.Arrow";m.displayName="Popover.CloseButton";P.displayName="Popover.Content";x.displayName="Popover.Header";g.displayName="Popover.Portal";h.displayName="Popover.Trigger";exports.Popover=w;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),i=require("radix-ui"),c=require("react"),l=require("class-variance-authority"),V=require("@spark-ui/icons/Close"),E=require("../Icon-C-cNTnzd.js"),S=require("../IconButton-JFDGiOOn.js"),y=c.createContext(null),W=":popover",$=({children:e,intent:o})=>{const[r,t]=c.useState(null);return a.jsx(y.Provider,{value:{headerId:r,setHeaderId:t,intent:o},children:e})},u=()=>{const e=c.useContext(y);if(!e)throw Error("usePopover must be used within a Popover provider");return e},N=({children:e,intent:o="surface",modal:r=!1,...t})=>a.jsx($,{intent:o,children:a.jsx(i.Popover.Root,{"data-spark-component":"popover",modal:r,...t,children:e})});N.displayName="Popover";const v=({asChild:e=!1,children:o,ref:r,...t})=>a.jsx(i.Popover.Anchor,{"data-spark-component":"popover-anchor",ref:r,asChild:e,...t,children:o});v.displayName="Popover.Anchor";const f=({asChild:e=!1,width:o=16,height:r=8,className:t,ref:n,...s})=>{const{intent:p}=u(),d=l.cva("visible",{variants:{intent:{surface:"fill-surface",main:"fill-main-container",support:"fill-support-container",accent:"fill-accent-container",success:"fill-success-container",alert:"fill-alert-container",danger:"fill-error-container",info:"fill-info-container",neutral:"fill-neutral-container"}},defaultVariants:{intent:"surface"}});return a.jsx(i.Popover.Arrow,{"data-spark-component":"popover-arrow",ref:n,className:d({intent:p,className:t}),asChild:e,width:o,height:r,...s})};f.displayName="Popover.Arrow";const m=({"aria-label":e,className:o,ref:r,...t})=>a.jsx(i.Popover.Close,{"data-spark-component":"popover-close-button",ref:r,className:l.cx("right-lg top-md absolute",o),asChild:!0,...t,children:a.jsx(S.IconButton,{size:"sm",intent:"neutral",design:"ghost","aria-label":e,children:a.jsx(E.Icon,{children:a.jsx(V.Close,{})})})});m.displayName="Popover.CloseButton";const O=l.cva(["rounded-md","shadow-sm","focus-visible:outline-hidden focus-visible:u-outline","max-h-(--radix-popper-available-height) overflow-y-auto"],{variants:{intent:{surface:"bg-surface text-on-surface",main:"bg-main-container text-on-main-container",support:"bg-support-container text-on-support-container",accent:"bg-accent-container text-on-accent-container",success:"bg-success-container text-on-success-container",alert:"bg-alert-container text-on-alert-container",danger:"bg-error-container text-on-error-container",info:"bg-info-container text-on-info-container",neutral:"bg-neutral-container text-on-neutral-container"},matchTriggerWidth:{true:"w-(--radix-popper-anchor-width)"},enforceBoundaries:{true:["max-w-(--radix-popper-available-width)"]},inset:{true:"overflow-hidden",false:"p-lg"},elevation:{dropdown:"z-dropdown",popover:"z-popover"}},compoundVariants:[{inset:!1,class:"has-data-[spark-component=popover-close-button]:pr-3xl"},{enforceBoundaries:!1,matchTriggerWidth:!1,class:"max-w-[min(var(--spacing-sz-384),100vw)]"}],defaultVariants:{matchTriggerWidth:!1,enforceBoundaries:!1,inset:!1,intent:"surface",elevation:"popover"}}),P=({className:e,children:o,matchTriggerWidth:r=!1,align:t="center",arrowPadding:n=16,asChild:s=!1,avoidCollisions:p=!0,"aria-labelledby":d,collisionBoundary:b,collisionPadding:j=0,hideWhenDetached:C=!1,side:I="bottom",sideOffset:A=8,sticky:B="partial",inset:T=!1,elevation:k="popover",ref:q,...H})=>{const{headerId:z,intent:R}=u();return a.jsx(i.Popover.Content,{"aria-labelledby":z||d,className:O({enforceBoundaries:!!b,matchTriggerWidth:r,inset:T,elevation:k,intent:R,className:e}),"data-spark-component":"popover-content",ref:q,align:t,arrowPadding:n,asChild:s,avoidCollisions:p,collisionBoundary:b,collisionPadding:j,hideWhenDetached:C,side:I,sideOffset:A,sticky:B,...H,children:o})};P.displayName="Popover.Content";const x=({children:e,className:o,ref:r,...t})=>{const n=`${W}-header-${c.useId()}`,{setHeaderId:s}=u();return c.useLayoutEffect(()=>(s(n),()=>s(null)),[n,s]),a.jsx("header",{id:n,ref:r,className:l.cx("mb-md text-headline-2",o),...t,children:e})};x.displayName="Popover.Header";const g=({children:e,...o})=>a.jsx(i.Popover.Portal,{...o,children:e});g.displayName="Popover.Portal";const h=({asChild:e=!1,children:o,ref:r,...t})=>a.jsx(i.Popover.Trigger,{"data-spark-component":"popover-trigger",ref:r,asChild:e,...t,children:o});h.displayName="Popover.Trigger";const w=Object.assign(N,{Anchor:v,Arrow:f,CloseButton:m,Content:P,Header:x,Portal:g,Trigger:h});w.displayName="Popover";v.displayName="Popover.Anchor";f.displayName="Popover.Arrow";m.displayName="Popover.CloseButton";P.displayName="Popover.Content";x.displayName="Popover.Header";g.displayName="Popover.Portal";h.displayName="Popover.Trigger";exports.Popover=w;
2
2
  //# sourceMappingURL=index.js.map
@@ -4,7 +4,7 @@ import { createContext as V, useState as W, useContext as j, useId as R, useLayo
4
4
  import { cva as b, cx as x } from "class-variance-authority";
5
5
  import { Close as F } from "@spark-ui/icons/Close";
6
6
  import { I as L } from "../Icon-BO327oHU.mjs";
7
- import { I as O } from "../IconButton-DdB3Pq13.mjs";
7
+ import { I as O } from "../IconButton-CP4JbWsI.mjs";
8
8
  const y = V(null), S = ":popover", X = ({
9
9
  children: e,
10
10
  intent: o
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react/jsx-runtime"),T=require("@spark-ui/hooks/use-scroll-overflow"),p=require("class-variance-authority"),l=require("react"),O=require("react-snap-carousel"),V=require("../Slot-DQ8z2zsy.js"),z=require("@spark-ui/icons/ArrowVerticalRight"),w=require("../Icon-C-cNTnzd.js"),S=require("../IconButton-BR1bJSQA.js"),D=require("@spark-ui/icons/ArrowVerticalLeft"),$=require("../Button-FZceRWG2.js"),v=l.createContext(null),P=({snapType:s="none",snapStop:n="normal",scrollBehavior:e="smooth",loop:r=!1,gap:t=16,withFade:i=!1,scrollPadding:a=0,children:c,className:f,...d})=>{const o=l.useRef(null),g=l.useRef(null),h=O.useSnapCarousel(),{overflow:j,refresh:b}=T.useScrollOverflow(o,{precisionTreshold:1}),{activePageIndex:A,pages:q,refresh:m}=h,x=q[A],E=x?[x[0]+1,x[x.length-1]+1]:[0,0],y=l.useCallback(()=>{m&&o.current&&setTimeout(()=>{m()},0)},[m]);l.useEffect(()=>{y()},[c,y]),l.useLayoutEffect(()=>{o.current&&requestAnimationFrame(()=>{b()})},[c,b]);const F={...h,snapType:s,snapStop:n,skipKeyboardNavigation:()=>{g.current?.focus()},scrollBehavior:e,visibleItemsRange:E,loop:r,gap:t,withFade:i,scrollPadding:a,scrollAreaRef:o,overflow:j};return u.jsxs(v.Provider,{value:F,children:[u.jsx("div",{"data-spark-component":"scrolling-list",className:p.cx("gap-lg group/scrolling-list relative flex flex-col default:w-full",f),...d,children:c}),u.jsx("span",{ref:g,className:"size-0 overflow-hidden",tabIndex:-1})]})};P.displayName="ScrollingList";const L=({children:s,visibility:n="always",className:e,...r})=>u.jsx("div",{"data-spark-component":"scrolling-list-controls",className:p.cx("default:px-md pointer-events-none absolute inset-0 flex flex-row items-center justify-between overflow-hidden",e),style:{"--scrolling-list-controls-opacity":n==="hover"?"0":"1"},"data-orientation":"horizontal",...r,children:s});L.displayName="ScrollingList.Controls";function K(s,n){const[e,r]=l.useState(!1);return l.useEffect(()=>{const t=c=>{r(!0);const f=c.target,d=n.current;if(f&&d){const o=f.getBoundingClientRect(),g=d.getBoundingClientRect();o.left>=g.left&&o.right<=g.right&&o.top>=g.top&&o.bottom<=g.bottom||f.scrollIntoView({behavior:"smooth",inline:"center",block:"nearest"})}},i=c=>{s.current&&!s.current.contains(c.relatedTarget)&&r(!1)},a=s.current;return a&&(a.addEventListener("focusin",t),a.addEventListener("focusout",i)),()=>{a&&(a.removeEventListener("focusin",t),a.removeEventListener("focusout",i))}},[s,n]),e}const I=({asChild:s=!1,children:n,index:e=0,className:r="",...t})=>{const i=l.useContext(v),a=l.useRef(null),c=i.snapPointIndexes.has(e);K(a,i.scrollAreaRef);const f=s?V.Slot:"div";return u.jsx(f,{"data-spark-component":"scrolling-list-item",role:"listitem",ref:a,className:p.cx("default:w-auto default:shrink-0",{"snap-start":c,"snap-normal":c&&i.snapStop==="normal","snap-always":c&&i.snapStop==="always"},r),...t,children:n})};I.displayName="ScrollingList.Item";function H(...s){return n=>{s.forEach(e=>{typeof e=="function"?e(n):e&&typeof e=="object"&&"current"in e&&(e.current=n)})}}const N=({children:s,ref:n,className:e="",...r})=>{const t=l.useContext(v),i={mandatory:"x mandatory",proximity:"x proximity",none:"none"},a=o=>{!t.loop&&!t.hasPrevPage||(o.preventDefault(),t.goTo(t.hasPrevPage?t.activePageIndex-1:t.pages.length-1,{behavior:t.scrollBehavior}))},c=o=>{!t.loop&&!t.hasNextPage||(o.preventDefault(),t.goTo(t.hasNextPage?t.activePageIndex+1:0,{behavior:t.scrollBehavior}))},f=o=>{o.key==="ArrowLeft"&&a(o),o.key==="ArrowRight"&&c(o)},d={scrollSnapType:i[t.snapType],scrollPaddingInline:"var(--scrolling-list-px)","--scrolling-list-px":`${t.scrollPadding}px`,"--scrolling-list-gap":`${t.gap}px`,...t.withFade&&{maskImage:"linear-gradient(to right, rgba(0, 0, 0, 0), rgba(0, 0, 0, 1) 44px, rgba(0, 0, 0, 1) calc(100% - 44px), rgba(0, 0, 0, 0))",maskSize:`calc(100% + ${t.overflow.left?"0px":"44px"} + ${t.overflow.right?"0px":"44px"}) 100%`,maskPosition:`${t.overflow.left?"0px":"-44px"} 0`}};return u.jsx("div",{"data-spark-component":"scrolling-list-items",id:"scrolling-list-items",role:"list",className:p.cx("relative transition-all duration-300","u-no-scrollbar overflow-x-auto scroll-smooth","w-full gap-(--scrolling-list-gap) default:flex default:flex-row","focus-visible:u-outline",e),ref:H(t.scrollAreaRef,t.scrollRef,n),style:d,onKeyDown:f,...r,children:l.Children.map(s,(o,g)=>l.isValidElement(o)?l.cloneElement(o,{index:g}):o)})};N.displayName="ScrollingList.Items";const k=({"aria-label":s,...n})=>{const e=l.useContext(v),r=()=>{e.hasNextPage?e.next({behavior:e.scrollBehavior}):e.goTo(0,{behavior:e.scrollBehavior})},i=!(e.overflow.left||e.overflow.right)||!e.loop&&!e.overflow.right;return u.jsx(S.IconButton,{"data-spark-component":"scrolling-list-next-button",size:"sm",intent:"surface",design:"filled",className:p.cx("pointer-events-auto opacity-(--scrolling-list-controls-opacity) shadow-sm disabled:invisible","group-hover/scrolling-list:opacity-none focus-visible:opacity-none"),onClick:r,disabled:i,"aria-label":s,"aria-controls":"scrolling-list-items",...n,children:u.jsx(w.Icon,{children:u.jsx(z.ArrowVerticalRight,{})})})};k.displayName="ScrollingList.NextButton";const B=({"aria-label":s,...n})=>{const e=l.useContext(v),r=()=>{e.activePageIndex===0&&(e.scrollAreaRef.current?.scrollLeft||0)>0?e.goTo(0,{behavior:e.scrollBehavior}):e.hasPrevPage?e.prev({behavior:e.scrollBehavior}):e.goTo(e.pages.length-1,{behavior:e.scrollBehavior})},i=!(e.overflow.left||e.overflow.right)||!e.loop&&!e.overflow.left;return u.jsx(S.IconButton,{"data-spark-component":"scrolling-list-prev-button",size:"sm",intent:"surface",design:"filled",className:p.cx("pointer-events-auto opacity-(--scrolling-list-controls-opacity) shadow-sm disabled:invisible","group-hover/scrolling-list:opacity-none focus-visible:opacity-none"),onClick:r,disabled:i,"aria-label":s,"aria-controls":"scrolling-list-items",...n,children:u.jsx(w.Icon,{children:u.jsx(D.ArrowVerticalLeft,{})})})};B.displayName="ScrollingList.PrevButton";const C=({children:s,...n})=>{const e=l.useContext(v);return u.jsx($.Button,{type:"button",design:"tinted",intent:"surface",tabIndex:0,className:p.cx("z-raised absolute top-1/2 left-0 -translate-y-1/2","not-focus-visible:pointer-events-none not-focus-visible:size-0 not-focus-visible:opacity-0"),onClick:e.skipKeyboardNavigation,...n,children:s})};C.displayName="ScrollingList.SkipButton";const R=Object.assign(P,{Controls:L,NextButton:k,PrevButton:B,Item:I,Items:N,SkipButton:C});R.displayName="ScrollingList";exports.ScrollingList=R;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react/jsx-runtime"),T=require("@spark-ui/hooks/use-scroll-overflow"),p=require("class-variance-authority"),l=require("react"),O=require("react-snap-carousel"),V=require("../Slot-DQ8z2zsy.js"),z=require("@spark-ui/icons/ArrowVerticalRight"),w=require("../Icon-C-cNTnzd.js"),S=require("../IconButton-JFDGiOOn.js"),D=require("@spark-ui/icons/ArrowVerticalLeft"),$=require("../Button-CXL2NOrq.js"),v=l.createContext(null),P=({snapType:s="none",snapStop:n="normal",scrollBehavior:e="smooth",loop:r=!1,gap:t=16,withFade:i=!1,scrollPadding:a=0,children:c,className:f,...d})=>{const o=l.useRef(null),g=l.useRef(null),h=O.useSnapCarousel(),{overflow:j,refresh:b}=T.useScrollOverflow(o,{precisionTreshold:1}),{activePageIndex:A,pages:q,refresh:m}=h,x=q[A],E=x?[x[0]+1,x[x.length-1]+1]:[0,0],y=l.useCallback(()=>{m&&o.current&&setTimeout(()=>{m()},0)},[m]);l.useEffect(()=>{y()},[c,y]),l.useLayoutEffect(()=>{o.current&&requestAnimationFrame(()=>{b()})},[c,b]);const F={...h,snapType:s,snapStop:n,skipKeyboardNavigation:()=>{g.current?.focus()},scrollBehavior:e,visibleItemsRange:E,loop:r,gap:t,withFade:i,scrollPadding:a,scrollAreaRef:o,overflow:j};return u.jsxs(v.Provider,{value:F,children:[u.jsx("div",{"data-spark-component":"scrolling-list",className:p.cx("gap-lg group/scrolling-list relative flex flex-col default:w-full",f),...d,children:c}),u.jsx("span",{ref:g,className:"size-0 overflow-hidden",tabIndex:-1})]})};P.displayName="ScrollingList";const L=({children:s,visibility:n="always",className:e,...r})=>u.jsx("div",{"data-spark-component":"scrolling-list-controls",className:p.cx("default:px-md pointer-events-none absolute inset-0 flex flex-row items-center justify-between overflow-hidden",e),style:{"--scrolling-list-controls-opacity":n==="hover"?"0":"1"},"data-orientation":"horizontal",...r,children:s});L.displayName="ScrollingList.Controls";function K(s,n){const[e,r]=l.useState(!1);return l.useEffect(()=>{const t=c=>{r(!0);const f=c.target,d=n.current;if(f&&d){const o=f.getBoundingClientRect(),g=d.getBoundingClientRect();o.left>=g.left&&o.right<=g.right&&o.top>=g.top&&o.bottom<=g.bottom||f.scrollIntoView({behavior:"smooth",inline:"center",block:"nearest"})}},i=c=>{s.current&&!s.current.contains(c.relatedTarget)&&r(!1)},a=s.current;return a&&(a.addEventListener("focusin",t),a.addEventListener("focusout",i)),()=>{a&&(a.removeEventListener("focusin",t),a.removeEventListener("focusout",i))}},[s,n]),e}const I=({asChild:s=!1,children:n,index:e=0,className:r="",...t})=>{const i=l.useContext(v),a=l.useRef(null),c=i.snapPointIndexes.has(e);K(a,i.scrollAreaRef);const f=s?V.Slot:"div";return u.jsx(f,{"data-spark-component":"scrolling-list-item",role:"listitem",ref:a,className:p.cx("default:w-auto default:shrink-0",{"snap-start":c,"snap-normal":c&&i.snapStop==="normal","snap-always":c&&i.snapStop==="always"},r),...t,children:n})};I.displayName="ScrollingList.Item";function H(...s){return n=>{s.forEach(e=>{typeof e=="function"?e(n):e&&typeof e=="object"&&"current"in e&&(e.current=n)})}}const N=({children:s,ref:n,className:e="",...r})=>{const t=l.useContext(v),i={mandatory:"x mandatory",proximity:"x proximity",none:"none"},a=o=>{!t.loop&&!t.hasPrevPage||(o.preventDefault(),t.goTo(t.hasPrevPage?t.activePageIndex-1:t.pages.length-1,{behavior:t.scrollBehavior}))},c=o=>{!t.loop&&!t.hasNextPage||(o.preventDefault(),t.goTo(t.hasNextPage?t.activePageIndex+1:0,{behavior:t.scrollBehavior}))},f=o=>{o.key==="ArrowLeft"&&a(o),o.key==="ArrowRight"&&c(o)},d={scrollSnapType:i[t.snapType],scrollPaddingInline:"var(--scrolling-list-px)","--scrolling-list-px":`${t.scrollPadding}px`,"--scrolling-list-gap":`${t.gap}px`,...t.withFade&&{maskImage:"linear-gradient(to right, rgba(0, 0, 0, 0), rgba(0, 0, 0, 1) 44px, rgba(0, 0, 0, 1) calc(100% - 44px), rgba(0, 0, 0, 0))",maskSize:`calc(100% + ${t.overflow.left?"0px":"44px"} + ${t.overflow.right?"0px":"44px"}) 100%`,maskPosition:`${t.overflow.left?"0px":"-44px"} 0`}};return u.jsx("div",{"data-spark-component":"scrolling-list-items",id:"scrolling-list-items",role:"list",className:p.cx("relative transition-all duration-300","u-no-scrollbar overflow-x-auto scroll-smooth","w-full gap-(--scrolling-list-gap) default:flex default:flex-row","focus-visible:u-outline",e),ref:H(t.scrollAreaRef,t.scrollRef,n),style:d,onKeyDown:f,...r,children:l.Children.map(s,(o,g)=>l.isValidElement(o)?l.cloneElement(o,{index:g}):o)})};N.displayName="ScrollingList.Items";const k=({"aria-label":s,...n})=>{const e=l.useContext(v),r=()=>{e.hasNextPage?e.next({behavior:e.scrollBehavior}):e.goTo(0,{behavior:e.scrollBehavior})},i=!(e.overflow.left||e.overflow.right)||!e.loop&&!e.overflow.right;return u.jsx(S.IconButton,{"data-spark-component":"scrolling-list-next-button",size:"sm",intent:"surface",design:"filled",className:p.cx("pointer-events-auto opacity-(--scrolling-list-controls-opacity) shadow-sm disabled:invisible","group-hover/scrolling-list:opacity-none focus-visible:opacity-none"),onClick:r,disabled:i,"aria-label":s,"aria-controls":"scrolling-list-items",...n,children:u.jsx(w.Icon,{children:u.jsx(z.ArrowVerticalRight,{})})})};k.displayName="ScrollingList.NextButton";const B=({"aria-label":s,...n})=>{const e=l.useContext(v),r=()=>{e.activePageIndex===0&&(e.scrollAreaRef.current?.scrollLeft||0)>0?e.goTo(0,{behavior:e.scrollBehavior}):e.hasPrevPage?e.prev({behavior:e.scrollBehavior}):e.goTo(e.pages.length-1,{behavior:e.scrollBehavior})},i=!(e.overflow.left||e.overflow.right)||!e.loop&&!e.overflow.left;return u.jsx(S.IconButton,{"data-spark-component":"scrolling-list-prev-button",size:"sm",intent:"surface",design:"filled",className:p.cx("pointer-events-auto opacity-(--scrolling-list-controls-opacity) shadow-sm disabled:invisible","group-hover/scrolling-list:opacity-none focus-visible:opacity-none"),onClick:r,disabled:i,"aria-label":s,"aria-controls":"scrolling-list-items",...n,children:u.jsx(w.Icon,{children:u.jsx(D.ArrowVerticalLeft,{})})})};B.displayName="ScrollingList.PrevButton";const C=({children:s,...n})=>{const e=l.useContext(v);return u.jsx($.Button,{type:"button",design:"tinted",intent:"surface",tabIndex:0,className:p.cx("z-raised absolute top-1/2 left-0 -translate-y-1/2","not-focus-visible:pointer-events-none not-focus-visible:size-0 not-focus-visible:opacity-0"),onClick:e.skipKeyboardNavigation,...n,children:s})};C.displayName="ScrollingList.SkipButton";const R=Object.assign(P,{Controls:L,NextButton:k,PrevButton:B,Item:I,Items:N,SkipButton:C});R.displayName="ScrollingList";exports.ScrollingList=R;
2
2
  //# sourceMappingURL=index.js.map
@@ -6,9 +6,9 @@ import { useSnapCarousel as J } from "react-snap-carousel";
6
6
  import { S as M } from "../Slot-DLY1rJrG.mjs";
7
7
  import { ArrowVerticalRight as Q } from "@spark-ui/icons/ArrowVerticalRight";
8
8
  import { I as P } from "../Icon-BO327oHU.mjs";
9
- import { I as L } from "../IconButton-DdB3Pq13.mjs";
9
+ import { I as L } from "../IconButton-CP4JbWsI.mjs";
10
10
  import { ArrowVerticalLeft as U } from "@spark-ui/icons/ArrowVerticalLeft";
11
- import { B as X } from "../Button-1M9DcZl0.mjs";
11
+ import { B as X } from "../Button-CcIRizse.mjs";
12
12
  const d = $(
13
13
  null
14
14
  ), N = ({
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),ae=require("@spark-ui/components/form-field"),ne=require("@spark-ui/hooks/use-combined-state"),r=require("react"),f=require("class-variance-authority"),M=require("../Icon-C-cNTnzd.js"),oe=require("@spark-ui/icons/ArrowHorizontalDown"),ce=e=>t=>r.Children.toArray(e).filter(r.isValidElement).find(l=>C(l)?.includes(t)),C=e=>e?e.type.displayName:"",T=(e,t=[])=>(r.Children.forEach(e,s=>{if(r.isValidElement(s)){if(C(s)==="Select.Item"||C(s)==="Select.Placeholder"){const l=s.props;t.push({value:l.value,disabled:!!l.disabled,text:l.children})}s.props.children&&T(s.props.children,t)}}),t),F=e=>{const t=new Map;return T(e).forEach(s=>{t.set(s.value,s)}),t},D=r.createContext(null),ie=":select",R=({children:e,defaultValue:t,value:s,onValueChange:l,disabled:o=!1,readOnly:c=!1,state:i,itemsComponent:n,name:d,required:x})=>{const[h,b]=ne.useCombinedState(s,t,l),[S,y]=r.useState(void 0),[m,v]=r.useState(F(n)),[I,p]=r.useState(),_=m.entries().next()?.value?.[1],B=typeof h=="string"?m.get(h):_,J=s!=null,u=ae.useFormFieldControl(),K=u.state||i,Q=`${ie}-field-${r.useId()}`,W=u.id||Q,Y=u.labelId,Z=u.disabled??o,ee=u.readOnly??c,te=u.name??d,se=!!(u.isRequired??x);return r.useEffect(()=>{const V=F(n),k=[...m.values()],N=[...V.values()];(k.length!==N.length||k.some((z,A)=>{const le=z.value!==N[A]?.value,re=z.text!==N[A]?.text;return le||re}))&&v(V)},[e]),a.jsx(D.Provider,{value:{disabled:Z,readOnly:ee,itemsMap:m,state:K,itemsComponent:n,selectedItem:B,setValue:b,isControlled:J,onValueChange:l,ariaLabel:I,setAriaLabel:p,fieldId:W,fieldLabelId:Y,name:te,required:se,placeholder:S,setPlaceholder:y},children:e})},g=()=>{const e=r.useContext(D);if(!e)throw Error("useSelectContext must be used within a Select provider");return e},$=({children:e,...t})=>{const s=ce(e),l=s("Trigger"),o=s("Items");return a.jsx(R,{...t,itemsComponent:o,children:l})};$.displayName="Select";const H=r.createContext(null),de=({children:e})=>{const[t,s]=r.useState("");return a.jsx(H.Provider,{value:{groupLabel:t,setGroupLabel:s},children:e})},U=()=>{const e=r.useContext(H);if(!e)throw Error("useSelectGroupContext must be used within a SelectGroup provider");return e},j=({children:e,ref:t,...s})=>a.jsx(de,{children:a.jsx(ue,{ref:t,...s,children:e})}),ue=({children:e,className:t,ref:s})=>{const{groupLabel:l}=U();return a.jsx("optgroup",{"data-spark-component":"select-group",ref:s,className:f.cx(t),label:l,children:e})};j.displayName="Select.Group";const w=({disabled:e=!1,value:t,children:s,ref:l})=>a.jsx("option",{"data-spark-component":"select-item",ref:l,value:t,disabled:e,children:s},t);w.displayName="Select.Item";const me=f.cva(["absolute left-0 top-0 size-full rounded-lg opacity-0","min-h-sz-44","ring-1 outline-hidden ring-inset focus:ring-2"],{variants:{state:{undefined:"ring-outline focus:ring-outline-high",error:"ring-error",alert:"ring-alert",success:"ring-success"},disabled:{true:"cursor-not-allowed"},readOnly:{true:"cursor-default"}},compoundVariants:[{disabled:!1,state:void 0,class:"hover:ring-outline-high"}]}),P=({children:e,className:t,ref:s,...l})=>{const{state:o,disabled:c,readOnly:i,ariaLabel:n,fieldLabelId:d,isControlled:x,onValueChange:h,selectedItem:b,setValue:S,name:y,required:m,fieldId:v}=g(),I=p=>{x?(p.preventDefault(),h?.(p.target.value)):S(p.target.value)};return a.jsx("select",{"data-spark-component":"select-items",ref:s,disabled:c||i,name:y,required:m,"aria-labelledby":d,...n&&{"aria-label":n},className:me({className:t,state:o,disabled:c,readOnly:i}),value:b?.value,onChange:I,id:v,...l,children:e})};P.displayName="Select.Items";const L=({children:e})=>{const{setGroupLabel:t}=U();return r.useEffect(()=>{t(e)},[e]),null};L.displayName="Select.Label";const E=({children:e})=>a.jsx(M.Icon,{size:"sm",className:"shrink-0",children:e});E.displayName="Select.LeadingIcon";const O=({disabled:e=!1,children:t,ref:s})=>{const{setPlaceholder:l}=g();return r.useEffect(()=>{l(t)},[t]),a.jsx("option",{"data-spark-component":"select-placeholder",ref:s,value:"",disabled:e,children:t},"placeholder")};O.displayName="Select.Placeholder";const pe=f.cva(["relative flex w-full items-center justify-between","min-h-sz-44 rounded-lg px-lg","text-body-1","ring-1 outline-hidden ring-inset focus-within:ring-focus"],{variants:{state:{undefined:"ring-outline",error:"ring-error",alert:"ring-alert",success:"ring-success"},disabled:{false:"focus-within:ring-2"},readOnly:{true:""}},compoundVariants:[{readOnly:!1,disabled:!1,class:"bg-surface text-on-surface"},{readOnly:!0,class:"bg-on-surface/dim-5 text-on-surface cursor-default"},{disabled:!0,class:["bg-on-surface/dim-5 text-on-surface/dim-3","cursor-not-allowed"]},{disabled:!1,state:void 0,class:"default:hover:ring-outline-high"}]}),q=({"aria-label":e,children:t,className:s,ref:l})=>{const{disabled:o,readOnly:c,state:i,setAriaLabel:n,itemsComponent:d}=g();return r.useEffect(()=>{e&&n(e)},[e]),a.jsxs("div",{"data-spark-component":"select-trigger",ref:l,className:pe({className:s,state:i,disabled:o,readOnly:c}),children:[a.jsx("span",{className:"gap-md flex items-center justify-start",children:t}),a.jsx(M.Icon,{className:"ml-md shrink-0",size:"sm",children:a.jsx(oe.ArrowHorizontalDown,{})}),d]})};q.displayName="Select.Trigger";const G=({children:e,className:t,placeholder:s,ref:l})=>{const{selectedItem:o,placeholder:c,disabled:i}=g(),n=o?.value==null,d=s||c;return a.jsx("span",{role:"presentation","data-spark-component":"select-value",ref:l,className:f.cx("flex shrink items-center text-left",t),children:a.jsx("span",{className:f.cx("line-clamp-1 flex-1 overflow-hidden break-all text-ellipsis",n&&!i&&"text-on-surface/dim-1"),children:n?d:e||o?.text})})};G.displayName="Select.Value";const X=Object.assign($,{Group:j,Item:w,Items:P,Placeholder:O,Label:L,Trigger:q,Value:G,LeadingIcon:E});X.displayName="Select";j.displayName="Select.Group";P.displayName="Select.Items";w.displayName="Select.Item";O.displayName="Select.Placeholder";L.displayName="Select.Label";q.displayName="Select.Trigger";G.displayName="Select.Value";E.displayName="Select.LeadingIcon";exports.Select=X;exports.SelectProvider=R;exports.useSelectContext=g;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),ae=require("@spark-ui/components/form-field"),ne=require("@spark-ui/hooks/use-combined-state"),r=require("react"),f=require("class-variance-authority"),M=require("../Icon-C-cNTnzd.js"),oe=require("@spark-ui/icons/ArrowHorizontalDown"),ce=e=>t=>r.Children.toArray(e).filter(r.isValidElement).find(l=>C(l)?.includes(t)),C=e=>e?e.type.displayName:"",T=(e,t=[])=>(r.Children.forEach(e,s=>{if(r.isValidElement(s)){if(C(s)==="Select.Item"||C(s)==="Select.Placeholder"){const l=s.props;t.push({value:l.value,disabled:!!l.disabled,text:l.children})}s.props.children&&T(s.props.children,t)}}),t),F=e=>{const t=new Map;return T(e).forEach(s=>{t.set(s.value,s)}),t},D=r.createContext(null),ie=":select",R=({children:e,defaultValue:t,value:s,onValueChange:l,disabled:o=!1,readOnly:c=!1,state:i,itemsComponent:n,name:d,required:x})=>{const[h,b]=ne.useCombinedState(s,t,l),[S,y]=r.useState(void 0),[m,v]=r.useState(F(n)),[I,p]=r.useState(),_=m.entries().next()?.value?.[1],B=typeof h=="string"?m.get(h):_,J=s!=null,u=ae.useFormFieldControl(),K=u.state||i,Q=`${ie}-field-${r.useId()}`,W=u.id||Q,Y=u.labelId,Z=u.disabled??o,ee=u.readOnly??c,te=u.name??d,se=!!(u.isRequired??x);return r.useEffect(()=>{const V=F(n),k=[...m.values()],N=[...V.values()];(k.length!==N.length||k.some((z,A)=>{const le=z.value!==N[A]?.value,re=z.text!==N[A]?.text;return le||re}))&&v(V)},[e]),a.jsx(D.Provider,{value:{disabled:Z,readOnly:ee,itemsMap:m,state:K,itemsComponent:n,selectedItem:B,setValue:b,isControlled:J,onValueChange:l,ariaLabel:I,setAriaLabel:p,fieldId:W,fieldLabelId:Y,name:te,required:se,placeholder:S,setPlaceholder:y},children:e})},g=()=>{const e=r.useContext(D);if(!e)throw Error("useSelectContext must be used within a Select provider");return e},$=({children:e,...t})=>{const s=ce(e),l=s("Trigger"),o=s("Items");return a.jsx(R,{...t,itemsComponent:o,children:l})};$.displayName="Select";const H=r.createContext(null),de=({children:e})=>{const[t,s]=r.useState("");return a.jsx(H.Provider,{value:{groupLabel:t,setGroupLabel:s},children:e})},U=()=>{const e=r.useContext(H);if(!e)throw Error("useSelectGroupContext must be used within a SelectGroup provider");return e},j=({children:e,ref:t,...s})=>a.jsx(de,{children:a.jsx(ue,{ref:t,...s,children:e})}),ue=({children:e,className:t,ref:s})=>{const{groupLabel:l}=U();return a.jsx("optgroup",{"data-spark-component":"select-group",ref:s,className:f.cx(t),label:l,children:e})};j.displayName="Select.Group";const w=({disabled:e=!1,value:t,children:s,ref:l})=>a.jsx("option",{"data-spark-component":"select-item",ref:l,value:t,disabled:e,children:s},t);w.displayName="Select.Item";const me=f.cva(["absolute left-0 top-0 size-full rounded-lg opacity-0","min-h-sz-44","ring-1 outline-hidden ring-inset focus:ring-2"],{variants:{state:{undefined:"ring-outline focus:ring-outline-high",error:"ring-error",alert:"ring-alert",success:"ring-success"},disabled:{true:"cursor-not-allowed"},readOnly:{true:"cursor-default"}},compoundVariants:[{disabled:!1,state:void 0,class:"hover:ring-outline-high"}]}),P=({children:e,className:t,ref:s,...l})=>{const{state:o,disabled:c,readOnly:i,ariaLabel:n,fieldLabelId:d,isControlled:x,onValueChange:h,selectedItem:b,setValue:S,name:y,required:m,fieldId:v}=g(),I=p=>{x?(p.preventDefault(),h?.(p.target.value)):S(p.target.value)};return a.jsx("select",{"data-spark-component":"select-items",ref:s,disabled:c||i,name:y,required:m,"aria-labelledby":d,...n&&{"aria-label":n},className:me({className:t,state:o,disabled:c,readOnly:i}),value:b?.value,onChange:I,id:v,...l,children:e})};P.displayName="Select.Items";const L=({children:e})=>{const{setGroupLabel:t}=U();return r.useEffect(()=>{t(e)},[e]),null};L.displayName="Select.Label";const E=({children:e})=>a.jsx(M.Icon,{size:"sm",className:"shrink-0",children:e});E.displayName="Select.LeadingIcon";const O=({disabled:e=!1,children:t,ref:s})=>{const{setPlaceholder:l}=g();return r.useEffect(()=>{l(t)},[t]),a.jsx("option",{"data-spark-component":"select-placeholder",ref:s,value:"",disabled:e,children:t},"placeholder")};O.displayName="Select.Placeholder";const pe=f.cva(["relative flex w-full items-center justify-between","min-h-sz-44 rounded-full px-lg","text-body-1","ring-1 outline-hidden ring-inset focus-within:ring-focus"],{variants:{state:{undefined:"ring-outline",error:"ring-error",alert:"ring-alert",success:"ring-success"},disabled:{false:"focus-within:ring-2"},readOnly:{true:""}},compoundVariants:[{readOnly:!1,disabled:!1,class:"bg-surface text-on-surface"},{readOnly:!0,class:"bg-on-surface/dim-5 text-on-surface cursor-default"},{disabled:!0,class:["bg-on-surface/dim-5 text-on-surface/dim-3","cursor-not-allowed"]},{disabled:!1,state:void 0,class:"default:hover:ring-outline-high"}]}),q=({"aria-label":e,children:t,className:s,ref:l})=>{const{disabled:o,readOnly:c,state:i,setAriaLabel:n,itemsComponent:d}=g();return r.useEffect(()=>{e&&n(e)},[e]),a.jsxs("div",{"data-spark-component":"select-trigger",ref:l,className:pe({className:s,state:i,disabled:o,readOnly:c}),children:[a.jsx("span",{className:"gap-md flex items-center justify-start",children:t}),a.jsx(M.Icon,{className:"ml-md shrink-0",size:"sm",children:a.jsx(oe.ArrowHorizontalDown,{})}),d]})};q.displayName="Select.Trigger";const G=({children:e,className:t,placeholder:s,ref:l})=>{const{selectedItem:o,placeholder:c,disabled:i}=g(),n=o?.value==null,d=s||c;return a.jsx("span",{role:"presentation","data-spark-component":"select-value",ref:l,className:f.cx("flex shrink items-center text-left",t),children:a.jsx("span",{className:f.cx("line-clamp-1 flex-1 overflow-hidden break-all text-ellipsis",n&&!i&&"text-on-surface/dim-1"),children:n?d:e||o?.text})})};G.displayName="Select.Value";const X=Object.assign($,{Group:j,Item:w,Items:P,Placeholder:O,Label:L,Trigger:q,Value:G,LeadingIcon:E});X.displayName="Select";j.displayName="Select.Group";P.displayName="Select.Items";w.displayName="Select.Item";O.displayName="Select.Placeholder";L.displayName="Select.Label";q.displayName="Select.Trigger";G.displayName="Select.Value";E.displayName="Select.LeadingIcon";exports.Select=X;exports.SelectProvider=R;exports.useSelectContext=g;
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/select/utils.ts","../../src/select/SelectContext.tsx","../../src/select/Select.tsx","../../src/select/SelectItemsGroupContext.tsx","../../src/select/SelectGroup.tsx","../../src/select/SelectItem.tsx","../../src/select/SelectItems.tsx","../../src/select/SelectLabel.tsx","../../src/select/SelectLeadingIcon.tsx","../../src/select/SelectPlaceholder.tsx","../../src/select/SelectTrigger.styles.tsx","../../src/select/SelectTrigger.tsx","../../src/select/SelectValue.tsx","../../src/select/index.ts"],"sourcesContent":["import { Children, type FC, isValidElement, type ReactElement, type ReactNode } from 'react'\n\nimport { type ItemProps } from './SelectItem'\nimport { type ItemsMap, type SelectItem } from './types'\n\nexport const findElement = (children: ReactNode) => (name: string) => {\n const validChildren = Children.toArray(children).filter(isValidElement)\n\n return validChildren.find(child => {\n return getElementDisplayName(child)?.includes(name)\n })\n}\n\nconst getElementDisplayName = (element?: ReactElement) => {\n return element ? (element.type as FC & { displayName?: string }).displayName : ''\n}\n\nconst getOrderedItems = (children: ReactNode, result: SelectItem[] = []): SelectItem[] => {\n Children.forEach(children, child => {\n if (!isValidElement(child)) return\n\n if (\n getElementDisplayName(child) === 'Select.Item' ||\n getElementDisplayName(child) === 'Select.Placeholder'\n ) {\n const childProps = child.props as ItemProps\n result.push({\n value: childProps.value,\n disabled: !!childProps.disabled,\n text: childProps.children,\n })\n }\n\n if ((child.props as { children: ReactNode }).children) {\n getOrderedItems((child.props as { children: ReactNode }).children, result)\n }\n })\n\n return result\n}\n\nexport const getItemsFromChildren = (children: ReactNode): ItemsMap => {\n const newMap: ItemsMap = new Map()\n\n getOrderedItems(children).forEach(itemData => {\n newMap.set(itemData.value, itemData)\n })\n\n return newMap\n}\n","import { useFormFieldControl } from '@spark-ui/components/form-field'\nimport { useCombinedState } from '@spark-ui/hooks/use-combined-state'\nimport {\n createContext,\n Dispatch,\n PropsWithChildren,\n ReactElement,\n SetStateAction,\n useContext,\n useEffect,\n useId,\n useState,\n} from 'react'\n\nimport { type ItemsMap, SelectItem } from './types'\nimport { getItemsFromChildren } from './utils'\n\nexport interface SelectContextState {\n itemsMap: ItemsMap\n disabled: boolean\n readOnly: boolean\n state?: 'error' | 'alert' | 'success'\n itemsComponent: ReactElement | undefined\n selectedItem: SelectItem | undefined\n setValue: (value: string) => void\n isControlled: boolean\n onValueChange?: (value: string) => void\n ariaLabel: string | undefined\n setAriaLabel: Dispatch<SetStateAction<string | undefined>>\n fieldId: string\n fieldLabelId: string | undefined\n name: string | undefined\n required: boolean\n placeholder: string | undefined\n setPlaceholder: Dispatch<SetStateAction<string | undefined>>\n}\n\nexport type SelectContextProps = PropsWithChildren<{\n /**\n * Use `state` prop to assign a specific state to the select, choosing from: `error`, `alert` and `success`. By doing so, the outline styles will be updated.\n */\n state?: 'error' | 'alert' | 'success'\n /**\n * When true, prevents the user from interacting with the select.\n */\n disabled?: boolean\n /**\n * Sets the select as interactive or not.\n */\n readOnly?: boolean\n /**\n * The value of the select when initially rendered. Use when you do not need to control the state of the select.\n */\n defaultValue?: string\n /**\n * The controlled value of the select. Should be used in conjunction with `onValueChange`.\n */\n value?: string\n /**\n * Event handler called when the value changes.\n */\n onValueChange?: (value: string) => void\n\n itemsComponent: ReactElement | undefined\n /**\n * This attribute is used to specify the name of the control.\n * If wrapped with a FormField with a name, will be inherited from it.\n */\n name?: string\n /**\n * A Boolean attribute indicating that an option with a non-empty string value must be selected.\n */\n required?: boolean\n}>\n\nconst SelectContext = createContext<SelectContextState | null>(null)\n\nconst ID_PREFIX = ':select'\n\nexport const SelectProvider = ({\n children,\n defaultValue,\n value: valueProp,\n onValueChange,\n disabled: disabledProp = false,\n readOnly: readOnlyProp = false,\n state: stateProp,\n itemsComponent,\n name: nameProp,\n required: requiredProp,\n}: SelectContextProps) => {\n const [value, setValue] = useCombinedState(valueProp, defaultValue, onValueChange)\n const [placeholder, setPlaceholder] = useState<string | undefined>(undefined)\n const [itemsMap, setItemsMap] = useState<ItemsMap>(getItemsFromChildren(itemsComponent))\n const [ariaLabel, setAriaLabel] = useState<string>()\n\n // Computed state\n const firstItem = itemsMap.entries().next()?.value?.[1]\n const selectedItem = typeof value === 'string' ? itemsMap.get(value) : firstItem\n const isControlled = valueProp != null\n\n // Derivated from FormField context\n const field = useFormFieldControl()\n const state = field.state || stateProp\n\n const internalFieldID = `${ID_PREFIX}-field-${useId()}`\n const fieldId = field.id || internalFieldID\n const fieldLabelId = field.labelId\n const disabled = field.disabled ?? disabledProp\n const readOnly = field.readOnly ?? readOnlyProp\n const name = field.name ?? nameProp\n const required = !!(field.isRequired ?? requiredProp)\n\n /**\n * Indices in a Map are set when an element is added to the Map.\n * If for some reason, in the Select:\n * - items order changes\n * - items are added\n * - items are removed\n *\n * The Map must be rebuilt from the new children in order to preserve logical indices.\n *\n */\n useEffect(() => {\n const newMap = getItemsFromChildren(itemsComponent)\n\n const previousItems = [...itemsMap.values()]\n const newItems = [...newMap.values()]\n\n const hasItemsChanges =\n previousItems.length !== newItems.length ||\n previousItems.some((item, index) => {\n const hasUpdatedValue = item.value !== newItems[index]?.value\n const hasUpdatedText = item.text !== newItems[index]?.text\n\n return hasUpdatedValue || hasUpdatedText\n })\n\n if (hasItemsChanges) {\n setItemsMap(newMap)\n }\n }, [children])\n\n return (\n <SelectContext.Provider\n value={{\n disabled,\n readOnly,\n itemsMap,\n state,\n itemsComponent,\n selectedItem,\n setValue,\n isControlled,\n onValueChange,\n ariaLabel,\n setAriaLabel,\n fieldId,\n fieldLabelId,\n name,\n required,\n placeholder,\n setPlaceholder,\n }}\n >\n {children}\n </SelectContext.Provider>\n )\n}\n\nexport const useSelectContext = () => {\n const context = useContext(SelectContext)\n\n if (!context) {\n throw Error('useSelectContext must be used within a Select provider')\n }\n\n return context\n}\n","import { type SelectContextProps, SelectProvider } from './SelectContext'\nimport { findElement } from './utils'\n\nexport type SelectProps = Omit<SelectContextProps, 'itemsComponent'>\n\nexport const Select = ({ children, ...props }: SelectProps) => {\n const finder = findElement(children)\n const trigger = finder('Trigger')\n const items = finder('Items')\n\n return (\n <SelectProvider {...props} itemsComponent={items}>\n {trigger}\n </SelectProvider>\n )\n}\n\nSelect.displayName = 'Select'\n","import { createContext, type PropsWithChildren, useContext, useState } from 'react'\n\nexport interface SelectContextState {\n groupLabel: string\n setGroupLabel: (label: string) => void\n}\n\ntype SelectContextProps = PropsWithChildren\n\nconst SelectGroupContext = createContext<SelectContextState | null>(null)\n\nexport const SelectGroupProvider = ({ children }: SelectContextProps) => {\n const [groupLabel, setGroupLabel] = useState('')\n\n return (\n <SelectGroupContext.Provider value={{ groupLabel, setGroupLabel }}>\n {children}\n </SelectGroupContext.Provider>\n )\n}\n\nexport const useSelectGroupContext = () => {\n const context = useContext(SelectGroupContext)\n\n if (!context) {\n throw Error('useSelectGroupContext must be used within a SelectGroup provider')\n }\n\n return context\n}\n","import { cx } from 'class-variance-authority'\nimport { ReactNode, type Ref } from 'react'\n\nimport { SelectGroupProvider, useSelectGroupContext } from './SelectItemsGroupContext'\n\ninterface GroupProps {\n children: ReactNode\n className?: string\n ref?: Ref<HTMLOptGroupElement>\n}\n\nexport const Group = ({ children, ref: forwardedRef, ...props }: GroupProps) => {\n return (\n <SelectGroupProvider>\n <GroupContent ref={forwardedRef} {...props}>\n {children}\n </GroupContent>\n </SelectGroupProvider>\n )\n}\n\nconst GroupContent = ({ children, className, ref: forwardedRef }: GroupProps) => {\n const { groupLabel } = useSelectGroupContext()\n\n return (\n <optgroup\n data-spark-component=\"select-group\"\n ref={forwardedRef}\n className={cx(className)}\n label={groupLabel}\n >\n {children}\n </optgroup>\n )\n}\n\nGroup.displayName = 'Select.Group'\n","import { type Ref } from 'react'\n\nexport interface ItemProps {\n disabled?: boolean\n value: string\n children: string\n ref?: Ref<HTMLOptionElement>\n}\n\nexport const Item = ({ disabled = false, value, children, ref: forwardedRef }: ItemProps) => {\n return (\n <option\n data-spark-component=\"select-item\"\n ref={forwardedRef}\n key={value}\n value={value}\n disabled={disabled}\n // label\n >\n {children}\n </option>\n )\n}\n\nItem.displayName = 'Select.Item'\n","import { cva } from 'class-variance-authority'\nimport { ChangeEvent, ComponentPropsWithRef, PropsWithChildren } from 'react'\n\nimport { useSelectContext } from './SelectContext'\n\nexport const styles = cva(\n [\n 'absolute left-0 top-0 size-full rounded-lg opacity-0',\n 'min-h-sz-44',\n // outline styles\n 'ring-1 outline-hidden ring-inset focus:ring-2',\n ],\n {\n variants: {\n state: {\n undefined: 'ring-outline focus:ring-outline-high',\n error: 'ring-error',\n alert: 'ring-alert',\n success: 'ring-success',\n },\n disabled: {\n true: 'cursor-not-allowed',\n },\n readOnly: {\n true: 'cursor-default',\n },\n },\n compoundVariants: [\n {\n disabled: false,\n state: undefined,\n class: 'hover:ring-outline-high',\n },\n ],\n }\n)\n\nexport const Items = ({\n children,\n className,\n ref,\n ...rest\n}: PropsWithChildren<ComponentPropsWithRef<'select'>>) => {\n const {\n state,\n disabled,\n readOnly,\n ariaLabel,\n fieldLabelId,\n isControlled,\n onValueChange,\n selectedItem,\n setValue,\n name,\n required,\n fieldId,\n } = useSelectContext()\n\n const handleChange = (event: ChangeEvent<HTMLSelectElement>) => {\n if (isControlled) {\n event.preventDefault()\n onValueChange?.(event.target.value)\n } else {\n setValue(event.target.value)\n }\n }\n\n return (\n <select\n data-spark-component=\"select-items\"\n ref={ref}\n disabled={disabled || readOnly}\n name={name}\n required={required}\n aria-labelledby={fieldLabelId}\n {...(ariaLabel && { 'aria-label': ariaLabel })}\n className={styles({ className, state, disabled, readOnly })}\n value={selectedItem?.value}\n onChange={handleChange}\n id={fieldId}\n {...rest}\n >\n {children}\n </select>\n )\n}\n\nItems.displayName = 'Select.Items'\n","import { useEffect } from 'react'\n\nimport { useSelectGroupContext } from './SelectItemsGroupContext'\n\ninterface LabelProps {\n children: string\n}\n\nexport const Label = ({ children }: LabelProps) => {\n const { setGroupLabel } = useSelectGroupContext()\n\n useEffect(() => {\n setGroupLabel(children)\n }, [children])\n\n return null\n}\n\nLabel.displayName = 'Select.Label'\n","import { ReactElement } from 'react'\n\nimport { Icon } from '../icon'\n\nexport const LeadingIcon = ({ children }: { children: ReactElement }) => {\n return (\n <Icon size={'sm'} className=\"shrink-0\">\n {children}\n </Icon>\n )\n}\n\nLeadingIcon.displayName = 'Select.LeadingIcon'\n","import { type Ref, useEffect } from 'react'\n\nimport { useSelectContext } from './SelectContext'\n\nexport interface PlaceholderProps {\n disabled?: boolean\n children: string\n ref?: Ref<HTMLOptionElement>\n}\n\nexport const Placeholder = ({\n disabled = false,\n children,\n ref: forwardedRef,\n}: PlaceholderProps) => {\n const { setPlaceholder } = useSelectContext()\n\n useEffect(() => {\n setPlaceholder(children)\n }, [children])\n\n return (\n <option\n data-spark-component=\"select-placeholder\"\n ref={forwardedRef}\n key=\"placeholder\"\n value=\"\"\n disabled={disabled}\n >\n {children}\n </option>\n )\n}\n\nPlaceholder.displayName = 'Select.Placeholder'\n","import { cva } from 'class-variance-authority'\n\nexport const styles = cva(\n [\n 'relative flex w-full items-center justify-between',\n 'min-h-sz-44 rounded-lg px-lg',\n 'text-body-1',\n // outline styles\n 'ring-1 outline-hidden ring-inset focus-within:ring-focus',\n ],\n {\n variants: {\n state: {\n undefined: 'ring-outline',\n error: 'ring-error',\n alert: 'ring-alert',\n success: 'ring-success',\n },\n disabled: {\n false: 'focus-within:ring-2',\n },\n readOnly: {\n true: '',\n },\n },\n compoundVariants: [\n {\n readOnly: false,\n disabled: false,\n class: 'bg-surface text-on-surface',\n },\n {\n readOnly: true,\n class: 'bg-on-surface/dim-5 text-on-surface cursor-default',\n },\n {\n disabled: true,\n class: ['bg-on-surface/dim-5 text-on-surface/dim-3', 'cursor-not-allowed'],\n },\n {\n disabled: false,\n state: undefined,\n class: 'default:hover:ring-outline-high',\n },\n ],\n }\n)\n","import { ArrowHorizontalDown } from '@spark-ui/icons/ArrowHorizontalDown'\nimport { ReactNode, type Ref, useEffect } from 'react'\n\nimport { Icon } from '../icon'\nimport { useSelectContext } from './SelectContext'\nimport { styles } from './SelectTrigger.styles'\n\ninterface TriggerProps {\n 'aria-label'?: string\n children: ReactNode\n className?: string\n ref?: Ref<HTMLDivElement>\n}\n\n/**\n * This trigger acts as a fake button for the `select` tag.\n * It is not interactive.\n */\nexport const Trigger = ({\n 'aria-label': ariaLabel,\n children,\n className,\n ref: forwardedRef,\n}: TriggerProps) => {\n const { disabled, readOnly, state, setAriaLabel, itemsComponent } = useSelectContext()\n\n useEffect(() => {\n if (ariaLabel) {\n setAriaLabel(ariaLabel)\n }\n }, [ariaLabel])\n\n return (\n <div\n data-spark-component=\"select-trigger\"\n ref={forwardedRef}\n className={styles({ className, state, disabled, readOnly })}\n >\n <span className=\"gap-md flex items-center justify-start\">{children}</span>\n\n <Icon className=\"ml-md shrink-0\" size=\"sm\">\n <ArrowHorizontalDown />\n </Icon>\n\n {itemsComponent}\n </div>\n )\n}\n\nTrigger.displayName = 'Select.Trigger'\n","import { cx } from 'class-variance-authority'\nimport { ReactNode, type Ref } from 'react'\n\nimport { useSelectContext } from './SelectContext'\n\nexport interface ValueProps {\n children?: ReactNode\n className?: string\n /**\n * Optional placeholder value for the trigger.\n * If not specified, the value inside `Select.Placeholder` item will be used.\n */\n placeholder?: string\n ref?: Ref<HTMLSpanElement>\n}\n\nexport const Value = ({\n children,\n className,\n placeholder: customPlaceholder,\n ref: forwardedRef,\n}: ValueProps) => {\n const { selectedItem, placeholder, disabled } = useSelectContext()\n\n const isPlaceholderSelected = selectedItem?.value == null\n const valuePlaceholder = customPlaceholder || placeholder\n\n return (\n <span\n role=\"presentation\"\n data-spark-component=\"select-value\"\n ref={forwardedRef}\n className={cx('flex shrink items-center text-left', className)}\n >\n <span\n className={cx(\n 'line-clamp-1 flex-1 overflow-hidden break-all text-ellipsis',\n isPlaceholderSelected && !disabled && 'text-on-surface/dim-1'\n )}\n >\n {isPlaceholderSelected ? valuePlaceholder : children || selectedItem?.text}\n </span>\n </span>\n )\n}\n\nValue.displayName = 'Select.Value'\n","import { Select as Root } from './Select'\nimport { SelectProvider, useSelectContext } from './SelectContext'\nimport { Group } from './SelectGroup'\nimport { Item } from './SelectItem'\nimport { Items } from './SelectItems'\nimport { Label } from './SelectLabel'\nimport { LeadingIcon } from './SelectLeadingIcon'\nimport { Placeholder } from './SelectPlaceholder'\nimport { Trigger } from './SelectTrigger'\nimport { Value } from './SelectValue'\n\nexport { useSelectContext, SelectProvider }\n\nexport const Select: typeof Root & {\n Group: typeof Group\n Item: typeof Item\n Items: typeof Items\n Placeholder: typeof Placeholder\n Label: typeof Label\n Trigger: typeof Trigger\n Value: typeof Value\n LeadingIcon: typeof LeadingIcon\n} = Object.assign(Root, {\n Group,\n Item,\n Items,\n Placeholder,\n Label,\n Trigger,\n Value,\n LeadingIcon,\n})\n\nSelect.displayName = 'Select'\nGroup.displayName = 'Select.Group'\nItems.displayName = 'Select.Items'\nItem.displayName = 'Select.Item'\nPlaceholder.displayName = 'Select.Placeholder'\nLabel.displayName = 'Select.Label'\nTrigger.displayName = 'Select.Trigger'\nValue.displayName = 'Select.Value'\nLeadingIcon.displayName = 'Select.LeadingIcon'\n"],"names":["findElement","children","name","Children","isValidElement","child","getElementDisplayName","element","getOrderedItems","result","childProps","getItemsFromChildren","newMap","itemData","SelectContext","createContext","ID_PREFIX","SelectProvider","defaultValue","valueProp","onValueChange","disabledProp","readOnlyProp","stateProp","itemsComponent","nameProp","requiredProp","value","setValue","useCombinedState","placeholder","setPlaceholder","useState","itemsMap","setItemsMap","ariaLabel","setAriaLabel","firstItem","selectedItem","isControlled","field","useFormFieldControl","state","internalFieldID","useId","fieldId","fieldLabelId","disabled","readOnly","required","useEffect","previousItems","newItems","item","index","hasUpdatedValue","hasUpdatedText","jsx","useSelectContext","context","useContext","Select","props","finder","trigger","items","SelectGroupContext","SelectGroupProvider","groupLabel","setGroupLabel","useSelectGroupContext","Group","forwardedRef","GroupContent","className","cx","Item","styles","cva","Items","ref","rest","handleChange","event","Label","LeadingIcon","Icon","Placeholder","Trigger","jsxs","ArrowHorizontalDown","Value","customPlaceholder","isPlaceholderSelected","valuePlaceholder","Root"],"mappings":"gWAKaA,GAAeC,GAAyBC,GAC7BC,EAAAA,SAAS,QAAQF,CAAQ,EAAE,OAAOG,gBAAc,EAEjD,KAAKC,GACjBC,EAAsBD,CAAK,GAAG,SAASH,CAAI,CACnD,EAGGI,EAAyBC,GACtBA,EAAWA,EAAQ,KAA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,SAAAC,EAAU,EAE1D,SAAA,CAAAS,EAAAA,IAAC,OAAA,CAAK,UAAU,yCAA0C,SAAAxD,CAAA,CAAS,EAEnEwD,EAAAA,IAAC6B,EAAAA,MAAK,UAAU,iBAAiB,KAAK,KACpC,SAAA7B,EAAAA,IAACiC,yBAAoB,CAAA,CACvB,EAEClE,CAAA,CAAA,CAAA,CAGP,EAEAgE,EAAQ,YAAc,iBCjCf,MAAMG,EAAQ,CAAC,CACpB,SAAA1F,EACA,UAAAyE,EACA,YAAakB,EACb,IAAKpB,CACP,IAAkB,CAChB,KAAM,CAAE,aAAAlC,EAAc,YAAAR,EAAa,SAAAiB,CAAA,EAAaW,EAAA,EAE1CmC,EAAwBvD,GAAc,OAAS,KAC/CwD,EAAmBF,GAAqB9D,EAE9C,OACE2B,EAAAA,IAAC,OAAA,CACC,KAAK,eACL,uBAAqB,eACrB,IAAKe,EACL,UAAWG,EAAAA,GAAG,qCAAsCD,CAAS,EAE7D,SAAAjB,EAAAA,IAAC,OAAA,CACC,UAAWkB,EAAAA,GACT,8DACAkB,GAAyB,CAAC9C,GAAY,uBAAA,EAGvC,SAAA8C,EAAwBC,EAAmB7F,GAAYqC,GAAc,IAAA,CAAA,CACxE,CAAA,CAGN,EAEAqD,EAAM,YAAc,eCjCb,MAAM9B,EAST,OAAO,OAAOkC,EAAM,CACtB,MAAAxB,EACA,KAAAK,EACA,MAAAG,EACA,YAAAQ,EACA,MAAAH,EACA,QAAAI,EACA,MAAAG,EACA,YAAAN,CACF,CAAC,EAEDxB,EAAO,YAAc,SACrBU,EAAM,YAAc,eACpBQ,EAAM,YAAc,eACpBH,EAAK,YAAc,cACnBW,EAAY,YAAc,qBAC1BH,EAAM,YAAc,eACpBI,EAAQ,YAAc,iBACtBG,EAAM,YAAc,eACpBN,EAAY,YAAc"}
1
+ {"version":3,"file":"index.js","sources":["../../src/select/utils.ts","../../src/select/SelectContext.tsx","../../src/select/Select.tsx","../../src/select/SelectItemsGroupContext.tsx","../../src/select/SelectGroup.tsx","../../src/select/SelectItem.tsx","../../src/select/SelectItems.tsx","../../src/select/SelectLabel.tsx","../../src/select/SelectLeadingIcon.tsx","../../src/select/SelectPlaceholder.tsx","../../src/select/SelectTrigger.styles.tsx","../../src/select/SelectTrigger.tsx","../../src/select/SelectValue.tsx","../../src/select/index.ts"],"sourcesContent":["import { Children, type FC, isValidElement, type ReactElement, type ReactNode } from 'react'\n\nimport { type ItemProps } from './SelectItem'\nimport { type ItemsMap, type SelectItem } from './types'\n\nexport const findElement = (children: ReactNode) => (name: string) => {\n const validChildren = Children.toArray(children).filter(isValidElement)\n\n return validChildren.find(child => {\n return getElementDisplayName(child)?.includes(name)\n })\n}\n\nconst getElementDisplayName = (element?: ReactElement) => {\n return element ? (element.type as FC & { displayName?: string }).displayName : ''\n}\n\nconst getOrderedItems = (children: ReactNode, result: SelectItem[] = []): SelectItem[] => {\n Children.forEach(children, child => {\n if (!isValidElement(child)) return\n\n if (\n getElementDisplayName(child) === 'Select.Item' ||\n getElementDisplayName(child) === 'Select.Placeholder'\n ) {\n const childProps = child.props as ItemProps\n result.push({\n value: childProps.value,\n disabled: !!childProps.disabled,\n text: childProps.children,\n })\n }\n\n if ((child.props as { children: ReactNode }).children) {\n getOrderedItems((child.props as { children: ReactNode }).children, result)\n }\n })\n\n return result\n}\n\nexport const getItemsFromChildren = (children: ReactNode): ItemsMap => {\n const newMap: ItemsMap = new Map()\n\n getOrderedItems(children).forEach(itemData => {\n newMap.set(itemData.value, itemData)\n })\n\n return newMap\n}\n","import { useFormFieldControl } from '@spark-ui/components/form-field'\nimport { useCombinedState } from '@spark-ui/hooks/use-combined-state'\nimport {\n createContext,\n Dispatch,\n PropsWithChildren,\n ReactElement,\n SetStateAction,\n useContext,\n useEffect,\n useId,\n useState,\n} from 'react'\n\nimport { type ItemsMap, SelectItem } from './types'\nimport { getItemsFromChildren } from './utils'\n\nexport interface SelectContextState {\n itemsMap: ItemsMap\n disabled: boolean\n readOnly: boolean\n state?: 'error' | 'alert' | 'success'\n itemsComponent: ReactElement | undefined\n selectedItem: SelectItem | undefined\n setValue: (value: string) => void\n isControlled: boolean\n onValueChange?: (value: string) => void\n ariaLabel: string | undefined\n setAriaLabel: Dispatch<SetStateAction<string | undefined>>\n fieldId: string\n fieldLabelId: string | undefined\n name: string | undefined\n required: boolean\n placeholder: string | undefined\n setPlaceholder: Dispatch<SetStateAction<string | undefined>>\n}\n\nexport type SelectContextProps = PropsWithChildren<{\n /**\n * Use `state` prop to assign a specific state to the select, choosing from: `error`, `alert` and `success`. By doing so, the outline styles will be updated.\n */\n state?: 'error' | 'alert' | 'success'\n /**\n * When true, prevents the user from interacting with the select.\n */\n disabled?: boolean\n /**\n * Sets the select as interactive or not.\n */\n readOnly?: boolean\n /**\n * The value of the select when initially rendered. Use when you do not need to control the state of the select.\n */\n defaultValue?: string\n /**\n * The controlled value of the select. Should be used in conjunction with `onValueChange`.\n */\n value?: string\n /**\n * Event handler called when the value changes.\n */\n onValueChange?: (value: string) => void\n\n itemsComponent: ReactElement | undefined\n /**\n * This attribute is used to specify the name of the control.\n * If wrapped with a FormField with a name, will be inherited from it.\n */\n name?: string\n /**\n * A Boolean attribute indicating that an option with a non-empty string value must be selected.\n */\n required?: boolean\n}>\n\nconst SelectContext = createContext<SelectContextState | null>(null)\n\nconst ID_PREFIX = ':select'\n\nexport const SelectProvider = ({\n children,\n defaultValue,\n value: valueProp,\n onValueChange,\n disabled: disabledProp = false,\n readOnly: readOnlyProp = false,\n state: stateProp,\n itemsComponent,\n name: nameProp,\n required: requiredProp,\n}: SelectContextProps) => {\n const [value, setValue] = useCombinedState(valueProp, defaultValue, onValueChange)\n const [placeholder, setPlaceholder] = useState<string | undefined>(undefined)\n const [itemsMap, setItemsMap] = useState<ItemsMap>(getItemsFromChildren(itemsComponent))\n const [ariaLabel, setAriaLabel] = useState<string>()\n\n // Computed state\n const firstItem = itemsMap.entries().next()?.value?.[1]\n const selectedItem = typeof value === 'string' ? itemsMap.get(value) : firstItem\n const isControlled = valueProp != null\n\n // Derivated from FormField context\n const field = useFormFieldControl()\n const state = field.state || stateProp\n\n const internalFieldID = `${ID_PREFIX}-field-${useId()}`\n const fieldId = field.id || internalFieldID\n const fieldLabelId = field.labelId\n const disabled = field.disabled ?? disabledProp\n const readOnly = field.readOnly ?? readOnlyProp\n const name = field.name ?? nameProp\n const required = !!(field.isRequired ?? requiredProp)\n\n /**\n * Indices in a Map are set when an element is added to the Map.\n * If for some reason, in the Select:\n * - items order changes\n * - items are added\n * - items are removed\n *\n * The Map must be rebuilt from the new children in order to preserve logical indices.\n *\n */\n useEffect(() => {\n const newMap = getItemsFromChildren(itemsComponent)\n\n const previousItems = [...itemsMap.values()]\n const newItems = [...newMap.values()]\n\n const hasItemsChanges =\n previousItems.length !== newItems.length ||\n previousItems.some((item, index) => {\n const hasUpdatedValue = item.value !== newItems[index]?.value\n const hasUpdatedText = item.text !== newItems[index]?.text\n\n return hasUpdatedValue || hasUpdatedText\n })\n\n if (hasItemsChanges) {\n setItemsMap(newMap)\n }\n }, [children])\n\n return (\n <SelectContext.Provider\n value={{\n disabled,\n readOnly,\n itemsMap,\n state,\n itemsComponent,\n selectedItem,\n setValue,\n isControlled,\n onValueChange,\n ariaLabel,\n setAriaLabel,\n fieldId,\n fieldLabelId,\n name,\n required,\n placeholder,\n setPlaceholder,\n }}\n >\n {children}\n </SelectContext.Provider>\n )\n}\n\nexport const useSelectContext = () => {\n const context = useContext(SelectContext)\n\n if (!context) {\n throw Error('useSelectContext must be used within a Select provider')\n }\n\n return context\n}\n","import { type SelectContextProps, SelectProvider } from './SelectContext'\nimport { findElement } from './utils'\n\nexport type SelectProps = Omit<SelectContextProps, 'itemsComponent'>\n\nexport const Select = ({ children, ...props }: SelectProps) => {\n const finder = findElement(children)\n const trigger = finder('Trigger')\n const items = finder('Items')\n\n return (\n <SelectProvider {...props} itemsComponent={items}>\n {trigger}\n </SelectProvider>\n )\n}\n\nSelect.displayName = 'Select'\n","import { createContext, type PropsWithChildren, useContext, useState } from 'react'\n\nexport interface SelectContextState {\n groupLabel: string\n setGroupLabel: (label: string) => void\n}\n\ntype SelectContextProps = PropsWithChildren\n\nconst SelectGroupContext = createContext<SelectContextState | null>(null)\n\nexport const SelectGroupProvider = ({ children }: SelectContextProps) => {\n const [groupLabel, setGroupLabel] = useState('')\n\n return (\n <SelectGroupContext.Provider value={{ groupLabel, setGroupLabel }}>\n {children}\n </SelectGroupContext.Provider>\n )\n}\n\nexport const useSelectGroupContext = () => {\n const context = useContext(SelectGroupContext)\n\n if (!context) {\n throw Error('useSelectGroupContext must be used within a SelectGroup provider')\n }\n\n return context\n}\n","import { cx } from 'class-variance-authority'\nimport { ReactNode, type Ref } from 'react'\n\nimport { SelectGroupProvider, useSelectGroupContext } from './SelectItemsGroupContext'\n\ninterface GroupProps {\n children: ReactNode\n className?: string\n ref?: Ref<HTMLOptGroupElement>\n}\n\nexport const Group = ({ children, ref: forwardedRef, ...props }: GroupProps) => {\n return (\n <SelectGroupProvider>\n <GroupContent ref={forwardedRef} {...props}>\n {children}\n </GroupContent>\n </SelectGroupProvider>\n )\n}\n\nconst GroupContent = ({ children, className, ref: forwardedRef }: GroupProps) => {\n const { groupLabel } = useSelectGroupContext()\n\n return (\n <optgroup\n data-spark-component=\"select-group\"\n ref={forwardedRef}\n className={cx(className)}\n label={groupLabel}\n >\n {children}\n </optgroup>\n )\n}\n\nGroup.displayName = 'Select.Group'\n","import { type Ref } from 'react'\n\nexport interface ItemProps {\n disabled?: boolean\n value: string\n children: string\n ref?: Ref<HTMLOptionElement>\n}\n\nexport const Item = ({ disabled = false, value, children, ref: forwardedRef }: ItemProps) => {\n return (\n <option\n data-spark-component=\"select-item\"\n ref={forwardedRef}\n key={value}\n value={value}\n disabled={disabled}\n // label\n >\n {children}\n </option>\n )\n}\n\nItem.displayName = 'Select.Item'\n","import { cva } from 'class-variance-authority'\nimport { ChangeEvent, ComponentPropsWithRef, PropsWithChildren } from 'react'\n\nimport { useSelectContext } from './SelectContext'\n\nexport const styles = cva(\n [\n 'absolute left-0 top-0 size-full rounded-lg opacity-0',\n 'min-h-sz-44',\n // outline styles\n 'ring-1 outline-hidden ring-inset focus:ring-2',\n ],\n {\n variants: {\n state: {\n undefined: 'ring-outline focus:ring-outline-high',\n error: 'ring-error',\n alert: 'ring-alert',\n success: 'ring-success',\n },\n disabled: {\n true: 'cursor-not-allowed',\n },\n readOnly: {\n true: 'cursor-default',\n },\n },\n compoundVariants: [\n {\n disabled: false,\n state: undefined,\n class: 'hover:ring-outline-high',\n },\n ],\n }\n)\n\nexport const Items = ({\n children,\n className,\n ref,\n ...rest\n}: PropsWithChildren<ComponentPropsWithRef<'select'>>) => {\n const {\n state,\n disabled,\n readOnly,\n ariaLabel,\n fieldLabelId,\n isControlled,\n onValueChange,\n selectedItem,\n setValue,\n name,\n required,\n fieldId,\n } = useSelectContext()\n\n const handleChange = (event: ChangeEvent<HTMLSelectElement>) => {\n if (isControlled) {\n event.preventDefault()\n onValueChange?.(event.target.value)\n } else {\n setValue(event.target.value)\n }\n }\n\n return (\n <select\n data-spark-component=\"select-items\"\n ref={ref}\n disabled={disabled || readOnly}\n name={name}\n required={required}\n aria-labelledby={fieldLabelId}\n {...(ariaLabel && { 'aria-label': ariaLabel })}\n className={styles({ className, state, disabled, readOnly })}\n value={selectedItem?.value}\n onChange={handleChange}\n id={fieldId}\n {...rest}\n >\n {children}\n </select>\n )\n}\n\nItems.displayName = 'Select.Items'\n","import { useEffect } from 'react'\n\nimport { useSelectGroupContext } from './SelectItemsGroupContext'\n\ninterface LabelProps {\n children: string\n}\n\nexport const Label = ({ children }: LabelProps) => {\n const { setGroupLabel } = useSelectGroupContext()\n\n useEffect(() => {\n setGroupLabel(children)\n }, [children])\n\n return null\n}\n\nLabel.displayName = 'Select.Label'\n","import { ReactElement } from 'react'\n\nimport { Icon } from '../icon'\n\nexport const LeadingIcon = ({ children }: { children: ReactElement }) => {\n return (\n <Icon size={'sm'} className=\"shrink-0\">\n {children}\n </Icon>\n )\n}\n\nLeadingIcon.displayName = 'Select.LeadingIcon'\n","import { type Ref, useEffect } from 'react'\n\nimport { useSelectContext } from './SelectContext'\n\nexport interface PlaceholderProps {\n disabled?: boolean\n children: string\n ref?: Ref<HTMLOptionElement>\n}\n\nexport const Placeholder = ({\n disabled = false,\n children,\n ref: forwardedRef,\n}: PlaceholderProps) => {\n const { setPlaceholder } = useSelectContext()\n\n useEffect(() => {\n setPlaceholder(children)\n }, [children])\n\n return (\n <option\n data-spark-component=\"select-placeholder\"\n ref={forwardedRef}\n key=\"placeholder\"\n value=\"\"\n disabled={disabled}\n >\n {children}\n </option>\n )\n}\n\nPlaceholder.displayName = 'Select.Placeholder'\n","import { cva } from 'class-variance-authority'\n\nexport const styles = cva(\n [\n 'relative flex w-full items-center justify-between',\n 'min-h-sz-44 rounded-full px-lg',\n 'text-body-1',\n // outline styles\n 'ring-1 outline-hidden ring-inset focus-within:ring-focus',\n ],\n {\n variants: {\n state: {\n undefined: 'ring-outline',\n error: 'ring-error',\n alert: 'ring-alert',\n success: 'ring-success',\n },\n disabled: {\n false: 'focus-within:ring-2',\n },\n readOnly: {\n true: '',\n },\n },\n compoundVariants: [\n {\n readOnly: false,\n disabled: false,\n class: 'bg-surface text-on-surface',\n },\n {\n readOnly: true,\n class: 'bg-on-surface/dim-5 text-on-surface cursor-default',\n },\n {\n disabled: true,\n class: ['bg-on-surface/dim-5 text-on-surface/dim-3', 'cursor-not-allowed'],\n },\n {\n disabled: false,\n state: undefined,\n class: 'default:hover:ring-outline-high',\n },\n ],\n }\n)\n","import { ArrowHorizontalDown } from '@spark-ui/icons/ArrowHorizontalDown'\nimport { ReactNode, type Ref, useEffect } from 'react'\n\nimport { Icon } from '../icon'\nimport { useSelectContext } from './SelectContext'\nimport { styles } from './SelectTrigger.styles'\n\ninterface TriggerProps {\n 'aria-label'?: string\n children: ReactNode\n className?: string\n ref?: Ref<HTMLDivElement>\n}\n\n/**\n * This trigger acts as a fake button for the `select` tag.\n * It is not interactive.\n */\nexport const Trigger = ({\n 'aria-label': ariaLabel,\n children,\n className,\n ref: forwardedRef,\n}: TriggerProps) => {\n const { disabled, readOnly, state, setAriaLabel, itemsComponent } = useSelectContext()\n\n useEffect(() => {\n if (ariaLabel) {\n setAriaLabel(ariaLabel)\n }\n }, [ariaLabel])\n\n return (\n <div\n data-spark-component=\"select-trigger\"\n ref={forwardedRef}\n className={styles({ className, state, disabled, readOnly })}\n >\n <span className=\"gap-md flex items-center justify-start\">{children}</span>\n\n <Icon className=\"ml-md shrink-0\" size=\"sm\">\n <ArrowHorizontalDown />\n </Icon>\n\n {itemsComponent}\n </div>\n )\n}\n\nTrigger.displayName = 'Select.Trigger'\n","import { cx } from 'class-variance-authority'\nimport { ReactNode, type Ref } from 'react'\n\nimport { useSelectContext } from './SelectContext'\n\nexport interface ValueProps {\n children?: ReactNode\n className?: string\n /**\n * Optional placeholder value for the trigger.\n * If not specified, the value inside `Select.Placeholder` item will be used.\n */\n placeholder?: string\n ref?: Ref<HTMLSpanElement>\n}\n\nexport const Value = ({\n children,\n className,\n placeholder: customPlaceholder,\n ref: forwardedRef,\n}: ValueProps) => {\n const { selectedItem, placeholder, disabled } = useSelectContext()\n\n const isPlaceholderSelected = selectedItem?.value == null\n const valuePlaceholder = customPlaceholder || placeholder\n\n return (\n <span\n role=\"presentation\"\n data-spark-component=\"select-value\"\n ref={forwardedRef}\n className={cx('flex shrink items-center text-left', className)}\n >\n <span\n className={cx(\n 'line-clamp-1 flex-1 overflow-hidden break-all text-ellipsis',\n isPlaceholderSelected && !disabled && 'text-on-surface/dim-1'\n )}\n >\n {isPlaceholderSelected ? valuePlaceholder : children || selectedItem?.text}\n </span>\n </span>\n )\n}\n\nValue.displayName = 'Select.Value'\n","import { Select as Root } from './Select'\nimport { SelectProvider, useSelectContext } from './SelectContext'\nimport { Group } from './SelectGroup'\nimport { Item } from './SelectItem'\nimport { Items } from './SelectItems'\nimport { Label } from './SelectLabel'\nimport { LeadingIcon } from './SelectLeadingIcon'\nimport { Placeholder } from './SelectPlaceholder'\nimport { Trigger } from './SelectTrigger'\nimport { Value } from './SelectValue'\n\nexport { useSelectContext, SelectProvider }\n\nexport const Select: typeof Root & {\n Group: typeof Group\n Item: typeof Item\n Items: typeof Items\n Placeholder: typeof Placeholder\n Label: typeof Label\n Trigger: typeof Trigger\n Value: typeof Value\n LeadingIcon: typeof LeadingIcon\n} = Object.assign(Root, {\n Group,\n Item,\n Items,\n Placeholder,\n Label,\n Trigger,\n Value,\n LeadingIcon,\n})\n\nSelect.displayName = 'Select'\nGroup.displayName = 'Select.Group'\nItems.displayName = 'Select.Items'\nItem.displayName = 'Select.Item'\nPlaceholder.displayName = 'Select.Placeholder'\nLabel.displayName = 'Select.Label'\nTrigger.displayName = 'Select.Trigger'\nValue.displayName = 'Select.Value'\nLeadingIcon.displayName = 'Select.LeadingIcon'\n"],"names":["findElement","children","name","Children","isValidElement","child","getElementDisplayName","element","getOrderedItems","result","childProps","getItemsFromChildren","newMap","itemData","SelectContext","createContext","ID_PREFIX","SelectProvider","defaultValue","valueProp","onValueChange","disabledProp","readOnlyProp","stateProp","itemsComponent","nameProp","requiredProp","value","setValue","useCombinedState","placeholder","setPlaceholder","useState","itemsMap","setItemsMap","ariaLabel","setAriaLabel","firstItem","selectedItem","isControlled","field","useFormFieldControl","state","internalFieldID","useId","fieldId","fieldLabelId","disabled","readOnly","required","useEffect","previousItems","newItems","item","index","hasUpdatedValue","hasUpdatedText","jsx","useSelectContext","context","useContext","Select","props","finder","trigger","items","SelectGroupContext","SelectGroupProvider","groupLabel","setGroupLabel","useSelectGroupContext","Group","forwardedRef","GroupContent","className","cx","Item","styles","cva","Items","ref","rest","handleChange","event","Label","LeadingIcon","Icon","Placeholder","Trigger","jsxs","ArrowHorizontalDown","Value","customPlaceholder","isPlaceholderSelected","valuePlaceholder","Root"],"mappings":"gWAKaA,GAAeC,GAAyBC,GAC7BC,EAAAA,SAAS,QAAQF,CAAQ,EAAE,OAAOG,gBA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 -215,7 +215,7 @@ E.displayName = "Select.Placeholder";
215
215
  const Se = U(
216
216
  [
217
217
  "relative flex w-full items-center justify-between",
218
- "min-h-sz-44 rounded-lg px-lg",
218
+ "min-h-sz-44 rounded-full px-lg",
219
219
  "text-body-1",
220
220
  // outline styles
221
221
  "ring-1 outline-hidden ring-inset focus-within:ring-focus"
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":["../../src/select/utils.ts","../../src/select/SelectContext.tsx","../../src/select/Select.tsx","../../src/select/SelectItemsGroupContext.tsx","../../src/select/SelectGroup.tsx","../../src/select/SelectItem.tsx","../../src/select/SelectItems.tsx","../../src/select/SelectLabel.tsx","../../src/select/SelectLeadingIcon.tsx","../../src/select/SelectPlaceholder.tsx","../../src/select/SelectTrigger.styles.tsx","../../src/select/SelectTrigger.tsx","../../src/select/SelectValue.tsx","../../src/select/index.ts"],"sourcesContent":["import { Children, type FC, isValidElement, type ReactElement, type ReactNode } from 'react'\n\nimport { type ItemProps } from './SelectItem'\nimport { type ItemsMap, type SelectItem } from './types'\n\nexport const findElement = (children: ReactNode) => (name: string) => {\n const validChildren = Children.toArray(children).filter(isValidElement)\n\n return validChildren.find(child => {\n return getElementDisplayName(child)?.includes(name)\n })\n}\n\nconst getElementDisplayName = (element?: ReactElement) => {\n return element ? (element.type as FC & { displayName?: string }).displayName : ''\n}\n\nconst getOrderedItems = (children: ReactNode, result: SelectItem[] = []): SelectItem[] => {\n Children.forEach(children, child => {\n if (!isValidElement(child)) return\n\n if (\n getElementDisplayName(child) === 'Select.Item' ||\n getElementDisplayName(child) === 'Select.Placeholder'\n ) {\n const childProps = child.props as ItemProps\n result.push({\n value: childProps.value,\n disabled: !!childProps.disabled,\n text: childProps.children,\n })\n }\n\n if ((child.props as { children: ReactNode }).children) {\n getOrderedItems((child.props as { children: ReactNode }).children, result)\n }\n })\n\n return result\n}\n\nexport const getItemsFromChildren = (children: ReactNode): ItemsMap => {\n const newMap: ItemsMap = new Map()\n\n getOrderedItems(children).forEach(itemData => {\n newMap.set(itemData.value, itemData)\n })\n\n return newMap\n}\n","import { useFormFieldControl } from '@spark-ui/components/form-field'\nimport { useCombinedState } from '@spark-ui/hooks/use-combined-state'\nimport {\n createContext,\n Dispatch,\n PropsWithChildren,\n ReactElement,\n SetStateAction,\n useContext,\n useEffect,\n useId,\n useState,\n} from 'react'\n\nimport { type ItemsMap, SelectItem } from './types'\nimport { getItemsFromChildren } from './utils'\n\nexport interface SelectContextState {\n itemsMap: ItemsMap\n disabled: boolean\n readOnly: boolean\n state?: 'error' | 'alert' | 'success'\n itemsComponent: ReactElement | undefined\n selectedItem: SelectItem | undefined\n setValue: (value: string) => void\n isControlled: boolean\n onValueChange?: (value: string) => void\n ariaLabel: string | undefined\n setAriaLabel: Dispatch<SetStateAction<string | undefined>>\n fieldId: string\n fieldLabelId: string | undefined\n name: string | undefined\n required: boolean\n placeholder: string | undefined\n setPlaceholder: Dispatch<SetStateAction<string | undefined>>\n}\n\nexport type SelectContextProps = PropsWithChildren<{\n /**\n * Use `state` prop to assign a specific state to the select, choosing from: `error`, `alert` and `success`. By doing so, the outline styles will be updated.\n */\n state?: 'error' | 'alert' | 'success'\n /**\n * When true, prevents the user from interacting with the select.\n */\n disabled?: boolean\n /**\n * Sets the select as interactive or not.\n */\n readOnly?: boolean\n /**\n * The value of the select when initially rendered. Use when you do not need to control the state of the select.\n */\n defaultValue?: string\n /**\n * The controlled value of the select. Should be used in conjunction with `onValueChange`.\n */\n value?: string\n /**\n * Event handler called when the value changes.\n */\n onValueChange?: (value: string) => void\n\n itemsComponent: ReactElement | undefined\n /**\n * This attribute is used to specify the name of the control.\n * If wrapped with a FormField with a name, will be inherited from it.\n */\n name?: string\n /**\n * A Boolean attribute indicating that an option with a non-empty string value must be selected.\n */\n required?: boolean\n}>\n\nconst SelectContext = createContext<SelectContextState | null>(null)\n\nconst ID_PREFIX = ':select'\n\nexport const SelectProvider = ({\n children,\n defaultValue,\n value: valueProp,\n onValueChange,\n disabled: disabledProp = false,\n readOnly: readOnlyProp = false,\n state: stateProp,\n itemsComponent,\n name: nameProp,\n required: requiredProp,\n}: SelectContextProps) => {\n const [value, setValue] = useCombinedState(valueProp, defaultValue, onValueChange)\n const [placeholder, setPlaceholder] = useState<string | undefined>(undefined)\n const [itemsMap, setItemsMap] = useState<ItemsMap>(getItemsFromChildren(itemsComponent))\n const [ariaLabel, setAriaLabel] = useState<string>()\n\n // Computed state\n const firstItem = itemsMap.entries().next()?.value?.[1]\n const selectedItem = typeof value === 'string' ? itemsMap.get(value) : firstItem\n const isControlled = valueProp != null\n\n // Derivated from FormField context\n const field = useFormFieldControl()\n const state = field.state || stateProp\n\n const internalFieldID = `${ID_PREFIX}-field-${useId()}`\n const fieldId = field.id || internalFieldID\n const fieldLabelId = field.labelId\n const disabled = field.disabled ?? disabledProp\n const readOnly = field.readOnly ?? readOnlyProp\n const name = field.name ?? nameProp\n const required = !!(field.isRequired ?? requiredProp)\n\n /**\n * Indices in a Map are set when an element is added to the Map.\n * If for some reason, in the Select:\n * - items order changes\n * - items are added\n * - items are removed\n *\n * The Map must be rebuilt from the new children in order to preserve logical indices.\n *\n */\n useEffect(() => {\n const newMap = getItemsFromChildren(itemsComponent)\n\n const previousItems = [...itemsMap.values()]\n const newItems = [...newMap.values()]\n\n const hasItemsChanges =\n previousItems.length !== newItems.length ||\n previousItems.some((item, index) => {\n const hasUpdatedValue = item.value !== newItems[index]?.value\n const hasUpdatedText = item.text !== newItems[index]?.text\n\n return hasUpdatedValue || hasUpdatedText\n })\n\n if (hasItemsChanges) {\n setItemsMap(newMap)\n }\n }, [children])\n\n return (\n <SelectContext.Provider\n value={{\n disabled,\n readOnly,\n itemsMap,\n state,\n itemsComponent,\n selectedItem,\n setValue,\n isControlled,\n onValueChange,\n ariaLabel,\n setAriaLabel,\n fieldId,\n fieldLabelId,\n name,\n required,\n placeholder,\n setPlaceholder,\n }}\n >\n {children}\n </SelectContext.Provider>\n )\n}\n\nexport const useSelectContext = () => {\n const context = useContext(SelectContext)\n\n if (!context) {\n throw Error('useSelectContext must be used within a Select provider')\n }\n\n return context\n}\n","import { type SelectContextProps, SelectProvider } from './SelectContext'\nimport { findElement } from './utils'\n\nexport type SelectProps = Omit<SelectContextProps, 'itemsComponent'>\n\nexport const Select = ({ children, ...props }: SelectProps) => {\n const finder = findElement(children)\n const trigger = finder('Trigger')\n const items = finder('Items')\n\n return (\n <SelectProvider {...props} itemsComponent={items}>\n {trigger}\n </SelectProvider>\n )\n}\n\nSelect.displayName = 'Select'\n","import { createContext, type PropsWithChildren, useContext, useState } from 'react'\n\nexport interface SelectContextState {\n groupLabel: string\n setGroupLabel: (label: string) => void\n}\n\ntype SelectContextProps = PropsWithChildren\n\nconst SelectGroupContext = createContext<SelectContextState | null>(null)\n\nexport const SelectGroupProvider = ({ children }: SelectContextProps) => {\n const [groupLabel, setGroupLabel] = useState('')\n\n return (\n <SelectGroupContext.Provider value={{ groupLabel, setGroupLabel }}>\n {children}\n </SelectGroupContext.Provider>\n )\n}\n\nexport const useSelectGroupContext = () => {\n const context = useContext(SelectGroupContext)\n\n if (!context) {\n throw Error('useSelectGroupContext must be used within a SelectGroup provider')\n }\n\n return context\n}\n","import { cx } from 'class-variance-authority'\nimport { ReactNode, type Ref } from 'react'\n\nimport { SelectGroupProvider, useSelectGroupContext } from './SelectItemsGroupContext'\n\ninterface GroupProps {\n children: ReactNode\n className?: string\n ref?: Ref<HTMLOptGroupElement>\n}\n\nexport const Group = ({ children, ref: forwardedRef, ...props }: GroupProps) => {\n return (\n <SelectGroupProvider>\n <GroupContent ref={forwardedRef} {...props}>\n {children}\n </GroupContent>\n </SelectGroupProvider>\n )\n}\n\nconst GroupContent = ({ children, className, ref: forwardedRef }: GroupProps) => {\n const { groupLabel } = useSelectGroupContext()\n\n return (\n <optgroup\n data-spark-component=\"select-group\"\n ref={forwardedRef}\n className={cx(className)}\n label={groupLabel}\n >\n {children}\n </optgroup>\n )\n}\n\nGroup.displayName = 'Select.Group'\n","import { type Ref } from 'react'\n\nexport interface ItemProps {\n disabled?: boolean\n value: string\n children: string\n ref?: Ref<HTMLOptionElement>\n}\n\nexport const Item = ({ disabled = false, value, children, ref: forwardedRef }: ItemProps) => {\n return (\n <option\n data-spark-component=\"select-item\"\n ref={forwardedRef}\n key={value}\n value={value}\n disabled={disabled}\n // label\n >\n {children}\n </option>\n )\n}\n\nItem.displayName = 'Select.Item'\n","import { cva } from 'class-variance-authority'\nimport { ChangeEvent, ComponentPropsWithRef, PropsWithChildren } from 'react'\n\nimport { useSelectContext } from './SelectContext'\n\nexport const styles = cva(\n [\n 'absolute left-0 top-0 size-full rounded-lg opacity-0',\n 'min-h-sz-44',\n // outline styles\n 'ring-1 outline-hidden ring-inset focus:ring-2',\n ],\n {\n variants: {\n state: {\n undefined: 'ring-outline focus:ring-outline-high',\n error: 'ring-error',\n alert: 'ring-alert',\n success: 'ring-success',\n },\n disabled: {\n true: 'cursor-not-allowed',\n },\n readOnly: {\n true: 'cursor-default',\n },\n },\n compoundVariants: [\n {\n disabled: false,\n state: undefined,\n class: 'hover:ring-outline-high',\n },\n ],\n }\n)\n\nexport const Items = ({\n children,\n className,\n ref,\n ...rest\n}: PropsWithChildren<ComponentPropsWithRef<'select'>>) => {\n const {\n state,\n disabled,\n readOnly,\n ariaLabel,\n fieldLabelId,\n isControlled,\n onValueChange,\n selectedItem,\n setValue,\n name,\n required,\n fieldId,\n } = useSelectContext()\n\n const handleChange = (event: ChangeEvent<HTMLSelectElement>) => {\n if (isControlled) {\n event.preventDefault()\n onValueChange?.(event.target.value)\n } else {\n setValue(event.target.value)\n }\n }\n\n return (\n <select\n data-spark-component=\"select-items\"\n ref={ref}\n disabled={disabled || readOnly}\n name={name}\n required={required}\n aria-labelledby={fieldLabelId}\n {...(ariaLabel && { 'aria-label': ariaLabel })}\n className={styles({ className, state, disabled, readOnly })}\n value={selectedItem?.value}\n onChange={handleChange}\n id={fieldId}\n {...rest}\n >\n {children}\n </select>\n )\n}\n\nItems.displayName = 'Select.Items'\n","import { useEffect } from 'react'\n\nimport { useSelectGroupContext } from './SelectItemsGroupContext'\n\ninterface LabelProps {\n children: string\n}\n\nexport const Label = ({ children }: LabelProps) => {\n const { setGroupLabel } = useSelectGroupContext()\n\n useEffect(() => {\n setGroupLabel(children)\n }, [children])\n\n return null\n}\n\nLabel.displayName = 'Select.Label'\n","import { ReactElement } from 'react'\n\nimport { Icon } from '../icon'\n\nexport const LeadingIcon = ({ children }: { children: ReactElement }) => {\n return (\n <Icon size={'sm'} className=\"shrink-0\">\n {children}\n </Icon>\n )\n}\n\nLeadingIcon.displayName = 'Select.LeadingIcon'\n","import { type Ref, useEffect } from 'react'\n\nimport { useSelectContext } from './SelectContext'\n\nexport interface PlaceholderProps {\n disabled?: boolean\n children: string\n ref?: Ref<HTMLOptionElement>\n}\n\nexport const Placeholder = ({\n disabled = false,\n children,\n ref: forwardedRef,\n}: PlaceholderProps) => {\n const { setPlaceholder } = useSelectContext()\n\n useEffect(() => {\n setPlaceholder(children)\n }, [children])\n\n return (\n <option\n data-spark-component=\"select-placeholder\"\n ref={forwardedRef}\n key=\"placeholder\"\n value=\"\"\n disabled={disabled}\n >\n {children}\n </option>\n )\n}\n\nPlaceholder.displayName = 'Select.Placeholder'\n","import { cva } from 'class-variance-authority'\n\nexport const styles = cva(\n [\n 'relative flex w-full items-center justify-between',\n 'min-h-sz-44 rounded-lg px-lg',\n 'text-body-1',\n // outline styles\n 'ring-1 outline-hidden ring-inset focus-within:ring-focus',\n ],\n {\n variants: {\n state: {\n undefined: 'ring-outline',\n error: 'ring-error',\n alert: 'ring-alert',\n success: 'ring-success',\n },\n disabled: {\n false: 'focus-within:ring-2',\n },\n readOnly: {\n true: '',\n },\n },\n compoundVariants: [\n {\n readOnly: false,\n disabled: false,\n class: 'bg-surface text-on-surface',\n },\n {\n readOnly: true,\n class: 'bg-on-surface/dim-5 text-on-surface cursor-default',\n },\n {\n disabled: true,\n class: ['bg-on-surface/dim-5 text-on-surface/dim-3', 'cursor-not-allowed'],\n },\n {\n disabled: false,\n state: undefined,\n class: 'default:hover:ring-outline-high',\n },\n ],\n }\n)\n","import { ArrowHorizontalDown } from '@spark-ui/icons/ArrowHorizontalDown'\nimport { ReactNode, type Ref, useEffect } from 'react'\n\nimport { Icon } from '../icon'\nimport { useSelectContext } from './SelectContext'\nimport { styles } from './SelectTrigger.styles'\n\ninterface TriggerProps {\n 'aria-label'?: string\n children: ReactNode\n className?: string\n ref?: Ref<HTMLDivElement>\n}\n\n/**\n * This trigger acts as a fake button for the `select` tag.\n * It is not interactive.\n */\nexport const Trigger = ({\n 'aria-label': ariaLabel,\n children,\n className,\n ref: forwardedRef,\n}: TriggerProps) => {\n const { disabled, readOnly, state, setAriaLabel, itemsComponent } = useSelectContext()\n\n useEffect(() => {\n if (ariaLabel) {\n setAriaLabel(ariaLabel)\n }\n }, [ariaLabel])\n\n return (\n <div\n data-spark-component=\"select-trigger\"\n ref={forwardedRef}\n className={styles({ className, state, disabled, readOnly })}\n >\n <span className=\"gap-md flex items-center justify-start\">{children}</span>\n\n <Icon className=\"ml-md shrink-0\" size=\"sm\">\n <ArrowHorizontalDown />\n </Icon>\n\n {itemsComponent}\n </div>\n )\n}\n\nTrigger.displayName = 'Select.Trigger'\n","import { cx } from 'class-variance-authority'\nimport { ReactNode, type Ref } from 'react'\n\nimport { useSelectContext } from './SelectContext'\n\nexport interface ValueProps {\n children?: ReactNode\n className?: string\n /**\n * Optional placeholder value for the trigger.\n * If not specified, the value inside `Select.Placeholder` item will be used.\n */\n placeholder?: string\n ref?: Ref<HTMLSpanElement>\n}\n\nexport const Value = ({\n children,\n className,\n placeholder: customPlaceholder,\n ref: forwardedRef,\n}: ValueProps) => {\n const { selectedItem, placeholder, disabled } = useSelectContext()\n\n const isPlaceholderSelected = selectedItem?.value == null\n const valuePlaceholder = customPlaceholder || placeholder\n\n return (\n <span\n role=\"presentation\"\n data-spark-component=\"select-value\"\n ref={forwardedRef}\n className={cx('flex shrink items-center text-left', className)}\n >\n <span\n className={cx(\n 'line-clamp-1 flex-1 overflow-hidden break-all text-ellipsis',\n isPlaceholderSelected && !disabled && 'text-on-surface/dim-1'\n )}\n >\n {isPlaceholderSelected ? valuePlaceholder : children || selectedItem?.text}\n </span>\n </span>\n )\n}\n\nValue.displayName = 'Select.Value'\n","import { Select as Root } from './Select'\nimport { SelectProvider, useSelectContext } from './SelectContext'\nimport { Group } from './SelectGroup'\nimport { Item } from './SelectItem'\nimport { Items } from './SelectItems'\nimport { Label } from './SelectLabel'\nimport { LeadingIcon } from './SelectLeadingIcon'\nimport { Placeholder } from './SelectPlaceholder'\nimport { Trigger } from './SelectTrigger'\nimport { Value } from './SelectValue'\n\nexport { useSelectContext, SelectProvider }\n\nexport const Select: typeof Root & {\n Group: typeof Group\n Item: typeof Item\n Items: typeof Items\n Placeholder: typeof Placeholder\n Label: typeof Label\n Trigger: typeof Trigger\n Value: typeof Value\n LeadingIcon: typeof LeadingIcon\n} = Object.assign(Root, {\n Group,\n Item,\n Items,\n Placeholder,\n Label,\n Trigger,\n Value,\n LeadingIcon,\n})\n\nSelect.displayName = 'Select'\nGroup.displayName = 'Select.Group'\nItems.displayName = 'Select.Items'\nItem.displayName = 'Select.Item'\nPlaceholder.displayName = 'Select.Placeholder'\nLabel.displayName = 'Select.Label'\nTrigger.displayName = 'Select.Trigger'\nValue.displayName = 'Select.Value'\nLeadingIcon.displayName = 'Select.LeadingIcon'\n"],"names":["findElement","children","name","Children","isValidElement","child","getElementDisplayName","element","getOrderedItems","result","childProps","getItemsFromChildren","newMap","itemData","SelectContext","createContext","ID_PREFIX","SelectProvider","defaultValue","valueProp","onValueChange","disabledProp","readOnlyProp","stateProp","itemsComponent","nameProp","requiredProp","value","setValue","useCombinedState","placeholder","setPlaceholder","useState","itemsMap","setItemsMap","ariaLabel","setAriaLabel","firstItem","selectedItem","isControlled","field","useFormFieldControl","state","internalFieldID","useId","fieldId","fieldLabelId","disabled","readOnly","required","useEffect","previousItems","newItems","item","index","hasUpdatedValue","hasUpdatedText","jsx","useSelectContext","context","useContext","Select","props","finder","trigger","items","SelectGroupContext","SelectGroupProvider","groupLabel","setGroupLabel","useSelectGroupContext","Group","forwardedRef","GroupContent","className","cx","Item","styles","cva","Items","ref","rest","handleChange","event","Label","LeadingIcon","Icon","Placeholder","Trigger","jsxs","ArrowHorizontalDown","Value","customPlaceholder","isPlaceholderSelected","valuePlaceholder","Root"],"mappings":";;;;;;;AAKO,MAAMA,KAAc,CAACC,MAAwB,CAACC,MAC7BC,EAAS,QAAQF,CAAQ,EAAE,OAAOG,CAAc,EAEjD,KAAK,CAAAC,MACjBC,EAAsBD,CAAK,GAAG,SAASH,CAAI,CACnD,GAGGI,IAAwB,CAACC,MACtBA,IAAWA,EAAQ,KAAuC,cAAc,IAG3EC,IAAkB,CAACP,GAAqBQ,IAAuB,QACnEN,EAAS,QAAQF,GAAU,CAAAI,MAAS;AAClC,MAAKD,EAAeC,CAAK,GAEzB;AAAA,QACEC,EAAsBD,CAAK,MAAM,iBACjCC,EAAsBD,CAAK,MAAM,sBACjC;AACA,YAAMK,IAAaL,EAAM;AACzB,MAAAI,EAAO,KAAK;AAAA,QACV,OAAOC,EAAW;AAAA,QAClB,UAAU,CAAC,CAACA,EAAW;AAAA,QACvB,MAAMA,EAAW;AAAA,MAAA,CAClB;AAAA,IACH;AAEA,IAAKL,EAAM,MAAkC,YAC3CG,EAAiBH,EAAM,MAAkC,UAAUI,CAAM;AAAA;AAE7E,CAAC,GAEMA,IAGIE,IAAuB,CAACV,MAAkC;AACrE,QAAMW,wBAAuB,IAAA;AAE7B,SAAAJ,EAAgBP,CAAQ,EAAE,QAAQ,CAAAY,MAAY;AAC5C,IAAAD,EAAO,IAAIC,EAAS,OAAOA,CAAQ;AAAA,EACrC,CAAC,GAEMD;AACT,GC0BME,IAAgBC,EAAyC,IAAI,GAE7DC,KAAY,WAELC,KAAiB,CAAC;AAAA,EAC7B,UAAAhB;AAAA,EACA,cAAAiB;AAAA,EACA,OAAOC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AAGN;AAEAqD,EAAM,cAAc;ACjCb,MAAM9B,KAST,OAAO,OAAOkC,GAAM;AAAA,EACtB,OAAAxB;AAAA,EACA,MAAAK;AAAA,EACA,OAAAG;AAAA,EACA,aAAAQ;AAAA,EACA,OAAAH;AAAA,EACA,SAAAI;AAAA,EACA,OAAAG;AAAA,EACA,aAAAN;AACF,CAAC;AAEDxB,GAAO,cAAc;AACrBU,EAAM,cAAc;AACpBQ,EAAM,cAAc;AACpBH,EAAK,cAAc;AACnBW,EAAY,cAAc;AAC1BH,EAAM,cAAc;AACpBI,EAAQ,cAAc;AACtBG,EAAM,cAAc;AACpBN,EAAY,cAAc;"}
1
+ {"version":3,"file":"index.mjs","sources":["../../src/select/utils.ts","../../src/select/SelectContext.tsx","../../src/select/Select.tsx","../../src/select/SelectItemsGroupContext.tsx","../../src/select/SelectGroup.tsx","../../src/select/SelectItem.tsx","../../src/select/SelectItems.tsx","../../src/select/SelectLabel.tsx","../../src/select/SelectLeadingIcon.tsx","../../src/select/SelectPlaceholder.tsx","../../src/select/SelectTrigger.styles.tsx","../../src/select/SelectTrigger.tsx","../../src/select/SelectValue.tsx","../../src/select/index.ts"],"sourcesContent":["import { Children, type FC, isValidElement, type ReactElement, type ReactNode } from 'react'\n\nimport { type ItemProps } from './SelectItem'\nimport { type ItemsMap, type SelectItem } from './types'\n\nexport const findElement = (children: ReactNode) => (name: string) => {\n const validChildren = Children.toArray(children).filter(isValidElement)\n\n return validChildren.find(child => {\n return getElementDisplayName(child)?.includes(name)\n })\n}\n\nconst getElementDisplayName = (element?: ReactElement) => {\n return element ? (element.type as FC & { displayName?: string }).displayName : ''\n}\n\nconst getOrderedItems = (children: ReactNode, result: SelectItem[] = []): SelectItem[] => {\n Children.forEach(children, child => {\n if (!isValidElement(child)) return\n\n if (\n getElementDisplayName(child) === 'Select.Item' ||\n getElementDisplayName(child) === 'Select.Placeholder'\n ) {\n const childProps = child.props as ItemProps\n result.push({\n value: childProps.value,\n disabled: !!childProps.disabled,\n text: childProps.children,\n })\n }\n\n if ((child.props as { children: ReactNode }).children) {\n getOrderedItems((child.props as { children: ReactNode }).children, result)\n }\n })\n\n return result\n}\n\nexport const getItemsFromChildren = (children: ReactNode): ItemsMap => {\n const newMap: ItemsMap = new Map()\n\n getOrderedItems(children).forEach(itemData => {\n newMap.set(itemData.value, itemData)\n })\n\n return newMap\n}\n","import { useFormFieldControl } from '@spark-ui/components/form-field'\nimport { useCombinedState } from '@spark-ui/hooks/use-combined-state'\nimport {\n createContext,\n Dispatch,\n PropsWithChildren,\n ReactElement,\n SetStateAction,\n useContext,\n useEffect,\n useId,\n useState,\n} from 'react'\n\nimport { type ItemsMap, SelectItem } from './types'\nimport { getItemsFromChildren } from './utils'\n\nexport interface SelectContextState {\n itemsMap: ItemsMap\n disabled: boolean\n readOnly: boolean\n state?: 'error' | 'alert' | 'success'\n itemsComponent: ReactElement | undefined\n selectedItem: SelectItem | undefined\n setValue: (value: string) => void\n isControlled: boolean\n onValueChange?: (value: string) => void\n ariaLabel: string | undefined\n setAriaLabel: Dispatch<SetStateAction<string | undefined>>\n fieldId: string\n fieldLabelId: string | undefined\n name: string | undefined\n required: boolean\n placeholder: string | undefined\n setPlaceholder: Dispatch<SetStateAction<string | undefined>>\n}\n\nexport type SelectContextProps = PropsWithChildren<{\n /**\n * Use `state` prop to assign a specific state to the select, choosing from: `error`, `alert` and `success`. By doing so, the outline styles will be updated.\n */\n state?: 'error' | 'alert' | 'success'\n /**\n * When true, prevents the user from interacting with the select.\n */\n disabled?: boolean\n /**\n * Sets the select as interactive or not.\n */\n readOnly?: boolean\n /**\n * The value of the select when initially rendered. Use when you do not need to control the state of the select.\n */\n defaultValue?: string\n /**\n * The controlled value of the select. Should be used in conjunction with `onValueChange`.\n */\n value?: string\n /**\n * Event handler called when the value changes.\n */\n onValueChange?: (value: string) => void\n\n itemsComponent: ReactElement | undefined\n /**\n * This attribute is used to specify the name of the control.\n * If wrapped with a FormField with a name, will be inherited from it.\n */\n name?: string\n /**\n * A Boolean attribute indicating that an option with a non-empty string value must be selected.\n */\n required?: boolean\n}>\n\nconst SelectContext = createContext<SelectContextState | null>(null)\n\nconst ID_PREFIX = ':select'\n\nexport const SelectProvider = ({\n children,\n defaultValue,\n value: valueProp,\n onValueChange,\n disabled: disabledProp = false,\n readOnly: readOnlyProp = false,\n state: stateProp,\n itemsComponent,\n name: nameProp,\n required: requiredProp,\n}: SelectContextProps) => {\n const [value, setValue] = useCombinedState(valueProp, defaultValue, onValueChange)\n const [placeholder, setPlaceholder] = useState<string | undefined>(undefined)\n const [itemsMap, setItemsMap] = useState<ItemsMap>(getItemsFromChildren(itemsComponent))\n const [ariaLabel, setAriaLabel] = useState<string>()\n\n // Computed state\n const firstItem = itemsMap.entries().next()?.value?.[1]\n const selectedItem = typeof value === 'string' ? itemsMap.get(value) : firstItem\n const isControlled = valueProp != null\n\n // Derivated from FormField context\n const field = useFormFieldControl()\n const state = field.state || stateProp\n\n const internalFieldID = `${ID_PREFIX}-field-${useId()}`\n const fieldId = field.id || internalFieldID\n const fieldLabelId = field.labelId\n const disabled = field.disabled ?? disabledProp\n const readOnly = field.readOnly ?? readOnlyProp\n const name = field.name ?? nameProp\n const required = !!(field.isRequired ?? requiredProp)\n\n /**\n * Indices in a Map are set when an element is added to the Map.\n * If for some reason, in the Select:\n * - items order changes\n * - items are added\n * - items are removed\n *\n * The Map must be rebuilt from the new children in order to preserve logical indices.\n *\n */\n useEffect(() => {\n const newMap = getItemsFromChildren(itemsComponent)\n\n const previousItems = [...itemsMap.values()]\n const newItems = [...newMap.values()]\n\n const hasItemsChanges =\n previousItems.length !== newItems.length ||\n previousItems.some((item, index) => {\n const hasUpdatedValue = item.value !== newItems[index]?.value\n const hasUpdatedText = item.text !== newItems[index]?.text\n\n return hasUpdatedValue || hasUpdatedText\n })\n\n if (hasItemsChanges) {\n setItemsMap(newMap)\n }\n }, [children])\n\n return (\n <SelectContext.Provider\n value={{\n disabled,\n readOnly,\n itemsMap,\n state,\n itemsComponent,\n selectedItem,\n setValue,\n isControlled,\n onValueChange,\n ariaLabel,\n setAriaLabel,\n fieldId,\n fieldLabelId,\n name,\n required,\n placeholder,\n setPlaceholder,\n }}\n >\n {children}\n </SelectContext.Provider>\n )\n}\n\nexport const useSelectContext = () => {\n const context = useContext(SelectContext)\n\n if (!context) {\n throw Error('useSelectContext must be used within a Select provider')\n }\n\n return context\n}\n","import { type SelectContextProps, SelectProvider } from './SelectContext'\nimport { findElement } from './utils'\n\nexport type SelectProps = Omit<SelectContextProps, 'itemsComponent'>\n\nexport const Select = ({ children, ...props }: SelectProps) => {\n const finder = findElement(children)\n const trigger = finder('Trigger')\n const items = finder('Items')\n\n return (\n <SelectProvider {...props} itemsComponent={items}>\n {trigger}\n </SelectProvider>\n )\n}\n\nSelect.displayName = 'Select'\n","import { createContext, type PropsWithChildren, useContext, useState } from 'react'\n\nexport interface SelectContextState {\n groupLabel: string\n setGroupLabel: (label: string) => void\n}\n\ntype SelectContextProps = PropsWithChildren\n\nconst SelectGroupContext = createContext<SelectContextState | null>(null)\n\nexport const SelectGroupProvider = ({ children }: SelectContextProps) => {\n const [groupLabel, setGroupLabel] = useState('')\n\n return (\n <SelectGroupContext.Provider value={{ groupLabel, setGroupLabel }}>\n {children}\n </SelectGroupContext.Provider>\n )\n}\n\nexport const useSelectGroupContext = () => {\n const context = useContext(SelectGroupContext)\n\n if (!context) {\n throw Error('useSelectGroupContext must be used within a SelectGroup provider')\n }\n\n return context\n}\n","import { cx } from 'class-variance-authority'\nimport { ReactNode, type Ref } from 'react'\n\nimport { SelectGroupProvider, useSelectGroupContext } from './SelectItemsGroupContext'\n\ninterface GroupProps {\n children: ReactNode\n className?: string\n ref?: Ref<HTMLOptGroupElement>\n}\n\nexport const Group = ({ children, ref: forwardedRef, ...props }: GroupProps) => {\n return (\n <SelectGroupProvider>\n <GroupContent ref={forwardedRef} {...props}>\n {children}\n </GroupContent>\n </SelectGroupProvider>\n )\n}\n\nconst GroupContent = ({ children, className, ref: forwardedRef }: GroupProps) => {\n const { groupLabel } = useSelectGroupContext()\n\n return (\n <optgroup\n data-spark-component=\"select-group\"\n ref={forwardedRef}\n className={cx(className)}\n label={groupLabel}\n >\n {children}\n </optgroup>\n )\n}\n\nGroup.displayName = 'Select.Group'\n","import { type Ref } from 'react'\n\nexport interface ItemProps {\n disabled?: boolean\n value: string\n children: string\n ref?: Ref<HTMLOptionElement>\n}\n\nexport const Item = ({ disabled = false, value, children, ref: forwardedRef }: ItemProps) => {\n return (\n <option\n data-spark-component=\"select-item\"\n ref={forwardedRef}\n key={value}\n value={value}\n disabled={disabled}\n // label\n >\n {children}\n </option>\n )\n}\n\nItem.displayName = 'Select.Item'\n","import { cva } from 'class-variance-authority'\nimport { ChangeEvent, ComponentPropsWithRef, PropsWithChildren } from 'react'\n\nimport { useSelectContext } from './SelectContext'\n\nexport const styles = cva(\n [\n 'absolute left-0 top-0 size-full rounded-lg opacity-0',\n 'min-h-sz-44',\n // outline styles\n 'ring-1 outline-hidden ring-inset focus:ring-2',\n ],\n {\n variants: {\n state: {\n undefined: 'ring-outline focus:ring-outline-high',\n error: 'ring-error',\n alert: 'ring-alert',\n success: 'ring-success',\n },\n disabled: {\n true: 'cursor-not-allowed',\n },\n readOnly: {\n true: 'cursor-default',\n },\n },\n compoundVariants: [\n {\n disabled: false,\n state: undefined,\n class: 'hover:ring-outline-high',\n },\n ],\n }\n)\n\nexport const Items = ({\n children,\n className,\n ref,\n ...rest\n}: PropsWithChildren<ComponentPropsWithRef<'select'>>) => {\n const {\n state,\n disabled,\n readOnly,\n ariaLabel,\n fieldLabelId,\n isControlled,\n onValueChange,\n selectedItem,\n setValue,\n name,\n required,\n fieldId,\n } = useSelectContext()\n\n const handleChange = (event: ChangeEvent<HTMLSelectElement>) => {\n if (isControlled) {\n event.preventDefault()\n onValueChange?.(event.target.value)\n } else {\n setValue(event.target.value)\n }\n }\n\n return (\n <select\n data-spark-component=\"select-items\"\n ref={ref}\n disabled={disabled || readOnly}\n name={name}\n required={required}\n aria-labelledby={fieldLabelId}\n {...(ariaLabel && { 'aria-label': ariaLabel })}\n className={styles({ className, state, disabled, readOnly })}\n value={selectedItem?.value}\n onChange={handleChange}\n id={fieldId}\n {...rest}\n >\n {children}\n </select>\n )\n}\n\nItems.displayName = 'Select.Items'\n","import { useEffect } from 'react'\n\nimport { useSelectGroupContext } from './SelectItemsGroupContext'\n\ninterface LabelProps {\n children: string\n}\n\nexport const Label = ({ children }: LabelProps) => {\n const { setGroupLabel } = useSelectGroupContext()\n\n useEffect(() => {\n setGroupLabel(children)\n }, [children])\n\n return null\n}\n\nLabel.displayName = 'Select.Label'\n","import { ReactElement } from 'react'\n\nimport { Icon } from '../icon'\n\nexport const LeadingIcon = ({ children }: { children: ReactElement }) => {\n return (\n <Icon size={'sm'} className=\"shrink-0\">\n {children}\n </Icon>\n )\n}\n\nLeadingIcon.displayName = 'Select.LeadingIcon'\n","import { type Ref, useEffect } from 'react'\n\nimport { useSelectContext } from './SelectContext'\n\nexport interface PlaceholderProps {\n disabled?: boolean\n children: string\n ref?: Ref<HTMLOptionElement>\n}\n\nexport const Placeholder = ({\n disabled = false,\n children,\n ref: forwardedRef,\n}: PlaceholderProps) => {\n const { setPlaceholder } = useSelectContext()\n\n useEffect(() => {\n setPlaceholder(children)\n }, [children])\n\n return (\n <option\n data-spark-component=\"select-placeholder\"\n ref={forwardedRef}\n key=\"placeholder\"\n value=\"\"\n disabled={disabled}\n >\n {children}\n </option>\n )\n}\n\nPlaceholder.displayName = 'Select.Placeholder'\n","import { cva } from 'class-variance-authority'\n\nexport const styles = cva(\n [\n 'relative flex w-full items-center justify-between',\n 'min-h-sz-44 rounded-full px-lg',\n 'text-body-1',\n // outline styles\n 'ring-1 outline-hidden ring-inset focus-within:ring-focus',\n ],\n {\n variants: {\n state: {\n undefined: 'ring-outline',\n error: 'ring-error',\n alert: 'ring-alert',\n success: 'ring-success',\n },\n disabled: {\n false: 'focus-within:ring-2',\n },\n readOnly: {\n true: '',\n },\n },\n compoundVariants: [\n {\n readOnly: false,\n disabled: false,\n class: 'bg-surface text-on-surface',\n },\n {\n readOnly: true,\n class: 'bg-on-surface/dim-5 text-on-surface cursor-default',\n },\n {\n disabled: true,\n class: ['bg-on-surface/dim-5 text-on-surface/dim-3', 'cursor-not-allowed'],\n },\n {\n disabled: false,\n state: undefined,\n class: 'default:hover:ring-outline-high',\n },\n ],\n }\n)\n","import { ArrowHorizontalDown } from '@spark-ui/icons/ArrowHorizontalDown'\nimport { ReactNode, type Ref, useEffect } from 'react'\n\nimport { Icon } from '../icon'\nimport { useSelectContext } from './SelectContext'\nimport { styles } from './SelectTrigger.styles'\n\ninterface TriggerProps {\n 'aria-label'?: string\n children: ReactNode\n className?: string\n ref?: Ref<HTMLDivElement>\n}\n\n/**\n * This trigger acts as a fake button for the `select` tag.\n * It is not interactive.\n */\nexport const Trigger = ({\n 'aria-label': ariaLabel,\n children,\n className,\n ref: forwardedRef,\n}: TriggerProps) => {\n const { disabled, readOnly, state, setAriaLabel, itemsComponent } = useSelectContext()\n\n useEffect(() => {\n if (ariaLabel) {\n setAriaLabel(ariaLabel)\n }\n }, [ariaLabel])\n\n return (\n <div\n data-spark-component=\"select-trigger\"\n ref={forwardedRef}\n className={styles({ className, state, disabled, readOnly })}\n >\n <span className=\"gap-md flex items-center justify-start\">{children}</span>\n\n <Icon className=\"ml-md shrink-0\" size=\"sm\">\n <ArrowHorizontalDown />\n </Icon>\n\n {itemsComponent}\n </div>\n )\n}\n\nTrigger.displayName = 'Select.Trigger'\n","import { cx } from 'class-variance-authority'\nimport { ReactNode, type Ref } from 'react'\n\nimport { useSelectContext } from './SelectContext'\n\nexport interface ValueProps {\n children?: ReactNode\n className?: string\n /**\n * Optional placeholder value for the trigger.\n * If not specified, the value inside `Select.Placeholder` item will be used.\n */\n placeholder?: string\n ref?: Ref<HTMLSpanElement>\n}\n\nexport const Value = ({\n children,\n className,\n placeholder: customPlaceholder,\n ref: forwardedRef,\n}: ValueProps) => {\n const { selectedItem, placeholder, disabled } = useSelectContext()\n\n const isPlaceholderSelected = selectedItem?.value == null\n const valuePlaceholder = customPlaceholder || placeholder\n\n return (\n <span\n role=\"presentation\"\n data-spark-component=\"select-value\"\n ref={forwardedRef}\n className={cx('flex shrink items-center text-left', className)}\n >\n <span\n className={cx(\n 'line-clamp-1 flex-1 overflow-hidden break-all text-ellipsis',\n isPlaceholderSelected && !disabled && 'text-on-surface/dim-1'\n )}\n >\n {isPlaceholderSelected ? valuePlaceholder : children || selectedItem?.text}\n </span>\n </span>\n )\n}\n\nValue.displayName = 'Select.Value'\n","import { Select as Root } from './Select'\nimport { SelectProvider, useSelectContext } from './SelectContext'\nimport { Group } from './SelectGroup'\nimport { Item } from './SelectItem'\nimport { Items } from './SelectItems'\nimport { Label } from './SelectLabel'\nimport { LeadingIcon } from './SelectLeadingIcon'\nimport { Placeholder } from './SelectPlaceholder'\nimport { Trigger } from './SelectTrigger'\nimport { Value } from './SelectValue'\n\nexport { useSelectContext, SelectProvider }\n\nexport const Select: typeof Root & {\n Group: typeof Group\n Item: typeof Item\n Items: typeof Items\n Placeholder: typeof Placeholder\n Label: typeof Label\n Trigger: typeof Trigger\n Value: typeof Value\n LeadingIcon: typeof LeadingIcon\n} = Object.assign(Root, {\n Group,\n Item,\n Items,\n Placeholder,\n Label,\n Trigger,\n Value,\n LeadingIcon,\n})\n\nSelect.displayName = 'Select'\nGroup.displayName = 'Select.Group'\nItems.displayName = 'Select.Items'\nItem.displayName = 'Select.Item'\nPlaceholder.displayName = 'Select.Placeholder'\nLabel.displayName = 'Select.Label'\nTrigger.displayName = 'Select.Trigger'\nValue.displayName = 'Select.Value'\nLeadingIcon.displayName = 'Select.LeadingIcon'\n"],"names":["findElement","children","name","Children","isValidElement","child","getElementDisplayName","element","getOrderedItems","result","childProps","getItemsFromChildren","newMap","itemData","SelectContext","createContext","ID_PREFIX","SelectProvider","defaultValue","valueProp","onValueChange","disabledProp","readOnlyProp","stateProp","itemsComponent","nameProp","requiredProp","value","setValue","useCombinedState","placeholder","setPlaceholder","useState","itemsMap","setItemsMap","ariaLabel","setAriaLabel","firstItem","selectedItem","isControlled","field","useFormFieldControl","state","internalFieldID","useId","fieldId","fieldLabelId","disabled","readOnly","required","useEffect","previousItems","newItems","item","index","hasUpdatedValue","hasUpdatedText","jsx","useSelectContext","context","useContext","Select","props","finder","trigger","items","SelectGroupContext","SelectGroupProvider","groupLabel","setGroupLabel","useSelectGroupContext","Group","forwardedRef","GroupContent","className","cx","Item","styles","cva","Items","ref","rest","handleChange","event","Label","LeadingIcon","Icon","Placeholder","Trigger","jsxs","ArrowHorizontalDown","Value","customPlaceholder","isPlaceholderSelected","valuePlaceholder","Root"],"mappings":";;;;;;;AAKO,MAAMA,KAAc,CAACC,MAAwB,CAACC,MAC7BC,EAAS,QAAQF,CAAQ,EAAE,OAAOG,CAAc,EAEjD,KAAK,CAAAC,MACjBC,EAAsBD,CAAK,GAAG,SAASH,CAAI,CACnD,GAGGI,IAAwB,CAACC,MACtBA,IAAWA,EAAQ,KAAuC,cAAc,IAG3EC,IAAkB,CAACP,GAAqBQ,IAAuB,QACnEN,EAAS,QAAQF,GAAU,CAAAI,MAAS;AAClC,MAAKD,EAAeC,CAAK,GAEzB;AAAA,QACEC,EAAsBD,CAAK,MAAM,iBACjCC,EAAsBD,CAAK,MAAM,sBACjC;AACA,YAAMK,IAAaL,EAAM;AACzB,MAAAI,EAAO,KAAK;AAAA,QACV,OAAOC,EAAW;AAAA,QAClB,UAAU,CAAC,CAACA,EAAW;AAAA,QACvB,MAAMA,EAAW;AAAA,MAAA,CAClB;AAAA,IACH;AAEA,IAAKL,EAAM,MAAkC,YAC3CG,EAAiBH,EAAM,MAAkC,UAAUI,CAAM;AAAA;AAE7E,CAAC,GAEMA,IAGIE,IAAuB,CAACV,MAAkC;AACrE,QAAMW,wBAAuB,IAAA;AAE7B,SAAAJ,EAAgBP,CAAQ,EAAE,QAAQ,CAAAY,MAAY;AAC5C,IAAAD,EAAO,I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AA,UACC,WAAWkB;AAAA,YACT;AAAA,YACAkB,KAAyB,CAAC9C,KAAY;AAAA,UAAA;AAAA,UAGvC,UAAA8C,IAAwBC,IAAmB7F,KAAYqC,GAAc;AAAA,QAAA;AAAA,MAAA;AAAA,IACxE;AAAA,EAAA;AAGN;AAEAqD,EAAM,cAAc;ACjCb,MAAM9B,KAST,OAAO,OAAOkC,GAAM;AAAA,EACtB,OAAAxB;AAAA,EACA,MAAAK;AAAA,EACA,OAAAG;AAAA,EACA,aAAAQ;AAAA,EACA,OAAAH;AAAA,EACA,SAAAI;AAAA,EACA,OAAAG;AAAA,EACA,aAAAN;AACF,CAAC;AAEDxB,GAAO,cAAc;AACrBU,EAAM,cAAc;AACpBQ,EAAM,cAAc;AACpBH,EAAK,cAAc;AACnBW,EAAY,cAAc;AAC1BH,EAAM,cAAc;AACpBI,EAAQ,cAAc;AACtBG,EAAM,cAAc;AACpBN,EAAY,cAAc;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("react/jsx-runtime"),O=require("@react-stately/toast"),c=require("react"),tt=require("react-dom"),T=require("@react-aria/toast"),S=require("class-variance-authority"),et=require("../Button-FZceRWG2.js"),nt=require("@spark-ui/icons/Close"),D=require("../Icon-C-cNTnzd.js"),at=require("../IconButton-BR1bJSQA.js"),it=[{design:"filled",intent:"success",class:["bg-success text-on-success"]},{design:"filled",intent:"alert",class:["bg-alert text-on-alert"]},{design:"filled",intent:"error",class:["bg-error text-on-error"]},{design:"filled",intent:"info",class:["bg-info text-on-info"]},{design:"filled",intent:"neutral",class:["bg-neutral text-on-neutral"]},{design:"filled",intent:"main",class:["bg-main text-on-main"]},{design:"filled",intent:"support",class:["bg-support text-on-support"]},{design:"filled",intent:"accent",class:["bg-accent text-on-accent"]},{design:"filled",intent:"inverse",class:["bg-surface-inverse text-on-surface-inverse"]}],ot=[{design:"tinted",intent:"success",class:["bg-success-container text-on-success-container"]},{design:"tinted",intent:"alert",class:["bg-alert-container text-on-alert-container"]},{design:"tinted",intent:"error",class:["bg-error-container text-on-error-container"]},{design:"tinted",intent:"info",class:["bg-info-container text-on-info-container"]},{design:"tinted",intent:"neutral",class:["bg-neutral-container text-on-neutral-container"]},{design:"tinted",intent:"main",class:["bg-main-container text-on-main-container"]},{design:"tinted",intent:"support",class:["bg-support-container text-on-support-container"]},{design:"tinted",intent:"accent",class:["bg-accent-container text-on-accent-container"]},{design:"tinted",intent:"inverse",class:["bg-surface-inverse text-on-surface-inverse"]}],st=S.cva(["rounded-md shadow-sm","max-w-[600px]","cursor-default pointer-events-auto touch-none select-none","absolute","group-focus-visible:outline-hidden group-focus-visible:u-outline group-not-focus-visible:ring-inset","group-data-[position=bottom]:bottom-0 group-data-[position=bottom-left]:bottom-0 group-data-[position=bottom-right]:bottom-0","group-data-[position=top]:top-0 group-data-[position=top-left]:top-0 group-data-[position=top-right]:top-0","animation-duration-400","[animation-fill-mode: forwards]!","data-[animation=queued]:animate-fade-in","data-[animation=entering]:animation-ease-decelerate-back","data-[animation=exiting]:animation-ease-accelerate","data-[animation=entering]:group-data-[position=bottom]:[&:not([data-swipe])]:animate-slide-in-bottom","data-[animation=exiting]:opacity-0 data-[animation=exiting]:transition-opacity","data-[animation=exiting]:group-data-[position=bottom]:[&:not([data-swipe])]:animate-slide-out-bottom","data-[animation=entering]:group-data-[position=bottom-left]:[&:not([data-swipe])]:animate-slide-in-bottom","data-[animation=exiting]:group-data-[position=bottom-left]:[&:not([data-swipe])]:animate-slide-out-bottom","data-[animation=entering]:group-data-[position=bottom-right]:[&:not([data-swipe])]:animate-slide-in-bottom","data-[animation=exiting]:group-data-[position=bottom-right]:[&:not([data-swipe])]:animate-slide-out-bottom","data-[animation=entering]:group-data-[position=top]:[&:not([data-swipe])]:animate-slide-in-top","data-[animation=exiting]:group-data-[position=top]:[&:not([data-swipe])]:animate-slide-out-top","data-[animation=entering]:group-data-[position=top-left]:[&:not([data-swipe])]:animate-slide-in-top","data-[animation=exiting]:group-data-[position=top-left]:[&:not([data-swipe])]:animate-slide-out-top","data-[animation=entering]:group-data-[position=top-right]:[&:not([data-swipe])]:animate-slide-in-top","data-[animation=exiting]:group-data-[position=top-right]:[&:not([data-swipe])]:animate-slide-out-top","data-[swipe=move]:data-[swipe-direction=right]:translate-x-(--swipe-position-x)","data-[swipe=move]:data-[swipe-direction=left]:translate-x-(--swipe-position-x)","data-[swipe=cancel]:translate-x-0","data-[swipe=end]:data-[swipe-direction=right]:animate-standalone-swipe-out-right","data-[swipe=end]:data-[swipe-direction=left]:animate-standalone-swipe-out-left"],{variants:{design:{filled:"",tinted:""},intent:{success:"",alert:"",error:"",info:"",neutral:"",main:"",support:"",accent:"",inverse:""}},compoundVariants:[...it,...ot],defaultVariants:{design:"filled",intent:"neutral"}}),rt=S.cva(["inline-grid items-center","col-start-1 row-start-1","pl-md pr-lg"],{variants:{actionOnNewline:{true:["grid-rows-[52px_1fr_52px]","grid-cols-[min-content_1fr_min-content]","[grid-template-areas:'icon_message_close'_'._message_.'_'action_action_action']"],false:["grid-cols-[min-content_1fr_min-content_min-content]","[grid-template-areas:'icon_message_action_close']"]}},defaultVariants:{actionOnNewline:!1}}),Q=c.createContext({}),q=()=>c.useContext(Q),h=({design:t="filled",intent:e="neutral",onClick:n,children:s,className:l,ref:u,...m})=>{const{toast:a,state:o}=q(),i=e??a.content.intent,f=t??a.content.design;return b.jsx(et.Button,{"data-spark-component":"snackbar-item-action",ref:u,size:"md",shape:"rounded",...i==="inverse"?{design:"ghost",intent:"surface"}:{design:f,intent:i==="error"?"danger":i},onClick:y=>{n?.(y),o.close(a.key)},style:{gridArea:"action",...m.style},className:S.cx("ml-md justify-self-end",l),...m,children:s})};h.displayName="Snackbar.ItemAction";const I=({design:t="filled",intent:e="neutral","aria-label":n,onClick:s,className:l,ref:u,...m})=>{const{toast:a,state:o}=q(),i=e??a.content.intent,f=t??a.content.design;return b.jsx(at.IconButton,{"data-spark-component":"snackbar-item-close",ref:u,size:"md",shape:"rounded",...i==="inverse"?{design:"ghost",intent:"surface"}:{design:f,intent:i==="error"?"danger":i},"aria-label":n,onClick:y=>{s?.(y),o.close(a.key)},style:{gridArea:"close",...m.style},className:S.cx("ml-md justify-self-end",l),...m,children:b.jsx(D.Icon,{size:"sm",children:b.jsx(nt.Close,{})})})};I.displayName="Snackbar.ItemClose";const C=({children:t,className:e,...n})=>b.jsx(D.Icon,{size:"md",className:S.cx("mx-md",e),style:{gridArea:"icon",...n.style},...n,children:t});C.displayName="Snackbar.ItemIcon";const V=75,ct=({swipeRef:t,onSwipeStart:e,onSwipeMove:n,onSwipeCancel:s,onSwipeEnd:l,threshold:u=10})=>{const[m,a]=c.useState(),o=c.useRef(null),i=c.useRef(null),f=c.useRef(null),y=r=>{i.current={x:r.clientX,y:r.clientY},document.addEventListener("selectstart",p=>p.preventDefault())},k=r=>{if(!i.current)return;const p=Math.abs(r.clientX-i.current.x),x=Math.abs(r.clientY-i.current.y);let d;p>x&&p>u?o.current=r.clientX>i.current.x?"right":"left":x>u&&(o.current=r.clientY>i.current.y?"down":"up"),o.current&&(f.current?(d="move",f.current={x:p,y:x},t.current.style.setProperty("--swipe-position-x",`${p>x?r.clientX-i.current.x:0}px`),t.current.style.setProperty("--swipe-position-y",`${p>x?0:r.clientY-i.current.y}px`),n?.({state:d,direction:o.current})):(d="start",f.current={x:p,y:x},e?.({state:d,direction:o.current})),a(d))},g=()=>{const r=f.current;if(i.current=null,f.current=null,r){const{x:p,y:x}=r;let d;p>x?p>V?(d="end",l?.({state:d,direction:o.current})):(d="cancel",s?.({state:d,direction:o.current})):x>V?(d="end",l?.({state:d,direction:o.current})):(d="cancel",s?.({state:d,direction:o.current})),a(d),document.removeEventListener("selectstart",v=>v.preventDefault())}};return c.useEffect(()=>{if(!t.current)return;const r=t.current;return r.addEventListener("pointerdown",y),document.addEventListener("pointermove",k),document.addEventListener("pointerup",g),()=>{r.removeEventListener("pointerdown",y),document.removeEventListener("pointermove",k),document.removeEventListener("pointerup",g)}},[]),{state:m,direction:o.current}},A=({"aria-label":t,"aria-labelledby":e,"aria-describedby":n,"aria-details":s,design:l,intent:u,actionOnNewline:m,className:a,children:o,ref:i,...f})=>{const y=c.useRef(null),k=typeof i!="function"&&i||y,{toast:g,state:r}=q(),{state:p,direction:x}=ct({swipeRef:k,onSwipeStart:r.pauseAll,onSwipeCancel:r.resumeAll,onSwipeEnd:({direction:_})=>{["left","right"].includes(`${_}`)&&r.close(g.key)}}),{message:d,icon:v,isClosable:$,onAction:B,actionLabel:R}=g.content,N=u??g.content.intent,j=l??g.content.design,z=m??g.content.actionOnNewline,F={ariaLabel:t,ariaLabelledby:e,ariaDescribedby:n,ariaDetails:s},{toastProps:M,titleProps:G,closeButtonProps:H,contentProps:K}=T.useToast({toast:g,...F},r,k),E=c.useCallback(_=>c.Children.toArray(o).filter(c.isValidElement).find(Z=>!!Z.type.displayName?.includes(_)),[o]),U=E("Snackbar.ItemIcon"),W=E("Snackbar.ItemAction"),J=E("Snackbar.ItemClose");return b.jsx("div",{"data-spark-component":"snackbar-item",className:st({design:j,intent:N,className:a}),"data-animation":g.animation,...!(p==="cancel"&&g.animation==="exiting")&&{"data-swipe":p,"data-swipe-direction":x},...g.animation==="exiting"&&{onAnimationEnd:()=>r.remove(g.key)},ref:k,...M,...f,children:b.jsxs("div",{className:rt({actionOnNewline:z}),...K,children:[P(U,v?C:null,{children:v}),b.jsx("p",{className:"px-md py-lg text-body-2 row-span-3",style:{gridArea:"message"},...G,children:d}),P(W,R&&B?h:null,{intent:N,design:j,onClick:B,children:R}),P(J,$?I:null,{intent:N,design:j,"aria-label":H["aria-label"]})]})})};A.displayName="Snackbar.Item";const P=(t,e,n)=>{if(t)return c.cloneElement(t,{...n,...t.props});if(e){const s=e;return b.jsx(s,{...n})}else return null},lt=S.cva(["fixed inset-x-lg z-toast group","outline-hidden pointer-events-none","grid grid-rows-1 grid-cols-1 gap-lg"],{variants:{position:{top:"top-lg justify-items-center","top-right":"top-lg justify-items-end","top-left":"top-lg justify-items-start",bottom:"bottom-lg justify-items-center","bottom-right":"bottom-lg justify-items-end","bottom-left":"bottom-lg justify-items-start"}},defaultVariants:{position:"bottom"}}),dt=({children:t=b.jsx(A,{}),state:e,position:n="bottom",className:s,ref:l,...u})=>{const m=c.useRef(null),a=l&&typeof l!="function"?l:m,{regionProps:o}=T.useToastRegion(u,e,a);return b.jsx("div",{...o,ref:a,"data-position":n,className:lt({position:n,className:s}),children:e.visibleToasts.map(i=>b.jsx(Q.Provider,{value:{toast:i,state:e},children:c.cloneElement(t,{key:i.key})},i.key))})},ut=({providers:t,subscriptions:e})=>{const n=c.useCallback(a=>(e.add(a),()=>e.delete(a)),[e]),s=c.useCallback(()=>[...t].reverse()[0],[t]),l=c.useCallback(a=>{t.add(a);for(const o of e)o()},[t,e]),u=c.useCallback(a=>{t.delete(a);for(const o of e)o()},[t,e]);return{provider:c.useSyncExternalStore(n,s,s),addProvider:l,deleteProvider:u}};let w=null;const L=()=>(w||(w=new O.ToastQueue({maxVisibleToasts:1,hasExitAnimation:!0})),w),mt=()=>{w=null},pt={providers:new Set,subscriptions:new Set},X=({ref:t,...e})=>{const n=c.useRef(null),s=O.useToastQueue(L()),{provider:l,addProvider:u,deleteProvider:m}=ut(pt);return c.useEffect(()=>(u(n),()=>{for(const a of L().visibleToasts)a.animation=void 0;m(n)}),[]),n===l&&s.visibleToasts.length>0?tt.createPortal(b.jsx(dt,{ref:t,state:s,...e}),document.body):null};X.displayName="Snackbar";const gt=({onClose:t,timeout:e=5e3,priority:n,...s})=>{L().add(s,{onClose:t,timeout:e&&!s.onAction?Math.max(e,5e3):void 0,priority:n})},Y=Object.assign(X,{Item:A,ItemAction:h,ItemClose:I,ItemIcon:C});Y.displayName="Snackbar";A.displayName="Snackbar.Item";h.displayName="Snackbar.ItemAction";I.displayName="Snackbar.ItemClose";C.displayName="Snackbar.ItemIcon";exports.Snackbar=Y;exports.addSnackbar=gt;exports.clearSnackbarQueue=mt;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("react/jsx-runtime"),O=require("@react-stately/toast"),c=require("react"),tt=require("react-dom"),T=require("@react-aria/toast"),S=require("class-variance-authority"),et=require("../Button-CXL2NOrq.js"),nt=require("@spark-ui/icons/Close"),D=require("../Icon-C-cNTnzd.js"),at=require("../IconButton-JFDGiOOn.js"),it=[{design:"filled",intent:"success",class:["bg-success text-on-success"]},{design:"filled",intent:"alert",class:["bg-alert text-on-alert"]},{design:"filled",intent:"error",class:["bg-error text-on-error"]},{design:"filled",intent:"info",class:["bg-info text-on-info"]},{design:"filled",intent:"neutral",class:["bg-neutral text-on-neutral"]},{design:"filled",intent:"main",class:["bg-main text-on-main"]},{design:"filled",intent:"support",class:["bg-support text-on-support"]},{design:"filled",intent:"accent",class:["bg-accent text-on-accent"]},{design:"filled",intent:"inverse",class:["bg-surface-inverse text-on-surface-inverse"]}],ot=[{design:"tinted",intent:"success",class:["bg-success-container text-on-success-container"]},{design:"tinted",intent:"alert",class:["bg-alert-container text-on-alert-container"]},{design:"tinted",intent:"error",class:["bg-error-container text-on-error-container"]},{design:"tinted",intent:"info",class:["bg-info-container text-on-info-container"]},{design:"tinted",intent:"neutral",class:["bg-neutral-container text-on-neutral-container"]},{design:"tinted",intent:"main",class:["bg-main-container text-on-main-container"]},{design:"tinted",intent:"support",class:["bg-support-container text-on-support-container"]},{design:"tinted",intent:"accent",class:["bg-accent-container text-on-accent-container"]},{design:"tinted",intent:"inverse",class:["bg-surface-inverse text-on-surface-inverse"]}],st=S.cva(["rounded-md shadow-sm","max-w-[600px]","cursor-default pointer-events-auto touch-none select-none","absolute","group-focus-visible:outline-hidden group-focus-visible:u-outline group-not-focus-visible:ring-inset","group-data-[position=bottom]:bottom-0 group-data-[position=bottom-left]:bottom-0 group-data-[position=bottom-right]:bottom-0","group-data-[position=top]:top-0 group-data-[position=top-left]:top-0 group-data-[position=top-right]:top-0","animation-duration-400","[animation-fill-mode: forwards]!","data-[animation=queued]:animate-fade-in","data-[animation=entering]:animation-ease-decelerate-back","data-[animation=exiting]:animation-ease-accelerate","data-[animation=entering]:group-data-[position=bottom]:[&:not([data-swipe])]:animate-slide-in-bottom","data-[animation=exiting]:opacity-0 data-[animation=exiting]:transition-opacity","data-[animation=exiting]:group-data-[position=bottom]:[&:not([data-swipe])]:animate-slide-out-bottom","data-[animation=entering]:group-data-[position=bottom-left]:[&:not([data-swipe])]:animate-slide-in-bottom","data-[animation=exiting]:group-data-[position=bottom-left]:[&:not([data-swipe])]:animate-slide-out-bottom","data-[animation=entering]:group-data-[position=bottom-right]:[&:not([data-swipe])]:animate-slide-in-bottom","data-[animation=exiting]:group-data-[position=bottom-right]:[&:not([data-swipe])]:animate-slide-out-bottom","data-[animation=entering]:group-data-[position=top]:[&:not([data-swipe])]:animate-slide-in-top","data-[animation=exiting]:group-data-[position=top]:[&:not([data-swipe])]:animate-slide-out-top","data-[animation=entering]:group-data-[position=top-left]:[&:not([data-swipe])]:animate-slide-in-top","data-[animation=exiting]:group-data-[position=top-left]:[&:not([data-swipe])]:animate-slide-out-top","data-[animation=entering]:group-data-[position=top-right]:[&:not([data-swipe])]:animate-slide-in-top","data-[animation=exiting]:group-data-[position=top-right]:[&:not([data-swipe])]:animate-slide-out-top","data-[swipe=move]:data-[swipe-direction=right]:translate-x-(--swipe-position-x)","data-[swipe=move]:data-[swipe-direction=left]:translate-x-(--swipe-position-x)","data-[swipe=cancel]:translate-x-0","data-[swipe=end]:data-[swipe-direction=right]:animate-standalone-swipe-out-right","data-[swipe=end]:data-[swipe-direction=left]:animate-standalone-swipe-out-left"],{variants:{design:{filled:"",tinted:""},intent:{success:"",alert:"",error:"",info:"",neutral:"",main:"",support:"",accent:"",inverse:""}},compoundVariants:[...it,...ot],defaultVariants:{design:"filled",intent:"neutral"}}),rt=S.cva(["inline-grid items-center","col-start-1 row-start-1","pl-md pr-lg"],{variants:{actionOnNewline:{true:["grid-rows-[52px_1fr_52px]","grid-cols-[min-content_1fr_min-content]","[grid-template-areas:'icon_message_close'_'._message_.'_'action_action_action']"],false:["grid-cols-[min-content_1fr_min-content_min-content]","[grid-template-areas:'icon_message_action_close']"]}},defaultVariants:{actionOnNewline:!1}}),Q=c.createContext({}),q=()=>c.useContext(Q),h=({design:t="filled",intent:e="neutral",onClick:n,children:s,className:l,ref:u,...m})=>{const{toast:a,state:o}=q(),i=e??a.content.intent,f=t??a.content.design;return b.jsx(et.Button,{"data-spark-component":"snackbar-item-action",ref:u,size:"md",shape:"rounded",...i==="inverse"?{design:"ghost",intent:"surface"}:{design:f,intent:i==="error"?"danger":i},onClick:y=>{n?.(y),o.close(a.key)},style:{gridArea:"action",...m.style},className:S.cx("ml-md justify-self-end",l),...m,children:s})};h.displayName="Snackbar.ItemAction";const I=({design:t="filled",intent:e="neutral","aria-label":n,onClick:s,className:l,ref:u,...m})=>{const{toast:a,state:o}=q(),i=e??a.content.intent,f=t??a.content.design;return b.jsx(at.IconButton,{"data-spark-component":"snackbar-item-close",ref:u,size:"md",shape:"rounded",...i==="inverse"?{design:"ghost",intent:"surface"}:{design:f,intent:i==="error"?"danger":i},"aria-label":n,onClick:y=>{s?.(y),o.close(a.key)},style:{gridArea:"close",...m.style},className:S.cx("ml-md justify-self-end",l),...m,children:b.jsx(D.Icon,{size:"sm",children:b.jsx(nt.Close,{})})})};I.displayName="Snackbar.ItemClose";const C=({children:t,className:e,...n})=>b.jsx(D.Icon,{size:"md",className:S.cx("mx-md",e),style:{gridArea:"icon",...n.style},...n,children:t});C.displayName="Snackbar.ItemIcon";const V=75,ct=({swipeRef:t,onSwipeStart:e,onSwipeMove:n,onSwipeCancel:s,onSwipeEnd:l,threshold:u=10})=>{const[m,a]=c.useState(),o=c.useRef(null),i=c.useRef(null),f=c.useRef(null),y=r=>{i.current={x:r.clientX,y:r.clientY},document.addEventListener("selectstart",p=>p.preventDefault())},k=r=>{if(!i.current)return;const p=Math.abs(r.clientX-i.current.x),x=Math.abs(r.clientY-i.current.y);let d;p>x&&p>u?o.current=r.clientX>i.current.x?"right":"left":x>u&&(o.current=r.clientY>i.current.y?"down":"up"),o.current&&(f.current?(d="move",f.current={x:p,y:x},t.current.style.setProperty("--swipe-position-x",`${p>x?r.clientX-i.current.x:0}px`),t.current.style.setProperty("--swipe-position-y",`${p>x?0:r.clientY-i.current.y}px`),n?.({state:d,direction:o.current})):(d="start",f.current={x:p,y:x},e?.({state:d,direction:o.current})),a(d))},g=()=>{const r=f.current;if(i.current=null,f.current=null,r){const{x:p,y:x}=r;let d;p>x?p>V?(d="end",l?.({state:d,direction:o.current})):(d="cancel",s?.({state:d,direction:o.current})):x>V?(d="end",l?.({state:d,direction:o.current})):(d="cancel",s?.({state:d,direction:o.current})),a(d),document.removeEventListener("selectstart",v=>v.preventDefault())}};return c.useEffect(()=>{if(!t.current)return;const r=t.current;return r.addEventListener("pointerdown",y),document.addEventListener("pointermove",k),document.addEventListener("pointerup",g),()=>{r.removeEventListener("pointerdown",y),document.removeEventListener("pointermove",k),document.removeEventListener("pointerup",g)}},[]),{state:m,direction:o.current}},A=({"aria-label":t,"aria-labelledby":e,"aria-describedby":n,"aria-details":s,design:l,intent:u,actionOnNewline:m,className:a,children:o,ref:i,...f})=>{const y=c.useRef(null),k=typeof i!="function"&&i||y,{toast:g,state:r}=q(),{state:p,direction:x}=ct({swipeRef:k,onSwipeStart:r.pauseAll,onSwipeCancel:r.resumeAll,onSwipeEnd:({direction:_})=>{["left","right"].includes(`${_}`)&&r.close(g.key)}}),{message:d,icon:v,isClosable:$,onAction:B,actionLabel:R}=g.content,N=u??g.content.intent,j=l??g.content.design,z=m??g.content.actionOnNewline,F={ariaLabel:t,ariaLabelledby:e,ariaDescribedby:n,ariaDetails:s},{toastProps:M,titleProps:G,closeButtonProps:H,contentProps:K}=T.useToast({toast:g,...F},r,k),E=c.useCallback(_=>c.Children.toArray(o).filter(c.isValidElement).find(Z=>!!Z.type.displayName?.includes(_)),[o]),U=E("Snackbar.ItemIcon"),W=E("Snackbar.ItemAction"),J=E("Snackbar.ItemClose");return b.jsx("div",{"data-spark-component":"snackbar-item",className:st({design:j,intent:N,className:a}),"data-animation":g.animation,...!(p==="cancel"&&g.animation==="exiting")&&{"data-swipe":p,"data-swipe-direction":x},...g.animation==="exiting"&&{onAnimationEnd:()=>r.remove(g.key)},ref:k,...M,...f,children:b.jsxs("div",{className:rt({actionOnNewline:z}),...K,children:[P(U,v?C:null,{children:v}),b.jsx("p",{className:"px-md py-lg text-body-2 row-span-3",style:{gridArea:"message"},...G,children:d}),P(W,R&&B?h:null,{intent:N,design:j,onClick:B,children:R}),P(J,$?I:null,{intent:N,design:j,"aria-label":H["aria-label"]})]})})};A.displayName="Snackbar.Item";const P=(t,e,n)=>{if(t)return c.cloneElement(t,{...n,...t.props});if(e){const s=e;return b.jsx(s,{...n})}else return null},lt=S.cva(["fixed inset-x-lg z-toast group","outline-hidden pointer-events-none","grid grid-rows-1 grid-cols-1 gap-lg"],{variants:{position:{top:"top-lg justify-items-center","top-right":"top-lg justify-items-end","top-left":"top-lg justify-items-start",bottom:"bottom-lg justify-items-center","bottom-right":"bottom-lg justify-items-end","bottom-left":"bottom-lg justify-items-start"}},defaultVariants:{position:"bottom"}}),dt=({children:t=b.jsx(A,{}),state:e,position:n="bottom",className:s,ref:l,...u})=>{const m=c.useRef(null),a=l&&typeof l!="function"?l:m,{regionProps:o}=T.useToastRegion(u,e,a);return b.jsx("div",{...o,ref:a,"data-position":n,className:lt({position:n,className:s}),children:e.visibleToasts.map(i=>b.jsx(Q.Provider,{value:{toast:i,state:e},children:c.cloneElement(t,{key:i.key})},i.key))})},ut=({providers:t,subscriptions:e})=>{const n=c.useCallback(a=>(e.add(a),()=>e.delete(a)),[e]),s=c.useCallback(()=>[...t].reverse()[0],[t]),l=c.useCallback(a=>{t.add(a);for(const o of e)o()},[t,e]),u=c.useCallback(a=>{t.delete(a);for(const o of e)o()},[t,e]);return{provider:c.useSyncExternalStore(n,s,s),addProvider:l,deleteProvider:u}};let w=null;const L=()=>(w||(w=new O.ToastQueue({maxVisibleToasts:1,hasExitAnimation:!0})),w),mt=()=>{w=null},pt={providers:new Set,subscriptions:new Set},X=({ref:t,...e})=>{const n=c.useRef(null),s=O.useToastQueue(L()),{provider:l,addProvider:u,deleteProvider:m}=ut(pt);return c.useEffect(()=>(u(n),()=>{for(const a of L().visibleToasts)a.animation=void 0;m(n)}),[]),n===l&&s.visibleToasts.length>0?tt.createPortal(b.jsx(dt,{ref:t,state:s,...e}),document.body):null};X.displayName="Snackbar";const gt=({onClose:t,timeout:e=5e3,priority:n,...s})=>{L().add(s,{onClose:t,timeout:e&&!s.onAction?Math.max(e,5e3):void 0,priority:n})},Y=Object.assign(X,{Item:A,ItemAction:h,ItemClose:I,ItemIcon:C});Y.displayName="Snackbar";A.displayName="Snackbar.Item";h.displayName="Snackbar.ItemAction";I.displayName="Snackbar.ItemClose";C.displayName="Snackbar.ItemIcon";exports.Snackbar=Y;exports.addSnackbar=gt;exports.clearSnackbarQueue=mt;
2
2
  //# sourceMappingURL=index.js.map
@@ -4,10 +4,10 @@ import { createContext as at, useContext as ot, useState as st, useRef as w, use
4
4
  import { createPortal as dt } from "react-dom";
5
5
  import { useToast as mt, useToastRegion as ut } from "@react-aria/toast";
6
6
  import { cva as B, cx as V } from "class-variance-authority";
7
- import { B as pt } from "../Button-1M9DcZl0.mjs";
7
+ import { B as pt } from "../Button-CcIRizse.mjs";
8
8
  import { Close as gt } from "@spark-ui/icons/Close";
9
9
  import { I as F } from "../Icon-BO327oHU.mjs";
10
- import { I as ft } from "../IconButton-DdB3Pq13.mjs";
10
+ import { I as ft } from "../IconButton-CP4JbWsI.mjs";
11
11
  const bt = [
12
12
  {
13
13
  design: "filled",
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),M=require("@spark-ui/components/form-field"),l=require("react"),m=require("../input/index.js"),A=require("@react-aria/numberfield"),_=require("@react-stately/numberfield"),S=require("@react-aria/button"),k=require("@spark-ui/icons/Minus"),G=require("@spark-ui/icons/Plus"),I=require("../Icon-C-cNTnzd.js"),P=require("../IconButton-BR1bJSQA.js"),T=require("@spark-ui/hooks/use-merge-refs"),$=({inputRef:r,locale:i="fr",...e})=>{const u=_.useNumberFieldState({...e,isDisabled:e.disabled,isReadOnly:e.readOnly,isRequired:e.required,locale:i}),{groupProps:n,inputProps:t,incrementButtonProps:s,decrementButtonProps:c}=A.useNumberField({isWheelDisabled:!1,...e,isDisabled:e.disabled,isReadOnly:e.readOnly,isRequired:e.required},u,r);return{groupProps:n,inputProps:t,incrementButtonProps:s,decrementButtonProps:c}},f=l.createContext(null),g=({children:r,formatOptions:i,minValue:e,maxValue:u,ref:n,...t})=>{const s=l.useRef(null),{groupProps:c,inputProps:d,incrementButtonProps:p,decrementButtonProps:R}=$({...t,..."value"in t&&{value:t.value??NaN},onChange:t.onValueChange,formatOptions:i,minValue:e,maxValue:u,inputRef:s}),a=M.useFormFieldControl(),b=!!a.id,v={...p,...b&&{"aria-controls":a.id}},D={...R,...b&&{"aria-controls":a.id}},O={...d,...b&&{id:a.id,required:a.isRequired,"aria-invalid":a.isInvalid?!0:void 0}},{onValueChange:L,...F}=t;return o.jsx(f.Provider,{value:{incrementButtonProps:v,decrementButtonProps:D,inputProps:O,inputRef:s},children:o.jsx(m.InputGroup,{...F,...c,"data-spark-component":"stepper",ref:n,children:r})})};g.displayName="Stepper";const B=()=>{const r=l.useContext(f);if(!r)throw Error("useStepperContext must be used within a Stepper provider");return r},x=({children:r,design:i="ghost",intent:e="neutral",className:u,ref:n,...t})=>{const s=l.useRef(null),c=n&&typeof n!="function"?n:s,{incrementButtonProps:d}=B(),{buttonProps:p}=S.useButton({...d,...t},c);return o.jsx(m.InputGroup.TrailingAddon,{asChild:!0,"data-spark-component":"stepper-increment-button",children:o.jsx(P.IconButton,{ref:c,design:i,intent:e,className:u,"aria-label":p["aria-label"],...p,disabled:t.disabled||p.disabled,children:r||o.jsx(I.Icon,{children:o.jsx(G.Plus,{})})})})},q=({children:r,design:i="ghost",intent:e="neutral",className:u,ref:n,...t})=>{const s=l.useRef(null),c=n&&typeof n!="function"?n:s,{decrementButtonProps:d}=B(),{buttonProps:p}=S.useButton({...d,...t},c);return o.jsx(m.InputGroup.LeadingAddon,{asChild:!0,"data-spark-component":"stepper-decrement-button",children:o.jsx(P.IconButton,{ref:c,design:i,intent:e,className:u,"aria-label":p["aria-label"],...p,disabled:t.disabled||p.disabled,children:r||o.jsx(I.Icon,{children:o.jsx(k.Minus,{})})})})},h=Object.assign(x,{id:"TrailingAddon"}),j=Object.assign(q,{id:"LeadingAddon"});x.displayName="Stepper.DecrementButton";q.displayName="Stepper.DecrementButton";const y=({ref:r,...i})=>{const{inputRef:e,inputProps:u}=B(),n=T.useMergeRefs(r,e),{className:t="",...s}=i;return o.jsx(m.Input,{ref:n,...s,...u,className:`min-w-sz-56 text-center ${t}`})},N=Object.assign(y,{id:"Input"});y.displayName="Stepper.Input";const C=Object.assign(g,{IncrementButton:h,DecrementButton:j,Input:N});C.displayName="Stepper";h.displayName="Stepper.IncrementButton";j.displayName="Stepper.DecrementButton";N.displayName="Stepper.Input";exports.Stepper=C;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),M=require("@spark-ui/components/form-field"),l=require("react"),m=require("../input/index.js"),A=require("@react-aria/numberfield"),_=require("@react-stately/numberfield"),S=require("@react-aria/button"),k=require("@spark-ui/icons/Minus"),G=require("@spark-ui/icons/Plus"),I=require("../Icon-C-cNTnzd.js"),P=require("../IconButton-JFDGiOOn.js"),T=require("@spark-ui/hooks/use-merge-refs"),$=({inputRef:r,locale:i="fr",...e})=>{const u=_.useNumberFieldState({...e,isDisabled:e.disabled,isReadOnly:e.readOnly,isRequired:e.required,locale:i}),{groupProps:n,inputProps:t,incrementButtonProps:s,decrementButtonProps:c}=A.useNumberField({isWheelDisabled:!1,...e,isDisabled:e.disabled,isReadOnly:e.readOnly,isRequired:e.required},u,r);return{groupProps:n,inputProps:t,incrementButtonProps:s,decrementButtonProps:c}},f=l.createContext(null),g=({children:r,formatOptions:i,minValue:e,maxValue:u,ref:n,...t})=>{const s=l.useRef(null),{groupProps:c,inputProps:d,incrementButtonProps:p,decrementButtonProps:R}=$({...t,..."value"in t&&{value:t.value??NaN},onChange:t.onValueChange,formatOptions:i,minValue:e,maxValue:u,inputRef:s}),a=M.useFormFieldControl(),b=!!a.id,v={...p,...b&&{"aria-controls":a.id}},D={...R,...b&&{"aria-controls":a.id}},O={...d,...b&&{id:a.id,required:a.isRequired,"aria-invalid":a.isInvalid?!0:void 0}},{onValueChange:L,...F}=t;return o.jsx(f.Provider,{value:{incrementButtonProps:v,decrementButtonProps:D,inputProps:O,inputRef:s},children:o.jsx(m.InputGroup,{...F,...c,"data-spark-component":"stepper",ref:n,children:r})})};g.displayName="Stepper";const B=()=>{const r=l.useContext(f);if(!r)throw Error("useStepperContext must be used within a Stepper provider");return r},x=({children:r,design:i="ghost",intent:e="neutral",className:u,ref:n,...t})=>{const s=l.useRef(null),c=n&&typeof n!="function"?n:s,{incrementButtonProps:d}=B(),{buttonProps:p}=S.useButton({...d,...t},c);return o.jsx(m.InputGroup.TrailingAddon,{asChild:!0,"data-spark-component":"stepper-increment-button",children:o.jsx(P.IconButton,{ref:c,design:i,intent:e,className:u,"aria-label":p["aria-label"],...p,disabled:t.disabled||p.disabled,children:r||o.jsx(I.Icon,{children:o.jsx(G.Plus,{})})})})},q=({children:r,design:i="ghost",intent:e="neutral",className:u,ref:n,...t})=>{const s=l.useRef(null),c=n&&typeof n!="function"?n:s,{decrementButtonProps:d}=B(),{buttonProps:p}=S.useButton({...d,...t},c);return o.jsx(m.InputGroup.LeadingAddon,{asChild:!0,"data-spark-component":"stepper-decrement-button",children:o.jsx(P.IconButton,{ref:c,design:i,intent:e,className:u,"aria-label":p["aria-label"],...p,disabled:t.disabled||p.disabled,children:r||o.jsx(I.Icon,{children:o.jsx(k.Minus,{})})})})},h=Object.assign(x,{id:"TrailingAddon"}),j=Object.assign(q,{id:"LeadingAddon"});x.displayName="Stepper.DecrementButton";q.displayName="Stepper.DecrementButton";const y=({ref:r,...i})=>{const{inputRef:e,inputProps:u}=B(),n=T.useMergeRefs(r,e),{className:t="",...s}=i;return o.jsx(m.Input,{ref:n,...s,...u,className:`min-w-sz-56 text-center ${t}`})},N=Object.assign(y,{id:"Input"});y.displayName="Stepper.Input";const C=Object.assign(g,{IncrementButton:h,DecrementButton:j,Input:N});C.displayName="Stepper";h.displayName="Stepper.IncrementButton";j.displayName="Stepper.DecrementButton";N.displayName="Stepper.Input";exports.Stepper=C;
2
2
  //# sourceMappingURL=index.js.map
@@ -8,7 +8,7 @@ import { useButton as B } from "@react-aria/button";
8
8
  import { Minus as M } from "@spark-ui/icons/Minus";
9
9
  import { Plus as T } from "@spark-ui/icons/Plus";
10
10
  import { I as P } from "../Icon-BO327oHU.mjs";
11
- import { I as S } from "../IconButton-DdB3Pq13.mjs";
11
+ import { I as S } from "../IconButton-CP4JbWsI.mjs";
12
12
  import { useMergeRefs as V } from "@spark-ui/hooks/use-merge-refs";
13
13
  const W = ({
14
14
  inputRef: r,
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),T=require("radix-ui"),s=require("react"),m=require("class-variance-authority"),D=require("@spark-ui/icons/ArrowVerticalLeft"),F=require("@spark-ui/icons/ArrowVerticalRight"),M=require("../Button-FZceRWG2.js"),j=require("../Icon-C-cNTnzd.js"),q=require("@spark-ui/hooks/use-merge-refs"),K=require("@spark-ui/icons/MoreMenuHorizontal"),H=require("../IconButton-BR1bJSQA.js"),g=require("../popover/index.js"),U=require("@spark-ui/internal-utils"),W=s.createContext({}),R=()=>{const t=s.useContext(W);if(!t)throw Error("useTabsContext must be used within a TabsContext Provider");return t},$=m.cva(["flex","data-[orientation=horizontal]:flex-col","data-[orientation=vertical]:flex-row","max-w-full"]),V=({intent:t="support",size:o="md",asChild:c=!1,forceMount:a=!1,orientation:n="horizontal",children:i,className:l,ref:d,...e})=>r.jsx(W.Provider,{value:{intent:t,size:o,orientation:n,forceMount:a},children:r.jsx(T.Tabs.Root,{ref:d,asChild:c,orientation:n,className:$({className:l}),"data-spark-component":"tabs",activationMode:"automatic",...e,children:i})});V.displayName="Tabs";const G=m.cva(["w-full p-lg","focus-visible:u-outline-inset"],{variants:{forceMount:{true:"data-[state=inactive]:hidden",false:""}}}),P=({children:t,asChild:o=!1,className:c,ref:a,...n})=>{const{forceMount:i}=R();return r.jsx(T.Tabs.Content,{"data-spark-component":"tabs-content",ref:a,forceMount:i||n.forceMount,className:G({className:c,forceMount:i}),asChild:o,...n,children:t})};P.displayName="Tabs.Content";const J=m.cva(["relative flex"]),Q=m.cva(["flex w-full","data-[orientation=horizontal]:flex-row","data-[orientation=vertical]:flex-col","overflow-y-hidden u-no-scrollbar data-[orientation=vertical]:overflow-x-hidden","after:flex after:shrink after:grow after:border-outline","data-[orientation=horizontal]:after:border-b-sm","data-[orientation=vertical]:after:border-r-sm"]),S=m.cva(["h-auto! flex-none","border-b-sm border-outline","outline-hidden","focus-visible:border-none focus-visible:bg-surface-hovered focus-visible:u-outline-inset!"]),X=(t,o)=>{const[c,a]=s.useState({width:void 0,height:void 0}),n=s.useRef(null),i=s.useRef(o);return s.useEffect(()=>{i.current=o},[o]),s.useEffect(()=>{const l=t&&"current"in t?t.current:t;if(!(!l||n.current))return n.current=new ResizeObserver(([d])=>{const{inlineSize:e,blockSize:x}=d?.borderBoxSize?.[0]??{};i.current?.(d),a({width:e,height:x})}),n.current.observe(l),()=>{n.current&&n.current.unobserve(l)}},[t,n,i]),c},N=({asChild:t=!1,loop:o=!1,children:c,className:a,ref:n,...i})=>{const l=s.useRef(null),d=s.useRef(null),e=n||d,{orientation:x}=R(),{width:w}=X(l),[u,b]=s.useState({prev:"hidden",next:"hidden"});s.useEffect(()=>{typeof e=="function"||!e.current||b(x!=="horizontal"?{prev:"hidden",next:"hidden"}:{prev:e.current.scrollWidth>e.current.clientWidth?"visible":"hidden",next:e.current.scrollWidth>e.current.clientWidth?"visible":"hidden"})},[x,e,w]),s.useEffect(()=>{if(typeof e=="function"||!e.current||u.prev==="hidden"||o)return;const v=f=>{b({prev:f.scrollLeft>0?"visible":"disabled",next:f.scrollLeft+f.clientWidth<f.scrollWidth?"visible":"disabled"})},p=e.current;return v(p),p.addEventListener("scroll",({target:f})=>v(f)),()=>p.removeEventListener("scroll",({target:f})=>v(f))},[e,u.prev,o]);const z=()=>{if(typeof e=="function"||!e.current)return;const v=o&&e.current.scrollLeft<=0;e.current.scrollTo({left:v?e.current.scrollLeft+e.current.scrollWidth-e.current.clientWidth:e.current.scrollLeft-e.current.clientWidth,behavior:"smooth"})},y=()=>{if(typeof e=="function"||!e.current)return;const v=o&&e.current.scrollLeft+e.current.clientWidth>=e.current.scrollWidth;e.current.scrollTo({left:v?0:e.current.scrollLeft+e.current.clientWidth,behavior:"smooth"})};return r.jsxs("div",{className:J({className:a}),ref:l,children:[u.prev!=="hidden"&&r.jsx(M.Button,{shape:"square",intent:"surface",size:"sm",className:S(),onClick:z,disabled:u.prev==="disabled","aria-label":"Scroll left",children:r.jsx(j.Icon,{children:r.jsx(D.ArrowVerticalLeft,{})})}),r.jsx(T.Tabs.List,{"data-spark-component":"tabs-list",ref:e,className:Q(),asChild:t,loop:o,...i,children:c}),u.next!=="hidden"&&r.jsx(M.Button,{shape:"square",intent:"surface",size:"sm",className:S(),onClick:y,disabled:u.next==="disabled","aria-label":"Scroll right",children:r.jsx(j.Icon,{children:r.jsx(F.ArrowVerticalRight,{})})})]})};N.displayName="Tabs.List";const C=s.createContext(void 0),E=()=>{const t=s.useContext(C);if(!t)throw new Error("TabsPopover components must be used within TabsPopover");return t},I=s.forwardRef(({"aria-label":t,children:o,...c},a)=>{const{popoverTriggerRef:n}=E(),i=q.useMergeRefs(a,n);return r.jsx(g.Popover.Trigger,{asChild:!0,...c,children:r.jsx(H.IconButton,{ref:i,size:"sm",intent:"surfaceInverse",design:"ghost","aria-label":t,tabIndex:-1,children:r.jsx(j.Icon,{children:o||r.jsx(K.MoreMenuHorizontal,{})})})})});I.displayName="Popover.Trigger";const A=s.forwardRef(({side:t,align:o="start",className:c,...a},n)=>{const{popoverSide:i}=E(),l=m.cx("gap-sm flex flex-col",c);return r.jsx(g.Popover.Content,{ref:n,...a,side:t??i,align:o,className:l})});A.displayName="Popover.Content";const B=({popoverSide:t,popoverTriggerRef:o,children:c})=>{const a=s.useMemo(()=>({popoverSide:t,popoverTriggerRef:o}),[t,o]),i=Object.assign((l=>r.jsx(C.Provider,{value:a,children:r.jsx(g.Popover,{...l,children:l.children})})),g.Popover,{Content:A,Trigger:I});return r.jsx(C.Provider,{value:a,children:c(i)})};B.displayName="Popover";const Y=m.cva(["px-md","relative flex flex-none items-center","border-outline","hover:not-disabled:bg-surface-hovered","after:absolute","data-[state=active]:font-bold","data-[state=inactive]:not-disabled:cursor-pointer","data-[orientation=horizontal]:border-b-sm data-[orientation=horizontal]:after:inset-x-0 data-[orientation=horizontal]:after:bottom-[-1px] data-[orientation=horizontal]:after:h-sz-2","data-[orientation=vertical]:border-r-sm data-[orientation=vertical]:after:inset-y-0 data-[orientation=vertical]:after:right-[-1px] data-[orientation=vertical]:after:w-sz-2","focus-visible:border-none focus-visible:bg-surface-hovered focus-visible:u-outline-inset","disabled:cursor-not-allowed disabled:opacity-dim-3","gap-md [&>*:first-child]:ml-md [&>*:last-child]:mr-md","[&>svg:last-child:first-child]:mx-auto"],{variants:{intent:U.makeVariants({main:["data-[state=active]:text-main data-[state=active]:after:bg-main"],support:["data-[state=active]:text-support data-[state=active]:after:bg-support"]}),size:{xs:["h-sz-32 min-w-sz-32 text-caption"],sm:["h-sz-36 min-w-sz-36 text-body-2"],md:["h-sz-40 min-w-sz-40 text-body-1"]},hasMenu:{true:"pr-3xl"},orientation:{horizontal:"",vertical:""}},compoundVariants:[{hasMenu:!0,orientation:"vertical",class:"w-full"}],defaultVariants:{intent:"support",size:"md",hasMenu:!1,orientation:"horizontal"}}),L=({asChild:t=!1,value:o,disabled:c=!1,children:a,className:n,ref:i,onKeyDown:l,renderMenu:d,...e})=>{const{intent:x,size:w,orientation:u}=R(),b=s.useRef(null),z=s.useRef(null),y=q.useMergeRefs(i,z),v=h=>{h.key==="F10"&&h.shiftKey&&d&&b.current&&(h.preventDefault(),b.current.click()),l?.(h)},p=!!d,f=u==="vertical"?"right":"bottom",k=r.jsx(T.Tabs.Trigger,{"data-spark-component":"tabs-trigger",ref:y,className:Y({intent:x,size:w,hasMenu:p,orientation:u??"horizontal",className:n}),asChild:t,disabled:c,value:o,onFocus:({target:h})=>h.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"}),onKeyDown:v,"aria-haspopup":p?"true":void 0,...e,children:a});return p?r.jsxs("div",{className:u==="vertical"?"relative w-full":"relative",children:[k,r.jsx("div",{className:"right-md mr-md pointer-events-auto absolute top-1/2 -translate-y-1/2",children:r.jsx(B,{popoverSide:f,popoverTriggerRef:b,children:h=>d?.({Popover:h})})})]}):k};L.displayName="Tabs.Trigger";const O=Object.assign(V,{List:N,Trigger:L,Content:P});O.displayName="Tabs";N.displayName="Tabs.List";L.displayName="Tabs.Trigger";P.displayName="Tabs.Content";exports.Tabs=O;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),T=require("radix-ui"),s=require("react"),m=require("class-variance-authority"),D=require("@spark-ui/icons/ArrowVerticalLeft"),F=require("@spark-ui/icons/ArrowVerticalRight"),M=require("../Button-CXL2NOrq.js"),j=require("../Icon-C-cNTnzd.js"),q=require("@spark-ui/hooks/use-merge-refs"),K=require("@spark-ui/icons/MoreMenuHorizontal"),H=require("../IconButton-JFDGiOOn.js"),g=require("../popover/index.js"),U=require("@spark-ui/internal-utils"),W=s.createContext({}),R=()=>{const t=s.useContext(W);if(!t)throw Error("useTabsContext must be used within a TabsContext Provider");return t},$=m.cva(["flex","data-[orientation=horizontal]:flex-col","data-[orientation=vertical]:flex-row","max-w-full"]),V=({intent:t="support",size:o="md",asChild:c=!1,forceMount:a=!1,orientation:n="horizontal",children:i,className:l,ref:d,...e})=>r.jsx(W.Provider,{value:{intent:t,size:o,orientation:n,forceMount:a},children:r.jsx(T.Tabs.Root,{ref:d,asChild:c,orientation:n,className:$({className:l}),"data-spark-component":"tabs",activationMode:"automatic",...e,children:i})});V.displayName="Tabs";const G=m.cva(["w-full p-lg","focus-visible:u-outline-inset"],{variants:{forceMount:{true:"data-[state=inactive]:hidden",false:""}}}),P=({children:t,asChild:o=!1,className:c,ref:a,...n})=>{const{forceMount:i}=R();return r.jsx(T.Tabs.Content,{"data-spark-component":"tabs-content",ref:a,forceMount:i||n.forceMount,className:G({className:c,forceMount:i}),asChild:o,...n,children:t})};P.displayName="Tabs.Content";const J=m.cva(["relative flex"]),Q=m.cva(["flex w-full","data-[orientation=horizontal]:flex-row","data-[orientation=vertical]:flex-col","overflow-y-hidden u-no-scrollbar data-[orientation=vertical]:overflow-x-hidden","after:flex after:shrink after:grow after:border-outline","data-[orientation=horizontal]:after:border-b-sm","data-[orientation=vertical]:after:border-r-sm"]),S=m.cva(["h-auto! flex-none","border-b-sm border-outline","outline-hidden","focus-visible:border-none focus-visible:bg-surface-hovered focus-visible:u-outline-inset!"]),X=(t,o)=>{const[c,a]=s.useState({width:void 0,height:void 0}),n=s.useRef(null),i=s.useRef(o);return s.useEffect(()=>{i.current=o},[o]),s.useEffect(()=>{const l=t&&"current"in t?t.current:t;if(!(!l||n.current))return n.current=new ResizeObserver(([d])=>{const{inlineSize:e,blockSize:x}=d?.borderBoxSize?.[0]??{};i.current?.(d),a({width:e,height:x})}),n.current.observe(l),()=>{n.current&&n.current.unobserve(l)}},[t,n,i]),c},N=({asChild:t=!1,loop:o=!1,children:c,className:a,ref:n,...i})=>{const l=s.useRef(null),d=s.useRef(null),e=n||d,{orientation:x}=R(),{width:w}=X(l),[u,b]=s.useState({prev:"hidden",next:"hidden"});s.useEffect(()=>{typeof e=="function"||!e.current||b(x!=="horizontal"?{prev:"hidden",next:"hidden"}:{prev:e.current.scrollWidth>e.current.clientWidth?"visible":"hidden",next:e.current.scrollWidth>e.current.clientWidth?"visible":"hidden"})},[x,e,w]),s.useEffect(()=>{if(typeof e=="function"||!e.current||u.prev==="hidden"||o)return;const v=f=>{b({prev:f.scrollLeft>0?"visible":"disabled",next:f.scrollLeft+f.clientWidth<f.scrollWidth?"visible":"disabled"})},p=e.current;return v(p),p.addEventListener("scroll",({target:f})=>v(f)),()=>p.removeEventListener("scroll",({target:f})=>v(f))},[e,u.prev,o]);const z=()=>{if(typeof e=="function"||!e.current)return;const v=o&&e.current.scrollLeft<=0;e.current.scrollTo({left:v?e.current.scrollLeft+e.current.scrollWidth-e.current.clientWidth:e.current.scrollLeft-e.current.clientWidth,behavior:"smooth"})},y=()=>{if(typeof e=="function"||!e.current)return;const v=o&&e.current.scrollLeft+e.current.clientWidth>=e.current.scrollWidth;e.current.scrollTo({left:v?0:e.current.scrollLeft+e.current.clientWidth,behavior:"smooth"})};return r.jsxs("div",{className:J({className:a}),ref:l,children:[u.prev!=="hidden"&&r.jsx(M.Button,{shape:"square",intent:"surface",size:"sm",className:S(),onClick:z,disabled:u.prev==="disabled","aria-label":"Scroll left",children:r.jsx(j.Icon,{children:r.jsx(D.ArrowVerticalLeft,{})})}),r.jsx(T.Tabs.List,{"data-spark-component":"tabs-list",ref:e,className:Q(),asChild:t,loop:o,...i,children:c}),u.next!=="hidden"&&r.jsx(M.Button,{shape:"square",intent:"surface",size:"sm",className:S(),onClick:y,disabled:u.next==="disabled","aria-label":"Scroll right",children:r.jsx(j.Icon,{children:r.jsx(F.ArrowVerticalRight,{})})})]})};N.displayName="Tabs.List";const C=s.createContext(void 0),E=()=>{const t=s.useContext(C);if(!t)throw new Error("TabsPopover components must be used within TabsPopover");return t},I=s.forwardRef(({"aria-label":t,children:o,...c},a)=>{const{popoverTriggerRef:n}=E(),i=q.useMergeRefs(a,n);return r.jsx(g.Popover.Trigger,{asChild:!0,...c,children:r.jsx(H.IconButton,{ref:i,size:"sm",intent:"surfaceInverse",design:"ghost","aria-label":t,tabIndex:-1,children:r.jsx(j.Icon,{children:o||r.jsx(K.MoreMenuHorizontal,{})})})})});I.displayName="Popover.Trigger";const A=s.forwardRef(({side:t,align:o="start",className:c,...a},n)=>{const{popoverSide:i}=E(),l=m.cx("gap-sm flex flex-col",c);return r.jsx(g.Popover.Content,{ref:n,...a,side:t??i,align:o,className:l})});A.displayName="Popover.Content";const B=({popoverSide:t,popoverTriggerRef:o,children:c})=>{const a=s.useMemo(()=>({popoverSide:t,popoverTriggerRef:o}),[t,o]),i=Object.assign((l=>r.jsx(C.Provider,{value:a,children:r.jsx(g.Popover,{...l,children:l.children})})),g.Popover,{Content:A,Trigger:I});return r.jsx(C.Provider,{value:a,children:c(i)})};B.displayName="Popover";const Y=m.cva(["px-md","relative flex flex-none items-center","border-outline","hover:not-disabled:bg-surface-hovered","after:absolute","data-[state=active]:font-bold","data-[state=inactive]:not-disabled:cursor-pointer","data-[orientation=horizontal]:border-b-sm data-[orientation=horizontal]:after:inset-x-0 data-[orientation=horizontal]:after:bottom-[-1px] data-[orientation=horizontal]:after:h-sz-2","data-[orientation=vertical]:border-r-sm data-[orientation=vertical]:after:inset-y-0 data-[orientation=vertical]:after:right-[-1px] data-[orientation=vertical]:after:w-sz-2","focus-visible:border-none focus-visible:bg-surface-hovered focus-visible:u-outline-inset","disabled:cursor-not-allowed disabled:opacity-dim-3","gap-md [&>*:first-child]:ml-md [&>*:last-child]:mr-md","[&>svg:last-child:first-child]:mx-auto"],{variants:{intent:U.makeVariants({main:["data-[state=active]:text-main data-[state=active]:after:bg-main"],support:["data-[state=active]:text-support data-[state=active]:after:bg-support"]}),size:{xs:["h-sz-32 min-w-sz-32 text-caption"],sm:["h-sz-36 min-w-sz-36 text-body-2"],md:["h-sz-40 min-w-sz-40 text-body-1"]},hasMenu:{true:"pr-3xl"},orientation:{horizontal:"",vertical:""}},compoundVariants:[{hasMenu:!0,orientation:"vertical",class:"w-full"}],defaultVariants:{intent:"support",size:"md",hasMenu:!1,orientation:"horizontal"}}),L=({asChild:t=!1,value:o,disabled:c=!1,children:a,className:n,ref:i,onKeyDown:l,renderMenu:d,...e})=>{const{intent:x,size:w,orientation:u}=R(),b=s.useRef(null),z=s.useRef(null),y=q.useMergeRefs(i,z),v=h=>{h.key==="F10"&&h.shiftKey&&d&&b.current&&(h.preventDefault(),b.current.click()),l?.(h)},p=!!d,f=u==="vertical"?"right":"bottom",k=r.jsx(T.Tabs.Trigger,{"data-spark-component":"tabs-trigger",ref:y,className:Y({intent:x,size:w,hasMenu:p,orientation:u??"horizontal",className:n}),asChild:t,disabled:c,value:o,onFocus:({target:h})=>h.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"}),onKeyDown:v,"aria-haspopup":p?"true":void 0,...e,children:a});return p?r.jsxs("div",{className:u==="vertical"?"relative w-full":"relative",children:[k,r.jsx("div",{className:"right-md mr-md pointer-events-auto absolute top-1/2 -translate-y-1/2",children:r.jsx(B,{popoverSide:f,popoverTriggerRef:b,children:h=>d?.({Popover:h})})})]}):k};L.displayName="Tabs.Trigger";const O=Object.assign(V,{List:N,Trigger:L,Content:P});O.displayName="Tabs";N.displayName="Tabs.List";L.displayName="Tabs.Trigger";P.displayName="Tabs.Content";exports.Tabs=O;
2
2
  //# sourceMappingURL=index.js.map