@skeletonlabs/skeleton-react 1.0.0-next.0 → 1.0.0-next.1

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,3 @@
1
+ import React from "react";
2
+ import { SwitchProps } from "./types.js";
3
+ export declare const Switch: React.FC<SwitchProps>;
@@ -0,0 +1,41 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ export const Switch = ({ id = "", name = "", checked = false, disabled = false, compact = false,
4
+ // Aria
5
+ labelledby = undefined, describedby = undefined,
6
+ // Root (Track)
7
+ base = "flex cursor-pointer transition duration-200", stateInactive = "preset-filled-surface-200-800", stateActive = "preset-filled-primary-500", stateDisabled = "opacity-50 cursor-not-allowed", width = "w-10", height = "h-6", padding = "p-0.5", rounded = "rounded-full", hover = "hover:brightness-90 dark:hover:brightness-110", classes = "",
8
+ // Thumb
9
+ thumbBase = "right-0 aspect-square h-full flex justify-center items-center text-right", thumbInactive = "preset-filled-surface-50-950", thumbActive = "bg-surface-50 text-surface-contrast-50", thumbRounded = "rounded-full", thumbTranslateX = "translate-x-4", thumbTransition = "transition", thumbEase = "ease-in-out", thumbDuration = "duration-200", thumbClasses = "",
10
+ // Icons
11
+ iconInactiveBase = "pointer-events-none", iconActiveBase = "pointer-events-none",
12
+ // Events
13
+ onCheckedChange = () => { },
14
+ // Children
15
+ inactiveChild, activeChild, }) => {
16
+ // Set Compact Mode
17
+ if (compact) {
18
+ base = thumbBase;
19
+ // Removes the height class
20
+ height = "";
21
+ // Thumb inherits track styles
22
+ thumbInactive = stateInactive;
23
+ thumbActive = stateActive;
24
+ // Remove X-axis translate
25
+ thumbTranslateX = "";
26
+ // Remove padding
27
+ padding = "";
28
+ }
29
+ function toggle() {
30
+ if (disabled)
31
+ return;
32
+ checked = !checked;
33
+ onCheckedChange(checked);
34
+ }
35
+ const rxTrackState = checked ? stateActive : stateInactive;
36
+ const rxThumbState = checked
37
+ ? `${thumbActive} ${thumbTranslateX}`
38
+ : thumbInactive;
39
+ const rxDisabled = disabled ? stateDisabled : "";
40
+ return (_jsxs("button", { type: "button", className: `${base} ${rxTrackState} ${width} ${height} ${padding} ${rounded} ${hover} ${rxDisabled} ${classes}`, role: "switch", "aria-checked": checked, "aria-labelledby": labelledby, "aria-describedby": describedby, onClick: toggle, "data-testid": "switch", children: [_jsx("input", { type: "checkbox", id: id, name: name, checked: checked, onChange: () => { }, className: "hidden", disabled: disabled }), _jsxs("div", { className: `${thumbBase} ${rxThumbState} ${thumbRounded} ${thumbTransition} ${thumbEase} ${thumbDuration} ${thumbClasses}`, children: [!checked && inactiveChild ? (_jsx("span", { className: iconInactiveBase, children: inactiveChild })) : null, checked && activeChild ? (_jsx("span", { className: iconActiveBase, children: activeChild })) : null] })] }));
41
+ };
@@ -0,0 +1,65 @@
1
+ import { ReactNode } from "react";
2
+ export interface SwitchProps {
3
+ /** Set a unique ID for the switch input. */
4
+ id: string;
5
+ /** Set a unique name for the switch input. */
6
+ name: string;
7
+ /** Set the checked state. */
8
+ checked?: boolean;
9
+ /** Set the disabled state. */
10
+ disabled?: boolean;
11
+ /** Set the compact display mode. */
12
+ compact?: boolean;
13
+ /** Identifies the element that labels the switch. */
14
+ labelledby?: string | undefined;
15
+ /** Identifies the element that describes the switch. */
16
+ describedby?: string | undefined;
17
+ /** Set base classes for the root element. */
18
+ base?: string;
19
+ /** Set inactive state classes for the root element. */
20
+ stateInactive?: string;
21
+ /** Set active state classes for the root element. */
22
+ stateActive?: string;
23
+ /** Set disabled state classes for the root element. */
24
+ stateDisabled?: string;
25
+ /** Set width classes for the root element. */
26
+ width?: string;
27
+ /** Set height classes for the root element. */
28
+ height?: string;
29
+ /** Set padding classes for the root element. */
30
+ padding?: string;
31
+ /** Set rounded classes for the root element. */
32
+ rounded?: string;
33
+ /** Set hover classes for the root element. */
34
+ hover?: string;
35
+ /** Provide arbitrary classes to the root element. */
36
+ classes?: string;
37
+ /** Set base classes for the thumb element. */
38
+ thumbBase?: string;
39
+ /** Set inactive classes for the thumb element. */
40
+ thumbInactive?: string;
41
+ /** Set active classes for the thumb element. */
42
+ thumbActive?: string;
43
+ /** Set rounded classes for the thumb element. */
44
+ thumbRounded?: string;
45
+ /** Set animation X-axis translate classes for the thumb element. */
46
+ thumbTranslateX?: string;
47
+ /** Set animation transition classes for the thumb element. */
48
+ thumbTransition?: string;
49
+ /** Set animation easing classes for the thumb element. */
50
+ thumbEase?: string;
51
+ /** Set animation duration classes for the thumb element. */
52
+ thumbDuration?: string;
53
+ /** Provide arbitrary classes to the thumb element. */
54
+ thumbClasses?: string;
55
+ /** Set base classes for the inactive icon child. */
56
+ iconInactiveBase?: string;
57
+ /** Set base classes for the active icon child. */
58
+ iconActiveBase?: string;
59
+ /** Triggers when the switch is toggled. */
60
+ onCheckedChange?: (event: boolean) => void;
61
+ /** The inactive state children. */
62
+ inactiveChild?: ReactNode;
63
+ /** The active state children. */
64
+ activeChild?: ReactNode;
65
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -10,7 +10,7 @@ children, }) => {
10
10
  };
11
11
  const TabsList = ({
12
12
  // Root
13
- base = "flex", justify = "justify-start", gap = "gap-2", border = "border-b-[1px] border-surface-200-800", classes = "",
13
+ base = "flex", justify = "justify-start", gap = "gap-2", border = "border-b border-surface-200-800", classes = "",
14
14
  // Children
15
15
  children, }) => {
16
16
  return (_jsx("div", { className: `${base} ${gap} ${justify} ${border} ${classes}`, role: "tablist", children: children }));
@@ -19,7 +19,7 @@ const TabsControl = ({ id = "", name, group, title = "",
19
19
  // A11y
20
20
  label = "", controls = "",
21
21
  // Root
22
- base = "group", width = "", active = "text-surface-950-50 border-surface-950-50", inactive = "text-surface-600-400 border-transparent", flex = "flex justify-center items-center", background = "", border = "border-b-[1px]", text = "type-scale-3", padding = "pb-2", rounded = "", gap = "gap-1", cursor = "cursor-pointer", classes = "",
22
+ base = "group", width = "", active = "text-surface-950-50 border-surface-950-50", inactive = "text-surface-600-400 border-transparent", flex = "flex justify-center items-center", background = "", border = "border-b", text = "type-scale-3", padding = "pb-2", rounded = "", gap = "gap-1", cursor = "cursor-pointer", classes = "",
23
23
  // Events
24
24
  onClick = () => { }, onKeydown = () => { }, onKeyup = () => { }, onChange = () => { },
25
25
  // Children
package/dist/index.d.ts CHANGED
@@ -3,4 +3,5 @@ export { Accordion } from "./components/Accordion/Accordion.js";
3
3
  export { Avatar } from "./components/Avatar/Avatar.js";
4
4
  export { AppBar, ToolBar } from "./components/AppBar/AppBar.js";
5
5
  export { Progress } from "./components/Progress/Progress.js";
6
+ export { Switch } from "./components/Switch/Switch.js";
6
7
  export { Tabs } from "./components/Tabs/Tabs.js";
package/dist/index.js CHANGED
@@ -4,4 +4,5 @@ export { Accordion } from "./components/Accordion/Accordion.js";
4
4
  export { Avatar } from "./components/Avatar/Avatar.js";
5
5
  export { AppBar, ToolBar } from "./components/AppBar/AppBar.js";
6
6
  export { Progress } from "./components/Progress/Progress.js";
7
+ export { Switch } from "./components/Switch/Switch.js";
7
8
  export { Tabs } from "./components/Tabs/Tabs.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skeletonlabs/skeleton-react",
3
- "version": "1.0.0-next.0",
3
+ "version": "1.0.0-next.1",
4
4
  "type": "module",
5
5
  "types": "./dist/index.d.ts",
6
6
  "exports": {
@@ -39,6 +39,7 @@
39
39
  "eslint-plugin-react-hooks": "^4.6.0",
40
40
  "eslint-plugin-react-refresh": "^0.4.6",
41
41
  "jsdom": "^24.0.0",
42
+ "lucide-react": "^0.341.0",
42
43
  "postcss": "^8.4.38",
43
44
  "react-router-dom": "^6.22.3",
44
45
  "tailwindcss": "^3.4.3",
@@ -47,7 +48,7 @@
47
48
  "vite": "^5.2.8",
48
49
  "vite-plugin-remix-router": "^2.0.0",
49
50
  "vitest": "^1.4.0",
50
- "@skeletonlabs/skeleton": "3.0.0-next.0",
51
+ "@skeletonlabs/skeleton": "3.0.0-next.1",
51
52
  "vite-plugin-tw-plugin-watcher": "0.0.0"
52
53
  },
53
54
  "peerDependencies": {