react-toolkit-ultra 1.0.28 → 1.0.30

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/README.md CHANGED
@@ -1,73 +1,8 @@
1
- # React + TypeScript + Vite
2
-
3
- This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
4
-
5
- Currently, two official plugins are available:
6
-
7
- - [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Oxc](https://oxc.rs)
8
- - [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/)
9
-
10
- ## React Compiler
11
-
12
- The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see [this documentation](https://react.dev/learn/react-compiler/installation).
13
-
14
- ## Expanding the ESLint configuration
15
-
16
- If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:
17
-
18
- ```js
19
- export default defineConfig([
20
- globalIgnores(['dist']),
21
- {
22
- files: ['**/*.{ts,tsx}'],
23
- extends: [
24
- // Other configs...
25
-
26
- // Remove tseslint.configs.recommended and replace with this
27
- tseslint.configs.recommendedTypeChecked,
28
- // Alternatively, use this for stricter rules
29
- tseslint.configs.strictTypeChecked,
30
- // Optionally, add this for stylistic rules
31
- tseslint.configs.stylisticTypeChecked,
32
-
33
- // Other configs...
34
- ],
35
- languageOptions: {
36
- parserOptions: {
37
- project: ['./tsconfig.node.json', './tsconfig.app.json'],
38
- tsconfigRootDir: import.meta.dirname,
39
- },
40
- // other options...
41
- },
42
- },
43
- ])
44
- ```
45
-
46
- You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules:
47
-
48
- ```js
49
- // eslint.config.js
50
- import reactX from 'eslint-plugin-react-x'
51
- import reactDom from 'eslint-plugin-react-dom'
52
-
53
- export default defineConfig([
54
- globalIgnores(['dist']),
55
- {
56
- files: ['**/*.{ts,tsx}'],
57
- extends: [
58
- // Other configs...
59
- // Enable lint rules for React
60
- reactX.configs['recommended-typescript'],
61
- // Enable lint rules for React DOM
62
- reactDom.configs.recommended,
63
- ],
64
- languageOptions: {
65
- parserOptions: {
66
- project: ['./tsconfig.node.json', './tsconfig.app.json'],
67
- tsconfigRootDir: import.meta.dirname,
68
- },
69
- // other options...
70
- },
71
- },
72
- ])
73
- ```
1
+ # React-Toolkit-Ultra
2
+
3
+ ```bash
4
+ npm install react-toolkit-ultra
5
+ # or
6
+ yarn add react-toolkit-ultra
7
+ # or
8
+ pnpm add react-toolkit-ultra
package/dist/index.cjs CHANGED
@@ -20,22 +20,24 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/index.ts
21
21
  var index_exports = {};
22
22
  __export(index_exports, {
23
- Switch: () => Switch
23
+ Switch: () => Switch,
24
+ SwitchLock: () => SwitchLock
24
25
  });
25
26
  module.exports = __toCommonJS(index_exports);
26
27
 
27
28
  // src/components/Switch/Switch.tsx
28
29
  var import_react = require("react");
30
+ var import_lucide_react = require("lucide-react");
29
31
  var import_jsx_runtime = require("react/jsx-runtime");
30
32
  var Switch = ({
31
33
  checked = false,
32
- onChange,
33
34
  disabled = false,
34
35
  width = 50,
35
36
  height = 24,
36
37
  bgColor = "#9835FF",
37
38
  inActiveColor = "#7a7a7ab3",
38
- thumbColor = "white"
39
+ thumbColor = "white",
40
+ onChange
39
41
  }) => {
40
42
  const [isOn, setOn] = (0, import_react.useState)(checked);
41
43
  const safeWidth = Math.min(Math.max(width, 50), 100);
@@ -60,7 +62,7 @@ var Switch = ({
60
62
  width: safeWidth,
61
63
  borderRadius: "15px",
62
64
  position: "relative",
63
- cursor: disabled ? "no-drop" : "pointer",
65
+ cursor: window.matchMedia("(hover: hover)").matches ? disabled ? "no-drop" : "pointer" : "default",
64
66
  transition: "background 0.3s ease"
65
67
  },
66
68
  children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
@@ -82,7 +84,98 @@ var Switch = ({
82
84
  }
83
85
  );
84
86
  };
87
+ var SwitchLock = ({
88
+ checked = false,
89
+ disabled = false,
90
+ width = 55,
91
+ height = 24,
92
+ bgColor = "#9835FF",
93
+ inActiveColor = "#7a7a7ab3",
94
+ thumbColor = "#9835FF",
95
+ onChange
96
+ }) => {
97
+ const [isON, setON] = (0, import_react.useState)(checked);
98
+ const safeWidth = Math.min(Math.max(width, 55), 100);
99
+ const safeHeight = Math.min(Math.max(height, 24), 30);
100
+ const thumSize = safeHeight - 3;
101
+ const toggle = () => {
102
+ if (disabled) return;
103
+ const newStatus = !isON;
104
+ setON(newStatus);
105
+ onChange?.(newStatus);
106
+ };
107
+ (0, import_react.useEffect)(() => {
108
+ setON(checked);
109
+ }, [checked]);
110
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
111
+ "div",
112
+ {
113
+ onClick: toggle,
114
+ style: {
115
+ position: "relative",
116
+ height: safeHeight,
117
+ width: safeWidth,
118
+ borderRadius: "5px",
119
+ borderWidth: "2px",
120
+ borderStyle: "solid",
121
+ borderColor: isON ? bgColor : inActiveColor,
122
+ cursor: window.matchMedia("(hover: hover)").matches ? disabled ? "no-drop" : "pointer" : "default",
123
+ overflow: "hidden",
124
+ transition: "border 0.3s ease"
125
+ },
126
+ children: [
127
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
128
+ import_lucide_react.LockKeyhole,
129
+ {
130
+ style: {
131
+ position: "absolute",
132
+ top: "50%",
133
+ left: isON ? 2 : -100,
134
+ transform: "translateY(-50%)",
135
+ height: thumSize - 3,
136
+ width: thumSize - 3,
137
+ color: bgColor,
138
+ transition: "left 0.5s ease"
139
+ }
140
+ }
141
+ ),
142
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
143
+ "span",
144
+ {
145
+ style: {
146
+ position: "absolute",
147
+ top: "50%",
148
+ left: isON ? safeWidth - safeHeight : "2px",
149
+ transform: "translateY(-50%)",
150
+ background: isON ? thumbColor : inActiveColor,
151
+ height: thumSize,
152
+ width: thumSize,
153
+ borderRadius: "5px",
154
+ transition: "all 0.3s ease"
155
+ }
156
+ }
157
+ ),
158
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
159
+ import_lucide_react.LockKeyholeOpen,
160
+ {
161
+ style: {
162
+ position: "absolute",
163
+ top: "50%",
164
+ right: isON ? "-100px" : "2px",
165
+ transform: "translateY(-50%)",
166
+ height: thumSize - 3,
167
+ width: thumSize - 3,
168
+ color: inActiveColor,
169
+ transition: "right 0.5s ease"
170
+ }
171
+ }
172
+ )
173
+ ]
174
+ }
175
+ );
176
+ };
85
177
  // Annotate the CommonJS export names for ESM import in node:
86
178
  0 && (module.exports = {
87
- Switch
179
+ Switch,
180
+ SwitchLock
88
181
  });
package/dist/index.d.cts CHANGED
@@ -10,6 +10,7 @@ type SwitchProms = {
10
10
  inActiveColor?: string;
11
11
  thumbColor?: string;
12
12
  };
13
- declare const Switch: ({ checked, onChange, disabled, width, height, bgColor, inActiveColor, thumbColor, }: SwitchProms) => react_jsx_runtime.JSX.Element;
13
+ declare const Switch: ({ checked, disabled, width, height, bgColor, inActiveColor, thumbColor, onChange, }: SwitchProms) => react_jsx_runtime.JSX.Element;
14
+ declare const SwitchLock: ({ checked, disabled, width, height, bgColor, inActiveColor, thumbColor, onChange, }: SwitchProms) => react_jsx_runtime.JSX.Element;
14
15
 
15
- export { Switch };
16
+ export { Switch, SwitchLock };
package/dist/index.d.ts CHANGED
@@ -10,6 +10,7 @@ type SwitchProms = {
10
10
  inActiveColor?: string;
11
11
  thumbColor?: string;
12
12
  };
13
- declare const Switch: ({ checked, onChange, disabled, width, height, bgColor, inActiveColor, thumbColor, }: SwitchProms) => react_jsx_runtime.JSX.Element;
13
+ declare const Switch: ({ checked, disabled, width, height, bgColor, inActiveColor, thumbColor, onChange, }: SwitchProms) => react_jsx_runtime.JSX.Element;
14
+ declare const SwitchLock: ({ checked, disabled, width, height, bgColor, inActiveColor, thumbColor, onChange, }: SwitchProms) => react_jsx_runtime.JSX.Element;
14
15
 
15
- export { Switch };
16
+ export { Switch, SwitchLock };
package/dist/index.js CHANGED
@@ -1,15 +1,16 @@
1
1
  // src/components/Switch/Switch.tsx
2
2
  import { useEffect, useState } from "react";
3
- import { jsx } from "react/jsx-runtime";
3
+ import { LockKeyhole, LockKeyholeOpen } from "lucide-react";
4
+ import { jsx, jsxs } from "react/jsx-runtime";
4
5
  var Switch = ({
5
6
  checked = false,
6
- onChange,
7
7
  disabled = false,
8
8
  width = 50,
9
9
  height = 24,
10
10
  bgColor = "#9835FF",
11
11
  inActiveColor = "#7a7a7ab3",
12
- thumbColor = "white"
12
+ thumbColor = "white",
13
+ onChange
13
14
  }) => {
14
15
  const [isOn, setOn] = useState(checked);
15
16
  const safeWidth = Math.min(Math.max(width, 50), 100);
@@ -34,7 +35,7 @@ var Switch = ({
34
35
  width: safeWidth,
35
36
  borderRadius: "15px",
36
37
  position: "relative",
37
- cursor: disabled ? "no-drop" : "pointer",
38
+ cursor: window.matchMedia("(hover: hover)").matches ? disabled ? "no-drop" : "pointer" : "default",
38
39
  transition: "background 0.3s ease"
39
40
  },
40
41
  children: /* @__PURE__ */ jsx(
@@ -56,6 +57,97 @@ var Switch = ({
56
57
  }
57
58
  );
58
59
  };
60
+ var SwitchLock = ({
61
+ checked = false,
62
+ disabled = false,
63
+ width = 55,
64
+ height = 24,
65
+ bgColor = "#9835FF",
66
+ inActiveColor = "#7a7a7ab3",
67
+ thumbColor = "#9835FF",
68
+ onChange
69
+ }) => {
70
+ const [isON, setON] = useState(checked);
71
+ const safeWidth = Math.min(Math.max(width, 55), 100);
72
+ const safeHeight = Math.min(Math.max(height, 24), 30);
73
+ const thumSize = safeHeight - 3;
74
+ const toggle = () => {
75
+ if (disabled) return;
76
+ const newStatus = !isON;
77
+ setON(newStatus);
78
+ onChange?.(newStatus);
79
+ };
80
+ useEffect(() => {
81
+ setON(checked);
82
+ }, [checked]);
83
+ return /* @__PURE__ */ jsxs(
84
+ "div",
85
+ {
86
+ onClick: toggle,
87
+ style: {
88
+ position: "relative",
89
+ height: safeHeight,
90
+ width: safeWidth,
91
+ borderRadius: "5px",
92
+ borderWidth: "2px",
93
+ borderStyle: "solid",
94
+ borderColor: isON ? bgColor : inActiveColor,
95
+ cursor: window.matchMedia("(hover: hover)").matches ? disabled ? "no-drop" : "pointer" : "default",
96
+ overflow: "hidden",
97
+ transition: "border 0.3s ease"
98
+ },
99
+ children: [
100
+ /* @__PURE__ */ jsx(
101
+ LockKeyhole,
102
+ {
103
+ style: {
104
+ position: "absolute",
105
+ top: "50%",
106
+ left: isON ? 2 : -100,
107
+ transform: "translateY(-50%)",
108
+ height: thumSize - 3,
109
+ width: thumSize - 3,
110
+ color: bgColor,
111
+ transition: "left 0.5s ease"
112
+ }
113
+ }
114
+ ),
115
+ /* @__PURE__ */ jsx(
116
+ "span",
117
+ {
118
+ style: {
119
+ position: "absolute",
120
+ top: "50%",
121
+ left: isON ? safeWidth - safeHeight : "2px",
122
+ transform: "translateY(-50%)",
123
+ background: isON ? thumbColor : inActiveColor,
124
+ height: thumSize,
125
+ width: thumSize,
126
+ borderRadius: "5px",
127
+ transition: "all 0.3s ease"
128
+ }
129
+ }
130
+ ),
131
+ /* @__PURE__ */ jsx(
132
+ LockKeyholeOpen,
133
+ {
134
+ style: {
135
+ position: "absolute",
136
+ top: "50%",
137
+ right: isON ? "-100px" : "2px",
138
+ transform: "translateY(-50%)",
139
+ height: thumSize - 3,
140
+ width: thumSize - 3,
141
+ color: inActiveColor,
142
+ transition: "right 0.5s ease"
143
+ }
144
+ }
145
+ )
146
+ ]
147
+ }
148
+ );
149
+ };
59
150
  export {
60
- Switch
151
+ Switch,
152
+ SwitchLock
61
153
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "react-toolkit-ultra",
3
3
  "private": false,
4
- "version": "1.0.28",
4
+ "version": "1.0.30",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
7
7
  "module": "./dist/index.js",
@@ -39,5 +39,8 @@
39
39
  "tsup": "^8.5.1",
40
40
  "typescript": "~6.0.2",
41
41
  "typescript-eslint": "^8.59.2"
42
+ },
43
+ "dependencies": {
44
+ "lucide-react": "^1.16.0"
42
45
  }
43
46
  }