react-luminus-components 1.1.26 → 1.1.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.vite/manifest.json +41 -41
- package/dist/{DataKey-BM6Hi4Og.js → DataKey-C3jtX0q4.js} +1 -1
- package/dist/{DataKey-DN_Gd8yX.cjs → DataKey-CuZpR5t0.cjs} +1 -1
- package/dist/{SimpleTooltip-DnZSi_qT.js → SimpleTooltip-BMSn8Fqk.js} +1 -1
- package/dist/{SimpleTooltip-Bg8N9Up2.cjs → SimpleTooltip-XmxUVlDH.cjs} +1 -1
- package/dist/{Typography-C0E6aQv2.cjs → Typography-CHpY2hUz.cjs} +1 -1
- package/dist/{Typography-CsdF39gW.js → Typography-DUoLZCdX.js} +1 -1
- package/dist/{UserAvatarToggle-0_jNWWSB.cjs → UserAvatarToggle-DP4YFoNZ.cjs} +10 -10
- package/dist/{UserAvatarToggle-xT1i6nSz.js → UserAvatarToggle-I_MgjXhA.js} +1658 -1656
- package/dist/contexts/prompt/PromptContext.d.ts +3 -0
- package/dist/contexts.cjs.js +1 -1
- package/dist/contexts.es.js +266 -251
- package/dist/hooks/usePrompt/usePrompt.d.ts +2 -1
- package/dist/hooks.cjs.js +1 -1
- package/dist/hooks.es.js +3 -3
- package/dist/layout.cjs.js +1 -1
- package/dist/layout.es.js +83 -82
- package/dist/main.cjs.js +1 -1
- package/dist/main.es.js +6 -6
- package/dist/models/index.d.ts +1 -0
- package/dist/models/types/PromptOptions.d.ts +6 -0
- package/dist/style.css +1 -1
- package/dist/useConfirm-BGatkLkP.js +27 -0
- package/dist/useConfirm-D677YHtT.cjs +1 -0
- package/package.json +1 -1
- package/dist/useConfirm-CQp43K_n.js +0 -27
- package/dist/useConfirm-CdQJyKxQ.cjs +0 -1
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
import PromptOptions from '@models/types/PromptOptions';
|
|
2
3
|
interface IPromptContext {
|
|
3
4
|
isShown: boolean;
|
|
4
5
|
text: string;
|
|
5
6
|
showPrompt: (text: string) => void;
|
|
6
7
|
hidePrompt: () => void;
|
|
7
8
|
resolveRef: React.MutableRefObject<(value: string | null) => void>;
|
|
9
|
+
options: PromptOptions;
|
|
10
|
+
setOptions: React.Dispatch<React.SetStateAction<PromptOptions>>;
|
|
8
11
|
}
|
|
9
12
|
declare const PromptContext: import("react").Context<IPromptContext>;
|
|
10
13
|
export default PromptContext;
|
package/dist/contexts.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./UserAvatarToggle-0_jNWWSB.cjs"),a=require("react"),ve=require("./useConfirm-CdQJyKxQ.cjs"),Fe=require("./Typography-C0E6aQv2.cjs"),v=require("./DataKey-DN_Gd8yX.cjs"),Ie=require("react-dom");function Pe(s){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const n in s)if(n!=="default"){const o=Object.getOwnPropertyDescriptor(s,n);Object.defineProperty(e,n,o.get?o:{enumerable:!0,get:()=>s[n]})}}return e.default=s,Object.freeze(e)}const h=Pe(a),Ue=s=>h.forwardRef((e,n)=>t.jsxRuntimeExports.jsx("div",{...e,ref:n,className:t.classNames(e.className,s)})),We={"aria-label":t.PropTypes.string,onClick:t.PropTypes.func,variant:t.PropTypes.oneOf(["white"])},me=h.forwardRef(({className:s,variant:e,"aria-label":n="Close",...o},r)=>t.jsxRuntimeExports.jsx("button",{ref:r,type:"button",className:t.classNames("btn-close",e&&`btn-close-${e}`,s),"aria-label":n,...o}));me.displayName="CloseButton";me.propTypes=We;const $e=me;var J;function he(s){if((!J&&J!==0||s)&&t.canUseDOM){var e=document.createElement("div");e.style.position="absolute",e.style.top="-9999px",e.style.width="50px",e.style.height="50px",e.style.overflow="scroll",document.body.appendChild(e),J=e.offsetWidth-e.clientWidth,document.body.removeChild(e)}return J}function ce(s){s===void 0&&(s=t.ownerDocument());try{var e=s.activeElement;return!e||!e.nodeName?null:e}catch{return s.body}}function He(s=document){const e=s.defaultView;return Math.abs(e.innerWidth-s.documentElement.clientWidth)}const ge=v.dataAttr("modal-open");class _e{constructor({ownerDocument:e,handleContainerOverflow:n=!0,isRTL:o=!1}={}){this.handleContainerOverflow=n,this.isRTL=o,this.modals=[],this.ownerDocument=e}getScrollbarWidth(){return He(this.ownerDocument)}getElement(){return(this.ownerDocument||document).body}setModalAttributes(e){}removeModalAttributes(e){}setContainerStyle(e){const n={overflow:"hidden"},o=this.isRTL?"paddingLeft":"paddingRight",r=this.getElement();e.style={overflow:r.style.overflow,[o]:r.style[o]},e.scrollBarWidth&&(n[o]=`${parseInt(t.style(r,o)||"0",10)+e.scrollBarWidth}px`),r.setAttribute(ge,""),t.style(r,n)}reset(){[...this.modals].forEach(e=>this.remove(e))}removeContainerStyle(e){const n=this.getElement();n.removeAttribute(ge),Object.assign(n.style,e.style)}add(e){let n=this.modals.indexOf(e);return n!==-1||(n=this.modals.length,this.modals.push(e),this.setModalAttributes(e),n!==0)||(this.state={scrollBarWidth:this.getScrollbarWidth(),style:{}},this.handleContainerOverflow&&this.setContainerStyle(this.state)),n}remove(e){const n=this.modals.indexOf(e);n!==-1&&(this.modals.splice(n,1),!this.modals.length&&this.handleContainerOverflow&&this.removeContainerStyle(this.state),this.removeModalAttributes(e))}isTopModal(e){return!!this.modals.length&&this.modals[this.modals.length-1]===e}}const fe=_e,qe=["show","role","className","style","children","backdrop","keyboard","onBackdropClick","onEscapeKeyDown","transition","runTransition","backdropTransition","runBackdropTransition","autoFocus","enforceFocus","restoreFocus","restoreFocusOptions","renderDialog","renderBackdrop","manager","container","onShow","onHide","onExit","onExited","onExiting","onEnter","onEntering","onEntered"];function Ke(s,e){if(s==null)return{};var n={},o=Object.keys(s),r,i;for(i=0;i<o.length;i++)r=o[i],!(e.indexOf(r)>=0)&&(n[r]=s[r]);return n}let ue;function ze(s){return ue||(ue=new fe({ownerDocument:s==null?void 0:s.document})),ue}function Ge(s){const e=t.useWindow(),n=s||ze(e),o=a.useRef({dialog:null,backdrop:null});return Object.assign(o.current,{add:()=>n.add(o.current),remove:()=>n.remove(o.current),isTopModal:()=>n.isTopModal(o.current),setDialogRef:a.useCallback(r=>{o.current.dialog=r},[]),setBackdropRef:a.useCallback(r=>{o.current.backdrop=r},[])})}const Re=a.forwardRef((s,e)=>{let{show:n=!1,role:o="dialog",className:r,style:i,children:u,backdrop:c=!0,keyboard:f=!0,onBackdropClick:p,onEscapeKeyDown:m,transition:E,runTransition:C,backdropTransition:w,runBackdropTransition:Q,autoFocus:W=!0,enforceFocus:Z=!0,restoreFocus:M=!0,restoreFocusOptions:ee,renderDialog:$,renderBackdrop:te=d=>t.jsxRuntimeExports.jsx("div",Object.assign({},d)),manager:se,container:ne,onShow:H,onHide:A=()=>{},onExit:oe,onExited:D,onExiting:_,onEnter:q,onEntering:K,onEntered:z}=s,re=Ke(s,qe);const R=t.useWindow(),N=t.useWaitForDOMRef(ne),x=Ge(se),ae=t.useMounted(),G=v.usePrevious(n),[y,T]=a.useState(!n),g=a.useRef(null);a.useImperativeHandle(e,()=>x,[x]),t.canUseDOM&&!G&&n&&(g.current=ce(R==null?void 0:R.document)),n&&y&&T(!1);const j=t.useEventCallback(()=>{if(x.add(),k.current=t.listen(document,"keydown",le),I.current=t.listen(document,"focus",()=>setTimeout(ie),!0),H&&H(),W){var d,Y;const U=ce((d=(Y=x.dialog)==null?void 0:Y.ownerDocument)!=null?d:R==null?void 0:R.document);x.dialog&&U&&!t.contains(x.dialog,U)&&(g.current=U,x.dialog.focus())}}),F=t.useEventCallback(()=>{if(x.remove(),k.current==null||k.current(),I.current==null||I.current(),M){var d;(d=g.current)==null||d.focus==null||d.focus(ee),g.current=null}});a.useEffect(()=>{!n||!N||j()},[n,N,j]),a.useEffect(()=>{y&&F()},[y,F]),t.useWillUnmount(()=>{F()});const ie=t.useEventCallback(()=>{if(!Z||!ae()||!x.isTopModal())return;const d=ce(R==null?void 0:R.document);x.dialog&&d&&!t.contains(x.dialog,d)&&x.dialog.focus()}),V=t.useEventCallback(d=>{d.target===d.currentTarget&&(p==null||p(d),c===!0&&A())}),le=t.useEventCallback(d=>{f&&t.isEscKey(d)&&x.isTopModal()&&(m==null||m(d),d.defaultPrevented||A())}),I=a.useRef(),k=a.useRef(),X=(...d)=>{T(!0),D==null||D(...d)};if(!N)return null;const S=Object.assign({role:o,ref:x.setDialogRef,"aria-modal":o==="dialog"?!0:void 0},re,{style:i,className:r,tabIndex:-1});let P=$?$(S):t.jsxRuntimeExports.jsx("div",Object.assign({},S,{children:h.cloneElement(u,{role:"document"})}));P=t.renderTransition(E,C,{unmountOnExit:!0,mountOnEnter:!0,appear:!0,in:!!n,onExit:oe,onExiting:_,onExited:X,onEnter:q,onEntering:K,onEntered:z,children:P});let O=null;return c&&(O=te({ref:x.setBackdropRef,onClick:V}),O=t.renderTransition(w,Q,{in:!!n,appear:!0,mountOnEnter:!0,unmountOnExit:!0,children:O})),t.jsxRuntimeExports.jsx(t.jsxRuntimeExports.Fragment,{children:Ie.createPortal(t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[O,P]}),N)})});Re.displayName="Modal";const Ve=Object.assign(Re,{Manager:fe});function Xe(s,e){s.classList?s.classList.add(e):t.hasClass(s,e)||(typeof s.className=="string"?s.className=s.className+" "+e:s.setAttribute("class",(s.className&&s.className.baseVal||"")+" "+e))}function Ee(s,e){return s.replace(new RegExp("(^|\\s)"+e+"(?:\\s|$)","g"),"$1").replace(/\s+/g," ").replace(/^\s*|\s*$/g,"")}function Ye(s,e){s.classList?s.classList.remove(e):typeof s.className=="string"?s.className=Ee(s.className,e):s.setAttribute("class",Ee(s.className&&s.className.baseVal||"",e))}const L={FIXED_CONTENT:".fixed-top, .fixed-bottom, .is-fixed, .sticky-top",STICKY_CONTENT:".sticky-top",NAVBAR_TOGGLER:".navbar-toggler"};class Je extends fe{adjustAndStore(e,n,o){const r=n.style[e];n.dataset[e]=r,t.style(n,{[e]:`${parseFloat(t.style(n,e))+o}px`})}restore(e,n){const o=n.dataset[e];o!==void 0&&(delete n.dataset[e],t.style(n,{[e]:o}))}setContainerStyle(e){super.setContainerStyle(e);const n=this.getElement();if(Xe(n,"modal-open"),!e.scrollBarWidth)return;const o=this.isRTL?"paddingLeft":"paddingRight",r=this.isRTL?"marginLeft":"marginRight";v.qsa(n,L.FIXED_CONTENT).forEach(i=>this.adjustAndStore(o,i,e.scrollBarWidth)),v.qsa(n,L.STICKY_CONTENT).forEach(i=>this.adjustAndStore(r,i,-e.scrollBarWidth)),v.qsa(n,L.NAVBAR_TOGGLER).forEach(i=>this.adjustAndStore(r,i,e.scrollBarWidth))}removeContainerStyle(e){super.removeContainerStyle(e);const n=this.getElement();Ye(n,"modal-open");const o=this.isRTL?"paddingLeft":"paddingRight",r=this.isRTL?"marginLeft":"marginRight";v.qsa(n,L.FIXED_CONTENT).forEach(i=>this.restore(o,i)),v.qsa(n,L.STICKY_CONTENT).forEach(i=>this.restore(r,i)),v.qsa(n,L.NAVBAR_TOGGLER).forEach(i=>this.restore(r,i))}}let de;function Qe(s){return de||(de=new Je(s)),de}const je=h.forwardRef(({className:s,bsPrefix:e,as:n="div",...o},r)=>(e=t.useBootstrapPrefix(e,"modal-body"),t.jsxRuntimeExports.jsx(n,{ref:r,className:t.classNames(s,e),...o})));je.displayName="ModalBody";const Ze=je,et=h.createContext({onHide(){}}),Ce=et,ye=h.forwardRef(({bsPrefix:s,className:e,contentClassName:n,centered:o,size:r,fullscreen:i,children:u,scrollable:c,...f},p)=>{s=t.useBootstrapPrefix(s,"modal");const m=`${s}-dialog`,E=typeof i=="string"?`${s}-fullscreen-${i}`:`${s}-fullscreen`;return t.jsxRuntimeExports.jsx("div",{...f,ref:p,className:t.classNames(m,e,r&&`${s}-${r}`,o&&`${m}-centered`,c&&`${m}-scrollable`,i&&E),children:t.jsxRuntimeExports.jsx("div",{className:t.classNames(`${s}-content`,n),children:u})})});ye.displayName="ModalDialog";const be=ye,we=h.forwardRef(({className:s,bsPrefix:e,as:n="div",...o},r)=>(e=t.useBootstrapPrefix(e,"modal-footer"),t.jsxRuntimeExports.jsx(n,{ref:r,className:t.classNames(s,e),...o})));we.displayName="ModalFooter";const tt=we,st=h.forwardRef(({closeLabel:s="Close",closeVariant:e,closeButton:n=!1,onHide:o,children:r,...i},u)=>{const c=a.useContext(Ce),f=t.useEventCallback(()=>{c==null||c.onHide(),o==null||o()});return t.jsxRuntimeExports.jsxs("div",{ref:u,...i,children:[r,n&&t.jsxRuntimeExports.jsx($e,{"aria-label":s,variant:e,onClick:f})]})}),nt=st,Me=h.forwardRef(({bsPrefix:s,className:e,closeLabel:n="Close",closeButton:o=!1,...r},i)=>(s=t.useBootstrapPrefix(s,"modal-header"),t.jsxRuntimeExports.jsx(nt,{ref:i,...r,className:t.classNames(e,s),closeLabel:n,closeButton:o})));Me.displayName="ModalHeader";const ot=Me,rt=Ue("h4"),Ne=h.forwardRef(({className:s,bsPrefix:e,as:n=rt,...o},r)=>(e=t.useBootstrapPrefix(e,"modal-title"),t.jsxRuntimeExports.jsx(n,{ref:r,className:t.classNames(s,e),...o})));Ne.displayName="ModalTitle";const at=Ne;function it(s){return t.jsxRuntimeExports.jsx(t.Fade,{...s,timeout:null})}function lt(s){return t.jsxRuntimeExports.jsx(t.Fade,{...s,timeout:null})}const Te=h.forwardRef(({bsPrefix:s,className:e,style:n,dialogClassName:o,contentClassName:r,children:i,dialogAs:u=be,"data-bs-theme":c,"aria-labelledby":f,"aria-describedby":p,"aria-label":m,show:E=!1,animation:C=!0,backdrop:w=!0,keyboard:Q=!0,onEscapeKeyDown:W,onShow:Z,onHide:M,container:ee,autoFocus:$=!0,enforceFocus:te=!0,restoreFocus:se=!0,restoreFocusOptions:ne,onEntered:H,onExit:A,onExiting:oe,onEnter:D,onEntering:_,onExited:q,backdropClassName:K,manager:z,...re},R)=>{const[N,x]=a.useState({}),[ae,G]=a.useState(!1),y=a.useRef(!1),T=a.useRef(!1),g=a.useRef(null),[j,F]=t.useCallbackRef(),ie=t.useMergedRefs(R,F),V=t.useEventCallback(M),le=t.useIsRTL();s=t.useBootstrapPrefix(s,"modal");const I=a.useMemo(()=>({onHide:V}),[V]);function k(){return z||Qe({isRTL:le})}function X(l){if(!t.canUseDOM)return;const B=k().getScrollbarWidth()>0,pe=l.scrollHeight>t.ownerDocument(l).documentElement.clientHeight;x({paddingRight:B&&!pe?he():void 0,paddingLeft:!B&&pe?he():void 0})}const S=t.useEventCallback(()=>{j&&X(j.dialog)});t.useWillUnmount(()=>{t.removeEventListener(window,"resize",S),g.current==null||g.current()});const P=()=>{y.current=!0},O=l=>{y.current&&j&&l.target===j.dialog&&(T.current=!0),y.current=!1},d=()=>{G(!0),g.current=t.transitionEnd(j.dialog,()=>{G(!1)})},Y=l=>{l.target===l.currentTarget&&d()},U=l=>{if(w==="static"){Y(l);return}if(T.current||l.target!==l.currentTarget){T.current=!1;return}M==null||M()},ke=l=>{Q?W==null||W(l):(l.preventDefault(),w==="static"&&d())},Se=(l,B)=>{l&&X(l),D==null||D(l,B)},Oe=l=>{g.current==null||g.current(),A==null||A(l)},Be=(l,B)=>{_==null||_(l,B),t.addEventListener(window,"resize",S)},Le=l=>{l&&(l.style.display=""),q==null||q(l),t.removeEventListener(window,"resize",S)},Ae=a.useCallback(l=>t.jsxRuntimeExports.jsx("div",{...l,className:t.classNames(`${s}-backdrop`,K,!C&&"show")}),[C,K,s]),xe={...n,...N};xe.display="block";const De=l=>t.jsxRuntimeExports.jsx("div",{role:"dialog",...l,style:xe,className:t.classNames(e,s,ae&&`${s}-static`,!C&&"show"),onClick:w?U:void 0,onMouseUp:O,"data-bs-theme":c,"aria-label":m,"aria-labelledby":f,"aria-describedby":p,children:t.jsxRuntimeExports.jsx(u,{...re,onMouseDown:P,className:o,contentClassName:r,children:i})});return t.jsxRuntimeExports.jsx(Ce.Provider,{value:I,children:t.jsxRuntimeExports.jsx(Ve,{show:E,ref:ie,backdrop:w,container:ee,keyboard:!0,autoFocus:$,enforceFocus:te,restoreFocus:se,restoreFocusOptions:ne,onEscapeKeyDown:ke,onShow:Z,onHide:M,onEnter:Se,onEntering:Be,onEntered:H,onExit:Oe,onExiting:oe,onExited:Le,manager:k(),transition:C?it:void 0,backdropTransition:C?lt:void 0,renderBackdrop:Ae,renderDialog:De})})});Te.displayName="Modal";const b=Object.assign(Te,{Body:Ze,Header:ot,Title:at,Footer:tt,Dialog:be,TRANSITION_DURATION:300,BACKDROP_TRANSITION_DURATION:150}),ct=()=>{const{confirmTexts:s}=a.useContext(t.LuminusComponentsContext),{isShown:e,text:n,onFinish:o}=ve.usePrompt(),[r,i]=a.useState(""),u=a.useCallback(()=>{o(null)},[o]),c=a.useCallback(()=>{o(r)},[o,r]);return a.useEffect(()=>{e===!0&&i("")},[e]),t.jsxRuntimeExports.jsxs(b,{show:e,size:"sm",centered:!0,onHide:u,children:[t.jsxRuntimeExports.jsx(b.Header,{children:t.jsxRuntimeExports.jsx(b.Title,{children:n})}),t.jsxRuntimeExports.jsx(b.Body,{children:t.jsxRuntimeExports.jsx("textarea",{autoFocus:!0,tabIndex:0,value:r,onChange:f=>i(f.currentTarget.value),className:"w-100",rows:5})}),t.jsxRuntimeExports.jsxs(b.Footer,{children:[t.jsxRuntimeExports.jsx("button",{type:"button",className:"btn btn-secondary",onClick:u,children:s.cancel}),t.jsxRuntimeExports.jsx("button",{type:"button",className:"btn btn-primary ml",onClick:c,children:s.confirm})]})]})},ut=({children:s})=>{const[e,n]=a.useState(!1),[o,r]=a.useState(""),i=a.useRef(()=>{}),u=a.useCallback(p=>{r(p),n(!0),console.log("showprompt")},[]),c=a.useCallback(()=>{n(!1)},[]),f=a.useMemo(()=>({isShown:e,text:o,showPrompt:u,hidePrompt:c,resolveRef:i}),[c,e,u,o,i]);return t.jsxRuntimeExports.jsxs(t.PromptContext.Provider,{value:f,children:[s,t.jsxRuntimeExports.jsx(ct,{})]})},dt=({children:s})=>{const[e,n]=a.useState(!1),[o,r]=a.useState(""),i=a.useCallback(f=>{n(!0),r(f)},[]),u=a.useCallback(()=>{n(!1)},[]),c=a.useMemo(()=>({show:e,text:o,showConfirm:i,hideConfirm:u}),[e,o,i,u]);return t.jsxRuntimeExports.jsxs(t.ConfirmContext.Provider,{value:c,children:[t.jsxRuntimeExports.jsx(pt,{}),s]})},mt=({cookieDomain:s,axiosInstance:e,LinkComponent:n,language:o,axiosTexts:r,confirmTexts:i,formValidationTexts:u,homeDashboardTexts:c,formSubmitTexts:f,appSearchTexts:p,children:m})=>{const E=a.useMemo(()=>({axiosInstance:e,cookieDomain:s,LinkComponent:n,language:o,axiosTexts:r,confirmTexts:i,formValidationTexts:u,homeDashboardTexts:c,formSubmitTexts:f,appSearchTexts:p}),[e,s,n,o,r,i,u,c,f,p]);return t.jsxRuntimeExports.jsx(t.LuminusComponentsContext.Provider,{value:E,children:t.jsxRuntimeExports.jsx(dt,{children:t.jsxRuntimeExports.jsxs(ut,{children:[t.jsxRuntimeExports.jsx(t.Ie,{}),m]})})})},ft=({children:s})=>{const[e,n]=a.useState(!1),[o]=a.useState(new Set),r=a.useCallback(c=>{o.add(c),n(!0)},[o]),i=a.useCallback(c=>{o.delete(c),o.size===0&&n(!1)},[o]),u=a.useMemo(()=>({isLoading:e,startLoading:r,stopLoading:i}),[e,r,i]);return t.jsxRuntimeExports.jsxs(t.LoadingContext.Provider,{value:u,children:[e&&t.jsxRuntimeExports.jsx(v.Loading,{}),s]})},xt=({children:s})=>{const e=t.useAxios(),n=a.useCallback(()=>{const m=localStorage.getItem("user")??null;return m?JSON.parse(m):null},[]),[o,r]=a.useState(n()),i=a.useCallback(async()=>{let m=null;return await e.get("/user/detail").then(E=>{m=E.data}).catch(()=>{m=null}),localStorage.setItem("user",JSON.stringify(m)),m},[e]),u=a.useCallback(()=>{localStorage.removeItem("user")},[]),c=a.useCallback(async()=>{const m=await i();return m?(r(m),!0):!1},[i]),f=a.useCallback(()=>{u(),r(null)},[u]),p=a.useMemo(()=>({user:o,loginUser:c,logoutUser:f}),[o,c,f]);return a.useEffect(()=>{r(n())},[n]),t.jsxRuntimeExports.jsx(t.UserContext.Provider,{value:p,children:s})},pt=()=>{const{confirmTexts:s}=a.useContext(t.LuminusComponentsContext),{onConfirm:e,onCancel:n,text:o,show:r}=ve.useConfirm();return t.jsxRuntimeExports.jsx(b,{show:r,size:"sm",centered:!0,onHide:n,children:t.jsxRuntimeExports.jsxs(b.Body,{children:[t.jsxRuntimeExports.jsx("div",{className:"mb-5 text-center",children:t.jsxRuntimeExports.jsx(Fe.Typography,{variant:"h6",children:o})}),t.jsxRuntimeExports.jsxs("div",{className:"w-100 d-flex gap-5",children:[t.jsxRuntimeExports.jsx("button",{type:"button",className:"btn btn-secondary w-100",onClick:n,children:s.no}),t.jsxRuntimeExports.jsx("button",{type:"button",className:"btn btn-primary w-100 ml",onClick:e,children:s.yes})]})]})})};exports.LoadingContext=t.LoadingContext;exports.LuminusComponentsContext=t.LuminusComponentsContext;exports.UserContext=t.UserContext;exports.LoadingProvider=ft;exports.LuminusComponentsProvider=mt;exports.UserProvider=xt;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./UserAvatarToggle-DP4YFoNZ.cjs"),a=require("react"),ve=require("./useConfirm-D677YHtT.cjs"),Fe=require("./Typography-CHpY2hUz.cjs"),v=require("./DataKey-CuZpR5t0.cjs"),Ie=require("react-dom");function Pe(s){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const n in s)if(n!=="default"){const o=Object.getOwnPropertyDescriptor(s,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:()=>s[n]})}}return t.default=s,Object.freeze(t)}const g=Pe(a),Ue=s=>g.forwardRef((t,n)=>e.jsxRuntimeExports.jsx("div",{...t,ref:n,className:e.classNames(t.className,s)})),We={"aria-label":e.PropTypes.string,onClick:e.PropTypes.func,variant:e.PropTypes.oneOf(["white"])},me=g.forwardRef(({className:s,variant:t,"aria-label":n="Close",...o},r)=>e.jsxRuntimeExports.jsx("button",{ref:r,type:"button",className:e.classNames("btn-close",t&&`btn-close-${t}`,s),"aria-label":n,...o}));me.displayName="CloseButton";me.propTypes=We;const $e=me;var J;function he(s){if((!J&&J!==0||s)&&e.canUseDOM){var t=document.createElement("div");t.style.position="absolute",t.style.top="-9999px",t.style.width="50px",t.style.height="50px",t.style.overflow="scroll",document.body.appendChild(t),J=t.offsetWidth-t.clientWidth,document.body.removeChild(t)}return J}function ce(s){s===void 0&&(s=e.ownerDocument());try{var t=s.activeElement;return!t||!t.nodeName?null:t}catch{return s.body}}function He(s=document){const t=s.defaultView;return Math.abs(t.innerWidth-s.documentElement.clientWidth)}const ge=v.dataAttr("modal-open");class _e{constructor({ownerDocument:t,handleContainerOverflow:n=!0,isRTL:o=!1}={}){this.handleContainerOverflow=n,this.isRTL=o,this.modals=[],this.ownerDocument=t}getScrollbarWidth(){return He(this.ownerDocument)}getElement(){return(this.ownerDocument||document).body}setModalAttributes(t){}removeModalAttributes(t){}setContainerStyle(t){const n={overflow:"hidden"},o=this.isRTL?"paddingLeft":"paddingRight",r=this.getElement();t.style={overflow:r.style.overflow,[o]:r.style[o]},t.scrollBarWidth&&(n[o]=`${parseInt(e.style(r,o)||"0",10)+t.scrollBarWidth}px`),r.setAttribute(ge,""),e.style(r,n)}reset(){[...this.modals].forEach(t=>this.remove(t))}removeContainerStyle(t){const n=this.getElement();n.removeAttribute(ge),Object.assign(n.style,t.style)}add(t){let n=this.modals.indexOf(t);return n!==-1||(n=this.modals.length,this.modals.push(t),this.setModalAttributes(t),n!==0)||(this.state={scrollBarWidth:this.getScrollbarWidth(),style:{}},this.handleContainerOverflow&&this.setContainerStyle(this.state)),n}remove(t){const n=this.modals.indexOf(t);n!==-1&&(this.modals.splice(n,1),!this.modals.length&&this.handleContainerOverflow&&this.removeContainerStyle(this.state),this.removeModalAttributes(t))}isTopModal(t){return!!this.modals.length&&this.modals[this.modals.length-1]===t}}const fe=_e,qe=["show","role","className","style","children","backdrop","keyboard","onBackdropClick","onEscapeKeyDown","transition","runTransition","backdropTransition","runBackdropTransition","autoFocus","enforceFocus","restoreFocus","restoreFocusOptions","renderDialog","renderBackdrop","manager","container","onShow","onHide","onExit","onExited","onExiting","onEnter","onEntering","onEntered"];function Ke(s,t){if(s==null)return{};var n={},o=Object.keys(s),r,i;for(i=0;i<o.length;i++)r=o[i],!(t.indexOf(r)>=0)&&(n[r]=s[r]);return n}let ue;function ze(s){return ue||(ue=new fe({ownerDocument:s==null?void 0:s.document})),ue}function Ge(s){const t=e.useWindow(),n=s||ze(t),o=a.useRef({dialog:null,backdrop:null});return Object.assign(o.current,{add:()=>n.add(o.current),remove:()=>n.remove(o.current),isTopModal:()=>n.isTopModal(o.current),setDialogRef:a.useCallback(r=>{o.current.dialog=r},[]),setBackdropRef:a.useCallback(r=>{o.current.backdrop=r},[])})}const je=a.forwardRef((s,t)=>{let{show:n=!1,role:o="dialog",className:r,style:i,children:m,backdrop:c=!0,keyboard:f=!0,onBackdropClick:p,onEscapeKeyDown:u,transition:h,runTransition:R,backdropTransition:w,runBackdropTransition:Q,autoFocus:W=!0,enforceFocus:Z=!0,restoreFocus:M=!0,restoreFocusOptions:ee,renderDialog:$,renderBackdrop:te=d=>e.jsxRuntimeExports.jsx("div",Object.assign({},d)),manager:se,container:ne,onShow:H,onHide:A=()=>{},onExit:oe,onExited:D,onExiting:_,onEnter:q,onEntering:K,onEntered:z}=s,re=Ke(s,qe);const j=e.useWindow(),N=e.useWaitForDOMRef(ne),x=Ge(se),ae=e.useMounted(),G=v.usePrevious(n),[y,T]=a.useState(!n),E=a.useRef(null);a.useImperativeHandle(t,()=>x,[x]),e.canUseDOM&&!G&&n&&(E.current=ce(j==null?void 0:j.document)),n&&y&&T(!1);const C=e.useEventCallback(()=>{if(x.add(),k.current=e.listen(document,"keydown",le),I.current=e.listen(document,"focus",()=>setTimeout(ie),!0),H&&H(),W){var d,Y;const U=ce((d=(Y=x.dialog)==null?void 0:Y.ownerDocument)!=null?d:j==null?void 0:j.document);x.dialog&&U&&!e.contains(x.dialog,U)&&(E.current=U,x.dialog.focus())}}),F=e.useEventCallback(()=>{if(x.remove(),k.current==null||k.current(),I.current==null||I.current(),M){var d;(d=E.current)==null||d.focus==null||d.focus(ee),E.current=null}});a.useEffect(()=>{!n||!N||C()},[n,N,C]),a.useEffect(()=>{y&&F()},[y,F]),e.useWillUnmount(()=>{F()});const ie=e.useEventCallback(()=>{if(!Z||!ae()||!x.isTopModal())return;const d=ce(j==null?void 0:j.document);x.dialog&&d&&!e.contains(x.dialog,d)&&x.dialog.focus()}),V=e.useEventCallback(d=>{d.target===d.currentTarget&&(p==null||p(d),c===!0&&A())}),le=e.useEventCallback(d=>{f&&e.isEscKey(d)&&x.isTopModal()&&(u==null||u(d),d.defaultPrevented||A())}),I=a.useRef(),k=a.useRef(),X=(...d)=>{T(!0),D==null||D(...d)};if(!N)return null;const S=Object.assign({role:o,ref:x.setDialogRef,"aria-modal":o==="dialog"?!0:void 0},re,{style:i,className:r,tabIndex:-1});let P=$?$(S):e.jsxRuntimeExports.jsx("div",Object.assign({},S,{children:g.cloneElement(m,{role:"document"})}));P=e.renderTransition(h,R,{unmountOnExit:!0,mountOnEnter:!0,appear:!0,in:!!n,onExit:oe,onExiting:_,onExited:X,onEnter:q,onEntering:K,onEntered:z,children:P});let O=null;return c&&(O=te({ref:x.setBackdropRef,onClick:V}),O=e.renderTransition(w,Q,{in:!!n,appear:!0,mountOnEnter:!0,unmountOnExit:!0,children:O})),e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:Ie.createPortal(e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[O,P]}),N)})});je.displayName="Modal";const Ve=Object.assign(je,{Manager:fe});function Xe(s,t){s.classList?s.classList.add(t):e.hasClass(s,t)||(typeof s.className=="string"?s.className=s.className+" "+t:s.setAttribute("class",(s.className&&s.className.baseVal||"")+" "+t))}function Ee(s,t){return s.replace(new RegExp("(^|\\s)"+t+"(?:\\s|$)","g"),"$1").replace(/\s+/g," ").replace(/^\s*|\s*$/g,"")}function Ye(s,t){s.classList?s.classList.remove(t):typeof s.className=="string"?s.className=Ee(s.className,t):s.setAttribute("class",Ee(s.className&&s.className.baseVal||"",t))}const L={FIXED_CONTENT:".fixed-top, .fixed-bottom, .is-fixed, .sticky-top",STICKY_CONTENT:".sticky-top",NAVBAR_TOGGLER:".navbar-toggler"};class Je extends fe{adjustAndStore(t,n,o){const r=n.style[t];n.dataset[t]=r,e.style(n,{[t]:`${parseFloat(e.style(n,t))+o}px`})}restore(t,n){const o=n.dataset[t];o!==void 0&&(delete n.dataset[t],e.style(n,{[t]:o}))}setContainerStyle(t){super.setContainerStyle(t);const n=this.getElement();if(Xe(n,"modal-open"),!t.scrollBarWidth)return;const o=this.isRTL?"paddingLeft":"paddingRight",r=this.isRTL?"marginLeft":"marginRight";v.qsa(n,L.FIXED_CONTENT).forEach(i=>this.adjustAndStore(o,i,t.scrollBarWidth)),v.qsa(n,L.STICKY_CONTENT).forEach(i=>this.adjustAndStore(r,i,-t.scrollBarWidth)),v.qsa(n,L.NAVBAR_TOGGLER).forEach(i=>this.adjustAndStore(r,i,t.scrollBarWidth))}removeContainerStyle(t){super.removeContainerStyle(t);const n=this.getElement();Ye(n,"modal-open");const o=this.isRTL?"paddingLeft":"paddingRight",r=this.isRTL?"marginLeft":"marginRight";v.qsa(n,L.FIXED_CONTENT).forEach(i=>this.restore(o,i)),v.qsa(n,L.STICKY_CONTENT).forEach(i=>this.restore(r,i)),v.qsa(n,L.NAVBAR_TOGGLER).forEach(i=>this.restore(r,i))}}let de;function Qe(s){return de||(de=new Je(s)),de}const Ce=g.forwardRef(({className:s,bsPrefix:t,as:n="div",...o},r)=>(t=e.useBootstrapPrefix(t,"modal-body"),e.jsxRuntimeExports.jsx(n,{ref:r,className:e.classNames(s,t),...o})));Ce.displayName="ModalBody";const Ze=Ce,et=g.createContext({onHide(){}}),Re=et,ye=g.forwardRef(({bsPrefix:s,className:t,contentClassName:n,centered:o,size:r,fullscreen:i,children:m,scrollable:c,...f},p)=>{s=e.useBootstrapPrefix(s,"modal");const u=`${s}-dialog`,h=typeof i=="string"?`${s}-fullscreen-${i}`:`${s}-fullscreen`;return e.jsxRuntimeExports.jsx("div",{...f,ref:p,className:e.classNames(u,t,r&&`${s}-${r}`,o&&`${u}-centered`,c&&`${u}-scrollable`,i&&h),children:e.jsxRuntimeExports.jsx("div",{className:e.classNames(`${s}-content`,n),children:m})})});ye.displayName="ModalDialog";const be=ye,we=g.forwardRef(({className:s,bsPrefix:t,as:n="div",...o},r)=>(t=e.useBootstrapPrefix(t,"modal-footer"),e.jsxRuntimeExports.jsx(n,{ref:r,className:e.classNames(s,t),...o})));we.displayName="ModalFooter";const tt=we,st=g.forwardRef(({closeLabel:s="Close",closeVariant:t,closeButton:n=!1,onHide:o,children:r,...i},m)=>{const c=a.useContext(Re),f=e.useEventCallback(()=>{c==null||c.onHide(),o==null||o()});return e.jsxRuntimeExports.jsxs("div",{ref:m,...i,children:[r,n&&e.jsxRuntimeExports.jsx($e,{"aria-label":s,variant:t,onClick:f})]})}),nt=st,Me=g.forwardRef(({bsPrefix:s,className:t,closeLabel:n="Close",closeButton:o=!1,...r},i)=>(s=e.useBootstrapPrefix(s,"modal-header"),e.jsxRuntimeExports.jsx(nt,{ref:i,...r,className:e.classNames(t,s),closeLabel:n,closeButton:o})));Me.displayName="ModalHeader";const ot=Me,rt=Ue("h4"),Ne=g.forwardRef(({className:s,bsPrefix:t,as:n=rt,...o},r)=>(t=e.useBootstrapPrefix(t,"modal-title"),e.jsxRuntimeExports.jsx(n,{ref:r,className:e.classNames(s,t),...o})));Ne.displayName="ModalTitle";const at=Ne;function it(s){return e.jsxRuntimeExports.jsx(e.Fade,{...s,timeout:null})}function lt(s){return e.jsxRuntimeExports.jsx(e.Fade,{...s,timeout:null})}const Te=g.forwardRef(({bsPrefix:s,className:t,style:n,dialogClassName:o,contentClassName:r,children:i,dialogAs:m=be,"data-bs-theme":c,"aria-labelledby":f,"aria-describedby":p,"aria-label":u,show:h=!1,animation:R=!0,backdrop:w=!0,keyboard:Q=!0,onEscapeKeyDown:W,onShow:Z,onHide:M,container:ee,autoFocus:$=!0,enforceFocus:te=!0,restoreFocus:se=!0,restoreFocusOptions:ne,onEntered:H,onExit:A,onExiting:oe,onEnter:D,onEntering:_,onExited:q,backdropClassName:K,manager:z,...re},j)=>{const[N,x]=a.useState({}),[ae,G]=a.useState(!1),y=a.useRef(!1),T=a.useRef(!1),E=a.useRef(null),[C,F]=e.useCallbackRef(),ie=e.useMergedRefs(j,F),V=e.useEventCallback(M),le=e.useIsRTL();s=e.useBootstrapPrefix(s,"modal");const I=a.useMemo(()=>({onHide:V}),[V]);function k(){return z||Qe({isRTL:le})}function X(l){if(!e.canUseDOM)return;const B=k().getScrollbarWidth()>0,xe=l.scrollHeight>e.ownerDocument(l).documentElement.clientHeight;x({paddingRight:B&&!xe?he():void 0,paddingLeft:!B&&xe?he():void 0})}const S=e.useEventCallback(()=>{C&&X(C.dialog)});e.useWillUnmount(()=>{e.removeEventListener(window,"resize",S),E.current==null||E.current()});const P=()=>{y.current=!0},O=l=>{y.current&&C&&l.target===C.dialog&&(T.current=!0),y.current=!1},d=()=>{G(!0),E.current=e.transitionEnd(C.dialog,()=>{G(!1)})},Y=l=>{l.target===l.currentTarget&&d()},U=l=>{if(w==="static"){Y(l);return}if(T.current||l.target!==l.currentTarget){T.current=!1;return}M==null||M()},ke=l=>{Q?W==null||W(l):(l.preventDefault(),w==="static"&&d())},Se=(l,B)=>{l&&X(l),D==null||D(l,B)},Oe=l=>{E.current==null||E.current(),A==null||A(l)},Be=(l,B)=>{_==null||_(l,B),e.addEventListener(window,"resize",S)},Le=l=>{l&&(l.style.display=""),q==null||q(l),e.removeEventListener(window,"resize",S)},Ae=a.useCallback(l=>e.jsxRuntimeExports.jsx("div",{...l,className:e.classNames(`${s}-backdrop`,K,!R&&"show")}),[R,K,s]),pe={...n,...N};pe.display="block";const De=l=>e.jsxRuntimeExports.jsx("div",{role:"dialog",...l,style:pe,className:e.classNames(t,s,ae&&`${s}-static`,!R&&"show"),onClick:w?U:void 0,onMouseUp:O,"data-bs-theme":c,"aria-label":u,"aria-labelledby":f,"aria-describedby":p,children:e.jsxRuntimeExports.jsx(m,{...re,onMouseDown:P,className:o,contentClassName:r,children:i})});return e.jsxRuntimeExports.jsx(Re.Provider,{value:I,children:e.jsxRuntimeExports.jsx(Ve,{show:h,ref:ie,backdrop:w,container:ee,keyboard:!0,autoFocus:$,enforceFocus:te,restoreFocus:se,restoreFocusOptions:ne,onEscapeKeyDown:ke,onShow:Z,onHide:M,onEnter:Se,onEntering:Be,onEntered:H,onExit:Oe,onExiting:oe,onExited:Le,manager:k(),transition:R?it:void 0,backdropTransition:R?lt:void 0,renderBackdrop:Ae,renderDialog:De})})});Te.displayName="Modal";const b=Object.assign(Te,{Body:Ze,Header:ot,Title:at,Footer:tt,Dialog:be,TRANSITION_DURATION:300,BACKDROP_TRANSITION_DURATION:150}),ct=()=>{const{confirmTexts:s}=a.useContext(e.LuminusComponentsContext),{isShown:t,text:n,onFinish:o}=ve.usePrompt(),{options:r}=a.useContext(e.PromptContext),[i,m]=a.useState(""),c=a.useCallback(()=>{o(null)},[o]),f=a.useCallback(()=>{o(i)},[o,i]);a.useEffect(()=>{t===!0&&m("")},[t]);const p=a.useMemo(()=>({value:i,onChange:u=>m(u.currentTarget.value),className:"w-100",autoFocus:!0,tabIndex:0}),[i]);return e.jsxRuntimeExports.jsxs(b,{show:t,size:"sm",centered:!0,onHide:c,children:[e.jsxRuntimeExports.jsx(b.Header,{children:e.jsxRuntimeExports.jsx(b.Title,{children:n})}),e.jsxRuntimeExports.jsxs(b.Body,{children:[r.input==="textarea"?e.jsxRuntimeExports.jsx("textarea",{...p,rows:5}):void 0,r.input==="input"?e.jsxRuntimeExports.jsx("input",{...p,type:r.type}):void 0]}),e.jsxRuntimeExports.jsxs(b.Footer,{children:[e.jsxRuntimeExports.jsx("button",{type:"button",className:"btn btn-secondary",onClick:c,children:s.cancel}),e.jsxRuntimeExports.jsx("button",{type:"button",className:"btn btn-primary ml",onClick:f,disabled:r.required&&!i,children:s.confirm})]})]})},ut=({children:s})=>{const[t,n]=a.useState(!1),[o,r]=a.useState(""),[i,m]=a.useState({input:"textarea",type:"text"}),c=a.useRef(()=>{}),f=a.useCallback(h=>{r(h),n(!0),console.log("showprompt")},[]),p=a.useCallback(()=>{n(!1)},[]),u=a.useMemo(()=>({isShown:t,text:o,showPrompt:f,hidePrompt:p,resolveRef:c,options:i,setOptions:m}),[t,o,f,p,i]);return e.jsxRuntimeExports.jsxs(e.PromptContext.Provider,{value:u,children:[s,e.jsxRuntimeExports.jsx(ct,{})]})},dt=({children:s})=>{const[t,n]=a.useState(!1),[o,r]=a.useState(""),i=a.useCallback(f=>{n(!0),r(f)},[]),m=a.useCallback(()=>{n(!1)},[]),c=a.useMemo(()=>({show:t,text:o,showConfirm:i,hideConfirm:m}),[t,o,i,m]);return e.jsxRuntimeExports.jsxs(e.ConfirmContext.Provider,{value:c,children:[e.jsxRuntimeExports.jsx(xt,{}),s]})},mt=({cookieDomain:s,axiosInstance:t,LinkComponent:n,language:o,axiosTexts:r,confirmTexts:i,formValidationTexts:m,homeDashboardTexts:c,formSubmitTexts:f,appSearchTexts:p,children:u})=>{const h=a.useMemo(()=>({axiosInstance:t,cookieDomain:s,LinkComponent:n,language:o,axiosTexts:r,confirmTexts:i,formValidationTexts:m,homeDashboardTexts:c,formSubmitTexts:f,appSearchTexts:p}),[t,s,n,o,r,i,m,c,f,p]);return e.jsxRuntimeExports.jsx(e.LuminusComponentsContext.Provider,{value:h,children:e.jsxRuntimeExports.jsx(dt,{children:e.jsxRuntimeExports.jsxs(ut,{children:[e.jsxRuntimeExports.jsx(e.Ie,{}),u]})})})},ft=({children:s})=>{const[t,n]=a.useState(!1),[o]=a.useState(new Set),r=a.useCallback(c=>{o.add(c),n(!0)},[o]),i=a.useCallback(c=>{o.delete(c),o.size===0&&n(!1)},[o]),m=a.useMemo(()=>({isLoading:t,startLoading:r,stopLoading:i}),[t,r,i]);return e.jsxRuntimeExports.jsxs(e.LoadingContext.Provider,{value:m,children:[t&&e.jsxRuntimeExports.jsx(v.Loading,{}),s]})},pt=({children:s})=>{const t=e.useAxios(),n=a.useCallback(()=>{const u=localStorage.getItem("user")??null;return u?JSON.parse(u):null},[]),[o,r]=a.useState(n()),i=a.useCallback(async()=>{let u=null;return await t.get("/user/detail").then(h=>{u=h.data}).catch(()=>{u=null}),localStorage.setItem("user",JSON.stringify(u)),u},[t]),m=a.useCallback(()=>{localStorage.removeItem("user")},[]),c=a.useCallback(async()=>{const u=await i();return u?(r(u),!0):!1},[i]),f=a.useCallback(()=>{m(),r(null)},[m]),p=a.useMemo(()=>({user:o,loginUser:c,logoutUser:f}),[o,c,f]);return a.useEffect(()=>{r(n())},[n]),e.jsxRuntimeExports.jsx(e.UserContext.Provider,{value:p,children:s})},xt=()=>{const{confirmTexts:s}=a.useContext(e.LuminusComponentsContext),{onConfirm:t,onCancel:n,text:o,show:r}=ve.useConfirm();return e.jsxRuntimeExports.jsx(b,{show:r,size:"sm",centered:!0,onHide:n,children:e.jsxRuntimeExports.jsxs(b.Body,{children:[e.jsxRuntimeExports.jsx("div",{className:"mb-5 text-center",children:e.jsxRuntimeExports.jsx(Fe.Typography,{variant:"h6",children:o})}),e.jsxRuntimeExports.jsxs("div",{className:"w-100 d-flex gap-5",children:[e.jsxRuntimeExports.jsx("button",{type:"button",className:"btn btn-secondary w-100",onClick:n,children:s.no}),e.jsxRuntimeExports.jsx("button",{type:"button",className:"btn btn-primary w-100 ml",onClick:t,children:s.yes})]})]})})};exports.LoadingContext=e.LoadingContext;exports.LuminusComponentsContext=e.LuminusComponentsContext;exports.UserContext=e.UserContext;exports.LoadingProvider=ft;exports.LuminusComponentsProvider=mt;exports.UserProvider=pt;
|