@nice2dev/ui 1.3.16 → 1.3.18
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 +138 -0
- package/README.md +2 -2
- package/dist/{NiceDataGrid-aNPAHsWy.cjs → NiceDataGrid-CFibAGHt.cjs} +1 -1
- package/dist/NiceEventOrchestrator.doc-Dwtq2s_L.cjs +6 -0
- package/dist/NiceForm-ChRj4r3f.cjs +1 -0
- package/dist/{NiceMention-CMqAGvO0.cjs → NiceMention-DNx3d9L7.cjs} +1 -1
- package/dist/NiceModuleLifecyclePanel-D8Q081R6.cjs +1 -0
- package/dist/{NiceSavedQueryPanel-JHrSlHAV.cjs → NiceSavedQueryPanel-BuRAgrBk.cjs} +1 -1
- package/dist/{NiceScheduler-2TwOZq-y.cjs → NiceScheduler-DAoo1eyo.cjs} +1 -1
- package/dist/{core-lazy-Cda-D35m.cjs → core-lazy-DohJQ33c.cjs} +1 -1
- package/dist/data/treeDragSession.mjs +52 -46
- package/dist/data.cjs +1 -1
- package/dist/docs/NiceEventOrchestrator.doc.json.mjs +19 -19
- package/dist/editors/inputs/NiceAutocomplete.mjs +44 -46
- package/dist/editors/pickers/NiceDateTimePicker.mjs +1 -1
- package/dist/editors.cjs +1 -1
- package/dist/index.cjs +216 -216
- package/dist/index.d.ts +192 -69
- package/dist/index.mjs +933 -926
- package/dist/navigation/NiceIconRail.mjs +74 -53
- package/dist/navigation/NiceNavShell.mjs +855 -807
- package/dist/navigation/NiceSetupWizard.mjs +287 -278
- package/dist/navigation/NiceSidebarNav.mjs +1487 -1144
- package/dist/navigation/navItemDrag.mjs +42 -0
- package/dist/navigation/navShellPane.mjs +16 -11
- package/dist/navigation/sidebarNavTypes.mjs +1 -0
- package/dist/navigation/sidebarSearch.mjs +28 -0
- package/dist/navigation.cjs +1 -1
- package/dist/navigation.d.ts +63 -21
- package/dist/style.css +2 -2
- package/dist/tools/NiceThemeDesigner.mjs +1359 -900
- package/dist/tools/NiceThemePreview.mjs +18 -18
- package/dist/tools/themeCatalog.mjs +50 -0
- package/dist/workflow/NiceWorkflowDesigner.mjs +452 -898
- package/package.json +4 -4
- package/dist/NiceEventOrchestrator.doc-CxjsLxBG.cjs +0 -6
- package/dist/NiceForm-BtRBLffD.cjs +0 -1
- package/dist/NiceModuleLifecyclePanel-ugNtHimh.cjs +0 -1
|
@@ -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-CFibAGHt.cjs"),He=require("./NiceButton-DzCqkG5a.cjs"),fi=require("./NiceForm-ChRj4r3f.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"),N=require("react"),ne=require("./NiceButton-DzCqkG5a.cjs"),Ce=require("./devops-cgRBnZVX.cjs"),Se=require("./NiceForm-BtRBLffD.cjs"),yt=require("./NiceColorPicker-BLwYNSXJ.cjs"),vt=require("./NiceModal-BRVzjuUN.cjs"),Me=({children:e,className:n,style:c,"data-testid":d,direction:a="horizontal",size:o,disabled:y,readOnly:x,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":""} ${x?"nice-btn-group--readonly":""} ${n||""}`,style:c,role:"group","data-testid":d,"aria-busy":b||void 0,children:[N.Children.map(e,s=>{if(!N.isValidElement(s))return s;const D={};return y&&(D.disabled=!0),x&&(D.disabled=!0),b&&(D.disabled=!0),o&&(D.size=o),N.cloneElement(s,D)}),b&&t.jsx("span",{className:"nice-btn-group__spinner",children:t.jsx("span",{className:"nice-spinner nice-spinner--sm"})})]});if(!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]})},Ge=new Map;function Q(e){if(!e)return"en";try{return Intl.DateTimeFormat.supportedLocalesOf(e).length>0?e:"en"}catch{return"en"}}function Te(e,n){const c=Q(e),d=`${c}|${JSON.stringify(n)}`;let a=Ge.get(d);return a||(a=new Intl.DateTimeFormat(c,n),Ge.set(d,a)),a}const Xe=(e,n)=>e.charAt(0).toLocaleUpperCase(Q(n))+e.slice(1);function O(e,n="short"){const c=Te(e,{weekday:n});return Array.from({length:7},(d,a)=>Xe(c.format(new Date(2023,0,1+a)),e))}function $e(e,n="long"){const c=Te(e,{month:n});return Array.from({length:12},(d,a)=>Xe(c.format(new Date(2023,a,1)),e))}function xe(e,n){return Te(e,{dateStyle:"short",timeStyle:"short"}).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 Qe(e,n,c,d=1/0){const a=[],o=Math.max(1,Math.floor(e.interval??1)),y=e.until?new Date(e.until):void 0,x=y&&y<c?y: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>x)break;for(const D of E){const j=new Date(s);if(j.setDate(s.getDate()+D),!(j<n)){if(j>x||a.length>=b)break;a.push(j)}}}return a}let w=new Date(n);for(;w<=x&&a.length<b;){a.push(new Date(w));const 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 _t(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();Qe(a.recurrence,new Date(a.start),c).forEach((y,x)=>{const b=new Date(y.getTime()+o);b>=n&&d.push({...a,id:`${a.id}_${x}`,start:y,end:b})})}return d}function Ze(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 Oe(e="r"){return`${e}_${Math.random().toString(36).slice(2,9)}`}function et(e={}){return{id:e.id??Oe(),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 tt(e){const n=(e.prepMinutes??0)+(e.cookMinutes??0);return n>0?n:void 0}const he=({ev:e,renderEvent:n,onClick:c,draggable:d,dragRef:a,onHover:o,categoryColor:y})=>{const x=y||e.color||"var(--nice-color-primary, #3b82f6)",E={solid:{backgroundColor:x,color:"var(--nice-color-white, #fff)"},striped:{background:`repeating-linear-gradient(45deg, ${x}, ${x} 4px, transparent 4px, transparent 8px)`,border:`1px solid ${x}`,color:"var(--nice-text-primary, #333)"},outlined:{backgroundColor:"transparent",border:`2px solid ${x}`,color:x},dashed:{backgroundColor:"transparent",border:`2px dashed ${x}`,color:x}}[e.eventStyle||"solid"];return t.jsx("div",{className:`nice-scheduler__event nice-scheduler__event--${e.eventStyle||"solid"}`,style: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 se(e,n){if(!(!e.category||!n))return n.find(c=>c.key===e.category)?.color}const xt=({events:e,curDate:n,firstDayOfWeek:c,onSlotClick:d,onEventClick:a,draggable:o,dragRef:y,categories:x,renderEvent:b,onHoverEvent:E,readOnly:w})=>{const{lang:f}=H.useNiceTranslation(),C=O(f,"short"),s=n.getFullYear(),D=n.getMonth(),j=new Date(s,D,1),l=new Date(s,D+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,D,u+1),isCurrentMonth:!0});let P=1;for(;m.length<42;)m.push({date:new Date(s,D+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=Ze(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(he,{ev:q,renderEvent:b,onClick:a,draggable:o&&!w,dragRef:y,onHover:E,categoryColor:se(q,x)},q.id)),R.length>3&&t.jsxs("div",{className:"nice-scheduler__month-more",children:["+",R.length-3]})]},g)})})]})},Dt=({events:e,days:n,startHour:c,endHour:d,draggable:a,dragRef:o,onEventClick:y,onSlotClick:x,onEventDrop:b,categories:E,workHours:w,showCurrentTime:f,renderEvent:C,onHoverEvent:s,readOnly:D})=>{const{lang:j}=H.useNiceTranslation(),l=[];for(let p=c;p<d;p++)l.push(p);O(j,"short");const k=O(j,"long"),h=N.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 N.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,v=p.children[i];if(v){const $=p.closest(".nice-scheduler__content")??p.closest(".nice-scheduler__timegrid");$&&($.scrollTop=v.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 v=new Date(i.start);return B(v,F)&&v.getHours()===p});return t.jsx("div",{className:"nice-scheduler__timegrid-cell",onDragOver:a&&!D?i=>i.preventDefault():void 0,onDrop:a&&!D?()=>{if(!o.current||!b)return;const i=o.current.event,v=new Date(i.end).getTime()-new Date(i.start).getTime(),$=new Date(F);$.setHours(p,0,0,0);const Y=new Date($.getTime()+v);b(i,$,Y),o.current=null}:void 0,onClick:()=>!D&&(()=>{const i=new Date(F);i.setHours(p);const v=new Date(i);v.setHours(p+1),x?.(i,v)})(),children:W.map(i=>t.jsx(he,{ev:i,renderEvent:C,onClick:y,draggable:a&&!D,dragRef:o,onHover:s,categoryColor:se(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"})})]})]})},Nt=({events:e,curDate:n,onEventClick:c,categories:d,t:a})=>{const o=[...e].filter(y=>new Date(y.start)>=new Date(n.getFullYear(),n.getMonth(),n.getDate())).sort((y,x)=>new Date(y.start).getTime()-new Date(x.start).getTime()).slice(0,50);return t.jsxs("div",{className:"nice-scheduler__agenda",children:[o.map(y=>t.jsx(wt,{ev:y,categories:d,onEventClick:c},y.id)),o.length===0&&t.jsx("div",{className:"nice-scheduler__agenda-empty",children:a("noEvents","No upcoming events")})]})},Ke=({parts:e})=>t.jsx("div",{className:"nice-scheduler__agenda-meta",children:e.map(([n,c],d)=>t.jsxs(N.Fragment,{children:[d>0&&" · ",t.jsx(H.NiceIcon,{name:n,size:12,style:{verticalAlign:"-2px"}})," ",c]},n))}),nt=({ev:e})=>{if(e.eventType==="recipe"&&e.recipe){const n=tt(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(Ke,{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(Ke,{parts:c})}return null},wt=({ev:e,categories:n,onEventClick:c})=>{const{t:d,lang:a}=H.useNiceTranslation(),o=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)),...o,children:[t.jsx("div",{className:"nice-scheduler__agenda-dot",style:{backgroundColor:se(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:[xe(a,new Date(e.start))," – ",xe(a,new Date(e.end))]}),e.description&&t.jsx("div",{className:"nice-scheduler__agenda-desc",children:e.description}),t.jsx(nt,{ev:e})]}),e.category&&n&&t.jsx("span",{className:"nice-scheduler__agenda-badge",style:{backgroundColor:se(e,n)||e.color},children:n.find(y=>y.key===e.category)?.label})]})},bt=({events:e,curDate:n,timelineDays:c,resources:d,draggable:a,dragRef:o,onEventClick:y,onSlotClick:x,onEventDrop:b,categories:E,renderEvent:w,onHoverEvent:f,readOnly:C})=>{const{lang:s}=H.useNiceTranslation(),D=Array.from({length:c},(k,h)=>L(n,h)),j=d??[{id:"__default",name:""}],l=O(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"}),D.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}),D.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&&x?.(m,L(m,1),k.id),children:u.map(g=>t.jsx(he,{ev:g,renderEvent:w,onClick:y,draggable:a&&!C,dragRef:o,onHover:f,categoryColor:se(g,E)},g.id))},P)})]},k.id)})})]})},Je=({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 y=n.filter(b=>b.category===o.key).length,x=!c.has(o.key);return t.jsxs("button",{className:`nice-scheduler__legend-item ${x?"":"nice-scheduler__legend-item--hidden"}`,onClick:()=>d(o.key),children:[t.jsx("span",{className:"nice-scheduler__legend-dot",style:{backgroundColor:x?o.color:"var(--nice-border-color, #ccc)"}}),t.jsx("span",{className:"nice-scheduler__legend-label",children:o.label}),t.jsx("span",{className:"nice-scheduler__legend-count",children:y})]},o.key)})]}),jt=({curDate:e,onDateSelect:n,firstDayOfWeek:c,t:d})=>{const{lang:a}=H.useNiceTranslation(),[o,y]=N.useState(e.getMonth()),[x,b]=N.useState(e.getFullYear()),E=new Date(x,o,1),w=new Date(x,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(x,o,h+1));const s=7-C.length%7;if(s<7)for(let h=1;h<=s;h++)C.push(new Date(x,o+1,h));const D=()=>{o===0?(y(11),b(h=>h-1)):y(h=>h-1)},j=()=>{o===11?(y(0),b(h=>h+1)):y(h=>h+1)},l=$e(a,"short"),k=O(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:D,"aria-label":d("scheduler.prevMonth","Previous month"),children:t.jsx(H.NiceIcon,{name:"chevron-left",size:"sm"})}),t.jsxs("span",{children:[l[o]," ",x]}),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)})]})]})},kt=({events:e,rangeStart:n,rangeEnd:c,startHour:d,endHour:a,draggable:o,dragRef:y,onEventClick:x,onSlotClick:b,onEventDrop:E,categories:w,workHours:f,showCurrentTime:C,renderEvent:s,onHoverEvent:D,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 v=d;v<a;v++)m.push(v);const P=O(l,"long"),u=N.useRef(null),g=N.useRef(null),R=N.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;N.useEffect(()=>{const v=u.current;if(!v)return;const $=new Date,Y=e.filter(I=>k.some(M=>B(M,$)&&B(new Date(I.start),$)));let U=Y.length>0?Math.min(...Y.map(I=>new Date(I.start).getHours())):$.getHours();U=Math.max(d,Math.min(U,a-1));const J=v.children[U-d];if(J){const I=R.current??v.closest(".nice-scheduler__content")??v.closest(".nice-scheduler__timegrid");I&&(I.scrollTop=J.offsetTop-4)}},[]);const i=v=>{g.current&&(g.current.scrollLeft=v.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((v,$)=>{const Y=v.getDay()===0||v.getDay()===6;return t.jsxs("div",{className:`nice-scheduler__timegrid-day-header ${B(v,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[v.getDay()]}),t.jsx("div",{className:"nice-scheduler__timegrid-day-num",children:v.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(v=>{const $=f?v>=f[0]&&v<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:`${v.toString().padStart(2,"0")}:00`}),k.map((Y,U)=>{const J=e.filter(I=>{const M=new Date(I.start);return B(M,Y)&&M.getHours()===v});return t.jsx("div",{className:"nice-scheduler__timegrid-cell",onDragOver:o&&!j?I=>I.preventDefault():void 0,onDrop:o&&!j?()=>{if(!y.current||!E)return;const I=y.current.event,M=new Date(I.end).getTime()-new Date(I.start).getTime(),V=new Date(Y);V.setHours(v,0,0,0),E(I,V,new Date(V.getTime()+M)),y.current=null}:void 0,onClick:()=>!j&&(()=>{const I=new Date(Y);I.setHours(v);const M=new Date(I);M.setHours(v+1),b?.(I,M)})(),children:J.map(I=>t.jsx(he,{ev:I,renderEvent:s,onClick:x,draggable:o&&!j,dragRef:y,onHover:D,categoryColor:se(I,w)},I.id))},U)})]},v)}),W&&k.some(v=>B(v,p))&&t.jsx("div",{className:"nice-scheduler__now-line",style:{top:`${q}%`},children:t.jsx("div",{className:"nice-scheduler__now-dot"})})]})})]})},Ct=({events:e,rangeStart:n,rangeEnd:c,firstDayOfWeek:d,onSlotClick:a,onEventClick:o,draggable:y,dragRef:x,categories:b,renderEvent:E,onHoverEvent:w,readOnly:f})=>{const{lang:C}=H.useNiceTranslation(),s=O(C,"short");O(C,"long");const D=[];let j=new Date(n);for(;j<=c;)D.push(new Date(j)),j=L(j,1);const l=(D[0].getDay()-d+7)%7,k=[];for(let m=l-1;m>=0;m--)k.push({date:L(D[0],-m-1),inRange:!1});D.forEach(m=>k.push({date:m,inRange:!0}));const h=7-k.length%7;if(h<7){const m=D[D.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=Ze(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:$e(C,"short")[m.date.getMonth()]})," ",m.date.getDate()]}):m.date.getDate()}),u.slice(0,3).map(p=>t.jsx(he,{ev:p,renderEvent:E,onClick:o,draggable:y&&!f,dragRef:x,onHover:w,categoryColor:se(p,b)},p.id)),u.length>3&&t.jsxs("div",{className:"nice-scheduler__month-more",children:["+",u.length-3]})]},P)})})]})},St=({event:e,rect:n,categories:c,renderTooltip:d})=>{const{lang:a}=H.useNiceTranslation();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 o=c?.find(y=>y.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:[xe(a,new Date(e.start))," – ",xe(a,new Date(e.end))]}),o&&t.jsxs("div",{className:"nice-scheduler__tooltip-cat",children:[t.jsx("span",{className:"nice-scheduler__tooltip-dot",style:{backgroundColor:o.color}}),o.label]}),e.description&&t.jsx("div",{className:"nice-scheduler__tooltip-desc",children:e.description}),t.jsx(nt,{ev:e})]})},Mt=({event:e,slotStart:n,slotEnd:c,categories:d,resources:a,formFields:o,formFieldsByType:y,eventTypes:x,renderEditor:b,saving:E,onSave:w,onDelete:f,onClose:C,t:s})=>{const D=!!e,j=N.useMemo(()=>({title:e?.title??"",description:e?.description??"",color:e?.color??"var(--nice-primary, #3b82f6)",category:e?.category??"",eventStyle:e?.eventStyle??"solid",start:e?.start??n??new Date,end:e?.end??c??new Date,allDay:e?.allDay??!1,resourceId:e?.resourceId??"",eventType:e?.eventType??"task",recurring:!!e?.recurrence,recurrenceFreq:e?.recurrence?.freq??"weekly",recurrenceInterval:e?.recurrence?.interval??1,recurrenceCount:e?.recurrence?.count,recipeTitle:e?.recipe?.title??"",recipeServings:e?.recipe?.servings??2,recipePrep:e?.recipe?.prepMinutes,recipeCook:e?.recipe?.cookMinutes,recipeIngredients:(e?.recipe?.ingredients??[]).map(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"),N=require("react"),ne=require("./NiceButton-DzCqkG5a.cjs"),Ce=require("./devops-cgRBnZVX.cjs"),Se=require("./NiceForm-ChRj4r3f.cjs"),yt=require("./NiceColorPicker-BLwYNSXJ.cjs"),vt=require("./NiceModal-BRVzjuUN.cjs"),Me=({children:e,className:n,style:c,"data-testid":d,direction:a="horizontal",size:o,disabled:y,readOnly:x,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":""} ${x?"nice-btn-group--readonly":""} ${n||""}`,style:c,role:"group","data-testid":d,"aria-busy":b||void 0,children:[N.Children.map(e,s=>{if(!N.isValidElement(s))return s;const D={};return y&&(D.disabled=!0),x&&(D.disabled=!0),b&&(D.disabled=!0),o&&(D.size=o),N.cloneElement(s,D)}),b&&t.jsx("span",{className:"nice-btn-group__spinner",children:t.jsx("span",{className:"nice-spinner nice-spinner--sm"})})]});if(!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]})},Ge=new Map;function Q(e){if(!e)return"en";try{return Intl.DateTimeFormat.supportedLocalesOf(e).length>0?e:"en"}catch{return"en"}}function Te(e,n){const c=Q(e),d=`${c}|${JSON.stringify(n)}`;let a=Ge.get(d);return a||(a=new Intl.DateTimeFormat(c,n),Ge.set(d,a)),a}const Xe=(e,n)=>e.charAt(0).toLocaleUpperCase(Q(n))+e.slice(1);function O(e,n="short"){const c=Te(e,{weekday:n});return Array.from({length:7},(d,a)=>Xe(c.format(new Date(2023,0,1+a)),e))}function $e(e,n="long"){const c=Te(e,{month:n});return Array.from({length:12},(d,a)=>Xe(c.format(new Date(2023,a,1)),e))}function xe(e,n){return Te(e,{dateStyle:"short",timeStyle:"short"}).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 Qe(e,n,c,d=1/0){const a=[],o=Math.max(1,Math.floor(e.interval??1)),y=e.until?new Date(e.until):void 0,x=y&&y<c?y: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>x)break;for(const D of E){const j=new Date(s);if(j.setDate(s.getDate()+D),!(j<n)){if(j>x||a.length>=b)break;a.push(j)}}}return a}let w=new Date(n);for(;w<=x&&a.length<b;){a.push(new Date(w));const 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 _t(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();Qe(a.recurrence,new Date(a.start),c).forEach((y,x)=>{const b=new Date(y.getTime()+o);b>=n&&d.push({...a,id:`${a.id}_${x}`,start:y,end:b})})}return d}function Ze(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 Oe(e="r"){return`${e}_${Math.random().toString(36).slice(2,9)}`}function et(e={}){return{id:e.id??Oe(),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 tt(e){const n=(e.prepMinutes??0)+(e.cookMinutes??0);return n>0?n:void 0}const he=({ev:e,renderEvent:n,onClick:c,draggable:d,dragRef:a,onHover:o,categoryColor:y})=>{const x=y||e.color||"var(--nice-color-primary, #3b82f6)",E={solid:{backgroundColor:x,color:"var(--nice-color-white, #fff)"},striped:{background:`repeating-linear-gradient(45deg, ${x}, ${x} 4px, transparent 4px, transparent 8px)`,border:`1px solid ${x}`,color:"var(--nice-text-primary, #333)"},outlined:{backgroundColor:"transparent",border:`2px solid ${x}`,color:x},dashed:{backgroundColor:"transparent",border:`2px dashed ${x}`,color:x}}[e.eventStyle||"solid"];return t.jsx("div",{className:`nice-scheduler__event nice-scheduler__event--${e.eventStyle||"solid"}`,style: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 se(e,n){if(!(!e.category||!n))return n.find(c=>c.key===e.category)?.color}const xt=({events:e,curDate:n,firstDayOfWeek:c,onSlotClick:d,onEventClick:a,draggable:o,dragRef:y,categories:x,renderEvent:b,onHoverEvent:E,readOnly:w})=>{const{lang:f}=H.useNiceTranslation(),C=O(f,"short"),s=n.getFullYear(),D=n.getMonth(),j=new Date(s,D,1),l=new Date(s,D+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,D,u+1),isCurrentMonth:!0});let P=1;for(;m.length<42;)m.push({date:new Date(s,D+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=Ze(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(he,{ev:q,renderEvent:b,onClick:a,draggable:o&&!w,dragRef:y,onHover:E,categoryColor:se(q,x)},q.id)),R.length>3&&t.jsxs("div",{className:"nice-scheduler__month-more",children:["+",R.length-3]})]},g)})})]})},Dt=({events:e,days:n,startHour:c,endHour:d,draggable:a,dragRef:o,onEventClick:y,onSlotClick:x,onEventDrop:b,categories:E,workHours:w,showCurrentTime:f,renderEvent:C,onHoverEvent:s,readOnly:D})=>{const{lang:j}=H.useNiceTranslation(),l=[];for(let p=c;p<d;p++)l.push(p);O(j,"short");const k=O(j,"long"),h=N.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 N.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,v=p.children[i];if(v){const $=p.closest(".nice-scheduler__content")??p.closest(".nice-scheduler__timegrid");$&&($.scrollTop=v.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 v=new Date(i.start);return B(v,F)&&v.getHours()===p});return t.jsx("div",{className:"nice-scheduler__timegrid-cell",onDragOver:a&&!D?i=>i.preventDefault():void 0,onDrop:a&&!D?()=>{if(!o.current||!b)return;const i=o.current.event,v=new Date(i.end).getTime()-new Date(i.start).getTime(),$=new Date(F);$.setHours(p,0,0,0);const Y=new Date($.getTime()+v);b(i,$,Y),o.current=null}:void 0,onClick:()=>!D&&(()=>{const i=new Date(F);i.setHours(p);const v=new Date(i);v.setHours(p+1),x?.(i,v)})(),children:W.map(i=>t.jsx(he,{ev:i,renderEvent:C,onClick:y,draggable:a&&!D,dragRef:o,onHover:s,categoryColor:se(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"})})]})]})},Nt=({events:e,curDate:n,onEventClick:c,categories:d,t:a})=>{const o=[...e].filter(y=>new Date(y.start)>=new Date(n.getFullYear(),n.getMonth(),n.getDate())).sort((y,x)=>new Date(y.start).getTime()-new Date(x.start).getTime()).slice(0,50);return t.jsxs("div",{className:"nice-scheduler__agenda",children:[o.map(y=>t.jsx(wt,{ev:y,categories:d,onEventClick:c},y.id)),o.length===0&&t.jsx("div",{className:"nice-scheduler__agenda-empty",children:a("noEvents","No upcoming events")})]})},Ke=({parts:e})=>t.jsx("div",{className:"nice-scheduler__agenda-meta",children:e.map(([n,c],d)=>t.jsxs(N.Fragment,{children:[d>0&&" · ",t.jsx(H.NiceIcon,{name:n,size:12,style:{verticalAlign:"-2px"}})," ",c]},n))}),nt=({ev:e})=>{if(e.eventType==="recipe"&&e.recipe){const n=tt(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(Ke,{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(Ke,{parts:c})}return null},wt=({ev:e,categories:n,onEventClick:c})=>{const{t:d,lang:a}=H.useNiceTranslation(),o=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)),...o,children:[t.jsx("div",{className:"nice-scheduler__agenda-dot",style:{backgroundColor:se(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:[xe(a,new Date(e.start))," – ",xe(a,new Date(e.end))]}),e.description&&t.jsx("div",{className:"nice-scheduler__agenda-desc",children:e.description}),t.jsx(nt,{ev:e})]}),e.category&&n&&t.jsx("span",{className:"nice-scheduler__agenda-badge",style:{backgroundColor:se(e,n)||e.color},children:n.find(y=>y.key===e.category)?.label})]})},bt=({events:e,curDate:n,timelineDays:c,resources:d,draggable:a,dragRef:o,onEventClick:y,onSlotClick:x,onEventDrop:b,categories:E,renderEvent:w,onHoverEvent:f,readOnly:C})=>{const{lang:s}=H.useNiceTranslation(),D=Array.from({length:c},(k,h)=>L(n,h)),j=d??[{id:"__default",name:""}],l=O(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"}),D.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}),D.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&&x?.(m,L(m,1),k.id),children:u.map(g=>t.jsx(he,{ev:g,renderEvent:w,onClick:y,draggable:a&&!C,dragRef:o,onHover:f,categoryColor:se(g,E)},g.id))},P)})]},k.id)})})]})},Je=({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 y=n.filter(b=>b.category===o.key).length,x=!c.has(o.key);return t.jsxs("button",{className:`nice-scheduler__legend-item ${x?"":"nice-scheduler__legend-item--hidden"}`,onClick:()=>d(o.key),children:[t.jsx("span",{className:"nice-scheduler__legend-dot",style:{backgroundColor:x?o.color:"var(--nice-border-color, #ccc)"}}),t.jsx("span",{className:"nice-scheduler__legend-label",children:o.label}),t.jsx("span",{className:"nice-scheduler__legend-count",children:y})]},o.key)})]}),jt=({curDate:e,onDateSelect:n,firstDayOfWeek:c,t:d})=>{const{lang:a}=H.useNiceTranslation(),[o,y]=N.useState(e.getMonth()),[x,b]=N.useState(e.getFullYear()),E=new Date(x,o,1),w=new Date(x,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(x,o,h+1));const s=7-C.length%7;if(s<7)for(let h=1;h<=s;h++)C.push(new Date(x,o+1,h));const D=()=>{o===0?(y(11),b(h=>h-1)):y(h=>h-1)},j=()=>{o===11?(y(0),b(h=>h+1)):y(h=>h+1)},l=$e(a,"short"),k=O(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:D,"aria-label":d("scheduler.prevMonth","Previous month"),children:t.jsx(H.NiceIcon,{name:"chevron-left",size:"sm"})}),t.jsxs("span",{children:[l[o]," ",x]}),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)})]})]})},kt=({events:e,rangeStart:n,rangeEnd:c,startHour:d,endHour:a,draggable:o,dragRef:y,onEventClick:x,onSlotClick:b,onEventDrop:E,categories:w,workHours:f,showCurrentTime:C,renderEvent:s,onHoverEvent:D,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 v=d;v<a;v++)m.push(v);const P=O(l,"long"),u=N.useRef(null),g=N.useRef(null),R=N.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;N.useEffect(()=>{const v=u.current;if(!v)return;const $=new Date,Y=e.filter(I=>k.some(M=>B(M,$)&&B(new Date(I.start),$)));let U=Y.length>0?Math.min(...Y.map(I=>new Date(I.start).getHours())):$.getHours();U=Math.max(d,Math.min(U,a-1));const J=v.children[U-d];if(J){const I=R.current??v.closest(".nice-scheduler__content")??v.closest(".nice-scheduler__timegrid");I&&(I.scrollTop=J.offsetTop-4)}},[]);const i=v=>{g.current&&(g.current.scrollLeft=v.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((v,$)=>{const Y=v.getDay()===0||v.getDay()===6;return t.jsxs("div",{className:`nice-scheduler__timegrid-day-header ${B(v,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[v.getDay()]}),t.jsx("div",{className:"nice-scheduler__timegrid-day-num",children:v.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(v=>{const $=f?v>=f[0]&&v<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:`${v.toString().padStart(2,"0")}:00`}),k.map((Y,U)=>{const J=e.filter(I=>{const M=new Date(I.start);return B(M,Y)&&M.getHours()===v});return t.jsx("div",{className:"nice-scheduler__timegrid-cell",onDragOver:o&&!j?I=>I.preventDefault():void 0,onDrop:o&&!j?()=>{if(!y.current||!E)return;const I=y.current.event,M=new Date(I.end).getTime()-new Date(I.start).getTime(),V=new Date(Y);V.setHours(v,0,0,0),E(I,V,new Date(V.getTime()+M)),y.current=null}:void 0,onClick:()=>!j&&(()=>{const I=new Date(Y);I.setHours(v);const M=new Date(I);M.setHours(v+1),b?.(I,M)})(),children:J.map(I=>t.jsx(he,{ev:I,renderEvent:s,onClick:x,draggable:o&&!j,dragRef:y,onHover:D,categoryColor:se(I,w)},I.id))},U)})]},v)}),W&&k.some(v=>B(v,p))&&t.jsx("div",{className:"nice-scheduler__now-line",style:{top:`${q}%`},children:t.jsx("div",{className:"nice-scheduler__now-dot"})})]})})]})},Ct=({events:e,rangeStart:n,rangeEnd:c,firstDayOfWeek:d,onSlotClick:a,onEventClick:o,draggable:y,dragRef:x,categories:b,renderEvent:E,onHoverEvent:w,readOnly:f})=>{const{lang:C}=H.useNiceTranslation(),s=O(C,"short");O(C,"long");const D=[];let j=new Date(n);for(;j<=c;)D.push(new Date(j)),j=L(j,1);const l=(D[0].getDay()-d+7)%7,k=[];for(let m=l-1;m>=0;m--)k.push({date:L(D[0],-m-1),inRange:!1});D.forEach(m=>k.push({date:m,inRange:!0}));const h=7-k.length%7;if(h<7){const m=D[D.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=Ze(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:$e(C,"short")[m.date.getMonth()]})," ",m.date.getDate()]}):m.date.getDate()}),u.slice(0,3).map(p=>t.jsx(he,{ev:p,renderEvent:E,onClick:o,draggable:y&&!f,dragRef:x,onHover:w,categoryColor:se(p,b)},p.id)),u.length>3&&t.jsxs("div",{className:"nice-scheduler__month-more",children:["+",u.length-3]})]},P)})})]})},St=({event:e,rect:n,categories:c,renderTooltip:d})=>{const{lang:a}=H.useNiceTranslation();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 o=c?.find(y=>y.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:[xe(a,new Date(e.start))," – ",xe(a,new Date(e.end))]}),o&&t.jsxs("div",{className:"nice-scheduler__tooltip-cat",children:[t.jsx("span",{className:"nice-scheduler__tooltip-dot",style:{backgroundColor:o.color}}),o.label]}),e.description&&t.jsx("div",{className:"nice-scheduler__tooltip-desc",children:e.description}),t.jsx(nt,{ev:e})]})},Mt=({event:e,slotStart:n,slotEnd:c,categories:d,resources:a,formFields:o,formFieldsByType:y,eventTypes:x,renderEditor:b,saving:E,onSave:w,onDelete:f,onClose:C,t:s})=>{const D=!!e,j=N.useMemo(()=>({title:e?.title??"",description:e?.description??"",color:e?.color??"var(--nice-primary, #3b82f6)",category:e?.category??"",eventStyle:e?.eventStyle??"solid",start:e?.start??n??new Date,end:e?.end??c??new Date,allDay:e?.allDay??!1,resourceId:e?.resourceId??"",eventType:e?.eventType??"task",recurring:!!e?.recurrence,recurrenceFreq:e?.recurrence?.freq??"weekly",recurrenceInterval:e?.recurrence?.interval??1,recurrenceCount:e?.recurrence?.count,recipeTitle:e?.recipe?.title??"",recipeServings:e?.recipe?.servings??2,recipePrep:e?.recipe?.prepMinutes,recipeCook:e?.recipe?.cookMinutes,recipeIngredients:(e?.recipe?.ingredients??[]).map(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]=N.useState(j);N.useEffect(()=>{k(j)},[j]);const h=N.useCallback((u,g)=>{k(R=>({...R,[u]:g}))},[]),m=N.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,v)=>{const $=i instanceof Date?i:new Date(i),Y=isNaN($.getTime())?new Date:$,U=g(Y),J=R(Y),I=(M,V)=>{const[ge,Z,G]=M.split("-").map(oe=>parseInt(oe,10)),[pe,fe]=V.split(":").map(oe=>parseInt(oe,10)),ae=new Date(Y);!isNaN(ge)&&!isNaN(Z)&&!isNaN(G)&&ae.setFullYear(ge,Z-1,G),!isNaN(pe)&&!isNaN(fe)&&ae.setHours(pe,fe,0,0),v(ae)};return t.jsxs("div",{style:{display:"flex",gap:12,flexWrap:"wrap",alignItems:"flex-end"},children:[t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:2},children:[t.jsx("span",{style:{fontSize:"0.7rem",color:"var(--nice-text-muted, #888)"},children:s("date","Date")}),t.jsx(Se.NiceDateTimePicker,{value:U,onChange:M=>I(M,J),size:"sm"})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:2},children:[t.jsx("span",{style:{fontSize:"0.7rem",color:"var(--nice-text-muted, #888)"},children:s("time","Time")}),t.jsx(Se.NiceDateTimePicker,{dateFormatPreset:"time",value:J,onChange:M=>I(U,M),size:"sm"})]})]})},S=[];x&&x.length>1&&S.push({field:"eventType",label:s("eventType","Type"),type:"select",group:s("common","Common"),options:x.map(i=>({label:i.icon?`${i.icon} ${i.label}`:i.label,value:i.type}))}),S.push({field:"title",label:s("title","Title"),type:"text",required:!0,group:s("common","Common")},{field:"start",label:s("start","Start"),render: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,v)=>t.jsx(yt.NiceColorPicker,{value:typeof i=="string"?i:"var(--nice-primary, #3b82f6)",onChange:v,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=y?.[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,y,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 v=parseFloat(i[1].replace(",","."));return{id:`ing-${W}`,name:i[3],quantity:isNaN(v)?void 0:v,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-D0QZW88r.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-B0tHOpJ7.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-B0tHOpJ7.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-B0tHOpJ7.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-D0QZW88r.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-B0tHOpJ7.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-B0tHOpJ7.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-B0tHOpJ7.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-DAoo1eyo.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-CFibAGHt.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;
|
|
@@ -1,74 +1,80 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useRef as
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { jsxs as S, jsx as g } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as D, useState as T, useMemo as X, useContext as Y, createContext as b } from "react";
|
|
3
|
+
/* empty css */
|
|
4
|
+
const x = b(null);
|
|
5
|
+
function P() {
|
|
6
|
+
return Y(x);
|
|
6
7
|
}
|
|
7
|
-
const
|
|
8
|
-
function
|
|
8
|
+
const k = 5;
|
|
9
|
+
function G(o, n, r, u, s) {
|
|
9
10
|
if (n.button !== 0)
|
|
10
11
|
return;
|
|
11
|
-
const t = n.currentTarget,
|
|
12
|
-
let c = !1,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
12
|
+
const t = n.currentTarget, i = n.pointerId, f = n.clientX, m = n.clientY;
|
|
13
|
+
let c = !1, d = { x: f, y: m };
|
|
14
|
+
const v = () => {
|
|
15
|
+
try {
|
|
16
|
+
t.setPointerCapture?.(i);
|
|
17
|
+
} catch {
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
s?.captureOnStart || v();
|
|
21
|
+
const E = (e) => {
|
|
22
|
+
if (e.pointerId === i) {
|
|
23
|
+
if (d = { x: e.clientX, y: e.clientY }, !c) {
|
|
24
|
+
if (Math.hypot(e.clientX - f, e.clientY - m) < k)
|
|
21
25
|
return;
|
|
22
|
-
c = !0;
|
|
26
|
+
c = !0, s?.captureOnStart && v();
|
|
23
27
|
}
|
|
24
|
-
e.preventDefault(),
|
|
28
|
+
e.preventDefault(), o.setGhost({ label: u, x: e.clientX, y: e.clientY }), o.emit({ type: "move", payload: r, x: e.clientX, y: e.clientY });
|
|
25
29
|
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
+
};
|
|
31
|
+
let w = !1;
|
|
32
|
+
const p = (e) => {
|
|
33
|
+
if (!w && (w = !0, t.removeEventListener("pointermove", E), t.removeEventListener("pointerup", a), t.removeEventListener("pointercancel", l), t.removeEventListener("keydown", y), window.removeEventListener("pointerup", a), window.removeEventListener("pointercancel", l), c)) {
|
|
34
|
+
o.setGhost(null), o.emit({ type: "end", payload: r, x: d.x, y: d.y, commit: e });
|
|
35
|
+
const L = (h) => {
|
|
30
36
|
h.stopPropagation(), h.preventDefault();
|
|
31
37
|
};
|
|
32
|
-
t.addEventListener("click",
|
|
38
|
+
t.addEventListener("click", L, { capture: !0, once: !0 }), window.setTimeout(() => t.removeEventListener("click", L, { capture: !0 }), 0);
|
|
33
39
|
}
|
|
34
|
-
},
|
|
35
|
-
e.pointerId ===
|
|
36
|
-
},
|
|
37
|
-
e.pointerId ===
|
|
38
|
-
},
|
|
39
|
-
e.key === "Escape" && c && (e.preventDefault(),
|
|
40
|
+
}, a = (e) => {
|
|
41
|
+
e.pointerId === i && p(!0);
|
|
42
|
+
}, l = (e) => {
|
|
43
|
+
e.pointerId === i && p(!1);
|
|
44
|
+
}, y = (e) => {
|
|
45
|
+
e.key === "Escape" && c && (e.preventDefault(), p(!1));
|
|
40
46
|
};
|
|
41
|
-
t.addEventListener("pointermove",
|
|
47
|
+
t.addEventListener("pointermove", E), t.addEventListener("pointerup", a), t.addEventListener("pointercancel", l), t.addEventListener("keydown", y), s?.captureOnStart && (window.addEventListener("pointerup", a), window.addEventListener("pointercancel", l));
|
|
42
48
|
}
|
|
43
|
-
const
|
|
44
|
-
const n =
|
|
49
|
+
const M = ({ children: o }) => {
|
|
50
|
+
const n = D(/* @__PURE__ */ new Set()), [r, u] = T(null), s = X(
|
|
45
51
|
() => ({
|
|
46
|
-
subscribe: (
|
|
47
|
-
n.current.delete(
|
|
52
|
+
subscribe: (t) => (n.current.add(t), () => {
|
|
53
|
+
n.current.delete(t);
|
|
48
54
|
}),
|
|
49
|
-
emit: (
|
|
50
|
-
n.current.forEach((
|
|
55
|
+
emit: (t) => {
|
|
56
|
+
n.current.forEach((i) => i(t));
|
|
51
57
|
},
|
|
52
|
-
setGhost:
|
|
58
|
+
setGhost: u
|
|
53
59
|
}),
|
|
54
60
|
[]
|
|
55
61
|
);
|
|
56
|
-
return /* @__PURE__ */
|
|
57
|
-
|
|
58
|
-
|
|
62
|
+
return /* @__PURE__ */ S(x.Provider, { value: s, children: [
|
|
63
|
+
o,
|
|
64
|
+
r && /* @__PURE__ */ g(
|
|
59
65
|
"div",
|
|
60
66
|
{
|
|
61
67
|
className: "nice-sortable-tree__ghost",
|
|
62
68
|
"aria-hidden": "true",
|
|
63
|
-
style: { left:
|
|
64
|
-
children:
|
|
69
|
+
style: { left: r.x, top: r.y },
|
|
70
|
+
children: r.label
|
|
65
71
|
}
|
|
66
72
|
)
|
|
67
73
|
] });
|
|
68
74
|
};
|
|
69
75
|
export {
|
|
70
76
|
x as TreeDragSessionContext,
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
77
|
+
M as TreeDragSessionProvider,
|
|
78
|
+
G as startTreeDrag,
|
|
79
|
+
P as useTreeDragSession
|
|
74
80
|
};
|
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-CFibAGHt.cjs"),e=require("./NiceSavedQueryPanel-BuRAgrBk.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;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
const e = "https://nice2dev.com/schemas/component-doc-v1.json",
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
/>` }], a = { role: "application", ariaLabel: "Event workflow orchestrator" }, l = ["NiceWorkflowDesigner", "NiceAPIFlow"],
|
|
1
|
+
const e = "https://nice2dev.com/schemas/component-doc-v1.json", t = "NiceEventOrchestrator", o = "Event-driven workflow orchestrator with triggers, conditions, and actions.", n = "no-code", s = "1.0.7", i = "stable", r = [{ name: "flows", type: "EventFlow[]", description: "Initial event flows" }, { name: "eventSources", type: "EventSourceDefinition[]", description: "Available event sources" }, { name: "eventHandlers", type: "EventHandlerDefinition[]", description: "Available event handlers" }, { name: "onFlowsChange", type: "(flows: EventFlow[]) => void", description: "Called with the flows after every change" }, { name: "onExport", type: "(code: string) => void", description: "Called with the generated code on export" }, { name: "onTest", type: "(flowId: string) => void", description: "Called when a flow is tested" }], c = [{ title: "Event Orchestrator", description: "Build event-driven workflows", code: `<NiceEventOrchestrator
|
|
2
|
+
flows={flows}
|
|
3
|
+
eventSources={sources}
|
|
4
|
+
eventHandlers={handlers}
|
|
5
|
+
onFlowsChange={setFlows}
|
|
6
|
+
/>` }], a = { role: "application", ariaLabel: "Event workflow orchestrator" }, l = ["NiceWorkflowDesigner", "NiceAPIFlow"], d = {
|
|
7
7
|
$schema: e,
|
|
8
|
-
name:
|
|
9
|
-
description:
|
|
8
|
+
name: t,
|
|
9
|
+
description: o,
|
|
10
10
|
category: n,
|
|
11
|
-
since:
|
|
12
|
-
status:
|
|
13
|
-
props:
|
|
14
|
-
examples:
|
|
11
|
+
since: s,
|
|
12
|
+
status: i,
|
|
13
|
+
props: r,
|
|
14
|
+
examples: c,
|
|
15
15
|
accessibility: a,
|
|
16
16
|
seeAlso: l
|
|
17
17
|
};
|
|
@@ -19,12 +19,12 @@ export {
|
|
|
19
19
|
e as $schema,
|
|
20
20
|
a as accessibility,
|
|
21
21
|
n as category,
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
d as default,
|
|
23
|
+
o as description,
|
|
24
|
+
c as examples,
|
|
25
|
+
t as name,
|
|
26
|
+
r as props,
|
|
27
27
|
l as seeAlso,
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
s as since,
|
|
29
|
+
i as status
|
|
30
30
|
};
|
|
@@ -3,27 +3,27 @@ import { useComponentDisplayStyle as Ce, useComponentDisplayClass as De, useNice
|
|
|
3
3
|
import Se, { useMemo as B, useState as j, useRef as L, useEffect as Ve, useCallback as Y, useId as Ue, useLayoutEffect as Be } from "react";
|
|
4
4
|
import { createPortal as Fe } from "react-dom";
|
|
5
5
|
import { useAnchoredPopup as He } from "../../utility/useAnchoredPopup.mjs";
|
|
6
|
-
function Pe({ text:
|
|
6
|
+
function Pe({ text: l, query: g }) {
|
|
7
7
|
if (!g)
|
|
8
|
-
return /* @__PURE__ */ i(oe, { children:
|
|
9
|
-
const
|
|
10
|
-
return
|
|
11
|
-
|
|
12
|
-
/* @__PURE__ */ i("strong", { children:
|
|
13
|
-
|
|
8
|
+
return /* @__PURE__ */ i(oe, { children: l });
|
|
9
|
+
const f = l.toLowerCase().indexOf(g.toLowerCase());
|
|
10
|
+
return f < 0 ? /* @__PURE__ */ i(oe, { children: l }) : /* @__PURE__ */ m("span", { children: [
|
|
11
|
+
l.slice(0, f),
|
|
12
|
+
/* @__PURE__ */ i("strong", { children: l.slice(f, f + g.length) }),
|
|
13
|
+
l.slice(f + g.length)
|
|
14
14
|
] });
|
|
15
15
|
}
|
|
16
16
|
const ze = [], Qe = ({
|
|
17
|
-
options:
|
|
17
|
+
options: l = ze,
|
|
18
18
|
value: g,
|
|
19
|
-
defaultValue:
|
|
19
|
+
defaultValue: f,
|
|
20
20
|
onChange: re,
|
|
21
21
|
minSearchLength: y = 1,
|
|
22
22
|
maxResults: C = 10,
|
|
23
23
|
onSearch: N,
|
|
24
24
|
clearable: ce,
|
|
25
25
|
loading: F,
|
|
26
|
-
multiple:
|
|
26
|
+
multiple: a,
|
|
27
27
|
renderOption: J,
|
|
28
28
|
highlightMatch: de = !0,
|
|
29
29
|
showAll: H = !0,
|
|
@@ -36,8 +36,8 @@ const ze = [], Qe = ({
|
|
|
36
36
|
readOnly: s,
|
|
37
37
|
size: q = "md",
|
|
38
38
|
id: G,
|
|
39
|
-
className:
|
|
40
|
-
style:
|
|
39
|
+
className: ue,
|
|
40
|
+
style: fe,
|
|
41
41
|
accessMode: pe,
|
|
42
42
|
showKeyboardHints: he,
|
|
43
43
|
displayStyle: O,
|
|
@@ -51,16 +51,16 @@ const ze = [], Qe = ({
|
|
|
51
51
|
(P === "disabled" || P === "readOnly") && (I = !0);
|
|
52
52
|
const v = Ae(G), { t: T } = Me(), [r, h] = Ee({
|
|
53
53
|
value: g,
|
|
54
|
-
defaultValue:
|
|
55
|
-
fallbackValue:
|
|
54
|
+
defaultValue: f,
|
|
55
|
+
fallbackValue: a ? [] : "",
|
|
56
56
|
onChange: re,
|
|
57
57
|
componentName: "NiceAutocomplete"
|
|
58
58
|
}), c = B(
|
|
59
|
-
() =>
|
|
60
|
-
[r,
|
|
59
|
+
() => a ? Array.isArray(r) ? r : r ? [r] : [] : [],
|
|
60
|
+
[r, a]
|
|
61
61
|
), [d, k] = j(
|
|
62
|
-
() =>
|
|
63
|
-
), [$, _] = j(!1), z = L(null), [
|
|
62
|
+
() => a || Array.isArray(r) ? "" : l.find((e) => String(e.value) === r)?.label ?? r ?? ""
|
|
63
|
+
), [$, _] = j(!1), z = L(null), [u, b] = j(-1), ve = L(null), _e = L(null), { popupRef: be, coords: x, ready: W, themeClass: R, portalTarget: ee } = He(
|
|
64
64
|
$,
|
|
65
65
|
z,
|
|
66
66
|
() => _(!1)
|
|
@@ -71,21 +71,21 @@ const ze = [], Qe = ({
|
|
|
71
71
|
U.submit,
|
|
72
72
|
U.cancel
|
|
73
73
|
];
|
|
74
|
-
return
|
|
75
|
-
}, [
|
|
74
|
+
return a && e.push({ key: "Backspace", description: T("shortcuts.removeLastTag", "Remove last tag") }), e;
|
|
75
|
+
}, [a, T]);
|
|
76
76
|
Ve(() => {
|
|
77
|
-
|
|
78
|
-
Array.isArray(r) ? "" :
|
|
77
|
+
a || k(
|
|
78
|
+
Array.isArray(r) ? "" : l.find((e) => String(e.value) === r)?.label ?? r ?? ""
|
|
79
79
|
);
|
|
80
|
-
}, [r,
|
|
80
|
+
}, [r, a, l]);
|
|
81
81
|
const o = B(() => {
|
|
82
82
|
if (d.length < y)
|
|
83
|
-
return H ? (N ?
|
|
83
|
+
return H ? (N ? l : [...l].sort((t, w) => t.label.localeCompare(w.label))).slice(0, C) : [];
|
|
84
84
|
if (N)
|
|
85
|
-
return
|
|
85
|
+
return l.slice(0, C);
|
|
86
86
|
const e = d.toLowerCase();
|
|
87
|
-
return
|
|
88
|
-
}, [
|
|
87
|
+
return l.filter((n) => n.label.toLowerCase().includes(e)).slice(0, C);
|
|
88
|
+
}, [l, d, y, C, N, H]), ye = B(() => {
|
|
89
89
|
const e = /* @__PURE__ */ new Map();
|
|
90
90
|
for (const n of o) {
|
|
91
91
|
const t = n.group || "";
|
|
@@ -100,16 +100,16 @@ const ze = [], Qe = ({
|
|
|
100
100
|
), K = Y(
|
|
101
101
|
(e) => {
|
|
102
102
|
if (!s)
|
|
103
|
-
if (
|
|
103
|
+
if (a) {
|
|
104
104
|
const n = String(e.value), t = c.includes(n) ? c.filter((w) => w !== n) : [...c, n];
|
|
105
105
|
h(t), k("");
|
|
106
106
|
} else
|
|
107
107
|
k(e.label), h(String(e.value)), _(!1);
|
|
108
108
|
},
|
|
109
|
-
[h,
|
|
109
|
+
[h, a, c, s]
|
|
110
110
|
), ke = (e) => {
|
|
111
111
|
if (!s) {
|
|
112
|
-
if (
|
|
112
|
+
if (a && e.key === "Backspace" && !d && c.length > 0) {
|
|
113
113
|
h(c.slice(0, -1));
|
|
114
114
|
return;
|
|
115
115
|
}
|
|
@@ -126,14 +126,14 @@ const ze = [], Qe = ({
|
|
|
126
126
|
e.preventDefault();
|
|
127
127
|
const n = e.key === "PageDown" ? 10 : -10;
|
|
128
128
|
b((t) => Math.max(0, Math.min(o.length - 1, Math.max(t, 0) + n)));
|
|
129
|
-
} else (e.key === "Enter" || e.key === "Tab") &&
|
|
129
|
+
} else (e.key === "Enter" || e.key === "Tab") && u >= 0 && u < o.length ? (e.preventDefault(), K(o[u])) : e.key === "Escape" && _(!1);
|
|
130
130
|
}
|
|
131
131
|
}, $e = Y(
|
|
132
132
|
(e) => {
|
|
133
133
|
s || h(c.filter((n) => n !== e));
|
|
134
134
|
},
|
|
135
135
|
[c, h, s]
|
|
136
|
-
), ne = Ue(), te = `${ne}-listbox`, ie = (e) => `${ne}-opt-${e}`, S = $ && o.length > 0, V = S &&
|
|
136
|
+
), ne = Ue(), te = `${ne}-listbox`, ie = (e) => `${ne}-opt-${e}`, S = $ && o.length > 0, V = S && u >= 0 && u < o.length ? ie(u) : void 0;
|
|
137
137
|
return Be(() => {
|
|
138
138
|
V && document.getElementById(V)?.scrollIntoView?.({ block: "nearest" });
|
|
139
139
|
}, [V]), Te(
|
|
@@ -142,7 +142,7 @@ const ze = [], Qe = ({
|
|
|
142
142
|
if (e.source === "keyboard" || s)
|
|
143
143
|
return !1;
|
|
144
144
|
if (e.intent === "activate") {
|
|
145
|
-
const t = o[
|
|
145
|
+
const t = o[u];
|
|
146
146
|
if (!t)
|
|
147
147
|
return !1;
|
|
148
148
|
K(t);
|
|
@@ -157,10 +157,9 @@ const ze = [], Qe = ({
|
|
|
157
157
|
), ge ? null : /* @__PURE__ */ m(
|
|
158
158
|
"div",
|
|
159
159
|
{
|
|
160
|
-
className: `nice-field nice-field--${q} ${me === "left" ? "nice-field--label-left" : ""} ${F ? "nice-field--loading" : ""} ${
|
|
160
|
+
className: `nice-field nice-field--${q} ${me === "left" ? "nice-field--label-left" : ""} ${F ? "nice-field--loading" : ""} ${ue || ""}`,
|
|
161
161
|
style: {
|
|
162
|
-
|
|
163
|
-
...ue,
|
|
162
|
+
...fe,
|
|
164
163
|
...M != null && {
|
|
165
164
|
"--nice-field-label-width": typeof M == "number" ? `${M}px` : M
|
|
166
165
|
},
|
|
@@ -188,23 +187,22 @@ const ze = [], Qe = ({
|
|
|
188
187
|
"div",
|
|
189
188
|
{
|
|
190
189
|
ref: z,
|
|
191
|
-
className: `nice-input nice-input--${q} ${p ? "nice-input--error" : ""} ${I ? "nice-input--disabled" : ""}`,
|
|
192
|
-
style: { width: "220px" },
|
|
190
|
+
className: `nice-input nice-input--autocomplete nice-input--${q} ${p ? "nice-input--error" : ""} ${I ? "nice-input--disabled" : ""}`,
|
|
193
191
|
children: /* @__PURE__ */ m(
|
|
194
192
|
"div",
|
|
195
193
|
{
|
|
196
194
|
className: "nice-field__input-wrap",
|
|
197
195
|
style: {
|
|
198
196
|
display: "flex",
|
|
199
|
-
flexWrap:
|
|
197
|
+
flexWrap: a ? "wrap" : "nowrap",
|
|
200
198
|
gap: 4,
|
|
201
199
|
alignItems: "center",
|
|
202
200
|
flex: 1,
|
|
203
201
|
minWidth: 0
|
|
204
202
|
},
|
|
205
203
|
children: [
|
|
206
|
-
|
|
207
|
-
const n =
|
|
204
|
+
a && c.map((e) => {
|
|
205
|
+
const n = l.find((t) => String(t.value) === e);
|
|
208
206
|
return /* @__PURE__ */ m("span", { className: "nice-autocomplete__tag", children: [
|
|
209
207
|
n?.label || e,
|
|
210
208
|
!s && /* @__PURE__ */ i(
|
|
@@ -251,7 +249,7 @@ const ze = [], Qe = ({
|
|
|
251
249
|
}
|
|
252
250
|
}
|
|
253
251
|
),
|
|
254
|
-
ce && !
|
|
252
|
+
ce && !a && d && !I && !s && /* @__PURE__ */ i(
|
|
255
253
|
"button",
|
|
256
254
|
{
|
|
257
255
|
type: "button",
|
|
@@ -277,7 +275,7 @@ const ze = [], Qe = ({
|
|
|
277
275
|
"data-theme": R === "nice-dark" ? "dark" : R === "nice-light" ? "light" : void 0,
|
|
278
276
|
role: "listbox",
|
|
279
277
|
id: te,
|
|
280
|
-
"aria-multiselectable":
|
|
278
|
+
"aria-multiselectable": a || void 0,
|
|
281
279
|
style: {
|
|
282
280
|
position: "fixed",
|
|
283
281
|
left: x.left,
|
|
@@ -294,17 +292,17 @@ const ze = [], Qe = ({
|
|
|
294
292
|
children: Array.from(ye.entries()).map(([e, n]) => /* @__PURE__ */ m(Se.Fragment, { children: [
|
|
295
293
|
e && /* @__PURE__ */ i("li", { className: "nice-dropdown__group-label", children: e }),
|
|
296
294
|
n.map((t) => {
|
|
297
|
-
const w = o.indexOf(t),
|
|
295
|
+
const w = o.indexOf(t), ae = w === u, le = a && c.includes(String(t.value));
|
|
298
296
|
return /* @__PURE__ */ i(
|
|
299
297
|
"li",
|
|
300
298
|
{
|
|
301
299
|
id: ie(w),
|
|
302
300
|
role: "option",
|
|
303
|
-
className: `nice-dropdown__option ${
|
|
301
|
+
className: `nice-dropdown__option ${ae ? "nice-dropdown__option--active" : ""} ${le ? "nice-dropdown__option--selected" : ""}`,
|
|
304
302
|
onMouseDown: (xe) => {
|
|
305
303
|
xe.preventDefault(), K(t);
|
|
306
304
|
},
|
|
307
|
-
"aria-selected":
|
|
305
|
+
"aria-selected": a ? le : ae,
|
|
308
306
|
children: J ? J(t, d) : de ? /* @__PURE__ */ i(Pe, { text: t.label, query: d }) : t.label
|
|
309
307
|
},
|
|
310
308
|
String(t.value)
|