@cocso-ui/react 0.0.1-beta.14 → 0.0.1-beta.16

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.
@@ -0,0 +1,7 @@
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<AccordionPrimitive.AccordionItemProps & import("react").RefAttributes<HTMLDivElement>>;
4
+ Header: import("react").ForwardRefExoticComponent<AccordionPrimitive.AccordionHeaderProps & import("react").RefAttributes<HTMLHeadingElement>>;
5
+ Trigger: import("react").ForwardRefExoticComponent<AccordionPrimitive.AccordionTriggerProps & import("react").RefAttributes<HTMLButtonElement>>;
6
+ Content: import("react").ForwardRefExoticComponent<AccordionPrimitive.AccordionContentProps & import("react").RefAttributes<HTMLDivElement>>;
7
+ };
@@ -0,0 +1 @@
1
+ export * from './Accordion';
@@ -1,15 +1,16 @@
1
1
  import * as React from 'react';
2
2
  import { type FontWeightToken } from '../../utils/token';
3
- declare const tags: readonly ["p", "a", "span", "div", "label", "li", "td", "th", "figcaption", "blockquote", "cite"];
4
- type Element = (typeof tags)[number];
5
- type Default = (typeof tags)[0];
6
- export type BodyProps<T extends Element = Default> = {
7
- as?: T;
3
+ export type BodyProps = {
4
+ asChild?: boolean;
8
5
  size?: 'lg' | 'md' | 'sm' | 'xs';
9
6
  color?: string;
10
7
  weight?: FontWeightToken;
11
- } & React.ComponentPropsWithoutRef<T>;
12
- export declare const Body: React.ForwardRefExoticComponent<BodyProps<"p" | "a" | "span" | "div" | "label" | "li" | "td" | "th" | "figcaption" | "blockquote" | "cite"> & React.RefAttributes<HTMLElement>> & {
8
+ } & React.ComponentPropsWithoutRef<'p'>;
9
+ export declare const Body: React.ForwardRefExoticComponent<{
10
+ asChild?: boolean;
11
+ size?: "lg" | "md" | "sm" | "xs";
12
+ color?: string;
13
+ weight?: FontWeightToken;
14
+ } & Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>, "ref"> & React.RefAttributes<HTMLParagraphElement>> & {
13
15
  displayName: string;
14
16
  };
15
- export {};
@@ -1,19 +1,16 @@
1
1
  import * as React from 'react';
2
2
  import { type FontWeightToken } from '../../utils/token';
3
- declare const tags: readonly ["button"];
4
- type Element = (typeof tags)[number];
5
- type Default = (typeof tags)[0];
6
- export type ButtonProps<T extends Element = Default> = {
7
- as?: T;
3
+ export type ButtonProps = {
4
+ asChild?: boolean;
8
5
  variant?: 'primary' | 'secondary' | 'tertiary' | 'danger' | 'success' | 'text';
9
6
  size?: 'xl' | 'lg' | 'md' | 'sm' | 'xs' | '2xs';
10
7
  disabled?: boolean;
11
8
  loading?: boolean;
12
9
  color?: string;
13
10
  weight?: FontWeightToken;
14
- } & React.ComponentPropsWithoutRef<T>;
11
+ } & React.ComponentPropsWithoutRef<'button'>;
15
12
  export declare const Button: React.ForwardRefExoticComponent<{
16
- as?: "button" | undefined;
13
+ asChild?: boolean;
17
14
  variant?: "primary" | "secondary" | "tertiary" | "danger" | "success" | "text";
18
15
  size?: "xl" | "lg" | "md" | "sm" | "xs" | "2xs";
19
16
  disabled?: boolean;
@@ -23,4 +20,3 @@ export declare const Button: React.ForwardRefExoticComponent<{
23
20
  } & Omit<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & React.RefAttributes<HTMLButtonElement>> & {
24
21
  displayName: string;
25
22
  };
26
- export {};
@@ -1,20 +1,21 @@
1
1
  import * as React from 'react';
2
+ import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
2
3
  export type CheckboxStatus = 'on' | 'off' | 'intermediate';
3
4
  export type CheckboxProps = {
4
- id: string;
5
+ id?: string;
5
6
  size?: 'lg' | 'md' | 'sm';
6
7
  status: CheckboxStatus;
7
8
  onChange: (next: CheckboxStatus) => void;
8
9
  label?: string;
9
10
  disabled?: boolean;
10
- } & Omit<React.ComponentPropsWithoutRef<'div'>, 'id'>;
11
+ } & Omit<React.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root>, 'checked' | 'onCheckedChange'>;
11
12
  export declare const Checkbox: React.ForwardRefExoticComponent<{
12
- id: string;
13
+ id?: string;
13
14
  size?: "lg" | "md" | "sm";
14
15
  status: CheckboxStatus;
15
16
  onChange: (next: CheckboxStatus) => void;
16
17
  label?: string;
17
18
  disabled?: boolean;
18
- } & Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "id"> & React.RefAttributes<HTMLDivElement>> & {
19
+ } & Omit<Omit<CheckboxPrimitive.CheckboxProps & import("react").RefAttributes<HTMLButtonElement>, "ref">, "checked" | "onCheckedChange"> & React.RefAttributes<never>> & {
19
20
  displayName: string;
20
21
  };
@@ -1,20 +1,16 @@
1
1
  import * as React from 'react';
2
2
  import { type FontWeightToken } from '../../utils/token';
3
- declare const tags: readonly ["h1", "h2", "h3", "h4", "h5", "h6"];
4
- type Element = (typeof tags)[number];
5
- type Default = (typeof tags)[0];
6
- export type DisplayProps<T extends Element = Default> = {
7
- as?: T;
3
+ export type DisplayProps = {
4
+ asChild?: boolean;
8
5
  size?: 'lg' | 'md' | 'sm';
9
6
  color?: string;
10
7
  weight?: FontWeightToken;
11
- } & React.ComponentPropsWithoutRef<T>;
8
+ } & React.ComponentPropsWithoutRef<'h1'>;
12
9
  export declare const Display: React.ForwardRefExoticComponent<{
13
- as?: "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | undefined;
10
+ asChild?: boolean;
14
11
  size?: "lg" | "md" | "sm";
15
12
  color?: string;
16
13
  weight?: FontWeightToken;
17
14
  } & Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>, "ref"> & React.RefAttributes<HTMLHeadingElement>> & {
18
15
  displayName: string;
19
16
  };
20
- export {};
@@ -1,20 +1,16 @@
1
1
  import * as React from 'react';
2
2
  import { type FontWeightToken } from '../../utils/token';
3
- declare const tags: readonly ["h1", "h2", "h3", "h4", "h5", "h6"];
4
- type Element = (typeof tags)[number];
5
- type Default = (typeof tags)[1];
6
- export type HeadingProps<T extends Element = Default> = {
7
- as?: T;
3
+ export type HeadingProps = {
4
+ asChild?: boolean;
8
5
  size?: 'xl' | 'lg' | 'md' | 'sm' | 'xs' | '2xs';
9
6
  color?: string;
10
7
  weight?: FontWeightToken;
11
- } & React.ComponentPropsWithoutRef<T>;
8
+ } & React.ComponentPropsWithoutRef<'h2'>;
12
9
  export declare const Heading: React.ForwardRefExoticComponent<{
13
- as?: "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | undefined;
10
+ asChild?: boolean;
14
11
  size?: "xl" | "lg" | "md" | "sm" | "xs" | "2xs";
15
12
  color?: string;
16
13
  weight?: FontWeightToken;
17
14
  } & Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>, "ref"> & React.RefAttributes<HTMLHeadingElement>> & {
18
15
  displayName: string;
19
16
  };
20
- export {};
@@ -1,15 +1,16 @@
1
1
  import * as React from 'react';
2
2
  import { type FontWeightToken } from '../../utils/token';
3
- declare const tags: readonly ["label", "p", "a", "span", "div", "li", "td", "th", "figcaption", "blockquote", "cite"];
4
- type Element = (typeof tags)[number];
5
- type Default = (typeof tags)[0];
6
- export type LabelProps<T extends Element = Default> = {
7
- as?: T;
3
+ export type LabelProps = {
4
+ asChild?: boolean;
8
5
  size?: 'lg' | 'md' | 'sm' | 'xs';
9
6
  color?: string;
10
7
  weight?: FontWeightToken;
11
- } & React.ComponentPropsWithoutRef<T>;
12
- export declare const Label: React.ForwardRefExoticComponent<LabelProps<"p" | "a" | "span" | "div" | "label" | "li" | "td" | "th" | "figcaption" | "blockquote" | "cite"> & React.RefAttributes<HTMLElement>> & {
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>> & {
13
15
  displayName: string;
14
16
  };
15
- export {};
package/lib/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var A=Object.create;var k=Object.defineProperty;var G=Object.getOwnPropertyDescriptor;var J=Object.getOwnPropertyNames;var Q=Object.getPrototypeOf,U=Object.prototype.hasOwnProperty;var X=(e,t)=>{for(var o in t)k(e,o,{get:t[o],enumerable:!0})},P=(e,t,o,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of J(t))!U.call(e,n)&&n!==o&&k(e,n,{get:()=>t[n],enumerable:!(a=G(t,n))||a.enumerable});return e};var u=(e,t,o)=>(o=e!=null?A(Q(e)):{},P(t||!e||!e.__esModule?k(o,"default",{value:e,enumerable:!0}):o,e)),Y=e=>P(k({},"__esModule",{value:!0}),e);var be={};X(be,{Body:()=>oe,Button:()=>ie,Checkbox:()=>xe,Display:()=>me,Heading:()=>ge,Label:()=>v,Spinner:()=>E});module.exports=Y(be);var D=u(require("react"),1);function m(e){if(e)return e.includes(".")?`var(--color-${e.replace(/\./g,"-")})`:e}var W={thin:"100",extralight:"200",light:"300",normal:"400",medium:"500",semibold:"600",bold:"700",extrabold:"800",black:"900"};function g(e){if(e)return e in W?W[e]:e}var Z=(...e)=>e.filter(Boolean).join(" ").trim(),l=(e,t,o=[],...a)=>{let n=Object.entries(t).filter(([,s])=>s!==!1&&s!==null&&s!==void 0).map(([s,c])=>`${e}--${s}_${c}`).join(" "),r=o.filter(s=>Object.entries(s).every(([c,i])=>t[c]===i)).map(s=>{let c=Object.entries(s).map(([i,d])=>`${i}_${d}`).join("-");return`${e}--${c}`}).join(" ");return Z(e,n,r,...a)};var S=require("react/jsx-runtime"),ee=["p","a","span","div","label","li","td","th","figcaption","blockquote","cite"],te=D.forwardRef(({as:e=ee[0],size:t="md",color:o,weight:a="normal",className:n,style:r,...s},c)=>{let i=e,p=l("cocso-body",{size:t},[],n);return(0,S.jsx)(i,{ref:c,className:p,style:{"--cocso-body-color":m(o),"--cocso-body-weight":g(a),...r},...s})}),oe=Object.assign(te,{displayName:"Body"});var T=u(require("react"),1);var F=u(require("react"),1);var b=require("react/jsx-runtime"),ne=["div"],se=F.forwardRef(({as:e=ne[0],size:t="md",color:o="palette.primary-500",bg:a="palette.gray-200",className:n,style:r,...s},c)=>{let i=e,p=l("cocso-spinner",{size:t},[],n);return(0,b.jsx)(i,{ref:c,className:p,style:{"--cocso-spinner-bg":m(a),"--cocso-spinner-color":m(o),...r},...s,children:(0,b.jsxs)("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,b.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"9",stroke:"var(--cocso-spinner-bg, currentColor)",strokeWidth:"3"}),(0,b.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"})]})})}),E=Object.assign(se,{displayName:"Spinner"});var w=require("react/jsx-runtime"),re=["button"],ae=e=>({"2xs":"xs",xs:"xs",sm:"xs",md:"sm",lg:"md",xl:"md"})[e],ce=T.forwardRef(({as:e=re[0],variant:t="primary",size:o="md",disabled:a=!1,loading:n=!1,color:r,weight:s="normal",className:c,style:i,children:d,onClick:p,onKeyDown:R,...C},N)=>{let x=e,y=a||n,$=T.useCallback(h=>{if(y){h.preventDefault();return}p?.(h)},[y,p]),K=T.useCallback(h=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),y||h.currentTarget.click()),R?.(h)},[y,R]),_={variant:t,size:o,loading:n,disabled:y},I=[...a?[{variant:t,disabled:a}]:[],...n?[{variant:t,loading:n}]:[]],V=l("cocso-button",_,I,c),q={"--cocso-button-color":m(r),"--cocso-button-weight":g(s),...i};return(0,w.jsx)(x,{ref:N,className:V,onClick:$,onKeyDown:K,role:"button",disabled:y,"aria-disabled":y,"aria-busy":n,style:q,...C,children:n?(0,w.jsx)(E,{className:"cocso-button-spinner",size:ae(o),color:"currentColor"}):d})}),ie=Object.assign(ce,{displayName:"Button"});var B=u(require("react"),1);var O=require("react/jsx-runtime"),le=["h1","h2","h3","h4","h5","h6"],pe=B.forwardRef(({as:e=le[0],size:t="md",color:o,weight:a="bold",className:n,style:r,...s},c)=>{let i=e,p=l("cocso-display",{size:t},[],n);return(0,O.jsx)(i,{ref:c,className:p,style:{"--cocso-display-color":m(o),"--cocso-display-weight":g(a),...r},...s})}),me=Object.assign(pe,{displayName:"Display"});var L=u(require("react"),1);var z=require("react/jsx-runtime"),fe=["h1","h2","h3","h4","h5","h6"],de=L.forwardRef(({as:e=fe[1],size:t="md",color:o,weight:a="bold",className:n,style:r,...s},c)=>{let i=e,p=l("cocso-heading",{size:t},[],n);return(0,z.jsx)(i,{ref:c,className:p,style:{"--cocso-heading-color":m(o),"--cocso-heading-weight":g(a),...r},...s})}),ge=Object.assign(de,{displayName:"Heading"});var M=u(require("react"),1);var H=require("react/jsx-runtime"),he=["label","p","a","span","div","li","td","th","figcaption","blockquote","cite"],ye=M.forwardRef(({as:e=he[0],size:t="md",color:o,weight:a="normal",className:n,style:r,...s},c)=>{let i=e,p=l("cocso-label",{size:t},[],n);return(0,H.jsx)(i,{ref:c,className:p,style:{"--cocso-label-color":m(o),"--cocso-label-weight":g(a),...r},...s})}),v=Object.assign(ye,{displayName:"Label"});var j=u(require("react"),1);var f=require("react/jsx-runtime"),ue=j.forwardRef(({id:e,size:t="md",status:o,onChange:a,label:n,disabled:r=!1,className:s,...c},i)=>{let d={size:t,disabled:r,status:o},p=[...r?[{status:o,disabled:r}]:[]],R=l("cocso-checkbox-inner",d,p,s),C=()=>{r||a(o==="on"?"off":"on")};return(0,f.jsxs)("div",{ref:i,className:"cocso-checkbox",tabIndex:r?-1:0,role:"checkbox","aria-checked":o==="on"?"true":o==="intermediate"?"mixed":"false","aria-disabled":r,onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),C())},...c,children:[(0,f.jsxs)("div",{className:R,onClick:C,children:[(0,f.jsx)("div",{className:"cocso-checkbox-icon",style:{opacity:o==="on"?1:0},children:(0,f.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,f.jsx)("path",{d:"M20 6 9 17l-5-5"})})}),(0,f.jsx)("div",{className:"cocso-checkbox-icon",style:{opacity:o==="intermediate"?1:0},children:(0,f.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,f.jsx)("path",{d:"M5 12h14"})})}),(0,f.jsx)("input",{type:"checkbox",id:e,checked:o==="on",onChange:C,disabled:r})]}),n&&(0,f.jsx)(v,{className:l("cocso-checkbox-label",d),htmlFor:e,size:t,children:n})]})}),xe=Object.assign(ue,{displayName:"Checkbox"});
1
+ "use strict";var Y=Object.create;var P=Object.defineProperty;var Z=Object.getOwnPropertyDescriptor;var ee=Object.getOwnPropertyNames;var oe=Object.getPrototypeOf,te=Object.prototype.hasOwnProperty;var re=(e,o)=>{for(var t in o)P(e,t,{get:o[t],enumerable:!0})},E=(e,o,t,n)=>{if(o&&typeof o=="object"||typeof o=="function")for(let r of ee(o))!te.call(e,r)&&r!==t&&P(e,r,{get:()=>o[r],enumerable:!(n=Z(o,r))||n.enumerable});return e};var x=(e,o,t)=>(t=e!=null?Y(oe(e)):{},E(o||!e||!e.__esModule?P(t,"default",{value:e,enumerable:!0}):t,e)),se=e=>E(P({},"__esModule",{value:!0}),e);var Re={};re(Re,{Accordion:()=>ne,Body:()=>ce,Button:()=>fe,Checkbox:()=>ye,Display:()=>he,Heading:()=>xe,Label:()=>T,Spinner:()=>N});module.exports=se(Re);var h=x(require("@radix-ui/react-accordion"),1),ne=Object.assign(h.Root,{Item:h.Item,Header:h.Header,Trigger:h.Trigger,Content:h.Content});var B=x(require("react"),1),L=require("@radix-ui/react-slot");function p(e){if(e)return e.includes(".")?`var(--color-${e.replace(/\./g,"-")})`:e}var F={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 F?F[e]:e}var ae=(...e)=>e.filter(Boolean).join(" ").trim(),m=(e,o,t=[],...n)=>{let r=Object.entries(o).filter(([,s])=>s!==!1&&s!==null&&s!==void 0).map(([s,i])=>`${e}--${s}_${i}`).join(" "),a=t.filter(s=>Object.entries(s).every(([i,l])=>o[i]===l)).map(s=>{let i=Object.entries(s).map(([l,c])=>`${l}_${c}`).join("-");return`${e}--${i}`}).join(" ");return ae(e,r,a,...n)};var H=require("react/jsx-runtime"),ie=B.forwardRef(({asChild:e=!1,size:o="md",color:t,weight:n="normal",className:r,style:a,...s},i)=>{let c=m("cocso-body",{size:o},[],r);return(0,H.jsx)(e?L.Slot:"p",{ref:i,className:c,style:{"--cocso-body-color":p(t),"--cocso-body-weight":C(n),...a},...s})}),ce=Object.assign(ie,{displayName:"Body"});var R=x(require("react"),1),M=require("@radix-ui/react-slot");var O=x(require("react"),1);var y=require("react/jsx-runtime"),me=["div"],le=O.forwardRef(({as:e=me[0],size:o="md",color:t="palette.primary-500",bg:n="palette.gray-200",className:r,style:a,...s},i)=>{let l=e,f=m("cocso-spinner",{size:o},[],r);return(0,y.jsx)(l,{ref:i,className:f,style:{"--cocso-spinner-bg":p(n),"--cocso-spinner-color":p(t),...a},...s,children:(0,y.jsxs)("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,y.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"9",stroke:"var(--cocso-spinner-bg, currentColor)",strokeWidth:"3"}),(0,y.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"})]})})}),N=Object.assign(le,{displayName:"Spinner"});var S=require("react/jsx-runtime"),pe=e=>({"2xs":"xs",xs:"xs",sm:"xs",md:"sm",lg:"md",xl:"md"})[e],de=R.forwardRef(({asChild:e=!1,variant:o="primary",size:t="md",disabled:n=!1,loading:r=!1,color:a,weight:s="normal",className:i,style:l,children:c,onClick:f,onKeyDown:k,...w},W)=>{let g=n||r,b=R.useCallback(u=>{if(g){u.preventDefault();return}f?.(u)},[g,f]),q=R.useCallback(u=>{(u.key==="Enter"||u.key===" ")&&(u.preventDefault(),g||u.currentTarget.click()),k?.(u)},[g,k]),J={variant:o,size:t,loading:r,disabled:g},Q=[...n?[{variant:o,disabled:n}]:[],...r?[{variant:o,loading:r}]:[]],U=m("cocso-button",J,Q,i),X={"--cocso-button-color":p(a),"--cocso-button-weight":C(s),...l};return(0,S.jsx)(e?M.Slot:"button",{ref:W,className:U,onClick:b,onKeyDown:q,role:"button",disabled:g,"aria-disabled":g,"aria-busy":r,style:X,...w,children:r?(0,S.jsx)(N,{className:"cocso-button-spinner",size:pe(t),color:"currentColor"}):c})}),fe=Object.assign(de,{displayName:"Button"});var z=x(require("react"),1),D=require("@radix-ui/react-slot");var j=require("react/jsx-runtime"),ge=z.forwardRef(({asChild:e=!1,size:o="md",color:t,weight:n="bold",className:r,style:a,...s},i)=>{let c=m("cocso-display",{size:o},[],r);return(0,j.jsx)(e?D.Slot:"h1",{ref:i,className:c,style:{"--cocso-display-color":p(t),"--cocso-display-weight":C(n),...a},...s})}),he=Object.assign(ge,{displayName:"Display"});var A=x(require("react"),1),$=require("@radix-ui/react-slot");var I=require("react/jsx-runtime"),Ce=A.forwardRef(({asChild:e=!1,size:o="md",color:t,weight:n="bold",className:r,style:a,...s},i)=>{let c=m("cocso-heading",{size:o},[],r);return(0,I.jsx)(e?$.Slot:"h2",{ref:i,className:c,style:{"--cocso-heading-color":p(t),"--cocso-heading-weight":C(n),...a},...s})}),xe=Object.assign(Ce,{displayName:"Heading"});var _=x(require("react"),1),V=require("@radix-ui/react-slot");var G=require("react/jsx-runtime"),ue=_.forwardRef(({asChild:e=!1,size:o="md",color:t,weight:n="normal",className:r,style:a,...s},i)=>{let c=m("cocso-label",{size:o},[],r);return(0,G.jsx)(e?V.Slot:"label",{ref:i,className:c,style:{"--cocso-label-color":p(t),"--cocso-label-weight":C(n),...a},...s})}),T=Object.assign(ue,{displayName:"Label"});var K=x(require("react"),1),v=x(require("@radix-ui/react-checkbox"),1);var d=require("react/jsx-runtime"),be=K.forwardRef(({id:e,size:o="md",status:t,onChange:n,label:r,disabled:a=!1,className:s,...i},l)=>{let c={size:o,disabled:a,status:t},f=[...a?[{status:t,disabled:a}]:[]],k=m("cocso-checkbox",c,f,s),w=g=>{if(!a){let b;g===!0?b="on":g==="indeterminate"?b="intermediate":b="off",n(b)}};return(0,d.jsxs)("div",{className:"cocso-checkbox-wrapper",children:[(0,d.jsxs)(v.Root,{ref:l,id:e,className:k,checked:(()=>{switch(t){case"on":return!0;case"intermediate":return"indeterminate";case"off":default:return!1}})(),onCheckedChange:w,disabled:a,...i,children:[(0,d.jsx)(v.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)(T,{className:m("cocso-checkbox-label",c),size:o,htmlFor:e,children:r})]})}),ye=Object.assign(be,{displayName:"Checkbox"});
package/lib/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export * from './components/Accordion';
1
2
  export * from './components/Body';
2
3
  export * from './components/Button';
3
4
  export * from './components/Display';
package/lib/index.js CHANGED
@@ -1 +1 @@
1
- import*as E from"react";function m(e){if(e)return e.includes(".")?`var(--color-${e.replace(/\./g,"-")})`:e}var k={thin:"100",extralight:"200",light:"300",normal:"400",medium:"500",semibold:"600",bold:"700",extrabold:"800",black:"900"};function d(e){if(e)return e in k?k[e]:e}var $=(...e)=>e.filter(Boolean).join(" ").trim(),l=(e,r,t=[],...c)=>{let n=Object.entries(r).filter(([,o])=>o!==!1&&o!==null&&o!==void 0).map(([o,a])=>`${e}--${o}_${a}`).join(" "),s=t.filter(o=>Object.entries(o).every(([a,i])=>r[a]===i)).map(o=>{let a=Object.entries(o).map(([i,f])=>`${i}_${f}`).join("-");return`${e}--${a}`}).join(" ");return $(e,n,s,...c)};import{jsx as I}from"react/jsx-runtime";var K=["p","a","span","div","label","li","td","th","figcaption","blockquote","cite"],_=E.forwardRef(({as:e=K[0],size:r="md",color:t,weight:c="normal",className:n,style:s,...o},a)=>{let i=e,p=l("cocso-body",{size:r},[],n);return I(i,{ref:a,className:p,style:{"--cocso-body-color":m(t),"--cocso-body-weight":d(c),...s},...o})}),me=Object.assign(_,{displayName:"Body"});import*as b from"react";import*as w from"react";import{jsx as T,jsxs as A}from"react/jsx-runtime";var V=["div"],q=w.forwardRef(({as:e=V[0],size:r="md",color:t="palette.primary-500",bg:c="palette.gray-200",className:n,style:s,...o},a)=>{let i=e,p=l("cocso-spinner",{size:r},[],n);return T(i,{ref:a,className:p,style:{"--cocso-spinner-bg":m(c),"--cocso-spinner-color":m(t),...s},...o,children:A("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[T("circle",{className:"opacity-25",cx:"12",cy:"12",r:"9",stroke:"var(--cocso-spinner-bg, currentColor)",strokeWidth:"3"}),T("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"})]})})}),v=Object.assign(q,{displayName:"Spinner"});import{jsx as N}from"react/jsx-runtime";var G=["button"],J=e=>({"2xs":"xs",xs:"xs",sm:"xs",md:"sm",lg:"md",xl:"md"})[e],Q=b.forwardRef(({as:e=G[0],variant:r="primary",size:t="md",disabled:c=!1,loading:n=!1,color:s,weight:o="normal",className:a,style:i,children:f,onClick:p,onKeyDown:C,...x},R)=>{let u=e,y=c||n,O=b.useCallback(g=>{if(y){g.preventDefault();return}p?.(g)},[y,p]),L=b.useCallback(g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),y||g.currentTarget.click()),C?.(g)},[y,C]),z={variant:r,size:t,loading:n,disabled:y},M=[...c?[{variant:r,disabled:c}]:[],...n?[{variant:r,loading:n}]:[]],H=l("cocso-button",z,M,a),j={"--cocso-button-color":m(s),"--cocso-button-weight":d(o),...i};return N(u,{ref:R,className:H,onClick:O,onKeyDown:L,role:"button",disabled:y,"aria-disabled":y,"aria-busy":n,style:j,...x,children:n?N(v,{className:"cocso-button-spinner",size:J(t),color:"currentColor"}):f})}),we=Object.assign(Q,{displayName:"Button"});import*as P from"react";import{jsx as Y}from"react/jsx-runtime";var U=["h1","h2","h3","h4","h5","h6"],X=P.forwardRef(({as:e=U[0],size:r="md",color:t,weight:c="bold",className:n,style:s,...o},a)=>{let i=e,p=l("cocso-display",{size:r},[],n);return Y(i,{ref:a,className:p,style:{"--cocso-display-color":m(t),"--cocso-display-weight":d(c),...s},...o})}),Fe=Object.assign(X,{displayName:"Display"});import*as W from"react";import{jsx as te}from"react/jsx-runtime";var Z=["h1","h2","h3","h4","h5","h6"],ee=W.forwardRef(({as:e=Z[1],size:r="md",color:t,weight:c="bold",className:n,style:s,...o},a)=>{let i=e,p=l("cocso-heading",{size:r},[],n);return te(i,{ref:a,className:p,style:{"--cocso-heading-color":m(t),"--cocso-heading-weight":d(c),...s},...o})}),je=Object.assign(ee,{displayName:"Heading"});import*as D from"react";import{jsx as se}from"react/jsx-runtime";var oe=["label","p","a","span","div","li","td","th","figcaption","blockquote","cite"],ne=D.forwardRef(({as:e=oe[0],size:r="md",color:t,weight:c="normal",className:n,style:s,...o},a)=>{let i=e,p=l("cocso-label",{size:r},[],n);return se(i,{ref:a,className:p,style:{"--cocso-label-color":m(t),"--cocso-label-weight":d(c),...s},...o})}),S=Object.assign(ne,{displayName:"Label"});import*as B from"react";import{jsx as h,jsxs as F}from"react/jsx-runtime";var re=B.forwardRef(({id:e,size:r="md",status:t,onChange:c,label:n,disabled:s=!1,className:o,...a},i)=>{let f={size:r,disabled:s,status:t},p=[...s?[{status:t,disabled:s}]:[]],C=l("cocso-checkbox-inner",f,p,o),x=()=>{s||c(t==="on"?"off":"on")};return F("div",{ref:i,className:"cocso-checkbox",tabIndex:s?-1:0,role:"checkbox","aria-checked":t==="on"?"true":t==="intermediate"?"mixed":"false","aria-disabled":s,onKeyDown:u=>{(u.key==="Enter"||u.key===" ")&&(u.preventDefault(),x())},...a,children:[F("div",{className:C,onClick:x,children:[h("div",{className:"cocso-checkbox-icon",style:{opacity:t==="on"?1:0},children:h("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:h("path",{d:"M20 6 9 17l-5-5"})})}),h("div",{className:"cocso-checkbox-icon",style:{opacity:t==="intermediate"?1:0},children:h("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:h("path",{d:"M5 12h14"})})}),h("input",{type:"checkbox",id:e,checked:t==="on",onChange:x,disabled:s})]}),n&&h(S,{className:l("cocso-checkbox-label",f),htmlFor:e,size:r,children:n})]})}),Ye=Object.assign(re,{displayName:"Checkbox"});export{me as Body,we as Button,Ye as Checkbox,Fe as Display,je as Heading,S as Label,v as Spinner};
1
+ import*as g from"@radix-ui/react-accordion";var me=Object.assign(g.Root,{Item:g.Item,Header:g.Header,Trigger:g.Trigger,Content:g.Content});import*as N from"react";import{Slot as I}from"@radix-ui/react-slot";function p(e){if(e)return e.includes(".")?`var(--color-${e.replace(/\./g,"-")})`:e}var w={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 w?w[e]:e}var $=(...e)=>e.filter(Boolean).join(" ").trim(),m=(e,r,s=[],...i)=>{let t=Object.entries(r).filter(([,o])=>o!==!1&&o!==null&&o!==void 0).map(([o,a])=>`${e}--${o}_${a}`).join(" "),n=s.filter(o=>Object.entries(o).every(([a,l])=>r[a]===l)).map(o=>{let a=Object.entries(o).map(([l,c])=>`${l}_${c}`).join("-");return`${e}--${a}`}).join(" ");return $(e,t,n,...i)};import{jsx as V}from"react/jsx-runtime";var _=N.forwardRef(({asChild:e=!1,size:r="md",color:s,weight:i="normal",className:t,style:n,...o},a)=>{let c=m("cocso-body",{size:r},[],t);return V(e?I:"p",{ref:a,className:c,style:{"--cocso-body-color":p(s),"--cocso-body-weight":h(i),...n},...o})}),ue=Object.assign(_,{displayName:"Body"});import*as b from"react";import{Slot as J}from"@radix-ui/react-slot";import*as S from"react";import{jsx as P,jsxs as q}from"react/jsx-runtime";var G=["div"],K=S.forwardRef(({as:e=G[0],size:r="md",color:s="palette.primary-500",bg:i="palette.gray-200",className:t,style:n,...o},a)=>{let l=e,d=m("cocso-spinner",{size:r},[],t);return P(l,{ref:a,className:d,style:{"--cocso-spinner-bg":p(i),"--cocso-spinner-color":p(s),...n},...o,children:q("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[P("circle",{className:"opacity-25",cx:"12",cy:"12",r:"9",stroke:"var(--cocso-spinner-bg, currentColor)",strokeWidth:"3"}),P("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"})]})})}),T=Object.assign(K,{displayName:"Spinner"});import{jsx as W}from"react/jsx-runtime";var Q=e=>({"2xs":"xs",xs:"xs",sm:"xs",md:"sm",lg:"md",xl:"md"})[e],U=b.forwardRef(({asChild:e=!1,variant:r="primary",size:s="md",disabled:i=!1,loading:t=!1,color:n,weight:o="normal",className:a,style:l,children:c,onClick:d,onKeyDown:y,...k},v)=>{let f=i||t,u=b.useCallback(C=>{if(f){C.preventDefault();return}d?.(C)},[f,d]),M=b.useCallback(C=>{(C.key==="Enter"||C.key===" ")&&(C.preventDefault(),f||C.currentTarget.click()),y?.(C)},[f,y]),z={variant:r,size:s,loading:t,disabled:f},D=[...i?[{variant:r,disabled:i}]:[],...t?[{variant:r,loading:t}]:[]],j=m("cocso-button",z,D,a),A={"--cocso-button-color":p(n),"--cocso-button-weight":h(o),...l};return W(e?J:"button",{ref:v,className:j,onClick:u,onKeyDown:M,role:"button",disabled:f,"aria-disabled":f,"aria-busy":t,style:A,...k,children:t?W(T,{className:"cocso-button-spinner",size:Q(s),color:"currentColor"}):c})}),Le=Object.assign(U,{displayName:"Button"});import*as E from"react";import{Slot as X}from"@radix-ui/react-slot";import{jsx as Z}from"react/jsx-runtime";var Y=E.forwardRef(({asChild:e=!1,size:r="md",color:s,weight:i="bold",className:t,style:n,...o},a)=>{let c=m("cocso-display",{size:r},[],t);return Z(e?X:"h1",{ref:a,className:c,style:{"--cocso-display-color":p(s),"--cocso-display-weight":h(i),...n},...o})}),$e=Object.assign(Y,{displayName:"Display"});import*as F from"react";import{Slot as ee}from"@radix-ui/react-slot";import{jsx as te}from"react/jsx-runtime";var oe=F.forwardRef(({asChild:e=!1,size:r="md",color:s,weight:i="bold",className:t,style:n,...o},a)=>{let c=m("cocso-heading",{size:r},[],t);return te(e?ee:"h2",{ref:a,className:c,style:{"--cocso-heading-color":p(s),"--cocso-heading-weight":h(i),...n},...o})}),Qe=Object.assign(oe,{displayName:"Heading"});import*as B from"react";import{Slot as re}from"@radix-ui/react-slot";import{jsx as ne}from"react/jsx-runtime";var se=B.forwardRef(({asChild:e=!1,size:r="md",color:s,weight:i="normal",className:t,style:n,...o},a)=>{let c=m("cocso-label",{size:r},[],t);return ne(e?re:"label",{ref:a,className:c,style:{"--cocso-label-color":p(s),"--cocso-label-weight":h(i),...n},...o})}),L=Object.assign(se,{displayName:"Label"});import*as O from"react";import*as R from"@radix-ui/react-checkbox";import{jsx as x,jsxs as H}from"react/jsx-runtime";var ae=O.forwardRef(({id:e,size:r="md",status:s,onChange:i,label:t,disabled:n=!1,className:o,...a},l)=>{let c={size:r,disabled:n,status:s},d=[...n?[{status:s,disabled:n}]:[]],y=m("cocso-checkbox",c,d,o),k=f=>{if(!n){let u;f===!0?u="on":f==="indeterminate"?u="intermediate":u="off",i(u)}};return H("div",{className:"cocso-checkbox-wrapper",children:[H(R.Root,{ref:l,id:e,className:y,checked:(()=>{switch(s){case"on":return!0;case"intermediate":return"indeterminate";case"off":default:return!1}})(),onCheckedChange:k,disabled:n,...a,children:[x(R.Indicator,{className:"cocso-checkbox-indicator",style:{opacity:s==="on"?1:0},children:x("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:x("path",{d:"M20 6 9 17l-5-5"})})}),x("div",{className:"cocso-checkbox-indicator",style:{opacity:s==="intermediate"?1:0},children:x("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:x("path",{d:"M5 12h14"})})})]}),t&&x(L,{className:m("cocso-checkbox-label",c),size:r,htmlFor:e,children:t})]})}),mo=Object.assign(ae,{displayName:"Checkbox"});export{me as Accordion,ue as Body,Le as Button,mo as Checkbox,$e as Display,Qe as Heading,L as Label,T as Spinner};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocso-ui/react",
3
- "version": "0.0.1-beta.14",
3
+ "version": "0.0.1-beta.16",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/cocso/cocso-ui.git",
@@ -25,7 +25,9 @@
25
25
  "lib"
26
26
  ],
27
27
  "dependencies": {
28
- "@radix-ui/react-checkbox": "^1.3.2"
28
+ "@radix-ui/react-accordion": "^1.2.11",
29
+ "@radix-ui/react-checkbox": "^1.3.2",
30
+ "@radix-ui/react-slot": "^1.2.3"
29
31
  },
30
32
  "peerDependencies": {
31
33
  "react": "^19.1.0",