@nild/components 0.0.16 → 0.0.18
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/divider/Divider.d.ts +1 -7
- package/dist/divider/Divider.js +1 -1
- package/dist/divider/index.d.ts +2 -3
- package/dist/divider/style/index.d.ts +4 -6
- package/dist/divider/style/index.js +1 -1
- package/dist/switch/Switch.d.ts +18 -16
- package/dist/switch/Switch.js +1 -1
- package/dist/switch/index.d.ts +2 -3
- package/dist/switch/style/index.d.ts +5 -9
- package/dist/switch/style/index.js +1 -1
- package/package.json +1 -1
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { DividerVariant, DividerDirection, DividerAlign } from './style';
|
|
3
|
-
export interface DividerProps extends HTMLAttributes<HTMLDivElement> {
|
|
4
|
-
variant?: DividerVariant;
|
|
5
|
-
direction?: DividerDirection;
|
|
6
|
-
align?: DividerAlign;
|
|
7
|
-
}
|
|
1
|
+
import { DividerProps } from './interfaces';
|
|
8
2
|
/**
|
|
9
3
|
* @category Components
|
|
10
4
|
*/
|
package/dist/divider/Divider.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as l}from"react/jsx-runtime";import{cnMerge as m,isEmpty as c}from"@nild/shared";import{forwardRef as f,Children as p}from"react";import{dividerClassNames as h}from"./style/index.js";const a=f(({className:i,children:e,variant:s="solid",direction:o="horizontal",align:t="center",...n},d)=>{const r=p.toArray(e);return l("div",{...n,className:m(h({emptyChildren:c(r),variant:s,direction:o,align:t}),i),ref:d,children:r})});a.displayName="Divider";export{a as default};
|
package/dist/divider/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { default as Divider
|
|
2
|
-
|
|
3
|
-
export type { DividerProps, DividerVariant, DividerDirection, DividerAlign };
|
|
1
|
+
import { default as Divider } from './Divider';
|
|
2
|
+
export type * from './interfaces';
|
|
4
3
|
export default Divider;
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export type DividerAlign = 'left' | 'center' | 'right';
|
|
6
|
-
export declare const ALIGN_CLS_MAP: Record<DividerAlign, string[]>;
|
|
1
|
+
import { DividerProps } from '../interfaces';
|
|
2
|
+
export declare const dividerClassNames: (props?: (DividerProps & {
|
|
3
|
+
emptyChildren: boolean;
|
|
4
|
+
}) | undefined) => string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e
|
|
1
|
+
import{cva as e}from"@nild/shared";const r=e(["nd-divider","border-split","text-primary"],{compoundVariants:[{emptyChildren:!0,direction:"horizontal",className:["w-full","min-w-full","border-b","my-6"]},{emptyChildren:!0,direction:"vertical",className:["inline-block","h-[1em]","align-middle","border-r","ms-3 me-3"]},{emptyChildren:!0,variant:"solid",className:["border-solid"]},{emptyChildren:!0,variant:"dashed",className:["border-dashed"]},{emptyChildren:!0,variant:"dotted",className:["border-dotted"]},{emptyChildren:!1,direction:"horizontal",className:["flex items-center text-center",'before:h-0 before:content-[""] before:border-b before:border-[color:inherit]','after:h-0 after:content-[""] after:border-b after:border-[color:inherit]',"my-6"]},{emptyChildren:!1,direction:"horizontal",variant:"solid",className:["before:border-solid","after:border-solid"]},{emptyChildren:!1,direction:"horizontal",variant:"dashed",className:["before:border-dashed","after:border-dashed"]},{emptyChildren:!1,direction:"horizontal",variant:"dotted",className:["before:border-dotted","after:border-dotted"]},{emptyChildren:!1,direction:"horizontal",align:"left",className:["before:basis-1/12","before:grow-0","after:flex-1"]},{emptyChildren:!1,direction:"horizontal",align:"center",className:["before:flex-1","after:flex-1"]},{emptyChildren:!1,direction:"horizontal",align:"right",className:["before:flex-1","after:basis-1/12","after:grow-0"]}]});export{r as dividerClassNames};
|
package/dist/switch/Switch.d.ts
CHANGED
|
@@ -1,16 +1,5 @@
|
|
|
1
|
-
import { ForwardRefExoticComponent,
|
|
2
|
-
import {
|
|
3
|
-
export interface SwitchProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'value' | 'defaultValue' | 'onChange'> {
|
|
4
|
-
variant?: SwitchVariant;
|
|
5
|
-
size?: SwitchSize;
|
|
6
|
-
shape?: SwitchShape;
|
|
7
|
-
checked?: boolean;
|
|
8
|
-
defaultChecked?: boolean;
|
|
9
|
-
value?: boolean;
|
|
10
|
-
defaultValue?: boolean;
|
|
11
|
-
disabled?: boolean;
|
|
12
|
-
onChange?: (checked: boolean) => void;
|
|
13
|
-
}
|
|
1
|
+
import { ForwardRefExoticComponent, HTMLAttributes, RefAttributes } from 'react';
|
|
2
|
+
import { SwitchProps, SwitchVariant, SwitchShape } from './interfaces';
|
|
14
3
|
/**
|
|
15
4
|
* @category Components
|
|
16
5
|
*/
|
|
@@ -19,7 +8,20 @@ declare const Switch: ForwardRefExoticComponent<SwitchProps & RefAttributes<HTML
|
|
|
19
8
|
Unchecked: typeof Unchecked;
|
|
20
9
|
Thumb: typeof Thumb;
|
|
21
10
|
};
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
11
|
+
interface CheckedProps extends HTMLAttributes<HTMLDivElement> {
|
|
12
|
+
variant: SwitchVariant;
|
|
13
|
+
checked: boolean;
|
|
14
|
+
}
|
|
15
|
+
declare const Checked: ForwardRefExoticComponent<CheckedProps & RefAttributes<HTMLDivElement>>;
|
|
16
|
+
interface UncheckedProps extends HTMLAttributes<HTMLDivElement> {
|
|
17
|
+
variant: SwitchVariant;
|
|
18
|
+
checked: boolean;
|
|
19
|
+
}
|
|
20
|
+
declare const Unchecked: ForwardRefExoticComponent<UncheckedProps & RefAttributes<HTMLDivElement>>;
|
|
21
|
+
interface ThumbProps extends HTMLAttributes<HTMLDivElement> {
|
|
22
|
+
variant: SwitchVariant;
|
|
23
|
+
shape: SwitchShape;
|
|
24
|
+
checked: boolean;
|
|
25
|
+
}
|
|
26
|
+
declare const Thumb: ForwardRefExoticComponent<ThumbProps & RefAttributes<HTMLDivElement>>;
|
|
25
27
|
export default Switch;
|
package/dist/switch/Switch.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as
|
|
1
|
+
import{jsxs as M,jsx as d}from"react/jsx-runtime";import{useControllableState as R}from"@nild/hooks";import{cnMerge as p}from"@nild/shared";import{forwardRef as k,Children as T,isValidElement as U,cloneElement as y}from"react";import{switchClassNames as q,checkedClassNames as A,uncheckedClassNames as B,thumbClassNames as D}from"./style/index.js";const h=k(({className:i,children:r,variant:a="solid",size:s="medium",shape:c="round",checked:l,defaultChecked:f,value:w,defaultValue:b,disabled:g,onChange:C,style:S,...j},x)=>{let n,m,o;T.forEach(r,e=>{U(e)&&(e.type===v?n=e:e.type===u?m=e:e.type===N&&(o=e))});const E={"--nd-switch-height":{small:"calc(var(--spacing) * 4)",medium:"calc(var(--spacing) * 6)",large:"calc(var(--spacing) * 8)"}[s]},[t,V]=R(l??w,f??b??!1),z=()=>{V(e=>(C?.(!e),!e))};return M("button",{...j,type:"button",role:"switch","aria-checked":t,disabled:g,className:p(q({variant:a,size:s,shape:c}),i),style:{...E,...S},ref:x,onClick:z,children:[n?y(n,{...n.props,variant:a,checked:t}):d(v,{variant:a,checked:t}),m?y(m,{...m.props,variant:a,checked:t}):d(u,{variant:a,checked:t}),o?y(o,{...o.props,variant:a,shape:c,checked:t}):d(N,{variant:a,shape:c,checked:t})]})});h.displayName="Switch";const v=k(({className:i,children:r,variant:a,checked:s,...c},l)=>d("div",{...c,className:p(A({variant:a,checked:s}),i),ref:l,children:r}));v.displayName="Switch.Checked";const u=k(({className:i,children:r,variant:a,checked:s,...c},l)=>d("div",{...c,className:p(B({variant:a,checked:s}),i),ref:l,children:r}));u.displayName="Switch.Unchecked";const N=k(({className:i,children:r,variant:a,shape:s,checked:c,...l},f)=>d("div",{...l,className:p(D({variant:a,shape:s,checked:c}),i),ref:f,children:r}));N.displayName="Switch.Thumb",h.Checked=v,h.Unchecked=u,h.Thumb=N;export{h as default};
|
package/dist/switch/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export type { SwitchProps, SwitchVariant, SwitchSize, SwitchShape };
|
|
1
|
+
import { default as Switch } from './Switch';
|
|
2
|
+
export type * from './interfaces';
|
|
4
3
|
export default Switch;
|
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const
|
|
3
|
-
export declare const
|
|
4
|
-
export declare const
|
|
5
|
-
export
|
|
6
|
-
export declare const SIZE_VAR_MAP: Record<SwitchSize, string>;
|
|
7
|
-
export declare const SIZE_CLS_MAP: Record<SwitchSize, string[]>;
|
|
8
|
-
export type SwitchShape = 'round' | 'square';
|
|
9
|
-
export declare const SHAPE_CLS_MAP: Record<SwitchShape, string[]>;
|
|
1
|
+
import { SwitchProps } from '../interfaces';
|
|
2
|
+
export declare const switchClassNames: (props?: SwitchProps | undefined) => string;
|
|
3
|
+
export declare const checkedClassNames: (props?: Pick<SwitchProps, "variant" | "checked"> | undefined) => string;
|
|
4
|
+
export declare const uncheckedClassNames: (props?: Pick<SwitchProps, "variant" | "checked"> | undefined) => string;
|
|
5
|
+
export declare const thumbClassNames: (props?: Pick<SwitchProps, "variant" | "shape" | "checked"> | undefined) => string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const r
|
|
1
|
+
import{cva as e}from"@nild/shared";import{DISABLED_CLS as r}from"../../_shared/style/index.js";const a=e(["nd-switch","group","h-[var(--nd-switch-height)]",["relative","inline-block","font-nd","overflow-hidden","cursor-pointer"],r],{variants:{variant:{solid:"",outlined:["border-solid","border","border-primary"]},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"}}}),t=e(["h-[var(--nd-switch-height)]","transition-[margin-inline,background-color]",["flex","justify-center","items-center"],["text-center","text-contrast"],["ps-[calc(var(--nd-switch-height)/3)]","pe-[calc(var(--nd-switch-height)*1.1)]"]],{variants:{checked:{true:["ms-0","me-0"],false:["-ms-[100%]","me-[100%]"]}},compoundVariants:[{variant:"solid",checked:!0,className:["bg-primary","group-enabled:group-hover:bg-primary-hover"]},{variant:"solid",checked:!1,className:["bg-[--alpha(var(--color-primary)/40%)]","group-enabled:group-hover:bg-[--alpha(var(--color-primary)/50%)]"]},{variant:"outlined",className:["bg-transparent","group-enabled:group-hover:bg-tertiary-hover"]}]}),s=e(["h-[var(--nd-switch-height)]","-mt-[var(--nd-switch-height)]","transition-[margin-inline,background-color]",["flex","justify-center","items-center"],["text-center","text-contrast"],["ps-[calc(var(--nd-switch-height)*1.1)]","pe-[calc(var(--nd-switch-height)/3)]"]],{variants:{checked:{true:["ms-[100%]","-me-[100%]"],false:["ms-0","me-0"]}},compoundVariants:[{variant:"solid",checked:!0,className:["bg-primary","group-enabled:group-hover:bg-primary-hover"]},{variant:"solid",checked:!1,className:["bg-[--alpha(var(--color-primary)/40%)]","group-enabled:group-hover:bg-[--alpha(var(--color-primary)/50%)]"]},{variant:"outlined",className:["bg-transparent","group-enabled:group-hover:bg-tertiary-hover"]}]}),i=e(["h-[var(--nd-switch-height)]",["flex","justify-center","items-center"],["absolute","aspect-square","scale-80"],["text-contrast","transition-[left,background-color]"]],{variants:{variant:{solid:["bg-contrast","top-0"],outlined:["bg-primary","top-[50%]","-translate-y-[50%]","group-enabled:group-hover:bg-primary-hover"]},shape:{round:"rounded-full",square:"rounded-md"},checked:{true:"left-[calc(100%-var(--nd-switch-height))]",false:"left-0"}}});export{t as checkedClassNames,a as switchClassNames,i as thumbClassNames,s as uncheckedClassNames};
|