@nice2dev/ui 1.4.4 → 1.4.6
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 +59 -0
- package/dist/{NiceDataGrid-mrnaLHQk.cjs → NiceDataGrid-D3qRQSjy.cjs} +1 -1
- package/dist/NiceForm-BWb4LTQJ.cjs +1 -0
- package/dist/{NiceHtmlEditor-C1OVtLQ6.cjs → NiceHtmlEditor-BzECmDO3.cjs} +1 -1
- package/dist/{NiceMention-tgJKS8PH.cjs → NiceMention-CYRqPKGU.cjs} +19 -19
- package/dist/NiceModuleLifecyclePanel-CiYbPcHV.cjs +1 -0
- package/dist/{NicePagination-D7XxeNFz.cjs → NicePagination-BAxwqeEd.cjs} +1 -1
- package/dist/{NicePivotGrid-Cnkr9WkC.cjs → NicePivotGrid-Cxu5PECg.cjs} +1 -1
- package/dist/NiceSavedQueryPanel-BSZhE-_l.cjs +587 -0
- package/dist/{NiceScheduler-Boo-D1S-.cjs → NiceScheduler-BqYiHPvz.cjs} +1 -1
- package/dist/{core-lazy-C_qnVGxE.cjs → core-lazy-BQexApr7.cjs} +1 -1
- package/dist/data/NiceTreeGrid.mjs +519 -458
- package/dist/data.cjs +1 -1
- package/dist/data.d.ts +20 -1
- package/dist/editors.cjs +1 -1
- package/dist/index.cjs +98 -98
- package/dist/index.d.ts +197 -1
- package/dist/index.mjs +303 -293
- package/dist/lazy.cjs +1 -1
- package/dist/navigation.cjs +1 -1
- package/dist/no-code/NiceNoCodeScriptEditor.mjs +584 -0
- package/dist/no-code/noCodeScript.mjs +326 -0
- package/dist/no-code-B1jzfUF5.cjs +331 -0
- package/dist/no-code.cjs +1 -1
- package/dist/no-code.d.ts +177 -0
- package/dist/no-code.mjs +26 -16
- package/dist/style.css +2 -2
- package/package.json +4 -4
- package/dist/NiceForm-O3sv-DNX.cjs +0 -1
- package/dist/NiceModuleLifecyclePanel-DKlqKPy2.cjs +0 -1
- package/dist/NiceSavedQueryPanel-BPGpKWN2.cjs +0 -587
- package/dist/NiceSelect-BNPXs6FQ.cjs +0 -1
- package/dist/no-code-B3BHeyG-.cjs +0 -331
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const t=require("react/jsx-runtime"),c=require("@nice2dev/ui-core"),s=require("react"),He=require("react-dom"),ze=require("./devops-cgRBnZVX.cjs");function ke(y,g,E,_){const B=_?.maxHeight??320,M=_?.anchorKey,w=s.useRef(null),[he,V]=s.useState(null),[le,G]=s.useState(!1),[re,R]=s.useState(""),b=s.useContext(c.NiceThemeContext)?.portalTarget??(typeof document<"u"?document.body:null),u=s.useRef(E);u.current=E;const F=c.useInputEngine();return c.useOverlayFocus(w,{open:y,modal:!1,initialFocus:"none",onClose:()=>u.current(),closeHint:!1}),s.useLayoutEffect(()=>{if(!y||!g.current)return;R(ze.scopeThemeClass(g.current)),G(!1);const l=()=>{const k=g.current;if(!k)return;const a=k.getBoundingClientRect(),q=w.current?.offsetHeight??B;let D=a.bottom;D+q>window.innerHeight-8&&a.top-q>8&&(D=a.top-q);let j=a.left;j+a.width>window.innerWidth-8&&(j=Math.max(8,window.innerWidth-a.width-8)),V(d=>d&&d.left===j&&d.top===D&&d.width===a.width?d:{left:j,top:D,width:a.width})};l();const I=requestAnimationFrame(()=>{l(),G(!0)}),v=k=>{const a=k.target;a instanceof Node&&(w.current?.contains(a)||g.current?.contains(a))||u.current()},m=()=>u.current();return window.addEventListener("scroll",v,!0),window.addEventListener("resize",m),()=>{cancelAnimationFrame(I),window.removeEventListener("scroll",v,!0),window.removeEventListener("resize",m)}},[y,g,B,M]),s.useEffect(()=>{if(!y)return;const l=v=>{const m=v.target;g.current?.contains(m)||w.current?.contains(m)||(m instanceof Element?m:m?.parentElement??null)?.closest('.nice-select__dropdown, [role="listbox"], [role="option"]')||u.current()},I=v=>{if(v.key!=="Escape"||v.defaultPrevented)return;const m=F?.topOverlay();m&&m.element!==w.current||u.current()};return document.addEventListener("mousedown",l),document.addEventListener("keydown",I),()=>{document.removeEventListener("mousedown",l),document.removeEventListener("keydown",I)}},[y,g,F]),{popupRef:w,coords:he,ready:le,themeClass:re,portalTarget:b}}const Se=Object.assign(s.forwardRef(({label:y,"aria-label":g,helperText:E,error:_,required:B,disabled:M,size:w="md",name:he,id:V,className:le,style:G,accessMode:re,displayStyle:R,options:pe,value:b,onChange:u,placeholder:F,multiple:l=!1,searchable:I=!0,clearable:v=!1,emptyText:m,maxHeight:k=240,optionsSource:a,valueField:q,labelField:D,virtualScroll:j,optionHeight:d=36,onSearch:T,loading:S,renderOption:J,multipleAutosize:Q=!1,showKeyboardHints:$e,labelPlacement:Ce,errorPlacement:X,labelWidth:Y,controlWidth:A,displayMode:Ee},Z)=>{const oe=c.useNiceAccessMode(re,V),Me=oe==="hidden";(oe==="disabled"||oe==="readOnly")&&(M=!0);const{t:$}=c.useNiceTranslation(),Ie=c.useComponentDisplayStyle("input",R),Le=c.useComponentDisplayClass("input",R),C=c.useControlId(V),me=c.useDisplayModeEdit({enabled:Ee,disabled:M}),[f,O]=s.useState(!1),[ee,te]=s.useState(""),[h,H]=s.useState(-1),[ve,De]=s.useState(0),xe=s.useRef(null),z=s.useRef(null),[_e,Te]=s.useState(null);s.useLayoutEffect(()=>{!S&&z.current&&Te(z.current.offsetWidth)},[S,b,R]);const[K,Oe]=s.useState(null);s.useLayoutEffect(()=>{l&&!Q&&z.current&&K==null&&Oe(z.current.offsetWidth)},[l,Q,K]);const Re=c.useNiceLookupSource(a??null,q??a?.keyField??"id",D??"name"),L=a?Re.options:(pe??[]).map(e=>typeof e=="string"?{value:e,label:e}:e),{popupRef:ne,coords:P,ready:ye,themeClass:se,portalTarget:ge}=ke(f,xe,()=>{O(!1),te("")}),r=s.useMemo(()=>b?Array.isArray(b)?b:[b]:[],[b]),o=s.useMemo(()=>{if(!ee&&!T||T)return L;const e=ee.toLowerCase();return L.filter(n=>n.label.toLowerCase().includes(e)||String(n.value).toLowerCase().includes(e))},[L,ee,T]),we=s.useMemo(()=>{const e=new Map;for(const n of o){const i=n.group||"";e.has(i)||e.set(i,[]),e.get(i).push(n)}return e},[o]),U=s.useCallback(e=>{if(l){const n=r.includes(e)?r.filter(i=>i!==e):[...r,e];u?.(n)}else u?.(e),O(!1),te("")},[l,r,u]),ie=s.useCallback(()=>{const e=o.findIndex(n=>r.includes(String(n.value)));H(e>=0?e:0),O(!0)},[o,r]),ae=s.useCallback(e=>H(n=>Math.max(0,Math.min(o.length-1,e(n)))),[o.length]),je=s.useCallback(e=>{const n=e.target instanceof HTMLInputElement;if(e.key==="Escape"){O(!1),te("");return}if((e.key==="Delete"||e.key==="Backspace")&&!n&&v&&r.length>0){e.preventDefault(),u?.(l?[]:"");return}if(e.key==="Enter"||e.key===" "&&!n){if(!f){ie(),e.preventDefault();return}h>=0&&o[h]&&(U(o[h].value),e.preventDefault());return}const i={ArrowDown:p=>p+1,ArrowUp:p=>p-1,PageDown:p=>p+10,PageUp:p=>p-10};n||(i.Home=()=>0,i.End=()=>o.length-1);const N=i[e.key];N&&(e.preventDefault(),f?ae(N):ie())},[f,h,o,U,ie,ae,v,r.length,u,l]),Ne=I||!!T,de=`${C}-listbox`,ue=e=>`${C}-opt-${e}`,be=f&&h>=0&&o[h]?ue(h):void 0;s.useLayoutEffect(()=>{const e=ne.current;if(!(!f||h<0||!e)){if(j){const n=h*d;n<e.scrollTop?e.scrollTop=n:n+d>e.scrollTop+e.clientHeight&&(e.scrollTop=n+d-e.clientHeight);return}e.querySelector(`[data-nice-option-index="${h}"]`)?.scrollIntoView?.({block:"nearest"})}},[f,h,j,d,ne]),c.useIntent(["navigate","activate"],e=>{if(e.source==="keyboard")return!1;if(e.intent==="activate"){const n=o[h];n&&!n.disabled&&U(String(n.value));return}if(e.direction!=="up"&&e.direction!=="down")return!1;ae(n=>n+(e.direction==="down"?1:-1))},{ref:ne,enabled:f&&Ne});const fe=s.useMemo(()=>r.length===0?null:l?r.map(e=>L.find(n=>n.value===e)?.label||e).join(", "):L.find(e=>e.value===r[0])?.label||r[0],[r,L,l]),Fe=s.useCallback(e=>{e.stopPropagation(),u?.(l?[]:"")},[u,l]),qe=s.useMemo(()=>[{key:"Enter",description:$("shortcuts.select","Select")},{key:"Space",description:$("shortcuts.openDropdown","Open dropdown")},c.COMMON_SHORTCUTS.moveUp,c.COMMON_SHORTCUTS.moveDown,c.COMMON_SHORTCUTS.cancel],[$]);return Me?null:t.jsxs("div",{className:`nice-field ${A==null?"nice-field--select-auto":""} nice-field--${w} ${Ce==="left"?"nice-field--label-left":""} ${S?"nice-field--loading":""} ${le||""}`,style:{...G,...Y!=null&&{"--nice-field-label-width":typeof Y=="number"?`${Y}px`:Y},...A!=null&&{"--nice-field-control-width":typeof A=="number"?`${A}px`:A},...S&&_e!=null&&{"--nice-select-locked-width":`${_e}px`}},"aria-busy":S||void 0,children:[y&&t.jsxs("label",{htmlFor:C,className:`nice-field__label ${B?"nice-field__label--required":""}`,children:[y,$e&&t.jsx(c.NiceKeyboardHint,{shortcuts:qe,size:"sm"})]}),t.jsxs("div",{className:"nice-field__control",children:[me.isDisplay?t.jsx(c.DisplayModeView,{value:fe,placeholder:F||$("controls.select","Select..."),disabled:M,onActivate:()=>{me.enterEdit(),O(!0)},ariaLabel:y??g}):t.jsxs("div",{className:"nice-select",ref:xe,children:[t.jsxs("button",{ref:e=>{z.current=e,typeof Z=="function"?Z(e):Z&&(Z.current=e)},type:"button",id:C,role:"combobox","aria-label":y?void 0:g,"aria-expanded":f,"aria-haspopup":"listbox","aria-controls":f?de:void 0,"aria-activedescendant":Ne?void 0:be,"aria-invalid":!!_,"aria-keyshortcuts":v&&r.length>0?"Delete":void 0,className:`nice-select__trigger nice-select__trigger--${w} nice-select--ds-${Le} ${f?"nice-select__trigger--open":""} ${_?"nice-select__trigger--error":""} ${M?"nice-select__trigger--disabled":""}`,style:{...Ie,...l&&!Q&&K!=null?{width:K,maxWidth:K,overflow:"hidden"}:{}},disabled:M,onClick:()=>f?O(!1):ie(),onKeyDown:je,children:[fe?t.jsx("span",{style:l&&!Q?{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}:void 0,children:fe}):t.jsx("span",{className:"nice-select__placeholder",children:F||$("controls.select","Select...")}),t.jsxs("span",{style:{display:"flex",alignItems:"center",gap:4},children:[v&&r.length>0&&t.jsx("span",{className:"nice-input__clear",onClick:Fe,role:"presentation",children:t.jsx(c.NiceIcon,{name:"close",size:14})}),t.jsx("span",{className:`nice-select__chevron ${f?"nice-select__chevron--open":""}`,children:t.jsx(c.NiceIcon,{name:"chevron-down",size:16})})]})]}),f&&P&&ge&&He.createPortal(t.jsxs("div",{ref:ne,className:`nice-select__dropdown${se?` ${se}`:""}`,"data-theme":se==="nice-dark"?"dark":se==="nice-light"?"light":void 0,role:"listbox",id:de,"aria-multiselectable":l||void 0,style:{maxHeight:k,position:"fixed",left:P.left,top:P.top,width:P.width,minWidth:P.width,zIndex:1e3,opacity:ye?1:0,pointerEvents:ye?void 0:"none"},onScroll:j?e=>De(e.currentTarget.scrollTop):void 0,children:[(I||T)&&t.jsx("div",{className:"nice-select__search",children:t.jsx("input",{type:"text",value:ee,onChange:e=>{te(e.target.value),H(0),T?.(e.target.value)},onKeyDown:je,placeholder:$("controls.search","Search..."),"aria-label":$("controls.search","Search..."),"aria-controls":de,"aria-activedescendant":be,"aria-autocomplete":"list",autoFocus:!0})}),S&&t.jsx("div",{className:"nice-select__loading",children:t.jsx("div",{className:"nice-spinner nice-spinner--sm",style:{margin:"8px auto"}})}),!S&&o.length===0?t.jsx("div",{className:"nice-select__empty",children:m||$("controls.noResults","No results found")}):j&&!Array.from(we.keys()).some(e=>e!=="")?(()=>{const n=o.length*d,i=Math.max(0,Math.floor(ve/d)-3),N=Math.min(o.length,Math.ceil((ve+k)/d)+3),p=o.slice(i,N);return t.jsx("div",{style:{height:n,position:"relative"},children:p.map((x,Ae)=>{const W=i+Ae,ce=r.includes(x.value);return t.jsx("div",{id:ue(W),"data-nice-option-index":W,role:"option","aria-selected":ce,"aria-disabled":x.disabled||void 0,className:`nice-select__option ${ce?"nice-select__option--selected":""} ${W===h?"nice-select__option--highlighted":""} ${x.disabled?"nice-select__option--disabled":""}`,style:{position:"absolute",top:W*d,left:0,right:0,height:d,display:"flex",alignItems:"center",padding:"0 12px"},onClick:()=>!x.disabled&&U(String(x.value)),onMouseEnter:()=>H(W),children:J?J(x,ce):t.jsxs(t.Fragment,{children:[x.icon&&t.jsx("span",{children:x.icon}),t.jsxs("div",{style:{flex:1},children:[t.jsx("div",{children:x.label}),x.description&&t.jsx("div",{className:"nice-select__option-desc",children:x.description})]}),ce&&t.jsx(c.NiceIcon,{name:"check",size:16,className:"nice-select__option-check"})]})},x.value)})})})():Array.from(we.entries()).map(([e,n])=>t.jsxs(s.Fragment,{children:[e&&t.jsx("div",{className:"nice-select__group-label",children:e}),n.map(i=>{const N=r.includes(i.value),p=o.indexOf(i);return t.jsx("div",{id:ue(p),"data-nice-option-index":p,role:"option","aria-selected":N,"aria-disabled":i.disabled||void 0,className:`nice-select__option ${N?"nice-select__option--selected":""} ${p===h?"nice-select__option--highlighted":""} ${i.disabled?"nice-select__option--disabled":""}`,onClick:()=>!i.disabled&&U(String(i.value)),onMouseEnter:()=>H(p),children:J?J(i,N):t.jsxs(t.Fragment,{children:[i.icon&&t.jsx("span",{children:i.icon}),t.jsxs("div",{style:{flex:1},children:[t.jsx("div",{children:i.label}),i.description&&t.jsx("div",{className:"nice-select__option-desc",children:i.description})]}),N&&t.jsx(c.NiceIcon,{name:"check",size:16,className:"nice-select__option-check"})]})},i.value)})]},e))]}),ge)]}),S&&t.jsx("span",{className:"nice-field__spinner",children:t.jsx("span",{className:"nice-spinner nice-spinner--sm"})}),X==="right"&&_&&t.jsx("div",{id:`${C}-error`,className:"nice-field__error",role:"alert",children:_}),X==="right"&&!_&&E&&t.jsx("div",{id:`${C}-helper`,className:"nice-field__helper",children:E})]}),X!=="right"&&_&&t.jsx("div",{id:`${C}-error`,className:"nice-field__error",role:"alert",children:_}),X!=="right"&&!_&&E&&t.jsx("div",{id:`${C}-helper`,className:"nice-field__helper",children:E})]})}),{displayName:"NiceSelect"}),Ke=Object.freeze(Object.defineProperty({__proto__:null,NiceSelect:Se},Symbol.toStringTag,{value:"Module"}));exports.NiceSelect=Se;exports.NiceSelect$1=Ke;exports.useAnchoredPopup=ke;
|