@enonic/ui 0.47.2 → 0.47.3

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.
@@ -17,7 +17,7 @@ return N("input",{ref:gn(r,m),id:o,className:cn("h-5.5 w-full border-0 text-base
17
17
  return N($r,{className:cn("-mx-1.5 flex size-7 shrink-0 items-center justify-center text-subtle",e),icon:Yn,title:i,onClick:()=>{a(""),s.current?.focus()},disabled:r,iconSize:28,iconStrokeWidth:1.25,...t})};Yr.displayName="SearchFieldClear";const _r=Object.assign(Gr,{Root:Gr,Icon:qr,Input:Wr,Clear:Yr});function Ur(e,t,n="any"){if(e===t)return!0;if(null==e||null==t)return!1;if(e.length!==t.length)return!1;const r="any"===n?[...e].sort():e,o="any"===n?[...t].sort():t;for(let i=0;i<r.length;i+=1)if(r[i]!==o[i])return!1;return!0}const Zr=[],Xr=e=>t=>Ur(t,e)?t:e,Jr=({children:e,open:t,defaultOpen:n=!1,onOpenChange:r,closeOnBlur:o=!0,value:a,defaultValue:d="",onChange:m,disabled:f=!1,error:g=!1,selectionMode:p="single",selection:b,defaultSelection:v=Zr,onSelectionChange:h,active:y,defaultActive:w,setActive:x,contentType:I="auto"})=>{const k=ee(),C=u(null),[D,S]=Zn(t,n,r),[M,A]=Zn(a,d,m),R="single"!==p,O="staged"===p,[P,T]=s(()=>new Set(v)),E=void 0!==b,L=l(()=>E?new Set(b):P,[E,b,P]),$=l(()=>Array.from(L),[L]),[V,F]=s($);c(()=>{F(O?Xr($):$)},[$,O]);const K=O?V:$,H=l(()=>new Set(K),[K]),B=l(()=>O&&!Ur(V,$),[O,V,$]),j=i(()=>{O&&F(Xr($))},[O,$]),[G,q]=Xn(y,w,x),{registerItem:W,unregisterItem:Y,getItems:_,isItemDisabled:U}=tr(),[Z,X]=s(!1),J=i(e=>{A(e),S(!0)},[A,S]),Q=i(e=>{S(e),e||j()},[S,j]),te=i(e=>{const t=new Set(e);E||T(t),h?.(e),"single"===p&&S(!1)},[E,h,p,S]),ne=i(e=>{O?F(e):te(e)},[O,te]),re=i(()=>{O&&(Ur(V,$)||te(V),S(!1))},[O,V,$,te,S]),{handleKeyDown:oe}=rr({getItems:_,isItemDisabled:U,active:G,setActive:q,loop:!1,orientation:"vertical",onSelect:e=>{let t;t=R?K.includes(e)?K.filter(t=>t!==e):[...K,e]:[e],ne(t)}}),ie=i(()=>{requestAnimationFrame(()=>{const e=document.getElementById(`${k}-tree`),t=e?.querySelector('[role="tree"]');t?.focus({focusVisible:!0})})},[k]),ae=i(e=>{if(!f){if((e.metaKey||e.ctrlKey)&&"Enter"===e.key&&O)return e.preventDefault(),void re();if("ArrowDown"===e.key||"ArrowUp"===e.key){if(!D)return e.preventDefault(),S(!0),void("tree"===I&&ie());if("tree"===I)return e.preventDefault(),void ie()}if("Escape"===e.key)return e.preventDefault(),void Q(!1);"tree"!==I&&" "!==e.key&&oe(e)}},[f,D,S,Q,oe,I,ie,O,re]);c(()=>{if(D&&void 0===G){const e=_();e.length>0&&q(e[0])}},[D,G,_,q]);const se=l(()=>({open:D,setOpen:Q,inputValue:M,setInputValue:J,baseId:k,controlRef:C,active:G,setActive:q,disabled:f,error:g,closeOnBlur:o,keyHandler:ae,selection:H,appliedSelection:$,stagedSelection:V,stagingEnabled:O,hasStagedChanges:B,applyStagedSelection:re,resetStagedSelection:j,contentType:I,selectionMode:R?"multiple":"single",onSelectionChange:ne,registerItem:W,unregisterItem:Y,getItems:_,isItemDisabled:U,hasValue:Z,setHasValue:X}),[D,Q,o,ae,M,J,G,q,k,f,g,H,$,V,O,B,re,j,I,R,ne,W,Y,_,U,Z]);/* @__PURE__ */
18
18
  return N(z,"tree"===I||"listbox"===I?{value:se,children:e}:{value:se,children:/* @__PURE__ */N(jr.Root,{selectionMode:R?"multiple":"single",selection:K,onSelectionChange:ne,disabled:f,active:G,focusMode:"activedescendant",baseId:k,setActive:q,keyHandler:ae,registerItem:W,unregisterItem:Y,getItems:_,isItemDisabled:U,children:e})})};Jr.displayName="Combobox.Root";const Qr=a(({className:e,children:t,...n},r)=>{const o=u(null),{setOpen:a,closeOnBlur:s}=T(),l=i(e=>{if(!s)return;const{relatedTarget:t}=e;t instanceof Node&&o.current?.contains(t)||t instanceof Element&&t.closest("[data-combobox-popup]")||a(!1)},[a,s]);
19
19
  /* @__PURE__ */
20
- return N("div",{ref:gn(r,o),className:e,onBlur:l,...n,children:t})});Qr.displayName="Combobox.Content";const eo=M(["flex items-center gap-2.5","h-12 rounded-sm border bg-surface-neutral","focus-within:outline-none focus-within:ring-3 focus-within:ring-ring focus-within:ring-offset-3 focus-within:ring-offset-ring-offset","transition-highlight"],{variants:{error:{true:"border-error focus-within:border-error focus-within:ring-error",false:"border-bdr-subtle"},open:{true:"border-bdr-strong",false:null},disabled:{true:"pointer-events-none select-none opacity-30",false:null}},defaultVariants:{error:!1,open:!1,disabled:!1}}),to=({className:e,children:t,...n})=>{const{open:r,disabled:o,error:i,controlRef:a}=T();/* @__PURE__ */
20
+ return N("div",{ref:gn(r,o),className:e,onBlur:l,...n,children:t})});Qr.displayName="Combobox.Content";const eo=M(["flex items-center gap-2.5","h-12 rounded-sm border bg-surface-neutral","focus-within:outline-none focus-within:ring-3 focus-within:ring-ring focus-within:ring-offset-3 focus-within:ring-offset-ring-offset","transition-highlight"],{variants:{error:{true:"border-error focus-within:border-error focus-within:ring-error",false:"border-bdr-subtle"},open:{true:"border-bdr-strong",false:null},disabled:{true:"pointer-events-none select-none opacity-30",false:null}},compoundVariants:[{error:!0,open:!0,class:"border-error"}],defaultVariants:{error:!1,open:!1,disabled:!1}}),to=({className:e,children:t,...n})=>{const{open:r,disabled:o,error:i,controlRef:a}=T();/* @__PURE__ */
21
21
  return N("div",{ref:a,className:cn(eo({error:i,open:r,disabled:o}),e),"data-open":r?"true":void 0,...n,children:t})};to.displayName="Combobox.Control";const no=a((e,t)=>{const n=u(null),r=gn(t,n),{open:o,keyHandler:i,baseId:a,active:s,disabled:l,error:d,contentType:m,hasValue:f}=T();return c(()=>{o&&!l&&n.current?.focus()},[o,l]),f&&!o?null:/* @__PURE__ */N(_r.Input,{ref:r,id:`${a}-input`,onKeyDown:i,"aria-disabled":l,"aria-invalid":d??void 0,role:"combobox","aria-autocomplete":"list","aria-expanded":o,"aria-haspopup":"tree"===m?"tree":"listbox","aria-controls":`${a}-${"tree"===m?"tree":"listbox"}`,"aria-activedescendant":"tree"===m?void 0:s?`${a}-listbox-option-${s}`:void 0,...e})});no.displayName="Combobox.Input";const ro=({children:e,className:t,...n})=>{const{inputValue:r,setInputValue:o,error:i}=T();/* @__PURE__ */
22
22
  return N(_r.Root,{value:r,onChange:o,className:cn("w-full pr-0","border-0 focus-within:border-0 focus-within:ring-0 focus-within:ring-offset-0",i&&"hover:outline-error",t),...n,children:e})};ro.displayName="Combobox.Search";const oo=({className:e,...t})=>{const{open:n,hasValue:r}=T();return r&&!n?null:/* @__PURE__ */N(_r.Icon,{className:e,...t})};oo.displayName="Combobox.SearchIcon";const io=({className:e,...t})=>{const{open:n,setOpen:r,disabled:o}=T();/* @__PURE__ */
23
23
  return N($r,{type:"button",variant:"text",size:"sm",iconSize:"lg",icon:Pn,"aria-label":"Toggle",onClick:()=>{o||r(!n)},disabled:o,tabIndex:-1,iconClassName:cn("transition-transform duration-150",n&&"rotate-180"),className:cn("mr-1.25 shrink-0 rounded-[0.1875rem] text-subtle hover:bg-surface-neutral-hover",'after:-inset-1 after:-z-10 relative z-0 overflow-visible after:pointer-events-auto after:absolute after:rounded-sm after:content-[""]',e),...t})};io.displayName="Combobox.Toggle";const ao=({className:e,children:t,...n})=>{const{open:r,setOpen:o,disabled:a,setHasValue:s}=T(),l=u(null),d=u(r);m(()=>(s(!0),()=>s(!1)),[s]),c(()=>{d.current&&!r&&l.current?.focus(),d.current=r},[r]);const f=i(()=>{a||o(!0)},[a,o]),g=i(e=>{"Enter"!==e.key&&" "!==e.key&&"ArrowDown"!==e.key&&"ArrowUp"!==e.key||(e.preventDefault(),o(!0))},[o]);return r?null:/* @__PURE__ */N("button",{ref:l,type:"button",onClick:f,onKeyDown:g,disabled:a,className:cn("flex flex-1 items-center gap-2 truncate text-left","-mx-4.5 -my-3 h-11.5 px-4.5","cursor-pointer select-none","focus-visible:outline-none",a&&"pointer-events-none cursor-not-allowed",e),...n,children:t})};ao.displayName="Combobox.Value";const so=({className:e,label:t="Apply",...n})=>{const{stagingEnabled:r,hasStagedChanges:o,applyStagedSelection:i}=T();return r&&o?/* @__PURE__ */N(In,{className:cn("h-7 min-w-14 gap-2 px-2.5 text-xs",e),type:"button",label:t,variant:"outline",onClick:i,...n}):null};so.displayName="Combobox.Apply";const lo=({container:e,forceMount:t,children:n})=>{const{open:r}=T(),[o,i]=s(!1);return c(()=>{i(!0)},[]),o&&(t||r)?h(n,e??document.body):null};lo.displayName="Combobox.Portal";const co=a(({children:e,className:t,style:n,...r},o)=>{const{open:i,setOpen:a,controlRef:l,closeOnBlur:c}=T(),d=u(null),f=gn(o,d),[g,p]=s(!1);m(()=>{if(!i||!d.current)return;const e=d.current.parentElement;p(e===document.body)},[i]),lr(d,g);const b=Jn({enabled:i&&g,anchorRef:l,contentRef:d,align:"start"});if(Un({enabled:i&&g&&c,contentRef:d,excludeRefs:l?[l]:void 0,onClose:()=>a(!1)}),!i)return null;const v=g&&l?.current?l.current.offsetWidth:void 0,h=g&&!b,y=g?{position:"fixed",top:b?`${b.top}px`:"0",left:void 0!==b?.left?`${b.left}px`:void 0,right:void 0!==b?.right?`${b.right}px`:void 0,width:v,...n??{}}:n??{};/* @__PURE__ */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@enonic/ui",
3
- "version": "0.47.2",
3
+ "version": "0.47.3",
4
4
  "description": "Enonic UI Component Library",
5
5
  "author": "Enonic",
6
6
  "license": "MIT",