@nice2dev/ui 1.4.13 → 1.4.15
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 +108 -0
- package/dist/{NiceColorPicker-BLwYNSXJ.cjs → NiceColorPicker-79rkvaSk.cjs} +1 -1
- package/dist/NiceDataGrid-B1AOjgjm.cjs +10 -0
- package/dist/NiceForm-fmePSeA9.cjs +1 -0
- package/dist/{NiceHtmlEditor-BzECmDO3.cjs → NiceHtmlEditor-By7R1wRo.cjs} +1 -1
- package/dist/{NiceMention-CYRqPKGU.cjs → NiceMention-i7n2BoMw.cjs} +1 -1
- package/dist/{NiceModuleLifecyclePanel-CiYbPcHV.cjs → NiceModuleLifecyclePanel-DVHQuhc-.cjs} +1 -1
- package/dist/{NicePagination-BAxwqeEd.cjs → NicePagination-D9JguOl0.cjs} +1 -1
- package/dist/NicePivotGrid-B_7iQJys.cjs +2 -0
- package/dist/NiceSavedQueryPanel-ChY4HwpM.cjs +587 -0
- package/dist/{NiceScheduler-BqYiHPvz.cjs → NiceScheduler-B2DamQ_L.cjs} +1 -1
- package/dist/backup/NiceBackupScheduler.mjs +171 -119
- package/dist/charts/NiceOrganizationChart.mjs +159 -59
- package/dist/charts/orgChartExport.mjs +71 -0
- package/dist/charts/tidyTree.mjs +43 -0
- package/dist/charts-C3Q3r8Yz.cjs +918 -0
- package/dist/charts.cjs +1 -1
- package/dist/charts.d.ts +9 -0
- package/dist/{core-lazy-BQexApr7.cjs → core-lazy-ChKRuEPb.cjs} +1 -1
- package/dist/data/NiceDataGrid.mjs +301 -320
- package/dist/data/NiceRowEditDialog.mjs +57 -0
- package/dist/data/NiceTreeGrid.mjs +670 -551
- package/dist/data/NiceTreeView.mjs +222 -180
- package/dist/data/treeRowDrop.mjs +130 -0
- package/dist/data.cjs +1 -1
- package/dist/data.d.ts +68 -5
- package/dist/{devops-cgRBnZVX.cjs → devops-o6Zm0VKB.cjs} +3 -3
- package/dist/devops.cjs +1 -1
- package/dist/editors/forms/NiceForm.mjs +216 -167
- package/dist/editors/inputs/NiceUpload.mjs +238 -238
- package/dist/editors.cjs +1 -1
- package/dist/editors.d.ts +13 -1
- package/dist/feedback.cjs +1 -1
- package/dist/index.cjs +254 -254
- package/dist/index.d.ts +293 -8
- package/dist/index.mjs +980 -966
- package/dist/lazy.cjs +1 -1
- package/dist/lazy.d.ts +11 -1
- package/dist/navigation.cjs +1 -1
- package/dist/no-code/NiceDataMapper.mjs +398 -361
- package/dist/no-code-CN_q6TcB.cjs +331 -0
- package/dist/no-code.cjs +1 -1
- package/dist/no-code.d.ts +11 -1
- package/dist/style.css +1 -1
- package/dist/tools/NicePermissionMatrix.mjs +171 -138
- package/dist/tools/NiceRoleEditor.mjs +334 -297
- package/package.json +4 -4
- package/dist/NiceDataGrid-D3qRQSjy.cjs +0 -10
- package/dist/NiceForm-BWb4LTQJ.cjs +0 -1
- package/dist/NicePivotGrid-Cxu5PECg.cjs +0 -152
- package/dist/NiceSavedQueryPanel-BSZhE-_l.cjs +0 -587
- package/dist/charts-BzlvCCg9.cjs +0 -768
- package/dist/no-code-B1jzfUF5.cjs +0 -331
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";const t=require("react/jsx-runtime"),H=require("@nice2dev/ui-core"),D=require("react"),re=require("./NiceButton-DzCqkG5a.cjs"),Q=require("./NiceForm-BWb4LTQJ.cjs"),Te=require("./devops-cgRBnZVX.cjs"),_t=require("./NiceColorPicker-BLwYNSXJ.cjs"),xt=require("./NiceModal-BRVzjuUN.cjs"),$e=({children:e,className:n,style:c,"data-testid":d,direction:a="horizontal",size:o,disabled:x,readOnly:_,loading:b,error:E,errorPlacement:w="bottom"})=>{const f=t.jsxs("div",{className:`nice-btn-group ${a==="vertical"?"nice-btn-group--vertical":""} ${b?"nice-btn-group--loading":""} ${_?"nice-btn-group--readonly":""} ${n||""}`,style:c,role:"group","data-testid":d,"aria-busy":b||void 0,children:[D.Children.map(e,s=>{if(!D.isValidElement(s))return s;const N={};return x&&(N.disabled=!0),_&&(N.disabled=!0),b&&(N.disabled=!0),o&&(N.size=o),D.cloneElement(s,N)}),b&&t.jsx("span",{className:"nice-btn-group__spinner",children:t.jsx("span",{className:"nice-spinner nice-spinner--sm"})})]});if(!E)return f;const C=t.jsx("div",{className:"nice-field__error",role:"alert",children:E});return w==="right"?t.jsxs("span",{className:`nice-btn-field nice-btn-field--right ${o?`nice-field--${o}`:""}`,children:[f,C]}):t.jsxs("span",{className:`nice-btn-field nice-btn-field--bottom ${o?`nice-field--${o}`:""}`,children:[f,C]})},Ke=new Map;function Qe(e){if(!e)return"en";try{return Intl.DateTimeFormat.supportedLocalesOf(e).length>0?e:"en"}catch{return"en"}}function we(e,n){const c=Qe(e),d=`${c}|${JSON.stringify(n)}`;let a=Ke.get(d);return a||(a=new Intl.DateTimeFormat(c,n),Ke.set(d,a)),a}const Ze=(e,n)=>e.charAt(0).toLocaleUpperCase(Qe(n))+e.slice(1);function Z(e,n="short"){const c=we(e,{weekday:n});return Array.from({length:7},(d,a)=>Ze(c.format(new Date(2023,0,1+a)),e))}function Ee(e,n="long"){const c=we(e,{month:n});return Array.from({length:12},(d,a)=>Ze(c.format(new Date(2023,a,1)),e))}function se(e,n){return we(e,{year:"numeric",month:"2-digit",day:"2-digit"}).format(n)}function De(e,n){return we(e,{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}).format(n)}const L=(e,n)=>{const c=new Date(e);return c.setDate(c.getDate()+n),c},B=(e,n)=>e.getFullYear()===n.getFullYear()&&e.getMonth()===n.getMonth()&&e.getDate()===n.getDate();function Oe(e,n,c,d=1/0){const a=[],o=Math.max(1,Math.floor(e.interval??1)),x=e.until?new Date(e.until):void 0,_=x&&x<c?x:c,b=Math.min(e.count&&e.count>0?e.count:1/0,d),E=e.freq==="weekly"&&e.byDay?.length?[...new Set(e.byDay.filter(f=>Number.isInteger(f)&&f>=0&&f<=6))].sort((f,C)=>f-C):[];if(E.length>0){const f=new Date(n);f.setDate(n.getDate()-n.getDay());for(let C=0;a.length<b;C+=o){const s=new Date(f);if(s.setDate(f.getDate()+C*7),s>_)break;for(const N of E){const j=new Date(s);if(j.setDate(s.getDate()+N),!(j<n)){if(j>_||a.length>=b)break;a.push(j)}}}return a}let w=new Date(n);for(;w<=_&&a.length<b;){a.push(new Date(w));const f=new Date(w);e.freq==="daily"?f.setDate(f.getDate()+o):e.freq==="weekly"?f.setDate(f.getDate()+7*o):e.freq==="monthly"?f.setMonth(f.getMonth()+o):f.setFullYear(f.getFullYear()+o),w=f}return a}function Nt(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();Oe(a.recurrence,new Date(a.start),c).forEach((x,_)=>{const b=new Date(x.getTime()+o);b>=n&&d.push({...a,id:`${a.id}_${_}`,start:x,end:b})})}return d}function et(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 tt(e="r"){return`${e}_${Math.random().toString(36).slice(2,9)}`}function nt(e={}){return{id:e.id??tt(),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 st(e){const n=(e.prepMinutes??0)+(e.cookMinutes??0);return n>0?n:void 0}const pe=({ev:e,renderEvent:n,onClick:c,draggable:d,dragRef:a,onHover:o,categoryColor:x})=>{const _=x||e.color||"var(--nice-color-primary, #3b82f6)",E={solid:{backgroundColor:_,color:"var(--nice-color-white, #fff)"},striped:{background:`repeating-linear-gradient(45deg, ${_}, ${_} 4px, transparent 4px, transparent 8px)`,border:`1px solid ${_}`,color:"var(--nice-text-primary, #333)"},outlined:{backgroundColor:"transparent",border:`2px solid ${_}`,color:_},dashed:{backgroundColor:"transparent",border:`2px dashed ${_}`,color:_}}[e.eventStyle||"solid"];return t.jsx("div",{className:`nice-scheduler__event nice-scheduler__event--${e.eventStyle||"solid"}`,style:E,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 ie(e,n){if(!(!e.category||!n))return n.find(c=>c.key===e.category)?.color}const Dt=({events:e,curDate:n,firstDayOfWeek:c,onSlotClick:d,onEventClick:a,draggable:o,dragRef:x,categories:_,renderEvent:b,onHoverEvent:E,readOnly:w})=>{const{lang:f}=H.useNiceTranslation(),C=Z(f,"short"),s=n.getFullYear(),N=n.getMonth(),j=new Date(s,N,1),l=new Date(s,N+1,0),k=(j.getDay()-c+7)%7,h=l.getDate(),m=[];for(let u=k-1;u>=0;u--)m.push({date:L(j,-u-1),isCurrentMonth:!1});for(let u=0;u<h;u++)m.push({date:new Date(s,N,u+1),isCurrentMonth:!0});let P=1;for(;m.length<42;)m.push({date:new Date(s,N+1,P++),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,g)=>t.jsx("div",{className:"nice-scheduler__month-dayname",children:C[(c+g)%7]},g))}),t.jsx("div",{className:"nice-scheduler__month-grid",children:m.map((u,g)=>{const R=et(e,u.date),p=B(u.date,new Date),S=u.date.getDay(),F=S===0||S===6;return t.jsxs("div",{className:`nice-scheduler__month-cell ${u.isCurrentMonth?"":"nice-scheduler__month-cell--other"} ${p?"nice-scheduler__month-cell--today":""} ${F?"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()}),R.slice(0,3).map(q=>t.jsx(pe,{ev:q,renderEvent:b,onClick:a,draggable:o&&!w,dragRef:x,onHover:E,categoryColor:ie(q,_)},q.id)),R.length>3&&t.jsxs("div",{className:"nice-scheduler__month-more",children:["+",R.length-3]})]},g)})})]})},wt=({events:e,days:n,startHour:c,endHour:d,draggable:a,dragRef:o,onEventClick:x,onSlotClick:_,onEventDrop:b,categories:E,workHours:w,showCurrentTime:f,renderEvent:C,onHoverEvent:s,readOnly:N})=>{const{lang:j}=H.useNiceTranslation(),l=[];for(let p=c;p<d;p++)l.push(p);Z(j,"short");const k=Z(j,"long"),h=D.useRef(null),m=new Date,P=m.getHours()*60+m.getMinutes(),u=(d-c)*60,g=(P-c*60)/u*100,R=f&&P>=c*60&&P<d*60;return D.useEffect(()=>{const p=h.current;if(!p)return;const S=new Date,F=e.filter($=>n.some(Y=>B(Y,new Date($.start)))),q=F.filter($=>B(new Date($.start),S));let W;q.length>0?W=Math.min(...q.map($=>new Date($.start).getHours())):F.length>0?W=Math.min(...F.map($=>new Date($.start).getHours())):W=8,W=Math.max(c,Math.min(W,d-1));const i=W-c,y=p.children[i];if(y){const $=p.closest(".nice-scheduler__content")??p.closest(".nice-scheduler__timegrid");$&&($.scrollTop=y.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((p,S)=>{const F=p.getDay()===0||p.getDay()===6;return t.jsxs("div",{className:`nice-scheduler__timegrid-day-header ${B(p,m)?"nice-scheduler__timegrid-day-header--today":""} ${F?"nice-scheduler__timegrid-day-header--weekend":""}`,children:[t.jsx("div",{className:"nice-scheduler__timegrid-day-name",children:k[p.getDay()]}),t.jsx("div",{className:"nice-scheduler__timegrid-day-num",children:p.getDate()})]},S)})]}),t.jsxs("div",{className:"nice-scheduler__timegrid-body",ref:h,style:{position:"relative"},children:[l.map(p=>{const S=w?p>=w[0]&&p<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:`${p.toString().padStart(2,"0")}:00`}),n.map((F,q)=>{const W=e.filter(i=>{const y=new Date(i.start);return B(y,F)&&y.getHours()===p});return t.jsx("div",{className:"nice-scheduler__timegrid-cell",onDragOver:a&&!N?i=>i.preventDefault():void 0,onDrop:a&&!N?()=>{if(!o.current||!b)return;const i=o.current.event,y=new Date(i.end).getTime()-new Date(i.start).getTime(),$=new Date(F);$.setHours(p,0,0,0);const Y=new Date($.getTime()+y);b(i,$,Y),o.current=null}:void 0,onClick:()=>!N&&(()=>{const i=new Date(F);i.setHours(p);const y=new Date(i);y.setHours(p+1),_?.(i,y)})(),children:W.map(i=>t.jsx(pe,{ev:i,renderEvent:C,onClick:x,draggable:a&&!N,dragRef:o,onHover:s,categoryColor:ie(i,E)},i.id))},q)})]},p)}),R&&n.some(p=>B(p,m))&&t.jsx("div",{className:"nice-scheduler__now-line",style:{top:`${g}%`},children:t.jsx("div",{className:"nice-scheduler__now-dot"})})]})]})},bt=({events:e,curDate:n,onEventClick:c,categories:d,t:a})=>{const o=[...e].filter(x=>new Date(x.start)>=new Date(n.getFullYear(),n.getMonth(),n.getDate())).sort((x,_)=>new Date(x.start).getTime()-new Date(_.start).getTime()).slice(0,50);return t.jsxs("div",{className:"nice-scheduler__agenda",children:[o.map(x=>t.jsx(jt,{ev:x,categories:d,onEventClick:c},x.id)),o.length===0&&t.jsx("div",{className:"nice-scheduler__agenda-empty",children:a("noEvents","No upcoming events")})]})},Je=({parts:e})=>t.jsx("div",{className:"nice-scheduler__agenda-meta",children:e.map(([n,c],d)=>t.jsxs(D.Fragment,{children:[d>0&&" · ",t.jsx(H.NiceIcon,{name:n,size:12,style:{verticalAlign:"-2px"}})," ",c]},n))}),rt=({ev:e})=>{if(e.eventType==="recipe"&&e.recipe){const n=st(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(Je,{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(Je,{parts:c})}return null},jt=({ev:e,categories:n,onEventClick:c})=>{const{t:d}=H.useNiceTranslation(),a=H.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:ie(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:[De(Q.getDefaultLocale(),new Date(e.start))," –"," ",De(Q.getDefaultLocale(),new Date(e.end))]}),e.description&&t.jsx("div",{className:"nice-scheduler__agenda-desc",children:e.description}),t.jsx(rt,{ev:e})]}),e.category&&n&&t.jsx("span",{className:"nice-scheduler__agenda-badge",style:{backgroundColor:ie(e,n)||e.color},children:n.find(o=>o.key===e.category)?.label})]})},kt=({events:e,curDate:n,timelineDays:c,resources:d,draggable:a,dragRef:o,onEventClick:x,onSlotClick:_,onEventDrop:b,categories:E,renderEvent:w,onHoverEvent:f,readOnly:C})=>{const{lang:s}=H.useNiceTranslation(),N=Array.from({length:c},(k,h)=>L(n,h)),j=d??[{id:"__default",name:""}],l=Z(s,"short");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"}),N.map((k,h)=>t.jsxs("div",{className:`nice-scheduler__timeline-day ${B(k,new Date)?"nice-scheduler__timeline-day--today":""}`,children:[l[k.getDay()]," ",k.getDate()]},h))]}),t.jsx("div",{className:"nice-scheduler__timeline-body",children:j.map(k=>{const h=e.filter(m=>!d||m.resourceId===k.id);return t.jsxs("div",{className:"nice-scheduler__timeline-row",children:[t.jsx("div",{className:"nice-scheduler__timeline-res-label",children:k.name}),N.map((m,P)=>{const u=h.filter(g=>B(new Date(g.start),m));return t.jsx("div",{className:"nice-scheduler__timeline-cell",onDragOver:a&&!C?g=>g.preventDefault():void 0,onDrop:a&&!C?()=>{if(!o.current||!b)return;const g=o.current.event,R=new Date(g.end).getTime()-new Date(g.start).getTime(),p=new Date(m);p.setHours(new Date(g.start).getHours(),new Date(g.start).getMinutes()),b(g,p,new Date(p.getTime()+R),k.id),o.current=null}:void 0,onClick:()=>!C&&_?.(m,L(m,1),k.id),children:u.map(g=>t.jsx(pe,{ev:g,renderEvent:w,onClick:x,draggable:a&&!C,dragRef:o,onHover:f,categoryColor:ie(g,E)},g.id))},P)})]},k.id)})})]})},Xe=({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 x=n.filter(b=>b.category===o.key).length,_=!c.has(o.key);return t.jsxs("button",{className:`nice-scheduler__legend-item ${_?"":"nice-scheduler__legend-item--hidden"}`,onClick:()=>d(o.key),children:[t.jsx("span",{className:"nice-scheduler__legend-dot",style:{backgroundColor:_?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:x})]},o.key)})]}),Ct=({curDate:e,onDateSelect:n,firstDayOfWeek:c,t:d})=>{const{lang:a}=H.useNiceTranslation(),[o,x]=D.useState(e.getMonth()),[_,b]=D.useState(e.getFullYear()),E=new Date(_,o,1),w=new Date(_,o+1,0),f=(E.getDay()-c+7)%7,C=[];for(let h=f-1;h>=0;h--)C.push(L(E,-h-1));for(let h=0;h<w.getDate();h++)C.push(new Date(_,o,h+1));const s=7-C.length%7;if(s<7)for(let h=1;h<=s;h++)C.push(new Date(_,o+1,h));const N=()=>{o===0?(x(11),b(h=>h-1)):x(h=>h-1)},j=()=>{o===11?(x(0),b(h=>h+1)):x(h=>h+1)},l=Ee(a,"short"),k=Z(a,"short");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:N,"aria-label":d("scheduler.prevMonth","Previous month"),children:t.jsx(H.NiceIcon,{name:"chevron-left",size:"sm"})}),t.jsxs("span",{children:[l[o]," ",_]}),t.jsx("button",{type:"button",className:"nice-btn nice-btn--xs",onClick:j,"aria-label":d("scheduler.nextMonth","Next month"),children:t.jsx(H.NiceIcon,{name:"chevron-right",size:"sm"})})]}),t.jsxs("div",{className:"nice-scheduler__mini-cal-grid",children:[k.map((h,m)=>t.jsx("div",{className:"nice-scheduler__mini-cal-dayname",children:k[(c+m)%7].charAt(0)},m)),C.map((h,m)=>{const P=B(h,new Date),u=B(h,e),g=h.getMonth()!==o;return t.jsx("button",{className:`nice-scheduler__mini-cal-day ${P?"nice-scheduler__mini-cal-day--today":""} ${u?"nice-scheduler__mini-cal-day--selected":""} ${g?"nice-scheduler__mini-cal-day--other":""}`,onClick:()=>n(h),children:h.getDate()},m)})]})]})},St=({events:e,rangeStart:n,rangeEnd:c,startHour:d,endHour:a,draggable:o,dragRef:x,onEventClick:_,onSlotClick:b,onEventDrop:E,categories:w,workHours:f,showCurrentTime:C,renderEvent:s,onHoverEvent:N,readOnly:j})=>{const{lang:l}=H.useNiceTranslation(),k=[];let h=new Date(n);for(;h<=c;)k.push(new Date(h)),h=L(h,1);const m=[];for(let y=d;y<a;y++)m.push(y);const P=Z(l,"long"),u=D.useRef(null),g=D.useRef(null),R=D.useRef(null),p=new Date,S=p.getHours()*60+p.getMinutes(),F=(a-d)*60,q=(S-d*60)/F*100,W=C&&S>=d*60&&S<a*60;D.useEffect(()=>{const y=u.current;if(!y)return;const $=new Date,Y=e.filter(I=>k.some(M=>B(M,$)&&B(new Date(I.start),$)));let V=Y.length>0?Math.min(...Y.map(I=>new Date(I.start).getHours())):$.getHours();V=Math.max(d,Math.min(V,a-1));const K=y.children[V-d];if(K){const I=R.current??y.closest(".nice-scheduler__content")??y.closest(".nice-scheduler__timegrid");I&&(I.scrollTop=K.offsetTop-4)}},[]);const i=y=>{g.current&&(g.current.scrollLeft=y.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:g,"aria-hidden":"true",children:t.jsxs("div",{className:"nice-scheduler__timegrid-header",children:[t.jsx("div",{className:"nice-scheduler__time-gutter"}),k.map((y,$)=>{const Y=y.getDay()===0||y.getDay()===6;return t.jsxs("div",{className:`nice-scheduler__timegrid-day-header ${B(y,p)?"nice-scheduler__timegrid-day-header--today":""} ${Y?"nice-scheduler__timegrid-day-header--weekend":""}`,children:[t.jsx("div",{className:"nice-scheduler__timegrid-day-name",children:P[y.getDay()]}),t.jsx("div",{className:"nice-scheduler__timegrid-day-num",children:y.getDate()})]},$)})]})}),t.jsx("div",{className:"nice-scheduler__timegrid-body-scroll",ref:R,onScroll:i,children:t.jsxs("div",{className:"nice-scheduler__timegrid-body",ref:u,style:{position:"relative"},children:[m.map(y=>{const $=f?y>=f[0]&&y<f[1]:!1;return t.jsxs("div",{className:`nice-scheduler__timegrid-row ${$?"nice-scheduler__timegrid-row--work":""}`,children:[t.jsx("div",{className:"nice-scheduler__time-gutter",children:`${y.toString().padStart(2,"0")}:00`}),k.map((Y,V)=>{const K=e.filter(I=>{const M=new Date(I.start);return B(M,Y)&&M.getHours()===y});return t.jsx("div",{className:"nice-scheduler__timegrid-cell",onDragOver:o&&!j?I=>I.preventDefault():void 0,onDrop:o&&!j?()=>{if(!x.current||!E)return;const I=x.current.event,M=new Date(I.end).getTime()-new Date(I.start).getTime(),O=new Date(Y);O.setHours(y,0,0,0),E(I,O,new Date(O.getTime()+M)),x.current=null}:void 0,onClick:()=>!j&&(()=>{const I=new Date(Y);I.setHours(y);const M=new Date(I);M.setHours(y+1),b?.(I,M)})(),children:K.map(I=>t.jsx(pe,{ev:I,renderEvent:s,onClick:_,draggable:o&&!j,dragRef:x,onHover:N,categoryColor:ie(I,w)},I.id))},V)})]},y)}),W&&k.some(y=>B(y,p))&&t.jsx("div",{className:"nice-scheduler__now-line",style:{top:`${q}%`},children:t.jsx("div",{className:"nice-scheduler__now-dot"})})]})})]})},Mt=({events:e,rangeStart:n,rangeEnd:c,firstDayOfWeek:d,onSlotClick:a,onEventClick:o,draggable:x,dragRef:_,categories:b,renderEvent:E,onHoverEvent:w,readOnly:f})=>{const{lang:C}=H.useNiceTranslation(),s=Z(C,"short");Z(C,"long");const N=[];let j=new Date(n);for(;j<=c;)N.push(new Date(j)),j=L(j,1);const l=(N[0].getDay()-d+7)%7,k=[];for(let m=l-1;m>=0;m--)k.push({date:L(N[0],-m-1),inRange:!1});N.forEach(m=>k.push({date:m,inRange:!0}));const h=7-k.length%7;if(h<7){const m=N[N.length-1];for(let P=1;P<=h;P++)k.push({date:L(m,P),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},(m,P)=>t.jsx("div",{className:"nice-scheduler__month-dayname",children:s[(d+P)%7]},P))}),t.jsx("div",{className:"nice-scheduler__month-grid",children:k.map((m,P)=>{const u=et(e,m.date),g=B(m.date,new Date),R=m.date.getDay()===0||m.date.getDay()===6;return t.jsxs("div",{className:`nice-scheduler__month-cell ${m.inRange?"":"nice-scheduler__month-cell--other"} ${g?"nice-scheduler__month-cell--today":""} ${R?"nice-scheduler__month-cell--weekend":""}`,onClick:()=>!f&&a?.(m.date,L(m.date,1)),children:[t.jsx("div",{className:"nice-scheduler__month-date",children:m.date.getDate()===1||P===0?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"nice-scheduler__month-monthname",children:Ee(C,"short")[m.date.getMonth()]})," ",m.date.getDate()]}):m.date.getDate()}),u.slice(0,3).map(p=>t.jsx(pe,{ev:p,renderEvent:E,onClick:o,draggable:x&&!f,dragRef:_,onHover:w,categoryColor:ie(p,b)},p.id)),u.length>3&&t.jsxs("div",{className:"nice-scheduler__month-more",children:["+",u.length-3]})]},P)})})]})},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:[De(Q.getDefaultLocale(),new Date(e.start))," –"," ",De(Q.getDefaultLocale(),new Date(e.end))]}),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(rt,{ev:e})]})},$t=({event:e,slotStart:n,slotEnd:c,categories:d,resources:a,formFields:o,formFieldsByType:x,eventTypes:_,renderEditor:b,saving:E,onSave:w,onDelete:f,onClose:C,t:s})=>{const N=!!e,j=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??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(u=>[u.quantity,u.unit,u.name].filter(g=>g!==void 0&&g!=="").join(" ")).join(`
|
|
1
|
+
"use strict";const t=require("react/jsx-runtime"),H=require("@nice2dev/ui-core"),D=require("react"),re=require("./NiceButton-DzCqkG5a.cjs"),Q=require("./NiceForm-fmePSeA9.cjs"),Te=require("./devops-o6Zm0VKB.cjs"),_t=require("./NiceColorPicker-79rkvaSk.cjs"),xt=require("./NiceModal-BRVzjuUN.cjs"),$e=({children:e,className:n,style:c,"data-testid":d,direction:a="horizontal",size:o,disabled:x,readOnly:_,loading:b,error:E,errorPlacement:w="bottom"})=>{const f=t.jsxs("div",{className:`nice-btn-group ${a==="vertical"?"nice-btn-group--vertical":""} ${b?"nice-btn-group--loading":""} ${_?"nice-btn-group--readonly":""} ${n||""}`,style:c,role:"group","data-testid":d,"aria-busy":b||void 0,children:[D.Children.map(e,s=>{if(!D.isValidElement(s))return s;const N={};return x&&(N.disabled=!0),_&&(N.disabled=!0),b&&(N.disabled=!0),o&&(N.size=o),D.cloneElement(s,N)}),b&&t.jsx("span",{className:"nice-btn-group__spinner",children:t.jsx("span",{className:"nice-spinner nice-spinner--sm"})})]});if(!E)return f;const C=t.jsx("div",{className:"nice-field__error",role:"alert",children:E});return w==="right"?t.jsxs("span",{className:`nice-btn-field nice-btn-field--right ${o?`nice-field--${o}`:""}`,children:[f,C]}):t.jsxs("span",{className:`nice-btn-field nice-btn-field--bottom ${o?`nice-field--${o}`:""}`,children:[f,C]})},Ke=new Map;function Qe(e){if(!e)return"en";try{return Intl.DateTimeFormat.supportedLocalesOf(e).length>0?e:"en"}catch{return"en"}}function we(e,n){const c=Qe(e),d=`${c}|${JSON.stringify(n)}`;let a=Ke.get(d);return a||(a=new Intl.DateTimeFormat(c,n),Ke.set(d,a)),a}const Ze=(e,n)=>e.charAt(0).toLocaleUpperCase(Qe(n))+e.slice(1);function Z(e,n="short"){const c=we(e,{weekday:n});return Array.from({length:7},(d,a)=>Ze(c.format(new Date(2023,0,1+a)),e))}function Ee(e,n="long"){const c=we(e,{month:n});return Array.from({length:12},(d,a)=>Ze(c.format(new Date(2023,a,1)),e))}function se(e,n){return we(e,{year:"numeric",month:"2-digit",day:"2-digit"}).format(n)}function De(e,n){return we(e,{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}).format(n)}const L=(e,n)=>{const c=new Date(e);return c.setDate(c.getDate()+n),c},B=(e,n)=>e.getFullYear()===n.getFullYear()&&e.getMonth()===n.getMonth()&&e.getDate()===n.getDate();function Oe(e,n,c,d=1/0){const a=[],o=Math.max(1,Math.floor(e.interval??1)),x=e.until?new Date(e.until):void 0,_=x&&x<c?x:c,b=Math.min(e.count&&e.count>0?e.count:1/0,d),E=e.freq==="weekly"&&e.byDay?.length?[...new Set(e.byDay.filter(f=>Number.isInteger(f)&&f>=0&&f<=6))].sort((f,C)=>f-C):[];if(E.length>0){const f=new Date(n);f.setDate(n.getDate()-n.getDay());for(let C=0;a.length<b;C+=o){const s=new Date(f);if(s.setDate(f.getDate()+C*7),s>_)break;for(const N of E){const j=new Date(s);if(j.setDate(s.getDate()+N),!(j<n)){if(j>_||a.length>=b)break;a.push(j)}}}return a}let w=new Date(n);for(;w<=_&&a.length<b;){a.push(new Date(w));const f=new Date(w);e.freq==="daily"?f.setDate(f.getDate()+o):e.freq==="weekly"?f.setDate(f.getDate()+7*o):e.freq==="monthly"?f.setMonth(f.getMonth()+o):f.setFullYear(f.getFullYear()+o),w=f}return a}function Nt(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();Oe(a.recurrence,new Date(a.start),c).forEach((x,_)=>{const b=new Date(x.getTime()+o);b>=n&&d.push({...a,id:`${a.id}_${_}`,start:x,end:b})})}return d}function et(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 tt(e="r"){return`${e}_${Math.random().toString(36).slice(2,9)}`}function nt(e={}){return{id:e.id??tt(),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 st(e){const n=(e.prepMinutes??0)+(e.cookMinutes??0);return n>0?n:void 0}const pe=({ev:e,renderEvent:n,onClick:c,draggable:d,dragRef:a,onHover:o,categoryColor:x})=>{const _=x||e.color||"var(--nice-color-primary, #3b82f6)",E={solid:{backgroundColor:_,color:"var(--nice-color-white, #fff)"},striped:{background:`repeating-linear-gradient(45deg, ${_}, ${_} 4px, transparent 4px, transparent 8px)`,border:`1px solid ${_}`,color:"var(--nice-text-primary, #333)"},outlined:{backgroundColor:"transparent",border:`2px solid ${_}`,color:_},dashed:{backgroundColor:"transparent",border:`2px dashed ${_}`,color:_}}[e.eventStyle||"solid"];return t.jsx("div",{className:`nice-scheduler__event nice-scheduler__event--${e.eventStyle||"solid"}`,style:E,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 ie(e,n){if(!(!e.category||!n))return n.find(c=>c.key===e.category)?.color}const Dt=({events:e,curDate:n,firstDayOfWeek:c,onSlotClick:d,onEventClick:a,draggable:o,dragRef:x,categories:_,renderEvent:b,onHoverEvent:E,readOnly:w})=>{const{lang:f}=H.useNiceTranslation(),C=Z(f,"short"),s=n.getFullYear(),N=n.getMonth(),j=new Date(s,N,1),l=new Date(s,N+1,0),k=(j.getDay()-c+7)%7,h=l.getDate(),m=[];for(let u=k-1;u>=0;u--)m.push({date:L(j,-u-1),isCurrentMonth:!1});for(let u=0;u<h;u++)m.push({date:new Date(s,N,u+1),isCurrentMonth:!0});let P=1;for(;m.length<42;)m.push({date:new Date(s,N+1,P++),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,g)=>t.jsx("div",{className:"nice-scheduler__month-dayname",children:C[(c+g)%7]},g))}),t.jsx("div",{className:"nice-scheduler__month-grid",children:m.map((u,g)=>{const R=et(e,u.date),p=B(u.date,new Date),S=u.date.getDay(),F=S===0||S===6;return t.jsxs("div",{className:`nice-scheduler__month-cell ${u.isCurrentMonth?"":"nice-scheduler__month-cell--other"} ${p?"nice-scheduler__month-cell--today":""} ${F?"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()}),R.slice(0,3).map(q=>t.jsx(pe,{ev:q,renderEvent:b,onClick:a,draggable:o&&!w,dragRef:x,onHover:E,categoryColor:ie(q,_)},q.id)),R.length>3&&t.jsxs("div",{className:"nice-scheduler__month-more",children:["+",R.length-3]})]},g)})})]})},wt=({events:e,days:n,startHour:c,endHour:d,draggable:a,dragRef:o,onEventClick:x,onSlotClick:_,onEventDrop:b,categories:E,workHours:w,showCurrentTime:f,renderEvent:C,onHoverEvent:s,readOnly:N})=>{const{lang:j}=H.useNiceTranslation(),l=[];for(let p=c;p<d;p++)l.push(p);Z(j,"short");const k=Z(j,"long"),h=D.useRef(null),m=new Date,P=m.getHours()*60+m.getMinutes(),u=(d-c)*60,g=(P-c*60)/u*100,R=f&&P>=c*60&&P<d*60;return D.useEffect(()=>{const p=h.current;if(!p)return;const S=new Date,F=e.filter($=>n.some(Y=>B(Y,new Date($.start)))),q=F.filter($=>B(new Date($.start),S));let W;q.length>0?W=Math.min(...q.map($=>new Date($.start).getHours())):F.length>0?W=Math.min(...F.map($=>new Date($.start).getHours())):W=8,W=Math.max(c,Math.min(W,d-1));const i=W-c,y=p.children[i];if(y){const $=p.closest(".nice-scheduler__content")??p.closest(".nice-scheduler__timegrid");$&&($.scrollTop=y.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((p,S)=>{const F=p.getDay()===0||p.getDay()===6;return t.jsxs("div",{className:`nice-scheduler__timegrid-day-header ${B(p,m)?"nice-scheduler__timegrid-day-header--today":""} ${F?"nice-scheduler__timegrid-day-header--weekend":""}`,children:[t.jsx("div",{className:"nice-scheduler__timegrid-day-name",children:k[p.getDay()]}),t.jsx("div",{className:"nice-scheduler__timegrid-day-num",children:p.getDate()})]},S)})]}),t.jsxs("div",{className:"nice-scheduler__timegrid-body",ref:h,style:{position:"relative"},children:[l.map(p=>{const S=w?p>=w[0]&&p<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:`${p.toString().padStart(2,"0")}:00`}),n.map((F,q)=>{const W=e.filter(i=>{const y=new Date(i.start);return B(y,F)&&y.getHours()===p});return t.jsx("div",{className:"nice-scheduler__timegrid-cell",onDragOver:a&&!N?i=>i.preventDefault():void 0,onDrop:a&&!N?()=>{if(!o.current||!b)return;const i=o.current.event,y=new Date(i.end).getTime()-new Date(i.start).getTime(),$=new Date(F);$.setHours(p,0,0,0);const Y=new Date($.getTime()+y);b(i,$,Y),o.current=null}:void 0,onClick:()=>!N&&(()=>{const i=new Date(F);i.setHours(p);const y=new Date(i);y.setHours(p+1),_?.(i,y)})(),children:W.map(i=>t.jsx(pe,{ev:i,renderEvent:C,onClick:x,draggable:a&&!N,dragRef:o,onHover:s,categoryColor:ie(i,E)},i.id))},q)})]},p)}),R&&n.some(p=>B(p,m))&&t.jsx("div",{className:"nice-scheduler__now-line",style:{top:`${g}%`},children:t.jsx("div",{className:"nice-scheduler__now-dot"})})]})]})},bt=({events:e,curDate:n,onEventClick:c,categories:d,t:a})=>{const o=[...e].filter(x=>new Date(x.start)>=new Date(n.getFullYear(),n.getMonth(),n.getDate())).sort((x,_)=>new Date(x.start).getTime()-new Date(_.start).getTime()).slice(0,50);return t.jsxs("div",{className:"nice-scheduler__agenda",children:[o.map(x=>t.jsx(jt,{ev:x,categories:d,onEventClick:c},x.id)),o.length===0&&t.jsx("div",{className:"nice-scheduler__agenda-empty",children:a("noEvents","No upcoming events")})]})},Je=({parts:e})=>t.jsx("div",{className:"nice-scheduler__agenda-meta",children:e.map(([n,c],d)=>t.jsxs(D.Fragment,{children:[d>0&&" · ",t.jsx(H.NiceIcon,{name:n,size:12,style:{verticalAlign:"-2px"}})," ",c]},n))}),rt=({ev:e})=>{if(e.eventType==="recipe"&&e.recipe){const n=st(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(Je,{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(Je,{parts:c})}return null},jt=({ev:e,categories:n,onEventClick:c})=>{const{t:d}=H.useNiceTranslation(),a=H.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:ie(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:[De(Q.getDefaultLocale(),new Date(e.start))," –"," ",De(Q.getDefaultLocale(),new Date(e.end))]}),e.description&&t.jsx("div",{className:"nice-scheduler__agenda-desc",children:e.description}),t.jsx(rt,{ev:e})]}),e.category&&n&&t.jsx("span",{className:"nice-scheduler__agenda-badge",style:{backgroundColor:ie(e,n)||e.color},children:n.find(o=>o.key===e.category)?.label})]})},kt=({events:e,curDate:n,timelineDays:c,resources:d,draggable:a,dragRef:o,onEventClick:x,onSlotClick:_,onEventDrop:b,categories:E,renderEvent:w,onHoverEvent:f,readOnly:C})=>{const{lang:s}=H.useNiceTranslation(),N=Array.from({length:c},(k,h)=>L(n,h)),j=d??[{id:"__default",name:""}],l=Z(s,"short");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"}),N.map((k,h)=>t.jsxs("div",{className:`nice-scheduler__timeline-day ${B(k,new Date)?"nice-scheduler__timeline-day--today":""}`,children:[l[k.getDay()]," ",k.getDate()]},h))]}),t.jsx("div",{className:"nice-scheduler__timeline-body",children:j.map(k=>{const h=e.filter(m=>!d||m.resourceId===k.id);return t.jsxs("div",{className:"nice-scheduler__timeline-row",children:[t.jsx("div",{className:"nice-scheduler__timeline-res-label",children:k.name}),N.map((m,P)=>{const u=h.filter(g=>B(new Date(g.start),m));return t.jsx("div",{className:"nice-scheduler__timeline-cell",onDragOver:a&&!C?g=>g.preventDefault():void 0,onDrop:a&&!C?()=>{if(!o.current||!b)return;const g=o.current.event,R=new Date(g.end).getTime()-new Date(g.start).getTime(),p=new Date(m);p.setHours(new Date(g.start).getHours(),new Date(g.start).getMinutes()),b(g,p,new Date(p.getTime()+R),k.id),o.current=null}:void 0,onClick:()=>!C&&_?.(m,L(m,1),k.id),children:u.map(g=>t.jsx(pe,{ev:g,renderEvent:w,onClick:x,draggable:a&&!C,dragRef:o,onHover:f,categoryColor:ie(g,E)},g.id))},P)})]},k.id)})})]})},Xe=({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 x=n.filter(b=>b.category===o.key).length,_=!c.has(o.key);return t.jsxs("button",{className:`nice-scheduler__legend-item ${_?"":"nice-scheduler__legend-item--hidden"}`,onClick:()=>d(o.key),children:[t.jsx("span",{className:"nice-scheduler__legend-dot",style:{backgroundColor:_?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:x})]},o.key)})]}),Ct=({curDate:e,onDateSelect:n,firstDayOfWeek:c,t:d})=>{const{lang:a}=H.useNiceTranslation(),[o,x]=D.useState(e.getMonth()),[_,b]=D.useState(e.getFullYear()),E=new Date(_,o,1),w=new Date(_,o+1,0),f=(E.getDay()-c+7)%7,C=[];for(let h=f-1;h>=0;h--)C.push(L(E,-h-1));for(let h=0;h<w.getDate();h++)C.push(new Date(_,o,h+1));const s=7-C.length%7;if(s<7)for(let h=1;h<=s;h++)C.push(new Date(_,o+1,h));const N=()=>{o===0?(x(11),b(h=>h-1)):x(h=>h-1)},j=()=>{o===11?(x(0),b(h=>h+1)):x(h=>h+1)},l=Ee(a,"short"),k=Z(a,"short");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:N,"aria-label":d("scheduler.prevMonth","Previous month"),children:t.jsx(H.NiceIcon,{name:"chevron-left",size:"sm"})}),t.jsxs("span",{children:[l[o]," ",_]}),t.jsx("button",{type:"button",className:"nice-btn nice-btn--xs",onClick:j,"aria-label":d("scheduler.nextMonth","Next month"),children:t.jsx(H.NiceIcon,{name:"chevron-right",size:"sm"})})]}),t.jsxs("div",{className:"nice-scheduler__mini-cal-grid",children:[k.map((h,m)=>t.jsx("div",{className:"nice-scheduler__mini-cal-dayname",children:k[(c+m)%7].charAt(0)},m)),C.map((h,m)=>{const P=B(h,new Date),u=B(h,e),g=h.getMonth()!==o;return t.jsx("button",{className:`nice-scheduler__mini-cal-day ${P?"nice-scheduler__mini-cal-day--today":""} ${u?"nice-scheduler__mini-cal-day--selected":""} ${g?"nice-scheduler__mini-cal-day--other":""}`,onClick:()=>n(h),children:h.getDate()},m)})]})]})},St=({events:e,rangeStart:n,rangeEnd:c,startHour:d,endHour:a,draggable:o,dragRef:x,onEventClick:_,onSlotClick:b,onEventDrop:E,categories:w,workHours:f,showCurrentTime:C,renderEvent:s,onHoverEvent:N,readOnly:j})=>{const{lang:l}=H.useNiceTranslation(),k=[];let h=new Date(n);for(;h<=c;)k.push(new Date(h)),h=L(h,1);const m=[];for(let y=d;y<a;y++)m.push(y);const P=Z(l,"long"),u=D.useRef(null),g=D.useRef(null),R=D.useRef(null),p=new Date,S=p.getHours()*60+p.getMinutes(),F=(a-d)*60,q=(S-d*60)/F*100,W=C&&S>=d*60&&S<a*60;D.useEffect(()=>{const y=u.current;if(!y)return;const $=new Date,Y=e.filter(I=>k.some(M=>B(M,$)&&B(new Date(I.start),$)));let V=Y.length>0?Math.min(...Y.map(I=>new Date(I.start).getHours())):$.getHours();V=Math.max(d,Math.min(V,a-1));const K=y.children[V-d];if(K){const I=R.current??y.closest(".nice-scheduler__content")??y.closest(".nice-scheduler__timegrid");I&&(I.scrollTop=K.offsetTop-4)}},[]);const i=y=>{g.current&&(g.current.scrollLeft=y.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:g,"aria-hidden":"true",children:t.jsxs("div",{className:"nice-scheduler__timegrid-header",children:[t.jsx("div",{className:"nice-scheduler__time-gutter"}),k.map((y,$)=>{const Y=y.getDay()===0||y.getDay()===6;return t.jsxs("div",{className:`nice-scheduler__timegrid-day-header ${B(y,p)?"nice-scheduler__timegrid-day-header--today":""} ${Y?"nice-scheduler__timegrid-day-header--weekend":""}`,children:[t.jsx("div",{className:"nice-scheduler__timegrid-day-name",children:P[y.getDay()]}),t.jsx("div",{className:"nice-scheduler__timegrid-day-num",children:y.getDate()})]},$)})]})}),t.jsx("div",{className:"nice-scheduler__timegrid-body-scroll",ref:R,onScroll:i,children:t.jsxs("div",{className:"nice-scheduler__timegrid-body",ref:u,style:{position:"relative"},children:[m.map(y=>{const $=f?y>=f[0]&&y<f[1]:!1;return t.jsxs("div",{className:`nice-scheduler__timegrid-row ${$?"nice-scheduler__timegrid-row--work":""}`,children:[t.jsx("div",{className:"nice-scheduler__time-gutter",children:`${y.toString().padStart(2,"0")}:00`}),k.map((Y,V)=>{const K=e.filter(I=>{const M=new Date(I.start);return B(M,Y)&&M.getHours()===y});return t.jsx("div",{className:"nice-scheduler__timegrid-cell",onDragOver:o&&!j?I=>I.preventDefault():void 0,onDrop:o&&!j?()=>{if(!x.current||!E)return;const I=x.current.event,M=new Date(I.end).getTime()-new Date(I.start).getTime(),O=new Date(Y);O.setHours(y,0,0,0),E(I,O,new Date(O.getTime()+M)),x.current=null}:void 0,onClick:()=>!j&&(()=>{const I=new Date(Y);I.setHours(y);const M=new Date(I);M.setHours(y+1),b?.(I,M)})(),children:K.map(I=>t.jsx(pe,{ev:I,renderEvent:s,onClick:_,draggable:o&&!j,dragRef:x,onHover:N,categoryColor:ie(I,w)},I.id))},V)})]},y)}),W&&k.some(y=>B(y,p))&&t.jsx("div",{className:"nice-scheduler__now-line",style:{top:`${q}%`},children:t.jsx("div",{className:"nice-scheduler__now-dot"})})]})})]})},Mt=({events:e,rangeStart:n,rangeEnd:c,firstDayOfWeek:d,onSlotClick:a,onEventClick:o,draggable:x,dragRef:_,categories:b,renderEvent:E,onHoverEvent:w,readOnly:f})=>{const{lang:C}=H.useNiceTranslation(),s=Z(C,"short");Z(C,"long");const N=[];let j=new Date(n);for(;j<=c;)N.push(new Date(j)),j=L(j,1);const l=(N[0].getDay()-d+7)%7,k=[];for(let m=l-1;m>=0;m--)k.push({date:L(N[0],-m-1),inRange:!1});N.forEach(m=>k.push({date:m,inRange:!0}));const h=7-k.length%7;if(h<7){const m=N[N.length-1];for(let P=1;P<=h;P++)k.push({date:L(m,P),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},(m,P)=>t.jsx("div",{className:"nice-scheduler__month-dayname",children:s[(d+P)%7]},P))}),t.jsx("div",{className:"nice-scheduler__month-grid",children:k.map((m,P)=>{const u=et(e,m.date),g=B(m.date,new Date),R=m.date.getDay()===0||m.date.getDay()===6;return t.jsxs("div",{className:`nice-scheduler__month-cell ${m.inRange?"":"nice-scheduler__month-cell--other"} ${g?"nice-scheduler__month-cell--today":""} ${R?"nice-scheduler__month-cell--weekend":""}`,onClick:()=>!f&&a?.(m.date,L(m.date,1)),children:[t.jsx("div",{className:"nice-scheduler__month-date",children:m.date.getDate()===1||P===0?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"nice-scheduler__month-monthname",children:Ee(C,"short")[m.date.getMonth()]})," ",m.date.getDate()]}):m.date.getDate()}),u.slice(0,3).map(p=>t.jsx(pe,{ev:p,renderEvent:E,onClick:o,draggable:x&&!f,dragRef:_,onHover:w,categoryColor:ie(p,b)},p.id)),u.length>3&&t.jsxs("div",{className:"nice-scheduler__month-more",children:["+",u.length-3]})]},P)})})]})},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:[De(Q.getDefaultLocale(),new Date(e.start))," –"," ",De(Q.getDefaultLocale(),new Date(e.end))]}),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(rt,{ev:e})]})},$t=({event:e,slotStart:n,slotEnd:c,categories:d,resources:a,formFields:o,formFieldsByType:x,eventTypes:_,renderEditor:b,saving:E,onSave:w,onDelete:f,onClose:C,t:s})=>{const N=!!e,j=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??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(u=>[u.quantity,u.unit,u.name].filter(g=>g!==void 0&&g!=="").join(" ")).join(`
|
|
2
2
|
`),recipeSteps:(e?.recipe?.steps??[]).map(u=>u.instruction).join(`
|
|
3
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,k]=D.useState(j);D.useEffect(()=>{k(j)},[j]);const h=D.useCallback((u,g)=>{k(R=>({...R,[u]:g}))},[]),m=D.useMemo(()=>{if(o&&o.length>0)return o;const u=i=>i.toString().padStart(2,"0"),g=i=>`${i.getFullYear()}-${u(i.getMonth()+1)}-${u(i.getDate())}`,R=i=>`${u(i.getHours())}:${u(i.getMinutes())}`,p=(i,y)=>{const $=i instanceof Date?i:new Date(i),Y=isNaN($.getTime())?new Date:$,V=g(Y),K=R(Y),I=(M,O)=>{const[fe,X,U]=M.split("-").map(de=>parseInt(de,10)),[ye,ve]=O.split(":").map(de=>parseInt(de,10)),le=new Date(Y);!isNaN(fe)&&!isNaN(X)&&!isNaN(U)&&le.setFullYear(fe,X-1,U),!isNaN(ye)&&!isNaN(ve)&&le.setHours(ye,ve,0,0),y(le)};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(Q.NiceDateTimePicker,{dateFormatPreset:"date-local",value:V,onChange:M=>I(M,K),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(Q.NiceDateTimePicker,{dateFormatPreset:"time",value:K,onChange:M=>I(V,M),size:"sm"})]})]})},S=[];_&&_.length>1&&S.push({field:"eventType",label:s("eventType","Type"),type:"select",group:s("common","Common"),options:_.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:p,group:s("common","Common")},{field:"end",label:s("end","End"),render:p,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,y)=>t.jsx(_t.NiceColorPicker,{value:typeof i=="string"?i:"var(--nice-primary, #3b82f6)",onChange:y,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 q=l.eventType??"task",W=x?.[q];if(W&&W.length>0)S.push(...W);else if(q==="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(q==="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]),P=()=>{const u=l.eventType??"task",g={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 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),g.recurrence=R}else g.recurrence=void 0;if(u==="recipe"){const R=String(l.recipeIngredients||"").split(`
|
|
4
4
|
`).map(q=>q.trim()).filter(Boolean).map((q,W)=>{const i=q.match(/^([\d.,/]+)\s*(\S+)?\s+(.+)$/);if(i){const y=parseFloat(i[1].replace(",","."));return{id:`ing-${W}`,name:i[3],quantity:isNaN(y)?void 0:y,unit:i[2]}}return{id:`ing-${W}`,name:q}}),p=String(l.recipeSteps||"").split(`
|