@nice2dev/ui 1.3.9 → 1.3.10

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 (59) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/dist/NiceColorPicker-BLwYNSXJ.cjs +1 -0
  3. package/dist/NiceColorPicker-DS59tNkP.js +552 -0
  4. package/dist/NiceDataGrid-CL2_7fS7.cjs +10 -0
  5. package/dist/NiceDataGrid-CpJrRN_H.js +2269 -0
  6. package/dist/NiceForm-BQj-K7p7.cjs +1 -0
  7. package/dist/NiceForm-HQ4h7hX_.js +5023 -0
  8. package/dist/NiceGantt-BygumlaY.cjs +1 -0
  9. package/dist/NiceGantt-DTC7OH-v.js +334 -0
  10. package/dist/NiceHtmlEditor-BtpuaLln.js +901 -0
  11. package/dist/NiceHtmlEditor-C1OVtLQ6.cjs +10 -0
  12. package/dist/NiceMention-CVxxCVtQ.js +11668 -0
  13. package/dist/NiceMention-Te66Oid1.cjs +430 -0
  14. package/dist/NiceModuleLifecyclePanel-DCrFyUH8.cjs +1 -0
  15. package/dist/NiceModuleLifecyclePanel-Mt80MdET.js +7441 -0
  16. package/dist/NicePagination-CKsAP38Q.cjs +1 -0
  17. package/dist/NicePagination-zOed5QxG.js +202 -0
  18. package/dist/NicePivotGrid-Clue9FM5.js +1184 -0
  19. package/dist/NicePivotGrid-Cnkr9WkC.cjs +152 -0
  20. package/dist/NiceSavedQueryPanel-NgG58w6i.js +6226 -0
  21. package/dist/NiceSavedQueryPanel-lTWY2plm.cjs +587 -0
  22. package/dist/NiceScheduler-BWwqFKEc.js +1712 -0
  23. package/dist/NiceScheduler-DqWEJU7g.cjs +5 -0
  24. package/dist/NiceSelect-BNPXs6FQ.cjs +1 -0
  25. package/dist/NiceSelect-DEruWHan.js +495 -0
  26. package/dist/NiceWindow-D3V7A69Q.js +2247 -0
  27. package/dist/NiceWindow-pgR4c-kQ.cjs +1 -0
  28. package/dist/core-lazy-Bjdu111n.js +351 -0
  29. package/dist/core-lazy-Bx_8BOlG.cjs +1 -0
  30. package/dist/data.cjs +1 -1
  31. package/dist/data.d.ts +46 -5
  32. package/dist/data.mjs +3 -3
  33. package/dist/devops-CqhA0rjL.js +9130 -0
  34. package/dist/devops-cgRBnZVX.cjs +18 -0
  35. package/dist/devops.cjs +1 -1
  36. package/dist/devops.mjs +1 -1
  37. package/dist/editors.cjs +1 -1
  38. package/dist/editors.mjs +7 -7
  39. package/dist/feedback.cjs +1 -1
  40. package/dist/feedback.mjs +1 -1
  41. package/dist/index.cjs +108 -108
  42. package/dist/index.css +1 -1
  43. package/dist/index.d.ts +51 -8
  44. package/dist/index.mjs +13739 -13579
  45. package/dist/lazy.cjs +1 -1
  46. package/dist/lazy.mjs +15 -15
  47. package/dist/navigation.cjs +1 -1
  48. package/dist/navigation.d.ts +2 -0
  49. package/dist/navigation.mjs +3 -3
  50. package/dist/no-code-BQqK8mvU.cjs +331 -0
  51. package/dist/no-code-Cppb-xz3.js +8320 -0
  52. package/dist/no-code.cjs +1 -1
  53. package/dist/no-code.mjs +1 -1
  54. package/dist/overlays.cjs +1 -1
  55. package/dist/overlays.mjs +1 -1
  56. package/dist/pickerCommons-BA3-D5RC.js +663 -0
  57. package/dist/pickerCommons-KrBqCBDn.cjs +1 -0
  58. package/dist/style.css +1 -1
  59. package/package.json +4 -4
@@ -0,0 +1,5 @@
1
+ "use strict";const t=require("react/jsx-runtime"),ee=require("@nice2dev/ui-core"),N=require("react"),Z=require("./NiceButton-DzCqkG5a.cjs"),je=require("./devops-cgRBnZVX.cjs"),Se=require("./NiceForm-BQj-K7p7.cjs"),mt=require("./NiceColorPicker-BLwYNSXJ.cjs"),ht=require("./NiceModal-BRVzjuUN.cjs"),Ce=({children:e,className:n,style:c,"data-testid":d,direction:a="horizontal",size:o,disabled:_,readOnly:x,loading:b,error:$,errorPlacement:w="bottom"})=>{const m=t.jsxs("div",{className:`nice-btn-group ${a==="vertical"?"nice-btn-group--vertical":""} ${b?"nice-btn-group--loading":""} ${x?"nice-btn-group--readonly":""} ${n||""}`,style:c,role:"group","data-testid":d,"aria-busy":b||void 0,children:[N.Children.map(e,s=>{if(!N.isValidElement(s))return s;const D={};return _&&(D.disabled=!0),x&&(D.disabled=!0),b&&(D.disabled=!0),o&&(D.size=o),N.cloneElement(s,D)}),b&&t.jsx("span",{className:"nice-btn-group__spinner",children:t.jsx("span",{className:"nice-spinner nice-spinner--sm"})})]});if(!$)return m;const k=t.jsx("div",{className:"nice-field__error",role:"alert",children:$});return w==="right"?t.jsxs("span",{className:`nice-btn-field nice-btn-field--right ${o?`nice-field--${o}`:""}`,children:[m,k]}):t.jsxs("span",{className:`nice-btn-field nice-btn-field--bottom ${o?`nice-field--${o}`:""}`,children:[m,k]})},A=(e,n)=>{const c=new Date(e);return c.setDate(c.getDate()+n),c},z=(e,n)=>e.getFullYear()===n.getFullYear()&&e.getMonth()===n.getMonth()&&e.getDate()===n.getDate(),gt=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],pt=["January","February","March","April","May","June","July","August","September","October","November","December"],yt=["sun","mon","tue","wed","thu","fri","sat"],ft=["january","february","march","april","may","june","july","august","september","october","november","december"];function ue(e){return yt.map((n,c)=>e(n,gt[c]))}function vt(e){return ft.map((n,c)=>e(n,pt[c]))}function Ve(e){const n=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];return["janShort","febShort","marShort","aprShort","mayShort","junShort","julShort","augShort","sepShort","octShort","novShort","decShort"].map((d,a)=>e(d,n[a]))}const _t=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],xt=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];function ke(e){return xt.map((n,c)=>e(n,_t[c]))}function Ke(e,n,c,d=1/0){const a=[],o=Math.max(1,Math.floor(e.interval??1)),_=e.until?new Date(e.until):void 0,x=_&&_<c?_:c,b=Math.min(e.count&&e.count>0?e.count:1/0,d),$=e.freq==="weekly"&&e.byDay?.length?[...new Set(e.byDay.filter(m=>Number.isInteger(m)&&m>=0&&m<=6))].sort((m,k)=>m-k):[];if($.length>0){const m=new Date(n);m.setDate(n.getDate()-n.getDay());for(let k=0;a.length<b;k+=o){const s=new Date(m);if(s.setDate(m.getDate()+k*7),s>x)break;for(const D of $){const j=new Date(s);if(j.setDate(s.getDate()+D),!(j<n)){if(j>x||a.length>=b)break;a.push(j)}}}return a}let w=new Date(n);for(;w<=x&&a.length<b;){a.push(new Date(w));const m=new Date(w);e.freq==="daily"?m.setDate(m.getDate()+o):e.freq==="weekly"?m.setDate(m.getDate()+7*o):e.freq==="monthly"?m.setMonth(m.getMonth()+o):m.setFullYear(m.getFullYear()+o),w=m}return a}function Dt(e,n,c){const d=[];for(const a of e){if(!a.recurrence){d.push(a);continue}const o=new Date(a.end).getTime()-new Date(a.start).getTime();Ke(a.recurrence,new Date(a.start),c).forEach((_,x)=>{const b=new Date(_.getTime()+o);b>=n&&d.push({...a,id:`${a.id}_${x}`,start:_,end:b})})}return d}function Ue(e,n){return e.filter(c=>{const d=new Date(c.start),a=new Date(c.end);return n>=new Date(d.getFullYear(),d.getMonth(),d.getDate())&&n<=new Date(a.getFullYear(),a.getMonth(),a.getDate())})}function Je(e="r"){return`${e}_${Math.random().toString(36).slice(2,9)}`}function Ge(e={}){return{id:e.id??Je(),title:e.title??"",description:e.description??"",servings:e.servings??2,prepMinutes:e.prepMinutes,cookMinutes:e.cookMinutes,difficulty:e.difficulty,cuisine:e.cuisine,tags:e.tags??[],ingredients:e.ingredients??[],steps:e.steps??[],photos:e.photos??[],nutrition:e.nutrition,sourceUrl:e.sourceUrl,createdAt:e.createdAt??new Date,updatedAt:e.updatedAt??new Date}}function Oe(e){const n=(e.prepMinutes??0)+(e.cookMinutes??0);return n>0?n:void 0}const me=({ev:e,renderEvent:n,onClick:c,draggable:d,dragRef:a,onHover:o,categoryColor:_})=>{const x=_||e.color||"var(--nice-color-primary, #3b82f6)",$={solid:{backgroundColor:x,color:"var(--nice-color-white, #fff)"},striped:{background:`repeating-linear-gradient(45deg, ${x}, ${x} 4px, transparent 4px, transparent 8px)`,border:`1px solid ${x}`,color:"var(--nice-text-primary, #333)"},outlined:{backgroundColor:"transparent",border:`2px solid ${x}`,color:x},dashed:{backgroundColor:"transparent",border:`2px dashed ${x}`,color:x}}[e.eventStyle||"solid"];return t.jsx("div",{className:`nice-scheduler__event nice-scheduler__event--${e.eventStyle||"solid"}`,style:$,role:"button",tabIndex:0,"aria-label":e.title,draggable:d,onDragStart:()=>{a.current={event:e}},onDragEnd:()=>{a.current=null},onClick:w=>{w.stopPropagation(),c?.(e)},onKeyDown:w=>{(w.key==="Enter"||w.key===" ")&&(w.preventDefault(),w.stopPropagation(),c?.(e))},onMouseEnter:w=>o(e,w.currentTarget.getBoundingClientRect()),onMouseLeave:()=>o(null),onFocus:w=>o(e,w.currentTarget.getBoundingClientRect()),onBlur:()=>o(null),children:n?n(e):e.title})};function te(e,n){if(!(!e.category||!n))return n.find(c=>c.key===e.category)?.color}const Nt=({events:e,curDate:n,firstDayOfWeek:c,onSlotClick:d,onEventClick:a,draggable:o,dragRef:_,categories:x,renderEvent:b,onHoverEvent:$,readOnly:w,t:m})=>{const k=ue(m),s=n.getFullYear(),D=n.getMonth(),j=new Date(s,D,1),l=new Date(s,D+1,0),u=(j.getDay()-c+7)%7,E=l.getDate(),p=[];for(let h=u-1;h>=0;h--)p.push({date:A(j,-h-1),isCurrentMonth:!1});for(let h=0;h<E;h++)p.push({date:new Date(s,D,h+1),isCurrentMonth:!0});let I=1;for(;p.length<42;)p.push({date:new Date(s,D+1,I++),isCurrentMonth:!1});return t.jsxs("div",{className:"nice-scheduler__month",children:[t.jsx("div",{className:"nice-scheduler__month-header",children:Array.from({length:7},(h,y)=>t.jsx("div",{className:"nice-scheduler__month-dayname",children:k[(c+y)%7]},y))}),t.jsx("div",{className:"nice-scheduler__month-grid",children:p.map((h,y)=>{const R=Ue(e,h.date),g=z(h.date,new Date),S=h.date.getDay(),F=S===0||S===6;return t.jsxs("div",{className:`nice-scheduler__month-cell ${h.isCurrentMonth?"":"nice-scheduler__month-cell--other"} ${g?"nice-scheduler__month-cell--today":""} ${F?"nice-scheduler__month-cell--weekend":""}`,onClick:()=>!w&&d?.(h.date,A(h.date,1)),children:[t.jsx("div",{className:"nice-scheduler__month-date",children:h.date.getDate()}),R.slice(0,3).map(P=>t.jsx(me,{ev:P,renderEvent:b,onClick:a,draggable:o&&!w,dragRef:_,onHover:$,categoryColor:te(P,x)},P.id)),R.length>3&&t.jsxs("div",{className:"nice-scheduler__month-more",children:["+",R.length-3]})]},y)})})]})},wt=({events:e,days:n,startHour:c,endHour:d,draggable:a,dragRef:o,onEventClick:_,onSlotClick:x,onEventDrop:b,categories:$,workHours:w,showCurrentTime:m,renderEvent:k,onHoverEvent:s,readOnly:D,t:j})=>{const l=[];for(let g=c;g<d;g++)l.push(g);ue(j);const u=ke(j),E=N.useRef(null),p=new Date,I=p.getHours()*60+p.getMinutes(),h=(d-c)*60,y=(I-c*60)/h*100,R=m&&I>=c*60&&I<d*60;return N.useEffect(()=>{const g=E.current;if(!g)return;const S=new Date,F=e.filter(T=>n.some(W=>z(W,new Date(T.start)))),P=F.filter(T=>z(new Date(T.start),S));let q;P.length>0?q=Math.min(...P.map(T=>new Date(T.start).getHours())):F.length>0?q=Math.min(...F.map(T=>new Date(T.start).getHours())):q=8,q=Math.max(c,Math.min(q,d-1));const i=q-c,f=g.children[i];if(f){const T=g.closest(".nice-scheduler__content")??g.closest(".nice-scheduler__timegrid");T&&(T.scrollTop=f.offsetTop-4)}},[]),t.jsxs("div",{className:"nice-scheduler__timegrid",children:[t.jsxs("div",{className:"nice-scheduler__timegrid-header",children:[t.jsx("div",{className:"nice-scheduler__time-gutter"}),n.map((g,S)=>{const F=g.getDay()===0||g.getDay()===6;return t.jsxs("div",{className:`nice-scheduler__timegrid-day-header ${z(g,p)?"nice-scheduler__timegrid-day-header--today":""} ${F?"nice-scheduler__timegrid-day-header--weekend":""}`,children:[t.jsx("div",{className:"nice-scheduler__timegrid-day-name",children:u[g.getDay()]}),t.jsx("div",{className:"nice-scheduler__timegrid-day-num",children:g.getDate()})]},S)})]}),t.jsxs("div",{className:"nice-scheduler__timegrid-body",ref:E,style:{position:"relative"},children:[l.map(g=>{const S=w?g>=w[0]&&g<w[1]:!1;return t.jsxs("div",{className:`nice-scheduler__timegrid-row ${S?"nice-scheduler__timegrid-row--work":""}`,children:[t.jsx("div",{className:"nice-scheduler__time-gutter",children:`${g.toString().padStart(2,"0")}:00`}),n.map((F,P)=>{const q=e.filter(i=>{const f=new Date(i.start);return z(f,F)&&f.getHours()===g});return t.jsx("div",{className:"nice-scheduler__timegrid-cell",onDragOver:a&&!D?i=>i.preventDefault():void 0,onDrop:a&&!D?()=>{if(!o.current||!b)return;const i=o.current.event,f=new Date(i.end).getTime()-new Date(i.start).getTime(),T=new Date(F);T.setHours(g,0,0,0);const W=new Date(T.getTime()+f);b(i,T,W),o.current=null}:void 0,onClick:()=>!D&&(()=>{const i=new Date(F);i.setHours(g);const f=new Date(i);f.setHours(g+1),x?.(i,f)})(),children:q.map(i=>t.jsx(me,{ev:i,renderEvent:k,onClick:_,draggable:a&&!D,dragRef:o,onHover:s,categoryColor:te(i,$)},i.id))},P)})]},g)}),R&&n.some(g=>z(g,p))&&t.jsx("div",{className:"nice-scheduler__now-line",style:{top:`${y}%`},children:t.jsx("div",{className:"nice-scheduler__now-dot"})})]})]})},bt=({events:e,curDate:n,onEventClick:c,categories:d,t:a})=>{const o=[...e].filter(_=>new Date(_.start)>=new Date(n.getFullYear(),n.getMonth(),n.getDate())).sort((_,x)=>new Date(_.start).getTime()-new Date(x.start).getTime()).slice(0,50);return t.jsxs("div",{className:"nice-scheduler__agenda",children:[o.map(_=>t.jsx(jt,{ev:_,categories:d,onEventClick:c},_.id)),o.length===0&&t.jsx("div",{className:"nice-scheduler__agenda-empty",children:a("noEvents","No upcoming events")})]})},ze=({parts:e})=>t.jsx("div",{className:"nice-scheduler__agenda-meta",children:e.map(([n,c],d)=>t.jsxs(N.Fragment,{children:[d>0&&" · ",t.jsx(ee.NiceIcon,{name:n,size:12,style:{verticalAlign:"-2px"}})," ",c]},n))}),Xe=({ev:e})=>{if(e.eventType==="recipe"&&e.recipe){const n=Oe(e.recipe),c=[];return n!==void 0&&c.push(["clock",`${n} min`]),e.recipe.ingredients?.length&&c.push(["list",`${e.recipe.ingredients.length} ingredients`]),e.recipe.servings&&c.push(["utensils",`${e.recipe.servings} servings`]),c.length===0?null:t.jsx(ze,{parts:c})}if(e.eventType==="service"&&e.service){const n=e.service,c=[];return n.serviceName&&c.push(["bell",n.serviceName]),n.providerName&&c.push(["user",n.providerName]),n.customerName&&c.push(["arrow-right",n.customerName]),typeof n.price=="number"&&c.push(["dollar",`${n.price}${n.currency?" "+n.currency:""}`]),c.length===0?null:t.jsx(ze,{parts:c})}return null},jt=({ev:e,categories:n,onEventClick:c})=>{const{t:d}=ee.useNiceTranslation(),a=ee.useAccessibleClick({onClick:()=>c?.(e)});return t.jsxs("div",{className:"nice-scheduler__agenda-item","aria-label":d("service.event","Event {title}").replace("{title}",String(e.title)),...a,children:[t.jsx("div",{className:"nice-scheduler__agenda-dot",style:{backgroundColor:te(e,n)||e.color||"var(--nice-color-primary, #3b82f6)"}}),t.jsxs("div",{className:"nice-scheduler__agenda-info",children:[t.jsx("div",{className:"nice-scheduler__agenda-title",children:e.title}),t.jsxs("div",{className:"nice-scheduler__agenda-time",children:[new Date(e.start).toLocaleString()," – ",new Date(e.end).toLocaleString()]}),e.description&&t.jsx("div",{className:"nice-scheduler__agenda-desc",children:e.description}),t.jsx(Xe,{ev:e})]}),e.category&&n&&t.jsx("span",{className:"nice-scheduler__agenda-badge",style:{backgroundColor:te(e,n)||e.color},children:n.find(o=>o.key===e.category)?.label})]})},St=({events:e,curDate:n,timelineDays:c,resources:d,draggable:a,dragRef:o,onEventClick:_,onSlotClick:x,onEventDrop:b,categories:$,renderEvent:w,onHoverEvent:m,readOnly:k,t:s})=>{const D=Array.from({length:c},(u,E)=>A(n,E)),j=d??[{id:"__default",name:""}],l=ue(s);return t.jsxs("div",{className:"nice-scheduler__timeline",children:[t.jsxs("div",{className:"nice-scheduler__timeline-header",children:[t.jsx("div",{className:"nice-scheduler__timeline-res-label"}),D.map((u,E)=>t.jsxs("div",{className:`nice-scheduler__timeline-day ${z(u,new Date)?"nice-scheduler__timeline-day--today":""}`,children:[l[u.getDay()]," ",u.getDate()]},E))]}),t.jsx("div",{className:"nice-scheduler__timeline-body",children:j.map(u=>{const E=e.filter(p=>!d||p.resourceId===u.id);return t.jsxs("div",{className:"nice-scheduler__timeline-row",children:[t.jsx("div",{className:"nice-scheduler__timeline-res-label",children:u.name}),D.map((p,I)=>{const h=E.filter(y=>z(new Date(y.start),p));return t.jsx("div",{className:"nice-scheduler__timeline-cell",onDragOver:a&&!k?y=>y.preventDefault():void 0,onDrop:a&&!k?()=>{if(!o.current||!b)return;const y=o.current.event,R=new Date(y.end).getTime()-new Date(y.start).getTime(),g=new Date(p);g.setHours(new Date(y.start).getHours(),new Date(y.start).getMinutes()),b(y,g,new Date(g.getTime()+R),u.id),o.current=null}:void 0,onClick:()=>!k&&x?.(p,A(p,1),u.id),children:h.map(y=>t.jsx(me,{ev:y,renderEvent:w,onClick:_,draggable:a&&!k,dragRef:o,onHover:m,categoryColor:te(y,$)},y.id))},I)})]},u.id)})})]})},He=({categories:e,events:n,filteredCategories:c,onToggleCategory:d,t:a})=>t.jsxs("div",{className:"nice-scheduler__legend",children:[t.jsx("div",{className:"nice-scheduler__legend-title",children:a("legend","Legend")}),e.map(o=>{const _=n.filter(b=>b.category===o.key).length,x=!c.has(o.key);return t.jsxs("button",{className:`nice-scheduler__legend-item ${x?"":"nice-scheduler__legend-item--hidden"}`,onClick:()=>d(o.key),children:[t.jsx("span",{className:"nice-scheduler__legend-dot",style:{backgroundColor:x?o.color:"var(--nice-border-color, #ccc)"}}),t.jsx("span",{className:"nice-scheduler__legend-label",children:o.label}),t.jsx("span",{className:"nice-scheduler__legend-count",children:_})]},o.key)})]}),Ct=({curDate:e,onDateSelect:n,firstDayOfWeek:c,t:d})=>{const[a,o]=N.useState(e.getMonth()),[_,x]=N.useState(e.getFullYear()),b=new Date(_,a,1),$=new Date(_,a+1,0),w=(b.getDay()-c+7)%7,m=[];for(let u=w-1;u>=0;u--)m.push(A(b,-u-1));for(let u=0;u<$.getDate();u++)m.push(new Date(_,a,u+1));const k=7-m.length%7;if(k<7)for(let u=1;u<=k;u++)m.push(new Date(_,a+1,u));const s=()=>{a===0?(o(11),x(u=>u-1)):o(u=>u-1)},D=()=>{a===11?(o(0),x(u=>u+1)):o(u=>u+1)},j=Ve(d),l=ue(d);return t.jsxs("div",{className:"nice-scheduler__mini-cal",children:[t.jsxs("div",{className:"nice-scheduler__mini-cal-header",children:[t.jsx("button",{type:"button",className:"nice-btn nice-btn--xs",onClick:s,"aria-label":d("scheduler.prevMonth","Previous month"),children:t.jsx(ee.NiceIcon,{name:"chevron-left",size:"sm"})}),t.jsxs("span",{children:[j[a]," ",_]}),t.jsx("button",{type:"button",className:"nice-btn nice-btn--xs",onClick:D,"aria-label":d("scheduler.nextMonth","Next month"),children:t.jsx(ee.NiceIcon,{name:"chevron-right",size:"sm"})})]}),t.jsxs("div",{className:"nice-scheduler__mini-cal-grid",children:[l.map((u,E)=>t.jsx("div",{className:"nice-scheduler__mini-cal-dayname",children:l[(c+E)%7].charAt(0)},E)),m.map((u,E)=>{const p=z(u,new Date),I=z(u,e),h=u.getMonth()!==a;return t.jsx("button",{className:`nice-scheduler__mini-cal-day ${p?"nice-scheduler__mini-cal-day--today":""} ${I?"nice-scheduler__mini-cal-day--selected":""} ${h?"nice-scheduler__mini-cal-day--other":""}`,onClick:()=>n(u),children:u.getDate()},E)})]})]})},kt=({events:e,rangeStart:n,rangeEnd:c,startHour:d,endHour:a,draggable:o,dragRef:_,onEventClick:x,onSlotClick:b,onEventDrop:$,categories:w,workHours:m,showCurrentTime:k,renderEvent:s,onHoverEvent:D,readOnly:j,t:l})=>{const u=[];let E=new Date(n);for(;E<=c;)u.push(new Date(E)),E=A(E,1);const p=[];for(let f=d;f<a;f++)p.push(f);const I=ke(l),h=N.useRef(null),y=N.useRef(null),R=N.useRef(null),g=new Date,S=g.getHours()*60+g.getMinutes(),F=(a-d)*60,P=(S-d*60)/F*100,q=k&&S>=d*60&&S<a*60;N.useEffect(()=>{const f=h.current;if(!f)return;const T=new Date,W=e.filter(L=>u.some(C=>z(C,T)&&z(new Date(L.start),T)));let H=W.length>0?Math.min(...W.map(L=>new Date(L.start).getHours())):T.getHours();H=Math.max(d,Math.min(H,a-1));const U=f.children[H-d];if(U){const L=R.current??f.closest(".nice-scheduler__content")??f.closest(".nice-scheduler__timegrid");L&&(L.scrollTop=U.offsetTop-4)}},[]);const i=f=>{y.current&&(y.current.scrollLeft=f.currentTarget.scrollLeft)};return t.jsxs("div",{className:"nice-scheduler__timegrid nice-scheduler__timegrid--range",children:[t.jsx("div",{className:"nice-scheduler__timegrid-header-scroll",ref:y,"aria-hidden":"true",children:t.jsxs("div",{className:"nice-scheduler__timegrid-header",children:[t.jsx("div",{className:"nice-scheduler__time-gutter"}),u.map((f,T)=>{const W=f.getDay()===0||f.getDay()===6;return t.jsxs("div",{className:`nice-scheduler__timegrid-day-header ${z(f,g)?"nice-scheduler__timegrid-day-header--today":""} ${W?"nice-scheduler__timegrid-day-header--weekend":""}`,children:[t.jsx("div",{className:"nice-scheduler__timegrid-day-name",children:I[f.getDay()]}),t.jsx("div",{className:"nice-scheduler__timegrid-day-num",children:f.getDate()})]},T)})]})}),t.jsx("div",{className:"nice-scheduler__timegrid-body-scroll",ref:R,onScroll:i,children:t.jsxs("div",{className:"nice-scheduler__timegrid-body",ref:h,style:{position:"relative"},children:[p.map(f=>{const T=m?f>=m[0]&&f<m[1]:!1;return t.jsxs("div",{className:`nice-scheduler__timegrid-row ${T?"nice-scheduler__timegrid-row--work":""}`,children:[t.jsx("div",{className:"nice-scheduler__time-gutter",children:`${f.toString().padStart(2,"0")}:00`}),u.map((W,H)=>{const U=e.filter(L=>{const C=new Date(L.start);return z(C,W)&&C.getHours()===f});return t.jsx("div",{className:"nice-scheduler__timegrid-cell",onDragOver:o&&!j?L=>L.preventDefault():void 0,onDrop:o&&!j?()=>{if(!_.current||!$)return;const L=_.current.event,C=new Date(L.end).getTime()-new Date(L.start).getTime(),O=new Date(W);O.setHours(f,0,0,0),$(L,O,new Date(O.getTime()+C)),_.current=null}:void 0,onClick:()=>!j&&(()=>{const L=new Date(W);L.setHours(f);const C=new Date(L);C.setHours(f+1),b?.(L,C)})(),children:U.map(L=>t.jsx(me,{ev:L,renderEvent:s,onClick:x,draggable:o&&!j,dragRef:_,onHover:D,categoryColor:te(L,w)},L.id))},H)})]},f)}),q&&u.some(f=>z(f,g))&&t.jsx("div",{className:"nice-scheduler__now-line",style:{top:`${P}%`},children:t.jsx("div",{className:"nice-scheduler__now-dot"})})]})})]})},Mt=({events:e,rangeStart:n,rangeEnd:c,firstDayOfWeek:d,onSlotClick:a,onEventClick:o,draggable:_,dragRef:x,categories:b,renderEvent:$,onHoverEvent:w,readOnly:m,t:k})=>{const s=ue(k);ke(k);const D=[];let j=new Date(n);for(;j<=c;)D.push(new Date(j)),j=A(j,1);const l=(D[0].getDay()-d+7)%7,u=[];for(let p=l-1;p>=0;p--)u.push({date:A(D[0],-p-1),inRange:!1});D.forEach(p=>u.push({date:p,inRange:!0}));const E=7-u.length%7;if(E<7){const p=D[D.length-1];for(let I=1;I<=E;I++)u.push({date:A(p,I),inRange:!1})}return t.jsxs("div",{className:"nice-scheduler__month nice-scheduler__month--range",children:[t.jsx("div",{className:"nice-scheduler__month-header",children:Array.from({length:7},(p,I)=>t.jsx("div",{className:"nice-scheduler__month-dayname",children:s[(d+I)%7]},I))}),t.jsx("div",{className:"nice-scheduler__month-grid",children:u.map((p,I)=>{const h=Ue(e,p.date),y=z(p.date,new Date),R=p.date.getDay()===0||p.date.getDay()===6;return t.jsxs("div",{className:`nice-scheduler__month-cell ${p.inRange?"":"nice-scheduler__month-cell--other"} ${y?"nice-scheduler__month-cell--today":""} ${R?"nice-scheduler__month-cell--weekend":""}`,onClick:()=>!m&&a?.(p.date,A(p.date,1)),children:[t.jsx("div",{className:"nice-scheduler__month-date",children:p.date.getDate()===1||I===0?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"nice-scheduler__month-monthname",children:Ve(k)[p.date.getMonth()]})," ",p.date.getDate()]}):p.date.getDate()}),h.slice(0,3).map(g=>t.jsx(me,{ev:g,renderEvent:$,onClick:o,draggable:_&&!m,dragRef:x,onHover:w,categoryColor:te(g,b)},g.id)),h.length>3&&t.jsxs("div",{className:"nice-scheduler__month-more",children:["+",h.length-3]})]},I)})})]})},Tt=({event:e,rect:n,categories:c,renderTooltip:d})=>{if(d)return t.jsx("div",{className:"nice-scheduler__tooltip",style:{position:"fixed",left:n.right+8,top:n.top,zIndex:1e4},children:d(e)});const a=c?.find(o=>o.key===e.category);return t.jsxs("div",{className:"nice-scheduler__tooltip",style:{position:"fixed",left:n.right+8,top:n.top,zIndex:1e4},children:[t.jsx("div",{className:"nice-scheduler__tooltip-title",children:e.title}),t.jsxs("div",{className:"nice-scheduler__tooltip-time",children:[new Date(e.start).toLocaleString()," – ",new Date(e.end).toLocaleString()]}),a&&t.jsxs("div",{className:"nice-scheduler__tooltip-cat",children:[t.jsx("span",{className:"nice-scheduler__tooltip-dot",style:{backgroundColor:a.color}}),a.label]}),e.description&&t.jsx("div",{className:"nice-scheduler__tooltip-desc",children:e.description}),t.jsx(Xe,{ev:e})]})},$t=({event:e,slotStart:n,slotEnd:c,categories:d,resources:a,formFields:o,formFieldsByType:_,eventTypes:x,renderEditor:b,saving:$,onSave:w,onDelete:m,onClose:k,t:s})=>{const D=!!e,j=N.useMemo(()=>({title:e?.title??"",description:e?.description??"",color:e?.color??"var(--nice-primary, #3b82f6)",category:e?.category??"",eventStyle:e?.eventStyle??"solid",start:e?.start??n??new Date,end:e?.end??c??new Date,allDay:e?.allDay??!1,resourceId:e?.resourceId??"",eventType:e?.eventType??"task",recurring:!!e?.recurrence,recurrenceFreq:e?.recurrence?.freq??"weekly",recurrenceInterval:e?.recurrence?.interval??1,recurrenceCount:e?.recurrence?.count,recipeTitle:e?.recipe?.title??"",recipeServings:e?.recipe?.servings??2,recipePrep:e?.recipe?.prepMinutes,recipeCook:e?.recipe?.cookMinutes,recipeIngredients:(e?.recipe?.ingredients??[]).map(h=>[h.quantity,h.unit,h.name].filter(y=>y!==void 0&&y!=="").join(" ")).join(`
2
+ `),recipeSteps:(e?.recipe?.steps??[]).map(h=>h.instruction).join(`
3
+ `),serviceName:e?.service?.serviceName??"",serviceProvider:e?.service?.providerName??"",serviceCustomer:e?.service?.customerName??"",serviceContact:e?.service?.customerContact??"",serviceLocation:e?.service?.location??"",servicePrice:e?.service?.price,serviceCurrency:e?.service?.currency??"PLN",serviceNotes:e?.service?.notes??""}),[e,n,c]),[l,u]=N.useState(j);N.useEffect(()=>{u(j)},[j]);const E=N.useCallback((h,y)=>{u(R=>({...R,[h]:y}))},[]),p=N.useMemo(()=>{if(o&&o.length>0)return o;const h=i=>i.toString().padStart(2,"0"),y=i=>`${i.getFullYear()}-${h(i.getMonth()+1)}-${h(i.getDate())}`,R=i=>`${h(i.getHours())}:${h(i.getMinutes())}`,g=(i,f)=>{const T=i instanceof Date?i:new Date(i),W=isNaN(T.getTime())?new Date:T,H=y(W),U=R(W),L=(C,O)=>{const[G,V,he]=C.split("-").map(ne=>parseInt(ne,10)),[ge,pe]=O.split(":").map(ne=>parseInt(ne,10)),ce=new Date(W);!isNaN(G)&&!isNaN(V)&&!isNaN(he)&&ce.setFullYear(G,V-1,he),!isNaN(ge)&&!isNaN(pe)&&ce.setHours(ge,pe,0,0),f(ce)};return t.jsxs("div",{style:{display:"flex",gap:12,flexWrap:"wrap",alignItems:"flex-end"},children:[t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:2},children:[t.jsx("span",{style:{fontSize:"0.7rem",color:"var(--nice-text-muted, #888)"},children:s("date","Date")}),t.jsx(Se.NiceDateTimePicker,{value:H,onChange:C=>L(C,U),size:"sm"})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:2},children:[t.jsx("span",{style:{fontSize:"0.7rem",color:"var(--nice-text-muted, #888)"},children:s("time","Time")}),t.jsx(Se.NiceDateTimePicker,{dateFormatPreset:"time",value:U,onChange:C=>L(H,C),size:"sm"})]})]})},S=[];x&&x.length>1&&S.push({field:"eventType",label:s("eventType","Type"),type:"select",group:s("common","Common"),options:x.map(i=>({label:i.icon?`${i.icon} ${i.label}`:i.label,value:i.type}))}),S.push({field:"title",label:s("title","Title"),type:"text",required:!0,group:s("common","Common")},{field:"start",label:s("start","Start"),render:g,group:s("common","Common")},{field:"end",label:s("end","End"),render:g,group:s("common","Common")},{field:"description",label:s("description","Description"),type:"textarea",group:s("common","Common")},{field:"color",label:s("color","Color"),group:s("common","Common"),render:(i,f)=>t.jsx(mt.NiceColorPicker,{value:typeof i=="string"?i:"var(--nice-primary, #3b82f6)",onChange:f,showInput:!1,showRandom:!1})}),d&&d.length>0&&S.push({field:"category",label:s("category","Category"),type:"select",group:s("common","Common"),options:[{label:s("none","(none)"),value:""},...d.map(i=>({label:i.label,value:i.key}))]}),a&&a.length>0&&S.push({field:"resourceId",label:s("resource","Resource"),type:"select",group:s("common","Common"),options:[{label:s("none","(none)"),value:""},...a.map(i=>({label:i.name,value:String(i.id)}))]});const F=s("recurring","Recurring");S.push({field:"recurring",label:s("repeat","Repeat"),type:"checkbox",group:F}),S.push({field:"recurrenceFreq",label:s("frequency","Frequency"),type:"select",group:F,visibleWhen:i=>!!i.recurring,options:[{label:s("daily","Daily"),value:"daily"},{label:s("weekly","Weekly"),value:"weekly"},{label:s("monthly","Monthly"),value:"monthly"},{label:s("yearly","Yearly"),value:"yearly"}]}),S.push({field:"recurrenceInterval",label:s("interval","Interval"),type:"number",group:F,visibleWhen:i=>!!i.recurring}),S.push({field:"recurrenceCount",label:s("occurrences","Occurrences (optional)"),type:"number",group:F,visibleWhen:i=>!!i.recurring});const P=l.eventType??"task",q=_?.[P];if(q&&q.length>0)S.push(...q);else if(P==="recipe"){const i=s("recipe.section","Recipe");S.push({field:"recipeTitle",label:s("recipe.title","Recipe title"),type:"text",group:i},{field:"recipeServings",label:s("recipe.servings","Servings"),type:"number",group:i},{field:"recipePrep",label:s("recipe.prepMinutes","Prep (min)"),type:"number",group:i},{field:"recipeCook",label:s("recipe.cookMinutes","Cook (min)"),type:"number",group:i},{field:"recipeIngredients",label:s("recipe.ingredients","Ingredients (one per line)"),type:"textarea",group:i,hint:s("recipe.ingredients.hint",'Format: "200 g flour"')},{field:"recipeSteps",label:s("recipe.steps","Steps (one per line)"),type:"textarea",group:i})}else if(P==="service"){const i=s("service.section","Service");S.push({field:"serviceName",label:s("service.name","Service name"),type:"text",group:i,required:!0},{field:"serviceProvider",label:s("service.provider","Provider"),type:"text",group:i},{field:"serviceCustomer",label:s("service.customer","Customer"),type:"text",group:i},{field:"serviceContact",label:s("service.contact","Contact"),type:"text",group:i},{field:"serviceLocation",label:s("service.location","Location"),type:"text",group:i},{field:"servicePrice",label:s("service.price","Price"),type:"number",group:i},{field:"serviceCurrency",label:s("service.currency","Currency"),type:"text",group:i},{field:"serviceNotes",label:s("service.notes","Notes"),type:"textarea",group:i})}return S},[o,_,x,d,a,l.eventType,s]),I=()=>{const h=l.eventType??"task",y={title:l.title,description:l.description||void 0,color:l.color,category:l.category||void 0,eventStyle:l.eventStyle,allDay:l.allDay,start:l.start instanceof Date?l.start:new Date(l.start),end:l.end instanceof Date?l.end:new Date(l.end),resourceId:l.resourceId||void 0,eventType:h};if(l.recurring){const R={freq:l.recurrenceFreq||"weekly",interval:typeof l.recurrenceInterval=="number"&&l.recurrenceInterval>0?l.recurrenceInterval:1};typeof l.recurrenceCount=="number"&&l.recurrenceCount>0&&(R.count=l.recurrenceCount),y.recurrence=R}else y.recurrence=void 0;if(h==="recipe"){const R=String(l.recipeIngredients||"").split(`
4
+ `).map(P=>P.trim()).filter(Boolean).map((P,q)=>{const i=P.match(/^([\d.,/]+)\s*(\S+)?\s+(.+)$/);if(i){const f=parseFloat(i[1].replace(",","."));return{id:`ing-${q}`,name:i[3],quantity:isNaN(f)?void 0:f,unit:i[2]}}return{id:`ing-${q}`,name:P}}),g=String(l.recipeSteps||"").split(`
5
+ `).map(P=>P.trim()).filter(Boolean).map((P,q)=>({id:`step-${q}`,order:q+1,instruction:P})),S=e?.recipe??Ge(),F={...S,title:l.recipeTitle||l.title||S.title,servings:typeof l.recipeServings=="number"?l.recipeServings:S.servings,prepMinutes:typeof l.recipePrep=="number"?l.recipePrep:S.prepMinutes,cookMinutes:typeof l.recipeCook=="number"?l.recipeCook:S.cookMinutes,ingredients:R,steps:g};y.recipe=F,y.service=void 0}else if(h==="service"){const R={serviceName:String(l.serviceName||""),providerName:l.serviceProvider||void 0,customerName:l.serviceCustomer||void 0,customerContact:l.serviceContact||void 0,location:l.serviceLocation||void 0,price:typeof l.servicePrice=="number"?l.servicePrice:void 0,currency:l.serviceCurrency||void 0,notes:l.serviceNotes||void 0};y.service=R,y.recipe=void 0}else y.recipe=void 0,y.service=void 0;return D&&(y.id=e.id),y};return t.jsx(ht.NiceModal,{open:!0,onClose:k,title:D?s("editEvent","Edit Event"):s("newEvent","New Event"),size:"md",footer:b?null:t.jsxs(t.Fragment,{children:[D&&m&&t.jsx(Z.NiceButton,{type:"button",variant:"error",size:"sm",onClick:()=>{m(e),k()},disabled:$,children:s("delete","Delete")}),t.jsx("div",{style:{flex:1}}),t.jsx(Z.NiceButton,{type:"button",variant:"secondary",size:"sm",onClick:k,disabled:$,children:s("cancel","Cancel")}),t.jsx(Z.NiceButton,{type:"button",variant:"primary",size:"sm",onClick:()=>{l.title&&w(I())},disabled:$||!l.title,children:$?s("saving","Saving…"):s("save","Save")})]}),children:t.jsx("div",{className:"nice-scheduler__form-body",onKeyDown:h=>{h.key==="Enter"&&h.target.tagName!=="TEXTAREA"&&(h.preventDefault(),l.title&&w(I()))},children:b?b({event:e,slotStart:n,slotEnd:c,save:w,cancel:k,remove:m}):t.jsx(Se.NiceForm,{items:p,data:l,onFieldChange:E,columns:1,gap:12,size:"sm"})})})},Et=["day","workWeek","week","dayRange","month","monthRange","timeline","agenda"],Me=({events:e,defaultEvents:n,resources:c,currentDate:d,view:a,onDateChange:o,onViewChange:_,onEventClick:x,onSlotClick:b,onEventDrop:$,draggable:w=!1,timelineDays:m=7,startHour:k=0,endHour:s=24,firstDayOfWeek:D=1,categories:j,showLegend:l,showTooltip:u,renderEvent:E,renderTooltip:p,workHours:I,showCurrentTime:h=!0,showMiniCalendar:y,onEventCreate:R,onEventEdit:g,onEventDelete:S,editable:F=!0,formFields:P,formFieldsByType:q,eventTypes:i,renderEventEditor:f,loadEvents:T,onEventsChange:W,accessMode:H="full",className:U,style:L})=>{const{t:C}=ee.useNiceTranslation(),O=H==="hidden",G=H==="readOnly"||H==="disabled",V=H==="disabled",[he,ge]=N.useState(d??new Date),[pe,ce]=N.useState(a??"week"),ne=d!==void 0&&o!==void 0,Te=a!==void 0&&_!==void 0,Y=ne?d:he,M=Te?a:pe;je.useIgnoredPropChangeWarning("NiceScheduler","currentDate","onDateChange",d,ne),je.useIgnoredPropChangeWarning("NiceScheduler","view","onViewChange",a,Te);const Qe=N.useRef(null),[K,_e]=N.useState(()=>{const r=new Date;return r.setHours(0,0,0,0),r}),[J,xe]=N.useState(()=>A(new Date,13)),[De,$e]=N.useState(null),Ze=N.useCallback((r,v)=>{u&&$e(r&&v?{event:r,rect:v}:null)},[u]),[se,ae]=N.useState(null),[et,ye]=N.useState(!1),Ne=e!==void 0&&W!==void 0,[tt,Ee]=ee.useControllableState({value:Ne?e:void 0,defaultValue:n,fallbackValue:[],onChange:W,componentName:"NiceScheduler"}),[Re,nt]=N.useState(!1),[Le,st]=N.useState(null),[Lt,Ie]=N.useState(!1),X=Le??(Ne||Re||e===void 0?tt:e);je.useIgnoredPropChangeWarning("NiceScheduler","events","onEventsChange",e,Ne||!(Re||Le!==null),"the built-in editor has taken over the list");const[oe,rt]=N.useState(new Set),Fe=N.useCallback(r=>{rt(v=>{const B=new Set(v);return B.has(r)?B.delete(r):B.add(r),B})},[]),le=N.useMemo(()=>{if(M==="month")return{start:new Date(Y.getFullYear(),Y.getMonth(),1),end:new Date(Y.getFullYear(),Y.getMonth()+2,0)};if(M==="timeline")return{start:new Date(Y),end:A(Y,m)};if(M==="dayRange"||M==="monthRange")return{start:new Date(K),end:A(J,1)};const r=(()=>{const v=new Date(Y),B=(v.getDay()-D+7)%7;return A(v,-B)})();return{start:A(r,-1),end:A(r,8)}},[Y,M,D,m,K,J]),we=N.useMemo(()=>{let r=Dt(X,le.start,le.end);return oe.size>0&&(r=r.filter(v=>!v.category||!oe.has(v.category))),r},[X,le,oe]),re=r=>{ge(r),o?.(r)},it=r=>{ce(r),_?.(r)},Ae=r=>{if(M==="day")re(A(Y,r));else if(M==="week"||M==="workWeek")re(A(Y,r*7));else if(M==="timeline")re(A(Y,r*m));else if(M==="dayRange"||M==="monthRange"){const v=Math.round((J.getTime()-K.getTime())/864e5)+1;_e(A(K,r*v)),xe(A(J,r*v))}else{const v=new Date(Y);v.setMonth(v.getMonth()+r),re(v)}},be=N.useMemo(()=>{const r=new Date(Y),v=(r.getDay()-D+7)%7;return A(r,-v)},[Y,D]),fe=N.useMemo(()=>{if(M==="day")return[Y];if(M==="workWeek"){const r=[];for(let v=0;v<7;v++){const B=A(be,v),Q=B.getDay();Q!==0&&Q!==6&&r.push(B)}return r}return Array.from({length:7},(r,v)=>A(be,v))},[M,Y,be]),ct=M==="day"?Y.toLocaleDateString():M==="week"||M==="workWeek"?`${fe[0].toLocaleDateString()} – ${fe[fe.length-1].toLocaleDateString()}`:M==="timeline"?`${Y.toLocaleDateString()} – ${A(Y,m-1).toLocaleDateString()}`:M==="dayRange"||M==="monthRange"?`${K.toLocaleDateString()} – ${J.toLocaleDateString()}`:`${vt(C)[Y.getMonth()]} ${Y.getFullYear()}`,at=N.useCallback((r,v,B)=>{G||(F&&ae({mode:"create",slotStart:r,slotEnd:v}),b?.(r,v,B))},[F,b,G]),ot=N.useCallback(r=>{F&&!G&&ae({mode:"edit",event:r}),x?.(r)},[F,x,G]),de=N.useCallback(r=>{nt(!0),Ee(r)},[Ee]),lt=N.useCallback(async r=>{const v=se?.mode==="create";try{if(ye(!0),v){const Q=(R?await R(r):void 0)??{...r,id:typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():`evt_${Date.now()}_${Math.random().toString(36).slice(2,7)}`},ve=X.slice();ve.push(Q),de(ve)}else{const Q=(g?await g(r):void 0)??r,ve=X.map(Be=>Be.id===Q.id?Q:Be);de(ve)}ae(null)}finally{ye(!1)}},[se,R,g,X,de]),dt=N.useCallback(async r=>{try{ye(!0),S&&await S(r);const v=X.filter(B=>B.id!==r.id);de(v),ae(null)}finally{ye(!1)}},[S,X,de]),Pe=le.start.getTime(),Ye=le.end.getTime();N.useEffect(()=>{if(!T)return;let r=!1;return Ie(!0),T({start:new Date(Pe),end:new Date(Ye)}).then(v=>{r||st(v)}).finally(()=>{r||Ie(!1)}),()=>{r=!0}},[T,Pe,Ye]);const ut=r=>({day:C("day","Day"),week:C("week","Week"),workWeek:C("workWeek","Work Week"),month:C("month","Month"),timeline:C("timeline","Timeline"),agenda:C("agenda","Agenda"),dayRange:C("dayRange","Day Range"),monthRange:C("monthRange","Month Range")})[r],ie={events:we,curDate:Y,firstDayOfWeek:D,startHour:k,endHour:s,draggable:w,dragRef:Qe,onEventClick:ot,onSlotClick:at,onEventDrop:$,resources:c,timelineDays:m,categories:j,workHours:I,showCurrentTime:h,renderEvent:E,showTooltip:u,renderTooltip:p,onHoverEvent:Ze,readOnly:G,t:C},qe=M==="dayRange"||M==="monthRange",We=r=>{const v=B=>B.toString().padStart(2,"0");return`${r.getFullYear()}-${v(r.getMonth()+1)}-${v(r.getDate())}`};return O?null:t.jsxs("div",{className:`nice-scheduler ${V?"nice-scheduler--disabled":""} ${U||""}`,style:L,children:[t.jsxs("div",{className:"nice-scheduler__toolbar",children:[t.jsxs("div",{className:"nice-scheduler__nav",children:[t.jsxs(Ce,{size:"sm",children:[t.jsx(Z.NiceButton,{onClick:()=>Ae(-1),disabled:V,"aria-label":C("previous","Previous"),children:"‹"}),t.jsx(Z.NiceButton,{onClick:()=>{if(qe){const r=new Date;r.setHours(0,0,0,0);const v=Math.round((J.getTime()-K.getTime())/864e5);_e(r),xe(A(r,v))}else re(new Date)},disabled:V,children:C("today","Today")}),t.jsx(Z.NiceButton,{onClick:()=>Ae(1),disabled:V,"aria-label":C("next","Next"),children:"›"})]}),qe?t.jsxs("span",{className:"nice-scheduler__range-picker",children:[t.jsx("input",{type:"date",className:"nice-textinput nice-textinput--sm",value:We(K),disabled:V,onChange:r=>{const v=new Date(r.target.value+"T00:00:00");isNaN(v.getTime())||_e(v)}}),t.jsx("span",{style:{margin:"0 4px"},children:"–"}),t.jsx("input",{type:"date",className:"nice-textinput nice-textinput--sm",value:We(J),disabled:V,onChange:r=>{const v=new Date(r.target.value+"T00:00:00");!isNaN(v.getTime())&&v>=K&&xe(v)}})]}):t.jsx("span",{className:"nice-scheduler__title",children:ct})]}),t.jsx("div",{className:"nice-scheduler__views",children:t.jsx(Ce,{size:"sm",children:Et.map(r=>t.jsx(Z.NiceButton,{variant:r===M?"primary":"secondary",onClick:()=>it(r),disabled:V,children:ut(r)},r))})})]}),t.jsxs("div",{className:"nice-scheduler__body",children:[y&&t.jsxs("div",{className:"nice-scheduler__sidebar",children:[t.jsx(Ct,{curDate:Y,onDateSelect:r=>re(r),firstDayOfWeek:D,t:C}),l&&j&&t.jsx(He,{categories:j,events:we,filteredCategories:oe,onToggleCategory:Fe,t:C})]}),t.jsxs("div",{className:"nice-scheduler__content",children:[M==="month"&&t.jsx(Nt,{...ie}),(M==="week"||M==="day"||M==="workWeek")&&t.jsx(wt,{...ie,days:fe}),M==="dayRange"&&t.jsx(kt,{...ie,rangeStart:K,rangeEnd:J}),M==="monthRange"&&t.jsx(Mt,{...ie,rangeStart:K,rangeEnd:J}),M==="timeline"&&t.jsx(St,{...ie}),M==="agenda"&&t.jsx(bt,{...ie})]}),!y&&l&&j&&t.jsx("div",{className:"nice-scheduler__sidebar nice-scheduler__sidebar--right",children:t.jsx(He,{categories:j,events:we,filteredCategories:oe,onToggleCategory:Fe,t:C})})]}),De&&t.jsx(Tt,{event:De.event,rect:De.rect,categories:j,renderTooltip:p}),se&&F&&t.jsx($t,{event:se.event,slotStart:se.slotStart,slotEnd:se.slotEnd,categories:j,resources:c,formFields:P,formFieldsByType:q,eventTypes:i,renderEditor:f,saving:et,onSave:lt,onDelete:dt,onClose:()=>ae(null),t:C})]})};process.env.NODE_ENV!=="production"&&(Me.displayName="NiceScheduler");const Rt=Object.freeze(Object.defineProperty({__proto__:null,NiceScheduler:Me},Symbol.toStringTag,{value:"Module"}));exports.NiceButtonGroup=Ce;exports.NiceScheduler=Me;exports.NiceScheduler$1=Rt;exports.createEmptyRecipe=Ge;exports.newRecipeId=Je;exports.recipeTotalMinutes=Oe;exports.recurrenceDates=Ke;
@@ -0,0 +1 @@
1
+ "use strict";const t=require("react/jsx-runtime"),c=require("@nice2dev/ui-core"),s=require("react"),He=require("react-dom"),ze=require("./devops-cgRBnZVX.cjs");function ke(y,g,E,_){const B=_?.maxHeight??320,M=_?.anchorKey,w=s.useRef(null),[he,V]=s.useState(null),[le,G]=s.useState(!1),[re,R]=s.useState(""),b=s.useContext(c.NiceThemeContext)?.portalTarget??(typeof document<"u"?document.body:null),u=s.useRef(E);u.current=E;const F=c.useInputEngine();return c.useOverlayFocus(w,{open:y,modal:!1,initialFocus:"none",onClose:()=>u.current(),closeHint:!1}),s.useLayoutEffect(()=>{if(!y||!g.current)return;R(ze.scopeThemeClass(g.current)),G(!1);const l=()=>{const k=g.current;if(!k)return;const a=k.getBoundingClientRect(),q=w.current?.offsetHeight??B;let D=a.bottom;D+q>window.innerHeight-8&&a.top-q>8&&(D=a.top-q);let j=a.left;j+a.width>window.innerWidth-8&&(j=Math.max(8,window.innerWidth-a.width-8)),V(d=>d&&d.left===j&&d.top===D&&d.width===a.width?d:{left:j,top:D,width:a.width})};l();const I=requestAnimationFrame(()=>{l(),G(!0)}),v=k=>{const a=k.target;a instanceof Node&&(w.current?.contains(a)||g.current?.contains(a))||u.current()},m=()=>u.current();return window.addEventListener("scroll",v,!0),window.addEventListener("resize",m),()=>{cancelAnimationFrame(I),window.removeEventListener("scroll",v,!0),window.removeEventListener("resize",m)}},[y,g,B,M]),s.useEffect(()=>{if(!y)return;const l=v=>{const m=v.target;g.current?.contains(m)||w.current?.contains(m)||(m instanceof Element?m:m?.parentElement??null)?.closest('.nice-select__dropdown, [role="listbox"], [role="option"]')||u.current()},I=v=>{if(v.key!=="Escape"||v.defaultPrevented)return;const m=F?.topOverlay();m&&m.element!==w.current||u.current()};return document.addEventListener("mousedown",l),document.addEventListener("keydown",I),()=>{document.removeEventListener("mousedown",l),document.removeEventListener("keydown",I)}},[y,g,F]),{popupRef:w,coords:he,ready:le,themeClass:re,portalTarget:b}}const Se=Object.assign(s.forwardRef(({label:y,"aria-label":g,helperText:E,error:_,required:B,disabled:M,size:w="md",name:he,id:V,className:le,style:G,accessMode:re,displayStyle:R,options:pe,value:b,onChange:u,placeholder:F,multiple:l=!1,searchable:I=!0,clearable:v=!1,emptyText:m,maxHeight:k=240,optionsSource:a,valueField:q,labelField:D,virtualScroll:j,optionHeight:d=36,onSearch:T,loading:S,renderOption:J,multipleAutosize:Q=!1,showKeyboardHints:$e,labelPlacement:Ce,errorPlacement:X,labelWidth:Y,controlWidth:A,displayMode:Ee},Z)=>{const oe=c.useNiceAccessMode(re,V),Me=oe==="hidden";(oe==="disabled"||oe==="readOnly")&&(M=!0);const{t:$}=c.useNiceTranslation(),Ie=c.useComponentDisplayStyle("input",R),Le=c.useComponentDisplayClass("input",R),C=c.useControlId(V),me=c.useDisplayModeEdit({enabled:Ee,disabled:M}),[f,O]=s.useState(!1),[ee,te]=s.useState(""),[h,H]=s.useState(-1),[ve,De]=s.useState(0),xe=s.useRef(null),z=s.useRef(null),[_e,Te]=s.useState(null);s.useLayoutEffect(()=>{!S&&z.current&&Te(z.current.offsetWidth)},[S,b,R]);const[K,Oe]=s.useState(null);s.useLayoutEffect(()=>{l&&!Q&&z.current&&K==null&&Oe(z.current.offsetWidth)},[l,Q,K]);const Re=c.useNiceLookupSource(a??null,q??a?.keyField??"id",D??"name"),L=a?Re.options:(pe??[]).map(e=>typeof e=="string"?{value:e,label:e}:e),{popupRef:ne,coords:P,ready:ye,themeClass:se,portalTarget:ge}=ke(f,xe,()=>{O(!1),te("")}),r=s.useMemo(()=>b?Array.isArray(b)?b:[b]:[],[b]),o=s.useMemo(()=>{if(!ee&&!T||T)return L;const e=ee.toLowerCase();return L.filter(n=>n.label.toLowerCase().includes(e)||String(n.value).toLowerCase().includes(e))},[L,ee,T]),we=s.useMemo(()=>{const e=new Map;for(const n of o){const i=n.group||"";e.has(i)||e.set(i,[]),e.get(i).push(n)}return e},[o]),U=s.useCallback(e=>{if(l){const n=r.includes(e)?r.filter(i=>i!==e):[...r,e];u?.(n)}else u?.(e),O(!1),te("")},[l,r,u]),ie=s.useCallback(()=>{const e=o.findIndex(n=>r.includes(String(n.value)));H(e>=0?e:0),O(!0)},[o,r]),ae=s.useCallback(e=>H(n=>Math.max(0,Math.min(o.length-1,e(n)))),[o.length]),je=s.useCallback(e=>{const n=e.target instanceof HTMLInputElement;if(e.key==="Escape"){O(!1),te("");return}if((e.key==="Delete"||e.key==="Backspace")&&!n&&v&&r.length>0){e.preventDefault(),u?.(l?[]:"");return}if(e.key==="Enter"||e.key===" "&&!n){if(!f){ie(),e.preventDefault();return}h>=0&&o[h]&&(U(o[h].value),e.preventDefault());return}const i={ArrowDown:p=>p+1,ArrowUp:p=>p-1,PageDown:p=>p+10,PageUp:p=>p-10};n||(i.Home=()=>0,i.End=()=>o.length-1);const N=i[e.key];N&&(e.preventDefault(),f?ae(N):ie())},[f,h,o,U,ie,ae,v,r.length,u,l]),Ne=I||!!T,de=`${C}-listbox`,ue=e=>`${C}-opt-${e}`,be=f&&h>=0&&o[h]?ue(h):void 0;s.useLayoutEffect(()=>{const e=ne.current;if(!(!f||h<0||!e)){if(j){const n=h*d;n<e.scrollTop?e.scrollTop=n:n+d>e.scrollTop+e.clientHeight&&(e.scrollTop=n+d-e.clientHeight);return}e.querySelector(`[data-nice-option-index="${h}"]`)?.scrollIntoView?.({block:"nearest"})}},[f,h,j,d,ne]),c.useIntent(["navigate","activate"],e=>{if(e.source==="keyboard")return!1;if(e.intent==="activate"){const n=o[h];n&&!n.disabled&&U(String(n.value));return}if(e.direction!=="up"&&e.direction!=="down")return!1;ae(n=>n+(e.direction==="down"?1:-1))},{ref:ne,enabled:f&&Ne});const fe=s.useMemo(()=>r.length===0?null:l?r.map(e=>L.find(n=>n.value===e)?.label||e).join(", "):L.find(e=>e.value===r[0])?.label||r[0],[r,L,l]),Fe=s.useCallback(e=>{e.stopPropagation(),u?.(l?[]:"")},[u,l]),qe=s.useMemo(()=>[{key:"Enter",description:$("shortcuts.select","Select")},{key:"Space",description:$("shortcuts.openDropdown","Open dropdown")},c.COMMON_SHORTCUTS.moveUp,c.COMMON_SHORTCUTS.moveDown,c.COMMON_SHORTCUTS.cancel],[$]);return Me?null:t.jsxs("div",{className:`nice-field ${A==null?"nice-field--select-auto":""} nice-field--${w} ${Ce==="left"?"nice-field--label-left":""} ${S?"nice-field--loading":""} ${le||""}`,style:{...G,...Y!=null&&{"--nice-field-label-width":typeof Y=="number"?`${Y}px`:Y},...A!=null&&{"--nice-field-control-width":typeof A=="number"?`${A}px`:A},...S&&_e!=null&&{"--nice-select-locked-width":`${_e}px`}},"aria-busy":S||void 0,children:[y&&t.jsxs("label",{htmlFor:C,className:`nice-field__label ${B?"nice-field__label--required":""}`,children:[y,$e&&t.jsx(c.NiceKeyboardHint,{shortcuts:qe,size:"sm"})]}),t.jsxs("div",{className:"nice-field__control",children:[me.isDisplay?t.jsx(c.DisplayModeView,{value:fe,placeholder:F||$("controls.select","Select..."),disabled:M,onActivate:()=>{me.enterEdit(),O(!0)},ariaLabel:y??g}):t.jsxs("div",{className:"nice-select",ref:xe,children:[t.jsxs("button",{ref:e=>{z.current=e,typeof Z=="function"?Z(e):Z&&(Z.current=e)},type:"button",id:C,role:"combobox","aria-label":y?void 0:g,"aria-expanded":f,"aria-haspopup":"listbox","aria-controls":f?de:void 0,"aria-activedescendant":Ne?void 0:be,"aria-invalid":!!_,"aria-keyshortcuts":v&&r.length>0?"Delete":void 0,className:`nice-select__trigger nice-select__trigger--${w} nice-select--ds-${Le} ${f?"nice-select__trigger--open":""} ${_?"nice-select__trigger--error":""} ${M?"nice-select__trigger--disabled":""}`,style:{...Ie,...l&&!Q&&K!=null?{width:K,maxWidth:K,overflow:"hidden"}:{}},disabled:M,onClick:()=>f?O(!1):ie(),onKeyDown:je,children:[fe?t.jsx("span",{style:l&&!Q?{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}:void 0,children:fe}):t.jsx("span",{className:"nice-select__placeholder",children:F||$("controls.select","Select...")}),t.jsxs("span",{style:{display:"flex",alignItems:"center",gap:4},children:[v&&r.length>0&&t.jsx("span",{className:"nice-input__clear",onClick:Fe,role:"presentation",children:t.jsx(c.NiceIcon,{name:"close",size:14})}),t.jsx("span",{className:`nice-select__chevron ${f?"nice-select__chevron--open":""}`,children:t.jsx(c.NiceIcon,{name:"chevron-down",size:16})})]})]}),f&&P&&ge&&He.createPortal(t.jsxs("div",{ref:ne,className:`nice-select__dropdown${se?` ${se}`:""}`,"data-theme":se==="nice-dark"?"dark":se==="nice-light"?"light":void 0,role:"listbox",id:de,"aria-multiselectable":l||void 0,style:{maxHeight:k,position:"fixed",left:P.left,top:P.top,width:P.width,minWidth:P.width,zIndex:1e3,opacity:ye?1:0,pointerEvents:ye?void 0:"none"},onScroll:j?e=>De(e.currentTarget.scrollTop):void 0,children:[(I||T)&&t.jsx("div",{className:"nice-select__search",children:t.jsx("input",{type:"text",value:ee,onChange:e=>{te(e.target.value),H(0),T?.(e.target.value)},onKeyDown:je,placeholder:$("controls.search","Search..."),"aria-label":$("controls.search","Search..."),"aria-controls":de,"aria-activedescendant":be,"aria-autocomplete":"list",autoFocus:!0})}),S&&t.jsx("div",{className:"nice-select__loading",children:t.jsx("div",{className:"nice-spinner nice-spinner--sm",style:{margin:"8px auto"}})}),!S&&o.length===0?t.jsx("div",{className:"nice-select__empty",children:m||$("controls.noResults","No results found")}):j&&!Array.from(we.keys()).some(e=>e!=="")?(()=>{const n=o.length*d,i=Math.max(0,Math.floor(ve/d)-3),N=Math.min(o.length,Math.ceil((ve+k)/d)+3),p=o.slice(i,N);return t.jsx("div",{style:{height:n,position:"relative"},children:p.map((x,Ae)=>{const W=i+Ae,ce=r.includes(x.value);return t.jsx("div",{id:ue(W),"data-nice-option-index":W,role:"option","aria-selected":ce,"aria-disabled":x.disabled||void 0,className:`nice-select__option ${ce?"nice-select__option--selected":""} ${W===h?"nice-select__option--highlighted":""} ${x.disabled?"nice-select__option--disabled":""}`,style:{position:"absolute",top:W*d,left:0,right:0,height:d,display:"flex",alignItems:"center",padding:"0 12px"},onClick:()=>!x.disabled&&U(String(x.value)),onMouseEnter:()=>H(W),children:J?J(x,ce):t.jsxs(t.Fragment,{children:[x.icon&&t.jsx("span",{children:x.icon}),t.jsxs("div",{style:{flex:1},children:[t.jsx("div",{children:x.label}),x.description&&t.jsx("div",{className:"nice-select__option-desc",children:x.description})]}),ce&&t.jsx(c.NiceIcon,{name:"check",size:16,className:"nice-select__option-check"})]})},x.value)})})})():Array.from(we.entries()).map(([e,n])=>t.jsxs(s.Fragment,{children:[e&&t.jsx("div",{className:"nice-select__group-label",children:e}),n.map(i=>{const N=r.includes(i.value),p=o.indexOf(i);return t.jsx("div",{id:ue(p),"data-nice-option-index":p,role:"option","aria-selected":N,"aria-disabled":i.disabled||void 0,className:`nice-select__option ${N?"nice-select__option--selected":""} ${p===h?"nice-select__option--highlighted":""} ${i.disabled?"nice-select__option--disabled":""}`,onClick:()=>!i.disabled&&U(String(i.value)),onMouseEnter:()=>H(p),children:J?J(i,N):t.jsxs(t.Fragment,{children:[i.icon&&t.jsx("span",{children:i.icon}),t.jsxs("div",{style:{flex:1},children:[t.jsx("div",{children:i.label}),i.description&&t.jsx("div",{className:"nice-select__option-desc",children:i.description})]}),N&&t.jsx(c.NiceIcon,{name:"check",size:16,className:"nice-select__option-check"})]})},i.value)})]},e))]}),ge)]}),S&&t.jsx("span",{className:"nice-field__spinner",children:t.jsx("span",{className:"nice-spinner nice-spinner--sm"})}),X==="right"&&_&&t.jsx("div",{id:`${C}-error`,className:"nice-field__error",role:"alert",children:_}),X==="right"&&!_&&E&&t.jsx("div",{id:`${C}-helper`,className:"nice-field__helper",children:E})]}),X!=="right"&&_&&t.jsx("div",{id:`${C}-error`,className:"nice-field__error",role:"alert",children:_}),X!=="right"&&!_&&E&&t.jsx("div",{id:`${C}-helper`,className:"nice-field__helper",children:E})]})}),{displayName:"NiceSelect"}),Ke=Object.freeze(Object.defineProperty({__proto__:null,NiceSelect:Se},Symbol.toStringTag,{value:"Module"}));exports.NiceSelect=Se;exports.NiceSelect$1=Ke;exports.useAnchoredPopup=ke;
@@ -0,0 +1,495 @@
1
+ import { jsxs as v, jsx as t, Fragment as Ie } from "react/jsx-runtime";
2
+ import { NiceThemeContext as We, useInputEngine as Be, useOverlayFocus as Ve, useNiceAccessMode as Ge, useNiceTranslation as Je, useComponentDisplayStyle as Qe, useComponentDisplayClass as Xe, useControlId as Ye, useDisplayModeEdit as Ze, useNiceLookupSource as en, useIntent as nn, COMMON_SHORTCUTS as ge, NiceKeyboardHint as tn, DisplayModeView as sn, NiceIcon as oe } from "@nice2dev/ui-core";
3
+ import cn, { useRef as de, useState as N, useContext as ln, useLayoutEffect as ae, useEffect as rn, forwardRef as on, useMemo as B, useCallback as V } from "react";
4
+ import { createPortal as an } from "react-dom";
5
+ import { s as dn } from "./devops-CqhA0rjL.js";
6
+ function un(g, y, D, _) {
7
+ const G = _?.maxHeight ?? 320, M = _?.anchorKey, w = de(null), [ye, J] = N(null), [ue, Q] = N(!1), [fe, A] = N(""), k = ln(We)?.portalTarget ?? (typeof document < "u" ? document.body : null), a = de(D);
8
+ a.current = D;
9
+ const H = Be();
10
+ return Ve(w, {
11
+ open: g,
12
+ modal: !1,
13
+ initialFocus: "none",
14
+ onClose: () => a.current(),
15
+ closeHint: !1
16
+ }), ae(() => {
17
+ if (!g || !y.current)
18
+ return;
19
+ A(dn(y.current)), Q(!1);
20
+ const s = () => {
21
+ const $ = y.current;
22
+ if (!$)
23
+ return;
24
+ const r = $.getBoundingClientRect(), R = w.current?.offsetHeight ?? G;
25
+ let T = r.bottom;
26
+ T + R > window.innerHeight - 8 && r.top - R > 8 && (T = r.top - R);
27
+ let x = r.left;
28
+ x + r.width > window.innerWidth - 8 && (x = Math.max(8, window.innerWidth - r.width - 8)), J(
29
+ (o) => o && o.left === x && o.top === T && o.width === r.width ? o : { left: x, top: T, width: r.width }
30
+ );
31
+ };
32
+ s();
33
+ const I = requestAnimationFrame(() => {
34
+ s(), Q(!0);
35
+ }), p = ($) => {
36
+ const r = $.target;
37
+ r instanceof Node && (w.current?.contains(r) || y.current?.contains(r)) || a.current();
38
+ }, h = () => a.current();
39
+ return window.addEventListener("scroll", p, !0), window.addEventListener("resize", h), () => {
40
+ cancelAnimationFrame(I), window.removeEventListener("scroll", p, !0), window.removeEventListener("resize", h);
41
+ };
42
+ }, [g, y, G, M]), rn(() => {
43
+ if (!g)
44
+ return;
45
+ const s = (p) => {
46
+ const h = p.target;
47
+ y.current?.contains(h) || w.current?.contains(h) || (h instanceof Element ? h : h?.parentElement ?? null)?.closest('.nice-select__dropdown, [role="listbox"], [role="option"]') || a.current();
48
+ }, I = (p) => {
49
+ if (p.key !== "Escape" || p.defaultPrevented)
50
+ return;
51
+ const h = H?.topOverlay();
52
+ h && h.element !== w.current || a.current();
53
+ };
54
+ return document.addEventListener("mousedown", s), document.addEventListener("keydown", I), () => {
55
+ document.removeEventListener("mousedown", s), document.removeEventListener("keydown", I);
56
+ };
57
+ }, [g, y, H]), { popupRef: w, coords: ye, ready: ue, themeClass: fe, portalTarget: k };
58
+ }
59
+ const fn = /* @__PURE__ */ Object.assign(
60
+ /* @__PURE__ */ on(
61
+ ({
62
+ label: g,
63
+ "aria-label": y,
64
+ helperText: D,
65
+ error: _,
66
+ required: G,
67
+ disabled: M,
68
+ size: w = "md",
69
+ name: ye,
70
+ id: J,
71
+ className: ue,
72
+ style: Q,
73
+ accessMode: fe,
74
+ displayStyle: A,
75
+ options: we,
76
+ value: k,
77
+ onChange: a,
78
+ placeholder: H,
79
+ multiple: s = !1,
80
+ searchable: I = !0,
81
+ clearable: p = !1,
82
+ emptyText: h,
83
+ maxHeight: $ = 240,
84
+ optionsSource: r,
85
+ valueField: R,
86
+ labelField: T,
87
+ virtualScroll: x,
88
+ optionHeight: o = 36,
89
+ onSearch: O,
90
+ loading: E,
91
+ renderOption: X,
92
+ multipleAutosize: Y = !1,
93
+ showKeyboardHints: Le,
94
+ labelPlacement: Te,
95
+ errorPlacement: Z,
96
+ labelWidth: ee,
97
+ controlWidth: j,
98
+ displayMode: Oe
99
+ }, ne) => {
100
+ const he = Ge(fe, J), Fe = he === "hidden";
101
+ (he === "disabled" || he === "readOnly") && (M = !0);
102
+ const { t: C } = Je(), Ae = Qe("input", A), He = Xe("input", A), S = Ye(J), xe = Ze({ enabled: Oe, disabled: M }), [d, F] = N(!1), [te, ie] = N(""), [u, z] = N(-1), [be, Re] = N(0), Ne = de(null), K = de(null), [ke, je] = N(null);
103
+ ae(() => {
104
+ !E && K.current && je(K.current.offsetWidth);
105
+ }, [E, k, A]);
106
+ const [P, ze] = N(null);
107
+ ae(() => {
108
+ s && !Y && K.current && P == null && ze(K.current.offsetWidth);
109
+ }, [s, Y, P]);
110
+ const Ke = en(
111
+ r ?? null,
112
+ R ?? r?.keyField ?? "id",
113
+ T ?? "name"
114
+ ), L = r ? Ke.options : (we ?? []).map(
115
+ (e) => typeof e == "string" ? { value: e, label: e } : e
116
+ ), { popupRef: se, coords: q, ready: $e, themeClass: ce, portalTarget: Ee } = un(
117
+ d,
118
+ Ne,
119
+ () => {
120
+ F(!1), ie("");
121
+ }
122
+ ), c = B(() => k ? Array.isArray(k) ? k : [k] : [], [k]), l = B(() => {
123
+ if (!te && !O || O)
124
+ return L;
125
+ const e = te.toLowerCase();
126
+ return L.filter(
127
+ (n) => n.label.toLowerCase().includes(e) || String(n.value).toLowerCase().includes(e)
128
+ );
129
+ }, [L, te, O]), Ce = B(() => {
130
+ const e = /* @__PURE__ */ new Map();
131
+ for (const n of l) {
132
+ const i = n.group || "";
133
+ e.has(i) || e.set(i, []), e.get(i).push(n);
134
+ }
135
+ return e;
136
+ }, [l]), U = V(
137
+ (e) => {
138
+ if (s) {
139
+ const n = c.includes(e) ? c.filter((i) => i !== e) : [...c, e];
140
+ a?.(n);
141
+ } else
142
+ a?.(e), F(!1), ie("");
143
+ },
144
+ [s, c, a]
145
+ ), le = V(() => {
146
+ const e = l.findIndex((n) => c.includes(String(n.value)));
147
+ z(e >= 0 ? e : 0), F(!0);
148
+ }, [l, c]), pe = V(
149
+ (e) => z((n) => Math.max(0, Math.min(l.length - 1, e(n)))),
150
+ [l.length]
151
+ ), Se = V(
152
+ (e) => {
153
+ const n = e.target instanceof HTMLInputElement;
154
+ if (e.key === "Escape") {
155
+ F(!1), ie("");
156
+ return;
157
+ }
158
+ if ((e.key === "Delete" || e.key === "Backspace") && !n && p && c.length > 0) {
159
+ e.preventDefault(), a?.(s ? [] : "");
160
+ return;
161
+ }
162
+ if (e.key === "Enter" || e.key === " " && !n) {
163
+ if (!d) {
164
+ le(), e.preventDefault();
165
+ return;
166
+ }
167
+ u >= 0 && l[u] && (U(l[u].value), e.preventDefault());
168
+ return;
169
+ }
170
+ const i = {
171
+ ArrowDown: (f) => f + 1,
172
+ ArrowUp: (f) => f - 1,
173
+ PageDown: (f) => f + 10,
174
+ PageUp: (f) => f - 10
175
+ };
176
+ n || (i.Home = () => 0, i.End = () => l.length - 1);
177
+ const b = i[e.key];
178
+ b && (e.preventDefault(), d ? pe(b) : le());
179
+ },
180
+ [
181
+ d,
182
+ u,
183
+ l,
184
+ U,
185
+ le,
186
+ pe,
187
+ p,
188
+ c.length,
189
+ a,
190
+ s
191
+ ]
192
+ ), De = I || !!O, me = `${S}-listbox`, ve = (e) => `${S}-opt-${e}`, Me = d && u >= 0 && l[u] ? ve(u) : void 0;
193
+ ae(() => {
194
+ const e = se.current;
195
+ if (!(!d || u < 0 || !e)) {
196
+ if (x) {
197
+ const n = u * o;
198
+ n < e.scrollTop ? e.scrollTop = n : n + o > e.scrollTop + e.clientHeight && (e.scrollTop = n + o - e.clientHeight);
199
+ return;
200
+ }
201
+ e.querySelector(`[data-nice-option-index="${u}"]`)?.scrollIntoView?.({ block: "nearest" });
202
+ }
203
+ }, [d, u, x, o, se]), nn(
204
+ ["navigate", "activate"],
205
+ (e) => {
206
+ if (e.source === "keyboard")
207
+ return !1;
208
+ if (e.intent === "activate") {
209
+ const n = l[u];
210
+ n && !n.disabled && U(String(n.value));
211
+ return;
212
+ }
213
+ if (e.direction !== "up" && e.direction !== "down")
214
+ return !1;
215
+ pe((n) => n + (e.direction === "down" ? 1 : -1));
216
+ },
217
+ { ref: se, enabled: d && De }
218
+ );
219
+ const _e = B(() => c.length === 0 ? null : s ? c.map((e) => L.find((n) => n.value === e)?.label || e).join(", ") : L.find((e) => e.value === c[0])?.label || c[0], [c, L, s]), Pe = V(
220
+ (e) => {
221
+ e.stopPropagation(), a?.(s ? [] : "");
222
+ },
223
+ [a, s]
224
+ ), qe = B(
225
+ () => [
226
+ { key: "Enter", description: C("shortcuts.select", "Select") },
227
+ { key: "Space", description: C("shortcuts.openDropdown", "Open dropdown") },
228
+ ge.moveUp,
229
+ ge.moveDown,
230
+ ge.cancel
231
+ ],
232
+ [C]
233
+ );
234
+ return Fe ? null : /* @__PURE__ */ v(
235
+ "div",
236
+ {
237
+ className: `nice-field ${j == null ? "nice-field--select-auto" : ""} nice-field--${w} ${Te === "left" ? "nice-field--label-left" : ""} ${E ? "nice-field--loading" : ""} ${ue || ""}`,
238
+ style: {
239
+ ...Q,
240
+ ...ee != null && {
241
+ "--nice-field-label-width": typeof ee == "number" ? `${ee}px` : ee
242
+ },
243
+ ...j != null && {
244
+ "--nice-field-control-width": typeof j == "number" ? `${j}px` : j
245
+ },
246
+ ...E && ke != null && { "--nice-select-locked-width": `${ke}px` }
247
+ },
248
+ "aria-busy": E || void 0,
249
+ children: [
250
+ g && /* @__PURE__ */ v(
251
+ "label",
252
+ {
253
+ htmlFor: S,
254
+ className: `nice-field__label ${G ? "nice-field__label--required" : ""}`,
255
+ children: [
256
+ g,
257
+ Le && /* @__PURE__ */ t(tn, { shortcuts: qe, size: "sm" })
258
+ ]
259
+ }
260
+ ),
261
+ /* @__PURE__ */ v("div", { className: "nice-field__control", children: [
262
+ xe.isDisplay ? /* @__PURE__ */ t(
263
+ sn,
264
+ {
265
+ value: _e,
266
+ placeholder: H || C("controls.select", "Select..."),
267
+ disabled: M,
268
+ onActivate: () => {
269
+ xe.enterEdit(), F(!0);
270
+ },
271
+ ariaLabel: g ?? y
272
+ }
273
+ ) : /* @__PURE__ */ v("div", { className: "nice-select", ref: Ne, children: [
274
+ /* @__PURE__ */ v(
275
+ "button",
276
+ {
277
+ ref: (e) => {
278
+ K.current = e, typeof ne == "function" ? ne(e) : ne && (ne.current = e);
279
+ },
280
+ type: "button",
281
+ id: S,
282
+ role: "combobox",
283
+ "aria-label": g ? void 0 : y,
284
+ "aria-expanded": d,
285
+ "aria-haspopup": "listbox",
286
+ "aria-controls": d ? me : void 0,
287
+ "aria-activedescendant": De ? void 0 : Me,
288
+ "aria-invalid": !!_,
289
+ "aria-keyshortcuts": p && c.length > 0 ? "Delete" : void 0,
290
+ className: `nice-select__trigger nice-select__trigger--${w} nice-select--ds-${He} ${d ? "nice-select__trigger--open" : ""} ${_ ? "nice-select__trigger--error" : ""} ${M ? "nice-select__trigger--disabled" : ""}`,
291
+ style: {
292
+ ...Ae,
293
+ ...s && !Y && P != null ? {
294
+ width: P,
295
+ maxWidth: P,
296
+ overflow: "hidden"
297
+ } : {}
298
+ },
299
+ disabled: M,
300
+ onClick: () => d ? F(!1) : le(),
301
+ onKeyDown: Se,
302
+ children: [
303
+ _e ? /* @__PURE__ */ t(
304
+ "span",
305
+ {
306
+ style: s && !Y ? {
307
+ flex: 1,
308
+ minWidth: 0,
309
+ overflow: "hidden",
310
+ textOverflow: "ellipsis",
311
+ whiteSpace: "nowrap"
312
+ } : void 0,
313
+ children: _e
314
+ }
315
+ ) : /* @__PURE__ */ t("span", { className: "nice-select__placeholder", children: H || C("controls.select", "Select...") }),
316
+ /* @__PURE__ */ v("span", { style: { display: "flex", alignItems: "center", gap: 4 }, children: [
317
+ p && c.length > 0 && // the pointer's shortcut for Delete / Backspace on the trigger
318
+ /* @__PURE__ */ t("span", { className: "nice-input__clear", onClick: Pe, role: "presentation", children: /* @__PURE__ */ t(oe, { name: "close", size: 14 }) }),
319
+ /* @__PURE__ */ t(
320
+ "span",
321
+ {
322
+ className: `nice-select__chevron ${d ? "nice-select__chevron--open" : ""}`,
323
+ children: /* @__PURE__ */ t(oe, { name: "chevron-down", size: 16 })
324
+ }
325
+ )
326
+ ] })
327
+ ]
328
+ }
329
+ ),
330
+ d && q && Ee && an(
331
+ /* @__PURE__ */ v(
332
+ "div",
333
+ {
334
+ ref: se,
335
+ className: `nice-select__dropdown${ce ? ` ${ce}` : ""}`,
336
+ "data-theme": ce === "nice-dark" ? "dark" : ce === "nice-light" ? "light" : void 0,
337
+ role: "listbox",
338
+ id: me,
339
+ "aria-multiselectable": s || void 0,
340
+ style: {
341
+ maxHeight: $,
342
+ position: "fixed",
343
+ left: q.left,
344
+ top: q.top,
345
+ width: q.width,
346
+ minWidth: q.width,
347
+ zIndex: 1e3,
348
+ // Hidden until measured so the estimate frame never paints above.
349
+ opacity: $e ? 1 : 0,
350
+ pointerEvents: $e ? void 0 : "none"
351
+ },
352
+ onScroll: x ? (e) => Re(e.currentTarget.scrollTop) : void 0,
353
+ children: [
354
+ (I || O) && /* @__PURE__ */ t("div", { className: "nice-select__search", children: /* @__PURE__ */ t(
355
+ "input",
356
+ {
357
+ type: "text",
358
+ value: te,
359
+ onChange: (e) => {
360
+ ie(e.target.value), z(0), O?.(e.target.value);
361
+ },
362
+ onKeyDown: Se,
363
+ placeholder: C("controls.search", "Search..."),
364
+ "aria-label": C("controls.search", "Search..."),
365
+ "aria-controls": me,
366
+ "aria-activedescendant": Me,
367
+ "aria-autocomplete": "list",
368
+ autoFocus: !0
369
+ }
370
+ ) }),
371
+ E && /* @__PURE__ */ t("div", { className: "nice-select__loading", children: /* @__PURE__ */ t(
372
+ "div",
373
+ {
374
+ className: "nice-spinner nice-spinner--sm",
375
+ style: { margin: "8px auto" }
376
+ }
377
+ ) }),
378
+ !E && l.length === 0 ? /* @__PURE__ */ t("div", { className: "nice-select__empty", children: h || C("controls.noResults", "No results found") }) : x && !Array.from(Ce.keys()).some((e) => e !== "") ? (() => {
379
+ const n = l.length * o, i = Math.max(
380
+ 0,
381
+ Math.floor(be / o) - 3
382
+ ), b = Math.min(
383
+ l.length,
384
+ Math.ceil((be + $) / o) + 3
385
+ ), f = l.slice(i, b);
386
+ return /* @__PURE__ */ t("div", { style: { height: n, position: "relative" }, children: f.map((m, Ue) => {
387
+ const W = i + Ue, re = c.includes(m.value);
388
+ return (
389
+ // eslint-disable-next-line jsx-a11y/click-events-have-key-events -- keys: the combobox (aria-activedescendant)
390
+ /* @__PURE__ */ t(
391
+ "div",
392
+ {
393
+ id: ve(W),
394
+ "data-nice-option-index": W,
395
+ role: "option",
396
+ "aria-selected": re,
397
+ "aria-disabled": m.disabled || void 0,
398
+ className: `nice-select__option ${re ? "nice-select__option--selected" : ""} ${W === u ? "nice-select__option--highlighted" : ""} ${m.disabled ? "nice-select__option--disabled" : ""}`,
399
+ style: {
400
+ position: "absolute",
401
+ top: W * o,
402
+ left: 0,
403
+ right: 0,
404
+ height: o,
405
+ display: "flex",
406
+ alignItems: "center",
407
+ padding: "0 12px"
408
+ },
409
+ onClick: () => !m.disabled && U(String(m.value)),
410
+ onMouseEnter: () => z(W),
411
+ children: X ? X(m, re) : /* @__PURE__ */ v(Ie, { children: [
412
+ m.icon && /* @__PURE__ */ t("span", { children: m.icon }),
413
+ /* @__PURE__ */ v("div", { style: { flex: 1 }, children: [
414
+ /* @__PURE__ */ t("div", { children: m.label }),
415
+ m.description && /* @__PURE__ */ t("div", { className: "nice-select__option-desc", children: m.description })
416
+ ] }),
417
+ re && /* @__PURE__ */ t(
418
+ oe,
419
+ {
420
+ name: "check",
421
+ size: 16,
422
+ className: "nice-select__option-check"
423
+ }
424
+ )
425
+ ] })
426
+ },
427
+ m.value
428
+ )
429
+ );
430
+ }) });
431
+ })() : Array.from(Ce.entries()).map(([e, n]) => /* @__PURE__ */ v(cn.Fragment, { children: [
432
+ e && /* @__PURE__ */ t("div", { className: "nice-select__group-label", children: e }),
433
+ n.map((i) => {
434
+ const b = c.includes(i.value), f = l.indexOf(i);
435
+ return (
436
+ // eslint-disable-next-line jsx-a11y/click-events-have-key-events -- keys: the combobox (aria-activedescendant)
437
+ /* @__PURE__ */ t(
438
+ "div",
439
+ {
440
+ id: ve(f),
441
+ "data-nice-option-index": f,
442
+ role: "option",
443
+ "aria-selected": b,
444
+ "aria-disabled": i.disabled || void 0,
445
+ className: `nice-select__option ${b ? "nice-select__option--selected" : ""} ${f === u ? "nice-select__option--highlighted" : ""} ${i.disabled ? "nice-select__option--disabled" : ""}`,
446
+ onClick: () => !i.disabled && U(String(i.value)),
447
+ onMouseEnter: () => z(f),
448
+ children: X ? X(i, b) : /* @__PURE__ */ v(Ie, { children: [
449
+ i.icon && /* @__PURE__ */ t("span", { children: i.icon }),
450
+ /* @__PURE__ */ v("div", { style: { flex: 1 }, children: [
451
+ /* @__PURE__ */ t("div", { children: i.label }),
452
+ i.description && /* @__PURE__ */ t("div", { className: "nice-select__option-desc", children: i.description })
453
+ ] }),
454
+ b && /* @__PURE__ */ t(
455
+ oe,
456
+ {
457
+ name: "check",
458
+ size: 16,
459
+ className: "nice-select__option-check"
460
+ }
461
+ )
462
+ ] })
463
+ },
464
+ i.value
465
+ )
466
+ );
467
+ })
468
+ ] }, e))
469
+ ]
470
+ }
471
+ ),
472
+ Ee
473
+ )
474
+ ] }),
475
+ E && /* @__PURE__ */ t("span", { className: "nice-field__spinner", children: /* @__PURE__ */ t("span", { className: "nice-spinner nice-spinner--sm" }) }),
476
+ Z === "right" && _ && /* @__PURE__ */ t("div", { id: `${S}-error`, className: "nice-field__error", role: "alert", children: _ }),
477
+ Z === "right" && !_ && D && /* @__PURE__ */ t("div", { id: `${S}-helper`, className: "nice-field__helper", children: D })
478
+ ] }),
479
+ Z !== "right" && _ && /* @__PURE__ */ t("div", { id: `${S}-error`, className: "nice-field__error", role: "alert", children: _ }),
480
+ Z !== "right" && !_ && D && /* @__PURE__ */ t("div", { id: `${S}-helper`, className: "nice-field__helper", children: D })
481
+ ]
482
+ }
483
+ );
484
+ }
485
+ ),
486
+ { displayName: "NiceSelect" }
487
+ ), gn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
488
+ __proto__: null,
489
+ NiceSelect: fn
490
+ }, Symbol.toStringTag, { value: "Module" }));
491
+ export {
492
+ fn as N,
493
+ gn as a,
494
+ un as u
495
+ };