@cocso-ui/react 0.0.1-beta.2 → 0.0.1-beta.21

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/README.md ADDED
@@ -0,0 +1,23 @@
1
+ ## `@cocso-ui/react`
2
+
3
+ 이 Package는 리액트 기반 컴포넌트를 제공해요.
4
+
5
+ `radix-ui`의 헤드리스 컴포넌트를 사용하여 접근성과 커스터마이징을 고려한 컴포넌트를 구현하고 있어요.
6
+
7
+ ### Installation
8
+
9
+ ```bash
10
+ pnpm install @cocso-ui/react
11
+ ```
12
+
13
+ ### Usage
14
+
15
+ 컴포넌트를 아래와 같은 형태로 import 할 수 있어요.
16
+
17
+ ```javascript
18
+ import {Button} from '@cocso-ui/react';
19
+ ```
20
+
21
+ ### Dependencies
22
+
23
+ - [@cocso-ui/css](../css)
@@ -0,0 +1,9 @@
1
+ import * as AccordionPrimitive from '@radix-ui/react-accordion';
2
+ export declare const Accordion: import("react").ForwardRefExoticComponent<(AccordionPrimitive.AccordionSingleProps | AccordionPrimitive.AccordionMultipleProps) & import("react").RefAttributes<HTMLDivElement>> & {
3
+ Item: import("react").ForwardRefExoticComponent<Omit<AccordionPrimitive.AccordionItemProps & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
4
+ Header: import("react").ForwardRefExoticComponent<AccordionPrimitive.AccordionHeaderProps & import("react").RefAttributes<HTMLHeadingElement>>;
5
+ Trigger: import("react").ForwardRefExoticComponent<{
6
+ chevron?: boolean;
7
+ } & Omit<AccordionPrimitive.AccordionTriggerProps & import("react").RefAttributes<HTMLButtonElement>, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
8
+ Content: import("react").ForwardRefExoticComponent<Omit<AccordionPrimitive.AccordionContentProps & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
9
+ };
@@ -0,0 +1 @@
1
+ export * from './Accordion';
@@ -1,15 +1,16 @@
1
1
  import * as React from 'react';
2
- type BodyElement = 'p' | 'a' | 'span' | 'div' | 'label' | 'li' | 'td' | 'th' | 'figcaption' | 'blockquote' | 'cite';
3
- export type BodyProps<T extends React.ElementType = 'p'> = {
4
- as?: T & BodyElement;
2
+ import { type FontWeightToken } from '../../utils/token';
3
+ export type BodyProps = {
4
+ asChild?: boolean;
5
5
  size?: 'lg' | 'md' | 'sm' | 'xs';
6
6
  color?: string;
7
- fontWeight?: 'normal' | 'bold';
8
- } & Omit<React.ComponentPropsWithoutRef<T>, 'size' | 'color' | 'fontWeight'>;
7
+ weight?: FontWeightToken;
8
+ } & React.ComponentPropsWithoutRef<'p'>;
9
9
  export declare const Body: React.ForwardRefExoticComponent<{
10
- as?: BodyElement | undefined;
10
+ asChild?: boolean;
11
11
  size?: "lg" | "md" | "sm" | "xs";
12
12
  color?: string;
13
- fontWeight?: "normal" | "bold";
14
- } & Omit<Omit<React.DetailedHTMLProps<React.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>, "ref"> | Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>, "ref"> | Omit<React.DetailedHTMLProps<React.BlockquoteHTMLAttributes<HTMLQuoteElement>, HTMLQuoteElement>, "ref"> | Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> | Omit<React.DetailedHTMLProps<React.LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>, "ref"> | Omit<React.DetailedHTMLProps<React.LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>, "ref"> | Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>, "ref"> | Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> | Omit<React.DetailedHTMLProps<React.TdHTMLAttributes<HTMLTableDataCellElement>, HTMLTableDataCellElement>, "ref"> | Omit<React.DetailedHTMLProps<React.ThHTMLAttributes<HTMLTableHeaderCellElement>, HTMLTableHeaderCellElement>, "ref">, "size" | "color" | "fontWeight"> & React.RefAttributes<HTMLElement>>;
15
- export {};
13
+ weight?: FontWeightToken;
14
+ } & Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>, "ref"> & React.RefAttributes<HTMLParagraphElement>> & {
15
+ displayName: string;
16
+ };
@@ -0,0 +1,22 @@
1
+ import * as React from 'react';
2
+ import { type FontWeightToken } from '../../utils/token';
3
+ export type ButtonProps = {
4
+ asChild?: boolean;
5
+ variant?: 'primary' | 'secondary' | 'tertiary' | 'danger' | 'success' | 'text';
6
+ size?: 'xl' | 'lg' | 'md' | 'sm' | 'xs' | '2xs';
7
+ disabled?: boolean;
8
+ loading?: boolean;
9
+ color?: string;
10
+ weight?: FontWeightToken;
11
+ } & React.ComponentPropsWithoutRef<'button'>;
12
+ export declare const Button: React.ForwardRefExoticComponent<{
13
+ asChild?: boolean;
14
+ variant?: "primary" | "secondary" | "tertiary" | "danger" | "success" | "text";
15
+ size?: "xl" | "lg" | "md" | "sm" | "xs" | "2xs";
16
+ disabled?: boolean;
17
+ loading?: boolean;
18
+ color?: string;
19
+ weight?: FontWeightToken;
20
+ } & Omit<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & React.RefAttributes<HTMLButtonElement>> & {
21
+ displayName: string;
22
+ };
@@ -0,0 +1 @@
1
+ export * from './Button';
@@ -0,0 +1,21 @@
1
+ import * as React from 'react';
2
+ import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
3
+ export type CheckboxStatus = 'on' | 'off' | 'intermediate';
4
+ export type CheckboxProps = {
5
+ id?: string;
6
+ size?: 'lg' | 'md' | 'sm';
7
+ status: CheckboxStatus;
8
+ onChange: (next: CheckboxStatus) => void;
9
+ label?: string;
10
+ disabled?: boolean;
11
+ } & Omit<React.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root>, 'checked' | 'onCheckedChange'>;
12
+ export declare const Checkbox: React.ForwardRefExoticComponent<{
13
+ id?: string;
14
+ size?: "lg" | "md" | "sm";
15
+ status: CheckboxStatus;
16
+ onChange: (next: CheckboxStatus) => void;
17
+ label?: string;
18
+ disabled?: boolean;
19
+ } & Omit<Omit<CheckboxPrimitive.CheckboxProps & import("react").RefAttributes<HTMLButtonElement>, "ref">, "checked" | "onCheckedChange"> & React.RefAttributes<never>> & {
20
+ displayName: string;
21
+ };
@@ -0,0 +1 @@
1
+ export * from './Checkbox';
@@ -1,11 +1,16 @@
1
1
  import * as React from 'react';
2
+ import { type FontWeightToken } from '../../utils/token';
2
3
  export type DisplayProps = {
3
- as?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
4
+ asChild?: boolean;
4
5
  size?: 'lg' | 'md' | 'sm';
5
6
  color?: string;
6
- } & React.HTMLAttributes<HTMLHeadingElement>;
7
+ weight?: FontWeightToken;
8
+ } & React.ComponentPropsWithoutRef<'h1'>;
7
9
  export declare const Display: React.ForwardRefExoticComponent<{
8
- as?: "h1" | "h2" | "h3" | "h4" | "h5" | "h6";
10
+ asChild?: boolean;
9
11
  size?: "lg" | "md" | "sm";
10
12
  color?: string;
11
- } & React.HTMLAttributes<HTMLHeadingElement> & React.RefAttributes<HTMLHeadingElement>>;
13
+ weight?: FontWeightToken;
14
+ } & Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>, "ref"> & React.RefAttributes<HTMLHeadingElement>> & {
15
+ displayName: string;
16
+ };
@@ -1,11 +1,16 @@
1
1
  import * as React from 'react';
2
+ import { type FontWeightToken } from '../../utils/token';
2
3
  export type HeadingProps = {
3
- as?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
4
+ asChild?: boolean;
4
5
  size?: 'xl' | 'lg' | 'md' | 'sm' | 'xs' | '2xs';
5
6
  color?: string;
6
- } & React.HTMLAttributes<HTMLHeadingElement>;
7
+ weight?: FontWeightToken;
8
+ } & React.ComponentPropsWithoutRef<'h2'>;
7
9
  export declare const Heading: React.ForwardRefExoticComponent<{
8
- as?: "h1" | "h2" | "h3" | "h4" | "h5" | "h6";
10
+ asChild?: boolean;
9
11
  size?: "xl" | "lg" | "md" | "sm" | "xs" | "2xs";
10
12
  color?: string;
11
- } & React.HTMLAttributes<HTMLHeadingElement> & React.RefAttributes<HTMLHeadingElement>>;
13
+ weight?: FontWeightToken;
14
+ } & Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>, "ref"> & React.RefAttributes<HTMLHeadingElement>> & {
15
+ displayName: string;
16
+ };
@@ -0,0 +1,16 @@
1
+ import * as React from 'react';
2
+ import { type FontWeightToken } from '../../utils/token';
3
+ export type LabelProps = {
4
+ asChild?: boolean;
5
+ size?: 'lg' | 'md' | 'sm' | 'xs';
6
+ color?: string;
7
+ weight?: FontWeightToken;
8
+ } & React.ComponentPropsWithoutRef<'label'>;
9
+ export declare const Label: React.ForwardRefExoticComponent<{
10
+ asChild?: boolean;
11
+ size?: "lg" | "md" | "sm" | "xs";
12
+ color?: string;
13
+ weight?: FontWeightToken;
14
+ } & Omit<React.DetailedHTMLProps<React.LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>, "ref"> & React.RefAttributes<HTMLLabelElement>> & {
15
+ displayName: string;
16
+ };
@@ -0,0 +1 @@
1
+ export * from './Label';
@@ -0,0 +1,19 @@
1
+ import * as React from 'react';
2
+ declare const tags: readonly ["div"];
3
+ type Element = (typeof tags)[number];
4
+ type Default = (typeof tags)[0];
5
+ export type SpinnerProps<T extends Element = Default> = {
6
+ as?: T;
7
+ size?: 'xl' | 'lg' | 'md' | 'sm' | 'xs';
8
+ color?: string;
9
+ bg?: string;
10
+ } & Omit<React.ComponentPropsWithoutRef<T>, 'size' | 'color'>;
11
+ export declare const Spinner: React.ForwardRefExoticComponent<{
12
+ as?: "div" | undefined;
13
+ size?: "xl" | "lg" | "md" | "sm" | "xs";
14
+ color?: string;
15
+ bg?: string;
16
+ } & Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "color" | "size"> & React.RefAttributes<HTMLDivElement>> & {
17
+ displayName: string;
18
+ };
19
+ export {};
@@ -0,0 +1 @@
1
+ export * from './Spinner';
package/lib/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var v=Object.create;var d=Object.defineProperty;var $=Object.getOwnPropertyDescriptor;var N=Object.getOwnPropertyNames;var W=Object.getPrototypeOf,B=Object.prototype.hasOwnProperty;var L=(t,o)=>{for(var r in o)d(t,r,{get:o[r],enumerable:!0})},c=(t,o,r,n)=>{if(o&&typeof o=="object"||typeof o=="function")for(let a of N(o))!B.call(t,a)&&a!==r&&d(t,a,{get:()=>o[a],enumerable:!(n=$(o,a))||n.enumerable});return t};var m=(t,o,r)=>(r=t!=null?v(W(t)):{},c(o||!t||!t.__esModule?d(r,"default",{value:t,enumerable:!0}):r,t)),M=t=>c(d({},"__esModule",{value:!0}),t);var A={};L(A,{Body:()=>x,Display:()=>P,Heading:()=>E,Primitive:()=>S,createPrimitive:()=>e});module.exports=M(A);var f=require("@radix-ui/react-slot"),h=m(require("react"),1),y=require("react/jsx-runtime");function e(t){let o=h.forwardRef((r,n)=>{let{asChild:a,...i}=r;return(0,y.jsx)(a?f.Slot:t,{...i,ref:n})});return o.displayName=`Primitive.${t}`,o}var S={div:e("div"),span:e("span"),button:e("button"),input:e("input"),form:e("form"),label:e("label"),p:e("p"),h1:e("h1"),h2:e("h2"),h3:e("h3"),h4:e("h4"),h5:e("h5"),h6:e("h6"),section:e("section"),article:e("article"),header:e("header"),footer:e("footer"),main:e("main"),nav:e("nav"),aside:e("aside"),ul:e("ul"),ol:e("ol"),li:e("li"),img:e("img"),a:e("a"),strong:e("strong"),em:e("em"),small:e("small"),table:e("table"),thead:e("thead"),tbody:e("tbody"),tr:e("tr"),td:e("td"),th:e("th")};var R=m(require("react"),1),u=require("react/jsx-runtime");function w(t){if(t)return`var(--color-${t.replace(".","-")})`}var x=R.forwardRef(({as:t="p",size:o="md",color:r="",fontWeight:n="normal",style:a,className:i,...s},p)=>{let l=t,T=`text-body text-body-${o}${n==="bold"?"-bold":""} ${i}`;return(0,u.jsx)(l,{ref:p,className:T,style:{"--text-color":w(r),...a},...s})});x.displayName="Body";var g=m(require("react"),1),b=require("react/jsx-runtime");function z(t){if(t)return`var(--color-${t.replace(".","-")})`}var P=g.forwardRef(({as:t="h1",size:o="md",color:r="",style:n,className:a,...i},s)=>{let p=t,l=`text-display text-display-${o} ${a}`;return(0,b.jsx)(p,{ref:s,className:l,style:{"--text-color":z(r),...n},...i})});P.displayName="Display";var C=m(require("react"),1),H=require("react/jsx-runtime");function D(t){if(t)return`var(--color-${t.replace(".","-")})`}var E=C.forwardRef(({as:t="h2",size:o="md",color:r="",style:n,className:a,...i},s)=>{let p=t,l=`text-heading text-heading-${o} ${a}`;return(0,H.jsx)(p,{ref:s,className:l,style:{"--text-color":D(r),...n},...i})});E.displayName="Heading";
1
+ "use strict";var oe=Object.create;var k=Object.defineProperty;var te=Object.getOwnPropertyDescriptor;var re=Object.getOwnPropertyNames;var ne=Object.getPrototypeOf,se=Object.prototype.hasOwnProperty;var ie=(e,o)=>{for(var t in o)k(e,t,{get:o[t],enumerable:!0})},E=(e,o,t,n)=>{if(o&&typeof o=="object"||typeof o=="function")for(let r of re(o))!se.call(e,r)&&r!==t&&k(e,r,{get:()=>o[r],enumerable:!(n=te(o,r))||n.enumerable});return e};var u=(e,o,t)=>(t=e!=null?oe(ne(e)):{},E(o||!e||!e.__esModule?k(t,"default",{value:e,enumerable:!0}):t,e)),ce=e=>E(k({},"__esModule",{value:!0}),e);var Te={};ie(Te,{Accordion:()=>de,Body:()=>ge,Button:()=>be,Checkbox:()=>we,Display:()=>Re,Heading:()=>Pe,Label:()=>L,Spinner:()=>S});module.exports=ce(Te);var h=u(require("@radix-ui/react-accordion"),1),N=require("react");var ae=(...e)=>e.filter(Boolean).join(" ").trim(),a=(e,o,t=[],...n)=>{let r=Object.entries(o).filter(([,s])=>s!==!1&&s!==null&&s!==void 0).map(([s,c])=>`${e}--${s}_${c}`).join(" "),i=t.filter(s=>Object.entries(s).every(([c,p])=>o[c]===p)).map(s=>{let c=Object.entries(s).map(([p,m])=>`${p}_${m}`).join("-");return`${e}--${c}`}).join(" ");return ae(e,r,i,...n)};var F=require("@radix-ui/react-slot"),x=require("react/jsx-runtime"),me=(0,N.forwardRef)(({className:e,...o},t)=>{let n=a("cocso-accordion-item",{},[],e);return(0,x.jsx)(h.Item,{ref:t,className:n,...o})}),pe=(0,N.forwardRef)(({className:e,children:o,chevron:t=!0,...n},r)=>{let i=a("cocso-accordion-trigger",{},[],e);return(0,x.jsx)(h.Trigger,{ref:r,className:i,...n,children:(0,x.jsxs)(F.Slottable,{children:[o,t&&(0,x.jsx)("div",{className:"cocso-accordion-chevron",children:(0,x.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,x.jsx)("path",{d:"m6 9 6 6 6-6"})})})]})})}),le=(0,N.forwardRef)(({className:e,...o},t)=>{let n=a("cocso-accordion-content",{},[],e);return(0,x.jsx)(h.Content,{ref:t,className:n,...o})}),de=Object.assign(h.Root,{Item:me,Header:h.Header,Trigger:pe,Content:le});var H=u(require("react"),1),O=require("@radix-ui/react-slot");function l(e){if(e)return e.includes(".")?`var(--color-${e.replace(/\./g,"-")})`:e}var A={thin:"100",extralight:"200",light:"300",normal:"400",medium:"500",semibold:"600",bold:"700",extrabold:"800",black:"900"};function C(e){if(e)return e in A?A[e]:e}var M=require("react/jsx-runtime"),fe=H.forwardRef(({asChild:e=!1,size:o="md",color:t,weight:n="normal",className:r,style:i,...s},c)=>{let m=a("cocso-body",{size:o},[],r);return(0,M.jsx)(e?O.Slot:"p",{ref:c,className:m,style:{"--cocso-body-color":l(t),"--cocso-body-weight":C(n),...i},...s})}),ge=Object.assign(fe,{displayName:"Body"});var v=u(require("react"),1),D=require("@radix-ui/react-slot");var z=u(require("react"),1);var R=require("react/jsx-runtime"),he=["div"],Ce=z.forwardRef(({as:e=he[0],size:o="md",color:t="palette.primary-500",bg:n="palette.gray-200",className:r,style:i,...s},c)=>{let p=e,f=a("cocso-spinner",{size:o},[],r);return(0,R.jsx)(p,{ref:c,className:f,style:{"--cocso-spinner-bg":l(n),"--cocso-spinner-color":l(t),...i},...s,children:(0,R.jsxs)("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,R.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"9",stroke:"var(--cocso-spinner-bg, currentColor)",strokeWidth:"3"}),(0,R.jsx)("path",{className:"opacity-75",fill:"var(--cocso-spinner-color, currentColor)",d:"M12 2a10 10 0 0110 10 10 10 0 01-5 8.66l-1-1.73a8 8 0 004-6.93 8 8 0 00-8-8V2z"})]})})}),S=Object.assign(Ce,{displayName:"Spinner"});var W=require("react/jsx-runtime"),ue=e=>({"2xs":"xs",xs:"xs",sm:"xs",md:"sm",lg:"md",xl:"md"})[e],xe=v.forwardRef(({asChild:e=!1,variant:o="primary",size:t="md",disabled:n=!1,loading:r=!1,color:i,weight:s="normal",className:c,style:p,children:m,onClick:f,onKeyDown:P,...T},B)=>{let g=n||r,y=v.useCallback(b=>{if(g){b.preventDefault();return}f?.(b)},[g,f]),U=v.useCallback(b=>{(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),g||b.currentTarget.click()),P?.(b)},[g,P]),X={variant:o,size:t,loading:r,disabled:g},Y=[...n?[{variant:o,disabled:n}]:[],...r?[{variant:o,loading:r}]:[]],Z=a("cocso-button",X,Y,c),ee={"--cocso-button-color":l(i),"--cocso-button-weight":C(s),...p};return(0,W.jsx)(e?D.Slot:"button",{ref:B,className:Z,onClick:y,onKeyDown:U,role:"button",disabled:g,"aria-disabled":g,"aria-busy":r,style:ee,...T,children:r?(0,W.jsx)(S,{className:"cocso-button-spinner",size:ue(t),color:"currentColor"}):m})}),be=Object.assign(xe,{displayName:"Button"});var j=u(require("react"),1),I=require("@radix-ui/react-slot");var $=require("react/jsx-runtime"),ye=j.forwardRef(({asChild:e=!1,size:o="md",color:t,weight:n="bold",className:r,style:i,...s},c)=>{let m=a("cocso-display",{size:o},[],r);return(0,$.jsx)(e?I.Slot:"h1",{ref:c,className:m,style:{"--cocso-display-color":l(t),"--cocso-display-weight":C(n),...i},...s})}),Re=Object.assign(ye,{displayName:"Display"});var _=u(require("react"),1),V=require("@radix-ui/react-slot");var G=require("react/jsx-runtime"),ve=_.forwardRef(({asChild:e=!1,size:o="md",color:t,weight:n="bold",className:r,style:i,...s},c)=>{let m=a("cocso-heading",{size:o},[],r);return(0,G.jsx)(e?V.Slot:"h2",{ref:c,className:m,style:{"--cocso-heading-color":l(t),"--cocso-heading-weight":C(n),...i},...s})}),Pe=Object.assign(ve,{displayName:"Heading"});var K=u(require("react"),1),q=require("@radix-ui/react-slot");var J=require("react/jsx-runtime"),ke=K.forwardRef(({asChild:e=!1,size:o="md",color:t,weight:n="normal",className:r,style:i,...s},c)=>{let m=a("cocso-label",{size:o},[],r);return(0,J.jsx)(e?q.Slot:"label",{ref:c,className:m,style:{"--cocso-label-color":l(t),"--cocso-label-weight":C(n),...i},...s})}),L=Object.assign(ke,{displayName:"Label"});var Q=u(require("react"),1),w=u(require("@radix-ui/react-checkbox"),1);var d=require("react/jsx-runtime"),Ne=Q.forwardRef(({id:e,size:o="md",status:t,onChange:n,label:r,disabled:i=!1,className:s,...c},p)=>{let m={size:o,disabled:i,status:t},f=[...i?[{status:t,disabled:i}]:[]],P=a("cocso-checkbox",m,f,s),T=g=>{if(!i){let y;g===!0?y="on":g==="indeterminate"?y="intermediate":y="off",n(y)}};return(0,d.jsxs)("div",{className:"cocso-checkbox-wrapper",children:[(0,d.jsxs)(w.Root,{ref:p,id:e,className:P,checked:(()=>{switch(t){case"on":return!0;case"intermediate":return"indeterminate";case"off":default:return!1}})(),onCheckedChange:T,disabled:i,...c,children:[(0,d.jsx)(w.Indicator,{className:"cocso-checkbox-indicator",style:{opacity:t==="on"?1:0},children:(0,d.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,d.jsx)("path",{d:"M20 6 9 17l-5-5"})})}),(0,d.jsx)("div",{className:"cocso-checkbox-indicator",style:{opacity:t==="intermediate"?1:0},children:(0,d.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:(0,d.jsx)("path",{d:"M5 12h14"})})})]}),r&&(0,d.jsx)(L,{className:a("cocso-checkbox-label",m),size:o,htmlFor:e,children:r})]})}),we=Object.assign(Ne,{displayName:"Checkbox"});
package/lib/index.d.ts CHANGED
@@ -1,4 +1,8 @@
1
- export * from './primitive';
1
+ export * from './components/Accordion';
2
2
  export * from './components/Body';
3
+ export * from './components/Button';
3
4
  export * from './components/Display';
4
5
  export * from './components/Heading';
6
+ export * from './components/Label';
7
+ export * from './components/Checkbox';
8
+ export * from './components/Spinner';
package/lib/index.js CHANGED
@@ -1 +1 @@
1
- import{Slot as y}from"@radix-ui/react-slot";import*as d from"react";import{jsx as R}from"react/jsx-runtime";function e(t){let o=d.forwardRef((r,a)=>{let{asChild:n,...i}=r;return R(n?y:t,{...i,ref:a})});return o.displayName=`Primitive.${t}`,o}var $={div:e("div"),span:e("span"),button:e("button"),input:e("input"),form:e("form"),label:e("label"),p:e("p"),h1:e("h1"),h2:e("h2"),h3:e("h3"),h4:e("h4"),h5:e("h5"),h6:e("h6"),section:e("section"),article:e("article"),header:e("header"),footer:e("footer"),main:e("main"),nav:e("nav"),aside:e("aside"),ul:e("ul"),ol:e("ol"),li:e("li"),img:e("img"),a:e("a"),strong:e("strong"),em:e("em"),small:e("small"),table:e("table"),thead:e("thead"),tbody:e("tbody"),tr:e("tr"),td:e("td"),th:e("th")};import*as m from"react";import{jsx as g}from"react/jsx-runtime";function x(t){if(t)return`var(--color-${t.replace(".","-")})`}var u=m.forwardRef(({as:t="p",size:o="md",color:r="",fontWeight:a="normal",style:n,className:i,...s},p)=>{let l=t,h=`text-body text-body-${o}${a==="bold"?"-bold":""} ${i}`;return g(l,{ref:p,className:h,style:{"--text-color":x(r),...n},...s})});u.displayName="Body";import*as c from"react";import{jsx as C}from"react/jsx-runtime";function P(t){if(t)return`var(--color-${t.replace(".","-")})`}var b=c.forwardRef(({as:t="h1",size:o="md",color:r="",style:a,className:n,...i},s)=>{let p=t,l=`text-display text-display-${o} ${n}`;return C(p,{ref:s,className:l,style:{"--text-color":P(r),...a},...i})});b.displayName="Display";import*as f from"react";import{jsx as T}from"react/jsx-runtime";function E(t){if(t)return`var(--color-${t.replace(".","-")})`}var H=f.forwardRef(({as:t="h2",size:o="md",color:r="",style:a,className:n,...i},s)=>{let p=t,l=`text-heading text-heading-${o} ${n}`;return T(p,{ref:s,className:l,style:{"--text-color":E(r),...a},...i})});H.displayName="Heading";export{u as Body,b as Display,H as Heading,$ as Primitive,e as createPrimitive};
1
+ import*as g from"@radix-ui/react-accordion";import{forwardRef as k}from"react";var _=(...e)=>e.filter(Boolean).join(" ").trim(),a=(e,o,t=[],...r)=>{let n=Object.entries(o).filter(([,s])=>s!==!1&&s!==null&&s!==void 0).map(([s,c])=>`${e}--${s}_${c}`).join(" "),i=t.filter(s=>Object.entries(s).every(([c,p])=>o[c]===p)).map(s=>{let c=Object.entries(s).map(([p,m])=>`${p}_${m}`).join("-");return`${e}--${c}`}).join(" ");return _(e,n,i,...r)};import{Slottable as V}from"@radix-ui/react-slot";import{jsx as b,jsxs as J}from"react/jsx-runtime";var G=k(({className:e,...o},t)=>{let r=a("cocso-accordion-item",{},[],e);return b(g.Item,{ref:t,className:r,...o})}),K=k(({className:e,children:o,chevron:t=!0,...r},n)=>{let i=a("cocso-accordion-trigger",{},[],e);return b(g.Trigger,{ref:n,className:i,...r,children:J(V,{children:[o,t&&b("div",{className:"cocso-accordion-chevron",children:b("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:b("path",{d:"m6 9 6 6 6-6"})})})]})})}),q=k(({className:e,...o},t)=>{let r=a("cocso-accordion-content",{},[],e);return b(g.Content,{ref:t,className:r,...o})}),ve=Object.assign(g.Root,{Item:G,Header:g.Header,Trigger:K,Content:q});import*as S from"react";import{Slot as Q}from"@radix-ui/react-slot";function l(e){if(e)return e.includes(".")?`var(--color-${e.replace(/\./g,"-")})`:e}var T={thin:"100",extralight:"200",light:"300",normal:"400",medium:"500",semibold:"600",bold:"700",extrabold:"800",black:"900"};function h(e){if(e)return e in T?T[e]:e}import{jsx as X}from"react/jsx-runtime";var U=S.forwardRef(({asChild:e=!1,size:o="md",color:t,weight:r="normal",className:n,style:i,...s},c)=>{let m=a("cocso-body",{size:o},[],n);return X(e?Q:"p",{ref:c,className:m,style:{"--cocso-body-color":l(t),"--cocso-body-weight":h(r),...i},...s})}),Be=Object.assign(U,{displayName:"Body"});import*as y from"react";import{Slot as oe}from"@radix-ui/react-slot";import*as W from"react";import{jsx as N,jsxs as ee}from"react/jsx-runtime";var Y=["div"],Z=W.forwardRef(({as:e=Y[0],size:o="md",color:t="palette.primary-500",bg:r="palette.gray-200",className:n,style:i,...s},c)=>{let p=e,d=a("cocso-spinner",{size:o},[],n);return N(p,{ref:c,className:d,style:{"--cocso-spinner-bg":l(r),"--cocso-spinner-color":l(t),...i},...s,children:ee("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[N("circle",{className:"opacity-25",cx:"12",cy:"12",r:"9",stroke:"var(--cocso-spinner-bg, currentColor)",strokeWidth:"3"}),N("path",{className:"opacity-75",fill:"var(--cocso-spinner-color, currentColor)",d:"M12 2a10 10 0 0110 10 10 10 0 01-5 8.66l-1-1.73a8 8 0 004-6.93 8 8 0 00-8-8V2z"})]})})}),L=Object.assign(Z,{displayName:"Spinner"});import{jsx as B}from"react/jsx-runtime";var te=e=>({"2xs":"xs",xs:"xs",sm:"xs",md:"sm",lg:"md",xl:"md"})[e],re=y.forwardRef(({asChild:e=!1,variant:o="primary",size:t="md",disabled:r=!1,loading:n=!1,color:i,weight:s="normal",className:c,style:p,children:m,onClick:d,onKeyDown:R,...P},w)=>{let f=r||n,x=y.useCallback(C=>{if(f){C.preventDefault();return}d?.(C)},[f,d]),z=y.useCallback(C=>{(C.key==="Enter"||C.key===" ")&&(C.preventDefault(),f||C.currentTarget.click()),R?.(C)},[f,R]),D={variant:o,size:t,loading:n,disabled:f},j=[...r?[{variant:o,disabled:r}]:[],...n?[{variant:o,loading:n}]:[]],I=a("cocso-button",D,j,c),$={"--cocso-button-color":l(i),"--cocso-button-weight":h(s),...p};return B(e?oe:"button",{ref:w,className:I,onClick:x,onKeyDown:z,role:"button",disabled:f,"aria-disabled":f,"aria-busy":n,style:$,...P,children:n?B(L,{className:"cocso-button-spinner",size:te(t),color:"currentColor"}):m})}),Ke=Object.assign(re,{displayName:"Button"});import*as E from"react";import{Slot as ne}from"@radix-ui/react-slot";import{jsx as ie}from"react/jsx-runtime";var se=E.forwardRef(({asChild:e=!1,size:o="md",color:t,weight:r="bold",className:n,style:i,...s},c)=>{let m=a("cocso-display",{size:o},[],n);return ie(e?ne:"h1",{ref:c,className:m,style:{"--cocso-display-color":l(t),"--cocso-display-weight":h(r),...i},...s})}),eo=Object.assign(se,{displayName:"Display"});import*as F from"react";import{Slot as ce}from"@radix-ui/react-slot";import{jsx as me}from"react/jsx-runtime";var ae=F.forwardRef(({asChild:e=!1,size:o="md",color:t,weight:r="bold",className:n,style:i,...s},c)=>{let m=a("cocso-heading",{size:o},[],n);return me(e?ce:"h2",{ref:c,className:m,style:{"--cocso-heading-color":l(t),"--cocso-heading-weight":h(r),...i},...s})}),ao=Object.assign(ae,{displayName:"Heading"});import*as A from"react";import{Slot as pe}from"@radix-ui/react-slot";import{jsx as de}from"react/jsx-runtime";var le=A.forwardRef(({asChild:e=!1,size:o="md",color:t,weight:r="normal",className:n,style:i,...s},c)=>{let m=a("cocso-label",{size:o},[],n);return de(e?pe:"label",{ref:c,className:m,style:{"--cocso-label-color":l(t),"--cocso-label-weight":h(r),...i},...s})}),H=Object.assign(le,{displayName:"Label"});import*as M from"react";import*as v from"@radix-ui/react-checkbox";import{jsx as u,jsxs as O}from"react/jsx-runtime";var fe=M.forwardRef(({id:e,size:o="md",status:t,onChange:r,label:n,disabled:i=!1,className:s,...c},p)=>{let m={size:o,disabled:i,status:t},d=[...i?[{status:t,disabled:i}]:[]],R=a("cocso-checkbox",m,d,s),P=f=>{if(!i){let x;f===!0?x="on":f==="indeterminate"?x="intermediate":x="off",r(x)}};return O("div",{className:"cocso-checkbox-wrapper",children:[O(v.Root,{ref:p,id:e,className:R,checked:(()=>{switch(t){case"on":return!0;case"intermediate":return"indeterminate";case"off":default:return!1}})(),onCheckedChange:P,disabled:i,...c,children:[u(v.Indicator,{className:"cocso-checkbox-indicator",style:{opacity:t==="on"?1:0},children:u("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:u("path",{d:"M20 6 9 17l-5-5"})})}),u("div",{className:"cocso-checkbox-indicator",style:{opacity:t==="intermediate"?1:0},children:u("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:u("path",{d:"M5 12h14"})})})]}),n&&u(H,{className:a("cocso-checkbox-label",m),size:o,htmlFor:e,children:n})]})}),Po=Object.assign(fe,{displayName:"Checkbox"});export{ve as Accordion,Be as Body,Ke as Button,Po as Checkbox,eo as Display,ao as Heading,H as Label,L as Spinner};
@@ -0,0 +1,2 @@
1
+ export declare const cn: (...classes: (string | undefined | null | false)[]) => string;
2
+ export declare const createClassName: (baseClass: string, variants: Record<string, any>, compoundVariants?: Record<string, any>[], ...additionalClasses: (string | undefined | null | false)[]) => string;
@@ -0,0 +1,15 @@
1
+ export declare function createColor(token: string | undefined): string | undefined;
2
+ declare const FONT_WEIGHT_MAP: {
3
+ readonly thin: "100";
4
+ readonly extralight: "200";
5
+ readonly light: "300";
6
+ readonly normal: "400";
7
+ readonly medium: "500";
8
+ readonly semibold: "600";
9
+ readonly bold: "700";
10
+ readonly extrabold: "800";
11
+ readonly black: "900";
12
+ };
13
+ export type FontWeightToken = keyof typeof FONT_WEIGHT_MAP;
14
+ export declare function createFontWeight(token: string | undefined): string | undefined;
15
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocso-ui/react",
3
- "version": "0.0.1-beta.2",
3
+ "version": "0.0.1-beta.21",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/cocso/cocso-ui.git",
@@ -25,17 +25,19 @@
25
25
  "lib"
26
26
  ],
27
27
  "dependencies": {
28
+ "@radix-ui/react-accordion": "^1.2.11",
29
+ "@radix-ui/react-checkbox": "^1.3.2",
28
30
  "@radix-ui/react-slot": "^1.2.3"
29
31
  },
30
32
  "peerDependencies": {
31
- "react": "^18 || ^19",
32
- "react-dom": "^18 || ^19"
33
+ "react": "^19.1.0",
34
+ "react-dom": "^19.1.0"
33
35
  },
34
36
  "devDependencies": {
35
- "@types/react": "^19",
36
- "@types/react-dom": "^19",
37
- "esbuild": "^0.24.0",
38
- "typescript": "^5.0.0"
37
+ "@types/react": "^19.1.8",
38
+ "@types/react-dom": "^19.1.6",
39
+ "esbuild": "^0.25.6",
40
+ "typescript": "^5.8.3"
39
41
  },
40
42
  "publishConfig": {
41
43
  "access": "public"
@@ -1,44 +0,0 @@
1
- import * as React from 'react';
2
- export interface PrimitiveProps {
3
- asChild?: boolean;
4
- }
5
- type PropsWithRef<E extends React.ElementType> = React.ComponentPropsWithRef<E> & PrimitiveProps;
6
- declare function createPrimitive<E extends React.ElementType>(element: E): React.ForwardRefExoticComponent<PropsWithRef<E>>;
7
- declare const Primitive: {
8
- div: React.ForwardRefExoticComponent<PropsWithRef<"div">>;
9
- span: React.ForwardRefExoticComponent<PropsWithRef<"span">>;
10
- button: React.ForwardRefExoticComponent<PropsWithRef<"button">>;
11
- input: React.ForwardRefExoticComponent<PropsWithRef<"input">>;
12
- form: React.ForwardRefExoticComponent<PropsWithRef<"form">>;
13
- label: React.ForwardRefExoticComponent<PropsWithRef<"label">>;
14
- p: React.ForwardRefExoticComponent<PropsWithRef<"p">>;
15
- h1: React.ForwardRefExoticComponent<PropsWithRef<"h1">>;
16
- h2: React.ForwardRefExoticComponent<PropsWithRef<"h2">>;
17
- h3: React.ForwardRefExoticComponent<PropsWithRef<"h3">>;
18
- h4: React.ForwardRefExoticComponent<PropsWithRef<"h4">>;
19
- h5: React.ForwardRefExoticComponent<PropsWithRef<"h5">>;
20
- h6: React.ForwardRefExoticComponent<PropsWithRef<"h6">>;
21
- section: React.ForwardRefExoticComponent<PropsWithRef<"section">>;
22
- article: React.ForwardRefExoticComponent<PropsWithRef<"article">>;
23
- header: React.ForwardRefExoticComponent<PropsWithRef<"header">>;
24
- footer: React.ForwardRefExoticComponent<PropsWithRef<"footer">>;
25
- main: React.ForwardRefExoticComponent<PropsWithRef<"main">>;
26
- nav: React.ForwardRefExoticComponent<PropsWithRef<"nav">>;
27
- aside: React.ForwardRefExoticComponent<PropsWithRef<"aside">>;
28
- ul: React.ForwardRefExoticComponent<PropsWithRef<"ul">>;
29
- ol: React.ForwardRefExoticComponent<PropsWithRef<"ol">>;
30
- li: React.ForwardRefExoticComponent<PropsWithRef<"li">>;
31
- img: React.ForwardRefExoticComponent<PropsWithRef<"img">>;
32
- a: React.ForwardRefExoticComponent<PropsWithRef<"a">>;
33
- strong: React.ForwardRefExoticComponent<PropsWithRef<"strong">>;
34
- em: React.ForwardRefExoticComponent<PropsWithRef<"em">>;
35
- small: React.ForwardRefExoticComponent<PropsWithRef<"small">>;
36
- table: React.ForwardRefExoticComponent<PropsWithRef<"table">>;
37
- thead: React.ForwardRefExoticComponent<PropsWithRef<"thead">>;
38
- tbody: React.ForwardRefExoticComponent<PropsWithRef<"tbody">>;
39
- tr: React.ForwardRefExoticComponent<PropsWithRef<"tr">>;
40
- td: React.ForwardRefExoticComponent<PropsWithRef<"td">>;
41
- th: React.ForwardRefExoticComponent<PropsWithRef<"th">>;
42
- };
43
- export { createPrimitive, Primitive };
44
- export type { PropsWithRef };