@solibo/solibo-ui 1.0.14 → 1.0.16

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 (206) hide show
  1. package/dist/assets/index.css +1 -1
  2. package/dist/assets/index10.css +1 -1
  3. package/dist/assets/index12.css +1 -1
  4. package/dist/assets/index13.css +1 -1
  5. package/dist/assets/index14.css +1 -1
  6. package/dist/assets/index15.css +1 -1
  7. package/dist/assets/index16.css +1 -1
  8. package/dist/assets/index17.css +1 -1
  9. package/dist/assets/index18.css +1 -1
  10. package/dist/assets/index19.css +0 -1
  11. package/dist/assets/index20.css +1 -1
  12. package/dist/assets/index21.css +1 -0
  13. package/dist/assets/index22.css +1 -1
  14. package/dist/assets/index23.css +1 -1
  15. package/dist/assets/index24.css +1 -1
  16. package/dist/assets/index25.css +1 -1
  17. package/dist/assets/index26.css +1 -1
  18. package/dist/assets/index27.css +1 -1
  19. package/dist/assets/index28.css +1 -1
  20. package/dist/assets/index29.css +1 -1
  21. package/dist/assets/index3.css +1 -1
  22. package/dist/assets/index30.css +1 -1
  23. package/dist/assets/index31.css +1 -1
  24. package/dist/assets/index32.css +1 -1
  25. package/dist/assets/index33.css +1 -1
  26. package/dist/assets/index34.css +1 -1
  27. package/dist/assets/index35.css +1 -1
  28. package/dist/assets/index36.css +1 -1
  29. package/dist/assets/index37.css +1 -1
  30. package/dist/assets/index38.css +1 -1
  31. package/dist/assets/index39.css +1 -1
  32. package/dist/assets/index4.css +1 -1
  33. package/dist/assets/index40.css +1 -1
  34. package/dist/assets/index41.css +1 -1
  35. package/dist/assets/index42.css +1 -1
  36. package/dist/assets/index43.css +1 -1
  37. package/dist/assets/index44.css +1 -1
  38. package/dist/assets/index45.css +1 -1
  39. package/dist/assets/index46.css +1 -1
  40. package/dist/assets/index47.css +1 -1
  41. package/dist/assets/index48.css +1 -1
  42. package/dist/assets/index49.css +1 -1
  43. package/dist/assets/index50.css +1 -1
  44. package/dist/assets/index51.css +1 -1
  45. package/dist/assets/index6.css +1 -1
  46. package/dist/assets/index8.css +1 -1
  47. package/dist/assets/index9.css +1 -1
  48. package/dist/assets/menu-popover.css +1 -0
  49. package/dist/components/app-link/index.cjs +1 -1
  50. package/dist/components/app-link/index.js +8 -8
  51. package/dist/components/aside/index.cjs +1 -1
  52. package/dist/components/aside/index.js +11 -11
  53. package/dist/components/avatar/index.cjs +1 -1
  54. package/dist/components/avatar/index.cjs.map +1 -1
  55. package/dist/components/avatar/index.js +58 -58
  56. package/dist/components/badge/index.cjs +1 -1
  57. package/dist/components/badge/index.js +27 -27
  58. package/dist/components/banner/index.cjs +1 -1
  59. package/dist/components/banner/index.js +14 -14
  60. package/dist/components/branding/index.cjs +1 -1
  61. package/dist/components/branding/index.js +1 -1
  62. package/dist/components/button/index.cjs +1 -1
  63. package/dist/components/button/index.js +18 -18
  64. package/dist/components/card/index.cjs +1 -1
  65. package/dist/components/card/index.js +46 -46
  66. package/dist/components/checkbox/index.cjs +1 -1
  67. package/dist/components/checkbox/index.js +7 -7
  68. package/dist/components/chip/index.cjs +1 -1
  69. package/dist/components/chip/index.cjs.map +1 -1
  70. package/dist/components/chip/index.js +27 -26
  71. package/dist/components/chip/index.js.map +1 -1
  72. package/dist/components/collapsible/index.cjs +1 -1
  73. package/dist/components/collapsible/index.cjs.map +1 -1
  74. package/dist/components/collapsible/index.js +18 -37
  75. package/dist/components/collapsible/index.js.map +1 -1
  76. package/dist/components/controls/index.cjs +1 -1
  77. package/dist/components/controls/index.cjs.map +1 -1
  78. package/dist/components/controls/index.js +128 -36
  79. package/dist/components/controls/index.js.map +1 -1
  80. package/dist/components/croppable/index.cjs +1 -1
  81. package/dist/components/croppable/index.js +181 -181
  82. package/dist/components/dialog/index.cjs +1 -1
  83. package/dist/components/dialog/index.js +31 -31
  84. package/dist/components/dropdown/index.cjs +1 -1
  85. package/dist/components/dropdown/index.cjs.map +1 -1
  86. package/dist/components/dropdown/index.js +113 -110
  87. package/dist/components/dropdown/index.js.map +1 -1
  88. package/dist/components/dropzone/index.cjs +1 -1
  89. package/dist/components/dropzone/index.js +1 -1
  90. package/dist/components/editor/index.cjs +16 -16
  91. package/dist/components/editor/index.cjs.map +1 -1
  92. package/dist/components/editor/index.js +197 -197
  93. package/dist/components/empty-state/index.cjs +1 -1
  94. package/dist/components/empty-state/index.js +1 -1
  95. package/dist/components/fieldset/index.cjs +1 -1
  96. package/dist/components/fieldset/index.js +1 -1
  97. package/dist/components/figure/index.cjs +1 -1
  98. package/dist/components/figure/index.js +1 -1
  99. package/dist/components/file/index.cjs +1 -1
  100. package/dist/components/file/index.cjs.map +1 -1
  101. package/dist/components/file/index.js +38 -34
  102. package/dist/components/file/index.js.map +1 -1
  103. package/dist/components/footer/index.cjs +1 -1
  104. package/dist/components/footer/index.js +1 -1
  105. package/dist/components/form/index.cjs +1 -1
  106. package/dist/components/form/index.js +1 -1
  107. package/dist/components/graph/index.cjs +1 -1
  108. package/dist/components/graph/index.js +1 -1
  109. package/dist/components/group/index.cjs +1 -1
  110. package/dist/components/group/index.js +1 -1
  111. package/dist/components/header/index.cjs +1 -1
  112. package/dist/components/header/index.cjs.map +1 -1
  113. package/dist/components/header/index.js +14 -14
  114. package/dist/components/icon/index.cjs +1 -1
  115. package/dist/components/icon/index.js +20 -20
  116. package/dist/components/iframe/index.cjs +1 -1
  117. package/dist/components/iframe/index.js +1 -1
  118. package/dist/components/image/index.cjs +1 -1
  119. package/dist/components/image/index.js +1 -1
  120. package/dist/components/input/index.cjs +1 -1
  121. package/dist/components/input/index.js +3 -3
  122. package/dist/components/link/index.cjs +1 -1
  123. package/dist/components/link/index.js +1 -1
  124. package/dist/components/list/index.cjs +1 -1
  125. package/dist/components/list/index.cjs.map +1 -1
  126. package/dist/components/list/index.js +39 -36
  127. package/dist/components/list/index.js.map +1 -1
  128. package/dist/components/loading/index.cjs +1 -1
  129. package/dist/components/loading/index.js +11 -11
  130. package/dist/components/menu/index.cjs +1 -1
  131. package/dist/components/menu/index.cjs.map +1 -1
  132. package/dist/components/menu/index.js +37 -87
  133. package/dist/components/menu/index.js.map +1 -1
  134. package/dist/components/message/index.cjs +1 -1
  135. package/dist/components/message/index.cjs.map +1 -1
  136. package/dist/components/message/index.js +26 -26
  137. package/dist/components/messages/index.cjs +1 -1
  138. package/dist/components/messages/index.js +20 -20
  139. package/dist/components/nav/index.cjs +1 -1
  140. package/dist/components/nav/index.js +25 -25
  141. package/dist/components/popover/index.cjs +1 -1
  142. package/dist/components/popover/index.cjs.map +1 -1
  143. package/dist/components/popover/index.js +56 -60
  144. package/dist/components/popover/index.js.map +1 -1
  145. package/dist/components/portal/index.cjs +1 -1
  146. package/dist/components/portal/index.js +7 -7
  147. package/dist/components/search/index.cjs +1 -1
  148. package/dist/components/search/index.cjs.map +1 -1
  149. package/dist/components/search/index.js +43 -45
  150. package/dist/components/search/index.js.map +1 -1
  151. package/dist/components/select/index.cjs +1 -1
  152. package/dist/components/select/index.js +3 -3
  153. package/dist/components/sortable/index.cjs +1 -1
  154. package/dist/components/sortable/index.js +74 -74
  155. package/dist/components/textarea/index.cjs +1 -1
  156. package/dist/components/textarea/index.cjs.map +1 -1
  157. package/dist/components/textarea/index.js +24 -20
  158. package/dist/components/textarea/index.js.map +1 -1
  159. package/dist/components/toasts/index.cjs +1 -1
  160. package/dist/components/toasts/index.js +4 -4
  161. package/dist/components/toggle/index.cjs +1 -1
  162. package/dist/components/toggle/index.js +6 -6
  163. package/dist/components/toolbar/index.cjs +1 -1
  164. package/dist/components/toolbar/index.js +1 -1
  165. package/dist/components/tooltip/index.cjs +1 -1
  166. package/dist/components/tooltip/index.js +1 -1
  167. package/dist/icons-DaZGJzI0.cjs +2 -0
  168. package/dist/icons-DaZGJzI0.cjs.map +1 -0
  169. package/dist/{icons-Bq3diTRm.js → icons-Dj0vEOCB.js} +2 -1
  170. package/dist/icons-Dj0vEOCB.js.map +1 -0
  171. package/dist/index-BIV5OwVJ.js +76 -0
  172. package/dist/index-BIV5OwVJ.js.map +1 -0
  173. package/dist/index-CQNlYa2P.cjs +2 -0
  174. package/dist/index-CQNlYa2P.cjs.map +1 -0
  175. package/dist/{index-DwzLUapm.js → index-CgA0NUMD.js} +35 -33
  176. package/dist/index-CgA0NUMD.js.map +1 -0
  177. package/dist/index-Dn1v0qm6.cjs +2 -0
  178. package/dist/index-Dn1v0qm6.cjs.map +1 -0
  179. package/dist/index.cjs +1 -1
  180. package/dist/index.d.ts +32 -9
  181. package/dist/index.js +2 -2
  182. package/dist/menu-popover-D1ALaiV5.cjs +2 -0
  183. package/dist/menu-popover-D1ALaiV5.cjs.map +1 -0
  184. package/dist/menu-popover-DQHDIw-8.js +74 -0
  185. package/dist/menu-popover-DQHDIw-8.js.map +1 -0
  186. package/dist/tokens.json +1 -1
  187. package/dist/use-touched-B999bBr8.js +20 -0
  188. package/dist/use-touched-B999bBr8.js.map +1 -0
  189. package/dist/use-touched-Bq5Gjbpz.cjs +2 -0
  190. package/dist/use-touched-Bq5Gjbpz.cjs.map +1 -0
  191. package/package.json +1 -1
  192. package/dist/assets/index52.css +0 -1
  193. package/dist/icons-Bq3diTRm.js.map +0 -1
  194. package/dist/icons-ovA21Oao.cjs +0 -2
  195. package/dist/icons-ovA21Oao.cjs.map +0 -1
  196. package/dist/index-BcY9DZZ8.cjs +0 -2
  197. package/dist/index-BcY9DZZ8.cjs.map +0 -1
  198. package/dist/index-CjI8oRpS.cjs +0 -2
  199. package/dist/index-CjI8oRpS.cjs.map +0 -1
  200. package/dist/index-ClZkChEh.js +0 -73
  201. package/dist/index-ClZkChEh.js.map +0 -1
  202. package/dist/index-DwzLUapm.js.map +0 -1
  203. package/dist/use-touched-DXIJVVzz.js +0 -14
  204. package/dist/use-touched-DXIJVVzz.js.map +0 -1
  205. package/dist/use-touched-D_TJ8wDc.cjs +0 -2
  206. package/dist/use-touched-D_TJ8wDc.cjs.map +0 -1
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('../../assets/index39.css');const s=require("react/jsx-runtime"),E=require("../../classix-5H4IWnMA.cjs"),a=require("react"),F=require("../button/index.cjs"),ce=require("../../icons-ovA21Oao.cjs"),X=require("../../index-BcY9DZZ8.cjs"),ue=require("../list/index.cjs"),N=require("../../index-CjI8oRpS.cjs");function V(t){return typeof t=="string"||typeof t=="number"?String(t):Array.isArray(t)?t.map(V).join(" "):a.isValidElement(t)?V(t.props.children):""}function de(t){return a.isValidElement(t)&&t.type==="option"}function pe(t){return a.isValidElement(t)&&t.type==="optgroup"}function fe(t){return a.isValidElement(t)&&t.type===a.Fragment}function me(t){return a.isValidElement(t)&&t.type===N.Select}function W(t,i,r=!1){const l=[];return a.Children.forEach(t,n=>{if(fe(n))l.push(...W(n.props.children,i,r));else if(de(n)){const c=V(n.props.children).trim(),f=n.props.value!=null?String(n.props.value):c;l.push({disabled:r||!!n.props.disabled,groupLabel:i,hidden:!!n.props.hidden,isPlaceholder:!!(n.props.hidden&&f===""),label:n.props.children,selected:!!n.props.selected,text:c,value:f})}else pe(n)&&l.push(...W(n.props.children,n.props.label,r||!!n.props.disabled))}),l}function be(t){const i=t.trim();if(!i)return null;const l=[.../[*?]/.test(i)?i:`*${i}*`].map(n=>n==="*"?".*":n==="?"?".":n.replace(/[|\\{}()[\]^$+.,]/g,"\\$&")).join("");return new RegExp(`^${l}$`,"i")}function _e(t,i){const r=be(i),l=t.filter(n=>!n.hidden&&!n.isPlaceholder);return r?l.filter(n=>r.test([n.groupLabel,n.text,n.value].filter(Boolean).join(" "))):l}function he(t,i){return t.find(r=>r.value===i)??t.find(r=>r.isPlaceholder)??t[0]}function ye(t,i,r){var l,n;return i!=null?String(i):r!=null?String(r):((l=t.find(c=>c.selected))==null?void 0:l.value)??((n=t[0])==null?void 0:n.value)??""}function xe(t){if(me(t)){const{children:i,placeholder:r,...l}=t.props;return{children:s.jsxs(s.Fragment,{children:[r&&s.jsx("option",{hidden:!0,value:"",children:r}),i]}),props:l}}return{children:t.props.children,props:t.props}}const ge="_combobox_1bqyf_3",ve="_dropdown_1bqyf_27",je="_empty_1bqyf_30",qe="_group_1bqyf_31",we="_placeholder_1bqyf_32",Se="_filter_1bqyf_40",Ce="_native_1bqyf_52",Ee="_option_1bqyf_62",Ne="_options_1bqyf_84",Ve="_panel_1bqyf_108",Le="_selected_1bqyf_132",Re="_text_1bqyf_136",$e="_trigger_1bqyf_144",Be="_minimal_1bqyf_180",Ie="_inline_1bqyf_235",De="_label_1bqyf_267",o={combobox:ge,"combobox-input":"_combobox-input_1bqyf_12",dropdown:ve,empty:je,group:qe,placeholder:we,filter:Se,native:Ce,option:Ee,options:Ne,panel:Ve,selected:Le,text:Re,trigger:$e,minimal:Be,inline:Ie,label:De,"inline-field":"_inline-field_1bqyf_273"};function Y(t,i){return{"--icon-svg":ce.iconSVG(t).replace("currentColor",i)}}const Pe=({children:t,className:i,combobox:r=!1,createOption:l,emptyLabel:n="No matches found",label:c,renderOption:f,searchPlaceholder:L="Filter",selectedItems:Z,variant:h="default",...ee})=>{const R=xe(t),{defaultValue:te,onChange:$,value:B,...ne}=R.props,g=N.sanitizeSelectProps(ne),M=a.useRef(null),Q=a.useRef(null),v=a.useId(),z=a.useRef(null),m=a.useRef(null),y=W(R.children),x=B!=null,I=ye(y,B,te),[D,P]=a.useState(()=>I),[u,p]=a.useState(!1),[j,q]=a.useState(""),w=x?String(B):D,O={default:N.resolveColor("--colors-semantic-content-secondary"),white:N.resolveColor("--color-white","white")},T=h==="minimal"?O.white:O.default,S=he(y,w),re=Y("chevron",T),le=Y("search",T),A=_e(y,j),b=j.trim(),C=!!(r&&l&&b&&l.isValid(b)),se=c&&h==="inline"?X.formatInlineLabel(c):c,G=e=>e?(f==null?void 0:f({groupLabel:e.groupLabel,isSelected:e.value===w,label:e.label,text:e.text,value:e.value}))??e.label:"Select an option";a.useEffect(()=>{!x&&!y.some(e=>e.value===D)&&P(I)},[I,D,x,y]),a.useEffect(()=>{var e;if(!u){q("");return}(e=m.current)==null||e.focus()},[u]),a.useEffect(()=>{if(!u)return;const e=d=>{var _;(_=Q.current)!=null&&_.contains(d.target)||p(!1)};return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[u]);const oe=e=>{x||P(e.target.value),$==null||$(e)},k=()=>{var e;p(!1),r||(e=M.current)==null||e.focus()},K=()=>{var e;q(""),p(!0),(e=m.current)==null||e.focus()},H=()=>{!l||!C||(l.onCreate(b),K())},ie=e=>{var U;x||P(e);const d=z.current;if(!d){k();return}const _=(U=Object.getOwnPropertyDescriptor(HTMLSelectElement.prototype,"value"))==null?void 0:U.set;_==null||_.call(d,e),d.dispatchEvent(new Event("change",{bubbles:!0})),r?K():k()},ae=e=>{e.key==="Escape"&&k(),e.key==="Enter"&&e.target===m.current&&C&&(e.preventDefault(),H())},J=s.jsxs("div",{className:E.t(o.dropdown,h==="inline"&&o.inline,h==="minimal"&&o.minimal,i),onKeyDown:ae,ref:Q,...ee,children:[s.jsx("select",{...g,"aria-hidden":"true",className:o.native,onChange:oe,ref:z,tabIndex:-1,value:w,children:R.children}),r?s.jsxs("div",{className:o.combobox,onClick:()=>{var e;return(e=m.current)==null?void 0:e.focus()},children:[Z,s.jsx("input",{"aria-autocomplete":"list","aria-expanded":u,"aria-label":g["aria-label"]??c??L,className:o["combobox-input"],disabled:g.disabled,onChange:e=>{q(e.target.value),p(!0)},onClick:()=>p(!0),onFocus:()=>p(!0),placeholder:L||void 0,ref:m,role:"combobox",type:"text",value:j})]}):s.jsx(F.Button,{"aria-expanded":u,"aria-haspopup":"dialog","aria-labelledby":c?`${v} ${v}-value`:void 0,className:E.t(o.trigger,(S==null?void 0:S.isPlaceholder)&&o.placeholder),"data-open":u?"true":void 0,disabled:g.disabled,onClick:()=>p(e=>!e),ref:M,style:re,variant:"tertiary",children:s.jsx("span",{className:o.text,id:`${v}-value`,children:G(S)})}),u&&s.jsxs("div",{className:o.panel,children:[!r&&s.jsx(X.Input,{"aria-label":"Filter",className:o.filter,icon:"search",onChange:e=>q(e.target.value),placeholder:L,ref:m,style:le,type:"search",value:j}),s.jsxs(ue.List,{"aria-label":"Dropdown",className:o.options,children:[A.map(e=>{const d=e.value===w;return s.jsx("li",{"data-component":"dropdown",children:s.jsxs(F.Button,{"aria-label":d?`${e.text}, selected`:e.text,className:E.t(o.option,d&&o.selected),disabled:e.disabled,onClick:()=>ie(e.value),variant:"tertiary",children:[s.jsx("span",{className:o.text,children:G(e)}),e.groupLabel&&s.jsx("small",{className:o.group,children:e.groupLabel})]})},`${e.groupLabel??"root"}-${e.value}`)}),C&&l&&s.jsx("li",{children:s.jsx(F.Button,{"aria-label":V(l.render(b))||b,className:o.option,onClick:H,variant:"tertiary",children:s.jsx("span",{className:o.text,children:l.render(b)})})}),A.length===0&&!C&&s.jsx("li",{className:o.empty,children:n})]})]})]});return c?s.jsxs("div",{className:E.t(o.label,h==="inline"&&o["inline-field"]),"data-component":"dropdown",children:[s.jsx("span",{id:v,children:se}),J]}):J};exports.Dropdown=Pe;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('../../assets/index37.css');const l=require("react/jsx-runtime"),g=require("../../classix-5H4IWnMA.cjs"),a=require("react"),F=require("../button/index.cjs"),de=require("../../icons-DaZGJzI0.cjs"),X=require("../../index-CQNlYa2P.cjs"),pe=require("../list/index.cjs"),E=require("../../index-Dn1v0qm6.cjs");function V(t){return typeof t=="string"||typeof t=="number"?String(t):Array.isArray(t)?t.map(V).join(" "):a.isValidElement(t)?V(t.props.children):""}function fe(t){return a.isValidElement(t)&&t.type==="option"}function me(t){return a.isValidElement(t)&&t.type==="optgroup"}function be(t){return a.isValidElement(t)&&t.type===a.Fragment}function _e(t){return a.isValidElement(t)&&t.type===E.Select}function W(t,i,r=!1){const s=[];return a.Children.forEach(t,n=>{if(be(n))s.push(...W(n.props.children,i,r));else if(fe(n)){const c=V(n.props.children).trim(),f=n.props.value!=null?String(n.props.value):c;s.push({disabled:r||!!n.props.disabled,groupLabel:i,hidden:!!n.props.hidden,isPlaceholder:!!(n.props.hidden&&f===""),label:n.props.children,selected:!!n.props.selected,text:c,value:f})}else me(n)&&s.push(...W(n.props.children,n.props.label,r||!!n.props.disabled))}),s}function he(t){const i=t.trim();if(!i)return null;const s=[.../[*?]/.test(i)?i:`*${i}*`].map(n=>n==="*"?".*":n==="?"?".":n.replace(/[|\\{}()[\]^$+.,]/g,"\\$&")).join("");return new RegExp(`^${s}$`,"i")}function ye(t,i){const r=he(i),s=t.filter(n=>!n.hidden&&!n.isPlaceholder);return r?s.filter(n=>r.test([n.groupLabel,n.text,n.value].filter(Boolean).join(" "))):s}function xe(t,i){return t.find(r=>r.value===i)??t.find(r=>r.isPlaceholder)??t[0]}function ge(t,i,r){var s,n;return i!=null?String(i):r!=null?String(r):((s=t.find(c=>c.selected))==null?void 0:s.value)??((n=t[0])==null?void 0:n.value)??""}function je(t){if(_e(t)){const{children:i,placeholder:r,...s}=t.props;return{children:l.jsxs(l.Fragment,{children:[r&&l.jsx("option",{hidden:!0,value:"",children:r}),i]}),props:s}}return{children:t.props.children,props:t.props}}const ve="_combobox_jkdyb_3",we="_dropdown_jkdyb_27",ke="_empty_jkdyb_30",Se="_group_jkdyb_31",Ne="_placeholder_jkdyb_32",Ce="_filter_jkdyb_40",Ee="_native_jkdyb_52",Ve="_option_jkdyb_62",Le="_options_jkdyb_84",Re="_panel_jkdyb_108",$e="_selected_jkdyb_132",Be="_text_jkdyb_136",Ie="_trigger_jkdyb_144",qe="_minimal_jkdyb_180",Pe="_inline_jkdyb_235",De="_label_jkdyb_267",o={combobox:ve,"combobox-input":"_combobox-input_jkdyb_12",dropdown:we,empty:ke,group:Se,placeholder:Ne,filter:Ce,native:Ee,option:Ve,options:Le,panel:Re,selected:$e,text:Be,trigger:Ie,minimal:qe,inline:Pe,label:De,"inline-field":"_inline-field_jkdyb_273"};function Y(t,i){return{"--icon-svg":de.iconSVG(t).replace("currentColor",i)}}const Fe=({children:t,className:i,combobox:r=!1,createOption:s,emptyLabel:n="No matches found",label:c,renderOption:f,searchPlaceholder:L="Filter",selectedItems:Z,variant:h="default",...ee})=>{const R=je(t),{defaultValue:te,onChange:$,value:B,...ne}=R.props,j=E.sanitizeSelectProps(ne),{className:re,...se}=j,M=a.useRef(null),Q=a.useRef(null),v=a.useId(),z=a.useRef(null),m=a.useRef(null),y=W(R.children),x=B!=null,I=ge(y,B,te),[q,P]=a.useState(()=>I),[u,p]=a.useState(!1),[w,k]=a.useState(""),S=x?String(B):q,O={default:E.resolveColor("--colors-semantic-content-secondary"),white:E.resolveColor("--color-white","white")},T=h==="minimal"?O.white:O.default,N=xe(y,S),le=Y("chevron",T),oe=Y("search",T),A=ye(y,w),b=w.trim(),C=!!(r&&s&&b&&s.isValid(b)),ie=c&&h==="inline"?X.formatInlineLabel(c):c,G=e=>e?(f==null?void 0:f({groupLabel:e.groupLabel,isSelected:e.value===S,label:e.label,text:e.text,value:e.value}))??e.label:"Select an option";a.useEffect(()=>{!x&&!y.some(e=>e.value===q)&&P(I)},[I,q,x,y]),a.useEffect(()=>{var e;if(!u){k("");return}(e=m.current)==null||e.focus()},[u]),a.useEffect(()=>{if(!u)return;const e=d=>{var _;(_=Q.current)!=null&&_.contains(d.target)||p(!1)};return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[u]);const ae=e=>{x||P(e.target.value),$==null||$(e)},D=()=>{var e;p(!1),r||(e=M.current)==null||e.focus()},K=()=>{var e;k(""),p(!0),(e=m.current)==null||e.focus()},H=()=>{!s||!C||(s.onCreate(b),K())},ce=e=>{var U;x||P(e);const d=z.current;if(!d){D();return}const _=(U=Object.getOwnPropertyDescriptor(HTMLSelectElement.prototype,"value"))==null?void 0:U.set;_==null||_.call(d,e),d.dispatchEvent(new Event("change",{bubbles:!0})),r?K():D()},ue=e=>{e.key==="Escape"&&D(),e.key==="Enter"&&e.target===m.current&&C&&(e.preventDefault(),H())},J=l.jsxs("div",{className:g.t(o.dropdown,h==="inline"&&o.inline,h==="minimal"&&o.minimal,i),onKeyDown:ue,ref:Q,...ee,children:[l.jsx("select",{...se,"aria-hidden":"true",className:g.t(o.native,re),onChange:ae,ref:z,tabIndex:-1,value:S,children:R.children}),r?l.jsxs("div",{className:o.combobox,onClick:()=>{var e;return(e=m.current)==null?void 0:e.focus()},children:[Z,l.jsx("input",{"aria-autocomplete":"list","aria-expanded":u,"aria-label":j["aria-label"]??c??L,className:o["combobox-input"],disabled:j.disabled,onChange:e=>{k(e.target.value),p(!0)},onClick:()=>p(!0),onFocus:()=>p(!0),placeholder:L||void 0,ref:m,role:"combobox",type:"text",value:w})]}):l.jsx(F.Button,{"aria-expanded":u,"aria-haspopup":"dialog","aria-labelledby":c?`${v} ${v}-value`:void 0,className:g.t(o.trigger,(N==null?void 0:N.isPlaceholder)&&o.placeholder),"data-open":u?"true":void 0,disabled:j.disabled,onClick:()=>p(e=>!e),ref:M,style:le,variant:"tertiary",children:l.jsx("span",{className:o.text,id:`${v}-value`,children:G(N)})}),u&&l.jsxs("div",{className:o.panel,children:[!r&&l.jsx(X.Input,{"aria-label":"Filter",className:o.filter,icon:"search",onChange:e=>k(e.target.value),placeholder:L,ref:m,style:oe,type:"search",value:w}),l.jsxs(pe.List,{"aria-label":"Dropdown",className:o.options,children:[A.map(e=>{const d=e.value===S;return l.jsx("li",{"data-component":"dropdown",children:l.jsxs(F.Button,{"aria-label":d?`${e.text}, selected`:e.text,className:g.t(o.option,d&&o.selected),disabled:e.disabled,onClick:()=>ce(e.value),variant:"tertiary",children:[l.jsx("span",{className:o.text,children:G(e)}),e.groupLabel&&l.jsx("small",{className:o.group,children:e.groupLabel})]})},`${e.groupLabel??"root"}-${e.value}`)}),C&&s&&l.jsx("li",{children:l.jsx(F.Button,{"aria-label":V(s.render(b))||b,className:o.option,onClick:H,variant:"tertiary",children:l.jsx("span",{className:o.text,children:s.render(b)})})}),A.length===0&&!C&&l.jsx("li",{className:o.empty,children:n})]})]})]});return c?l.jsxs("div",{className:g.t(o.label,h==="inline"&&o["inline-field"]),"data-component":"dropdown",children:[l.jsx("span",{id:v,children:ie}),J]}):J};exports.Dropdown=Fe;
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../../../src/components/dropdown/options.tsx","../../../src/components/dropdown/index.tsx"],"sourcesContent":["import React, { Children, isValidElement } from 'react';\n\nimport { Select, type SelectProps } from '@/components/select';\n\ntype NativeSelectProps = Omit<React.ComponentPropsWithoutRef<'select'>, 'children' | 'multiple'> & {\n children: React.ReactNode;\n multiple?: false;\n};\n\ntype NativeSelectElement = React.ReactElement<NativeSelectProps, 'select'>;\ntype WrappedSelectElement = React.ReactElement<SelectProps, typeof Select>;\n\nexport type DropdownSelectElement = NativeSelectElement | WrappedSelectElement;\n\nexport type DropdownOption = {\n disabled: boolean;\n groupLabel?: string;\n hidden: boolean;\n isPlaceholder: boolean;\n label: React.ReactNode;\n selected: boolean;\n text: string;\n value: string;\n};\n\nexport type DropdownRenderOption = Pick<\n DropdownOption,\n 'groupLabel' | 'label' | 'text' | 'value'\n> & {\n isSelected: boolean;\n};\n\nexport function getNodeText(node: React.ReactNode): string {\n if (typeof node === 'string' || typeof node === 'number') return String(node);\n if (Array.isArray(node)) return node.map(getNodeText).join(' ');\n if (isValidElement<{ children?: React.ReactNode }>(node)) return getNodeText(node.props.children);\n return '';\n}\n\nfunction isOptionElement(\n node: React.ReactNode\n): node is React.ReactElement<React.ComponentPropsWithoutRef<'option'>, 'option'> {\n return isValidElement(node) && node.type === 'option';\n}\n\nfunction isOptGroupElement(\n node: React.ReactNode\n): node is React.ReactElement<React.ComponentPropsWithoutRef<'optgroup'>, 'optgroup'> {\n return isValidElement(node) && node.type === 'optgroup';\n}\n\nfunction isFragmentElement(\n node: React.ReactNode\n): node is React.ReactElement<{ children?: React.ReactNode }, typeof React.Fragment> {\n return isValidElement(node) && node.type === React.Fragment;\n}\n\nfunction isWrappedSelectElement(node: React.ReactNode): node is WrappedSelectElement {\n return isValidElement(node) && node.type === Select;\n}\n\nexport function extractOptions(\n children: React.ReactNode,\n groupLabel?: string,\n groupDisabled = false\n): DropdownOption[] {\n const options: DropdownOption[] = [];\n\n Children.forEach(children, (child) => {\n if (isFragmentElement(child)) {\n options.push(...extractOptions(child.props.children, groupLabel, groupDisabled));\n } else if (isOptionElement(child)) {\n const text = getNodeText(child.props.children).trim();\n const value = child.props.value != null ? String(child.props.value) : text;\n options.push({\n disabled: groupDisabled || Boolean(child.props.disabled),\n groupLabel,\n hidden: Boolean(child.props.hidden),\n isPlaceholder: Boolean(child.props.hidden && value === ''),\n label: child.props.children,\n selected: Boolean(child.props.selected),\n text,\n value,\n });\n } else if (isOptGroupElement(child)) {\n options.push(\n ...extractOptions(\n child.props.children,\n child.props.label,\n groupDisabled || Boolean(child.props.disabled)\n )\n );\n }\n });\n\n return options;\n}\n\nfunction buildWildcardMatcher(query: string) {\n const trimmedQuery = query.trim();\n if (!trimmedQuery) return null;\n\n const wildcardQuery = /[*?]/.test(trimmedQuery) ? trimmedQuery : `*${trimmedQuery}*`;\n const expression = [...wildcardQuery]\n .map((character) => {\n if (character === '*') return '.*';\n if (character === '?') return '.';\n return character.replace(/[|\\\\{}()[\\]^$+.,]/g, '\\\\$&');\n })\n .join('');\n\n return new RegExp(`^${expression}$`, 'i');\n}\n\nexport function filterOptions(options: DropdownOption[], query: string) {\n const matcher = buildWildcardMatcher(query);\n const selectableOptions = options.filter((option) => !option.hidden && !option.isPlaceholder);\n return matcher\n ? selectableOptions.filter((option) =>\n matcher.test([option.groupLabel, option.text, option.value].filter(Boolean).join(' '))\n )\n : selectableOptions;\n}\n\nexport function getDisplayOption(options: DropdownOption[], selectedValue: string) {\n return (\n options.find((option) => option.value === selectedValue) ??\n options.find((option) => option.isPlaceholder) ??\n options[0]\n );\n}\n\nexport function getInitialValue(\n options: DropdownOption[],\n value?: NativeSelectProps['value'],\n defaultValue?: NativeSelectProps['defaultValue']\n) {\n if (value != null) return String(value);\n if (defaultValue != null) return String(defaultValue);\n return options.find((option) => option.selected)?.value ?? options[0]?.value ?? '';\n}\n\nexport function normalizeSelectElement(selectElement: DropdownSelectElement) {\n if (isWrappedSelectElement(selectElement)) {\n const { children, placeholder, ...props } = selectElement.props;\n return {\n children: (\n <>\n {placeholder && (\n <option\n hidden\n value=''\n >\n {placeholder}\n </option>\n )}\n {children}\n </>\n ),\n props,\n };\n }\n\n return { children: selectElement.props.children, props: selectElement.props };\n}\n","import cx from 'classix';\nimport React, { useEffect, useId, useRef, useState } from 'react';\n\nimport { Button } from '@/components/button';\nimport { type IconName, iconSVG } from '@/components/icon/icons';\nimport { Input } from '@/components/input';\nimport { List } from '@/components/list';\nimport { sanitizeSelectProps } from '@/components/select/sanitize-select-props';\nimport { resolveColor } from '@/lib/color';\nimport { formatInlineLabel } from '@/lib/text';\n\nimport {\n type DropdownOption,\n type DropdownRenderOption,\n type DropdownSelectElement,\n extractOptions,\n filterOptions,\n getDisplayOption,\n getInitialValue,\n getNodeText,\n normalizeSelectElement,\n} from './options';\nimport styles from './styles.module.css';\n\nexport type { DropdownRenderOption } from './options';\n\nexport type DropdownCreateOption = {\n isValid: (value: string) => boolean;\n onCreate: (value: string) => void;\n render: (value: string) => React.ReactNode;\n};\n\nexport type DropdownProps = Omit<React.ComponentPropsWithoutRef<'div'>, 'children'> & {\n children: DropdownSelectElement;\n combobox?: boolean;\n createOption?: DropdownCreateOption;\n emptyLabel?: string;\n label?: string;\n renderOption?: (option: DropdownRenderOption) => React.ReactNode;\n searchPlaceholder?: string;\n selectedItems?: React.ReactNode;\n variant?: 'default' | 'inline' | 'minimal';\n};\n\ntype withVars = React.CSSProperties & {\n '--icon-svg'?: string;\n};\n\nfunction getIconWithVars(icon: IconName, color: string): withVars {\n return {\n '--icon-svg': iconSVG(icon).replace('currentColor', color),\n };\n}\n\nexport const Dropdown = ({\n children: selectElement,\n className,\n combobox = false,\n createOption,\n emptyLabel = 'No matches found',\n label,\n renderOption,\n searchPlaceholder = 'Filter',\n selectedItems,\n variant = 'default',\n ...props\n}: DropdownProps) => {\n const normalizedSelect = normalizeSelectElement(selectElement);\n const { defaultValue, onChange, value, ...restSelectProps } = normalizedSelect.props;\n const selectProps = sanitizeSelectProps(restSelectProps);\n const buttonRef = useRef<HTMLButtonElement>(null);\n const containerRef = useRef<HTMLDivElement>(null);\n const labelId = useId();\n const nativeSelectRef = useRef<HTMLSelectElement>(null);\n const searchRef = useRef<HTMLInputElement>(null);\n const options = extractOptions(normalizedSelect.children);\n const isControlled = value != null;\n const initialValue = getInitialValue(options, value, defaultValue);\n const [internalValue, setInternalValue] = useState(() => initialValue);\n const [isOpen, setIsOpen] = useState(false);\n const [query, setQuery] = useState('');\n const selectedValue = isControlled ? String(value) : internalValue;\n const iconColors = {\n default: resolveColor('--colors-semantic-content-secondary'),\n white: resolveColor('--color-white', 'white'),\n };\n const dropdownIconColor = variant === 'minimal' ? iconColors.white : iconColors.default;\n const displayOption = getDisplayOption(options, selectedValue);\n const triggerWithVars = getIconWithVars('chevron', dropdownIconColor);\n const filterWithVars = getIconWithVars('search', dropdownIconColor);\n const filteredOptions = filterOptions(options, query);\n const customValue = query.trim();\n const canCreateOption = Boolean(\n combobox && createOption && customValue && createOption.isValid(customValue)\n );\n const displayLabel = label && variant === 'inline' ? formatInlineLabel(label) : label;\n const renderDropdownOption = (option: DropdownOption | undefined) => {\n if (!option) return 'Select an option';\n\n return (\n renderOption?.({\n groupLabel: option.groupLabel,\n isSelected: option.value === selectedValue,\n label: option.label,\n text: option.text,\n value: option.value,\n }) ?? option.label\n );\n };\n\n useEffect(() => {\n if (!isControlled && !options.some((option) => option.value === internalValue)) {\n setInternalValue(initialValue);\n }\n }, [initialValue, internalValue, isControlled, options]);\n\n useEffect(() => {\n if (!isOpen) {\n setQuery('');\n return;\n }\n\n searchRef.current?.focus();\n }, [isOpen]);\n\n useEffect(() => {\n if (!isOpen) {\n return;\n }\n\n const handlePointerDown = (event: MouseEvent) => {\n if (!containerRef.current?.contains(event.target as Node)) {\n setIsOpen(false);\n }\n };\n\n document.addEventListener('mousedown', handlePointerDown);\n\n return () => {\n document.removeEventListener('mousedown', handlePointerDown);\n };\n }, [isOpen]);\n\n const handleNativeChange = (event: React.ChangeEvent<HTMLSelectElement>) => {\n if (!isControlled) {\n setInternalValue(event.target.value);\n }\n\n onChange?.(event);\n };\n\n const closeMenu = () => {\n setIsOpen(false);\n if (!combobox) {\n buttonRef.current?.focus();\n }\n };\n\n const continueComboboxSelection = () => {\n setQuery('');\n setIsOpen(true);\n searchRef.current?.focus();\n };\n\n const commitCustomValue = () => {\n if (!createOption || !canCreateOption) return;\n\n createOption.onCreate(customValue);\n continueComboboxSelection();\n };\n\n const commitValue = (nextValue: string) => {\n if (!isControlled) {\n setInternalValue(nextValue);\n }\n\n const nativeSelect = nativeSelectRef.current;\n\n if (!nativeSelect) {\n closeMenu();\n return;\n }\n\n const valueSetter = Object.getOwnPropertyDescriptor(HTMLSelectElement.prototype, 'value')?.set;\n\n valueSetter?.call(nativeSelect, nextValue);\n nativeSelect.dispatchEvent(new Event('change', { bubbles: true }));\n if (combobox) {\n continueComboboxSelection();\n } else {\n closeMenu();\n }\n };\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (event.key === 'Escape') {\n closeMenu();\n }\n\n if (event.key === 'Enter' && event.target === searchRef.current && canCreateOption) {\n event.preventDefault();\n commitCustomValue();\n }\n };\n\n const dropdown = (\n <div\n className={cx(\n styles.dropdown,\n variant === 'inline' && styles.inline,\n variant === 'minimal' && styles.minimal,\n className\n )}\n onKeyDown={handleKeyDown}\n ref={containerRef}\n {...props}\n >\n <select\n {...selectProps}\n aria-hidden='true'\n className={styles.native}\n onChange={handleNativeChange}\n ref={nativeSelectRef}\n tabIndex={-1}\n value={selectedValue}\n >\n {normalizedSelect.children}\n </select>\n {combobox ? (\n <div\n className={styles.combobox}\n onClick={() => searchRef.current?.focus()}\n >\n {selectedItems}\n <input\n aria-autocomplete='list'\n aria-expanded={isOpen}\n aria-label={selectProps['aria-label'] ?? label ?? searchPlaceholder}\n className={styles['combobox-input']}\n disabled={selectProps.disabled}\n onChange={(event) => {\n setQuery(event.target.value);\n setIsOpen(true);\n }}\n onClick={() => setIsOpen(true)}\n onFocus={() => setIsOpen(true)}\n placeholder={searchPlaceholder || undefined}\n ref={searchRef}\n role='combobox'\n type='text'\n value={query}\n />\n </div>\n ) : (\n <Button\n aria-expanded={isOpen}\n aria-haspopup='dialog'\n aria-labelledby={label ? `${labelId} ${labelId}-value` : undefined}\n className={cx(styles.trigger, displayOption?.isPlaceholder && styles.placeholder)}\n data-open={isOpen ? 'true' : undefined}\n disabled={selectProps.disabled}\n onClick={() => setIsOpen((currentValue) => !currentValue)}\n ref={buttonRef}\n style={triggerWithVars}\n variant='tertiary'\n >\n <span\n className={styles.text}\n id={`${labelId}-value`}\n >\n {renderDropdownOption(displayOption)}\n </span>\n </Button>\n )}\n {isOpen && (\n <div className={styles.panel}>\n {!combobox && (\n <Input\n aria-label='Filter'\n className={styles.filter}\n icon='search'\n onChange={(event) => setQuery(event.target.value)}\n placeholder={searchPlaceholder}\n ref={searchRef}\n style={filterWithVars}\n type='search'\n value={query}\n />\n )}\n <List\n aria-label='Dropdown'\n className={styles.options}\n >\n {filteredOptions.map((option) => {\n const isSelected = option.value === selectedValue;\n\n return (\n <li key={`${option.groupLabel ?? 'root'}-${option.value}`}>\n <Button\n aria-label={isSelected ? `${option.text}, selected` : option.text}\n className={cx(styles.option, isSelected && styles.selected)}\n disabled={option.disabled}\n onClick={() => commitValue(option.value)}\n variant='tertiary'\n >\n <span className={styles.text}>{renderDropdownOption(option)}</span>\n {option.groupLabel && (\n <small className={styles.group}>{option.groupLabel}</small>\n )}\n </Button>\n </li>\n );\n })}\n {canCreateOption && createOption && (\n <li>\n <Button\n aria-label={getNodeText(createOption.render(customValue)) || customValue}\n className={styles.option}\n onClick={commitCustomValue}\n variant='tertiary'\n >\n <span className={styles.text}>{createOption.render(customValue)}</span>\n </Button>\n </li>\n )}\n {filteredOptions.length === 0 && !canCreateOption && (\n <li className={styles.empty}>{emptyLabel}</li>\n )}\n </List>\n </div>\n )}\n </div>\n );\n\n return label ? (\n <div className={cx(styles.label, variant === 'inline' && styles['inline-field'])}>\n <span id={labelId}>{displayLabel}</span>\n {dropdown}\n </div>\n ) : (\n dropdown\n );\n};\n"],"names":["getNodeText","node","String","Array","isArray","map","join","isValidElement","props","children","isOptionElement","type","isOptGroupElement","isFragmentElement","React","Fragment","isWrappedSelectElement","Select","extractOptions","groupLabel","groupDisabled","options","Children","forEach","child","push","text","trim","value","disabled","Boolean","hidden","isPlaceholder","label","selected","buildWildcardMatcher","query","trimmedQuery","expression","test","character","replace","RegExp","filterOptions","matcher","selectableOptions","filter","option","getDisplayOption","selectedValue","find","getInitialValue","defaultValue","normalizeSelectElement","selectElement","placeholder","jsxs","getIconWithVars","icon","color","iconSVG","Dropdown","className","combobox","createOption","emptyLabel","renderOption","searchPlaceholder","selectedItems","variant","normalizedSelect","onChange","restSelectProps","selectProps","sanitizeSelectProps","buttonRef","useRef","containerRef","labelId","useId","nativeSelectRef","searchRef","isControlled","initialValue","internalValue","setInternalValue","useState","isOpen","setIsOpen","setQuery","iconColors","default","resolveColor","white","dropdownIconColor","displayOption","triggerWithVars","filterWithVars","filteredOptions","customValue","canCreateOption","isValid","displayLabel","formatInlineLabel","renderDropdownOption","isSelected","useEffect","some","current","focus","handlePointerDown","event","contains","target","document","addEventListener","removeEventListener","handleNativeChange","closeMenu","continueComboboxSelection","commitCustomValue","onCreate","commitValue","nextValue","nativeSelect","valueSetter","Object","getOwnPropertyDescriptor","HTMLSelectElement","prototype","set","call","dispatchEvent","Event","bubbles","handleKeyDown","key","preventDefault","dropdown","cx","styles","inline","minimal","jsx","native","undefined","Button","trigger","currentValue","panel","Input","List","group","render","length","empty"],"mappings":"oWAgCO,SAASA,EAAYC,EAA+B,CACzD,OAAI,OAAOA,GAAS,UAAY,OAAOA,GAAS,SAAiBC,OAAOD,CAAI,EACxEE,MAAMC,QAAQ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OAClB,QAASyE,EACT,QAAQ,WAER,eAAC,OAAA,CAAK,UAAWoB,EAAOlH,KAAOsC,SAAAA,EAAayF,OAAOtD,CAAW,CAAA,CAAE,EAClE,EACF,EAEDD,EAAgBwD,SAAW,GAAK,CAACtD,SAC/B,KAAA,CAAG,UAAWwC,EAAOe,MAAQ1F,SAAAA,CAAAA,CAAW,CAAA,CAAA,CAE7C,CAAA,CAAA,CACF,CAAA,EAEJ,EAGF,OAAOhC,EACLuB,EAAAA,KAAC,MAAA,CAAI,UAAWmF,EAAAA,EAAGC,EAAO3G,MAAOoC,IAAY,UAAYuE,EAAO,cAAc,CAAC,EAAE,iBAAA,WAC/E,SAAA,CAAAG,EAAAA,IAAC,OAAA,CAAK,GAAIjE,EAAUwB,SAAAA,GAAa,EAChCoC,CAAAA,CAAAA,CACH,EAEAA,CAEJ"}
1
+ {"version":3,"file":"index.cjs","sources":["../../../src/components/dropdown/options.tsx","../../../src/components/dropdown/index.tsx"],"sourcesContent":["import React, { Children, isValidElement } from 'react';\n\nimport { Select, type SelectProps } from '@/components/select';\n\ntype NativeSelectProps = Omit<React.ComponentPropsWithoutRef<'select'>, 'children' | 'multiple'> & {\n children: React.ReactNode;\n multiple?: false;\n};\n\ntype NativeSelectElement = React.ReactElement<NativeSelectProps, 'select'>;\ntype WrappedSelectElement = React.ReactElement<SelectProps, typeof Select>;\n\nexport type DropdownSelectElement = NativeSelectElement | WrappedSelectElement;\n\nexport type DropdownOption = {\n disabled: boolean;\n groupLabel?: string;\n hidden: boolean;\n isPlaceholder: boolean;\n label: React.ReactNode;\n selected: boolean;\n text: string;\n value: string;\n};\n\nexport type DropdownRenderOption = Pick<\n DropdownOption,\n 'groupLabel' | 'label' | 'text' | 'value'\n> & {\n isSelected: boolean;\n};\n\nexport function getNodeText(node: React.ReactNode): string {\n if (typeof node === 'string' || typeof node === 'number') return String(node);\n if (Array.isArray(node)) return node.map(getNodeText).join(' ');\n if (isValidElement<{ children?: React.ReactNode }>(node)) return getNodeText(node.props.children);\n return '';\n}\n\nfunction isOptionElement(\n node: React.ReactNode\n): node is React.ReactElement<React.ComponentPropsWithoutRef<'option'>, 'option'> {\n return isValidElement(node) && node.type === 'option';\n}\n\nfunction isOptGroupElement(\n node: React.ReactNode\n): node is React.ReactElement<React.ComponentPropsWithoutRef<'optgroup'>, 'optgroup'> {\n return isValidElement(node) && node.type === 'optgroup';\n}\n\nfunction isFragmentElement(\n node: React.ReactNode\n): node is React.ReactElement<{ children?: React.ReactNode }, typeof React.Fragment> {\n return isValidElement(node) && node.type === React.Fragment;\n}\n\nfunction isWrappedSelectElement(node: React.ReactNode): node is WrappedSelectElement {\n return isValidElement(node) && node.type === Select;\n}\n\nexport function extractOptions(\n children: React.ReactNode,\n groupLabel?: string,\n groupDisabled = false\n): DropdownOption[] {\n const options: DropdownOption[] = [];\n\n Children.forEach(children, (child) => {\n if (isFragmentElement(child)) {\n options.push(...extractOptions(child.props.children, groupLabel, groupDisabled));\n } else if (isOptionElement(child)) {\n const text = getNodeText(child.props.children).trim();\n const value = child.props.value != null ? String(child.props.value) : text;\n options.push({\n disabled: groupDisabled || Boolean(child.props.disabled),\n groupLabel,\n hidden: Boolean(child.props.hidden),\n isPlaceholder: Boolean(child.props.hidden && value === ''),\n label: child.props.children,\n selected: Boolean(child.props.selected),\n text,\n value,\n });\n } else if (isOptGroupElement(child)) {\n options.push(\n ...extractOptions(\n child.props.children,\n child.props.label,\n groupDisabled || Boolean(child.props.disabled)\n )\n );\n }\n });\n\n return options;\n}\n\nfunction buildWildcardMatcher(query: string) {\n const trimmedQuery = query.trim();\n if (!trimmedQuery) return null;\n\n const wildcardQuery = /[*?]/.test(trimmedQuery) ? trimmedQuery : `*${trimmedQuery}*`;\n const expression = [...wildcardQuery]\n .map((character) => {\n if (character === '*') return '.*';\n if (character === '?') return '.';\n return character.replace(/[|\\\\{}()[\\]^$+.,]/g, '\\\\$&');\n })\n .join('');\n\n return new RegExp(`^${expression}$`, 'i');\n}\n\nexport function filterOptions(options: DropdownOption[], query: string) {\n const matcher = buildWildcardMatcher(query);\n const selectableOptions = options.filter((option) => !option.hidden && !option.isPlaceholder);\n return matcher\n ? selectableOptions.filter((option) =>\n matcher.test([option.groupLabel, option.text, option.value].filter(Boolean).join(' '))\n )\n : selectableOptions;\n}\n\nexport function getDisplayOption(options: DropdownOption[], selectedValue: string) {\n return (\n options.find((option) => option.value === selectedValue) ??\n options.find((option) => option.isPlaceholder) ??\n options[0]\n );\n}\n\nexport function getInitialValue(\n options: DropdownOption[],\n value?: NativeSelectProps['value'],\n defaultValue?: NativeSelectProps['defaultValue']\n) {\n if (value != null) return String(value);\n if (defaultValue != null) return String(defaultValue);\n return options.find((option) => option.selected)?.value ?? options[0]?.value ?? '';\n}\n\nexport function normalizeSelectElement(selectElement: DropdownSelectElement) {\n if (isWrappedSelectElement(selectElement)) {\n const { children, placeholder, ...props } = selectElement.props;\n return {\n children: (\n <>\n {placeholder && (\n <option\n hidden\n value=''\n >\n {placeholder}\n </option>\n )}\n {children}\n </>\n ),\n props,\n };\n }\n\n return { children: selectElement.props.children, props: selectElement.props };\n}\n","import cx from 'classix';\nimport React, { useEffect, useId, useRef, useState } from 'react';\n\nimport { Button } from '@/components/button';\nimport { type IconName, iconSVG } from '@/components/icon/icons';\nimport { Input } from '@/components/input';\nimport { List } from '@/components/list';\nimport { sanitizeSelectProps } from '@/components/select/sanitize-select-props';\nimport { resolveColor } from '@/lib/color';\nimport { formatInlineLabel } from '@/lib/text';\n\nimport {\n type DropdownOption,\n type DropdownRenderOption,\n type DropdownSelectElement,\n extractOptions,\n filterOptions,\n getDisplayOption,\n getInitialValue,\n getNodeText,\n normalizeSelectElement,\n} from './options';\nimport styles from './styles.module.css';\n\nexport type { DropdownRenderOption } from './options';\n\nexport type DropdownCreateOption = {\n isValid: (value: string) => boolean;\n onCreate: (value: string) => void;\n render: (value: string) => React.ReactNode;\n};\n\nexport type DropdownProps = Omit<React.ComponentPropsWithoutRef<'div'>, 'children'> & {\n children: DropdownSelectElement;\n combobox?: boolean;\n createOption?: DropdownCreateOption;\n emptyLabel?: string;\n label?: string;\n renderOption?: (option: DropdownRenderOption) => React.ReactNode;\n searchPlaceholder?: string;\n selectedItems?: React.ReactNode;\n variant?: 'default' | 'inline' | 'minimal';\n};\n\ntype withVars = React.CSSProperties & {\n '--icon-svg'?: string;\n};\n\nfunction getIconWithVars(icon: IconName, color: string): withVars {\n return {\n '--icon-svg': iconSVG(icon).replace('currentColor', color),\n };\n}\n\nexport const Dropdown = ({\n children: selectElement,\n className,\n combobox = false,\n createOption,\n emptyLabel = 'No matches found',\n label,\n renderOption,\n searchPlaceholder = 'Filter',\n selectedItems,\n variant = 'default',\n ...props\n}: DropdownProps) => {\n const normalizedSelect = normalizeSelectElement(selectElement);\n const { defaultValue, onChange, value, ...restSelectProps } = normalizedSelect.props;\n const selectProps = sanitizeSelectProps(restSelectProps);\n const { className: selectClassName, ...nativeSelectProps } = selectProps;\n const buttonRef = useRef<HTMLButtonElement>(null);\n const containerRef = useRef<HTMLDivElement>(null);\n const labelId = useId();\n const nativeSelectRef = useRef<HTMLSelectElement>(null);\n const searchRef = useRef<HTMLInputElement>(null);\n const options = extractOptions(normalizedSelect.children);\n const isControlled = value != null;\n const initialValue = getInitialValue(options, value, defaultValue);\n const [internalValue, setInternalValue] = useState(() => initialValue);\n const [isOpen, setIsOpen] = useState(false);\n const [query, setQuery] = useState('');\n const selectedValue = isControlled ? String(value) : internalValue;\n const iconColors = {\n default: resolveColor('--colors-semantic-content-secondary'),\n white: resolveColor('--color-white', 'white'),\n };\n const dropdownIconColor = variant === 'minimal' ? iconColors.white : iconColors.default;\n const displayOption = getDisplayOption(options, selectedValue);\n const triggerWithVars = getIconWithVars('chevron', dropdownIconColor);\n const filterWithVars = getIconWithVars('search', dropdownIconColor);\n const filteredOptions = filterOptions(options, query);\n const customValue = query.trim();\n const canCreateOption = Boolean(\n combobox && createOption && customValue && createOption.isValid(customValue)\n );\n const displayLabel = label && variant === 'inline' ? formatInlineLabel(label) : label;\n const renderDropdownOption = (option: DropdownOption | undefined) => {\n if (!option) return 'Select an option';\n\n return (\n renderOption?.({\n groupLabel: option.groupLabel,\n isSelected: option.value === selectedValue,\n label: option.label,\n text: option.text,\n value: option.value,\n }) ?? option.label\n );\n };\n\n useEffect(() => {\n if (!isControlled && !options.some((option) => option.value === internalValue)) {\n setInternalValue(initialValue);\n }\n }, [initialValue, internalValue, isControlled, options]);\n\n useEffect(() => {\n if (!isOpen) {\n setQuery('');\n return;\n }\n\n searchRef.current?.focus();\n }, [isOpen]);\n\n useEffect(() => {\n if (!isOpen) {\n return;\n }\n\n const handlePointerDown = (event: MouseEvent) => {\n if (!containerRef.current?.contains(event.target as Node)) {\n setIsOpen(false);\n }\n };\n\n document.addEventListener('mousedown', handlePointerDown);\n\n return () => {\n document.removeEventListener('mousedown', handlePointerDown);\n };\n }, [isOpen]);\n\n const handleNativeChange = (event: React.ChangeEvent<HTMLSelectElement>) => {\n if (!isControlled) {\n setInternalValue(event.target.value);\n }\n\n onChange?.(event);\n };\n\n const closeMenu = () => {\n setIsOpen(false);\n if (!combobox) {\n buttonRef.current?.focus();\n }\n };\n\n const continueComboboxSelection = () => {\n setQuery('');\n setIsOpen(true);\n searchRef.current?.focus();\n };\n\n const commitCustomValue = () => {\n if (!createOption || !canCreateOption) return;\n\n createOption.onCreate(customValue);\n continueComboboxSelection();\n };\n\n const commitValue = (nextValue: string) => {\n if (!isControlled) {\n setInternalValue(nextValue);\n }\n\n const nativeSelect = nativeSelectRef.current;\n\n if (!nativeSelect) {\n closeMenu();\n return;\n }\n\n const valueSetter = Object.getOwnPropertyDescriptor(HTMLSelectElement.prototype, 'value')?.set;\n\n valueSetter?.call(nativeSelect, nextValue);\n nativeSelect.dispatchEvent(new Event('change', { bubbles: true }));\n if (combobox) {\n continueComboboxSelection();\n } else {\n closeMenu();\n }\n };\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (event.key === 'Escape') {\n closeMenu();\n }\n\n if (event.key === 'Enter' && event.target === searchRef.current && canCreateOption) {\n event.preventDefault();\n commitCustomValue();\n }\n };\n\n const dropdown = (\n <div\n className={cx(\n styles.dropdown,\n variant === 'inline' && styles.inline,\n variant === 'minimal' && styles.minimal,\n className\n )}\n onKeyDown={handleKeyDown}\n ref={containerRef}\n {...props}\n >\n <select\n {...nativeSelectProps}\n aria-hidden='true'\n className={cx(styles.native, selectClassName)}\n onChange={handleNativeChange}\n ref={nativeSelectRef}\n tabIndex={-1}\n value={selectedValue}\n >\n {normalizedSelect.children}\n </select>\n {combobox ? (\n <div\n className={styles.combobox}\n onClick={() => searchRef.current?.focus()}\n >\n {selectedItems}\n <input\n aria-autocomplete='list'\n aria-expanded={isOpen}\n aria-label={selectProps['aria-label'] ?? label ?? searchPlaceholder}\n className={styles['combobox-input']}\n disabled={selectProps.disabled}\n onChange={(event) => {\n setQuery(event.target.value);\n setIsOpen(true);\n }}\n onClick={() => setIsOpen(true)}\n onFocus={() => setIsOpen(true)}\n placeholder={searchPlaceholder || undefined}\n ref={searchRef}\n role='combobox'\n type='text'\n value={query}\n />\n </div>\n ) : (\n <Button\n aria-expanded={isOpen}\n aria-haspopup='dialog'\n aria-labelledby={label ? `${labelId} ${labelId}-value` : undefined}\n className={cx(styles.trigger, displayOption?.isPlaceholder && styles.placeholder)}\n data-open={isOpen ? 'true' : undefined}\n disabled={selectProps.disabled}\n onClick={() => setIsOpen((currentValue) => !currentValue)}\n ref={buttonRef}\n style={triggerWithVars}\n variant='tertiary'\n >\n <span\n className={styles.text}\n id={`${labelId}-value`}\n >\n {renderDropdownOption(displayOption)}\n </span>\n </Button>\n )}\n {isOpen && (\n <div className={styles.panel}>\n {!combobox && (\n <Input\n aria-label='Filter'\n className={styles.filter}\n icon='search'\n onChange={(event) => setQuery(event.target.value)}\n placeholder={searchPlaceholder}\n ref={searchRef}\n style={filterWithVars}\n type='search'\n value={query}\n />\n )}\n <List\n aria-label='Dropdown'\n className={styles.options}\n >\n {filteredOptions.map((option) => {\n const isSelected = option.value === selectedValue;\n\n return (\n <li key={`${option.groupLabel ?? 'root'}-${option.value}`}>\n <Button\n aria-label={isSelected ? `${option.text}, selected` : option.text}\n className={cx(styles.option, isSelected && styles.selected)}\n disabled={option.disabled}\n onClick={() => commitValue(option.value)}\n variant='tertiary'\n >\n <span className={styles.text}>{renderDropdownOption(option)}</span>\n {option.groupLabel && (\n <small className={styles.group}>{option.groupLabel}</small>\n )}\n </Button>\n </li>\n );\n })}\n {canCreateOption && createOption && (\n <li>\n <Button\n aria-label={getNodeText(createOption.render(customValue)) || customValue}\n className={styles.option}\n onClick={commitCustomValue}\n variant='tertiary'\n >\n <span className={styles.text}>{createOption.render(customValue)}</span>\n </Button>\n </li>\n )}\n {filteredOptions.length === 0 && !canCreateOption && (\n <li className={styles.empty}>{emptyLabel}</li>\n )}\n </List>\n </div>\n )}\n </div>\n );\n\n return label ? (\n <div className={cx(styles.label, variant === 'inline' && styles['inline-field'])}>\n <span id={labelId}>{displayLabel}</span>\n {dropdown}\n </div>\n ) : (\n dropdown\n );\n};\n"],"names":["getNodeText","node","String","Array","isArray","map","join","isValidElement","props","children","isOptionElement","type","isOptGroupElement","isFragmentElement","React","Fragment","isWrappedSelectElement","Select","extractOptions","groupLabel","groupDisabled","options","Children","forEach","child","push","text","trim","value","disabled","Boolean","hidden","isPlaceholder","label","selected","buildWildcardMatcher","query","trimmedQuery","expression","test","character","replace","RegExp","filterOptions","matcher","selectableOptions","filter","option","getDisplayOption","selectedValue","find","getInitialValue","defaultValue","normalizeSelectElement","selectElement","placeholder","jsxs","getIconWithVars","icon","color","iconSVG","Dropdown","className","combobox","createOption","emptyLabel","renderOption","searchPlaceholder","selectedItems","variant","normalizedSelect","onChange","restSelectProps","selectProps","sanitizeSelectProps","selectClassName","nativeSelectProps","buttonRef","useRef","containerRef","labelId","useId","nativeSelectRef","searchRef","isControlled","initialValue","internalValue","setInternalValue","useState","isOpen","setIsOpen","setQuery","iconColors","default","resolveColor","white","dropdownIconColor","displayOption","triggerWithVars","filterWithVars","filteredOptions","customValue","canCreateOption","isValid","displayLabel","formatInlineLabel","renderDropdownOption","isSelected","useEffect","some","current","focus","handlePointerDown","event","contains","target","document","addEventListener","removeEventListener","handleNativeChange","closeMenu","continueComboboxSelection","commitCustomValue","onCreate","commitValue","nextValue","nativeSelect","valueSetter","Object","getOwnPropertyDescriptor","HTMLSelectElement","prototype","set","call","dispatchEvent","Event","bubbles","handleKeyDown","key","preventDefault","dropdown","cx","styles","inline","minimal","jsx","native","undefined","Button","trigger","currentValue","panel","Input","List","group","render","length","empty"],"mappings":"oWAgCO,SAASA,EAAYC,EAA+B,CACzD,OAAI,OAAOA,GAAS,UAAY,OAAOA,GAAS,SAAiBC,OAAOD,CAAI,EACxEE,MAAMC,QAAQH,CAAI,EAAUA,EAAKI,IAAIL,CAAW,EAAEM,KAAK,GAAG,EAC1DC,EAAAA,eAA+CN,CAAI,EAAUD,EAAYC,EAAKO,MAAMC,QAAQ,EACzF,EACT,CAEA,SAASC,GACPT,EACgF,CAChF,OAAOM,EAAAA,eAAeN,CAAI,GAAKA,EAAKU,OAAS,QAC/C,CAEA,SAASC,GACPX,EACoF,CACpF,OAAOM,EAAAA,eAAeN,CAAI,GAAKA,EAAKU,OAAS,UAC/C,CAEA,SAASE,GACPZ,EACmF,CACnF,OAAOM,EAAAA,eAAeN,CAAI,GAAKA,EAAKU,OAASG,EAAMC,QACrD,CAEA,SAASC,GAAuBf,EAAqD,CACnF,OAAOM,EAAAA,eAAeN,CAAI,GAAKA,EAAKU,OAASM,EAAAA,MAC/C,CAEO,SAASC,EACdT,EACAU,EACAC,EAAgB,GACE,CAClB,MAAMC,EAA4B,CAAA,EAElCC,OAAAA,EAAAA,SAASC,QAAQd,EAAWe,GAAU,CACpC,GAAIX,GAAkBW,CAAK,EACzBH,EAAQI,KAAK,GAAGP,EAAeM,EAAMhB,MAAMC,SAAUU,EAAYC,CAAa,CAAC,UACtEV,GAAgBc,CAAK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Ha.js";
3
- import fe, { Children as me, isValidElement as v, useRef as I, useId as be, useState as W, useEffect as Q } from "react";
4
- import { Button as z } from "../button/index.js";
5
- import { i as he } from "../../icons-Bq3diTRm.js";
6
- import { f as _e, I as ye } from "../../index-ClZkChEh.js";
7
- import { List as ge } from "../list/index.js";
8
- import { S as ve, s as xe, r as ee } from "../../index-DwzLUapm.js";
9
- import '../../assets/index39.css';function L(t) {
10
- return typeof t == "string" || typeof t == "number" ? String(t) : Array.isArray(t) ? t.map(L).join(" ") : v(t) ? L(t.props.children) : "";
1
+ import { jsxs as p, Fragment as me, jsx as i } from "react/jsx-runtime";
2
+ import { t as v } from "../../classix-DG18itHa.js";
3
+ import be, { Children as he, isValidElement as x, useRef as V, useId as _e, useState as Q, useEffect as z } from "react";
4
+ import { Button as M } from "../button/index.js";
5
+ import { i as ye } from "../../icons-Dj0vEOCB.js";
6
+ import { f as ge, I as ve } from "../../index-BIV5OwVJ.js";
7
+ import { List as xe } from "../list/index.js";
8
+ import { S as ke, s as we, r as ee } from "../../index-CgA0NUMD.js";
9
+ import '../../assets/index37.css';function I(t) {
10
+ return typeof t == "string" || typeof t == "number" ? String(t) : Array.isArray(t) ? t.map(I).join(" ") : x(t) ? I(t.props.children) : "";
11
11
  }
12
- function we(t) {
13
- return v(t) && t.type === "option";
12
+ function je(t) {
13
+ return x(t) && t.type === "option";
14
14
  }
15
- function Se(t) {
16
- return v(t) && t.type === "optgroup";
15
+ function Ne(t) {
16
+ return x(t) && t.type === "optgroup";
17
17
  }
18
- function qe(t) {
19
- return v(t) && t.type === fe.Fragment;
18
+ function Se(t) {
19
+ return x(t) && t.type === be.Fragment;
20
20
  }
21
- function Ne(t) {
22
- return v(t) && t.type === ve;
21
+ function Ce(t) {
22
+ return x(t) && t.type === ke;
23
23
  }
24
- function M(t, i, r = !1) {
24
+ function A(t, s, r = !1) {
25
25
  const l = [];
26
- return me.forEach(t, (n) => {
27
- if (qe(n))
28
- l.push(...M(n.props.children, i, r));
29
- else if (we(n)) {
30
- const a = L(n.props.children).trim(), f = n.props.value != null ? String(n.props.value) : a;
26
+ return he.forEach(t, (n) => {
27
+ if (Se(n))
28
+ l.push(...A(n.props.children, s, r));
29
+ else if (je(n)) {
30
+ const a = I(n.props.children).trim(), f = n.props.value != null ? String(n.props.value) : a;
31
31
  l.push({
32
32
  disabled: r || !!n.props.disabled,
33
- groupLabel: i,
33
+ groupLabel: s,
34
34
  hidden: !!n.props.hidden,
35
35
  isPlaceholder: !!(n.props.hidden && f === ""),
36
36
  label: n.props.children,
@@ -38,37 +38,37 @@ function M(t, i, r = !1) {
38
38
  text: a,
39
39
  value: f
40
40
  });
41
- } else Se(n) && l.push(...M(n.props.children, n.props.label, r || !!n.props.disabled));
41
+ } else Ne(n) && l.push(...A(n.props.children, n.props.label, r || !!n.props.disabled));
42
42
  }), l;
43
43
  }
44
- function Ce(t) {
45
- const i = t.trim();
46
- if (!i) return null;
47
- const l = [.../[*?]/.test(i) ? i : `*${i}*`].map((n) => n === "*" ? ".*" : n === "?" ? "." : n.replace(/[|\\{}()[\]^$+.,]/g, "\\$&")).join("");
44
+ function Ee(t) {
45
+ const s = t.trim();
46
+ if (!s) return null;
47
+ const l = [.../[*?]/.test(s) ? s : `*${s}*`].map((n) => n === "*" ? ".*" : n === "?" ? "." : n.replace(/[|\\{}()[\]^$+.,]/g, "\\$&")).join("");
48
48
  return new RegExp(`^${l}$`, "i");
49
49
  }
50
- function Ee(t, i) {
51
- const r = Ce(i), l = t.filter((n) => !n.hidden && !n.isPlaceholder);
50
+ function Ve(t, s) {
51
+ const r = Ee(s), l = t.filter((n) => !n.hidden && !n.isPlaceholder);
52
52
  return r ? l.filter((n) => r.test([n.groupLabel, n.text, n.value].filter(Boolean).join(" "))) : l;
53
53
  }
54
- function Ve(t, i) {
55
- return t.find((r) => r.value === i) ?? t.find((r) => r.isPlaceholder) ?? t[0];
54
+ function Ie(t, s) {
55
+ return t.find((r) => r.value === s) ?? t.find((r) => r.isPlaceholder) ?? t[0];
56
56
  }
57
- function Ie(t, i, r) {
57
+ function Le(t, s, r) {
58
58
  var l, n;
59
- return i != null ? String(i) : r != null ? String(r) : ((l = t.find((a) => a.selected)) == null ? void 0 : l.value) ?? ((n = t[0]) == null ? void 0 : n.value) ?? "";
59
+ return s != null ? String(s) : r != null ? String(r) : ((l = t.find((a) => a.selected)) == null ? void 0 : l.value) ?? ((n = t[0]) == null ? void 0 : n.value) ?? "";
60
60
  }
61
- function Le(t) {
62
- if (Ne(t)) {
61
+ function $e(t) {
62
+ if (Ce(t)) {
63
63
  const {
64
- children: i,
64
+ children: s,
65
65
  placeholder: r,
66
66
  ...l
67
67
  } = t.props;
68
68
  return {
69
- children: /* @__PURE__ */ p(pe, { children: [
70
- r && /* @__PURE__ */ s("option", { hidden: !0, value: "", children: r }),
71
- i
69
+ children: /* @__PURE__ */ p(me, { children: [
70
+ r && /* @__PURE__ */ i("option", { hidden: !0, value: "", children: r }),
71
+ s
72
72
  ] }),
73
73
  props: l
74
74
  };
@@ -78,135 +78,138 @@ function Le(t) {
78
78
  props: t.props
79
79
  };
80
80
  }
81
- const $e = "_combobox_1bqyf_3", Be = "_dropdown_1bqyf_27", ke = "_empty_1bqyf_30", De = "_group_1bqyf_31", Pe = "_placeholder_1bqyf_32", Re = "_filter_1bqyf_40", je = "_native_1bqyf_52", Fe = "_option_1bqyf_62", We = "_options_1bqyf_84", Qe = "_panel_1bqyf_108", ze = "_selected_1bqyf_132", Me = "_text_1bqyf_136", Ae = "_trigger_1bqyf_144", Ge = "_minimal_1bqyf_180", Ke = "_inline_1bqyf_235", Oe = "_label_1bqyf_267", o = {
82
- combobox: $e,
83
- "combobox-input": "_combobox-input_1bqyf_12",
84
- dropdown: Be,
85
- empty: ke,
86
- group: De,
87
- placeholder: Pe,
88
- filter: Re,
89
- native: je,
90
- option: Fe,
91
- options: We,
92
- panel: Qe,
93
- selected: ze,
94
- text: Me,
95
- trigger: Ae,
96
- minimal: Ge,
97
- inline: Ke,
98
- label: Oe,
99
- "inline-field": "_inline-field_1bqyf_273"
81
+ const Be = "_combobox_jkdyb_3", Pe = "_dropdown_jkdyb_27", De = "_empty_jkdyb_30", Re = "_group_jkdyb_31", Fe = "_placeholder_jkdyb_32", We = "_filter_jkdyb_40", Qe = "_native_jkdyb_52", ze = "_option_jkdyb_62", Me = "_options_jkdyb_84", Ae = "_panel_jkdyb_108", Ge = "_selected_jkdyb_132", Ke = "_text_jkdyb_136", Oe = "_trigger_jkdyb_144", Te = "_minimal_jkdyb_180", qe = "_inline_jkdyb_235", He = "_label_jkdyb_267", o = {
82
+ combobox: Be,
83
+ "combobox-input": "_combobox-input_jkdyb_12",
84
+ dropdown: Pe,
85
+ empty: De,
86
+ group: Re,
87
+ placeholder: Fe,
88
+ filter: We,
89
+ native: Qe,
90
+ option: ze,
91
+ options: Me,
92
+ panel: Ae,
93
+ selected: Ge,
94
+ text: Ke,
95
+ trigger: Oe,
96
+ minimal: Te,
97
+ inline: qe,
98
+ label: He,
99
+ "inline-field": "_inline-field_jkdyb_273"
100
100
  };
101
- function te(t, i) {
101
+ function te(t, s) {
102
102
  return {
103
- "--icon-svg": he(t).replace("currentColor", i)
103
+ "--icon-svg": ye(t).replace("currentColor", s)
104
104
  };
105
105
  }
106
- const tt = ({
106
+ const rt = ({
107
107
  children: t,
108
- className: i,
108
+ className: s,
109
109
  combobox: r = !1,
110
110
  createOption: l,
111
111
  emptyLabel: n = "No matches found",
112
112
  label: a,
113
113
  renderOption: f,
114
- searchPlaceholder: $ = "Filter",
114
+ searchPlaceholder: L = "Filter",
115
115
  selectedItems: ne,
116
116
  variant: _ = "default",
117
117
  ...re
118
118
  }) => {
119
- const B = Le(t), {
119
+ const $ = $e(t), {
120
120
  defaultValue: le,
121
- onChange: k,
122
- value: D,
121
+ onChange: B,
122
+ value: P,
123
123
  ...oe
124
- } = B.props, x = xe(oe), A = I(null), G = I(null), w = be(), K = I(null), m = I(null), y = M(B.children), g = D != null, P = Ie(y, D, le), [R, j] = W(() => P), [c, d] = W(!1), [S, q] = W(""), N = g ? String(D) : R, O = {
124
+ } = $.props, k = we(oe), {
125
+ className: se,
126
+ ...ie
127
+ } = k, G = V(null), K = V(null), w = _e(), O = V(null), m = V(null), y = A($.children), g = P != null, D = Le(y, P, le), [R, F] = Q(() => D), [c, u] = Q(!1), [j, N] = Q(""), S = g ? String(P) : R, T = {
125
128
  default: ee("--colors-semantic-content-secondary"),
126
129
  white: ee("--color-white", "white")
127
- }, T = _ === "minimal" ? O.white : O.default, C = Ve(y, N), ie = te("chevron", T), se = te("search", T), H = Ee(y, S), b = S.trim(), E = !!(r && l && b && l.isValid(b)), ae = a && _ === "inline" ? _e(a) : a, J = (e) => e ? (f == null ? void 0 : f({
130
+ }, q = _ === "minimal" ? T.white : T.default, C = Ie(y, S), ae = te("chevron", q), ce = te("search", q), H = Ve(y, j), b = j.trim(), E = !!(r && l && b && l.isValid(b)), de = a && _ === "inline" ? ge(a) : a, J = (e) => e ? (f == null ? void 0 : f({
128
131
  groupLabel: e.groupLabel,
129
- isSelected: e.value === N,
132
+ isSelected: e.value === S,
130
133
  label: e.label,
131
134
  text: e.text,
132
135
  value: e.value
133
136
  })) ?? e.label : "Select an option";
134
- Q(() => {
135
- !g && !y.some((e) => e.value === R) && j(P);
136
- }, [P, R, g, y]), Q(() => {
137
+ z(() => {
138
+ !g && !y.some((e) => e.value === R) && F(D);
139
+ }, [D, R, g, y]), z(() => {
137
140
  var e;
138
141
  if (!c) {
139
- q("");
142
+ N("");
140
143
  return;
141
144
  }
142
145
  (e = m.current) == null || e.focus();
143
- }, [c]), Q(() => {
146
+ }, [c]), z(() => {
144
147
  if (!c)
145
148
  return;
146
- const e = (u) => {
149
+ const e = (d) => {
147
150
  var h;
148
- (h = G.current) != null && h.contains(u.target) || d(!1);
151
+ (h = K.current) != null && h.contains(d.target) || u(!1);
149
152
  };
150
153
  return document.addEventListener("mousedown", e), () => {
151
154
  document.removeEventListener("mousedown", e);
152
155
  };
153
156
  }, [c]);
154
- const ce = (e) => {
155
- g || j(e.target.value), k == null || k(e);
156
- }, F = () => {
157
+ const ue = (e) => {
158
+ g || F(e.target.value), B == null || B(e);
159
+ }, W = () => {
157
160
  var e;
158
- d(!1), r || (e = A.current) == null || e.focus();
161
+ u(!1), r || (e = G.current) == null || e.focus();
159
162
  }, U = () => {
160
163
  var e;
161
- q(""), d(!0), (e = m.current) == null || e.focus();
164
+ N(""), u(!0), (e = m.current) == null || e.focus();
162
165
  }, X = () => {
163
166
  !l || !E || (l.onCreate(b), U());
164
- }, ue = (e) => {
167
+ }, pe = (e) => {
165
168
  var Z;
166
- g || j(e);
167
- const u = K.current;
168
- if (!u) {
169
- F();
169
+ g || F(e);
170
+ const d = O.current;
171
+ if (!d) {
172
+ W();
170
173
  return;
171
174
  }
172
175
  const h = (Z = Object.getOwnPropertyDescriptor(HTMLSelectElement.prototype, "value")) == null ? void 0 : Z.set;
173
- h == null || h.call(u, e), u.dispatchEvent(new Event("change", {
176
+ h == null || h.call(d, e), d.dispatchEvent(new Event("change", {
174
177
  bubbles: !0
175
- })), r ? U() : F();
176
- }, de = (e) => {
177
- e.key === "Escape" && F(), e.key === "Enter" && e.target === m.current && E && (e.preventDefault(), X());
178
- }, Y = /* @__PURE__ */ p("div", { className: V(o.dropdown, _ === "inline" && o.inline, _ === "minimal" && o.minimal, i), onKeyDown: de, ref: G, ...re, children: [
179
- /* @__PURE__ */ s("select", { ...x, "aria-hidden": "true", className: o.native, onChange: ce, ref: K, tabIndex: -1, value: N, children: B.children }),
178
+ })), r ? U() : W();
179
+ }, fe = (e) => {
180
+ e.key === "Escape" && W(), e.key === "Enter" && e.target === m.current && E && (e.preventDefault(), X());
181
+ }, Y = /* @__PURE__ */ p("div", { className: v(o.dropdown, _ === "inline" && o.inline, _ === "minimal" && o.minimal, s), onKeyDown: fe, ref: K, ...re, children: [
182
+ /* @__PURE__ */ i("select", { ...ie, "aria-hidden": "true", className: v(o.native, se), onChange: ue, ref: O, tabIndex: -1, value: S, children: $.children }),
180
183
  r ? /* @__PURE__ */ p("div", { className: o.combobox, onClick: () => {
181
184
  var e;
182
185
  return (e = m.current) == null ? void 0 : e.focus();
183
186
  }, children: [
184
187
  ne,
185
- /* @__PURE__ */ s("input", { "aria-autocomplete": "list", "aria-expanded": c, "aria-label": x["aria-label"] ?? a ?? $, className: o["combobox-input"], disabled: x.disabled, onChange: (e) => {
186
- q(e.target.value), d(!0);
187
- }, onClick: () => d(!0), onFocus: () => d(!0), placeholder: $ || void 0, ref: m, role: "combobox", type: "text", value: S })
188
- ] }) : /* @__PURE__ */ s(z, { "aria-expanded": c, "aria-haspopup": "dialog", "aria-labelledby": a ? `${w} ${w}-value` : void 0, className: V(o.trigger, (C == null ? void 0 : C.isPlaceholder) && o.placeholder), "data-open": c ? "true" : void 0, disabled: x.disabled, onClick: () => d((e) => !e), ref: A, style: ie, variant: "tertiary", children: /* @__PURE__ */ s("span", { className: o.text, id: `${w}-value`, children: J(C) }) }),
188
+ /* @__PURE__ */ i("input", { "aria-autocomplete": "list", "aria-expanded": c, "aria-label": k["aria-label"] ?? a ?? L, className: o["combobox-input"], disabled: k.disabled, onChange: (e) => {
189
+ N(e.target.value), u(!0);
190
+ }, onClick: () => u(!0), onFocus: () => u(!0), placeholder: L || void 0, ref: m, role: "combobox", type: "text", value: j })
191
+ ] }) : /* @__PURE__ */ i(M, { "aria-expanded": c, "aria-haspopup": "dialog", "aria-labelledby": a ? `${w} ${w}-value` : void 0, className: v(o.trigger, (C == null ? void 0 : C.isPlaceholder) && o.placeholder), "data-open": c ? "true" : void 0, disabled: k.disabled, onClick: () => u((e) => !e), ref: G, style: ae, variant: "tertiary", children: /* @__PURE__ */ i("span", { className: o.text, id: `${w}-value`, children: J(C) }) }),
189
192
  c && /* @__PURE__ */ p("div", { className: o.panel, children: [
190
- !r && /* @__PURE__ */ s(ye, { "aria-label": "Filter", className: o.filter, icon: "search", onChange: (e) => q(e.target.value), placeholder: $, ref: m, style: se, type: "search", value: S }),
191
- /* @__PURE__ */ p(ge, { "aria-label": "Dropdown", className: o.options, children: [
193
+ !r && /* @__PURE__ */ i(ve, { "aria-label": "Filter", className: o.filter, icon: "search", onChange: (e) => N(e.target.value), placeholder: L, ref: m, style: ce, type: "search", value: j }),
194
+ /* @__PURE__ */ p(xe, { "aria-label": "Dropdown", className: o.options, children: [
192
195
  H.map((e) => {
193
- const u = e.value === N;
194
- return /* @__PURE__ */ s("li", { "data-component": "dropdown", children: /* @__PURE__ */ p(z, { "aria-label": u ? `${e.text}, selected` : e.text, className: V(o.option, u && o.selected), disabled: e.disabled, onClick: () => ue(e.value), variant: "tertiary", children: [
195
- /* @__PURE__ */ s("span", { className: o.text, children: J(e) }),
196
- e.groupLabel && /* @__PURE__ */ s("small", { className: o.group, children: e.groupLabel })
196
+ const d = e.value === S;
197
+ return /* @__PURE__ */ i("li", { "data-component": "dropdown", children: /* @__PURE__ */ p(M, { "aria-label": d ? `${e.text}, selected` : e.text, className: v(o.option, d && o.selected), disabled: e.disabled, onClick: () => pe(e.value), variant: "tertiary", children: [
198
+ /* @__PURE__ */ i("span", { className: o.text, children: J(e) }),
199
+ e.groupLabel && /* @__PURE__ */ i("small", { className: o.group, children: e.groupLabel })
197
200
  ] }) }, `${e.groupLabel ?? "root"}-${e.value}`);
198
201
  }),
199
- E && l && /* @__PURE__ */ s("li", { children: /* @__PURE__ */ s(z, { "aria-label": L(l.render(b)) || b, className: o.option, onClick: X, variant: "tertiary", children: /* @__PURE__ */ s("span", { className: o.text, children: l.render(b) }) }) }),
200
- H.length === 0 && !E && /* @__PURE__ */ s("li", { className: o.empty, children: n })
202
+ E && l && /* @__PURE__ */ i("li", { children: /* @__PURE__ */ i(M, { "aria-label": I(l.render(b)) || b, className: o.option, onClick: X, variant: "tertiary", children: /* @__PURE__ */ i("span", { className: o.text, children: l.render(b) }) }) }),
203
+ H.length === 0 && !E && /* @__PURE__ */ i("li", { className: o.empty, children: n })
201
204
  ] })
202
205
  ] })
203
206
  ] });
204
- return a ? /* @__PURE__ */ p("div", { className: V(o.label, _ === "inline" && o["inline-field"]), "data-component": "dropdown", children: [
205
- /* @__PURE__ */ s("span", { id: w, children: ae }),
207
+ return a ? /* @__PURE__ */ p("div", { className: v(o.label, _ === "inline" && o["inline-field"]), "data-component": "dropdown", children: [
208
+ /* @__PURE__ */ i("span", { id: w, children: de }),
206
209
  Y
207
210
  ] }) : Y;
208
211
  };
209
212
  export {
210
- tt as Dropdown
213
+ rt as Dropdown
211
214
  };
212
215
  //# sourceMappingURL=index.js.map