@nice2dev/ui 1.0.10 → 1.0.11
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/NiceErrorBoundary-BZEHCXNM.cjs +1 -0
- package/dist/NiceErrorBoundary-D6jw6wwD.js +762 -0
- package/dist/NiceForm-BgR-m8T9.cjs +382 -0
- package/dist/NiceForm-DYKciCeR.js +5131 -0
- package/dist/NiceModal-Br3J9jOV.cjs +1 -0
- package/dist/NiceModal-DVAsBzHP.js +95 -0
- package/dist/NiceModuleLifecyclePanel-D3azLDdj.js +5249 -0
- package/dist/NiceModuleLifecyclePanel-DEfAIhFf.cjs +1 -0
- package/dist/NicePagination-CbB5P1N_.js +171 -0
- package/dist/NicePagination-UGjzvRUS.cjs +1 -0
- package/dist/NicePinCodeInput-BmRO9HSQ.js +11830 -0
- package/dist/NicePinCodeInput-D91uvVsF.cjs +419 -0
- package/dist/NiceSavedQueryPanel-7nZe46t8.cjs +596 -0
- package/dist/NiceSavedQueryPanel-BSGzs7Oc.js +6449 -0
- package/dist/NiceTabs-BeaxZzAO.js +1636 -0
- package/dist/NiceTabs-DcbYFIWR.cjs +1 -0
- package/dist/NiceWindow-Bga9fOkg.js +1409 -0
- package/dist/NiceWindow-CxWTj5xH.cjs +1 -0
- package/dist/charts-BcvKWYUl.cjs +759 -0
- package/dist/charts-DZvmvfhM.js +4621 -0
- package/dist/charts.cjs +1 -1
- package/dist/charts.mjs +1 -1
- package/dist/core-B4b1BmHt.js +22177 -0
- package/dist/core-CjmLbclt.cjs +96 -0
- package/dist/data.cjs +1 -1
- package/dist/data.mjs +1 -1
- package/dist/editors.cjs +1 -1
- package/dist/editors.mjs +3 -3
- package/dist/feedback.cjs +1 -1
- package/dist/feedback.mjs +2 -2
- package/dist/index-DlHlXz8e.js +57319 -0
- package/dist/index-Dx726U90.cjs +5192 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +45 -45
- package/dist/lazy.cjs +1 -1
- package/dist/lazy.mjs +3 -3
- package/dist/navigation.cjs +1 -1
- package/dist/navigation.mjs +17 -17
- package/dist/overlays.cjs +1 -1
- package/dist/overlays.mjs +71 -71
- package/package.json +4 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const e=require("react/jsx-runtime"),o=require("./core-CjmLbclt.cjs"),c=require("react"),Fe=require("react-dom"),Me=c.forwardRef(({label:l,helperText:m,error:s,required:p,disabled:i,readOnly:n,size:d="md",name:j,id:f,className:u,style:_,accessMode:S,displayStyle:Y,variant:x,value:k,defaultValue:E,onChange:h,onBlur:z,onKeyDown:D,placeholder:y,type:L="text",maxLength:b,prefix:F,suffix:B,clearable:w,autoFocus:M,submitOnEnter:T,onSubmit:K,showKeyboardHints:I,labelPlacement:V,errorPlacement:ae,loading:oe,labelWidth:ne,controlWidth:X,displayMode:W,...$},v)=>{const q=o.Ns(S,f);if(q==="hidden")return null;q==="disabled"&&(i=!0),q==="readOnly"&&(n=!0);const{t:R}=o.Wo(),H=o.cs(f),Q=o.Ui("input",Y),le=o.Gi("input",Y),me=x==="filled"?"filled":x==="underlined"?"underlined":"",O=c.useCallback(()=>h?.(""),[h]),Z=o.Qi({enabled:W,readOnly:n,disabled:i}),re=o.Xs({enabled:T,onSubmit:K}),ie=c.useCallback(g=>{re(g),D?.(g)},[re,D]),a=c.useMemo(()=>{const g=[];return T&&g.push({key:"Enter",description:R("shortcuts.submit","Submit")}),w&&g.push({key:"Escape",description:R("shortcuts.clear","Clear")}),g},[T,w,R]);return e.jsxs("div",{className:`nice-field nice-field--${d} ${V==="left"?"nice-field--label-left":""} ${V==="inside"?"nice-field--label-inside":""} ${oe?"nice-field--loading":""} ${u||""}`,style:{..._,...ne!=null&&{"--nice-field-label-width":typeof ne=="number"?`${ne}px`:ne},...X!=null&&{"--nice-field-control-width":typeof X=="number"?`${X}px`:X}},"aria-busy":oe||void 0,"data-floating":V==="inside"&&k?"true":void 0,children:[l&&V!=="inside"&&e.jsxs("label",{htmlFor:H,className:`nice-field__label ${p?"nice-field__label--required":""}`,children:[l,I&&a.length>0&&e.jsx(o.Hr,{shortcuts:a,size:"sm"})]}),e.jsxs("div",{className:"nice-field__control",children:[Z.isDisplay?e.jsx(o.Zi,{value:k??E??"",placeholder:y,disabled:i,readOnly:n,onActivate:Z.enterEdit,ariaLabel:l}):e.jsxs("div",{className:`nice-input nice-input--${d} nice-input--ds-${me||le} ${s?"nice-input--error":""} ${i?"nice-input--disabled":""} ${n?"nice-input--readonly":""}`,style:x?void 0:Q,children:[F&&e.jsx("span",{className:"nice-input__icon",children:F}),e.jsx("input",{ref:g=>{typeof v=="function"?v(g):v&&(v.current=g),Z.autoFocusRef(g)},id:H,className:"nice-input__native",type:L,name:j,value:k,defaultValue:E,placeholder:y,disabled:i||oe,readOnly:n,maxLength:b,autoFocus:M,"aria-invalid":!!s,"aria-describedby":s?`${H}-error`:m?`${H}-helper`:void 0,onChange:g=>h?.(g.target.value),onBlur:g=>{W&&Z.exitEdit(),z?.(g)},onKeyDown:ie,...$}),w&&k&&e.jsx("button",{type:"button",className:"nice-input__clear",onClick:O,"aria-label":R("controls.clear","Clear"),children:"✕"}),B&&e.jsx("span",{className:"nice-input__icon",children:B}),l&&V==="inside"&&e.jsx("label",{htmlFor:H,className:`nice-input__floating-label ${p?"nice-input__floating-label--required":""}`,children:l})]}),oe&&e.jsx("span",{className:"nice-field__spinner",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})}),ae==="right"&&s&&e.jsx("div",{id:`${H}-error`,className:"nice-field__error",role:"alert",children:s}),ae==="right"&&!s&&m&&e.jsx("div",{id:`${H}-helper`,className:"nice-field__helper",children:m})]}),ae!=="right"&&s&&e.jsx("div",{id:`${H}-error`,className:"nice-field__error",role:"alert",children:s}),ae!=="right"&&!s&&m&&e.jsx("div",{id:`${H}-helper`,className:"nice-field__helper",children:m})]})});Me.displayName="NiceTextInput";const Ce=c.forwardRef(({label:l,helperText:m,error:s,required:p,disabled:i,readOnly:n,size:d="md",name:j,id:f,className:u,style:_,accessMode:S,displayStyle:Y,value:x,onChange:k,onBlur:E,onKeyDown:h,placeholder:z,min:D,max:y,step:L=1,precision:b,prefix:F,prefixType:B="label",prefixOptions:w,prefixValue:M,onPrefixChange:T,suffix:K,showStepper:I=!0,submitOnEnter:V,onSubmit:ae,showKeyboardHints:oe,labelPlacement:ne,errorPlacement:X,loading:W,labelWidth:$,controlWidth:v,formatPreset:q,format:R,suffixType:H="label",suffixOptions:Q,suffixValue:le,onSuffixChange:me,displayMode:O},Z)=>{const re=o.Ns(S,f);if(re==="hidden")return null;re==="disabled"&&(i=!0),re==="readOnly"&&(n=!0);const{t:ie}=o.Wo(),a=o.cs(f),g=o.Ui("input",Y),G=o.Gi("input",Y),[C,J]=c.useState(!1),[P,_e]=c.useState(null),xe=o.Qi({enabled:O,readOnly:n,disabled:i}),de=c.useMemo(()=>{let t=3;return y!=null&&(t=String(Math.abs(Math.floor(y))).length),D!=null&&D<0&&(t+=1),b&&(t+=b+1),Math.max(3,t)+1},[y,D,b]),Ne=c.useCallback(t=>{if(R)return R(t);if(!q)return b!=null?t.toFixed(b):String(t);switch(q){case"integer":return Math.round(t).toLocaleString();case"decimal":return t.toLocaleString(void 0,{minimumFractionDigits:b??2,maximumFractionDigits:b??2});case"money":return t.toLocaleString(void 0,{minimumFractionDigits:b??2,maximumFractionDigits:b??2,useGrouping:!0});case"percent":return(t*100).toLocaleString(void 0,{minimumFractionDigits:b??0,maximumFractionDigits:b??2})+"%";default:return String(t)}},[R,q,b]),je=c.useMemo(()=>C&&P!==null?P:x==null?"":C?b!=null?x.toFixed(b):String(x):Ne(x),[x,C,P,Ne,b]),ue=x!=null&&x<0,se=!!(F||B==="select"&&w&&w.length>0),ee=ue&&se&&!C,ke=ee?je.replace(/^[-−]/,""):je,pe=c.useCallback(t=>{let N=t;return D!==void 0&&(N=Math.max(D,N)),y!==void 0&&(N=Math.min(y,N)),b!==void 0&&(N=parseFloat(N.toFixed(b))),N},[D,y,b]),we=c.useCallback(t=>{const N=t.target.value;if(_e(N),N===""||N==="-"||N==="."||N==="-."){N===""&&k?.(null);return}const ce=parseFloat(N);if(!isNaN(ce)){let he=ce;D!==void 0&&(he=Math.max(D,he)),y!==void 0&&(he=Math.min(y,he)),k?.(he)}},[k,D,y]),ve=c.useCallback(()=>{const t=ge.current,N=pe((t??0)+L);ge.current=N,k?.(N)},[L,k,pe]),ye=c.useCallback(()=>{const t=ge.current,N=pe((t??0)-L);ge.current=N,k?.(N)},[L,k,pe]),ge=c.useRef(x);ge.current=x;const r=c.useRef(null),U=c.useCallback(()=>{r.current&&(clearTimeout(r.current),r.current=null)},[]),A=c.useCallback(t=>{U();let N=300;const ce=()=>{t(),N=Math.max(30,N*.82),r.current=setTimeout(ce,N)};r.current=setTimeout(ce,400)},[U]),fe=o.Xs({enabled:V,onSubmit:ae}),$e=c.useCallback(t=>{fe(t),t.key==="ArrowUp"?(t.preventDefault(),ve()):t.key==="ArrowDown"&&(t.preventDefault(),ye()),h?.(t)},[fe,h,ve,ye]),te=c.useMemo(()=>{const t=[];return V&&t.push(o.Ws.submit),I&&(t.push({key:"ArrowUp",description:ie("shortcuts.increment","Increase value")}),t.push({key:"ArrowDown",description:ie("shortcuts.decrement","Decrease value")})),t},[V,I,ie]);return e.jsxs("div",{className:`nice-field nice-field--${d} ${ne==="left"?"nice-field--label-left":""} ${W?"nice-field--loading":""} ${u||""}`,style:{..._,...$!=null&&{"--nice-field-label-width":typeof $=="number"?`${$}px`:$},...v!=null&&{"--nice-field-control-width":typeof v=="number"?`${v}px`:v}},"aria-busy":W||void 0,children:[l&&e.jsxs("label",{htmlFor:a,className:`nice-field__label ${p?"nice-field__label--required":""}`,children:[l,oe&&te.length>0&&e.jsx(o.Hr,{shortcuts:te,size:"sm"})]}),e.jsxs("div",{className:"nice-field__control",children:[xe.isDisplay?e.jsx(o.Zi,{value:x==null?"":F?e.jsxs(e.Fragment,{children:[F,je]}):je,placeholder:z,disabled:i,readOnly:n,onActivate:xe.enterEdit,ariaLabel:l}):e.jsx(e.Fragment,{children:e.jsxs("div",{className:`nice-input nice-input--number nice-input--${d} nice-input--ds-${G} ${s?"nice-input--error":""} ${i?"nice-input--disabled":""} ${n?"nice-input--readonly":""}`,style:g,children:[I&&!n&&e.jsx("button",{type:"button",className:"nice-input__clear nice-input__minus",onClick:ye,onMouseDown:()=>A(ye),onMouseUp:U,onMouseLeave:U,disabled:i,"aria-label":ie("controls.decrement","Decrement"),children:"−"}),B==="select"&&w&&w.length>0?e.jsxs(e.Fragment,{children:[ee&&e.jsx("span",{className:"nice-input__sign",children:"−"}),e.jsx("select",{className:"nice-input__suffix-select nice-input__icon--prefix",value:M??w[0]?.value,disabled:i,onChange:t=>{const N=t.target.value,ce=w.find(be=>be.value===(M??w[0]?.value)),he=w.find(be=>be.value===N);T?.(N,ce?.weight,he?.weight)},children:w.map(t=>e.jsx("option",{value:t.value,children:t.label},t.value))})]}):F?e.jsxs("span",{className:"nice-input__icon nice-input__icon--prefix",children:[ee&&e.jsx("span",{className:"nice-input__sign",children:"−"}),F]}):null,e.jsx("input",{ref:t=>{typeof Z=="function"?Z(t):Z&&(Z.current=t),xe.autoFocusRef(t)},id:a,className:"nice-input__native",type:!C&&(R||q)?"text":"number",name:j,value:ke,placeholder:z,min:D,max:y,step:L,disabled:i||W,readOnly:n,"aria-invalid":!!s,onChange:we,onFocus:t=>{J(!0),_e(null),t.target.select()},onBlur:t=>{if(J(!1),_e(null),x!=null&&b!==void 0){const N=parseFloat(x.toFixed(b));N!==x&&k?.(N)}O&&xe.exitEdit(),E?.(t)},onKeyDown:$e,style:{width:`${de}ch`}}),H==="select"&&Q&&Q.length>0?e.jsx("select",{className:"nice-input__suffix-select nice-input__icon--suffix",value:le??Q[0]?.value,disabled:i,onChange:t=>{const N=t.target.value,ce=Q.find(be=>be.value===(le??Q[0]?.value)),he=Q.find(be=>be.value===N);me?.(N,ce?.weight,he?.weight)},children:Q.map(t=>e.jsx("option",{value:t.value,children:t.label},t.value))}):K?e.jsx("span",{className:"nice-input__icon nice-input__icon--suffix",children:K}):null,I&&!n&&e.jsx("button",{type:"button",className:"nice-input__clear nice-input__plus",onClick:ve,onMouseDown:()=>A(ve),onMouseUp:U,onMouseLeave:U,disabled:i,"aria-label":ie("controls.increment","Increment"),children:"+"})]})}),W&&e.jsx("span",{className:"nice-field__spinner",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})}),X==="right"&&s&&e.jsx("div",{className:"nice-field__error",role:"alert",children:s}),X==="right"&&!s&&m&&e.jsx("div",{className:"nice-field__helper",children:m})]}),X!=="right"&&s&&e.jsx("div",{className:"nice-field__error",role:"alert",children:s}),X!=="right"&&!s&&m&&e.jsx("div",{className:"nice-field__helper",children:m})]})});Ce.displayName="NiceNumberInput";const Se=c.forwardRef(({label:l,helperText:m,error:s,required:p,disabled:i,size:n="md",name:d,id:j,className:f,style:u,accessMode:_,displayStyle:S,options:Y,value:x,onChange:k,placeholder:E,multiple:h=!1,searchable:z=!1,clearable:D=!1,emptyText:y,maxHeight:L=240,optionsSource:b,valueField:F,labelField:B,virtualScroll:w,optionHeight:M=36,onSearch:T,loading:K,renderOption:I,multipleAutosize:V=!1,showKeyboardHints:ae,labelPlacement:oe,errorPlacement:ne,labelWidth:X,controlWidth:W,displayMode:$},v)=>{const q=o.Ns(_,j);if(q==="hidden")return null;(q==="disabled"||q==="readOnly")&&(i=!0);const{t:R}=o.Wo(),H=o.Ui("input",S),Q=o.Gi("input",S),le=o.cs(j),me=o.Qi({enabled:$,disabled:i}),[O,Z]=c.useState(!1),[re,ie]=c.useState(""),[a,g]=c.useState(-1),[G,C]=c.useState(0),J=c.useRef(null),P=c.useRef(null),[_e,xe]=c.useState(null);c.useLayoutEffect(()=>{!K&&P.current&&xe(P.current.offsetWidth)},[K,x,S]);const[de,Ne]=c.useState(null);c.useLayoutEffect(()=>{h&&!V&&P.current&&de==null&&Ne(P.current.offsetWidth)},[h,V,de]);const je=o.Fl(b??null,F??b?.keyField??"id",B??"name"),ue=b?je.options:(Y??[]).map(r=>typeof r=="string"?{value:r,label:r}:r);o.ds(J,()=>{Z(!1),ie("")});const se=c.useMemo(()=>x?Array.isArray(x)?x:[x]:[],[x]),ee=c.useMemo(()=>{if(!re&&!T||T)return ue;const r=re.toLowerCase();return ue.filter(U=>U.label.toLowerCase().includes(r)||String(U.value).toLowerCase().includes(r))},[ue,re,T]),ke=c.useMemo(()=>{const r=new Map;for(const U of ee){const A=U.group||"";r.has(A)||r.set(A,[]),r.get(A).push(U)}return r},[ee]),pe=c.useCallback(r=>{if(h){const U=se.includes(r)?se.filter(A=>A!==r):[...se,r];k?.(U)}else k?.(r),Z(!1),ie("")},[h,se,k]),we=c.useCallback(r=>{if(r.key==="Escape"){Z(!1),ie("");return}if(r.key==="Enter"||r.key===" "){if(!O){Z(!0),r.preventDefault();return}a>=0&&ee[a]&&(pe(ee[a].value),r.preventDefault());return}r.key==="ArrowDown"&&(r.preventDefault(),g(U=>Math.min(U+1,ee.length-1))),r.key==="ArrowUp"&&(r.preventDefault(),g(U=>Math.max(U-1,0)))},[O,a,ee,pe]),ve=c.useMemo(()=>se.length===0?null:h?se.map(r=>ue.find(U=>U.value===r)?.label||r).join(", "):ue.find(r=>r.value===se[0])?.label||se[0],[se,ue,h]),ye=c.useCallback(r=>{r.stopPropagation(),k?.(h?[]:"")},[k,h]),ge=c.useMemo(()=>[{key:"Enter",description:R("shortcuts.select","Select")},{key:"Space",description:R("shortcuts.openDropdown","Open dropdown")},o.Ws.moveUp,o.Ws.moveDown,o.Ws.cancel],[R]);return e.jsxs("div",{className:`nice-field ${W==null?"nice-field--select-auto":""} nice-field--${n} ${oe==="left"?"nice-field--label-left":""} ${K?"nice-field--loading":""} ${f||""}`,style:{...u,...X!=null&&{"--nice-field-label-width":typeof X=="number"?`${X}px`:X},...W!=null&&{"--nice-field-control-width":typeof W=="number"?`${W}px`:W},...K&&_e!=null&&{"--nice-select-locked-width":`${_e}px`}},"aria-busy":K||void 0,children:[l&&e.jsxs("label",{htmlFor:le,className:`nice-field__label ${p?"nice-field__label--required":""}`,children:[l,ae&&e.jsx(o.Hr,{shortcuts:ge,size:"sm"})]}),e.jsxs("div",{className:"nice-field__control",children:[me.isDisplay?e.jsx(o.Zi,{value:ve,placeholder:E||R("controls.select","Select..."),disabled:i,onActivate:()=>{me.enterEdit(),Z(!0)},ariaLabel:l}):e.jsxs("div",{className:"nice-select",ref:J,children:[e.jsxs("button",{ref:r=>{P.current=r,typeof v=="function"?v(r):v&&(v.current=r)},type:"button",id:le,role:"combobox","aria-expanded":O,"aria-haspopup":"listbox","aria-invalid":!!s,className:`nice-select__trigger nice-select__trigger--${n} nice-select--ds-${Q} ${O?"nice-select__trigger--open":""} ${s?"nice-select__trigger--error":""} ${i?"nice-select__trigger--disabled":""}`,style:{...H,...h&&!V&&de!=null?{width:de,maxWidth:de,overflow:"hidden"}:{}},disabled:i,onClick:()=>Z(!O),onKeyDown:we,children:[ve?e.jsx("span",{style:h&&!V?{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}:void 0,children:ve}):e.jsx("span",{className:"nice-select__placeholder",children:E||R("controls.select","Select...")}),e.jsxs("span",{style:{display:"flex",alignItems:"center",gap:4},children:[D&&se.length>0&&e.jsx("span",{className:"nice-input__clear",onClick:ye,role:"button","aria-label":R("controls.clear","Clear"),children:"✕"}),e.jsx("svg",{className:`nice-select__chevron ${O?"nice-select__chevron--open":""}`,viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z",clipRule:"evenodd"})})]})]}),O&&e.jsxs("div",{className:"nice-select__dropdown",role:"listbox",style:{maxHeight:L},onScroll:w?r=>C(r.currentTarget.scrollTop):void 0,children:[(z||T)&&e.jsx("div",{className:"nice-select__search",children:e.jsx("input",{type:"text",value:re,onChange:r=>{ie(r.target.value),g(0),T?.(r.target.value)},placeholder:R("controls.search","Search..."),autoFocus:!0})}),K&&e.jsx("div",{className:"nice-select__loading",children:e.jsx("div",{className:"nice-spinner nice-spinner--sm",style:{margin:"8px auto"}})}),!K&&ee.length===0?e.jsx("div",{className:"nice-select__empty",children:y||R("controls.noResults","No results found")}):w&&!Array.from(ke.keys()).some(r=>r!=="")?(()=>{const U=ee.length*M,A=Math.max(0,Math.floor(G/M)-3),fe=Math.min(ee.length,Math.ceil((G+L)/M)+3),$e=ee.slice(A,fe);return e.jsx("div",{style:{height:U,position:"relative"},children:$e.map((te,t)=>{const N=A+t,ce=se.includes(te.value);return e.jsx("div",{role:"option","aria-selected":ce,className:`nice-select__option ${ce?"nice-select__option--selected":""} ${N===a?"nice-select__option--highlighted":""} ${te.disabled?"nice-select__option--disabled":""}`,style:{position:"absolute",top:N*M,left:0,right:0,height:M,display:"flex",alignItems:"center",padding:"0 12px"},onClick:()=>!te.disabled&&pe(String(te.value)),onMouseEnter:()=>g(N),children:I?I(te,ce):e.jsxs(e.Fragment,{children:[te.icon&&e.jsx("span",{children:te.icon}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{children:te.label}),te.description&&e.jsx("div",{className:"nice-select__option-desc",children:te.description})]}),ce&&e.jsx("svg",{className:"nice-select__option-check",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M16.704 4.153a.75.75 0 01.143 1.052l-8 10.5a.75.75 0 01-1.127.075l-4.5-4.5a.75.75 0 011.06-1.06l3.894 3.893 7.48-9.817a.75.75 0 011.05-.143z",clipRule:"evenodd"})})]})},te.value)})})})():Array.from(ke.entries()).map(([r,U])=>e.jsxs(c.Fragment,{children:[r&&e.jsx("div",{className:"nice-select__group-label",children:r}),U.map(A=>{const fe=se.includes(A.value),$e=ee.indexOf(A);return e.jsx("div",{role:"option","aria-selected":fe,className:`nice-select__option ${fe?"nice-select__option--selected":""} ${$e===a?"nice-select__option--highlighted":""} ${A.disabled?"nice-select__option--disabled":""}`,onClick:()=>!A.disabled&&pe(String(A.value)),onMouseEnter:()=>g($e),children:I?I(A,fe):e.jsxs(e.Fragment,{children:[A.icon&&e.jsx("span",{children:A.icon}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{children:A.label}),A.description&&e.jsx("div",{className:"nice-select__option-desc",children:A.description})]}),fe&&e.jsx("svg",{className:"nice-select__option-check",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M16.704 4.153a.75.75 0 01.143 1.052l-8 10.5a.75.75 0 01-1.127.075l-4.5-4.5a.75.75 0 011.06-1.06l3.894 3.893 7.48-9.817a.75.75 0 011.05-.143z",clipRule:"evenodd"})})]})},A.value)})]},r))]})]}),K&&e.jsx("span",{className:"nice-field__spinner",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})}),ne==="right"&&s&&e.jsx("div",{id:`${le}-error`,className:"nice-field__error",role:"alert",children:s}),ne==="right"&&!s&&m&&e.jsx("div",{id:`${le}-helper`,className:"nice-field__helper",children:m})]}),ne!=="right"&&s&&e.jsx("div",{id:`${le}-error`,className:"nice-field__error",role:"alert",children:s}),ne!=="right"&&!s&&m&&e.jsx("div",{id:`${le}-helper`,className:"nice-field__helper",children:m})]})});Se.displayName="NiceSelect";const Re=c.forwardRef(({label:l,checked:m=!1,indeterminate:s=!1,onChange:p,disabled:i,readOnly:n,loading:d,required:j,size:f="md",name:u,id:_,className:S,style:Y,error:x,helperText:k,accessMode:E,displayStyle:h,showKeyboardHints:z,labelPlacement:D,errorPlacement:y,labelWidth:L,controlWidth:b},F)=>{const B=o.Ns(E,_);if(B==="hidden")return null;(B==="disabled"||B==="readOnly")&&(i=!0);const{t:w}=o.Wo(),M=o.cs(_);o.Gi("toggle",h);const T=c.useMemo(()=>[{key:"Space",description:w("shortcuts.toggle","Toggle")}],[w]),K=c.useCallback(I=>{I&&(I.indeterminate=s),typeof F=="function"?F(I):F&&(F.current=I)},[s,F]);return e.jsxs("div",{className:`nice-field nice-field--inline nice-field--${f} ${D==="left"?"nice-field--label-left":""} ${y==="right"?"nice-field--error-right":""} ${d?"nice-field--loading":""} ${S||""}`,style:{...Y,...L!=null&&{"--nice-field-label-width":typeof L=="number"?`${L}px`:L},...b!=null&&{"--nice-field-control-width":typeof b=="number"?`${b}px`:b}},"aria-busy":d||void 0,children:[D==="left"&&l&&e.jsx("span",{className:`nice-field__label ${j?"nice-field__label--required":""}`,children:l}),e.jsxs("div",{className:"nice-field__control",children:[e.jsxs("label",{className:`nice-checkbox ${f!=="md"?`nice-checkbox--${f}`:""} ${i||d?"nice-checkbox--disabled":""}`,htmlFor:M,children:[e.jsx("input",{ref:K,id:M,type:"checkbox",className:"nice-checkbox__input",name:u,checked:m,disabled:i||d,readOnly:n,"aria-invalid":!!x,onChange:I=>{n||d||p?.(I.target.checked)}}),e.jsx("span",{className:"nice-checkbox__box",children:e.jsx("svg",{viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:s?e.jsx("line",{x1:"2",y1:"6",x2:"10",y2:"6"}):e.jsx("polyline",{points:"2 6 5 9 10 3"})})}),D!=="left"&&l&&e.jsx("span",{children:l}),z&&e.jsx(o.Hr,{shortcuts:T,size:"sm"})]}),d&&e.jsx("span",{className:"nice-field__spinner",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})}),y==="right"&&x&&e.jsx("div",{id:`${M}-error`,className:"nice-field__error",role:"alert",children:x}),y==="right"&&!x&&k&&e.jsx("div",{id:`${M}-helper`,className:"nice-field__helper",children:k})]}),y!=="right"&&x&&e.jsx("div",{id:`${M}-error`,className:"nice-field__error",role:"alert",children:x}),y!=="right"&&!x&&k&&e.jsx("div",{id:`${M}-helper`,className:"nice-field__helper",children:k})]})});Re.displayName="NiceCheckbox";const De=c.forwardRef(({label:l,checked:m=!1,onChange:s,disabled:p,readOnly:i,loading:n,required:d,size:j="md",name:f,id:u,className:_,style:S,accessMode:Y,displayStyle:x,showKeyboardHints:k,error:E,helperText:h,labelPlacement:z,errorPlacement:D,labelWidth:y,controlWidth:L},b)=>{const F=o.Ns(Y,u);if(F==="hidden")return null;(F==="disabled"||F==="readOnly")&&(p=!0);const{t:B}=o.Wo(),w=o.cs(u);o.Ui("toggle",x);const M=o.Gi("toggle",x),T=c.useMemo(()=>[{key:"Space",description:B("shortcuts.toggle","Toggle on/off")}],[B]);return e.jsxs("div",{className:`nice-field nice-field--inline nice-field--${j} ${z==="left"?"nice-field--label-left":""} ${n?"nice-field--loading":""} ${_||""}`,style:{...S,...y!=null&&{"--nice-field-label-width":typeof y=="number"?`${y}px`:y},...L!=null&&{"--nice-field-control-width":typeof L=="number"?`${L}px`:L}},"aria-busy":n||void 0,children:[z==="left"&&l&&e.jsx("span",{className:`nice-field__label ${d?"nice-field__label--required":""}`,children:l}),e.jsxs("div",{className:"nice-field__control",children:[e.jsxs("label",{className:`nice-toggle nice-toggle--ds-${M} ${j!=="md"?`nice-toggle--${j}`:""} ${p||n?"nice-toggle--disabled":""}`,htmlFor:w,children:[e.jsx("input",{ref:b,id:w,type:"checkbox",className:"nice-toggle__input",name:f,checked:m,disabled:p||n,readOnly:i,role:"switch","aria-checked":m,"aria-invalid":!!E,onChange:K=>{i||n||s?.(K.target.checked)}}),e.jsx("span",{className:"nice-toggle__track",children:e.jsx("span",{className:"nice-toggle__thumb"})}),z!=="left"&&l&&e.jsx("span",{children:l}),k&&e.jsx(o.Hr,{shortcuts:T,size:"sm"})]}),n&&e.jsx("span",{className:"nice-field__spinner",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})}),D==="right"&&E&&e.jsx("div",{id:`${w}-error`,className:"nice-field__error",role:"alert",children:E}),D==="right"&&!E&&h&&e.jsx("div",{id:`${w}-helper`,className:"nice-field__helper",children:h})]}),D!=="right"&&E&&e.jsx("div",{id:`${w}-error`,className:"nice-field__error",role:"alert",children:E}),D!=="right"&&!E&&h&&e.jsx("div",{id:`${w}-helper`,className:"nice-field__helper",children:h})]})});De.displayName="NiceToggle";const Ie=["#ef4444","#f97316","#f59e0b","#84cc16","#10b981","#06b6d4","#3b82f6","#6366f1","#8b5cf6","#ec4899","#64748b","#1e293b"];function He(){return"#"+Math.floor(Math.random()*16777215).toString(16).padStart(6,"0")}function Ue(l,m,s){const p=l/255,i=m/255,n=s/255,d=Math.max(p,i,n),j=Math.min(p,i,n),f=(d+j)/2;let u=0,_=0;if(d!==j){const S=d-j;switch(_=f>.5?S/(2-d-j):S/(d+j),d){case p:u=(i-n)/S+(i<n?6:0);break;case i:u=(n-p)/S+2;break;case n:u=(p-i)/S+4;break}u*=60}return{h:Math.round(u),s:Math.round(_*100),l:Math.round(f*100)}}function Ae(l,m,s){const p=m/100,i=s/100,n=(1-Math.abs(2*i-1))*p,d=n*(1-Math.abs(l/60%2-1)),j=i-n/2;let f=0,u=0,_=0;return l<60?[f,u,_]=[n,d,0]:l<120?[f,u,_]=[d,n,0]:l<180?[f,u,_]=[0,n,d]:l<240?[f,u,_]=[0,d,n]:l<300?[f,u,_]=[d,0,n]:[f,u,_]=[n,0,d],{r:Math.round((f+j)*255),g:Math.round((u+j)*255),b:Math.round((_+j)*255)}}function Be(l,m,s){const p=l/255,i=m/255,n=s/255,d=Math.max(p,i,n),j=Math.min(p,i,n),f=d-j;let u=0;f!==0&&(d===p?u=(i-n)/f%6:d===i?u=(n-p)/f+2:u=(p-i)/f+4,u*=60,u<0&&(u+=360));const _=d===0?0:f/d;return{h:Math.round(u),s:Math.round(_*100),v:Math.round(d*100)}}function Te(l,m,s){const p=m/100,i=s/100,n=i*p,d=n*(1-Math.abs(l/60%2-1)),j=i-n;let f=0,u=0,_=0;return l<60?[f,u,_]=[n,d,0]:l<120?[f,u,_]=[d,n,0]:l<180?[f,u,_]=[0,n,d]:l<240?[f,u,_]=[0,d,n]:l<300?[f,u,_]=[d,0,n]:[f,u,_]=[n,0,d],{r:Math.round((f+j)*255),g:Math.round((u+j)*255),b:Math.round((_+j)*255)}}function qe(l){const m=/^#?([0-9a-f]{6})$/i.exec(l.trim()),s=/^#?([0-9a-f]{8})$/i.exec(l.trim());if(s){const p=s[1];return{r:parseInt(p.slice(0,2),16),g:parseInt(p.slice(2,4),16),b:parseInt(p.slice(4,6),16),a:parseInt(p.slice(6,8),16)/255}}if(m){const p=parseInt(m[1],16);return{r:p>>16&255,g:p>>8&255,b:p&255,a:1}}return{r:0,g:0,b:0,a:1}}function Ge(l,m,s,p,i){const n=j=>Math.max(0,Math.min(255,Math.round(j))).toString(16).padStart(2,"0"),d=`#${n(l)}${n(m)}${n(s)}`;return i?`${d}${n(p*255)}`:d}const Le=c.forwardRef(({label:l,helperText:m,error:s,required:p,disabled:i,id:n,className:d,style:j,accessMode:f,displayStyle:u,value:_="#3b82f6",onChange:S,presets:Y=Ie,showInput:x=!0,showRandom:k=!0,withAlpha:E=!1,showKeyboardHints:h,size:z="md",labelPlacement:D,errorPlacement:y,labelWidth:L,controlWidth:b,loading:F},B)=>{const w=o.Ns(f,n);if(w==="hidden")return null;(w==="disabled"||w==="readOnly")&&(i=!0);const{t:M}=o.Wo(),T=o.cs(n);o.Gi("input",u);const K=c.useCallback(()=>{i||S?.(He())},[i,S]),[I,V]=c.useState(!1),[ae,oe]=c.useState(null),ne=c.useRef(null),X=c.useRef(null);c.useLayoutEffect(()=>{if(!I||!X.current)return;const $=()=>{const v=X.current?.getBoundingClientRect();if(!v)return;const q=280,R=360;let H=v.left,Q=v.bottom+6;H+q>window.innerWidth-8&&(H=Math.max(8,window.innerWidth-q-8)),Q+R>window.innerHeight-8&&(Q=Math.max(8,v.top-R-6)),oe({left:H,top:Q})};return $(),window.addEventListener("scroll",$,!0),window.addEventListener("resize",$),()=>{window.removeEventListener("scroll",$,!0),window.removeEventListener("resize",$)}},[I]),c.useEffect(()=>{if(!I)return;const $=q=>{const R=q.target;ne.current?.contains(R)||X.current?.contains(R)||V(!1)},v=q=>{q.key==="Escape"&&V(!1)};return document.addEventListener("mousedown",$),document.addEventListener("keydown",v),()=>{document.removeEventListener("mousedown",$),document.removeEventListener("keydown",v)}},[I]);const W=c.useMemo(()=>[{key:"Enter",description:M("shortcuts.openPicker","Open color picker")},{key:"Arrow keys",description:M("shortcuts.navigatePresets","Navigate presets")}],[M]);return e.jsxs("div",{className:`nice-field nice-field--${z} ${D==="left"?"nice-field--label-left":""} ${F?"nice-field--loading":""} ${d||""}`,style:{...j,...L!=null&&{"--nice-field-label-width":typeof L=="number"?`${L}px`:L},...b!=null&&{"--nice-field-control-width":typeof b=="number"?`${b}px`:b}},"aria-busy":F||void 0,children:[l&&e.jsxs("label",{htmlFor:T,className:`nice-field__label ${p?"nice-field__label--required":""}`,children:[l,h&&e.jsx(o.Hr,{shortcuts:W,size:"sm"})]}),e.jsx("div",{className:"nice-field__control",children:e.jsxs("div",{className:"nice-color-picker",children:[e.jsxs("div",{className:"nice-color-picker__preview-row",children:[e.jsx("div",{ref:X,className:"nice-color-picker__swatch",id:T,style:{background:_},onClick:$=>{$.stopPropagation(),i||V(v=>!v)},onKeyDown:$=>{!i&&($.key==="Enter"||$.key===" ")&&($.preventDefault(),V(v=>!v))},role:"button",tabIndex:0,"aria-label":M("colorPicker.openPalette","Open color palette"),"aria-haspopup":"dialog","aria-expanded":I,children:e.jsx("input",{ref:$=>{typeof B=="function"?B($):B&&(B.current=$)},type:"hidden",value:_,disabled:i,readOnly:!0})}),x&&e.jsx("div",{className:"nice-input nice-input--sm",style:{width:100},children:e.jsx("input",{className:"nice-input__native",type:"text",value:_,disabled:i,onChange:$=>S?.($.target.value),maxLength:7})}),k&&e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm nice-color-picker__random",onClick:K,disabled:i,title:M("colorPicker.random","Random"),"aria-label":M("colorPicker.random","Random"),style:{fontSize:"0.65rem",textTransform:"uppercase",letterSpacing:"0.05em"},children:M("colorPicker.random","Random")}),F&&e.jsx("span",{className:"nice-field__spinner",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})}),y==="right"&&s&&e.jsx("div",{id:`${T}-error`,className:"nice-field__error",role:"alert",children:s}),y==="right"&&!s&&m&&e.jsx("div",{id:`${T}-helper`,className:"nice-field__helper",children:m})]}),I&&ae&&typeof document<"u"&&Fe.createPortal(e.jsx("div",{ref:ne,className:"nice-color-picker__popup nice-color-picker__popup--portal",role:"dialog","aria-label":M("colorPicker.palette","Color palette"),style:{position:"fixed",left:ae.left,top:ae.top},onClick:$=>$.stopPropagation(),children:(()=>{const $=qe(_),v={r:$.r,g:$.g,b:$.b},q=E?$.a:1,R=Ue(v.r,v.g,v.b),H=Be(v.r,v.g,v.b),Q=(a,g,G,C=q)=>S?.(Ge(a,g,G,C,E)),le=(a,g,G)=>Q(a,g,G),me=(a,g,G)=>{const C=Ae(a,g,G);Q(C.r,C.g,C.b)},O=(a,g,G)=>{const C=Te(a,g,G);Q(C.r,C.g,C.b)},Z=a=>Q(v.r,v.g,v.b,a),re=a=>{if(i)return;const g=a.currentTarget,G=J=>{const P=g.getBoundingClientRect(),_e=Math.max(0,Math.min(P.width,J.clientX-P.left)),xe=Math.max(0,Math.min(P.height,J.clientY-P.top)),de=Math.round(_e/P.width*100),Ne=100-Math.round(xe/P.height*100);O(H.h,de,Ne)};G(a);const C=()=>{document.removeEventListener("pointermove",G),document.removeEventListener("pointerup",C)};document.addEventListener("pointermove",G),document.addEventListener("pointerup",C)},ie=`hsl(${H.h}, 100%, 50%)`;return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"nice-color-picker__popup-header",children:e.jsx("input",{type:"text",className:"nice-input__native nice-color-picker__popup-hex",value:_,disabled:i,onChange:a=>S?.(a.target.value),maxLength:E?9:7,"aria-label":M("colorPicker.hexValue","Hex value")})}),e.jsx("input",{type:"range",min:0,max:360,value:H.h,disabled:i,onChange:a=>O(Number(a.target.value),H.s,H.v),className:"nice-color-picker__hue-slider","aria-label":M("colorPicker.hue","Hue")}),e.jsx("div",{className:"nice-color-picker__sv",style:{background:`linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, ${ie})`},onPointerDown:re,role:"application","aria-label":M("colorPicker.svPalette","Saturation/value palette"),children:e.jsx("span",{className:"nice-color-picker__sv-marker",style:{left:`${H.s}%`,top:`${100-H.v}%`}})}),e.jsxs("div",{className:"nice-color-picker__sliders",children:[e.jsx("div",{className:"nice-color-picker__slider-col",children:["h","s","l"].map(a=>{const g=a==="h"?360:100,G=R[a],C=J=>me(a==="h"?J:R.h,a==="s"?J:R.s,a==="l"?J:R.l);return e.jsxs("div",{className:"nice-color-picker__slider-row",children:[e.jsx("label",{className:"nice-color-picker__slider-label",children:a.toUpperCase()}),e.jsx("input",{type:"range",min:0,max:g,value:G,disabled:i,onChange:J=>C(Number(J.target.value))}),e.jsx("input",{type:"number",min:0,max:g,value:G,disabled:i,onChange:J=>C(Number(J.target.value)||0),className:"nice-input__native nice-color-picker__slider-num"})]},a)})}),e.jsx("div",{className:"nice-color-picker__slider-col",children:["r","g","b"].map(a=>{const g=v[a],G=C=>le(a==="r"?C:v.r,a==="g"?C:v.g,a==="b"?C:v.b);return e.jsxs("div",{className:"nice-color-picker__slider-row",children:[e.jsx("label",{className:"nice-color-picker__slider-label",children:a.toUpperCase()}),e.jsx("input",{type:"range",min:0,max:255,value:g,disabled:i,onChange:C=>G(Number(C.target.value))}),e.jsx("input",{type:"number",min:0,max:255,value:g,disabled:i,onChange:C=>G(Number(C.target.value)||0),className:"nice-input__native nice-color-picker__slider-num"})]},a)})})]}),E&&e.jsxs("div",{className:"nice-color-picker__alpha-row",children:[e.jsx("label",{className:"nice-color-picker__slider-label",children:"A"}),e.jsx("input",{type:"range",min:0,max:100,value:Math.round(q*100),disabled:i,onChange:a=>Z(Number(a.target.value)/100),className:"nice-color-picker__alpha-slider",style:{background:`linear-gradient(to right, transparent, rgb(${v.r},${v.g},${v.b}))`},"aria-label":M("colorPicker.alpha","Alpha")}),e.jsx("input",{type:"number",min:0,max:100,value:Math.round(q*100),disabled:i,onChange:a=>Z((Number(a.target.value)||0)/100),className:"nice-input__native nice-color-picker__slider-num"})]}),Y.length>0&&e.jsx("div",{className:"nice-color-picker__popup-presets",children:Y.map(a=>e.jsx("div",{className:`nice-color-picker__preset ${_===a?"nice-color-picker__preset--active":""}`,style:{background:a},onClick:()=>{S?.(a),V(!1)},role:"button",tabIndex:0,"aria-label":a,onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),S?.(a),V(!1))}},a))})]})})()}),document.body)]})}),y!=="right"&&s&&e.jsx("div",{id:`${T}-error`,className:"nice-field__error",role:"alert",children:s}),y!=="right"&&!s&&m&&e.jsx("div",{id:`${T}-helper`,className:"nice-field__helper",children:m})]})});Le.displayName="NiceColorPicker";const Ee=c.forwardRef(({children:l,variant:m="primary",size:s="md",type:p="button",disabled:i,loading:n,fullWidth:d,onClick:j,leftIcon:f,rightIcon:u,error:_,errorPlacement:S="bottom",className:Y,style:x,id:k,accessMode:E,displayStyle:h,...z},D)=>{const y=o.Ns(E,k);if(y==="hidden")return null;(y==="disabled"||y==="readOnly")&&(i=!0);const L=o.Ui("button",h),b=o.Gi("button",h),F=m!=="primary"?(({background:M,color:T,...K})=>K)(L):L,B=e.jsxs("button",{ref:D,type:p,id:k,className:`nice-btn nice-btn--${m} nice-btn--${s} nice-btn--ds-${b} ${d?"nice-btn--full-width":""} ${n?"nice-btn--loading":""} ${_&&!S?"nice-btn--has-error":""} ${Y||""}`,style:{...F,...x},disabled:i||n,"aria-busy":n||void 0,"aria-disabled":i||n||void 0,onClick:j,...z,children:[n&&e.jsx("svg",{className:"nice-btn__spinner",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3","aria-hidden":"true",children:e.jsx("circle",{cx:"12",cy:"12",r:"10",strokeDasharray:"31.4 31.4",strokeLinecap:"round"})}),!n&&f&&e.jsx("span",{"aria-hidden":"true",children:f}),!n&&e.jsx("span",{children:l}),n&&e.jsx("span",{style:{visibility:"hidden"},"aria-hidden":"true",children:l}),!n&&u&&e.jsx("span",{"aria-hidden":"true",children:u})]});if(!_)return B;const w=e.jsx("div",{className:"nice-field__error",role:"alert",children:_});return S==="right"?e.jsxs("span",{className:`nice-btn-field nice-btn-field--right nice-field--${s}`,style:{display:"inline-flex",flexDirection:"row",alignItems:"center",gap:"8px",width:"fit-content"},children:[B,w]}):e.jsxs("span",{className:`nice-btn-field nice-btn-field--bottom nice-field--${s}`,style:{display:"inline-flex",flexDirection:"column",alignItems:"flex-start",gap:"4px",width:"fit-content"},children:[B,w]})});Ee.displayName="NiceButton";const Ke=({tabs:l,activeTab:m,onChange:s,variant:p="default",vertical:i,size:n="md",className:d,style:j,displayStyle:f})=>{const u=o.Ui("tab",f),_=o.Gi("tab",f),[S,Y]=c.useState(m||l[0]?.id),x=m??S,k=c.useCallback(h=>{Y(h),s?.(h)},[s]),E=l.find(h=>h.id===x)?.content;return e.jsxs("div",{className:`nice-tabs nice-tabs--${n} nice-tabs--ds-${_} ${d||""}`,style:{...u,...j,...i?{display:"flex",gap:16}:{}},children:[e.jsx("div",{className:`nice-tabs__list ${p!=="default"?`nice-tabs__list--${p}`:""} ${i?"nice-tabs__list--vertical":""}`,role:"tablist",children:l.map(h=>e.jsxs("button",{type:"button",role:"tab","aria-selected":x===h.id,className:`nice-tabs__tab ${x===h.id?"nice-tabs__tab--active":""} ${h.disabled?"nice-tabs__tab--disabled":""}`,disabled:h.disabled,onClick:()=>k(h.id),children:[h.icon,e.jsx("span",{children:h.label}),h.badge!==void 0&&e.jsx("span",{className:"nice-tabs__badge",children:h.badge})]},h.id))}),E&&e.jsx("div",{className:"nice-tabs__panel",role:"tabpanel",children:E})]})};exports.NiceButton=Ee;exports.NiceCheckbox=Re;exports.NiceColorPicker=Le;exports.NiceNumberInput=Ce;exports.NiceSelect=Se;exports.NiceTabs=Ke;exports.NiceTextInput=Me;exports.NiceToggle=De;
|