@purr-react-tailwindcss/components.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/LICENSE +21 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/package.json +6 -7
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Dinh Thien Phuc
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var u=require('clsx'),i=require('react'),q=require('@purr-core/hooks.sync-state-with-props');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var u__default=/*#__PURE__*/_interopDefault(u);var i__default=/*#__PURE__*/_interopDefault(i);var q__default=/*#__PURE__*/_interopDefault(q);var k=Object.defineProperty;var l=(t,e)=>()=>(t&&(e=t(t=0)),e);var n=(t,e)=>{for(var r in e)k(t,r,{get:e[r],enumerable:true});};var c={};n(c,{SwitchLabelLeft:()=>h});var h,f=l(()=>{h=i.memo(({leftLabel:t="",disabled:e=false,htmlAttributes:r})=>t?i__default.default.createElement("span",{className:u__default.default("mr-2 font-sans text-base",e?"cursor-not-allowed text-white/50 opacity-50":"text-white opacity-100","switch-label","switch-label__left",e&&"switch-label__left--disabled"),...r},t):null);h.displayName="SwitchLabelLeft";});var m={};n(m,{SwitchLabelRight:()=>p});var p,w=l(()=>{p=i.memo(({rightLabel:t="",disabled:e=false,htmlAttributes:r})=>t?i__default.default.createElement("span",{className:u__default.default("ml-2 font-sans text-base",e?"cursor-not-allowed text-white/50 opacity-50":"text-white opacity-100","switch-label","switch-label__right",e&&"switch-label__right--disabled"),...r},t):null);p.displayName="SwitchLabelRight";});var z=i.lazy(()=>Promise.resolve().then(()=>(f(),c)).then(t=>({default:t.SwitchLabelLeft}))),R=i.lazy(()=>Promise.resolve().then(()=>(w(),m)).then(t=>({default:t.SwitchLabelRight}))),W=i.forwardRef(({value:t=false,leftLabel:e="",rightLabel:r="",htmlAttributes:S,inputHtmlAttributes:d,leftLabelHtmlAttributes:x,rightLabelHtmlAttributes:L,onChange:y,disabled:a=false,required:v=false,isStandalone:I=false},N)=>{let{currentValue:o,setCurrentValue:_}=q__default.default(t,I),P=s=>{_(s.target.checked),y?.(s.target.checked,s);};return i__default.default.createElement("div",{className:"switch inline-flex items-center",...S},i__default.default.createElement(i.Suspense,null,!!e&&i__default.default.createElement(z,{htmlAttributes:x,leftLabel:e,disabled:a})),i__default.default.createElement("div",{className:u__default.default("relative h-3 w-8 rounded-lg transition-all duration-200 ease-in-out after:pointer-events-none after:absolute after:-left-1 after:-top-1 after:h-5 after:w-5 after:rounded-full after:transition-all after:duration-200 after:ease-in-out",a&&o&&"bg-sky-400/20 after:bg-slate-700",a&&!o&&"bg-white/20 after:bg-gray-500",!a&&o&&"bg-sky-400/50 after:bg-blue-300",!a&&!o&&"bg-white/50 after:bg-gray-200",o?"after:translate-x-5":"after:translate-x-0","switch-pad",o&&"switch-pad--on",a&&"switch-pad--disabled")},i__default.default.createElement("input",{ref:N,checked:o,onChange:P,disabled:a,type:"checkbox",required:v,className:u__default.default("absolute left-0 top-0 h-3 w-8 opacity-0",a?"cursor-not-allowed":"cursor-pointer"),...d})),i__default.default.createElement(i.Suspense,null,!!r&&i__default.default.createElement(R,{htmlAttributes:L,rightLabel:r,disabled:a})))});W.displayName="Switch";exports.Switch=W;
|
|
1
|
+
'use strict';var u=require('clsx'),i=require('react'),q=require('@purr-react-core/hooks.sync-state-with-props');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var u__default=/*#__PURE__*/_interopDefault(u);var i__default=/*#__PURE__*/_interopDefault(i);var q__default=/*#__PURE__*/_interopDefault(q);var k=Object.defineProperty;var l=(t,e)=>()=>(t&&(e=t(t=0)),e);var n=(t,e)=>{for(var r in e)k(t,r,{get:e[r],enumerable:true});};var c={};n(c,{SwitchLabelLeft:()=>h});var h,f=l(()=>{h=i.memo(({leftLabel:t="",disabled:e=false,htmlAttributes:r})=>t?i__default.default.createElement("span",{className:u__default.default("mr-2 font-sans text-base",e?"cursor-not-allowed text-white/50 opacity-50":"text-white opacity-100","switch-label","switch-label__left",e&&"switch-label__left--disabled"),...r},t):null);h.displayName="SwitchLabelLeft";});var m={};n(m,{SwitchLabelRight:()=>p});var p,w=l(()=>{p=i.memo(({rightLabel:t="",disabled:e=false,htmlAttributes:r})=>t?i__default.default.createElement("span",{className:u__default.default("ml-2 font-sans text-base",e?"cursor-not-allowed text-white/50 opacity-50":"text-white opacity-100","switch-label","switch-label__right",e&&"switch-label__right--disabled"),...r},t):null);p.displayName="SwitchLabelRight";});var z=i.lazy(()=>Promise.resolve().then(()=>(f(),c)).then(t=>({default:t.SwitchLabelLeft}))),R=i.lazy(()=>Promise.resolve().then(()=>(w(),m)).then(t=>({default:t.SwitchLabelRight}))),W=i.forwardRef(({value:t=false,leftLabel:e="",rightLabel:r="",htmlAttributes:S,inputHtmlAttributes:d,leftLabelHtmlAttributes:x,rightLabelHtmlAttributes:L,onChange:y,disabled:a=false,required:v=false,isStandalone:I=false},N)=>{let{currentValue:o,setCurrentValue:_}=q__default.default(t,I),P=s=>{_(s.target.checked),y?.(s.target.checked,s);};return i__default.default.createElement("div",{className:"switch inline-flex items-center",...S},i__default.default.createElement(i.Suspense,null,!!e&&i__default.default.createElement(z,{htmlAttributes:x,leftLabel:e,disabled:a})),i__default.default.createElement("div",{className:u__default.default("relative h-3 w-8 rounded-lg transition-all duration-200 ease-in-out after:pointer-events-none after:absolute after:-left-1 after:-top-1 after:h-5 after:w-5 after:rounded-full after:transition-all after:duration-200 after:ease-in-out",a&&o&&"bg-sky-400/20 after:bg-slate-700",a&&!o&&"bg-white/20 after:bg-gray-500",!a&&o&&"bg-sky-400/50 after:bg-blue-300",!a&&!o&&"bg-white/50 after:bg-gray-200",o?"after:translate-x-5":"after:translate-x-0","switch-pad",o&&"switch-pad--on",a&&"switch-pad--disabled")},i__default.default.createElement("input",{ref:N,checked:o,onChange:P,disabled:a,type:"checkbox",required:v,className:u__default.default("absolute left-0 top-0 h-3 w-8 opacity-0",a?"cursor-not-allowed":"cursor-pointer"),...d})),i__default.default.createElement(i.Suspense,null,!!r&&i__default.default.createElement(R,{htmlAttributes:L,rightLabel:r,disabled:a})))});W.displayName="Switch";exports.Switch=W;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { HTMLAttributes, InputHTMLAttributes, ChangeEvent } from 'react';
|
|
2
2
|
import { FieldError } from 'react-hook-form';
|
|
3
|
-
import { IExtendable } from '@purr-core/utils.definitions';
|
|
3
|
+
import { IExtendable } from '@purr-react-core/utils.definitions';
|
|
4
4
|
|
|
5
5
|
interface ISwitchLeftLabelProps {
|
|
6
6
|
leftLabel?: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { HTMLAttributes, InputHTMLAttributes, ChangeEvent } from 'react';
|
|
2
2
|
import { FieldError } from 'react-hook-form';
|
|
3
|
-
import { IExtendable } from '@purr-core/utils.definitions';
|
|
3
|
+
import { IExtendable } from '@purr-react-core/utils.definitions';
|
|
4
4
|
|
|
5
5
|
interface ISwitchLeftLabelProps {
|
|
6
6
|
leftLabel?: string;
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import u from'clsx';import i,{lazy,forwardRef,Suspense,memo}from'react';import q from'@purr-core/hooks.sync-state-with-props';var k=Object.defineProperty;var l=(t,e)=>()=>(t&&(e=t(t=0)),e);var n=(t,e)=>{for(var r in e)k(t,r,{get:e[r],enumerable:true});};var c={};n(c,{SwitchLabelLeft:()=>h});var h,f=l(()=>{h=memo(({leftLabel:t="",disabled:e=false,htmlAttributes:r})=>t?i.createElement("span",{className:u("mr-2 font-sans text-base",e?"cursor-not-allowed text-white/50 opacity-50":"text-white opacity-100","switch-label","switch-label__left",e&&"switch-label__left--disabled"),...r},t):null);h.displayName="SwitchLabelLeft";});var m={};n(m,{SwitchLabelRight:()=>p});var p,w=l(()=>{p=memo(({rightLabel:t="",disabled:e=false,htmlAttributes:r})=>t?i.createElement("span",{className:u("ml-2 font-sans text-base",e?"cursor-not-allowed text-white/50 opacity-50":"text-white opacity-100","switch-label","switch-label__right",e&&"switch-label__right--disabled"),...r},t):null);p.displayName="SwitchLabelRight";});var z=lazy(()=>Promise.resolve().then(()=>(f(),c)).then(t=>({default:t.SwitchLabelLeft}))),R=lazy(()=>Promise.resolve().then(()=>(w(),m)).then(t=>({default:t.SwitchLabelRight}))),W=forwardRef(({value:t=false,leftLabel:e="",rightLabel:r="",htmlAttributes:S,inputHtmlAttributes:d,leftLabelHtmlAttributes:x,rightLabelHtmlAttributes:L,onChange:y,disabled:a=false,required:v=false,isStandalone:I=false},N)=>{let{currentValue:o,setCurrentValue:_}=q(t,I),P=s=>{_(s.target.checked),y?.(s.target.checked,s);};return i.createElement("div",{className:"switch inline-flex items-center",...S},i.createElement(Suspense,null,!!e&&i.createElement(z,{htmlAttributes:x,leftLabel:e,disabled:a})),i.createElement("div",{className:u("relative h-3 w-8 rounded-lg transition-all duration-200 ease-in-out after:pointer-events-none after:absolute after:-left-1 after:-top-1 after:h-5 after:w-5 after:rounded-full after:transition-all after:duration-200 after:ease-in-out",a&&o&&"bg-sky-400/20 after:bg-slate-700",a&&!o&&"bg-white/20 after:bg-gray-500",!a&&o&&"bg-sky-400/50 after:bg-blue-300",!a&&!o&&"bg-white/50 after:bg-gray-200",o?"after:translate-x-5":"after:translate-x-0","switch-pad",o&&"switch-pad--on",a&&"switch-pad--disabled")},i.createElement("input",{ref:N,checked:o,onChange:P,disabled:a,type:"checkbox",required:v,className:u("absolute left-0 top-0 h-3 w-8 opacity-0",a?"cursor-not-allowed":"cursor-pointer"),...d})),i.createElement(Suspense,null,!!r&&i.createElement(R,{htmlAttributes:L,rightLabel:r,disabled:a})))});W.displayName="Switch";export{W as Switch};
|
|
1
|
+
import u from'clsx';import i,{lazy,forwardRef,Suspense,memo}from'react';import q from'@purr-react-core/hooks.sync-state-with-props';var k=Object.defineProperty;var l=(t,e)=>()=>(t&&(e=t(t=0)),e);var n=(t,e)=>{for(var r in e)k(t,r,{get:e[r],enumerable:true});};var c={};n(c,{SwitchLabelLeft:()=>h});var h,f=l(()=>{h=memo(({leftLabel:t="",disabled:e=false,htmlAttributes:r})=>t?i.createElement("span",{className:u("mr-2 font-sans text-base",e?"cursor-not-allowed text-white/50 opacity-50":"text-white opacity-100","switch-label","switch-label__left",e&&"switch-label__left--disabled"),...r},t):null);h.displayName="SwitchLabelLeft";});var m={};n(m,{SwitchLabelRight:()=>p});var p,w=l(()=>{p=memo(({rightLabel:t="",disabled:e=false,htmlAttributes:r})=>t?i.createElement("span",{className:u("ml-2 font-sans text-base",e?"cursor-not-allowed text-white/50 opacity-50":"text-white opacity-100","switch-label","switch-label__right",e&&"switch-label__right--disabled"),...r},t):null);p.displayName="SwitchLabelRight";});var z=lazy(()=>Promise.resolve().then(()=>(f(),c)).then(t=>({default:t.SwitchLabelLeft}))),R=lazy(()=>Promise.resolve().then(()=>(w(),m)).then(t=>({default:t.SwitchLabelRight}))),W=forwardRef(({value:t=false,leftLabel:e="",rightLabel:r="",htmlAttributes:S,inputHtmlAttributes:d,leftLabelHtmlAttributes:x,rightLabelHtmlAttributes:L,onChange:y,disabled:a=false,required:v=false,isStandalone:I=false},N)=>{let{currentValue:o,setCurrentValue:_}=q(t,I),P=s=>{_(s.target.checked),y?.(s.target.checked,s);};return i.createElement("div",{className:"switch inline-flex items-center",...S},i.createElement(Suspense,null,!!e&&i.createElement(z,{htmlAttributes:x,leftLabel:e,disabled:a})),i.createElement("div",{className:u("relative h-3 w-8 rounded-lg transition-all duration-200 ease-in-out after:pointer-events-none after:absolute after:-left-1 after:-top-1 after:h-5 after:w-5 after:rounded-full after:transition-all after:duration-200 after:ease-in-out",a&&o&&"bg-sky-400/20 after:bg-slate-700",a&&!o&&"bg-white/20 after:bg-gray-500",!a&&o&&"bg-sky-400/50 after:bg-blue-300",!a&&!o&&"bg-white/50 after:bg-gray-200",o?"after:translate-x-5":"after:translate-x-0","switch-pad",o&&"switch-pad--on",a&&"switch-pad--disabled")},i.createElement("input",{ref:N,checked:o,onChange:P,disabled:a,type:"checkbox",required:v,className:u("absolute left-0 top-0 h-3 w-8 opacity-0",a?"cursor-not-allowed":"cursor-pointer"),...d})),i.createElement(Suspense,null,!!r&&i.createElement(R,{htmlAttributes:L,rightLabel:r,disabled:a})))});W.displayName="Switch";export{W as Switch};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@purr-react-tailwindcss/components.switch",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.9",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -21,12 +21,11 @@
|
|
|
21
21
|
"dist"
|
|
22
22
|
],
|
|
23
23
|
"peerDependencies": {
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"react-
|
|
28
|
-
"@purr-core/
|
|
29
|
-
"@purr-core/hooks.sync-state-with-props": "0.0.9"
|
|
24
|
+
"react": "^18.0.0 || ^19.0.0",
|
|
25
|
+
"clsx": "^2.0.0",
|
|
26
|
+
"react-hook-form": "^7.0.0",
|
|
27
|
+
"@purr-react-core/utils.definitions": "0.0.14",
|
|
28
|
+
"@purr-react-core/hooks.sync-state-with-props": "0.0.11"
|
|
30
29
|
},
|
|
31
30
|
"author": "@DinhThienPhuc",
|
|
32
31
|
"license": "ISC",
|