@nice2dev/ui 1.0.30 → 1.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +848 -0
- package/README.md +30 -31
- package/dist/NiceCalendarScheduler.doc-BEtQkZjV.cjs +9 -0
- package/dist/NiceCalendarScheduler.doc-D__LRgOx.js +33 -0
- package/dist/NiceCodeEditor-BVUwp9yX.js +1134 -0
- package/dist/NiceCodeEditor-cIqUSk3j.cjs +260 -0
- package/dist/NiceColorPicker-C8NZZcXE.js +596 -0
- package/dist/NiceColorPicker-CKVbjicN.cjs +1 -0
- package/dist/NiceConfirmDialog-B57cl_F7.cjs +1 -0
- package/dist/NiceConfirmDialog-DmBX1Iea.js +81 -0
- package/dist/NiceConfirmDialog-N9fBTLYm.js +81 -0
- package/dist/NiceConfirmDialog-oSxVpsCs.cjs +1 -0
- package/dist/NiceDataGrid-3AIf2D3t.cjs +10 -0
- package/dist/NiceDataGrid-CXCUAkRb.js +1736 -0
- package/dist/NiceDocumentViewer-B-uEPZAf.js +672 -0
- package/dist/NiceDocumentViewer-BE0gKBlw.cjs +180 -0
- package/dist/NiceDrawingCanvas.doc-Dv5vB4gY.js +32 -0
- package/dist/NiceDrawingCanvas.doc-Ww9zz17x.cjs +8 -0
- package/dist/NiceErrorBoundary-BD-uqk_q.js +709 -0
- package/dist/NiceErrorBoundary-CIPXaYik.cjs +1 -0
- package/dist/NiceFileManagerViews.doc-CKlnm6cX.cjs +1 -0
- package/dist/NiceFileManagerViews.doc-Cg21DArG.js +25 -0
- package/dist/NiceForm-BNZB31Pg.js +4499 -0
- package/dist/NiceForm-C6F0HvrX.cjs +1 -0
- package/dist/NiceForm-CCyfWgIs.js +4805 -0
- package/dist/NiceForm-CPyAXxBO.cjs +1 -0
- package/dist/NiceGantt-CSFLZD2y.js +328 -0
- package/dist/NiceGantt-_ysNSVYR.cjs +1 -0
- package/dist/NiceHtmlEditor-B8B8AcSC.js +841 -0
- package/dist/NiceHtmlEditor-D8RQcBNp.cjs +10 -0
- package/dist/NiceLoginForm-Bai7aN8V.js +708 -0
- package/dist/NiceLoginForm-BrvIc-wq.cjs +1 -0
- package/dist/NiceMegaMenu.doc-7UyOCd3l.cjs +7 -0
- package/dist/NiceMegaMenu.doc-zeIyVa65.js +31 -0
- package/dist/NiceMention-CWoLD0SE.js +11082 -0
- package/dist/NiceMention-J1lUDLhg.cjs +430 -0
- package/dist/NiceMention.css +1 -0
- package/dist/NiceModal-0UxviEYE.cjs +1 -0
- package/dist/NiceModal-Bj53SKLI.js +95 -0
- package/dist/NiceModal-D-iOonog.js +95 -0
- package/dist/NiceModal-DC0UlQhc.cjs +1 -0
- package/dist/NiceModuleLifecyclePanel-4hzDw6it.js +6999 -0
- package/dist/NiceModuleLifecyclePanel-BBOg9g0b.cjs +1 -0
- package/dist/NiceModuleLifecyclePanel-Df_1k5qW.cjs +1 -0
- package/dist/NiceModuleLifecyclePanel-DtuXRiLR.js +6991 -0
- package/dist/NiceModuleLifecyclePanel.css +1 -1
- package/dist/NicePagination-Bjxy9aEc.js +172 -0
- package/dist/NicePagination-CPn-Q1h_.js +172 -0
- package/dist/NicePagination-CfFfNwrg.cjs +1 -0
- package/dist/NicePagination-EEQ6o1dF.cjs +1 -0
- package/dist/NicePivotGrid-Cmiolup9.cjs +152 -0
- package/dist/NicePivotGrid-DX_iUj2X.js +1167 -0
- package/dist/NiceSavedQueryPanel-BhjFJBvn.cjs +586 -0
- package/dist/NiceSavedQueryPanel-CH5c3rUG.js +6988 -0
- package/dist/NiceSavedQueryPanel-KvyXTnFx.js +5129 -0
- package/dist/NiceSavedQueryPanel-aQrEmmcC.cjs +596 -0
- package/dist/NiceScannerControl-Cd5KXJA9.js +12769 -0
- package/dist/NiceScannerControl-DZsERSw_.cjs +698 -0
- package/dist/NiceScannerControl.css +1 -0
- package/dist/NiceScheduler-DuxPzQQZ.js +1645 -0
- package/dist/NiceScheduler-nW7fMzKL.cjs +5 -0
- package/dist/NiceSelect-BVoqtfYN.cjs +1 -0
- package/dist/NiceSelect-DHowflmX.js +433 -0
- package/dist/NiceWindow-BoDzlGk-.js +1621 -0
- package/dist/NiceWindow-DdD9k4nc.cjs +1 -0
- package/dist/NiceWindow-DgONWxBm.cjs +1 -0
- package/dist/NiceWindow-xnTSHdHv.js +1623 -0
- package/dist/charts-B-sl1V9y.cjs +882 -0
- package/dist/charts-Bs0aDM0X.js +4671 -0
- package/dist/charts-DO2z6Ziu.js +31920 -0
- package/dist/charts-DjjKkw0q.cjs +761 -0
- package/dist/charts.cjs +1 -1
- package/dist/charts.mjs +7 -7
- package/dist/core-BUsZ7_vI.js +27914 -0
- package/dist/core-C2KhqEaU.cjs +1 -0
- package/dist/core-CLfcCDKc.cjs +122 -0
- package/dist/core-K2DIxXLn.js +795 -0
- package/dist/data-branching-D7l_kILW.cjs +1 -0
- package/dist/data-branching-DC6hcBQN.cjs +1 -0
- package/dist/data-branching-DykdTpjJ.js +6255 -0
- package/dist/data-branching-lJ07lDN-.js +6255 -0
- package/dist/data-branching.cjs +1 -1
- package/dist/data-branching.mjs +1 -1
- package/dist/data.cjs +1 -1
- package/dist/data.d.ts +70 -44
- package/dist/data.mjs +17 -16
- package/dist/devops-Bi8MXtko.js +8165 -0
- package/dist/devops-CU0sOVEA.cjs +17 -0
- package/dist/devops-CXyEwQeM.js +8165 -0
- package/dist/devops-On_1wRf9.cjs +17 -0
- package/dist/devops.cjs +1 -1
- package/dist/devops.mjs +1 -1
- package/dist/editors.cjs +1 -1
- package/dist/editors.d.ts +288 -432
- package/dist/editors.mjs +58 -62
- package/dist/feedback.cjs +1 -1
- package/dist/feedback.d.ts +1 -1
- package/dist/feedback.mjs +3 -3
- package/dist/index-BDH1yDSg.js +69235 -0
- package/dist/index-C9njkNOD.cjs +5470 -0
- package/dist/index.cjs +5137 -1
- package/dist/index.css +1 -1
- package/dist/index.d.ts +556 -929
- package/dist/index.mjs +66371 -1017
- package/dist/lazy.cjs +1 -1
- package/dist/lazy.mjs +24 -24
- package/dist/navigation.cjs +1 -1
- package/dist/navigation.d.ts +31 -213
- package/dist/navigation.mjs +105 -113
- package/dist/no-code-8lO7o6xi.js +7425 -0
- package/dist/no-code-C58g8_fb.cjs +332 -0
- package/dist/no-code-Cj4xJ3w9.js +7425 -0
- package/dist/no-code-K8tOLNew.cjs +332 -0
- package/dist/no-code.cjs +1 -1
- package/dist/no-code.mjs +1 -1
- package/dist/overlays.cjs +1 -1
- package/dist/overlays.d.ts +10 -0
- package/dist/overlays.mjs +36 -36
- package/dist/pickerCommons-B-wOzHFh.cjs +1 -0
- package/dist/pickerCommons-CORo9j2a.js +2119 -0
- package/dist/pickerCommons-COiSUiP2.js +1122 -0
- package/dist/pickerCommons-D3WShRrR.cjs +1 -0
- package/dist/style.css +6 -6
- package/dist/vendor-BPVpdtPp.js +271 -0
- package/dist/vendor-Bo2Q64AF.cjs +1 -0
- package/package.json +17 -17
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";const t=require("react/jsx-runtime"),Fe=require("./charts-B-sl1V9y.cjs"),D=require("react"),X=require("./NiceColorPicker-CKVbjicN.cjs"),we=require("./NiceForm-C6F0HvrX.cjs"),st=require("./NiceModal-0UxviEYE.cjs"),be=({children:e,className:s,style:c,direction:d="horizontal",size:a,disabled:m,readOnly:v,loading:N,error:k,errorPlacement:F="bottom"})=>{const w=t.jsxs("div",{className:`nice-btn-group ${d==="vertical"?"nice-btn-group--vertical":""} ${N?"nice-btn-group--loading":""} ${v?"nice-btn-group--readonly":""} ${s||""}`,style:c,role:"group","aria-busy":N||void 0,children:[D.Children.map(e,C=>{if(!D.isValidElement(C))return C;const n={};return m&&(n.disabled=!0),v&&(n.disabled=!0),N&&(n.disabled=!0),a&&(n.size=a),D.cloneElement(C,n)}),N&&t.jsx("span",{className:"nice-btn-group__spinner",children:t.jsx("span",{className:"nice-spinner nice-spinner--sm"})})]});if(!k)return w;const j=t.jsx("div",{className:"nice-field__error",role:"alert",children:k});return F==="right"?t.jsxs("span",{className:`nice-btn-field nice-btn-field--right ${a?`nice-field--${a}`:""}`,style:{display:"inline-flex",flexDirection:"row",alignItems:"center",gap:"8px",width:"fit-content"},children:[w,j]}):t.jsxs("span",{className:`nice-btn-field nice-btn-field--bottom ${a?`nice-field--${a}`:""}`,style:{display:"inline-flex",flexDirection:"column",alignItems:"flex-start",gap:"4px",width:"fit-content"},children:[w,j]})},L=(e,s)=>{const c=new Date(e);return c.setDate(c.getDate()+s),c},W=(e,s)=>e.getFullYear()===s.getFullYear()&&e.getMonth()===s.getMonth()&&e.getDate()===s.getDate(),rt=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],it=["January","February","March","April","May","June","July","August","September","October","November","December"],ct=["sun","mon","tue","wed","thu","fri","sat"],at=["january","february","march","april","may","june","july","august","september","october","november","december"];function oe(e){return ct.map((s,c)=>e(s,rt[c]))}function lt(e){return at.map((s,c)=>e(s,it[c]))}function Ie(e){const s=["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,s[a]))}const ot=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],dt=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];function je(e){return dt.map((s,c)=>e(s,ot[c]))}function ut(e,s,c){const d=[];for(const a of e){if(!a.recurrence){d.push(a);continue}const{freq:m,interval:v=1,until:N,count:k}=a.recurrence,F=new Date(a.end).getTime()-new Date(a.start).getTime();let w=new Date(a.start),j=0;const C=N?new Date(Math.min(N.getTime(),c.getTime())):c;for(;w<=C&&(!k||j<k);){const n=new Date(w.getTime()+F);n>=s&&d.push({...a,id:`${a.id}_${j}`,start:new Date(w),end:n}),j++;const _=new Date(w);m==="daily"?_.setDate(_.getDate()+v):m==="weekly"?_.setDate(_.getDate()+7*v):m==="monthly"?_.setMonth(_.getMonth()+v):m==="yearly"&&_.setFullYear(_.getFullYear()+v),w=_}}return d}function Ae(e,s){return e.filter(c=>{const d=new Date(c.start),a=new Date(c.end);return s>=new Date(d.getFullYear(),d.getMonth(),d.getDate())&&s<=new Date(a.getFullYear(),a.getMonth(),a.getDate())})}function Pe(e="r"){return`${e}_${Math.random().toString(36).slice(2,9)}`}function Ye(e={}){return{id:e.id??Pe(),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 qe(e){const s=(e.prepMinutes??0)+(e.cookMinutes??0);return s>0?s:void 0}const de=({ev:e,renderEvent:s,onClick:c,draggable:d,dragRef:a,onHover:m,categoryColor:v})=>{const N=v||e.color||"var(--color-primary, #3b82f6)",F={solid:{backgroundColor:N,color:"var(--bg-primary, #fff)"},striped:{background:`repeating-linear-gradient(45deg, ${N}, ${N} 4px, transparent 4px, transparent 8px)`,border:`1px solid ${N}`,color:"var(--bg-tertiary, #333)"},outlined:{backgroundColor:"transparent",border:`2px solid ${N}`,color:N},dashed:{backgroundColor:"transparent",border:`2px dashed ${N}`,color:N}}[e.eventStyle||"solid"];return t.jsx("div",{className:`nice-scheduler__event nice-scheduler__event--${e.eventStyle||"solid"}`,style:F,draggable:d,onDragStart:()=>{a.current={event:e}},onDragEnd:()=>{a.current=null},onClick:w=>{w.stopPropagation(),c?.(e)},onMouseEnter:w=>m(e,w.currentTarget.getBoundingClientRect()),onMouseLeave:()=>m(null),children:s?s(e):e.title})};function ee(e,s){if(!(!e.category||!s))return s.find(c=>c.key===e.category)?.color}const mt=({events:e,curDate:s,firstDayOfWeek:c,onSlotClick:d,onEventClick:a,draggable:m,dragRef:v,categories:N,renderEvent:k,onHoverEvent:F,readOnly:w,t:j})=>{const C=oe(j),n=s.getFullYear(),_=s.getMonth(),E=new Date(n,_,1),l=new Date(n,_+1,0),o=(E.getDay()-c+7)%7,M=l.getDate(),y=[];for(let u=o-1;u>=0;u--)y.push({date:L(E,-u-1),isCurrentMonth:!1});for(let u=0;u<M;u++)y.push({date:new Date(n,_,u+1),isCurrentMonth:!0});let R=1;for(;y.length<42;)y.push({date:new Date(n,_+1,R++),isCurrentMonth:!1});return t.jsxs("div",{className:"nice-scheduler__month",children:[t.jsx("div",{className:"nice-scheduler__month-header",children:Array.from({length:7},(u,p)=>t.jsx("div",{className:"nice-scheduler__month-dayname",children:C[(c+p)%7]},p))}),t.jsx("div",{className:"nice-scheduler__month-grid",children:y.map((u,p)=>{const $=Ae(e,u.date),h=W(u.date,new Date),b=u.date.getDay(),P=b===0||b===6;return t.jsxs("div",{className:`nice-scheduler__month-cell ${u.isCurrentMonth?"":"nice-scheduler__month-cell--other"} ${h?"nice-scheduler__month-cell--today":""} ${P?"nice-scheduler__month-cell--weekend":""}`,onClick:()=>!w&&d?.(u.date,L(u.date,1)),children:[t.jsx("div",{className:"nice-scheduler__month-date",children:u.date.getDate()}),$.slice(0,3).map(I=>t.jsx(de,{ev:I,renderEvent:k,onClick:a,draggable:m&&!w,dragRef:v,onHover:F,categoryColor:ee(I,N)},I.id)),$.length>3&&t.jsxs("div",{className:"nice-scheduler__month-more",children:["+",$.length-3]})]},p)})})]})},ht=({events:e,days:s,startHour:c,endHour:d,draggable:a,dragRef:m,onEventClick:v,onSlotClick:N,onEventDrop:k,categories:F,workHours:w,showCurrentTime:j,renderEvent:C,onHoverEvent:n,readOnly:_,t:E})=>{const l=[];for(let h=c;h<d;h++)l.push(h);oe(E);const o=je(E),M=D.useRef(null),y=new Date,R=y.getHours()*60+y.getMinutes(),u=(d-c)*60,p=(R-c*60)/u*100,$=j&&R>=c*60&&R<d*60;return D.useEffect(()=>{const h=M.current;if(!h)return;const b=new Date,P=e.filter(T=>s.some(q=>W(q,new Date(T.start)))),I=P.filter(T=>W(new Date(T.start),b));let Y;I.length>0?Y=Math.min(...I.map(T=>new Date(T.start).getHours())):P.length>0?Y=Math.min(...P.map(T=>new Date(T.start).getHours())):Y=8,Y=Math.max(c,Math.min(Y,d-1));const i=Y-c,g=h.children[i];if(g){const T=h.closest(".nice-scheduler__content")??h.closest(".nice-scheduler__timegrid");T&&(T.scrollTop=g.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"}),s.map((h,b)=>{const P=h.getDay()===0||h.getDay()===6;return t.jsxs("div",{className:`nice-scheduler__timegrid-day-header ${W(h,y)?"nice-scheduler__timegrid-day-header--today":""} ${P?"nice-scheduler__timegrid-day-header--weekend":""}`,children:[t.jsx("div",{className:"nice-scheduler__timegrid-day-name",children:o[h.getDay()]}),t.jsx("div",{className:"nice-scheduler__timegrid-day-num",children:h.getDate()})]},b)})]}),t.jsxs("div",{className:"nice-scheduler__timegrid-body",ref:M,style:{position:"relative"},children:[l.map(h=>{const b=w?h>=w[0]&&h<w[1]:!1;return t.jsxs("div",{className:`nice-scheduler__timegrid-row ${b?"nice-scheduler__timegrid-row--work":""}`,children:[t.jsx("div",{className:"nice-scheduler__time-gutter",children:`${h.toString().padStart(2,"0")}:00`}),s.map((P,I)=>{const Y=e.filter(i=>{const g=new Date(i.start);return W(g,P)&&g.getHours()===h});return t.jsx("div",{className:"nice-scheduler__timegrid-cell",onDragOver:a&&!_?i=>i.preventDefault():void 0,onDrop:a&&!_?()=>{if(!m.current||!k)return;const i=m.current.event,g=new Date(i.end).getTime()-new Date(i.start).getTime(),T=new Date(P);T.setHours(h,0,0,0);const q=new Date(T.getTime()+g);k(i,T,q),m.current=null}:void 0,onClick:()=>!_&&(()=>{const i=new Date(P);i.setHours(h);const g=new Date(i);g.setHours(h+1),N?.(i,g)})(),children:Y.map(i=>t.jsx(de,{ev:i,renderEvent:C,onClick:v,draggable:a&&!_,dragRef:m,onHover:n,categoryColor:ee(i,F)},i.id))},I)})]},h)}),$&&s.some(h=>W(h,y))&&t.jsx("div",{className:"nice-scheduler__now-line",style:{top:`${p}%`},children:t.jsx("div",{className:"nice-scheduler__now-dot"})})]})]})},gt=({events:e,curDate:s,onEventClick:c,categories:d,t:a})=>{const m=[...e].filter(v=>new Date(v.start)>=new Date(s.getFullYear(),s.getMonth(),s.getDate())).sort((v,N)=>new Date(v.start).getTime()-new Date(N.start).getTime()).slice(0,50);return t.jsxs("div",{className:"nice-scheduler__agenda",children:[m.map(v=>t.jsx(pt,{ev:v,categories:d,onEventClick:c},v.id)),m.length===0&&t.jsx("div",{className:"nice-scheduler__agenda-empty",children:a("noEvents","No upcoming events")})]})},He=({ev:e})=>{if(e.eventType==="recipe"&&e.recipe){const s=qe(e.recipe),c=[];return s!==void 0&&c.push(`⏱ ${s} min`),e.recipe.ingredients?.length&&c.push(`🥕 ${e.recipe.ingredients.length} ingredients`),e.recipe.servings&&c.push(`🍽 ${e.recipe.servings} servings`),c.length===0?null:t.jsx("div",{className:"nice-scheduler__agenda-meta",children:c.join(" · ")})}if(e.eventType==="service"&&e.service){const s=e.service,c=[];return s.serviceName&&c.push(`🛎 ${s.serviceName}`),s.providerName&&c.push(`👤 ${s.providerName}`),s.customerName&&c.push(`→ ${s.customerName}`),typeof s.price=="number"&&c.push(`💵 ${s.price}${s.currency?" "+s.currency:""}`),c.length===0?null:t.jsx("div",{className:"nice-scheduler__agenda-meta",children:c.join(" · ")})}return null},pt=({ev:e,categories:s,onEventClick:c})=>{const d=Fe.el({onClick:()=>c?.(e)});return t.jsxs("div",{className:"nice-scheduler__agenda-item","aria-label":`Event ${e.title}`,...d,children:[t.jsx("div",{className:"nice-scheduler__agenda-dot",style:{backgroundColor:ee(e,s)||e.color||"var(--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(He,{ev:e})]}),e.category&&s&&t.jsx("span",{className:"nice-scheduler__agenda-badge",style:{backgroundColor:ee(e,s)||e.color},children:s.find(a=>a.key===e.category)?.label})]})},yt=({events:e,curDate:s,timelineDays:c,resources:d,draggable:a,dragRef:m,onEventClick:v,onSlotClick:N,onEventDrop:k,categories:F,renderEvent:w,onHoverEvent:j,readOnly:C,t:n})=>{const _=Array.from({length:c},(o,M)=>L(s,M)),E=d??[{id:"__default",name:""}],l=oe(n);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"}),_.map((o,M)=>t.jsxs("div",{className:`nice-scheduler__timeline-day ${W(o,new Date)?"nice-scheduler__timeline-day--today":""}`,children:[l[o.getDay()]," ",o.getDate()]},M))]}),t.jsx("div",{className:"nice-scheduler__timeline-body",children:E.map(o=>{const M=e.filter(y=>!d||y.resourceId===o.id);return t.jsxs("div",{className:"nice-scheduler__timeline-row",children:[t.jsx("div",{className:"nice-scheduler__timeline-res-label",children:o.name}),_.map((y,R)=>{const u=M.filter(p=>W(new Date(p.start),y));return t.jsx("div",{className:"nice-scheduler__timeline-cell",onDragOver:a&&!C?p=>p.preventDefault():void 0,onDrop:a&&!C?()=>{if(!m.current||!k)return;const p=m.current.event,$=new Date(p.end).getTime()-new Date(p.start).getTime(),h=new Date(y);h.setHours(new Date(p.start).getHours(),new Date(p.start).getMinutes()),k(p,h,new Date(h.getTime()+$),o.id),m.current=null}:void 0,onClick:()=>!C&&N?.(y,L(y,1),o.id),children:u.map(p=>t.jsx(de,{ev:p,renderEvent:w,onClick:v,draggable:a&&!C,dragRef:m,onHover:j,categoryColor:ee(p,F)},p.id))},R)})]},o.id)})})]})},Le=({categories:e,events:s,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(m=>{const v=s.filter(k=>k.category===m.key).length,N=!c.has(m.key);return t.jsxs("button",{className:`nice-scheduler__legend-item ${N?"":"nice-scheduler__legend-item--hidden"}`,onClick:()=>d(m.key),children:[t.jsx("span",{className:"nice-scheduler__legend-dot",style:{backgroundColor:N?m.color:"var(--border-color, #ccc)"}}),t.jsx("span",{className:"nice-scheduler__legend-label",children:m.label}),t.jsx("span",{className:"nice-scheduler__legend-count",children:v})]},m.key)})]}),ft=({curDate:e,onDateSelect:s,firstDayOfWeek:c,t:d})=>{const[a,m]=D.useState(e.getMonth()),[v,N]=D.useState(e.getFullYear()),k=new Date(v,a,1),F=new Date(v,a+1,0),w=(k.getDay()-c+7)%7,j=[];for(let o=w-1;o>=0;o--)j.push(L(k,-o-1));for(let o=0;o<F.getDate();o++)j.push(new Date(v,a,o+1));const C=7-j.length%7;if(C<7)for(let o=1;o<=C;o++)j.push(new Date(v,a+1,o));const n=()=>{a===0?(m(11),N(o=>o-1)):m(o=>o-1)},_=()=>{a===11?(m(0),N(o=>o+1)):m(o=>o+1)},E=Ie(d),l=oe(d);return t.jsxs("div",{className:"nice-scheduler__mini-cal",children:[t.jsxs("div",{className:"nice-scheduler__mini-cal-header",children:[t.jsx("button",{className:"nice-btn nice-btn--xs",onClick:n,children:"�"}),t.jsxs("span",{children:[E[a]," ",v]}),t.jsx("button",{className:"nice-btn nice-btn--xs",onClick:_,children:"�"})]}),t.jsxs("div",{className:"nice-scheduler__mini-cal-grid",children:[l.map((o,M)=>t.jsx("div",{className:"nice-scheduler__mini-cal-dayname",children:l[(c+M)%7].charAt(0)},M)),j.map((o,M)=>{const y=W(o,new Date),R=W(o,e),u=o.getMonth()!==a;return t.jsx("button",{className:`nice-scheduler__mini-cal-day ${y?"nice-scheduler__mini-cal-day--today":""} ${R?"nice-scheduler__mini-cal-day--selected":""} ${u?"nice-scheduler__mini-cal-day--other":""}`,onClick:()=>s(o),children:o.getDate()},M)})]})]})},_t=({events:e,rangeStart:s,rangeEnd:c,startHour:d,endHour:a,draggable:m,dragRef:v,onEventClick:N,onSlotClick:k,onEventDrop:F,categories:w,workHours:j,showCurrentTime:C,renderEvent:n,onHoverEvent:_,readOnly:E,t:l})=>{const o=[];let M=new Date(s);for(;M<=c;)o.push(new Date(M)),M=L(M,1);const y=[];for(let g=d;g<a;g++)y.push(g);const R=je(l),u=D.useRef(null),p=D.useRef(null),$=D.useRef(null),h=new Date,b=h.getHours()*60+h.getMinutes(),P=(a-d)*60,I=(b-d*60)/P*100,Y=C&&b>=d*60&&b<a*60;D.useEffect(()=>{const g=u.current;if(!g)return;const T=new Date,q=e.filter(x=>o.some(H=>W(H,T)&&W(new Date(x.start),T)));let V=q.length>0?Math.min(...q.map(x=>new Date(x.start).getHours())):T.getHours();V=Math.max(d,Math.min(V,a-1));const G=g.children[V-d];if(G){const x=$.current??g.closest(".nice-scheduler__content")??g.closest(".nice-scheduler__timegrid");x&&(x.scrollTop=G.offsetTop-4)}},[]);const i=g=>{p.current&&(p.current.scrollLeft=g.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:p,"aria-hidden":"true",children:t.jsxs("div",{className:"nice-scheduler__timegrid-header",children:[t.jsx("div",{className:"nice-scheduler__time-gutter"}),o.map((g,T)=>{const q=g.getDay()===0||g.getDay()===6;return t.jsxs("div",{className:`nice-scheduler__timegrid-day-header ${W(g,h)?"nice-scheduler__timegrid-day-header--today":""} ${q?"nice-scheduler__timegrid-day-header--weekend":""}`,children:[t.jsx("div",{className:"nice-scheduler__timegrid-day-name",children:R[g.getDay()]}),t.jsx("div",{className:"nice-scheduler__timegrid-day-num",children:g.getDate()})]},T)})]})}),t.jsx("div",{className:"nice-scheduler__timegrid-body-scroll",ref:$,onScroll:i,children:t.jsxs("div",{className:"nice-scheduler__timegrid-body",ref:u,style:{position:"relative"},children:[y.map(g=>{const T=j?g>=j[0]&&g<j[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:`${g.toString().padStart(2,"0")}:00`}),o.map((q,V)=>{const G=e.filter(x=>{const H=new Date(x.start);return W(H,q)&&H.getHours()===g});return t.jsx("div",{className:"nice-scheduler__timegrid-cell",onDragOver:m&&!E?x=>x.preventDefault():void 0,onDrop:m&&!E?()=>{if(!v.current||!F)return;const x=v.current.event,H=new Date(x.end).getTime()-new Date(x.start).getTime(),z=new Date(q);z.setHours(g,0,0,0),F(x,z,new Date(z.getTime()+H)),v.current=null}:void 0,onClick:()=>!E&&(()=>{const x=new Date(q);x.setHours(g);const H=new Date(x);H.setHours(g+1),k?.(x,H)})(),children:G.map(x=>t.jsx(de,{ev:x,renderEvent:n,onClick:N,draggable:m&&!E,dragRef:v,onHover:_,categoryColor:ee(x,w)},x.id))},V)})]},g)}),Y&&o.some(g=>W(g,h))&&t.jsx("div",{className:"nice-scheduler__now-line",style:{top:`${I}%`},children:t.jsx("div",{className:"nice-scheduler__now-dot"})})]})})]})},vt=({events:e,rangeStart:s,rangeEnd:c,firstDayOfWeek:d,onSlotClick:a,onEventClick:m,draggable:v,dragRef:N,categories:k,renderEvent:F,onHoverEvent:w,readOnly:j,t:C})=>{const n=oe(C);je(C);const _=[];let E=new Date(s);for(;E<=c;)_.push(new Date(E)),E=L(E,1);const l=(_[0].getDay()-d+7)%7,o=[];for(let y=l-1;y>=0;y--)o.push({date:L(_[0],-y-1),inRange:!1});_.forEach(y=>o.push({date:y,inRange:!0}));const M=7-o.length%7;if(M<7){const y=_[_.length-1];for(let R=1;R<=M;R++)o.push({date:L(y,R),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},(y,R)=>t.jsx("div",{className:"nice-scheduler__month-dayname",children:n[(d+R)%7]},R))}),t.jsx("div",{className:"nice-scheduler__month-grid",children:o.map((y,R)=>{const u=Ae(e,y.date),p=W(y.date,new Date),$=y.date.getDay()===0||y.date.getDay()===6;return t.jsxs("div",{className:`nice-scheduler__month-cell ${y.inRange?"":"nice-scheduler__month-cell--other"} ${p?"nice-scheduler__month-cell--today":""} ${$?"nice-scheduler__month-cell--weekend":""}`,onClick:()=>!j&&a?.(y.date,L(y.date,1)),children:[t.jsx("div",{className:"nice-scheduler__month-date",children:y.date.getDate()===1||R===0?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"nice-scheduler__month-monthname",children:Ie(C)[y.date.getMonth()]})," ",y.date.getDate()]}):y.date.getDate()}),u.slice(0,3).map(h=>t.jsx(de,{ev:h,renderEvent:F,onClick:m,draggable:v&&!j,dragRef:N,onHover:w,categoryColor:ee(h,k)},h.id)),u.length>3&&t.jsxs("div",{className:"nice-scheduler__month-more",children:["+",u.length-3]})]},R)})})]})},xt=({event:e,rect:s,categories:c,renderTooltip:d})=>{if(d)return t.jsx("div",{className:"nice-scheduler__tooltip",style:{position:"fixed",left:s.right+8,top:s.top,zIndex:1e4},children:d(e)});const a=c?.find(m=>m.key===e.category);return t.jsxs("div",{className:"nice-scheduler__tooltip",style:{position:"fixed",left:s.right+8,top:s.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(He,{ev:e})]})},Nt=({event:e,slotStart:s,slotEnd:c,categories:d,resources:a,formFields:m,formFieldsByType:v,eventTypes:N,renderEditor:k,saving:F,onSave:w,onDelete:j,onClose:C,t:n})=>{const _=!!e,E=D.useMemo(()=>({title:e?.title??"",description:e?.description??"",color:e?.color??"var(--nice-primary, #3b82f6)",category:e?.category??"",eventStyle:e?.eventStyle??"solid",start:e?.start??s??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(u=>[u.quantity,u.unit,u.name].filter(p=>p!==void 0&&p!=="").join(" ")).join(`
|
|
2
|
+
`),recipeSteps:(e?.recipe?.steps??[]).map(u=>u.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,s,c]),[l,o]=D.useState(E);D.useEffect(()=>{o(E)},[E]);const M=D.useCallback((u,p)=>{o($=>({...$,[u]:p}))},[]),y=D.useMemo(()=>{if(m&&m.length>0)return m;const u=i=>i.toString().padStart(2,"0"),p=i=>`${i.getFullYear()}-${u(i.getMonth()+1)}-${u(i.getDate())}`,$=i=>`${u(i.getHours())}:${u(i.getMinutes())}`,h=(i,g)=>{const T=i instanceof Date?i:new Date(i),q=isNaN(T.getTime())?new Date:T,V=p(q),G=$(q),x=(H,z)=>{const[K,ue,me]=H.split("-").map(ie=>parseInt(ie,10)),[he,ge]=z.split(":").map(ie=>parseInt(ie,10)),re=new Date(q);!isNaN(K)&&!isNaN(ue)&&!isNaN(me)&&re.setFullYear(K,ue-1,me),!isNaN(he)&&!isNaN(ge)&&re.setHours(he,ge,0,0),g(re)};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(--text-muted, #888)"},children:n("date","Date")}),t.jsx(we.NiceDateTimePicker,{value:V,onChange:H=>x(H,G),size:"sm"})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:2},children:[t.jsx("span",{style:{fontSize:"0.7rem",color:"var(--text-muted, #888)"},children:n("time","Time")}),t.jsx(we.NiceDateTimePicker,{dateFormatPreset:"time",value:G,onChange:H=>x(V,H),size:"sm"})]})]})},b=[];N&&N.length>1&&b.push({field:"eventType",label:n("eventType","Type"),type:"select",group:n("common","Common"),options:N.map(i=>({label:i.icon?`${i.icon} ${i.label}`:i.label,value:i.type}))}),b.push({field:"title",label:n("title","Title"),type:"text",required:!0,group:n("common","Common")},{field:"start",label:n("start","Start"),render:h,group:n("common","Common")},{field:"end",label:n("end","End"),render:h,group:n("common","Common")},{field:"description",label:n("description","Description"),type:"textarea",group:n("common","Common")},{field:"color",label:n("color","Color"),group:n("common","Common"),render:(i,g)=>t.jsx(X.NiceColorPicker,{value:typeof i=="string"?i:"var(--nice-primary, #3b82f6)",onChange:g,showInput:!1,showRandom:!1})}),d&&d.length>0&&b.push({field:"category",label:n("category","Category"),type:"select",group:n("common","Common"),options:[{label:n("none","(none)"),value:""},...d.map(i=>({label:i.label,value:i.key}))]}),a&&a.length>0&&b.push({field:"resourceId",label:n("resource","Resource"),type:"select",group:n("common","Common"),options:[{label:n("none","(none)"),value:""},...a.map(i=>({label:i.name,value:String(i.id)}))]});const P=n("recurring","Recurring");b.push({field:"recurring",label:n("repeat","Repeat"),type:"checkbox",group:P}),b.push({field:"recurrenceFreq",label:n("frequency","Frequency"),type:"select",group:P,visibleWhen:i=>!!i.recurring,options:[{label:n("daily","Daily"),value:"daily"},{label:n("weekly","Weekly"),value:"weekly"},{label:n("monthly","Monthly"),value:"monthly"},{label:n("yearly","Yearly"),value:"yearly"}]}),b.push({field:"recurrenceInterval",label:n("interval","Interval"),type:"number",group:P,visibleWhen:i=>!!i.recurring}),b.push({field:"recurrenceCount",label:n("occurrences","Occurrences (optional)"),type:"number",group:P,visibleWhen:i=>!!i.recurring});const I=l.eventType??"task",Y=v?.[I];if(Y&&Y.length>0)b.push(...Y);else if(I==="recipe"){const i=n("recipe.section","Recipe");b.push({field:"recipeTitle",label:n("recipe.title","Recipe title"),type:"text",group:i},{field:"recipeServings",label:n("recipe.servings","Servings"),type:"number",group:i},{field:"recipePrep",label:n("recipe.prepMinutes","Prep (min)"),type:"number",group:i},{field:"recipeCook",label:n("recipe.cookMinutes","Cook (min)"),type:"number",group:i},{field:"recipeIngredients",label:n("recipe.ingredients","Ingredients (one per line)"),type:"textarea",group:i,hint:n("recipe.ingredients.hint",'Format: "200 g flour"')},{field:"recipeSteps",label:n("recipe.steps","Steps (one per line)"),type:"textarea",group:i})}else if(I==="service"){const i=n("service.section","Service");b.push({field:"serviceName",label:n("service.name","Service name"),type:"text",group:i,required:!0},{field:"serviceProvider",label:n("service.provider","Provider"),type:"text",group:i},{field:"serviceCustomer",label:n("service.customer","Customer"),type:"text",group:i},{field:"serviceContact",label:n("service.contact","Contact"),type:"text",group:i},{field:"serviceLocation",label:n("service.location","Location"),type:"text",group:i},{field:"servicePrice",label:n("service.price","Price"),type:"number",group:i},{field:"serviceCurrency",label:n("service.currency","Currency"),type:"text",group:i},{field:"serviceNotes",label:n("service.notes","Notes"),type:"textarea",group:i})}return b},[m,v,N,d,a,l.eventType,n]),R=()=>{const u=l.eventType??"task",p={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:u};if(l.recurring){const $={freq:l.recurrenceFreq||"weekly",interval:typeof l.recurrenceInterval=="number"&&l.recurrenceInterval>0?l.recurrenceInterval:1};typeof l.recurrenceCount=="number"&&l.recurrenceCount>0&&($.count=l.recurrenceCount),p.recurrence=$}else p.recurrence=void 0;if(u==="recipe"){const $=String(l.recipeIngredients||"").split(`
|
|
4
|
+
`).map(I=>I.trim()).filter(Boolean).map((I,Y)=>{const i=I.match(/^([\d.,/]+)\s*(\S+)?\s+(.+)$/);if(i){const g=parseFloat(i[1].replace(",","."));return{id:`ing-${Y}`,name:i[3],quantity:isNaN(g)?void 0:g,unit:i[2]}}return{id:`ing-${Y}`,name:I}}),h=String(l.recipeSteps||"").split(`
|
|
5
|
+
`).map(I=>I.trim()).filter(Boolean).map((I,Y)=>({id:`step-${Y}`,order:Y+1,instruction:I})),b=e?.recipe??Ye(),P={...b,title:l.recipeTitle||l.title||b.title,servings:typeof l.recipeServings=="number"?l.recipeServings:b.servings,prepMinutes:typeof l.recipePrep=="number"?l.recipePrep:b.prepMinutes,cookMinutes:typeof l.recipeCook=="number"?l.recipeCook:b.cookMinutes,ingredients:$,steps:h};p.recipe=P,p.service=void 0}else if(u==="service"){const $={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};p.service=$,p.recipe=void 0}else p.recipe=void 0,p.service=void 0;return _&&(p.id=e.id),p};return t.jsx(st.NiceModal,{open:!0,onClose:C,title:_?n("editEvent","Edit Event"):n("newEvent","New Event"),size:"md",footer:k?null:t.jsxs(t.Fragment,{children:[_&&j&&t.jsx(X.NiceButton,{type:"button",variant:"error",size:"sm",onClick:()=>{j(e),C()},disabled:F,children:n("delete","Delete")}),t.jsx("div",{style:{flex:1}}),t.jsx(X.NiceButton,{type:"button",variant:"secondary",size:"sm",onClick:C,disabled:F,children:n("cancel","Cancel")}),t.jsx(X.NiceButton,{type:"button",variant:"primary",size:"sm",onClick:()=>{l.title&&w(R())},disabled:F||!l.title,children:F?n("saving","Saving…"):n("save","Save")})]}),children:t.jsx("div",{className:"nice-scheduler__form-body",onKeyDown:u=>{u.key==="Enter"&&u.target.tagName!=="TEXTAREA"&&(u.preventDefault(),l.title&&w(R()))},children:k?k({event:e,slotStart:s,slotEnd:c,save:w,cancel:C,remove:j}):t.jsx(we.NiceForm,{items:y,data:l,onFieldChange:M,columns:1,gap:12,size:"sm"})})})},Dt=["day","workWeek","week","dayRange","month","monthRange","timeline","agenda"],Se=({events:e,resources:s,currentDate:c,view:d,onDateChange:a,onViewChange:m,onEventClick:v,onSlotClick:N,onEventDrop:k,draggable:F=!1,timelineDays:w=7,startHour:j=0,endHour:C=24,firstDayOfWeek:n=1,categories:_,showLegend:E,showTooltip:l,renderEvent:o,renderTooltip:M,workHours:y,showCurrentTime:R=!0,showMiniCalendar:u,onEventCreate:p,onEventEdit:$,onEventDelete:h,editable:b=!0,formFields:P,formFieldsByType:I,eventTypes:Y,renderEventEditor:i,loadEvents:g,onEventsChange:T,accessMode:q="full",className:V,style:G})=>{const{t:x}=Fe.Gt(),H=q==="hidden",z=q==="readOnly"||q==="disabled",K=q==="disabled",[ue,me]=D.useState(c??new Date),[he,ge]=D.useState(d??"week"),re=c!==void 0&&a!==void 0,ie=d!==void 0&&m!==void 0,A=re?c:ue,S=ie?d:he,Be=D.useRef(null),[U,_e]=D.useState(()=>{const r=new Date;return r.setHours(0,0,0,0),r}),[J,ve]=D.useState(()=>L(new Date,13)),[xe,Ce]=D.useState(null),We=D.useCallback((r,f)=>{l&&Ce(r&&f?{event:r,rect:f}:null)},[l]),[te,ce]=D.useState(null),[ze,pe]=D.useState(!1),[Ve,Ke]=D.useState(null),[Ue,Ge]=D.useState(null),[bt,ke]=D.useState(!1),O=Ue??Ve??e,[ae,Je]=D.useState(new Set),Me=D.useCallback(r=>{Je(f=>{const B=new Set(f);return B.has(r)?B.delete(r):B.add(r),B})},[]),Q=D.useMemo(()=>{if(S==="month")return{start:new Date(A.getFullYear(),A.getMonth(),1),end:new Date(A.getFullYear(),A.getMonth()+2,0)};if(S==="timeline")return{start:new Date(A),end:L(A,w)};if(S==="dayRange"||S==="monthRange")return{start:new Date(U),end:L(J,1)};const r=(()=>{const f=new Date(A),B=(f.getDay()-n+7)%7;return L(f,-B)})();return{start:L(r,-1),end:L(r,8)}},[A,S,n,w,U,J]),Ne=D.useMemo(()=>{let r=ut(O,Q.start,Q.end);return ae.size>0&&(r=r.filter(f=>!f.category||!ae.has(f.category))),r},[O,Q,ae]),ne=r=>{me(r),a?.(r)},Xe=r=>{ge(r),m?.(r)},Te=r=>{if(S==="day")ne(L(A,r));else if(S==="week"||S==="workWeek")ne(L(A,r*7));else if(S==="timeline")ne(L(A,r*w));else if(S==="dayRange"||S==="monthRange"){const f=Math.round((J.getTime()-U.getTime())/864e5)+1;_e(L(U,r*f)),ve(L(J,r*f))}else{const f=new Date(A);f.setMonth(f.getMonth()+r),ne(f)}},De=D.useMemo(()=>{const r=new Date(A),f=(r.getDay()-n+7)%7;return L(r,-f)},[A,n]),ye=D.useMemo(()=>{if(S==="day")return[A];if(S==="workWeek"){const r=[];for(let f=0;f<7;f++){const B=L(De,f),Z=B.getDay();Z!==0&&Z!==6&&r.push(B)}return r}return Array.from({length:7},(r,f)=>L(De,f))},[S,A,De]),Oe=S==="day"?A.toLocaleDateString():S==="week"||S==="workWeek"?`${ye[0].toLocaleDateString()} – ${ye[ye.length-1].toLocaleDateString()}`:S==="timeline"?`${A.toLocaleDateString()} – ${L(A,w-1).toLocaleDateString()}`:S==="dayRange"||S==="monthRange"?`${U.toLocaleDateString()} – ${J.toLocaleDateString()}`:`${lt(x)[A.getMonth()]} ${A.getFullYear()}`,Qe=D.useCallback((r,f,B)=>{z||(b&&ce({mode:"create",slotStart:r,slotEnd:f}),N?.(r,f,B))},[b,N,z]),Ze=D.useCallback(r=>{b&&!z&&ce({mode:"edit",event:r}),v?.(r)},[b,v,z]),le=D.useCallback(r=>{Ke(r),T?.(r)},[T]),et=D.useCallback(async r=>{const f=te?.mode==="create";try{if(pe(!0),f){const Z=(p?await p(r):void 0)??{...r,id:typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():`evt_${Date.now()}_${Math.random().toString(36).slice(2,7)}`},fe=O.slice();fe.push(Z),le(fe)}else{const Z=($?await $(r):void 0)??r,fe=O.map(Re=>Re.id===Z.id?Z:Re);le(fe)}ce(null)}finally{pe(!1)}},[te,p,$,O,le]),tt=D.useCallback(async r=>{try{pe(!0),h&&await h(r);const f=O.filter(B=>B.id!==r.id);le(f),ce(null)}finally{pe(!1)}},[h,O,le]);D.useEffect(()=>{if(!g)return;let r=!1;return ke(!0),g({start:Q.start,end:Q.end}).then(f=>{r||Ge(f)}).finally(()=>{r||ke(!1)}),()=>{r=!0}},[g,Q.start.getTime(),Q.end.getTime()]);const nt=r=>({day:x("day","Day"),week:x("week","Week"),workWeek:x("workWeek","Work Week"),month:x("month","Month"),timeline:x("timeline","Timeline"),agenda:x("agenda","Agenda"),dayRange:x("dayRange","Day Range"),monthRange:x("monthRange","Month Range")})[r],se={events:Ne,curDate:A,firstDayOfWeek:n,startHour:j,endHour:C,draggable:F,dragRef:Be,onEventClick:Ze,onSlotClick:Qe,onEventDrop:k,resources:s,timelineDays:w,categories:_,workHours:y,showCurrentTime:R,renderEvent:o,showTooltip:l,renderTooltip:M,onHoverEvent:We,readOnly:z,t:x},$e=S==="dayRange"||S==="monthRange",Ee=r=>{const f=B=>B.toString().padStart(2,"0");return`${r.getFullYear()}-${f(r.getMonth()+1)}-${f(r.getDate())}`};return H?null:t.jsxs("div",{className:`nice-scheduler ${K?"nice-scheduler--disabled":""} ${V||""}`,style:G,children:[t.jsxs("div",{className:"nice-scheduler__toolbar",children:[t.jsxs("div",{className:"nice-scheduler__nav",children:[t.jsxs(be,{size:"sm",children:[t.jsx(X.NiceButton,{onClick:()=>Te(-1),disabled:K,"aria-label":x("previous","Previous"),children:"‹"}),t.jsx(X.NiceButton,{onClick:()=>{if($e){const r=new Date;r.setHours(0,0,0,0);const f=Math.round((J.getTime()-U.getTime())/864e5);_e(r),ve(L(r,f))}else ne(new Date)},disabled:K,children:x("today","Today")}),t.jsx(X.NiceButton,{onClick:()=>Te(1),disabled:K,"aria-label":x("next","Next"),children:"›"})]}),$e?t.jsxs("span",{className:"nice-scheduler__range-picker",children:[t.jsx("input",{type:"date",className:"nice-textinput nice-textinput--sm",value:Ee(U),disabled:K,onChange:r=>{const f=new Date(r.target.value+"T00:00:00");isNaN(f.getTime())||_e(f)}}),t.jsx("span",{style:{margin:"0 4px"},children:"–"}),t.jsx("input",{type:"date",className:"nice-textinput nice-textinput--sm",value:Ee(J),disabled:K,onChange:r=>{const f=new Date(r.target.value+"T00:00:00");!isNaN(f.getTime())&&f>=U&&ve(f)}})]}):t.jsx("span",{className:"nice-scheduler__title",children:Oe})]}),t.jsx("div",{className:"nice-scheduler__views",children:t.jsx(be,{size:"sm",children:Dt.map(r=>t.jsx(X.NiceButton,{variant:r===S?"primary":"secondary",onClick:()=>Xe(r),disabled:K,children:nt(r)},r))})})]}),t.jsxs("div",{className:"nice-scheduler__body",children:[u&&t.jsxs("div",{className:"nice-scheduler__sidebar",children:[t.jsx(ft,{curDate:A,onDateSelect:r=>ne(r),firstDayOfWeek:n,t:x}),E&&_&&t.jsx(Le,{categories:_,events:Ne,filteredCategories:ae,onToggleCategory:Me,t:x})]}),t.jsxs("div",{className:"nice-scheduler__content",children:[S==="month"&&t.jsx(mt,{...se}),(S==="week"||S==="day"||S==="workWeek")&&t.jsx(ht,{...se,days:ye}),S==="dayRange"&&t.jsx(_t,{...se,rangeStart:U,rangeEnd:J}),S==="monthRange"&&t.jsx(vt,{...se,rangeStart:U,rangeEnd:J}),S==="timeline"&&t.jsx(yt,{...se}),S==="agenda"&&t.jsx(gt,{...se})]}),!u&&E&&_&&t.jsx("div",{className:"nice-scheduler__sidebar nice-scheduler__sidebar--right",children:t.jsx(Le,{categories:_,events:Ne,filteredCategories:ae,onToggleCategory:Me,t:x})})]}),xe&&t.jsx(xt,{event:xe.event,rect:xe.rect,categories:_,renderTooltip:M}),te&&b&&t.jsx(Nt,{event:te.event,slotStart:te.slotStart,slotEnd:te.slotEnd,categories:_,resources:s,formFields:P,formFieldsByType:I,eventTypes:Y,renderEditor:i,saving:ze,onSave:et,onDelete:tt,onClose:()=>ce(null),t:x})]})};Se.displayName="NiceScheduler";const wt=Object.freeze(Object.defineProperty({__proto__:null,NiceScheduler:Se},Symbol.toStringTag,{value:"Module"}));exports.NiceButtonGroup=be;exports.NiceScheduler=Se;exports.NiceScheduler$1=wt;exports.createEmptyRecipe=Ye;exports.newRecipeId=Pe;exports.recipeTotalMinutes=qe;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const t=require("react/jsx-runtime"),o=require("./charts-B-sl1V9y.cjs"),n=require("react"),Ae=require("react-dom");function _e(p){const c=p?.closest?.("[data-theme], .nice-dark, .nice-light, .dark");if(!c)return"";const a=c.getAttribute("data-theme");return a==="dark"||c.classList.contains("nice-dark")||c.classList.contains("dark")?"nice-dark":a==="light"||c.classList.contains("nice-light")?"nice-light":""}function ve(p,c,a,re){const b=n.useRef(null),[oe,W]=n.useState(null),[te,B]=n.useState(!1),[ne,A]=n.useState(""),x=n.useContext(o.Er)?.portalTarget??(typeof document<"u"?document.body:null),u=n.useRef(a);return u.current=a,n.useLayoutEffect(()=>{if(!p||!c.current)return;A(_e(c.current)),B(!1);const _=()=>{const k=c.current;if(!k)return;const r=k.getBoundingClientRect(),N=b.current?.offsetHeight??320;let E=r.bottom;E+N>window.innerHeight-8&&r.top-N>8&&(E=r.top-N);let C=r.left;C+r.width>window.innerWidth-8&&(C=Math.max(8,window.innerWidth-r.width-8)),W(g=>g&&g.left===C&&g.top===E&&g.width===r.width?g:{left:C,top:E,width:r.width})};_();const l=requestAnimationFrame(()=>{_(),B(!0)}),v=k=>{const r=k.target;r instanceof Node&&(b.current?.contains(r)||c.current?.contains(r))||u.current()},m=()=>u.current();return window.addEventListener("scroll",v,!0),window.addEventListener("resize",m),()=>{cancelAnimationFrame(l),window.removeEventListener("scroll",v,!0),window.removeEventListener("resize",m)}},[p,c,320]),n.useEffect(()=>{if(!p)return;const _=v=>{const m=v.target;c.current?.contains(m)||b.current?.contains(m)||(m instanceof Element?m:m?.parentElement??null)?.closest('.nice-select__dropdown, [role="listbox"], [role="option"]')||u.current()},l=v=>{v.key==="Escape"&&u.current()};return document.addEventListener("mousedown",_),document.addEventListener("keydown",l),()=>{document.removeEventListener("mousedown",_),document.removeEventListener("keydown",l)}},[p,c]),{popupRef:b,coords:oe,ready:te,themeClass:ne,portalTarget:x}}const le=n.forwardRef(({label:p,helperText:c,error:a,required:re,disabled:S,size:b="md",name:oe,id:W,className:te,style:B,accessMode:ne,displayStyle:A,options:ae,value:x,onChange:u,placeholder:_,multiple:l=!1,searchable:v=!0,clearable:m=!1,emptyText:k,maxHeight:r=240,optionsSource:N,valueField:E,labelField:C,virtualScroll:g,optionHeight:F=36,onSearch:I,loading:w,renderOption:P,multipleAutosize:Y=!1,showKeyboardHints:ge,labelPlacement:we,errorPlacement:K,labelWidth:U,controlWidth:T,displayMode:ye},G)=>{const se=o.Dc(ne,W),je=se==="hidden";(se==="disabled"||se==="readOnly")&&(S=!0);const{t:y}=o.Gt(),be=o.rc("input",A),ke=o.ac("input",A),L=o.bc(W),de=o.sc({enabled:ye,disabled:S}),[j,M]=n.useState(!1),[J,Q]=n.useState(""),[R,q]=n.useState(-1),[ue,Ne]=n.useState(0),fe=n.useRef(null),z=n.useRef(null),[he,$e]=n.useState(null);n.useLayoutEffect(()=>{!w&&z.current&&$e(z.current.offsetWidth)},[w,x,A]);const[O,Se]=n.useState(null);n.useLayoutEffect(()=>{l&&!Y&&z.current&&O==null&&Se(z.current.offsetWidth)},[l,Y,O]);const Ee=o.Jd(N??null,E??N?.keyField??"id",C??"name"),$=N?Ee.options:(ae??[]).map(e=>typeof e=="string"?{value:e,label:e}:e),{popupRef:Ce,coords:H,ready:pe,themeClass:V,portalTarget:me}=ve(j,fe,()=>{M(!1),Q("")}),d=n.useMemo(()=>x?Array.isArray(x)?x:[x]:[],[x]),f=n.useMemo(()=>{if(!J&&!I||I)return $;const e=J.toLowerCase();return $.filter(i=>i.label.toLowerCase().includes(e)||String(i.value).toLowerCase().includes(e))},[$,J,I]),xe=n.useMemo(()=>{const e=new Map;for(const i of f){const s=i.group||"";e.has(s)||e.set(s,[]),e.get(s).push(i)}return e},[f]),X=n.useCallback(e=>{if(l){const i=d.includes(e)?d.filter(s=>s!==e):[...d,e];u?.(i)}else u?.(e),M(!1),Q("")},[l,d,u]),Le=n.useCallback(e=>{if(e.key==="Escape"){M(!1),Q("");return}if(e.key==="Enter"||e.key===" "){if(!j){M(!0),e.preventDefault();return}R>=0&&f[R]&&(X(f[R].value),e.preventDefault());return}e.key==="ArrowDown"&&(e.preventDefault(),q(i=>Math.min(i+1,f.length-1))),e.key==="ArrowUp"&&(e.preventDefault(),q(i=>Math.max(i-1,0)))},[j,R,f,X]),ce=n.useMemo(()=>d.length===0?null:l?d.map(e=>$.find(i=>i.value===e)?.label||e).join(", "):$.find(e=>e.value===d[0])?.label||d[0],[d,$,l]),Me=n.useCallback(e=>{e.stopPropagation(),u?.(l?[]:"")},[u,l]),Re=n.useMemo(()=>[{key:"Enter",description:y("shortcuts.select","Select")},{key:"Space",description:y("shortcuts.openDropdown","Open dropdown")},o.Yc.moveUp,o.Yc.moveDown,o.Yc.cancel],[y]);return je?null:t.jsxs("div",{className:`nice-field ${T==null?"nice-field--select-auto":""} nice-field--${b} ${we==="left"?"nice-field--label-left":""} ${w?"nice-field--loading":""} ${te||""}`,style:{...B,...U!=null&&{"--nice-field-label-width":typeof U=="number"?`${U}px`:U},...T!=null&&{"--nice-field-control-width":typeof T=="number"?`${T}px`:T},...w&&he!=null&&{"--nice-select-locked-width":`${he}px`}},"aria-busy":w||void 0,children:[p&&t.jsxs("label",{htmlFor:L,className:`nice-field__label ${re?"nice-field__label--required":""}`,children:[p,ge&&t.jsx(o.ha,{shortcuts:Re,size:"sm"})]}),t.jsxs("div",{className:"nice-field__control",children:[de.isDisplay?t.jsx(o.cc,{value:ce,placeholder:_||y("controls.select","Select..."),disabled:S,onActivate:()=>{de.enterEdit(),M(!0)},ariaLabel:p}):t.jsxs("div",{className:"nice-select",ref:fe,children:[t.jsxs("button",{ref:e=>{z.current=e,typeof G=="function"?G(e):G&&(G.current=e)},type:"button",id:L,role:"combobox","aria-expanded":j,"aria-haspopup":"listbox","aria-invalid":!!a,className:`nice-select__trigger nice-select__trigger--${b} nice-select--ds-${ke} ${j?"nice-select__trigger--open":""} ${a?"nice-select__trigger--error":""} ${S?"nice-select__trigger--disabled":""}`,style:{...be,...l&&!Y&&O!=null?{width:O,maxWidth:O,overflow:"hidden"}:{}},disabled:S,onClick:()=>M(!j),onKeyDown:Le,children:[ce?t.jsx("span",{style:l&&!Y?{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}:void 0,children:ce}):t.jsx("span",{className:"nice-select__placeholder",children:_||y("controls.select","Select...")}),t.jsxs("span",{style:{display:"flex",alignItems:"center",gap:4},children:[m&&d.length>0&&t.jsx("span",{className:"nice-input__clear",onClick:Me,role:"button","aria-label":y("controls.clear","Clear"),children:t.jsx(o.oa,{name:"close",size:14})}),t.jsx("span",{className:`nice-select__chevron ${j?"nice-select__chevron--open":""}`,children:t.jsx(o.oa,{name:"chevron-down",size:16})})]})]}),j&&H&&me&&Ae.createPortal(t.jsxs("div",{ref:Ce,className:`nice-select__dropdown${V?` ${V}`:""}`,"data-theme":V==="nice-dark"?"dark":V==="nice-light"?"light":void 0,role:"listbox",style:{maxHeight:r,position:"fixed",left:H.left,top:H.top,width:H.width,minWidth:H.width,zIndex:1e3,opacity:pe?1:0,pointerEvents:pe?void 0:"none"},onScroll:g?e=>Ne(e.currentTarget.scrollTop):void 0,children:[(v||I)&&t.jsx("div",{className:"nice-select__search",children:t.jsx("input",{type:"text",value:J,onChange:e=>{Q(e.target.value),q(0),I?.(e.target.value)},placeholder:y("controls.search","Search..."),autoFocus:!0})}),w&&t.jsx("div",{className:"nice-select__loading",children:t.jsx("div",{className:"nice-spinner nice-spinner--sm",style:{margin:"8px auto"}})}),!w&&f.length===0?t.jsx("div",{className:"nice-select__empty",children:k||y("controls.noResults","No results found")}):g&&!Array.from(xe.keys()).some(e=>e!=="")?(()=>{const i=f.length*F,s=Math.max(0,Math.floor(ue/F)-3),D=Math.min(f.length,Math.ceil((ue+r)/F)+3),Z=f.slice(s,D);return t.jsx("div",{style:{height:i,position:"relative"},children:Z.map((h,De)=>{const ie=s+De,ee=d.includes(h.value);return t.jsx("div",{role:"option","aria-selected":ee,className:`nice-select__option ${ee?"nice-select__option--selected":""} ${ie===R?"nice-select__option--highlighted":""} ${h.disabled?"nice-select__option--disabled":""}`,style:{position:"absolute",top:ie*F,left:0,right:0,height:F,display:"flex",alignItems:"center",padding:"0 12px"},onClick:()=>!h.disabled&&X(String(h.value)),onMouseEnter:()=>q(ie),children:P?P(h,ee):t.jsxs(t.Fragment,{children:[h.icon&&t.jsx("span",{children:h.icon}),t.jsxs("div",{style:{flex:1},children:[t.jsx("div",{children:h.label}),h.description&&t.jsx("div",{className:"nice-select__option-desc",children:h.description})]}),ee&&t.jsx("svg",{className:"nice-select__option-check",viewBox:"0 0 20 20",fill:"currentColor",children:t.jsx("path",{fillRule:"evenodd",d:"M16.704 4.153a.75.75 0 01.143 1.052l-8 10.5a.75.75 0 01-1.127.075l-4.5-4.5a.75.75 0 011.06-1.06l3.894 3.893 7.48-9.817a.75.75 0 011.05-.143z",clipRule:"evenodd"})})]})},h.value)})})})():Array.from(xe.entries()).map(([e,i])=>t.jsxs(n.Fragment,{children:[e&&t.jsx("div",{className:"nice-select__group-label",children:e}),i.map(s=>{const D=d.includes(s.value),Z=f.indexOf(s);return t.jsx("div",{role:"option","aria-selected":D,className:`nice-select__option ${D?"nice-select__option--selected":""} ${Z===R?"nice-select__option--highlighted":""} ${s.disabled?"nice-select__option--disabled":""}`,onClick:()=>!s.disabled&&X(String(s.value)),onMouseEnter:()=>q(Z),children:P?P(s,D):t.jsxs(t.Fragment,{children:[s.icon&&t.jsx("span",{children:s.icon}),t.jsxs("div",{style:{flex:1},children:[t.jsx("div",{children:s.label}),s.description&&t.jsx("div",{className:"nice-select__option-desc",children:s.description})]}),D&&t.jsx("svg",{className:"nice-select__option-check",viewBox:"0 0 20 20",fill:"currentColor",children:t.jsx("path",{fillRule:"evenodd",d:"M16.704 4.153a.75.75 0 01.143 1.052l-8 10.5a.75.75 0 01-1.127.075l-4.5-4.5a.75.75 0 011.06-1.06l3.894 3.893 7.48-9.817a.75.75 0 011.05-.143z",clipRule:"evenodd"})})]})},s.value)})]},e))]}),me)]}),w&&t.jsx("span",{className:"nice-field__spinner",children:t.jsx("span",{className:"nice-spinner nice-spinner--sm"})}),K==="right"&&a&&t.jsx("div",{id:`${L}-error`,className:"nice-field__error",role:"alert",children:a}),K==="right"&&!a&&c&&t.jsx("div",{id:`${L}-helper`,className:"nice-field__helper",children:c})]}),K!=="right"&&a&&t.jsx("div",{id:`${L}-error`,className:"nice-field__error",role:"alert",children:a}),K!=="right"&&!a&&c&&t.jsx("div",{id:`${L}-helper`,className:"nice-field__helper",children:c})]})});le.displayName="NiceSelect";const Fe=Object.freeze(Object.defineProperty({__proto__:null,NiceSelect:le},Symbol.toStringTag,{value:"Module"}));exports.NiceSelect=le;exports.NiceSelect$1=Fe;exports.scopeThemeClass=_e;exports.useAnchoredPopup=ve;
|
|
@@ -0,0 +1,433 @@
|
|
|
1
|
+
import { jsxs as a, jsx as t, Fragment as xe } from "react/jsx-runtime";
|
|
2
|
+
import { E as Oe, D as qe, G as He, r as We, g as Be, c as Ge, n as Ke, p as Pe, q as oe, j as Ue, t as Je, o as be } from "./charts-DO2z6Ziu.js";
|
|
3
|
+
import Ye, { useRef as ne, useState as m, useContext as Qe, useLayoutEffect as de, useEffect as Ve, forwardRef as Xe, useMemo as W, useCallback as ae } from "react";
|
|
4
|
+
import { createPortal as Ze } from "react-dom";
|
|
5
|
+
function et(h) {
|
|
6
|
+
const s = h?.closest?.("[data-theme], .nice-dark, .nice-light, .dark");
|
|
7
|
+
if (!s)
|
|
8
|
+
return "";
|
|
9
|
+
const r = s.getAttribute("data-theme");
|
|
10
|
+
return r === "dark" || s.classList.contains("nice-dark") || s.classList.contains("dark") ? "nice-dark" : r === "light" || s.classList.contains("nice-light") ? "nice-light" : "";
|
|
11
|
+
}
|
|
12
|
+
function tt(h, s, r, ue) {
|
|
13
|
+
const k = ne(null), [fe, B] = m(null), [se, G] = m(!1), [ie, I] = m(""), _ = Qe(Oe)?.portalTarget ?? (typeof document < "u" ? document.body : null), d = ne(r);
|
|
14
|
+
return d.current = r, de(() => {
|
|
15
|
+
if (!h || !s.current)
|
|
16
|
+
return;
|
|
17
|
+
I(et(s.current)), G(!1);
|
|
18
|
+
const v = () => {
|
|
19
|
+
const N = s.current;
|
|
20
|
+
if (!N)
|
|
21
|
+
return;
|
|
22
|
+
const l = N.getBoundingClientRect(), $ = k.current?.offsetHeight ?? 320;
|
|
23
|
+
let L = l.bottom;
|
|
24
|
+
L + $ > window.innerHeight - 8 && l.top - $ > 8 && (L = l.top - $);
|
|
25
|
+
let M = l.left;
|
|
26
|
+
M + l.width > window.innerWidth - 8 && (M = Math.max(8, window.innerWidth - l.width - 8)), B(
|
|
27
|
+
(w) => w && w.left === M && w.top === L && w.width === l.width ? w : { left: M, top: L, width: l.width }
|
|
28
|
+
);
|
|
29
|
+
};
|
|
30
|
+
v();
|
|
31
|
+
const c = requestAnimationFrame(() => {
|
|
32
|
+
v(), G(!0);
|
|
33
|
+
}), g = (N) => {
|
|
34
|
+
const l = N.target;
|
|
35
|
+
l instanceof Node && (k.current?.contains(l) || s.current?.contains(l)) || d.current();
|
|
36
|
+
}, p = () => d.current();
|
|
37
|
+
return window.addEventListener("scroll", g, !0), window.addEventListener("resize", p), () => {
|
|
38
|
+
cancelAnimationFrame(c), window.removeEventListener("scroll", g, !0), window.removeEventListener("resize", p);
|
|
39
|
+
};
|
|
40
|
+
}, [h, s, 320]), Ve(() => {
|
|
41
|
+
if (!h)
|
|
42
|
+
return;
|
|
43
|
+
const v = (g) => {
|
|
44
|
+
const p = g.target;
|
|
45
|
+
s.current?.contains(p) || k.current?.contains(p) || (p instanceof Element ? p : p?.parentElement ?? null)?.closest('.nice-select__dropdown, [role="listbox"], [role="option"]') || d.current();
|
|
46
|
+
}, c = (g) => {
|
|
47
|
+
g.key === "Escape" && d.current();
|
|
48
|
+
};
|
|
49
|
+
return document.addEventListener("mousedown", v), document.addEventListener("keydown", c), () => {
|
|
50
|
+
document.removeEventListener("mousedown", v), document.removeEventListener("keydown", c);
|
|
51
|
+
};
|
|
52
|
+
}, [h, s]), { popupRef: k, coords: fe, ready: se, themeClass: ie, portalTarget: _ };
|
|
53
|
+
}
|
|
54
|
+
const ke = Xe(
|
|
55
|
+
({
|
|
56
|
+
label: h,
|
|
57
|
+
helperText: s,
|
|
58
|
+
error: r,
|
|
59
|
+
required: ue,
|
|
60
|
+
disabled: C,
|
|
61
|
+
size: k = "md",
|
|
62
|
+
name: fe,
|
|
63
|
+
id: B,
|
|
64
|
+
className: se,
|
|
65
|
+
style: G,
|
|
66
|
+
accessMode: ie,
|
|
67
|
+
displayStyle: I,
|
|
68
|
+
options: he,
|
|
69
|
+
value: _,
|
|
70
|
+
onChange: d,
|
|
71
|
+
placeholder: v,
|
|
72
|
+
multiple: c = !1,
|
|
73
|
+
searchable: g = !0,
|
|
74
|
+
clearable: p = !1,
|
|
75
|
+
emptyText: N,
|
|
76
|
+
maxHeight: l = 240,
|
|
77
|
+
optionsSource: $,
|
|
78
|
+
valueField: L,
|
|
79
|
+
labelField: M,
|
|
80
|
+
virtualScroll: w,
|
|
81
|
+
optionHeight: F = 36,
|
|
82
|
+
onSearch: T,
|
|
83
|
+
loading: y,
|
|
84
|
+
renderOption: K,
|
|
85
|
+
multipleAutosize: P = !1,
|
|
86
|
+
showKeyboardHints: Ne,
|
|
87
|
+
labelPlacement: $e,
|
|
88
|
+
errorPlacement: U,
|
|
89
|
+
labelWidth: J,
|
|
90
|
+
controlWidth: j,
|
|
91
|
+
displayMode: Ee
|
|
92
|
+
}, Y) => {
|
|
93
|
+
const ce = qe(ie, B), Ce = ce === "hidden";
|
|
94
|
+
(ce === "disabled" || ce === "readOnly") && (C = !0);
|
|
95
|
+
const { t: x } = He(), Le = We("input", I), Me = Be("input", I), S = Ge(B), pe = Ke({ enabled: Ee, disabled: C }), [b, D] = m(!1), [Q, V] = m(""), [R, z] = m(-1), [me, Se] = m(0), _e = ne(null), O = ne(null), [ve, De] = m(null);
|
|
96
|
+
de(() => {
|
|
97
|
+
!y && O.current && De(O.current.offsetWidth);
|
|
98
|
+
}, [y, _, I]);
|
|
99
|
+
const [q, Re] = m(null);
|
|
100
|
+
de(() => {
|
|
101
|
+
c && !P && O.current && q == null && Re(O.current.offsetWidth);
|
|
102
|
+
}, [c, P, q]);
|
|
103
|
+
const Ae = Pe(
|
|
104
|
+
$ ?? null,
|
|
105
|
+
L ?? $?.keyField ?? "id",
|
|
106
|
+
M ?? "name"
|
|
107
|
+
), E = $ ? Ae.options : (he ?? []).map(
|
|
108
|
+
(e) => typeof e == "string" ? { value: e, label: e } : e
|
|
109
|
+
), { popupRef: Ie, coords: H, ready: ge, themeClass: X, portalTarget: we } = tt(
|
|
110
|
+
b,
|
|
111
|
+
_e,
|
|
112
|
+
() => {
|
|
113
|
+
D(!1), V("");
|
|
114
|
+
}
|
|
115
|
+
), o = W(() => _ ? Array.isArray(_) ? _ : [_] : [], [_]), u = W(() => {
|
|
116
|
+
if (!Q && !T || T)
|
|
117
|
+
return E;
|
|
118
|
+
const e = Q.toLowerCase();
|
|
119
|
+
return E.filter(
|
|
120
|
+
(i) => i.label.toLowerCase().includes(e) || String(i.value).toLowerCase().includes(e)
|
|
121
|
+
);
|
|
122
|
+
}, [E, Q, T]), ye = W(() => {
|
|
123
|
+
const e = /* @__PURE__ */ new Map();
|
|
124
|
+
for (const i of u) {
|
|
125
|
+
const n = i.group || "";
|
|
126
|
+
e.has(n) || e.set(n, []), e.get(n).push(i);
|
|
127
|
+
}
|
|
128
|
+
return e;
|
|
129
|
+
}, [u]), Z = ae(
|
|
130
|
+
(e) => {
|
|
131
|
+
if (c) {
|
|
132
|
+
const i = o.includes(e) ? o.filter((n) => n !== e) : [...o, e];
|
|
133
|
+
d?.(i);
|
|
134
|
+
} else
|
|
135
|
+
d?.(e), D(!1), V("");
|
|
136
|
+
},
|
|
137
|
+
[c, o, d]
|
|
138
|
+
), Fe = ae(
|
|
139
|
+
(e) => {
|
|
140
|
+
if (e.key === "Escape") {
|
|
141
|
+
D(!1), V("");
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
145
|
+
if (!b) {
|
|
146
|
+
D(!0), e.preventDefault();
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
R >= 0 && u[R] && (Z(u[R].value), e.preventDefault());
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
e.key === "ArrowDown" && (e.preventDefault(), z((i) => Math.min(i + 1, u.length - 1))), e.key === "ArrowUp" && (e.preventDefault(), z((i) => Math.max(i - 1, 0)));
|
|
153
|
+
},
|
|
154
|
+
[b, R, u, Z]
|
|
155
|
+
), le = W(() => o.length === 0 ? null : c ? o.map((e) => E.find((i) => i.value === e)?.label || e).join(", ") : E.find((e) => e.value === o[0])?.label || o[0], [o, E, c]), Te = ae(
|
|
156
|
+
(e) => {
|
|
157
|
+
e.stopPropagation(), d?.(c ? [] : "");
|
|
158
|
+
},
|
|
159
|
+
[d, c]
|
|
160
|
+
), je = W(
|
|
161
|
+
() => [
|
|
162
|
+
{ key: "Enter", description: x("shortcuts.select", "Select") },
|
|
163
|
+
{ key: "Space", description: x("shortcuts.openDropdown", "Open dropdown") },
|
|
164
|
+
oe.moveUp,
|
|
165
|
+
oe.moveDown,
|
|
166
|
+
oe.cancel
|
|
167
|
+
],
|
|
168
|
+
[x]
|
|
169
|
+
);
|
|
170
|
+
return Ce ? null : /* @__PURE__ */ a(
|
|
171
|
+
"div",
|
|
172
|
+
{
|
|
173
|
+
className: `nice-field ${j == null ? "nice-field--select-auto" : ""} nice-field--${k} ${$e === "left" ? "nice-field--label-left" : ""} ${y ? "nice-field--loading" : ""} ${se || ""}`,
|
|
174
|
+
style: {
|
|
175
|
+
...G,
|
|
176
|
+
...J != null && {
|
|
177
|
+
"--nice-field-label-width": typeof J == "number" ? `${J}px` : J
|
|
178
|
+
},
|
|
179
|
+
...j != null && {
|
|
180
|
+
"--nice-field-control-width": typeof j == "number" ? `${j}px` : j
|
|
181
|
+
},
|
|
182
|
+
...y && ve != null && { "--nice-select-locked-width": `${ve}px` }
|
|
183
|
+
},
|
|
184
|
+
"aria-busy": y || void 0,
|
|
185
|
+
children: [
|
|
186
|
+
h && /* @__PURE__ */ a(
|
|
187
|
+
"label",
|
|
188
|
+
{
|
|
189
|
+
htmlFor: S,
|
|
190
|
+
className: `nice-field__label ${ue ? "nice-field__label--required" : ""}`,
|
|
191
|
+
children: [
|
|
192
|
+
h,
|
|
193
|
+
Ne && /* @__PURE__ */ t(Ue, { shortcuts: je, size: "sm" })
|
|
194
|
+
]
|
|
195
|
+
}
|
|
196
|
+
),
|
|
197
|
+
/* @__PURE__ */ a("div", { className: "nice-field__control", children: [
|
|
198
|
+
pe.isDisplay ? /* @__PURE__ */ t(
|
|
199
|
+
Je,
|
|
200
|
+
{
|
|
201
|
+
value: le,
|
|
202
|
+
placeholder: v || x("controls.select", "Select..."),
|
|
203
|
+
disabled: C,
|
|
204
|
+
onActivate: () => {
|
|
205
|
+
pe.enterEdit(), D(!0);
|
|
206
|
+
},
|
|
207
|
+
ariaLabel: h
|
|
208
|
+
}
|
|
209
|
+
) : /* @__PURE__ */ a("div", { className: "nice-select", ref: _e, children: [
|
|
210
|
+
/* @__PURE__ */ a(
|
|
211
|
+
"button",
|
|
212
|
+
{
|
|
213
|
+
ref: (e) => {
|
|
214
|
+
O.current = e, typeof Y == "function" ? Y(e) : Y && (Y.current = e);
|
|
215
|
+
},
|
|
216
|
+
type: "button",
|
|
217
|
+
id: S,
|
|
218
|
+
role: "combobox",
|
|
219
|
+
"aria-expanded": b,
|
|
220
|
+
"aria-haspopup": "listbox",
|
|
221
|
+
"aria-invalid": !!r,
|
|
222
|
+
className: `nice-select__trigger nice-select__trigger--${k} nice-select--ds-${Me} ${b ? "nice-select__trigger--open" : ""} ${r ? "nice-select__trigger--error" : ""} ${C ? "nice-select__trigger--disabled" : ""}`,
|
|
223
|
+
style: {
|
|
224
|
+
...Le,
|
|
225
|
+
...c && !P && q != null ? {
|
|
226
|
+
width: q,
|
|
227
|
+
maxWidth: q,
|
|
228
|
+
overflow: "hidden"
|
|
229
|
+
} : {}
|
|
230
|
+
},
|
|
231
|
+
disabled: C,
|
|
232
|
+
onClick: () => D(!b),
|
|
233
|
+
onKeyDown: Fe,
|
|
234
|
+
children: [
|
|
235
|
+
le ? /* @__PURE__ */ t(
|
|
236
|
+
"span",
|
|
237
|
+
{
|
|
238
|
+
style: c && !P ? {
|
|
239
|
+
flex: 1,
|
|
240
|
+
minWidth: 0,
|
|
241
|
+
overflow: "hidden",
|
|
242
|
+
textOverflow: "ellipsis",
|
|
243
|
+
whiteSpace: "nowrap"
|
|
244
|
+
} : void 0,
|
|
245
|
+
children: le
|
|
246
|
+
}
|
|
247
|
+
) : /* @__PURE__ */ t("span", { className: "nice-select__placeholder", children: v || x("controls.select", "Select...") }),
|
|
248
|
+
/* @__PURE__ */ a("span", { style: { display: "flex", alignItems: "center", gap: 4 }, children: [
|
|
249
|
+
p && o.length > 0 && /* @__PURE__ */ t(
|
|
250
|
+
"span",
|
|
251
|
+
{
|
|
252
|
+
className: "nice-input__clear",
|
|
253
|
+
onClick: Te,
|
|
254
|
+
role: "button",
|
|
255
|
+
"aria-label": x("controls.clear", "Clear"),
|
|
256
|
+
children: /* @__PURE__ */ t(be, { name: "close", size: 14 })
|
|
257
|
+
}
|
|
258
|
+
),
|
|
259
|
+
/* @__PURE__ */ t(
|
|
260
|
+
"span",
|
|
261
|
+
{
|
|
262
|
+
className: `nice-select__chevron ${b ? "nice-select__chevron--open" : ""}`,
|
|
263
|
+
children: /* @__PURE__ */ t(be, { name: "chevron-down", size: 16 })
|
|
264
|
+
}
|
|
265
|
+
)
|
|
266
|
+
] })
|
|
267
|
+
]
|
|
268
|
+
}
|
|
269
|
+
),
|
|
270
|
+
b && H && we && Ze(
|
|
271
|
+
/* @__PURE__ */ a(
|
|
272
|
+
"div",
|
|
273
|
+
{
|
|
274
|
+
ref: Ie,
|
|
275
|
+
className: `nice-select__dropdown${X ? ` ${X}` : ""}`,
|
|
276
|
+
"data-theme": X === "nice-dark" ? "dark" : X === "nice-light" ? "light" : void 0,
|
|
277
|
+
role: "listbox",
|
|
278
|
+
style: {
|
|
279
|
+
maxHeight: l,
|
|
280
|
+
position: "fixed",
|
|
281
|
+
left: H.left,
|
|
282
|
+
top: H.top,
|
|
283
|
+
width: H.width,
|
|
284
|
+
minWidth: H.width,
|
|
285
|
+
zIndex: 1e3,
|
|
286
|
+
// Hidden until measured so the estimate frame never paints above.
|
|
287
|
+
opacity: ge ? 1 : 0,
|
|
288
|
+
pointerEvents: ge ? void 0 : "none"
|
|
289
|
+
},
|
|
290
|
+
onScroll: w ? (e) => Se(e.currentTarget.scrollTop) : void 0,
|
|
291
|
+
children: [
|
|
292
|
+
(g || T) && /* @__PURE__ */ t("div", { className: "nice-select__search", children: /* @__PURE__ */ t(
|
|
293
|
+
"input",
|
|
294
|
+
{
|
|
295
|
+
type: "text",
|
|
296
|
+
value: Q,
|
|
297
|
+
onChange: (e) => {
|
|
298
|
+
V(e.target.value), z(0), T?.(e.target.value);
|
|
299
|
+
},
|
|
300
|
+
placeholder: x("controls.search", "Search..."),
|
|
301
|
+
autoFocus: !0
|
|
302
|
+
}
|
|
303
|
+
) }),
|
|
304
|
+
y && /* @__PURE__ */ t("div", { className: "nice-select__loading", children: /* @__PURE__ */ t(
|
|
305
|
+
"div",
|
|
306
|
+
{
|
|
307
|
+
className: "nice-spinner nice-spinner--sm",
|
|
308
|
+
style: { margin: "8px auto" }
|
|
309
|
+
}
|
|
310
|
+
) }),
|
|
311
|
+
!y && u.length === 0 ? /* @__PURE__ */ t("div", { className: "nice-select__empty", children: N || x("controls.noResults", "No results found") }) : w && !Array.from(ye.keys()).some((e) => e !== "") ? (() => {
|
|
312
|
+
const i = u.length * F, n = Math.max(
|
|
313
|
+
0,
|
|
314
|
+
Math.floor(me / F) - 3
|
|
315
|
+
), A = Math.min(
|
|
316
|
+
u.length,
|
|
317
|
+
Math.ceil((me + l) / F) + 3
|
|
318
|
+
), ee = u.slice(n, A);
|
|
319
|
+
return /* @__PURE__ */ t("div", { style: { height: i, position: "relative" }, children: ee.map((f, ze) => {
|
|
320
|
+
const re = n + ze, te = o.includes(f.value);
|
|
321
|
+
return /* @__PURE__ */ t(
|
|
322
|
+
"div",
|
|
323
|
+
{
|
|
324
|
+
role: "option",
|
|
325
|
+
"aria-selected": te,
|
|
326
|
+
className: `nice-select__option ${te ? "nice-select__option--selected" : ""} ${re === R ? "nice-select__option--highlighted" : ""} ${f.disabled ? "nice-select__option--disabled" : ""}`,
|
|
327
|
+
style: {
|
|
328
|
+
position: "absolute",
|
|
329
|
+
top: re * F,
|
|
330
|
+
left: 0,
|
|
331
|
+
right: 0,
|
|
332
|
+
height: F,
|
|
333
|
+
display: "flex",
|
|
334
|
+
alignItems: "center",
|
|
335
|
+
padding: "0 12px"
|
|
336
|
+
},
|
|
337
|
+
onClick: () => !f.disabled && Z(String(f.value)),
|
|
338
|
+
onMouseEnter: () => z(re),
|
|
339
|
+
children: K ? K(f, te) : /* @__PURE__ */ a(xe, { children: [
|
|
340
|
+
f.icon && /* @__PURE__ */ t("span", { children: f.icon }),
|
|
341
|
+
/* @__PURE__ */ a("div", { style: { flex: 1 }, children: [
|
|
342
|
+
/* @__PURE__ */ t("div", { children: f.label }),
|
|
343
|
+
f.description && /* @__PURE__ */ t("div", { className: "nice-select__option-desc", children: f.description })
|
|
344
|
+
] }),
|
|
345
|
+
te && /* @__PURE__ */ t(
|
|
346
|
+
"svg",
|
|
347
|
+
{
|
|
348
|
+
className: "nice-select__option-check",
|
|
349
|
+
viewBox: "0 0 20 20",
|
|
350
|
+
fill: "currentColor",
|
|
351
|
+
children: /* @__PURE__ */ t(
|
|
352
|
+
"path",
|
|
353
|
+
{
|
|
354
|
+
fillRule: "evenodd",
|
|
355
|
+
d: "M16.704 4.153a.75.75 0 01.143 1.052l-8 10.5a.75.75 0 01-1.127.075l-4.5-4.5a.75.75 0 011.06-1.06l3.894 3.893 7.48-9.817a.75.75 0 011.05-.143z",
|
|
356
|
+
clipRule: "evenodd"
|
|
357
|
+
}
|
|
358
|
+
)
|
|
359
|
+
}
|
|
360
|
+
)
|
|
361
|
+
] })
|
|
362
|
+
},
|
|
363
|
+
f.value
|
|
364
|
+
);
|
|
365
|
+
}) });
|
|
366
|
+
})() : Array.from(ye.entries()).map(([e, i]) => /* @__PURE__ */ a(Ye.Fragment, { children: [
|
|
367
|
+
e && /* @__PURE__ */ t("div", { className: "nice-select__group-label", children: e }),
|
|
368
|
+
i.map((n) => {
|
|
369
|
+
const A = o.includes(n.value), ee = u.indexOf(n);
|
|
370
|
+
return /* @__PURE__ */ t(
|
|
371
|
+
"div",
|
|
372
|
+
{
|
|
373
|
+
role: "option",
|
|
374
|
+
"aria-selected": A,
|
|
375
|
+
className: `nice-select__option ${A ? "nice-select__option--selected" : ""} ${ee === R ? "nice-select__option--highlighted" : ""} ${n.disabled ? "nice-select__option--disabled" : ""}`,
|
|
376
|
+
onClick: () => !n.disabled && Z(String(n.value)),
|
|
377
|
+
onMouseEnter: () => z(ee),
|
|
378
|
+
children: K ? K(n, A) : /* @__PURE__ */ a(xe, { children: [
|
|
379
|
+
n.icon && /* @__PURE__ */ t("span", { children: n.icon }),
|
|
380
|
+
/* @__PURE__ */ a("div", { style: { flex: 1 }, children: [
|
|
381
|
+
/* @__PURE__ */ t("div", { children: n.label }),
|
|
382
|
+
n.description && /* @__PURE__ */ t("div", { className: "nice-select__option-desc", children: n.description })
|
|
383
|
+
] }),
|
|
384
|
+
A && /* @__PURE__ */ t(
|
|
385
|
+
"svg",
|
|
386
|
+
{
|
|
387
|
+
className: "nice-select__option-check",
|
|
388
|
+
viewBox: "0 0 20 20",
|
|
389
|
+
fill: "currentColor",
|
|
390
|
+
children: /* @__PURE__ */ t(
|
|
391
|
+
"path",
|
|
392
|
+
{
|
|
393
|
+
fillRule: "evenodd",
|
|
394
|
+
d: "M16.704 4.153a.75.75 0 01.143 1.052l-8 10.5a.75.75 0 01-1.127.075l-4.5-4.5a.75.75 0 011.06-1.06l3.894 3.893 7.48-9.817a.75.75 0 011.05-.143z",
|
|
395
|
+
clipRule: "evenodd"
|
|
396
|
+
}
|
|
397
|
+
)
|
|
398
|
+
}
|
|
399
|
+
)
|
|
400
|
+
] })
|
|
401
|
+
},
|
|
402
|
+
n.value
|
|
403
|
+
);
|
|
404
|
+
})
|
|
405
|
+
] }, e))
|
|
406
|
+
]
|
|
407
|
+
}
|
|
408
|
+
),
|
|
409
|
+
we
|
|
410
|
+
)
|
|
411
|
+
] }),
|
|
412
|
+
y && /* @__PURE__ */ t("span", { className: "nice-field__spinner", children: /* @__PURE__ */ t("span", { className: "nice-spinner nice-spinner--sm" }) }),
|
|
413
|
+
U === "right" && r && /* @__PURE__ */ t("div", { id: `${S}-error`, className: "nice-field__error", role: "alert", children: r }),
|
|
414
|
+
U === "right" && !r && s && /* @__PURE__ */ t("div", { id: `${S}-helper`, className: "nice-field__helper", children: s })
|
|
415
|
+
] }),
|
|
416
|
+
U !== "right" && r && /* @__PURE__ */ t("div", { id: `${S}-error`, className: "nice-field__error", role: "alert", children: r }),
|
|
417
|
+
U !== "right" && !r && s && /* @__PURE__ */ t("div", { id: `${S}-helper`, className: "nice-field__helper", children: s })
|
|
418
|
+
]
|
|
419
|
+
}
|
|
420
|
+
);
|
|
421
|
+
}
|
|
422
|
+
);
|
|
423
|
+
ke.displayName = "NiceSelect";
|
|
424
|
+
const lt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
425
|
+
__proto__: null,
|
|
426
|
+
NiceSelect: ke
|
|
427
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
428
|
+
export {
|
|
429
|
+
ke as N,
|
|
430
|
+
lt as a,
|
|
431
|
+
et as s,
|
|
432
|
+
tt as u
|
|
433
|
+
};
|