@jamsrui/switch 0.0.7 → 0.0.9
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 +13 -11
- package/dist/index.mjs +1 -1
- package/dist/primitive/index.d.mts +18 -0
- package/dist/primitive/index.mjs +1 -0
- package/dist/{styles.d.mts → primitive/styles.d.mts} +7 -17
- package/dist/primitive/styles.mjs +1 -0
- package/dist/primitive/switch-config.d.mts +27 -0
- package/dist/primitive/switch-config.mjs +1 -0
- package/dist/{switch-context.d.mts → primitive/switch-context.d.mts} +6 -5
- package/dist/primitive/switch-input.d.mts +10 -0
- package/dist/primitive/switch-input.mjs +1 -0
- package/dist/{switch-label.d.mts → primitive/switch-label.d.mts} +2 -2
- package/dist/primitive/switch-label.mjs +1 -0
- package/dist/primitive/switch-root.d.mts +10 -0
- package/dist/primitive/switch-root.mjs +1 -0
- package/dist/primitive/switch-thumb.d.mts +10 -0
- package/dist/primitive/switch-thumb.mjs +1 -0
- package/dist/{switch-track.d.mts → primitive/switch-track.d.mts} +1 -1
- package/dist/primitive/switch-track.mjs +1 -0
- package/dist/{switch-wrapper.d.mts → primitive/switch-wrapper.d.mts} +1 -1
- package/dist/primitive/switch-wrapper.mjs +1 -0
- package/dist/primitive/switch.d.mts +22 -0
- package/dist/primitive/switch.mjs +1 -0
- package/dist/primitive/use-switch.d.mts +38 -0
- package/dist/primitive/use-switch.mjs +1 -0
- package/dist/switch-config.d.mts +16 -14
- package/dist/switch.d.mts +23 -12
- package/dist/switch.mjs +1 -1
- package/package.json +11 -10
- package/dist/styles.mjs +0 -1
- package/dist/switch-B3u5LmQm.d.mts +0 -54
- package/dist/switch-label.mjs +0 -1
- package/dist/switch-thumb.d.mts +0 -10
- package/dist/switch-thumb.mjs +0 -1
- package/dist/switch-track.mjs +0 -1
- package/dist/switch-wrapper.mjs +0 -1
- package/dist/swith-error-message.d.mts +0 -10
- package/dist/swith-error-message.mjs +0 -1
- package/dist/use-switch.d.mts +0 -13
- package/dist/use-switch.mjs +0 -1
- /package/dist/{swith-content.d.mts → primitive/switch-content.d.mts} +0 -0
- /package/dist/{swith-content.mjs → primitive/switch-content.mjs} +0 -0
- /package/dist/{switch-context.mjs → primitive/switch-context.mjs} +0 -0
- /package/dist/{switch-description.d.mts → primitive/switch-description.d.mts} +0 -0
- /package/dist/{switch-description.mjs → primitive/switch-description.mjs} +0 -0
package/dist/index.d.mts
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
export { S as Switch } from './switch-B3u5LmQm.mjs';
|
|
2
1
|
export { SwitchConfig, useSwitchConfig } from './switch-config.mjs';
|
|
2
|
+
export { Switch } from './switch.mjs';
|
|
3
3
|
import 'react/jsx-runtime';
|
|
4
|
+
import '@jamsrui/core';
|
|
5
|
+
import './primitive/use-switch.mjs';
|
|
4
6
|
import '@jamsrui/utils';
|
|
5
|
-
import './styles.mjs';
|
|
6
|
-
import '
|
|
7
|
-
import './switch-description.mjs';
|
|
7
|
+
import './primitive/styles.mjs';
|
|
8
|
+
import './primitive/switch-content.mjs';
|
|
8
9
|
import 'react';
|
|
9
|
-
import './switch-
|
|
10
|
-
import './switch-
|
|
11
|
-
import './switch-
|
|
12
|
-
import './switch-
|
|
13
|
-
import './
|
|
14
|
-
import '
|
|
15
|
-
import '
|
|
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';
|
|
15
|
+
import 'motion/react';
|
|
16
|
+
import './primitive/switch-track.mjs';
|
|
17
|
+
import './primitive/switch-wrapper.mjs';
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{
|
|
1
|
+
"use client";import{SwitchConfig as t,useSwitchConfig as e}from"./switch-config";import{Switch as f}from"./switch";export{f as Switch,t as SwitchConfig,e as useSwitchConfig};
|
|
@@ -0,0 +1,18 @@
|
|
|
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';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{Switch as r}from"./switch";import{SwitchConfig as i,useSwitchConfig as c}from"./switch-config";import{SwitchContent as h}from"./switch-content";import{SwitchContext as w,useSwitchContext as x}from"./switch-context";import{SwitchDescription as m}from"./switch-description";import{SwitchInput as u}from"./switch-input";import{SwitchLabel as C}from"./switch-label";import{SwitchRoot as b}from"./switch-root";import{SwitchThumb as l}from"./switch-thumb";import{SwitchTrack as k}from"./switch-track";import{SwitchWrapper as I}from"./switch-wrapper";import{useSwitch as R}from"./use-switch";export{r as Switch,i as SwitchConfig,h as SwitchContent,w as SwitchContext,m as SwitchDescription,u as SwitchInput,C as SwitchLabel,b as SwitchRoot,l as SwitchThumb,k as SwitchTrack,I as SwitchWrapper,R as useSwitch,c as useSwitchConfig,x as useSwitchContext};
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _jamsrui_utils from '@jamsrui/utils';
|
|
2
2
|
import { VariantProps } from '@jamsrui/utils';
|
|
3
3
|
|
|
4
|
-
declare const
|
|
5
|
-
declare const switchVariants: tailwind_variants.TVReturnType<{
|
|
6
|
-
isInvalid: {
|
|
7
|
-
true: {};
|
|
8
|
-
};
|
|
4
|
+
declare const switchVariants: _jamsrui_utils.TVReturnType<{
|
|
9
5
|
color: {
|
|
10
6
|
default: {
|
|
11
7
|
track: string;
|
|
@@ -66,11 +62,8 @@ declare const switchVariants: tailwind_variants.TVReturnType<{
|
|
|
66
62
|
description: string;
|
|
67
63
|
content: string;
|
|
68
64
|
wrapper: string;
|
|
69
|
-
|
|
65
|
+
input: string;
|
|
70
66
|
}, undefined, {
|
|
71
|
-
isInvalid: {
|
|
72
|
-
true: {};
|
|
73
|
-
};
|
|
74
67
|
color: {
|
|
75
68
|
default: {
|
|
76
69
|
track: string;
|
|
@@ -131,11 +124,8 @@ declare const switchVariants: tailwind_variants.TVReturnType<{
|
|
|
131
124
|
description: string;
|
|
132
125
|
content: string;
|
|
133
126
|
wrapper: string;
|
|
134
|
-
|
|
135
|
-
},
|
|
136
|
-
isInvalid: {
|
|
137
|
-
true: {};
|
|
138
|
-
};
|
|
127
|
+
input: string;
|
|
128
|
+
}, _jamsrui_utils.TVReturnType<{
|
|
139
129
|
color: {
|
|
140
130
|
default: {
|
|
141
131
|
track: string;
|
|
@@ -196,9 +186,9 @@ declare const switchVariants: tailwind_variants.TVReturnType<{
|
|
|
196
186
|
description: string;
|
|
197
187
|
content: string;
|
|
198
188
|
wrapper: string;
|
|
199
|
-
|
|
189
|
+
input: string;
|
|
200
190
|
}, undefined, unknown, unknown, undefined>>;
|
|
201
191
|
type SwitchVariants = VariantProps<typeof switchVariants>;
|
|
202
192
|
type SwitchSlots = keyof ReturnType<typeof switchVariants>;
|
|
203
193
|
|
|
204
|
-
export { type SwitchSlots, type SwitchVariants, switchVariants
|
|
194
|
+
export { type SwitchSlots, type SwitchVariants, switchVariants };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{groupDataFocusVisibleClasses as e,tv as r}from"@jamsrui/utils";const s=r({slots:{root:"group flex flex-col gap-2",track:[...e,"flex cursor-pointer shrink-0 items-center rounded-full bg-surface-secondary p-1","uig-disabled:cursor-not-allowed uig-disabled:opacity-60","cursor-default ui-interactive:cursor-pointer 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-pointer 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 switchVariants};
|
|
@@ -0,0 +1,27 @@
|
|
|
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 };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createConfigContext as o}from"@jamsrui/utils";const[t,r]=o({displayName:"SwitchConfig"});export{t as SwitchConfig,r as useSwitchConfig};
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import 'react/jsx-runtime';
|
|
2
|
+
import { useSwitch } from './use-switch.mjs';
|
|
4
3
|
import '@jamsrui/utils';
|
|
5
4
|
import './styles.mjs';
|
|
6
|
-
import '
|
|
5
|
+
import './switch-content.mjs';
|
|
7
6
|
import './switch-description.mjs';
|
|
7
|
+
import './switch-input.mjs';
|
|
8
8
|
import './switch-label.mjs';
|
|
9
|
+
import './switch-root.mjs';
|
|
9
10
|
import './switch-thumb.mjs';
|
|
11
|
+
import 'react/jsx-runtime';
|
|
12
|
+
import 'motion/react';
|
|
10
13
|
import './switch-track.mjs';
|
|
11
14
|
import './switch-wrapper.mjs';
|
|
12
|
-
import './swith-content.mjs';
|
|
13
|
-
import './swith-error-message.mjs';
|
|
14
15
|
|
|
15
16
|
declare const useSwitchContext: () => SwitchContext.Props;
|
|
16
17
|
declare const SwitchContext: react.Context<SwitchContext.Props | null>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { UIProps } from '@jamsrui/utils';
|
|
3
|
+
|
|
4
|
+
declare const SwitchInput: (props: SwitchInput.Props) => react.ReactElement<unknown, string | react.JSXElementConstructor<any>>;
|
|
5
|
+
declare namespace SwitchInput {
|
|
6
|
+
interface Props extends UIProps<"input"> {
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export { SwitchInput };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useRenderElement as r}from"@jamsrui/hooks";import{useSwitchContext as p}from"./switch-context";const i=t=>{const{getInputProps:e}=p();return r("input",{props:[e(t)]})};export{i as SwitchInput};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { UIProps } from '@jamsrui/utils';
|
|
3
3
|
|
|
4
|
-
declare const SwitchLabel: (props: SwitchLabel.Props) => react.ReactElement<unknown, string | react.JSXElementConstructor<any
|
|
4
|
+
declare const SwitchLabel: (props: SwitchLabel.Props) => react.ReactElement<unknown, string | react.JSXElementConstructor<any>>;
|
|
5
5
|
declare namespace SwitchLabel {
|
|
6
|
-
interface Props extends UIProps<"
|
|
6
|
+
interface Props extends UIProps<"span"> {
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
9
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useRenderElement as t}from"@jamsrui/hooks";import{useSwitchContext as o}from"./switch-context";const m=e=>{const{getLabelProps:r}=o();return t("span",{props:[r(e)]})};export{m as SwitchLabel};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { UIProps } from '@jamsrui/utils';
|
|
3
|
+
|
|
4
|
+
declare const SwitchRoot: (props: SwitchRoot.Props) => react.ReactElement<unknown, string | react.JSXElementConstructor<any>>;
|
|
5
|
+
declare namespace SwitchRoot {
|
|
6
|
+
interface Props extends UIProps<"div"> {
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export { SwitchRoot };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useRenderElement as o}from"@jamsrui/hooks";import{useSwitchContext as r}from"./switch-context";const i=t=>{const{getRootProps:e}=r();return o("div",{props:[e(t)]})};export{i as SwitchRoot};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { HTMLMotionProps } from 'motion/react';
|
|
3
|
+
|
|
4
|
+
declare const SwitchThumb: (props: SwitchThumb.Props) => react_jsx_runtime.JSX.Element;
|
|
5
|
+
declare namespace SwitchThumb {
|
|
6
|
+
interface Props extends HTMLMotionProps<"div"> {
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export { SwitchThumb };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as e}from"react/jsx-runtime";import{motion as i}from"motion/react";import{useSwitchContext as r}from"./switch-context";const p=o=>{const{getThumbProps:t}=r();return e(i.div,{...t(o),children:o.children})};export{p as SwitchThumb};
|
|
@@ -3,7 +3,7 @@ import { UIProps } from '@jamsrui/utils';
|
|
|
3
3
|
|
|
4
4
|
declare const SwitchTrack: (props: SwitchTrack.Props) => react.ReactElement<unknown, string | react.JSXElementConstructor<any>>;
|
|
5
5
|
declare namespace SwitchTrack {
|
|
6
|
-
interface Props extends UIProps<"
|
|
6
|
+
interface Props extends UIProps<"div"> {
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
9
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useRenderElement as t}from"@jamsrui/hooks";import{useSwitchContext as o}from"./switch-context";const c=r=>{const{getTrackProps:e}=o();return t("div",{props:[e(r)]})};export{c as SwitchTrack};
|
|
@@ -3,7 +3,7 @@ import { UIProps } from '@jamsrui/utils';
|
|
|
3
3
|
|
|
4
4
|
declare const SwitchWrapper: (props: SwitchWrapper.Props) => react.ReactElement<unknown, string | react.JSXElementConstructor<any>>;
|
|
5
5
|
declare namespace SwitchWrapper {
|
|
6
|
-
interface Props extends UIProps<"
|
|
6
|
+
interface Props extends UIProps<"label"> {
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
9
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useRenderElement as t}from"@jamsrui/hooks";import{useSwitchContext as p}from"./switch-context";const m=e=>{const{getWrapperProps:r}=p();return t("label",{props:[r(e)]})};export{m as SwitchWrapper};
|
|
@@ -0,0 +1,22 @@
|
|
|
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 };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as p}from"react/jsx-runtime";import{mergeConfigProps as c}from"@jamsrui/utils";import{useSwitchConfig as i}from"./switch-config";import{SwitchContext as n}from"./switch-context";import{useSwitch as s}from"./use-switch";const S=t=>{const o=i(),e=c(o,o,t),r=s(e);return p(n,{value:r,children:t.children})};export{S as Switch};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { PropGetter, SlotsToClassNames } from '@jamsrui/utils';
|
|
2
|
+
import { SwitchVariants, SwitchSlots } from './styles.mjs';
|
|
3
|
+
import { SwitchContent } from './switch-content.mjs';
|
|
4
|
+
import { SwitchDescription } from './switch-description.mjs';
|
|
5
|
+
import { SwitchInput } from './switch-input.mjs';
|
|
6
|
+
import { SwitchLabel } from './switch-label.mjs';
|
|
7
|
+
import { SwitchRoot } from './switch-root.mjs';
|
|
8
|
+
import { SwitchThumb } from './switch-thumb.mjs';
|
|
9
|
+
import { SwitchTrack } from './switch-track.mjs';
|
|
10
|
+
import { SwitchWrapper } from './switch-wrapper.mjs';
|
|
11
|
+
import 'react';
|
|
12
|
+
import 'react/jsx-runtime';
|
|
13
|
+
import 'motion/react';
|
|
14
|
+
|
|
15
|
+
declare const useSwitch: (props: useSwitch.Props) => {
|
|
16
|
+
isChecked: boolean;
|
|
17
|
+
getRootProps: PropGetter<SwitchRoot.Props>;
|
|
18
|
+
getThumbProps: PropGetter<SwitchThumb.Props>;
|
|
19
|
+
getLabelProps: PropGetter<SwitchLabel.Props>;
|
|
20
|
+
getDescriptionProps: PropGetter<SwitchDescription.Props>;
|
|
21
|
+
getContentProps: PropGetter<SwitchContent.Props>;
|
|
22
|
+
getWrapperProps: PropGetter<SwitchWrapper.Props>;
|
|
23
|
+
getTrackProps: PropGetter<SwitchTrack.Props>;
|
|
24
|
+
getInputProps: PropGetter<SwitchInput.Props>;
|
|
25
|
+
};
|
|
26
|
+
declare namespace useSwitch {
|
|
27
|
+
interface Props extends SwitchVariants {
|
|
28
|
+
isReadonly?: boolean;
|
|
29
|
+
isDisabled?: boolean;
|
|
30
|
+
isChecked?: boolean;
|
|
31
|
+
onCheckedChange?: (value: boolean) => void;
|
|
32
|
+
defaultChecked?: boolean;
|
|
33
|
+
children?: React.ReactNode;
|
|
34
|
+
classNames?: SlotsToClassNames<SwitchSlots>;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export { useSwitch };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
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 n,mapPropsVariants as j,mergeProps as H}from"@jamsrui/utils";import{switchVariants as g}from"./styles";const z=R=>{const[I,G]=j(R,g.variantKeys),e=g(G),{isChecked:T,defaultChecked:v,onCheckedChange:V,isDisabled:o,isReadonly:c,classNames:s}=I,[i,l]=W({defaultProp:v,onChange:V,prop:T}),{isFocusVisible:m,ref:D}=A({isDisabled:o}),{isPressed:h,ref:x}=F({isDisabled:o}),d=E([D,x]),u=L(),w=a(t=>{!o&&!c&&l(t.target.checked)},[o,c,l]),P=a(t=>({...t,className:e.root({className:r(s?.root,t.className)}),"data-slot":n("root"),"data-component":n("switch"),"data-checked":p(i),"data-focus-visible":p(m),"data-pressed":p(h),"data-disabled":p(o)}),[s?.root,i,o,m,h,e]),b=a(t=>({...H(t,{onChange:w}),ref:d,type:"checkbox","data-slot":n("input"),className:e.input({className:r(s?.input,t.className)}),disabled:o,readOnly:c}),[s?.input,w,d,o,c,e]),N=a(t=>({...t,"data-slot":"track",className:e.track({className:r(s?.track,t.className)})}),[s?.track,e]),S=a(t=>({...t,layoutId:u,"data-slot":"thumb",className:e.thumb({className:r(s?.thumb,t.className)})}),[s?.thumb,u,e]),f=a(t=>({...t,"data-slot":"label",className:e.label({className:r(s?.label,t.className)})}),[s?.label,e]),C=a(t=>({...t,"data-slot":"description",className:e.description({className:r(s?.description,t.className)})}),[s?.description,e]),k=a(t=>({...t,"data-slot":"content",className:e.content({className:r(s?.content,t.className)})}),[s?.content,e]),y=a(t=>({...t,"data-slot":"wrapper",className:e.wrapper({className:r(s?.wrapper,t.className)})}),[s?.wrapper,e]);return M(()=>({isChecked:i,getRootProps:P,getThumbProps:S,getLabelProps:f,getDescriptionProps:C,getContentProps:k,getWrapperProps:y,getTrackProps:N,getInputProps:b}),[i,P,S,f,C,k,y,N,b])};export{z as useSwitch};
|
package/dist/switch-config.d.mts
CHANGED
|
@@ -1,25 +1,27 @@
|
|
|
1
|
-
import { S as Switch } from './switch-B3u5LmQm.mjs';
|
|
2
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
|
-
import {
|
|
2
|
+
import { WithGlobalConfig } from '@jamsrui/core';
|
|
3
|
+
import { Switch } from './switch.mjs';
|
|
4
|
+
import './primitive/use-switch.mjs';
|
|
4
5
|
import '@jamsrui/utils';
|
|
5
|
-
import './styles.mjs';
|
|
6
|
-
import '
|
|
7
|
-
import './switch-description.mjs';
|
|
6
|
+
import './primitive/styles.mjs';
|
|
7
|
+
import './primitive/switch-content.mjs';
|
|
8
8
|
import 'react';
|
|
9
|
-
import './switch-
|
|
10
|
-
import './switch-
|
|
11
|
-
import './switch-
|
|
12
|
-
import './switch-
|
|
13
|
-
import './
|
|
14
|
-
import '
|
|
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';
|
|
14
|
+
import 'motion/react';
|
|
15
|
+
import './primitive/switch-track.mjs';
|
|
16
|
+
import './primitive/switch-wrapper.mjs';
|
|
15
17
|
|
|
16
18
|
declare const useSwitchConfig: () => SwitchConfig.Props;
|
|
17
|
-
declare const SwitchConfig: (props: SwitchConfig.Props & {
|
|
19
|
+
declare const SwitchConfig: (props: Omit<Partial<SwitchConfig.Props>, "children"> & {
|
|
18
20
|
merge?: boolean;
|
|
21
|
+
children: React.ReactNode;
|
|
19
22
|
}) => react_jsx_runtime.JSX.Element;
|
|
20
23
|
declare namespace SwitchConfig {
|
|
21
|
-
|
|
22
|
-
}
|
|
24
|
+
type Props = WithGlobalConfig<Switch.Props>;
|
|
23
25
|
}
|
|
24
26
|
|
|
25
27
|
export { SwitchConfig, useSwitchConfig };
|
package/dist/switch.d.mts
CHANGED
|
@@ -1,13 +1,24 @@
|
|
|
1
|
-
import 'react/jsx-runtime';
|
|
2
|
-
|
|
3
|
-
import '@jamsrui/utils';
|
|
4
|
-
import './styles.mjs';
|
|
5
|
-
import '
|
|
6
|
-
import './switch-description.mjs';
|
|
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';
|
|
7
6
|
import 'react';
|
|
8
|
-
import './switch-
|
|
9
|
-
import './switch-
|
|
10
|
-
import './switch-
|
|
11
|
-
import './switch-
|
|
12
|
-
import './
|
|
13
|
-
import '
|
|
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';
|
|
12
|
+
import 'motion/react';
|
|
13
|
+
import './primitive/switch-track.mjs';
|
|
14
|
+
import './primitive/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
|
+
label?: string;
|
|
20
|
+
slots?: SlotsToReactNode<SwitchSlots>;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export { Switch };
|
package/dist/switch.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{jsx as t,jsxs as r}from"react/jsx-runtime";import{Slot as i}from"@jamsrui/slot";import{mergeConfigProps as h}from"@jamsrui/utils";import{AnimatePresence as w}from"motion/react";import{SwitchContent as m,SwitchContext as a,SwitchDescription as f,SwitchInput as u,SwitchLabel as P,SwitchRoot as b,SwitchThumb as d,SwitchTrack as g,SwitchWrapper as x,useSwitch as C}from"./primitive";import{useSwitchConfig as T}from"./switch-config";const D=c=>{const e=T(),s=h(e,e,c),{label:l,children:S,slots:o,...n}=s,p=C(n);return t(a,{value:p,children:t(i,{slot:o?.root,children:t(b,{children:t(i,{slot:o?.wrapper,children:r(x,{children:[t(i,{slot:o?.input,children:t(u,{})}),t(i,{slot:o?.content,children:r(m,{children:[t(i,{slot:o?.label,children:t(P,{children:l})}),t(i,{slot:o?.description,children:t(f,{children:S})})]})}),t(w,{initial:!1,children:t(i,{slot:o?.track,children:t(g,{children:t(i,{slot:o?.thumb,children:t(d,{})})})})})]})})})})})};export{D as Switch};
|
package/package.json
CHANGED
|
@@ -1,15 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jamsrui/switch",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"peerDependencies": {
|
|
5
|
-
"motion": ">=12",
|
|
6
|
-
"react": ">=19"
|
|
7
|
-
},
|
|
8
|
-
"dependencies": {
|
|
9
|
-
"@jamsrui/hooks": "^0.0.7",
|
|
10
|
-
"@jamsrui/utils": "^0.0.7",
|
|
11
|
-
"@jamsrui/core": "^0.0.7"
|
|
12
|
-
},
|
|
3
|
+
"version": "0.0.9",
|
|
13
4
|
"exports": {
|
|
14
5
|
".": {
|
|
15
6
|
"types": "./dist/index.d.ts",
|
|
@@ -17,6 +8,16 @@
|
|
|
17
8
|
"require": "./dist/index.js"
|
|
18
9
|
}
|
|
19
10
|
},
|
|
11
|
+
"peerDependencies": {
|
|
12
|
+
"motion": ">=12",
|
|
13
|
+
"react": ">=19"
|
|
14
|
+
},
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@jamsrui/hooks": "^0.0.9",
|
|
17
|
+
"@jamsrui/core": "^0.0.8",
|
|
18
|
+
"@jamsrui/utils": "^0.0.9",
|
|
19
|
+
"@jamsrui/slot": "^0.0.9"
|
|
20
|
+
},
|
|
20
21
|
"description": "A modern and beautiful Next.js UI components library.",
|
|
21
22
|
"keywords": [
|
|
22
23
|
"react",
|
package/dist/styles.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{focusVisibleClasses as e,tv as r}from"@jamsrui/utils";const s="",a=r({slots:{root:"group flex flex-col gap-2",track:[...e,"flex cursor-pointer shrink-0 items-center rounded-full bg-surface-secondary p-1","uig-disabled:cursor-not-allowed uig-disabled:opacity-60","cursor-default ui-interactive:cursor-pointer 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-500",content:"grid grow gap-1",wrapper:"flex items-center justify-between gap-2",errorMessage:"text-danger text-xs"},variants:{isInvalid:{true:{}},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"},sm:{track:"h-6 w-10",thumb:"size-4"},md:{track:"mr-2 h-7 w-12",thumb:"size-5"},lg:{track:"mr-2 h-8 w-14",thumb:"size-6"}},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{a as switchVariants,s as test};
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { PropGetter, UIProps, SlotsToClassNames } from '@jamsrui/utils';
|
|
3
|
-
import { SwitchVariants, SwitchSlots } from './styles.mjs';
|
|
4
|
-
import { SwitchDescription } from './switch-description.mjs';
|
|
5
|
-
import { SwitchLabel } from './switch-label.mjs';
|
|
6
|
-
import { SwitchThumb } from './switch-thumb.mjs';
|
|
7
|
-
import { SwitchTrack } from './switch-track.mjs';
|
|
8
|
-
import { SwitchWrapper } from './switch-wrapper.mjs';
|
|
9
|
-
import { SwitchContent } from './swith-content.mjs';
|
|
10
|
-
import { SwitchErrorMessage } from './swith-error-message.mjs';
|
|
11
|
-
|
|
12
|
-
declare const useSwitch: (props: useSwitch.Props) => {
|
|
13
|
-
getRootProps: PropGetter<Switch.Props>;
|
|
14
|
-
getThumbProps: PropGetter<SwitchThumb.Props>;
|
|
15
|
-
getLabelProps: PropGetter<SwitchLabel.Props>;
|
|
16
|
-
getDescriptionProps: PropGetter<SwitchDescription.Props>;
|
|
17
|
-
getContentProps: PropGetter<SwitchContent.Props>;
|
|
18
|
-
getWrapperProps: PropGetter<SwitchWrapper.Props>;
|
|
19
|
-
getTrackProps: PropGetter<SwitchTrack.Props>;
|
|
20
|
-
getErrorMessageProps: PropGetter<SwitchErrorMessage.Props>;
|
|
21
|
-
label: string | undefined;
|
|
22
|
-
errorMessage: string | undefined;
|
|
23
|
-
hasContent: boolean;
|
|
24
|
-
};
|
|
25
|
-
declare namespace useSwitch {
|
|
26
|
-
interface Props extends SwitchVariants, UIProps<"div"> {
|
|
27
|
-
label?: string;
|
|
28
|
-
errorMessage?: string;
|
|
29
|
-
classNames?: SlotsToClassNames<SwitchSlots>;
|
|
30
|
-
slotProps?: {
|
|
31
|
-
track?: SwitchTrack.Props;
|
|
32
|
-
thumb?: SwitchThumb.Props;
|
|
33
|
-
label?: SwitchLabel.Props;
|
|
34
|
-
description?: SwitchDescription.Props;
|
|
35
|
-
content?: SwitchContent.Props;
|
|
36
|
-
wrapper?: SwitchWrapper.Props;
|
|
37
|
-
errorMessage?: SwitchErrorMessage.Props;
|
|
38
|
-
};
|
|
39
|
-
isReadonly?: boolean;
|
|
40
|
-
isDisabled?: boolean;
|
|
41
|
-
isChecked?: boolean;
|
|
42
|
-
onCheckedChange?: (value: boolean) => void;
|
|
43
|
-
defaultChecked?: boolean;
|
|
44
|
-
isInvalid?: boolean;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
declare const Switch: (props: Switch.Props) => react_jsx_runtime.JSX.Element;
|
|
49
|
-
declare namespace Switch {
|
|
50
|
-
interface Props extends useSwitch.Props {
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export { Switch as S, useSwitch as u };
|
package/dist/switch-label.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{useRenderElement as l}from"@jamsrui/hooks";import{useSwitchContext as n}from"./switch-context";const i=r=>{const{getLabelProps:t,label:e}=n(),o=l("label",{props:[t(r),{children:e}]});return e?o:null};export{i as SwitchLabel};
|
package/dist/switch-thumb.d.mts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import * as react from 'react';
|
|
2
|
-
import { UIProps } from '@jamsrui/utils';
|
|
3
|
-
|
|
4
|
-
declare const SwitchThumb: (props: SwitchThumb.Props) => react.ReactElement<unknown, string | react.JSXElementConstructor<any>>;
|
|
5
|
-
declare namespace SwitchThumb {
|
|
6
|
-
interface Props extends UIProps<"div"> {
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export { SwitchThumb };
|
package/dist/switch-thumb.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{useRenderElement as t}from"@jamsrui/hooks";import{useSwitchContext as o}from"./switch-context";const n=e=>{const{getThumbProps:r}=o();return t("div",{props:[r(e)]})};export{n as SwitchThumb};
|
package/dist/switch-track.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{useRenderElement as e}from"@jamsrui/hooks";import{useSwitchContext as o}from"./switch-context";const c=r=>{const{getTrackProps:t}=o();return e("button",{props:[t(r)]})};export{c as SwitchTrack};
|
package/dist/switch-wrapper.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{useRenderElement as t}from"@jamsrui/hooks";import{useSwitchContext as p}from"./switch-context";const i=r=>{const{getWrapperProps:e}=p();return t("div",{props:[e(r)]})};export{i as SwitchWrapper};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import * as react from 'react';
|
|
2
|
-
import { UIProps } from '@jamsrui/utils';
|
|
3
|
-
|
|
4
|
-
declare const SwitchErrorMessage: (props: SwitchErrorMessage.Props) => react.ReactElement<unknown, string | react.JSXElementConstructor<any>>;
|
|
5
|
-
declare namespace SwitchErrorMessage {
|
|
6
|
-
interface Props extends UIProps<"span"> {
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export { SwitchErrorMessage };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{useRenderElement as o}from"@jamsrui/hooks";import{useSwitchContext as t}from"./switch-context";const i=r=>{const{getErrorMessageProps:e,errorMessage:s}=t();return o("span",{props:[e(r),{children:s}]})};export{i as SwitchErrorMessage};
|
package/dist/use-switch.d.mts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import '@jamsrui/utils';
|
|
2
|
-
import './styles.mjs';
|
|
3
|
-
export { u as useSwitch } from './switch-B3u5LmQm.mjs';
|
|
4
|
-
import './switch-description.mjs';
|
|
5
|
-
import './switch-label.mjs';
|
|
6
|
-
import './switch-thumb.mjs';
|
|
7
|
-
import './switch-track.mjs';
|
|
8
|
-
import './switch-wrapper.mjs';
|
|
9
|
-
import './swith-content.mjs';
|
|
10
|
-
import './swith-error-message.mjs';
|
|
11
|
-
import 'tailwind-variants';
|
|
12
|
-
import 'react/jsx-runtime';
|
|
13
|
-
import 'react';
|
package/dist/use-switch.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{useCallback as a,useMemo as M}from"react";import{cn as o,dataAttrDev as g,mapPropsVariants as T,mergeProps as c}from"@jamsrui/utils";import{switchVariants as u}from"./styles";const I=k=>{const[f,C]=T(k,u.variantKeys),s=u(C),{classNames:r,slotProps:e,label:i,errorMessage:l,children:y,isChecked:G,defaultChecked:v,onCheckedChange:D,isDisabled:x,isReadonly:E,...p}=f,n=a(()=>({...p,"data-slot":g("root"),"data-component":g("switch"),className:s.root({className:o(r?.root,p.className)})}),[r?.root,p,s]),m=a(t=>({...c(e?.thumb,t),"data-slot":"thumb",className:s.thumb({className:o(e?.thumb?.className,r?.thumb,t.className)})}),[r?.thumb,e?.thumb,s]),h=a(t=>({...c(e?.label,t),"data-slot":"label",className:s.label({className:o(e?.label?.className,r?.label,t.className)})}),[r?.label,e?.label,s]),w=a(t=>({...c(e?.description,t),"data-slot":"description",className:s.description({className:o(e?.description?.className,r?.description,t.className)})}),[r?.description,e?.description,s]),P=a(t=>({...c(e?.content,t),"data-slot":"content",className:s.content({className:o(e?.content?.className,r?.content,t.className)})}),[r?.content,e?.content,s]),b=a(t=>({...c(e?.wrapper,t),"data-slot":"wrapper",className:s.wrapper({className:o(e?.wrapper?.className,r?.wrapper,t.className)})}),[r?.wrapper,e?.wrapper,s]),d=a(t=>({...c(e?.track,t),"data-slot":"track",className:s.track({className:o(e?.track?.className,r?.track,t.className)})}),[r?.track,e?.track,s]),N=a(t=>({...c(e?.errorMessage,t),"data-slot":"error-message",className:s.errorMessage({className:o(e?.errorMessage?.className,r?.errorMessage,t.className)})}),[r?.errorMessage,e?.errorMessage,s]),S=!!i||!!y;return M(()=>({getRootProps:n,getThumbProps:m,getLabelProps:h,getDescriptionProps:w,getContentProps:P,getWrapperProps:b,getTrackProps:d,getErrorMessageProps:N,label:i,errorMessage:l,hasContent:S}),[n,m,h,w,P,b,d,N,i,l,S])};export{I as useSwitch};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|