@nild/components 0.0.46 → 0.0.48

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.
@@ -2,8 +2,7 @@ import { default as getComputedStyleValue } from './get-computed-style-value';
2
2
  import { default as getGlobalState, GlobalStateKey } from './get-global-state';
3
3
  import { default as getOwnerDocument } from './get-owner-document';
4
4
  import { default as isPlainChildren } from './is-plain-children';
5
- import { default as lockDocumentScroll } from './lock-document-scroll';
6
5
  import { default as mergeHandlers } from './merge-handlers';
7
6
  import { default as mergeProps } from './merge-props';
8
7
  import { default as registerSlots } from './register-slots';
9
- export { getGlobalState, getComputedStyleValue, getOwnerDocument, GlobalStateKey, isPlainChildren, lockDocumentScroll, registerSlots, mergeHandlers, mergeProps, };
8
+ export { getGlobalState, getComputedStyleValue, getOwnerDocument, GlobalStateKey, isPlainChildren, registerSlots, mergeHandlers, mergeProps, };
File without changes
package/dist/form/Form.js CHANGED
@@ -1 +1 @@
1
- import{jsx as j,jsxs as k}from"react/jsx-runtime";import{useEffectCallback as B}from"@nild/hooks";import{cnMerge as R}from"@nild/shared";import{forwardRef as D,useState as T,useRef as q,useCallback as z,useMemo as G}from"react";import H from"../_shared/utils/register-slots/index.js";import{isFieldElement as J}from"../field/Field.js";import{updateByPath as K,getByPath as L}from"./_shared/path.js";import{isActionsElement as O}from"./Actions.js";import{FormProvider as Q,hasIssues as U}from"./contexts/index.js";import{useFormIssues as W}from"./hooks/useFormIssues.js";import X from"./style/index.js";const M=(t,o)=>Array.isArray(t)?t.includes(o):t===o,Y=H({field:{isMatched:J,multiple:!0},actions:{isMatched:O}}),A=D((t,o)=>{const{className:F,children:V,defaultValue:w={},resolver:x,validateTrigger:m=["submit","change"],onChange:c,onInvalid:d,onSubmit:f,disabled:l=!1,...C}=t,[i,p]=T(w),{errors:E,getMeta:v,touch:I,touchAll:N,validateValue:h}=W({resolver:x}),a=q(i);a.current=i;const g=B((r,s)=>{const e=K(a.current,r,s);e!==a.current&&(p(e),a.current=e,I(r),c?.(e),M(m,"change")&&h(e,r))}),b=z(r=>L(i,r),[i]),P=async r=>{if(r.preventDefault(),l)return;const s=a.current,e=M(m,"submit")?await h(s):{value:s,errors:E};if(!e)return;const u=e.value??s,n=e.errors??{};if(e.value&&(a.current=e.value,p(e.value)),U(n)){N(u,n),d?.(n,u,r);return}await f?.(u,r)},S=G(()=>({disabled:l,getMeta:v,getValue:b,setValue:g}),[l,v,b,g]),{slots:y}=Y(V);return j(Q,{value:S,children:k("form",{...C,className:R(X.form(),F),"data-disabled":l||void 0,ref:o,onSubmit:P,children:[y.field.el,y.actions.el]})})});A.displayName="Form";export{A as default};
1
+ import{jsx as j,jsxs as k}from"react/jsx-runtime";import{useRefState as B,useEffectCallback as R}from"@nild/hooks";import{cnMerge as D}from"@nild/shared";import{forwardRef as T,useCallback as q,useMemo as z}from"react";import G from"../_shared/utils/register-slots/index.js";import{isFieldElement as H}from"../field/Field.js";import{updateByPath as J,getByPath as K}from"./_shared/path.js";import{isActionsElement as L}from"./Actions.js";import{FormProvider as O,hasIssues as Q}from"./contexts/index.js";import{useFormIssues as U}from"./hooks/useFormIssues.js";import W from"./style/index.js";const M=(r,t)=>Array.isArray(r)?r.includes(t):r===t,X=G({field:{isMatched:H,multiple:!0},actions:{isMatched:L}}),A=T((r,t)=>{const{className:F,children:V,defaultValue:w={},resolver:x,validateTrigger:u=["submit","change"],onChange:n,onInvalid:c,onSubmit:d,disabled:o=!1,...C}=r,[f,p,l]=B(w),{errors:E,getMeta:v,touch:I,touchAll:N,validateValue:h}=U({resolver:x}),g=R((a,s)=>{const e=J(l.current,a,s);e!==l.current&&(p(e),I(a),n?.(e),M(u,"change")&&h(e,a))}),b=q(a=>K(f,a),[f]),P=async a=>{if(a.preventDefault(),o)return;const s=l.current,e=M(u,"submit")?await h(s):{value:s,errors:E};if(!e)return;const i=e.value??s,m=e.errors??{};if(e.value&&p(e.value),Q(m)){N(i,m),c?.(m,i,a);return}await d?.(i,a)},S=z(()=>({disabled:o,getMeta:v,getValue:b,setValue:g}),[o,v,b,g]),{slots:y}=X(V);return j(O,{value:S,children:k("form",{...C,className:D(W.form(),F),"data-disabled":o||void 0,ref:t,onSubmit:P,children:[y.field.el,y.actions.el]})})});A.displayName="Form";export{A as default};
@@ -1 +1 @@
1
- import{jsx as m,jsxs as y}from"react/jsx-runtime";import{useControllableState as E}from"@nild/hooks";import{cnMerge as N}from"@nild/shared";import{forwardRef as k,isValidElement as I}from"react";import M from"../_shared/utils/register-slots/index.js";import{useCompositeContext as j,InputProvider as P}from"./contexts/index.js";import{isPrefixElement as S}from"./Prefix.js";import p from"./style/index.js";import{isSuffixElement as V}from"./Suffix.js";const w=e=>I(e)&&e.type===r,J=M({prefix:{isMatched:S},suffix:{isMatched:V}}),r=k((e,d)=>{const a=j(),{className:f,children:u,variant:l=a.variant,size:t=a.size,block:c=a.block,disabled:s=a.disabled,type:v="text",value:x,defaultValue:b="",onChange:o,...h}=e,{slots:n}=J(u),[g,z]=E(x,b),C=i=>{z(i.target.value),o?.(i.target.value,i)};return m(P,{value:{size:t,disabled:s,variant:l},children:y("span",{className:N(p.inputWrapper({variant:l,size:t,block:c,disabled:s}),f),"data-disabled":s||void 0,children:[n.prefix.el,m("input",{ref:d,type:v,value:g,onChange:C,disabled:s,className:p.input({size:t}),...h}),n.suffix.el]})})});r.displayName="Input";export{r as default,w as isInputElement};
1
+ import{jsx as m,jsxs as y}from"react/jsx-runtime";import{useControllableState as E}from"@nild/hooks";import{cnMerge as N}from"@nild/shared";import{forwardRef as k,isValidElement as I}from"react";import M from"../_shared/utils/register-slots/index.js";import{useCompositeContext as j,InputProvider as P}from"./contexts/index.js";import{isPrefixElement as S}from"./Prefix.js";import p from"./style/index.js";import{isSuffixElement as V}from"./Suffix.js";const w=e=>I(e)&&e.type===l,J=M({prefix:{isMatched:S},suffix:{isMatched:V}}),l=k((e,d)=>{const a=j(),{className:f,children:u,variant:t=a.variant,size:i=a.size,block:c=a.block,disabled:s=a.disabled,type:v="text",value:x,defaultValue:b="",onChange:o,...h}=e,{slots:n}=J(u),[g,z]=E(x,b),C=r=>{z(r.target.value),o?.(r.target.value,r)};return m(P,{value:{size:i,disabled:s,variant:t},children:y("span",{className:N(p.inputWrapper({variant:t,size:i,block:c,disabled:s}),f),"data-disabled":s||void 0,children:[n.prefix.el,m("input",{ref:d,type:v,value:g,onChange:C,disabled:s,className:p.input({size:i,variant:t}),...h}),n.suffix.el]})})});l.displayName="Input";export{l as default,w as isInputElement};
@@ -1 +1 @@
1
- import{jsx as o}from"react/jsx-runtime";import{cnMerge as f}from"@nild/shared";import{forwardRef as n,isValidElement as p}from"react";import{useInputContext as l}from"./contexts/index.js";import c from"./style/index.js";const d=e=>p(e)&&e.type===s,s=n((e,r)=>{const{size:a}=l(),{className:i,children:t,...m}=e;return o("span",{...m,className:f(c.prefix({size:a}),i),ref:r,children:t})});s.displayName="Input.Prefix";export{s as default,d as isPrefixElement};
1
+ import{jsx as n}from"react/jsx-runtime";import{cnMerge as f}from"@nild/shared";import{forwardRef as p,isValidElement as l}from"react";import{useInputContext as c}from"./contexts/index.js";import x from"./style/index.js";const d=e=>l(e)&&e.type===r,r=p((e,a)=>{const{size:s,variant:i}=c(),{className:t,children:m,...o}=e;return n("span",{...o,className:f(x.prefix({size:s,variant:i}),t),ref:a,children:m})});r.displayName="Input.Prefix";export{r as default,d as isPrefixElement};
@@ -1 +1 @@
1
- import{jsx as m}from"react/jsx-runtime";import{cnMerge as o}from"@nild/shared";import{forwardRef as n,isValidElement as p}from"react";import{useInputContext as l}from"./contexts/index.js";import u from"./style/index.js";const c=s=>p(s)&&s.type===e,e=n((s,a)=>{const{size:r}=l(),{className:t,children:i,...f}=s;return m("span",{...f,className:o(u.suffix({size:r}),t),ref:a,children:i})});e.displayName="Input.Suffix";export{e as default,c as isSuffixElement};
1
+ import{jsx as o}from"react/jsx-runtime";import{cnMerge as n}from"@nild/shared";import{forwardRef as p,isValidElement as l}from"react";import{useInputContext as u}from"./contexts/index.js";import c from"./style/index.js";const d=s=>l(s)&&s.type===a,a=p((s,e)=>{const{size:r,variant:t}=u(),{className:i,children:f,...m}=s;return o("span",{...m,className:n(c.suffix({size:r,variant:t}),i),ref:e,children:f})});a.displayName="Input.Suffix";export{a as default,d as isSuffixElement};
@@ -6,9 +6,9 @@ declare const _default: {
6
6
  appended?: boolean;
7
7
  }) | undefined) => string;
8
8
  inputWrapper: (props?: InputProps | undefined) => string;
9
- input: (props?: InputProps | undefined) => string;
10
- prefix: (props?: InputProps | undefined) => string;
11
- suffix: (props?: InputProps | undefined) => string;
9
+ input: (props?: Pick<InputProps, "variant" | "size"> | undefined) => string;
10
+ prefix: (props?: Pick<InputProps, "variant" | "size"> | undefined) => string;
11
+ suffix: (props?: Pick<InputProps, "variant" | "size"> | undefined) => string;
12
12
  prepend: (props?: (Pick<InputProps, "variant" | "size"> & {
13
13
  type: "string" | "element";
14
14
  }) | undefined) => string;
@@ -1 +1 @@
1
- import{cva as e}from"@nild/shared";import t from"../../_shared/style/index.js";const n=e(["nd-input-composite","inline-flex","items-stretch",t.disabled()],{variants:{block:{true:["flex","w-full"],false:""}}}),r=e(["flex-auto"],{variants:{prepended:{true:["rounded-l-none"],false:""},appended:{true:["rounded-r-none"],false:""}},compoundVariants:[{variant:"outlined",appended:!0,className:["mr-[-1px]","hover:z-1"]}]}),a=e(["nd-input-wrapper","group",["inline-flex","items-center","box-border","font-nd","transition-colors","overflow-hidden"],["border","enabled:focus-within:border-brand","enabled:focus-within:z-1"],"enabled:focus-visible-within:ring-focused",t.disabled()],{variants:{variant:{outlined:["bg-transparent","border-main","enabled:hover:border-brand-hover"],filled:["bg-muted","border-subtle","enabled:[&:hover:not(:focus-within)]:bg-muted-hover","enabled:[&:hover:not(:focus-within)]:border-muted"]},size:{small:["h-6","text-sm","rounded-sm"],medium:["h-8","text-md","rounded-md"],large:["h-10","text-lg","rounded-md"]},block:{true:["flex","w-full"],false:""}}}),i=e(["nd-input","flex-auto","h-full","bg-transparent","border-none","outline-none","p-0","m-0","text-main","placeholder:text-subtle","disabled:cursor-not-allowed","[&::-ms-reveal]:hidden","[&::-ms-clear]:hidden","[&::-webkit-inner-spin-button]:appearance-none","[&::-webkit-outer-spin-button]:appearance-none","[&::-webkit-inner-spin-button]:m-0","[&::-webkit-outer-spin-button]:m-0","[-moz-appearance:textfield]"],{variants:{size:{small:["px-2","text-sm"],medium:["px-3","text-md"],large:["px-4","text-lg"]}}}),s=e(["nd-input-prefix","shrink-0","h-full","inline-flex","items-center","text-muted"],{variants:{size:{small:["pl-2","text-sm"],medium:["pl-3","text-md"],large:["pl-4","text-lg"]}}}),l=e(["nd-input-suffix","shrink-0","h-full","inline-flex","items-center","text-muted"],{variants:{size:{small:["pr-2","text-sm"],medium:["pr-3","text-md"],large:["pr-4","text-lg"]}}}),d=e(["shrink-0"],{variants:{variant:{outlined:["mr-[-1px]","hover:z-1","focus:z-1","focus-within:z-1"],filled:[]},type:{string:["inline-flex","items-center","border"],element:["rounded-r-none"]},size:{small:["h-6","text-sm","rounded-l-sm"],medium:["h-8","text-md","rounded-l-md"],large:["h-10","text-lg","rounded-l-md"]}},compoundVariants:[{type:"string",variant:"outlined",className:["bg-muted","border-main","text-muted"]},{type:"string",variant:"filled",className:["bg-brand","border-transparent","text-brand-contrast"]},{type:"string",size:"small",className:["px-2"]},{type:"string",size:"medium",className:["px-3"]},{type:"string",size:"large",className:["px-4"]}]}),o=e(["shrink-0"],{variants:{type:{string:["inline-flex","items-center","border"],element:["rounded-l-none","h-auto"]},size:{small:["h-6","text-sm","rounded-r-sm"],medium:["h-8","text-md","rounded-r-md"],large:["h-10","text-lg","rounded-r-md"]}},compoundVariants:[{type:"string",variant:"outlined",className:["bg-muted","border-main","text-muted"]},{type:"string",variant:"filled",className:["bg-brand","border-transparent","text-brand-contrast"]},{type:"string",size:"small",className:["px-2"]},{type:"string",size:"medium",className:["px-3"]},{type:"string",size:"large",className:["px-4"]}]}),m=e(["group-focus-within:text-brand"]),p=e(["gap-2","items-center"],{variants:{block:{true:["flex","w-full"],false:["inline-flex"]}}}),u=e(["flex-auto","min-w-0","text-center"],{compoundVariants:[{size:"small",block:!1,className:["w-6"]},{size:"medium",block:!1,className:["w-8"]},{size:"large",block:!1,className:["w-10"]}]}),x={composite:n,compositedInputWrapper:r,inputWrapper:a,input:i,prefix:s,suffix:l,prepend:d,append:o,searchIcon:m,otpWrapper:p,otpInputWrapper:u};export{x as default};
1
+ import{cva as e}from"@nild/shared";import t from"../../_shared/style/index.js";const a=e(["nd-input-composite","inline-flex","items-stretch",t.disabled()],{variants:{block:{true:["flex","w-full"],false:""}}}),n=e(["flex-auto"],{variants:{prepended:{true:["rounded-l-none"],false:""},appended:{true:["rounded-r-none"],false:""}},compoundVariants:[{variant:"outlined",appended:!0,className:["mr-[-1px]","hover:z-1"]}]}),i=e(["nd-input-wrapper","group",["inline-flex","items-center","box-border","font-nd","transition-colors","overflow-hidden"],["border","enabled:focus-within:z-1"],t.disabled()],{variants:{variant:{outlined:["bg-transparent","border-main","enabled:hover:border-brand-hover","enabled:focus-within:border-brand","enabled:focus-visible-within:ring-focused"],filled:["bg-muted","border-subtle","enabled:[&:hover:not(:focus-within)]:bg-muted-hover","enabled:[&:hover:not(:focus-within)]:border-muted","enabled:focus-within:border-brand","enabled:focus-visible-within:ring-focused"],underlined:["bg-transparent","border-transparent","border-b-main","enabled:[&:hover:not(:focus-within)]:border-b-brand-hover","enabled:focus-within:border-b-brand"]},size:{small:["h-6","text-sm"],medium:["h-8","text-md"],large:["h-10","text-lg"]},block:{true:["flex","w-full"],false:""}},compoundVariants:[{variant:["outlined","filled"],size:"small",className:["rounded-sm"]},{variant:["outlined","filled"],size:["medium","large"],className:["rounded-md"]}]}),l=e(["nd-input","flex-auto","h-full","bg-transparent","border-none","outline-none","p-0","m-0","text-main","placeholder:text-subtle","disabled:cursor-not-allowed","[&::-ms-reveal]:hidden","[&::-ms-clear]:hidden","[&::-webkit-inner-spin-button]:appearance-none","[&::-webkit-outer-spin-button]:appearance-none","[&::-webkit-inner-spin-button]:m-0","[&::-webkit-outer-spin-button]:m-0","[-moz-appearance:textfield]"],{variants:{size:{small:["text-sm"],medium:["text-md"],large:["text-lg"]}},compoundVariants:[{variant:["outlined","filled"],size:"small",className:["px-2"]},{variant:["outlined","filled"],size:"medium",className:["px-3"]},{variant:["outlined","filled"],size:"large",className:["px-4"]}]}),r=e(["nd-input-prefix","shrink-0","h-full","inline-flex","items-center","text-muted"],{variants:{size:{small:["text-sm"],medium:["text-md"],large:["text-lg"]}},compoundVariants:[{variant:["outlined","filled"],size:"small",className:["pl-2"]},{variant:["outlined","filled"],size:"medium",className:["pl-3"]},{variant:["outlined","filled"],size:"large",className:["pl-4"]}]}),s=e(["nd-input-suffix","shrink-0","h-full","inline-flex","items-center","text-muted"],{variants:{size:{small:["text-sm"],medium:["text-md"],large:["text-lg"]}},compoundVariants:[{variant:["outlined","filled"],size:"small",className:["pr-2"]},{variant:["outlined","filled"],size:"medium",className:["pr-3"]},{variant:["outlined","filled"],size:"large",className:["pr-4"]}]}),d=e(["shrink-0"],{variants:{variant:{outlined:["mr-[-1px]","hover:z-1","focus:z-1","focus-within:z-1"],filled:[],underlined:[]},type:{string:["inline-flex","items-center","border"],element:[]},size:{small:["h-6","text-sm"],medium:["h-8","text-md"],large:["h-10","text-lg"]}},compoundVariants:[{type:"element",variant:["outlined","filled"],className:["rounded-r-none"]},{type:["string","element"],variant:["outlined","filled"],size:"small",className:["rounded-l-sm"]},{type:["string","element"],variant:["outlined","filled"],size:["medium","large"],className:["rounded-l-md"]},{type:"string",variant:"outlined",className:["bg-muted","border-main","text-muted"]},{type:"string",variant:"filled",className:["bg-brand","border-transparent","text-brand-contrast"]},{type:"string",variant:"underlined",className:["bg-transparent","border-transparent","border-b-main","text-muted"]},{type:"string",variant:["outlined","filled"],size:"small",className:["px-2"]},{type:"string",variant:["outlined","filled"],size:"medium",className:["px-3"]},{type:"string",variant:["outlined","filled"],size:"large",className:["px-4"]}]}),o=e(["shrink-0"],{variants:{variant:{outlined:[],filled:[],underlined:[]},type:{string:["inline-flex","items-center","border"],element:["h-auto"]},size:{small:["h-6","text-sm"],medium:["h-8","text-md"],large:["h-10","text-lg"]}},compoundVariants:[{type:"element",variant:["outlined","filled"],className:["rounded-l-none"]},{type:["string","element"],variant:["outlined","filled"],size:"small",className:["rounded-r-sm"]},{type:["string","element"],variant:["outlined","filled"],size:["medium","large"],className:["rounded-r-md"]},{type:"string",variant:"outlined",className:["bg-muted","border-main","text-muted"]},{type:"string",variant:"filled",className:["bg-brand","border-transparent","text-brand-contrast"]},{type:"string",variant:"underlined",className:["bg-transparent","border-transparent","border-b-main","text-muted"]},{type:"string",variant:["outlined","filled"],size:"small",className:["px-2"]},{type:"string",variant:["outlined","filled"],size:"medium",className:["px-3"]},{type:"string",variant:["outlined","filled"],size:"large",className:["px-4"]}]}),m=e(["group-focus-within:text-brand"]),u=e(["gap-2","items-center"],{variants:{block:{true:["flex","w-full"],false:["inline-flex"]}}}),p=e(["flex-auto","min-w-0","text-center"],{compoundVariants:[{size:"small",block:!1,className:["w-6"]},{size:"medium",block:!1,className:["w-8"]},{size:"large",block:!1,className:["w-10"]}]}),c={composite:a,compositedInputWrapper:n,inputWrapper:i,input:l,prefix:r,suffix:s,prepend:d,append:o,searchIcon:m,otpWrapper:u,otpInputWrapper:p};export{c as default};
@@ -1 +1 @@
1
- import{jsxs as v,jsx as g}from"react/jsx-runtime";import{useEffectCallback as h,useEventListener as B}from"@nild/hooks";import{cnMerge as n,mergeRefs as H}from"@nild/shared";import{forwardRef as L,useRef as V,useEffect as q,isValidElement as A}from"react";import{createPortal as G}from"react-dom";import J from"../_shared/utils/get-owner-document/index.js";import K from"../_shared/utils/lock-document-scroll/index.js";import Q from"../_shared/utils/register-slots/index.js";import{isBodyElement as U}from"./Body.js";import W,{isCloseElement as X}from"./Close.js";import{useModalContext as Y}from"./contexts/index.js";import{isFooterElement as Z}from"./Footer.js";import{isHeaderElement as _}from"./Header.js";import{useModalStack as $}from"./hooks/useModalStack.js";import{useModalFocusScope as ee}from"./hooks/useModalFocusScope.js";import m from"./style/index.js";const re=e=>A(e)&&e.type===c,ae=Q({header:{isMatched:e=>_(e)},body:{isMatched:e=>U(e)},footer:{isMatched:e=>Z(e)},close:{isMatched:e=>X(e)}}),c=L(({className:e,style:M,children:k,container:d,overlayless:f=!1,overlayClassName:N,surfaceClassName:x,onTransitionEnd:C,...F},z)=>{const{open:s,variant:R,placement:p,size:w,closeOnEscape:I,closeOnOverlayClick:O,trapFocus:P,lockScroll:u,restoreFocus:j,accessibility:t,refs:y,updateOpen:b}=Y(),l=V(null),r=J(d,l.current,y.trigger.current),a=d??r?.body??null,{zIndex:D,topmost:i}=$(r,!!a),S=h(()=>{f||!s||!O||!i||b(!1)}),T=h(E=>{!s||!i||E.key==="Escape"&&I&&(E.preventDefault(),b(!1))});if(q(()=>{if(!(!a||!u||!r))return K(r)},[u,r,a]),ee({open:s,trapFocus:P,restoreFocus:j,topmost:i,ownerDocument:r,surfaceRef:l,triggerRef:y.trigger}),B(r,"keydown",T),!a)return null;const{slots:o}=ae(k);return G(v("div",{className:n(m.portal({placement:p}),e),style:{zIndex:D,...M},...F,children:[!f&&g("div",{className:n(m.overlay(),N),onClick:S}),v("div",{ref:H(l,z),className:n(m.surface({variant:R,placement:p,size:w}),x),"aria-describedby":t["aria-describedby"],"aria-label":t["aria-label"],"aria-labelledby":t["aria-labelledby"],"aria-modal":"true",role:"dialog",tabIndex:-1,onTransitionEnd:C,children:[o.header.el,o.body.el,o.footer.el,o.close.el??g(W,{})]})]}),a)});c.displayName="Modal.Portal";export{c as default,re as isPortalElement};
1
+ import{jsxs as E,jsx as v}from"react/jsx-runtime";import{useEffectCallback as g,useScrollLock as T,useEventListener as B}from"@nild/hooks";import{cnMerge as n,mergeRefs as H}from"@nild/shared";import{forwardRef as V,useRef as q,isValidElement as A}from"react";import{createPortal as G}from"react-dom";import J from"../_shared/utils/get-owner-document/index.js";import K from"../_shared/utils/register-slots/index.js";import{isBodyElement as Q}from"./Body.js";import U,{isCloseElement as W}from"./Close.js";import{useModalContext as X}from"./contexts/index.js";import{isFooterElement as Y}from"./Footer.js";import{isHeaderElement as Z}from"./Header.js";import{useModalStack as _}from"./hooks/useModalStack.js";import{useModalFocusScope as $}from"./hooks/useModalFocusScope.js";import c from"./style/index.js";const ee=e=>A(e)&&e.type===m,ae=K({header:{isMatched:e=>Z(e)},body:{isMatched:e=>Q(e)},footer:{isMatched:e=>Y(e)},close:{isMatched:e=>W(e)}}),m=V(({className:e,style:h,children:M,container:d,overlayless:p=!1,overlayClassName:k,surfaceClassName:N,onTransitionEnd:x,...C},F)=>{const{open:s,variant:R,placement:f,size:z,closeOnEscape:w,closeOnOverlayClick:I,trapFocus:O,lockScroll:P,restoreFocus:S,accessibility:l,refs:u,updateOpen:b}=X(),t=q(null),a=J(d,t.current,u.trigger.current),r=d??a?.body??null,{zIndex:j,topmost:i}=_(a,!!r),D=g(()=>{p||!s||!I||!i||b(!1)}),L=g(y=>{!s||!i||y.key==="Escape"&&w&&(y.preventDefault(),b(!1))});if(T(a,P&&!!r),$({open:s,trapFocus:O,restoreFocus:S,topmost:i,ownerDocument:a,surfaceRef:t,triggerRef:u.trigger}),B(a,"keydown",L),!r)return null;const{slots:o}=ae(M);return G(E("div",{className:n(c.portal({placement:f}),e),style:{zIndex:j,...h},...C,children:[!p&&v("div",{className:n(c.overlay(),k),onClick:D}),E("div",{ref:H(t,F),className:n(c.surface({variant:R,placement:f,size:z}),N),"aria-describedby":l["aria-describedby"],"aria-label":l["aria-label"],"aria-labelledby":l["aria-labelledby"],"aria-modal":"true",role:"dialog",tabIndex:-1,onTransitionEnd:x,children:[o.header.el,o.body.el,o.footer.el,o.close.el??v(U,{})]})]}),r)});m.displayName="Modal.Portal";export{m as default,ee as isPortalElement};
@@ -1 +1 @@
1
- import{useEffectCallback as v,useIsomorphicLayoutEffect as A,useEventListener as y}from"@nild/hooks";import{useRef as h,useEffect as E}from"react";const C=["a[href]","area[href]","button:not([disabled])",'input:not([disabled]):not([type="hidden"])',"select:not([disabled])","textarea:not([disabled])","iframe","summary",'[contenteditable="true"]','[tabindex]:not([tabindex="-1"])'].join(","),w=e=>{const t=e.ownerDocument.defaultView;if(!t)return!e.hidden;const o=t.getComputedStyle(e);return o.display!=="none"&&o.visibility!=="hidden"&&!e.hidden},g=e=>Array.from(e.querySelectorAll(C)).filter(t=>!t.hasAttribute("disabled")&&t.getAttribute("aria-hidden")!=="true"&&t.tabIndex>=0&&w(t)),m=(e,t=!1)=>{const o=g(e).at(t?-1:0)??e;return o.focus(),o},K=(e,t)=>{var o;const c=e!=null&&e.isConnected?e:t!=null&&t.isConnected?t:null;(o=c?.focus)==null||o.call(c)},S=({open:e,trapFocus:t,restoreFocus:o,topmost:c,ownerDocument:u,surfaceRef:a,triggerRef:p})=>{const b=h(null),i=h(e),x=v(n=>{const r=a.current;if(!r||!e||!c||n.key!=="Tab"||!t)return;const s=g(r),l=u?.activeElement;if(s.length===0){n.preventDefault(),r.focus();return}if(!l||!r.contains(l)){n.preventDefault(),m(r,n.shiftKey);return}const d=s[0],f=s.at(-1);n.shiftKey&&l===d?(n.preventDefault(),f?.focus()):!n.shiftKey&&l===f&&(n.preventDefault(),d?.focus())}),D=v(n=>{const r=a.current,s=n.target;!r||!t||!e||!c||!s||r.contains(s)||m(r)});E(()=>{const n=i.current;e&&!n&&(b.current=u?.activeElement),i.current=e},[e,u]),E(()=>{const n=p.current;return()=>{!o||i.current||K(b.current,n)}},[o,p]),A(()=>{if(!e)return;const n=setTimeout(()=>{const r=a.current;if(!r||!c)return;const s=u?.activeElement;(!s||!r.contains(s))&&m(r)},0);return()=>{clearTimeout(n)}},[e,u,a,c]),y(u,"keydown",x),y(u,"focusin",D)};export{S as useModalFocusScope};
1
+ import{useTimeout as C,useEffectCallback as h,useIsomorphicLayoutEffect as w,useEventListener as y}from"@nild/hooks";import{useRef as E,useEffect as g}from"react";const K=["a[href]","area[href]","button:not([disabled])",'input:not([disabled]):not([type="hidden"])',"select:not([disabled])","textarea:not([disabled])","iframe","summary",'[contenteditable="true"]','[tabindex]:not([tabindex="-1"])'].join(","),S=e=>{const n=e.ownerDocument.defaultView;if(!n)return!e.hidden;const u=n.getComputedStyle(e);return u.display!=="none"&&u.visibility!=="hidden"&&!e.hidden},x=e=>Array.from(e.querySelectorAll(K)).filter(n=>!n.hasAttribute("disabled")&&n.getAttribute("aria-hidden")!=="true"&&n.tabIndex>=0&&S(n)),p=(e,n=!1)=>{const u=x(e).at(n?-1:0)??e;return u.focus(),u},k=(e,n)=>{var u;const c=e!=null&&e.isConnected?e:n!=null&&n.isConnected?n:null;(u=c?.focus)==null||u.call(c)},F=({open:e,trapFocus:n,restoreFocus:u,topmost:c,ownerDocument:o,surfaceRef:a,triggerRef:b})=>{const v=E(null),i=E(e),d=C(()=>{const t=a.current;if(!t||!c)return;const r=o?.activeElement;(!r||!t.contains(r))&&p(t)},0),D=h(t=>{const r=a.current;if(!r||!e||!c||t.key!=="Tab"||!n)return;const s=x(r),l=o?.activeElement;if(s.length===0){t.preventDefault(),r.focus();return}if(!l||!r.contains(l)){t.preventDefault(),p(r,t.shiftKey);return}const f=s[0],m=s.at(-1);t.shiftKey&&l===f?(t.preventDefault(),m?.focus()):!t.shiftKey&&l===m&&(t.preventDefault(),f?.focus())}),A=h(t=>{const r=a.current,s=t.target;!r||!n||!e||!c||!s||r.contains(s)||p(r)});g(()=>{const t=i.current;e&&!t&&(v.current=o?.activeElement),i.current=e},[e,o]),g(()=>{const t=b.current;return()=>{!u||i.current||k(v.current,t)}},[u,b]),w(()=>{if(e)return d.run(),d.cancel},[d,e,o,a,c]),y(o,"keydown",D),y(o,"focusin",A)};export{F as useModalFocusScope};
File without changes
@@ -1 +1 @@
1
- import{jsxs as H,jsx as l}from"react/jsx-runtime";import{useControllableState as J,useEffectCallback as f,useIsomorphicLayoutEffect as K}from"@nild/hooks";import{isArray as Q,makeArray as V,isFunction as W}from"@nild/shared";import{useState as X,useMemo as P,useRef as Y}from"react";import Z from"../_shared/utils/register-slots/index.js";import _ from"../transition/Transition.js";import{PopupProvider as $,PortalProvider as G,ArrowProvider as ee}from"./contexts/index.js";import re from"./hooks/usePopup.js";import R from"./Portal.js";import m from"./Trigger.js";const te=Z({trigger:{isMatched:e=>e.type===m},portal:{isMatched:e=>e.type===R},firstBare:{isMatched:e=>e.type!==m&&e.type!==R,strategy:"first"}}),T=({children:e,placement:b,offset:x,action:d="click",size:h="medium",arrowed:v=!0,inverse:y=!1,delay:a=100,open:A,defaultOpen:g=!1,disabled:B,onOpen:w,onClose:C})=>{const{slots:t}=te(e),[o,O]=X(g),[s,j]=J(A,g),[k,z=100]=Q(a)?a:[a,a],i=P(()=>new Set(V(d)),[d]),r=Y(),[{triggerRef:n,portalRef:u,portalContext:E,arrowRef:S,arrowContext:F},{update:I,autoUpdate:L}]=re({placement:b,offset:x}),p=f(c=>{B||j(D=>{const M=W(c)?c(D):c;return M?w?.():C?.(),M})}),N=f(()=>{i.has("hover")&&(r.current&&clearTimeout(r.current),r.current=setTimeout(()=>{p(!0)},k))}),U=f(()=>{i.has("hover")&&(r.current&&clearTimeout(r.current),r.current=setTimeout(()=>{p(!1)},z))}),q=P(()=>({actions:i,size:h,arrowed:v,inverse:y,refs:{trigger:n,portal:u,arrow:S},setOpen:p,enter:N,leave:U}),[i,h,v,y]);return K(()=>{if(s&&!o)O(!0);else if(s&&o&&n.current&&u.current)return L(n.current,u.current,I)},[s,o]),H($,{value:q,children:[t.trigger.el??(t.firstBare.el&&l(m,{children:t.firstBare.el})),l(G,{value:E,children:l(ee,{value:F,children:t.portal.el&&l(_,{visible:s,children:o&&t.portal.el})})})]})};T.displayName="Popup";export{T as default};
1
+ import{jsxs as K,jsx as i}from"react/jsx-runtime";import{useControllableState as Q,useEffectCallback as u,useTimeout as M,useIsomorphicLayoutEffect as V}from"@nild/hooks";import{isArray as W,makeArray as X,isFunction as Y}from"@nild/shared";import{useState as Z,useMemo as P}from"react";import _ from"../_shared/utils/register-slots/index.js";import $ from"../transition/Transition.js";import{PopupProvider as J,PortalProvider as ee,ArrowProvider as re}from"./contexts/index.js";import te from"./hooks/usePopup.js";import O from"./Portal.js";import m from"./Trigger.js";const oe=_({trigger:{isMatched:e=>e.type===m},portal:{isMatched:e=>e.type===O},firstBare:{isMatched:e=>e.type!==m&&e.type!==O,strategy:"first"}}),R=({children:e,placement:S,offset:j,action:f="click",size:d="medium",arrowed:h=!0,inverse:v=!1,delay:t=100,open:k,defaultOpen:y=!1,disabled:z,onOpen:g,onClose:w})=>{const{slots:r}=oe(e),[o,A]=Z(y),[a,B]=Q(k,y),[E,F=100]=W(t)?t:[t,t],s=P(()=>new Set(X(f)),[f]),[{triggerRef:l,portalRef:n,portalContext:I,arrowRef:L,arrowContext:N},{update:T,autoUpdate:U}]=te({placement:S,offset:j}),p=u(c=>{z||B(H=>{const b=Y(c)?c(H):c;return b?g?.():w?.(),b})}),x=M(()=>p(!0),E),C=M(()=>p(!1),F),q=u(()=>{s.has("hover")&&(C.cancel(),x.run())}),D=u(()=>{s.has("hover")&&(x.cancel(),C.run())}),G=P(()=>({actions:s,size:d,arrowed:h,inverse:v,refs:{trigger:l,portal:n,arrow:L},setOpen:p,enter:q,leave:D}),[s,d,h,v]);return V(()=>{if(a&&!o)A(!0);else if(a&&o&&l.current&&n.current)return U(l.current,n.current,T)},[a,o]),K(J,{value:G,children:[r.trigger.el??(r.firstBare.el&&i(m,{children:r.firstBare.el})),i(ee,{value:I,children:i(re,{value:N,children:r.portal.el&&i($,{visible:a,children:o&&r.portal.el})})})]})};R.displayName="Popup";export{R as default};
@@ -1 +1 @@
1
- import{jsxs as Y,jsx as j}from"react/jsx-runtime";import{useControllableState as Z,useEffectCallback as u,useIsomorphicLayoutEffect as D}from"@nild/hooks";import{forwardRefWithGenerics as _,mergeRefs as K,cnMerge as Q}from"@nild/shared";import{useRef as L,useState as M,useMemo as ee,cloneElement as te}from"react";import{useRovingIndexNavigation as oe}from"../_shared/hooks/use-roving-index-navigation/index.js";import F from"../_shared/utils/merge-handlers/index.js";import ne from"../_shared/utils/register-slots/index.js";import{SegmentProvider as se}from"./contexts/index.js";import{isItemElement as ie}from"./Item.js";import $ from"./style/index.js";const re=ne({item:{isMatched:ie,multiple:!0}}),ae=y=>{const{slots:h}=re(y),g=h.item.el,a=[],d=[];return g.forEach((i,l)=>{var c;a.push({key:((c=i.key)==null?void 0:c.toString())??`${h.item.seq[l]}`,element:i,props:i.props}),i.props.disabled||d.push(l)}),{items:a,enabledIndices:d,firstEnabledIndex:d[0]??-1}},q=_((y,h)=>{const{className:g,children:a,value:d,defaultValue:i,onChange:l,size:c="medium",orientation:m="horizontal",disabled:p=!1,block:x=!1,...k}=y,I=L(null),v=L([]),[A,C]=M({opacity:0}),{items:s,enabledIndices:z,firstEnabledIndex:b}=ee(()=>ae(a),[a]),W=i??(b>=0?s[b].props.value:void 0),[S,G]=Z(d,W),N=s.findIndex(e=>Object.is(e.props.value,S)),r=N>=0?N:b,w=z.includes(r)?r:b,[O,E]=M(w),H=u(e=>{Object.is(S,e)||(G(e),l?.(e))}),R=u(e=>{const t=s[e];!t||p||t.props.disabled||H(t.props.value)}),P=u(e=>{const t=v.current[e];!t||typeof window>"u"||window.requestAnimationFrame(()=>{t.isConnected&&t.focus()})}),T=u(e=>{E(e),P(e)}),{handleKeyDown:V}=oe({orientation:m,activeIndex:O,selectedIndex:w,enabledIndices:p?[]:z,selectOnMove:!0,selectOnConfirm:!0,onActiveChange:T,onSelect:R,onKeyDown:k.onKeyDown}),f=u(()=>{const e=I.current,t=v.current[r];if(!e||!t||r<0){C(o=>o.opacity===0?o:{opacity:0});return}const n={opacity:1,width:t.offsetWidth,height:t.offsetHeight,transform:`translate3d(${t.offsetLeft}px, ${t.offsetTop}px, 0)`};C(o=>o.opacity===n.opacity&&o.width===n.width&&o.height===n.height&&o.transform===n.transform?o:n)});D(()=>{E(w)},[w]),D(()=>{f();const e=I.current;if(!e||typeof window>"u")return;const t=window.ResizeObserver;if(t){const n=new t(f);return n.observe(e),v.current.slice(0,s.length).forEach(o=>{o&&n.observe(o)}),()=>{n.disconnect()}}return window.addEventListener("resize",f),()=>{window.removeEventListener("resize",f)}},[x,r,s,m,c,f]);const B=(e,t)=>{const{element:n}=e,o=p||!!e.props.disabled,J=t===r,U=t===O;return j(se,{value:{selected:J,size:c,orientation:m,block:x},children:te(n,{value:e.props.value,disabled:o,tabIndex:U&&!o?0:-1,onClick:F(e.props.onClick,()=>R(t)),onFocus:F(e.props.onFocus,()=>{!o&&E(t)}),ref:K(n.ref,X=>{v.current[t]=X})})},e.key)};return Y("div",{...k,"aria-disabled":p,"aria-orientation":m,className:Q($.segment({orientation:m,block:x}),g),"data-disabled":p||void 0,onKeyDown:V,ref:K(h,I),role:"radiogroup",children:[s.length>0&&j("div",{"aria-hidden":"true",className:$.indicator(),style:A}),s.map(B)]})});q.displayName="Segment";export{q as default};
1
+ import{jsxs as _,jsx as z}from"react/jsx-runtime";import{useControllableState as U,useEffectCallback as u,useIsomorphicLayoutEffect as D,useResizeObserver as ee}from"@nild/hooks";import{forwardRefWithGenerics as te,mergeRefs as K,cnMerge as oe}from"@nild/shared";import{useRef as M,useState as F,useMemo as $,cloneElement as se}from"react";import{useRovingIndexNavigation as ne}from"../_shared/hooks/use-roving-index-navigation/index.js";import q from"../_shared/utils/merge-handlers/index.js";import ie from"../_shared/utils/register-slots/index.js";import{SegmentProvider as re}from"./contexts/index.js";import{isItemElement as ae}from"./Item.js";import A from"./style/index.js";const le=ie({item:{isMatched:ae,multiple:!0}}),de=g=>{const{slots:f}=le(g),y=f.item.el,a=[],l=[];return y.forEach((i,d)=>{var c;a.push({key:((c=i.key)==null?void 0:c.toString())??`${f.item.seq[d]}`,element:i,props:i.props}),i.props.disabled||l.push(d)}),{items:a,enabledIndices:l,firstEnabledIndex:l[0]??-1}},L=te((g,f)=>{const{className:y,children:a,value:l,defaultValue:i,onChange:d,size:c="medium",orientation:m="horizontal",disabled:p=!1,block:I=!1,...C}=g,w=M(null),h=M([]),[W,E]=F({opacity:0}),{items:s,enabledIndices:S,firstEnabledIndex:b}=$(()=>de(a),[a]),G=i??(b>=0?s[b].props.value:void 0),[N,H]=U(l,G),O=s.findIndex(e=>Object.is(e.props.value,N)),r=O>=0?O:b,v=S.includes(r)?r:b,[R,x]=F(v),P=u(e=>{Object.is(N,e)||(H(e),d?.(e))}),j=u(e=>{const t=s[e];!t||p||t.props.disabled||P(t.props.value)}),T=u(e=>{const t=h.current[e];!t||typeof window>"u"||window.requestAnimationFrame(()=>{t.isConnected&&t.focus()})}),V=u(e=>{x(e),T(e)}),{handleKeyDown:B}=ne({orientation:m,activeIndex:R,selectedIndex:v,enabledIndices:p?[]:S,selectOnMove:!0,selectOnConfirm:!0,onActiveChange:V,onSelect:j,onKeyDown:C.onKeyDown}),k=u(()=>{const e=w.current,t=h.current[r];if(!e||!t||r<0){E(o=>o.opacity===0?o:{opacity:0});return}const n={opacity:1,width:t.offsetWidth,height:t.offsetHeight,transform:`translate3d(${t.offsetLeft}px, ${t.offsetTop}px, 0)`};E(o=>o.opacity===n.opacity&&o.width===n.width&&o.height===n.height&&o.transform===n.transform?o:n)});D(()=>{x(v)},[v]),D(()=>{k()},[I,r,s,m,c,k]);const J=$(()=>[w,...s.map((e,t)=>({get current(){return h.current[t]}}))],[s]);ee(J,k);const Q=(e,t)=>{const{element:n}=e,o=p||!!e.props.disabled,X=t===r,Y=t===R;return z(re,{value:{selected:X,size:c,orientation:m,block:I},children:se(n,{value:e.props.value,disabled:o,tabIndex:Y&&!o?0:-1,onClick:q(e.props.onClick,()=>j(t)),onFocus:q(e.props.onFocus,()=>{!o&&x(t)}),ref:K(n.ref,Z=>{h.current[t]=Z})})},e.key)};return _("div",{...C,"aria-disabled":p,"aria-orientation":m,className:oe(A.segment({orientation:m,block:I}),y),"data-disabled":p||void 0,onKeyDown:B,ref:K(f,w),role:"radiogroup",children:[s.length>0&&z("div",{"aria-hidden":"true",className:A.indicator(),style:W}),s.map(Q)]})});L.displayName="Segment";export{L as default};
@@ -1 +1 @@
1
- import{jsxs as J,jsx as m}from"react/jsx-runtime";import{useControllableState as de,useIsomorphicLayoutEffect as pe}from"@nild/hooks";import{Icon as ue}from"@nild/icons";import me from"@nild/icons/Down";import{forwardRefWithGenerics as be,mergeRefs as Q,cnMerge as fe}from"@nild/shared";import{useId as he,useRef as K,useState as ge,useMemo as ve,cloneElement as ye}from"react";import D from"../_shared/utils/merge-handlers/index.js";import xe from"../_shared/utils/register-slots/index.js";import L from"../popup/index.js";import{useSelectNavigation as Ie}from"./hooks/useSelectNavigation.js";import{isOptionElement as Oe}from"./Option.js";import N from"./style/index.js";const je=xe({option:{isMatched:t=>Oe(t),multiple:!0}}),g=t=>Array.isArray(t)?t:[],we=(t,l,s)=>{if(!t)return Object.is(l,s);const n=g(l),i=g(s);return n.length===i.length&&n.every((r,c)=>Object.is(r,i[c]))},ke=(t,l)=>t.some(s=>Object.is(s,l))?t.filter(s=>!Object.is(s,l)):t.concat(l),De=(t,l,s)=>{const{slots:n}=je(t),i=n.option.el,r=[],c=[],v=[],y=l?g(s):[];let x="",d=!0,b=-1;return i.forEach((p,f)=>{var I;const o=p.props,O=l?y.some(j=>Object.is(j,o.value)):Object.is(o.value,s);r.push({key:((I=p.key)==null?void 0:I.toString())??`${n.option.seq[f]}`,selected:O,element:p,props:o}),o.disabled||c.push(f),O&&(d=!1,!o.disabled&&b<0&&(b=f),l?v.push(o.label):x=o.label)}),{options:r,enabledIndices:c,selectedIndex:b,selectionValues:y,selectionText:l?v.join(", "):x,selectionEmpty:d}},U=be((t,l)=>{var s;const{className:n,children:i,"aria-label":r,"aria-labelledby":c,onKeyDown:v,placeholder:y,variant:x="outlined",size:d="medium",block:b=!1,disabled:p=!1,placement:f="bottom-start",offset:I=8,multiple:o=!1,value:O,defaultValue:j,onChange:w,...X}=t,Y=he(),E=K(null),A=K(null),V=K([]),[S,C]=ge(!1),[M,Z]=de(O,o?g(j):j),{options:R,enabledIndices:W,selectedIndex:_,selectionValues:ee,selectionText:oe,selectionEmpty:$}=ve(()=>De(i,o,M),[i,o,M]),h=!p&&W.length>0,u=h&&S,B=()=>h&&C(!0),z=()=>C(!1),q=e=>{we(o,M,e)||(o?w?.(g(e)):w?.(e),Z(()=>e))},G=e=>{const a=R[e];if(!(!a||a.props.disabled)){if(o)return q(ke(ee,a.props.value));q(a.props.value),z(),ie()}},{activeIndex:k,setActiveIndex:te,focusListbox:le,handleTriggerKeyDown:se,handleListboxKeyDown:ae,handleListboxBlur:ne,focusTrigger:ie}=Ie({open:u,selectedIndex:_,enabledIndices:W,triggerRef:E,listboxRef:A,optionRefs:V,onOpen:B,onClose:z,onSelect:G});pe(()=>{!h&&S&&C(!1)},[h,S]);const P=(e,a)=>e.props.id??`${Y}-option-${a}`,F=k>=0?R[k]:void 0,re=u&&F?P(F,k):void 0,ce=(e,a)=>{const H=e.element;return ye(H,{key:e.key,id:P(e,a),size:d,active:k===a,className:e.props.className,onClick:D(e.props.onClick,()=>G(a)),onMouseDown:D(e.props.onMouseDown,T=>T.preventDefault()),onMouseEnter:D(e.props.onMouseEnter,()=>{e.props.disabled||te(a)}),ref:Q(H.ref,T=>{V.current[a]=T}),selected:e.selected})};return J(L,{action:"click",arrowed:!1,disabled:!h,offset:I,open:u,placement:f,onClose:z,onOpen:B,children:[m(L.Trigger,{children:J("button",{...X,"aria-expanded":u,"aria-haspopup":"listbox","aria-label":r,"aria-labelledby":c,className:fe(N.trigger({variant:x,size:d,block:b,disabled:p,open:u}),n),disabled:p,onKeyDown:D(v,se),ref:Q(l,E),type:"button",children:[m("span",{className:N.triggerContent({size:d,placeholder:$}),children:$?y??"":oe}),m("span",{"aria-hidden":"true",className:N.triggerIcon({size:d,open:u}),children:m(ue,{component:me})})]})}),m(L.Portal,{children:m("div",{"aria-activedescendant":re,"aria-label":r,"aria-labelledby":c,"aria-multiselectable":o||void 0,className:N.listbox(),onBlur:ne,onKeyDown:ae,ref:e=>{A.current=e,e&&u&&le()},role:"listbox",style:{minWidth:(s=E.current)==null?void 0:s.offsetWidth},tabIndex:-1,children:R.map(ce)})})]})});U.displayName="Select";export{U as default};
1
+ import{jsxs as J,jsx as b}from"react/jsx-runtime";import{useControllableState as de,useIsomorphicLayoutEffect as pe}from"@nild/hooks";import{Icon as me}from"@nild/icons";import ue from"@nild/icons/Down";import{forwardRefWithGenerics as be,mergeRefs as Q,cnMerge as fe}from"@nild/shared";import{useId as he,useRef as K,useState as ve,useMemo as ye,cloneElement as ge}from"react";import D from"../_shared/utils/merge-handlers/index.js";import xe from"../_shared/utils/register-slots/index.js";import L from"../popup/index.js";import{useSelectNavigation as Ie}from"./hooks/useSelectNavigation.js";import{isOptionElement as je}from"./Option.js";import N from"./style/index.js";const we=xe({option:{isMatched:t=>je(t),multiple:!0}}),y=t=>Array.isArray(t)?t:[],Oe=(t,l,s)=>{if(!t)return Object.is(l,s);const n=y(l),i=y(s);return n.length===i.length&&n.every((r,c)=>Object.is(r,i[c]))},ke=(t,l)=>t.some(s=>Object.is(s,l))?t.filter(s=>!Object.is(s,l)):t.concat(l),De=(t,l,s)=>{const{slots:n}=we(t),i=n.option.el,r=[],c=[],g=[],x=l?y(s):[];let u="",d=!0,f=-1;return i.forEach((p,h)=>{var I;const o=p.props,j=l?x.some(w=>Object.is(w,o.value)):Object.is(o.value,s);r.push({key:((I=p.key)==null?void 0:I.toString())??`${n.option.seq[h]}`,selected:j,element:p,props:o}),o.disabled||c.push(h),j&&(d=!1,!o.disabled&&f<0&&(f=h),l?g.push(o.label):u=o.label)}),{options:r,enabledIndices:c,selectedIndex:f,selectionValues:x,selectionText:l?g.join(", "):u,selectionEmpty:d}},U=be((t,l)=>{var s;const{className:n,children:i,"aria-label":r,"aria-labelledby":c,onKeyDown:g,placeholder:x,variant:u="outlined",size:d="medium",block:f=!1,disabled:p=!1,placement:h="bottom-start",offset:I=8,multiple:o=!1,value:j,defaultValue:w,onChange:O,...X}=t,Y=he(),E=K(null),A=K(null),V=K([]),[S,C]=ve(!1),[M,Z]=de(j,o?y(w):w),{options:R,enabledIndices:W,selectedIndex:_,selectionValues:ee,selectionText:oe,selectionEmpty:$}=ye(()=>De(i,o,M),[i,o,M]),v=!p&&W.length>0,m=v&&S,B=()=>v&&C(!0),z=()=>C(!1),q=e=>{Oe(o,M,e)||(o?O?.(y(e)):O?.(e),Z(()=>e))},G=e=>{const a=R[e];if(!(!a||a.props.disabled)){if(o)return q(ke(ee,a.props.value));q(a.props.value),z(),ie()}},{activeIndex:k,setActiveIndex:te,focusListbox:le,handleTriggerKeyDown:se,handleListboxKeyDown:ae,handleListboxBlur:ne,focusTrigger:ie}=Ie({open:m,selectedIndex:_,enabledIndices:W,triggerRef:E,listboxRef:A,optionRefs:V,onOpen:B,onClose:z,onSelect:G});pe(()=>{!v&&S&&C(!1)},[v,S]);const P=(e,a)=>e.props.id??`${Y}-option-${a}`,F=k>=0?R[k]:void 0,re=m&&F?P(F,k):void 0,ce=(e,a)=>{const H=e.element;return ge(H,{key:e.key,id:P(e,a),size:d,active:k===a,className:e.props.className,onClick:D(e.props.onClick,()=>G(a)),onMouseDown:D(e.props.onMouseDown,T=>T.preventDefault()),onMouseEnter:D(e.props.onMouseEnter,()=>{e.props.disabled||te(a)}),ref:Q(H.ref,T=>{V.current[a]=T}),selected:e.selected})};return J(L,{action:"click",arrowed:!1,disabled:!v,offset:I,open:m,placement:h,onClose:z,onOpen:B,children:[b(L.Trigger,{children:J("button",{...X,"aria-expanded":m,"aria-haspopup":"listbox","aria-label":r,"aria-labelledby":c,className:fe(N.trigger({variant:u,size:d,block:f,disabled:p,open:m}),n),disabled:p,onKeyDown:D(g,se),ref:Q(l,E),type:"button",children:[b("span",{className:N.triggerContent({variant:u,size:d,placeholder:$}),children:$?x??"":oe}),b("span",{"aria-hidden":"true",className:N.triggerIcon({variant:u,size:d,open:m}),children:b(me,{component:ue})})]})}),b(L.Portal,{children:b("div",{"aria-activedescendant":re,"aria-label":r,"aria-labelledby":c,"aria-multiselectable":o||void 0,className:N.listbox(),onBlur:ne,onKeyDown:ae,ref:e=>{A.current=e,e&&m&&le()},role:"listbox",style:{minWidth:(s=E.current)==null?void 0:s.offsetWidth},tabIndex:-1,children:R.map(ce)})})]})});U.displayName="Select";export{U as default};
@@ -1 +1 @@
1
- import{useEffectCallback as i,useIsomorphicLayoutEffect as v}from"@nild/hooks";import{useRef as I,useState as L}from"react";const x=n=>{if(typeof window>"u"||!n)return;const s=n.ownerDocument;s.activeElement!==n&&window.requestAnimationFrame(()=>{n.isConnected&&s.activeElement!==n&&n.focus()})},T=({open:n,selectedIndex:s,enabledIndices:t,triggerRef:k,listboxRef:D,optionRefs:g,onOpen:p,onClose:l,onSelect:m})=>{const d=I(!1),[o,f]=L(-1),w=i(()=>x(D.current)),b=i(()=>x(k.current)),a=e=>f(r=>{const c=t.length-1;if(c<0)return-1;if(e==="start")return t[0];if(e==="end")return t[c];const u=t.indexOf(r);if(u===-1)return e===1?t[0]:t[c];const A=Math.min(Math.max(u+e,0),c);return t[A]}),h=i(e=>{if(t.length!==0)switch(e.key){case"ArrowDown":e.preventDefault(),n?a(1):p();break;case"ArrowUp":e.preventDefault(),n?a(-1):p();break;case"Home":n&&(e.preventDefault(),a("start"));break;case"End":n&&(e.preventDefault(),a("end"));break;case"Enter":case" ":e.preventDefault(),n?m(o):p();break;case"Escape":n&&(e.preventDefault(),l(),b());break}}),E=i(e=>{switch(e.key){case"ArrowDown":e.preventDefault(),a(1);break;case"ArrowUp":e.preventDefault(),a(-1);break;case"Home":e.preventDefault(),a("start");break;case"End":e.preventDefault(),a("end");break;case"Enter":case" ":e.preventDefault(),m(o);break;case"Escape":e.preventDefault(),l(),b();break;case"Tab":l();break}}),y=i(e=>{var r,c;const u=e.relatedTarget;(r=k.current)!=null&&r.contains(u)||(c=D.current)!=null&&c.contains(u)||l()});return v(()=>{if(!n){d.current=!1,f(-1);return}const e=s>=0?s:t[0]??-1;f(r=>d.current&&t.includes(r)?r:e),d.current=!0},[t,n,s]),v(()=>{n&&w()},[w,n]),v(()=>{if(!n||o<0||typeof window>"u")return;const e=window.requestAnimationFrame(()=>{var r;(r=g.current[o])==null||r.scrollIntoView({block:"nearest"})});return()=>window.cancelAnimationFrame(e)},[o,n]),{activeIndex:o,setActiveIndex:f,focusTrigger:b,focusListbox:w,handleTriggerKeyDown:h,handleListboxKeyDown:E,handleListboxBlur:y}};export{T as useSelectNavigation};
1
+ import{useRaf as k,useEffectCallback as l,useIsomorphicLayoutEffect as w}from"@nild/hooks";import{useRef as C,useState as H}from"react";const g=n=>{if(typeof window>"u"||!n)return;const c=n.ownerDocument;c.activeElement!==n&&n.isConnected&&c.activeElement!==n&&n.focus()},K=({open:n,selectedIndex:c,enabledIndices:t,triggerRef:m,listboxRef:h,optionRefs:x,onOpen:p,onClose:f,onSelect:E})=>{const b=C(!1),[u,i]=H(-1),y=k(()=>g(h.current)),A=k(()=>g(m.current)),d=k(()=>{var e;(e=x.current[u])==null||e.scrollIntoView({block:"nearest"})}),v=l(()=>y.run()),D=l(()=>A.run()),r=e=>i(a=>{const s=t.length-1;if(s<0)return-1;if(e==="start")return t[0];if(e==="end")return t[s];const o=t.indexOf(a);if(o===-1)return e===1?t[0]:t[s];const T=Math.min(Math.max(o+e,0),s);return t[T]}),I=l(e=>{if(t.length!==0)switch(e.key){case"ArrowDown":e.preventDefault(),n?r(1):p();break;case"ArrowUp":e.preventDefault(),n?r(-1):p();break;case"Home":n&&(e.preventDefault(),r("start"));break;case"End":n&&(e.preventDefault(),r("end"));break;case"Enter":case" ":e.preventDefault(),n?E(u):p();break;case"Escape":n&&(e.preventDefault(),f(),D());break}}),L=l(e=>{switch(e.key){case"ArrowDown":e.preventDefault(),r(1);break;case"ArrowUp":e.preventDefault(),r(-1);break;case"Home":e.preventDefault(),r("start");break;case"End":e.preventDefault(),r("end");break;case"Enter":case" ":e.preventDefault(),E(u);break;case"Escape":e.preventDefault(),f(),D();break;case"Tab":f();break}}),R=l(e=>{var a,s;const o=e.relatedTarget;(a=m.current)!=null&&a.contains(o)||(s=h.current)!=null&&s.contains(o)||f()});return w(()=>{if(!n){b.current=!1,i(-1);return}const e=c>=0?c:t[0]??-1;i(a=>b.current&&t.includes(a)?a:e),b.current=!0},[t,n,c]),w(()=>{n&&v()},[v,n]),w(()=>{if(!(!n||u<0))return d.run(),d.cancel},[u,n,d]),{activeIndex:u,setActiveIndex:i,focusTrigger:D,focusListbox:v,handleTriggerKeyDown:I,handleListboxKeyDown:L,handleListboxBlur:R}};export{K as useSelectNavigation};
@@ -8,10 +8,12 @@ declare const _default: {
8
8
  open?: boolean;
9
9
  } | undefined) => string;
10
10
  triggerContent: (props?: {
11
+ variant?: SelectVariant;
11
12
  size?: SelectSize;
12
13
  placeholder?: boolean;
13
14
  } | undefined) => string;
14
15
  triggerIcon: (props?: {
16
+ variant?: SelectVariant;
15
17
  size?: SelectSize;
16
18
  open?: boolean;
17
19
  } | undefined) => string;
@@ -1 +1 @@
1
- import{cva as e}from"@nild/shared";import t from"../../_shared/style/index.js";const n=e(["nd-select-trigger","group",["inline-flex","items-center"],"box-border","font-nd","overflow-hidden","text-left","appearance-none","border","transition-colors","outline-none",t.disabled()],{variants:{variant:{outlined:["bg-transparent","border-main","enabled:hover:border-brand-hover"],filled:["bg-muted","border-subtle"]},size:{small:["h-6","text-sm","rounded-sm"],medium:["h-8","text-md","rounded-md"],large:["h-10","text-lg","rounded-md"]},block:{true:["flex","w-full"],false:""},disabled:{true:"",false:"cursor-pointer"},open:{true:["border-brand","z-1","ring-focused"],false:""}},compoundVariants:[{variant:"filled",disabled:!1,open:!1,className:["enabled:hover:bg-muted-hover","enabled:hover:border-muted"]},{variant:"filled",open:!0,className:["bg-muted-hover"]}]}),r=e(["nd-select-trigger-content","min-w-0","flex-auto","truncate"],{variants:{size:{small:["pl-2","text-sm"],medium:["pl-3","text-md"],large:["pl-4","text-lg"]},placeholder:{true:["text-subtle"],false:["text-main"]}}}),l=e(["nd-select-trigger-icon","shrink-0","inline-flex","items-center","text-muted","transition-transform"],{variants:{size:{small:["px-2","text-sm"],medium:["px-3","text-md"],large:["px-4","text-lg"]},open:{true:["rotate-180"],false:""}}}),o=e(["nd-select-listbox","max-h-60","overflow-auto","overscroll-contain","px-1","py-1","outline-none"]),i=e(["nd-select-option","w-full","flex","items-center","gap-2","rounded-sm","text-left","text-main","select-none","transition-colors",t.disabled()],{variants:{size:{small:["min-h-8","px-2","text-sm"],medium:["min-h-9","px-3","text-md"],large:["min-h-10","px-4","text-lg"]},disabled:{true:["text-subtle"],false:["cursor-pointer"]},active:{true:["bg-surface-muted"],false:""}}}),a=e(["nd-select-option-content","min-w-0","flex-auto"]),s=e(["nd-select-option-label","block","truncate"]),d=e(["nd-select-option-indicator","shrink-0","inline-flex","items-center","justify-center"],{variants:{size:{small:["size-3.5","text-sm"],medium:["size-4","text-md"],large:["size-4.5","text-lg"]}}}),m={trigger:n,triggerContent:r,triggerIcon:l,listbox:o,option:i,optionContent:a,optionLabel:s,optionIndicator:d};export{m as default};
1
+ import{cva as e}from"@nild/shared";import t from"../../_shared/style/index.js";const l=e(["nd-select-trigger","group",["inline-flex","items-center"],"box-border","font-nd","overflow-hidden","text-left","appearance-none","border","transition-colors","outline-none",t.disabled()],{variants:{variant:{outlined:["bg-transparent","border-main","enabled:hover:border-brand-hover"],filled:["bg-muted","border-subtle"],underlined:["bg-transparent","border-transparent","border-b-main","enabled:hover:border-b-brand-hover","enabled:focus-visible:border-b-brand"]},size:{small:["h-6","text-sm"],medium:["h-8","text-md"],large:["h-10","text-lg"]},block:{true:["flex","w-full"],false:""},disabled:{true:"",false:"cursor-pointer"},open:{true:["z-1"],false:""}},compoundVariants:[{variant:["outlined","filled"],size:"small",className:["rounded-sm"]},{variant:["outlined","filled"],size:["medium","large"],className:["rounded-md"]},{variant:["outlined","filled"],open:!0,className:["border-brand","ring-focused"]},{variant:"underlined",open:!0,className:["border-b-brand"]},{variant:"filled",disabled:!1,open:!1,className:["enabled:hover:bg-muted-hover","enabled:hover:border-muted"]},{variant:"filled",open:!0,className:["bg-muted-hover"]}]}),n=e(["nd-select-trigger-content","min-w-0","flex-auto","truncate"],{variants:{size:{small:["text-sm"],medium:["text-md"],large:["text-lg"]},placeholder:{true:["text-subtle"],false:["text-main"]}},compoundVariants:[{variant:["outlined","filled"],size:"small",className:["pl-2"]},{variant:["outlined","filled"],size:"medium",className:["pl-3"]},{variant:["outlined","filled"],size:"large",className:["pl-4"]}]}),a=e(["nd-select-trigger-icon","shrink-0","inline-flex","items-center","text-muted","transition-transform"],{variants:{size:{small:["text-sm"],medium:["text-md"],large:["text-lg"]},open:{true:["rotate-180"],false:""}},compoundVariants:[{variant:["outlined","filled"],size:"small",className:["px-2"]},{variant:["outlined","filled"],size:"medium",className:["px-3"]},{variant:["outlined","filled"],size:"large",className:["px-4"]}]}),r=e(["nd-select-listbox","max-h-60","overflow-auto","overscroll-contain","px-1","py-1","outline-none"]),i=e(["nd-select-option","w-full","flex","items-center","gap-2","rounded-sm","text-left","text-main","select-none","transition-colors",t.disabled()],{variants:{size:{small:["min-h-8","px-2","text-sm"],medium:["min-h-9","px-3","text-md"],large:["min-h-10","px-4","text-lg"]},disabled:{true:["text-subtle"],false:["cursor-pointer"]},active:{true:["bg-surface-muted"],false:""}}}),s=e(["nd-select-option-content","min-w-0","flex-auto"]),o=e(["nd-select-option-label","block","truncate"]),d=e(["nd-select-option-indicator","shrink-0","inline-flex","items-center","justify-center"],{variants:{size:{small:["size-3.5","text-sm"],medium:["size-4","text-md"],large:["size-4.5","text-lg"]}}}),m={trigger:l,triggerContent:n,triggerIcon:a,listbox:r,option:i,optionContent:s,optionLabel:o,optionIndicator:d};export{m as default};
File without changes
File without changes
@@ -1,3 +1,3 @@
1
- import{useEffectCallback as F}from"@nild/hooks";import{useState as H,useRef as W,useMemo as f,useCallback as b,useEffect as $}from"react";import k from"../../_shared/utils/get-computed-style-value/index.js";import"@nild/shared";import{normalizeContent as G,normalizeImage as N,toTuple as I,createTile as R}from"../_shared/canvas.js";const m={dataUrl:null,size:null},w=C=>{const{rootRef:v,layerRef:p,text:g,image:h,pattern:t,textStyle:o,opacity:E,zIndex:j,onError:y}=C,[n,A]=H(m),z=W(m),u=f(()=>G(g).join(`
2
- `),[g]),s=f(()=>{const l=N(h);return l?{...l}:void 0},[h]),r=f(()=>{const[l,i]=I(t?.gap,[64,48]),[e,a]=I(t?.offset,[0,0]);return{gap:[l,i],offset:[e,a],rotate:t?.rotate??-22,composition:t?.composition??"stack",compositionGap:t?.compositionGap??8}},[t?.composition,t?.compositionGap,t?.gap,t?.offset,t?.rotate]),S=b(()=>{const l=o?.fontSize??16,i=k(p.current,"color");return{fontSize:l,fontWeight:o?.fontWeight??400,fontFamily:o?.fontFamily||k(v.current,"fontFamily")||"-apple-system, blinkmacsystemfont, 'Segoe UI', roboto, 'Helvetica Neue', arial, 'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji'",fontStyle:o?.fontStyle??"normal",lineHeight:o?.lineHeight??l*1.4,color:o!=null&&o.color?i||o.color:i||"currentColor",textAlign:o?.textAlign??"center"}},[p,v,o?.color,o?.fontFamily,o?.fontSize,o?.fontStyle,o?.fontWeight,o?.lineHeight,o?.textAlign]),x=F((l,i)=>{y?.(l,i)}),d=b(l=>{var i,e,a,U;const{current:c}=z;(c.dataUrl!==l.dataUrl||((i=c.size)==null?void 0:i.width)!==((e=l.size)==null?void 0:e.width)||((a=c.size)==null?void 0:a.height)!==((U=l.size)==null?void 0:U.height))&&(z.current=l,A(l))},[]);return $(()=>{let l=!1;const i=u?u.split(`
3
- `):[];if(!i.length&&!s){d(m);return}return R({content:i,image:s,pattern:r,textStyle:S()}).then(e=>{l||(d({dataUrl:e.dataUrl,size:e.width&&e.height?{width:e.width,height:e.height}:null}),e.error&&e.image&&x(e.error,e.image))}),()=>{l=!0}},[x,u,s,r,S,d]),{layerStyle:{backgroundImage:n.dataUrl?`url(${n.dataUrl})`:void 0,backgroundSize:n.size?`${n.size.width}px ${n.size.height}px`:void 0,backgroundPosition:`${r.offset[0]}px ${r.offset[1]}px`,color:o?.color,opacity:E??.16,zIndex:j??1}}};export{w as default,w as useWatermarkLayer};
1
+ import{useRefState as F,useEffectCallback as H}from"@nild/hooks";import{useMemo as f,useCallback as b,useEffect as W}from"react";import k from"../../_shared/utils/get-computed-style-value/index.js";import"@nild/shared";import{normalizeContent as j,normalizeImage as G,toTuple as I,createTile as N}from"../_shared/canvas.js";const w={dataUrl:null,size:null},C=E=>{const{rootRef:m,layerRef:v,text:p,image:g,pattern:t,textStyle:o,opacity:$,zIndex:A,onError:h}=E,[n,y,z]=F(w),u=f(()=>j(p).join(`
2
+ `),[p]),s=f(()=>{const l=G(g);return l?{...l}:void 0},[g]),r=f(()=>{const[l,i]=I(t?.gap,[64,48]),[e,a]=I(t?.offset,[0,0]);return{gap:[l,i],offset:[e,a],rotate:t?.rotate??-22,composition:t?.composition??"stack",compositionGap:t?.compositionGap??8}},[t?.composition,t?.compositionGap,t?.gap,t?.offset,t?.rotate]),S=b(()=>{const l=o?.fontSize??16,i=k(v.current,"color");return{fontSize:l,fontWeight:o?.fontWeight??400,fontFamily:o?.fontFamily||k(m.current,"fontFamily")||"-apple-system, blinkmacsystemfont, 'Segoe UI', roboto, 'Helvetica Neue', arial, 'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji'",fontStyle:o?.fontStyle??"normal",lineHeight:o?.lineHeight??l*1.4,color:o!=null&&o.color?i||o.color:i||"currentColor",textAlign:o?.textAlign??"center"}},[v,m,o?.color,o?.fontFamily,o?.fontSize,o?.fontStyle,o?.fontWeight,o?.lineHeight,o?.textAlign]),x=H((l,i)=>{h?.(l,i)}),d=b(l=>{var i,e,a,U;const{current:c}=z;(c.dataUrl!==l.dataUrl||((i=c.size)==null?void 0:i.width)!==((e=l.size)==null?void 0:e.width)||((a=c.size)==null?void 0:a.height)!==((U=l.size)==null?void 0:U.height))&&y(l)},[y,z]);return W(()=>{let l=!1;const i=u?u.split(`
3
+ `):[];if(!i.length&&!s){d(w);return}return N({content:i,image:s,pattern:r,textStyle:S()}).then(e=>{l||(d({dataUrl:e.dataUrl,size:e.width&&e.height?{width:e.width,height:e.height}:null}),e.error&&e.image&&x(e.error,e.image))}),()=>{l=!0}},[x,u,s,r,S,d]),{layerStyle:{backgroundImage:n.dataUrl?`url(${n.dataUrl})`:void 0,backgroundSize:n.size?`${n.size.width}px ${n.size.height}px`:void 0,backgroundPosition:`${r.offset[0]}px ${r.offset[1]}px`,color:o?.color,opacity:$??.16,zIndex:A??1}}};export{C as default,C as useWatermarkLayer};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@nild/components",
3
3
  "private": false,
4
- "version": "0.0.46",
4
+ "version": "0.0.48",
5
5
  "type": "module",
6
6
  "module": "./dist/index.js",
7
7
  "exports": {
@@ -31,9 +31,9 @@
31
31
  "peerDependencies": {
32
32
  "react": "^18.2.0",
33
33
  "react-dom": "^18.2.0",
34
- "@nild/icons": "^0.0.20",
35
- "@nild/hooks": "^0.0.20",
36
- "@nild/shared": "^0.0.17"
34
+ "@nild/icons": "^0.0.21",
35
+ "@nild/shared": "^0.0.18",
36
+ "@nild/hooks": "^0.0.21"
37
37
  },
38
38
  "scripts": {
39
39
  "build": "vite build --mode PROD",
@@ -1,2 +0,0 @@
1
- declare const lockDocumentScroll: (doc: Document) => () => void;
2
- export default lockDocumentScroll;
@@ -1 +0,0 @@
1
- import{isBrowser as r}from"@nild/shared";let t=0,n="",i="";const a=e=>{const o=e.defaultView??(r()?window:null);return o?[e.documentElement,e.body].some(d=>{const l=o.getComputedStyle(d),s=l.getPropertyValue("scrollbar-gutter")||l.scrollbarGutter||"";return/\bstable\b/.test(s)}):!1},y=e=>{if(!r())return()=>{};if(t===0){n=e.body.style.overflow,i=e.body.style.paddingRight;const o=Number.parseFloat(window.getComputedStyle(e.body).paddingRight||"0")||0,d=e.documentElement.clientWidth>0?window.innerWidth-e.documentElement.clientWidth:0,l=!a(e);e.body.style.overflow="hidden",l&&d>0&&(e.body.style.paddingRight=`${o+d}px`)}return t+=1,()=>{t=Math.max(0,t-1),t===0&&(e.body.style.overflow=n,e.body.style.paddingRight=i)}};export{y as default};