@jamsrui/switch 0.0.11 → 0.0.13

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.
Files changed (68) hide show
  1. package/dist/chunk-2SD3LCHA.mjs +1 -0
  2. package/dist/chunk-3DYOKGGX.mjs +1 -0
  3. package/dist/chunk-3YY6BKHQ.mjs +1 -0
  4. package/dist/chunk-BSFNJ44W.mjs +1 -0
  5. package/dist/chunk-PH3TTZ56.mjs +1 -0
  6. package/dist/chunk-RBAAFDUL.mjs +1 -0
  7. package/dist/chunk-SO3SNGFL.mjs +1 -0
  8. package/dist/chunk-STY4A2DS.mjs +1 -0
  9. package/dist/chunk-TZ3CFLGK.mjs +1 -0
  10. package/dist/index.d.mts +20 -13
  11. package/dist/index.mjs +1 -1
  12. package/dist/{primitive/styles.d.mts → styles.d.mts} +0 -51
  13. package/dist/styles.mjs +1 -0
  14. package/dist/switch-config.d.mts +7 -10
  15. package/dist/switch-config.mjs +1 -1
  16. package/dist/switch-content.mjs +1 -0
  17. package/dist/{primitive/switch-context.d.mts → switch-context.d.mts} +0 -3
  18. package/dist/switch-context.mjs +1 -0
  19. package/dist/switch-input.mjs +1 -0
  20. package/dist/{primitive/switch-root.d.mts → switch-root.d.mts} +1 -1
  21. package/dist/switch-root.mjs +1 -0
  22. package/dist/switch-thumb.mjs +1 -0
  23. package/dist/switch-track.mjs +1 -0
  24. package/dist/switch.d.mts +8 -13
  25. package/dist/switch.mjs +1 -1
  26. package/dist/{primitive/use-switch.d.mts → use-switch.d.mts} +7 -14
  27. package/dist/use-switch.mjs +1 -0
  28. package/package.json +6 -5
  29. package/dist/chunk-4FAMDC4W.mjs +0 -1
  30. package/dist/chunk-BXBHWVKC.mjs +0 -1
  31. package/dist/chunk-CV6X5VZS.mjs +0 -1
  32. package/dist/chunk-IGNAWQUV.mjs +0 -1
  33. package/dist/chunk-IIZ5FKIW.mjs +0 -1
  34. package/dist/chunk-PXWG26DS.mjs +0 -0
  35. package/dist/chunk-UV6DZE4H.mjs +0 -1
  36. package/dist/chunk-VGHIDOWS.mjs +0 -1
  37. package/dist/chunk-VP7BK66R.mjs +0 -1
  38. package/dist/chunk-VSR2PVUI.mjs +0 -1
  39. package/dist/chunk-WQGZQL5E.mjs +0 -1
  40. package/dist/chunk-X76H4PSZ.mjs +0 -1
  41. package/dist/chunk-YFRKKQNC.mjs +0 -1
  42. package/dist/chunk-YZHN6POK.mjs +0 -1
  43. package/dist/chunk-ZID55QUD.mjs +0 -1
  44. package/dist/primitive/index.d.mts +0 -18
  45. package/dist/primitive/index.mjs +0 -1
  46. package/dist/primitive/styles.mjs +0 -1
  47. package/dist/primitive/switch-config.d.mts +0 -27
  48. package/dist/primitive/switch-config.mjs +0 -1
  49. package/dist/primitive/switch-content.mjs +0 -1
  50. package/dist/primitive/switch-context.mjs +0 -1
  51. package/dist/primitive/switch-description.d.mts +0 -10
  52. package/dist/primitive/switch-description.mjs +0 -1
  53. package/dist/primitive/switch-input.mjs +0 -1
  54. package/dist/primitive/switch-label.d.mts +0 -10
  55. package/dist/primitive/switch-label.mjs +0 -1
  56. package/dist/primitive/switch-root.mjs +0 -1
  57. package/dist/primitive/switch-thumb.mjs +0 -1
  58. package/dist/primitive/switch-track.mjs +0 -1
  59. package/dist/primitive/switch-wrapper.d.mts +0 -10
  60. package/dist/primitive/switch-wrapper.mjs +0 -1
  61. package/dist/primitive/switch.d.mts +0 -22
  62. package/dist/primitive/switch.mjs +0 -1
  63. package/dist/primitive/use-switch.mjs +0 -1
  64. /package/dist/{chunk-NR7TBHSW.mjs → chunk-ZMFP3ZII.mjs} +0 -0
  65. /package/dist/{primitive/switch-content.d.mts → switch-content.d.mts} +0 -0
  66. /package/dist/{primitive/switch-input.d.mts → switch-input.d.mts} +0 -0
  67. /package/dist/{primitive/switch-thumb.d.mts → switch-thumb.d.mts} +0 -0
  68. /package/dist/{primitive/switch-track.d.mts → switch-track.d.mts} +0 -0
@@ -0,0 +1 @@
1
+ import{a as t}from"./chunk-3DYOKGGX.mjs";import{a as e}from"./chunk-TZ3CFLGK.mjs";import{b as r}from"./chunk-ZMFP3ZII.mjs";import{useRenderElement as s}from"@jamsrui/hooks";import{Fragment as m,jsx as o,jsxs as h}from"react/jsx-runtime";var w=p=>{let{children:c=o(e,{}),...i}=p,{getTrackProps:n}=r();return s("div",{props:[n(i),{children:h(m,{children:[c,o(t,{})]})}]})};export{w as a};
@@ -0,0 +1 @@
1
+ import{b as t}from"./chunk-ZMFP3ZII.mjs";import{useFieldA11yContext as o}from"@jamsrui/context";import{useRenderElement as p}from"@jamsrui/hooks";var c=e=>{let{getInputProps:r}=t(),n=o();return p("input",{props:[r(e),n?.getInputProps()??{}]})};export{c as a};
@@ -0,0 +1 @@
1
+ import{createConfigContext as o}from"@jamsrui/utils";var[t,e]=o({displayName:"SwitchConfig"});export{t as a,e as b};
@@ -0,0 +1 @@
1
+ import{a as n}from"./chunk-PH3TTZ56.mjs";import{b as i}from"./chunk-3YY6BKHQ.mjs";import{a as c}from"./chunk-SO3SNGFL.mjs";import{a as r}from"./chunk-ZMFP3ZII.mjs";import{FieldA11yContext as f,useFieldA11y as h}from"@jamsrui/context";import{mergeConfigProps as w}from"@jamsrui/utils";import{jsx as t}from"react/jsx-runtime";var g=o=>{let e=i(),s=w(e,e,o),m=n(s),p=h();return t(f,{value:p,children:t(r,{value:m,children:t(c,{children:o.children})})})};export{g as a};
@@ -0,0 +1 @@
1
+ import{a as i}from"./chunk-RBAAFDUL.mjs";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 p,mapPropsVariants as j,mergeProps as H}from"@jamsrui/utils";var z=N=>{let[S,g]=j(N,i.variantKeys),e=i(g),{isChecked:y,defaultChecked:I,onCheckedChange:R,disabled:v=!1,inputProps:a,...n}=S,[c,l]=A({defaultProp:I,onChange:R,prop:y}),s=v,{isFocusVisible:m,ref:T}=D({isDisabled:s}),{isPressed:h,ref:V}=F({isDisabled:s}),x=a?.ref,d=E([x,T,V]),u=G(),P=o(t=>{s||l(t.target.checked)},[s,l]),f=o(()=>({...n,className:e.root({className:n.className}),"data-slot":p("root"),"data-component":p("switch"),"data-checked":r(c),"data-focus-visible":r(m),"data-pressed":r(h),"data-disabled":r(s)}),[n,c,s,m,h,e]),w=o(t=>({...H(t,a,{onChange:P}),ref:d,type:"checkbox","data-slot":p("input"),className:e.input({className:U(a?.className,t.className)}),disabled:s}),[P,a,d,s,e]),b=o(t=>({...t,"data-slot":"track",className:e.track({className:t.className})}),[e]),C=o(t=>({...t,layoutId:u,"data-slot":"thumb",className:e.thumb({className:t.className})}),[u,e]),k=o(t=>({...t,"data-slot":"content",className:e.content({className:t.className})}),[e]);return M(()=>({isChecked:c,getRootProps:f,getThumbProps:C,getContentProps:k,getTrackProps:b,getInputProps:w}),[c,f,C,k,b,w])};export{z as a};
@@ -0,0 +1 @@
1
+ import{groupDataFocusVisibleClasses as e,tv as t}from"@jamsrui/utils";var 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 a};
@@ -0,0 +1 @@
1
+ import{b as e}from"./chunk-ZMFP3ZII.mjs";import{useRenderElement as o}from"@jamsrui/hooks";var i=r=>{let{getRootProps:t}=e();return o("div",{props:[t()]})};export{i as a};
@@ -0,0 +1 @@
1
+ import{b as e}from"./chunk-ZMFP3ZII.mjs";import{useRenderElement as n}from"@jamsrui/hooks";var i=t=>{let{getContentProps:r}=e();return n("div",{props:[r(t)]})};export{i as a};
@@ -0,0 +1 @@
1
+ import{b as o}from"./chunk-ZMFP3ZII.mjs";import{motion as n}from"motion/react";import{jsx as p}from"react/jsx-runtime";var c=t=>{let{getThumbProps:r}=o(),{children:e,...i}=t;return p(n.div,{...r(i),children:e})};export{c as a};
package/dist/index.d.mts CHANGED
@@ -1,17 +1,24 @@
1
+ import * as react from 'react';
2
+ import * as react_jsx_runtime from 'react/jsx-runtime';
1
3
  export { SwitchConfig, useSwitchConfig } from './switch-config.mjs';
2
- export { Switch } from './switch.mjs';
3
- import 'react/jsx-runtime';
4
+ import { Switch as Switch$1 } from './switch.mjs';
5
+ import { SwitchContent } from './switch-content.mjs';
6
+ import { SwitchThumb } from './switch-thumb.mjs';
7
+ import { SwitchTrack } from './switch-track.mjs';
4
8
  import '@jamsrui/core';
5
- import './primitive/use-switch.mjs';
9
+ import './use-switch.mjs';
6
10
  import '@jamsrui/utils';
7
- import './primitive/styles.mjs';
8
- import './primitive/switch-content.mjs';
9
- import 'react';
10
- import './primitive/switch-description.mjs';
11
- import './primitive/switch-input.mjs';
12
- import './primitive/switch-label.mjs';
13
- import './primitive/switch-root.mjs';
14
- import './primitive/switch-thumb.mjs';
11
+ import './styles.mjs';
12
+ import './switch-input.mjs';
13
+ import './switch-root.mjs';
15
14
  import 'motion/react';
16
- import './primitive/switch-track.mjs';
17
- import './primitive/switch-wrapper.mjs';
15
+
16
+ declare const Switch: ((props: Switch$1.Props) => react_jsx_runtime.JSX.Element) & {
17
+ Root: (props: Switch$1.Props) => react_jsx_runtime.JSX.Element;
18
+ Content: (props: SwitchContent.Props) => react.ReactElement<unknown, string | react.JSXElementConstructor<any>>;
19
+ Track: (props: SwitchTrack.Props) => react.ReactElement<unknown, string | react.JSXElementConstructor<any>>;
20
+ Thumb: (props: SwitchThumb.Props) => react_jsx_runtime.JSX.Element;
21
+ };
22
+ type SwitchProps = Switch$1.Props;
23
+
24
+ export { Switch, type SwitchProps };
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- "use client";import{a as t}from"./chunk-VGHIDOWS.mjs";import{a as i,b as o}from"./chunk-IGNAWQUV.mjs";import"./chunk-PXWG26DS.mjs";import"./chunk-YZHN6POK.mjs";import"./chunk-ZID55QUD.mjs";import"./chunk-X76H4PSZ.mjs";import"./chunk-UV6DZE4H.mjs";import"./chunk-VP7BK66R.mjs";import"./chunk-YFRKKQNC.mjs";import"./chunk-VSR2PVUI.mjs";import"./chunk-BXBHWVKC.mjs";import"./chunk-WQGZQL5E.mjs";import"./chunk-4FAMDC4W.mjs";import"./chunk-IIZ5FKIW.mjs";import"./chunk-CV6X5VZS.mjs";import"./chunk-NR7TBHSW.mjs";export{t as Switch,i as SwitchConfig,o as useSwitchConfig};
1
+ import{a as r}from"./chunk-2SD3LCHA.mjs";import{a as t}from"./chunk-BSFNJ44W.mjs";import"./chunk-PH3TTZ56.mjs";import"./chunk-RBAAFDUL.mjs";import{a as c,b as h}from"./chunk-3YY6BKHQ.mjs";import{a as o}from"./chunk-STY4A2DS.mjs";import"./chunk-3DYOKGGX.mjs";import"./chunk-SO3SNGFL.mjs";import{a as i}from"./chunk-TZ3CFLGK.mjs";import"./chunk-ZMFP3ZII.mjs";var e=Object.assign(t,{Root:t,Content:o,Track:r,Thumb:i});export{e as Switch,c as SwitchConfig,h as useSwitchConfig};
@@ -40,28 +40,11 @@ declare const switchVariants: _jamsrui_utils.TVReturnType<{
40
40
  thumb: string;
41
41
  };
42
42
  };
43
- labelPlacement: {
44
- start: {
45
- wrapper: string;
46
- };
47
- end: {
48
- wrapper: string;
49
- };
50
- top: {
51
- wrapper: string;
52
- };
53
- bottom: {
54
- wrapper: string;
55
- };
56
- };
57
43
  }, {
58
44
  root: string;
59
45
  track: string[];
60
46
  thumb: string;
61
- label: string;
62
- description: string;
63
47
  content: string;
64
- wrapper: string;
65
48
  input: string;
66
49
  }, undefined, {
67
50
  color: {
@@ -102,28 +85,11 @@ declare const switchVariants: _jamsrui_utils.TVReturnType<{
102
85
  thumb: string;
103
86
  };
104
87
  };
105
- labelPlacement: {
106
- start: {
107
- wrapper: string;
108
- };
109
- end: {
110
- wrapper: string;
111
- };
112
- top: {
113
- wrapper: string;
114
- };
115
- bottom: {
116
- wrapper: string;
117
- };
118
- };
119
88
  }, {
120
89
  root: string;
121
90
  track: string[];
122
91
  thumb: string;
123
- label: string;
124
- description: string;
125
92
  content: string;
126
- wrapper: string;
127
93
  input: string;
128
94
  }, _jamsrui_utils.TVReturnType<{
129
95
  color: {
@@ -164,28 +130,11 @@ declare const switchVariants: _jamsrui_utils.TVReturnType<{
164
130
  thumb: string;
165
131
  };
166
132
  };
167
- labelPlacement: {
168
- start: {
169
- wrapper: string;
170
- };
171
- end: {
172
- wrapper: string;
173
- };
174
- top: {
175
- wrapper: string;
176
- };
177
- bottom: {
178
- wrapper: string;
179
- };
180
- };
181
133
  }, {
182
134
  root: string;
183
135
  track: string[];
184
136
  thumb: string;
185
- label: string;
186
- description: string;
187
137
  content: string;
188
- wrapper: string;
189
138
  input: string;
190
139
  }, undefined, unknown, unknown, undefined>>;
191
140
  type SwitchVariants = VariantProps<typeof switchVariants>;
@@ -0,0 +1 @@
1
+ import{a}from"./chunk-RBAAFDUL.mjs";export{a as switchVariants};
@@ -1,19 +1,16 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { WithGlobalConfig } from '@jamsrui/core';
3
3
  import { Switch } from './switch.mjs';
4
- import './primitive/use-switch.mjs';
4
+ import './use-switch.mjs';
5
5
  import '@jamsrui/utils';
6
- import './primitive/styles.mjs';
7
- import './primitive/switch-content.mjs';
6
+ import './styles.mjs';
7
+ import './switch-content.mjs';
8
8
  import 'react';
9
- import './primitive/switch-description.mjs';
10
- import './primitive/switch-input.mjs';
11
- import './primitive/switch-label.mjs';
12
- import './primitive/switch-root.mjs';
13
- import './primitive/switch-thumb.mjs';
9
+ import './switch-input.mjs';
10
+ import './switch-root.mjs';
11
+ import './switch-thumb.mjs';
14
12
  import 'motion/react';
15
- import './primitive/switch-track.mjs';
16
- import './primitive/switch-wrapper.mjs';
13
+ import './switch-track.mjs';
17
14
 
18
15
  declare const useSwitchConfig: () => SwitchConfig.Props;
19
16
  declare const SwitchConfig: (props: Omit<Partial<SwitchConfig.Props>, "children"> & {
@@ -1 +1 @@
1
- import{a,b}from"./chunk-IGNAWQUV.mjs";export{a as SwitchConfig,b as useSwitchConfig};
1
+ "use client";import{a,b}from"./chunk-3YY6BKHQ.mjs";export{a as SwitchConfig,b as useSwitchConfig};
@@ -0,0 +1 @@
1
+ "use client";import{a}from"./chunk-STY4A2DS.mjs";import"./chunk-ZMFP3ZII.mjs";export{a as SwitchContent};
@@ -3,15 +3,12 @@ import { useSwitch } from './use-switch.mjs';
3
3
  import '@jamsrui/utils';
4
4
  import './styles.mjs';
5
5
  import './switch-content.mjs';
6
- import './switch-description.mjs';
7
6
  import './switch-input.mjs';
8
- import './switch-label.mjs';
9
7
  import './switch-root.mjs';
10
8
  import './switch-thumb.mjs';
11
9
  import 'react/jsx-runtime';
12
10
  import 'motion/react';
13
11
  import './switch-track.mjs';
14
- import './switch-wrapper.mjs';
15
12
 
16
13
  declare const useSwitchContext: () => SwitchContext.Props;
17
14
  declare const SwitchContext: react.Context<SwitchContext.Props | null>;
@@ -0,0 +1 @@
1
+ "use client";import{a,b}from"./chunk-ZMFP3ZII.mjs";export{a as SwitchContext,b as useSwitchContext};
@@ -0,0 +1 @@
1
+ "use client";import{a}from"./chunk-3DYOKGGX.mjs";import"./chunk-ZMFP3ZII.mjs";export{a as SwitchInput};
@@ -1,7 +1,7 @@
1
1
  import * as react from 'react';
2
2
  import { UIProps } from '@jamsrui/utils';
3
3
 
4
- declare const SwitchRoot: (props: SwitchRoot.Props) => react.ReactElement<unknown, string | react.JSXElementConstructor<any>>;
4
+ declare const SwitchRoot: (_props: SwitchRoot.Props) => react.ReactElement<unknown, string | react.JSXElementConstructor<any>>;
5
5
  declare namespace SwitchRoot {
6
6
  interface Props extends UIProps<"div"> {
7
7
  }
@@ -0,0 +1 @@
1
+ "use client";import{a}from"./chunk-SO3SNGFL.mjs";import"./chunk-ZMFP3ZII.mjs";export{a as SwitchRoot};
@@ -0,0 +1 @@
1
+ "use client";import{a}from"./chunk-TZ3CFLGK.mjs";import"./chunk-ZMFP3ZII.mjs";export{a as SwitchThumb};
@@ -0,0 +1 @@
1
+ "use client";import{a}from"./chunk-2SD3LCHA.mjs";import"./chunk-3DYOKGGX.mjs";import"./chunk-TZ3CFLGK.mjs";import"./chunk-ZMFP3ZII.mjs";export{a as SwitchTrack};
package/dist/switch.d.mts CHANGED
@@ -1,23 +1,18 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { useSwitch } from './primitive/use-switch.mjs';
3
- import { SlotsToReactNode } from '@jamsrui/utils';
4
- import { SwitchSlots } from './primitive/styles.mjs';
5
- import './primitive/switch-content.mjs';
2
+ import { useSwitch } from './use-switch.mjs';
3
+ import '@jamsrui/utils';
4
+ import './styles.mjs';
5
+ import './switch-content.mjs';
6
6
  import 'react';
7
- import './primitive/switch-description.mjs';
8
- import './primitive/switch-input.mjs';
9
- import './primitive/switch-label.mjs';
10
- import './primitive/switch-root.mjs';
11
- import './primitive/switch-thumb.mjs';
7
+ import './switch-input.mjs';
8
+ import './switch-root.mjs';
9
+ import './switch-thumb.mjs';
12
10
  import 'motion/react';
13
- import './primitive/switch-track.mjs';
14
- import './primitive/switch-wrapper.mjs';
11
+ import './switch-track.mjs';
15
12
 
16
13
  declare const Switch: (props: Switch.Props) => react_jsx_runtime.JSX.Element;
17
14
  declare namespace Switch {
18
15
  interface Props extends useSwitch.Props {
19
- label?: string;
20
- slots?: SlotsToReactNode<SwitchSlots>;
21
16
  }
22
17
  }
23
18
 
package/dist/switch.mjs CHANGED
@@ -1 +1 @@
1
- import{a}from"./chunk-VGHIDOWS.mjs";import"./chunk-IGNAWQUV.mjs";import"./chunk-PXWG26DS.mjs";import"./chunk-YZHN6POK.mjs";import"./chunk-ZID55QUD.mjs";import"./chunk-X76H4PSZ.mjs";import"./chunk-UV6DZE4H.mjs";import"./chunk-VP7BK66R.mjs";import"./chunk-YFRKKQNC.mjs";import"./chunk-VSR2PVUI.mjs";import"./chunk-BXBHWVKC.mjs";import"./chunk-WQGZQL5E.mjs";import"./chunk-4FAMDC4W.mjs";import"./chunk-IIZ5FKIW.mjs";import"./chunk-CV6X5VZS.mjs";import"./chunk-NR7TBHSW.mjs";export{a as Switch};
1
+ "use client";import{a}from"./chunk-BSFNJ44W.mjs";import"./chunk-PH3TTZ56.mjs";import"./chunk-RBAAFDUL.mjs";import"./chunk-3YY6BKHQ.mjs";import"./chunk-SO3SNGFL.mjs";import"./chunk-ZMFP3ZII.mjs";export{a as Switch};
@@ -1,37 +1,30 @@
1
- import { PropGetter, SlotsToClassNames } from '@jamsrui/utils';
2
- import { SwitchVariants, SwitchSlots } from './styles.mjs';
1
+ import { PropGetter, UIProps } from '@jamsrui/utils';
2
+ import { SwitchVariants } from './styles.mjs';
3
3
  import { SwitchContent } from './switch-content.mjs';
4
- import { SwitchDescription } from './switch-description.mjs';
5
4
  import { SwitchInput } from './switch-input.mjs';
6
- import { SwitchLabel } from './switch-label.mjs';
7
5
  import { SwitchRoot } from './switch-root.mjs';
8
6
  import { SwitchThumb } from './switch-thumb.mjs';
9
7
  import { SwitchTrack } from './switch-track.mjs';
10
- import { SwitchWrapper } from './switch-wrapper.mjs';
11
8
  import 'react';
12
9
  import 'react/jsx-runtime';
13
10
  import 'motion/react';
14
11
 
15
12
  declare const useSwitch: (props: useSwitch.Props) => {
16
13
  isChecked: boolean;
17
- getRootProps: PropGetter<SwitchRoot.Props>;
14
+ getRootProps: () => SwitchRoot.Props;
18
15
  getThumbProps: PropGetter<SwitchThumb.Props>;
19
- getLabelProps: PropGetter<SwitchLabel.Props>;
20
- getDescriptionProps: PropGetter<SwitchDescription.Props>;
21
16
  getContentProps: PropGetter<SwitchContent.Props>;
22
- getWrapperProps: PropGetter<SwitchWrapper.Props>;
23
17
  getTrackProps: PropGetter<SwitchTrack.Props>;
24
18
  getInputProps: PropGetter<SwitchInput.Props>;
25
19
  };
26
20
  declare namespace useSwitch {
27
- interface Props extends SwitchVariants {
28
- isReadonly?: boolean;
29
- isDisabled?: boolean;
21
+ interface Props extends SwitchVariants, SwitchRoot.Props {
22
+ defaultChecked?: boolean;
23
+ disabled?: boolean;
30
24
  isChecked?: boolean;
31
25
  onCheckedChange?: (value: boolean) => void;
32
- defaultChecked?: boolean;
33
26
  children?: React.ReactNode;
34
- classNames?: SlotsToClassNames<SwitchSlots>;
27
+ inputProps?: UIProps<"input">;
35
28
  }
36
29
  }
37
30
 
@@ -0,0 +1 @@
1
+ import{a}from"./chunk-PH3TTZ56.mjs";import"./chunk-RBAAFDUL.mjs";export{a as useSwitch};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jamsrui/switch",
3
- "version": "0.0.11",
3
+ "version": "0.0.13",
4
4
  "exports": {
5
5
  ".": {
6
6
  "types": "./dist/index.d.ts",
@@ -16,10 +16,11 @@
16
16
  "react": ">=19"
17
17
  },
18
18
  "dependencies": {
19
- "@jamsrui/hooks": "^0.0.11",
20
- "@jamsrui/core": "^0.0.10",
21
- "@jamsrui/slot": "^0.0.11",
22
- "@jamsrui/utils": "^0.0.11"
19
+ "@jamsrui/context": "^0.0.2",
20
+ "@jamsrui/hooks": "^0.0.13",
21
+ "@jamsrui/core": "^0.0.11",
22
+ "@jamsrui/slot": "^0.0.12",
23
+ "@jamsrui/utils": "^0.0.13"
23
24
  },
24
25
  "description": "A modern and beautiful Next.js UI components library.",
25
26
  "keywords": [
@@ -1 +0,0 @@
1
- import{groupDataFocusVisibleClasses as e,tv as r}from"@jamsrui/utils";var s=r({slots:{root:"group flex flex-col gap-2",track:[...e,"flex 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",label:"text-sm uig-interactive:cursor-pointer",description:"text-xs text-foreground-secondary",content:"grid grow gap-1",wrapper:"flex items-center justify-between gap-2 relative",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-4"},sm:{track:"h-6 w-10",thumb:"size-4 uig-pressed:w-5"},md:{track:"h-7 w-12",thumb:"size-5 uig-pressed:w-6"},lg:{track:"h-8 w-14",thumb:"size-6 uig-pressed:w-7"}},labelPlacement:{start:{wrapper:"flex-row"},end:{wrapper:"flex-row-reverse"},top:{wrapper:"flex-col"},bottom:{wrapper:"flex-col-reverse"}}},defaultVariants:{size:"md",color:"success",labelPlacement:"start"}});export{s as a};
@@ -1 +0,0 @@
1
- import{a as c}from"./chunk-WQGZQL5E.mjs";import{b as e}from"./chunk-IIZ5FKIW.mjs";import{a as r}from"./chunk-NR7TBHSW.mjs";import{mergeConfigProps as s}from"@jamsrui/utils";import{jsx as p}from"react/jsx-runtime";var S=t=>{let o=e(),i=s(o,o,t),n=c(i);return p(r,{value:n,children:t.children})};export{S as a};
@@ -1 +0,0 @@
1
- import{b as t}from"./chunk-NR7TBHSW.mjs";import{useRenderElement as o}from"@jamsrui/hooks";var i=e=>{let{getContentProps:r}=t();return o("div",{props:[r(e)]})};export{i as a};
@@ -1 +0,0 @@
1
- import{createConfigContext as o}from"@jamsrui/utils";var[t,r]=o({displayName:"SwitchConfig"});export{t as a,r as b};
@@ -1 +0,0 @@
1
- import{createConfigContext as o}from"@jamsrui/utils";var[t,r]=o({displayName:"SwitchConfig"});export{t as a,r as b};
File without changes
@@ -1 +0,0 @@
1
- import{b as t}from"./chunk-NR7TBHSW.mjs";import{useRenderElement as r}from"@jamsrui/hooks";var i=e=>{let{getRootProps:o}=t();return r("div",{props:[o(e)]})};export{i as a};
@@ -1 +0,0 @@
1
- import{b as r}from"./chunk-IGNAWQUV.mjs";import{a as S}from"./chunk-YZHN6POK.mjs";import{a as n}from"./chunk-ZID55QUD.mjs";import{a as p}from"./chunk-X76H4PSZ.mjs";import{a as h}from"./chunk-UV6DZE4H.mjs";import{a as w}from"./chunk-VP7BK66R.mjs";import{a as m}from"./chunk-YFRKKQNC.mjs";import{a}from"./chunk-VSR2PVUI.mjs";import{a as s}from"./chunk-WQGZQL5E.mjs";import{a as l}from"./chunk-CV6X5VZS.mjs";import{a as c}from"./chunk-NR7TBHSW.mjs";import{Slot as i}from"@jamsrui/slot";import{mergeConfigProps as C}from"@jamsrui/utils";import{AnimatePresence as T}from"motion/react";import{jsx as t,jsxs as f}from"react/jsx-runtime";var D=u=>{let e=r(),P=C(e,e,u),{label:b,children:d,slots:o,...g}=P,x=s(g);return t(c,{value:x,children:t(i,{slot:o?.root,children:t(h,{children:t(i,{slot:o?.wrapper,children:f(a,{children:[t(i,{slot:o?.input,children:t(n,{})}),t(i,{slot:o?.content,children:f(l,{children:[t(i,{slot:o?.label,children:t(p,{children:b})}),t(i,{slot:o?.description,children:t(S,{children:d})})]})}),t(T,{initial:!1,children:t(i,{slot:o?.track,children:t(m,{children:t(i,{slot:o?.thumb,children:t(w,{})})})})})]})})})})})};export{D as a};
@@ -1 +0,0 @@
1
- import{b as t}from"./chunk-NR7TBHSW.mjs";import{motion as r}from"motion/react";import{jsx as e}from"react/jsx-runtime";var p=o=>{let{getThumbProps:i}=t();return e(r.div,{...i(o),children:o.children})};export{p as a};
@@ -1 +0,0 @@
1
- import{b as e}from"./chunk-NR7TBHSW.mjs";import{useRenderElement as p}from"@jamsrui/hooks";var m=r=>{let{getWrapperProps:t}=e();return p("label",{props:[t(r)]})};export{m as a};
@@ -1 +0,0 @@
1
- import{a as n}from"./chunk-4FAMDC4W.mjs";import{useCallback as a,useId as L,useMemo as M}from"react";import{useControlledState as W,useFocusVisible as A,useMergeRefs as E,usePress as F}from"@jamsrui/hooks";import{cn as r,dataAttr as p,dataAttrDev as l,mapPropsVariants as j,mergeProps as H}from"@jamsrui/utils";var z=R=>{let[I,G]=j(R,n.variantKeys),e=n(G),{isChecked:T,defaultChecked:v,onCheckedChange:V,isDisabled:o,isReadonly:c,classNames:s}=I,[i,m]=W({defaultProp:v,onChange:V,prop:T}),{isFocusVisible:h,ref:D}=A({isDisabled:o}),{isPressed:d,ref:x}=F({isDisabled:o}),u=E([D,x]),w=L(),P=a(t=>{!o&&!c&&m(t.target.checked)},[o,c,m]),b=a(t=>({...t,className:e.root({className:r(s?.root,t.className)}),"data-slot":l("root"),"data-component":l("switch"),"data-checked":p(i),"data-focus-visible":p(h),"data-pressed":p(d),"data-disabled":p(o)}),[s?.root,i,o,h,d,e]),N=a(t=>({...H(t,{onChange:P}),ref:u,type:"checkbox","data-slot":l("input"),className:e.input({className:r(s?.input,t.className)}),disabled:o,readOnly:c}),[s?.input,P,u,o,c,e]),S=a(t=>({...t,"data-slot":"track",className:e.track({className:r(s?.track,t.className)})}),[s?.track,e]),f=a(t=>({...t,layoutId:w,"data-slot":"thumb",className:e.thumb({className:r(s?.thumb,t.className)})}),[s?.thumb,w,e]),C=a(t=>({...t,"data-slot":"label",className:e.label({className:r(s?.label,t.className)})}),[s?.label,e]),k=a(t=>({...t,"data-slot":"description",className:e.description({className:r(s?.description,t.className)})}),[s?.description,e]),y=a(t=>({...t,"data-slot":"content",className:e.content({className:r(s?.content,t.className)})}),[s?.content,e]),g=a(t=>({...t,"data-slot":"wrapper",className:e.wrapper({className:r(s?.wrapper,t.className)})}),[s?.wrapper,e]);return M(()=>({isChecked:i,getRootProps:b,getThumbProps:f,getLabelProps:C,getDescriptionProps:k,getContentProps:y,getWrapperProps:g,getTrackProps:S,getInputProps:N}),[i,b,f,C,k,y,g,S,N])};export{z as a};
@@ -1 +0,0 @@
1
- import{b as e}from"./chunk-NR7TBHSW.mjs";import{useRenderElement as o}from"@jamsrui/hooks";var m=r=>{let{getLabelProps:t}=e();return o("span",{props:[t(r)]})};export{m as a};
@@ -1 +0,0 @@
1
- import{b as r}from"./chunk-NR7TBHSW.mjs";import{useRenderElement as o}from"@jamsrui/hooks";var c=e=>{let{getTrackProps:t}=r();return o("div",{props:[t(e)]})};export{c as a};
@@ -1 +0,0 @@
1
- import{b as e}from"./chunk-NR7TBHSW.mjs";import{useRenderElement as o}from"@jamsrui/hooks";var n=r=>{let{getDescriptionProps:t}=e();return o("div",{props:[t(r)]})};export{n as a};
@@ -1 +0,0 @@
1
- import{b as t}from"./chunk-NR7TBHSW.mjs";import{useRenderElement as p}from"@jamsrui/hooks";var i=e=>{let{getInputProps:r}=t();return p("input",{props:[r(e)]})};export{i as a};
@@ -1,18 +0,0 @@
1
- export { Switch } from './switch.mjs';
2
- export { SwitchConfig, useSwitchConfig } from './switch-config.mjs';
3
- export { SwitchContent } from './switch-content.mjs';
4
- export { SwitchContext, useSwitchContext } from './switch-context.mjs';
5
- export { SwitchDescription } from './switch-description.mjs';
6
- export { SwitchInput } from './switch-input.mjs';
7
- export { SwitchLabel } from './switch-label.mjs';
8
- export { SwitchRoot } from './switch-root.mjs';
9
- export { SwitchThumb } from './switch-thumb.mjs';
10
- export { SwitchTrack } from './switch-track.mjs';
11
- export { SwitchWrapper } from './switch-wrapper.mjs';
12
- export { useSwitch } from './use-switch.mjs';
13
- import 'react/jsx-runtime';
14
- import '@jamsrui/core';
15
- import 'react';
16
- import '@jamsrui/utils';
17
- import 'motion/react';
18
- import './styles.mjs';
@@ -1 +0,0 @@
1
- "use client";import"../chunk-PXWG26DS.mjs";import{a as h}from"../chunk-YZHN6POK.mjs";import{a as i}from"../chunk-ZID55QUD.mjs";import{a as j}from"../chunk-X76H4PSZ.mjs";import{a as k}from"../chunk-UV6DZE4H.mjs";import{a as l}from"../chunk-VP7BK66R.mjs";import{a as m}from"../chunk-YFRKKQNC.mjs";import{a as n}from"../chunk-VSR2PVUI.mjs";import{a as f}from"../chunk-BXBHWVKC.mjs";import{a as e}from"../chunk-WQGZQL5E.mjs";import"../chunk-4FAMDC4W.mjs";import{a,b}from"../chunk-IIZ5FKIW.mjs";import{a as g}from"../chunk-CV6X5VZS.mjs";import{a as c,b as d}from"../chunk-NR7TBHSW.mjs";export{f as Switch,a as SwitchConfig,g as SwitchContent,c as SwitchContext,h as SwitchDescription,i as SwitchInput,j as SwitchLabel,k as SwitchRoot,l as SwitchThumb,m as SwitchTrack,n as SwitchWrapper,e as useSwitch,b as useSwitchConfig,d as useSwitchContext};
@@ -1 +0,0 @@
1
- import{a}from"../chunk-4FAMDC4W.mjs";export{a as switchVariants};
@@ -1,27 +0,0 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { WithGlobalConfig } from '@jamsrui/core';
3
- import { Switch } from './switch.mjs';
4
- import './use-switch.mjs';
5
- import '@jamsrui/utils';
6
- import './styles.mjs';
7
- import './switch-content.mjs';
8
- import 'react';
9
- import './switch-description.mjs';
10
- import './switch-input.mjs';
11
- import './switch-label.mjs';
12
- import './switch-root.mjs';
13
- import './switch-thumb.mjs';
14
- import 'motion/react';
15
- import './switch-track.mjs';
16
- import './switch-wrapper.mjs';
17
-
18
- declare const useSwitchConfig: () => SwitchConfig.Props;
19
- declare const SwitchConfig: (props: Omit<Partial<SwitchConfig.Props>, "children"> & {
20
- merge?: boolean;
21
- children: React.ReactNode;
22
- }) => react_jsx_runtime.JSX.Element;
23
- declare namespace SwitchConfig {
24
- type Props = WithGlobalConfig<Switch.Props>;
25
- }
26
-
27
- export { SwitchConfig, useSwitchConfig };
@@ -1 +0,0 @@
1
- import{a,b}from"../chunk-IIZ5FKIW.mjs";export{a as SwitchConfig,b as useSwitchConfig};
@@ -1 +0,0 @@
1
- import{a}from"../chunk-CV6X5VZS.mjs";import"../chunk-NR7TBHSW.mjs";export{a as SwitchContent};
@@ -1 +0,0 @@
1
- import{a,b}from"../chunk-NR7TBHSW.mjs";export{a as SwitchContext,b as useSwitchContext};
@@ -1,10 +0,0 @@
1
- import * as react from 'react';
2
- import { UIProps } from '@jamsrui/utils';
3
-
4
- declare const SwitchDescription: (props: SwitchDescription.Props) => react.ReactElement<unknown, string | react.JSXElementConstructor<any>>;
5
- declare namespace SwitchDescription {
6
- interface Props extends UIProps<"div"> {
7
- }
8
- }
9
-
10
- export { SwitchDescription };
@@ -1 +0,0 @@
1
- import{a}from"../chunk-YZHN6POK.mjs";import"../chunk-NR7TBHSW.mjs";export{a as SwitchDescription};
@@ -1 +0,0 @@
1
- import{a}from"../chunk-ZID55QUD.mjs";import"../chunk-NR7TBHSW.mjs";export{a as SwitchInput};
@@ -1,10 +0,0 @@
1
- import * as react from 'react';
2
- import { UIProps } from '@jamsrui/utils';
3
-
4
- declare const SwitchLabel: (props: SwitchLabel.Props) => react.ReactElement<unknown, string | react.JSXElementConstructor<any>>;
5
- declare namespace SwitchLabel {
6
- interface Props extends UIProps<"span"> {
7
- }
8
- }
9
-
10
- export { SwitchLabel };
@@ -1 +0,0 @@
1
- import{a}from"../chunk-X76H4PSZ.mjs";import"../chunk-NR7TBHSW.mjs";export{a as SwitchLabel};
@@ -1 +0,0 @@
1
- import{a}from"../chunk-UV6DZE4H.mjs";import"../chunk-NR7TBHSW.mjs";export{a as SwitchRoot};
@@ -1 +0,0 @@
1
- import{a}from"../chunk-VP7BK66R.mjs";import"../chunk-NR7TBHSW.mjs";export{a as SwitchThumb};
@@ -1 +0,0 @@
1
- import{a}from"../chunk-YFRKKQNC.mjs";import"../chunk-NR7TBHSW.mjs";export{a as SwitchTrack};
@@ -1,10 +0,0 @@
1
- import * as react from 'react';
2
- import { UIProps } from '@jamsrui/utils';
3
-
4
- declare const SwitchWrapper: (props: SwitchWrapper.Props) => react.ReactElement<unknown, string | react.JSXElementConstructor<any>>;
5
- declare namespace SwitchWrapper {
6
- interface Props extends UIProps<"label"> {
7
- }
8
- }
9
-
10
- export { SwitchWrapper };
@@ -1 +0,0 @@
1
- import{a}from"../chunk-VSR2PVUI.mjs";import"../chunk-NR7TBHSW.mjs";export{a as SwitchWrapper};
@@ -1,22 +0,0 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { useSwitch } from './use-switch.mjs';
3
- import '@jamsrui/utils';
4
- import './styles.mjs';
5
- import './switch-content.mjs';
6
- import 'react';
7
- import './switch-description.mjs';
8
- import './switch-input.mjs';
9
- import './switch-label.mjs';
10
- import './switch-root.mjs';
11
- import './switch-thumb.mjs';
12
- import 'motion/react';
13
- import './switch-track.mjs';
14
- import './switch-wrapper.mjs';
15
-
16
- declare const Switch: (props: Switch.Props) => react_jsx_runtime.JSX.Element;
17
- declare namespace Switch {
18
- interface Props extends useSwitch.Props {
19
- }
20
- }
21
-
22
- export { Switch };
@@ -1 +0,0 @@
1
- import{a}from"../chunk-BXBHWVKC.mjs";import"../chunk-WQGZQL5E.mjs";import"../chunk-4FAMDC4W.mjs";import"../chunk-IIZ5FKIW.mjs";import"../chunk-NR7TBHSW.mjs";export{a as Switch};
@@ -1 +0,0 @@
1
- import{a}from"../chunk-WQGZQL5E.mjs";import"../chunk-4FAMDC4W.mjs";export{a as useSwitch};
File without changes