@nice2dev/ui 1.4.15 → 1.4.17
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/CHANGELOG.md +41 -0
- package/dist/NiceAlert-RVTgQxCE.cjs +1 -0
- package/dist/NiceDataGrid-DpSADM9L.cjs +10 -0
- package/dist/NiceForm-CzH9IPmZ.cjs +1 -0
- package/dist/{NiceHtmlEditor-By7R1wRo.cjs → NiceHtmlEditor-BEWNA_UI.cjs} +1 -1
- package/dist/NiceLoginForm-Bkm5j80r.cjs +1 -0
- package/dist/{NiceMention-i7n2BoMw.cjs → NiceMention-CrJJtDJx.cjs} +1 -1
- package/dist/{NiceModuleLifecyclePanel-DVHQuhc-.cjs → NiceModuleLifecyclePanel-CxVQOIIA.cjs} +1 -1
- package/dist/{NicePagination-D9JguOl0.cjs → NicePagination-CnKYyKI5.cjs} +1 -1
- package/dist/{NicePivotGrid-B_7iQJys.cjs → NicePivotGrid-BshofJh1.cjs} +1 -1
- package/dist/NiceSavedQueryPanel-C40zmo8O.cjs +587 -0
- package/dist/{NiceScheduler-B2DamQ_L.cjs → NiceScheduler-CSWtLS5G.cjs} +1 -1
- package/dist/{core-lazy-ChKRuEPb.cjs → core-lazy-DUKT6R8d.cjs} +1 -1
- package/dist/data/NiceRowEditDialog.mjs +42 -35
- package/dist/data/NiceTreeGrid.mjs +512 -474
- package/dist/data.cjs +1 -1
- package/dist/data.d.ts +30 -3
- package/dist/editors/forms/NiceForm.mjs +55 -52
- package/dist/editors/inputs/NiceRadioGroup.mjs +12 -12
- package/dist/editors/inputs/NiceSelect.mjs +51 -51
- package/dist/editors.cjs +1 -1
- package/dist/feedback.cjs +1 -1
- package/dist/index.cjs +101 -101
- package/dist/index.d.ts +31 -4
- package/dist/lazy.cjs +1 -1
- package/dist/navigation.cjs +1 -1
- package/dist/{no-code-CN_q6TcB.cjs → no-code-DPc82kyy.cjs} +11 -11
- package/dist/no-code.cjs +1 -1
- package/package.json +4 -4
- package/dist/NiceDataGrid-B1AOjgjm.cjs +0 -10
- package/dist/NiceForm-fmePSeA9.cjs +0 -1
- package/dist/NiceLoginForm-C2-WgRn0.cjs +0 -1
- package/dist/NiceSavedQueryPanel-ChY4HwpM.cjs +0 -587
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const e=require("react/jsx-runtime"),p=require("@nice2dev/ui-core"),n=require("react"),V=require("./NiceAlert-RVTgQxCE.cjs"),W=require("./NiceButton-DzCqkG5a.cjs"),U=({open:t,onClose:r,title:c,position:a="right",size:s="md",children:i,footer:d,transitionDuration:l,className:u,style:b,displayStyle:f,testId:_,"data-testid":v})=>{const o=p.useComponentDisplayStyle("modal",f),x=p.useComponentDisplayClass("modal",f),{t:N}=p.useNiceTranslation(),h=n.useRef(null);return p.useOverlayFocus(h,{open:t,onClose:r}),n.useEffect(()=>{if(t)return document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}},[t]),t?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"nice-drawer-overlay nice-drawer-overlay--visible",onMouseDown:j=>{j.target===j.currentTarget&&r()}}),e.jsxs("div",{ref:h,className:`nice-drawer nice-drawer--open nice-drawer--${a} nice-drawer--${s} nice-drawer--ds-${x} ${u||""}`,style:{...o,...b,...l!=null?{transitionDuration:`${l}ms`}:{}},role:"dialog","aria-modal":"true","aria-label":c,"data-testid":v??_,children:[c&&e.jsxs("div",{className:"nice-drawer__header",children:[e.jsx("h3",{className:"nice-drawer__title",children:c}),e.jsx("button",{type:"button",className:"nice-drawer__close",onClick:r,"aria-label":N("controls.close","Close"),children:e.jsx(p.NiceIcon,{name:"close",size:18})})]}),e.jsx("div",{className:"nice-drawer__body",children:i}),d&&e.jsx("div",{className:"nice-drawer__footer",children:d})]})]}):null},K=({toasts:t,onDismiss:r,position:c="top-right"})=>{const{t:a}=p.useNiceTranslation(),s=n.useRef(null),i=n.useRef(null);p.useInputHints(s,[{intent:"back",label:a("toast.dismiss","Dismiss")}]);const d=n.useCallback(l=>{const u=s.current;if(!u||!l.contains(document.activeElement))return;const b=[...u.querySelectorAll(".nice-toast:not(.nice-toast--exiting)")],f=b.indexOf(l),_=b[f+1]??b[f-1];(_&&_!==l?_.querySelector("button"):i.current?.isConnected?i.current:null)?.focus()},[]);return n.useEffect(()=>{const l=s.current;if(!l)return;const u=b=>{const f=b.relatedTarget;f instanceof HTMLElement&&!l.contains(f)&&(i.current=f)};return l.addEventListener("focusin",u),()=>l.removeEventListener("focusin",u)},[]),e.jsx("div",{ref:s,className:`nice-toast-container nice-toast-container--${c}`,role:"region","aria-label":a("toast.region","Notifications"),children:t.map(l=>e.jsx(Y,{toast:l,onDismiss:r,onLeave:d},l.id))})},Y=({toast:t,onDismiss:r,onLeave:c})=>{const{t:a}=p.useNiceTranslation(),s=n.useRef(null),[i,d]=n.useState(!1),[l,u]=n.useState(!1),[b,f]=n.useState(!1),_=l||b,v=n.useCallback(()=>{s.current&&c(s.current),d(!0)},[c]);return n.useEffect(()=>{if(_||i)return;const o=t.duration??4e3;if(o>0){const x=setTimeout(()=>d(!0),o);return()=>clearTimeout(x)}},[t.duration,_,i]),n.useEffect(()=>{if(i){const o=setTimeout(()=>r(t.id),200);return()=>clearTimeout(o)}},[i,t.id,r]),n.useEffect(()=>{const o=s.current;if(!o)return;const x=g=>{g.key==="Escape"&&!g.defaultPrevented&&(g.preventDefault(),v())},N=()=>u(!0),h=()=>u(!1),j=()=>f(!0),m=g=>{o.contains(g.relatedTarget)||f(!1)};return o.addEventListener("keydown",x),o.addEventListener("mouseenter",N),o.addEventListener("mouseleave",h),o.addEventListener("focusin",j),o.addEventListener("focusout",m),()=>{o.removeEventListener("keydown",x),o.removeEventListener("mouseenter",N),o.removeEventListener("mouseleave",h),o.removeEventListener("focusin",j),o.removeEventListener("focusout",m)}},[v]),e.jsxs("div",{ref:s,className:`nice-toast nice-toast--${t.variant} ${i?"nice-toast--exiting":""}`,role:"alert",style:{position:"relative"},children:[e.jsx("div",{className:"nice-toast__icon",children:V.alertIcons[t.variant]}),e.jsxs("div",{className:"nice-toast__content",children:[t.title&&e.jsx("div",{className:"nice-toast__title",children:t.title}),e.jsx("div",{className:"nice-toast__message",children:t.message}),t.action&&e.jsx("button",{type:"button",className:"nice-toast__action",onClick:()=>{t.action?.onClick(),v()},children:t.action.label})]}),e.jsx("button",{type:"button",className:"nice-toast__close",onClick:v,"aria-label":a("toast.close","Close"),children:e.jsx(p.NiceIcon,{name:"close",size:16})})]})};let G=0;function J(){const[t,r]=n.useState([]),c=n.useCallback((s,i,d)=>{const l=`toast-${++G}`;return r(u=>[...u,{id:l,variant:s,message:i,title:d?.title,duration:d?.duration,action:d?.action}]),l},[]),a=n.useCallback(s=>{r(i=>i.filter(d=>d.id!==s))},[]);return{toasts:t,dismiss:a,info:(s,i)=>c("info",s,i),success:(s,i)=>c("success",s,i),warning:(s,i)=>c("warning",s,i),error:(s,i)=>c("error",s,i)}}function Q({error:t,showRetry:r,retryLabel:c,title:a,onReset:s}){const{t:i}=p.useNiceTranslation();return e.jsxs("div",{className:"nice-error-boundary",role:"alert",children:[e.jsx("div",{className:"nice-error-boundary__icon",children:e.jsx(p.NiceIcon,{name:"warning",size:32})}),e.jsx("h2",{className:"nice-error-boundary__title",children:a??i("errorBoundary.somethingWentWrong","Something went wrong")}),e.jsx("p",{className:"nice-error-boundary__message",children:t.message}),r&&e.jsx("button",{type:"button",className:"nice-btn nice-btn--primary",onClick:s,children:c??i("errorBoundary.retry","Retry")})]})}const z=class z extends n.Component{constructor(){super(...arguments),this.state={hasError:!1,error:null},this.handleReset=()=>{this.setState({hasError:!1,error:null})}}static getDerivedStateFromError(r){return{hasError:!0,error:r}}componentDidCatch(r,c){this.props.onError?.(r,c)}render(){if(this.state.hasError&&this.state.error){const{fallback:r,showRetry:c=!0,retryLabel:a,title:s}=this.props;return typeof r=="function"?r(this.state.error,this.handleReset):r||e.jsx(Q,{error:this.state.error,showRetry:c,retryLabel:a,title:s,onReset:this.handleReset})}return this.props.children}};z.displayName="NiceErrorBoundary";let B=z;function X(t){return window.addEventListener("online",t),window.addEventListener("offline",t),()=>{window.removeEventListener("online",t),window.removeEventListener("offline",t)}}function Z(){return navigator.onLine}function ee(){return!0}const ne=({message:t,variant:r="warning",icon:c,online:a,size:s="md",className:i,style:d,"data-testid":l})=>{const{t:u}=p.useNiceTranslation(),b=n.useSyncExternalStore(X,Z,ee);return a??b?null:e.jsxs("div",{className:`nice-offline-banner nice-offline-banner--${r} nice-offline-banner--${s} ${i||""}`,style:d,role:"alert","aria-live":"assertive","data-testid":l,children:[e.jsx("span",{className:"nice-offline-banner__icon",children:c??e.jsx(p.NiceIcon,{name:"wifi",size:18})}),e.jsx("span",{className:"nice-offline-banner__message",children:t??u("offlineBanner.message","You are offline. Some features may be unavailable.")})]})},se=({error:t,onRetry:r,retryLabel:c,title:a,autoRetrySeconds:s,variant:i="error",icon:d,size:l="md",className:u,style:b,"data-testid":f})=>{const{t:_}=p.useNiceTranslation(),v=c??_("retryPanel.retry","Retry"),o=a??_("retryPanel.operationFailed","Operation failed"),[x,N]=n.useState(s??0),h=n.useRef(void 0),j=typeof t=="string"?t:t.message,m=n.useCallback(()=>{N(s??0),r()},[r,s]);return n.useEffect(()=>{if(!(!s||s<=0))return N(s),h.current=setInterval(()=>{N(g=>g<=1?(clearInterval(h.current),r(),0):g-1)},1e3),()=>clearInterval(h.current)},[s,r]),e.jsxs("div",{className:`nice-retry-panel nice-retry-panel--${i} nice-retry-panel--${l} ${u||""}`,style:b,role:"alert","data-testid":f,children:[e.jsx("div",{className:"nice-retry-panel__icon",children:d??e.jsx(p.NiceIcon,{name:"warning",size:24})}),e.jsxs("div",{className:"nice-retry-panel__content",children:[e.jsx("div",{className:"nice-retry-panel__title",children:o}),e.jsx("p",{className:"nice-retry-panel__message",children:j})]}),e.jsxs("div",{className:"nice-retry-panel__actions",children:[e.jsx("button",{type:"button",className:"nice-btn nice-btn--primary nice-btn--sm",onClick:m,children:v}),s&&x>0&&e.jsx("span",{className:"nice-retry-panel__countdown",children:_("retryPanel.autoRetryInS","Auto-retry in {countdown}s").replace("{countdown}",String(x))})]})]})};function M({timeoutMs:t=1e4,slowThresholdMs:r=3e3,onTimeout:c,autoRetry:a=!1,autoRetryCount:s=3}={}){const[i,d]=n.useState(!1),[l,u]=n.useState(!1),[b,f]=n.useState(!1),[_,v]=n.useState(0),[o,x]=n.useState(0),N=n.useRef(null),h=n.useRef(null),j=n.useRef(null),m=n.useRef(0),g=n.useCallback(()=>{N.current&&clearTimeout(N.current),h.current&&clearTimeout(h.current),j.current&&clearInterval(j.current)},[]),C=n.useCallback(()=>{g(),d(!0),u(!1),f(!1),v(0),m.current=Date.now(),j.current=setInterval(()=>{v(Date.now()-m.current)},200),N.current=setTimeout(()=>{u(!0)},r),h.current=setTimeout(()=>{f(!0),d(!1),u(!1),g(),c?.()},t)},[g,r,t,c]),S=n.useCallback(()=>{g(),d(!1),u(!1)},[g]),T=n.useCallback(()=>{x(w=>w+1),f(!1),C()},[C]);return n.useEffect(()=>()=>g(),[g]),n.useEffect(()=>{if(a&&b&&o<s){const w=Math.pow(2,o)*1e3,k=setTimeout(()=>T(),w);return()=>clearTimeout(k)}},[a,s,b,o,T]),{isLoading:i,isSlow:l,isTimedOut:b,elapsed:_,retryCount:o,start:C,stop:S,retry:T}}const te=({timeoutMs:t=1e4,slowThresholdMs:r=3e3,onTimeout:c,onRetry:a,autoRetry:s=!1,autoRetryCount:i=3,showProgress:d=!0,slowMessage:l,timeoutMessage:u,loading:b,children:f,size:_="md",className:v,style:o,"data-testid":x})=>{const{t:N}=p.useNiceTranslation(),{isSlow:h,isTimedOut:j,elapsed:m,start:g,stop:C,retry:S}=M({timeoutMs:t,slowThresholdMs:r,onTimeout:c,autoRetry:s,autoRetryCount:i}),T=n.useRef(g);T.current=g;const w=n.useRef(C);w.current=C,n.useEffect(()=>{b?T.current():w.current()},[b]);const k=()=>{S(),a?.()};if(!b)return e.jsx(e.Fragment,{children:f});if(j)return e.jsxs("div",{className:`nice-timeout-feedback nice-timeout-feedback--timeout nice-timeout-feedback--${_} ${v??""}`,style:o,role:"alert","data-testid":x,children:[e.jsx("p",{className:"nice-timeout-feedback__message",children:u??N("timeoutFeedback.timeout","The operation timed out. Please try again.")}),e.jsx(W.NiceButton,{size:"sm",className:"nice-timeout-feedback__retry-btn",onClick:k,children:N("timeoutFeedback.retry","Try again")})]});const E=Math.min(100,m/t*100);return e.jsxs("div",{className:`nice-timeout-feedback nice-timeout-feedback--${_} ${h?"nice-timeout-feedback--slow":""} ${v??""}`,style:o,role:"status","aria-busy":"true","data-testid":x,children:[e.jsx("div",{className:"nice-timeout-feedback__spinner","aria-hidden":"true"}),h&&e.jsx("p",{className:"nice-timeout-feedback__slow-msg",children:l??N("timeoutFeedback.slow","This is taking longer than usual…")}),d&&e.jsx("div",{className:"nice-timeout-feedback__progress",role:"progressbar","aria-label":N("timeoutFeedback.progress","Time until timeout"),"aria-valuenow":Math.round(E),"aria-valuemin":0,"aria-valuemax":100,children:e.jsx("div",{className:"nice-timeout-feedback__progress-bar",style:{width:`${E}%`}})})]})},re=Object.assign(n.forwardRef(({visible:t,onAcceptAll:r,onRejectAll:c,onSave:a,categories:s=["necessary","analytics","marketing","preferences"],defaults:i,position:d="bottom",size:l="md",policyUrl:u,showDetails:b=!1,className:f,style:_,id:v,testId:o,"data-testid":x,...N},h)=>{const j=p.useControlId(v),{t:m}=p.useNiceTranslation(),[g,C]=n.useState(!0),S=t??g,[T,w]=n.useState(b),[k,E]=n.useState(()=>{const y={necessary:!0,analytics:!1,marketing:!1,preferences:!1};return i&&Object.assign(y,i),y.necessary=!0,y}),P={necessary:m("cookie.necessary","Necessary"),analytics:m("cookie.analytics","Analytics"),marketing:m("cookie.marketing","Marketing"),preferences:m("cookie.preferences","Preferences")},L={necessary:m("cookie.necessaryDesc","Required for the website to function. Cannot be disabled."),analytics:m("cookie.analyticsDesc","Help us understand how visitors interact with the website."),marketing:m("cookie.marketingDesc","Used to deliver relevant advertisements."),preferences:m("cookie.preferencesDesc","Allow the website to remember your choices.")},O=n.useCallback(()=>{const y={necessary:!0,analytics:!0,marketing:!0,preferences:!0};r?.(),a?.(y),C(!1)},[r,a]),R=n.useCallback(()=>{const y={necessary:!0,analytics:!1,marketing:!1,preferences:!1};c?.(),a?.(y),C(!1)},[c,a]),q=n.useCallback(()=>{a?.({...k,necessary:!0}),C(!1)},[k,a]),$=n.useRef(null);p.useOverlayFocus($,{open:S});const A=n.useCallback(y=>{$.current=y,typeof h=="function"?h(y):h&&(h.current=y)},[h]);return S?e.jsx("div",{ref:A,id:j,className:`nice-cookie-consent nice-cookie-consent--${d} nice-cookie-consent--${l} ${f??""}`,style:_,role:"dialog","aria-label":m("cookie.label","Cookie Consent"),"aria-modal":"true","data-testid":x??o,...N,children:e.jsxs("div",{className:"nice-cookie-consent__content",children:[e.jsxs("p",{className:"nice-cookie-consent__message",children:[m("cookie.message","We use cookies to enhance your experience. By continuing to visit this site you agree to our use of cookies."),u&&e.jsxs(e.Fragment,{children:[" ",e.jsx("a",{href:u,className:"nice-cookie-consent__link",target:"_blank",rel:"noopener noreferrer",children:m("cookie.learnMore","Learn more")})]})]}),T&&e.jsx("div",{className:"nice-cookie-consent__details",children:s.map(y=>e.jsxs("label",{className:"nice-cookie-consent__category",children:[e.jsx("input",{type:"checkbox",checked:k[y],disabled:y==="necessary",onChange:F=>E(D=>({...D,[y]:F.target.checked})),className:"nice-cookie-consent__checkbox"}),e.jsxs("div",{className:"nice-cookie-consent__cat-info",children:[e.jsx("strong",{children:P[y]}),e.jsx("span",{className:"nice-cookie-consent__cat-desc",children:L[y]})]})]},y))}),e.jsxs("div",{className:"nice-cookie-consent__actions",children:[!T&&e.jsx("button",{type:"button",className:"nice-cookie-consent__btn nice-cookie-consent__btn--details",onClick:()=>w(!0),children:m("cookie.customize","Customize")}),T&&e.jsx("button",{type:"button",className:"nice-cookie-consent__btn nice-cookie-consent__btn--save",onClick:q,children:m("cookie.savePreferences","Save preferences")}),e.jsx("button",{type:"button",className:"nice-cookie-consent__btn nice-cookie-consent__btn--reject",onClick:R,children:m("cookie.rejectAll","Reject all")}),e.jsx("button",{type:"button",className:"nice-cookie-consent__btn nice-cookie-consent__btn--accept",onClick:O,children:m("cookie.acceptAll","Accept all")})]})]})}):null}),{displayName:"NiceCookieConsent"}),ie=Object.assign(n.forwardRef(({onSubmit:t,onForgotPassword:r,onRegister:c,loading:a=!1,error:s,variant:i="primary",size:d="md",showRememberMe:l=!0,showForgotPassword:u=!0,showRegister:b=!1,title:f,logo:_,usernameLabel:v,passwordLabel:o,usernamePlaceholder:x,passwordPlaceholder:N,className:h,style:j,id:m,testId:g,"data-testid":C,...S},T)=>{const w=p.useControlId(m),{t:k}=p.useNiceTranslation(),[E,P]=n.useState(""),[L,O]=n.useState(""),[R,q]=n.useState(!1),[$,A]=n.useState(!1),y=`${w}-user`,F=`${w}-pass`,D=`${w}-remember`,H=n.useCallback(I=>{I.preventDefault(),!a&&t?.({username:E,password:L,rememberMe:R})},[a,E,L,R,t]);return e.jsxs("form",{ref:T,id:w,className:`nice-login nice-login--${i} nice-login--${d} ${h??""}`,style:j,onSubmit:H,noValidate:!0,"data-testid":C??g,...S,children:[_&&e.jsx("div",{className:"nice-login__logo",children:_}),f&&e.jsx("h2",{className:"nice-login__title",children:f??k("login.title","Sign In")}),s&&e.jsx("div",{className:"nice-login__error",role:"alert",children:s}),e.jsxs("div",{className:"nice-login__field",children:[e.jsx("label",{htmlFor:y,className:"nice-login__label",children:v??k("login.username","Username")}),e.jsx("input",{id:y,className:"nice-login__input",type:"text",value:E,onChange:I=>P(I.target.value),placeholder:x??k("login.usernamePlaceholder","Enter your username"),autoComplete:"username",required:!0,disabled:a,"aria-required":"true"})]}),e.jsxs("div",{className:"nice-login__field",children:[e.jsx("label",{htmlFor:F,className:"nice-login__label",children:o??k("login.password","Password")}),e.jsxs("div",{className:"nice-login__password-wrap",children:[e.jsx("input",{id:F,className:"nice-login__input",type:$?"text":"password",value:L,onChange:I=>O(I.target.value),placeholder:N??k("login.passwordPlaceholder","Enter your password"),autoComplete:"current-password",required:!0,disabled:a,"aria-required":"true"}),e.jsx("button",{type:"button",className:"nice-login__toggle-password",onClick:()=>A(!$),"aria-label":$?k("login.hidePassword","Hide password"):k("login.showPassword","Show password"),tabIndex:-1,children:e.jsx(p.NiceIcon,{name:$?"eye-off":"eye",size:16})})]})]}),e.jsxs("div",{className:"nice-login__options",children:[l&&e.jsxs("label",{className:"nice-login__remember",htmlFor:D,children:[e.jsx("input",{id:D,type:"checkbox",checked:R,onChange:I=>q(I.target.checked),disabled:a}),e.jsx("span",{children:k("login.rememberMe","Remember me")})]}),u&&r&&e.jsx("button",{type:"button",className:"nice-login__forgot",onClick:r,disabled:a,children:k("login.forgotPassword","Forgot password?")})]}),e.jsx("button",{type:"submit",className:`nice-login__submit nice-login__submit--${i}`,disabled:a||!E||!L,children:a?k("login.loading","Signing in..."):k("login.submit","Sign In")}),b&&c&&e.jsxs("p",{className:"nice-login__register",children:[k("login.noAccount","Don't have an account?")," ",e.jsx("button",{type:"button",className:"nice-login__register-link",onClick:c,disabled:a,children:k("login.register","Register")})]})]})}),{displayName:"NiceLoginForm"});exports.NiceCookieConsent=re;exports.NiceDrawer=U;exports.NiceErrorBoundary=B;exports.NiceLoginForm=ie;exports.NiceOfflineBanner=ne;exports.NiceRetryPanel=se;exports.NiceTimeoutFeedback=te;exports.NiceToastContainer=K;exports.useNiceTimeout=M;exports.useNiceToast=J;
|