neatkit 0.15.0 → 0.15.2

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.
Files changed (37) hide show
  1. package/dist/Boundary.cjs +1 -1
  2. package/dist/Boundary.js +1 -1
  3. package/dist/Markdown.cjs +1 -1
  4. package/dist/Markdown.js +1 -1
  5. package/dist/Popover.cjs +1 -1
  6. package/dist/Popover.js +1 -1
  7. package/dist/Select.cjs +1 -1
  8. package/dist/Select.js +123 -123
  9. package/dist/Sidebar.cjs +1 -1
  10. package/dist/Sidebar.js +3 -3
  11. package/dist/{Table-GlG5aITK.cjs → Table-DBkiHOd0.cjs} +1 -1
  12. package/dist/{Table-Dvi-4XA7.js → Table-DdTjtnRE.js} +1 -1
  13. package/dist/Table.cjs +1 -1
  14. package/dist/Table.js +1 -1
  15. package/dist/{Tooltip-CDOwCTig.js → Tooltip-4RWCnb2Q.js} +1 -1
  16. package/dist/{Tooltip-DrAZSmEv.cjs → Tooltip-B2rZmRCs.cjs} +1 -1
  17. package/dist/Tooltip.cjs +1 -1
  18. package/dist/Tooltip.js +1 -1
  19. package/dist/components/Portal/hooks/useAnchoredPosition.d.ts +12 -10
  20. package/dist/components/Portal/utils/floating-position.d.ts +5 -36
  21. package/dist/components/Portal/utils/geometry.d.ts +45 -0
  22. package/dist/components/Select/utils/listbox-position.d.ts +6 -5
  23. package/dist/index.cjs +1 -1
  24. package/dist/index.js +1 -1
  25. package/dist/style.css +1 -1
  26. package/dist/tokens.d.ts +1 -1
  27. package/dist/{units-BEMW4BNr.cjs → units-BUvyiHxw.cjs} +1 -1
  28. package/dist/{units-D4Waz9EO.js → units-CMj64udI.js} +1 -1
  29. package/dist/useAnchoredPosition-CrdY2Eat.cjs +1 -0
  30. package/dist/useAnchoredPosition-xI79veB2.js +79 -0
  31. package/dist/useFloatingPosition-DPVO2E8O.cjs +1 -0
  32. package/dist/useFloatingPosition-DktY7k-t.js +110 -0
  33. package/package.json +1 -1
  34. package/dist/useAnchoredPosition-BEzN03Oi.cjs +0 -1
  35. package/dist/useAnchoredPosition-BIXEDNSo.js +0 -119
  36. package/dist/useFloatingPosition-8_GSpDjw.cjs +0 -1
  37. package/dist/useFloatingPosition-Cizey9UN.js +0 -58
@@ -1 +1 @@
1
- "use client";"use strict";const o=require("react/jsx-runtime"),a=require("react"),H=require("./reference-C2guRuR0.cjs"),D=require("./Surface-BttJYSDt.cjs"),K=require("./Button-pinr6Woy.cjs"),O=require("./Tooltip-DrAZSmEv.cjs"),v=a.createContext("body"),w=a.forwardRef(function(l,e){const{align:t="left",children:s,className:i,scope:c="col",sticky:b=!1,...d}=l;return o.jsx("th",{...d,ref:e,className:["nk-table__header-cell",i].filter(Boolean).join(" "),"data-align":t,"data-sticky":b||void 0,scope:c,children:s})});function S(n){for(const l of a.Children.toArray(n)){if(a.isValidElement(l)&&l.type===a.Fragment){if(S(l.props.children))return!0;continue}return!0}return!1}function F(n){const{"aria-label":l,icon:e,label:t,...s}=n;return o.jsx(O.Tooltip2,{content:t,children:o.jsx(K.Button,{...s,"aria-label":l??t,icon:e,shape:"rectangle",size:"small",type:"button",variant:"ghost"})})}function P(n){const{actions:l}=n;function e(t){t.stopPropagation()}return o.jsx("td",{className:"nk-table__cell nk-table__action-cell","data-align":"right",onClick:e,children:l.length>0?o.jsx("span",{className:"nk-table__action-list",children:l.map(t=>a.createElement(F,{...t,key:t.label}))}):null})}const q=a.forwardRef(function(l,e){const{children:t,className:s,emptyColumnCount:i=1,emptyMessage:c,...b}=l,d=!S(t),h=Number.isFinite(i)?Math.max(1,Math.floor(i)):1;return o.jsx("tbody",{...b,ref:e,className:["nk-table__body",s].filter(Boolean).join(" "),children:d&&c!==void 0?o.jsxs("tr",{className:"nk-table__row",children:[o.jsx("td",{"aria-hidden":"true",className:"nk-table__cell nk-table__overscroll-start-cell"}),o.jsx("td",{className:"nk-table__cell nk-table__empty-cell",colSpan:h,children:o.jsx("div",{className:"nk-table__empty-content",children:c})}),o.jsx(P,{actions:[]})]}):o.jsx(v.Provider,{value:"body",children:t})})});function z(n,l,e){return n===void 0?l:e?e(n):n instanceof Date?Number.isNaN(n.getTime())?"Invalid Date":n.toISOString().slice(0,10):typeof n=="boolean"?n?"Yes":"No":n}function V(n){if(typeof n=="number"||typeof n=="string")return String(n)}const E=a.forwardRef(function(l,e){const{align:t="left",children:s,className:i,format:c,title:b,truncate:d,value:h,...k}=l,{rowTrigger:r,...u}=k,p=z(h,s,c),f=d===void 0?void 0:{maxWidth:d},_=b??(d===void 0?void 0:V(p));return o.jsxs("td",{...u,ref:e,className:["nk-table__cell",i].filter(Boolean).join(" "),"data-align":t,title:_,children:[(r==null?void 0:r.kind)==="link"&&r.linkProperties?o.jsx("a",{ref:r.reference,"aria-label":r.ariaLabel,className:"nk-table__row-trigger",download:r.linkProperties.download,href:r.linkProperties.href,hrefLang:r.linkProperties.hrefLang,onClick:r.linkProperties.onNavigate,rel:r.linkProperties.rel,target:r.linkProperties.target}):null,(r==null?void 0:r.kind)==="button"?o.jsx("button",{ref:r.reference,"aria-label":r.ariaLabel,className:"nk-table__row-trigger",onClick:r.onClick,type:"button"}):null,d!==void 0?o.jsx("span",{className:"nk-table__truncated-content",style:f,children:p}):p]})}),M=a.forwardRef(function(l,e){const{children:t,className:s,...i}=l;return o.jsx("tfoot",{...i,ref:e,className:["nk-table__foot",s].filter(Boolean).join(" "),children:o.jsx(v.Provider,{value:"foot",children:t})})}),Y=a.forwardRef(function(l,e){const{children:t,className:s,...i}=l;return o.jsx("thead",{...i,ref:e,className:["nk-table__head",s].filter(Boolean).join(" "),children:o.jsx(v.Provider,{value:"head",children:t})})}),X=["a[href]","audio[controls]","button","iframe","input","label","select","summary","textarea","video[controls]","[contenteditable]:not([contenteditable='false'])"].join(","),$=new Set(["button","checkbox","combobox","grid","link","listbox","menu","menubar","menuitem","menuitemcheckbox","menuitemradio","option","radio","radiogroup","scrollbar","searchbox","slider","spinbutton","switch","tab","tablist","textbox","tree","treegrid","treeitem"]);function G(n,l){var t;let e=n;for(;e&&e!==l;){if(e.matches(X)||(((t=e.getAttribute("role"))==null?void 0:t.split(/\s+/))??[]).some(i=>$.has(i)))return!0;e=e.parentElement}return!1}function J(n,l){let e=!1;function t(i){return a.Children.map(i,c=>a.isValidElement(c)?c.type===a.Fragment?a.cloneElement(c,void 0,t(c.props.children)):!e&&c.type===E?(e=!0,a.cloneElement(c,{rowTrigger:l})):c:c)}const s=t(n);return{attached:e,content:s}}const Q=a.forwardRef(function(l,e){const{children:t,className:s,...i}=l;return o.jsx(w,{...i,ref:e,align:"right",className:["nk-table__action-header-cell",s].filter(Boolean).join(" "),children:t??o.jsx("span",{className:"nk-table__visually-hidden",children:"Row actions"})})}),U=a.forwardRef(function(l,e){const{"aria-label":t,actions:s,children:i,className:c,download:b,href:d,hrefLang:h,onClick:k,onNavigate:r,rel:u,target:p,...f}=l,_=a.useRef(null),g=a.useContext(v),j=d!==void 0||k!==void 0,N=(t==null?void 0:t.trim())||(d!==void 0?"Open row":"Activate row");function T(m){_.current=m}let x;d!==void 0?x={ariaLabel:N,kind:"link",linkProperties:{download:b,href:d,hrefLang:h,onNavigate:r,rel:u,target:p},reference:T}:k!==void 0&&(x={ariaLabel:N,kind:"button",onClick:k,reference:T});const B=x?J(i,x):{content:i};function L(m){if(m.defaultPrevented)return;const y=m.target;if(!(y instanceof Element)||G(y,m.currentTarget))return;const C=_.current;if(!C)return;const R=C.ownerDocument.defaultView;if(!R){C.click();return}C.dispatchEvent(new R.MouseEvent("click",{altKey:m.altKey,bubbles:!0,button:m.button,buttons:m.buttons,cancelable:!0,clientX:m.clientX,clientY:m.clientY,ctrlKey:m.ctrlKey,metaKey:m.metaKey,shiftKey:m.shiftKey}))}const A=g==="head"?o.jsx(Q,{}):o.jsx(P,{actions:s??[]}),I=g==="head"?o.jsx("th",{"aria-hidden":"true",className:"nk-table__header-cell nk-table__overscroll-start-cell"}):o.jsx("td",{"aria-hidden":"true",className:"nk-table__cell nk-table__overscroll-start-cell"});return o.jsxs("tr",{...f,ref:e,"aria-label":j?void 0:t,className:["nk-table__row",c].filter(Boolean).join(" "),"data-interactive":j||void 0,onClick:j?L:void 0,children:[I,B.content,A]})});function W(){const n=a.useRef(null),l=a.useRef(null),[e,t]=a.useState(!1),[s,i]=a.useState(!1);a.useEffect(()=>{const b=n.current,d=l.current;if(!b||!d)return;const h=b,k=d;function r(){const _=h.scrollWidth>h.clientWidth;t(_),_||i(!1)}r();const u=h.ownerDocument.defaultView;u==null||u.addEventListener("resize",r);const p=u==null?void 0:u.ResizeObserver,f=p?new p(r):void 0;return f==null||f.observe(h),f==null||f.observe(k),()=>{u==null||u.removeEventListener("resize",r),f==null||f.disconnect()}},[]);function c(b){i(e&&b.currentTarget.scrollLeft>1)}return{containerReference:n,contentReference:l,isScrollable:e,isScrolled:s,handleScroll:c}}const Z=a.forwardRef(function(l,e){const{"aria-label":t,children:s,className:i,containerClassName:c,frame:b="outline",...d}=l,{containerReference:h,contentReference:k,isScrollable:r,isScrolled:u,handleScroll:p}=W(),f=t?`${t} scroll area`:"Scrollable table",_=a.useCallback(g=>{k.current=g,H.assignElementReference(e,g)},[k,e]);return o.jsx(D.Surface,{ref:h,"aria-label":r?f:void 0,className:["nk-table",c].filter(Boolean).join(" "),"data-frame":b,"data-scrolled":u||void 0,onScroll:p,role:r?"region":void 0,tabIndex:r?0:void 0,children:o.jsx("table",{...d,ref:_,"aria-label":t,className:["nk-table__element",i].filter(Boolean).join(" "),children:s})})}),ee=Object.assign(Z,{Body:q,Cell:E,Foot:M,HeaderCell:w,Head:Y,Row:U});exports.Table=ee;
1
+ "use client";"use strict";const o=require("react/jsx-runtime"),a=require("react"),H=require("./reference-C2guRuR0.cjs"),D=require("./Surface-BttJYSDt.cjs"),K=require("./Button-pinr6Woy.cjs"),O=require("./Tooltip-B2rZmRCs.cjs"),v=a.createContext("body"),w=a.forwardRef(function(l,e){const{align:t="left",children:s,className:i,scope:c="col",sticky:b=!1,...d}=l;return o.jsx("th",{...d,ref:e,className:["nk-table__header-cell",i].filter(Boolean).join(" "),"data-align":t,"data-sticky":b||void 0,scope:c,children:s})});function S(n){for(const l of a.Children.toArray(n)){if(a.isValidElement(l)&&l.type===a.Fragment){if(S(l.props.children))return!0;continue}return!0}return!1}function F(n){const{"aria-label":l,icon:e,label:t,...s}=n;return o.jsx(O.Tooltip2,{content:t,children:o.jsx(K.Button,{...s,"aria-label":l??t,icon:e,shape:"rectangle",size:"small",type:"button",variant:"ghost"})})}function P(n){const{actions:l}=n;function e(t){t.stopPropagation()}return o.jsx("td",{className:"nk-table__cell nk-table__action-cell","data-align":"right",onClick:e,children:l.length>0?o.jsx("span",{className:"nk-table__action-list",children:l.map(t=>a.createElement(F,{...t,key:t.label}))}):null})}const q=a.forwardRef(function(l,e){const{children:t,className:s,emptyColumnCount:i=1,emptyMessage:c,...b}=l,d=!S(t),h=Number.isFinite(i)?Math.max(1,Math.floor(i)):1;return o.jsx("tbody",{...b,ref:e,className:["nk-table__body",s].filter(Boolean).join(" "),children:d&&c!==void 0?o.jsxs("tr",{className:"nk-table__row",children:[o.jsx("td",{"aria-hidden":"true",className:"nk-table__cell nk-table__overscroll-start-cell"}),o.jsx("td",{className:"nk-table__cell nk-table__empty-cell",colSpan:h,children:o.jsx("div",{className:"nk-table__empty-content",children:c})}),o.jsx(P,{actions:[]})]}):o.jsx(v.Provider,{value:"body",children:t})})});function z(n,l,e){return n===void 0?l:e?e(n):n instanceof Date?Number.isNaN(n.getTime())?"Invalid Date":n.toISOString().slice(0,10):typeof n=="boolean"?n?"Yes":"No":n}function V(n){if(typeof n=="number"||typeof n=="string")return String(n)}const E=a.forwardRef(function(l,e){const{align:t="left",children:s,className:i,format:c,title:b,truncate:d,value:h,...k}=l,{rowTrigger:r,...u}=k,p=z(h,s,c),f=d===void 0?void 0:{maxWidth:d},_=b??(d===void 0?void 0:V(p));return o.jsxs("td",{...u,ref:e,className:["nk-table__cell",i].filter(Boolean).join(" "),"data-align":t,title:_,children:[(r==null?void 0:r.kind)==="link"&&r.linkProperties?o.jsx("a",{ref:r.reference,"aria-label":r.ariaLabel,className:"nk-table__row-trigger",download:r.linkProperties.download,href:r.linkProperties.href,hrefLang:r.linkProperties.hrefLang,onClick:r.linkProperties.onNavigate,rel:r.linkProperties.rel,target:r.linkProperties.target}):null,(r==null?void 0:r.kind)==="button"?o.jsx("button",{ref:r.reference,"aria-label":r.ariaLabel,className:"nk-table__row-trigger",onClick:r.onClick,type:"button"}):null,d!==void 0?o.jsx("span",{className:"nk-table__truncated-content",style:f,children:p}):p]})}),M=a.forwardRef(function(l,e){const{children:t,className:s,...i}=l;return o.jsx("tfoot",{...i,ref:e,className:["nk-table__foot",s].filter(Boolean).join(" "),children:o.jsx(v.Provider,{value:"foot",children:t})})}),Y=a.forwardRef(function(l,e){const{children:t,className:s,...i}=l;return o.jsx("thead",{...i,ref:e,className:["nk-table__head",s].filter(Boolean).join(" "),children:o.jsx(v.Provider,{value:"head",children:t})})}),X=["a[href]","audio[controls]","button","iframe","input","label","select","summary","textarea","video[controls]","[contenteditable]:not([contenteditable='false'])"].join(","),$=new Set(["button","checkbox","combobox","grid","link","listbox","menu","menubar","menuitem","menuitemcheckbox","menuitemradio","option","radio","radiogroup","scrollbar","searchbox","slider","spinbutton","switch","tab","tablist","textbox","tree","treegrid","treeitem"]);function G(n,l){var t;let e=n;for(;e&&e!==l;){if(e.matches(X)||(((t=e.getAttribute("role"))==null?void 0:t.split(/\s+/))??[]).some(i=>$.has(i)))return!0;e=e.parentElement}return!1}function J(n,l){let e=!1;function t(i){return a.Children.map(i,c=>a.isValidElement(c)?c.type===a.Fragment?a.cloneElement(c,void 0,t(c.props.children)):!e&&c.type===E?(e=!0,a.cloneElement(c,{rowTrigger:l})):c:c)}const s=t(n);return{attached:e,content:s}}const Q=a.forwardRef(function(l,e){const{children:t,className:s,...i}=l;return o.jsx(w,{...i,ref:e,align:"right",className:["nk-table__action-header-cell",s].filter(Boolean).join(" "),children:t??o.jsx("span",{className:"nk-table__visually-hidden",children:"Row actions"})})}),U=a.forwardRef(function(l,e){const{"aria-label":t,actions:s,children:i,className:c,download:b,href:d,hrefLang:h,onClick:k,onNavigate:r,rel:u,target:p,...f}=l,_=a.useRef(null),g=a.useContext(v),j=d!==void 0||k!==void 0,N=(t==null?void 0:t.trim())||(d!==void 0?"Open row":"Activate row");function T(m){_.current=m}let x;d!==void 0?x={ariaLabel:N,kind:"link",linkProperties:{download:b,href:d,hrefLang:h,onNavigate:r,rel:u,target:p},reference:T}:k!==void 0&&(x={ariaLabel:N,kind:"button",onClick:k,reference:T});const B=x?J(i,x):{content:i};function L(m){if(m.defaultPrevented)return;const y=m.target;if(!(y instanceof Element)||G(y,m.currentTarget))return;const C=_.current;if(!C)return;const R=C.ownerDocument.defaultView;if(!R){C.click();return}C.dispatchEvent(new R.MouseEvent("click",{altKey:m.altKey,bubbles:!0,button:m.button,buttons:m.buttons,cancelable:!0,clientX:m.clientX,clientY:m.clientY,ctrlKey:m.ctrlKey,metaKey:m.metaKey,shiftKey:m.shiftKey}))}const A=g==="head"?o.jsx(Q,{}):o.jsx(P,{actions:s??[]}),I=g==="head"?o.jsx("th",{"aria-hidden":"true",className:"nk-table__header-cell nk-table__overscroll-start-cell"}):o.jsx("td",{"aria-hidden":"true",className:"nk-table__cell nk-table__overscroll-start-cell"});return o.jsxs("tr",{...f,ref:e,"aria-label":j?void 0:t,className:["nk-table__row",c].filter(Boolean).join(" "),"data-interactive":j||void 0,onClick:j?L:void 0,children:[I,B.content,A]})});function W(){const n=a.useRef(null),l=a.useRef(null),[e,t]=a.useState(!1),[s,i]=a.useState(!1);a.useEffect(()=>{const b=n.current,d=l.current;if(!b||!d)return;const h=b,k=d;function r(){const _=h.scrollWidth>h.clientWidth;t(_),_||i(!1)}r();const u=h.ownerDocument.defaultView;u==null||u.addEventListener("resize",r);const p=u==null?void 0:u.ResizeObserver,f=p?new p(r):void 0;return f==null||f.observe(h),f==null||f.observe(k),()=>{u==null||u.removeEventListener("resize",r),f==null||f.disconnect()}},[]);function c(b){i(e&&b.currentTarget.scrollLeft>1)}return{containerReference:n,contentReference:l,isScrollable:e,isScrolled:s,handleScroll:c}}const Z=a.forwardRef(function(l,e){const{"aria-label":t,children:s,className:i,containerClassName:c,frame:b="outline",...d}=l,{containerReference:h,contentReference:k,isScrollable:r,isScrolled:u,handleScroll:p}=W(),f=t?`${t} scroll area`:"Scrollable table",_=a.useCallback(g=>{k.current=g,H.assignElementReference(e,g)},[k,e]);return o.jsx(D.Surface,{ref:h,"aria-label":r?f:void 0,className:["nk-table",c].filter(Boolean).join(" "),"data-frame":b,"data-scrolled":u||void 0,onScroll:p,role:r?"region":void 0,tabIndex:r?0:void 0,children:o.jsx("table",{...d,ref:_,"aria-label":t,className:["nk-table__element",i].filter(Boolean).join(" "),children:s})})}),ee=Object.assign(Z,{Body:q,Cell:E,Foot:M,HeaderCell:w,Head:Y,Row:U});exports.Table=ee;
@@ -4,7 +4,7 @@ import { createContext as V, forwardRef as _, Children as L, isValidElement as j
4
4
  import { a as G } from "./reference-CXMr27nM.js";
5
5
  import { S as J } from "./Surface-vEFsZC12.js";
6
6
  import { B as Q } from "./Button-DdxB1ps7.js";
7
- import { T as U } from "./Tooltip-CDOwCTig.js";
7
+ import { T as U } from "./Tooltip-4RWCnb2Q.js";
8
8
  const N = V("body"), I = _(function(l, e) {
9
9
  const {
10
10
  align: t = "left",
package/dist/Table.cjs CHANGED
@@ -1 +1 @@
1
- "use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./Table-GlG5aITK.cjs");exports.default=e.Table;
1
+ "use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./Table-DBkiHOd0.cjs");exports.default=e.Table;
package/dist/Table.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { T as a } from "./Table-Dvi-4XA7.js";
2
+ import { T as a } from "./Table-DdTjtnRE.js";
3
3
  export {
4
4
  a as default
5
5
  };
@@ -3,7 +3,7 @@ import { jsx as A, jsxs as J, Fragment as Ie } from "react/jsx-runtime";
3
3
  import { useMemo as Z, createContext as he, forwardRef as ve, Fragment as Pe, useId as Le, useContext as Fe, useRef as o, useState as N, useCallback as c, useEffect as V, cloneElement as K } from "react";
4
4
  import { m as Oe } from "./aria-Bv-xVREf.js";
5
5
  import { g as _e, a as Q } from "./reference-CXMr27nM.js";
6
- import { u as Me, r as xe } from "./useFloatingPosition-Cizey9UN.js";
6
+ import { u as Me, r as xe } from "./useFloatingPosition-DktY7k-t.js";
7
7
  import { u as We } from "./effects-DGbA6Q2O.js";
8
8
  import { b as ke, c as Be, d as Ne, P as Ve } from "./usePresence-BTRY1_l-.js";
9
9
  import { i as Ae } from "./focus-restoration-BvNZzrQA.js";
@@ -1 +1 @@
1
- "use client";"use strict";const m=require("react/jsx-runtime"),n=require("react"),be=require("./aria-DM-xYEHQ.cjs"),W=require("./reference-C2guRuR0.cjs"),G=require("./useFloatingPosition-8_GSpDjw.cjs"),Ee=require("./effects-D98vUn6N.cjs"),F=require("./usePresence-Dm0mls5p.cjs"),ye=require("./focus-restoration-70WcQRr5.cjs"),De=require("./Surface-BttJYSDt.cjs"),Ie=500,K=n.createContext(null);function he(s){const{children:p,delay:i=Ie}=s,c=n.useMemo(()=>({delay:i}),[i]);return m.jsx(K.Provider,{value:c,children:p})}const Q=500,J=100;function ve(s,p,i,c){p.current=s,W.assignElementReference(i,s),W.assignElementReference(c,s)}function Pe(s){return Number.isFinite(s)?Math.max(0,s):Q}const Le=n.forwardRef(function(p,i){const{children:c,align:B="center",className:X,content:d,contentClassName:Z,contentStyle:N,delay:ee,disabled:g=!1,onOpenChange:D,placement:S="top",style:ne}=p;if(d==null||typeof d=="boolean"||typeof d=="string"&&!d.trim())throw new Error("Tooltip content must not be empty");if(c.type===n.Fragment)throw new Error("Tooltip requires a single non-Fragment trigger");const V=`${n.useId()}-tooltip`,k=n.useContext(K),O=c.props,A=W.getElementReference(c),T=n.useRef(null),C=n.useRef(null),z=n.useRef(g),_=n.useRef(!1),I=n.useRef(null),h=n.useRef(null),v=n.useRef(null),P=n.useRef(!1),R=n.useRef(!1),w=n.useRef(!1),u=n.useRef(!1),[b,re]=n.useState(null),[te,oe]=n.useState(null),[L,se]=n.useState(!1);z.current=g;const x=Pe(ee??(k==null?void 0:k.delay)??Q),E=F.usePresence(L),Y=(b==null?void 0:b.ownerDocument)??(typeof document>"u"?null:document),M=Ee.useBoundary("Tooltip").boundaryElement,q=F.useOverlayLayer(E.present,M),l=G.useFloatingPosition(E.present,S,b,te,M,B),ce=n.useMemo(()=>[T,C],[]),ie=be.mergeIdentifiers(O["aria-describedby"],V),ue=L&&E.present?ie:O["aria-describedby"],H=n.useCallback(e=>{ve(e,T,A,i),re(e)},[i,A]),le=n.useCallback(e=>{C.current=e,e||(u.current=!1),oe(e)},[]),t=n.useCallback(()=>{const e=I.current;e&&e.ownerWindow.clearTimeout(e.timerId),I.current=null},[]),o=n.useCallback(()=>{const e=h.current;e&&e.ownerWindow.clearTimeout(e.timerId),h.current=null},[]),y=n.useCallback(()=>{const e=v.current;e&&e.ownerWindow.clearTimeout(e.timerId),v.current=null},[]),r=n.useCallback(e=>{_.current!==e&&(e||(u.current=!1),_.current=e,se(e),D==null||D(e))},[D]),j=n.useCallback(e=>{var U,$;if(o(),R.current||w.current||u.current)return;if(e===0){r(!1);return}const a=((U=T.current)==null?void 0:U.ownerDocument.defaultView)??(($=C.current)==null?void 0:$.ownerDocument.defaultView);if(!a){r(!1);return}const f=a.setTimeout(()=>{h.current=null,!R.current&&!w.current&&!u.current&&r(!1)},e);h.current={ownerWindow:a,timerId:f}},[o,r]),ae=n.useCallback(()=>{var f;if(t(),o(),x===0){r(!0);return}const e=(f=T.current)==null?void 0:f.ownerDocument.defaultView;if(!e)return;const a=e.setTimeout(()=>{I.current=null,z.current||r(!0)},x);I.current={ownerWindow:e,timerId:a}},[o,t,x,r]);function fe(e){if(R.current=!0,o(),P.current||ye.isElementFocusRestoration(e.currentTarget)){t();return}t(),r(!0)}function de(e){e.currentTarget.contains(e.relatedTarget)||(R.current=!1,t(),j(0))}function me(){w.current=!0,ae()}function pe(){w.current=!1,t(),j(J)}function ge(){u.current=!0,o()}function Te(){u.current=!1,j(J)}function Re(){var f;t(),o(),r(!1);const e=(f=T.current)==null?void 0:f.ownerDocument.defaultView;if(!e)return;P.current=!0,y();const a=e.setTimeout(()=>{P.current=!1,v.current=null},0);v.current={ownerWindow:e,timerId:a}}if(F.useDismissableLayer({boundary:M,active:L,boundaries:ce,dismissOnPointerDownOutside:!0,layerId:q.id,onEscapeDismiss:()=>r(!1),onPointerDownOutsideDismiss:()=>r(!1),ownerDocument:Y}),n.useEffect(()=>{g&&(t(),o(),y(),P.current=!1,R.current=!1,w.current=!1,u.current=!1,_.current&&r(!1))},[o,t,y,g,r]),n.useEffect(()=>{},[b]),n.useEffect(()=>()=>{t(),o(),y()},[o,t,y]),g)return n.cloneElement(c,{ref:H});const we=n.cloneElement(c,G.resolveTriggerOverrides(O,{"aria-describedby":ue,className:["nk-tooltip__trigger",X].filter(Boolean).join(" "),onBlur:de,onFocus:fe,onMouseEnter:me,onMouseLeave:pe,onPointerDown:Re,ref:H,style:ne}));return m.jsxs(m.Fragment,{children:[we,E.present&&Y?m.jsx(F.Portal,{children:m.jsxs(De.Surface,{ref:le,"aria-hidden":L?void 0:!0,className:["nk-tooltip",Z].filter(Boolean).join(" "),"data-placement":(l==null?void 0:l.placement)??S,"data-align":B,"data-state":E.state==="closing"?"closing":"open",id:V,onMouseEnter:ge,onMouseLeave:Te,role:"tooltip",style:l?{...N,"--nk-tooltip-arrow-offset":`${l.arrowOffset}px`,left:l.left,top:l.top,zIndex:q.zIndex}:{...N,visibility:"hidden",zIndex:q.zIndex},children:[m.jsx("span",{"aria-hidden":"true",className:"nk-tooltip__arrow"}),d]})}):null]})}),Fe=Object.assign(Le,{Provider:he});exports.Tooltip2=Fe;
1
+ "use client";"use strict";const m=require("react/jsx-runtime"),n=require("react"),be=require("./aria-DM-xYEHQ.cjs"),W=require("./reference-C2guRuR0.cjs"),G=require("./useFloatingPosition-DPVO2E8O.cjs"),Ee=require("./effects-D98vUn6N.cjs"),F=require("./usePresence-Dm0mls5p.cjs"),ye=require("./focus-restoration-70WcQRr5.cjs"),De=require("./Surface-BttJYSDt.cjs"),Ie=500,K=n.createContext(null);function he(s){const{children:p,delay:i=Ie}=s,c=n.useMemo(()=>({delay:i}),[i]);return m.jsx(K.Provider,{value:c,children:p})}const Q=500,J=100;function ve(s,p,i,c){p.current=s,W.assignElementReference(i,s),W.assignElementReference(c,s)}function Pe(s){return Number.isFinite(s)?Math.max(0,s):Q}const Le=n.forwardRef(function(p,i){const{children:c,align:B="center",className:X,content:d,contentClassName:Z,contentStyle:N,delay:ee,disabled:g=!1,onOpenChange:D,placement:S="top",style:ne}=p;if(d==null||typeof d=="boolean"||typeof d=="string"&&!d.trim())throw new Error("Tooltip content must not be empty");if(c.type===n.Fragment)throw new Error("Tooltip requires a single non-Fragment trigger");const V=`${n.useId()}-tooltip`,k=n.useContext(K),O=c.props,A=W.getElementReference(c),T=n.useRef(null),C=n.useRef(null),z=n.useRef(g),_=n.useRef(!1),I=n.useRef(null),h=n.useRef(null),v=n.useRef(null),P=n.useRef(!1),R=n.useRef(!1),w=n.useRef(!1),u=n.useRef(!1),[b,re]=n.useState(null),[te,oe]=n.useState(null),[L,se]=n.useState(!1);z.current=g;const x=Pe(ee??(k==null?void 0:k.delay)??Q),E=F.usePresence(L),Y=(b==null?void 0:b.ownerDocument)??(typeof document>"u"?null:document),M=Ee.useBoundary("Tooltip").boundaryElement,q=F.useOverlayLayer(E.present,M),l=G.useFloatingPosition(E.present,S,b,te,M,B),ce=n.useMemo(()=>[T,C],[]),ie=be.mergeIdentifiers(O["aria-describedby"],V),ue=L&&E.present?ie:O["aria-describedby"],H=n.useCallback(e=>{ve(e,T,A,i),re(e)},[i,A]),le=n.useCallback(e=>{C.current=e,e||(u.current=!1),oe(e)},[]),t=n.useCallback(()=>{const e=I.current;e&&e.ownerWindow.clearTimeout(e.timerId),I.current=null},[]),o=n.useCallback(()=>{const e=h.current;e&&e.ownerWindow.clearTimeout(e.timerId),h.current=null},[]),y=n.useCallback(()=>{const e=v.current;e&&e.ownerWindow.clearTimeout(e.timerId),v.current=null},[]),r=n.useCallback(e=>{_.current!==e&&(e||(u.current=!1),_.current=e,se(e),D==null||D(e))},[D]),j=n.useCallback(e=>{var U,$;if(o(),R.current||w.current||u.current)return;if(e===0){r(!1);return}const a=((U=T.current)==null?void 0:U.ownerDocument.defaultView)??(($=C.current)==null?void 0:$.ownerDocument.defaultView);if(!a){r(!1);return}const f=a.setTimeout(()=>{h.current=null,!R.current&&!w.current&&!u.current&&r(!1)},e);h.current={ownerWindow:a,timerId:f}},[o,r]),ae=n.useCallback(()=>{var f;if(t(),o(),x===0){r(!0);return}const e=(f=T.current)==null?void 0:f.ownerDocument.defaultView;if(!e)return;const a=e.setTimeout(()=>{I.current=null,z.current||r(!0)},x);I.current={ownerWindow:e,timerId:a}},[o,t,x,r]);function fe(e){if(R.current=!0,o(),P.current||ye.isElementFocusRestoration(e.currentTarget)){t();return}t(),r(!0)}function de(e){e.currentTarget.contains(e.relatedTarget)||(R.current=!1,t(),j(0))}function me(){w.current=!0,ae()}function pe(){w.current=!1,t(),j(J)}function ge(){u.current=!0,o()}function Te(){u.current=!1,j(J)}function Re(){var f;t(),o(),r(!1);const e=(f=T.current)==null?void 0:f.ownerDocument.defaultView;if(!e)return;P.current=!0,y();const a=e.setTimeout(()=>{P.current=!1,v.current=null},0);v.current={ownerWindow:e,timerId:a}}if(F.useDismissableLayer({boundary:M,active:L,boundaries:ce,dismissOnPointerDownOutside:!0,layerId:q.id,onEscapeDismiss:()=>r(!1),onPointerDownOutsideDismiss:()=>r(!1),ownerDocument:Y}),n.useEffect(()=>{g&&(t(),o(),y(),P.current=!1,R.current=!1,w.current=!1,u.current=!1,_.current&&r(!1))},[o,t,y,g,r]),n.useEffect(()=>{},[b]),n.useEffect(()=>()=>{t(),o(),y()},[o,t,y]),g)return n.cloneElement(c,{ref:H});const we=n.cloneElement(c,G.resolveTriggerOverrides(O,{"aria-describedby":ue,className:["nk-tooltip__trigger",X].filter(Boolean).join(" "),onBlur:de,onFocus:fe,onMouseEnter:me,onMouseLeave:pe,onPointerDown:Re,ref:H,style:ne}));return m.jsxs(m.Fragment,{children:[we,E.present&&Y?m.jsx(F.Portal,{children:m.jsxs(De.Surface,{ref:le,"aria-hidden":L?void 0:!0,className:["nk-tooltip",Z].filter(Boolean).join(" "),"data-placement":(l==null?void 0:l.placement)??S,"data-align":B,"data-state":E.state==="closing"?"closing":"open",id:V,onMouseEnter:ge,onMouseLeave:Te,role:"tooltip",style:l?{...N,"--nk-tooltip-arrow-offset":`${l.arrowOffset}px`,left:l.left,top:l.top,zIndex:q.zIndex}:{...N,visibility:"hidden",zIndex:q.zIndex},children:[m.jsx("span",{"aria-hidden":"true",className:"nk-tooltip__arrow"}),d]})}):null]})}),Fe=Object.assign(Le,{Provider:he});exports.Tooltip2=Fe;
package/dist/Tooltip.cjs CHANGED
@@ -1 +1 @@
1
- "use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./Tooltip-DrAZSmEv.cjs");exports.default=e.Tooltip2;
1
+ "use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./Tooltip-B2rZmRCs.cjs");exports.default=e.Tooltip2;
package/dist/Tooltip.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { T as a } from "./Tooltip-CDOwCTig.js";
2
+ import { T as a } from "./Tooltip-4RWCnb2Q.js";
3
3
  export {
4
4
  a as default
5
5
  };
@@ -1,24 +1,24 @@
1
- import { type EdgeBounds } from "../utils/floating-position";
1
+ import { type EdgeBounds, type ElementBounds, type ElementSize } from "../utils/geometry";
2
2
  /** A type representing the coordinates every fitted position carries. */
3
3
  type PositionCoordinates = {
4
- /** The horizontal position, in the coordinate space of its producer. */
4
+ /** The horizontal position in the boundary's local CSS coordinate space. */
5
5
  left: number;
6
- /** The vertical position, in the coordinate space of its producer. */
6
+ /** The vertical position in the boundary's local CSS coordinate space. */
7
7
  top: number;
8
8
  };
9
9
  /** A type representing the measurements one repositioning pass receives. */
10
10
  export type AnchoredMeasurement = {
11
- /** The bounds of the element the content is anchored to. */
12
- triggerBounds: DOMRect;
13
- /** The bounds of the positioned content, once it is mounted. */
14
- panelBounds: DOMRect | undefined;
15
- /** The visible bounds of the boundary the content stays inside. */
11
+ /** The trigger bounds in the boundary's local CSS coordinate space. */
12
+ triggerBounds: ElementBounds;
13
+ /** The mounted content's layout size, including padding and borders. */
14
+ panelSize: ElementSize | undefined;
15
+ /** The visible boundary edges in its local CSS coordinate space. */
16
16
  visibleBounds: EdgeBounds;
17
17
  /**
18
18
  * Reads the shared spacing token resolved from the anchoring element.
19
19
  *
20
- * Resolution is deferred until a fit asks for it, so only fits that space
21
- * content away from their anchor pay for the style read.
20
+ * The token is resolved on its first use in an observer session and cached
21
+ * until the observers are reattached.
22
22
  */
23
23
  readSpacing: () => number;
24
24
  };
@@ -50,6 +50,8 @@ export type AnchoredPositionOptions<Position extends PositionCoordinates> = {
50
50
  * the supplied fit decides where the content actually belongs. Coordinates
51
51
  * are returned relative to the boundary's padding box, which is what absolute
52
52
  * positioning inside the boundary resolves against.
53
+ * Positive axis-aligned scaling of the boundary or its ancestors is included;
54
+ * rotated, skewed, or reflected coordinate systems are not supported.
53
55
  *
54
56
  * @param options - The positioned elements and the fit placing them.
55
57
  *
@@ -1,4 +1,5 @@
1
1
  import { type FloatingAlignment } from "./floating-alignment";
2
+ import type { EdgeBounds, ElementBounds, ElementSize } from "./geometry";
2
3
  /** A type representing a side available to anchored floating content. */
3
4
  export type FloatingPlacement = "bottom" | "left" | "right" | "top";
4
5
  /** A type representing the measured position of anchored floating content. */
@@ -12,51 +13,19 @@ export type FloatingPosition = {
12
13
  /** The boundary-relative vertical position. */
13
14
  top: number;
14
15
  };
15
- /**
16
- * A type representing the edges a rectangle is fitted against.
17
- *
18
- * Only edges are ever read, and describing them structurally keeps the
19
- * geometry independent of any realm: a `DOMRect` from any document
20
- * satisfies it, and a fitted result needs no constructor to build.
21
- */
22
- export type EdgeBounds = {
23
- /** The distance from the coordinate space's top to the lower edge. */
24
- bottom: number;
25
- /** The distance from the coordinate space's left to the leading edge. */
26
- left: number;
27
- /** The distance from the coordinate space's left to the trailing edge. */
28
- right: number;
29
- /** The distance from the coordinate space's top to the upper edge. */
30
- top: number;
31
- };
32
- /**
33
- * Narrows a boundary to the part of it the viewer can actually see.
34
- *
35
- * A boundary taller or wider than the viewport still reports its full size,
36
- * so fitting against it alone can place a panel in boundary space that is
37
- * scrolled out of view. Collision detection therefore runs against the
38
- * visible intersection, while coordinates stay relative to the boundary.
39
- *
40
- * @param boundaryBounds - The boundary bounds in viewport coordinates.
41
- * @param viewportWidth - The visible viewport width in CSS pixels.
42
- * @param viewportHeight - The visible viewport height in CSS pixels.
43
- *
44
- * @returns The visible region, or the boundary when nothing intersects.
45
- */
46
- export declare function getVisibleBounds(boundaryBounds: EdgeBounds, viewportWidth: number, viewportHeight: number): EdgeBounds;
47
16
  /**
48
17
  * Calculates collision-aware floating coordinates within a boundary.
49
18
  *
50
- * Every rectangle is expressed in the same coordinate space, so the returned
51
- * coordinates share that space and callers convert them once.
19
+ * Bounds and dimensions share the boundary's local CSS coordinate space,
20
+ * so the fitted position can be applied directly to the panel.
52
21
  *
53
22
  * @param placement - The preferred floating placement.
54
23
  * @param spacing - The minimum distance from triggers and boundary edges.
55
24
  * @param triggerBounds - The bounds of the anchoring trigger.
56
- * @param panelBounds - The measured bounds of the floating panel.
25
+ * @param panelSize - The panel's layout size, including padding and borders.
57
26
  * @param boundaryBounds - The bounds the panel must remain inside.
58
27
  * @param align - The preferred cross-axis alignment before clamping.
59
28
  *
60
29
  * @returns The fitted coordinates and resolved floating placement.
61
30
  */
62
- export declare function calculateFloatingPosition(placement: FloatingPlacement, spacing: number, triggerBounds: DOMRect, panelBounds: DOMRect, boundaryBounds: EdgeBounds, align?: FloatingAlignment): FloatingPosition;
31
+ export declare function calculateFloatingPosition(placement: FloatingPlacement, spacing: number, triggerBounds: ElementBounds, panelSize: ElementSize, boundaryBounds: EdgeBounds, align?: FloatingAlignment): FloatingPosition;
@@ -0,0 +1,45 @@
1
+ /** A type representing an element's border-box dimensions in CSS pixels. */
2
+ export type ElementSize = {
3
+ /** The horizontal extent of the border box. */
4
+ width: number;
5
+ /** The vertical extent of the border box. */
6
+ height: number;
7
+ };
8
+ /** A type representing the edges a rectangle is fitted against. */
9
+ export type EdgeBounds = {
10
+ /** The distance from the coordinate space's top to the lower edge. */
11
+ bottom: number;
12
+ /** The distance from the coordinate space's left to the leading edge. */
13
+ left: number;
14
+ /** The distance from the coordinate space's left to the trailing edge. */
15
+ right: number;
16
+ /** The distance from the coordinate space's top to the upper edge. */
17
+ top: number;
18
+ };
19
+ /** A type representing an element's bounds within one coordinate space. */
20
+ export type ElementBounds = EdgeBounds & ElementSize;
21
+ /**
22
+ * Measures an element's layout width and height.
23
+ *
24
+ * Dimensions include padding and borders, exclude CSS transforms, and retain
25
+ * fractional CSS pixels when available.
26
+ *
27
+ * @param element - The element whose layout dimensions are measured.
28
+ * @param viewportWindow - The window resolving the element's styles.
29
+ *
30
+ * @returns The border-box dimensions in local CSS pixels.
31
+ */
32
+ export declare function measureElementSize(element: HTMLElement, viewportWindow: Window): ElementSize;
33
+ /**
34
+ * Returns the part of a boundary inside the viewport.
35
+ *
36
+ * A fully off-screen boundary is returned unchanged so callers still receive
37
+ * a region when no visible intersection exists.
38
+ *
39
+ * @param boundaryBounds - The boundary bounds in viewport coordinates.
40
+ * @param viewportWidth - The visible viewport width in CSS pixels.
41
+ * @param viewportHeight - The visible viewport height in CSS pixels.
42
+ *
43
+ * @returns The visible region, or the boundary when nothing intersects.
44
+ */
45
+ export declare function calculateVisibleBounds(boundaryBounds: EdgeBounds, viewportWidth: number, viewportHeight: number): EdgeBounds;
@@ -1,5 +1,5 @@
1
1
  import { type FloatingAlignment } from "../../Portal/utils/floating-alignment";
2
- import type { EdgeBounds } from "../../Portal/utils/floating-position";
2
+ import type { EdgeBounds, ElementBounds, ElementSize } from "../../Portal/utils/geometry";
3
3
  /** A type representing the fitted position of a Select listbox. */
4
4
  export type ListboxPosition = {
5
5
  /** The boundary-relative horizontal position. */
@@ -14,17 +14,18 @@ export type ListboxPosition = {
14
14
  /**
15
15
  * Calculates the listbox position and height fitted inside a boundary.
16
16
  *
17
- * Every rectangle is expressed in the same coordinate space, so the returned
18
- * coordinates share that space and callers convert them once.
17
+ * Bounds and dimensions share the boundary's local CSS coordinate space,
18
+ * so the fitted position and size constraints can be applied directly.
19
19
  *
20
20
  * A boundary shorter than the readable minimum is deliberately exceeded,
21
21
  * because a listbox collapsed to a few pixels shows nothing at all.
22
22
  *
23
23
  * @param triggerBounds - The bounds of the trigger anchoring the listbox.
24
- * @param listboxBounds - The measured listbox bounds, when it is mounted.
24
+ * @param listboxSize - The listbox's layout size, including its padding
25
+ * and borders.
25
26
  * @param boundaryBounds - The bounds the listbox must remain inside.
26
27
  * @param align - The preferred horizontal alignment before clamping.
27
28
  *
28
29
  * @returns The fitted listbox coordinates and size constraints.
29
30
  */
30
- export declare function calculateListboxPosition(triggerBounds: DOMRect, listboxBounds: DOMRect | undefined, boundaryBounds: EdgeBounds, align?: FloatingAlignment): ListboxPosition;
31
+ export declare function calculateListboxPosition(triggerBounds: ElementBounds, listboxSize: ElementSize | undefined, boundaryBounds: EdgeBounds, align?: FloatingAlignment): ListboxPosition;
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./units-BEMW4BNr.cjs");exports.breakpoint=e.breakpoint;exports.cell=e.cell;exports.px=e.px;exports.space=e.space;exports.tokens=e.tokens;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./units-BUvyiHxw.cjs");exports.breakpoint=e.breakpoint;exports.cell=e.cell;exports.px=e.px;exports.space=e.space;exports.tokens=e.tokens;
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { b as e, c as p, p as o, s as t, t as c } from "./units-D4Waz9EO.js";
1
+ import { b as e, c as p, p as o, s as t, t as c } from "./units-CMj64udI.js";
2
2
  export {
3
3
  e as breakpoint,
4
4
  p as cell,