neatkit 0.9.0 → 0.10.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.
Files changed (67) hide show
  1. package/dist/{Button-DU4j_IED.cjs → Button-CVe9T_Zw.cjs} +1 -1
  2. package/dist/{Button-BV5OUXpc.js → Button-D6rXvcqq.js} +1 -1
  3. package/dist/Button.cjs +1 -1
  4. package/dist/Button.js +1 -1
  5. package/dist/Checkbox.cjs +1 -1
  6. package/dist/Checkbox.js +111 -110
  7. package/dist/Input.cjs +1 -1
  8. package/dist/Input.js +52 -51
  9. package/dist/Markdown.cjs +1 -1
  10. package/dist/Markdown.js +1 -1
  11. package/dist/Modal.cjs +1 -1
  12. package/dist/Modal.js +57 -56
  13. package/dist/PinInput.cjs +1 -1
  14. package/dist/PinInput.js +88 -87
  15. package/dist/Popover.cjs +1 -1
  16. package/dist/Popover.js +2 -2
  17. package/dist/Progress.cjs +1 -0
  18. package/dist/Progress.js +40 -0
  19. package/dist/Radio.cjs +1 -1
  20. package/dist/Radio.js +48 -47
  21. package/dist/Select.cjs +1 -1
  22. package/dist/Select.js +363 -359
  23. package/dist/Sidebar.cjs +1 -1
  24. package/dist/Sidebar.js +44 -44
  25. package/dist/Spinner-BE0F4y2S.cjs +1 -0
  26. package/dist/Spinner-CmxlDlOk.js +23 -0
  27. package/dist/Spinner.cjs +1 -1
  28. package/dist/Spinner.js +1 -1
  29. package/dist/{Table-qetwZpTC.cjs → Table-BqWBgMTU.cjs} +1 -1
  30. package/dist/{Table-CADupJEU.js → Table-DutHfiXR.js} +2 -2
  31. package/dist/Table.cjs +1 -1
  32. package/dist/Table.js +1 -1
  33. package/dist/{Tooltip-B2d5ss7S.cjs → Tooltip-CCuE-hfp.cjs} +1 -1
  34. package/dist/{Tooltip-BK64rkxV.js → Tooltip-CeyRKNv4.js} +1 -1
  35. package/dist/Tooltip.cjs +1 -1
  36. package/dist/Tooltip.js +1 -1
  37. package/dist/components/Portal/hooks/useAnchoredPosition.d.ts +59 -0
  38. package/dist/components/Progress/Progress.d.ts +38 -0
  39. package/dist/components/Progress/index.d.ts +2 -0
  40. package/dist/components/Progress/utils/value.d.ts +25 -0
  41. package/dist/components/Select/Select.d.ts +6 -74
  42. package/dist/components/Select/components/CustomSelect.d.ts +59 -0
  43. package/dist/components/Select/components/NativeSelect.d.ts +26 -0
  44. package/dist/components/Select/components/SelectListbox.d.ts +50 -0
  45. package/dist/components/Select/hooks/useSelectFormReset.d.ts +27 -0
  46. package/dist/components/Select/hooks/useSelectPosition.d.ts +12 -0
  47. package/dist/components/Select/hooks/useTypeahead.d.ts +14 -0
  48. package/dist/components/Select/utils/options.d.ts +38 -0
  49. package/dist/components/Sidebar/Sidebar.d.ts +30 -24
  50. package/dist/components/Sidebar/components/SidebarOverlay.d.ts +3 -4
  51. package/dist/components/Sidebar/components/SidebarPanel.d.ts +2 -2
  52. package/dist/style.css +1 -1
  53. package/dist/useAnchoredPosition-C0VS7hm6.js +105 -0
  54. package/dist/useAnchoredPosition-D7GRFzoX.cjs +1 -0
  55. package/dist/useFloatingPosition-Dq8xpr3E.js +27 -0
  56. package/dist/useFloatingPosition-g5kXywoB.cjs +1 -0
  57. package/dist/useFocusTrap-C0IcCdNf.js +136 -0
  58. package/dist/useFocusTrap-gAK_402D.cjs +1 -0
  59. package/package.json +6 -1
  60. package/dist/Spinner-BXgw60UC.cjs +0 -1
  61. package/dist/Spinner-CVYvk6YK.js +0 -25
  62. package/dist/floating-position-DIjh2wnP.cjs +0 -1
  63. package/dist/floating-position-DvR6e334.js +0 -50
  64. package/dist/useFloatingPosition-B3ZC-v3v.js +0 -43
  65. package/dist/useFloatingPosition-GzkP9dCc.cjs +0 -1
  66. package/dist/useFocusTrap-BrFZdMqQ.cjs +0 -1
  67. package/dist/useFocusTrap-DhVnlboe.js +0 -136
@@ -1 +1 @@
1
- "use client";"use strict";const r=require("react/jsx-runtime"),y=require("react"),B=require("./Icon-BIBzgznI.cjs"),F=require("./Spinner-BXgw60UC.cjs");function x(t){return t==null||typeof t=="boolean"||typeof t=="string"&&!t.trim()?!1:Array.isArray(t)?t.some(x):y.isValidElement(t)&&t.type===y.Fragment?x(t.props.children):!0}function K(t,l){const a=t.getBoundingClientRect(),b=l.clientX-a.left,u=l.clientY-a.top;t.style.setProperty("--nk-button-glow-x",`${b}px`),t.style.setProperty("--nk-button-glow-y",`${u}px`)}const $=y.forwardRef(function(l,a){const{as:b,children:u,className:w,disabled:I,fullWidth:A=!1,icon:s,iconAlignment:k="left",loading:h=!1,onClick:q,onKeyDown:v,onMouseMove:D,role:g,shape:R="capsule",tabIndex:P,textAlignment:E="center",tone:M,variant:N="primary",...c}=l,i=b??"button",o=I||h,S=!!s&&!x(u),d=i==="a"&&"href"in c&&typeof c.href=="string",f=typeof i=="string"&&i!=="button"&&!d,_=e=>{if(o){e.preventDefault(),e.stopPropagation();return}const n=q;n==null||n(e)},T=e=>{K(e.currentTarget,e);const n=D;n==null||n(e)},z=e=>{const n=v;n==null||n(e),!(e.defaultPrevented||o||!f||e.key!=="Enter"&&e.key!==" ")&&(e.preventDefault(),e.currentTarget.click())},j={"aria-disabled":o||void 0};i==="button"&&(j.type=c.type??"button");const C=d&&o?{href:void 0}:void 0;let m=g;d&&o?m=g??"link":f&&(m=g??"button");let p=P;return i!=="button"&&(d&&o?p=void 0:o?p=-1:f&&(p=P??0)),y.createElement(i,{...c,...j,...C,ref:a,"aria-busy":h||void 0,className:["nk-button",w].filter(Boolean).join(" "),"data-full-width":A||void 0,"data-icon-only":S||void 0,"data-shape":R,"data-tone":M,"data-variant":N,onClick:_,onKeyDown:f?z:v,onMouseMove:T,role:m,tabIndex:p},r.jsxs(r.Fragment,{children:[r.jsxs("span",{className:"nk-button__content",style:{justifyContent:E},children:[s&&k==="left"?r.jsx(B.Icon,{type:s}):null,u,s&&k==="right"?r.jsx(B.Icon,{type:s}):null]}),h?r.jsx(F.Spinner,{"aria-hidden":"true","aria-label":void 0,className:"nk-button__spinner",role:void 0,size:16}):null]}))});exports.Button=$;
1
+ "use client";"use strict";const r=require("react/jsx-runtime"),y=require("react"),B=require("./Icon-BIBzgznI.cjs"),F=require("./Spinner-BE0F4y2S.cjs");function x(t){return t==null||typeof t=="boolean"||typeof t=="string"&&!t.trim()?!1:Array.isArray(t)?t.some(x):y.isValidElement(t)&&t.type===y.Fragment?x(t.props.children):!0}function K(t,l){const a=t.getBoundingClientRect(),b=l.clientX-a.left,u=l.clientY-a.top;t.style.setProperty("--nk-button-glow-x",`${b}px`),t.style.setProperty("--nk-button-glow-y",`${u}px`)}const $=y.forwardRef(function(l,a){const{as:b,children:u,className:w,disabled:I,fullWidth:A=!1,icon:s,iconAlignment:k="left",loading:h=!1,onClick:q,onKeyDown:v,onMouseMove:D,role:g,shape:R="capsule",tabIndex:P,textAlignment:E="center",tone:M,variant:N="primary",...c}=l,i=b??"button",o=I||h,S=!!s&&!x(u),d=i==="a"&&"href"in c&&typeof c.href=="string",f=typeof i=="string"&&i!=="button"&&!d,_=e=>{if(o){e.preventDefault(),e.stopPropagation();return}const n=q;n==null||n(e)},T=e=>{K(e.currentTarget,e);const n=D;n==null||n(e)},z=e=>{const n=v;n==null||n(e),!(e.defaultPrevented||o||!f||e.key!=="Enter"&&e.key!==" ")&&(e.preventDefault(),e.currentTarget.click())},j={"aria-disabled":o||void 0};i==="button"&&(j.type=c.type??"button");const C=d&&o?{href:void 0}:void 0;let m=g;d&&o?m=g??"link":f&&(m=g??"button");let p=P;return i!=="button"&&(d&&o?p=void 0:o?p=-1:f&&(p=P??0)),y.createElement(i,{...c,...j,...C,ref:a,"aria-busy":h||void 0,className:["nk-button",w].filter(Boolean).join(" "),"data-full-width":A||void 0,"data-icon-only":S||void 0,"data-shape":R,"data-tone":M,"data-variant":N,onClick:_,onKeyDown:f?z:v,onMouseMove:T,role:m,tabIndex:p},r.jsxs(r.Fragment,{children:[r.jsxs("span",{className:"nk-button__content",style:{justifyContent:E},children:[s&&k==="left"?r.jsx(B.Icon,{type:s}):null,u,s&&k==="right"?r.jsx(B.Icon,{type:s}):null]}),h?r.jsx(F.Spinner,{"aria-hidden":"true","aria-label":void 0,className:"nk-button__spinner",role:void 0,size:16}):null]}))});exports.Button=$;
@@ -2,7 +2,7 @@
2
2
  import { jsxs as B, Fragment as C, jsx as g } from "react/jsx-runtime";
3
3
  import { forwardRef as K, createElement as q, isValidElement as G, Fragment as O } from "react";
4
4
  import { I as w } from "./Icon-CxK1wlGk.js";
5
- import { S as V } from "./Spinner-CVYvk6YK.js";
5
+ import { S as V } from "./Spinner-CmxlDlOk.js";
6
6
  function h(t) {
7
7
  return t == null || typeof t == "boolean" || typeof t == "string" && !t.trim() ? !1 : Array.isArray(t) ? t.some(h) : G(t) && t.type === O ? h(t.props.children) : !0;
8
8
  }
package/dist/Button.cjs CHANGED
@@ -1 +1 @@
1
- "use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./Button-DU4j_IED.cjs");exports.default=e.Button;
1
+ "use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./Button-CVe9T_Zw.cjs");exports.default=e.Button;
package/dist/Button.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { B as a } from "./Button-BV5OUXpc.js";
2
+ import { B as a } from "./Button-D6rXvcqq.js";
3
3
  export {
4
4
  a as default
5
5
  };
package/dist/Checkbox.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"),N=require("./aria-Bntn6ad_.cjs"),Q=require("./field-control-NfLwcPj6.cjs"),W=require("./Icon-BIBzgznI.cjs"),Z=require("./Text-DWYlIcPj.cjs"),T=Symbol("nk-checkbox-option");function $(o){Object.assign(o,{[T]:!0})}function F(o){if(typeof o!="function"&&typeof o!="object"||o===null)return!1;const a=o;return a[T]?!0:a.type!==void 0&&a.type!==o?F(a.type):!1}const z=r.createContext(void 0),ee=Object.freeze([]);function K(o,a){r.Children.forEach(o,n=>{if(n==null||typeof n=="boolean")return;if(!r.isValidElement(n))throw new Error("Checkbox.Group children must be direct Checkbox elements or fragments");if(n.type===r.Fragment){K(n.props.children,a);return}if(!F(n.type))throw new Error("Checkbox.Group children must be direct Checkbox elements or fragments");const i=n;a.push({disabled:!!i.props.disabled,required:!!i.props.required,value:String(i.props.value??"on")})})}function ne(o){const a=[];K(o,a);const n=new Set;return a.forEach(i=>{if(n.has(i.value))throw new Error("Checkbox.Group Checkbox values must be unique");n.add(i.value)}),a}function te(o,a,n){a.current=o,typeof n=="function"?n(o):n&&(n.current=o)}const U=r.forwardRef(function(a,n){const{"aria-invalid":i,children:u,className:S,defaultValue:s=ee,disabled:d=!1,invalid:E=!1,name:j,onChange:v,orientation:k="vertical",required:f=!1,value:x,...y}=a,p=r.useRef(null),[e,h]=r.useState(s),c=x!==void 0,O=c?x:e,B=E||N.hasInvalidState(i),_=ne(u),g=d?[]:_.filter(t=>!t.disabled).map(t=>t.value),m=new Set(g),C=O.some(t=>m.has(t)),V=g[0],R=_.find(t=>!t.disabled&&t.value===V),P=s.some(t=>m.has(t)),w=!!(R!=null&&R.required),D=r.useCallback(t=>te(t,p,n),[n]);r.useEffect(()=>{var I;if(c)return;const t=(I=p.current)==null?void 0:I.querySelector('input[type="checkbox"]'),b=t instanceof HTMLInputElement?t.form:null;if(!b)return;const G=b.getRootNode();function q(A){var L;if(A.target!==b||A.defaultPrevented)return;const H=Array.from(((L=p.current)==null?void 0:L.querySelectorAll('input[type="checkbox"]'))??[]).find(M=>!M.disabled&&M.value===V);H&&(H.required=!!(w||f&&!P)),h(s)}return G.addEventListener("reset",q),()=>G.removeEventListener("reset",q)},[u,s,P,c,f,w,V]);function Y(t){if(!c){const b=t.currentTarget.value,G=t.currentTarget.checked;h(q=>G?[...new Set([...q,b])]:q.filter(I=>I!==b))}v==null||v(t)}const J={defaultValue:s,disabled:d,handleChange:Y,hasSelection:C,name:j,required:f,value:x,validationValue:V};return l.jsx(z.Provider,{value:J,children:l.jsx("div",{...y,ref:D,"aria-disabled":d||void 0,"aria-invalid":N.resolveAriaInvalid(E,i),className:["nk-checkbox-group",S].filter(Boolean).join(" "),"data-disabled":d||void 0,"data-invalid":B||void 0,"data-orientation":k,role:"group",children:u})})});Q.markFieldGroupControl(U,"label");function oe(){return r.useContext(z)}const X=r.forwardRef(function(a,n){var m;const{"aria-invalid":i,checked:u,children:S,className:s,defaultChecked:d,disabled:E=!1,invalid:j=!1,name:v,onChange:k,required:f=!1,style:x,value:y="on",...p}=a,e=oe(),h=String(y),c=(e==null?void 0:e.value)!==void 0,O=E||!!(e!=null&&e.disabled),B=!!(e!=null&&e.required&&!e.hasSelection&&e.validationValue===h),_=j||N.hasInvalidState(i);function g(C){k==null||k(C),C.defaultPrevented||e==null||e.handleChange(C)}return l.jsxs("label",{className:["nk-checkbox",s].filter(Boolean).join(" "),"data-disabled":O||void 0,"data-invalid":_||void 0,style:x,children:[l.jsx("input",{...p,ref:n,"aria-invalid":N.resolveAriaInvalid(j,i),checked:e?c?(m=e.value)==null?void 0:m.includes(h):void 0:u,className:"nk-checkbox__control",defaultChecked:e&&!c?e.defaultValue.includes(h):d,disabled:O,name:(e==null?void 0:e.name)??v,onChange:g,required:f||B,type:"checkbox",value:y}),l.jsx("span",{"aria-hidden":"true",className:"nk-checkbox__visual",children:l.jsx(W.Icon,{className:"nk-checkbox__icon",size:12,type:"checkmark"})}),S!==void 0?l.jsxs(Z.Text,{as:"span",className:"nk-checkbox__label",children:[S,f?l.jsx("span",{"aria-hidden":"true",className:"nk-checkbox__required",children:"*"}):null]}):null]})});$(X);const ae=Object.assign(X,{Group:U});exports.default=ae;
1
+ "use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const l=require("react/jsx-runtime"),i=require("react"),I=require("./aria-Bntn6ad_.cjs"),Q=require("./reference-C2guRuR0.cjs"),W=require("./field-control-NfLwcPj6.cjs"),Z=require("./Icon-BIBzgznI.cjs"),$=require("./Text-DWYlIcPj.cjs"),T=Symbol("nk-checkbox-option");function ee(a){Object.assign(a,{[T]:!0})}function F(a){if(typeof a!="function"&&typeof a!="object"||a===null)return!1;const o=a;return o[T]?!0:o.type!==void 0&&o.type!==a?F(o.type):!1}const z=i.createContext(void 0),ne=Object.freeze([]);function K(a,o){i.Children.forEach(a,t=>{if(t==null||typeof t=="boolean")return;if(!i.isValidElement(t))throw new Error("Checkbox.Group children must be direct Checkbox elements or fragments");if(t.type===i.Fragment){K(t.props.children,o);return}if(!F(t.type))throw new Error("Checkbox.Group children must be direct Checkbox elements or fragments");const r=t;o.push({disabled:!!r.props.disabled,required:!!r.props.required,value:String(r.props.value??"on")})})}function te(a){const o=[];K(a,o);const t=new Set;return o.forEach(r=>{if(t.has(r.value))throw new Error("Checkbox.Group Checkbox values must be unique");t.add(r.value)}),o}function oe(a,o,t){o.current=a,Q.assignElementReference(t,a)}const U=i.forwardRef(function(o,t){const{"aria-invalid":r,children:u,className:E,defaultValue:s=ne,disabled:d=!1,invalid:S=!1,name:j,onChange:v,orientation:k="vertical",required:f=!1,value:x,...g}=o,p=i.useRef(null),[e,h]=i.useState(s),c=x!==void 0,O=c?x:e,N=S||I.hasInvalidState(r),_=te(u),y=d?[]:_.filter(n=>!n.disabled).map(n=>n.value),m=new Set(y),C=O.some(n=>m.has(n)),V=y[0],w=_.find(n=>!n.disabled&&n.value===V),B=s.some(n=>m.has(n)),P=!!(w!=null&&w.required),D=i.useCallback(n=>oe(n,p,t),[t]);i.useEffect(()=>{var G;if(c)return;const n=(G=p.current)==null?void 0:G.querySelector('input[type="checkbox"]'),b=n instanceof HTMLInputElement?n.form:null;if(!b)return;const R=b.getRootNode();function q(A){var L;if(A.target!==b||A.defaultPrevented)return;const H=Array.from(((L=p.current)==null?void 0:L.querySelectorAll('input[type="checkbox"]'))??[]).find(M=>!M.disabled&&M.value===V);H&&(H.required=!!(P||f&&!B)),h(s)}return R.addEventListener("reset",q),()=>R.removeEventListener("reset",q)},[u,s,B,c,f,P,V]);function Y(n){if(!c){const b=n.currentTarget.value,R=n.currentTarget.checked;h(q=>R?[...new Set([...q,b])]:q.filter(G=>G!==b))}v==null||v(n)}const J={defaultValue:s,disabled:d,handleChange:Y,hasSelection:C,name:j,required:f,value:x,validationValue:V};return l.jsx(z.Provider,{value:J,children:l.jsx("div",{...g,ref:D,"aria-disabled":d||void 0,"aria-invalid":I.resolveAriaInvalid(S,r),className:["nk-checkbox-group",E].filter(Boolean).join(" "),"data-disabled":d||void 0,"data-invalid":N||void 0,"data-orientation":k,role:"group",children:u})})});W.markFieldGroupControl(U,"label");function ae(){return i.useContext(z)}const X=i.forwardRef(function(o,t){var m;const{"aria-invalid":r,checked:u,children:E,className:s,defaultChecked:d,disabled:S=!1,invalid:j=!1,name:v,onChange:k,required:f=!1,style:x,value:g="on",...p}=o,e=ae(),h=String(g),c=(e==null?void 0:e.value)!==void 0,O=S||!!(e!=null&&e.disabled),N=!!(e!=null&&e.required&&!e.hasSelection&&e.validationValue===h),_=j||I.hasInvalidState(r);function y(C){k==null||k(C),C.defaultPrevented||e==null||e.handleChange(C)}return l.jsxs("label",{className:["nk-checkbox",s].filter(Boolean).join(" "),"data-disabled":O||void 0,"data-invalid":_||void 0,style:x,children:[l.jsx("input",{...p,ref:t,"aria-invalid":I.resolveAriaInvalid(j,r),checked:e?c?(m=e.value)==null?void 0:m.includes(h):void 0:u,className:"nk-checkbox__control",defaultChecked:e&&!c?e.defaultValue.includes(h):d,disabled:O,name:(e==null?void 0:e.name)??v,onChange:y,required:f||N,type:"checkbox",value:g}),l.jsx("span",{"aria-hidden":"true",className:"nk-checkbox__visual",children:l.jsx(Z.Icon,{className:"nk-checkbox__icon",size:12,type:"checkmark"})}),E!==void 0?l.jsxs($.Text,{as:"span",className:"nk-checkbox__label",children:[E,f?l.jsx("span",{"aria-hidden":"true",className:"nk-checkbox__required",children:"*"}):null]}):null]})});ee(X);const re=Object.assign(X,{Group:U});exports.default=re;
package/dist/Checkbox.js CHANGED
@@ -1,216 +1,217 @@
1
1
  "use client";
2
2
  import { jsx as h, jsxs as L } from "react/jsx-runtime";
3
- import { createContext as Z, forwardRef as F, useRef as $, useState as ee, useCallback as ne, useEffect as oe, Children as te, isValidElement as ae, Fragment as ie, useContext as re } from "react";
3
+ import { createContext as Z, forwardRef as F, useRef as $, useState as ee, useCallback as ne, useEffect as oe, Children as te, isValidElement as ae, Fragment as re, useContext as ie } from "react";
4
4
  import { r as T, h as z } from "./aria-CeA9QfD1.js";
5
- import { m as le } from "./field-control-XAn_FKks.js";
6
- import { I as se } from "./Icon-CxK1wlGk.js";
7
- import { T as ce } from "./Text-rN6iDo0V.js";
5
+ import { a as le } from "./reference-CXMr27nM.js";
6
+ import { m as se } from "./field-control-XAn_FKks.js";
7
+ import { I as ce } from "./Icon-CxK1wlGk.js";
8
+ import { T as de } from "./Text-rN6iDo0V.js";
8
9
  const K = Symbol("nk-checkbox-option");
9
- function ue(t) {
10
- Object.assign(t, { [K]: !0 });
10
+ function ue(a) {
11
+ Object.assign(a, { [K]: !0 });
11
12
  }
12
- function M(t) {
13
- if (typeof t != "function" && typeof t != "object" || t === null)
13
+ function M(a) {
14
+ if (typeof a != "function" && typeof a != "object" || a === null)
14
15
  return !1;
15
- const a = t;
16
- return a[K] ? !0 : a.type !== void 0 && a.type !== t ? M(a.type) : !1;
16
+ const t = a;
17
+ return t[K] ? !0 : t.type !== void 0 && t.type !== a ? M(t.type) : !1;
17
18
  }
18
- const U = Z(void 0), de = Object.freeze([]);
19
- function X(t, a) {
20
- te.forEach(t, (n) => {
21
- if (n == null || typeof n == "boolean")
19
+ const U = Z(void 0), fe = Object.freeze([]);
20
+ function X(a, t) {
21
+ te.forEach(a, (o) => {
22
+ if (o == null || typeof o == "boolean")
22
23
  return;
23
- if (!ae(n))
24
+ if (!ae(o))
24
25
  throw new Error(
25
26
  "Checkbox.Group children must be direct Checkbox elements or fragments"
26
27
  );
27
- if (n.type === ie) {
28
- X(n.props.children, a);
28
+ if (o.type === re) {
29
+ X(o.props.children, t);
29
30
  return;
30
31
  }
31
- if (!M(n.type))
32
+ if (!M(o.type))
32
33
  throw new Error(
33
34
  "Checkbox.Group children must be direct Checkbox elements or fragments"
34
35
  );
35
- const i = n;
36
- a.push({
37
- disabled: !!i.props.disabled,
38
- required: !!i.props.required,
39
- value: String(i.props.value ?? "on")
36
+ const r = o;
37
+ t.push({
38
+ disabled: !!r.props.disabled,
39
+ required: !!r.props.required,
40
+ value: String(r.props.value ?? "on")
40
41
  });
41
42
  });
42
43
  }
43
- function fe(t) {
44
- const a = [];
45
- X(t, a);
46
- const n = /* @__PURE__ */ new Set();
47
- return a.forEach((i) => {
48
- if (n.has(i.value))
44
+ function he(a) {
45
+ const t = [];
46
+ X(a, t);
47
+ const o = /* @__PURE__ */ new Set();
48
+ return t.forEach((r) => {
49
+ if (o.has(r.value))
49
50
  throw new Error("Checkbox.Group Checkbox values must be unique");
50
- n.add(i.value);
51
- }), a;
51
+ o.add(r.value);
52
+ }), t;
52
53
  }
53
- function he(t, a, n) {
54
- a.current = t, typeof n == "function" ? n(t) : n && (n.current = t);
54
+ function be(a, t, o) {
55
+ t.current = a, le(o, a);
55
56
  }
56
57
  const D = F(
57
- function(a, n) {
58
+ function(t, o) {
58
59
  const {
59
- "aria-invalid": i,
60
+ "aria-invalid": r,
60
61
  children: s,
61
62
  className: E,
62
- defaultValue: r = de,
63
+ defaultValue: i = fe,
63
64
  disabled: c = !1,
64
65
  invalid: S = !1,
65
66
  name: q,
66
67
  onChange: b,
67
- orientation: k = "vertical",
68
- required: u = !1,
69
- value: p,
70
- ...y
71
- } = a, v = $(null), [e, d] = ee(r), l = p !== void 0, O = l ? p : e, B = S || z(i), V = fe(s), _ = c ? [] : V.filter((o) => !o.disabled).map((o) => o.value), m = new Set(_), x = O.some(
72
- (o) => m.has(o)
73
- ), g = _[0], I = V.find(
74
- (o) => !o.disabled && o.value === g
75
- ), j = r.some(
76
- (o) => m.has(o)
77
- ), P = !!(I != null && I.required), J = ne(
78
- (o) => he(
79
- o,
80
- v,
81
- n
68
+ orientation: m = "vertical",
69
+ required: d = !1,
70
+ value: k,
71
+ ...O
72
+ } = t, p = $(null), [e, u] = ee(i), l = k !== void 0, V = l ? k : e, R = S || z(r), g = he(s), y = c ? [] : g.filter((n) => !n.disabled).map((n) => n.value), v = new Set(y), x = V.some(
73
+ (n) => v.has(n)
74
+ ), _ = y[0], B = g.find(
75
+ (n) => !n.disabled && n.value === _
76
+ ), I = i.some(
77
+ (n) => v.has(n)
78
+ ), w = !!(B != null && B.required), J = ne(
79
+ (n) => be(
80
+ n,
81
+ p,
82
+ o
82
83
  ),
83
- [n]
84
+ [o]
84
85
  );
85
86
  oe(() => {
86
87
  var N;
87
88
  if (l) return;
88
- const o = (N = v.current) == null ? void 0 : N.querySelector(
89
+ const n = (N = p.current) == null ? void 0 : N.querySelector(
89
90
  'input[type="checkbox"]'
90
- ), f = o instanceof HTMLInputElement ? o.form : null;
91
+ ), f = n instanceof HTMLInputElement ? n.form : null;
91
92
  if (!f) return;
92
93
  const G = f.getRootNode();
93
- function C(R) {
94
+ function C(j) {
94
95
  var A;
95
- if (R.target !== f || R.defaultPrevented) return;
96
- const w = Array.from(
97
- ((A = v.current) == null ? void 0 : A.querySelectorAll(
96
+ if (j.target !== f || j.defaultPrevented) return;
97
+ const P = Array.from(
98
+ ((A = p.current) == null ? void 0 : A.querySelectorAll(
98
99
  'input[type="checkbox"]'
99
100
  )) ?? []
100
101
  ).find(
101
- (H) => !H.disabled && H.value === g
102
+ (H) => !H.disabled && H.value === _
102
103
  );
103
- w && (w.required = !!(P || u && !j)), d(r);
104
+ P && (P.required = !!(w || d && !I)), u(i);
104
105
  }
105
106
  return G.addEventListener("reset", C), () => G.removeEventListener("reset", C);
106
107
  }, [
107
108
  s,
108
- r,
109
- j,
109
+ i,
110
+ I,
110
111
  l,
111
- u,
112
- P,
113
- g
112
+ d,
113
+ w,
114
+ _
114
115
  ]);
115
- function Q(o) {
116
+ function Q(n) {
116
117
  if (!l) {
117
- const f = o.currentTarget.value, G = o.currentTarget.checked;
118
- d((C) => G ? [.../* @__PURE__ */ new Set([...C, f])] : C.filter((N) => N !== f));
118
+ const f = n.currentTarget.value, G = n.currentTarget.checked;
119
+ u((C) => G ? [.../* @__PURE__ */ new Set([...C, f])] : C.filter((N) => N !== f));
119
120
  }
120
- b == null || b(o);
121
+ b == null || b(n);
121
122
  }
122
123
  const W = {
123
- defaultValue: r,
124
+ defaultValue: i,
124
125
  disabled: c,
125
126
  handleChange: Q,
126
127
  hasSelection: x,
127
128
  name: q,
128
- required: u,
129
- value: p,
130
- validationValue: g
129
+ required: d,
130
+ value: k,
131
+ validationValue: _
131
132
  };
132
133
  return /* @__PURE__ */ h(U.Provider, { value: W, children: /* @__PURE__ */ h(
133
134
  "div",
134
135
  {
135
- ...y,
136
+ ...O,
136
137
  ref: J,
137
138
  "aria-disabled": c || void 0,
138
- "aria-invalid": T(S, i),
139
+ "aria-invalid": T(S, r),
139
140
  className: [
140
141
  "nk-checkbox-group",
141
142
  E
142
143
  ].filter(Boolean).join(" "),
143
144
  "data-disabled": c || void 0,
144
- "data-invalid": B || void 0,
145
- "data-orientation": k,
145
+ "data-invalid": R || void 0,
146
+ "data-orientation": m,
146
147
  role: "group",
147
148
  children: s
148
149
  }
149
150
  ) });
150
151
  }
151
152
  );
152
- le(D, "label");
153
- function be() {
154
- return re(U);
153
+ se(D, "label");
154
+ function me() {
155
+ return ie(U);
155
156
  }
156
- const Y = F(function(a, n) {
157
- var m;
157
+ const Y = F(function(t, o) {
158
+ var v;
158
159
  const {
159
- "aria-invalid": i,
160
+ "aria-invalid": r,
160
161
  checked: s,
161
162
  children: E,
162
- className: r,
163
+ className: i,
163
164
  defaultChecked: c,
164
165
  disabled: S = !1,
165
166
  invalid: q = !1,
166
167
  name: b,
167
- onChange: k,
168
- required: u = !1,
169
- style: p,
170
- value: y = "on",
171
- ...v
172
- } = a, e = be(), d = String(y), l = (e == null ? void 0 : e.value) !== void 0, O = S || !!(e != null && e.disabled), B = !!(e != null && e.required && !e.hasSelection && e.validationValue === d), V = q || z(i);
173
- function _(x) {
174
- k == null || k(x), x.defaultPrevented || e == null || e.handleChange(x);
168
+ onChange: m,
169
+ required: d = !1,
170
+ style: k,
171
+ value: O = "on",
172
+ ...p
173
+ } = t, e = me(), u = String(O), l = (e == null ? void 0 : e.value) !== void 0, V = S || !!(e != null && e.disabled), R = !!(e != null && e.required && !e.hasSelection && e.validationValue === u), g = q || z(r);
174
+ function y(x) {
175
+ m == null || m(x), x.defaultPrevented || e == null || e.handleChange(x);
175
176
  }
176
177
  return /* @__PURE__ */ L(
177
178
  "label",
178
179
  {
179
- className: ["nk-checkbox", r].filter(Boolean).join(" "),
180
- "data-disabled": O || void 0,
181
- "data-invalid": V || void 0,
182
- style: p,
180
+ className: ["nk-checkbox", i].filter(Boolean).join(" "),
181
+ "data-disabled": V || void 0,
182
+ "data-invalid": g || void 0,
183
+ style: k,
183
184
  children: [
184
185
  /* @__PURE__ */ h(
185
186
  "input",
186
187
  {
187
- ...v,
188
- ref: n,
189
- "aria-invalid": T(q, i),
190
- checked: e ? l ? (m = e.value) == null ? void 0 : m.includes(d) : void 0 : s,
188
+ ...p,
189
+ ref: o,
190
+ "aria-invalid": T(q, r),
191
+ checked: e ? l ? (v = e.value) == null ? void 0 : v.includes(u) : void 0 : s,
191
192
  className: "nk-checkbox__control",
192
- defaultChecked: e && !l ? e.defaultValue.includes(d) : c,
193
- disabled: O,
193
+ defaultChecked: e && !l ? e.defaultValue.includes(u) : c,
194
+ disabled: V,
194
195
  name: (e == null ? void 0 : e.name) ?? b,
195
- onChange: _,
196
- required: u || B,
196
+ onChange: y,
197
+ required: d || R,
197
198
  type: "checkbox",
198
- value: y
199
+ value: O
199
200
  }
200
201
  ),
201
- /* @__PURE__ */ h("span", { "aria-hidden": "true", className: "nk-checkbox__visual", children: /* @__PURE__ */ h(se, { className: "nk-checkbox__icon", size: 12, type: "checkmark" }) }),
202
- E !== void 0 ? /* @__PURE__ */ L(ce, { as: "span", className: "nk-checkbox__label", children: [
202
+ /* @__PURE__ */ h("span", { "aria-hidden": "true", className: "nk-checkbox__visual", children: /* @__PURE__ */ h(ce, { className: "nk-checkbox__icon", size: 12, type: "checkmark" }) }),
203
+ E !== void 0 ? /* @__PURE__ */ L(de, { as: "span", className: "nk-checkbox__label", children: [
203
204
  E,
204
- u ? /* @__PURE__ */ h("span", { "aria-hidden": "true", className: "nk-checkbox__required", children: "*" }) : null
205
+ d ? /* @__PURE__ */ h("span", { "aria-hidden": "true", className: "nk-checkbox__required", children: "*" }) : null
205
206
  ] }) : null
206
207
  ]
207
208
  }
208
209
  );
209
210
  });
210
211
  ue(Y);
211
- const Ee = Object.assign(Y, {
212
+ const qe = Object.assign(Y, {
212
213
  Group: D
213
214
  });
214
215
  export {
215
- Ee as default
216
+ qe as default
216
217
  };
package/dist/Input.cjs CHANGED
@@ -1 +1 @@
1
- "use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const i=require("react/jsx-runtime"),t=require("react"),S=require("./Button-DU4j_IED.cjs"),$=require("./Spinner-BXgw60UC.cjs"),w=require("./aria-Bntn6ad_.cjs");function v(a){return Array.isArray(a)?a.length>0:a!=null&&String(a).length>0}function F(a,s,n){s.current=a,typeof n=="function"?n(a):n&&(n.current=a)}function G(a){var n;const s=(n=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(a),"value"))==null?void 0:n.set;s?s.call(a,""):a.value=""}const J=t.forwardRef(function(s,n){const{"aria-busy":V,"aria-invalid":b,className:C,clearable:y=!1,defaultValue:g,disabled:A=!1,id:N,invalid:h=!1,loading:l=!1,onChange:d,readOnly:p=!1,style:P,type:r="text",value:o,...m}=s,O=t.useId(),I=t.useRef(null),[q,B]=t.useState(v(g)),[u,_]=t.useState(!1);t.useEffect(()=>{r!=="password"&&_(!1)},[r]);const T=t.useCallback(e=>F(e,I,n),[n]),f=N??`${O}-control`,c=A||l,D=h||w.hasInvalidState(b),E=o!==void 0?v(o):q,H=r==="password"&&u?"text":r,M=w.resolveAriaInvalid(h,b),j=y&&E&&!p&&!c,k=r==="password"&&!l,x=j||k;function R(e){o===void 0&&B(v(e.currentTarget.value)),d==null||d(e)}function U(){const e=I.current;e&&(G(e),e.dispatchEvent(new Event("input",{bubbles:!0})),e.focus())}function z(){_(e=>!e)}return i.jsxs("div",{className:["nk-input",C].filter(Boolean).join(" "),"data-clearable":y||void 0,"data-disabled":c||void 0,"data-invalid":D||void 0,"data-loading":l||void 0,"data-read-only":p||void 0,"data-has-trailing-action":x||void 0,style:P,children:[i.jsx("input",{...m,ref:T,"aria-busy":l?!0:V,"aria-invalid":M,className:"nk-input__control",defaultValue:g,disabled:c,id:f,onChange:R,readOnly:p,type:H,value:o}),x?i.jsxs("span",{className:"nk-input__trailing",children:[j?i.jsx(S.Button,{"aria-controls":f,"aria-label":"Clear input",className:"nk-input__action",icon:"cross",onClick:U,shape:"rectangle",type:"button",variant:"ghost"}):null,k?i.jsx(S.Button,{"aria-controls":f,"aria-label":u?"Hide password":"Show password","aria-pressed":u,className:"nk-input__action",disabled:c,icon:u?"eye-off":"eye",onClick:z,shape:"rectangle",type:"button",variant:"ghost"}):null]}):null,l?i.jsx($.Spinner,{"aria-hidden":"true","aria-label":void 0,className:"nk-input__spinner",role:void 0,size:14}):null]})});exports.default=J;
1
+ "use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const i=require("react/jsx-runtime"),t=require("react"),x=require("./Button-CVe9T_Zw.cjs"),$=require("./Spinner-BE0F4y2S.cjs"),S=require("./aria-Bntn6ad_.cjs"),F=require("./reference-C2guRuR0.cjs");function v(e){return Array.isArray(e)?e.length>0:e!=null&&String(e).length>0}function G(e,s,n){s.current=e,F.assignElementReference(n,e)}function J(e){var n;const s=(n=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(e),"value"))==null?void 0:n.set;s?s.call(e,""):e.value=""}const K=t.forwardRef(function(s,n){const{"aria-busy":V,"aria-invalid":b,className:m,clearable:y=!1,defaultValue:g,disabled:C=!1,id:A,invalid:h=!1,loading:l=!1,onChange:d,readOnly:p=!1,style:N,type:r="text",value:o,...P}=s,q=t.useId(),I=t.useRef(null),[O,R]=t.useState(v(g)),[c,w]=t.useState(!1);t.useEffect(()=>{r!=="password"&&w(!1)},[r]);const B=t.useCallback(a=>G(a,I,n),[n]),f=A??`${q}-control`,u=C||l,T=h||S.hasInvalidState(b),E=o!==void 0?v(o):O,D=r==="password"&&c?"text":r,H=S.resolveAriaInvalid(h,b),_=y&&E&&!p&&!u,j=r==="password"&&!l,k=_||j;function M(a){o===void 0&&R(v(a.currentTarget.value)),d==null||d(a)}function U(){const a=I.current;a&&(J(a),a.dispatchEvent(new Event("input",{bubbles:!0})),a.focus())}function z(){w(a=>!a)}return i.jsxs("div",{className:["nk-input",m].filter(Boolean).join(" "),"data-clearable":y||void 0,"data-disabled":u||void 0,"data-invalid":T||void 0,"data-loading":l||void 0,"data-read-only":p||void 0,"data-has-trailing-action":k||void 0,style:N,children:[i.jsx("input",{...P,ref:B,"aria-busy":l?!0:V,"aria-invalid":H,className:"nk-input__control",defaultValue:g,disabled:u,id:f,onChange:M,readOnly:p,type:D,value:o}),k?i.jsxs("span",{className:"nk-input__trailing",children:[_?i.jsx(x.Button,{"aria-controls":f,"aria-label":"Clear input",className:"nk-input__action",icon:"cross",onClick:U,shape:"rectangle",type:"button",variant:"ghost"}):null,j?i.jsx(x.Button,{"aria-controls":f,"aria-label":c?"Hide password":"Show password","aria-pressed":c,className:"nk-input__action",disabled:u,icon:c?"eye-off":"eye",onClick:z,shape:"rectangle",type:"button",variant:"ghost"}):null]}):null,l?i.jsx($.Spinner,{"aria-hidden":"true","aria-label":void 0,className:"nk-input__spinner",role:void 0,size:14}):null]})});exports.default=K;
package/dist/Input.js CHANGED
@@ -1,95 +1,96 @@
1
1
  "use client";
2
- import { jsxs as w, jsx as c } from "react/jsx-runtime";
2
+ import { jsxs as _, jsx as d } from "react/jsx-runtime";
3
3
  import { forwardRef as F, useId as G, useRef as J, useState as V, useEffect as K, useCallback as L } from "react";
4
- import { B as C } from "./Button-BV5OUXpc.js";
5
- import { S as M } from "./Spinner-CVYvk6YK.js";
4
+ import { B as C } from "./Button-D6rXvcqq.js";
5
+ import { S as M } from "./Spinner-CmxlDlOk.js";
6
6
  import { h as Q, r as W } from "./aria-CeA9QfD1.js";
7
+ import { a as X } from "./reference-CXMr27nM.js";
7
8
  function f(a) {
8
9
  return Array.isArray(a) ? a.length > 0 : a != null && String(a).length > 0;
9
10
  }
10
- function X(a, i, t) {
11
- i.current = a, typeof t == "function" ? t(a) : t && (t.current = a);
11
+ function Y(a, t, n) {
12
+ t.current = a, X(n, a);
12
13
  }
13
- function Y(a) {
14
- var t;
15
- const i = (t = Object.getOwnPropertyDescriptor(
14
+ function Z(a) {
15
+ var n;
16
+ const t = (n = Object.getOwnPropertyDescriptor(
16
17
  Object.getPrototypeOf(a),
17
18
  "value"
18
- )) == null ? void 0 : t.set;
19
- i ? i.call(a, "") : a.value = "";
19
+ )) == null ? void 0 : n.set;
20
+ t ? t.call(a, "") : a.value = "";
20
21
  }
21
- const sa = F(function(i, t) {
22
+ const la = F(function(t, n) {
22
23
  const {
23
24
  "aria-busy": A,
24
25
  "aria-invalid": v,
25
26
  className: N,
26
27
  clearable: b = !1,
27
- defaultValue: y,
28
+ defaultValue: h,
28
29
  disabled: S = !1,
29
30
  id: x,
30
- invalid: h = !1,
31
+ invalid: y = !1,
31
32
  loading: s = !1,
32
- onChange: d,
33
+ onChange: c,
33
34
  readOnly: u = !1,
34
35
  style: P,
35
- type: e = "text",
36
+ type: i = "text",
36
37
  value: l,
37
38
  ...j
38
- } = i, O = G(), g = J(null), [B, T] = V(
39
- f(y)
40
- ), [o, m] = V(!1);
39
+ } = t, O = G(), g = J(null), [R, B] = V(
40
+ f(h)
41
+ ), [r, m] = V(!1);
41
42
  K(() => {
42
- e !== "password" && m(!1);
43
- }, [e]);
44
- const D = L(
45
- (n) => X(
46
- n,
43
+ i !== "password" && m(!1);
44
+ }, [i]);
45
+ const E = L(
46
+ (e) => Y(
47
+ e,
47
48
  g,
48
- t
49
+ n
49
50
  ),
50
- [t]
51
- ), p = x ?? `${O}-control`, r = S || s, E = h || Q(v), H = l !== void 0 ? f(l) : B, U = e === "password" && o ? "text" : e, z = W(h, v), I = b && H && !u && !r, k = e === "password" && !s, _ = I || k;
52
- function R(n) {
53
- l === void 0 && T(f(n.currentTarget.value)), d == null || d(n);
51
+ [n]
52
+ ), p = x ?? `${O}-control`, o = S || s, T = y || Q(v), D = l !== void 0 ? f(l) : R, H = i === "password" && r ? "text" : i, U = W(y, v), I = b && D && !u && !o, w = i === "password" && !s, k = I || w;
53
+ function z(e) {
54
+ l === void 0 && B(f(e.currentTarget.value)), c == null || c(e);
54
55
  }
55
56
  function $() {
56
- const n = g.current;
57
- n && (Y(n), n.dispatchEvent(new Event("input", { bubbles: !0 })), n.focus());
57
+ const e = g.current;
58
+ e && (Z(e), e.dispatchEvent(new Event("input", { bubbles: !0 })), e.focus());
58
59
  }
59
60
  function q() {
60
- m((n) => !n);
61
+ m((e) => !e);
61
62
  }
62
- return /* @__PURE__ */ w(
63
+ return /* @__PURE__ */ _(
63
64
  "div",
64
65
  {
65
66
  className: ["nk-input", N].filter(Boolean).join(" "),
66
67
  "data-clearable": b || void 0,
67
- "data-disabled": r || void 0,
68
- "data-invalid": E || void 0,
68
+ "data-disabled": o || void 0,
69
+ "data-invalid": T || void 0,
69
70
  "data-loading": s || void 0,
70
71
  "data-read-only": u || void 0,
71
- "data-has-trailing-action": _ || void 0,
72
+ "data-has-trailing-action": k || void 0,
72
73
  style: P,
73
74
  children: [
74
- /* @__PURE__ */ c(
75
+ /* @__PURE__ */ d(
75
76
  "input",
76
77
  {
77
78
  ...j,
78
- ref: D,
79
+ ref: E,
79
80
  "aria-busy": s ? !0 : A,
80
- "aria-invalid": z,
81
+ "aria-invalid": U,
81
82
  className: "nk-input__control",
82
- defaultValue: y,
83
- disabled: r,
83
+ defaultValue: h,
84
+ disabled: o,
84
85
  id: p,
85
- onChange: R,
86
+ onChange: z,
86
87
  readOnly: u,
87
- type: U,
88
+ type: H,
88
89
  value: l
89
90
  }
90
91
  ),
91
- _ ? /* @__PURE__ */ w("span", { className: "nk-input__trailing", children: [
92
- I ? /* @__PURE__ */ c(
92
+ k ? /* @__PURE__ */ _("span", { className: "nk-input__trailing", children: [
93
+ I ? /* @__PURE__ */ d(
93
94
  C,
94
95
  {
95
96
  "aria-controls": p,
@@ -102,15 +103,15 @@ const sa = F(function(i, t) {
102
103
  variant: "ghost"
103
104
  }
104
105
  ) : null,
105
- k ? /* @__PURE__ */ c(
106
+ w ? /* @__PURE__ */ d(
106
107
  C,
107
108
  {
108
109
  "aria-controls": p,
109
- "aria-label": o ? "Hide password" : "Show password",
110
- "aria-pressed": o,
110
+ "aria-label": r ? "Hide password" : "Show password",
111
+ "aria-pressed": r,
111
112
  className: "nk-input__action",
112
- disabled: r,
113
- icon: o ? "eye-off" : "eye",
113
+ disabled: o,
114
+ icon: r ? "eye-off" : "eye",
114
115
  onClick: q,
115
116
  shape: "rectangle",
116
117
  type: "button",
@@ -118,7 +119,7 @@ const sa = F(function(i, t) {
118
119
  }
119
120
  ) : null
120
121
  ] }) : null,
121
- s ? /* @__PURE__ */ c(
122
+ s ? /* @__PURE__ */ d(
122
123
  M,
123
124
  {
124
125
  "aria-hidden": "true",
@@ -133,5 +134,5 @@ const sa = F(function(i, t) {
133
134
  );
134
135
  });
135
136
  export {
136
- sa as default
137
+ la as default
137
138
  };