@instincthub/react-ui 0.1.41 → 0.1.43
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/dist/src/assets/css/forms/ihub-file-uploader.css +186 -0
- package/dist/src/components/forms/ChipsInput.js +1 -1
- package/dist/src/components/forms/DateTimePicker.js +1 -1
- package/dist/src/components/forms/InputText.js +1 -1
- package/dist/src/components/forms/PasswordField.js +1 -1
- package/dist/src/components/forms/uploads/IhubFileUploader.js +1 -1
- package/dist/src/types/components/forms/uploads/IhubFileUploader.d.ts +4 -2
- package/dist/src/types/types/index.d.ts +10 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -245,3 +245,189 @@
|
|
|
245
245
|
.ihub-uploader-cancel-btn.outlined-btn:hover {
|
|
246
246
|
background-color: rgba(0, 131, 143, 0.05);
|
|
247
247
|
}
|
|
248
|
+
|
|
249
|
+
/* ── Thumbnail Grid ──────────────────────────────── */
|
|
250
|
+
|
|
251
|
+
.ihub-uploader-thumbs {
|
|
252
|
+
display: grid;
|
|
253
|
+
grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
|
|
254
|
+
gap: 8px;
|
|
255
|
+
margin-top: 12px;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
.ihub-uploader-thumb {
|
|
259
|
+
position: relative;
|
|
260
|
+
border-radius: 8px;
|
|
261
|
+
overflow: hidden;
|
|
262
|
+
aspect-ratio: 1;
|
|
263
|
+
background: var(--Magnolia, #f4f3fe);
|
|
264
|
+
border: 1px solid rgba(0, 0, 0, 0.08);
|
|
265
|
+
transition: transform 0.15s, box-shadow 0.15s;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
.ihub-uploader-thumb:hover {
|
|
269
|
+
transform: scale(1.03);
|
|
270
|
+
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
.ihub-uploader-thumb-preview {
|
|
274
|
+
width: 100%;
|
|
275
|
+
height: 100%;
|
|
276
|
+
cursor: pointer;
|
|
277
|
+
position: relative;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
.ihub-uploader-thumb-preview img,
|
|
281
|
+
.ihub-uploader-thumb-preview video {
|
|
282
|
+
width: 100%;
|
|
283
|
+
height: 100%;
|
|
284
|
+
object-fit: cover;
|
|
285
|
+
display: block;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
.ihub-uploader-thumb-badge {
|
|
289
|
+
position: absolute;
|
|
290
|
+
bottom: 4px;
|
|
291
|
+
left: 4px;
|
|
292
|
+
background: rgba(0, 0, 0, 0.6);
|
|
293
|
+
color: #fff;
|
|
294
|
+
border-radius: 4px;
|
|
295
|
+
padding: 2px 4px;
|
|
296
|
+
display: flex;
|
|
297
|
+
align-items: center;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
.ihub-uploader-thumb-remove {
|
|
301
|
+
position: absolute;
|
|
302
|
+
top: 4px;
|
|
303
|
+
right: 4px;
|
|
304
|
+
width: 20px;
|
|
305
|
+
height: 20px;
|
|
306
|
+
border-radius: 50%;
|
|
307
|
+
background: rgba(0, 0, 0, 0.6);
|
|
308
|
+
color: #fff;
|
|
309
|
+
border: none;
|
|
310
|
+
cursor: pointer;
|
|
311
|
+
display: flex;
|
|
312
|
+
align-items: center;
|
|
313
|
+
justify-content: center;
|
|
314
|
+
opacity: 0;
|
|
315
|
+
transition: opacity 0.15s;
|
|
316
|
+
z-index: 2;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
.ihub-uploader-thumb:hover .ihub-uploader-thumb-remove {
|
|
320
|
+
opacity: 1;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
.ihub-uploader-thumb-remove:hover {
|
|
324
|
+
background: var(--Danger, #ea5f5e);
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
/* ── Lightbox Modal ──────────────────────────────── */
|
|
328
|
+
|
|
329
|
+
.ihub-uploader-lightbox {
|
|
330
|
+
position: fixed;
|
|
331
|
+
inset: 0;
|
|
332
|
+
z-index: 9999;
|
|
333
|
+
background: rgba(0, 0, 0, 0.9);
|
|
334
|
+
display: flex;
|
|
335
|
+
align-items: center;
|
|
336
|
+
justify-content: center;
|
|
337
|
+
animation: ihub-lightbox-fade-in 0.2s ease;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
@keyframes ihub-lightbox-fade-in {
|
|
341
|
+
from { opacity: 0; }
|
|
342
|
+
to { opacity: 1; }
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
.ihub-uploader-lightbox-content {
|
|
346
|
+
position: relative;
|
|
347
|
+
width: 90vw;
|
|
348
|
+
height: 90vh;
|
|
349
|
+
display: flex;
|
|
350
|
+
align-items: center;
|
|
351
|
+
justify-content: center;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
.ihub-uploader-lightbox-close {
|
|
355
|
+
position: absolute;
|
|
356
|
+
top: 0;
|
|
357
|
+
right: 0;
|
|
358
|
+
background: none;
|
|
359
|
+
border: none;
|
|
360
|
+
color: #fff;
|
|
361
|
+
cursor: pointer;
|
|
362
|
+
padding: 8px;
|
|
363
|
+
z-index: 3;
|
|
364
|
+
opacity: 0.7;
|
|
365
|
+
transition: opacity 0.15s;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
.ihub-uploader-lightbox-close:hover {
|
|
369
|
+
opacity: 1;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
.ihub-uploader-lightbox-media {
|
|
373
|
+
max-width: 85vw;
|
|
374
|
+
max-height: 80vh;
|
|
375
|
+
display: flex;
|
|
376
|
+
align-items: center;
|
|
377
|
+
justify-content: center;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
.ihub-uploader-lightbox-media img,
|
|
381
|
+
.ihub-uploader-lightbox-media video {
|
|
382
|
+
max-width: 100%;
|
|
383
|
+
max-height: 80vh;
|
|
384
|
+
object-fit: contain;
|
|
385
|
+
border-radius: 8px;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
.ihub-uploader-lightbox-nav {
|
|
389
|
+
position: absolute;
|
|
390
|
+
top: 50%;
|
|
391
|
+
transform: translateY(-50%);
|
|
392
|
+
background: rgba(255, 255, 255, 0.1);
|
|
393
|
+
border: none;
|
|
394
|
+
color: #fff;
|
|
395
|
+
cursor: pointer;
|
|
396
|
+
padding: 12px;
|
|
397
|
+
border-radius: 50%;
|
|
398
|
+
z-index: 3;
|
|
399
|
+
transition: background 0.15s;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
.ihub-uploader-lightbox-nav:hover {
|
|
403
|
+
background: rgba(255, 255, 255, 0.25);
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
.ihub-uploader-lightbox-prev {
|
|
407
|
+
left: 16px;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
.ihub-uploader-lightbox-next {
|
|
411
|
+
right: 16px;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
.ihub-uploader-lightbox-info {
|
|
415
|
+
position: absolute;
|
|
416
|
+
bottom: 0;
|
|
417
|
+
left: 0;
|
|
418
|
+
right: 0;
|
|
419
|
+
display: flex;
|
|
420
|
+
justify-content: space-between;
|
|
421
|
+
padding: 12px 16px;
|
|
422
|
+
color: rgba(255, 255, 255, 0.7);
|
|
423
|
+
font-size: 13px;
|
|
424
|
+
background: linear-gradient(transparent, rgba(0, 0, 0, 0.5));
|
|
425
|
+
border-radius: 0 0 8px 8px;
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
/* ── DarkMode ─────────────────────────────────────── */
|
|
429
|
+
|
|
430
|
+
html.DarkMode .ihub-uploader-thumb {
|
|
431
|
+
background: var(--White, #212121);
|
|
432
|
+
border-color: rgba(183, 205, 226, 0.15);
|
|
433
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{slicedToArray as e,toConsumableArray as a}from"../../../_virtual/_rollupPluginBabelHelpers.js";import{jsxs as i,jsx as r}from"react/jsx-runtime";import{useState as t,useRef as n}from"react";import{isValidEmail as c}from"../lib/helpFunction.js";import"../lib/utils.js";var l=function(l){var o=l.label,s=l.name,u=l.value,h=void 0===u?[]:u,d=l.onChange,p=l.placeholder,m=void 0===p?"Add tags...":p,v=l.separator,b=void 0===v?",":v,f=l.maxChips,g=l.allowDuplicates,y=void 0!==g&&g,k=l.disabled,N=void 0!==k&&k,C=l.validateEmail,w=l.errorMessage,x=void 0===w?"":w,D=l.className,A=void 0===D?"":D,B=l.chipClassName,j=void 0===B?"":B,q=l.inputClassName,F=void 0===q?"":q,P=l.size,E=void 0===P?"medium":P,I=l.ariaLabel,K=void 0===I?"Chips input":I,L=l.required,M=void 0!==L&&L,R=t(""),_=e(R,2),z=_[0],H=_[1],T=t(""),G=e(T,2),J=G[0],O=G[1],Q=t(-1),S=e(Q,2),U=S[0],V=S[1],W=n(null),X=n(null),Y=function(e){var i=e.trim();if(i){if(C)if(!c(i))return O("Please enter a valid email address"),void O(x||"Invalid input");y||!h.includes(i)?f&&h.length>=f?O("Maximum of ".concat(f," tags allowed")):(O(""),d([].concat(a(h),[i])),H("")):O("Duplicate value")}},Z=function(e){if(!N){var i=a(h);i.splice(e,1),d(i),V(-1),W.current&&W.current.focus()}};return i("div",{className:"ihub-wrapper",children:[i("div",{ref:X,className:"ihub-chips-container ".concat(function(){switch(E){case"small":return"ihub-chips-small";case"large":return"ihub-chips-large";default:return"ihub-chips-medium"}}()," ").concat(A," ").concat(N?"ihub-chips-disabled":""," ").concat(J?"ihub-chips-error":""),onClick:function(){W.current&&!N&&W.current.focus()},"aria-labelledby":K,"aria-describedby":J?"chips-error-message":void 0,children:[h.map(function(e,a){return i("div",{className:"ihub-chip ".concat(j," ").concat(U===a?"ihub-chip-active":""),onClick:function(){return function(e){N||V(e)}(a)},tabIndex:N?-1:0,"aria-label":"".concat(e,", press delete to remove"),onKeyDown:function(e){"Delete"!==e.key&&"Backspace"!==e.key||Z(a)},children:[r("span",{className:"ihub-chip-text",children:e}),!N&&r("button",{type:"button",className:"ihub-chip-remove",onClick:function(e){e.stopPropagation(),Z(a)},"aria-label":"Remove ".concat(e),children:"×"})]},"".concat(e,"-").concat(a))}),r("input",{ref:W,type:"text",className:"ihub-chips-input ".concat(F),placeholder:0===h.length?m:"",value:z,onChange:function(e){if(H(e.target.value),O(""),e.target.value.includes(b)){for(var a=e.target.value.split(b),i=0;i<a.length-1;i++)Y(a[i]);H(a[a.length-1])}},onKeyDown:function(e){"Enter"===e.key&&z&&(e.preventDefault(),Y(z)),e.key===b&&z&&(e.preventDefault(),Y(z)),"Backspace"===e.key&&!z&&h.length>0&&Z(h.length-1),"ArrowLeft"===e.key&&(-1===U&&h.length>0?V(h.length-1):U>0&&V(U-1)),"ArrowRight"===e.key&&(U>=0&&U<h.length-1?V(U+1):(V(-1),W.current&&W.current.focus())),"Delete"!==e.key&&"Backspace"!==e.key||-1===U||Z(U)},onFocus:function(){V(-1)},onBlur:function(e){z.trim()&&Y(z)},disabled:N||void 0!==f&&h.length>=f,"aria-invalid":!!J,required:M}),o&&i("label",{htmlFor:s,className:"ihub-chips-label ihub-text-label",children:[o,M&&r("span",{className:"ihub-required",children:"*"})]})]}),J&&r("div",{className:"ihub-chips-error-message",id:"chips-error-message",children:J}),s?r("input",{name:s,className:"ihub-ghost",value:"".concat(h)}):""]})};export{l as default};
|
|
1
|
+
import{slicedToArray as e,toConsumableArray as a}from"../../../_virtual/_rollupPluginBabelHelpers.js";import{jsxs as i,jsx as r}from"react/jsx-runtime";import{useState as t,useRef as n}from"react";import{isValidEmail as c}from"../lib/helpFunction.js";import"../lib/utils.js";var l=function(l){var o=l.label,s=l.name,u=l.value,h=void 0===u?[]:u,d=l.onChange,p=l.placeholder,m=void 0===p?"Add tags...":p,v=l.separator,b=void 0===v?",":v,f=l.maxChips,g=l.allowDuplicates,y=void 0!==g&&g,k=l.disabled,N=void 0!==k&&k,C=l.validateEmail,w=l.errorMessage,x=void 0===w?"":w,D=l.className,A=void 0===D?"":D,B=l.chipClassName,j=void 0===B?"":B,q=l.inputClassName,F=void 0===q?"":q,P=l.size,E=void 0===P?"medium":P,I=l.ariaLabel,K=void 0===I?"Chips input":I,L=l.required,M=void 0!==L&&L,R=t(""),_=e(R,2),z=_[0],H=_[1],T=t(""),G=e(T,2),J=G[0],O=G[1],Q=t(-1),S=e(Q,2),U=S[0],V=S[1],W=n(null),X=n(null),Y=function(e){var i=e.trim();if(i){if(C)if(!c(i))return O("Please enter a valid email address"),void O(x||"Invalid input");y||!h.includes(i)?f&&h.length>=f?O("Maximum of ".concat(f," tags allowed")):(O(""),d([].concat(a(h),[i])),H("")):O("Duplicate value")}},Z=function(e){if(!N){var i=a(h);i.splice(e,1),d(i),V(-1),W.current&&W.current.focus()}};return i("div",{className:"ihub-wrapper",children:[i("div",{ref:X,className:"ihub-chips-container ".concat(function(){switch(E){case"small":return"ihub-chips-small";case"large":return"ihub-chips-large";default:return"ihub-chips-medium"}}()," ").concat(A," ").concat(N?"ihub-chips-disabled":""," ").concat(J?"ihub-chips-error":""),onClick:function(){W.current&&!N&&W.current.focus()},"aria-labelledby":K,"aria-describedby":J?"chips-error-message":void 0,children:[h.map(function(e,a){return i("div",{className:"ihub-chip ".concat(j," ").concat(U===a?"ihub-chip-active":""),onClick:function(){return function(e){N||V(e)}(a)},tabIndex:N?-1:0,"aria-label":"".concat(e,", press delete to remove"),onKeyDown:function(e){"Delete"!==e.key&&"Backspace"!==e.key||Z(a)},children:[r("span",{className:"ihub-chip-text",children:e}),!N&&r("button",{type:"button",className:"ihub-chip-remove",onClick:function(e){e.stopPropagation(),Z(a)},"aria-label":"Remove ".concat(e),children:"×"})]},"".concat(e,"-").concat(a))}),r("input",{ref:W,type:"text",id:s,className:"ihub-chips-input ".concat(F),placeholder:0===h.length?m:"",value:z,onChange:function(e){if(H(e.target.value),O(""),e.target.value.includes(b)){for(var a=e.target.value.split(b),i=0;i<a.length-1;i++)Y(a[i]);H(a[a.length-1])}},onKeyDown:function(e){"Enter"===e.key&&z&&(e.preventDefault(),Y(z)),e.key===b&&z&&(e.preventDefault(),Y(z)),"Backspace"===e.key&&!z&&h.length>0&&Z(h.length-1),"ArrowLeft"===e.key&&(-1===U&&h.length>0?V(h.length-1):U>0&&V(U-1)),"ArrowRight"===e.key&&(U>=0&&U<h.length-1?V(U+1):(V(-1),W.current&&W.current.focus())),"Delete"!==e.key&&"Backspace"!==e.key||-1===U||Z(U)},onFocus:function(){V(-1)},onBlur:function(e){z.trim()&&Y(z)},disabled:N||void 0!==f&&h.length>=f,"aria-invalid":!!J,required:M}),o&&i("label",{htmlFor:s,className:"ihub-chips-label ihub-text-label",children:[o,M&&r("span",{className:"ihub-required",children:"*"})]})]}),J&&r("div",{className:"ihub-chips-error-message",id:"chips-error-message",children:J}),s?r("input",{name:s,className:"ihub-ghost",value:"".concat(h)}):""]})};export{l as default};
|
|
2
2
|
//# sourceMappingURL=ChipsInput.js.map
|
|
@@ -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 s,useEffect as u,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,se=I.showCalendarIcon,ue=void 0===se||se,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"),st=e(lt,2),ut=st[0],ct=st[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=s(null),wt=s(null),Dt=s(null),kt=s(null),xt=s({}),Ct=l({}),It=e(Ct,2),At=It[0],Tt=It[1];u(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]);u(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]);u(function(){if(void 0!==j){var e=De(j);Ie(e),Oe||Pe(e?Lt(e):"")}},[j,Oe,Lt]),u(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,s=i.minute,u=i.second,c=i.ampm;if(r&&d&&o&&l&&s)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(s),G?parseInt(u||"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 u(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:[ue&&("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 s=n[l],u=a.slice(d,d+s);u&&(r+=u,d+=s,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:[ue&&("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(ut)%12||12).toString().padStart(2,"0"):ut,onChange:function(e){var t=e.target.value.replace(/\D/g,"").slice(0,2);(""===t||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,"").slice(0,2);(""===t||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,"").slice(0,2);(""===t||parseInt(t)<60)&>(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(ut),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};
|
|
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 o from"@mui/icons-material/CalendarMonthOutlined";import d from"@mui/icons-material/AccessTime";import{useState as l,useRef as u,useEffect as c,useCallback as s,useMemo as m}from"react";import{createPortal as p}from"react-dom";import{startOfDay as h}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{setHours as S}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 _}from"../../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/setSeconds.js";import{isValid as w}from"../../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/isValid.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,P=I.value,T=void 0===P?"":P,j=I.onChange,L=I.required,F=void 0!==L&&L,O=I.minDate,B=I.maxDate,E=I.minTime,W=I.maxTime,Y=I.disabledDates,q=void 0===Y?[]:Y,K=I.disabledTimes,z=void 0===K?[]:K,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,oe=I.id,de=I.disabled,le=void 0!==de&&de,ue=I.showCalendarIcon,ce=void 0===ue||ue,se=I.showTimeIcon,me=void 0===se||se,pe=I.showQuickActions,he=void 0===pe||pe,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,Se=I.mode,He=void 0===Se?"datetime":Se,_e=I.maxWidth,we=void 0===_e?600:_e,De=function(e){if(!e)return null;try{var t=new Date(e);return w(t)?t:null}catch(e){return null}},ke=l(De(T)),xe=e(ke,2),Ce=xe[0],Ie=xe[1],Ae=l(""),Pe=e(Ae,2),Te=Pe[0],je=Pe[1],Le=l(!1),Fe=e(Le,2),Oe=Fe[0],Be=Fe[1],Ee=l(!1),We=e(Ee,2),Ye=We[0],qe=We[1],Ke=l("time"===He?"time":"calendar"),ze=e(Ke,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),ot=rt[0],dt=rt[1],lt=l(Ce?C(Ce,"HH"):"00"),ut=e(lt,2),ct=ut[0],st=ut[1],mt=l(Ce?C(Ce,"mm"):"00"),pt=e(mt,2),ht=pt[0],ft=pt[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),St=Nt[0],Ht=Nt[1],_t=l(!1),wt=e(_t,2),Dt=wt[0],kt=wt[1],xt=l(!1),Ct=e(xt,2);Ct[0];var It=Ct[1],At=l(!1),Pt=e(At,2);Pt[0];var Tt=Pt[1],jt=u(null),Lt=u(null),Ft=u(null),Ot=u(null),Bt=u({}),Et=l({}),Wt=e(Et,2),Yt=Wt[0],qt=Wt[1];c(function(){Ce&&(st(C(Ce,"HH")),ft(C(Ce,"mm")),gt(C(Ce,"ss")),Ht(Ce.getHours()>=12?"PM":"AM"))},[Ce]);var Kt=s(function(){var e=Ne?Ft.current:Ot.current;if(e)if(window.innerWidth<=768)qt({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);qt(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]);c(function(){if(Ye)return Kt(),window.addEventListener("scroll",Kt,!0),window.addEventListener("resize",Kt),function(){window.removeEventListener("scroll",Kt,!0),window.removeEventListener("resize",Kt)}},[Ye,Kt]);var zt=s(function(e){if(!e)return"";switch(He){case"date":return C(h(e),"yyyy-MM-dd");case"time":return C(e,G?"HH:mm:ss":"HH:mm");default:return e.toISOString()}},[He,G]),Rt=s(function(e){var t=e||Ce;if(!t)return"";try{if("date"===He)return C(t,Z);if("time"===He)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,He,Z,ee,G]);c(function(){if(void 0!==T){var e=De(T);Ie(e),Oe||je(e?Rt(e):"")}},[T,Oe,Rt]),c(function(){if(Ye){var e=function(e){var t,a,n,i=e.target;null!==(t=jt.current)&&void 0!==t&&t.contains(i)||Ne&&null!==(a=Ft.current)&&void 0!==a&&a.contains(i)||!Ne&&null!==(n=Ot.current)&&void 0!==n&&n.contains(i)||qe(!1)},t=setTimeout(function(){document.addEventListener("mousedown",e)},0);return function(){clearTimeout(t),document.removeEventListener("mousedown",e)}}},[Ye,Ne]);var Qt=s(function(e){var t=C(e,"yyyy-MM-dd");return q.includes(t)},[q]),Vt=s(function(e){return(!O||!f(e,h(new Date(O))))&&(!B||!y(e,b(new Date(B))))},[O,B]),Gt=s(function(t,a){if(!E&&!W)return!0;var n=60*t+a;if(E){var i=E.split(":").map(Number),r=e(i,2);if(n<60*r[0]+r[1])return!1}if(W){var o=W.split(":").map(Number),d=e(o,2);if(n>60*d[0]+d[1])return!1}return!0},[E,W]),Jt=s(function(e,t){var a="".concat(e.toString().padStart(2,"0"),":").concat(t.toString().padStart(2,"0"));return z.includes(a)},[z]),Ut=s(function(){if(Ue(null),F&&!Ce)return Ue("Date and time are required"),!1;if(!Ce)return!0;if(!Vt(Ce))return Ue("Selected date is outside allowed range"),!1;if(Qt(Ce))return Ue("Selected date is not available"),!1;var e=Ce.getHours(),t=Ce.getMinutes();return Gt(e,t)?!Jt(e,t)||(Ue("Selected time is not available"),!1):(Ue("Selected time is outside allowed range"),!1)},[Ce,F,Vt,Qt,Gt,Jt]),Xt=function(e){if(!Qt(e)&&Vt(e)){var t=e;if("date"===He)t=h(e),Ie(t),dt(t),null==j||j(zt(t)),qe(!1),Ue(null);else{if(Ce)t=S(e,Ce.getHours()),t=H(t,Ce.getMinutes()),t=_(t,Ce.getSeconds());else{var a=new Date;t=S(e,a.getHours()),t=H(t,a.getMinutes()),t=_(t,0)}Ie(t),dt(t),null==j||j(zt(t)),"datetime"===He&&Qe("time")}}},Zt=m(function(){for(var e=ot.getFullYear(),t=ot.getMonth(),a=v(ot),n=g(a),i=M(ot),r=[],o=0;o<n;o++)r.push(null);for(var d=1;d<=i;d++)r.push(new Date(e,t,d));return r},[ot]),$t=m(function(){for(var e=[],t=0;t<24;t++)for(var a=0;a<60;a+=U)if(!Jt(t,a)&&Gt(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,Jt,Gt]),ea=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(w(i))return i}catch(e){}}try{var r=new Date(e);if(w(r))return r}catch(e){}return null},ta=function(){var e=new Date,t="date"===He?h(e):e;Ie(t),dt(t),null==j||j(zt(t)),Ue(null)},aa=function(){Ie(null),st("00"),ft("00"),gt("00"),Ht("AM"),null==j||j(""),Ue(null)},na=function(e,n){var i=t(t({},at),{},a({},e,n));nt(i);var r=i.year,o=i.month,d=i.day,l=i.hour,u=i.minute,c=i.second,s=i.ampm;if(r&&o&&d&&l&&u)try{var m=parseInt(l);Q&&("PM"===s&&12!==m&&(m+=12),"AM"===s&&12===m&&(m=0));var p=new Date(parseInt(r),parseInt(o)-1,parseInt(d),m,parseInt(u),G?parseInt(c||"0"):0);if(w(p)){var f="date"===He?h(p):p;Ie(f),null==j||j(zt(f)),Ue(null)}}catch(e){}},ia=function(e,t,a,n){if(e.target.value.length>=a&&n&&/\d/.test(e.key)){e.preventDefault();var i=Bt.current[n];i&&(i.focus(),i.select())}};return c(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:oe||re,children:[A,F&&i("span",{className:"ihub-required",children:"*"})]}),n("div",Ne?{ref:Ft,className:"ihub-datetime-separate-fields",children:[("date"===He||"datetime"===He)&&n("div",{className:"ihub-datetime-date-fields",children:[i("input",{ref:function(e){Bt.current.year=e},type:"text",className:"ihub-datetime-field ihub-datetime-year",value:at.year,onChange:function(e){return na("year",e.target.value.replace(/\D/g,"").slice(0,4))},onKeyDown:function(e){return ia(e,0,4,"month")},placeholder:"YYYY",maxLength:4,disabled:le,id:"".concat(oe,"-year"),"aria-label":"Year"}),i("span",{className:"ihub-datetime-separator",children:"/"}),i("input",{ref:function(e){Bt.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)&&na("month",t)},onKeyDown:function(e){return ia(e,0,2,"day")},placeholder:"MM",maxLength:2,disabled:le,id:"".concat(oe,"-month"),"aria-label":"Month"}),i("span",{className:"ihub-datetime-separator",children:"/"}),i("input",{ref:function(e){Bt.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)&&na("day",t)},onKeyDown:function(e){return ia(e,0,2,"hour")},placeholder:"DD",maxLength:2,disabled:le,id:"".concat(oe,"-day"),"aria-label":"Day"})]}),("time"===He||"datetime"===He)&&n("div",{className:"ihub-datetime-time-fields",children:[i("input",{ref:function(e){Bt.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)&&na("hour",t)},onKeyDown:function(e){return ia(e,0,2,"minute")},placeholder:"HH",maxLength:2,disabled:le,id:"".concat(oe,"-hour"),"aria-label":"Hour"}),i("span",{className:"ihub-datetime-separator",children:":"}),i("input",{ref:function(e){Bt.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)&&na("minute",t)},onKeyDown:function(e){return ia(e,0,2,G?"second":void 0)},placeholder:"MM",maxLength:2,disabled:le,id:"".concat(oe,"-minute"),"aria-label":"Minute"}),G&&n(r,{children:[i("span",{className:"ihub-datetime-separator",children:":"}),i("input",{ref:function(e){Bt.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)&&na("second",t)},placeholder:"SS",maxLength:2,disabled:le,id:"".concat(oe,"-second"),"aria-label":"Second"})]}),Q&&i("button",{type:"button",className:"ihub-datetime-field ihub-datetime-ampm-toggle",onClick:function(){return na("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:[ce&&("date"===He||"datetime"===He)&&i("button",{type:"button",className:"ihub-datetime-icon-btn",onClick:function(){le||(qe(!0),Qe("calendar"))},disabled:le,"aria-label":"Open calendar",children:i(o,{})}),me&&("time"===He||"datetime"===He)&&i("button",{type:"button",className:"ihub-datetime-icon-btn",onClick:function(){le||(qe(!0),Qe("time"))},disabled:le,"aria-label":"Open time picker",children:i(d,{})})]})]}:{ref:Ot,className:"ihub-datetime-input-container",children:[i("input",{ref:Lt,type:"text",className:"ihub-datetime-input",value:Oe?Te:Rt(),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="",o=0,d=0,l=0;l<n.length;l++){var u=n[l],c=a.slice(o,o+u);c&&(r+=c,o+=u,l<n.length-1&&o<a.length&&d<i.length&&(r+=i[d]),d++)}return{formatted:r,cursorPos:r.length}}(a),i=n.formatted,r=n.cursorPos;if(je(i),$e(r),setTimeout(function(){t&&t.setSelectionRange&&t.setSelectionRange(r,r)},0),!i.trim())return Ie(null),null==j||j(""),void Ue(null);var o=ea(i);if(o){var d="date"===He?h(o):o;Ie(d),null==j||j(zt(d)),Ue(null)}},onFocus:function(e){Be(!0),Ce&&!Te&&je(Rt()),null==ve||ve(e)},onBlur:function(e){if(Be(!1),Te.trim()){var t=ea(Te);if(t){var a="date"===He?h(t):t;Ie(a),null==j||j(zt(a)),je(Rt(a)),Ue(null)}else Ue("Invalid date/time format")}else Ue(F?"Date and time are required":null);Ut(),null==ge||ge(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:Oe?function(e){for(var t=("date"===He?Z:"time"===He?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],o=e[n];"_"===r?o&&/[^\d]/.test(o)&&i+1<t.length&&/[^_]/.test(t[i+1])?(a+=t[i+1],n++,i++):o&&/\d/.test(o)?(a+=o,n++):a+="_":(a+=r,o===r&&n++)}return a.length<t.length&&(a+=t.slice(a.length)),a}(Te):"date"===He?te||Z:"time"===He?te||ee:te||"".concat(Z," ").concat(ee),disabled:le,required:F,name:re,id:oe,"aria-label":fe||A,"aria-invalid":!!Je,"aria-describedby":Je?"".concat(oe,"-error"):void 0,autoFocus:be}),n("div",{className:"ihub-datetime-icons",children:[ce&&("date"===He||"datetime"===He)&&i("button",{type:"button",className:"ihub-datetime-icon-btn",onClick:function(){le||(qe(!0),Qe("calendar"))},disabled:le,"aria-label":"Open calendar",children:i(o,{})}),me&&("time"===He||"datetime"===He)&&i("button",{type:"button",className:"ihub-datetime-icon-btn",onClick:function(){le||(qe(!0),Qe("time"))},disabled:le,"aria-label":"Open time picker",children:i(d,{})})]})]}),Je&&i("div",{id:"".concat(oe,"-error"),className:"ihub-datetime-error",children:Je}),Ye&&!le&&"undefined"!=typeof document&&p(n("div",{ref:jt,className:"ihub-datetime-picker-dropdown",style:Yt,role:"dialog","aria-label":"Date and time picker",onMouseDown:function(e){return e.stopPropagation()},children:["datetime"===He&&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"===He)&&("date"===He||"datetime"===He)&&n("div",{className:"ihub-datetime-calendar",children:[n("div",{className:"ihub-datetime-month-nav",children:[i("button",{type:"button",onClick:function(){dt(D(ot,1))},className:"ihub-datetime-nav-btn","aria-label":"Previous month",children:"‹"}),i("span",{className:"ihub-datetime-month-year",children:C(ot,"MMMM yyyy")}),i("button",{type:"button",onClick:function(){dt(k(ot,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:Zt.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=Qt(e)||!Vt(e);return i("button",{type:"button",className:"ihub-datetime-day ".concat(a?"selected":""," ").concat(n?"today":""," ").concat(r?"disabled":""),onClick:function(){return Xt(e)},disabled:r,"aria-label":C(e,"MMMM d, yyyy"),"aria-selected":!!a||void 0,children:e.getDate()},e.getTime())})})]}),("time"===Re||"time"===He)&&("time"===He||"datetime"===He)&&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:Dt?ct:Q?(parseInt(ct)%12||12).toString().padStart(2,"0"):ct,onFocus:function(){if(kt(!0),Q){var e=(parseInt(ct)%12||12).toString().padStart(2,"0");st(e)}},onBlur:function(){if(kt(!1),""===ct)st("00");else if(Q){var e=parseInt(ct)||0;e>12&&(e=12),e<1&&(e=12),st(("PM"===St?12===e?12:e+12:12===e?0:e).toString().padStart(2,"0"))}else st(ct.padStart(2,"0"))},onChange:function(e){var t=e.target.value.replace(/\D/g,"").slice(0,2),a=Q?12:23;(""===t||parseInt(t)<=a)&&st(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:ht,onFocus:function(){return It(!0)},onBlur:function(){It(!1),ft(""===ht?"00":ht.padStart(2,"0"))},onChange:function(e){var t=e.target.value.replace(/\D/g,"").slice(0,2);(""===t||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,onFocus:function(){return Tt(!0)},onBlur:function(){Tt(!1),gt(""===vt?"00":vt.padStart(2,"0"))},onChange:function(e){var t=e.target.value.replace(/\D/g,"").slice(0,2);(""===t||parseInt(t)<60)&>(t)},maxLength:2,placeholder:"SS"})]})]}),Q&&n("div",{className:"ihub-datetime-ampm",children:[i("button",{type:"button",className:"ihub-datetime-ampm-btn ".concat("AM"===St?"active":""),onClick:function(){return Ht("AM")},children:"AM"}),i("button",{type:"button",className:"ihub-datetime-ampm-btn ".concat("PM"===St?"active":""),onClick:function(){return Ht("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:$t.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(){var t=e.hours,a=e.minutes;st(t.toString().padStart(2,"0")),ft(a.toString().padStart(2,"0")),Q&&Ht(t>=12?"PM":"AM");var n=Ce||new Date,i=S(n,t);i=H(i,a),i=_(i,0),Ie(i),null==j||j(zt(i)),qe(!1),Ue(null)},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"!==He){var t=new Date;return void Xt(t)}e=new Date}var a=parseInt(ct),n=parseInt(ht),i=G?parseInt(vt):0;if(Q&&("PM"===St&&12!==a?a+=12:"AM"===St&&12===a&&(a=0)),!Jt(a,n)&&Gt(a,n)){var r=S(e,a);r=H(r,n),r=_(r,i),Ie(r),null==j||j(zt(r)),qe(!1),Ue(null)}else Ue("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:ta,children:"Now"}),i("button",{type:"button",className:"ihub-datetime-action-btn",onClick:aa,children:"Clear"})]})]}),document.body)]}),he&&!le&&!Ye&&n("div",{className:"ihub-datetime-quick-links",children:[i("button",{type:"button",className:"ihub-datetime-link",onClick:ta,children:"Now"}),i("span",{className:"ihub-datetime-separator",children:"|"}),i("button",{type:"button",className:"ihub-datetime-link",onClick:aa,children:"Clear"})]}),re&&i("input",{type:"hidden",name:re,value:Ce?zt(Ce):""})]})};export{I as default};
|
|
2
2
|
//# sourceMappingURL=DateTimePicker.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{slicedToArray as e,objectSpread2 as a}from"../../../_virtual/_rollupPluginBabelHelpers.js";import{jsxs as i,jsx as r}from"react/jsx-runtime";import{useState as l,useEffect as t}from"react";var n=function(n){var o=n.label,d=n.name,c=n.value,s=void 0===c?"":c,u=n.placeholder,h=void 0===u?"":u,m=n.required,p=void 0!==m&&m,v=n.type,b=void 0===v?"text":v,f=n.maxLength,x=n.disabled,N=void 0!==x&&x,g=n.readOnly,y=void 0!==g&&g,_=n.className,j=void 0===_?"":_,q=n.textTransform,B=n.error,L=n.onChange,T=n.onBlur,C=n.helperText,O=n.note,w=n.id,A=n.activeLabel,F=void 0!==A&&A,H=l(),P=e(H,2),S=P[0],k=P[1],z=l(F),D=e(z,2),E=D[0],G=D[1];t(function(){G(!!F||!!s),s!==S&&k(s)},[s]);var I={};return q&&(I["data-text-transform"]=q),i("div",a(a({className:"ihub-wrapper ".concat(E?"ihub-value":""," ").concat(B?"ihub-is_invalid":""," ").concat(h?"ihub-has-placeholder":""," ").concat(j)},I),{},{children:[r("input",{type:b,id:w,name:d,value:S,className:"ihub-input",placeholder:h,required:p,maxLength:f,disabled:N,readOnly:y,onChange:function(e){G(!!e.target.value),k(e.target.value),L&&L(e)},onBlur:T}),i("label",{htmlFor:d,className:"ihub-text-label",children:[o,p&&r("span",{className:"ihub-required",children:"*"})]}),C&&!B&&r("p",{className:"ihub-notes",children:C}),B&&r("p",{className:"ihub-notes ihub-is_invalid",children:B}),O&&r("p",{className:"ihub-input-notes",id:"".concat(w,"-note"),children:O})]}))};export{n as default};
|
|
1
|
+
import{slicedToArray as e,objectSpread2 as a}from"../../../_virtual/_rollupPluginBabelHelpers.js";import{jsxs as i,jsx as r}from"react/jsx-runtime";import{useState as l,useEffect as t}from"react";var n=function(n){var o=n.label,d=n.name,c=n.value,s=void 0===c?"":c,u=n.placeholder,h=void 0===u?"":u,m=n.required,p=void 0!==m&&m,v=n.type,b=void 0===v?"text":v,f=n.maxLength,x=n.disabled,N=void 0!==x&&x,g=n.readOnly,y=void 0!==g&&g,_=n.className,j=void 0===_?"":_,q=n.textTransform,B=n.error,L=n.onChange,T=n.onBlur,C=n.helperText,O=n.note,w=n.id,A=n.activeLabel,F=void 0!==A&&A,H=l(),P=e(H,2),S=P[0],k=P[1],z=l(F),D=e(z,2),E=D[0],G=D[1];t(function(){G(!!F||!!s),s!==S&&k(s)},[s]);var I={};return q&&(I["data-text-transform"]=q),i("div",a(a({className:"ihub-wrapper ".concat(E?"ihub-value":""," ").concat(B?"ihub-is_invalid":""," ").concat(h?"ihub-has-placeholder":""," ").concat(j)},I),{},{children:[r("input",{type:b,id:w||d,name:d,value:S,className:"ihub-input",placeholder:h,required:p,maxLength:f,disabled:N,readOnly:y,onChange:function(e){G(!!e.target.value),k(e.target.value),L&&L(e)},onBlur:T}),i("label",{htmlFor:w||d,className:"ihub-text-label",children:[o,p&&r("span",{className:"ihub-required",children:"*"})]}),C&&!B&&r("p",{className:"ihub-notes",children:C}),B&&r("p",{className:"ihub-notes ihub-is_invalid",children:B}),O&&r("p",{className:"ihub-input-notes",id:"".concat(w,"-note"),children:O})]}))};export{n as default};
|
|
2
2
|
//# sourceMappingURL=InputText.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{slicedToArray as e}from"../../../_virtual/_rollupPluginBabelHelpers.js";import{jsxs as i,jsx as a}from"react/jsx-runtime";import{useState as r,useEffect as n}from"react";import l from"@mui/icons-material/Visibility";import
|
|
1
|
+
import{slicedToArray as e}from"../../../_virtual/_rollupPluginBabelHelpers.js";import{jsxs as i,jsx as a}from"react/jsx-runtime";import{useState as r,useEffect as n}from"react";import l from"@mui/icons-material/Visibility";import s from"@mui/icons-material/VisibilityOff";function t(t){var o=t.id,u=t.name,c=t.label,d=t.note,m=t.required,h=void 0!==m&&m,p=t.value,b=void 0===p?"":p,v=t.setValue,f=t.onChange,N=t.setNameValue,w=t.error,x=t.className,y=t.helperText,_=t.placeholder,g=r(!1),V=e(g,2),q=V[0],C=V[1],j=r(""),F=e(j,2),O=F[0],T=F[1],k=r(!1),A=e(k,2);A[0];var B=A[1],H=r(!1),M=e(H,2),P=M[0],z=M[1];n(function(){b!==O&&T(b),z(!!b)},[b]);return i("div",{className:"ihub-wrapper ihub-mb-4 ".concat(P?"ihub-value":""," ").concat(w?"ihub-is_invalid":""," ").concat(x),children:[a("div",{className:"ihub-password-wrapper",children:i("div",{className:"input_icon",children:[a("input",{type:q?"text":"password",id:o||"password",name:u,required:h,value:O,onChange:function(e){var i=e.target.value;T(i),z(!!i),i&&(v&&v(i),f&&f(e),N&&N(u,i))},onFocus:function(){return B(!0)},onMouseOut:function(){return B(!1)},className:"ihub-input",placeholder:_}),i("label",{htmlFor:o||"password",className:"ihub-text-label",children:[c,h&&a("span",{className:"ihub-required",children:"*"})]}),a("div",{onClick:function(){C(function(e){return!e})},className:"symbols ihub-d-inline",children:a(q?l:s,{})})]})}),y&&!w&&a("p",{className:"ihub-notes",children:y}),w&&a("p",{className:"ihub-notes ihub-is_invalid",children:w}),d&&a("p",{className:"ihub-input-notes",id:"".concat(o,"-note"),children:d})]})}export{t as default};
|
|
2
2
|
//# sourceMappingURL=PasswordField.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{slicedToArray as e,asyncToGenerator as n,regenerator as r}from"../../../../_virtual/_rollupPluginBabelHelpers.js";import{jsxs as o,jsx as i,Fragment as t}from"react/jsx-runtime";import{useState as a,useRef as l}from"react";import{FILE_URL as s,slugifyFileName as c,IN_DEV_MODE as u}from"../../lib/helpFunction.js";import{S3Client as d,PutObjectCommand as p}from"@aws-sdk/client-s3";import{Upload as h}from"@aws-sdk/lib-storage";import{openToast as m}from"../../lib/modals/modals.js";function v(v){var f=v.header,b=v.label,g=void 0===b?"Drag and drop files here or click to browse":b,y=v.accept,N=void 0===y?"*":y,C=v.maxFileSize,k=void 0===C?0:C,w=v.name,_=void 0===w?"upload":w,x=v.module,L=void 0===x?"":x,E=v.step,B=void 0===E?"":E,S=v.username,I=void 0===S?null:S,T=v.onUploadComplete,U=v.setValues,A=v.setModules,P=v.setSteps,W=v.className,M=void 0===W?"":W,z=a(null),D=e(z,2),j=D[0],O=D[1],F=a(!1),K=e(F,2),R=K[0],X=K[1],H=a(0),G=e(H,2),V=G[0],Y=G[1],q=a("idle"),Q=e(q,2),J=Q[0],Z=Q[1],$=a(""),ee=e($,2),ne=ee[0],re=ee[1],oe=l(null),ie=function(e){if(0===e)return"0 Bytes";var n=Math.floor(Math.log(e)/Math.log(1024));return parseFloat((e/Math.pow(1024,n)).toFixed(2))+" "+["Bytes","KB","MB","GB"][n]},te=function(e){re(""),function(e){var n;if("*"===N)return!0;var r=e.type,o=".".concat(null===(n=e.name.split(".").pop())||void 0===n?void 0:n.toLowerCase());return!!N.split(",").map(function(e){return e.trim()}).some(function(e){if(e.startsWith("."))return o===e.toLowerCase();if(e.endsWith("/*")){var n=e.replace("/*","");return r.startsWith("".concat(n,"/"))}return r===e})||(re("File type not accepted. Please upload a file matching: ".concat(N)),!1)}(e)&&function(e){if(k&&e.size>k){var n=ie(k);return re("File size exceeds the maximum limit of ".concat(n)),!1}return!0}(e)&&(O(e),Z("idle"),Y(0))},ae=function(){var e=n(r().m(function e(){var n,o,i,t,a,l,v,f,b,g,y,C;return r().w(function(e){for(;;)switch(e.p=e.n){case 0:if(j){e.n=1;break}return re("Please select a file first"),e.a(2);case 1:if(Z("uploading"),re(""),e.p=2,n=new d({region:process.env.NEXT_PUBLIC_AWS_REGION,endpoint:process.env.NEXT_PUBLIC_AWS_S3_ENDPOINT_URL,requestChecksumCalculation:"WHEN_REQUIRED",credentials:{accessKeyId:process.env.NEXT_PUBLIC_AWS_ACCESS_KEY_ID||"",secretAccessKey:process.env.NEXT_PUBLIC_AWS_SECRET_ACCESS_KEY||""}}),o=(new Date).toISOString(),i=c("".concat(I||"anonymous","-").concat(o,"-").concat(j.name)),t=u?"test-env__".concat(i):i,a="video/*"===N?process.env.NEXT_PUBLIC_AWS_LOCATION:process.env.NEXT_PUBLIC_AWS_LOCATION_FILES,l=process.env.NEXT_PUBLIC_AWS_BUCKET_NAME||"",v="".concat(a,"/").concat(t),!(j.size<104857600)){e.n=4;break}return Y(10),f=new p({Bucket:l,Key:v,Body:j,ContentType:j.type,ACL:"public-read"}),b=setInterval(function(){Y(function(e){return Math.min(e+5,95)})},300),e.n=3,n.send(f);case 3:clearInterval(b),Y(100),e.n=5;break;case 4:return(g=new h({client:n,params:{Bucket:l,Key:v,Body:j,ContentType:j.type,ACL:"public-read"}})).on("httpUploadProgress",function(e){var n=Math.round(e.loaded/e.total*100);Y(n)}),e.n=5,g.done();case 5:Z("success"),m("File Uploaded Successfully!"),y={bucket:l,title:j.name,key:t,content_type:j.type,size:j.size,location:"".concat(s,"creators/").concat(t)},T&&T(y),U&&U(_,y.key),A&&A(L,_,y.key),P&&P(L,B,_,y.key),setTimeout(function(){O(null),Z("idle"),Y(0)},3e3),e.n=7;break;case 6:e.p=6,C=e.v,console.error("Upload error:",C),Z("error"),re("Error uploading file. Please try again."),m("Error uploading file!",400),Y(0);case 7:return e.a(2)}},e,null,[[2,6]])}));return function(){return e.apply(this,arguments)}}(),le=function(){O(null),Z("idle"),Y(0),re("")};return o("div",{className:"ihub-uploader ".concat(M),children:[f&&i("h3",{className:"ihub-uploader-header",children:f}),o("div",{className:"ihub-uploader-container",children:[!j&&o("div",{className:"ihub-uploader-dropzone ".concat(R?"ihub-uploader-dropzone-active":""),onDragOver:function(e){e.preventDefault(),e.stopPropagation(),X(!0)},onDragLeave:function(e){e.preventDefault(),e.stopPropagation(),X(!1)},onDrop:function(e){e.preventDefault(),e.stopPropagation(),X(!1);var n=e.dataTransfer.files;n&&n.length>0&&te(n[0])},onClick:function(){oe.current&&oe.current.click()},children:[i("div",{className:"ihub-uploader-icon",children:o("svg",{xmlns:"http://www.w3.org/2000/svg",width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),i("polyline",{points:"17 8 12 3 7 8"}),i("line",{x1:"12",y1:"3",x2:"12",y2:"15"})]})}),i("p",{className:"ihub-uploader-text",children:g}),i("p",{className:"ihub-uploader-hint",children:k>0&&"Maximum file size: ".concat(ie(k))}),i("input",{ref:oe,type:"file",accept:N,onChange:function(e){var n=e.target.files;n&&n.length>0&&te(n[0])},className:"ihub-uploader-input"})]}),j&&o("div",{className:"ihub-uploader-preview",children:[o("div",{className:"ihub-uploader-file-info",children:[i("div",{className:"ihub-uploader-file-icon",children:j.type.startsWith("image/")?i("img",{src:URL.createObjectURL(j),alt:j.name,className:"ihub-uploader-thumbnail"}):o("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),i("polyline",{points:"14 2 14 8 20 8"}),i("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),i("line",{x1:"16",y1:"17",x2:"8",y2:"17"}),i("polyline",{points:"10 9 9 9 8 9"})]})}),o("div",{className:"ihub-uploader-file-details",children:[i("p",{className:"ihub-uploader-file-name",children:j.name}),i("p",{className:"ihub-uploader-file-size",children:ie(j.size)})]})]}),"uploading"===J&&i("div",{className:"ihub-uploader-progress",children:i("div",{className:"ihub-uploader-progress-bar",style:{width:"".concat(V,"%")},children:o("span",{className:"ihub-uploader-progress-text",children:[V,"%"]})})}),o("div",{className:"ihub-uploader-actions",children:["idle"===J&&o(t,{children:[i("button",{className:"ihub-uploader-upload-btn ihub-important-btn",onClick:ae,children:"Upload"}),i("button",{className:"ihub-uploader-cancel-btn outlined-btn",onClick:le,children:"Cancel"})]}),"uploading"===J&&i("button",{className:"ihub-uploader-cancel-btn outlined-btn",onClick:le,children:"Cancel"}),"success"===J&&o("div",{className:"ihub-uploader-success",children:[o("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i("path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14"}),i("polyline",{points:"22 4 12 14.01 9 11.01"})]}),i("span",{children:"Upload Complete"})]}),"error"===J&&o(t,{children:[i("button",{className:"ihub-uploader-retry-btn ihub-important-btn",onClick:ae,children:"Retry"}),i("button",{className:"ihub-uploader-cancel-btn outlined-btn",onClick:le,children:"Cancel"})]})]})]}),ne&&o("div",{className:"ihub-uploader-error",children:[o("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i("circle",{cx:"12",cy:"12",r:"10"}),i("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),i("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}),i("span",{children:ne})]})]})]})}export{v as default};
|
|
1
|
+
import{slicedToArray as e,asyncToGenerator as n,regenerator as r,toConsumableArray as t}from"../../../../_virtual/_rollupPluginBabelHelpers.js";import{jsxs as o,jsx as i,Fragment as l}from"react/jsx-runtime";import{useState as a,useRef as s}from"react";import{FILE_URL as c,slugifyFileName as u,IN_DEV_MODE as d,reqOptions as p}from"../../lib/helpFunction.js";import{S3Client as h,PutObjectCommand as v,DeleteObjectCommand as m}from"@aws-sdk/client-s3";import{Upload as f}from"@aws-sdk/lib-storage";import{openToast as b}from"../../lib/modals/modals.js";function g(g){var w,k=g.header,y=g.label,_=void 0===y?"Drag and drop files here or click to browse":y,C=g.accept,N=void 0===C?"*":C,x=g.maxFileSize,E=void 0===x?0:x,L=g.name,B=void 0===L?"upload":L,S=g.module,I=void 0===S?"":S,W=g.step,T=void 0===W?"":W,U=g.username,A=void 0===U?null:U,P=g.onUploadComplete,D=g.setValues,R=g.setModules,j=g.setSteps,K=g.className,z=void 0===K?"":K,M=g.saveEndpoint,O=g.deleteEndpoint,X=g.token,F=g.enableS3Delete,H=void 0!==F&&F,G=g.onRemove,Y=a(null),V=e(Y,2),q=V[0],Q=V[1],J=a(!1),Z=e(J,2),$=Z[0],ee=Z[1],ne=a(0),re=e(ne,2),te=re[0],oe=re[1],ie=a("idle"),le=e(ie,2),ae=le[0],se=le[1],ce=a(""),ue=e(ce,2),de=ue[0],pe=ue[1],he=a([]),ve=e(he,2),me=ve[0],fe=ve[1],be=a(null),ge=e(be,2),we=ge[0],ke=ge[1],ye=s(null),_e=function(e){if(0===e)return"0 Bytes";var n=Math.floor(Math.log(e)/Math.log(1024));return parseFloat((e/Math.pow(1024,n)).toFixed(2))+" "+["Bytes","KB","MB","GB"][n]},Ce=function(e){pe(""),function(e){var n;if("*"===N)return!0;var r=e.type,t=".".concat(null===(n=e.name.split(".").pop())||void 0===n?void 0:n.toLowerCase());return!!N.split(",").map(function(e){return e.trim()}).some(function(e){return e.startsWith(".")?t===e.toLowerCase():e.endsWith("/*")?r.startsWith("".concat(e.replace("/*",""),"/")):r===e})||(pe("File type not accepted. Please upload: ".concat(N)),!1)}(e)&&function(e){return!(E&&e.size>E&&(pe("File size exceeds the maximum limit of ".concat(_e(E))),1))}(e)&&(Q(e),se("idle"),oe(0))},Ne=function(){var e=n(r().m(function e(n){var t,o,i,l,a,s,c,u;return r().w(function(e){for(;;)switch(e.p=e.n){case 0:if(M&&X){e.n=1;break}return e.a(2,null);case 1:return e.p=1,o=JSON.stringify({file_url:n.location,file_key:n.key,file_name:n.title,file_size:n.size,content_type:n.content_type,media_type:null!==(t=n.content_type)&&void 0!==t&&t.startsWith("video/")?"video":"image"}),i=p("POST",o,X,"json"),e.n=2,fetch(M,i);case 2:if(!(l=e.v).ok){e.n=4;break}return e.n=3,l.json();case 3:return a=e.v,e.a(2,a.id);case 4:return s=console,c=l.status,e.n=5,l.text();case 5:s.error.call(s,"Save to DB failed:",c,e.v),e.n=7;break;case 6:e.p=6,u=e.v,console.error("Save to DB error:",u);case 7:return e.a(2,null)}},e,null,[[1,6]])}));return function(n){return e.apply(this,arguments)}}(),xe=function(){var e=n(r().m(function e(n){var t,o,i,l;return r().w(function(e){for(;;)switch(e.p=e.n){case 0:if(e.p=0,t=new URL(n),o=t.pathname.replace(/^\//,"")){e.n=1;break}return e.a(2);case 1:return i=new h({region:process.env.NEXT_PUBLIC_AWS_REGION,endpoint:process.env.NEXT_PUBLIC_AWS_S3_ENDPOINT_URL,requestChecksumCalculation:"WHEN_REQUIRED",credentials:{accessKeyId:process.env.NEXT_PUBLIC_AWS_ACCESS_KEY_ID||"",secretAccessKey:process.env.NEXT_PUBLIC_AWS_SECRET_ACCESS_KEY||""}}),e.n=2,i.send(new m({Bucket:process.env.NEXT_PUBLIC_AWS_BUCKET_NAME||"",Key:o}));case 2:e.n=4;break;case 3:e.p=3,l=e.v,console.error("S3 delete error:",l);case 4:return e.a(2)}},e,null,[[0,3]])}));return function(n){return e.apply(this,arguments)}}(),Ee=function(){var e=n(r().m(function e(n){var t,o,i;return r().w(function(e){for(;;)switch(e.p=e.n){case 0:if(O&&X){e.n=1;break}return e.a(2,!1);case 1:return e.p=1,t=p("DELETE",null,X),e.n=2,fetch("".concat(O).concat(n,"/"),t);case 2:return o=e.v,e.a(2,o.ok||404===o.status);case 3:return e.p=3,i=e.v,console.error("DB delete error:",i),e.a(2,!1)}},e,null,[[1,3]])}));return function(n){return e.apply(this,arguments)}}(),Le=function(){var e=n(r().m(function e(n){var t;return r().w(function(e){for(;;)switch(e.n){case 0:if(t=me[n]){e.n=1;break}return e.a(2);case 1:if(!t.dbId||!O){e.n=2;break}return e.n=2,Ee(t.dbId);case 2:if(!H||!t.response.location){e.n=3;break}return e.n=3,xe(t.response.location);case 3:fe(function(e){return e.filter(function(e,r){return r!==n})}),G&&G(t.response),b("File removed");case 4:return e.a(2)}},e)}));return function(n){return e.apply(this,arguments)}}(),Be=function(){var e=n(r().m(function e(){var n,o,i,l,a,s,p,m,g,w,k,y,_,C;return r().w(function(e){for(;;)switch(e.p=e.n){case 0:if(q){e.n=1;break}return pe("Please select a file first"),e.a(2);case 1:if(se("uploading"),pe(""),e.p=2,n=new h({region:process.env.NEXT_PUBLIC_AWS_REGION,endpoint:process.env.NEXT_PUBLIC_AWS_S3_ENDPOINT_URL,requestChecksumCalculation:"WHEN_REQUIRED",credentials:{accessKeyId:process.env.NEXT_PUBLIC_AWS_ACCESS_KEY_ID||"",secretAccessKey:process.env.NEXT_PUBLIC_AWS_SECRET_ACCESS_KEY||""}}),o=(new Date).toISOString(),i=u("".concat(A||"anonymous","-").concat(o,"-").concat(q.name)),l=d?"test-env__".concat(i):i,a="video/*"===N?process.env.NEXT_PUBLIC_AWS_LOCATION:process.env.NEXT_PUBLIC_AWS_LOCATION_FILES,s=process.env.NEXT_PUBLIC_AWS_BUCKET_NAME||"",p="".concat(a,"/").concat(l),!(q.size<104857600)){e.n=4;break}return oe(10),m=new v({Bucket:s,Key:p,Body:q,ContentType:q.type,ACL:"public-read"}),g=setInterval(function(){oe(function(e){return Math.min(e+5,95)})},300),e.n=3,n.send(m);case 3:clearInterval(g),oe(100),e.n=5;break;case 4:return(w=new f({client:n,params:{Bucket:s,Key:p,Body:q,ContentType:q.type,ACL:"public-read"}})).on("httpUploadProgress",function(e){var n=Math.round(e.loaded/e.total*100);oe(n)}),e.n=5,w.done();case 5:if(se("success"),b("File Uploaded Successfully!"),k={bucket:s,title:q.name,key:l,content_type:q.type,size:q.size,location:"".concat(c,"creators/").concat(l)},!M||!X){e.n=7;break}return e.n=6,Ne(k);case 6:(_=e.v)&&(y=_);case 7:fe(function(e){return[].concat(t(e),[{response:k,dbId:y,fullS3Key:p}])}),P&&P(k),D&&D(B,k.key),R&&R(I,B,k.key),j&&j(I,T,B,k.key),setTimeout(function(){Q(null),se("idle"),oe(0)},2e3),e.n=9;break;case 8:e.p=8,C=e.v,console.error("Upload error:",C),se("error"),pe("Error uploading file. Please try again."),b("Error uploading file!",400),oe(0);case 9:return e.a(2)}},e,null,[[2,8]])}));return function(){return e.apply(this,arguments)}}(),Se=function(){Q(null),se("idle"),oe(0),pe("")};return o("div",{className:"ihub-uploader ".concat(z),children:[k&&i("h3",{className:"ihub-uploader-header",children:k}),o("div",{className:"ihub-uploader-container",children:[!q&&o("div",{className:"ihub-uploader-dropzone ".concat($?"ihub-uploader-dropzone-active":""),onDragOver:function(e){e.preventDefault(),e.stopPropagation(),ee(!0)},onDragLeave:function(e){e.preventDefault(),e.stopPropagation(),ee(!1)},onDrop:function(e){e.preventDefault(),e.stopPropagation(),ee(!1);var n=e.dataTransfer.files;n&&n.length>0&&Ce(n[0])},onClick:function(){var e;null===(e=ye.current)||void 0===e||e.click()},children:[i("div",{className:"ihub-uploader-icon",children:o("svg",{xmlns:"http://www.w3.org/2000/svg",width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),i("polyline",{points:"17 8 12 3 7 8"}),i("line",{x1:"12",y1:"3",x2:"12",y2:"15"})]})}),i("p",{className:"ihub-uploader-text",children:_}),i("p",{className:"ihub-uploader-hint",children:E>0&&"Maximum file size: ".concat(_e(E))}),i("input",{ref:ye,type:"file",accept:N,onChange:function(e){var n=e.target.files;n&&n.length>0&&Ce(n[0])},className:"ihub-uploader-input"})]}),q&&o("div",{className:"ihub-uploader-preview",children:[o("div",{className:"ihub-uploader-file-info",children:[i("div",{className:"ihub-uploader-file-icon",children:q.type.startsWith("image/")?i("img",{src:URL.createObjectURL(q),alt:q.name,className:"ihub-uploader-thumbnail"}):o("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),i("polyline",{points:"14 2 14 8 20 8"}),i("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),i("line",{x1:"16",y1:"17",x2:"8",y2:"17"}),i("polyline",{points:"10 9 9 9 8 9"})]})}),o("div",{className:"ihub-uploader-file-details",children:[i("p",{className:"ihub-uploader-file-name",children:q.name}),i("p",{className:"ihub-uploader-file-size",children:_e(q.size)})]})]}),"uploading"===ae&&i("div",{className:"ihub-uploader-progress",children:i("div",{className:"ihub-uploader-progress-bar",style:{width:"".concat(te,"%")},children:o("span",{className:"ihub-uploader-progress-text",children:[te,"%"]})})}),o("div",{className:"ihub-uploader-actions",children:["idle"===ae&&o(l,{children:[i("button",{className:"ihub-uploader-upload-btn ihub-important-btn",onClick:Be,children:"Upload"}),i("button",{className:"ihub-uploader-cancel-btn outlined-btn",onClick:Se,children:"Cancel"})]}),"uploading"===ae&&i("button",{className:"ihub-uploader-cancel-btn outlined-btn",onClick:Se,children:"Cancel"}),"success"===ae&&o("div",{className:"ihub-uploader-success",children:[o("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i("path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14"}),i("polyline",{points:"22 4 12 14.01 9 11.01"})]}),i("span",{children:"Upload Complete"})]}),"error"===ae&&o(l,{children:[i("button",{className:"ihub-uploader-retry-btn ihub-important-btn",onClick:Be,children:"Retry"}),i("button",{className:"ihub-uploader-cancel-btn outlined-btn",onClick:Se,children:"Cancel"})]})]})]}),me.length>0&&i("div",{className:"ihub-uploader-thumbs",children:me.map(function(e,n){var r,t=null===(r=e.response.content_type)||void 0===r?void 0:r.startsWith("video/");return o("div",{className:"ihub-uploader-thumb",children:[o("div",{className:"ihub-uploader-thumb-preview",onClick:function(){return ke(n)},title:"Click to preview",children:[t?i("video",{src:e.response.location,muted:!0}):i("img",{src:e.response.location,alt:e.response.title}),t&&i("span",{className:"ihub-uploader-thumb-badge",children:i("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"currentColor",children:i("polygon",{points:"5 3 19 12 5 21 5 3"})})})]}),i("button",{type:"button",className:"ihub-uploader-thumb-remove",onClick:function(e){e.stopPropagation(),Le(n)},title:"Remove",children:o("svg",{xmlns:"http://www.w3.org/2000/svg",width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:[i("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),i("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},n)})}),null!==we&&me[we]&&i("div",{className:"ihub-uploader-lightbox",onClick:function(){return ke(null)},children:o("div",{className:"ihub-uploader-lightbox-content",onClick:function(e){return e.stopPropagation()},children:[i("button",{className:"ihub-uploader-lightbox-close",onClick:function(){return ke(null)},children:o("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),i("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}),we>0&&i("button",{className:"ihub-uploader-lightbox-nav ihub-uploader-lightbox-prev",onClick:function(){return ke(we-1)},children:i("svg",{xmlns:"http://www.w3.org/2000/svg",width:"28",height:"28",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:i("polyline",{points:"15 18 9 12 15 6"})})}),i("div",{className:"ihub-uploader-lightbox-media",children:null!==(w=me[we].response.content_type)&&void 0!==w&&w.startsWith("video/")?i("video",{src:me[we].response.location,controls:!0,autoPlay:!0}):i("img",{src:me[we].response.location,alt:me[we].response.title})}),we<me.length-1&&i("button",{className:"ihub-uploader-lightbox-nav ihub-uploader-lightbox-next",onClick:function(){return ke(we+1)},children:i("svg",{xmlns:"http://www.w3.org/2000/svg",width:"28",height:"28",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:i("polyline",{points:"9 18 15 12 9 6"})})}),o("div",{className:"ihub-uploader-lightbox-info",children:[i("span",{children:me[we].response.title}),o("span",{children:[we+1," / ",me.length]})]})]})}),de&&o("div",{className:"ihub-uploader-error",children:[o("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i("circle",{cx:"12",cy:"12",r:"10"}),i("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),i("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}),i("span",{children:de})]})]})]})}export{g as default};
|
|
2
2
|
//# sourceMappingURL=IhubFileUploader.js.map
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { FileUploaderType } from "@/types";
|
|
2
2
|
/**
|
|
3
|
-
* A modern file uploader component with drag and drop support
|
|
3
|
+
* A modern file uploader component with drag and drop support.
|
|
4
|
+
* Uploads directly to S3, optionally saves to DB, and supports
|
|
5
|
+
* delete from both DB and S3.
|
|
4
6
|
*/
|
|
5
|
-
export default function IhubFileUploader({ header, label, accept, maxFileSize, name, module, step, username, onUploadComplete, setValues, setModules, setSteps, className, }: FileUploaderType): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export default function IhubFileUploader({ header, label, accept, maxFileSize, name, module, step, username, onUploadComplete, setValues, setModules, setSteps, className, saveEndpoint, deleteEndpoint, token, enableS3Delete, onRemove, }: FileUploaderType): import("react/jsx-runtime").JSX.Element;
|
|
@@ -150,6 +150,16 @@ export interface FileUploaderType {
|
|
|
150
150
|
setSteps?: (module: string, step: string, name: string, value: string) => void;
|
|
151
151
|
/** Additional CSS class names */
|
|
152
152
|
className?: string;
|
|
153
|
+
/** API endpoint to save media record after S3 upload (POST). If set, saves to DB automatically. */
|
|
154
|
+
saveEndpoint?: string;
|
|
155
|
+
/** API endpoint prefix for deleting media record (DELETE {deleteEndpoint}/{id}/). If set, enables DB delete on remove. */
|
|
156
|
+
deleteEndpoint?: string;
|
|
157
|
+
/** Auth token for API calls (used with reqOptions for saveEndpoint/deleteEndpoint). */
|
|
158
|
+
token?: string | null;
|
|
159
|
+
/** If true, delete file from S3 when user removes it. Requires the file_url to extract the S3 key. Default: false. */
|
|
160
|
+
enableS3Delete?: boolean;
|
|
161
|
+
/** Callback when a file is removed (after DB + S3 delete). Receives the S3UploadResponseType of the removed file. */
|
|
162
|
+
onRemove?: (response: S3UploadResponseType) => void;
|
|
153
163
|
}
|
|
154
164
|
export interface FetchDataType {
|
|
155
165
|
page: string;
|