@nild/components 0.0.22 → 0.0.24

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.
@@ -1 +1 @@
1
- import{createContext as e}from"@nild/shared";const[a,t]=e({defaultValue:{variant:"solid",size:"medium",equal:!1,disabled:!1}});export{a as GroupProvider,t as useGroupContext};
1
+ import{createContextSuite as e}from"@nild/shared";const[a,o]=e({defaultValue:{variant:"solid",size:"medium",equal:!1,disabled:!1}});export{a as GroupProvider,o as useGroupContext};
@@ -1 +1 @@
1
- import{jsx as r}from"react/jsx-runtime";import{useControllableState as y,useEffectCallback as E}from"@nild/hooks";import{isString as c,cnMerge as w}from"@nild/shared";import{forwardRef as z,Children as M,isValidElement as S}from"react";import{CheckboxProvider as j}from"./contexts/index.js";import t from"./Indicator.js";import s from"./Label.js";import{checkboxClassNames as P}from"./style/index.js";const m=z(({className:h,children:l,variant:f="solid",size:o="medium",checked:p,defaultChecked:u,value:C,defaultValue:b,indeterminate:R,disabled:d,onChange:n,...k},v)=>{const i=[],a=new Map,[x,N]=y(p??C,u??b??!1),g=E(()=>{d||N(e=>(n?.(!e),!e))});return M.forEach(l,e=>{S(e)?e.type===t?(a.delete(t),a.set(t,e)):e.type===s&&(a.delete(s),a.set(s,e)):c(e)&&(a.has(s)||a.set(s,r(s,{children:e})))}),i.push(...a.values()),a.has(t)||i.unshift(r(t,{})),!a.has(s)&&c(l)&&i.push(r(s,{children:l})),r(j,{value:{variant:f,size:o,checked:x,handleChange:g},children:r("label",{...k,className:w(P({size:o,disabled:d}),h),ref:v,children:i})})});m.displayName="Checkbox";export{m as default};
1
+ import{jsx as s}from"react/jsx-runtime";import{useControllableState as w,useEffectCallback as E}from"@nild/hooks";import{isString as u,cnMerge as M}from"@nild/shared";import{forwardRef as S,Children as V,isValidElement as j}from"react";import{useGroupContext as G,CheckboxProvider as P}from"./contexts/index.js";import i from"./Indicator.js";import r from"./Label.js";import{checkboxClassNames as I}from"./style/index.js";const h=S((f,p)=>{const t=[],l=new Map,e=G(),{className:v,children:o,variant:C=e?.variant??"solid",size:n=e?.size??"medium",disabled:c=e?.disabled??!1,checked:b,defaultChecked:k,value:d,onChange:m,...x}=f,[z,N]=w(e?e.value.includes(d):b,k??!1),g=E(()=>{c||N(a=>(e?e.setValue(a?e.value.filter(y=>y!==d):e.value.concat(d)):m?.(!a),!a))});return V.forEach(o,a=>{j(a)?a.type===i?(l.delete(i),l.set(i,a)):a.type===r&&(l.delete(r),l.set(r,a)):u(a)&&(l.has(r)||l.set(r,s(r,{children:a})))}),t.push(...l.values()),l.has(i)||t.unshift(s(i,{})),!l.has(r)&&u(o)&&t.push(s(r,{children:o})),s(P,{value:{variant:C,size:n,checked:z,handleChange:g},children:s("label",{...x,className:M(I({size:n,disabled:c}),v),ref:p,children:t})})});h.displayName="Checkbox";export{h as default};
@@ -0,0 +1,3 @@
1
+ import { GroupProps } from './interfaces';
2
+ declare const Group: <T>(props: GroupProps<T> & import('react').RefAttributes<HTMLDivElement>) => import('react').ReactElement | null;
3
+ export default Group;
@@ -0,0 +1 @@
1
+ import{jsx as r}from"react/jsx-runtime";import{useControllableState as b,useEffectCallback as C}from"@nild/hooks";import{forwardRefWithGenerics as N,cnMerge as x}from"@nild/shared";import{GroupProvider as G}from"./contexts/index.js";import{groupClassNames as g}from"./style/index.js";const o=N(({className:s,children:i,direction:l="horizontal",variant:t="solid",size:d="medium",disabled:n=!1,value:m,defaultValue:u=[],onChange:e,...c},f)=>{const[p,v]=b(m,u),h=C(a=>{v(()=>(e?.(a),a))});return r(G,{value:{variant:t,size:d,disabled:n,value:p,setValue:h},children:r("div",{...c,className:x(g({direction:l}),s),ref:f,children:i})})});o.displayName="Checkbox.Group";export{o as default};
@@ -1,7 +1,14 @@
1
- import { CheckboxProps } from '../interfaces';
1
+ import { CheckboxProps, GroupProps } from '../interfaces';
2
2
  declare const CheckboxProvider: import('react').Provider<Pick<CheckboxProps, "variant" | "size" | "checked"> & {
3
3
  handleChange?: () => void;
4
4
  }>, useCheckboxContext: () => Pick<CheckboxProps, "variant" | "size" | "checked"> & {
5
5
  handleChange?: () => void;
6
6
  };
7
- export { CheckboxProvider, useCheckboxContext };
7
+ declare const GroupProvider: import('react').Provider<(Pick<GroupProps<unknown>, "variant" | "size" | "disabled"> & {
8
+ value: any[];
9
+ setValue: (value: any[]) => void;
10
+ }) | undefined>, useGroupContext: () => (Pick<GroupProps<unknown>, "variant" | "size" | "disabled"> & {
11
+ value: any[];
12
+ setValue: (value: any[]) => void;
13
+ }) | undefined;
14
+ export { CheckboxProvider, GroupProvider, useCheckboxContext, useGroupContext };
@@ -1 +1 @@
1
- import{createContext as e}from"@nild/shared";const[t,o]=e({defaultValue:{}});export{t as CheckboxProvider,o as useCheckboxContext};
1
+ import{createContextSuite as e}from"@nild/shared";const[o,t]=e({defaultValue:{}}),[r,a]=e({defaultValue:void 0});export{o as CheckboxProvider,r as GroupProvider,t as useCheckboxContext,a as useGroupContext};
@@ -4,6 +4,7 @@
4
4
  declare const Checkbox: import('react').ForwardRefExoticComponent<import('./interfaces').CheckboxProps & import('react').RefAttributes<HTMLLabelElement>> & {
5
5
  Indicator: import('react').ForwardRefExoticComponent<import('./interfaces').IndicatorProps & import('react').RefAttributes<HTMLDivElement>>;
6
6
  Label: import('react').ForwardRefExoticComponent<import('./interfaces').LabelProps & import('react').RefAttributes<HTMLSpanElement>>;
7
+ Group: <T>(props: import('./interfaces').GroupProps<T> & import('react').RefAttributes<HTMLDivElement>) => import('react').ReactElement | null;
7
8
  };
8
9
  export type * from './interfaces';
9
10
  export default Checkbox;
@@ -1 +1 @@
1
- import o from"./Checkbox.js";import r from"./Indicator.js";import t from"./Label.js";const m=Object.assign(o,{Indicator:r,Label:t});export{m as default};
1
+ import o from"./Checkbox.js";import r from"./Group.js";import t from"./Indicator.js";import m from"./Label.js";const i=Object.assign(o,{Indicator:t,Label:m,Group:r});export{i as default};
@@ -1,7 +1,8 @@
1
- import { CheckboxProps } from '../interfaces';
1
+ import { CheckboxProps, GroupProps } from '../interfaces';
2
2
  export declare const checkboxClassNames: (props?: Pick<CheckboxProps, "size" | "disabled"> | undefined) => string;
3
3
  export declare const indicatorClassNames: (props?: Pick<CheckboxProps, "size"> | undefined) => string;
4
4
  export declare const indicatorInputClassNames: (props?: object | undefined) => string;
5
5
  export declare const defaultIndicatorBlockClassNames: (props?: Pick<CheckboxProps, "variant" | "checked"> | undefined) => string;
6
6
  export declare const defaultIndicatorIconClassNames: (props?: object | undefined) => string;
7
7
  export declare const labelClassNames: (props?: Pick<CheckboxProps, "size"> | undefined) => string;
8
+ export declare const groupClassNames: (props?: Pick<GroupProps<unknown>, "direction"> | 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-checkbox","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:"w-3.5 h-3.5 text-sm",medium:"w-4 h-4 text-md",large:"w-4.5 h-4.5 text-xl"}}}),s=e([["absolute","inset-0","opacity-0"],["group-enabled:cursor-pointer","group-disabled:cursor-not-allowed"]]),o=e([["flex","items-center","justify-center"],["w-full","h-full","rounded-sm","border-solid","border-1","border-primary"],"transition-[background-color,color]"],{compoundVariants:[{checked:!0,variant:"solid",className:["bg-primary text-contrast","group-enabled:group-hover:bg-primary-hover"]},{checked:!0,variant:"outlined",className:["bg-transparent text-primary","group-enabled:group-hover:bg-tertiary-hover"]},{checked:!1,className:["bg-transparent text-transparent","group-enabled:group-hover:bg-tertiary-hover"]}]}),l=e(["mr-[0.25px]"]),i=e(["text-sm"],{variants:{size:{small:"text-sm",medium:"text-md",large:"text-lg"}}});export{r as checkboxClassNames,o as defaultIndicatorBlockClassNames,l as defaultIndicatorIconClassNames,t as indicatorClassNames,s as indicatorInputClassNames,i as labelClassNames};
1
+ import{cva as e}from"@nild/shared";import{DISABLED_CLS as a}from"../../_shared/style/index.js";const r=e(["nd-checkbox","group",["flex","items-center"],"cursor-pointer",a],{variants:{size:{small:"gap-1.5",medium:"gap-2",large:"gap-2.5"},disabled:{true:"disabled",false:""}}}),s=e(["relative",["flex","items-center","justify-center"]],{variants:{size:{small:"w-3.5 h-3.5 text-sm",medium:"w-4 h-4 text-md",large:"w-4.5 h-4.5 text-lg"}}}),t=e([["absolute","inset-0","opacity-0"],["group-enabled:cursor-pointer","group-disabled:cursor-not-allowed"]]),o=e([["flex","items-center","justify-center"],["w-full","h-full","rounded-sm","border-solid","border-1","border-primary"],"transition-[background-color,color]"],{compoundVariants:[{checked:!0,variant:"solid",className:["bg-primary text-contrast","group-enabled:group-hover:bg-primary-hover"]},{checked:!0,variant:"outlined",className:["bg-transparent text-primary","group-enabled:group-hover:bg-tertiary-hover"]},{checked:!1,className:["bg-transparent text-transparent","group-enabled:group-hover:bg-tertiary-hover"]}]}),l=e(["w-full"]),i=e(["text-sm"],{variants:{size:{small:"text-sm",medium:"text-md",large:"text-lg"}}}),n=e(["nd-checkbox-group",["flex","gap-x-4","gap-y-2"]],{variants:{direction:{horizontal:"flex-row flex-wrap",vertical:"flex-col"}}});export{r as checkboxClassNames,o as defaultIndicatorBlockClassNames,l as defaultIndicatorIconClassNames,n as groupClassNames,s as indicatorClassNames,t as indicatorInputClassNames,i as labelClassNames};
@@ -1 +1 @@
1
- import{createContext as t}from"@nild/shared";const[e,o]=t({defaultValue:{}});export{e as SwitchProvider,o as useSwitchContext};
1
+ import{createContextSuite as t}from"@nild/shared";const[e,o]=t({defaultValue:{}});export{e as SwitchProvider,o as useSwitchContext};
@@ -1 +1 @@
1
- import{jsx as s}from"react/jsx-runtime";import{cnMerge as p}from"@nild/shared";import{forwardRef as f}from"react";import{textTagClassNames as x,textClassNames as N}from"./style/index.js";const e=f(({className:r,children:t,variants:o=[],secondary:d=!1,disabled:m=!1,...n},i)=>{const c=[...new Set(o)].reduce((l,a)=>s(a,{className:x({variant:a}),children:l}),t);return s("span",{...n,className:p(N({secondary:d,disabled:m}),r),ref:i,children:c})});e.displayName="Typography.Text";export{e as default};
1
+ import{jsx as s}from"react/jsx-runtime";import{cnMerge as p}from"@nild/shared";import{forwardRef as f}from"react";import{textTagClassNames as N,textClassNames as x}from"./style/index.js";const e=f(({className:r,children:t,tags:o=[],secondary:d=!1,disabled:m=!1,...c},l)=>{const i=[...new Set(o)].reduce((n,a)=>s(a,{className:N({tag:a}),children:n}),t);return s("span",{...c,className:p(x({secondary:d,disabled:m}),r),ref:l,children:i})});e.displayName="Typography.Text";export{e as default};
@@ -1,9 +1,9 @@
1
- import { LinkProps, ParagraphProps, TextProps, TextVariant, TitleProps, TypographyProps } from '../interfaces';
1
+ import { LinkProps, ParagraphProps, TextProps, TextTag, TitleProps, TypographyProps } from '../interfaces';
2
2
  export declare const linkClassNames: (props?: LinkProps | undefined) => string;
3
3
  export declare const paragraphClassNames: (props?: ParagraphProps | undefined) => string;
4
4
  export declare const textClassNames: (props?: TextProps | undefined) => string;
5
5
  export declare const textTagClassNames: (props?: {
6
- variant: TextVariant;
6
+ tag: TextTag;
7
7
  } | undefined) => string;
8
8
  export declare const titleClassNames: (props?: TitleProps | undefined) => string;
9
9
  export declare const typographyClassNames: (props?: TypographyProps | undefined) => string;
@@ -1 +1 @@
1
- import{cva as e}from"@nild/shared";import{DISABLED_CLS as t}from"../../_shared/style/index.js";const a=e(["nd-link",["font-nd","text-link","text-[length:inherit]","cursor-pointer","enabled:hover:text-link-hover","enabled:active:text-link-active"],t],{variants:{disabled:{true:"disabled",false:""},underlined:{true:"underline",false:"no-underline"}}}),r=e(["nd-paragraph",["font-nd","text-primary","text-[length:inherit]"],["mt-0","mb-[1em]"]]),s=e(["nd-text",["font-nd","text-[length:inherit]"],t],{variants:{secondary:{true:"text-secondary",false:"text-primary"},disabled:{true:"disabled",false:""}}}),n=e("",{variants:{variant:{strong:"",del:"",u:["underline"],i:"",mark:["bg-primary","text-contrast"],code:[["ps-1.5","pe-1.5"],["bg-secondary","text-sm","rounded-sm"],["border","border-solid","border-secondary"]],kbd:[["ps-1.5","pe-1.5"],["text-sm","rounded-sm"],["border","border-b-2","border-solid","border-secondary"]]}}}),d=e(["nd-title",["font-nd","font-semibold","text-primary"],["mt-[1em]","mb-[0.5em]"]],{variants:{level:{1:["text-6xl"],2:["text-5xl"],3:["text-4xl"],4:["text-3xl"],5:["text-2xl"],6:["text-lg"]}}}),l=e(["nd-typography",["font-nd","text-md"]]);export{a as linkClassNames,r as paragraphClassNames,s as textClassNames,n as textTagClassNames,d as titleClassNames,l as typographyClassNames};
1
+ import{cva as e}from"@nild/shared";import{DISABLED_CLS as t}from"../../_shared/style/index.js";const a=e(["nd-link",["font-nd","text-link","text-[length:inherit]","cursor-pointer","enabled:hover:text-link-hover","enabled:active:text-link-active"],t],{variants:{disabled:{true:"disabled",false:""},underlined:{true:"underline",false:"no-underline"}}}),r=e(["nd-paragraph",["font-nd","text-primary","text-[length:inherit]"],["mt-0","mb-[1em]"]]),s=e(["nd-text",["font-nd","text-[length:inherit]"],t],{variants:{secondary:{true:"text-secondary",false:"text-primary"},disabled:{true:"disabled",false:""}}}),n=e("",{variants:{tag:{strong:"",del:"",u:["underline"],i:"",mark:["bg-primary","text-contrast"],code:[["ps-1.5","pe-1.5"],["bg-secondary","text-sm","rounded-sm"],["border","border-solid","border-secondary"]],kbd:[["ps-1.5","pe-1.5"],["text-sm","rounded-sm"],["border","border-b-2","border-solid","border-secondary"]]}}}),d=e(["nd-title",["font-nd","font-semibold","text-primary"],["mt-[1em]","mb-[0.5em]"]],{variants:{level:{1:["text-6xl"],2:["text-5xl"],3:["text-4xl"],4:["text-3xl"],5:["text-2xl"],6:["text-lg"]}}}),l=e(["nd-typography",["font-nd","text-md"]]);export{a as linkClassNames,r as paragraphClassNames,s as textClassNames,n as textTagClassNames,d as titleClassNames,l as typographyClassNames};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@nild/components",
3
3
  "private": false,
4
- "version": "0.0.22",
4
+ "version": "0.0.24",
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/hooks": "0.0.12",
35
- "@nild/icons": "0.0.11",
36
- "@nild/shared": "0.0.10"
34
+ "@nild/hooks": "0.0.13",
35
+ "@nild/shared": "0.0.11",
36
+ "@nild/icons": "0.0.12"
37
37
  },
38
38
  "scripts": {
39
39
  "build": "vite build --mode PROD",