@instincthub/react-ui 0.1.42 → 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.
@@ -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 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 t from"@mui/icons-material/VisibilityOff";function s(s){var o=s.id,u=s.name,c=s.label,m=s.note,d=s.required,h=void 0!==d&&d,p=s.value,b=void 0===p?"":p,v=s.setValue,f=s.onChange,N=s.setNameValue,w=s.error,x=s.className,y=s.helperText,_=s.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:u,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:t,{})})]})}),y&&!w&&a("p",{className:"ihub-notes",children:y}),w&&a("p",{className:"ihub-notes ihub-is_invalid",children:w}),m&&a("p",{className:"ihub-input-notes",id:"".concat(o,"-note"),children:m})]})}export{s as default};
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;