@jamsrui/switch 0.0.15 → 0.0.17

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/index.d.mts CHANGED
@@ -19,6 +19,15 @@ declare const Switch: ((props: Switch$1.Props) => react_jsx_runtime.JSX.Element)
19
19
  Track: (props: SwitchTrack.Props) => react.ReactElement<unknown, string | react.JSXElementConstructor<any>>;
20
20
  Thumb: (props: SwitchThumb.Props) => react_jsx_runtime.JSX.Element;
21
21
  };
22
- type SwitchProps = Switch$1.Props;
22
+ declare namespace Switch {
23
+ interface Props extends Switch$1.Props {
24
+ }
25
+ interface Content extends SwitchContent.Props {
26
+ }
27
+ interface Track extends SwitchTrack.Props {
28
+ }
29
+ interface Thumb extends SwitchThumb.Props {
30
+ }
31
+ }
23
32
 
24
- export { Switch, type SwitchProps };
33
+ export { Switch };
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{SwitchConfig as n,useSwitchConfig as f}from"./switch-config.mjs";import{Switch as t}from"./switch.mjs";import{SwitchContent as o}from"./switch-content.mjs";import{SwitchThumb as i}from"./switch-thumb.mjs";import{SwitchTrack as r}from"./switch-track.mjs";const w=Object.assign(t,{Root:t,Content:o,Track:r,Thumb:i});export{w as Switch,n as SwitchConfig,f as useSwitchConfig};
1
+ import{SwitchConfig as w,useSwitchConfig as S}from"./switch-config.mjs";import{Switch as t}from"./switch.mjs";import{SwitchContent as o}from"./switch-content.mjs";import{SwitchThumb as e}from"./switch-thumb.mjs";import{SwitchTrack as r}from"./switch-track.mjs";const p=Object.assign(t,{Root:t,Content:o,Track:r,Thumb:e});export{p as Switch,w as SwitchConfig,S as useSwitchConfig};
package/dist/styles.d.mts CHANGED
@@ -40,6 +40,9 @@ declare const switchVariants: _jamsrui_utils.TVReturnType<{
40
40
  thumb: string;
41
41
  };
42
42
  };
43
+ isInvalid: {
44
+ true: {};
45
+ };
43
46
  }, {
44
47
  root: string;
45
48
  track: string[];
@@ -85,6 +88,9 @@ declare const switchVariants: _jamsrui_utils.TVReturnType<{
85
88
  thumb: string;
86
89
  };
87
90
  };
91
+ isInvalid: {
92
+ true: {};
93
+ };
88
94
  }, {
89
95
  root: string;
90
96
  track: string[];
@@ -130,6 +136,9 @@ declare const switchVariants: _jamsrui_utils.TVReturnType<{
130
136
  thumb: string;
131
137
  };
132
138
  };
139
+ isInvalid: {
140
+ true: {};
141
+ };
133
142
  }, {
134
143
  root: string;
135
144
  track: string[];
package/dist/styles.mjs CHANGED
@@ -1 +1 @@
1
- import{groupDataFocusVisibleClasses as e,tv as t}from"@jamsrui/utils";const s=t({slots:{root:"group flex gap-2",track:[...e,"flex relative cursor-default shrink-0 items-center rounded-full bg-surface-secondary p-1","uig-disabled:cursor-not-allowed uig-disabled:opacity-60","ui-interactive:hover:opacity-95","justify-start uig-checked:justify-end"],thumb:"size-8 rounded-full bg-white shadow-md flex justify-center items-center",content:"grid grow gap-1",input:"opacity-[0.0001] absolute inset-0 cursor-default disabled:cursor-not-allowed z-1"},variants:{color:{default:{track:"uig-checked:bg-default"},primary:{track:"uig-checked:bg-primary"},secondary:{track:"uig-checked:bg-secondary"},success:{track:"uig-checked:bg-success"},warning:{track:"uig-checked:bg-warning"},danger:{track:"uig-checked:bg-danger"}},size:{xs:{track:"h-4 w-7 px-0.5",thumb:"size-3 uig-pressed:w-3.5"},sm:{track:"h-5 w-9",thumb:"size-3.5 uig-pressed:w-4"},md:{track:"h-6 w-10",thumb:"size-4 uig-pressed:w-5"},lg:{track:"h-7 w-12",thumb:"size-5 uig-pressed:w-6"}}},defaultVariants:{size:"md",color:"success"}});export{s as switchVariants};
1
+ import{groupDataFocusVisibleClasses as e,tv as t}from"@jamsrui/utils";const s=t({slots:{root:"group flex gap-2",track:[...e,"flex relative cursor-default shrink-0 items-center rounded-full bg-surface-secondary p-1","uig-disabled:cursor-not-allowed uig-disabled:opacity-60","ui-interactive:hover:opacity-95","justify-start uig-checked:justify-end"],thumb:"size-8 rounded-full bg-white shadow-md flex justify-center items-center",content:"grid grow gap-1",input:"opacity-[0.0001] absolute inset-0 cursor-default disabled:cursor-not-allowed z-1"},variants:{color:{default:{track:"uig-checked:bg-default"},primary:{track:"uig-checked:bg-primary"},secondary:{track:"uig-checked:bg-secondary"},success:{track:"uig-checked:bg-success"},warning:{track:"uig-checked:bg-warning"},danger:{track:"uig-checked:bg-danger"}},size:{xs:{track:"h-4 w-7 px-0.5",thumb:"size-3 uig-pressed:w-3.5"},sm:{track:"h-5 w-9",thumb:"size-3.5 uig-pressed:w-4"},md:{track:"h-6 w-10",thumb:"size-4 uig-pressed:w-5"},lg:{track:"h-7 w-12",thumb:"size-5 uig-pressed:w-6"}},isInvalid:{true:{}}},defaultVariants:{size:"md",color:"success"}});export{s as switchVariants};
@@ -1 +1 @@
1
- "use client";import{jsx as p}from"react/jsx-runtime";import{motion as i}from"motion/react";import{useSwitchContext as n}from"./switch-context.mjs";const c=o=>{const{getThumbProps:t}=n(),{children:r,...e}=o;return p(i.div,{...t(e),children:r})};export{c as SwitchThumb};
1
+ "use client";import{jsx as o}from"react/jsx-runtime";import{LayoutGroup as p,motion as n}from"motion/react";import{useSwitchContext as s}from"./switch-context.mjs";const u=t=>{const{getThumbProps:r}=s(),{children:i,...e}=t;return o(p,{children:o(n.div,{...r(e),layout:"position",style:{originY:"0px"},children:i})})};export{u as SwitchThumb};
@@ -21,10 +21,12 @@ declare namespace useSwitch {
21
21
  interface Props extends SwitchVariants, SwitchRoot.Props {
22
22
  defaultChecked?: boolean;
23
23
  disabled?: boolean;
24
- isChecked?: boolean;
24
+ checked?: boolean;
25
25
  onCheckedChange?: (value: boolean) => void;
26
26
  children?: React.ReactNode;
27
27
  inputProps?: UIProps<"input">;
28
+ name?: string;
29
+ form?: string;
28
30
  }
29
31
  }
30
32
 
@@ -1 +1 @@
1
- import{useCallback as o,useId as G,useMemo as M}from"react";import{useControlledState as A,useFocusVisible as D,useMergeRefs as E,usePress as F}from"@jamsrui/hooks";import{cn as U,dataAttr as r,dataAttrDev as i,mapPropsVariants as j,mergeProps as H}from"@jamsrui/utils";import{switchVariants as k}from"./styles.mjs";const z=N=>{const[S,g]=j(N,k.variantKeys),e=k(g),{isChecked:y,defaultChecked:I,onCheckedChange:R,disabled:v=!1,inputProps:a,...n}=S,[c,p]=A({defaultProp:I,onChange:R,prop:y}),s=v,{isFocusVisible:l,ref:T}=D({isDisabled:s}),{isPressed:m,ref:V}=F({isDisabled:s}),x=a?.ref,h=E([x,T,V]),d=G(),u=o(t=>{s||p(t.target.checked)},[s,p]),P=o(()=>({...n,className:e.root({className:n.className}),"data-slot":i("root"),"data-component":i("switch"),"data-checked":r(c),"data-focus-visible":r(l),"data-pressed":r(m),"data-disabled":r(s)}),[n,c,s,l,m,e]),f=o(t=>({...H(t,a,{onChange:u}),ref:h,type:"checkbox","data-slot":i("input"),className:e.input({className:U(a?.className,t.className)}),disabled:s}),[u,a,h,s,e]),w=o(t=>({...t,"data-slot":"track",className:e.track({className:t.className})}),[e]),b=o(t=>({...t,layoutId:d,"data-slot":"thumb",className:e.thumb({className:t.className})}),[d,e]),C=o(t=>({...t,"data-slot":"content",className:e.content({className:t.className})}),[e]);return M(()=>({isChecked:c,getRootProps:P,getThumbProps:b,getContentProps:C,getTrackProps:w,getInputProps:f}),[c,P,b,C,w,f])};export{z as useSwitch};
1
+ import{useCallback as o,useId as G,useMemo as M}from"react";import{useControlledState as A,useFocusVisible as D,useMergeRefs as E,usePress as F}from"@jamsrui/hooks";import{cn as U,dataAttr as r,dataAttrDev as i,mapPropsVariants as j,mergeProps as H}from"@jamsrui/utils";import{switchVariants as C}from"./styles.mjs";const z=N=>{const[S,g]=j(N,C.variantKeys),e=C(g),{checked:y,defaultChecked:I,onCheckedChange:R,disabled:v=!1,inputProps:a,...n}=S,[c,p]=A({defaultProp:I,onChange:R,prop:y}),s=v,{isFocusVisible:m,ref:T}=D({isDisabled:s}),{isPressed:l,ref:V}=F({isDisabled:s}),x=a?.ref,h=E([x,T,V]),d=G(),u=o(t=>{s||p(t.target.checked)},[s,p]),f=o(()=>({...n,className:e.root({className:n.className}),"data-slot":i("root"),"data-component":i("switch"),"data-checked":r(c),"data-focus-visible":r(m),"data-pressed":r(l),"data-disabled":r(s)}),[n,c,s,m,l,e]),P=o(t=>({...H(t,a,{onChange:u}),ref:h,type:"checkbox","data-slot":i("input"),className:e.input({className:U(a?.className,t.className)}),disabled:s}),[u,a,h,s,e]),w=o(t=>({...t,"data-slot":"track",className:e.track({className:t.className})}),[e]),b=o(t=>({...t,layoutId:d,"data-slot":"thumb",className:e.thumb({className:t.className})}),[d,e]),k=o(t=>({...t,"data-slot":"content",className:e.content({className:t.className})}),[e]);return M(()=>({isChecked:c,getRootProps:f,getThumbProps:b,getContentProps:k,getTrackProps:w,getInputProps:P}),[c,f,b,k,w,P])};export{z as useSwitch};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jamsrui/switch",
3
- "version": "0.0.15",
3
+ "version": "0.0.17",
4
4
  "exports": {
5
5
  ".": {
6
6
  "types": "./dist/index.d.ts",
@@ -17,10 +17,10 @@
17
17
  },
18
18
  "dependencies": {
19
19
  "@jamsrui/core": "^0.0.13",
20
- "@jamsrui/hooks": "^0.0.15",
20
+ "@jamsrui/hooks": "^0.0.16",
21
21
  "@jamsrui/slot": "^0.0.14",
22
- "@jamsrui/utils": "^0.0.15",
23
- "@jamsrui/context": "^0.0.4"
22
+ "@jamsrui/utils": "^0.0.16",
23
+ "@jamsrui/context": "^0.0.5"
24
24
  },
25
25
  "description": "A modern and beautiful Next.js UI components library.",
26
26
  "keywords": [