neatkit 0.14.1 → 0.15.0
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/Boundary.cjs +1 -1
- package/dist/Boundary.js +1 -1
- package/dist/Markdown.cjs +1 -1
- package/dist/Markdown.js +1 -1
- package/dist/Popover.cjs +1 -1
- package/dist/Popover.js +104 -101
- package/dist/Select.cjs +1 -1
- package/dist/Select.js +321 -310
- package/dist/Sidebar.cjs +1 -1
- package/dist/Sidebar.js +3 -3
- package/dist/{Table-BiRwd6PX.js → Table-Dvi-4XA7.js} +1 -1
- package/dist/{Table-DYO-bPlD.cjs → Table-GlG5aITK.cjs} +1 -1
- package/dist/Table.cjs +1 -1
- package/dist/Table.js +1 -1
- package/dist/Tooltip-CDOwCTig.js +229 -0
- package/dist/Tooltip-DrAZSmEv.cjs +1 -0
- package/dist/Tooltip.cjs +1 -1
- package/dist/Tooltip.js +1 -1
- package/dist/components/Popover/Popover.d.ts +17 -0
- package/dist/components/Popover/index.d.ts +1 -1
- package/dist/components/Portal/hooks/useFloatingPosition.d.ts +3 -1
- package/dist/components/Portal/utils/floating-alignment.d.ts +18 -0
- package/dist/components/Portal/utils/floating-position.d.ts +3 -1
- package/dist/components/Select/Select.d.ts +1 -1
- package/dist/components/Select/components/CustomSelect.d.ts +9 -0
- package/dist/components/Select/components/SelectListbox.d.ts +3 -0
- package/dist/components/Select/hooks/useSelectPosition.d.ts +3 -1
- package/dist/components/Select/index.d.ts +1 -1
- package/dist/components/Select/utils/listbox-position.d.ts +3 -1
- package/dist/components/Tooltip/Tooltip.d.ts +10 -0
- package/dist/components/Tooltip/index.d.ts +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/style.css +1 -1
- package/dist/tokens.d.ts +2 -8
- package/dist/{units-CpnLv2H4.cjs → units-BEMW4BNr.cjs} +1 -1
- package/dist/{units-Bx_CBIy8.js → units-D4Waz9EO.js} +1 -5
- package/dist/useAnchoredPosition-BEzN03Oi.cjs +1 -0
- package/dist/useAnchoredPosition-BIXEDNSo.js +119 -0
- package/dist/useFloatingPosition-8_GSpDjw.cjs +1 -0
- package/dist/useFloatingPosition-Cizey9UN.js +58 -0
- package/package.json +1 -1
- package/dist/Tooltip-CxcO3Vu-.cjs +0 -1
- package/dist/Tooltip-WwAWQ_Kq.js +0 -226
- package/dist/useAnchoredPosition-C0VS7hm6.js +0 -105
- package/dist/useAnchoredPosition-D7GRFzoX.cjs +0 -1
- package/dist/useFloatingPosition-DQgw-w_Z.cjs +0 -1
- package/dist/useFloatingPosition-MGoyautY.js +0 -57
package/dist/Boundary.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const c=require("react"),W=require("./effects-D98vUn6N.cjs"),v=require("./units-
|
|
1
|
+
"use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const c=require("react"),W=require("./effects-D98vUn6N.cjs"),v=require("./units-BEMW4BNr.cjs"),I=[{minWidth:v.breakpoint("extra-large"),marginPercent:32,preferredWidth:1200},{minWidth:v.breakpoint("large"),marginPercent:20,preferredWidth:1100},{minWidth:v.breakpoint("medium"),marginPercent:14,preferredWidth:v.breakpoint("medium")},{minWidth:v.breakpoint("small"),marginPercent:8,preferredWidth:650}],F=16;function L(e){for(const n of I)if(e>=n.minWidth)return n}function O(e,n){if(!Number.isFinite(e)||!Number.isFinite(n)||e<v.breakpoint("small")||n<=0)return;const t=L(e);if(!t)return;const r=e*t.marginPercent/100,o=e-r*2,l=Math.min(t.preferredWidth,e-F),u=Math.max(o,l);let a=Math.floor(u/n);if(a%2===0&&(a-=1),!(a<3))return Math.min((a-1)*n,e)}function V(e,n){if(typeof e=="function"){e(n);return}e&&(e.current=n)}function _(){const e=new Set;let n;return{publish(t){n!==t&&(n=t,e.forEach(r=>r()))},read(){return n},subscribe(t){return e.add(t),()=>{e.delete(t)}}}}function T(e){if(e.clientWidth===0)return;const n=window.getComputedStyle(e),t=(Number.parseFloat(n.paddingLeft)||0)+(Number.parseFloat(n.paddingRight)||0);return Math.max(e.clientWidth-t,0)}function z(e){const t=window.getComputedStyle(e).getPropertyValue("--nk-cell").trim().match(/^([+]?(?:\d+\.?\d*|\.\d+))px$/i);if(!t)return;const r=Number.parseFloat(t[1]);return Number.isFinite(r)&&r>0?r:void 0}function A(e,n){const t=c.useRef(null),r=c.useRef(null),o=c.useRef(void 0),l=c.useRef(null),[u,a]=c.useState(void 0),[y,p]=c.useState(null);l.current||(l.current=_());const h=l.current,m=c.useCallback(i=>{const s=T(i);if(h.publish(s),!n||s===void 0){if(o.current===void 0)return;o.current=void 0,a(void 0);return}const g=z(i),b=g===void 0?void 0:O(s,g);o.current!==b&&(o.current=b,a(b))},[h,n]),d=c.useCallback(i=>{var g;if((g=r.current)==null||g.disconnect(),r.current=null,typeof ResizeObserver>"u")return;const s=new ResizeObserver(()=>m(i));s.observe(i),r.current=s},[m]),f=c.useCallback(i=>{var s;(s=r.current)==null||s.disconnect(),r.current=null,t.current=i,p(i),V(e,i),!(!i||typeof window>"u")&&(m(i),d(i))},[d,e,m]);return W.useIsomorphicLayoutEffect(()=>{t.current&&m(t.current)}),c.useEffect(()=>(t.current&&d(t.current),()=>{var i;(i=r.current)==null||i.disconnect(),r.current=null}),[d]),{contentWidth:u,rootElement:y,rootReference:f,width:h}}const q=1,w=new WeakMap;function S(e,n){const t=n.painters[n.painters.length-1],r=t?t():n.original,{style:o}=e;o.backgroundColor!==r.backgroundColor&&(o.backgroundColor=r.backgroundColor),o.colorScheme!==r.colorScheme&&(o.colorScheme=r.colorScheme)}function x(e,n){let t=w.get(e);if(!t){const{style:r}=e.documentElement;t={original:{backgroundColor:r.backgroundColor,colorScheme:r.colorScheme},painters:[]},w.set(e,t)}t.painters.push(n),S(e.documentElement,t)}function k(e,n){const t=w.get(e);if(!t)return;const r=t.painters.lastIndexOf(n);r!==-1&&t.painters.splice(r,1),S(e.documentElement,t),t.painters.length===0&&w.delete(e)}function C(e){const n=w.get(e);n&&S(e.documentElement,n)}function D(e){const{nested:n,rootElement:t,width:r}=e,o=c.useRef(!1);W.useIsomorphicLayoutEffect(()=>{if(!t)return;const l=t,{ownerDocument:u}=l;if(!u.defaultView)return;const a=u.defaultView;function y(){return l.clientWidth===0?!1:Math.abs(l.clientWidth-u.documentElement.clientWidth)<=q}function p(){const f=a.getComputedStyle(l);return{backgroundColor:f.backgroundColor,colorScheme:f.colorScheme}}function h(){const f=!n&&y();if(f===o.current){f&&C(u);return}f?x(u,p):k(u,p),o.current=f}h();const m=r.subscribe(h),d=typeof a.matchMedia=="function"?a.matchMedia("(prefers-color-scheme: dark)"):null;return d==null||d.addEventListener("change",h),()=>{m(),d==null||d.removeEventListener("change",h),o.current&&(k(u,p),o.current=!1)}},[n,t,r]),W.useIsomorphicLayoutEffect(()=>{!o.current||!t||C(t.ownerDocument)})}const j=c.forwardRef(function(n,t){const{as:r,children:o,className:l,style:u,theme:a="auto",accent:y,decoration:p="grid",width:h="narrow",height:m="content",spacing:d="standard",...f}=n,{contentWidth:i,rootElement:s,rootReference:g,width:b}=A(t,h==="narrow"),M=W.useBoundary();D({nested:M!==void 0,rootElement:s,width:b});const E=c.useMemo(()=>({boundaryElement:s,portalElement:s,width:b}),[s,b]),P=r??"div",R=y!==void 0?{...u,"--nk-accent":y}:u,B=i===void 0?void 0:{width:`${i}px`},N=c.createElement(P,{...f,ref:g,className:["nk-boundary",l].filter(Boolean).join(" "),"data-theme":a,"data-decoration":p,"data-width":h,"data-height":m,"data-spacing":d,style:R},c.createElement("div",{className:"nk-boundary__content",style:B},o));return c.createElement(W.BoundaryContext.Provider,{value:E},N)});exports.default=j;
|
package/dist/Boundary.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useRef as v, useState as M, useCallback as w, useEffect as O, forwardRef as z, useMemo as L, createElement as C } from "react";
|
|
3
3
|
import { a as S, u as T, B as _ } from "./effects-DGbA6Q2O.js";
|
|
4
|
-
import { b } from "./units-
|
|
4
|
+
import { b } from "./units-D4Waz9EO.js";
|
|
5
5
|
const x = [
|
|
6
6
|
{
|
|
7
7
|
minWidth: b("extra-large"),
|
package/dist/Markdown.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const d=require("react/jsx-runtime"),M=require("react"),G=require("react-markdown"),W=require("rehype-raw"),H=require("rehype-sanitize"),V=require("rehype-slug"),J=require("remark-gfm"),Y=require("./Alert-LJDkNUqH.cjs"),X=require("./Code-f0GWveGp.cjs"),Q=require("./Divider-C7XGlr26.cjs"),_=require("./Table-DYO-bPlD.cjs"),k=require("./Text-DWYlIcPj.cjs"),Z={bash:"Shell",c:"C","c++":"C++",cpp:"C++",css:"CSS",go:"Go",golang:"Go",html:"HTML",js:"JavaScript",javascript:"JavaScript",jsx:"JavaScript",json:"JSON",markdown:"Markdown",md:"Markdown",py:"Python",python:"Python",rb:"Ruby",ruby:"Ruby",rs:"Rust",rust:"Rust",sh:"Shell",shell:"Shell",sql:"SQL",ts:"TypeScript",tsx:"TypeScript",typescript:"TypeScript",xml:"HTML",yaml:"YAML",yml:"YAML"};function ee(e){var a;const o=(a=e==null?void 0:e.split(/\s+/).find(f=>f.startsWith("language-")))==null?void 0:a.slice(9).toLowerCase();return o?Z[o]:void 0}const A="md-",B=["a","blockquote","br","code","del","em","h1","h2","h3","h4","h5","h6","hr","img","input","li","ol","p","picture","pre","section","source","strong","sup","table","tbody","td","th","thead","tr","ul"],ne={...H.defaultSchema,allowComments:!1,allowDoctypes:!1,ancestors:{...H.defaultSchema.ancestors,source:["picture"]},attributes:{"*":["dir","id","lang","title"],a:["ariaDescribedBy","ariaLabel","dataFootnoteBackref","dataFootnoteRef",["className","data-footnote-backref"],"href","hrefLang"],code:[["className",/^language-[\w+-]+$/]],h2:[["className","sr-only"]],img:["alt","height","src","srcSet","width"],input:["checked",["disabled",!0],"readOnly",["type","checkbox"]],li:[["className","task-list-item"]],ol:["start",["className","contains-task-list"]],section:["dataFootnotes",["className","footnotes"]],source:["media","srcSet","type"],td:["align","colSpan","rowSpan"],th:["align","colSpan","rowSpan","scope"],ul:[["className","contains-task-list"]]},clobber:H.defaultSchema.clobber,clobberPrefix:A,strip:["script","style"],tagNames:[...B]};function re(e,o){const a=o.flags.replace(/[gy]/g,"");return new RegExp(o.source,a).test(e)}function te(e){if(!e)return null;try{const o=new URL(e);return o.protocol!=="http:"&&o.protocol!=="https:"||o.username||o.password?null:o}catch{return null}}function R(e,o,a){if(e.includes("\\")||/[\u0000-\u0020\u007f]/.test(e)||o===void 0)return;const f=/^[a-z][a-z\d+.-]*:/i.test(e),m=e.startsWith("//");if(o==="*")return!f&&!m||/^https?:/i.test(e)||m?e:void 0;const s=Array.isArray(o)?o:[o],t=te(a);try{let n=null;if(f?n=new URL(e):t&&(n=new URL(e,t)),!n||n.protocol!=="http:"&&n.protocol!=="https:"||n.username||n.password)return;const r=n.href;return s.some(c=>re(r,c))?r:void 0}catch{return}}function v(e,o,a){if(!e)return;const m=e.split(",").map(s=>{const t=s.trim().split(/\s+/),[n,r]=t,u=r===void 0||/^(?:\d+w|(?:\d+(?:\.\d+)?|\.\d+)x)$/.test(r);if(t.length>2||!u||n===void 0||n.length===0)return null;const c=R(n,o,a);return c?`${c}${r?` ${r}`:""}`:null});if(!m.some(s=>s===null))return m.join(", ")}function oe(){function e(o){o.children=o.children.filter(a=>a.type!=="element"||a.tagName!=="input"||a.position===void 0),o.children.forEach(a=>{a.type==="element"&&e(a)})}return o=>e(o)}function S(e,o){return Array.isArray(e)?e.map(a=>typeof a=="string"?`${o}${a}`:a):typeof e=="string"?e.split(/\s+/).map(a=>`${o}${a}`).join(" "):e}function se(e){const{clobberPrefix:o,prefix:a}=e;function f(m){if(m.type==="element"){const{properties:s}=m;s.id=S(s.id,a),s.name=S(s.name,a),s.ariaDescribedBy=S(s.ariaDescribedBy,a),s.ariaLabelledBy=S(s.ariaLabelledBy,a),typeof s.href=="string"&&s.href.startsWith("#")&&(s.href=`#${o}${a}${s.href.slice(1)}`)}"children"in m&&m.children.forEach(f)}return m=>f(m)}function C(e){return e==="center"||e==="left"||e==="right"?e:void 0}function E(e){return e.type==="text"?e.value:"children"in e?e.children.map(E).join(""):""}function T(e){return typeof e=="string"?e:void 0}function ie(e){if(!e)return null;const o=e.children.find(n=>n.type==="element"&&n.tagName==="code");if(!o||e.children.some(n=>n!==o&&(n.type!=="text"||n.value.trim().length>0)))return null;const f=o.properties.className;let m;Array.isArray(f)?m=f.join(" "):typeof f=="string"&&(m=f);const s=o.children.map(E).join("").replace(/\n$/,"");return{codeProps:{className:m,dir:T(o.properties.dir),id:T(o.properties.id),lang:T(o.properties.lang),title:T(o.properties.title)},content:s}}function ae(e,o,a,f,m){return{a:function(t){const{children:n,className:r,dangerouslySetInnerHTML:u,node:c,...i}=t;return d.jsx("a",{...i,className:["nk-markdown__link",r].filter(Boolean).join(" "),onClick:m,children:n})},blockquote:function(t){const{children:n,dangerouslySetInnerHTML:r,node:u,...c}=t;return d.jsx("blockquote",{...c,className:"nk-markdown__blockquote",children:n})},code:function(t){const{children:n,className:r,dangerouslySetInnerHTML:u,node:c,...i}=t;return d.jsx("code",{...i,className:["nk-markdown__inline-code",r].filter(Boolean).join(" "),children:n})},h1:function(t){const{children:n,className:r,dangerouslySetInnerHTML:u,node:c,ref:i,...l}=t;return d.jsx(k.Text,{...l,as:"h1",className:["nk-markdown__heading",r].filter(Boolean).join(" "),size:"heading",weight:"semibold",children:n})},h2:function(t){const{children:n,className:r,dangerouslySetInnerHTML:u,node:c,ref:i,...l}=t;return d.jsx(k.Text,{...l,as:"h2",className:["nk-markdown__heading",r!=null&&r.split(/\s+/).includes("sr-only")?"nk-markdown__visually-hidden":void 0].filter(Boolean).join(" "),size:"title",weight:"semibold",children:n})},h3:function(t){const{children:n,className:r,dangerouslySetInnerHTML:u,node:c,ref:i,...l}=t;return d.jsx(k.Text,{...l,as:"h3",className:["nk-markdown__heading",r].filter(Boolean).join(" "),size:"subtitle",weight:"semibold",children:n})},h4:function(t){const{children:n,className:r,dangerouslySetInnerHTML:u,node:c,ref:i,...l}=t;return d.jsx(k.Text,{...l,as:"h4",className:["nk-markdown__heading",r].filter(Boolean).join(" "),weight:"semibold",children:n})},h5:function(t){const{children:n,className:r,dangerouslySetInnerHTML:u,node:c,ref:i,...l}=t;return d.jsx(k.Text,{...l,as:"h5",className:["nk-markdown__heading",r].filter(Boolean).join(" "),weight:"semibold",children:n})},h6:function(t){const{children:n,className:r,dangerouslySetInnerHTML:u,node:c,ref:i,...l}=t;return d.jsx(k.Text,{...l,as:"h6",className:["nk-markdown__heading",r].filter(Boolean).join(" "),weight:"medium",children:n})},hr:function(t){const{dangerouslySetInnerHTML:n,node:r,...u}=t;return d.jsx(Q.Divider,{...u})},img:function(t){const{alt:n,className:r,dangerouslySetInnerHTML:u,node:c,src:i,srcSet:l,...b}=t,x=R(typeof i=="string"?i:"",e,o),L=v(l,e,o);return x?d.jsx("img",{...b,alt:n??"",className:["nk-markdown__image",r].filter(Boolean).join(" "),decoding:"async",loading:"lazy",src:x,srcSet:L}):n?d.jsx("span",{className:"nk-markdown__blocked-image",children:n}):null},input:function(t){const{checked:n,className:r,dangerouslySetInnerHTML:u,node:c,...i}=t;return d.jsxs(d.Fragment,{children:[d.jsx("input",{...i,"aria-label":n?"Completed task":"Incomplete task",checked:n,className:["nk-markdown__task-control","nk-markdown__visually-hidden",r].filter(Boolean).join(" "),disabled:!0,readOnly:!0,type:"checkbox"}),d.jsx("span",{"aria-hidden":"true",className:"nk-markdown__task",children:n?"☒":"☐"})]})},li:function(t){const{children:n,className:r,dangerouslySetInnerHTML:u,node:c,...i}=t,l=(r==null?void 0:r.split(/\s+/).includes("task-list-item"))??!1;return d.jsx("li",{...i,className:["nk-markdown__list-item",l?"nk-markdown__list-item--task":void 0].filter(Boolean).join(" "),children:n})},ol:function(t){const{children:n,className:r,dangerouslySetInnerHTML:u,node:c,...i}=t,l=(r==null?void 0:r.split(/\s+/).includes("contains-task-list"))??!1;return d.jsx("ol",{...i,className:["nk-markdown__list","nk-markdown__list--ordered",l?"nk-markdown__list--tasks":void 0].filter(Boolean).join(" "),children:n})},p:function(t){const{children:n,className:r,dangerouslySetInnerHTML:u,node:c,ref:i,...l}=t;return d.jsx(k.Text,{...l,className:["nk-markdown__paragraph",r].filter(Boolean).join(" "),children:n})},picture:function(t){const{children:n,className:r,dangerouslySetInnerHTML:u,node:c,...i}=t;return d.jsx("picture",{...i,className:["nk-markdown__picture",r].filter(Boolean).join(" "),children:n})},pre:function(t){const{children:n,dangerouslySetInnerHTML:r,node:u,ref:c,...i}=t,l=ie(u);return l?d.jsx(X.Code,{code:l.content,codeProps:l.codeProps,language:ee(l.codeProps.className),maxHighlightLength:a,maxLineCount:f,preProps:i}):d.jsx("pre",{...i,children:n})},source:function(t){const{children:n,dangerouslySetInnerHTML:r,node:u,srcSet:c,...i}=t,l=v(c,e,o);return l?d.jsx("source",{...i,srcSet:l}):null},table:function(t){const{children:n,dangerouslySetInnerHTML:r,frame:u,node:c,...i}=t;return d.jsx(_.Table,{...i,children:n})},tbody:function(t){const{children:n,dangerouslySetInnerHTML:r,node:u,...c}=t;return d.jsx(_.Table.Body,{...c,children:n})},td:function(t){const{align:n,children:r,dangerouslySetInnerHTML:u,node:c,style:i,...l}=t;return d.jsx(_.Table.Cell,{...l,align:C((i==null?void 0:i.textAlign)??n),children:r})},th:function(t){const{align:n,children:r,dangerouslySetInnerHTML:u,node:c,style:i,...l}=t;return d.jsx(_.Table.HeaderCell,{...l,align:C((i==null?void 0:i.textAlign)??n),children:r})},thead:function(t){const{children:n,dangerouslySetInnerHTML:r,node:u,...c}=t;return d.jsx(_.Table.Head,{...c,children:n})},tr:function(t){const{children:n,dangerouslySetInnerHTML:r,node:u,onClick:c,...i}=t;return d.jsx(_.Table.Row,{...i,children:n})},ul:function(t){const{children:n,className:r,dangerouslySetInnerHTML:u,node:c,...i}=t,l=(r==null?void 0:r.split(/\s+/).includes("contains-task-list"))??!1;return d.jsx("ul",{...i,className:["nk-markdown__list","nk-markdown__list--unordered",l?"nk-markdown__list--tasks":void 0].filter(Boolean).join(" "),children:n})}}}const le={clobberPrefix:""},ce=25e3,de="Markdown content exceeds the rendering limit.";function ue(e,o){if(!e.startsWith("#")||e.length===1)return null;let a=e.slice(1);try{a=decodeURIComponent(a)}catch{return null}return o.getElementById(a)}function me(e){const o=e.tabIndex<0&&!e.hasAttribute("tabindex");if(o&&e.setAttribute("tabindex","-1"),e.focus({preventScroll:!0}),!!o){if(e.ownerDocument.activeElement!==e){e.removeAttribute("tabindex");return}e.addEventListener("blur",()=>e.removeAttribute("tabindex"),{once:!0})}}function fe(e,o){const a=e,f=new a.HashChangeEvent("hashchange",{newURL:e.location.href,oldURL:o});e.dispatchEvent(f)}function he(e){return e===null?null:Number.isFinite(e)?Math.max(0,Math.floor(e)):0}const pe=M.forwardRef(function(o,a){const{allowedImageSources:f,anchorPrefix:m="",className:s,content:t,dangerouslySetInnerHTML:n,imageBaseUrl:r,maxCodeHighlightLength:u,maxCodeLineCount:c,maxContentLength:i=ce,rehypePlugins:l,remarkPlugins:b,scrollOffset:g=128,style:x,...L}=o,P=he(i),D=P!==null&&t.length>P,j=M.useCallback(h=>{var N;if(h.defaultPrevented||h.button!==0||h.metaKey||h.ctrlKey||h.shiftKey||h.altKey)return;const y=h.currentTarget.getAttribute("href");if(!y)return;const w=ue(y,h.currentTarget.ownerDocument);if(!w||typeof w.scrollIntoView!="function")return;const p=w.ownerDocument.defaultView;if(!p)return;h.preventDefault();const z=((N=p.matchMedia)==null?void 0:N.call(p,"(prefers-reduced-motion: reduce)").matches)??!1,F=g===null||z?"auto":"smooth",U=p.location.href,K=p.location.hash!==y;p.location.hash!==y&&p.history.pushState(p.history.state,"",y),me(w),w.scrollIntoView({behavior:F,block:"start"}),K&&fe(p,U)},[g]),O=M.useMemo(()=>ae(f,r,u,c,j),[f,j,r,u,c]),q=M.useMemo(()=>[J,...b??[]],[b]),$=M.useMemo(()=>[W,...l??[],oe,V,[se,{clobberPrefix:A,prefix:m}],[H,ne]],[m,l]),I={...x};if(g!==null){const h=Number.isFinite(g)?Math.max(0,g):0;I["--nk-markdown-scroll-offset"]=`${h}px`}return d.jsx("div",{...L,ref:a,className:["nk-markdown",s].filter(Boolean).join(" "),style:I,children:D?d.jsx(Y.Alert,{role:"alert",tone:"warning",children:de}):d.jsx(G,{allowedElements:B,components:O,rehypePlugins:$,remarkPlugins:q,remarkRehypeOptions:le,children:t})})});exports.default=pe;
|
|
1
|
+
"use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const d=require("react/jsx-runtime"),M=require("react"),G=require("react-markdown"),W=require("rehype-raw"),H=require("rehype-sanitize"),V=require("rehype-slug"),J=require("remark-gfm"),Y=require("./Alert-LJDkNUqH.cjs"),X=require("./Code-f0GWveGp.cjs"),Q=require("./Divider-C7XGlr26.cjs"),_=require("./Table-GlG5aITK.cjs"),k=require("./Text-DWYlIcPj.cjs"),Z={bash:"Shell",c:"C","c++":"C++",cpp:"C++",css:"CSS",go:"Go",golang:"Go",html:"HTML",js:"JavaScript",javascript:"JavaScript",jsx:"JavaScript",json:"JSON",markdown:"Markdown",md:"Markdown",py:"Python",python:"Python",rb:"Ruby",ruby:"Ruby",rs:"Rust",rust:"Rust",sh:"Shell",shell:"Shell",sql:"SQL",ts:"TypeScript",tsx:"TypeScript",typescript:"TypeScript",xml:"HTML",yaml:"YAML",yml:"YAML"};function ee(e){var a;const o=(a=e==null?void 0:e.split(/\s+/).find(f=>f.startsWith("language-")))==null?void 0:a.slice(9).toLowerCase();return o?Z[o]:void 0}const A="md-",B=["a","blockquote","br","code","del","em","h1","h2","h3","h4","h5","h6","hr","img","input","li","ol","p","picture","pre","section","source","strong","sup","table","tbody","td","th","thead","tr","ul"],ne={...H.defaultSchema,allowComments:!1,allowDoctypes:!1,ancestors:{...H.defaultSchema.ancestors,source:["picture"]},attributes:{"*":["dir","id","lang","title"],a:["ariaDescribedBy","ariaLabel","dataFootnoteBackref","dataFootnoteRef",["className","data-footnote-backref"],"href","hrefLang"],code:[["className",/^language-[\w+-]+$/]],h2:[["className","sr-only"]],img:["alt","height","src","srcSet","width"],input:["checked",["disabled",!0],"readOnly",["type","checkbox"]],li:[["className","task-list-item"]],ol:["start",["className","contains-task-list"]],section:["dataFootnotes",["className","footnotes"]],source:["media","srcSet","type"],td:["align","colSpan","rowSpan"],th:["align","colSpan","rowSpan","scope"],ul:[["className","contains-task-list"]]},clobber:H.defaultSchema.clobber,clobberPrefix:A,strip:["script","style"],tagNames:[...B]};function re(e,o){const a=o.flags.replace(/[gy]/g,"");return new RegExp(o.source,a).test(e)}function te(e){if(!e)return null;try{const o=new URL(e);return o.protocol!=="http:"&&o.protocol!=="https:"||o.username||o.password?null:o}catch{return null}}function R(e,o,a){if(e.includes("\\")||/[\u0000-\u0020\u007f]/.test(e)||o===void 0)return;const f=/^[a-z][a-z\d+.-]*:/i.test(e),m=e.startsWith("//");if(o==="*")return!f&&!m||/^https?:/i.test(e)||m?e:void 0;const s=Array.isArray(o)?o:[o],t=te(a);try{let n=null;if(f?n=new URL(e):t&&(n=new URL(e,t)),!n||n.protocol!=="http:"&&n.protocol!=="https:"||n.username||n.password)return;const r=n.href;return s.some(c=>re(r,c))?r:void 0}catch{return}}function v(e,o,a){if(!e)return;const m=e.split(",").map(s=>{const t=s.trim().split(/\s+/),[n,r]=t,u=r===void 0||/^(?:\d+w|(?:\d+(?:\.\d+)?|\.\d+)x)$/.test(r);if(t.length>2||!u||n===void 0||n.length===0)return null;const c=R(n,o,a);return c?`${c}${r?` ${r}`:""}`:null});if(!m.some(s=>s===null))return m.join(", ")}function oe(){function e(o){o.children=o.children.filter(a=>a.type!=="element"||a.tagName!=="input"||a.position===void 0),o.children.forEach(a=>{a.type==="element"&&e(a)})}return o=>e(o)}function S(e,o){return Array.isArray(e)?e.map(a=>typeof a=="string"?`${o}${a}`:a):typeof e=="string"?e.split(/\s+/).map(a=>`${o}${a}`).join(" "):e}function se(e){const{clobberPrefix:o,prefix:a}=e;function f(m){if(m.type==="element"){const{properties:s}=m;s.id=S(s.id,a),s.name=S(s.name,a),s.ariaDescribedBy=S(s.ariaDescribedBy,a),s.ariaLabelledBy=S(s.ariaLabelledBy,a),typeof s.href=="string"&&s.href.startsWith("#")&&(s.href=`#${o}${a}${s.href.slice(1)}`)}"children"in m&&m.children.forEach(f)}return m=>f(m)}function C(e){return e==="center"||e==="left"||e==="right"?e:void 0}function E(e){return e.type==="text"?e.value:"children"in e?e.children.map(E).join(""):""}function T(e){return typeof e=="string"?e:void 0}function ie(e){if(!e)return null;const o=e.children.find(n=>n.type==="element"&&n.tagName==="code");if(!o||e.children.some(n=>n!==o&&(n.type!=="text"||n.value.trim().length>0)))return null;const f=o.properties.className;let m;Array.isArray(f)?m=f.join(" "):typeof f=="string"&&(m=f);const s=o.children.map(E).join("").replace(/\n$/,"");return{codeProps:{className:m,dir:T(o.properties.dir),id:T(o.properties.id),lang:T(o.properties.lang),title:T(o.properties.title)},content:s}}function ae(e,o,a,f,m){return{a:function(t){const{children:n,className:r,dangerouslySetInnerHTML:u,node:c,...i}=t;return d.jsx("a",{...i,className:["nk-markdown__link",r].filter(Boolean).join(" "),onClick:m,children:n})},blockquote:function(t){const{children:n,dangerouslySetInnerHTML:r,node:u,...c}=t;return d.jsx("blockquote",{...c,className:"nk-markdown__blockquote",children:n})},code:function(t){const{children:n,className:r,dangerouslySetInnerHTML:u,node:c,...i}=t;return d.jsx("code",{...i,className:["nk-markdown__inline-code",r].filter(Boolean).join(" "),children:n})},h1:function(t){const{children:n,className:r,dangerouslySetInnerHTML:u,node:c,ref:i,...l}=t;return d.jsx(k.Text,{...l,as:"h1",className:["nk-markdown__heading",r].filter(Boolean).join(" "),size:"heading",weight:"semibold",children:n})},h2:function(t){const{children:n,className:r,dangerouslySetInnerHTML:u,node:c,ref:i,...l}=t;return d.jsx(k.Text,{...l,as:"h2",className:["nk-markdown__heading",r!=null&&r.split(/\s+/).includes("sr-only")?"nk-markdown__visually-hidden":void 0].filter(Boolean).join(" "),size:"title",weight:"semibold",children:n})},h3:function(t){const{children:n,className:r,dangerouslySetInnerHTML:u,node:c,ref:i,...l}=t;return d.jsx(k.Text,{...l,as:"h3",className:["nk-markdown__heading",r].filter(Boolean).join(" "),size:"subtitle",weight:"semibold",children:n})},h4:function(t){const{children:n,className:r,dangerouslySetInnerHTML:u,node:c,ref:i,...l}=t;return d.jsx(k.Text,{...l,as:"h4",className:["nk-markdown__heading",r].filter(Boolean).join(" "),weight:"semibold",children:n})},h5:function(t){const{children:n,className:r,dangerouslySetInnerHTML:u,node:c,ref:i,...l}=t;return d.jsx(k.Text,{...l,as:"h5",className:["nk-markdown__heading",r].filter(Boolean).join(" "),weight:"semibold",children:n})},h6:function(t){const{children:n,className:r,dangerouslySetInnerHTML:u,node:c,ref:i,...l}=t;return d.jsx(k.Text,{...l,as:"h6",className:["nk-markdown__heading",r].filter(Boolean).join(" "),weight:"medium",children:n})},hr:function(t){const{dangerouslySetInnerHTML:n,node:r,...u}=t;return d.jsx(Q.Divider,{...u})},img:function(t){const{alt:n,className:r,dangerouslySetInnerHTML:u,node:c,src:i,srcSet:l,...b}=t,x=R(typeof i=="string"?i:"",e,o),L=v(l,e,o);return x?d.jsx("img",{...b,alt:n??"",className:["nk-markdown__image",r].filter(Boolean).join(" "),decoding:"async",loading:"lazy",src:x,srcSet:L}):n?d.jsx("span",{className:"nk-markdown__blocked-image",children:n}):null},input:function(t){const{checked:n,className:r,dangerouslySetInnerHTML:u,node:c,...i}=t;return d.jsxs(d.Fragment,{children:[d.jsx("input",{...i,"aria-label":n?"Completed task":"Incomplete task",checked:n,className:["nk-markdown__task-control","nk-markdown__visually-hidden",r].filter(Boolean).join(" "),disabled:!0,readOnly:!0,type:"checkbox"}),d.jsx("span",{"aria-hidden":"true",className:"nk-markdown__task",children:n?"☒":"☐"})]})},li:function(t){const{children:n,className:r,dangerouslySetInnerHTML:u,node:c,...i}=t,l=(r==null?void 0:r.split(/\s+/).includes("task-list-item"))??!1;return d.jsx("li",{...i,className:["nk-markdown__list-item",l?"nk-markdown__list-item--task":void 0].filter(Boolean).join(" "),children:n})},ol:function(t){const{children:n,className:r,dangerouslySetInnerHTML:u,node:c,...i}=t,l=(r==null?void 0:r.split(/\s+/).includes("contains-task-list"))??!1;return d.jsx("ol",{...i,className:["nk-markdown__list","nk-markdown__list--ordered",l?"nk-markdown__list--tasks":void 0].filter(Boolean).join(" "),children:n})},p:function(t){const{children:n,className:r,dangerouslySetInnerHTML:u,node:c,ref:i,...l}=t;return d.jsx(k.Text,{...l,className:["nk-markdown__paragraph",r].filter(Boolean).join(" "),children:n})},picture:function(t){const{children:n,className:r,dangerouslySetInnerHTML:u,node:c,...i}=t;return d.jsx("picture",{...i,className:["nk-markdown__picture",r].filter(Boolean).join(" "),children:n})},pre:function(t){const{children:n,dangerouslySetInnerHTML:r,node:u,ref:c,...i}=t,l=ie(u);return l?d.jsx(X.Code,{code:l.content,codeProps:l.codeProps,language:ee(l.codeProps.className),maxHighlightLength:a,maxLineCount:f,preProps:i}):d.jsx("pre",{...i,children:n})},source:function(t){const{children:n,dangerouslySetInnerHTML:r,node:u,srcSet:c,...i}=t,l=v(c,e,o);return l?d.jsx("source",{...i,srcSet:l}):null},table:function(t){const{children:n,dangerouslySetInnerHTML:r,frame:u,node:c,...i}=t;return d.jsx(_.Table,{...i,children:n})},tbody:function(t){const{children:n,dangerouslySetInnerHTML:r,node:u,...c}=t;return d.jsx(_.Table.Body,{...c,children:n})},td:function(t){const{align:n,children:r,dangerouslySetInnerHTML:u,node:c,style:i,...l}=t;return d.jsx(_.Table.Cell,{...l,align:C((i==null?void 0:i.textAlign)??n),children:r})},th:function(t){const{align:n,children:r,dangerouslySetInnerHTML:u,node:c,style:i,...l}=t;return d.jsx(_.Table.HeaderCell,{...l,align:C((i==null?void 0:i.textAlign)??n),children:r})},thead:function(t){const{children:n,dangerouslySetInnerHTML:r,node:u,...c}=t;return d.jsx(_.Table.Head,{...c,children:n})},tr:function(t){const{children:n,dangerouslySetInnerHTML:r,node:u,onClick:c,...i}=t;return d.jsx(_.Table.Row,{...i,children:n})},ul:function(t){const{children:n,className:r,dangerouslySetInnerHTML:u,node:c,...i}=t,l=(r==null?void 0:r.split(/\s+/).includes("contains-task-list"))??!1;return d.jsx("ul",{...i,className:["nk-markdown__list","nk-markdown__list--unordered",l?"nk-markdown__list--tasks":void 0].filter(Boolean).join(" "),children:n})}}}const le={clobberPrefix:""},ce=25e3,de="Markdown content exceeds the rendering limit.";function ue(e,o){if(!e.startsWith("#")||e.length===1)return null;let a=e.slice(1);try{a=decodeURIComponent(a)}catch{return null}return o.getElementById(a)}function me(e){const o=e.tabIndex<0&&!e.hasAttribute("tabindex");if(o&&e.setAttribute("tabindex","-1"),e.focus({preventScroll:!0}),!!o){if(e.ownerDocument.activeElement!==e){e.removeAttribute("tabindex");return}e.addEventListener("blur",()=>e.removeAttribute("tabindex"),{once:!0})}}function fe(e,o){const a=e,f=new a.HashChangeEvent("hashchange",{newURL:e.location.href,oldURL:o});e.dispatchEvent(f)}function he(e){return e===null?null:Number.isFinite(e)?Math.max(0,Math.floor(e)):0}const pe=M.forwardRef(function(o,a){const{allowedImageSources:f,anchorPrefix:m="",className:s,content:t,dangerouslySetInnerHTML:n,imageBaseUrl:r,maxCodeHighlightLength:u,maxCodeLineCount:c,maxContentLength:i=ce,rehypePlugins:l,remarkPlugins:b,scrollOffset:g=128,style:x,...L}=o,P=he(i),D=P!==null&&t.length>P,j=M.useCallback(h=>{var N;if(h.defaultPrevented||h.button!==0||h.metaKey||h.ctrlKey||h.shiftKey||h.altKey)return;const y=h.currentTarget.getAttribute("href");if(!y)return;const w=ue(y,h.currentTarget.ownerDocument);if(!w||typeof w.scrollIntoView!="function")return;const p=w.ownerDocument.defaultView;if(!p)return;h.preventDefault();const z=((N=p.matchMedia)==null?void 0:N.call(p,"(prefers-reduced-motion: reduce)").matches)??!1,F=g===null||z?"auto":"smooth",U=p.location.href,K=p.location.hash!==y;p.location.hash!==y&&p.history.pushState(p.history.state,"",y),me(w),w.scrollIntoView({behavior:F,block:"start"}),K&&fe(p,U)},[g]),O=M.useMemo(()=>ae(f,r,u,c,j),[f,j,r,u,c]),q=M.useMemo(()=>[J,...b??[]],[b]),$=M.useMemo(()=>[W,...l??[],oe,V,[se,{clobberPrefix:A,prefix:m}],[H,ne]],[m,l]),I={...x};if(g!==null){const h=Number.isFinite(g)?Math.max(0,g):0;I["--nk-markdown-scroll-offset"]=`${h}px`}return d.jsx("div",{...L,ref:a,className:["nk-markdown",s].filter(Boolean).join(" "),style:I,children:D?d.jsx(Y.Alert,{role:"alert",tone:"warning",children:de}):d.jsx(G,{allowedElements:B,components:O,rehypePlugins:$,remarkPlugins:q,remarkRehypeOptions:le,children:t})})});exports.default=pe;
|
package/dist/Markdown.js
CHANGED
|
@@ -9,7 +9,7 @@ import ee from "remark-gfm";
|
|
|
9
9
|
import { A as ne } from "./Alert-DQ5CCE0N.js";
|
|
10
10
|
import { C as re } from "./Code-pROJjsiG.js";
|
|
11
11
|
import { D as te } from "./Divider-DZgpYpr-.js";
|
|
12
|
-
import { T as _ } from "./Table-
|
|
12
|
+
import { T as _ } from "./Table-Dvi-4XA7.js";
|
|
13
13
|
import { T as k } from "./Text-rN6iDo0V.js";
|
|
14
14
|
const oe = {
|
|
15
15
|
bash: "Shell",
|
package/dist/Popover.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const l=require("react/jsx-runtime"),r=require("react"),
|
|
1
|
+
"use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const l=require("react/jsx-runtime"),r=require("react"),je=require("./aria-DM-xYEHQ.cjs"),se=require("./effects-D98vUn6N.cjs"),B=require("./reference-C2guRuR0.cjs"),ne=require("./useFloatingPosition-8_GSpDjw.cjs"),h=require("./usePresence-Dm0mls5p.cjs"),De=require("./useFocusTrap-CrMcAu8s.cjs"),Le=require("./Surface-BttJYSDt.cjs");function Ne(n){const{inert:i,panelElement:c}=n;return se.useIsomorphicLayoutEffect(()=>{c&&(c.inert=i)},[i,c]),null}function _e(n,i,c){i.current=n,B.assignElementReference(c,n)}function Me(n,i,c){i.current=n,B.assignElementReference(c,n)}function Be(n){const i=n.tagName.toLowerCase();return n.getAttribute("role")==="button"&&i!=="button"?!1:["button","input","select","summary","textarea"].includes(i)?!0:i==="a"&&n.hasAttribute("href")}function ze(n){return n==="grid"||n==="listbox"||n==="menu"||n==="tree"?n:"dialog"}const Ae=r.forwardRef(function(i,c){const{"aria-label":z,"aria-labelledby":oe,align:A="center",autoFocus:w=!0,children:ae,className:ie,closeOnEscape:ce=!0,closeOnOutsideInteraction:ue=!0,defaultOpen:le=!1,disabled:x=!1,initialFocusReference:E,onEscapeKeyDown:de,onOpenChange:k,onPointerDownOutside:I,open:H,placement:K="bottom",restoreFocus:j=!0,role:V="dialog",style:$,tabIndex:fe,trapFocus:b=!1,trigger:d,...pe}=i;if(d.type===r.Fragment)throw new Error("Popover requires a single non-Fragment trigger");const U=r.useId(),ge=r.useContext(h.FocusScopeContext),G=`${U}-popover`,o=d.props,J=B.getElementReference(d),Q=o.id??`${U}-trigger`,v=x||o.disabled===!0||o["aria-disabled"]===!0||o["aria-disabled"]==="true",R=H!==void 0,[me,be]=r.useState(le),t=R?H:me,C=h.usePresence(t),W=r.useRef(null),X=r.useRef(null),D=r.useRef("programmatic"),L=r.useRef(null),Y=r.useRef(t),T=r.useRef(null),[ve,ye]=r.useReducer(e=>e+1,0),[u,Pe]=r.useState(null),[f,he]=r.useState(null),a=(u==null?void 0:u.ownerDocument)??(typeof document>"u"?null:document),O=se.useBoundary("Popover").boundaryElement,S=h.useOverlayLayer(C.present,O),Ee=r.useMemo(()=>[W,X],[]),p=ne.useFloatingPosition(C.present,K,u,f,O,A),Re=r.useCallback(e=>{Me(e,W,J),Pe(e)},[J]),Te=r.useCallback(e=>{_e(e,X,c),he(e)},[c]),g=r.useCallback((e,s)=>{t!==e&&(R?(L.current={open:e,reason:s},ye()):(D.current=s,be(e)),k==null||k(e,s))},[R,k,t]),xe=r.useCallback(()=>{g(!1,"escape")},[g]),ke=r.useCallback(()=>{g(!1,"outside")},[g]),Ie=r.useCallback(e=>{var m;if(I==null||I(e),e.defaultPrevented)return;const s=(m=a==null?void 0:a.defaultView)==null?void 0:m.HTMLElement;s?T.current=e.composedPath().find(P=>P instanceof s&&P.tabIndex>=0)??e.target:T.current=e.target},[I,a]);h.useDismissableLayer({boundary:O,active:t,boundaries:Ee,dismissOnEscape:ce,dismissOnPointerDownOutside:ue,layerId:S.id,onEscapeDismiss:xe,onEscapeKeyDown:de,onPointerDownOutside:Ie,onPointerDownOutsideDismiss:ke,ownerDocument:a});const Ce=De.useFocusTrap({boundary:O,active:t&&b,autoFocus:w,container:f,initialFocusReference:E,layerId:S.id,restoreFocus:j});r.useEffect(()=>{if(!t||b||!w||!f)return;let e=!0;return Promise.resolve().then(()=>{if(!e)return;const s=E==null?void 0:E.current;(s&&f.contains(s)?s:f).focus({preventScroll:!0})}),()=>{e=!1}},[w,E,t,f,b]),r.useEffect(()=>{var te;const e=Y.current;Y.current=t;const s=L.current;let m=D.current;if(R&&(m="programmatic",e!==t&&(s==null?void 0:s.open)===t&&(m=s.reason)),L.current=null,t){D.current="programmatic",T.current=null;return}const P=a==null?void 0:a.activeElement,_=T.current,M=(te=a==null?void 0:a.defaultView)==null?void 0:te.HTMLElement,we=m==="outside"&&M&&_ instanceof M&&P instanceof M&&(_===P||_.contains(P));e&&!b&&j&&!we&&(u==null||u.focus({preventScroll:!0})),T.current=null},[ve,R,t,a,j,b,u]),r.useEffect(()=>{x&&t&&g(!1,"programmatic")},[x,t,g]);function Oe(e){if(v){e.preventDefault(),e.stopPropagation();return}e.defaultPrevented||g(!t,"trigger")}function Se(e){e.defaultPrevented||v||Be(e.currentTarget)||e.key!=="Enter"&&e.key!==" "||(e.preventDefault(),e.currentTarget.click())}if(x)return d;const N=typeof d.type=="string",y=N?d.type:null,Z=y==="a"&&typeof o.href=="string",ee=N&&!(y==="button"||y==="input"||y==="select"||y==="summary"||y==="textarea"||Z),re=Z&&v;let q=o.role;q===void 0&&(re?q="link":ee&&(q="button"));let F=o.tabIndex;F===void 0&&ee&&(F=0),v&&(F=-1);const qe=v?{...o,onClick:void 0}:o,Fe=r.cloneElement(d,ne.resolveTriggerOverrides(qe,{"aria-controls":t?je.mergeIdentifiers(o["aria-controls"],G):o["aria-controls"],"aria-expanded":t,"aria-haspopup":o["aria-haspopup"]??ze(V),"aria-disabled":v?!0:o["aria-disabled"],className:"nk-popover__trigger",href:re?void 0:o.href,id:Q,onClick:Oe,onKeyDown:N?Se:void 0,ref:Re,role:q,tabIndex:F}));return l.jsxs(l.Fragment,{children:[Fe,l.jsx(h.FocusScopeContext.Provider,{value:t&&b?Ce:ge,children:C.present&&a?l.jsx(h.Portal,{children:l.jsxs(Le.Surface,{...pe,ref:Te,"aria-hidden":t?void 0:!0,"aria-label":t?z:void 0,"aria-labelledby":t?oe??(z===void 0?Q:void 0):void 0,className:["nk-popover",ie].filter(Boolean).join(" "),"data-placement":(p==null?void 0:p.placement)??K,"data-align":A,"data-state":C.state==="closing"?"closing":"open",id:G,role:t?V:void 0,style:p?{...$,"--nk-popover-arrow-offset":`${p.arrowOffset}px`,left:p.left,top:p.top,zIndex:S.zIndex}:{...$,visibility:"hidden",zIndex:S.zIndex},tabIndex:fe??-1,children:[l.jsx(Ne,{inert:!t,panelElement:f}),l.jsx("span",{"aria-hidden":"true",className:"nk-popover__arrow"}),l.jsx("div",{className:"nk-popover__content",children:ae})]})}):null})]})});exports.default=Ae;
|
package/dist/Popover.js
CHANGED
|
@@ -1,99 +1,101 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs as
|
|
3
|
-
import { forwardRef as
|
|
4
|
-
import { m as
|
|
5
|
-
import { u as
|
|
6
|
-
import { g as
|
|
7
|
-
import { u as
|
|
8
|
-
import { F as
|
|
9
|
-
import { u as
|
|
10
|
-
import { S as
|
|
11
|
-
function
|
|
2
|
+
import { jsxs as oe, Fragment as _e, jsx as I } from "react/jsx-runtime";
|
|
3
|
+
import { forwardRef as Be, Fragment as qe, useId as ze, useContext as Ae, useState as A, useRef as y, useReducer as Me, useMemo as $e, useCallback as h, useEffect as M, cloneElement as je } from "react";
|
|
4
|
+
import { m as He } from "./aria-Bv-xVREf.js";
|
|
5
|
+
import { u as Ke, a as Ve } from "./effects-DGbA6Q2O.js";
|
|
6
|
+
import { g as Ue, a as ae } from "./reference-CXMr27nM.js";
|
|
7
|
+
import { u as Ge, r as Je } from "./useFloatingPosition-Cizey9UN.js";
|
|
8
|
+
import { F as se, b as Qe, c as We, d as Xe, P as Ye } from "./usePresence-BTRY1_l-.js";
|
|
9
|
+
import { u as Ze } from "./useFocusTrap-BxPazAL6.js";
|
|
10
|
+
import { S as er } from "./Surface-vEFsZC12.js";
|
|
11
|
+
function rr(t) {
|
|
12
12
|
const { inert: a, panelElement: i } = t;
|
|
13
|
-
return
|
|
13
|
+
return Ve(() => {
|
|
14
14
|
i && (i.inert = a);
|
|
15
15
|
}, [a, i]), null;
|
|
16
16
|
}
|
|
17
|
-
function rr(t, a, i) {
|
|
18
|
-
a.current = t, se(i, t);
|
|
19
|
-
}
|
|
20
17
|
function tr(t, a, i) {
|
|
21
|
-
a.current = t,
|
|
18
|
+
a.current = t, ae(i, t);
|
|
19
|
+
}
|
|
20
|
+
function nr(t, a, i) {
|
|
21
|
+
a.current = t, ae(i, t);
|
|
22
22
|
}
|
|
23
|
-
function
|
|
23
|
+
function or(t) {
|
|
24
24
|
const a = t.tagName.toLowerCase();
|
|
25
25
|
return t.getAttribute("role") === "button" && a !== "button" ? !1 : ["button", "input", "select", "summary", "textarea"].includes(a) ? !0 : a === "a" && t.hasAttribute("href");
|
|
26
26
|
}
|
|
27
|
-
function
|
|
27
|
+
function sr(t) {
|
|
28
28
|
return t === "grid" || t === "listbox" || t === "menu" || t === "tree" ? t : "dialog";
|
|
29
29
|
}
|
|
30
|
-
const
|
|
30
|
+
const br = Be(function(a, i) {
|
|
31
31
|
const {
|
|
32
32
|
"aria-label": $,
|
|
33
|
-
"aria-labelledby":
|
|
33
|
+
"aria-labelledby": ie,
|
|
34
|
+
align: j = "center",
|
|
34
35
|
autoFocus: D = !0,
|
|
35
|
-
children:
|
|
36
|
-
className:
|
|
37
|
-
closeOnEscape:
|
|
38
|
-
closeOnOutsideInteraction:
|
|
39
|
-
defaultOpen:
|
|
36
|
+
children: ce,
|
|
37
|
+
className: le,
|
|
38
|
+
closeOnEscape: ue = !0,
|
|
39
|
+
closeOnOutsideInteraction: de = !0,
|
|
40
|
+
defaultOpen: fe = !1,
|
|
40
41
|
disabled: R = !1,
|
|
41
42
|
initialFocusReference: P,
|
|
42
|
-
onEscapeKeyDown:
|
|
43
|
+
onEscapeKeyDown: pe,
|
|
43
44
|
onOpenChange: x,
|
|
44
45
|
onPointerDownOutside: O,
|
|
45
|
-
open:
|
|
46
|
-
placement:
|
|
46
|
+
open: H,
|
|
47
|
+
placement: K = "bottom",
|
|
47
48
|
restoreFocus: L = !0,
|
|
48
|
-
role:
|
|
49
|
-
style:
|
|
50
|
-
tabIndex:
|
|
49
|
+
role: V = "dialog",
|
|
50
|
+
style: U,
|
|
51
|
+
tabIndex: ge,
|
|
51
52
|
trapFocus: g = !1,
|
|
52
53
|
trigger: l,
|
|
53
|
-
...
|
|
54
|
+
...me
|
|
54
55
|
} = a;
|
|
55
|
-
if (l.type ===
|
|
56
|
+
if (l.type === qe)
|
|
56
57
|
throw new Error("Popover requires a single non-Fragment trigger");
|
|
57
|
-
const
|
|
58
|
+
const G = ze(), be = Ae(se), J = `${G}-popover`, o = l.props, Q = Ue(l), W = o.id ?? `${G}-trigger`, m = R || o.disabled === !0 || o["aria-disabled"] === !0 || o["aria-disabled"] === "true", T = H !== void 0, [ve, ye] = A(fe), r = T ? H : ve, k = Qe(r), X = y(null), Y = y(null), N = y("programmatic"), _ = y(null), Z = y(r), E = y(null), [he, Pe] = Me(
|
|
58
59
|
(e) => e + 1,
|
|
59
60
|
0
|
|
60
|
-
), [c,
|
|
61
|
-
() => [
|
|
61
|
+
), [c, Te] = A(null), [u, Ee] = A(null), s = (c == null ? void 0 : c.ownerDocument) ?? (typeof document > "u" ? null : document), C = Ke("Popover").boundaryElement, S = We(k.present, C), Ie = $e(
|
|
62
|
+
() => [X, Y],
|
|
62
63
|
[]
|
|
63
|
-
), d =
|
|
64
|
+
), d = Ge(
|
|
64
65
|
k.present,
|
|
65
|
-
|
|
66
|
+
K,
|
|
66
67
|
c,
|
|
67
68
|
u,
|
|
68
|
-
C
|
|
69
|
-
|
|
69
|
+
C,
|
|
70
|
+
j
|
|
71
|
+
), Re = h(
|
|
70
72
|
(e) => {
|
|
71
|
-
|
|
73
|
+
nr(
|
|
72
74
|
e,
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
),
|
|
75
|
+
X,
|
|
76
|
+
Q
|
|
77
|
+
), Te(e);
|
|
76
78
|
},
|
|
77
|
-
[
|
|
78
|
-
),
|
|
79
|
+
[Q]
|
|
80
|
+
), xe = h(
|
|
79
81
|
(e) => {
|
|
80
|
-
|
|
82
|
+
tr(
|
|
81
83
|
e,
|
|
82
|
-
|
|
84
|
+
Y,
|
|
83
85
|
i
|
|
84
|
-
),
|
|
86
|
+
), Ee(e);
|
|
85
87
|
},
|
|
86
88
|
[i]
|
|
87
89
|
), f = h((e, n) => {
|
|
88
90
|
r !== e && (T ? (_.current = {
|
|
89
91
|
open: e,
|
|
90
92
|
reason: n
|
|
91
|
-
},
|
|
92
|
-
}, [T, x, r]),
|
|
93
|
+
}, Pe()) : (N.current = n, ye(e)), x == null || x(e, n));
|
|
94
|
+
}, [T, x, r]), Oe = h(() => {
|
|
93
95
|
f(!1, "escape");
|
|
94
|
-
}, [f]),
|
|
96
|
+
}, [f]), ke = h(() => {
|
|
95
97
|
f(!1, "outside");
|
|
96
|
-
}, [f]),
|
|
98
|
+
}, [f]), Ce = h((e) => {
|
|
97
99
|
var p;
|
|
98
100
|
if (O == null || O(e), e.defaultPrevented) return;
|
|
99
101
|
const n = (p = s == null ? void 0 : s.defaultView) == null ? void 0 : p.HTMLElement;
|
|
@@ -101,20 +103,20 @@ const mr = _e(function(a, i) {
|
|
|
101
103
|
(v) => v instanceof n && v.tabIndex >= 0
|
|
102
104
|
) ?? e.target : E.current = e.target;
|
|
103
105
|
}, [O, s]);
|
|
104
|
-
|
|
106
|
+
Xe({
|
|
105
107
|
boundary: C,
|
|
106
108
|
active: r,
|
|
107
|
-
boundaries:
|
|
108
|
-
dismissOnEscape:
|
|
109
|
-
dismissOnPointerDownOutside:
|
|
109
|
+
boundaries: Ie,
|
|
110
|
+
dismissOnEscape: ue,
|
|
111
|
+
dismissOnPointerDownOutside: de,
|
|
110
112
|
layerId: S.id,
|
|
111
|
-
onEscapeDismiss:
|
|
112
|
-
onEscapeKeyDown:
|
|
113
|
-
onPointerDownOutside:
|
|
114
|
-
onPointerDownOutsideDismiss:
|
|
113
|
+
onEscapeDismiss: Oe,
|
|
114
|
+
onEscapeKeyDown: pe,
|
|
115
|
+
onPointerDownOutside: Ce,
|
|
116
|
+
onPointerDownOutsideDismiss: ke,
|
|
115
117
|
ownerDocument: s
|
|
116
118
|
});
|
|
117
|
-
const
|
|
119
|
+
const Se = Ze({
|
|
118
120
|
boundary: C,
|
|
119
121
|
active: r && g,
|
|
120
122
|
autoFocus: D,
|
|
@@ -134,19 +136,19 @@ const mr = _e(function(a, i) {
|
|
|
134
136
|
e = !1;
|
|
135
137
|
};
|
|
136
138
|
}, [D, P, r, u, g]), M(() => {
|
|
137
|
-
var
|
|
138
|
-
const e =
|
|
139
|
-
|
|
139
|
+
var ne;
|
|
140
|
+
const e = Z.current;
|
|
141
|
+
Z.current = r;
|
|
140
142
|
const n = _.current;
|
|
141
143
|
let p = N.current;
|
|
142
144
|
if (T && (p = "programmatic", e !== r && (n == null ? void 0 : n.open) === r && (p = n.reason)), _.current = null, r) {
|
|
143
145
|
N.current = "programmatic", E.current = null;
|
|
144
146
|
return;
|
|
145
147
|
}
|
|
146
|
-
const v = s == null ? void 0 : s.activeElement, q = E.current, z = (
|
|
147
|
-
e && !g && L && !
|
|
148
|
+
const v = s == null ? void 0 : s.activeElement, q = E.current, z = (ne = s == null ? void 0 : s.defaultView) == null ? void 0 : ne.HTMLElement, Ne = p === "outside" && z && q instanceof z && v instanceof z && (q === v || q.contains(v));
|
|
149
|
+
e && !g && L && !Ne && (c == null || c.focus({ preventScroll: !0 })), E.current = null;
|
|
148
150
|
}, [
|
|
149
|
-
|
|
151
|
+
he,
|
|
150
152
|
T,
|
|
151
153
|
r,
|
|
152
154
|
s,
|
|
@@ -156,80 +158,81 @@ const mr = _e(function(a, i) {
|
|
|
156
158
|
]), M(() => {
|
|
157
159
|
R && r && f(!1, "programmatic");
|
|
158
160
|
}, [R, r, f]);
|
|
159
|
-
function
|
|
161
|
+
function we(e) {
|
|
160
162
|
if (m) {
|
|
161
163
|
e.preventDefault(), e.stopPropagation();
|
|
162
164
|
return;
|
|
163
165
|
}
|
|
164
166
|
e.defaultPrevented || f(!r, "trigger");
|
|
165
167
|
}
|
|
166
|
-
function
|
|
167
|
-
e.defaultPrevented || m ||
|
|
168
|
+
function Fe(e) {
|
|
169
|
+
e.defaultPrevented || m || or(e.currentTarget) || e.key !== "Enter" && e.key !== " " || (e.preventDefault(), e.currentTarget.click());
|
|
168
170
|
}
|
|
169
171
|
if (R) return l;
|
|
170
|
-
const B = typeof l.type == "string", b = B ? l.type : null,
|
|
172
|
+
const B = typeof l.type == "string", b = B ? l.type : null, ee = b === "a" && typeof o.href == "string", re = B && !(b === "button" || b === "input" || b === "select" || b === "summary" || b === "textarea" || ee), te = ee && m;
|
|
171
173
|
let w = o.role;
|
|
172
|
-
w === void 0 && (
|
|
174
|
+
w === void 0 && (te ? w = "link" : re && (w = "button"));
|
|
173
175
|
let F = o.tabIndex;
|
|
174
|
-
F === void 0 &&
|
|
175
|
-
const
|
|
176
|
+
F === void 0 && re && (F = 0), m && (F = -1);
|
|
177
|
+
const De = m ? { ...o, onClick: void 0 } : o, Le = je(
|
|
176
178
|
l,
|
|
177
|
-
|
|
178
|
-
"aria-controls": r ?
|
|
179
|
+
Je(De, {
|
|
180
|
+
"aria-controls": r ? He(o["aria-controls"], J) : o["aria-controls"],
|
|
179
181
|
"aria-expanded": r,
|
|
180
|
-
"aria-haspopup": o["aria-haspopup"] ??
|
|
182
|
+
"aria-haspopup": o["aria-haspopup"] ?? sr(V),
|
|
181
183
|
"aria-disabled": m ? !0 : o["aria-disabled"],
|
|
182
184
|
className: "nk-popover__trigger",
|
|
183
|
-
href:
|
|
184
|
-
id:
|
|
185
|
-
onClick:
|
|
186
|
-
onKeyDown: B ?
|
|
187
|
-
ref:
|
|
185
|
+
href: te ? void 0 : o.href,
|
|
186
|
+
id: W,
|
|
187
|
+
onClick: we,
|
|
188
|
+
onKeyDown: B ? Fe : void 0,
|
|
189
|
+
ref: Re,
|
|
188
190
|
role: w,
|
|
189
191
|
tabIndex: F
|
|
190
192
|
})
|
|
191
193
|
);
|
|
192
|
-
return /* @__PURE__ */
|
|
193
|
-
|
|
194
|
+
return /* @__PURE__ */ oe(_e, { children: [
|
|
195
|
+
Le,
|
|
194
196
|
/* @__PURE__ */ I(
|
|
195
|
-
|
|
197
|
+
se.Provider,
|
|
196
198
|
{
|
|
197
|
-
value: r && g ?
|
|
198
|
-
children: k.present && s ? /* @__PURE__ */ I(
|
|
199
|
-
|
|
199
|
+
value: r && g ? Se : be,
|
|
200
|
+
children: k.present && s ? /* @__PURE__ */ I(Ye, { children: /* @__PURE__ */ oe(
|
|
201
|
+
er,
|
|
200
202
|
{
|
|
201
|
-
...
|
|
202
|
-
ref:
|
|
203
|
+
...me,
|
|
204
|
+
ref: xe,
|
|
203
205
|
"aria-hidden": r ? void 0 : !0,
|
|
204
206
|
"aria-label": r ? $ : void 0,
|
|
205
|
-
"aria-labelledby": r ?
|
|
206
|
-
className: ["nk-popover",
|
|
207
|
-
"data-placement": (d == null ? void 0 : d.placement) ??
|
|
207
|
+
"aria-labelledby": r ? ie ?? ($ === void 0 ? W : void 0) : void 0,
|
|
208
|
+
className: ["nk-popover", le].filter(Boolean).join(" "),
|
|
209
|
+
"data-placement": (d == null ? void 0 : d.placement) ?? K,
|
|
210
|
+
"data-align": j,
|
|
208
211
|
"data-state": k.state === "closing" ? "closing" : "open",
|
|
209
|
-
id:
|
|
210
|
-
role: r ?
|
|
212
|
+
id: J,
|
|
213
|
+
role: r ? V : void 0,
|
|
211
214
|
style: d ? {
|
|
212
|
-
...
|
|
215
|
+
...U,
|
|
213
216
|
"--nk-popover-arrow-offset": `${d.arrowOffset}px`,
|
|
214
217
|
left: d.left,
|
|
215
218
|
top: d.top,
|
|
216
219
|
zIndex: S.zIndex
|
|
217
220
|
} : {
|
|
218
|
-
...
|
|
221
|
+
...U,
|
|
219
222
|
visibility: "hidden",
|
|
220
223
|
zIndex: S.zIndex
|
|
221
224
|
},
|
|
222
|
-
tabIndex:
|
|
225
|
+
tabIndex: ge ?? -1,
|
|
223
226
|
children: [
|
|
224
227
|
/* @__PURE__ */ I(
|
|
225
|
-
|
|
228
|
+
rr,
|
|
226
229
|
{
|
|
227
230
|
inert: !r,
|
|
228
231
|
panelElement: u
|
|
229
232
|
}
|
|
230
233
|
),
|
|
231
234
|
/* @__PURE__ */ I("span", { "aria-hidden": "true", className: "nk-popover__arrow" }),
|
|
232
|
-
/* @__PURE__ */ I("div", { className: "nk-popover__content", children:
|
|
235
|
+
/* @__PURE__ */ I("div", { className: "nk-popover__content", children: ce })
|
|
233
236
|
]
|
|
234
237
|
}
|
|
235
238
|
) }) : null
|
|
@@ -238,5 +241,5 @@ const mr = _e(function(a, i) {
|
|
|
238
241
|
] });
|
|
239
242
|
});
|
|
240
243
|
export {
|
|
241
|
-
|
|
244
|
+
br as default
|
|
242
245
|
};
|
package/dist/Select.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
1
|
+
"use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const c=require("react/jsx-runtime"),l=require("react"),Z=require("./effects-D98vUn6N.cjs"),U=require("./aria-DM-xYEHQ.cjs"),ge=require("./reference-C2guRuR0.cjs"),q=require("./Icon-CgQ62bgw.cjs"),X=require("./usePresence-Dm0mls5p.cjs"),se=require("./useAnchoredPosition-BEzN03Oi.cjs");function ke(t){const{form:n,onReset:s,resetValue:o,triggerReference:a}=t,d=l.useRef(null);return l.useEffect(()=>{var f;const u=(f=a.current)==null?void 0:f.form;if(!u)return;function i(){const m=d.current;if(m){const y=Array.from(m.options),I=y.find(x=>x.value===o)??y[0];y.forEach(x=>{x.defaultSelected=x===I})}s()}return u.addEventListener("reset",i),()=>u.removeEventListener("reset",i)},[n,s,o,a]),d}const H=8,z=4,we=160,Ee=72;function Re(t,n,s,o="start"){const a=s.bottom-t.bottom-z-H,d=t.top-s.top-z-H,u=a<we&&d>a,i=Math.max(Ee,u?d:a),f=Math.max(t.width,(n==null?void 0:n.width)??t.width),m=s.left+H,y=se.calculateAlignedPosition(o,t.left,t.width,f),I=Math.min(Math.max(m,y),Math.max(m,s.right-H-f)),x=u?Math.max(s.top+H,t.top-z-Math.min((n==null?void 0:n.height)??i,i)):t.bottom+z;return{left:I,maxHeight:i,minWidth:t.width,top:x}}function _e(t,n,s,o,a="start"){const d=l.useCallback(u=>{const{panelBounds:i,triggerBounds:f,visibleBounds:m}=u;return Re(f,i,m,a)},[a]);return se.useAnchoredPosition({active:t,boundary:o,fit:d,panel:s,trigger:n})}const Oe=500;function Se(t){const n=l.useRef(""),s=l.useRef(null),o=l.useRef(null);return l.useEffect(()=>()=>{const a=o.current;a&&s.current!==null&&a.clearTimeout(s.current)},[]),l.useCallback(a=>{var f;const d=(f=t.current)==null?void 0:f.ownerDocument.defaultView;if(!d)return null;o.current=d;const u=n.current+a,i=Array.from(u).every(m=>m===a);return n.current=i?a:u,s.current!==null&&d.clearTimeout(s.current),s.current=d.setTimeout(()=>{n.current="",s.current=null},Oe),n.current},[t])}function J(t,n,s){if(t.length===0)return-1;for(let o=1;o<=t.length;o+=1){const a=(n+s*o+t.length)%t.length;if(!t[a].disabled)return a}return-1}function De(t,n,s){for(let o=1;o<=t.length;o+=1){const a=(s+o+t.length)%t.length,d=t[a];if(!d.disabled&&d.label.toLocaleLowerCase().startsWith(n))return a}return-1}function je(t){const n=new Set;t.forEach(s=>{if(n.has(s.value))throw new Error("Select option values must be unique");n.add(s.value)})}function Le(t){const{active:n,align:s,closeOnEscape:o,closeOnOutsideInteraction:a,highlightedIndex:d,id:u,listboxReference:i,onEscapeDismiss:f,onEscapeKeyDown:m,onHighlight:y,onOutsideDismiss:I,onPointerDownOutside:x,onSelect:O,options:S,ownerDocument:A,position:E,selectedValue:R,state:D,triggerReference:V}=t,v=l.useRef(null),W=Z.useBoundary("Select").boundaryElement,_=X.useOverlayLayer(!0,W),$=l.useMemo(()=>[V,v],[V]),G=l.useCallback(h=>{v.current=h,i(h)},[i]);return X.useDismissableLayer({active:n,boundaries:$,boundary:W,dismissOnEscape:o,dismissOnPointerDownOutside:a,layerId:_.id,onEscapeDismiss:f,onEscapeKeyDown:m,onPointerDownOutside:x,onPointerDownOutsideDismiss:I,ownerDocument:A}),c.jsx("div",{"aria-hidden":n?void 0:!0,"aria-labelledby":u,className:"nk-select__listbox","data-align":s,"data-state":D,id:`${u}-listbox`,ref:G,role:"listbox",style:E?{left:E.left,maxHeight:E.maxHeight,minWidth:E.minWidth,top:E.top,zIndex:_.zIndex}:{visibility:"hidden",zIndex:_.zIndex},children:S.map((h,C)=>c.jsxs("div",{"aria-disabled":h.disabled||void 0,"aria-selected":h.value===R,className:"nk-select__option","data-highlighted":C===d||void 0,"data-selected":h.value===R||void 0,id:`${u}-option-${C}`,onPointerDown:Y=>{Y.preventDefault(),h.disabled||O(h)},onPointerMove:()=>{h.disabled||y(C)},role:"option",children:[h.icon?c.jsx(q.Icon,{type:h.icon}):null,c.jsx("span",{className:"nk-select__option-label",children:h.label}),h.value===R?c.jsx(q.Icon,{className:"nk-select__check",type:"checkmark"}):null]},h.value))})}function Pe(t,n,s){n.current=t,ge.assignElementReference(s,t)}function Ae(t){var te;const{"aria-invalid":n,align:s="start",className:o,closeOnEscape:a=!0,closeOnOutsideInteraction:d=!0,defaultValue:u="",disabled:i=!1,displayOverride:f,form:m,forwardedReference:y,id:I,invalid:x=!1,name:O,onChange:S,onClick:A,onEscapeKeyDown:E,onKeyDown:R,onOpenChange:D,onPointerDownOutside:V,options:v,placeholder:W,required:_=!1,style:$,value:G,width:h,...C}=t;je(v);const Y=l.useId(),j=I??Y,g=l.useRef(null),[N,ae]=l.useState(null),[p,le]=l.useState(!1),[k,T]=l.useState(-1),[ie,B]=l.useState(u),L=G!==void 0,P=L?G:ie,re=v.find(e=>e.value===P),oe=x||U.hasInvalidState(n),ce=U.resolveAriaInvalid(x,n),Q=X.usePresence(p),M=((te=g.current)==null?void 0:te.ownerDocument)??(typeof document>"u"?null:document),de=Z.useBoundary("Select").boundaryElement,ue=_e(Q.present,g.current,N,de,s),fe=Se(g),me=h===void 0?$:{...$,width:h},K=f??re,he=l.useCallback(e=>Pe(e,g,y),[y]),b=l.useCallback(e=>{p!==e&&(le(e),D==null||D(e))},[D,p]),ve=l.useCallback(()=>{L||B(u),b(!1)},[u,L,b]),pe=ke({form:m,onReset:ve,resetValue:L?P:u,triggerReference:g}),F=l.useCallback((e=1)=>{const r=v.findIndex(ne=>ne.value===P&&!ne.disabled),w=e===1?-1:v.length;T(r>=0?r:J(v,w,e)),b(!0)},[v,P,b]),ee=l.useCallback(e=>{var r;i||e.disabled||(L||B(e.value),b(!1),(r=g.current)==null||r.focus(),S==null||S(e.value))},[i,L,S,b]),be=l.useCallback(()=>{var e;b(!1),(e=g.current)==null||e.focus()},[b]),ye=l.useCallback(()=>{b(!1)},[b]);function xe(e){A==null||A(e),!(e.defaultPrevented||i)&&(p?b(!1):F())}function Ie(e){if(R==null||R(e),!(e.defaultPrevented||i)){if(e.key==="ArrowDown"||e.key==="ArrowUp"){e.preventDefault();const r=e.key==="ArrowDown"?1:-1;p?T(w=>J(v,w,r)):F(r);return}if(e.key==="Home"||e.key==="End"){if(e.preventDefault(),!p)F(e.key==="Home"?1:-1);else{const r=e.key==="Home"?1:-1,w=r===1?-1:v.length;T(J(v,w,r))}return}if(e.key==="Enter"||e.key===" "){e.preventDefault();const r=v[k];p&&r?ee(r):p||F();return}if(e.key==="Tab"){b(!1);return}if(e.key.length===1&&!e.altKey&&!e.ctrlKey&&!e.metaKey){const r=fe(e.key.toLocaleLowerCase());if(r===null)return;const w=De(v,r,k);w>=0&&(e.preventDefault(),p||b(!0),T(w))}}}return l.useEffect(()=>{i&&b(!1)},[i,b]),l.useEffect(()=>{var e;if(p&&k>=0){const r=M==null?void 0:M.getElementById(`${j}-option-${k}`);r&&(N!=null&&N.contains(r))&&((e=r.scrollIntoView)==null||e.call(r,{block:"nearest"}))}},[k,j,N,p]),c.jsxs("span",{className:["nk-select",o].filter(Boolean).join(" "),"data-disabled":i||void 0,"data-invalid":oe||void 0,"data-mode":"custom","data-open":p||void 0,style:me,children:[c.jsxs("button",{...C,ref:he,"aria-activedescendant":p&&k>=0?`${j}-option-${k}`:void 0,"aria-controls":`${j}-listbox`,"aria-expanded":p,"aria-haspopup":"listbox","aria-invalid":ce,"aria-required":_||void 0,"aria-autocomplete":"none",className:"nk-select__trigger",disabled:i,form:m,id:j,onClick:xe,onKeyDown:Ie,role:"combobox",type:"button",children:[K?c.jsxs("span",{className:"nk-select__value",children:[K.icon?c.jsx(q.Icon,{type:K.icon}):null,c.jsx("span",{className:"nk-select__value-label",children:K.label})]}):c.jsx("span",{className:"nk-select__placeholder",children:W}),c.jsx(q.Icon,{className:"nk-select__icon",type:"chevron-down"})]}),O||_?c.jsxs("select",{ref:pe,"aria-hidden":"true",className:"nk-select__form-control",disabled:i,form:m,name:O,onChange:()=>{},onInvalid:e=>{var r;e.preventDefault(),(r=g.current)==null||r.focus()},required:_,tabIndex:-1,value:P,children:[c.jsx("option",{value:""}),v.map(e=>c.jsx("option",{disabled:e.disabled,value:e.value,children:e.label},e.value))]}):null,Q.present&&M?c.jsx(X.Portal,{children:c.jsx(Le,{active:p,align:s,closeOnEscape:a,closeOnOutsideInteraction:d,highlightedIndex:k,id:j,listboxReference:ae,onEscapeDismiss:be,onEscapeKeyDown:E,onHighlight:T,onOutsideDismiss:ye,onPointerDownOutside:V,onSelect:ee,options:v,ownerDocument:M,position:ue,selectedValue:P,state:Q.state==="closing"?"closing":"open",triggerReference:g})}):null]})}function Ce(t){const{"aria-invalid":n,children:s,className:o,defaultValue:a,disabled:d=!1,forwardedReference:u,invalid:i=!1,placeholder:f,style:m,value:y,...I}=t,x=U.resolveAriaInvalid(i,n),O=i||U.hasInvalidState(n);return c.jsxs("span",{className:["nk-select",o].filter(Boolean).join(" "),"data-disabled":d||void 0,"data-invalid":O||void 0,"data-mode":"native",style:m,children:[c.jsxs("select",{...I,ref:u,"aria-invalid":x,className:"nk-select__control",defaultValue:y===void 0?a??(f!==void 0?"":void 0):void 0,disabled:d,value:y,children:[f!==void 0?c.jsx("option",{disabled:!0,value:"",children:f}):null,s]}),c.jsx(q.Icon,{className:"nk-select__icon",type:"chevron-down"})]})}const Ne=l.forwardRef(function(n,s){const{options:o}=n;return Z.useBoundary("Select"),o!==void 0?c.jsx(Ae,{...n,forwardedReference:s}):c.jsx(Ce,{...n,forwardedReference:s})});exports.default=Ne;
|