@nild/components 0.0.37 → 0.0.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_shared/utils/get-global-state/__tests__/index.test.d.ts +1 -0
- package/dist/_shared/utils/get-global-state/index.d.ts +5 -0
- package/dist/_shared/utils/get-global-state/index.js +1 -0
- package/dist/_shared/utils/get-owner-document/__tests__/index.test.d.ts +1 -0
- package/dist/_shared/utils/get-owner-document/index.d.ts +2 -0
- package/dist/_shared/utils/get-owner-document/index.js +1 -0
- package/dist/_shared/utils/index.d.ts +8 -2
- package/dist/_shared/utils/is-plain-children/__tests__/index.test.d.ts +1 -0
- package/dist/_shared/utils/lock-document-scroll/__tests__/index.test.d.ts +1 -0
- package/dist/_shared/utils/lock-document-scroll/index.d.ts +2 -0
- package/dist/_shared/utils/lock-document-scroll/index.js +1 -0
- package/dist/_shared/utils/merge-handlers/__tests__/index.test.d.ts +1 -0
- package/dist/_shared/utils/merge-handlers/index.d.ts +3 -0
- package/dist/_shared/utils/merge-handlers/index.js +1 -0
- package/dist/_shared/utils/merge-props/__tests__/index.test.d.ts +1 -0
- package/dist/_shared/utils/merge-props/index.d.ts +3 -0
- package/dist/_shared/utils/merge-props/index.js +1 -0
- package/dist/_shared/utils/register-slots/__tests__/index.test.d.ts +1 -0
- package/dist/_shared/utils/register-slots/index.d.ts +28 -0
- package/dist/_shared/utils/register-slots/index.js +1 -0
- package/dist/button/__tests__/Button.test.d.ts +0 -0
- package/dist/button/style/index.js +1 -1
- package/dist/checkbox/Checkbox.js +1 -1
- package/dist/checkbox/Indicator.js +1 -1
- package/dist/checkbox/__tests__/Checkbox.test.d.ts +0 -0
- package/dist/checkbox/contexts/index.d.ts +2 -2
- package/dist/checkbox/style/index.d.ts +3 -1
- package/dist/checkbox/style/index.js +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.js +1 -1
- package/dist/input/Composite.js +1 -1
- package/dist/input/Input.js +1 -1
- package/dist/input/__tests__/Input.test.d.ts +0 -0
- package/dist/input/style/index.js +1 -1
- package/dist/modal/Body.d.ts +5 -0
- package/dist/modal/Body.js +1 -0
- package/dist/modal/Close.d.ts +5 -0
- package/dist/modal/Close.js +1 -0
- package/dist/modal/Footer.d.ts +5 -0
- package/dist/modal/Footer.js +1 -0
- package/dist/modal/Header.d.ts +5 -0
- package/dist/modal/Header.js +1 -0
- package/dist/modal/Modal.d.ts +4 -0
- package/dist/modal/Modal.js +1 -0
- package/dist/modal/Portal.d.ts +5 -0
- package/dist/modal/Portal.js +1 -0
- package/dist/modal/Trigger.d.ts +5 -0
- package/dist/modal/Trigger.js +1 -0
- package/dist/modal/__tests__/Modal.test.d.ts +0 -0
- package/dist/modal/_shared/__tests__/index.test.d.ts +1 -0
- package/dist/modal/_shared/index.d.ts +5 -0
- package/dist/modal/_shared/index.js +1 -0
- package/dist/modal/_shared/stack.d.ts +7 -0
- package/dist/modal/_shared/stack.js +1 -0
- package/dist/modal/contexts/index.d.ts +24 -0
- package/dist/modal/contexts/index.js +1 -0
- package/dist/modal/hooks/index.d.ts +1 -0
- package/dist/modal/hooks/useModalStack.d.ts +4 -0
- package/dist/modal/hooks/useModalStack.js +1 -0
- package/dist/modal/index.d.ts +13 -0
- package/dist/modal/index.js +1 -0
- package/dist/modal/style/index.d.ts +27 -0
- package/dist/modal/style/index.js +1 -0
- package/dist/popup/Popup.js +1 -1
- package/dist/popup/__tests__/Popup.test.d.ts +0 -0
- package/dist/popup/style/index.js +1 -1
- package/dist/radio/Indicator.js +1 -1
- package/dist/radio/Radio.js +1 -1
- package/dist/radio/__tests__/Radio.test.d.ts +0 -0
- package/dist/radio/contexts/index.d.ts +2 -2
- package/dist/radio/style/index.d.ts +4 -1
- package/dist/radio/style/index.js +1 -1
- package/dist/switch/Switch.js +1 -1
- package/dist/switch/__tests__/Switch.test.d.ts +0 -0
- package/dist/switch/style/index.js +1 -1
- package/dist/tailwind.css +1 -1
- package/dist/transition/Transition.js +1 -1
- package/dist/transition/__tests__/Transition.test.d.ts +0 -0
- package/dist/transition/index.d.ts +1 -1
- package/dist/transition/interfaces/index.d.ts +2 -2
- package/dist/transition/interfaces/index.js +1 -1
- package/dist/transition/style/index.d.ts +2 -2
- package/dist/transition/style/index.js +1 -1
- package/package.json +1 -1
- /package/dist/_shared/utils/{isPlainChildren.d.ts → is-plain-children/index.d.ts} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var t=(l=>(l.Modal="@nild/components/modal-global-state",l))(t||{});const n=(l,e)=>{const a=Symbol.for(l),o=globalThis;return a in o||(o[a]=e()),o[a]};export{t as GlobalStateKey,n as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{isBrowser as e}from"@nild/shared";const r=(...t)=>{var o;return((o=t.find(n=>n?.ownerDocument))==null?void 0:o.ownerDocument)||(e()?document:null)};export{r as default};
|
|
@@ -1,2 +1,8 @@
|
|
|
1
|
-
import { default as
|
|
2
|
-
|
|
1
|
+
import { default as getGlobalState, GlobalStateKey } from './get-global-state';
|
|
2
|
+
import { default as getOwnerDocument } from './get-owner-document';
|
|
3
|
+
import { default as isPlainChildren } from './is-plain-children';
|
|
4
|
+
import { default as lockDocumentScroll } from './lock-document-scroll';
|
|
5
|
+
import { default as mergeHandlers } from './merge-handlers';
|
|
6
|
+
import { default as mergeProps } from './merge-props';
|
|
7
|
+
import { default as registerSlots } from './register-slots';
|
|
8
|
+
export { getGlobalState, getOwnerDocument, GlobalStateKey, isPlainChildren, lockDocumentScroll, registerSlots, mergeHandlers, mergeProps, };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const n=e=>typeof e=="object"&&e!==null&&"defaultPrevented"in e,r=(...e)=>(...t)=>{const[o]=t;for(const f of e)if(f&&(f(...t),n(o)&&o.defaultPrevented))break};export{r as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{cnMerge as a}from"@nild/shared";import i from"../merge-handlers/index.js";const l=(o,n)=>{const c={...o,...n},f=new Set([...Object.keys(o),...Object.keys(n)]);for(const s of f){if(s==="className"){const t=o.className,e=n.className;(t||e)&&(c.className=a(e,t));continue}if(s==="style"){const t=o.style,e=n.style;(t||e)&&(c.style={...e,...t});continue}if(/^on[A-Z]/.test(s)){const t=o[s],e=n[s];(typeof t=="function"||typeof e=="function")&&(c[s]=i(t,e))}}return c};export{l as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ReactElement, ReactNode } from 'react';
|
|
2
|
+
interface SlotDefinition {
|
|
3
|
+
isMatched: (child: ReactElement) => boolean;
|
|
4
|
+
multiple?: boolean;
|
|
5
|
+
strategy?: 'first' | 'last';
|
|
6
|
+
}
|
|
7
|
+
type SlotSchema = Record<string, SlotDefinition>;
|
|
8
|
+
interface SingleSlot {
|
|
9
|
+
el: ReactElement | null;
|
|
10
|
+
seq: number;
|
|
11
|
+
}
|
|
12
|
+
interface MultipleSlot {
|
|
13
|
+
el: ReactElement[];
|
|
14
|
+
seq: number[];
|
|
15
|
+
}
|
|
16
|
+
interface PlainChild {
|
|
17
|
+
content: string | number;
|
|
18
|
+
seq: number;
|
|
19
|
+
}
|
|
20
|
+
type SlotValue<T extends SlotDefinition> = T['multiple'] extends true ? MultipleSlot : SingleSlot;
|
|
21
|
+
interface CollectSlotsResult<Schema extends SlotSchema> {
|
|
22
|
+
slots: {
|
|
23
|
+
[K in keyof Schema]: SlotValue<Schema[K]>;
|
|
24
|
+
};
|
|
25
|
+
plainChildren: PlainChild[];
|
|
26
|
+
}
|
|
27
|
+
declare const registerSlots: <Schema extends SlotSchema>(schema: Schema) => (children: ReactNode) => CollectSlotsResult<Schema>;
|
|
28
|
+
export default registerSlots;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Children as c,isValidElement as a,Fragment as h}from"react";const m=f=>{const o=Object.entries(f);return p=>{const l=o.reduce((n,[t,e])=>(n[t]=e.multiple?{el:[],seq:[]}:{el:null,seq:-1},n),{}),i=[];let r=0;const u=n=>{c.forEach(n,t=>{if(!(t==null||typeof t=="boolean")){if(a(t)&&t.type===h){u(t.props.children);return}if(typeof t=="string"||typeof t=="number"){i.push({content:t,seq:r}),r+=1;return}if(!a(t)){r+=1;return}for(const[e,s]of o)if(s.isMatched(t)){s.multiple?(l[e].el.push(t),l[e].seq.push(r)):(l[e].el===null||(s.strategy??"last")==="last")&&(l[e].el=t,l[e].seq=r);break}r+=1}})};return u(p),{slots:l,plainChildren:i}}};export{m as default};
|
|
File without changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{cva as e}from"@nild/shared";import{DISABLED_CLS as a}from"../../_shared/style/index.js";const r=e(["nd-button",["font-nd","cursor-pointer","transition-colors"],["whitespace-nowrap","truncate"],a],{variants:{variant:{solid:["bg-brand","text-brand-contrast","enabled:hover:bg-brand-hover","enabled:active:bg-brand-active"],outlined:["bg-transparent","border","border-main","text-main","enabled:hover:border-brand-hover","enabled:hover:text-brand-hover","enabled:active:border-brand-active","enabled:active:text-brand-active"],filled:["bg-muted","text-main","enabled:hover:bg-muted-hover","enabled:active:bg-muted-active"],text:["bg-transparent","text-main","enabled:hover:bg-muted-hover","enabled:active:bg-muted-active"]},shape:{round:["rounded-full"],square:["rounded-md"]},size:{small:["px-2","h-6","text-sm"],medium:["px-4","h-8","text-md"],large:["px-6","h-10","text-lg"]},block:{true:"w-full",false:""},disabled:{true:"disabled",false:""},equal:{true:["flex","justify-center","items-center"],false:""}},compoundVariants:[{size:"small",equal:!0,className:["w-6 h-6","p-1"]},{size:"medium",equal:!0,className:["w-8 h-8","p-1.5"]},{size:"large",equal:!0,className:["w-10 h-10","p-2"]}]}),t=e(["nd-button-group",["flex"]],{variants:{direction:{horizontal:"",vertical:"flex-col"}}}),n=e("",{compoundVariants:[{first:!0,direction:"horizontal",className:"rounded-r-none"},{first:!0,direction:"vertical",className:"rounded-b-none"},{last:!0,direction:"horizontal",className:"rounded-l-none"},{last:!0,direction:"vertical",className:"rounded-t-none"},{first:!1,last:!1,className:"rounded-none"},{last:!1,direction:"horizontal",variant:"outlined",className:["mr-[-1px]","hover:z-1"]},{last:!1,direction:"vertical",variant:"outlined",className:["mb-[-1px]","hover:z-1"]},{last:!1,direction:"horizontal",variant:"solid",className:["border-r","border-r-brand-hover"]},{last:!1,direction:"horizontal",variant:["filled","text"],className:["border-r","border-r-muted"]},{last:!1,direction:"vertical",variant:"solid",className:["border-b","border-b-brand-hover"]},{last:!1,direction:"vertical",variant:["filled","text"],className:["border-b","border-b-muted"]}]}),o={button:r,group:t,groupedButton:n};export{o as default};
|
|
1
|
+
import{cva as e}from"@nild/shared";import{DISABLED_CLS as a}from"../../_shared/style/index.js";const r=e(["nd-button",["font-nd","cursor-pointer","transition-colors"],["whitespace-nowrap","truncate"],"focus-visible:ring-focused",a],{variants:{variant:{solid:["bg-brand","text-brand-contrast","enabled:hover:bg-brand-hover","enabled:active:bg-brand-active"],outlined:["bg-transparent","border","border-main","text-main","enabled:hover:border-brand-hover","enabled:hover:text-brand-hover","enabled:active:border-brand-active","enabled:active:text-brand-active"],filled:["bg-muted","text-main","enabled:hover:bg-muted-hover","enabled:active:bg-muted-active"],text:["bg-transparent","text-main","enabled:hover:bg-muted-hover","enabled:active:bg-muted-active"]},shape:{round:["rounded-full"],square:["rounded-md"]},size:{small:["px-2","h-6","text-sm"],medium:["px-4","h-8","text-md"],large:["px-6","h-10","text-lg"]},block:{true:"w-full",false:""},disabled:{true:"disabled",false:""},equal:{true:["flex","justify-center","items-center"],false:""}},compoundVariants:[{size:"small",equal:!0,className:["w-6 h-6","p-1"]},{size:"medium",equal:!0,className:["w-8 h-8","p-1.5"]},{size:"large",equal:!0,className:["w-10 h-10","p-2"]}]}),t=e(["nd-button-group",["flex"]],{variants:{direction:{horizontal:"",vertical:"flex-col"}}}),n=e("focus-visible:z-1",{compoundVariants:[{first:!0,direction:"horizontal",className:"rounded-r-none"},{first:!0,direction:"vertical",className:"rounded-b-none"},{last:!0,direction:"horizontal",className:"rounded-l-none"},{last:!0,direction:"vertical",className:"rounded-t-none"},{first:!1,last:!1,className:"rounded-none"},{last:!1,direction:"horizontal",variant:"outlined",className:["mr-[-1px]","hover:z-1"]},{last:!1,direction:"vertical",variant:"outlined",className:["mb-[-1px]","hover:z-1"]},{last:!1,direction:"horizontal",variant:"solid",className:["border-r","border-r-brand-hover"]},{last:!1,direction:"horizontal",variant:["filled","text"],className:["border-r","border-r-muted"]},{last:!1,direction:"vertical",variant:"solid",className:["border-b","border-b-brand-hover"]},{last:!1,direction:"vertical",variant:["filled","text"],className:["border-b","border-b-muted"]}]}),o={button:r,group:t,groupedButton:n};export{o as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as d,jsxs as E}from"react/jsx-runtime";import{useControllableState as G,useEffectCallback as P}from"@nild/hooks";import{cnMerge as R}from"@nild/shared";import{forwardRef as S}from"react";import V from"../_shared/utils/register-slots/index.js";import{useGroupContext as A,CheckboxProvider as B}from"./contexts/index.js";import h from"./Indicator.js";import b from"./Label.js";import F from"./style/index.js";const I=V({indicator:{isMatched:a=>a.type===h},label:{isMatched:a=>a.type===b}}),p=S((a,v)=>{var n;const e=A(),{className:C,children:k,variant:x=e?.variant??"solid",size:c=e?.size??"medium",disabled:i=e?.disabled??!1,checked:q,defaultChecked:y,value:r,onChange:m,...z}=a,{slots:l,plainChildren:s}=I(k),[M,N]=G(e?e.value.includes(r):q,y??!1),g=P(()=>{i||N(t=>(e?e.setValue(t?e.value.filter(w=>w!==r):e.value.concat(r)):m?.(!t),!t))}),u=l.indicator.el??d(h,{}),o=l.label.el??(s.length>0?d(b,{children:s[0].content}):null),j=l.label.el?l.label.seq:((n=s[0])==null?void 0:n.seq)??-1,f=!!l.indicator.el&&!!o&&j<l.indicator.seq;return d(B,{value:{variant:x,size:c,checked:M,disabled:i,setChecked:g},children:E("label",{...z,className:R(F.checkbox({size:c,disabled:i}),C),ref:v,children:[f?o:u,f?u:o]})})});p.displayName="Checkbox";export{p as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as
|
|
1
|
+
import{jsxs as k,jsx as a}from"react/jsx-runtime";import{Icon as u}from"@nild/icons";import x from"@nild/icons/CheckSmall";import{cnMerge as I}from"@nild/shared";import{forwardRef as N}from"react";import{useCheckboxContext as C}from"./contexts/index.js";import e from"./style/index.js";const c=N(({className:s,children:o,...i},t)=>{const{variant:d,size:n,checked:r,disabled:m,setChecked:l}=C(),f=!o,p=o??(h=>a("div",{className:e.defaultIndicatorBlock({variant:d,checked:h}),children:a(u,{className:e.defaultIndicatorIcon(),component:x})}));return k("div",{...i,className:I(e.indicator({size:n,default:f}),s),ref:t,children:[p(!!r),a("input",{type:"checkbox",className:e.indicatorInput(),checked:r,disabled:m,onChange:l})]})});c.displayName="Checkbox.Indicator";export{c as default};
|
|
File without changes
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CheckboxProps, GroupProps } from '../interfaces';
|
|
2
|
-
declare const CheckboxProvider: import('react').Provider<Pick<CheckboxProps, "variant" | "size" | "checked"> & {
|
|
2
|
+
declare const CheckboxProvider: import('react').Provider<Pick<CheckboxProps, "variant" | "size" | "disabled" | "checked"> & {
|
|
3
3
|
setChecked?: () => void;
|
|
4
|
-
}>, useCheckboxContext: () => Pick<CheckboxProps, "variant" | "size" | "checked"> & {
|
|
4
|
+
}>, useCheckboxContext: () => Pick<CheckboxProps, "variant" | "size" | "disabled" | "checked"> & {
|
|
5
5
|
setChecked?: () => void;
|
|
6
6
|
};
|
|
7
7
|
declare const GroupProvider: import('react').Provider<(Pick<GroupProps<unknown>, "variant" | "size" | "disabled"> & {
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { CheckboxProps, GroupProps } from '../interfaces';
|
|
2
2
|
declare const _default: {
|
|
3
3
|
checkbox: (props?: Pick<CheckboxProps, "size" | "disabled"> | undefined) => string;
|
|
4
|
-
indicator: (props?: Pick<CheckboxProps, "size">
|
|
4
|
+
indicator: (props?: (Pick<CheckboxProps, "size"> & {
|
|
5
|
+
default?: boolean;
|
|
6
|
+
}) | undefined) => string;
|
|
5
7
|
indicatorInput: (props?: object | undefined) => string;
|
|
6
8
|
defaultIndicatorBlock: (props?: Pick<CheckboxProps, "variant" | "checked"> | undefined) => string;
|
|
7
9
|
defaultIndicatorIcon: (props?: object | undefined) => string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{cva as e}from"@nild/shared";import{DISABLED_CLS as r}from"../../_shared/style/index.js";const a=e(["nd-checkbox","group",["flex","items-center"],"cursor-pointer",r],{variants:{size:{small:"gap-1.5",medium:"gap-2",large:"gap-2.5"},disabled:{true:"disabled",false:""}}}),t=e(["relative",["flex","items-center","justify-center"]],{variants:{size:{small:"size-3.5 text-sm",medium:"size-4 text-md",large:"size-4.5 text-lg"}}}),o=e([["absolute","inset-0","opacity-0"],["group-enabled:cursor-pointer","group-disabled:cursor-not-allowed"]]),n=e([["flex","items-center","justify-center"],["size-full","rounded-sm","border"],"transition-[background-color,color,border-color]"],{compoundVariants:[{checked:!0,variant:"solid",className:["bg-brand border-brand text-brand-contrast","group-enabled:group-hover:bg-brand-hover"]},{checked:!0,variant:"outlined",className:["bg-transparent border-brand text-brand","group-enabled:group-hover:
|
|
1
|
+
import{cva as e}from"@nild/shared";import{DISABLED_CLS as r}from"../../_shared/style/index.js";const a=e(["nd-checkbox","group",["flex","items-center"],"cursor-pointer",r],{variants:{size:{small:"gap-1.5",medium:"gap-2",large:"gap-2.5"},disabled:{true:"disabled",false:""}}}),t=e(["nd-checkbox-indicator","relative",["flex","items-center","justify-center"]],{variants:{size:{small:"size-3.5 text-sm",medium:"size-4 text-md",large:"size-4.5 text-lg"},default:{true:["rounded-sm","transition-[box-shadow]","group-enabled:focus-visible-within:ring-focused"],false:""}}}),o=e([["absolute","inset-0","opacity-0"],["group-enabled:cursor-pointer","group-disabled:cursor-not-allowed"]]),n=e([["flex","items-center","justify-center"],["size-full","rounded-sm","border"],"transition-[background-color,color,border-color]","group-enabled:group-hover:border-brand-hover"],{compoundVariants:[{checked:!0,variant:"solid",className:["bg-brand border-brand text-brand-contrast","group-enabled:group-hover:bg-brand-hover"]},{checked:!0,variant:"outlined",className:["bg-transparent border-brand text-brand","group-enabled:group-hover:text-brand-hover"]},{checked:!1,className:["bg-transparent border-main text-transparent"]}]}),d=e(["w-full"]),i=e(["text-sm"],{variants:{size:{small:"text-sm",medium:"text-md",large:"text-lg"}}}),s=e(["nd-checkbox-group",["flex","gap-x-4","gap-y-2"]],{variants:{direction:{horizontal:"flex-row flex-wrap",vertical:"flex-col"}}}),l={checkbox:a,indicator:t,indicatorInput:o,defaultIndicatorBlock:n,defaultIndicatorIcon:d,label:i,group:s};export{l as default};
|
package/dist/index.d.ts
CHANGED
|
@@ -2,10 +2,11 @@ import { default as Button } from './button';
|
|
|
2
2
|
import { default as Checkbox } from './checkbox';
|
|
3
3
|
import { default as Divider } from './divider';
|
|
4
4
|
import { default as Input } from './input';
|
|
5
|
+
import { default as Modal } from './modal';
|
|
5
6
|
import { default as Popover } from './popover';
|
|
6
7
|
import { default as Radio } from './radio';
|
|
7
8
|
import { default as Switch } from './switch';
|
|
8
9
|
import { default as Tooltip } from './tooltip';
|
|
9
|
-
import { default as Transition } from './transition';
|
|
10
|
+
import { default as Transition, TransitionStatus } from './transition';
|
|
10
11
|
import { default as Typography } from './typography';
|
|
11
|
-
export { Button, Checkbox, Divider, Popover, Radio, Switch, Tooltip, Transition, Typography,
|
|
12
|
+
export { Button, Checkbox, Divider, Input, Modal, Popover, Radio, Switch, Tooltip, Transition, TransitionStatus, Typography, };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{default as a}from"./button/index.js";import{default as o}from"./checkbox/index.js";import{default as t}from"./divider/Divider.js";import{default as r}from"./input/index.js";import{default as s}from"./popover/index.js";import{default as
|
|
1
|
+
import{default as a}from"./button/index.js";import{default as o}from"./checkbox/index.js";import{default as t}from"./divider/Divider.js";import{default as r}from"./input/index.js";import{default as s}from"./modal/index.js";import{default as m}from"./popover/index.js";import{default as i}from"./radio/index.js";import{default as f}from"./switch/index.js";import{default as p}from"./tooltip/index.js";import{default as u}from"./transition/Transition.js";import{TransitionStatus as d}from"./transition/interfaces/index.js";import{default as e}from"./typography/index.js";/* empty css */export{a as Button,o as Checkbox,t as Divider,r as Input,s as Modal,m as Popover,i as Radio,f as Switch,p as Tooltip,u as Transition,d as TransitionStatus,e as Typography};
|
package/dist/input/Composite.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as c,jsxs as u}from"react/jsx-runtime";import{cnMerge as f}from"@nild/shared";import{forwardRef as h,cloneElement as v}from"react";import b from"../_shared/utils/register-slots/index.js";import{isAppendElement as E}from"./Append.js";import{CompositeProvider as M}from"./contexts/index.js";import{isInputElement as N}from"./Input.js";import{isPrependElement as x}from"./Prepend.js";import o from"./style/index.js";const I=b({prepend:{isMatched:x},input:{isMatched:N},append:{isMatched:E}}),s=h(({className:i,children:n,variant:p="outlined",size:t="medium",block:r=!1,disabled:l=!1,...m},d)=>{var a;const{slots:e}=I(n);return e.input.el?c(M,{value:{variant:p,size:t,block:r,disabled:l},children:u("span",{ref:d,className:f(o.composite({block:r}),i),...m,children:[e.prepend.el,v(e.input.el,{...(a=e.input.el)==null?void 0:a.props,className:o.compositedInputWrapper({variant:p,prepended:!!e.prepend.el,appended:!!e.append.el})}),e.append.el]})}):null});s.displayName="Input.Composite";export{s as default};
|
package/dist/input/Input.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
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,f)=>{const a=j(),{className:d,children:u,variant:l=a.variant,size:s=a.size,block:c=a.block,disabled:t=a.disabled,type:x="text",value:v,defaultValue:b="",onChange:o,...h}=e,{slots:n}=J(u),[g,z]=E(v,b),C=i=>{z(i.target.value),o?.(i.target.value,i)};return m(P,{value:{size:s,disabled:t,variant:l},children:y("span",{className:N(p.inputWrapper({variant:l,size:s,block:c,disabled:t}),d),children:[n.prefix.el,m("input",{ref:f,type:x,value:g,onChange:C,disabled:t,className:p.input({size:s}),...h}),n.suffix.el]})})});r.displayName="Input";export{r as default,w as isInputElement};
|
|
File without changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{cva as e}from"@nild/shared";import{DISABLED_CLS as t}from"../../_shared/style/index.js";const n=e(["nd-input-composite","inline-flex","items-stretch"],{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"
|
|
1
|
+
import{cva as e}from"@nild/shared";import{DISABLED_CLS as t}from"../../_shared/style/index.js";const n=e(["nd-input-composite","inline-flex","items-stretch"],{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],{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:""},disabled:{true:"disabled",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};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ReactElement, ReactNode } from 'react';
|
|
2
|
+
import { BodyProps } from './interfaces';
|
|
3
|
+
export declare const isBodyElement: (child: ReactNode) => child is ReactElement<BodyProps>;
|
|
4
|
+
declare const Body: import('react').ForwardRefExoticComponent<BodyProps & import('react').RefAttributes<HTMLDivElement>>;
|
|
5
|
+
export default Body;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as m}from"react/jsx-runtime";import{cnMerge as d}from"@nild/shared";import{forwardRef as i,isValidElement as l}from"react";import t from"./style/index.js";const f=a=>l(a)&&a.type===e,e=i(({className:a,children:r,...s},o)=>m("div",{...s,className:d(t.body(),a),ref:o,children:r}));e.displayName="Modal.Body";export{e as default,f as isBodyElement};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ReactElement, ReactNode } from 'react';
|
|
2
|
+
import { CloseProps } from './interfaces';
|
|
3
|
+
export declare const isCloseElement: (child: ReactNode) => child is ReactElement<CloseProps>;
|
|
4
|
+
declare const Close: import('react').ForwardRefExoticComponent<import('../button').ButtonProps & import('react').RefAttributes<HTMLButtonElement>>;
|
|
5
|
+
export default Close;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as o}from"react/jsx-runtime";import{Icon as C}from"@nild/icons";import x from"@nild/icons/Close";import{cnMerge as h}from"@nild/shared";import{forwardRef as M,isValidElement as N}from"react";import q from"../_shared/utils/merge-handlers/index.js";import y from"../button/index.js";import{useModalContext as z}from"./contexts/index.js";import E from"./style/index.js";const g=e=>N(e)&&e.type===a,a=M(({children:e,variant:r="text",shape:s="square",size:l="small",equal:i=!0,"aria-label":m="Close",onClick:t,className:n,disabled:p,...c},d)=>{const{disabled:f,close:u}=z();return o(y,{...c,"aria-label":m,className:h(E.close(),n),disabled:f||p,equal:i,onClick:q(t,b=>(u(),b)),ref:d,shape:s,size:l,variant:r,children:e??o(C,{component:x})})});a.displayName="Modal.Close";export{a as default,g as isCloseElement};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ReactElement, ReactNode } from 'react';
|
|
2
|
+
import { FooterProps } from './interfaces';
|
|
3
|
+
export declare const isFooterElement: (child: ReactNode) => child is ReactElement<FooterProps>;
|
|
4
|
+
declare const Footer: import('react').ForwardRefExoticComponent<FooterProps & import('react').RefAttributes<HTMLDivElement>>;
|
|
5
|
+
export default Footer;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as m}from"react/jsx-runtime";import{cnMerge as t}from"@nild/shared";import{forwardRef as i,isValidElement as f}from"react";import l from"./style/index.js";const d=e=>f(e)&&e.type===r,r=i(({className:e,children:a,...o},s)=>m("div",{...o,className:t(l.footer(),e),ref:s,children:a}));r.displayName="Modal.Footer";export{r as default,d as isFooterElement};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ReactElement, ReactNode } from 'react';
|
|
2
|
+
import { HeaderProps } from './interfaces';
|
|
3
|
+
export declare const isHeaderElement: (child: ReactNode) => child is ReactElement<HeaderProps>;
|
|
4
|
+
declare const Header: import('react').ForwardRefExoticComponent<HeaderProps & import('react').RefAttributes<HTMLDivElement>>;
|
|
5
|
+
export default Header;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as d}from"react/jsx-runtime";import{cnMerge as i}from"@nild/shared";import{forwardRef as o,isValidElement as l}from"react";import t from"./style/index.js";const f=e=>l(e)&&e.type===a,a=o(({className:e,children:r,...s},m)=>d("div",{...s,className:i(t.header(),e),ref:m,children:r}));a.displayName="Modal.Header";export{a as default,f as isHeaderElement};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsxs as X,jsx as T}from"react/jsx-runtime";import{useControllableState as w,useEffectCallback as x}from"@nild/hooks";import{isFunction as G,cnJoin as B}from"@nild/shared";import{useRef as s,useEffect as H,useMemo as K,cloneElement as L}from"react";import Q from"../_shared/utils/get-owner-document/index.js";import V from"../_shared/utils/register-slots/index.js";import W from"../transition/Transition.js";import{TransitionStatus as P}from"../transition/interfaces/index.js";import{resolvePlacement as Y}from"./_shared/index.js";import{ModalProvider as Z}from"./contexts/index.js";import{isPortalElement as j}from"./Portal.js";import z from"./style/index.js";import _,{isTriggerElement as D}from"./Trigger.js";const $=V({trigger:{isMatched:a=>D(a)},portal:{isMatched:a=>j(a)},firstBare:{isMatched:a=>!D(a)&&!j(a),strategy:"first"}}),U=a=>{const{children:q,variant:o="dialog",size:u="medium",open:A,defaultOpen:I=!1,disabled:i=!1,closeOnEscape:p=!0,closeOnOverlayClick:f=!0,trapFocus:d=!0,restoreFocus:b=!0,lockScroll:v=!0,"aria-label":y,"aria-labelledby":E,"aria-describedby":g,onOpen:O,onClose:C}=a,{slots:l}=$(q),[e,J]=w(A,I),n=s(e),M=s(null),h=s(null),N=s(null),k=s(e),c=Y(o,a.placement);n.current=e;const m=x(r=>{if(i)return;const S=n.current,t=G(r)?r(S):r;t!==S&&(n.current=t,J(t),t?O?.():C?.())}),F=x(()=>{m(!1)});H(()=>{if(e&&!k.current){const r=Q(M.current,h.current);N.current=r?.activeElement}k.current=e},[e]);const R=K(()=>({open:e,variant:o,placement:c,size:u,disabled:i,closeOnEscape:p,closeOnOverlayClick:f,trapFocus:d,restoreFocus:b,lockScroll:v,accessibility:{"aria-label":y,"aria-labelledby":E,"aria-describedby":g},refs:{trigger:M,surface:h,lastActiveEl:N},requestOpen:m,close:F}),[g,y,E,F,p,f,i,v,e,c,m,b,u,d,o]);return X(Z,{value:R,children:[l.trigger.el??(l.firstBare.el&&T(_,{children:l.firstBare.el})),l.portal.el&&T(W,{visible:e,children:r=>!e&&[P.UNMOUNTED,P.EXITED].includes(r)?null:L(l.portal.el,{...l.portal.el.props,overlayClassName:B(z.overlayMotion({status:r}),l.portal.el.props.overlayClassName),surfaceClassName:B(z.surfaceMotion({status:r,variant:o,placement:c}),l.portal.el.props.surfaceClassName)})})]})};U.displayName="Modal";export{U as default};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
import { PortalProps } from './interfaces';
|
|
3
|
+
export declare const isPortalElement: (child: unknown) => child is ReactElement<PortalProps>;
|
|
4
|
+
declare const Portal: import('react').ForwardRefExoticComponent<PortalProps & import('react').RefAttributes<HTMLDivElement>>;
|
|
5
|
+
export default Portal;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsxs as F,jsx as D}from"react/jsx-runtime";import{useEffectCallback as p,useIsomorphicLayoutEffect as J,useEventListener as I}from"@nild/hooks";import{cnMerge as y,mergeRefs as Q}from"@nild/shared";import{forwardRef as U,useRef as X,useEffect as z,isValidElement as Y}from"react";import{createPortal as Z}from"react-dom";import _ from"../_shared/utils/get-owner-document/index.js";import $ from"../_shared/utils/lock-document-scroll/index.js";import ee from"../_shared/utils/register-slots/index.js";import{getFocusableElements as te,focusWithin as v,restoreFocusTo as re}from"./_shared/index.js";import{isBodyElement as ae}from"./Body.js";import se,{isCloseElement as oe}from"./Close.js";import{useModalContext as le}from"./contexts/index.js";import{isFooterElement as ne}from"./Footer.js";import{isHeaderElement as ie}from"./Header.js";import{useModalStack as ce}from"./hooks/useModalStack.js";import E from"./style/index.js";const fe=a=>Y(a)&&a.type===b,ue=ee({header:{isMatched:a=>ie(a)},body:{isMatched:a=>ae(a)},footer:{isMatched:a=>ne(a)},close:{isMatched:a=>oe(a)}}),b=U(({className:a,style:K,children:O,container:h,overlayless:g=!1,overlayClassName:w,surfaceClassName:L,onTransitionEnd:P,...R},S)=>{const{open:l,variant:j,placement:k,size:A,closeOnEscape:B,closeOnOverlayClick:H,trapFocus:M,lockScroll:x,restoreFocus:C,accessibility:u,refs:s,close:T}=le(),N=X(l),t=_(h,s.surface.current,s.trigger.current),n=h??t?.body??null,{zIndex:V,topmost:i}=ce(t,!!n);N.current=l;const W=p(()=>{g||!l||!H||!i||T()}),q=p(e=>{const r=s.surface.current;if(!r||!l||!i)return;if(e.key==="Escape"&&B){e.preventDefault(),T();return}if(e.key!=="Tab"||!M)return;const o=te(r),f=t?.activeElement;if(o.length===0){e.preventDefault(),r.focus();return}if(!f||!r.contains(f)){e.preventDefault(),v(r,e.shiftKey);return}const m=o[0],d=o.at(-1);e.shiftKey&&f===m?(e.preventDefault(),d?.focus()):!e.shiftKey&&f===d&&(e.preventDefault(),m?.focus())}),G=p(e=>{const r=s.surface.current,o=e.target;!r||!M||!l||!i||!o||r.contains(o)||v(r)});if(z(()=>{if(!(!n||!x||!t))return $(t)},[x,t,n]),z(()=>()=>{!C||N.current||re(s.lastActiveEl.current,s.trigger.current)},[s.lastActiveEl,s.trigger,C]),J(()=>{if(!l)return;const e=setTimeout(()=>{const r=s.surface.current;if(!r||!i)return;const o=t?.activeElement;(!o||!r.contains(o))&&v(r)},0);return()=>{clearTimeout(e)}},[l,t,s.surface,i]),I(t,"keydown",q),I(t,"focusin",G),!n)return null;const{slots:c}=ue(O);return Z(F("div",{className:y(E.portal({placement:k}),a),style:{zIndex:V,...K},...R,children:[!g&&D("div",{className:y(E.overlay(),w),onClick:W}),F("div",{ref:Q(s.surface,S),className:y(E.surface({variant:j,placement:k,size:A}),L),"aria-describedby":u["aria-describedby"],"aria-label":u["aria-label"],"aria-labelledby":u["aria-labelledby"],"aria-modal":"true",role:"dialog",tabIndex:-1,onTransitionEnd:P,children:[c.header.el,c.body.el,c.footer.el,c.close.el??D(se,{})]})]}),n)});b.displayName="Modal.Portal";export{b as default,fe as isPortalElement};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useEffectCallback as m}from"@nild/hooks";import{mergeRefs as f}from"@nild/shared";import{isValidElement as s,Children as n,cloneElement as p}from"react";import g from"../_shared/utils/merge-props/index.js";import{useModalContext as c}from"./contexts/index.js";import d from"./style/index.js";const u=e=>s(e)&&e.type===o,o=({children:e})=>{const{refs:t,requestOpen:a}=c(),r=n.toArray(e).find(l=>s(l)),i=m(()=>{a(!0)});return r?p(r,g(r.props,{className:d.trigger(),onClick:i,ref:f(t.trigger,r.props.ref)})):null};o.displayName="Modal.Trigger";export{o as default,u as isTriggerElement};
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ModalPlacement, ModalVariant } from '../interfaces';
|
|
2
|
+
export declare const resolvePlacement: (variant: ModalVariant, placement?: ModalPlacement) => ModalPlacement;
|
|
3
|
+
export declare const getFocusableElements: (container: HTMLElement) => HTMLElement[];
|
|
4
|
+
export declare const focusWithin: (container: HTMLElement, fromEnd?: boolean) => HTMLElement;
|
|
5
|
+
export declare const restoreFocusTo: (target?: HTMLElement | null, fallback?: HTMLElement | null) => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const a=(t,e)=>t==="drawer"?e&&e!=="center"?e:"right":"center",o=["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(","),d=t=>{const e=window.getComputedStyle(t);return e.display!=="none"&&e.visibility!=="hidden"&&!t.hidden},r=t=>Array.from(t.querySelectorAll(o)).filter(e=>!e.hasAttribute("disabled")&&e.getAttribute("aria-hidden")!=="true"&&e.tabIndex>=0&&d(e)),l=(t,e=!1)=>{const n=r(t).at(e?-1:0)??t;return n.focus(),n},s=(t,e)=>{var n;const i=t!=null&&t.isConnected?t:e!=null&&e.isConnected?e:null;(n=i?.focus)==null||n.call(i)};export{l as focusWithin,r as getFocusableElements,a as resolvePlacement,s as restoreFocusTo};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const EMPTY_MODAL_STACK: readonly symbol[];
|
|
2
|
+
export interface ModalStackStore {
|
|
3
|
+
getSnapshot: () => readonly symbol[];
|
|
4
|
+
mount: (token: symbol) => VoidFunction;
|
|
5
|
+
subscribe: (listener: VoidFunction) => VoidFunction;
|
|
6
|
+
}
|
|
7
|
+
export declare const getModalStackStore: (ownerDocument: Document) => ModalStackStore;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import c,{GlobalStateKey as i}from"../../_shared/utils/get-global-state/index.js";import"@nild/shared";import"react";const a=[],l=()=>{const t=[],o=new Set;let s=a;const n=()=>{s=[...t],o.forEach(e=>{e()})};return{getSnapshot:()=>s,mount:e=>(t.includes(e)||(t.push(e),n()),()=>{const r=t.indexOf(e);r!==-1&&(t.splice(r,1),n())}),subscribe:e=>(o.add(e),()=>{o.delete(e)})}},p=t=>{const o=c(i.Modal,()=>new WeakMap),s=o.get(t);if(s)return s;const n=l();return o.set(t,n),n};export{a as EMPTY_MODAL_STACK,p as getModalStackStore};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Dispatch, RefObject, SetStateAction } from 'react';
|
|
2
|
+
import { ModalAccessibility, ModalPlacement, ModalSize, ModalVariant } from '../interfaces';
|
|
3
|
+
export interface ModalContextValue {
|
|
4
|
+
open: boolean;
|
|
5
|
+
variant: ModalVariant;
|
|
6
|
+
placement: ModalPlacement;
|
|
7
|
+
size: ModalSize;
|
|
8
|
+
disabled: boolean;
|
|
9
|
+
closeOnEscape: boolean;
|
|
10
|
+
closeOnOverlayClick: boolean;
|
|
11
|
+
trapFocus: boolean;
|
|
12
|
+
restoreFocus: boolean;
|
|
13
|
+
lockScroll: boolean;
|
|
14
|
+
accessibility: ModalAccessibility;
|
|
15
|
+
refs: {
|
|
16
|
+
trigger: RefObject<Element>;
|
|
17
|
+
surface: RefObject<HTMLDivElement>;
|
|
18
|
+
lastActiveEl: RefObject<HTMLElement | null>;
|
|
19
|
+
};
|
|
20
|
+
requestOpen: Dispatch<SetStateAction<boolean>>;
|
|
21
|
+
close: () => void;
|
|
22
|
+
}
|
|
23
|
+
declare const ModalProvider: import('react').Provider<ModalContextValue>, useModalContext: () => ModalContextValue;
|
|
24
|
+
export { ModalProvider, useModalContext };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createContextSuite as e}from"@nild/shared";const[l,r]=e({defaultValue:{open:!1,variant:"dialog",placement:"center",size:"medium",disabled:!1,closeOnEscape:!0,closeOnOverlayClick:!0,trapFocus:!0,restoreFocus:!0,lockScroll:!0,accessibility:{"aria-label":void 0,"aria-labelledby":void 0,"aria-describedby":void 0},refs:{trigger:{current:null},surface:{current:null},lastActiveEl:{current:null}},requestOpen:()=>{},close:()=>{}}});export{l as ModalProvider,r as useModalContext};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useModalStack } from './useModalStack';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useRef as l,useEffect as m,useSyncExternalStore as S}from"react";import{getModalStackStore as d,EMPTY_MODAL_STACK as u}from"../_shared/stack.js";const f=40,i=(e,o)=>{const r=l(Symbol("modal")),t=e?d(e):null;m(()=>{if(!(!o||!t))return t.mount(r.current)},[o,t]);const n=S(c=>t?.subscribe(c)??(()=>{}),()=>t?.getSnapshot()??u,()=>u),s=n.indexOf(r.current),a=n.at(-1)===r.current;return{zIndex:f+(s===-1?0:s),topmost:a}};export{i as useModalStack};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @category Components
|
|
3
|
+
*/
|
|
4
|
+
declare const Modal: import('react').FC<import('./interfaces').ModalProps> & {
|
|
5
|
+
Trigger: import('react').FC<import('./interfaces').TriggerProps>;
|
|
6
|
+
Portal: import('react').ForwardRefExoticComponent<import('./interfaces').PortalProps & import('react').RefAttributes<HTMLDivElement>>;
|
|
7
|
+
Header: import('react').ForwardRefExoticComponent<import('./interfaces').HeaderProps & import('react').RefAttributes<HTMLDivElement>>;
|
|
8
|
+
Body: import('react').ForwardRefExoticComponent<import('./interfaces').BodyProps & import('react').RefAttributes<HTMLDivElement>>;
|
|
9
|
+
Footer: import('react').ForwardRefExoticComponent<import('./interfaces').FooterProps & import('react').RefAttributes<HTMLDivElement>>;
|
|
10
|
+
Close: import('react').ForwardRefExoticComponent<import('../button').ButtonProps & import('react').RefAttributes<HTMLButtonElement>>;
|
|
11
|
+
};
|
|
12
|
+
export type * from './interfaces';
|
|
13
|
+
export default Modal;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import o from"./Body.js";import r from"./Close.js";import m from"./Footer.js";import t from"./Header.js";import i from"./Modal.js";import e from"./Portal.js";import f from"./Trigger.js";const p=Object.assign(i,{Trigger:f,Portal:e,Header:t,Body:o,Footer:m,Close:r});export{p as default};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { TransitionStatus } from '../../transition/interfaces';
|
|
2
|
+
import { ModalPlacement, ModalSize, ModalVariant } from '../interfaces';
|
|
3
|
+
declare const _default: {
|
|
4
|
+
trigger: (props?: object | undefined) => string;
|
|
5
|
+
portal: (props?: {
|
|
6
|
+
placement: ModalPlacement;
|
|
7
|
+
} | undefined) => string;
|
|
8
|
+
overlay: (props?: object | undefined) => string;
|
|
9
|
+
overlayMotion: (props?: {
|
|
10
|
+
status: TransitionStatus;
|
|
11
|
+
} | undefined) => string;
|
|
12
|
+
surfaceMotion: (props?: {
|
|
13
|
+
status: TransitionStatus;
|
|
14
|
+
variant: ModalVariant;
|
|
15
|
+
placement: ModalPlacement;
|
|
16
|
+
} | undefined) => string;
|
|
17
|
+
header: (props?: object | undefined) => string;
|
|
18
|
+
body: (props?: object | undefined) => string;
|
|
19
|
+
footer: (props?: object | undefined) => string;
|
|
20
|
+
close: (props?: object | undefined) => string;
|
|
21
|
+
surface: (props?: {
|
|
22
|
+
variant: ModalVariant;
|
|
23
|
+
placement: ModalPlacement;
|
|
24
|
+
size: ModalSize;
|
|
25
|
+
} | undefined) => string;
|
|
26
|
+
};
|
|
27
|
+
export default _default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{cva as e}from"@nild/shared";import{TransitionStatus as a}from"../../transition/interfaces/index.js";const t=[a.UNMOUNTED,a.ENTERING,a.EXITING,a.EXITED],r=e(["nd-modal-trigger"]),s=e(["nd-modal-portal","fixed","inset-0","flex","pointer-events-auto"],{variants:{placement:{center:["items-center","justify-center","p-4"],left:["items-stretch","justify-start"],right:["items-stretch","justify-end"],top:["items-start","justify-center"],bottom:["items-end","justify-center"]}}}),l=e(["nd-modal-overlay","absolute","inset-0","transition-opacity","duration-[var(--default-transition-duration)]","ease-out","bg-[color-mix(in_oklch,var(--background-color-page-inverse)_18%,transparent)]"]),n=e([],{variants:{status:{[a.UNMOUNTED]:"",[a.ENTERING]:"",[a.ENTERED]:"",[a.EXITING]:"",[a.EXITED]:""}},compoundVariants:[{status:t,className:"opacity-0"},{status:a.ENTERED,className:"opacity-100"}]}),o=e(["nd-modal-header","shrink-0","px-6","pt-6","pb-4","pr-16","text-lg","font-semibold"]),i=e(["nd-modal-body","min-h-0","flex-auto","overflow-auto","px-6","pb-6"]),m=e(["nd-modal-footer","shrink-0","flex","justify-end","gap-3","border-t","border-subtle","px-6","py-4"]),c=e(["nd-modal-close","absolute","top-4","right-6","z-1"]),d=e(["nd-modal-surface","relative","pointer-events-auto","flex","min-h-0","flex-col","overflow-hidden","bg-panel","text-main","shadow-2xl","outline-none","transition-[opacity,translate,scale]","duration-[var(--default-transition-duration)]","ease-out"],{variants:{variant:{dialog:"",drawer:""},placement:{center:["w-full","max-h-[calc(100vh-2rem)]"],left:["h-full","max-h-screen"],right:["h-full","max-h-screen"],top:["w-full","max-w-screen"],bottom:["w-full","max-w-screen"]},size:{small:"",medium:"",large:"",full:""}},compoundVariants:[{variant:"dialog",placement:"center",size:"small",className:["max-w-96","rounded-xl"]},{variant:"dialog",placement:"center",size:"medium",className:["max-w-[36rem]","rounded-xl"]},{variant:"dialog",placement:"center",size:"large",className:["max-w-[48rem]","rounded-xl"]},{variant:"dialog",placement:"center",size:"full",className:["h-[calc(100vh-2rem)]","w-[calc(100vw-2rem)]","max-w-none","rounded-xl"]},{variant:"drawer",placement:["left","right"],size:"small",className:"w-80"},{variant:"drawer",placement:["left","right"],size:"medium",className:"w-[28rem]"},{variant:"drawer",placement:["left","right"],size:"large",className:"w-[36rem]"},{variant:"drawer",placement:["left","right"],size:"full",className:"w-screen"},{variant:"drawer",placement:["top","bottom"],size:"small",className:"h-64"},{variant:"drawer",placement:["top","bottom"],size:"medium",className:"h-96"},{variant:"drawer",placement:["top","bottom"],size:"large",className:"h-[32rem]"},{variant:"drawer",placement:["top","bottom"],size:"full",className:"h-screen"}]}),u=e([],{variants:{status:{[a.UNMOUNTED]:"",[a.ENTERING]:"",[a.ENTERED]:"",[a.EXITING]:"",[a.EXITED]:""},variant:{dialog:"",drawer:""},placement:{center:"",left:"",right:"",top:"",bottom:""}},compoundVariants:[{status:t,variant:"dialog",className:["opacity-0","scale-95"]},{status:a.ENTERED,variant:"dialog",className:["opacity-100","scale-100"]},{status:t,variant:"drawer",placement:"left",className:"-translate-x-full"},{status:a.ENTERED,variant:"drawer",placement:"left",className:"translate-x-0"},{status:t,variant:"drawer",placement:"right",className:"translate-x-full"},{status:a.ENTERED,variant:"drawer",placement:"right",className:"translate-x-0"},{status:t,variant:"drawer",placement:"top",className:"-translate-y-full"},{status:a.ENTERED,variant:"drawer",placement:"top",className:"translate-y-0"},{status:t,variant:"drawer",placement:"bottom",className:"translate-y-full"},{status:a.ENTERED,variant:"drawer",placement:"bottom",className:"translate-y-0"}]}),p={trigger:r,portal:s,overlay:l,overlayMotion:n,surfaceMotion:u,header:o,body:i,footer:m,close:c,surface:d};export{p as default};
|
package/dist/popup/Popup.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as
|
|
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};
|
|
File without changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{cva as r}from"@nild/shared";const e=r(["nd-popup-trigger"]),a=r(["nd-popup-portal",["absolute","top-0","left-0"]]),t=r(["rounded-md","shadow-lg"],{variants:{size:{small:["px-2","py-1"],medium:["px-4","py-3"],large:["px-6","py-5"]},inverse:{true:["bg-page-inverse","text-main-inverse"],false:["bg-panel","text-main"]}}}),o=r(["nd-popup-arrow","absolute"],{variants:{size:{small:["w-1.5","h-1.5"],medium:["w-3","h-3"],large:["w-4.5","h-4.5"]},arrowed:{true:"",false:["opacity-0","invisible"]},inverse:{true:["bg-page-inverse"],false:["bg-panel"]},orientation:{up:["transform-[translateY(-50%)_rotate(45deg)]","rounded-tl-sm"],down:["transform-[translateY(50%)_rotate(45deg)]","rounded-br-sm"],left:["transform-[translateX(-50%)_rotate(45deg)]","rounded-bl-sm"],right:["transform-[translateX(50%)_rotate(45deg)]","rounded-tr-sm"]}},compoundVariants:[{orientation:"up",className:["shadow-[-1px_-1px_0_0_var(--border-color-
|
|
1
|
+
import{cva as r}from"@nild/shared";const e=r(["nd-popup-trigger"]),a=r(["nd-popup-portal",["absolute","top-0","left-0"]]),t=r(["rounded-md","shadow-lg"],{variants:{size:{small:["px-2","py-1"],medium:["px-4","py-3"],large:["px-6","py-5"]},inverse:{true:["bg-page-inverse","text-main-inverse"],false:["bg-panel","text-main"]}}}),o=r(["nd-popup-arrow","absolute"],{variants:{size:{small:["w-1.5","h-1.5"],medium:["w-3","h-3"],large:["w-4.5","h-4.5"]},arrowed:{true:"",false:["opacity-0","invisible"]},inverse:{true:["bg-page-inverse"],false:["bg-panel"]},orientation:{up:["transform-[translateY(-50%)_rotate(45deg)]","rounded-tl-sm"],down:["transform-[translateY(50%)_rotate(45deg)]","rounded-br-sm"],left:["transform-[translateX(-50%)_rotate(45deg)]","rounded-bl-sm"],right:["transform-[translateX(50%)_rotate(45deg)]","rounded-tr-sm"]}},compoundVariants:[{orientation:"up",className:["shadow-[-1px_-1px_0_0_var(--border-color-muted)]"]},{orientation:"down",className:["shadow-[1px_1px_0_0_var(--border-color-muted)]"]},{orientation:"left",className:["shadow-[-1px_1px_0_0_var(--border-color-muted)]"]},{orientation:"right",className:["shadow-[1px_-1px_0_0_var(--border-color-muted)]"]}]}),s={trigger:e,portal:a,portalContent:t,arrow:o};export{s as default};
|
package/dist/radio/Indicator.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as
|
|
1
|
+
import{jsxs as t,jsx as a}from"react/jsx-runtime";import{cnMerge as d}from"@nild/shared";import{forwardRef as x}from"react";import{useRadioContext as g}from"./contexts/index.js";import e from"./style/index.js";const o=x(({className:n,children:c,...l},m)=>{const{variant:r,size:f,checked:i,disabled:p,setChecked:u}=g(),h=!c,v=c??(s=>t("svg",{viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:e.defaultIndicatorSvg(),children:[a("circle",{cx:"10",cy:"10",className:d(e.defaultIndicatorOuterCircle({variant:r,checked:s}))}),a("circle",{cx:"10",cy:"10",className:e.defaultIndicatorInnerCircle({variant:r,checked:s})})]}));return t("div",{...l,className:d(e.indicator({size:f,default:h}),n),ref:m,children:[v(!!i),a("input",{type:"radio",className:e.indicatorInput(),checked:i,disabled:p,onChange:u})]})});o.displayName="Radio.Indicator";export{o as default};
|
package/dist/radio/Radio.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as t,jsxs as j}from"react/jsx-runtime";import{useControllableState as w,useEffectCallback as E}from"@nild/hooks";import{cnMerge as G}from"@nild/shared";import{forwardRef as P}from"react";import S from"../_shared/utils/register-slots/index.js";import{useGroupContext as V,RadioProvider as A}from"./contexts/index.js";import p from"./Indicator.js";import h from"./Label.js";import F from"./style/index.js";const I=S({indicator:{isMatched:a=>a.type===p},label:{isMatched:a=>a.type===h}}),v=P((a,b)=>{var d;const e=V(),{className:C,children:k,variant:x=e?.variant??"solid",size:n=e?.size??"medium",disabled:i=e?.disabled??!1,checked:z,defaultChecked:q,value:c,onChange:m,...y}=a,{slots:l,plainChildren:o}=I(k),[M,N]=w(e?e.value===c:z,q??!1),R=E(()=>{i||N(s=>s||(e?e.setValue(c):m?.(!s),!s))}),u=l.indicator.el??t(p,{}),r=l.label.el??(o.length>0?t(h,{children:o[0].content}):null),g=l.label.el?l.label.seq:((d=o[0])==null?void 0:d.seq)??-1,f=!!l.indicator.el&&!!r&&g<l.indicator.seq;return t(A,{value:{variant:x,size:n,checked:M,disabled:i,setChecked:R},children:j("label",{...y,className:G(F.radio({size:n,disabled:i}),C),ref:b,children:[f?r:u,f?u:r]})})});v.displayName="Radio";export{v as default};
|
|
File without changes
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { RadioProps, GroupProps } from '../interfaces';
|
|
2
|
-
declare const RadioProvider: import('react').Provider<Pick<RadioProps, "variant" | "size" | "checked"> & {
|
|
2
|
+
declare const RadioProvider: import('react').Provider<Pick<RadioProps, "variant" | "size" | "disabled" | "checked"> & {
|
|
3
3
|
setChecked?: () => void;
|
|
4
|
-
}>, useRadioContext: () => Pick<RadioProps, "variant" | "size" | "checked"> & {
|
|
4
|
+
}>, useRadioContext: () => Pick<RadioProps, "variant" | "size" | "disabled" | "checked"> & {
|
|
5
5
|
setChecked?: () => void;
|
|
6
6
|
};
|
|
7
7
|
declare const GroupProvider: import('react').Provider<(Pick<GroupProps<unknown>, "variant" | "size" | "disabled"> & {
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { RadioProps, GroupProps } from '../interfaces';
|
|
2
2
|
declare const _default: {
|
|
3
3
|
radio: (props?: Pick<RadioProps, "size" | "disabled"> | undefined) => string;
|
|
4
|
-
indicator: (props?: Pick<RadioProps, "size">
|
|
4
|
+
indicator: (props?: (Pick<RadioProps, "size"> & {
|
|
5
|
+
default?: boolean;
|
|
6
|
+
}) | undefined) => string;
|
|
5
7
|
indicatorInput: (props?: object | undefined) => string;
|
|
8
|
+
defaultIndicatorSvg: (props?: object | undefined) => string;
|
|
6
9
|
defaultIndicatorOuterCircle: (props?: Pick<RadioProps, "variant" | "checked"> | undefined) => string;
|
|
7
10
|
defaultIndicatorInnerCircle: (props?: Pick<RadioProps, "variant" | "checked"> | undefined) => string;
|
|
8
11
|
label: (props?: Pick<RadioProps, "size"> | undefined) => string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{cva as e}from"@nild/shared";import{DISABLED_CLS as a}from"../../_shared/style/index.js";const r=e(["nd-radio","group",["flex","items-center"],"cursor-pointer",a],{variants:{size:{small:"gap-1.5",medium:"gap-2",large:"gap-2.5"},disabled:{true:"disabled",false:""}}}),t=e(["relative",["flex","items-center","justify-center"]],{variants:{size:{small:"size-3.5 text-sm",medium:"size-4 text-md",large:"size-4.5 text-lg"}}}),
|
|
1
|
+
import{cva as e}from"@nild/shared";import{DISABLED_CLS as a}from"../../_shared/style/index.js";const r=e(["nd-radio","group",["flex","items-center"],"cursor-pointer",a],{variants:{size:{small:"gap-1.5",medium:"gap-2",large:"gap-2.5"},disabled:{true:"disabled",false:""}}}),t=e(["nd-radio-indicator","relative",["flex","items-center","justify-center"]],{variants:{size:{small:"size-3.5 text-sm",medium:"size-4 text-md",large:"size-4.5 text-lg"},default:{true:["rounded-full","transition-[box-shadow]","group-enabled:focus-visible-within:ring-focused"],false:""}}}),i=e([["absolute","inset-0","opacity-0"],["group-enabled:cursor-pointer","group-disabled:cursor-not-allowed"]]),l=e(["size-full"]),o=e(["stroke-1","r-9","transition-[stroke,fill]","group-enabled:group-hover:stroke-brand-hover"],{compoundVariants:[{checked:!0,variant:"solid",className:["fill-brand stroke-brand","group-enabled:group-hover:fill-brand-hover"]},{checked:!0,variant:"outlined",className:["fill-transparent stroke-brand"]},{checked:!1,className:["fill-transparent stroke-main"]}]}),n=e(["transition-[fill]"],{variants:{variant:{solid:"r-4.5",outlined:"r-5.5"}},compoundVariants:[{checked:!0,variant:"solid",className:["fill-brand-contrast"]},{checked:!0,variant:"outlined",className:["fill-brand","group-enabled:group-hover:fill-brand-hover"]},{checked:!1,className:["fill-transparent"]}]}),s=e(["text-sm"],{variants:{size:{small:"text-sm",medium:"text-md",large:"text-lg"}}}),d=e(["nd-radio-group",["flex","gap-x-4","gap-y-2"]],{variants:{direction:{horizontal:"flex-row flex-wrap",vertical:"flex-col"}}}),c={radio:r,indicator:t,indicatorInput:i,defaultIndicatorSvg:l,defaultIndicatorOuterCircle:o,defaultIndicatorInnerCircle:n,label:s,group:d};export{c as default};
|
package/dist/switch/Switch.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as c,jsxs as x}from"react/jsx-runtime";import{useControllableState as C}from"@nild/hooks";import{cnMerge as N}from"@nild/shared";import{forwardRef as S}from"react";import j from"../_shared/utils/register-slots/index.js";import{SwitchProvider as z}from"./contexts/index.js";import P from"./style/index.js";import h from"./Thumb.js";import a from"./Track.js";const R=j({checkedTrack:{isMatched:e=>e.type===a&&e.props.type==="checked"},uncheckedTrack:{isMatched:e=>e.type===a&&e.props.type==="unchecked"},thumb:{isMatched:e=>e.type===h}}),p=S(({className:e,children:m,variant:s="solid",size:i="medium",shape:o="round",checked:n,defaultChecked:u,value:k,defaultValue:f,disabled:y,onChange:d,style:v,...g},b)=>{const{slots:t}=R(m),w={"--nd-switch-height":{small:"calc(var(--spacing) * 4)",medium:"calc(var(--spacing) * 6)",large:"calc(var(--spacing) * 8)"}[i]},[r,M]=C(n??k,u??f??!1),T=()=>{M(l=>(d?.(!l),!l))};return c(z,{value:{variant:s,shape:o,checked:r},children:x("button",{...g,type:"button",role:"switch","aria-checked":r,disabled:y,className:N(P.switch({variant:s,size:i,shape:o,checked:r}),e),style:{...w,...v},ref:b,onClick:T,children:[t.checkedTrack.el??c(a,{type:"checked"}),t.uncheckedTrack.el??c(a,{type:"unchecked"}),t.thumb.el??c(h,{})]})})});p.displayName="Switch";export{p as default};
|
|
File without changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{cva as e}from"@nild/shared";import{DISABLED_CLS as
|
|
1
|
+
import{cva as e}from"@nild/shared";import{DISABLED_CLS as a}from"../../_shared/style/index.js";const t=e(["nd-switch","group","h-[var(--nd-switch-height)]",["relative","inline-block","font-nd","overflow-hidden","cursor-pointer"],"transition-[outline-color,box-shadow]",a],{variants:{variant:{solid:"focus-visible:ring-focused",outlined:["outline","focus-visible:ring-focused-with-outline"]},size:{small:["min-w-8","text-sm"],medium:["min-w-10","text-md"],large:["min-w-12","text-lg"]},shape:{round:"rounded-full",square:"rounded-md"}},compoundVariants:[{checked:!0,variant:"outlined",className:["outline-brand"]},{checked:!1,variant:"outlined",className:["outline-main","enabled:hover:outline-brand-hover"]}]}),n=e(["h-[var(--nd-switch-height)]","transition-[margin-inline,background-color]",["flex","justify-center","items-center"],["text-center","text-brand-contrast"]],{variants:{type:{checked:["ps-[calc(var(--nd-switch-height)/3)]","pe-[calc(var(--nd-switch-height)*1.1)]"],unchecked:["ps-[calc(var(--nd-switch-height)*1.1)]","pe-[calc(var(--nd-switch-height)/3)]","-mt-[var(--nd-switch-height)]"]}},compoundVariants:[{type:"checked",checked:!0,className:["ms-0","me-0"]},{type:"checked",checked:!1,className:["-ms-[100%]","me-[100%]"]},{type:"unchecked",checked:!0,className:["ms-[100%]","-me-[100%]"]},{type:"unchecked",checked:!1,className:["ms-0","me-0"]},{variant:"solid",checked:!0,className:["bg-brand","group-enabled:group-hover:bg-brand-hover"]},{variant:"solid",checked:!1,className:["bg-emphasized","group-enabled:group-hover:bg-emphasized-hover"]},{variant:"outlined",className:["bg-transparent"]}]}),r=e(["h-[var(--nd-switch-height)]",["flex","justify-center","items-center"],["absolute","top-0","aspect-square","scale-80"],["text-brand-contrast","transition-[left,background-color]"]],{variants:{variant:{solid:["bg-brand-contrast"],outlined:["bg-emphasized","group-enabled:group-hover:bg-brand-hover"]},shape:{round:"rounded-full",square:"rounded-md"},checked:{true:"left-[calc(100%-var(--nd-switch-height))]",false:"left-0"}},compoundVariants:[{variant:"outlined",checked:!0,className:["bg-brand"]}]}),c={switch:t,track:n,thumb:r};export{c as default};
|
package/dist/tailwind.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
@theme static{ --nd-brand-h: 158; --nd-brand-c: .14; --nd-neutral-c: .001; --nd-shadow-l: 15%; --nd-shadow-c: .008; --nd-color-brand-0: light-dark( oklch(99% var(--nd-brand-c) var(--nd-brand-h)), oklch(14% var(--nd-brand-c) var(--nd-brand-h)) ); --nd-color-brand-5: light-dark( oklch(97% var(--nd-brand-c) var(--nd-brand-h)), oklch(17% var(--nd-brand-c) var(--nd-brand-h)) ); --nd-color-brand-10: light-dark( oklch(
|
|
1
|
+
@theme static{ --nd-brand-h: 158; --nd-brand-c: .14; --nd-neutral-c: .001; --nd-shadow-l: 15%; --nd-shadow-c: .008; --nd-color-brand-0: light-dark( oklch(99% var(--nd-brand-c) var(--nd-brand-h)), oklch(14% var(--nd-brand-c) var(--nd-brand-h)) ); --nd-color-brand-5: light-dark( oklch(97% var(--nd-brand-c) var(--nd-brand-h)), oklch(17% var(--nd-brand-c) var(--nd-brand-h)) ); --nd-color-brand-10: light-dark( oklch(95% var(--nd-brand-c) var(--nd-brand-h)), oklch(20% var(--nd-brand-c) var(--nd-brand-h)) ); --nd-color-brand-15: light-dark( oklch(92% var(--nd-brand-c) var(--nd-brand-h)), oklch(25% var(--nd-brand-c) var(--nd-brand-h)) ); --nd-color-brand-20: light-dark( oklch(88% var(--nd-brand-c) var(--nd-brand-h)), oklch(30% var(--nd-brand-c) var(--nd-brand-h)) ); --nd-color-brand-30: light-dark( oklch(80% var(--nd-brand-c) var(--nd-brand-h)), oklch(38% var(--nd-brand-c) var(--nd-brand-h)) ); --nd-color-brand-40: light-dark( oklch(72% var(--nd-brand-c) var(--nd-brand-h)), oklch(46% var(--nd-brand-c) var(--nd-brand-h)) ); --nd-color-brand-50: light-dark( oklch(64% var(--nd-brand-c) var(--nd-brand-h)), oklch(52% var(--nd-brand-c) var(--nd-brand-h)) ); --nd-color-brand-60: oklch(58% var(--nd-brand-c) var(--nd-brand-h)); --nd-color-brand-70: light-dark( oklch(50% var(--nd-brand-c) var(--nd-brand-h)), oklch(66% var(--nd-brand-c) var(--nd-brand-h)) ); --nd-color-brand-80: light-dark( oklch(40% var(--nd-brand-c) var(--nd-brand-h)), oklch(76% var(--nd-brand-c) var(--nd-brand-h)) ); --nd-color-brand-90: light-dark( oklch(30% var(--nd-brand-c) var(--nd-brand-h)), oklch(88% var(--nd-brand-c) var(--nd-brand-h)) ); --nd-color-brand-100: light-dark( oklch(20% var(--nd-brand-c) var(--nd-brand-h)), oklch(96% var(--nd-brand-c) var(--nd-brand-h)) ); --nd-color-neutral-0: light-dark( oklch(99% var(--nd-neutral-c) var(--nd-brand-h)), oklch(14% var(--nd-neutral-c) var(--nd-brand-h)) ); --nd-color-neutral-5: light-dark( oklch(97.5% var(--nd-neutral-c) var(--nd-brand-h)), oklch(17% var(--nd-neutral-c) var(--nd-brand-h)) ); --nd-color-neutral-10: light-dark( oklch(95.5% var(--nd-neutral-c) var(--nd-brand-h)), oklch(21% var(--nd-neutral-c) var(--nd-brand-h)) ); --nd-color-neutral-15: light-dark( oklch(92.5% var(--nd-neutral-c) var(--nd-brand-h)), oklch(26% var(--nd-neutral-c) var(--nd-brand-h)) ); --nd-color-neutral-20: light-dark( oklch(89% var(--nd-neutral-c) var(--nd-brand-h)), oklch(32% var(--nd-neutral-c) var(--nd-brand-h)) ); --nd-color-neutral-30: light-dark( oklch(81% var(--nd-neutral-c) var(--nd-brand-h)), oklch(42% var(--nd-neutral-c) var(--nd-brand-h)) ); --nd-color-neutral-40: light-dark( oklch(72% var(--nd-neutral-c) var(--nd-brand-h)), oklch(50% var(--nd-neutral-c) var(--nd-brand-h)) ); --nd-color-neutral-50: light-dark( oklch(60% var(--nd-neutral-c) var(--nd-brand-h)), oklch(58% var(--nd-neutral-c) var(--nd-brand-h)) ); --nd-color-neutral-60: light-dark( oklch(50% var(--nd-neutral-c) var(--nd-brand-h)), oklch(67% var(--nd-neutral-c) var(--nd-brand-h)) ); --nd-color-neutral-70: light-dark( oklch(40% var(--nd-neutral-c) var(--nd-brand-h)), oklch(76% var(--nd-neutral-c) var(--nd-brand-h)) ); --nd-color-neutral-80: light-dark( oklch(32% var(--nd-neutral-c) var(--nd-brand-h)), oklch(85% var(--nd-neutral-c) var(--nd-brand-h)) ); --nd-color-neutral-90: light-dark( oklch(22% var(--nd-neutral-c) var(--nd-brand-h)), oklch(93% var(--nd-neutral-c) var(--nd-brand-h)) ); --nd-color-neutral-100: light-dark( oklch(15% var(--nd-neutral-c) var(--nd-brand-h)), oklch(98% var(--nd-neutral-c) var(--nd-brand-h)) ); --nd-color-shadow-key: light-dark( oklch(var(--nd-shadow-l) var(--nd-shadow-c) var(--nd-brand-h) / 16%), oklch(0% 0 0deg / 65%) ); --nd-color-shadow-ambient: light-dark( oklch(var(--nd-shadow-l) var(--nd-shadow-c) var(--nd-brand-h) / 4%), oklch(0% 0 0deg / 30%) ); --nd-font-family: -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"; }@theme{ --color-brand: var(--nd-color-brand-60); --color-brand-hover: light-dark(var(--nd-color-brand-50), var(--nd-color-brand-70)); --color-brand-active: var(--nd-color-brand-60); --color-brand-subtle: var(--nd-color-brand-15); --color-brand-subtle-hover: var(--nd-color-brand-20); --color-brand-subtle-active: var(--nd-color-brand-30); --color-brand-contrast: light-dark(var(--nd-color-neutral-0), var(--nd-color-neutral-100)); --color-brand-ring: light-dark( color-mix(in oklch, var(--nd-color-brand-60) 28%, transparent), color-mix(in oklch, var(--nd-color-brand-60) 36%, transparent) ); --border-color-main: var(--nd-color-neutral-20); --border-color-muted: var(--nd-color-neutral-15); --border-color-subtle: var(--nd-color-neutral-10); --outline-color-main: var(--border-color-main); --outline-color-muted: var(--border-color-muted); --outline-color-subtle: var(--border-color-subtle); --background-color-page: var(--nd-color-neutral-0); --background-color-page-inverse: var(--nd-color-neutral-100); --background-color-subtle: var(--nd-color-neutral-5); --background-color-subtle-hover: var(--nd-color-neutral-10); --background-color-muted: var(--nd-color-neutral-10); --background-color-muted-hover: var(--nd-color-neutral-15); --background-color-muted-active: var(--nd-color-neutral-20); --background-color-emphasized: var(--nd-color-neutral-20); --background-color-emphasized-hover: var(--nd-color-neutral-30); --background-color-panel: light-dark( var(--background-color-page), var(--background-color-muted) ); --text-color-main: var(--nd-color-neutral-100); --text-color-main-inverse: var(--nd-color-neutral-0); --text-color-muted: var(--nd-color-neutral-70); --text-color-subtle: var(--nd-color-neutral-50); --text-sm: .75rem; --text-sm--line-height: 1.25rem; --text-md: .875rem; --text-md--line-height: 1.375rem; --text-lg: 1rem; --text-lg--line-height: 1.5rem; --text-xl: 1.125rem; --text-xl--line-height: 1.625rem; --text-2xl: 1.25rem; --text-2xl--line-height: 1.75rem; --text-3xl: 1.5rem; --text-3xl--line-height: 2rem; --text-4xl: 1.875rem; --text-4xl--line-height: 2.375rem; --text-5xl: 2.375rem; --text-5xl--line-height: 2.875rem; --text-6xl: 2.875rem; --text-6xl--line-height: 3.375rem; --radius-xs: .125rem; --radius-sm: .25rem; --radius-md: .375rem; --radius-lg: .5rem; --radius-xl: .75rem; --radius-2xl: 1rem; --radius-3xl: 1.5rem; --shadow-sm: 0 0 0 .8px var(--border-color-muted), 0 1px 2px 0 var(--nd-color-shadow-key); --shadow-md: 0 0 0 .8px var(--border-color-muted), 0 4px 6px -1px var(--nd-color-shadow-key), 0 2px 4px -2px var(--nd-color-shadow-ambient); --shadow-lg: 0 0 0 .8px var(--border-color-muted), 0 10px 15px -3px var(--nd-color-shadow-key), 0 4px 6px -4px var(--nd-color-shadow-ambient); --shadow-xl: 0 0 0 .8px var(--border-color-muted), 0 20px 25px -5px var(--nd-color-shadow-key), 0 8px 10px -6px var(--nd-color-shadow-ambient); --shadow-2xl: 0 0 0 .8px var(--border-color-muted), 0 25px 50px -12px var(--nd-color-shadow-key), 0 12px 24px -12px var(--nd-color-shadow-ambient); --font-nd: var(--nd-font-family); --default-transition-duration: .2s; }@utility stroke-main{stroke: var(--border-color-main);}@utility stroke-muted{stroke: var(--border-color-muted);}@utility stroke-subtle{stroke: var(--border-color-subtle);}@utility underline{text-decoration: underline; text-underline-offset: .125rem;}@utility ring-focused{outline: none; box-shadow: 0 0 0 .2rem var(--color-brand-ring),var(--tw-shadow, 0 0 #00000000);}@utility ring-focused-with-outline{box-shadow: 0 0 0 .2rem var(--color-brand-ring),var(--tw-shadow, 0 0 #00000000);}@utility r-*{r: --value(number);}@custom-variant focus-visible-within{&:has(:focus-visible) {@slot;}}@custom-variant disabled{&.disabled,&:disabled {@slot;}}@custom-variant enabled{&:not(.disabled,:disabled) {@slot;}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{cnMerge as M,isFunction as I}from"@nild/shared";import{useState as O,useRef as U,useEffect as f,cloneElement as G,Children as v,isValidElement as g}from"react";import h from"../_shared/utils/merge-handlers/index.js";import{TransitionStatus as r}from"./interfaces/index.js";import S from"./style/index.js";const d=(e,s)=>{const c=I(e)?e(s):e;return v.toArray(c).find(t=>g(t))},R=({className:e,children:s,visible:c=!0})=>{const[t,N]=O(()=>{const n=c?r.ENTERED:r.EXITED;return d(s,n)?n:r.UNMOUNTED}),i=d(s,t),T=i?c?r.ENTERED:r.EXITED:r.UNMOUNTED,E=U(),u=U(i);u.current=t===r.UNMOUNTED?i:i??u.current;const l=()=>{var n;(n=E.current)==null||n.cancel(),E.current=void 0},m=n=>{l();let o=!0;const p=()=>{o&&(o=!1,E.current=void 0,n())};p.cancel=()=>{o=!1},E.current=p},D=(n,o)=>{l(),N(n),m(()=>{m(()=>{N(o)}),E.current&&setTimeout(E.current,0)})},X=n=>{n&&n.target!==n.currentTarget||T===r.UNMOUNTED&&t===r.EXITED&&N(r.UNMOUNTED)};if(f(()=>{E.current&&(E.current(),E.current=void 0)},[t]),f(()=>{if(T===r.ENTERED){t===r.UNMOUNTED?N(r.EXITED):t!==r.ENTERING&&t!==r.ENTERED&&D(r.ENTERING,r.ENTERED);return}if(T===r.EXITED){(t===r.ENTERING||t===r.ENTERED)&&D(r.EXITING,r.EXITED);return}t!==r.EXITED&&t!==r.UNMOUNTED&&D(r.EXITING,r.EXITED)},[T,t]),!u.current)return null;const a=u.current;return G(a,{...a.props,className:I(s)?a.props.className:M(a.props.className,S.transition({status:t}),e),onTransitionEnd:h(a.props.onTransitionEnd,X)})};R.displayName="Transition";export{R as default};
|
|
File without changes
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
-
export declare enum
|
|
2
|
+
export declare enum TransitionStatus {
|
|
3
3
|
UNMOUNTED = "unmounted",
|
|
4
4
|
ENTERING = "entering",
|
|
5
5
|
ENTERED = "entered",
|
|
@@ -8,6 +8,6 @@ export declare enum Status {
|
|
|
8
8
|
}
|
|
9
9
|
export interface TransitionProps {
|
|
10
10
|
className?: string;
|
|
11
|
-
children?: ReactNode;
|
|
11
|
+
children?: ReactNode | ((status: TransitionStatus) => ReactNode);
|
|
12
12
|
visible?: boolean;
|
|
13
13
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var t=(E=>(E.UNMOUNTED="unmounted",E.ENTERING="entering",E.ENTERED="entered",E.EXITING="exiting",E.EXITED="exited",E))(t||{});export{t as
|
|
1
|
+
var t=(E=>(E.UNMOUNTED="unmounted",E.ENTERING="entering",E.ENTERED="entered",E.EXITING="exiting",E.EXITED="exited",E))(t||{});export{t as TransitionStatus};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{cva as
|
|
1
|
+
import{cva as t}from"@nild/shared";import{TransitionStatus as i}from"../interfaces/index.js";const a=t(["transition-[opacity,visibility]"],{compoundVariants:[{status:i.ENTERED,className:["opacity-100","visible"]},{status:[i.UNMOUNTED,i.ENTERING,i.EXITING,i.EXITED],className:["opacity-0","invisible"]}]}),s={transition:a};export{s as default};
|
package/package.json
CHANGED
|
File without changes
|