@instincthub/react-ui 0.5.1 → 0.6.1

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.
@@ -814,6 +814,30 @@ small {
814
814
  border-radius: 50%;
815
815
  }
816
816
  /* -----LOADER */
817
+ /* LoadingAnimate variant="inline": inside its container, never the
818
+ fixed full-viewport overlay (.react_loading). */
819
+ .ihub-loading-inline {
820
+ display: flex;
821
+ align-items: center;
822
+ justify-content: center;
823
+ width: 100%;
824
+ min-height: 48px;
825
+ padding: 4px 0;
826
+ }
827
+ .ihub-loading-inline .lds-ellipsis {
828
+ height: 40px;
829
+ }
830
+ .ihub-loading-inline .lds-ellipsis div {
831
+ top: 13px;
832
+ }
833
+ .ihub-loading-inline__label {
834
+ position: absolute;
835
+ width: 1px;
836
+ height: 1px;
837
+ overflow: hidden;
838
+ clip: rect(0 0 0 0);
839
+ white-space: nowrap;
840
+ }
817
841
  .lds-ellipsis {
818
842
  display: inline-block;
819
843
  position: relative;
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_rollupPluginBabelHelpers.cjs"),n=require("react/jsx-runtime"),i=require("react");function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=t(require("@mui/icons-material/MenuOutlined"));exports.default=function(t){var o=t.items,r=t.icon,c=t.position,u=void 0===c?"right":c,s=t.className,l=void 0===s?"":s,d=t.title,m=void 0===d?"Open menu":d,b=i.useState(!1),p=e.slicedToArray(b,2),f=p[0],h=p[1],v=i.useRef(null);return i.useEffect(function(){function e(e){v.current&&!v.current.contains(e.target)&&h(!1)}return document.addEventListener("mousedown",e),function(){document.removeEventListener("mousedown",e)}},[]),n.jsxs("div",{className:"ihub-action-dropdown ".concat(l," ").concat(f?"ihub-dropdown-active":""),ref:v,onKeyDown:function(e){"Escape"===e.key&&h(!1)},children:[n.jsx("button",{className:"ihub-dropdown-toggle",onClick:function(){return h(!f)},"aria-haspopup":"true","aria-expanded":f,title:m,children:r||n.jsx(a.default,{})}),f&&n.jsx("ul",{className:"ihub-main-list ihub-position-".concat(u),role:"menu",children:o.map(function(e,i){return e.label&&n.jsxs("li",{className:"".concat(e.disabled?"ihub-item-disabled":""," ").concat(e.className||""),onClick:e.disabled?void 0:(t=e.onClick,function(){t&&t(),h(!1)}),role:"menuitem",tabIndex:e.disabled?-1:0,children:[e.icon&&n.jsx("span",{className:"ihub-item-icon",children:e.icon}),n.jsx("span",{className:"ihub-item-label",children:e.label})]},i);var t})})]})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_rollupPluginBabelHelpers.cjs"),n=require("react/jsx-runtime"),i=require("react");function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=t(require("@mui/icons-material/MenuOutlined"));exports.default=function(t){var o=t.items,r=t.icon,u=t.position,c=void 0===u?"right":u,s=t.className,l=void 0===s?"":s,d=t.title,m=void 0===d?"Open menu":d,b=i.useState(!1),p=e.slicedToArray(b,2),f=p[0],h=p[1],v=i.useRef(null);return i.useEffect(function(){function e(e){v.current&&!v.current.contains(e.target)&&h(!1)}return document.addEventListener("mousedown",e),function(){document.removeEventListener("mousedown",e)}},[]),n.jsxs("div",{className:"ihub-action-dropdown ".concat(l," ").concat(f?"ihub-dropdown-active":""),ref:v,onKeyDown:function(e){"Escape"===e.key&&h(!1)},children:[n.jsx("button",{type:"button",className:"ihub-dropdown-toggle",onClick:function(){return h(!f)},"aria-haspopup":"true","aria-expanded":f,title:m,children:r||n.jsx(a.default,{})}),f&&n.jsx("ul",{className:"ihub-main-list ihub-position-".concat(c),role:"menu",children:o.map(function(e,i){return e.label&&n.jsxs("li",{className:"".concat(e.disabled?"ihub-item-disabled":""," ").concat(e.className||""),onClick:e.disabled?void 0:(t=e.onClick,function(){t&&t(),h(!1)}),role:"menuitem",tabIndex:e.disabled?-1:0,children:[e.icon&&n.jsx("span",{className:"ihub-item-icon",children:e.icon}),n.jsx("span",{className:"ihub-item-label",children:e.label})]},i);var t})})]})};
2
2
  //# sourceMappingURL=ActionCallbackDropdown.cjs.map
@@ -1,2 +1,2 @@
1
- import{slicedToArray as e}from"../../../_virtual/_rollupPluginBabelHelpers.js";import{jsxs as n,jsx as i}from"react/jsx-runtime";import{useState as o,useRef as t,useEffect as a}from"react";import r from"@mui/icons-material/MenuOutlined";function c(c){var l=c.items,u=c.icon,s=c.position,d=void 0===s?"right":s,m=c.className,p=void 0===m?"":m,b=c.title,h=void 0===b?"Open menu":b,f=o(!1),v=e(f,2),N=v[0],w=v[1],g=t(null);a(function(){function e(e){g.current&&!g.current.contains(e.target)&&w(!1)}return document.addEventListener("mousedown",e),function(){document.removeEventListener("mousedown",e)}},[]);return n("div",{className:"ihub-action-dropdown ".concat(p," ").concat(N?"ihub-dropdown-active":""),ref:g,onKeyDown:function(e){"Escape"===e.key&&w(!1)},children:[i("button",{className:"ihub-dropdown-toggle",onClick:function(){return w(!N)},"aria-haspopup":"true","aria-expanded":N,title:h,children:u||i(r,{})}),N&&i("ul",{className:"ihub-main-list ihub-position-".concat(d),role:"menu",children:l.map(function(e,o){return e.label&&n("li",{className:"".concat(e.disabled?"ihub-item-disabled":""," ").concat(e.className||""),onClick:e.disabled?void 0:(t=e.onClick,function(){t&&t(),w(!1)}),role:"menuitem",tabIndex:e.disabled?-1:0,children:[e.icon&&i("span",{className:"ihub-item-icon",children:e.icon}),i("span",{className:"ihub-item-label",children:e.label})]},o);var t})})]})}export{c as default};
1
+ import{slicedToArray as e}from"../../../_virtual/_rollupPluginBabelHelpers.js";import{jsxs as n,jsx as i}from"react/jsx-runtime";import{useState as o,useRef as t,useEffect as a}from"react";import r from"@mui/icons-material/MenuOutlined";function c(c){var l=c.items,u=c.icon,s=c.position,d=void 0===s?"right":s,m=c.className,p=void 0===m?"":m,b=c.title,h=void 0===b?"Open menu":b,f=o(!1),v=e(f,2),N=v[0],w=v[1],g=t(null);a(function(){function e(e){g.current&&!g.current.contains(e.target)&&w(!1)}return document.addEventListener("mousedown",e),function(){document.removeEventListener("mousedown",e)}},[]);return n("div",{className:"ihub-action-dropdown ".concat(p," ").concat(N?"ihub-dropdown-active":""),ref:g,onKeyDown:function(e){"Escape"===e.key&&w(!1)},children:[i("button",{type:"button",className:"ihub-dropdown-toggle",onClick:function(){return w(!N)},"aria-haspopup":"true","aria-expanded":N,title:h,children:u||i(r,{})}),N&&i("ul",{className:"ihub-main-list ihub-position-".concat(d),role:"menu",children:l.map(function(e,o){return e.label&&n("li",{className:"".concat(e.disabled?"ihub-item-disabled":""," ").concat(e.className||""),onClick:e.disabled?void 0:(t=e.onClick,function(){t&&t(),w(!1)}),role:"menuitem",tabIndex:e.disabled?-1:0,children:[e.icon&&i("span",{className:"ihub-item-icon",children:e.icon}),i("span",{className:"ihub-item-label",children:e.label})]},o);var t})})]})}export{c as default};
2
2
  //# sourceMappingURL=ActionCallbackDropdown.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_rollupPluginBabelHelpers.cjs"),n=require("react/jsx-runtime"),r=require("react");function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var i=t(require("next/link"));exports.default=function(t){var u=r.useState(!1),c=e.slicedToArray(u,2),l=c[0],o=c[1],s=r.useRef(null);return r.useEffect(function(){var e=function(e){s.current&&!s.current.contains(e.target)&&o(!1)};return document.addEventListener("mousedown",e),function(){document.removeEventListener("mousedown",e)}},[]),n.jsx("div",{className:"ihub-react-action",ref:s,children:n.jsxs("div",{className:"ctrl-dropdown",children:[n.jsx("button",{className:"outlined-btn",onClick:function(){o(!l)},children:"..."}),l&&n.jsx("ul",{className:"main_list",children:t.items.map(function(e,r){return n.jsx("li",{children:e.url?n.jsxs(i.default,{href:e.url,onClick:function(){return o(!1)},children:[e.icon,e.label]}):n.jsxs("button",{onClick:function(){return(n=e).onClick&&n.onClick(),void o(!1);var n},children:[e.icon,e.label]})},r)})})]})})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_rollupPluginBabelHelpers.cjs"),n=require("react/jsx-runtime"),t=require("react");function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u=r(require("next/link"));exports.default=function(r){var i=t.useState(!1),c=e.slicedToArray(i,2),l=c[0],o=c[1],s=t.useRef(null);return t.useEffect(function(){var e=function(e){s.current&&!s.current.contains(e.target)&&o(!1)};return document.addEventListener("mousedown",e),function(){document.removeEventListener("mousedown",e)}},[]),n.jsx("div",{className:"ihub-react-action",ref:s,children:n.jsxs("div",{className:"ctrl-dropdown",children:[n.jsx("button",{type:"button",className:"outlined-btn",onClick:function(){o(!l)},children:"..."}),l&&n.jsx("ul",{className:"main_list",children:r.items.map(function(e,t){return n.jsx("li",{children:e.url?n.jsxs(u.default,{href:e.url,onClick:function(){return o(!1)},children:[e.icon,e.label]}):n.jsxs("button",{type:"button",onClick:function(){return(n=e).onClick&&n.onClick(),void o(!1);var n},children:[e.icon,e.label]})},t)})})]})})};
2
2
  //# sourceMappingURL=ActionDropdown.cjs.map
@@ -1,2 +1,2 @@
1
- import{slicedToArray as n}from"../../../_virtual/_rollupPluginBabelHelpers.js";import{jsx as r,jsxs as e}from"react/jsx-runtime";import{useState as t,useRef as i,useEffect as o}from"react";import l from"next/link";function c(c){var u=t(!1),a=n(u,2),d=a[0],m=a[1],s=i(null);return o(function(){var n=function(n){s.current&&!s.current.contains(n.target)&&m(!1)};return document.addEventListener("mousedown",n),function(){document.removeEventListener("mousedown",n)}},[]),r("div",{className:"ihub-react-action",ref:s,children:e("div",{className:"ctrl-dropdown",children:[r("button",{className:"outlined-btn",onClick:function(){m(!d)},children:"..."}),d&&r("ul",{className:"main_list",children:c.items.map(function(n,t){return r("li",{children:n.url?e(l,{href:n.url,onClick:function(){return m(!1)},children:[n.icon,n.label]}):e("button",{onClick:function(){return(r=n).onClick&&r.onClick(),void m(!1);var r},children:[n.icon,n.label]})},t)})})]})})}export{c as default};
1
+ import{slicedToArray as n}from"../../../_virtual/_rollupPluginBabelHelpers.js";import{jsx as r,jsxs as t}from"react/jsx-runtime";import{useState as e,useRef as i,useEffect as o}from"react";import l from"next/link";function c(c){var u=e(!1),a=n(u,2),d=a[0],m=a[1],s=i(null);return o(function(){var n=function(n){s.current&&!s.current.contains(n.target)&&m(!1)};return document.addEventListener("mousedown",n),function(){document.removeEventListener("mousedown",n)}},[]),r("div",{className:"ihub-react-action",ref:s,children:t("div",{className:"ctrl-dropdown",children:[r("button",{type:"button",className:"outlined-btn",onClick:function(){m(!d)},children:"..."}),d&&r("ul",{className:"main_list",children:c.items.map(function(n,e){return r("li",{children:n.url?t(l,{href:n.url,onClick:function(){return m(!1)},children:[n.icon,n.label]}):t("button",{type:"button",onClick:function(){return(r=n).onClick&&r.onClick(),void m(!1);var r},children:[n.icon,n.label]})},e)})})]})})}export{c as default};
2
2
  //# sourceMappingURL=ActionDropdown.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_rollupPluginBabelHelpers.cjs"),a=require("react/jsx-runtime"),t=require("@mui/icons-material/CalendarMonthOutlined"),n=require("react");function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var i=r(t);exports.default=function(t){var r=t.label,l=t.value,s=void 0===l?"":l,c=t.onChange,u=t.required,o=void 0!==u&&u,d=t.minDate,h=t.maxDate,p=t.disabledDates,b=void 0===p?[]:p,v=t.errorMessage,f=t.className,m=void 0===f?"":f;t.displayFormat,t.locale;var g=t.includeTime,x=void 0!==g&&g,y=t.name,j=t.id;t.placeholder;var N=t.disabled,T=void 0!==N&&N,D=t.showCalendarPicker,w=void 0===D||D,S=t.showQuickActions,C=void 0===S||S,k=t.ariaLabel,M=n.useState(s),A=e.slicedToArray(M,2),F=A[0],Y=A[1],I=n.useState(s?new Date(s):null),L=e.slicedToArray(I,2),q=L[0],P=L[1],B=n.useState(!1),E=e.slicedToArray(B,2),O=E[0],H=E[1],R=n.useState(v||null),$=e.slicedToArray(R,2),_=$[0],J=$[1],K=n.useState(s?s.split("-")[0]:""),Q=e.slicedToArray(K,2),W=Q[0],z=Q[1],G=n.useState(s?s.split("-")[1]:""),U=e.slicedToArray(G,2),V=U[0],X=U[1],Z=n.useState(s?s.split("-")[2]:""),ee=e.slicedToArray(Z,2),ae=ee[0],te=ee[1],ne=n.useState(s&&x&&s.includes("T")?s.split("T")[1].split(":")[0]:"00"),re=e.slicedToArray(ne,2),ie=re[0],le=re[1],se=n.useState(s&&x&&s.includes("T")?s.split("T")[1].split(":")[1]:"00"),ce=e.slicedToArray(se,2),ue=ce[0],oe=ce[1],de=n.useRef(null),he=n.useRef(null),pe=n.useRef(null),be=n.useRef(null),ve=n.useRef(null),fe=n.useState(q?q.getMonth():(new Date).getMonth()),me=e.slicedToArray(fe,2),ge=me[0],xe=me[1],ye=n.useState(q?q.getFullYear():(new Date).getFullYear()),je=e.slicedToArray(ye,2),Ne=je[0],Te=je[1];n.useEffect(function(){if(s){var a=new Date(s);if(!isNaN(a.getTime())&&(P(a),Y(s),s.includes("-"))){var t=s.split("-"),n=e.slicedToArray(t,3),r=n[0],i=n[1],l=n[2];if(z(r),X(i),te(l.split("T")[0]||l),x&&s.includes("T")){var c=s.split("T")[1];if(c){var u=c.split(":"),o=e.slicedToArray(u,2),d=o[0],h=o[1];le(d),oe(h)}}}}},[s,x]),n.useEffect(function(){var e=function(e){de.current&&!de.current.contains(e.target)&&he.current&&!he.current.contains(e.target)&&H(!1)};return document.addEventListener("mousedown",e),function(){document.removeEventListener("mousedown",e)}},[]);var De=function(e){var a=new Date(e);return!isNaN(a.getTime())},we=function(){return J(null),o&&!F?(J("Date is required"),!1):!F||(De(F)?function(e){if(!d&&!h)return!0;var a=new Date(e),t=d?new Date(d):null,n=h?new Date(h):null;return!(t&&a<t||n&&a>n)}(F)?(e=F,!b.includes(e)||(J("This date is not available"),!1)):(J("Date must be between ".concat(d||"any"," and ").concat(h||"any")),!1):(J("Please enter a valid date"),!1));var e},Se=function(e,a,t){if(4===e.length&&2===a.length&&2===t.length){var n=a.padStart(2,"0"),r=t.padStart(2,"0"),i="".concat(e,"-").concat(n,"-").concat(r);if(De(i)){var l=new Date(i);if(P(l),Y(i),x)return void Ce(e,a,t,ie,ue);c&&c(i)}}},Ce=function(e,a,t,n,r){if(4===e.length&&2===a.length&&2===t.length){var i=a.padStart(2,"0"),l=t.padStart(2,"0"),s=n.padStart(2,"0"),u=r.padStart(2,"0"),o="".concat(e,"-").concat(i,"-").concat(l,"T").concat(s,":").concat(u,":00");if(De(o)){var d=new Date(o);P(d),Y(o),c&&c(o)}}},ke=function(e,a){"Tab"!==e.key&&("Enter"!==e.key&&" "!==e.key||"day"!==a||(e.preventDefault(),H(!O)),"/"===e.key&&(e.preventDefault(),"month"===a&&ve.current?ve.current.focus():"year"===a&&be.current&&be.current.focus()),"Escape"===e.key&&H(!1))},Me=function(){},Ae=function(e){we()},Fe=function(){xe(function(e){return 0===e?(Te(function(e){return e-1}),11):e-1})},Ye=function(){xe(function(e){return 11===e?(Te(function(e){return e+1}),0):e+1})},Ie=function(){Te(function(e){return e-1})},Le=function(){Te(function(e){return e+1})},qe=function(e){var a=e.currentTarget.getAttribute("data-day"),t=e.currentTarget.getAttribute("data-month"),n=e.currentTarget.getAttribute("data-year"),r=new Date(parseInt(n),parseInt(t),parseInt(a)+1),i=r.toISOString().split("T")[0];if(P(r),z(i.split("-")[0]),X(i.split("-")[1]),te(i.split("-")[2]),x){var l="".concat(i,"T").concat(ie.padStart(2,"0"),":").concat(ue.padStart(2,"0"),":00");Y(l),c&&c(l)}else Y(i),c&&c(i);we(),H(!1)},Pe=function(){var e=new Date,a=e.toISOString().split("T")[0];if(P(e),xe(e.getMonth()),Te(e.getFullYear()),z(a.split("-")[0]),X(a.split("-")[1]),te(a.split("-")[2]),x){var t=e.getHours().toString().padStart(2,"0"),n=e.getMinutes().toString().padStart(2,"0");le(t),oe(n);var r="".concat(a,"T").concat(t,":").concat(n,":00");Y(r),c&&c(r)}else Y(a),c&&c(a)},Be=function(){P(null),Y(""),z(""),X(""),te(""),le("00"),oe("00"),c&&c("")};return a.jsxs("div",{className:"ihub-wrapper",children:[a.jsxs("div",{className:"ihub-date-wrapper ".concat(m," ").concat(_?"ihub-is_invalid":""),children:[a.jsxs("label",{className:"ihub-text-label",htmlFor:j||y,children:[r,o&&a.jsx("span",{className:"ihub-required",children:"*"})]}),a.jsxs("div",{ref:he,className:"ihub-date-input-container ".concat(_?"date-err":""),onClick:function(){return!T&&w&&H(!0)},children:[a.jsx("input",{ref:pe,type:"text",className:"ihub-date-input ihub-date-year",value:W,onChange:function(e){var a=e.target.value.slice(0,4);/^\d*$/.test(a)&&(z(a),Se(a,V,ae))},onFocus:Me,onBlur:Ae,onKeyDown:function(e){return ke(e,"year")},placeholder:"YYYY",maxLength:4,disabled:T,"aria-label":"Year ".concat(k||r),"aria-invalid":!!_}),a.jsx("span",{className:"ihub-date-separator",children:"-"}),a.jsx("input",{ref:be,type:"text",className:"ihub-date-input",value:V,onChange:function(e){var a=e.target.value.slice(0,2);/^\d*$/.test(a)&&parseInt(a)<=12&&(X(a),Se(W,a,ae),2===a.length&&ve.current&&ve.current.focus())},onFocus:Me,onBlur:Ae,onKeyDown:function(e){return ke(e,"month")},placeholder:"MM",maxLength:2,disabled:T,"aria-label":"Month ".concat(k||r),"aria-invalid":!!_}),a.jsx("span",{className:"ihub-date-separator",children:"-"}),a.jsx("input",{ref:ve,type:"text",className:"ihub-date-input",value:ae,onChange:function(e){var a=e.target.value.slice(0,2);/^\d*$/.test(a)&&parseInt(a)<=31&&(te(a),Se(W,V,a))},onFocus:Me,onBlur:Ae,onKeyDown:function(e){return ke(e,"day")},placeholder:"DD",maxLength:2,disabled:T,"aria-label":"Day ".concat(k||r),"aria-invalid":!!_}),x&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"ihub-datetime-separator",children:"at"}),a.jsxs("div",{className:"ihub-time-wrapper",children:[a.jsx("input",{type:"text",className:"ihub-date-input",value:ie,onChange:function(e){var a=e.target.value.slice(0,2);/^\d*$/.test(a)&&parseInt(a)<=23&&(le(a),Ce(W,V,ae,a,ue))},onBlur:Ae,placeholder:"HH",maxLength:2,disabled:T,"aria-label":"Hours ".concat(k||r)}),a.jsx("span",{className:"ihub-date-separator",children:":"}),a.jsx("input",{type:"text",className:"ihub-date-input",value:ue,onChange:function(e){var a=e.target.value.slice(0,2);/^\d*$/.test(a)&&parseInt(a)<=59&&(oe(a),Ce(W,V,ae,ie,a))},onBlur:Ae,placeholder:"MM",maxLength:2,disabled:T,"aria-label":"Minutes ".concat(k||r)})]})]}),w&&a.jsx("button",{type:"button",className:"ihub-calendar-toggle",onClick:function(e){e.stopPropagation(),!T&&H(!O)},"aria-label":"Toggle calendar",disabled:T,children:a.jsx(i.default,{})})]}),_&&a.jsx("div",{className:"ihub-error-message",children:_}),O&&w&&!T&&a.jsx("div",{className:"ihub-calendar-container",ref:de,role:"dialog","aria-label":"Choose date",children:function(){var e=function(e,a){return new Date(e,a+1,0).getDate()}(Ne,ge),t=function(e,a){return new Date(e,a,1).getDay()}(Ne,ge),n=[];n.push(a.jsxs("div",{className:"ihub-calendar-header",children:[a.jsx("button",{className:"ihub-calendar-nav",onClick:Ie,"aria-label":"Previous Year",children:"«"}),a.jsx("button",{className:"ihub-calendar-nav",onClick:Fe,"aria-label":"Previous Month",children:"‹"}),a.jsx("div",{className:"ihub-calendar-title",children:a.jsxs("span",{children:[["January","February","March","April","May","June","July","August","September","October","November","December"][ge]," ",Ne]})}),a.jsx("button",{className:"ihub-calendar-nav",onClick:Ye,"aria-label":"Next Month",children:"›"}),a.jsx("button",{className:"ihub-calendar-nav",onClick:Le,"aria-label":"Next Year",children:"»"})]},"header")),n.push(a.jsxs("div",{className:"ihub-calendar-days",children:[a.jsx("div",{children:"Su"}),a.jsx("div",{children:"Mo"}),a.jsx("div",{children:"Tu"}),a.jsx("div",{children:"We"}),a.jsx("div",{children:"Th"}),a.jsx("div",{children:"Fr"}),a.jsx("div",{children:"Sa"})]},"weekdays"));for(var r=[],i=1,l=ge,s=Ne,c=0;c<6;c++){for(var u=[],o=0;o<7;o++)if(0===c&&o<t)u.push(a.jsx("div",{className:"ihub-calendar-cell"},"empty-".concat(o)));else if(i<=e){var p=new Date(Ne,ge,i),v=p.toISOString().split("T")[0],f=!!q&&(q.getDate()===i&&q.getMonth()===ge&&q.getFullYear()===Ne),m=(new Date).getDate()===i&&(new Date).getMonth()===ge&&(new Date).getFullYear()===Ne,g=d&&p<new Date(d)||h&&p>new Date(h)||b.includes(v);u.push(a.jsx("div",{className:"ihub-calendar-cell ".concat(f?"ihub-selected":""," ").concat(m?"ihub-today":""," ").concat(g?"ihub-disabled":""),"aria-selected":f,role:"gridcell",tabIndex:f?0:-1,"data-day":i,"data-month":l,"data-year":s,onClick:qe,children:i},"day-".concat(i))),i++}else u.push(a.jsx("div",{className:"ihub-calendar-cell"},"empty-after-".concat(o)));if(r.push(a.jsx("div",{className:"ihub-calendar-row",role:"row",children:u},"row-".concat(c))),i>e)break}return n.push(a.jsx("div",{className:"ihub-calendar-grid",role:"grid",children:r},"grid")),C&&n.push(a.jsxs("div",{className:"ihub-calendar-actions",children:[a.jsx("button",{className:"ihub-calendar-action-btn",onClick:Pe,type:"button",children:"Today"}),a.jsx("button",{className:"ihub-calendar-action-btn",onClick:Be,type:"button",children:"Clear"})]},"actions")),n}()})]}),C&&!T&&a.jsxs("div",{className:"ihub-auto-date ihub-date-picker-action",children:[a.jsx("span",{className:"ihub-set-today ihub-fs-sm",onClick:Pe,children:"Today"}),a.jsx("span",{className:"ihub-separator ihub-fs-sm",children:"|"}),a.jsx("span",{className:"ihub-clear-date ihub-fs-sm",onClick:Be,children:"Clear"})]}),y&&a.jsx("input",{type:"hidden",name:y,value:F})]})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_rollupPluginBabelHelpers.cjs"),a=require("react/jsx-runtime"),t=require("@mui/icons-material/CalendarMonthOutlined"),n=require("react");function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var i=r(t);exports.default=function(t){var r=t.label,l=t.value,s=void 0===l?"":l,c=t.onChange,u=t.required,o=void 0!==u&&u,d=t.minDate,h=t.maxDate,p=t.disabledDates,b=void 0===p?[]:p,v=t.errorMessage,f=t.className,m=void 0===f?"":f;t.displayFormat,t.locale;var g=t.includeTime,x=void 0!==g&&g,y=t.name,j=t.id;t.placeholder;var N=t.disabled,T=void 0!==N&&N,D=t.showCalendarPicker,w=void 0===D||D,S=t.showQuickActions,C=void 0===S||S,k=t.ariaLabel,M=n.useState(s),A=e.slicedToArray(M,2),F=A[0],Y=A[1],I=n.useState(s?new Date(s):null),L=e.slicedToArray(I,2),q=L[0],P=L[1],B=n.useState(!1),E=e.slicedToArray(B,2),O=E[0],H=E[1],R=n.useState(v||null),$=e.slicedToArray(R,2),_=$[0],J=$[1],K=n.useState(s?s.split("-")[0]:""),Q=e.slicedToArray(K,2),W=Q[0],z=Q[1],G=n.useState(s?s.split("-")[1]:""),U=e.slicedToArray(G,2),V=U[0],X=U[1],Z=n.useState(s?s.split("-")[2]:""),ee=e.slicedToArray(Z,2),ae=ee[0],te=ee[1],ne=n.useState(s&&x&&s.includes("T")?s.split("T")[1].split(":")[0]:"00"),re=e.slicedToArray(ne,2),ie=re[0],le=re[1],se=n.useState(s&&x&&s.includes("T")?s.split("T")[1].split(":")[1]:"00"),ce=e.slicedToArray(se,2),ue=ce[0],oe=ce[1],de=n.useRef(null),he=n.useRef(null),pe=n.useRef(null),be=n.useRef(null),ve=n.useRef(null),fe=n.useState(q?q.getMonth():(new Date).getMonth()),me=e.slicedToArray(fe,2),ge=me[0],xe=me[1],ye=n.useState(q?q.getFullYear():(new Date).getFullYear()),je=e.slicedToArray(ye,2),Ne=je[0],Te=je[1];n.useEffect(function(){if(s){var a=new Date(s);if(!isNaN(a.getTime())&&(P(a),Y(s),s.includes("-"))){var t=s.split("-"),n=e.slicedToArray(t,3),r=n[0],i=n[1],l=n[2];if(z(r),X(i),te(l.split("T")[0]||l),x&&s.includes("T")){var c=s.split("T")[1];if(c){var u=c.split(":"),o=e.slicedToArray(u,2),d=o[0],h=o[1];le(d),oe(h)}}}}},[s,x]),n.useEffect(function(){var e=function(e){de.current&&!de.current.contains(e.target)&&he.current&&!he.current.contains(e.target)&&H(!1)};return document.addEventListener("mousedown",e),function(){document.removeEventListener("mousedown",e)}},[]);var De=function(e){var a=new Date(e);return!isNaN(a.getTime())},we=function(){return J(null),o&&!F?(J("Date is required"),!1):!F||(De(F)?function(e){if(!d&&!h)return!0;var a=new Date(e),t=d?new Date(d):null,n=h?new Date(h):null;return!(t&&a<t||n&&a>n)}(F)?(e=F,!b.includes(e)||(J("This date is not available"),!1)):(J("Date must be between ".concat(d||"any"," and ").concat(h||"any")),!1):(J("Please enter a valid date"),!1));var e},Se=function(e,a,t){if(4===e.length&&2===a.length&&2===t.length){var n=a.padStart(2,"0"),r=t.padStart(2,"0"),i="".concat(e,"-").concat(n,"-").concat(r);if(De(i)){var l=new Date(i);if(P(l),Y(i),x)return void Ce(e,a,t,ie,ue);c&&c(i)}}},Ce=function(e,a,t,n,r){if(4===e.length&&2===a.length&&2===t.length){var i=a.padStart(2,"0"),l=t.padStart(2,"0"),s=n.padStart(2,"0"),u=r.padStart(2,"0"),o="".concat(e,"-").concat(i,"-").concat(l,"T").concat(s,":").concat(u,":00");if(De(o)){var d=new Date(o);P(d),Y(o),c&&c(o)}}},ke=function(e,a){"Tab"!==e.key&&("Enter"!==e.key&&" "!==e.key||"day"!==a||(e.preventDefault(),H(!O)),"/"===e.key&&(e.preventDefault(),"month"===a&&ve.current?ve.current.focus():"year"===a&&be.current&&be.current.focus()),"Escape"===e.key&&H(!1))},Me=function(){},Ae=function(e){we()},Fe=function(){xe(function(e){return 0===e?(Te(function(e){return e-1}),11):e-1})},Ye=function(){xe(function(e){return 11===e?(Te(function(e){return e+1}),0):e+1})},Ie=function(){Te(function(e){return e-1})},Le=function(){Te(function(e){return e+1})},qe=function(e){var a=e.currentTarget.getAttribute("data-day"),t=e.currentTarget.getAttribute("data-month"),n=e.currentTarget.getAttribute("data-year"),r=new Date(parseInt(n),parseInt(t),parseInt(a)+1),i=r.toISOString().split("T")[0];if(P(r),z(i.split("-")[0]),X(i.split("-")[1]),te(i.split("-")[2]),x){var l="".concat(i,"T").concat(ie.padStart(2,"0"),":").concat(ue.padStart(2,"0"),":00");Y(l),c&&c(l)}else Y(i),c&&c(i);we(),H(!1)},Pe=function(){var e=new Date,a=e.toISOString().split("T")[0];if(P(e),xe(e.getMonth()),Te(e.getFullYear()),z(a.split("-")[0]),X(a.split("-")[1]),te(a.split("-")[2]),x){var t=e.getHours().toString().padStart(2,"0"),n=e.getMinutes().toString().padStart(2,"0");le(t),oe(n);var r="".concat(a,"T").concat(t,":").concat(n,":00");Y(r),c&&c(r)}else Y(a),c&&c(a)},Be=function(){P(null),Y(""),z(""),X(""),te(""),le("00"),oe("00"),c&&c("")};return a.jsxs("div",{className:"ihub-wrapper",children:[a.jsxs("div",{className:"ihub-date-wrapper ".concat(m," ").concat(_?"ihub-is_invalid":""),children:[a.jsxs("label",{className:"ihub-text-label",htmlFor:j||y,children:[r,o&&a.jsx("span",{className:"ihub-required",children:"*"})]}),a.jsxs("div",{ref:he,className:"ihub-date-input-container ".concat(_?"date-err":""),onClick:function(){return!T&&w&&H(!0)},children:[a.jsx("input",{ref:pe,type:"text",className:"ihub-date-input ihub-date-year",value:W,onChange:function(e){var a=e.target.value.slice(0,4);/^\d*$/.test(a)&&(z(a),Se(a,V,ae))},onFocus:Me,onBlur:Ae,onKeyDown:function(e){return ke(e,"year")},placeholder:"YYYY",maxLength:4,disabled:T,"aria-label":"Year ".concat(k||r),"aria-invalid":!!_}),a.jsx("span",{className:"ihub-date-separator",children:"-"}),a.jsx("input",{ref:be,type:"text",className:"ihub-date-input",value:V,onChange:function(e){var a=e.target.value.slice(0,2);/^\d*$/.test(a)&&parseInt(a)<=12&&(X(a),Se(W,a,ae),2===a.length&&ve.current&&ve.current.focus())},onFocus:Me,onBlur:Ae,onKeyDown:function(e){return ke(e,"month")},placeholder:"MM",maxLength:2,disabled:T,"aria-label":"Month ".concat(k||r),"aria-invalid":!!_}),a.jsx("span",{className:"ihub-date-separator",children:"-"}),a.jsx("input",{ref:ve,type:"text",className:"ihub-date-input",value:ae,onChange:function(e){var a=e.target.value.slice(0,2);/^\d*$/.test(a)&&parseInt(a)<=31&&(te(a),Se(W,V,a))},onFocus:Me,onBlur:Ae,onKeyDown:function(e){return ke(e,"day")},placeholder:"DD",maxLength:2,disabled:T,"aria-label":"Day ".concat(k||r),"aria-invalid":!!_}),x&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"ihub-datetime-separator",children:"at"}),a.jsxs("div",{className:"ihub-time-wrapper",children:[a.jsx("input",{type:"text",className:"ihub-date-input",value:ie,onChange:function(e){var a=e.target.value.slice(0,2);/^\d*$/.test(a)&&parseInt(a)<=23&&(le(a),Ce(W,V,ae,a,ue))},onBlur:Ae,placeholder:"HH",maxLength:2,disabled:T,"aria-label":"Hours ".concat(k||r)}),a.jsx("span",{className:"ihub-date-separator",children:":"}),a.jsx("input",{type:"text",className:"ihub-date-input",value:ue,onChange:function(e){var a=e.target.value.slice(0,2);/^\d*$/.test(a)&&parseInt(a)<=59&&(oe(a),Ce(W,V,ae,ie,a))},onBlur:Ae,placeholder:"MM",maxLength:2,disabled:T,"aria-label":"Minutes ".concat(k||r)})]})]}),w&&a.jsx("button",{type:"button",className:"ihub-calendar-toggle",onClick:function(e){e.stopPropagation(),!T&&H(!O)},"aria-label":"Toggle calendar",disabled:T,children:a.jsx(i.default,{})})]}),_&&a.jsx("div",{className:"ihub-error-message",children:_}),O&&w&&!T&&a.jsx("div",{className:"ihub-calendar-container",ref:de,role:"dialog","aria-label":"Choose date",children:function(){var e=function(e,a){return new Date(e,a+1,0).getDate()}(Ne,ge),t=function(e,a){return new Date(e,a,1).getDay()}(Ne,ge),n=[];n.push(a.jsxs("div",{className:"ihub-calendar-header",children:[a.jsx("button",{type:"button",className:"ihub-calendar-nav",onClick:Ie,"aria-label":"Previous Year",children:"«"}),a.jsx("button",{type:"button",className:"ihub-calendar-nav",onClick:Fe,"aria-label":"Previous Month",children:"‹"}),a.jsx("div",{className:"ihub-calendar-title",children:a.jsxs("span",{children:[["January","February","March","April","May","June","July","August","September","October","November","December"][ge]," ",Ne]})}),a.jsx("button",{type:"button",className:"ihub-calendar-nav",onClick:Ye,"aria-label":"Next Month",children:"›"}),a.jsx("button",{type:"button",className:"ihub-calendar-nav",onClick:Le,"aria-label":"Next Year",children:"»"})]},"header")),n.push(a.jsxs("div",{className:"ihub-calendar-days",children:[a.jsx("div",{children:"Su"}),a.jsx("div",{children:"Mo"}),a.jsx("div",{children:"Tu"}),a.jsx("div",{children:"We"}),a.jsx("div",{children:"Th"}),a.jsx("div",{children:"Fr"}),a.jsx("div",{children:"Sa"})]},"weekdays"));for(var r=[],i=1,l=ge,s=Ne,c=0;c<6;c++){for(var u=[],o=0;o<7;o++)if(0===c&&o<t)u.push(a.jsx("div",{className:"ihub-calendar-cell"},"empty-".concat(o)));else if(i<=e){var p=new Date(Ne,ge,i),v=p.toISOString().split("T")[0],f=!!q&&(q.getDate()===i&&q.getMonth()===ge&&q.getFullYear()===Ne),m=(new Date).getDate()===i&&(new Date).getMonth()===ge&&(new Date).getFullYear()===Ne,g=d&&p<new Date(d)||h&&p>new Date(h)||b.includes(v);u.push(a.jsx("div",{className:"ihub-calendar-cell ".concat(f?"ihub-selected":""," ").concat(m?"ihub-today":""," ").concat(g?"ihub-disabled":""),"aria-selected":f,role:"gridcell",tabIndex:f?0:-1,"data-day":i,"data-month":l,"data-year":s,onClick:qe,children:i},"day-".concat(i))),i++}else u.push(a.jsx("div",{className:"ihub-calendar-cell"},"empty-after-".concat(o)));if(r.push(a.jsx("div",{className:"ihub-calendar-row",role:"row",children:u},"row-".concat(c))),i>e)break}return n.push(a.jsx("div",{className:"ihub-calendar-grid",role:"grid",children:r},"grid")),C&&n.push(a.jsxs("div",{className:"ihub-calendar-actions",children:[a.jsx("button",{className:"ihub-calendar-action-btn",onClick:Pe,type:"button",children:"Today"}),a.jsx("button",{className:"ihub-calendar-action-btn",onClick:Be,type:"button",children:"Clear"})]},"actions")),n}()})]}),C&&!T&&a.jsxs("div",{className:"ihub-auto-date ihub-date-picker-action",children:[a.jsx("span",{className:"ihub-set-today ihub-fs-sm",onClick:Pe,children:"Today"}),a.jsx("span",{className:"ihub-separator ihub-fs-sm",children:"|"}),a.jsx("span",{className:"ihub-clear-date ihub-fs-sm",onClick:Be,children:"Clear"})]}),y&&a.jsx("input",{type:"hidden",name:y,value:F})]})};
2
2
  //# sourceMappingURL=DateInputPicker.cjs.map
@@ -1,2 +1,2 @@
1
- import{slicedToArray as e}from"../../../_virtual/_rollupPluginBabelHelpers.js";import{jsxs as a,jsx as t,Fragment as n}from"react/jsx-runtime";import r from"@mui/icons-material/CalendarMonthOutlined";import{useState as i,useRef as l,useEffect as c}from"react";var u=function(u){var o=u.label,s=u.value,d=void 0===s?"":s,h=u.onChange,p=u.required,b=void 0!==p&&p,v=u.minDate,m=u.maxDate,f=u.disabledDates,g=void 0===f?[]:f,y=u.errorMessage,N=u.className,D=void 0===N?"":N;u.displayFormat,u.locale;var w=u.includeTime,T=void 0!==w&&w,C=u.name,k=u.id;u.placeholder;var S=u.disabled,M=void 0!==S&&S,x=u.showCalendarPicker,F=void 0===x||x,Y=u.showQuickActions,I=void 0===Y||Y,L=u.ariaLabel,A=i(d),B=e(A,2),P=B[0],H=B[1],O=i(d?new Date(d):null),$=e(O,2),E=$[0],q=$[1],J=i(!1),K=e(J,2),_=K[0],j=K[1],Q=i(y||null),W=e(Q,2),z=W[0],G=W[1],R=i(d?d.split("-")[0]:""),U=e(R,2),V=U[0],X=U[1],Z=i(d?d.split("-")[1]:""),ee=e(Z,2),ae=ee[0],te=ee[1],ne=i(d?d.split("-")[2]:""),re=e(ne,2),ie=re[0],le=re[1],ce=i(d&&T&&d.includes("T")?d.split("T")[1].split(":")[0]:"00"),ue=e(ce,2),oe=ue[0],se=ue[1],de=i(d&&T&&d.includes("T")?d.split("T")[1].split(":")[1]:"00"),he=e(de,2),pe=he[0],be=he[1],ve=l(null),me=l(null),fe=l(null),ge=l(null),ye=l(null),Ne=i(E?E.getMonth():(new Date).getMonth()),De=e(Ne,2),we=De[0],Te=De[1],Ce=i(E?E.getFullYear():(new Date).getFullYear()),ke=e(Ce,2),Se=ke[0],Me=ke[1];c(function(){if(d){var a=new Date(d);if(!isNaN(a.getTime())&&(q(a),H(d),d.includes("-"))){var t=d.split("-"),n=e(t,3),r=n[0],i=n[1],l=n[2];if(X(r),te(i),le(l.split("T")[0]||l),T&&d.includes("T")){var c=d.split("T")[1];if(c){var u=c.split(":"),o=e(u,2),s=o[0],h=o[1];se(s),be(h)}}}}},[d,T]),c(function(){var e=function(e){ve.current&&!ve.current.contains(e.target)&&me.current&&!me.current.contains(e.target)&&j(!1)};return document.addEventListener("mousedown",e),function(){document.removeEventListener("mousedown",e)}},[]);var xe=function(e){var a=new Date(e);return!isNaN(a.getTime())},Fe=function(){return G(null),b&&!P?(G("Date is required"),!1):!P||(xe(P)?function(e){if(!v&&!m)return!0;var a=new Date(e),t=v?new Date(v):null,n=m?new Date(m):null;return!(t&&a<t||n&&a>n)}(P)?(e=P,!g.includes(e)||(G("This date is not available"),!1)):(G("Date must be between ".concat(v||"any"," and ").concat(m||"any")),!1):(G("Please enter a valid date"),!1));var e},Ye=function(e,a,t){if(4===e.length&&2===a.length&&2===t.length){var n=a.padStart(2,"0"),r=t.padStart(2,"0"),i="".concat(e,"-").concat(n,"-").concat(r);if(xe(i)){var l=new Date(i);if(q(l),H(i),T)return void Ie(e,a,t,oe,pe);h&&h(i)}}},Ie=function(e,a,t,n,r){if(4===e.length&&2===a.length&&2===t.length){var i=a.padStart(2,"0"),l=t.padStart(2,"0"),c=n.padStart(2,"0"),u=r.padStart(2,"0"),o="".concat(e,"-").concat(i,"-").concat(l,"T").concat(c,":").concat(u,":00");if(xe(o)){var s=new Date(o);q(s),H(o),h&&h(o)}}},Le=function(e,a){"Tab"!==e.key&&("Enter"!==e.key&&" "!==e.key||"day"!==a||(e.preventDefault(),j(!_)),"/"===e.key&&(e.preventDefault(),"month"===a&&ye.current?ye.current.focus():"year"===a&&ge.current&&ge.current.focus()),"Escape"===e.key&&j(!1))},Ae=function(){},Be=function(e){Fe()},Pe=function(){Te(function(e){return 0===e?(Me(function(e){return e-1}),11):e-1})},He=function(){Te(function(e){return 11===e?(Me(function(e){return e+1}),0):e+1})},Oe=function(){Me(function(e){return e-1})},$e=function(){Me(function(e){return e+1})},Ee=function(e){var a=e.currentTarget.getAttribute("data-day"),t=e.currentTarget.getAttribute("data-month"),n=e.currentTarget.getAttribute("data-year"),r=new Date(parseInt(n),parseInt(t),parseInt(a)+1),i=r.toISOString().split("T")[0];if(q(r),X(i.split("-")[0]),te(i.split("-")[1]),le(i.split("-")[2]),T){var l="".concat(i,"T").concat(oe.padStart(2,"0"),":").concat(pe.padStart(2,"0"),":00");H(l),h&&h(l)}else H(i),h&&h(i);Fe(),j(!1)},qe=function(){var e=new Date,a=e.toISOString().split("T")[0];if(q(e),Te(e.getMonth()),Me(e.getFullYear()),X(a.split("-")[0]),te(a.split("-")[1]),le(a.split("-")[2]),T){var t=e.getHours().toString().padStart(2,"0"),n=e.getMinutes().toString().padStart(2,"0");se(t),be(n);var r="".concat(a,"T").concat(t,":").concat(n,":00");H(r),h&&h(r)}else H(a),h&&h(a)},Je=function(){q(null),H(""),X(""),te(""),le(""),se("00"),be("00"),h&&h("")};return a("div",{className:"ihub-wrapper",children:[a("div",{className:"ihub-date-wrapper ".concat(D," ").concat(z?"ihub-is_invalid":""),children:[a("label",{className:"ihub-text-label",htmlFor:k||C,children:[o,b&&t("span",{className:"ihub-required",children:"*"})]}),a("div",{ref:me,className:"ihub-date-input-container ".concat(z?"date-err":""),onClick:function(){return!M&&F&&j(!0)},children:[t("input",{ref:fe,type:"text",className:"ihub-date-input ihub-date-year",value:V,onChange:function(e){var a=e.target.value.slice(0,4);/^\d*$/.test(a)&&(X(a),Ye(a,ae,ie))},onFocus:Ae,onBlur:Be,onKeyDown:function(e){return Le(e,"year")},placeholder:"YYYY",maxLength:4,disabled:M,"aria-label":"Year ".concat(L||o),"aria-invalid":!!z}),t("span",{className:"ihub-date-separator",children:"-"}),t("input",{ref:ge,type:"text",className:"ihub-date-input",value:ae,onChange:function(e){var a=e.target.value.slice(0,2);/^\d*$/.test(a)&&parseInt(a)<=12&&(te(a),Ye(V,a,ie),2===a.length&&ye.current&&ye.current.focus())},onFocus:Ae,onBlur:Be,onKeyDown:function(e){return Le(e,"month")},placeholder:"MM",maxLength:2,disabled:M,"aria-label":"Month ".concat(L||o),"aria-invalid":!!z}),t("span",{className:"ihub-date-separator",children:"-"}),t("input",{ref:ye,type:"text",className:"ihub-date-input",value:ie,onChange:function(e){var a=e.target.value.slice(0,2);/^\d*$/.test(a)&&parseInt(a)<=31&&(le(a),Ye(V,ae,a))},onFocus:Ae,onBlur:Be,onKeyDown:function(e){return Le(e,"day")},placeholder:"DD",maxLength:2,disabled:M,"aria-label":"Day ".concat(L||o),"aria-invalid":!!z}),T&&a(n,{children:[t("div",{className:"ihub-datetime-separator",children:"at"}),a("div",{className:"ihub-time-wrapper",children:[t("input",{type:"text",className:"ihub-date-input",value:oe,onChange:function(e){var a=e.target.value.slice(0,2);/^\d*$/.test(a)&&parseInt(a)<=23&&(se(a),Ie(V,ae,ie,a,pe))},onBlur:Be,placeholder:"HH",maxLength:2,disabled:M,"aria-label":"Hours ".concat(L||o)}),t("span",{className:"ihub-date-separator",children:":"}),t("input",{type:"text",className:"ihub-date-input",value:pe,onChange:function(e){var a=e.target.value.slice(0,2);/^\d*$/.test(a)&&parseInt(a)<=59&&(be(a),Ie(V,ae,ie,oe,a))},onBlur:Be,placeholder:"MM",maxLength:2,disabled:M,"aria-label":"Minutes ".concat(L||o)})]})]}),F&&t("button",{type:"button",className:"ihub-calendar-toggle",onClick:function(e){e.stopPropagation(),!M&&j(!_)},"aria-label":"Toggle calendar",disabled:M,children:t(r,{})})]}),z&&t("div",{className:"ihub-error-message",children:z}),_&&F&&!M&&t("div",{className:"ihub-calendar-container",ref:ve,role:"dialog","aria-label":"Choose date",children:function(){var e=function(e,a){return new Date(e,a+1,0).getDate()}(Se,we),n=function(e,a){return new Date(e,a,1).getDay()}(Se,we),r=[];r.push(a("div",{className:"ihub-calendar-header",children:[t("button",{className:"ihub-calendar-nav",onClick:Oe,"aria-label":"Previous Year",children:"«"}),t("button",{className:"ihub-calendar-nav",onClick:Pe,"aria-label":"Previous Month",children:"‹"}),t("div",{className:"ihub-calendar-title",children:a("span",{children:[["January","February","March","April","May","June","July","August","September","October","November","December"][we]," ",Se]})}),t("button",{className:"ihub-calendar-nav",onClick:He,"aria-label":"Next Month",children:"›"}),t("button",{className:"ihub-calendar-nav",onClick:$e,"aria-label":"Next Year",children:"»"})]},"header")),r.push(a("div",{className:"ihub-calendar-days",children:[t("div",{children:"Su"}),t("div",{children:"Mo"}),t("div",{children:"Tu"}),t("div",{children:"We"}),t("div",{children:"Th"}),t("div",{children:"Fr"}),t("div",{children:"Sa"})]},"weekdays"));for(var i=[],l=1,c=we,u=Se,o=0;o<6;o++){for(var s=[],d=0;d<7;d++)if(0===o&&d<n)s.push(t("div",{className:"ihub-calendar-cell"},"empty-".concat(d)));else if(l<=e){var h=new Date(Se,we,l),p=h.toISOString().split("T")[0],b=!!E&&(E.getDate()===l&&E.getMonth()===we&&E.getFullYear()===Se),f=(new Date).getDate()===l&&(new Date).getMonth()===we&&(new Date).getFullYear()===Se,y=v&&h<new Date(v)||m&&h>new Date(m)||g.includes(p);s.push(t("div",{className:"ihub-calendar-cell ".concat(b?"ihub-selected":""," ").concat(f?"ihub-today":""," ").concat(y?"ihub-disabled":""),"aria-selected":b,role:"gridcell",tabIndex:b?0:-1,"data-day":l,"data-month":c,"data-year":u,onClick:Ee,children:l},"day-".concat(l))),l++}else s.push(t("div",{className:"ihub-calendar-cell"},"empty-after-".concat(d)));if(i.push(t("div",{className:"ihub-calendar-row",role:"row",children:s},"row-".concat(o))),l>e)break}return r.push(t("div",{className:"ihub-calendar-grid",role:"grid",children:i},"grid")),I&&r.push(a("div",{className:"ihub-calendar-actions",children:[t("button",{className:"ihub-calendar-action-btn",onClick:qe,type:"button",children:"Today"}),t("button",{className:"ihub-calendar-action-btn",onClick:Je,type:"button",children:"Clear"})]},"actions")),r}()})]}),I&&!M&&a("div",{className:"ihub-auto-date ihub-date-picker-action",children:[t("span",{className:"ihub-set-today ihub-fs-sm",onClick:qe,children:"Today"}),t("span",{className:"ihub-separator ihub-fs-sm",children:"|"}),t("span",{className:"ihub-clear-date ihub-fs-sm",onClick:Je,children:"Clear"})]}),C&&t("input",{type:"hidden",name:C,value:P})]})};export{u as default};
1
+ import{slicedToArray as e}from"../../../_virtual/_rollupPluginBabelHelpers.js";import{jsxs as a,jsx as t,Fragment as n}from"react/jsx-runtime";import r from"@mui/icons-material/CalendarMonthOutlined";import{useState as i,useRef as l,useEffect as c}from"react";var u=function(u){var o=u.label,s=u.value,d=void 0===s?"":s,h=u.onChange,p=u.required,b=void 0!==p&&p,v=u.minDate,m=u.maxDate,f=u.disabledDates,g=void 0===f?[]:f,y=u.errorMessage,N=u.className,D=void 0===N?"":N;u.displayFormat,u.locale;var w=u.includeTime,T=void 0!==w&&w,C=u.name,k=u.id;u.placeholder;var S=u.disabled,M=void 0!==S&&S,x=u.showCalendarPicker,F=void 0===x||x,Y=u.showQuickActions,I=void 0===Y||Y,L=u.ariaLabel,A=i(d),B=e(A,2),P=B[0],H=B[1],O=i(d?new Date(d):null),$=e(O,2),E=$[0],q=$[1],J=i(!1),K=e(J,2),_=K[0],j=K[1],Q=i(y||null),W=e(Q,2),z=W[0],G=W[1],R=i(d?d.split("-")[0]:""),U=e(R,2),V=U[0],X=U[1],Z=i(d?d.split("-")[1]:""),ee=e(Z,2),ae=ee[0],te=ee[1],ne=i(d?d.split("-")[2]:""),re=e(ne,2),ie=re[0],le=re[1],ce=i(d&&T&&d.includes("T")?d.split("T")[1].split(":")[0]:"00"),ue=e(ce,2),oe=ue[0],se=ue[1],de=i(d&&T&&d.includes("T")?d.split("T")[1].split(":")[1]:"00"),he=e(de,2),pe=he[0],be=he[1],ve=l(null),me=l(null),fe=l(null),ge=l(null),ye=l(null),Ne=i(E?E.getMonth():(new Date).getMonth()),De=e(Ne,2),we=De[0],Te=De[1],Ce=i(E?E.getFullYear():(new Date).getFullYear()),ke=e(Ce,2),Se=ke[0],Me=ke[1];c(function(){if(d){var a=new Date(d);if(!isNaN(a.getTime())&&(q(a),H(d),d.includes("-"))){var t=d.split("-"),n=e(t,3),r=n[0],i=n[1],l=n[2];if(X(r),te(i),le(l.split("T")[0]||l),T&&d.includes("T")){var c=d.split("T")[1];if(c){var u=c.split(":"),o=e(u,2),s=o[0],h=o[1];se(s),be(h)}}}}},[d,T]),c(function(){var e=function(e){ve.current&&!ve.current.contains(e.target)&&me.current&&!me.current.contains(e.target)&&j(!1)};return document.addEventListener("mousedown",e),function(){document.removeEventListener("mousedown",e)}},[]);var xe=function(e){var a=new Date(e);return!isNaN(a.getTime())},Fe=function(){return G(null),b&&!P?(G("Date is required"),!1):!P||(xe(P)?function(e){if(!v&&!m)return!0;var a=new Date(e),t=v?new Date(v):null,n=m?new Date(m):null;return!(t&&a<t||n&&a>n)}(P)?(e=P,!g.includes(e)||(G("This date is not available"),!1)):(G("Date must be between ".concat(v||"any"," and ").concat(m||"any")),!1):(G("Please enter a valid date"),!1));var e},Ye=function(e,a,t){if(4===e.length&&2===a.length&&2===t.length){var n=a.padStart(2,"0"),r=t.padStart(2,"0"),i="".concat(e,"-").concat(n,"-").concat(r);if(xe(i)){var l=new Date(i);if(q(l),H(i),T)return void Ie(e,a,t,oe,pe);h&&h(i)}}},Ie=function(e,a,t,n,r){if(4===e.length&&2===a.length&&2===t.length){var i=a.padStart(2,"0"),l=t.padStart(2,"0"),c=n.padStart(2,"0"),u=r.padStart(2,"0"),o="".concat(e,"-").concat(i,"-").concat(l,"T").concat(c,":").concat(u,":00");if(xe(o)){var s=new Date(o);q(s),H(o),h&&h(o)}}},Le=function(e,a){"Tab"!==e.key&&("Enter"!==e.key&&" "!==e.key||"day"!==a||(e.preventDefault(),j(!_)),"/"===e.key&&(e.preventDefault(),"month"===a&&ye.current?ye.current.focus():"year"===a&&ge.current&&ge.current.focus()),"Escape"===e.key&&j(!1))},Ae=function(){},Be=function(e){Fe()},Pe=function(){Te(function(e){return 0===e?(Me(function(e){return e-1}),11):e-1})},He=function(){Te(function(e){return 11===e?(Me(function(e){return e+1}),0):e+1})},Oe=function(){Me(function(e){return e-1})},$e=function(){Me(function(e){return e+1})},Ee=function(e){var a=e.currentTarget.getAttribute("data-day"),t=e.currentTarget.getAttribute("data-month"),n=e.currentTarget.getAttribute("data-year"),r=new Date(parseInt(n),parseInt(t),parseInt(a)+1),i=r.toISOString().split("T")[0];if(q(r),X(i.split("-")[0]),te(i.split("-")[1]),le(i.split("-")[2]),T){var l="".concat(i,"T").concat(oe.padStart(2,"0"),":").concat(pe.padStart(2,"0"),":00");H(l),h&&h(l)}else H(i),h&&h(i);Fe(),j(!1)},qe=function(){var e=new Date,a=e.toISOString().split("T")[0];if(q(e),Te(e.getMonth()),Me(e.getFullYear()),X(a.split("-")[0]),te(a.split("-")[1]),le(a.split("-")[2]),T){var t=e.getHours().toString().padStart(2,"0"),n=e.getMinutes().toString().padStart(2,"0");se(t),be(n);var r="".concat(a,"T").concat(t,":").concat(n,":00");H(r),h&&h(r)}else H(a),h&&h(a)},Je=function(){q(null),H(""),X(""),te(""),le(""),se("00"),be("00"),h&&h("")};return a("div",{className:"ihub-wrapper",children:[a("div",{className:"ihub-date-wrapper ".concat(D," ").concat(z?"ihub-is_invalid":""),children:[a("label",{className:"ihub-text-label",htmlFor:k||C,children:[o,b&&t("span",{className:"ihub-required",children:"*"})]}),a("div",{ref:me,className:"ihub-date-input-container ".concat(z?"date-err":""),onClick:function(){return!M&&F&&j(!0)},children:[t("input",{ref:fe,type:"text",className:"ihub-date-input ihub-date-year",value:V,onChange:function(e){var a=e.target.value.slice(0,4);/^\d*$/.test(a)&&(X(a),Ye(a,ae,ie))},onFocus:Ae,onBlur:Be,onKeyDown:function(e){return Le(e,"year")},placeholder:"YYYY",maxLength:4,disabled:M,"aria-label":"Year ".concat(L||o),"aria-invalid":!!z}),t("span",{className:"ihub-date-separator",children:"-"}),t("input",{ref:ge,type:"text",className:"ihub-date-input",value:ae,onChange:function(e){var a=e.target.value.slice(0,2);/^\d*$/.test(a)&&parseInt(a)<=12&&(te(a),Ye(V,a,ie),2===a.length&&ye.current&&ye.current.focus())},onFocus:Ae,onBlur:Be,onKeyDown:function(e){return Le(e,"month")},placeholder:"MM",maxLength:2,disabled:M,"aria-label":"Month ".concat(L||o),"aria-invalid":!!z}),t("span",{className:"ihub-date-separator",children:"-"}),t("input",{ref:ye,type:"text",className:"ihub-date-input",value:ie,onChange:function(e){var a=e.target.value.slice(0,2);/^\d*$/.test(a)&&parseInt(a)<=31&&(le(a),Ye(V,ae,a))},onFocus:Ae,onBlur:Be,onKeyDown:function(e){return Le(e,"day")},placeholder:"DD",maxLength:2,disabled:M,"aria-label":"Day ".concat(L||o),"aria-invalid":!!z}),T&&a(n,{children:[t("div",{className:"ihub-datetime-separator",children:"at"}),a("div",{className:"ihub-time-wrapper",children:[t("input",{type:"text",className:"ihub-date-input",value:oe,onChange:function(e){var a=e.target.value.slice(0,2);/^\d*$/.test(a)&&parseInt(a)<=23&&(se(a),Ie(V,ae,ie,a,pe))},onBlur:Be,placeholder:"HH",maxLength:2,disabled:M,"aria-label":"Hours ".concat(L||o)}),t("span",{className:"ihub-date-separator",children:":"}),t("input",{type:"text",className:"ihub-date-input",value:pe,onChange:function(e){var a=e.target.value.slice(0,2);/^\d*$/.test(a)&&parseInt(a)<=59&&(be(a),Ie(V,ae,ie,oe,a))},onBlur:Be,placeholder:"MM",maxLength:2,disabled:M,"aria-label":"Minutes ".concat(L||o)})]})]}),F&&t("button",{type:"button",className:"ihub-calendar-toggle",onClick:function(e){e.stopPropagation(),!M&&j(!_)},"aria-label":"Toggle calendar",disabled:M,children:t(r,{})})]}),z&&t("div",{className:"ihub-error-message",children:z}),_&&F&&!M&&t("div",{className:"ihub-calendar-container",ref:ve,role:"dialog","aria-label":"Choose date",children:function(){var e=function(e,a){return new Date(e,a+1,0).getDate()}(Se,we),n=function(e,a){return new Date(e,a,1).getDay()}(Se,we),r=[];r.push(a("div",{className:"ihub-calendar-header",children:[t("button",{type:"button",className:"ihub-calendar-nav",onClick:Oe,"aria-label":"Previous Year",children:"«"}),t("button",{type:"button",className:"ihub-calendar-nav",onClick:Pe,"aria-label":"Previous Month",children:"‹"}),t("div",{className:"ihub-calendar-title",children:a("span",{children:[["January","February","March","April","May","June","July","August","September","October","November","December"][we]," ",Se]})}),t("button",{type:"button",className:"ihub-calendar-nav",onClick:He,"aria-label":"Next Month",children:"›"}),t("button",{type:"button",className:"ihub-calendar-nav",onClick:$e,"aria-label":"Next Year",children:"»"})]},"header")),r.push(a("div",{className:"ihub-calendar-days",children:[t("div",{children:"Su"}),t("div",{children:"Mo"}),t("div",{children:"Tu"}),t("div",{children:"We"}),t("div",{children:"Th"}),t("div",{children:"Fr"}),t("div",{children:"Sa"})]},"weekdays"));for(var i=[],l=1,c=we,u=Se,o=0;o<6;o++){for(var s=[],d=0;d<7;d++)if(0===o&&d<n)s.push(t("div",{className:"ihub-calendar-cell"},"empty-".concat(d)));else if(l<=e){var h=new Date(Se,we,l),p=h.toISOString().split("T")[0],b=!!E&&(E.getDate()===l&&E.getMonth()===we&&E.getFullYear()===Se),f=(new Date).getDate()===l&&(new Date).getMonth()===we&&(new Date).getFullYear()===Se,y=v&&h<new Date(v)||m&&h>new Date(m)||g.includes(p);s.push(t("div",{className:"ihub-calendar-cell ".concat(b?"ihub-selected":""," ").concat(f?"ihub-today":""," ").concat(y?"ihub-disabled":""),"aria-selected":b,role:"gridcell",tabIndex:b?0:-1,"data-day":l,"data-month":c,"data-year":u,onClick:Ee,children:l},"day-".concat(l))),l++}else s.push(t("div",{className:"ihub-calendar-cell"},"empty-after-".concat(d)));if(i.push(t("div",{className:"ihub-calendar-row",role:"row",children:s},"row-".concat(o))),l>e)break}return r.push(t("div",{className:"ihub-calendar-grid",role:"grid",children:i},"grid")),I&&r.push(a("div",{className:"ihub-calendar-actions",children:[t("button",{className:"ihub-calendar-action-btn",onClick:qe,type:"button",children:"Today"}),t("button",{className:"ihub-calendar-action-btn",onClick:Je,type:"button",children:"Clear"})]},"actions")),r}()})]}),I&&!M&&a("div",{className:"ihub-auto-date ihub-date-picker-action",children:[t("span",{className:"ihub-set-today ihub-fs-sm",onClick:qe,children:"Today"}),t("span",{className:"ihub-separator ihub-fs-sm",children:"|"}),t("span",{className:"ihub-clear-date ihub-fs-sm",onClick:Je,children:"Clear"})]}),C&&t("input",{type:"hidden",name:C,value:P})]})};export{u as default};
2
2
  //# sourceMappingURL=DateInputPicker.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_rollupPluginBabelHelpers.cjs"),a=require("react/jsx-runtime"),s=require("react"),n=require("next/link"),l=require("next/image"),i=require("../lib/json/unsplashDefaultObject.cjs"),r=require("../lib/helpFunction.cjs");function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u=t(n),o=t(l);exports.default=function(n){var l,t,c,d,h,p,v=n.useDispatch,m=n.useSelector,b=n.selectUnsplashObject,f=n.unsplashObject,j=n.height,x=void 0===j?"100vh":j,g=n.width,y=void 0===g?"100%":g,N=n.borderRadius,k=void 0===N?"8px":N,w=n.overlayIntensity,_=void 0===w?.2:w,D=n.onImageClick,S=v(),q=m(b),E=s.useState(!0),O=e.slicedToArray(E,2),T=O[0],C=O[1],A=s.useState(!1),I=e.slicedToArray(A,2),L=I[0],P=I[1],U=s.useState(null),F=e.slicedToArray(U,2),R=F[0],B=F[1],H=function(){var a=e.asyncToGenerator(e.regenerator().m(function a(){var s,l,t,u;return e.regenerator().w(function(e){for(;;)switch(e.p=e.n){case 0:if(!L){e.n=1;break}return e.a(2);case 1:if(P(!0),B(null),r.IN_DEV_MODE){e.n=8;break}return e.p=2,e.n=3,fetch("https://api.unsplash.com/photos/random?query=".concat(n.category,"&client_id=").concat(process.env.NEXT_PUBLIC_UNSPLASH_ACCESS_KEY));case 3:if((s=e.v).ok){e.n=4;break}throw new Error("Failed to fetch: ".concat(s.status," ").concat(s.statusText));case 4:return e.n=5,s.json();case 5:l=e.v,t=i.unsplashDefaultObject,null!=l&&l.id&&(t=l),S(f.actions.add(t)),e.n=7;break;case 6:e.p=6,u=e.v,console.error("Error fetching random image:",u),B("Failed to load image. Please try again."),S(f.actions.add(i.unsplashDefaultObject));case 7:e.n=9;break;case 8:S(f.actions.add(i.unsplashDefaultObject));case 9:P(!1);case 10:return e.a(2)}},a,null,[[2,6]])}));return function(){return a.apply(this,arguments)}}();s.useEffect(function(){H()},[n.category]);return a.jsxs("div",{className:"ihub-unsplash-container",style:{width:y,borderRadius:k,height:x,background:(null==q?void 0:q.color)||"#f5f5f5"},children:[T&&a.jsx("div",{className:"ihub-unsplash-loader",children:a.jsx("div",{className:"ihub-unsplash-spinner"})}),R&&a.jsxs("div",{className:"ihub-unsplash-error",children:[a.jsx("p",{children:R}),a.jsx("button",{onClick:H,disabled:L,children:"Try Again"})]}),a.jsxs("div",{className:"ihub-unsplash-image-container ".concat(T?"ihub-unsplash-loading":""),onClick:D,children:[a.jsx(o.default,{src:(null==q||null===(l=q.urls)||void 0===l?void 0:l.regular)||"",alt:(null==q?void 0:q.alt_description)||n.category||"Unsplash image",className:"ihub-unsplash-image",fill:!0,sizes:"(max-width: 768px) 100vw, (max-width: 1200px) 50vw, 33vw",priority:!0,onLoad:function(){C(!1)},style:{objectFit:"cover",borderRadius:k}}),a.jsx("div",{className:"ihub-unsplash-overlay",style:{opacity:_}}),a.jsxs("div",{className:"ihub-unsplash-info",children:[(null==q?void 0:q.description)&&a.jsx("p",{className:"ihub-unsplash-description",children:q.description}),a.jsxs("div",{className:"ihub-unsplash-metadata",children:[(null==q||null===(t=q.user)||void 0===t||null===(t=t.profile_image)||void 0===t?void 0:t.small)&&a.jsx(o.default,{src:q.user.profile_image.small,alt:(null===(c=q.user)||void 0===c?void 0:c.name)||"Photographer",width:24,height:24,className:"ihub-unsplash-avatar"}),a.jsxs("div",{className:"ihub-unsplash-user-info",children:[a.jsx(u.default,{href:(null==q||null===(d=q.user)||void 0===d||null===(d=d.links)||void 0===d?void 0:d.html)||"#",target:"_blank",rel:"noopener noreferrer",className:"ihub-unsplash-username",children:(null==q||null===(h=q.user)||void 0===h?void 0:h.name)||"Unknown"}),(null==q||null===(p=q.user)||void 0===p?void 0:p.location)&&a.jsx("span",{className:"ihub-unsplash-location",children:q.user.location})]}),a.jsxs("div",{className:"ihub-unsplash-stats",children:[(null==q?void 0:q.created_at)&&a.jsx("span",{className:"ihub-unsplash-date",children:function(e){if(!e)return"";var a=new Date(e);return new Intl.DateTimeFormat("en-US",{year:"numeric",month:"long",day:"numeric"}).format(a)}(q.created_at)}),void 0!==(null==q?void 0:q.likes)&&a.jsxs("span",{className:"ihub-unsplash-likes",children:[a.jsx("span",{className:"ihub-unsplash-heart",children:"♥"})," ",q.likes]})]})]})]})]}),a.jsx("div",{className:"ihub-unsplash-actions",children:a.jsx("button",{className:"ihub-unsplash-refresh",onClick:H,disabled:L,"aria-label":"Load a new image",title:"Load a new image",children:L?"Loading...":"Refresh Image"})})]})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_rollupPluginBabelHelpers.cjs"),a=require("react/jsx-runtime"),s=require("react"),n=require("next/link"),l=require("next/image"),i=require("../lib/json/unsplashDefaultObject.cjs"),r=require("../lib/helpFunction.cjs");function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u=t(n),o=t(l);exports.default=function(n){var l,t,c,d,h,p,v=n.useDispatch,m=n.useSelector,b=n.selectUnsplashObject,f=n.unsplashObject,j=n.height,x=void 0===j?"100vh":j,g=n.width,y=void 0===g?"100%":g,N=n.borderRadius,k=void 0===N?"8px":N,w=n.overlayIntensity,_=void 0===w?.2:w,D=n.onImageClick,S=v(),q=m(b),E=s.useState(!0),O=e.slicedToArray(E,2),T=O[0],C=O[1],A=s.useState(!1),I=e.slicedToArray(A,2),L=I[0],P=I[1],U=s.useState(null),F=e.slicedToArray(U,2),R=F[0],B=F[1],H=function(){var a=e.asyncToGenerator(e.regenerator().m(function a(){var s,l,t,u;return e.regenerator().w(function(e){for(;;)switch(e.p=e.n){case 0:if(!L){e.n=1;break}return e.a(2);case 1:if(P(!0),B(null),r.IN_DEV_MODE){e.n=8;break}return e.p=2,e.n=3,fetch("https://api.unsplash.com/photos/random?query=".concat(n.category,"&client_id=").concat(process.env.NEXT_PUBLIC_UNSPLASH_ACCESS_KEY));case 3:if((s=e.v).ok){e.n=4;break}throw new Error("Failed to fetch: ".concat(s.status," ").concat(s.statusText));case 4:return e.n=5,s.json();case 5:l=e.v,t=i.unsplashDefaultObject,null!=l&&l.id&&(t=l),S(f.actions.add(t)),e.n=7;break;case 6:e.p=6,u=e.v,console.error("Error fetching random image:",u),B("Failed to load image. Please try again."),S(f.actions.add(i.unsplashDefaultObject));case 7:e.n=9;break;case 8:S(f.actions.add(i.unsplashDefaultObject));case 9:P(!1);case 10:return e.a(2)}},a,null,[[2,6]])}));return function(){return a.apply(this,arguments)}}();s.useEffect(function(){H()},[n.category]);return a.jsxs("div",{className:"ihub-unsplash-container",style:{width:y,borderRadius:k,height:x,background:(null==q?void 0:q.color)||"#f5f5f5"},children:[T&&a.jsx("div",{className:"ihub-unsplash-loader",children:a.jsx("div",{className:"ihub-unsplash-spinner"})}),R&&a.jsxs("div",{className:"ihub-unsplash-error",children:[a.jsx("p",{children:R}),a.jsx("button",{type:"button",onClick:H,disabled:L,children:"Try Again"})]}),a.jsxs("div",{className:"ihub-unsplash-image-container ".concat(T?"ihub-unsplash-loading":""),onClick:D,children:[a.jsx(o.default,{src:(null==q||null===(l=q.urls)||void 0===l?void 0:l.regular)||"",alt:(null==q?void 0:q.alt_description)||n.category||"Unsplash image",className:"ihub-unsplash-image",fill:!0,sizes:"(max-width: 768px) 100vw, (max-width: 1200px) 50vw, 33vw",priority:!0,onLoad:function(){C(!1)},style:{objectFit:"cover",borderRadius:k}}),a.jsx("div",{className:"ihub-unsplash-overlay",style:{opacity:_}}),a.jsxs("div",{className:"ihub-unsplash-info",children:[(null==q?void 0:q.description)&&a.jsx("p",{className:"ihub-unsplash-description",children:q.description}),a.jsxs("div",{className:"ihub-unsplash-metadata",children:[(null==q||null===(t=q.user)||void 0===t||null===(t=t.profile_image)||void 0===t?void 0:t.small)&&a.jsx(o.default,{src:q.user.profile_image.small,alt:(null===(c=q.user)||void 0===c?void 0:c.name)||"Photographer",width:24,height:24,className:"ihub-unsplash-avatar"}),a.jsxs("div",{className:"ihub-unsplash-user-info",children:[a.jsx(u.default,{href:(null==q||null===(d=q.user)||void 0===d||null===(d=d.links)||void 0===d?void 0:d.html)||"#",target:"_blank",rel:"noopener noreferrer",className:"ihub-unsplash-username",children:(null==q||null===(h=q.user)||void 0===h?void 0:h.name)||"Unknown"}),(null==q||null===(p=q.user)||void 0===p?void 0:p.location)&&a.jsx("span",{className:"ihub-unsplash-location",children:q.user.location})]}),a.jsxs("div",{className:"ihub-unsplash-stats",children:[(null==q?void 0:q.created_at)&&a.jsx("span",{className:"ihub-unsplash-date",children:function(e){if(!e)return"";var a=new Date(e);return new Intl.DateTimeFormat("en-US",{year:"numeric",month:"long",day:"numeric"}).format(a)}(q.created_at)}),void 0!==(null==q?void 0:q.likes)&&a.jsxs("span",{className:"ihub-unsplash-likes",children:[a.jsx("span",{className:"ihub-unsplash-heart",children:"♥"})," ",q.likes]})]})]})]})]}),a.jsx("div",{className:"ihub-unsplash-actions",children:a.jsx("button",{type:"button",className:"ihub-unsplash-refresh",onClick:H,disabled:L,"aria-label":"Load a new image",title:"Load a new image",children:L?"Loading...":"Refresh Image"})})]})};
2
2
  //# sourceMappingURL=UnsplashRandomImage.cjs.map
@@ -1,2 +1,2 @@
1
- import{slicedToArray as a,asyncToGenerator as e,regenerator as n}from"../../../_virtual/_rollupPluginBabelHelpers.js";import{jsxs as i,jsx as s}from"react/jsx-runtime";import{useState as l,useEffect as r}from"react";import o from"next/link";import t from"next/image";import{unsplashDefaultObject as c}from"../lib/json/unsplashDefaultObject.js";import{IN_DEV_MODE as u}from"../lib/helpFunction.js";var d=function(d){var h,p,m,v,b,f,g=d.useDispatch,N=d.useSelector,y=d.selectUnsplashObject,k=d.unsplashObject,w=d.height,_=void 0===w?"100vh":w,j=d.width,x=void 0===j?"100%":j,C=d.borderRadius,L=void 0===C?"8px":C,S=d.overlayIntensity,T=void 0===S?.2:S,U=d.onImageClick,E=g(),F=N(y),I=l(!0),P=a(I,2),A=P[0],D=P[1],R=l(!1),O=a(R,2),B=O[0],H=O[1],q=l(null),z=a(q,2),G=z[0],K=z[1],X=function(){var a=e(n().m(function a(){var e,i,s,l;return n().w(function(a){for(;;)switch(a.p=a.n){case 0:if(!B){a.n=1;break}return a.a(2);case 1:if(H(!0),K(null),u){a.n=8;break}return a.p=2,a.n=3,fetch("https://api.unsplash.com/photos/random?query=".concat(d.category,"&client_id=").concat(process.env.NEXT_PUBLIC_UNSPLASH_ACCESS_KEY));case 3:if((e=a.v).ok){a.n=4;break}throw new Error("Failed to fetch: ".concat(e.status," ").concat(e.statusText));case 4:return a.n=5,e.json();case 5:i=a.v,s=c,null!=i&&i.id&&(s=i),E(k.actions.add(s)),a.n=7;break;case 6:a.p=6,l=a.v,console.error("Error fetching random image:",l),K("Failed to load image. Please try again."),E(k.actions.add(c));case 7:a.n=9;break;case 8:E(k.actions.add(c));case 9:H(!1);case 10:return a.a(2)}},a,null,[[2,6]])}));return function(){return a.apply(this,arguments)}}();r(function(){X()},[d.category]);return i("div",{className:"ihub-unsplash-container",style:{width:x,borderRadius:L,height:_,background:(null==F?void 0:F.color)||"#f5f5f5"},children:[A&&s("div",{className:"ihub-unsplash-loader",children:s("div",{className:"ihub-unsplash-spinner"})}),G&&i("div",{className:"ihub-unsplash-error",children:[s("p",{children:G}),s("button",{onClick:X,disabled:B,children:"Try Again"})]}),i("div",{className:"ihub-unsplash-image-container ".concat(A?"ihub-unsplash-loading":""),onClick:U,children:[s(t,{src:(null==F||null===(h=F.urls)||void 0===h?void 0:h.regular)||"",alt:(null==F?void 0:F.alt_description)||d.category||"Unsplash image",className:"ihub-unsplash-image",fill:!0,sizes:"(max-width: 768px) 100vw, (max-width: 1200px) 50vw, 33vw",priority:!0,onLoad:function(){D(!1)},style:{objectFit:"cover",borderRadius:L}}),s("div",{className:"ihub-unsplash-overlay",style:{opacity:T}}),i("div",{className:"ihub-unsplash-info",children:[(null==F?void 0:F.description)&&s("p",{className:"ihub-unsplash-description",children:F.description}),i("div",{className:"ihub-unsplash-metadata",children:[(null==F||null===(p=F.user)||void 0===p||null===(p=p.profile_image)||void 0===p?void 0:p.small)&&s(t,{src:F.user.profile_image.small,alt:(null===(m=F.user)||void 0===m?void 0:m.name)||"Photographer",width:24,height:24,className:"ihub-unsplash-avatar"}),i("div",{className:"ihub-unsplash-user-info",children:[s(o,{href:(null==F||null===(v=F.user)||void 0===v||null===(v=v.links)||void 0===v?void 0:v.html)||"#",target:"_blank",rel:"noopener noreferrer",className:"ihub-unsplash-username",children:(null==F||null===(b=F.user)||void 0===b?void 0:b.name)||"Unknown"}),(null==F||null===(f=F.user)||void 0===f?void 0:f.location)&&s("span",{className:"ihub-unsplash-location",children:F.user.location})]}),i("div",{className:"ihub-unsplash-stats",children:[(null==F?void 0:F.created_at)&&s("span",{className:"ihub-unsplash-date",children:function(a){if(!a)return"";var e=new Date(a);return new Intl.DateTimeFormat("en-US",{year:"numeric",month:"long",day:"numeric"}).format(e)}(F.created_at)}),void 0!==(null==F?void 0:F.likes)&&i("span",{className:"ihub-unsplash-likes",children:[s("span",{className:"ihub-unsplash-heart",children:"♥"})," ",F.likes]})]})]})]})]}),s("div",{className:"ihub-unsplash-actions",children:s("button",{className:"ihub-unsplash-refresh",onClick:X,disabled:B,"aria-label":"Load a new image",title:"Load a new image",children:B?"Loading...":"Refresh Image"})})]})};export{d as default};
1
+ import{slicedToArray as a,asyncToGenerator as e,regenerator as n}from"../../../_virtual/_rollupPluginBabelHelpers.js";import{jsxs as i,jsx as s}from"react/jsx-runtime";import{useState as l,useEffect as r}from"react";import o from"next/link";import t from"next/image";import{unsplashDefaultObject as u}from"../lib/json/unsplashDefaultObject.js";import{IN_DEV_MODE as c}from"../lib/helpFunction.js";var d=function(d){var h,p,m,v,b,f,g=d.useDispatch,N=d.useSelector,y=d.selectUnsplashObject,k=d.unsplashObject,w=d.height,_=void 0===w?"100vh":w,j=d.width,x=void 0===j?"100%":j,C=d.borderRadius,L=void 0===C?"8px":C,S=d.overlayIntensity,T=void 0===S?.2:S,U=d.onImageClick,E=g(),F=N(y),I=l(!0),P=a(I,2),A=P[0],D=P[1],R=l(!1),O=a(R,2),B=O[0],H=O[1],q=l(null),z=a(q,2),G=z[0],K=z[1],X=function(){var a=e(n().m(function a(){var e,i,s,l;return n().w(function(a){for(;;)switch(a.p=a.n){case 0:if(!B){a.n=1;break}return a.a(2);case 1:if(H(!0),K(null),c){a.n=8;break}return a.p=2,a.n=3,fetch("https://api.unsplash.com/photos/random?query=".concat(d.category,"&client_id=").concat(process.env.NEXT_PUBLIC_UNSPLASH_ACCESS_KEY));case 3:if((e=a.v).ok){a.n=4;break}throw new Error("Failed to fetch: ".concat(e.status," ").concat(e.statusText));case 4:return a.n=5,e.json();case 5:i=a.v,s=u,null!=i&&i.id&&(s=i),E(k.actions.add(s)),a.n=7;break;case 6:a.p=6,l=a.v,console.error("Error fetching random image:",l),K("Failed to load image. Please try again."),E(k.actions.add(u));case 7:a.n=9;break;case 8:E(k.actions.add(u));case 9:H(!1);case 10:return a.a(2)}},a,null,[[2,6]])}));return function(){return a.apply(this,arguments)}}();r(function(){X()},[d.category]);return i("div",{className:"ihub-unsplash-container",style:{width:x,borderRadius:L,height:_,background:(null==F?void 0:F.color)||"#f5f5f5"},children:[A&&s("div",{className:"ihub-unsplash-loader",children:s("div",{className:"ihub-unsplash-spinner"})}),G&&i("div",{className:"ihub-unsplash-error",children:[s("p",{children:G}),s("button",{type:"button",onClick:X,disabled:B,children:"Try Again"})]}),i("div",{className:"ihub-unsplash-image-container ".concat(A?"ihub-unsplash-loading":""),onClick:U,children:[s(t,{src:(null==F||null===(h=F.urls)||void 0===h?void 0:h.regular)||"",alt:(null==F?void 0:F.alt_description)||d.category||"Unsplash image",className:"ihub-unsplash-image",fill:!0,sizes:"(max-width: 768px) 100vw, (max-width: 1200px) 50vw, 33vw",priority:!0,onLoad:function(){D(!1)},style:{objectFit:"cover",borderRadius:L}}),s("div",{className:"ihub-unsplash-overlay",style:{opacity:T}}),i("div",{className:"ihub-unsplash-info",children:[(null==F?void 0:F.description)&&s("p",{className:"ihub-unsplash-description",children:F.description}),i("div",{className:"ihub-unsplash-metadata",children:[(null==F||null===(p=F.user)||void 0===p||null===(p=p.profile_image)||void 0===p?void 0:p.small)&&s(t,{src:F.user.profile_image.small,alt:(null===(m=F.user)||void 0===m?void 0:m.name)||"Photographer",width:24,height:24,className:"ihub-unsplash-avatar"}),i("div",{className:"ihub-unsplash-user-info",children:[s(o,{href:(null==F||null===(v=F.user)||void 0===v||null===(v=v.links)||void 0===v?void 0:v.html)||"#",target:"_blank",rel:"noopener noreferrer",className:"ihub-unsplash-username",children:(null==F||null===(b=F.user)||void 0===b?void 0:b.name)||"Unknown"}),(null==F||null===(f=F.user)||void 0===f?void 0:f.location)&&s("span",{className:"ihub-unsplash-location",children:F.user.location})]}),i("div",{className:"ihub-unsplash-stats",children:[(null==F?void 0:F.created_at)&&s("span",{className:"ihub-unsplash-date",children:function(a){if(!a)return"";var e=new Date(a);return new Intl.DateTimeFormat("en-US",{year:"numeric",month:"long",day:"numeric"}).format(e)}(F.created_at)}),void 0!==(null==F?void 0:F.likes)&&i("span",{className:"ihub-unsplash-likes",children:[s("span",{className:"ihub-unsplash-heart",children:"♥"})," ",F.likes]})]})]})]})]}),s("div",{className:"ihub-unsplash-actions",children:s("button",{type:"button",className:"ihub-unsplash-refresh",onClick:X,disabled:B,"aria-label":"Load a new image",title:"Load a new image",children:B?"Loading...":"Refresh Image"})})]})};export{d as default};
2
2
  //# sourceMappingURL=UnsplashRandomImage.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../_virtual/_rollupPluginBabelHelpers.cjs"),n=require("react/jsx-runtime"),r=require("react"),t=require("../../lib/helpFunction.cjs"),o=require("../../lib/modals/modals.cjs"),i=require("./presignedPut.cjs");exports.default=function(s){var l,a=s.header,c=s.label,u=void 0===c?"Drag and drop files here or click to browse":c,d=s.accept,p=void 0===d?"*":d,h=s.maxFileSize,x=void 0===h?0:h,v=s.name,b=void 0===v?"upload":v,f=s.module,m=void 0===f?"":f,g=s.step,j=void 0===g?"":g,y=s.onUploadComplete,k=s.setValues,w=s.setModules,N=s.setSteps,C=s.className,L=void 0===C?"":C,T=s.saveEndpoint,B=s.deleteEndpoint,_=s.token,P=s.getPresignedUrl,S=s.deleteFile,W=s.onRemove,z=r.useState(null),D=e.slicedToArray(z,2),F=D[0],U=D[1],M=r.useState(!1),A=e.slicedToArray(M,2),O=A[0],q=A[1],E=r.useState(0),R=e.slicedToArray(E,2),G=R[0],I=R[1],H=r.useState("idle"),V=e.slicedToArray(H,2),J=V[0],K=V[1],Q=r.useState(""),X=e.slicedToArray(Q,2),Y=X[0],Z=X[1],$=r.useState([]),ee=e.slicedToArray($,2),ne=ee[0],re=ee[1],te=r.useState(null),oe=e.slicedToArray(te,2),ie=oe[0],se=oe[1],le=r.useRef(null),ae=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){Z(""),function(e){var n;if("*"===p)return!0;var r=e.type,t=".".concat(null===(n=e.name.split(".").pop())||void 0===n?void 0:n.toLowerCase());return!!p.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})||(Z("File type not accepted. Please upload: ".concat(p)),!1)}(e)&&function(e){return!(x&&e.size>x&&(Z("File size exceeds the maximum limit of ".concat(ae(x))),1))}(e)&&(U(e),K("idle"),I(0))},ue=function(){var n=e.asyncToGenerator(e.regenerator().m(function n(r){var o,i,s,l,a,c,u,d;return e.regenerator().w(function(e){for(;;)switch(e.p=e.n){case 0:if(T&&_){e.n=1;break}return e.a(2,null);case 1:return e.p=1,i=JSON.stringify({file_url:r.location,file_key:r.key,file_name:r.title,file_size:r.size,content_type:r.content_type,media_type:null!==(o=r.content_type)&&void 0!==o&&o.startsWith("video/")?"video":"image"}),s=t.reqOptions("POST",i,_,"json"),e.n=2,fetch(T,s);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 c=console,u=l.status,e.n=5,l.text();case 5:c.error.call(c,"Save to DB failed:",u,e.v),e.n=7;break;case 6:e.p=6,d=e.v,console.error("Save to DB error:",d);case 7:return e.a(2,null)}},n,null,[[1,6]])}));return function(e){return n.apply(this,arguments)}}(),de=function(){var n=e.asyncToGenerator(e.regenerator().m(function n(r){var o,i,s;return e.regenerator().w(function(e){for(;;)switch(e.p=e.n){case 0:if(B&&_){e.n=1;break}return e.a(2,!1);case 1:return e.p=1,o=t.reqOptions("DELETE",null,_),e.n=2,fetch("".concat(B).concat(r,"/"),o);case 2:return i=e.v,e.a(2,i.ok||404===i.status);case 3:return e.p=3,s=e.v,console.error("DB delete error:",s),e.a(2,!1)}},n,null,[[1,3]])}));return function(e){return n.apply(this,arguments)}}(),pe=function(){var n=e.asyncToGenerator(e.regenerator().m(function n(r){var t,i;return e.regenerator().w(function(e){for(;;)switch(e.p=e.n){case 0:if(t=ne[r]){e.n=1;break}return e.a(2);case 1:if(!t.dbId||!B){e.n=2;break}return e.n=2,de(t.dbId);case 2:if(!S){e.n=6;break}return e.p=3,e.n=4,S(t.response);case 4:e.n=6;break;case 5:e.p=5,i=e.v,console.error("File delete error:",i);case 6:re(function(e){return e.filter(function(e,n){return n!==r})}),W&&W(t.response),o.openToast("File removed");case 7:return e.a(2)}},n,null,[[3,5]])}));return function(e){return n.apply(this,arguments)}}(),he=function(){var n=e.asyncToGenerator(e.regenerator().m(function n(){var r,t,s,l,a;return e.regenerator().w(function(n){for(;;)switch(n.p=n.n){case 0:if(F){n.n=1;break}return Z("Please select a file first"),n.a(2);case 1:if(K("uploading"),Z(""),P){n.n=2;break}return console.error(i.UPLOADS_NOT_CONFIGURED),K("error"),Z("Uploads are not configured."),n.a(2);case 2:return n.p=2,n.n=3,i.presignAndUpload(F,P,I);case 3:if(r=n.v,I(100),K("success"),o.openToast("File Uploaded Successfully!"),t={title:F.name,key:r.key,content_type:r.contentType,size:F.size,location:r.cdnUrl},!T||!_){n.n=5;break}return n.n=4,ue(t);case 4:(l=n.v)&&(s=l);case 5:re(function(n){return[].concat(e.toConsumableArray(n),[{response:t,dbId:s}])}),y&&y(t),k&&k(b,t.key),w&&w(m,b,t.key),N&&N(m,j,b,t.key),setTimeout(function(){U(null),K("idle"),I(0)},2e3),n.n=7;break;case 6:n.p=6,a=n.v,console.error("Upload error:",a),K("error"),Z("Error uploading file. Please try again."),o.openToast("Error uploading file!",400),I(0);case 7:return n.a(2)}},n,null,[[2,6]])}));return function(){return n.apply(this,arguments)}}(),xe=function(){U(null),K("idle"),I(0),Z("")};return n.jsxs("div",{className:"ihub-uploader ".concat(L),children:[a&&n.jsx("h3",{className:"ihub-uploader-header",children:a}),n.jsxs("div",{className:"ihub-uploader-container",children:[!F&&n.jsxs("div",{className:"ihub-uploader-dropzone ".concat(O?"ihub-uploader-dropzone-active":""),onDragOver:function(e){e.preventDefault(),e.stopPropagation(),q(!0)},onDragLeave:function(e){e.preventDefault(),e.stopPropagation(),q(!1)},onDrop:function(e){e.preventDefault(),e.stopPropagation(),q(!1);var n=e.dataTransfer.files;n&&n.length>0&&ce(n[0])},onClick:function(){var e;null===(e=le.current)||void 0===e||e.click()},children:[n.jsx("div",{className:"ihub-uploader-icon",children:n.jsxs("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:[n.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),n.jsx("polyline",{points:"17 8 12 3 7 8"}),n.jsx("line",{x1:"12",y1:"3",x2:"12",y2:"15"})]})}),n.jsx("p",{className:"ihub-uploader-text",children:u}),n.jsx("p",{className:"ihub-uploader-hint",children:x>0&&"Maximum file size: ".concat(ae(x))}),n.jsx("input",{ref:le,type:"file",accept:p,onChange:function(e){var n=e.target.files;n&&n.length>0&&ce(n[0])},className:"ihub-uploader-input"})]}),F&&n.jsxs("div",{className:"ihub-uploader-preview",children:[n.jsxs("div",{className:"ihub-uploader-file-info",children:[n.jsx("div",{className:"ihub-uploader-file-icon",children:F.type.startsWith("image/")?n.jsx("img",{src:URL.createObjectURL(F),alt:F.name,className:"ihub-uploader-thumbnail"}):n.jsxs("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:[n.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),n.jsx("polyline",{points:"14 2 14 8 20 8"}),n.jsx("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),n.jsx("line",{x1:"16",y1:"17",x2:"8",y2:"17"}),n.jsx("polyline",{points:"10 9 9 9 8 9"})]})}),n.jsxs("div",{className:"ihub-uploader-file-details",children:[n.jsx("p",{className:"ihub-uploader-file-name",children:F.name}),n.jsx("p",{className:"ihub-uploader-file-size",children:ae(F.size)})]})]}),"uploading"===J&&n.jsx("div",{className:"ihub-uploader-progress",children:n.jsx("div",{className:"ihub-uploader-progress-bar",style:{width:"".concat(G,"%")},children:n.jsxs("span",{className:"ihub-uploader-progress-text",children:[G,"%"]})})}),n.jsxs("div",{className:"ihub-uploader-actions",children:["idle"===J&&n.jsxs(n.Fragment,{children:[n.jsx("button",{className:"ihub-uploader-upload-btn ihub-important-btn",onClick:he,children:"Upload"}),n.jsx("button",{className:"ihub-uploader-cancel-btn outlined-btn",onClick:xe,children:"Cancel"})]}),"uploading"===J&&n.jsx("button",{className:"ihub-uploader-cancel-btn outlined-btn",onClick:xe,children:"Cancel"}),"success"===J&&n.jsxs("div",{className:"ihub-uploader-success",children:[n.jsxs("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:[n.jsx("path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14"}),n.jsx("polyline",{points:"22 4 12 14.01 9 11.01"})]}),n.jsx("span",{children:"Upload Complete"})]}),"error"===J&&n.jsxs(n.Fragment,{children:[n.jsx("button",{className:"ihub-uploader-retry-btn ihub-important-btn",onClick:he,children:"Retry"}),n.jsx("button",{className:"ihub-uploader-cancel-btn outlined-btn",onClick:xe,children:"Cancel"})]})]})]}),ne.length>0&&n.jsx("div",{className:"ihub-uploader-thumbs",children:ne.map(function(e,r){var t,o=null===(t=e.response.content_type)||void 0===t?void 0:t.startsWith("video/");return n.jsxs("div",{className:"ihub-uploader-thumb",children:[n.jsxs("div",{className:"ihub-uploader-thumb-preview",onClick:function(){return se(r)},title:"Click to preview",children:[o?n.jsx("video",{src:e.response.location,muted:!0}):n.jsx("img",{src:e.response.location,alt:e.response.title}),o&&n.jsx("span",{className:"ihub-uploader-thumb-badge",children:n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"currentColor",children:n.jsx("polygon",{points:"5 3 19 12 5 21 5 3"})})})]}),n.jsx("button",{type:"button",className:"ihub-uploader-thumb-remove",onClick:function(e){e.stopPropagation(),pe(r)},title:"Remove",children:n.jsxs("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:[n.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),n.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},r)})}),null!==ie&&ne[ie]&&n.jsx("div",{className:"ihub-uploader-lightbox",onClick:function(){return se(null)},children:n.jsxs("div",{className:"ihub-uploader-lightbox-content",onClick:function(e){return e.stopPropagation()},children:[n.jsx("button",{className:"ihub-uploader-lightbox-close",onClick:function(){return se(null)},children:n.jsxs("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:[n.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),n.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}),ie>0&&n.jsx("button",{className:"ihub-uploader-lightbox-nav ihub-uploader-lightbox-prev",onClick:function(){return se(ie-1)},children:n.jsx("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:n.jsx("polyline",{points:"15 18 9 12 15 6"})})}),n.jsx("div",{className:"ihub-uploader-lightbox-media",children:null!==(l=ne[ie].response.content_type)&&void 0!==l&&l.startsWith("video/")?n.jsx("video",{src:ne[ie].response.location,controls:!0,autoPlay:!0}):n.jsx("img",{src:ne[ie].response.location,alt:ne[ie].response.title})}),ie<ne.length-1&&n.jsx("button",{className:"ihub-uploader-lightbox-nav ihub-uploader-lightbox-next",onClick:function(){return se(ie+1)},children:n.jsx("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:n.jsx("polyline",{points:"9 18 15 12 9 6"})})}),n.jsxs("div",{className:"ihub-uploader-lightbox-info",children:[n.jsx("span",{children:ne[ie].response.title}),n.jsxs("span",{children:[ie+1," / ",ne.length]})]})]})}),Y&&n.jsxs("div",{className:"ihub-uploader-error",children:[n.jsxs("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:[n.jsx("circle",{cx:"12",cy:"12",r:"10"}),n.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),n.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}),n.jsx("span",{children:Y})]})]})]})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../_virtual/_rollupPluginBabelHelpers.cjs"),n=require("react/jsx-runtime"),r=require("react"),t=require("../../lib/helpFunction.cjs"),o=require("../../lib/modals/modals.cjs"),i=require("./presignedPut.cjs");exports.default=function(s){var l,a=s.header,c=s.label,u=void 0===c?"Drag and drop files here or click to browse":c,d=s.accept,p=void 0===d?"*":d,h=s.maxFileSize,x=void 0===h?0:h,v=s.name,b=void 0===v?"upload":v,f=s.module,m=void 0===f?"":f,g=s.step,j=void 0===g?"":g,y=s.onUploadComplete,k=s.setValues,w=s.setModules,N=s.setSteps,C=s.className,L=void 0===C?"":C,T=s.saveEndpoint,B=s.deleteEndpoint,_=s.token,P=s.getPresignedUrl,S=s.deleteFile,W=s.onRemove,z=r.useState(null),D=e.slicedToArray(z,2),F=D[0],U=D[1],M=r.useState(!1),A=e.slicedToArray(M,2),O=A[0],q=A[1],E=r.useState(0),R=e.slicedToArray(E,2),G=R[0],I=R[1],H=r.useState("idle"),V=e.slicedToArray(H,2),J=V[0],K=V[1],Q=r.useState(""),X=e.slicedToArray(Q,2),Y=X[0],Z=X[1],$=r.useState([]),ee=e.slicedToArray($,2),ne=ee[0],re=ee[1],te=r.useState(null),oe=e.slicedToArray(te,2),ie=oe[0],se=oe[1],le=r.useRef(null),ae=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){Z(""),function(e){var n;if("*"===p)return!0;var r=e.type,t=".".concat(null===(n=e.name.split(".").pop())||void 0===n?void 0:n.toLowerCase());return!!p.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})||(Z("File type not accepted. Please upload: ".concat(p)),!1)}(e)&&function(e){return!(x&&e.size>x&&(Z("File size exceeds the maximum limit of ".concat(ae(x))),1))}(e)&&(U(e),K("idle"),I(0))},ue=function(){var n=e.asyncToGenerator(e.regenerator().m(function n(r){var o,i,s,l,a,c,u,d;return e.regenerator().w(function(e){for(;;)switch(e.p=e.n){case 0:if(T&&_){e.n=1;break}return e.a(2,null);case 1:return e.p=1,i=JSON.stringify({file_url:r.location,file_key:r.key,file_name:r.title,file_size:r.size,content_type:r.content_type,media_type:null!==(o=r.content_type)&&void 0!==o&&o.startsWith("video/")?"video":"image"}),s=t.reqOptions("POST",i,_,"json"),e.n=2,fetch(T,s);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 c=console,u=l.status,e.n=5,l.text();case 5:c.error.call(c,"Save to DB failed:",u,e.v),e.n=7;break;case 6:e.p=6,d=e.v,console.error("Save to DB error:",d);case 7:return e.a(2,null)}},n,null,[[1,6]])}));return function(e){return n.apply(this,arguments)}}(),de=function(){var n=e.asyncToGenerator(e.regenerator().m(function n(r){var o,i,s;return e.regenerator().w(function(e){for(;;)switch(e.p=e.n){case 0:if(B&&_){e.n=1;break}return e.a(2,!1);case 1:return e.p=1,o=t.reqOptions("DELETE",null,_),e.n=2,fetch("".concat(B).concat(r,"/"),o);case 2:return i=e.v,e.a(2,i.ok||404===i.status);case 3:return e.p=3,s=e.v,console.error("DB delete error:",s),e.a(2,!1)}},n,null,[[1,3]])}));return function(e){return n.apply(this,arguments)}}(),pe=function(){var n=e.asyncToGenerator(e.regenerator().m(function n(r){var t,i;return e.regenerator().w(function(e){for(;;)switch(e.p=e.n){case 0:if(t=ne[r]){e.n=1;break}return e.a(2);case 1:if(!t.dbId||!B){e.n=2;break}return e.n=2,de(t.dbId);case 2:if(!S){e.n=6;break}return e.p=3,e.n=4,S(t.response);case 4:e.n=6;break;case 5:e.p=5,i=e.v,console.error("File delete error:",i);case 6:re(function(e){return e.filter(function(e,n){return n!==r})}),W&&W(t.response),o.openToast("File removed");case 7:return e.a(2)}},n,null,[[3,5]])}));return function(e){return n.apply(this,arguments)}}(),he=function(){var n=e.asyncToGenerator(e.regenerator().m(function n(){var r,t,s,l,a;return e.regenerator().w(function(n){for(;;)switch(n.p=n.n){case 0:if(F){n.n=1;break}return Z("Please select a file first"),n.a(2);case 1:if(K("uploading"),Z(""),P){n.n=2;break}return console.error(i.UPLOADS_NOT_CONFIGURED),K("error"),Z("Uploads are not configured."),n.a(2);case 2:return n.p=2,n.n=3,i.presignAndUpload(F,P,I);case 3:if(r=n.v,I(100),K("success"),o.openToast("File Uploaded Successfully!"),t={title:F.name,key:r.key,content_type:r.contentType,size:F.size,location:r.cdnUrl},!T||!_){n.n=5;break}return n.n=4,ue(t);case 4:(l=n.v)&&(s=l);case 5:re(function(n){return[].concat(e.toConsumableArray(n),[{response:t,dbId:s}])}),y&&y(t),k&&k(b,t.key),w&&w(m,b,t.key),N&&N(m,j,b,t.key),setTimeout(function(){U(null),K("idle"),I(0)},2e3),n.n=7;break;case 6:n.p=6,a=n.v,console.error("Upload error:",a),K("error"),Z("Error uploading file. Please try again."),o.openToast("Error uploading file!",400),I(0);case 7:return n.a(2)}},n,null,[[2,6]])}));return function(){return n.apply(this,arguments)}}(),xe=function(){U(null),K("idle"),I(0),Z("")};return n.jsxs("div",{className:"ihub-uploader ".concat(L),children:[a&&n.jsx("h3",{className:"ihub-uploader-header",children:a}),n.jsxs("div",{className:"ihub-uploader-container",children:[!F&&n.jsxs("div",{className:"ihub-uploader-dropzone ".concat(O?"ihub-uploader-dropzone-active":""),onDragOver:function(e){e.preventDefault(),e.stopPropagation(),q(!0)},onDragLeave:function(e){e.preventDefault(),e.stopPropagation(),q(!1)},onDrop:function(e){e.preventDefault(),e.stopPropagation(),q(!1);var n=e.dataTransfer.files;n&&n.length>0&&ce(n[0])},onClick:function(){var e;null===(e=le.current)||void 0===e||e.click()},children:[n.jsx("div",{className:"ihub-uploader-icon",children:n.jsxs("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:[n.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),n.jsx("polyline",{points:"17 8 12 3 7 8"}),n.jsx("line",{x1:"12",y1:"3",x2:"12",y2:"15"})]})}),n.jsx("p",{className:"ihub-uploader-text",children:u}),n.jsx("p",{className:"ihub-uploader-hint",children:x>0&&"Maximum file size: ".concat(ae(x))}),n.jsx("input",{ref:le,type:"file",accept:p,onChange:function(e){var n=e.target.files;n&&n.length>0&&ce(n[0])},className:"ihub-uploader-input"})]}),F&&n.jsxs("div",{className:"ihub-uploader-preview",children:[n.jsxs("div",{className:"ihub-uploader-file-info",children:[n.jsx("div",{className:"ihub-uploader-file-icon",children:F.type.startsWith("image/")?n.jsx("img",{src:URL.createObjectURL(F),alt:F.name,className:"ihub-uploader-thumbnail"}):n.jsxs("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:[n.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),n.jsx("polyline",{points:"14 2 14 8 20 8"}),n.jsx("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),n.jsx("line",{x1:"16",y1:"17",x2:"8",y2:"17"}),n.jsx("polyline",{points:"10 9 9 9 8 9"})]})}),n.jsxs("div",{className:"ihub-uploader-file-details",children:[n.jsx("p",{className:"ihub-uploader-file-name",children:F.name}),n.jsx("p",{className:"ihub-uploader-file-size",children:ae(F.size)})]})]}),"uploading"===J&&n.jsx("div",{className:"ihub-uploader-progress",children:n.jsx("div",{className:"ihub-uploader-progress-bar",style:{width:"".concat(G,"%")},children:n.jsxs("span",{className:"ihub-uploader-progress-text",children:[G,"%"]})})}),n.jsxs("div",{className:"ihub-uploader-actions",children:["idle"===J&&n.jsxs(n.Fragment,{children:[n.jsx("button",{type:"button",className:"ihub-uploader-upload-btn ihub-important-btn",onClick:he,children:"Upload"}),n.jsx("button",{type:"button",className:"ihub-uploader-cancel-btn outlined-btn",onClick:xe,children:"Cancel"})]}),"uploading"===J&&n.jsx("button",{type:"button",className:"ihub-uploader-cancel-btn outlined-btn",onClick:xe,children:"Cancel"}),"success"===J&&n.jsxs("div",{className:"ihub-uploader-success",children:[n.jsxs("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:[n.jsx("path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14"}),n.jsx("polyline",{points:"22 4 12 14.01 9 11.01"})]}),n.jsx("span",{children:"Upload Complete"})]}),"error"===J&&n.jsxs(n.Fragment,{children:[n.jsx("button",{type:"button",className:"ihub-uploader-retry-btn ihub-important-btn",onClick:he,children:"Retry"}),n.jsx("button",{type:"button",className:"ihub-uploader-cancel-btn outlined-btn",onClick:xe,children:"Cancel"})]})]})]}),ne.length>0&&n.jsx("div",{className:"ihub-uploader-thumbs",children:ne.map(function(e,r){var t,o=null===(t=e.response.content_type)||void 0===t?void 0:t.startsWith("video/");return n.jsxs("div",{className:"ihub-uploader-thumb",children:[n.jsxs("div",{className:"ihub-uploader-thumb-preview",onClick:function(){return se(r)},title:"Click to preview",children:[o?n.jsx("video",{src:e.response.location,muted:!0}):n.jsx("img",{src:e.response.location,alt:e.response.title}),o&&n.jsx("span",{className:"ihub-uploader-thumb-badge",children:n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"currentColor",children:n.jsx("polygon",{points:"5 3 19 12 5 21 5 3"})})})]}),n.jsx("button",{type:"button",className:"ihub-uploader-thumb-remove",onClick:function(e){e.stopPropagation(),pe(r)},title:"Remove",children:n.jsxs("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:[n.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),n.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},r)})}),null!==ie&&ne[ie]&&n.jsx("div",{className:"ihub-uploader-lightbox",onClick:function(){return se(null)},children:n.jsxs("div",{className:"ihub-uploader-lightbox-content",onClick:function(e){return e.stopPropagation()},children:[n.jsx("button",{type:"button",className:"ihub-uploader-lightbox-close",onClick:function(){return se(null)},children:n.jsxs("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:[n.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),n.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}),ie>0&&n.jsx("button",{type:"button",className:"ihub-uploader-lightbox-nav ihub-uploader-lightbox-prev",onClick:function(){return se(ie-1)},children:n.jsx("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:n.jsx("polyline",{points:"15 18 9 12 15 6"})})}),n.jsx("div",{className:"ihub-uploader-lightbox-media",children:null!==(l=ne[ie].response.content_type)&&void 0!==l&&l.startsWith("video/")?n.jsx("video",{src:ne[ie].response.location,controls:!0,autoPlay:!0}):n.jsx("img",{src:ne[ie].response.location,alt:ne[ie].response.title})}),ie<ne.length-1&&n.jsx("button",{type:"button",className:"ihub-uploader-lightbox-nav ihub-uploader-lightbox-next",onClick:function(){return se(ie+1)},children:n.jsx("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:n.jsx("polyline",{points:"9 18 15 12 9 6"})})}),n.jsxs("div",{className:"ihub-uploader-lightbox-info",children:[n.jsx("span",{children:ne[ie].response.title}),n.jsxs("span",{children:[ie+1," / ",ne.length]})]})]})}),Y&&n.jsxs("div",{className:"ihub-uploader-error",children:[n.jsxs("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:[n.jsx("circle",{cx:"12",cy:"12",r:"10"}),n.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),n.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}),n.jsx("span",{children:Y})]})]})]})};
2
2
  //# sourceMappingURL=IhubFileUploader.cjs.map
@@ -1,2 +1,2 @@
1
- import{slicedToArray as e,asyncToGenerator as n,regenerator as r,toConsumableArray as o}from"../../../../_virtual/_rollupPluginBabelHelpers.js";import{jsxs as t,jsx as i,Fragment as l}from"react/jsx-runtime";import{useState as a,useRef as s}from"react";import{reqOptions as c}from"../../lib/helpFunction.js";import{openToast as u}from"../../lib/modals/modals.js";import{presignAndUpload as d,UPLOADS_NOT_CONFIGURED as p}from"./presignedPut.js";function h(h){var v,m=h.header,f=h.label,b=void 0===f?"Drag and drop files here or click to browse":f,g=h.accept,k=void 0===g?"*":g,w=h.maxFileSize,y=void 0===w?0:w,x=h.name,N=void 0===x?"upload":x,C=h.module,L=void 0===C?"":C,B=h.step,j=void 0===B?"":B,W=h.onUploadComplete,z=h.setValues,P=h.setModules,_=h.setSteps,D=h.className,F=void 0===D?"":D,M=h.saveEndpoint,U=h.deleteEndpoint,E=h.token,S=h.getPresignedUrl,T=h.deleteFile,R=h.onRemove,O=a(null),H=e(O,2),I=H[0],V=H[1],A=a(!1),G=e(A,2),J=G[0],K=G[1],q=a(0),Q=e(q,2),X=Q[0],Y=Q[1],Z=a("idle"),$=e(Z,2),ee=$[0],ne=$[1],re=a(""),oe=e(re,2),te=oe[0],ie=oe[1],le=a([]),ae=e(le,2),se=ae[0],ce=ae[1],ue=a(null),de=e(ue,2),pe=de[0],he=de[1],ve=s(null),me=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]},fe=function(e){ie(""),function(e){var n;if("*"===k)return!0;var r=e.type,o=".".concat(null===(n=e.name.split(".").pop())||void 0===n?void 0:n.toLowerCase());return!!k.split(",").map(function(e){return e.trim()}).some(function(e){return e.startsWith(".")?o===e.toLowerCase():e.endsWith("/*")?r.startsWith("".concat(e.replace("/*",""),"/")):r===e})||(ie("File type not accepted. Please upload: ".concat(k)),!1)}(e)&&function(e){return!(y&&e.size>y&&(ie("File size exceeds the maximum limit of ".concat(me(y))),1))}(e)&&(V(e),ne("idle"),Y(0))},be=function(){var e=n(r().m(function e(n){var o,t,i,l,a,s,u,d;return r().w(function(e){for(;;)switch(e.p=e.n){case 0:if(M&&E){e.n=1;break}return e.a(2,null);case 1:return e.p=1,t=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!==(o=n.content_type)&&void 0!==o&&o.startsWith("video/")?"video":"image"}),i=c("POST",t,E,"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,u=l.status,e.n=5,l.text();case 5:s.error.call(s,"Save to DB failed:",u,e.v),e.n=7;break;case 6:e.p=6,d=e.v,console.error("Save to DB error:",d);case 7:return e.a(2,null)}},e,null,[[1,6]])}));return function(n){return e.apply(this,arguments)}}(),ge=function(){var e=n(r().m(function e(n){var o,t,i;return r().w(function(e){for(;;)switch(e.p=e.n){case 0:if(U&&E){e.n=1;break}return e.a(2,!1);case 1:return e.p=1,o=c("DELETE",null,E),e.n=2,fetch("".concat(U).concat(n,"/"),o);case 2:return t=e.v,e.a(2,t.ok||404===t.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)}}(),ke=function(){var e=n(r().m(function e(n){var o,t;return r().w(function(e){for(;;)switch(e.p=e.n){case 0:if(o=se[n]){e.n=1;break}return e.a(2);case 1:if(!o.dbId||!U){e.n=2;break}return e.n=2,ge(o.dbId);case 2:if(!T){e.n=6;break}return e.p=3,e.n=4,T(o.response);case 4:e.n=6;break;case 5:e.p=5,t=e.v,console.error("File delete error:",t);case 6:ce(function(e){return e.filter(function(e,r){return r!==n})}),R&&R(o.response),u("File removed");case 7:return e.a(2)}},e,null,[[3,5]])}));return function(n){return e.apply(this,arguments)}}(),we=function(){var e=n(r().m(function e(){var n,t,i,l,a;return r().w(function(e){for(;;)switch(e.p=e.n){case 0:if(I){e.n=1;break}return ie("Please select a file first"),e.a(2);case 1:if(ne("uploading"),ie(""),S){e.n=2;break}return console.error(p),ne("error"),ie("Uploads are not configured."),e.a(2);case 2:return e.p=2,e.n=3,d(I,S,Y);case 3:if(n=e.v,Y(100),ne("success"),u("File Uploaded Successfully!"),t={title:I.name,key:n.key,content_type:n.contentType,size:I.size,location:n.cdnUrl},!M||!E){e.n=5;break}return e.n=4,be(t);case 4:(l=e.v)&&(i=l);case 5:ce(function(e){return[].concat(o(e),[{response:t,dbId:i}])}),W&&W(t),z&&z(N,t.key),P&&P(L,N,t.key),_&&_(L,j,N,t.key),setTimeout(function(){V(null),ne("idle"),Y(0)},2e3),e.n=7;break;case 6:e.p=6,a=e.v,console.error("Upload error:",a),ne("error"),ie("Error uploading file. Please try again."),u("Error uploading file!",400),Y(0);case 7:return e.a(2)}},e,null,[[2,6]])}));return function(){return e.apply(this,arguments)}}(),ye=function(){V(null),ne("idle"),Y(0),ie("")};return t("div",{className:"ihub-uploader ".concat(F),children:[m&&i("h3",{className:"ihub-uploader-header",children:m}),t("div",{className:"ihub-uploader-container",children:[!I&&t("div",{className:"ihub-uploader-dropzone ".concat(J?"ihub-uploader-dropzone-active":""),onDragOver:function(e){e.preventDefault(),e.stopPropagation(),K(!0)},onDragLeave:function(e){e.preventDefault(),e.stopPropagation(),K(!1)},onDrop:function(e){e.preventDefault(),e.stopPropagation(),K(!1);var n=e.dataTransfer.files;n&&n.length>0&&fe(n[0])},onClick:function(){var e;null===(e=ve.current)||void 0===e||e.click()},children:[i("div",{className:"ihub-uploader-icon",children:t("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:b}),i("p",{className:"ihub-uploader-hint",children:y>0&&"Maximum file size: ".concat(me(y))}),i("input",{ref:ve,type:"file",accept:k,onChange:function(e){var n=e.target.files;n&&n.length>0&&fe(n[0])},className:"ihub-uploader-input"})]}),I&&t("div",{className:"ihub-uploader-preview",children:[t("div",{className:"ihub-uploader-file-info",children:[i("div",{className:"ihub-uploader-file-icon",children:I.type.startsWith("image/")?i("img",{src:URL.createObjectURL(I),alt:I.name,className:"ihub-uploader-thumbnail"}):t("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"})]})}),t("div",{className:"ihub-uploader-file-details",children:[i("p",{className:"ihub-uploader-file-name",children:I.name}),i("p",{className:"ihub-uploader-file-size",children:me(I.size)})]})]}),"uploading"===ee&&i("div",{className:"ihub-uploader-progress",children:i("div",{className:"ihub-uploader-progress-bar",style:{width:"".concat(X,"%")},children:t("span",{className:"ihub-uploader-progress-text",children:[X,"%"]})})}),t("div",{className:"ihub-uploader-actions",children:["idle"===ee&&t(l,{children:[i("button",{className:"ihub-uploader-upload-btn ihub-important-btn",onClick:we,children:"Upload"}),i("button",{className:"ihub-uploader-cancel-btn outlined-btn",onClick:ye,children:"Cancel"})]}),"uploading"===ee&&i("button",{className:"ihub-uploader-cancel-btn outlined-btn",onClick:ye,children:"Cancel"}),"success"===ee&&t("div",{className:"ihub-uploader-success",children:[t("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"===ee&&t(l,{children:[i("button",{className:"ihub-uploader-retry-btn ihub-important-btn",onClick:we,children:"Retry"}),i("button",{className:"ihub-uploader-cancel-btn outlined-btn",onClick:ye,children:"Cancel"})]})]})]}),se.length>0&&i("div",{className:"ihub-uploader-thumbs",children:se.map(function(e,n){var r,o=null===(r=e.response.content_type)||void 0===r?void 0:r.startsWith("video/");return t("div",{className:"ihub-uploader-thumb",children:[t("div",{className:"ihub-uploader-thumb-preview",onClick:function(){return he(n)},title:"Click to preview",children:[o?i("video",{src:e.response.location,muted:!0}):i("img",{src:e.response.location,alt:e.response.title}),o&&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(),ke(n)},title:"Remove",children:t("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!==pe&&se[pe]&&i("div",{className:"ihub-uploader-lightbox",onClick:function(){return he(null)},children:t("div",{className:"ihub-uploader-lightbox-content",onClick:function(e){return e.stopPropagation()},children:[i("button",{className:"ihub-uploader-lightbox-close",onClick:function(){return he(null)},children:t("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"})]})}),pe>0&&i("button",{className:"ihub-uploader-lightbox-nav ihub-uploader-lightbox-prev",onClick:function(){return he(pe-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!==(v=se[pe].response.content_type)&&void 0!==v&&v.startsWith("video/")?i("video",{src:se[pe].response.location,controls:!0,autoPlay:!0}):i("img",{src:se[pe].response.location,alt:se[pe].response.title})}),pe<se.length-1&&i("button",{className:"ihub-uploader-lightbox-nav ihub-uploader-lightbox-next",onClick:function(){return he(pe+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"})})}),t("div",{className:"ihub-uploader-lightbox-info",children:[i("span",{children:se[pe].response.title}),t("span",{children:[pe+1," / ",se.length]})]})]})}),te&&t("div",{className:"ihub-uploader-error",children:[t("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:te})]})]})]})}export{h 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{reqOptions as c}from"../../lib/helpFunction.js";import{openToast as u}from"../../lib/modals/modals.js";import{presignAndUpload as d,UPLOADS_NOT_CONFIGURED as p}from"./presignedPut.js";function h(h){var v,b=h.header,m=h.label,f=void 0===m?"Drag and drop files here or click to browse":m,g=h.accept,k=void 0===g?"*":g,w=h.maxFileSize,y=void 0===w?0:w,x=h.name,N=void 0===x?"upload":x,C=h.module,L=void 0===C?"":C,B=h.step,j=void 0===B?"":B,W=h.onUploadComplete,z=h.setValues,P=h.setModules,_=h.setSteps,D=h.className,F=void 0===D?"":D,M=h.saveEndpoint,U=h.deleteEndpoint,E=h.token,S=h.getPresignedUrl,T=h.deleteFile,R=h.onRemove,O=a(null),H=e(O,2),I=H[0],V=H[1],A=a(!1),G=e(A,2),J=G[0],K=G[1],q=a(0),Q=e(q,2),X=Q[0],Y=Q[1],Z=a("idle"),$=e(Z,2),ee=$[0],ne=$[1],re=a(""),te=e(re,2),oe=te[0],ie=te[1],le=a([]),ae=e(le,2),se=ae[0],ce=ae[1],ue=a(null),de=e(ue,2),pe=de[0],he=de[1],ve=s(null),be=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]},me=function(e){ie(""),function(e){var n;if("*"===k)return!0;var r=e.type,t=".".concat(null===(n=e.name.split(".").pop())||void 0===n?void 0:n.toLowerCase());return!!k.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})||(ie("File type not accepted. Please upload: ".concat(k)),!1)}(e)&&function(e){return!(y&&e.size>y&&(ie("File size exceeds the maximum limit of ".concat(be(y))),1))}(e)&&(V(e),ne("idle"),Y(0))},fe=function(){var e=n(r().m(function e(n){var t,o,i,l,a,s,u,d;return r().w(function(e){for(;;)switch(e.p=e.n){case 0:if(M&&E){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=c("POST",o,E,"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,u=l.status,e.n=5,l.text();case 5:s.error.call(s,"Save to DB failed:",u,e.v),e.n=7;break;case 6:e.p=6,d=e.v,console.error("Save to DB error:",d);case 7:return e.a(2,null)}},e,null,[[1,6]])}));return function(n){return e.apply(this,arguments)}}(),ge=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(U&&E){e.n=1;break}return e.a(2,!1);case 1:return e.p=1,t=c("DELETE",null,E),e.n=2,fetch("".concat(U).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)}}(),ke=function(){var e=n(r().m(function e(n){var t,o;return r().w(function(e){for(;;)switch(e.p=e.n){case 0:if(t=se[n]){e.n=1;break}return e.a(2);case 1:if(!t.dbId||!U){e.n=2;break}return e.n=2,ge(t.dbId);case 2:if(!T){e.n=6;break}return e.p=3,e.n=4,T(t.response);case 4:e.n=6;break;case 5:e.p=5,o=e.v,console.error("File delete error:",o);case 6:ce(function(e){return e.filter(function(e,r){return r!==n})}),R&&R(t.response),u("File removed");case 7:return e.a(2)}},e,null,[[3,5]])}));return function(n){return e.apply(this,arguments)}}(),we=function(){var e=n(r().m(function e(){var n,o,i,l,a;return r().w(function(e){for(;;)switch(e.p=e.n){case 0:if(I){e.n=1;break}return ie("Please select a file first"),e.a(2);case 1:if(ne("uploading"),ie(""),S){e.n=2;break}return console.error(p),ne("error"),ie("Uploads are not configured."),e.a(2);case 2:return e.p=2,e.n=3,d(I,S,Y);case 3:if(n=e.v,Y(100),ne("success"),u("File Uploaded Successfully!"),o={title:I.name,key:n.key,content_type:n.contentType,size:I.size,location:n.cdnUrl},!M||!E){e.n=5;break}return e.n=4,fe(o);case 4:(l=e.v)&&(i=l);case 5:ce(function(e){return[].concat(t(e),[{response:o,dbId:i}])}),W&&W(o),z&&z(N,o.key),P&&P(L,N,o.key),_&&_(L,j,N,o.key),setTimeout(function(){V(null),ne("idle"),Y(0)},2e3),e.n=7;break;case 6:e.p=6,a=e.v,console.error("Upload error:",a),ne("error"),ie("Error uploading file. Please try again."),u("Error uploading file!",400),Y(0);case 7:return e.a(2)}},e,null,[[2,6]])}));return function(){return e.apply(this,arguments)}}(),ye=function(){V(null),ne("idle"),Y(0),ie("")};return o("div",{className:"ihub-uploader ".concat(F),children:[b&&i("h3",{className:"ihub-uploader-header",children:b}),o("div",{className:"ihub-uploader-container",children:[!I&&o("div",{className:"ihub-uploader-dropzone ".concat(J?"ihub-uploader-dropzone-active":""),onDragOver:function(e){e.preventDefault(),e.stopPropagation(),K(!0)},onDragLeave:function(e){e.preventDefault(),e.stopPropagation(),K(!1)},onDrop:function(e){e.preventDefault(),e.stopPropagation(),K(!1);var n=e.dataTransfer.files;n&&n.length>0&&me(n[0])},onClick:function(){var e;null===(e=ve.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:f}),i("p",{className:"ihub-uploader-hint",children:y>0&&"Maximum file size: ".concat(be(y))}),i("input",{ref:ve,type:"file",accept:k,onChange:function(e){var n=e.target.files;n&&n.length>0&&me(n[0])},className:"ihub-uploader-input"})]}),I&&o("div",{className:"ihub-uploader-preview",children:[o("div",{className:"ihub-uploader-file-info",children:[i("div",{className:"ihub-uploader-file-icon",children:I.type.startsWith("image/")?i("img",{src:URL.createObjectURL(I),alt:I.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:I.name}),i("p",{className:"ihub-uploader-file-size",children:be(I.size)})]})]}),"uploading"===ee&&i("div",{className:"ihub-uploader-progress",children:i("div",{className:"ihub-uploader-progress-bar",style:{width:"".concat(X,"%")},children:o("span",{className:"ihub-uploader-progress-text",children:[X,"%"]})})}),o("div",{className:"ihub-uploader-actions",children:["idle"===ee&&o(l,{children:[i("button",{type:"button",className:"ihub-uploader-upload-btn ihub-important-btn",onClick:we,children:"Upload"}),i("button",{type:"button",className:"ihub-uploader-cancel-btn outlined-btn",onClick:ye,children:"Cancel"})]}),"uploading"===ee&&i("button",{type:"button",className:"ihub-uploader-cancel-btn outlined-btn",onClick:ye,children:"Cancel"}),"success"===ee&&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"===ee&&o(l,{children:[i("button",{type:"button",className:"ihub-uploader-retry-btn ihub-important-btn",onClick:we,children:"Retry"}),i("button",{type:"button",className:"ihub-uploader-cancel-btn outlined-btn",onClick:ye,children:"Cancel"})]})]})]}),se.length>0&&i("div",{className:"ihub-uploader-thumbs",children:se.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 he(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(),ke(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!==pe&&se[pe]&&i("div",{className:"ihub-uploader-lightbox",onClick:function(){return he(null)},children:o("div",{className:"ihub-uploader-lightbox-content",onClick:function(e){return e.stopPropagation()},children:[i("button",{type:"button",className:"ihub-uploader-lightbox-close",onClick:function(){return he(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"})]})}),pe>0&&i("button",{type:"button",className:"ihub-uploader-lightbox-nav ihub-uploader-lightbox-prev",onClick:function(){return he(pe-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!==(v=se[pe].response.content_type)&&void 0!==v&&v.startsWith("video/")?i("video",{src:se[pe].response.location,controls:!0,autoPlay:!0}):i("img",{src:se[pe].response.location,alt:se[pe].response.title})}),pe<se.length-1&&i("button",{type:"button",className:"ihub-uploader-lightbox-nav ihub-uploader-lightbox-next",onClick:function(){return he(pe+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:se[pe].response.title}),o("span",{children:[pe+1," / ",se.length]})]})]})}),oe&&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:oe})]})]})]})}export{h as default};
2
2
  //# sourceMappingURL=IhubFileUploader.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime");exports.default=function(){return e.jsx("div",{className:"react_loading container",children:e.jsx("div",{children:e.jsxs("div",{className:"lds-ellipsis",children:[e.jsx("div",{}),e.jsx("div",{}),e.jsx("div",{}),e.jsx("div",{})]})})})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var i=require("react/jsx-runtime");function e(){return i.jsxs("div",{className:"lds-ellipsis","aria-hidden":"true",children:[i.jsx("div",{}),i.jsx("div",{}),i.jsx("div",{}),i.jsx("div",{})]})}exports.default=function(){var s=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},a=s.variant,l=void 0===a?"page":a,n=s.label,r=void 0===n?"Loading":n;return"inline"===l?i.jsxs("div",{className:"ihub-loading-inline",role:"status","aria-live":"polite",children:[i.jsx(e,{}),i.jsx("span",{className:"ihub-loading-inline__label",children:r})]}):i.jsx("div",{className:"react_loading container",children:i.jsx("div",{children:i.jsx(e,{})})})};
2
2
  //# sourceMappingURL=LoadingAnimate.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"LoadingAnimate.cjs","sources":["../../../../src/components/theme/LoadingAnimate.tsx"],"sourcesContent":["import React from \"react\";\n\nexport default function LoadingAnimate() {\n return (\n <div className=\"react_loading container\">\n <div>\n <div className=\"lds-ellipsis\">\n <div></div>\n <div></div>\n <div></div>\n <div></div>\n </div>\n </div>\n </div>\n );\n}\n"],"names":["_jsx","className","children","jsx","_jsxs","jsxs"],"mappings":"uHAEc,WACZ,OACEA,EAAAA,WAAKC,UAAU,0BACbC,SAAAF,EAAAG,IAAA,MAAA,CAAAD,SACEE,EAAKC,KAAA,MAAA,CAAAJ,UAAU,yBACbD,EAAAA,IAAW,MAAA,CAAA,GACXA,EAAWG,IAAA,MAAA,CAAA,GACXH,EAAWG,IAAA,MAAA,CAAA,GACXH,EAAAA,oBAKV"}
1
+ {"version":3,"file":"LoadingAnimate.cjs","sources":["../../../../src/components/theme/LoadingAnimate.tsx"],"sourcesContent":["import React from \"react\";\n\nexport interface LoadingAnimateProps {\n /**\n * \"page\" (default): the full-viewport overlay, for a whole page loading.\n * \"inline\": stays inside its container, for a panel, card, modal section or\n * expanded table row. Never use \"page\" for part of a screen: it is\n * `position: fixed` and blanks everything while that one part loads.\n */\n variant?: \"page\" | \"inline\";\n /** Screen-reader text for the inline variant. Defaults to \"Loading\". */\n label?: string;\n}\n\nfunction Ellipsis() {\n return (\n <div className=\"lds-ellipsis\" aria-hidden=\"true\">\n <div></div>\n <div></div>\n <div></div>\n <div></div>\n </div>\n );\n}\n\n/**\n * Animated three-dot loader.\n * @param props - {@link LoadingAnimateProps}\n * @example\n * <LoadingAnimate /> // whole page\n * <LoadingAnimate variant=\"inline\" label=\"Loading people\" /> // one section\n */\nexport default function LoadingAnimate({ variant = \"page\", label = \"Loading\" }: LoadingAnimateProps = {}) {\n if (variant === \"inline\") {\n return (\n <div className=\"ihub-loading-inline\" role=\"status\" aria-live=\"polite\">\n <Ellipsis />\n <span className=\"ihub-loading-inline__label\">{label}</span>\n </div>\n );\n }\n return (\n <div className=\"react_loading container\">\n <div>\n <Ellipsis />\n </div>\n </div>\n );\n}\n"],"names":["Ellipsis","_jsxs","className","children","_jsx","jsx","_ref","arguments","length","undefined","_ref$variant","variant","_ref$label","label","role"],"mappings":"uGAcA,SAASA,IACP,OACEC,EAAAA,KAAK,MAAA,CAAAC,UAAU,6BAA2B,OAAMC,SAAA,CAC9CC,EAAAA,IAAW,MAAA,CAAA,GACXA,gBACAA,EAAAC,IAAA,MAAA,CAAA,GACAD,EAAAA,IAAW,MAAA,CAAA,KAGjB,iBASwB,WAAgF,IAAAE,EAAAC,UAAAC,OAAA,QAAAC,IAAAF,UAAA,GAAAA,UAAA,GAAF,CAAE,EAAAG,EAAAJ,EAA/DK,QAAAA,OAAU,IAAHD,EAAG,OAAMA,EAAAE,EAAAN,EAAEO,MAAAA,OAAQ,IAAHD,EAAG,UAASA,EAC1E,MAAgB,WAAZD,EAEAV,EAAAA,KAAK,MAAA,CAAAC,UAAU,sBAAsBY,KAAK,SAAQ,YAAW,SAAQX,SAAA,CACnEC,EAAAA,IAACJ,EAAQ,CAAA,GACTI,EAAAC,IAAA,OAAA,CAAMH,UAAU,6BAA4BC,SAAEU,OAKlDT,EAAAA,IAAA,MAAA,CAAKF,UAAU,0BAAyBC,SACtCC,EACEC,IAAA,MAAA,CAAAF,SAAAC,EAAAA,IAACJ,EAAQ,OAIjB"}
@@ -1,2 +1,2 @@
1
- import{jsx as i,jsxs as d}from"react/jsx-runtime";function e(){return i("div",{className:"react_loading container",children:i("div",{children:d("div",{className:"lds-ellipsis",children:[i("div",{}),i("div",{}),i("div",{}),i("div",{})]})})})}export{e as default};
1
+ import{jsxs as i,jsx as e}from"react/jsx-runtime";function a(){return i("div",{className:"lds-ellipsis","aria-hidden":"true",children:[e("div",{}),e("div",{}),e("div",{}),e("div",{})]})}function n(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},l=n.variant,d=void 0===l?"page":l,r=n.label,t=void 0===r?"Loading":r;return"inline"===d?i("div",{className:"ihub-loading-inline",role:"status","aria-live":"polite",children:[e(a,{}),e("span",{className:"ihub-loading-inline__label",children:t})]}):e("div",{className:"react_loading container",children:e("div",{children:e(a,{})})})}export{n as default};
2
2
  //# sourceMappingURL=LoadingAnimate.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"LoadingAnimate.js","sources":["../../../../src/components/theme/LoadingAnimate.tsx"],"sourcesContent":["import React from \"react\";\n\nexport default function LoadingAnimate() {\n return (\n <div className=\"react_loading container\">\n <div>\n <div className=\"lds-ellipsis\">\n <div></div>\n <div></div>\n <div></div>\n <div></div>\n </div>\n </div>\n </div>\n );\n}\n"],"names":["LoadingAnimate","_jsx","className","children","_jsxs"],"mappings":"kDAEc,SAAUA,IACtB,OACEC,SAAKC,UAAU,0BACbC,SAAAF,EAAA,MAAA,CAAAE,SACEC,EAAK,MAAA,CAAAF,UAAU,yBACbD,EAAW,MAAA,CAAA,GACXA,EAAW,MAAA,CAAA,GACXA,EAAW,MAAA,CAAA,GACXA,kBAKV"}
1
+ {"version":3,"file":"LoadingAnimate.js","sources":["../../../../src/components/theme/LoadingAnimate.tsx"],"sourcesContent":["import React from \"react\";\n\nexport interface LoadingAnimateProps {\n /**\n * \"page\" (default): the full-viewport overlay, for a whole page loading.\n * \"inline\": stays inside its container, for a panel, card, modal section or\n * expanded table row. Never use \"page\" for part of a screen: it is\n * `position: fixed` and blanks everything while that one part loads.\n */\n variant?: \"page\" | \"inline\";\n /** Screen-reader text for the inline variant. Defaults to \"Loading\". */\n label?: string;\n}\n\nfunction Ellipsis() {\n return (\n <div className=\"lds-ellipsis\" aria-hidden=\"true\">\n <div></div>\n <div></div>\n <div></div>\n <div></div>\n </div>\n );\n}\n\n/**\n * Animated three-dot loader.\n * @param props - {@link LoadingAnimateProps}\n * @example\n * <LoadingAnimate /> // whole page\n * <LoadingAnimate variant=\"inline\" label=\"Loading people\" /> // one section\n */\nexport default function LoadingAnimate({ variant = \"page\", label = \"Loading\" }: LoadingAnimateProps = {}) {\n if (variant === \"inline\") {\n return (\n <div className=\"ihub-loading-inline\" role=\"status\" aria-live=\"polite\">\n <Ellipsis />\n <span className=\"ihub-loading-inline__label\">{label}</span>\n </div>\n );\n }\n return (\n <div className=\"react_loading container\">\n <div>\n <Ellipsis />\n </div>\n </div>\n );\n}\n"],"names":["Ellipsis","_jsxs","className","children","_jsx","LoadingAnimate","_ref","arguments","length","undefined","_ref$variant","variant","_ref$label","label","role"],"mappings":"kDAcA,SAASA,IACP,OACEC,EAAK,MAAA,CAAAC,UAAU,6BAA2B,OAAMC,SAAA,CAC9CC,EAAW,MAAA,CAAA,GACXA,YACAA,EAAA,MAAA,CAAA,GACAA,EAAW,MAAA,CAAA,KAGjB,CASwB,SAAAC,IAAgF,IAAAC,EAAAC,UAAAC,OAAA,QAAAC,IAAAF,UAAA,GAAAA,UAAA,GAAF,CAAE,EAAAG,EAAAJ,EAA/DK,QAAAA,OAAU,IAAHD,EAAG,OAAMA,EAAAE,EAAAN,EAAEO,MAAAA,OAAQ,IAAHD,EAAG,UAASA,EAC1E,MAAgB,WAAZD,EAEAV,EAAK,MAAA,CAAAC,UAAU,sBAAsBY,KAAK,SAAQ,YAAW,SAAQX,SAAA,CACnEC,EAACJ,EAAQ,CAAA,GACTI,EAAA,OAAA,CAAMF,UAAU,6BAA4BC,SAAEU,OAKlDT,EAAA,MAAA,CAAKF,UAAU,0BAAyBC,SACtCC,EACE,MAAA,CAAAD,SAAAC,EAACJ,EAAQ,OAIjB"}
@@ -1 +1,19 @@
1
- export default function LoadingAnimate(): import("react/jsx-runtime").JSX.Element;
1
+ export interface LoadingAnimateProps {
2
+ /**
3
+ * "page" (default): the full-viewport overlay, for a whole page loading.
4
+ * "inline": stays inside its container, for a panel, card, modal section or
5
+ * expanded table row. Never use "page" for part of a screen: it is
6
+ * `position: fixed` and blanks everything while that one part loads.
7
+ */
8
+ variant?: "page" | "inline";
9
+ /** Screen-reader text for the inline variant. Defaults to "Loading". */
10
+ label?: string;
11
+ }
12
+ /**
13
+ * Animated three-dot loader.
14
+ * @param props - {@link LoadingAnimateProps}
15
+ * @example
16
+ * <LoadingAnimate /> // whole page
17
+ * <LoadingAnimate variant="inline" label="Loading people" /> // one section
18
+ */
19
+ export default function LoadingAnimate({ variant, label }?: LoadingAnimateProps): import("react/jsx-runtime").JSX.Element;
@@ -1,6 +1,7 @@
1
1
  export { default as ChangeStyleVariable } from "./ChangeStyleVariable";
2
2
  export { default as DarkModeProvider, useTheme } from "./DarkModeProvider";
3
3
  export { default as LoadingAnimate } from "./LoadingAnimate";
4
+ export type { LoadingAnimateProps } from "./LoadingAnimate";
4
5
  export { default as SessionProviders } from "./SessionProviders";
5
6
  export { default as SessionExpiresLogout } from "./signout/SessionExpiresLogout";
6
7
  export { default as SignOutSession } from "./signout/SignOutSession";