@nice2dev/ui 1.4.3 → 1.4.4
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 +31 -0
- package/dist/{NiceDataGrid-CrKDzMM1.cjs → NiceDataGrid-mrnaLHQk.cjs} +1 -1
- package/dist/{NiceForm-CT9hEXpc.cjs → NiceForm-O3sv-DNX.cjs} +1 -1
- package/dist/NiceMention-tgJKS8PH.cjs +432 -0
- package/dist/{NiceSavedQueryPanel-C5Ab_NWx.cjs → NiceSavedQueryPanel-BPGpKWN2.cjs} +1 -1
- package/dist/{NiceScheduler-BZQAKEVF.cjs → NiceScheduler-Boo-D1S-.cjs} +1 -1
- package/dist/{core-lazy-VTd5zfoZ.cjs → core-lazy-C_qnVGxE.cjs} +1 -1
- package/dist/data.cjs +1 -1
- package/dist/editors/pickers/NiceDateRangeBox.mjs +258 -227
- package/dist/editors/pickers/NiceDateTimePicker.mjs +403 -388
- package/dist/editors/rich/NiceMarkdownEditor.mjs +2 -1
- package/dist/editors/rich/NiceWiki.mjs +225 -158
- package/dist/editors.cjs +1 -1
- package/dist/editors.d.ts +29 -7
- package/dist/index.cjs +112 -112
- package/dist/index.d.ts +90 -7
- package/dist/index.mjs +716 -713
- package/dist/style.css +2 -2
- package/dist/tools/NiceThemeGalleryPicker.mjs +362 -0
- package/package.json +4 -4
- package/dist/NiceMention-BZEHqPrf.cjs +0 -432
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";const e=require("react/jsx-runtime"),hi=require("@nice2dev/i18n"),N=require("@nice2dev/ui-core"),n=require("react"),mi=require("./NiceDataGrid-
|
|
1
|
+
"use strict";const e=require("react/jsx-runtime"),hi=require("@nice2dev/i18n"),N=require("@nice2dev/ui-core"),n=require("react"),mi=require("./NiceDataGrid-mrnaLHQk.cjs"),He=require("./NiceButton-DzCqkG5a.cjs"),fi=require("./NiceForm-O3sv-DNX.cjs"),pi=require("./NiceModal-BRVzjuUN.cjs"),gi=require("./core-lBFqvT0V.cjs"),_i=require("./NiceSelect-BNPXs6FQ.cjs"),Ln=require("./no-code-B3BHeyG-.cjs"),Pn=require("./NiceColorPicker-BLwYNSXJ.cjs"),bi=[];function xi(t,a){return t.filter(s=>a.every(r=>{const l=s[r.field],o=r.value;switch(r.operator){case"eq":return l===o;case"ne":return l!==o;case"gt":return typeof l=="number"&&typeof o=="number"&&l>o;case"gte":return typeof l=="number"&&typeof o=="number"&&l>=o;case"lt":return typeof l=="number"&&typeof o=="number"&&l<o;case"lte":return typeof l=="number"&&typeof o=="number"&&l<=o;case"contains":return String(l).toLowerCase().includes(String(o).toLowerCase());case"startsWith":return String(l).toLowerCase().startsWith(String(o).toLowerCase());case"endsWith":return String(l).toLowerCase().endsWith(String(o).toLowerCase());default:return!0}}))}function yi(t){return t.map(a=>({field:a.field,type:a.dataType||"string",label:typeof a.header=="string"?a.header:a.field}))}function vi(t,a){const{enableAI:s=!0,aiModel:r,enableNLSearch:l=!0,enableInsights:o=!0,nlPlaceholder:d,onAIFilter:c,onInsights:f,showAISearchBar:m=!0,exampleQueries:w=["Show items from last week","Filter by status = active","Orders over $1000",'Names starting with "A"'],columns:E=bi,data:P,...R}=t,[T,K]=n.useState(""),[p,b]=n.useState([]),[I,_]=n.useState([]),[z,C]=n.useState(!1),[G,H]=n.useState(null),he=n.useRef(null),{t:se}=hi.useNiceTranslation(),fe=N.useNiceAI(),{parseFilter:Ie,isLoading:ee}=N.useNaturalLanguageFilter(),we=s&&fe.isConfigured,B=p.length>0?xi(P||[],p):P,$e=n.useCallback(async A=>{if(!we||!l||!A.trim())return;H(A);const g=yi(E);try{const pe=await Ie(A,g);b(pe),c?.(A,pe)}catch{b([])}},[we,l,E,Ie,c]),ke=n.useCallback(()=>{b([]),H(null),K("")},[]),Pe=n.useCallback(()=>p,[p]),Z=n.useCallback(async()=>{if(!we||!o||!P?.length)return[];try{const A=await fe.complete([{role:"user",content:`Analyze this data and provide 3-5 key insights. Data sample (${P.length} total rows): ${JSON.stringify(P.slice(0,20))}
|
|
2
2
|
|
|
3
3
|
Columns: ${E.map(g=>g.field).join(", ")}
|
|
4
4
|
|
|
@@ -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-CT9hEXpc.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-O3sv-DNX.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(`
|
|
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(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const r=require("react/jsx-runtime"),C=require("@nice2dev/ui-core"),o=require("react"),f=({height:e=200})=>r.jsx("div",{className:"ntd-lazy-loading",style:{display:"flex",alignItems:"center",justifyContent:"center",height:e,background:"var(--ntd-color-surface, #f5f5f5)",borderRadius:"var(--ntd-radius, 8px)",animation:"ntd-pulse 1.5s ease-in-out infinite"},children:r.jsx("div",{className:"ntd-lazy-loading-spinner",style:{width:24,height:24,border:"2px solid var(--ntd-color-border, #ddd)",borderTopColor:"var(--ntd-color-primary, #6366f1)",borderRadius:"50%",animation:"ntd-spin 0.8s linear infinite"}})}),L=(e,t)=>{const{t:a}=C.useNiceTranslation();return r.jsxs("div",{className:"ntd-lazy-error",style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:24,background:"var(--ntd-color-error-bg, #fee2e2)",borderRadius:"var(--ntd-radius, 8px)",color:"var(--ntd-color-error, #dc2626)"},children:[r.jsx(C.NiceIcon,{name:"error",size:32}),r.jsx("p",{style:{margin:"12px 0 8px",fontWeight:500},children:a("lazy.failedToLoadComponent","Failed to load component")}),r.jsx("p",{style:{margin:0,fontSize:"0.875em",opacity:.8},children:e.message}),r.jsx("button",{onClick:t,style:{marginTop:16,padding:"8px 16px",border:"none",borderRadius:"var(--ntd-radius, 8px)",background:"var(--ntd-color-error, #dc2626)",color:"var(--nice-color-white, #fff)",cursor:"pointer",fontSize:"0.875em"},children:a("lazy.retry","Retry")})]})};class D extends o.Component{constructor(){super(...arguments),this.state={error:null},this.handleRetry=()=>{this.setState({error:null})}}static getDerivedStateFromError(t){return{error:t}}render(){return this.state.error?this.props.fallback(this.state.error,this.handleRetry):this.props.children}}function i(e,t={}){const{fallback:a=r.jsx(f,{}),preloadOnMount:l=!1,preloadOnHover:p=!1,preloadAfterIdle:n,minLoadingTime:m=0,ssrFallback:c,errorFallback:S=L,displayName:P}=t;let b=null,h=!1;const y=async()=>{if(b)return b;const x=Date.now();b=e();const v=await b;if(m>0){const w=Date.now()-x;w<m&&await new Promise(u=>setTimeout(u,m-w))}return h=!0,v},I=o.lazy(y),q=x=>{const v=o.useRef(null);return o.useEffect(()=>{l&&!h&&y()},[]),o.useEffect(()=>{if(n&&!h){const u="requestIdleCallback"in window?window.requestIdleCallback(()=>y(),{timeout:n}):setTimeout(()=>y(),n);return()=>{"cancelIdleCallback"in window?window.cancelIdleCallback(u):clearTimeout(u)}}},[]),o.useEffect(()=>{if(!p||h)return;const u=v.current;if(!u)return;const N=()=>{h||y()};return u.addEventListener("mouseenter",N,{once:!0}),()=>u.removeEventListener("mouseenter",N)},[]),typeof window>"u"&&c?r.jsx(r.Fragment,{children:c}):r.jsx("div",{ref:v,className:"ntd-lazy-wrapper",children:r.jsx(D,{fallback:S,children:r.jsx(o.Suspense,{fallback:a,children:r.jsx(I,{...x})})})})},R=async()=>{h||await y()},k=q;return k.preload=R,k.displayName=P||"LazyComponent",k}function G(e=.1,t="100px"){const a=o.useRef(null),[l,p]=o.useState(!1);return o.useEffect(()=>{if(!a.current||l)return;const n=new IntersectionObserver(([m])=>{m.isIntersecting&&(p(!0),n.disconnect())},{threshold:e,rootMargin:t});return n.observe(a.current),()=>n.disconnect()},[e,t,l]),[a,l]}function V(e,t=2e3){o.useEffect(()=>{if("requestIdleCallback"in window){const a=window.requestIdleCallback(()=>{e.forEach(l=>l())},{timeout:t});return()=>window.cancelIdleCallback(a)}else{const a=setTimeout(()=>{e.forEach(l=>l())},t);return()=>clearTimeout(a)}},[])}function T(e,t){const a=o.useRef(new Set);o.useEffect(()=>{const l=document.querySelectorAll("a[href]"),p=n=>{const c=n.currentTarget.getAttribute("href");c&&e[c]&&!a.current.has(c)&&(e[c](),a.current.add(c))};return l.forEach(n=>{n.addEventListener("mouseenter",p)}),()=>{l.forEach(n=>{n.removeEventListener("mouseenter",p)})}},[t,e])}const z=()=>r.jsx(f,{height:400}),g=()=>r.jsx(f,{height:300}),j=()=>r.jsx(f,{height:500}),E=()=>r.jsx(f,{height:600}),d=e=>e,s={CodeEditor:i(d(()=>Promise.resolve().then(()=>require("./NiceCodeEditor-DhdjnDLV.cjs")).then(e=>({default:e.NiceCodeEditor}))),{fallback:r.jsx(z,{}),preloadOnHover:!0,displayName:"LazyCodeEditor"}),HtmlEditor:i(d(()=>Promise.resolve().then(()=>require("./NiceHtmlEditor-C1OVtLQ6.cjs")).then(e=>({default:e.NiceHtmlEditor}))),{fallback:r.jsx(z,{}),preloadOnHover:!0,displayName:"LazyHtmlEditor"}),DocumentViewer:i(d(()=>Promise.resolve().then(()=>require("./NiceDocumentViewer-CDXAmPp7.cjs")).then(e=>({default:e.NiceDocumentViewer}))),{fallback:r.jsx(f,{height:600}),displayName:"LazyDocumentViewer"}),Chart:i(d(()=>Promise.resolve().then(()=>require("./charts-BzlvCCg9.cjs")).then(e=>e.NiceChart$1).then(e=>({default:e.NiceChart}))),{fallback:r.jsx(g,{}),preloadAfterIdle:3e3,displayName:"LazyChart"}),VectorMap:i(d(()=>Promise.resolve().then(()=>require("./charts-BzlvCCg9.cjs")).then(e=>e.NiceVectorMap$1).then(e=>({default:e.NiceVectorMap}))),{fallback:r.jsx(f,{height:400}),displayName:"LazyVectorMap"}),Sankey:i(d(()=>Promise.resolve().then(()=>require("./charts-BzlvCCg9.cjs")).then(e=>e.NiceSankey$1).then(e=>({default:e.NiceSankey}))),{fallback:r.jsx(g,{}),displayName:"LazySankey"}),Scheduler:i(d(()=>Promise.resolve().then(()=>require("./NiceScheduler-
|
|
1
|
+
"use strict";const r=require("react/jsx-runtime"),C=require("@nice2dev/ui-core"),o=require("react"),f=({height:e=200})=>r.jsx("div",{className:"ntd-lazy-loading",style:{display:"flex",alignItems:"center",justifyContent:"center",height:e,background:"var(--ntd-color-surface, #f5f5f5)",borderRadius:"var(--ntd-radius, 8px)",animation:"ntd-pulse 1.5s ease-in-out infinite"},children:r.jsx("div",{className:"ntd-lazy-loading-spinner",style:{width:24,height:24,border:"2px solid var(--ntd-color-border, #ddd)",borderTopColor:"var(--ntd-color-primary, #6366f1)",borderRadius:"50%",animation:"ntd-spin 0.8s linear infinite"}})}),L=(e,t)=>{const{t:a}=C.useNiceTranslation();return r.jsxs("div",{className:"ntd-lazy-error",style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:24,background:"var(--ntd-color-error-bg, #fee2e2)",borderRadius:"var(--ntd-radius, 8px)",color:"var(--ntd-color-error, #dc2626)"},children:[r.jsx(C.NiceIcon,{name:"error",size:32}),r.jsx("p",{style:{margin:"12px 0 8px",fontWeight:500},children:a("lazy.failedToLoadComponent","Failed to load component")}),r.jsx("p",{style:{margin:0,fontSize:"0.875em",opacity:.8},children:e.message}),r.jsx("button",{onClick:t,style:{marginTop:16,padding:"8px 16px",border:"none",borderRadius:"var(--ntd-radius, 8px)",background:"var(--ntd-color-error, #dc2626)",color:"var(--nice-color-white, #fff)",cursor:"pointer",fontSize:"0.875em"},children:a("lazy.retry","Retry")})]})};class D extends o.Component{constructor(){super(...arguments),this.state={error:null},this.handleRetry=()=>{this.setState({error:null})}}static getDerivedStateFromError(t){return{error:t}}render(){return this.state.error?this.props.fallback(this.state.error,this.handleRetry):this.props.children}}function i(e,t={}){const{fallback:a=r.jsx(f,{}),preloadOnMount:l=!1,preloadOnHover:p=!1,preloadAfterIdle:n,minLoadingTime:m=0,ssrFallback:c,errorFallback:S=L,displayName:P}=t;let b=null,h=!1;const y=async()=>{if(b)return b;const x=Date.now();b=e();const v=await b;if(m>0){const w=Date.now()-x;w<m&&await new Promise(u=>setTimeout(u,m-w))}return h=!0,v},I=o.lazy(y),q=x=>{const v=o.useRef(null);return o.useEffect(()=>{l&&!h&&y()},[]),o.useEffect(()=>{if(n&&!h){const u="requestIdleCallback"in window?window.requestIdleCallback(()=>y(),{timeout:n}):setTimeout(()=>y(),n);return()=>{"cancelIdleCallback"in window?window.cancelIdleCallback(u):clearTimeout(u)}}},[]),o.useEffect(()=>{if(!p||h)return;const u=v.current;if(!u)return;const N=()=>{h||y()};return u.addEventListener("mouseenter",N,{once:!0}),()=>u.removeEventListener("mouseenter",N)},[]),typeof window>"u"&&c?r.jsx(r.Fragment,{children:c}):r.jsx("div",{ref:v,className:"ntd-lazy-wrapper",children:r.jsx(D,{fallback:S,children:r.jsx(o.Suspense,{fallback:a,children:r.jsx(I,{...x})})})})},R=async()=>{h||await y()},k=q;return k.preload=R,k.displayName=P||"LazyComponent",k}function G(e=.1,t="100px"){const a=o.useRef(null),[l,p]=o.useState(!1);return o.useEffect(()=>{if(!a.current||l)return;const n=new IntersectionObserver(([m])=>{m.isIntersecting&&(p(!0),n.disconnect())},{threshold:e,rootMargin:t});return n.observe(a.current),()=>n.disconnect()},[e,t,l]),[a,l]}function V(e,t=2e3){o.useEffect(()=>{if("requestIdleCallback"in window){const a=window.requestIdleCallback(()=>{e.forEach(l=>l())},{timeout:t});return()=>window.cancelIdleCallback(a)}else{const a=setTimeout(()=>{e.forEach(l=>l())},t);return()=>clearTimeout(a)}},[])}function T(e,t){const a=o.useRef(new Set);o.useEffect(()=>{const l=document.querySelectorAll("a[href]"),p=n=>{const c=n.currentTarget.getAttribute("href");c&&e[c]&&!a.current.has(c)&&(e[c](),a.current.add(c))};return l.forEach(n=>{n.addEventListener("mouseenter",p)}),()=>{l.forEach(n=>{n.removeEventListener("mouseenter",p)})}},[t,e])}const z=()=>r.jsx(f,{height:400}),g=()=>r.jsx(f,{height:300}),j=()=>r.jsx(f,{height:500}),E=()=>r.jsx(f,{height:600}),d=e=>e,s={CodeEditor:i(d(()=>Promise.resolve().then(()=>require("./NiceCodeEditor-DhdjnDLV.cjs")).then(e=>({default:e.NiceCodeEditor}))),{fallback:r.jsx(z,{}),preloadOnHover:!0,displayName:"LazyCodeEditor"}),HtmlEditor:i(d(()=>Promise.resolve().then(()=>require("./NiceHtmlEditor-C1OVtLQ6.cjs")).then(e=>({default:e.NiceHtmlEditor}))),{fallback:r.jsx(z,{}),preloadOnHover:!0,displayName:"LazyHtmlEditor"}),DocumentViewer:i(d(()=>Promise.resolve().then(()=>require("./NiceDocumentViewer-CDXAmPp7.cjs")).then(e=>({default:e.NiceDocumentViewer}))),{fallback:r.jsx(f,{height:600}),displayName:"LazyDocumentViewer"}),Chart:i(d(()=>Promise.resolve().then(()=>require("./charts-BzlvCCg9.cjs")).then(e=>e.NiceChart$1).then(e=>({default:e.NiceChart}))),{fallback:r.jsx(g,{}),preloadAfterIdle:3e3,displayName:"LazyChart"}),VectorMap:i(d(()=>Promise.resolve().then(()=>require("./charts-BzlvCCg9.cjs")).then(e=>e.NiceVectorMap$1).then(e=>({default:e.NiceVectorMap}))),{fallback:r.jsx(f,{height:400}),displayName:"LazyVectorMap"}),Sankey:i(d(()=>Promise.resolve().then(()=>require("./charts-BzlvCCg9.cjs")).then(e=>e.NiceSankey$1).then(e=>({default:e.NiceSankey}))),{fallback:r.jsx(g,{}),displayName:"LazySankey"}),Scheduler:i(d(()=>Promise.resolve().then(()=>require("./NiceScheduler-Boo-D1S-.cjs")).then(e=>e.NiceScheduler$1).then(e=>({default:e.NiceScheduler}))),{fallback:r.jsx(E,{}),displayName:"LazyScheduler"}),Gantt:i(d(()=>Promise.resolve().then(()=>require("./NiceGantt-BygumlaY.cjs")).then(e=>({default:e.NiceGantt}))),{fallback:r.jsx(E,{}),displayName:"LazyGantt"}),PivotGrid:i(d(()=>Promise.resolve().then(()=>require("./NicePivotGrid-Cnkr9WkC.cjs")).then(e=>e.NicePivotGrid$1).then(e=>({default:e.NicePivotGrid}))),{fallback:r.jsx(j,{}),displayName:"LazyPivotGrid"}),DataGrid:i(d(()=>Promise.resolve().then(()=>require("./NiceDataGrid-mrnaLHQk.cjs")).then(e=>e.NiceDataGrid$1).then(e=>({default:e.NiceDataGrid}))),{fallback:r.jsx(j,{}),preloadAfterIdle:2e3,displayName:"LazyDataGrid"})};async function H(){await Promise.all([s.CodeEditor.preload(),s.HtmlEditor.preload(),s.DocumentViewer.preload(),s.Chart.preload(),s.VectorMap.preload(),s.Sankey.preload(),s.Scheduler.preload(),s.Gantt.preload(),s.PivotGrid.preload()])}async function O(e){await Promise.all(e.map(t=>s[t].preload()))}exports.DefaultErrorFallback=L;exports.DefaultLoadingFallback=f;exports.LazyComponents=s;exports.createLazyComponent=i;exports.preloadAllHeavyComponents=H;exports.preloadComponents=O;exports.useLazyOnVisible=G;exports.usePreloadOnIdle=V;exports.usePreloadOnRouteHint=T;
|
package/dist/data.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./NiceDataGrid-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./NiceDataGrid-mrnaLHQk.cjs"),e=require("./NiceSavedQueryPanel-BPGpKWN2.cjs"),r=require("./NicePivotGrid-Cnkr9WkC.cjs");exports.NiceDataGrid=i.NiceDataGrid;exports.applyColumnOrder=i.applyColumnOrder;exports.buildColumnGroupSegments=i.buildColumnGroupSegments;exports.buildGridState=i.buildGridState;exports.computeAggregate=i.computeAggregate;exports.escapeCsvField=i.escapeCsvField;exports.formatNumberPattern=i.formatNumberPattern;exports.measureColumnContentWidth=i.measureColumnContentWidth;exports.readStoredGridState=i.readStoredGridState;exports.writeStoredGridState=i.writeStoredGridState;exports.NiceDataGridAI=e.NiceDataGridAI;exports.NiceKanbanBoard=e.NiceKanbanBoard;exports.NiceList=e.NiceList;exports.NiceModuleGrid=e.NiceModuleGrid;exports.NiceReconciliationView=e.NiceReconciliationView;exports.NiceSavedQueryPanel=e.NiceSavedQueryPanel;exports.NiceSpreadsheet=e.NiceSpreadsheet;exports.NiceTable=e.NiceTable;exports.NiceTileView=e.NiceTileView;exports.NiceTreeGrid=e.NiceTreeGrid;exports.NiceTreeList=e.NiceTreeList;exports.NiceTreeView=e.NiceTreeView;exports.NicePivotGrid=r.NicePivotGrid;exports.NicePivotGridFieldChooser=r.NicePivotGridFieldChooser;
|