@instincthub/react-ui 0.1.34 → 0.1.36

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.
@@ -174,6 +174,10 @@
174
174
  z-index: 10;
175
175
  }
176
176
 
177
+ .ihub-table tr:nth-child(1n) {
178
+ background-color: var(--White);
179
+ }
180
+
177
181
  .ihub-empty-state {
178
182
  padding: 40px 0;
179
183
  text-align: center;
@@ -283,7 +287,7 @@
283
287
  }
284
288
 
285
289
  /* Dark mode support */
286
- @media (prefers-color-scheme: dark) {
290
+ /* @media (prefers-color-scheme: dark) {
287
291
  .ihub-table th {
288
292
  background-color: var(--OpacityBackground);
289
293
  color: var(--Gunmetal);
@@ -322,7 +326,7 @@
322
326
  background-color: var(--White);
323
327
  color: var(--LavenderGray);
324
328
  }
325
- }
329
+ } */
326
330
 
327
331
  /* Status Badge Styles */
328
332
  .ihub-status-badge {
@@ -1,2 +1,2 @@
1
- import{slicedToArray as e,objectSpread2 as t,defineProperty as a}from"../../../_virtual/_rollupPluginBabelHelpers.js";import{jsxs as n,jsx as i,Fragment as r}from"react/jsx-runtime";import d from"@mui/icons-material/CalendarMonthOutlined";import o from"@mui/icons-material/AccessTime";import{useState as l,useRef as c,useEffect as s,useCallback as u,useMemo as m}from"react";import{startOfDay as h}from"../../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/startOfDay.js";import{isBefore as p}from"../../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/isBefore.js";import{isAfter as y}from"../../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/isAfter.js";import{endOfDay as f}from"../../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/endOfDay.js";import{startOfMonth as b}from"../../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/startOfMonth.js";import{getDay as v}from"../../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/getDay.js";import{getDaysInMonth as g}from"../../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/getDaysInMonth.js";import{isSameDay as M}from"../../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/isSameDay.js";import{isValid as N}from"../../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/isValid.js";import{setHours as _}from"../../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/setHours.js";import{setMinutes as H}from"../../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/setMinutes.js";import{setSeconds as S}from"../../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/setSeconds.js";import{subMonths as D}from"../../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/subMonths.js";import{addMonths as k}from"../../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/addMonths.js";import{parse as w}from"../../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/parse.js";import{formatDate as C}from"../../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/format.js";var x=function(x){var I=x.label,A=x.value,j=void 0===A?"":A,P=x.onChange,T=x.required,L=void 0!==T&&T,F=x.minDate,O=x.maxDate,Y=x.minTime,q=x.maxTime,K=x.disabledDates,B=void 0===K?[]:K,E=x.disabledTimes,Q=void 0===E?[]:E,R=x.use12Hour,V=void 0!==R&&R,W=x.includeSeconds,z=void 0!==W&&W,G=x.timeStep,J=void 0===G?30:G,U=x.dateFormat,X=void 0===U?"yyyy-MM-dd":U,Z=x.timeFormat,$=void 0===Z?V?"hh:mm a":"HH:mm":Z;x.locale;var ee=x.placeholder,te=x.errorMessage,ae=x.className,ne=void 0===ae?"":ae,ie=x.name,re=x.id,de=x.disabled,oe=void 0!==de&&de,le=x.showCalendarIcon,ce=void 0===le||le,se=x.showTimeIcon,ue=void 0===se||se,me=x.showQuickActions,he=void 0===me||me,pe=x.ariaLabel,ye=x.autoFocus,fe=void 0!==ye&&ye,be=x.onFocus,ve=x.onBlur,ge=x.useSeparateFields,Me=void 0!==ge&&ge,Ne=x.mode,_e=void 0===Ne?"datetime":Ne,He=function(e){if(!e)return null;try{var t=new Date(e);return N(t)?t:null}catch(e){return null}},Se=l(He(j)),De=e(Se,2),ke=De[0],we=De[1],Ce=l(""),xe=e(Ce,2),Ie=xe[0],Ae=xe[1],je=l(!1),Pe=e(je,2),Te=Pe[0],Le=Pe[1],Fe=l(!1),Oe=e(Fe,2),Ye=Oe[0],qe=Oe[1],Ke=l("time"===_e?"time":"calendar"),Be=e(Ke,2),Ee=Be[0],Qe=Be[1],Re=l(te||null),Ve=e(Re,2),We=Ve[0],ze=Ve[1],Ge=l(0),Je=e(Ge,2);Je[0];var Ue=Je[1],Xe=l({year:"",month:"",day:"",hour:"",minute:"",second:"",ampm:"AM"}),Ze=e(Xe,2),$e=Ze[0],et=Ze[1],tt=l(ke||new Date),at=e(tt,2),nt=at[0],it=at[1],rt=l(ke?C(ke,"HH"):"00"),dt=e(rt,2),ot=dt[0],lt=dt[1],ct=l(ke?C(ke,"mm"):"00"),st=e(ct,2),ut=st[0],mt=st[1],ht=l(ke?C(ke,"ss"):"00"),pt=e(ht,2),yt=pt[0],ft=pt[1],bt=l(ke&&ke.getHours()>=12?"PM":"AM"),vt=e(bt,2),gt=vt[0],Mt=vt[1],Nt=c(null),_t=c(null),Ht=c(null),St=c({});s(function(){ke&&(lt(C(ke,"HH")),mt(C(ke,"mm")),ft(C(ke,"ss")),Mt(ke.getHours()>=12?"PM":"AM"))},[ke]);var Dt=u(function(e){if(!e)return"";switch(_e){case"date":return C(h(e),"yyyy-MM-dd");case"time":return C(e,z?"HH:mm:ss":"HH:mm");default:return e.toISOString()}},[_e,z]),kt=u(function(e){var t=e||ke;if(!t)return"";try{if("date"===_e)return C(t,X);if("time"===_e)return C(t,z?$:$.replace(":ss",""));var a=C(t,X),n=C(t,z?$:$.replace(":ss",""));return"".concat(a," ").concat(n)}catch(e){return""}},[ke,_e,X,$,z]);s(function(){if(void 0!==j){var e=He(j);we(e),Te||Ae(e?kt(e):"")}},[j,Te,kt]),s(function(){var e=function(e){Nt.current&&!Nt.current.contains(e.target)&&(Me&&Ht.current?Ht.current.contains(e.target)||qe(!1):!Me&&_t.current&&_t.current.contains(e.target)||qe(!1))};return document.addEventListener("mousedown",e),function(){document.removeEventListener("mousedown",e)}},[Me]);var wt=u(function(e){var t=C(e,"yyyy-MM-dd");return B.includes(t)},[B]),Ct=u(function(e){return(!F||!p(e,h(new Date(F))))&&(!O||!y(e,f(new Date(O))))},[F,O]),xt=u(function(t,a){if(!Y&&!q)return!0;var n=60*t+a;if(Y){var i=Y.split(":").map(Number),r=e(i,2);if(n<60*r[0]+r[1])return!1}if(q){var d=q.split(":").map(Number),o=e(d,2);if(n>60*o[0]+o[1])return!1}return!0},[Y,q]),It=u(function(e,t){var a="".concat(e.toString().padStart(2,"0"),":").concat(t.toString().padStart(2,"0"));return Q.includes(a)},[Q]),At=u(function(){if(ze(null),L&&!ke)return ze("Date and time are required"),!1;if(!ke)return!0;if(!Ct(ke))return ze("Selected date is outside allowed range"),!1;if(wt(ke))return ze("Selected date is not available"),!1;var e=ke.getHours(),t=ke.getMinutes();return xt(e,t)?!It(e,t)||(ze("Selected time is not available"),!1):(ze("Selected time is outside allowed range"),!1)},[ke,L,Ct,wt,xt,It]),jt=function(e){if(!wt(e)&&Ct(e)){var t=e;if("date"===_e)t=h(e),we(t),it(t),null==P||P(Dt(t)),qe(!1),ze(null);else{if(ke)t=_(e,ke.getHours()),t=H(t,ke.getMinutes()),t=S(t,ke.getSeconds());else{var a=new Date;t=_(e,a.getHours()),t=H(t,a.getMinutes()),t=S(t,0)}we(t),it(t),"datetime"===_e&&Qe("time")}}},Pt=m(function(){for(var e=nt.getFullYear(),t=nt.getMonth(),a=b(nt),n=v(a),i=g(nt),r=[],d=0;d<n;d++)r.push(null);for(var o=1;o<=i;o++)r.push(new Date(e,t,o));return r},[nt]),Tt=m(function(){for(var e=[],t=0;t<24;t++)for(var a=0;a<60;a+=J)if(!It(t,a)&&xt(t,a)){var n=t,i="";V&&(i=t<12?" AM":" PM",n=0===t?12:t>12?t-12:t);var r="".concat(n.toString().padStart(2,"0"),":").concat(a.toString().padStart(2,"0")).concat(i);e.push({hours:t,minutes:a,display:r})}return e},[J,V,It,xt]),Lt=function(e){if(!e.trim())return null;for(var t=0,a=["".concat(X," ").concat($),"".concat(X," ").concat($.replace(":ss","")),"yyyy-MM-dd HH:mm:ss","yyyy-MM-dd HH:mm","yyyy-MM-dd'T'HH:mm:ss","yyyy-MM-dd'T'HH:mm","MM/dd/yyyy HH:mm","MM/dd/yyyy hh:mm a","MM-dd-yyyy HH:mm","MM-dd-yyyy hh:mm a","dd/MM/yyyy HH:mm","dd/MM/yyyy hh:mm a","dd-MM-yyyy HH:mm","dd-MM-yyyy hh:mm a","yyyy-MM-dd","MM/dd/yyyy","dd/MM/yyyy","MM-dd-yyyy","dd-MM-yyyy"];t<a.length;t++){var n=a[t];try{var i=w(e,n,new Date);if(N(i))return i}catch(e){}}try{var r=new Date(e);if(N(r))return r}catch(e){}return null},Ft=function(){var e=new Date,t="date"===_e?h(e):e;we(t),it(t),null==P||P(Dt(t)),ze(null)},Ot=function(){we(null),lt("00"),mt("00"),ft("00"),Mt("AM"),null==P||P(""),ze(null)},Yt=function(e,n){var i=t(t({},$e),{},a({},e,n));et(i);var r=i.year,d=i.month,o=i.day,l=i.hour,c=i.minute,s=i.second,u=i.ampm;if(r&&d&&o&&l&&c)try{var m=parseInt(l);V&&("PM"===u&&12!==m&&(m+=12),"AM"===u&&12===m&&(m=0));var p=new Date(parseInt(r),parseInt(d)-1,parseInt(o),m,parseInt(c),z?parseInt(s||"0"):0);if(N(p)){var y="date"===_e?h(p):p;we(y),null==P||P(Dt(y)),ze(null)}}catch(e){}},qt=function(e,t,a,n){if(e.target.value.length>=a&&n&&/\d/.test(e.key)){e.preventDefault();var i=St.current[n];i&&(i.focus(),i.select())}};return s(function(){ke&&Me&&et({year:ke.getFullYear().toString(),month:(ke.getMonth()+1).toString().padStart(2,"0"),day:ke.getDate().toString().padStart(2,"0"),hour:V?(ke.getHours()%12||12).toString().padStart(2,"0"):ke.getHours().toString().padStart(2,"0"),minute:ke.getMinutes().toString().padStart(2,"0"),second:ke.getSeconds().toString().padStart(2,"0"),ampm:ke.getHours()>=12?"PM":"AM"})},[ke,Me,V]),n("div",{className:"ihub-datetime-picker-wrapper ".concat(ne),children:[n("div",{className:"ihub-datetime-picker ".concat(We?"ihub-error":""),children:[n("label",{className:"ihub-datetime-label",htmlFor:re||ie,children:[I,L&&i("span",{className:"ihub-required",children:"*"})]}),n("div",Me?{ref:Ht,className:"ihub-datetime-separate-fields",children:[("date"===_e||"datetime"===_e)&&n("div",{className:"ihub-datetime-date-fields",children:[i("input",{ref:function(e){St.current.year=e},type:"text",className:"ihub-datetime-field ihub-datetime-year",value:$e.year,onChange:function(e){return Yt("year",e.target.value.replace(/\D/g,"").slice(0,4))},onKeyDown:function(e){return qt(e,0,4,"month")},placeholder:"YYYY",maxLength:4,disabled:oe,id:"".concat(re,"-year"),"aria-label":"Year"}),i("span",{className:"ihub-datetime-separator",children:"/"}),i("input",{ref:function(e){St.current.month=e},type:"text",className:"ihub-datetime-field ihub-datetime-month",value:$e.month,onChange:function(e){var t=e.target.value.replace(/\D/g,"").slice(0,2);(parseInt(t)<=12||""===t)&&Yt("month",t)},onKeyDown:function(e){return qt(e,0,2,"day")},placeholder:"MM",maxLength:2,disabled:oe,id:"".concat(re,"-month"),"aria-label":"Month"}),i("span",{className:"ihub-datetime-separator",children:"/"}),i("input",{ref:function(e){St.current.day=e},type:"text",className:"ihub-datetime-field ihub-datetime-day",value:$e.day,onChange:function(e){var t=e.target.value.replace(/\D/g,"").slice(0,2);(parseInt(t)<=31||""===t)&&Yt("day",t)},onKeyDown:function(e){return qt(e,0,2,"hour")},placeholder:"DD",maxLength:2,disabled:oe,id:"".concat(re,"-day"),"aria-label":"Day"})]}),("time"===_e||"datetime"===_e)&&n("div",{className:"ihub-datetime-time-fields",children:[i("input",{ref:function(e){St.current.hour=e},type:"text",className:"ihub-datetime-field ihub-datetime-hour",value:$e.hour,onChange:function(e){var t=e.target.value.replace(/\D/g,"").slice(0,2),a=V?12:23;(parseInt(t)<=a||""===t)&&Yt("hour",t)},onKeyDown:function(e){return qt(e,0,2,"minute")},placeholder:"HH",maxLength:2,disabled:oe,id:"".concat(re,"-hour"),"aria-label":"Hour"}),i("span",{className:"ihub-datetime-separator",children:":"}),i("input",{ref:function(e){St.current.minute=e},type:"text",className:"ihub-datetime-field ihub-datetime-minute",value:$e.minute,onChange:function(e){var t=e.target.value.replace(/\D/g,"").slice(0,2);(parseInt(t)<60||""===t)&&Yt("minute",t)},onKeyDown:function(e){return qt(e,0,2,z?"second":void 0)},placeholder:"MM",maxLength:2,disabled:oe,id:"".concat(re,"-minute"),"aria-label":"Minute"}),z&&n(r,{children:[i("span",{className:"ihub-datetime-separator",children:":"}),i("input",{ref:function(e){St.current.second=e},type:"text",className:"ihub-datetime-field ihub-datetime-second",value:$e.second,onChange:function(e){var t=e.target.value.replace(/\D/g,"").slice(0,2);(parseInt(t)<60||""===t)&&Yt("second",t)},placeholder:"SS",maxLength:2,disabled:oe,id:"".concat(re,"-second"),"aria-label":"Second"})]}),V&&i("button",{type:"button",className:"ihub-datetime-field ihub-datetime-ampm-toggle",onClick:function(){return Yt("ampm","AM"===$e.ampm?"PM":"AM")},disabled:oe,"aria-label":"Toggle AM/PM, currently ".concat($e.ampm),children:$e.ampm})]}),n("div",{className:"ihub-datetime-icons",children:[ce&&("date"===_e||"datetime"===_e)&&i("button",{type:"button",className:"ihub-datetime-icon-btn",onClick:function(){oe||(qe(!0),Qe("calendar"))},disabled:oe,"aria-label":"Open calendar",children:i(d,{})}),ue&&("time"===_e||"datetime"===_e)&&i("button",{type:"button",className:"ihub-datetime-icon-btn",onClick:function(){oe||(qe(!0),Qe("time"))},disabled:oe,"aria-label":"Open time picker",children:i(o,{})})]})]}:{className:"ihub-datetime-input-container",children:[i("input",{ref:_t,type:"text",className:"ihub-datetime-input",value:Te?Ie:kt(),onChange:function(e){var t=e.target,a=t.value;t.selectionStart;var n=function(e){var t=z?"".concat(X," ").concat($):"".concat(X," ").concat($.replace(":ss","")),a=e.replace(/\D/g,""),n={"yyyy-MM-dd HH:mm:ss":[4,2,2,2,2,2],"yyyy-MM-dd HH:mm":[4,2,2,2,2],"MM/dd/yyyy HH:mm":[2,2,4,2,2],"MM/dd/yyyy hh:mm a":[2,2,4,2,2],"dd/MM/yyyy HH:mm":[2,2,4,2,2],"dd/MM/yyyy hh:mm a":[2,2,4,2,2]}[t];n||(n=[4,2,2,2,2]);for(var i=t.replace(/[yMdHhms]/g,"").split("").filter(function(e){return e.trim()}),r="",d=0,o=0,l=0;l<n.length;l++){var c=n[l],s=a.slice(d,d+c);s&&(r+=s,d+=c,l<n.length-1&&d<a.length&&o<i.length&&(r+=i[o]),o++)}return{formatted:r,cursorPos:r.length}}(a),i=n.formatted,r=n.cursorPos;if(Ae(i),Ue(r),setTimeout(function(){t&&t.setSelectionRange&&t.setSelectionRange(r,r)},0),!i.trim())return we(null),null==P||P(""),void ze(null);var d=Lt(i);if(d){var o="date"===_e?h(d):d;we(o),null==P||P(Dt(o)),ze(null)}},onFocus:function(e){Le(!0),ke&&!Ie&&Ae(kt()),null==be||be(e)},onBlur:function(e){if(Le(!1),Ie.trim()){var t=Lt(Ie);if(t){var a="date"===_e?h(t):t;we(a),null==P||P(Dt(a)),Ae(kt(a)),ze(null)}else ze("Invalid date/time format")}else ze(L?"Date and time are required":null);At(),null==ve||ve(e)},onKeyDown:function(e){"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),qe(!Ye)),"Escape"===e.key&&qe(!1),"Tab"===e.key&&Ye&&e.stopPropagation()},placeholder:Te?function(e){for(var t=("date"===_e?X:"time"===_e?z?$:$.replace(":ss",""):z?"".concat(X," ").concat($):"".concat(X," ").concat($.replace(":ss",""))).replace(/yyyy/g,"____").replace(/yy/g,"__").replace(/MM/g,"__").replace(/dd/g,"__").replace(/HH/g,"__").replace(/hh/g,"__").replace(/mm/g,"__").replace(/ss/g,"__").replace(/a/g,"__"),a="",n=0,i=0;i<t.length&&n<e.length;i++){var r=t[i],d=e[n];"_"===r?d&&/[^\d]/.test(d)&&i+1<t.length&&/[^_]/.test(t[i+1])?(a+=t[i+1],n++,i++):d&&/\d/.test(d)?(a+=d,n++):a+="_":(a+=r,d===r&&n++)}return a.length<t.length&&(a+=t.slice(a.length)),a}(Ie):"date"===_e?ee||X:"time"===_e?ee||$:ee||"".concat(X," ").concat($),disabled:oe,required:L,name:ie,id:re,"aria-label":pe||I,"aria-invalid":!!We,"aria-describedby":We?"".concat(re,"-error"):void 0,autoFocus:fe}),n("div",{className:"ihub-datetime-icons",children:[ce&&("date"===_e||"datetime"===_e)&&i("button",{type:"button",className:"ihub-datetime-icon-btn",onClick:function(){oe||(qe(!0),Qe("calendar"))},disabled:oe,"aria-label":"Open calendar",children:i(d,{})}),ue&&("time"===_e||"datetime"===_e)&&i("button",{type:"button",className:"ihub-datetime-icon-btn",onClick:function(){oe||(qe(!0),Qe("time"))},disabled:oe,"aria-label":"Open time picker",children:i(o,{})})]})]}),We&&i("div",{id:"".concat(re,"-error"),className:"ihub-datetime-error",children:We}),Ye&&!oe&&n("div",{ref:Nt,className:"ihub-datetime-picker-dropdown",role:"dialog","aria-label":"Date and time picker",children:["datetime"===_e&&n("div",{className:"ihub-datetime-tabs",children:[i("button",{className:"ihub-datetime-tab ".concat("calendar"===Ee?"active":""),onClick:function(){return Qe("calendar")},type:"button",children:"Date"}),i("button",{className:"ihub-datetime-tab ".concat("time"===Ee?"active":""),onClick:function(){return Qe("time")},type:"button",children:"Time"})]}),("calendar"===Ee||"date"===_e)&&("date"===_e||"datetime"===_e)&&n("div",{className:"ihub-datetime-calendar",children:[n("div",{className:"ihub-datetime-month-nav",children:[i("button",{type:"button",onClick:function(){it(D(nt,1))},className:"ihub-datetime-nav-btn","aria-label":"Previous month",children:"‹"}),i("span",{className:"ihub-datetime-month-year",children:C(nt,"MMMM yyyy")}),i("button",{type:"button",onClick:function(){it(k(nt,1))},className:"ihub-datetime-nav-btn","aria-label":"Next month",children:"›"})]}),i("div",{className:"ihub-datetime-weekdays",children:["Su","Mo","Tu","We","Th","Fr","Sa"].map(function(e){return i("div",{className:"ihub-datetime-weekday",children:e},e)})}),i("div",{className:"ihub-datetime-days",children:Pt.map(function(e,t){if(!e)return i("div",{className:"ihub-datetime-day-empty"},"empty-".concat(t));var a=!!ke&&M(e,ke),n=M(e,new Date),r=wt(e)||!Ct(e);return i("button",{type:"button",className:"ihub-datetime-day ".concat(a?"selected":""," ").concat(n?"today":""," ").concat(r?"disabled":""),onClick:function(){return jt(e)},disabled:r,"aria-label":C(e,"MMMM d, yyyy"),"aria-selected":!!a||void 0,children:e.getDate()},e.getTime())})})]}),("time"===Ee||"time"===_e)&&("time"===_e||"datetime"===_e)&&n("div",{className:"ihub-datetime-time",children:[n("div",{className:"ihub-datetime-time-inputs",children:[n("div",{className:"ihub-datetime-time-group",children:[i("label",{children:"Hours"}),i("input",{type:"text",className:"ihub-datetime-time-input",value:V?(parseInt(ot)%12||12).toString().padStart(2,"0"):ot,onChange:function(e){var t=e.target.value.replace(/\D/g,"");(V&&parseInt(t)<=12||!V&&parseInt(t)<24)&&lt(t)},maxLength:2,placeholder:"HH"})]}),i("span",{className:"ihub-datetime-time-separator",children:":"}),n("div",{className:"ihub-datetime-time-group",children:[i("label",{children:"Minutes"}),i("input",{type:"text",className:"ihub-datetime-time-input",value:ut,onChange:function(e){var t=e.target.value.replace(/\D/g,"");parseInt(t)<60&&mt(t)},maxLength:2,placeholder:"MM"})]}),z&&n(r,{children:[i("span",{className:"ihub-datetime-time-separator",children:":"}),n("div",{className:"ihub-datetime-time-group",children:[i("label",{children:"Seconds"}),i("input",{type:"text",className:"ihub-datetime-time-input",value:yt,onChange:function(e){var t=e.target.value.replace(/\D/g,"");parseInt(t)<60&&ft(t)},maxLength:2,placeholder:"SS"})]})]}),V&&n("div",{className:"ihub-datetime-ampm",children:[i("button",{type:"button",className:"ihub-datetime-ampm-btn ".concat("AM"===gt?"active":""),onClick:function(){return Mt("AM")},children:"AM"}),i("button",{type:"button",className:"ihub-datetime-ampm-btn ".concat("PM"===gt?"active":""),onClick:function(){return Mt("PM")},children:"PM"})]})]}),n("div",{className:"ihub-datetime-time-list",children:[i("div",{className:"ihub-datetime-time-list-header",children:"Quick select:"}),i("div",{className:"ihub-datetime-time-options",children:Tt.map(function(e,t){var a=ke&&ke.getHours()===e.hours&&ke.getMinutes()===e.minutes;return i("button",{type:"button",className:"ihub-datetime-time-option ".concat(a?"selected":""),onClick:function(){lt(e.hours.toString().padStart(2,"0")),mt(e.minutes.toString().padStart(2,"0")),V&&Mt(e.hours>=12?"PM":"AM")},children:e.display},t)})})]}),i("div",{className:"ihub-datetime-time-actions",children:i("button",{type:"button",className:"ihub-datetime-apply-btn",onClick:function(){var e=ke;if(!e){if("time"!==_e){var t=new Date;return void jt(t)}e=new Date}var a=parseInt(ot),n=parseInt(ut),i=z?parseInt(yt):0;if(V&&("PM"===gt&&12!==a?a+=12:"AM"===gt&&12===a&&(a=0)),!It(a,n)&&xt(a,n)){var r=_(e,a);r=H(r,n),r=S(r,i),we(r),null==P||P(Dt(r)),qe(!1),ze(null)}else ze("Selected time is not available")},children:"Apply Time"})})]}),he&&n("div",{className:"ihub-datetime-actions",children:[i("button",{type:"button",className:"ihub-datetime-action-btn",onClick:Ft,children:"Now"}),i("button",{type:"button",className:"ihub-datetime-action-btn",onClick:Ot,children:"Clear"})]})]})]}),he&&!oe&&!Ye&&n("div",{className:"ihub-datetime-quick-links",children:[i("button",{type:"button",className:"ihub-datetime-link",onClick:Ft,children:"Now"}),i("span",{className:"ihub-datetime-separator",children:"|"}),i("button",{type:"button",className:"ihub-datetime-link",onClick:Ot,children:"Clear"})]}),ie&&i("input",{type:"hidden",name:ie,value:ke?Dt(ke):""})]})};export{x as default};
1
+ import{slicedToArray as e,objectSpread2 as t,defineProperty as a}from"../../../_virtual/_rollupPluginBabelHelpers.js";import{jsxs as n,jsx as i,Fragment as r}from"react/jsx-runtime";import d from"@mui/icons-material/CalendarMonthOutlined";import o from"@mui/icons-material/AccessTime";import{useState as l,useRef as u,useEffect as s,useCallback as c,useMemo as m}from"react";import{createPortal as h}from"react-dom";import{startOfDay as p}from"../../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/startOfDay.js";import{isBefore as f}from"../../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/isBefore.js";import{isAfter as y}from"../../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/isAfter.js";import{endOfDay as b}from"../../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/endOfDay.js";import{startOfMonth as v}from"../../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/startOfMonth.js";import{getDay as g}from"../../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/getDay.js";import{getDaysInMonth as M}from"../../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/getDaysInMonth.js";import{isSameDay as N}from"../../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/isSameDay.js";import{isValid as H}from"../../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/isValid.js";import{setHours as _}from"../../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/setHours.js";import{setMinutes as S}from"../../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/setMinutes.js";import{setSeconds as w}from"../../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/setSeconds.js";import{subMonths as D}from"../../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/subMonths.js";import{addMonths as k}from"../../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/addMonths.js";import{parse as x}from"../../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/parse.js";import{formatDate as C}from"../../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/format.js";var I=function(I){var A=I.label,T=I.value,j=void 0===T?"":T,P=I.onChange,L=I.required,F=void 0!==L&&L,O=I.minDate,E=I.maxDate,W=I.minTime,Y=I.maxTime,q=I.disabledDates,K=void 0===q?[]:q,B=I.disabledTimes,z=void 0===B?[]:B,R=I.use12Hour,Q=void 0!==R&&R,V=I.includeSeconds,G=void 0!==V&&V,J=I.timeStep,U=void 0===J?30:J,X=I.dateFormat,Z=void 0===X?"yyyy-MM-dd":X,$=I.timeFormat,ee=void 0===$?Q?"hh:mm a":"HH:mm":$;I.locale;var te=I.placeholder,ae=I.errorMessage,ne=I.className,ie=void 0===ne?"":ne,re=I.name,de=I.id,oe=I.disabled,le=void 0!==oe&&oe,ue=I.showCalendarIcon,se=void 0===ue||ue,ce=I.showTimeIcon,me=void 0===ce||ce,he=I.showQuickActions,pe=void 0===he||he,fe=I.ariaLabel,ye=I.autoFocus,be=void 0!==ye&&ye,ve=I.onFocus,ge=I.onBlur,Me=I.useSeparateFields,Ne=void 0!==Me&&Me,He=I.mode,_e=void 0===He?"datetime":He,Se=I.maxWidth,we=void 0===Se?600:Se,De=function(e){if(!e)return null;try{var t=new Date(e);return H(t)?t:null}catch(e){return null}},ke=l(De(j)),xe=e(ke,2),Ce=xe[0],Ie=xe[1],Ae=l(""),Te=e(Ae,2),je=Te[0],Pe=Te[1],Le=l(!1),Fe=e(Le,2),Oe=Fe[0],Ee=Fe[1],We=l(!1),Ye=e(We,2),qe=Ye[0],Ke=Ye[1],Be=l("time"===_e?"time":"calendar"),ze=e(Be,2),Re=ze[0],Qe=ze[1],Ve=l(ae||null),Ge=e(Ve,2),Je=Ge[0],Ue=Ge[1],Xe=l(0),Ze=e(Xe,2);Ze[0];var $e=Ze[1],et=l({year:"",month:"",day:"",hour:"",minute:"",second:"",ampm:"AM"}),tt=e(et,2),at=tt[0],nt=tt[1],it=l(Ce||new Date),rt=e(it,2),dt=rt[0],ot=rt[1],lt=l(Ce?C(Ce,"HH"):"00"),ut=e(lt,2),st=ut[0],ct=ut[1],mt=l(Ce?C(Ce,"mm"):"00"),ht=e(mt,2),pt=ht[0],ft=ht[1],yt=l(Ce?C(Ce,"ss"):"00"),bt=e(yt,2),vt=bt[0],gt=bt[1],Mt=l(Ce&&Ce.getHours()>=12?"PM":"AM"),Nt=e(Mt,2),Ht=Nt[0],_t=Nt[1],St=u(null),wt=u(null),Dt=u(null),kt=u(null),xt=u({}),Ct=l({}),It=e(Ct,2),At=It[0],Tt=It[1];s(function(){Ce&&(ct(C(Ce,"HH")),ft(C(Ce,"mm")),gt(C(Ce,"ss")),_t(Ce.getHours()>=12?"PM":"AM"))},[Ce]);var jt=c(function(){var e=Ne?Dt.current:kt.current;if(e)if(window.innerWidth<=768)Tt({position:"fixed",top:"50%",left:"50%",right:"auto",transform:"translate(-50%, -50%)",width:Math.min(.95*window.innerWidth,400),maxWidth:we,maxHeight:"90vh",marginTop:0,zIndex:9999});else{var a=e.getBoundingClientRect(),n=window.innerHeight,i=n-a.bottom<450&&a.top>450,r=Math.min(Math.max(a.width,320),we);Tt(t(t({position:"fixed",left:a.left,right:"auto",width:r,maxWidth:we,marginTop:0},i?{bottom:n-a.top+4,top:"auto"}:{top:a.bottom+4,bottom:"auto"}),{},{zIndex:9999}))}},[Ne,we]);s(function(){if(qe)return jt(),window.addEventListener("scroll",jt,!0),window.addEventListener("resize",jt),function(){window.removeEventListener("scroll",jt,!0),window.removeEventListener("resize",jt)}},[qe,jt]);var Pt=c(function(e){if(!e)return"";switch(_e){case"date":return C(p(e),"yyyy-MM-dd");case"time":return C(e,G?"HH:mm:ss":"HH:mm");default:return e.toISOString()}},[_e,G]),Lt=c(function(e){var t=e||Ce;if(!t)return"";try{if("date"===_e)return C(t,Z);if("time"===_e)return C(t,G?ee:ee.replace(":ss",""));var a=C(t,Z),n=C(t,G?ee:ee.replace(":ss",""));return"".concat(a," ").concat(n)}catch(e){return""}},[Ce,_e,Z,ee,G]);s(function(){if(void 0!==j){var e=De(j);Ie(e),Oe||Pe(e?Lt(e):"")}},[j,Oe,Lt]),s(function(){if(qe){var e=function(e){var t,a,n,i=e.target;null!==(t=St.current)&&void 0!==t&&t.contains(i)||Ne&&null!==(a=Dt.current)&&void 0!==a&&a.contains(i)||!Ne&&null!==(n=kt.current)&&void 0!==n&&n.contains(i)||Ke(!1)},t=setTimeout(function(){document.addEventListener("mousedown",e)},0);return function(){clearTimeout(t),document.removeEventListener("mousedown",e)}}},[qe,Ne]);var Ft=c(function(e){var t=C(e,"yyyy-MM-dd");return K.includes(t)},[K]),Ot=c(function(e){return(!O||!f(e,p(new Date(O))))&&(!E||!y(e,b(new Date(E))))},[O,E]),Et=c(function(t,a){if(!W&&!Y)return!0;var n=60*t+a;if(W){var i=W.split(":").map(Number),r=e(i,2);if(n<60*r[0]+r[1])return!1}if(Y){var d=Y.split(":").map(Number),o=e(d,2);if(n>60*o[0]+o[1])return!1}return!0},[W,Y]),Wt=c(function(e,t){var a="".concat(e.toString().padStart(2,"0"),":").concat(t.toString().padStart(2,"0"));return z.includes(a)},[z]),Yt=c(function(){if(Ue(null),F&&!Ce)return Ue("Date and time are required"),!1;if(!Ce)return!0;if(!Ot(Ce))return Ue("Selected date is outside allowed range"),!1;if(Ft(Ce))return Ue("Selected date is not available"),!1;var e=Ce.getHours(),t=Ce.getMinutes();return Et(e,t)?!Wt(e,t)||(Ue("Selected time is not available"),!1):(Ue("Selected time is outside allowed range"),!1)},[Ce,F,Ot,Ft,Et,Wt]),qt=function(e){if(!Ft(e)&&Ot(e)){var t=e;if("date"===_e)t=p(e),Ie(t),ot(t),null==P||P(Pt(t)),Ke(!1),Ue(null);else{if(Ce)t=_(e,Ce.getHours()),t=S(t,Ce.getMinutes()),t=w(t,Ce.getSeconds());else{var a=new Date;t=_(e,a.getHours()),t=S(t,a.getMinutes()),t=w(t,0)}Ie(t),ot(t),null==P||P(Pt(t)),"datetime"===_e&&Qe("time")}}},Kt=m(function(){for(var e=dt.getFullYear(),t=dt.getMonth(),a=v(dt),n=g(a),i=M(dt),r=[],d=0;d<n;d++)r.push(null);for(var o=1;o<=i;o++)r.push(new Date(e,t,o));return r},[dt]),Bt=m(function(){for(var e=[],t=0;t<24;t++)for(var a=0;a<60;a+=U)if(!Wt(t,a)&&Et(t,a)){var n=t,i="";Q&&(i=t<12?" AM":" PM",n=0===t?12:t>12?t-12:t);var r="".concat(n.toString().padStart(2,"0"),":").concat(a.toString().padStart(2,"0")).concat(i);e.push({hours:t,minutes:a,display:r})}return e},[U,Q,Wt,Et]),zt=function(e){if(!e.trim())return null;for(var t=0,a=["".concat(Z," ").concat(ee),"".concat(Z," ").concat(ee.replace(":ss","")),"yyyy-MM-dd HH:mm:ss","yyyy-MM-dd HH:mm","yyyy-MM-dd'T'HH:mm:ss","yyyy-MM-dd'T'HH:mm","MM/dd/yyyy HH:mm","MM/dd/yyyy hh:mm a","MM-dd-yyyy HH:mm","MM-dd-yyyy hh:mm a","dd/MM/yyyy HH:mm","dd/MM/yyyy hh:mm a","dd-MM-yyyy HH:mm","dd-MM-yyyy hh:mm a","yyyy-MM-dd","MM/dd/yyyy","dd/MM/yyyy","MM-dd-yyyy","dd-MM-yyyy"];t<a.length;t++){var n=a[t];try{var i=x(e,n,new Date);if(H(i))return i}catch(e){}}try{var r=new Date(e);if(H(r))return r}catch(e){}return null},Rt=function(){var e=new Date,t="date"===_e?p(e):e;Ie(t),ot(t),null==P||P(Pt(t)),Ue(null)},Qt=function(){Ie(null),ct("00"),ft("00"),gt("00"),_t("AM"),null==P||P(""),Ue(null)},Vt=function(e,n){var i=t(t({},at),{},a({},e,n));nt(i);var r=i.year,d=i.month,o=i.day,l=i.hour,u=i.minute,s=i.second,c=i.ampm;if(r&&d&&o&&l&&u)try{var m=parseInt(l);Q&&("PM"===c&&12!==m&&(m+=12),"AM"===c&&12===m&&(m=0));var h=new Date(parseInt(r),parseInt(d)-1,parseInt(o),m,parseInt(u),G?parseInt(s||"0"):0);if(H(h)){var f="date"===_e?p(h):h;Ie(f),null==P||P(Pt(f)),Ue(null)}}catch(e){}},Gt=function(e,t,a,n){if(e.target.value.length>=a&&n&&/\d/.test(e.key)){e.preventDefault();var i=xt.current[n];i&&(i.focus(),i.select())}};return s(function(){Ce&&Ne&&nt({year:Ce.getFullYear().toString(),month:(Ce.getMonth()+1).toString().padStart(2,"0"),day:Ce.getDate().toString().padStart(2,"0"),hour:Q?(Ce.getHours()%12||12).toString().padStart(2,"0"):Ce.getHours().toString().padStart(2,"0"),minute:Ce.getMinutes().toString().padStart(2,"0"),second:Ce.getSeconds().toString().padStart(2,"0"),ampm:Ce.getHours()>=12?"PM":"AM"})},[Ce,Ne,Q]),n("div",{className:"ihub-datetime-picker-wrapper ".concat(ie),style:{maxWidth:we},children:[n("div",{className:"ihub-datetime-picker ".concat(Je?"ihub-error":""),children:[n("label",{className:"ihub-datetime-label",htmlFor:de||re,children:[A,F&&i("span",{className:"ihub-required",children:"*"})]}),n("div",Ne?{ref:Dt,className:"ihub-datetime-separate-fields",children:[("date"===_e||"datetime"===_e)&&n("div",{className:"ihub-datetime-date-fields",children:[i("input",{ref:function(e){xt.current.year=e},type:"text",className:"ihub-datetime-field ihub-datetime-year",value:at.year,onChange:function(e){return Vt("year",e.target.value.replace(/\D/g,"").slice(0,4))},onKeyDown:function(e){return Gt(e,0,4,"month")},placeholder:"YYYY",maxLength:4,disabled:le,id:"".concat(de,"-year"),"aria-label":"Year"}),i("span",{className:"ihub-datetime-separator",children:"/"}),i("input",{ref:function(e){xt.current.month=e},type:"text",className:"ihub-datetime-field ihub-datetime-month",value:at.month,onChange:function(e){var t=e.target.value.replace(/\D/g,"").slice(0,2);(parseInt(t)<=12||""===t)&&Vt("month",t)},onKeyDown:function(e){return Gt(e,0,2,"day")},placeholder:"MM",maxLength:2,disabled:le,id:"".concat(de,"-month"),"aria-label":"Month"}),i("span",{className:"ihub-datetime-separator",children:"/"}),i("input",{ref:function(e){xt.current.day=e},type:"text",className:"ihub-datetime-field ihub-datetime-day",value:at.day,onChange:function(e){var t=e.target.value.replace(/\D/g,"").slice(0,2);(parseInt(t)<=31||""===t)&&Vt("day",t)},onKeyDown:function(e){return Gt(e,0,2,"hour")},placeholder:"DD",maxLength:2,disabled:le,id:"".concat(de,"-day"),"aria-label":"Day"})]}),("time"===_e||"datetime"===_e)&&n("div",{className:"ihub-datetime-time-fields",children:[i("input",{ref:function(e){xt.current.hour=e},type:"text",className:"ihub-datetime-field ihub-datetime-hour",value:at.hour,onChange:function(e){var t=e.target.value.replace(/\D/g,"").slice(0,2),a=Q?12:23;(parseInt(t)<=a||""===t)&&Vt("hour",t)},onKeyDown:function(e){return Gt(e,0,2,"minute")},placeholder:"HH",maxLength:2,disabled:le,id:"".concat(de,"-hour"),"aria-label":"Hour"}),i("span",{className:"ihub-datetime-separator",children:":"}),i("input",{ref:function(e){xt.current.minute=e},type:"text",className:"ihub-datetime-field ihub-datetime-minute",value:at.minute,onChange:function(e){var t=e.target.value.replace(/\D/g,"").slice(0,2);(parseInt(t)<60||""===t)&&Vt("minute",t)},onKeyDown:function(e){return Gt(e,0,2,G?"second":void 0)},placeholder:"MM",maxLength:2,disabled:le,id:"".concat(de,"-minute"),"aria-label":"Minute"}),G&&n(r,{children:[i("span",{className:"ihub-datetime-separator",children:":"}),i("input",{ref:function(e){xt.current.second=e},type:"text",className:"ihub-datetime-field ihub-datetime-second",value:at.second,onChange:function(e){var t=e.target.value.replace(/\D/g,"").slice(0,2);(parseInt(t)<60||""===t)&&Vt("second",t)},placeholder:"SS",maxLength:2,disabled:le,id:"".concat(de,"-second"),"aria-label":"Second"})]}),Q&&i("button",{type:"button",className:"ihub-datetime-field ihub-datetime-ampm-toggle",onClick:function(){return Vt("ampm","AM"===at.ampm?"PM":"AM")},disabled:le,"aria-label":"Toggle AM/PM, currently ".concat(at.ampm),children:at.ampm})]}),n("div",{className:"ihub-datetime-icons",children:[se&&("date"===_e||"datetime"===_e)&&i("button",{type:"button",className:"ihub-datetime-icon-btn",onClick:function(){le||(Ke(!0),Qe("calendar"))},disabled:le,"aria-label":"Open calendar",children:i(d,{})}),me&&("time"===_e||"datetime"===_e)&&i("button",{type:"button",className:"ihub-datetime-icon-btn",onClick:function(){le||(Ke(!0),Qe("time"))},disabled:le,"aria-label":"Open time picker",children:i(o,{})})]})]}:{ref:kt,className:"ihub-datetime-input-container",children:[i("input",{ref:wt,type:"text",className:"ihub-datetime-input",value:Oe?je:Lt(),onChange:function(e){var t=e.target,a=t.value;t.selectionStart;var n=function(e){var t=G?"".concat(Z," ").concat(ee):"".concat(Z," ").concat(ee.replace(":ss","")),a=e.replace(/\D/g,""),n={"yyyy-MM-dd HH:mm:ss":[4,2,2,2,2,2],"yyyy-MM-dd HH:mm":[4,2,2,2,2],"MM/dd/yyyy HH:mm":[2,2,4,2,2],"MM/dd/yyyy hh:mm a":[2,2,4,2,2],"dd/MM/yyyy HH:mm":[2,2,4,2,2],"dd/MM/yyyy hh:mm a":[2,2,4,2,2]}[t];n||(n=[4,2,2,2,2]);for(var i=t.replace(/[yMdHhms]/g,"").split("").filter(function(e){return e.trim()}),r="",d=0,o=0,l=0;l<n.length;l++){var u=n[l],s=a.slice(d,d+u);s&&(r+=s,d+=u,l<n.length-1&&d<a.length&&o<i.length&&(r+=i[o]),o++)}return{formatted:r,cursorPos:r.length}}(a),i=n.formatted,r=n.cursorPos;if(Pe(i),$e(r),setTimeout(function(){t&&t.setSelectionRange&&t.setSelectionRange(r,r)},0),!i.trim())return Ie(null),null==P||P(""),void Ue(null);var d=zt(i);if(d){var o="date"===_e?p(d):d;Ie(o),null==P||P(Pt(o)),Ue(null)}},onFocus:function(e){Ee(!0),Ce&&!je&&Pe(Lt()),null==ve||ve(e)},onBlur:function(e){if(Ee(!1),je.trim()){var t=zt(je);if(t){var a="date"===_e?p(t):t;Ie(a),null==P||P(Pt(a)),Pe(Lt(a)),Ue(null)}else Ue("Invalid date/time format")}else Ue(F?"Date and time are required":null);Yt(),null==ge||ge(e)},onKeyDown:function(e){"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),Ke(!qe)),"Escape"===e.key&&Ke(!1),"Tab"===e.key&&qe&&e.stopPropagation()},placeholder:Oe?function(e){for(var t=("date"===_e?Z:"time"===_e?G?ee:ee.replace(":ss",""):G?"".concat(Z," ").concat(ee):"".concat(Z," ").concat(ee.replace(":ss",""))).replace(/yyyy/g,"____").replace(/yy/g,"__").replace(/MM/g,"__").replace(/dd/g,"__").replace(/HH/g,"__").replace(/hh/g,"__").replace(/mm/g,"__").replace(/ss/g,"__").replace(/a/g,"__"),a="",n=0,i=0;i<t.length&&n<e.length;i++){var r=t[i],d=e[n];"_"===r?d&&/[^\d]/.test(d)&&i+1<t.length&&/[^_]/.test(t[i+1])?(a+=t[i+1],n++,i++):d&&/\d/.test(d)?(a+=d,n++):a+="_":(a+=r,d===r&&n++)}return a.length<t.length&&(a+=t.slice(a.length)),a}(je):"date"===_e?te||Z:"time"===_e?te||ee:te||"".concat(Z," ").concat(ee),disabled:le,required:F,name:re,id:de,"aria-label":fe||A,"aria-invalid":!!Je,"aria-describedby":Je?"".concat(de,"-error"):void 0,autoFocus:be}),n("div",{className:"ihub-datetime-icons",children:[se&&("date"===_e||"datetime"===_e)&&i("button",{type:"button",className:"ihub-datetime-icon-btn",onClick:function(){le||(Ke(!0),Qe("calendar"))},disabled:le,"aria-label":"Open calendar",children:i(d,{})}),me&&("time"===_e||"datetime"===_e)&&i("button",{type:"button",className:"ihub-datetime-icon-btn",onClick:function(){le||(Ke(!0),Qe("time"))},disabled:le,"aria-label":"Open time picker",children:i(o,{})})]})]}),Je&&i("div",{id:"".concat(de,"-error"),className:"ihub-datetime-error",children:Je}),qe&&!le&&"undefined"!=typeof document&&h(n("div",{ref:St,className:"ihub-datetime-picker-dropdown",style:At,role:"dialog","aria-label":"Date and time picker",onMouseDown:function(e){return e.stopPropagation()},children:["datetime"===_e&&n("div",{className:"ihub-datetime-tabs",children:[i("button",{className:"ihub-datetime-tab ".concat("calendar"===Re?"active":""),onClick:function(){return Qe("calendar")},type:"button",children:"Date"}),i("button",{className:"ihub-datetime-tab ".concat("time"===Re?"active":""),onClick:function(){return Qe("time")},type:"button",children:"Time"})]}),("calendar"===Re||"date"===_e)&&("date"===_e||"datetime"===_e)&&n("div",{className:"ihub-datetime-calendar",children:[n("div",{className:"ihub-datetime-month-nav",children:[i("button",{type:"button",onClick:function(){ot(D(dt,1))},className:"ihub-datetime-nav-btn","aria-label":"Previous month",children:"‹"}),i("span",{className:"ihub-datetime-month-year",children:C(dt,"MMMM yyyy")}),i("button",{type:"button",onClick:function(){ot(k(dt,1))},className:"ihub-datetime-nav-btn","aria-label":"Next month",children:"›"})]}),i("div",{className:"ihub-datetime-weekdays",children:["Su","Mo","Tu","We","Th","Fr","Sa"].map(function(e){return i("div",{className:"ihub-datetime-weekday",children:e},e)})}),i("div",{className:"ihub-datetime-days",children:Kt.map(function(e,t){if(!e)return i("div",{className:"ihub-datetime-day-empty"},"empty-".concat(t));var a=!!Ce&&N(e,Ce),n=N(e,new Date),r=Ft(e)||!Ot(e);return i("button",{type:"button",className:"ihub-datetime-day ".concat(a?"selected":""," ").concat(n?"today":""," ").concat(r?"disabled":""),onClick:function(){return qt(e)},disabled:r,"aria-label":C(e,"MMMM d, yyyy"),"aria-selected":!!a||void 0,children:e.getDate()},e.getTime())})})]}),("time"===Re||"time"===_e)&&("time"===_e||"datetime"===_e)&&n("div",{className:"ihub-datetime-time",children:[n("div",{className:"ihub-datetime-time-inputs",children:[n("div",{className:"ihub-datetime-time-group",children:[i("label",{children:"Hours"}),i("input",{type:"text",className:"ihub-datetime-time-input",value:Q?(parseInt(st)%12||12).toString().padStart(2,"0"):st,onChange:function(e){var t=e.target.value.replace(/\D/g,"");(Q&&parseInt(t)<=12||!Q&&parseInt(t)<24)&&ct(t)},maxLength:2,placeholder:"HH"})]}),i("span",{className:"ihub-datetime-time-separator",children:":"}),n("div",{className:"ihub-datetime-time-group",children:[i("label",{children:"Minutes"}),i("input",{type:"text",className:"ihub-datetime-time-input",value:pt,onChange:function(e){var t=e.target.value.replace(/\D/g,"");parseInt(t)<60&&ft(t)},maxLength:2,placeholder:"MM"})]}),G&&n(r,{children:[i("span",{className:"ihub-datetime-time-separator",children:":"}),n("div",{className:"ihub-datetime-time-group",children:[i("label",{children:"Seconds"}),i("input",{type:"text",className:"ihub-datetime-time-input",value:vt,onChange:function(e){var t=e.target.value.replace(/\D/g,"");parseInt(t)<60&&gt(t)},maxLength:2,placeholder:"SS"})]})]}),Q&&n("div",{className:"ihub-datetime-ampm",children:[i("button",{type:"button",className:"ihub-datetime-ampm-btn ".concat("AM"===Ht?"active":""),onClick:function(){return _t("AM")},children:"AM"}),i("button",{type:"button",className:"ihub-datetime-ampm-btn ".concat("PM"===Ht?"active":""),onClick:function(){return _t("PM")},children:"PM"})]})]}),n("div",{className:"ihub-datetime-time-list",children:[i("div",{className:"ihub-datetime-time-list-header",children:"Quick select:"}),i("div",{className:"ihub-datetime-time-options",children:Bt.map(function(e,t){var a=Ce&&Ce.getHours()===e.hours&&Ce.getMinutes()===e.minutes;return i("button",{type:"button",className:"ihub-datetime-time-option ".concat(a?"selected":""),onClick:function(){ct(e.hours.toString().padStart(2,"0")),ft(e.minutes.toString().padStart(2,"0")),Q&&_t(e.hours>=12?"PM":"AM")},children:e.display},t)})})]}),i("div",{className:"ihub-datetime-time-actions",children:i("button",{type:"button",className:"ihub-datetime-apply-btn",onClick:function(){var e=Ce;if(!e){if("time"!==_e){var t=new Date;return void qt(t)}e=new Date}var a=parseInt(st),n=parseInt(pt),i=G?parseInt(vt):0;if(Q&&("PM"===Ht&&12!==a?a+=12:"AM"===Ht&&12===a&&(a=0)),!Wt(a,n)&&Et(a,n)){var r=_(e,a);r=S(r,n),r=w(r,i),Ie(r),null==P||P(Pt(r)),Ke(!1),Ue(null)}else Ue("Selected time is not available")},children:"Apply Time"})})]}),pe&&n("div",{className:"ihub-datetime-actions",children:[i("button",{type:"button",className:"ihub-datetime-action-btn",onClick:Rt,children:"Now"}),i("button",{type:"button",className:"ihub-datetime-action-btn",onClick:Qt,children:"Clear"})]})]}),document.body)]}),pe&&!le&&!qe&&n("div",{className:"ihub-datetime-quick-links",children:[i("button",{type:"button",className:"ihub-datetime-link",onClick:Rt,children:"Now"}),i("span",{className:"ihub-datetime-separator",children:"|"}),i("button",{type:"button",className:"ihub-datetime-link",onClick:Qt,children:"Clear"})]}),re&&i("input",{type:"hidden",name:re,value:Ce?Pt(Ce):""})]})};export{I as default};
2
2
  //# sourceMappingURL=DateTimePicker.js.map
@@ -1,2 +1,2 @@
1
- import{slicedToArray as e,typeof as t}from"../../../_virtual/_rollupPluginBabelHelpers.js";import{jsxs as a,Fragment as i,jsx as l}from"react/jsx-runtime";import{useState as r,useEffect as s}from"react";import n from"@mui/icons-material/ExpandMore";import{setCookie as o}from"../lib/helpFunction.js";import u from"../ui/viewer/ContentViewer.js";var d=function(d){var c=r(!1),m=e(c,2),p=m[0],f=m[1],h=r("Choose..."),b=e(h,2),v=b[0],_=b[1],N=r([]),V=e(N,2),y=V[0],C=V[1],j=r(""),x=e(j,2),k=x[0],w=x[1];s(function(){var e=[];for(var t in d.options)d.options[t].id===d.defaultValue&&(_(d.options[t].title),w(d.options[t].id)),e.push(d.options[t]);C(e)},[d.options,d.defaultValue]),s(function(){var e;if("object"===t(d.defaultValue)&&null!==(e=d.defaultValue)&&void 0!==e&&e.id)_(d.defaultValue.title),w(d.defaultValue.id);else if(d.defaultValue){var a=d.options.find(function(e){return e.id===d.defaultValue});null!=a&&a.id&&(_(a.title),w(a.id))}else _("Choose..."),w("")},[d.defaultValue,d.options]);return a(i,{children:[a("div",{className:"ihub-select ".concat(d.err?"ihub-form-err":""),style:{width:d.defaultWidth||"300px"},children:[a("div",{className:"ihub-select__btn",onClick:function(){return 0!==d.status&&f(!p)},children:[a("div",{className:0===d.status?"disabled":"",children:[l("input",{type:"text",className:"ihub-select__input",value:d.upperCases?String(k).toUpperCase():k||"",id:"id_"+d.name,name:d.name,required:d.required,"data-name":d.dataName||d.name,readOnly:!0}),l(u,{content:v||"...",showToolbar:!1})]}),d.label&&l("label",{className:"ihub-select__label",children:d.label}),l("div",{className:"search_btn",children:0===d.status?l("div",{className:"ihub-select__loader"}):l(n,{})})]}),p&&l("div",{className:"ihub-select__content",children:y.map(function(e,t){return l("div",{className:"ihub-select__item",onClick:function(){return function(e,t){_(t),w(e.id),f(!1),d.setValue&&d.setValue(e),d.setNameValue&&d.setNameValue(d.name,e),d.setObjects&&d.setObjects(e),d.setArrayProps&&d.setArrayProps(d.arrayProps||[],e),d.setCookies&&o(d.setCookies,JSON.stringify(e),365)}(e,e.title)},children:e.title},t)})})]}),d.note&&l("p",{className:"ihub-input-notes",children:d.note}),d.error&&l("span",{className:"ihub-error-text",children:d.error})]})};export{d as default};
1
+ import{slicedToArray as e,typeof as t}from"../../../_virtual/_rollupPluginBabelHelpers.js";import{jsxs as a,Fragment as i,jsx as l}from"react/jsx-runtime";import{useState as s,useEffect as r}from"react";import n from"@mui/icons-material/ExpandMore";import{setCookie as o}from"../lib/helpFunction.js";import u from"../ui/viewer/ContentViewer.js";var c=function(c){var d=s(!1),m=e(d,2),p=m[0],f=m[1],h=s("Choose..."),b=e(h,2),v=b[0],N=b[1],_=s([]),V=e(_,2),y=V[0],C=V[1],j=s(""),x=e(j,2),k=x[0],w=x[1];r(function(){var e=[];for(var t in c.options)c.options[t].id===c.defaultValue&&(N(c.options[t].title),w(c.options[t].id)),e.push(c.options[t]);C(e)},[c.options,c.defaultValue]),r(function(){var e;if("object"===t(c.defaultValue)&&null!==(e=c.defaultValue)&&void 0!==e&&e.id)N(c.defaultValue.title),w(c.defaultValue.id);else if(c.defaultValue){var a=c.options.find(function(e){return e.id===c.defaultValue});null!=a&&a.id&&(N(a.title),w(a.id))}else N("Choose..."),w("")},[c.defaultValue,c.options]);return a(i,{children:[a("div",{className:"ihub-select ".concat(c.err?"ihub-form-err":"").concat(c.className?" ".concat(c.className):""),style:{width:c.defaultWidth||"300px"},children:[a("div",{className:"ihub-select__btn",onClick:function(){return 0!==c.status&&f(!p)},children:[a("div",{className:0===c.status?"disabled":"",children:[l("input",{type:"text",className:"ihub-select__input",value:c.upperCases?String(k).toUpperCase():k||"",id:"id_"+c.name,name:c.name,required:c.required,"data-name":c.dataName||c.name,readOnly:!0}),l(u,{content:v||"...",showToolbar:!1})]}),c.label&&l("label",{className:"ihub-select__label",children:c.label}),l("div",{className:"search_btn",children:0===c.status?l("div",{className:"ihub-select__loader"}):l(n,{})})]}),p&&l("div",{className:"ihub-select__content",children:y.map(function(e,t){return l("div",{className:"ihub-select__item",onClick:function(){return function(e,t){N(t),w(e.id),f(!1),c.setValue&&c.setValue(e),c.setNameValue&&c.setNameValue(c.name,e),c.setObjects&&c.setObjects(e),c.setArrayProps&&c.setArrayProps(c.arrayProps||[],e),c.setCookies&&o(c.setCookies,JSON.stringify(e),365)}(e,e.title)},children:e.title},t)})})]}),c.note&&l("p",{className:"ihub-input-notes",children:c.note}),c.error&&l("span",{className:"ihub-error-text",children:c.error})]})};export{c as default};
2
2
  //# sourceMappingURL=FilterObjects.js.map
@@ -1,2 +1,2 @@
1
- import{slicedToArray as e,asyncToGenerator as n,regenerator as r,toConsumableArray as a,typeof as i,createForOfIteratorHelper as l}from"../../../_virtual/_rollupPluginBabelHelpers.js";import{jsx as t,jsxs as c}from"react/jsx-runtime";import{memo as o,useState as s,useEffect as u,useCallback as d}from"react";import{reqOptions as h,API_HOST_URL as m}from"../lib/helpFunction.js";import"../lib/utils.js";import f from"@mui/icons-material/SearchOutlined";import v from"@mui/icons-material/Check";import p from"@mui/icons-material/CloseOutlined";var b=function(e){if(!e||!Array.isArray(e))return[];var n,r=[],t=l(e);try{for(t.s();!(n=t.n()).done;){var c=n.value;Array.isArray(c)?r.push.apply(r,a(b(c))):c&&"object"===i(c)&&c.id&&r.push(c)}}catch(e){t.e(e)}finally{t.f()}var o=r.filter(function(e,n,r){return r.findIndex(function(n){return n.id===e.id})===n});return o};function y(l){var o=l.label,y=l.token,N=l.handle,g=l.selected,k=l.setSelected,S=l.appLabel,j=l.modelName,C=l.filterChannel,O=void 0!==C&&C,_=l.limitQuery,x=void 0===_?5:_,D=l.limitSelect,w=void 0===D?0:D,F=l.options,T=l.keyName,A=void 0===T?"title":T,E=l.placeholder,B=void 0===E?"Search by Username or Email":E,I=l.searchUrl,q=l.err,H=void 0!==q&&q,P=l.required,U=void 0!==P&&P,G=s(""),J=e(G,2),K=J[0],L=J[1],Q=s([]),R=e(Q,2),z=R[0],M=R[1],V=s(!1),W=e(V,2),X=W[0],Y=W[1],Z=s(null),$=e(Z,2),ee=$[0],ne=$[1];u(function(){M(F||[])},[F]),u(function(){if(g&&g.length>0){var e=b(g);JSON.stringify(e)!==JSON.stringify(g)&&console.warn("SearchObjectsFromDB: Detected malformed selected array. Parent should provide flattened data:",{original:g,expectedFormat:e,keyName:A})}console.log("SearchObjectsFromDB Debug:",{keyName:A,selectedLength:(null==g?void 0:g.length)||0,selectedSample:null==g?void 0:g[0],label:o})},[g,A,o]);var re,ae=d(n(r().m(function e(){var n,i,l,t,c,o;return r().w(function(e){for(;;)switch(e.p=e.n){case 0:return Y(!0),ne(null),n=h("GET",null,y),i=I?I.includes("/?")?"".concat(I,"&search=").concat(K):"".concat(I,"?search=").concat(K):S?"".concat(m,"channels/").concat(N,"/dynamic-search/?app_label=").concat(S,"&model_name=").concat(j,"&value=").concat(K,"&filter_channel=").concat(O):"".concat(m,"auth/").concat(N,"/search-user/").concat(K,"/?limit=").concat(x),e.p=1,e.n=2,fetch(i,n);case 2:if((l=e.v).ok){e.n=3;break}throw new Error("HTTP error ".concat(l.status));case 3:return e.n=4,l.json();case 4:t=e.v,M([].concat(a(t.results||[]),a(F||[]))),e.n=6;break;case 5:e.p=5,o=e.v,c=o instanceof Error?o.message:"Unknown error occurred",console.error("Error fetching search results:",c),ne(c),M(a(F||[]));case 6:return e.p=6,Y(!1),e.f(6);case 7:return e.a(2)}},e,null,[[1,5,6,7]])})),[K,y,I,S,j,N,O,x]),ie=d(function(e){"Enter"===e.key&&(e.preventDefault(),ae())},[ae]),le=d(function(){L(""),M(a(F||[])),ne(null)},[]),te=d(function(e){return!(!e||!g||0===g.length)&&b(g).some(function(n){if(!n)return!1;var r="object"===i(n)?null==n?void 0:n.id:n,a=(null==e?void 0:e.username)||(null==e?void 0:e.id);return r===a&&null!=r&&null!=a})},[g]),ce=d(function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(e&&e.id&&g){var r=b(g),i=r.find(function(n){return(null==n?void 0:n.id)===e.id});if(n){var l=r.filter(function(n){return(null==n?void 0:n.id)!==e.id});k(l)}else!i&&(0===w||r.length<w)?k([].concat(a(r),[e])):1===w&&k([e])}},[g,k,w]);return t("div",{className:"ihub-react-search-container",children:c("div",{className:"ihub-react-search card",children:[o&&c("h4",{className:"ihub-fs-sm ihub-mt-2 ihub-mb-2",children:[o," ",U&&t("span",{className:"ihub-required",children:"*"})]}),c("div",{className:"ihub-search-input",children:[t("input",{type:"text",placeholder:B,onKeyDown:ie,value:K,onChange:function(e){return L(e.target.value)},disabled:X,required:U&&!g.length}),c("div",{className:"ihub-search-icons",children:[K&&t(p,{onClick:le,className:"ihub-search-icon ihub-close-icon"}),t(f,{onClick:ae,className:"ihub-search-icon ihub-search-button ".concat(X?"ihub-disabled":"")})]})]}),X&&t("div",{className:"ihub-loading",children:"Searching..."}),ee&&t("div",{className:"ihub-search-error",children:ee}),c("ul",{className:"ihub-search-results",children:[null==z?void 0:z.map(function(e,n){return c("li",{className:"ihub-search-result-item ihub-valid",onClick:function(){return e&&ce(e)},children:[te(e)&&t(v,{className:"ihub-check-icon",style:{position:"relative",top:"5px",marginRight:"10px"}}),e[A]||(null==e?void 0:e.title)||"",te(e)?t(p,{className:"ihub-delete-icon ihub-ml-auto",onClick:function(){return e&&ce(e,!0)}}):""]},"".concat((null==e?void 0:e.id)||(null==e?void 0:e.username)||n))}),X||ee||z.length||g.length?"":t("li",{className:"ihub-no-results",children:"No available options"})]}),(re=b(g||[]),0===re.length?null:c("ul",{className:"ihub-selected-options",children:[t("h4",{className:"ihub-fs-md",children:"Selected Options:"}),re.map(function(e,n){if(!e||"object"!==i(e))return console.warn("SearchObjectsFromDB: Invalid item in selected array:",e),null;var r=e,a=r[A]||r.title||r.name||r.full_name||r.name_plus_username||r.display_name||r.username||"Item ".concat(n+1),l=e.id||r.username||"selected-".concat(n);return a&&a!=="Item ".concat(n+1)||console.log("SearchObjectsFromDB: Display text debug:",{item:e,keyName:A,itemKeyName:r[A],title:r.title,name:r.name,fullName:r.full_name,displayText:a}),c("li",{children:[t("span",{children:a}),t(p,{className:"ihub-delete-icon",onClick:function(){return ce(e,!0)}})]},l)})]})),H&&t("p",{className:"ihub-error",children:"This field is required"})]})})}var N=o(y);export{N as default};
1
+ import{slicedToArray as e,asyncToGenerator as r,regenerator as n,toConsumableArray as a,typeof as i,createForOfIteratorHelper as t}from"../../../_virtual/_rollupPluginBabelHelpers.js";import{jsx as c,jsxs as l}from"react/jsx-runtime";import{memo as o,useState as s,useEffect as u,useCallback as d}from"react";import{reqOptions as h,API_HOST_URL as m}from"../lib/helpFunction.js";import"../lib/utils.js";import f from"@mui/icons-material/SearchOutlined";import v from"@mui/icons-material/Check";import p from"@mui/icons-material/CloseOutlined";var b=function(e){if(!e||!Array.isArray(e))return[];var r,n=[],c=t(e);try{for(c.s();!(r=c.n()).done;){var l=r.value;Array.isArray(l)?n.push.apply(n,a(b(l))):l&&"object"===i(l)&&l.id&&n.push(l)}}catch(e){c.e(e)}finally{c.f()}var o=n.filter(function(e,r,n){return n.findIndex(function(r){return r.id===e.id})===r});return o};function y(t){var o=t.label,y=t.token,g=t.handle,N=t.selected,k=t.setSelected,j=t.appLabel,S=t.modelName,w=t.filterChannel,O=void 0!==w&&w,C=t.limitQuery,D=void 0===C?5:C,E=t.limitSelect,T=void 0===E?0:E,_=t.options,x=t.keyName,F=void 0===x?"title":x,A=t.placeholder,B=void 0===A?"Search by Username or Email":A,I=t.searchUrl,U=t.err,q=void 0!==U&&U,H=t.required,P=void 0!==H&&H,G=t.defaultUrl,J=s(""),K=e(J,2),L=K[0],Q=K[1],R=s([]),z=e(R,2),M=z[0],V=z[1],W=s(!1),X=e(W,2),Y=X[0],Z=X[1],$=s(null),ee=e($,2),re=ee[0],ne=ee[1];u(function(){G||V(_||[])},[_,G]);var ae=d(r(n().m(function e(){var r,a,i,t,c;return n().w(function(e){for(;;)switch(e.p=e.n){case 0:if(G){e.n=1;break}return e.a(2);case 1:return Z(!0),ne(null),e.p=2,r=h("GET",null,y),e.n=3,fetch(G,r);case 3:if((a=e.v).ok){e.n=4;break}throw new Error("HTTP error ".concat(a.status));case 4:return e.n=5,a.json();case 5:i=e.v,V(i.results||i||[]),e.n=7;break;case 6:e.p=6,c=e.v,t=c instanceof Error?c.message:"Unknown error",console.error("SearchObjectsFromDB: Error fetching default data:",t),V(_||[]);case 7:return e.p=7,Z(!1),e.f(7);case 8:return e.a(2)}},e,null,[[2,6,7,8]])})),[G,y,_]);u(function(){G&&ae()},[G,ae]),u(function(){if(N&&N.length>0){var e=b(N);JSON.stringify(e)!==JSON.stringify(N)&&console.warn("SearchObjectsFromDB: Detected malformed selected array. Parent should provide flattened data:",{original:N,expectedFormat:e,keyName:F})}console.log("SearchObjectsFromDB Debug:",{keyName:F,selectedLength:(null==N?void 0:N.length)||0,selectedSample:null==N?void 0:N[0],label:o})},[N,F,o]);var ie,te=d(r(n().m(function e(){var r,i,t,c,l,o,s;return n().w(function(e){for(;;)switch(e.p=e.n){case 0:return Z(!0),ne(null),r=h("GET",null,y),i=I?I.includes("/?")?"".concat(I,"&search=").concat(L):"".concat(I,"?search=").concat(L):j?"".concat(m,"channels/").concat(g,"/dynamic-search/?app_label=").concat(j,"&model_name=").concat(S,"&value=").concat(L,"&filter_channel=").concat(O):"".concat(m,"auth/").concat(g,"/search-user/").concat(L,"/?limit=").concat(D),e.p=1,e.n=2,fetch(i,r);case 2:if((t=e.v).ok){e.n=3;break}throw new Error("HTTP error ".concat(t.status));case 3:return e.n=4,t.json();case 4:c=e.v,l=c.results||[],V(G?l:[].concat(a(l),a(_||[]))),e.n=6;break;case 5:e.p=5,s=e.v,o=s instanceof Error?s.message:"Unknown error occurred",console.error("Error fetching search results:",o),ne(o),V(G?[]:a(_||[]));case 6:return e.p=6,Z(!1),e.f(6);case 7:return e.a(2)}},e,null,[[1,5,6,7]])})),[L,y,I,j,S,g,O,D,G,_]),ce=d(function(e){"Enter"===e.key&&(e.preventDefault(),te())},[te]),le=d(function(){Q(""),ne(null),G?ae():V(a(_||[]))},[G,ae,_]),oe=d(function(e){return!(!e||!N||0===N.length)&&b(N).some(function(r){if(!r)return!1;var n="object"===i(r)?null==r?void 0:r.id:r,a=(null==e?void 0:e.username)||(null==e?void 0:e.id);return n===a&&null!=n&&null!=a})},[N]),se=d(function(e){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(e&&e.id&&N){var n=b(N),i=n.find(function(r){return(null==r?void 0:r.id)===e.id});if(r){var t=n.filter(function(r){return(null==r?void 0:r.id)!==e.id});k(t)}else!i&&(0===T||n.length<T)?k([].concat(a(n),[e])):1===T&&k([e])}},[N,k,T]);return c("div",{className:"ihub-react-search-container",children:l("div",{className:"ihub-react-search card",children:[o&&l("h4",{className:"ihub-fs-sm ihub-mt-2 ihub-mb-2",children:[o," ",P&&c("span",{className:"ihub-required",children:"*"})]}),l("div",{className:"ihub-search-input",children:[c("input",{type:"text",placeholder:B,onKeyDown:ce,value:L,onChange:function(e){return Q(e.target.value)},disabled:Y,required:P&&!N.length}),l("div",{className:"ihub-search-icons",children:[L&&c(p,{onClick:le,className:"ihub-search-icon ihub-close-icon"}),c(f,{onClick:te,className:"ihub-search-icon ihub-search-button ".concat(Y?"ihub-disabled":"")})]})]}),Y&&c("div",{className:"ihub-loading",children:"Searching..."}),re&&c("div",{className:"ihub-search-error",children:re}),l("ul",{className:"ihub-search-results",children:[null==M?void 0:M.map(function(e,r){return l("li",{className:"ihub-search-result-item ihub-valid",onClick:function(){return e&&se(e)},children:[oe(e)&&c(v,{className:"ihub-check-icon",style:{position:"relative",top:"5px",marginRight:"10px"}}),e[F]||(null==e?void 0:e.title)||"",oe(e)?c(p,{className:"ihub-delete-icon ihub-ml-auto",onClick:function(){return e&&se(e,!0)}}):""]},"".concat((null==e?void 0:e.id)||(null==e?void 0:e.username)||r))}),Y||re||M.length||N.length?"":c("li",{className:"ihub-no-results",children:"No available options"})]}),(ie=b(N||[]),0===ie.length?null:l("ul",{className:"ihub-selected-options",children:[c("h4",{className:"ihub-fs-md",children:"Selected Options:"}),ie.map(function(e,r){if(!e||"object"!==i(e))return console.warn("SearchObjectsFromDB: Invalid item in selected array:",e),null;var n=e,a=n[F]||n.title||n.name||n.full_name||n.name_plus_username||n.display_name||n.username||"Item ".concat(r+1),t=e.id||n.username||"selected-".concat(r);return a&&a!=="Item ".concat(r+1)||console.log("SearchObjectsFromDB: Display text debug:",{item:e,keyName:F,itemKeyName:n[F],title:n.title,name:n.name,fullName:n.full_name,displayText:a}),l("li",{children:[c("span",{children:a}),c(p,{className:"ihub-delete-icon",onClick:function(){return se(e,!0)}})]},t)})]})),q&&c("p",{className:"ihub-error",children:"This field is required"})]})})}var g=o(y);export{g as default};
2
2
  //# sourceMappingURL=SearchObjectsFromDB.js.map
@@ -18,6 +18,7 @@ interface FilterObjectsProps {
18
18
  status?: number;
19
19
  upperCases?: boolean;
20
20
  error?: string;
21
+ className?: string;
21
22
  }
22
23
  /**
23
24
  * FilterOnject dropdown
@@ -40,6 +41,13 @@ interface FilterObjectsProps {
40
41
  * arrayProps={arrayProps}
41
42
  * dataName="filterObjects"
42
43
  * setCookies="filterObjects" // Optional
44
+ * className="custom-class" // Optional
45
+ * defaultWidth="400px" // Optional
46
+ * required // Optional
47
+ * err={hasError} // Optional
48
+ * upperCases // Optional
49
+ * status={isLoading ? 0 : 1} // Optional: 0 for loading/disabled, 1 for active
50
+ * error={errorMessage} // Optional: error message to display
43
51
  * />
44
52
  * ```
45
53
  * Props interface for the FilterObjects component
@@ -17,6 +17,8 @@ interface SearchObjectsFromDBProps<T extends SearchObjectItemType = SearchObject
17
17
  selected: T[];
18
18
  err?: boolean;
19
19
  required?: boolean;
20
+ /** URL to fetch the initial default display list on mount and after search is cleared */
21
+ defaultUrl?: string;
20
22
  }
21
23
  /**
22
24
  * Component for searching objects from a database with filtering capabilities
@@ -46,7 +48,9 @@ interface SearchObjectsFromDBProps<T extends SearchObjectItemType = SearchObject
46
48
  * @param {string} props.searchUrl - The search url for the API request
47
49
  * @param {T[]} props.selected - The selected for the API request
48
50
  * @param {boolean} props.err - The error for the API request
51
+ * @param {string} props.defaultUrl - URL to fetch the initial default display list on mount.
52
+ * When set, search results replace the list entirely (no merge with options), preventing duplicates.
49
53
  */
50
- declare function SearchObjectsFromDB<T extends SearchObjectItemType = SearchObjectItemType>({ label, token, handle, selected, setSelected, appLabel, modelName, filterChannel, limitQuery, limitSelect, options, keyName, placeholder, searchUrl, err, required, }: SearchObjectsFromDBProps<T>): JSX.Element;
54
+ declare function SearchObjectsFromDB<T extends SearchObjectItemType = SearchObjectItemType>({ label, token, handle, selected, setSelected, appLabel, modelName, filterChannel, limitQuery, limitSelect, options, keyName, placeholder, searchUrl, err, required, defaultUrl, }: SearchObjectsFromDBProps<T>): JSX.Element;
51
55
  declare const _default: typeof SearchObjectsFromDB;
52
56
  export default _default;
@@ -684,6 +684,8 @@ export interface DateTimePickerPropsType {
684
684
  useSeparateFields?: boolean;
685
685
  /** Input mode: datetime (default), date only, or time only */
686
686
  mode?: "datetime" | "date" | "time";
687
+ /** Maximum width of the picker dropdown in pixels (default: 600) */
688
+ maxWidth?: number;
687
689
  }
688
690
  export interface DateRange {
689
691
  startDate: string;