@propellerads/switch 5.0.0 → 5.0.2
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 +1 -1
- package/dist/index.js +40 -42
- package/dist/index.js.map +1 -1
- package/package.json +9 -8
package/README.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
|
|
1
|
+
import "react";
|
|
2
|
+
import e, { keyframes as t } from "styled-components";
|
|
3
|
+
import { actionColor as n, black as r, fontSmall as i, gray50 as a, gray95 as o, hslToHsla as s } from "@propellerads/stylevariables";
|
|
4
|
+
import { jsx as c, jsxs as l } from "react/jsx-runtime";
|
|
5
|
+
//#region src/style.tsx
|
|
6
|
+
var u = t`
|
|
5
7
|
50% {
|
|
6
8
|
transform: scaleX(1.1);
|
|
7
9
|
}
|
|
8
|
-
`,
|
|
10
|
+
`, d = s(r, "0.15"), f = s(r, "0.5"), p = s(n, "0.5"), m = e.div`
|
|
9
11
|
display: flex;
|
|
10
12
|
align-items: center;
|
|
11
|
-
`,
|
|
13
|
+
`, h = e.div`
|
|
12
14
|
display: block;
|
|
13
|
-
font-size: ${
|
|
14
|
-
color: ${
|
|
15
|
+
font-size: ${i}px;
|
|
16
|
+
color: ${a};
|
|
15
17
|
|
|
16
18
|
label {
|
|
17
19
|
position: relative;
|
|
@@ -27,8 +29,8 @@ const l = p`
|
|
|
27
29
|
content: '';
|
|
28
30
|
transition: background 0.1s ease;
|
|
29
31
|
border-radius: 50px;
|
|
30
|
-
background: ${
|
|
31
|
-
box-shadow: inset 0 0 3px ${
|
|
32
|
+
background: ${o};
|
|
33
|
+
box-shadow: inset 0 0 3px ${d};
|
|
32
34
|
}
|
|
33
35
|
|
|
34
36
|
&:after {
|
|
@@ -40,10 +42,10 @@ const l = p`
|
|
|
40
42
|
height: 12px;
|
|
41
43
|
content: '';
|
|
42
44
|
transition: all 0.2s ease;
|
|
43
|
-
animation: ${
|
|
45
|
+
animation: ${u} 0.3s ease-out;
|
|
44
46
|
border-radius: 50px;
|
|
45
47
|
background: white;
|
|
46
|
-
box-shadow: 0 0 3px 0 ${
|
|
48
|
+
box-shadow: 0 0 3px 0 ${f};
|
|
47
49
|
}
|
|
48
50
|
}
|
|
49
51
|
|
|
@@ -57,43 +59,39 @@ const l = p`
|
|
|
57
59
|
}
|
|
58
60
|
|
|
59
61
|
&:checked + label:before {
|
|
60
|
-
background: ${(e) => e?.theme?.actionColor?.main ||
|
|
61
|
-
box-shadow: inset 0 0 1px ${
|
|
62
|
+
background: ${(e) => e?.theme?.actionColor?.main || n};
|
|
63
|
+
box-shadow: inset 0 0 1px ${p};
|
|
62
64
|
}
|
|
63
65
|
|
|
64
66
|
&:checked + label:after {
|
|
65
67
|
left: 24px;
|
|
66
|
-
animation: ${
|
|
68
|
+
animation: ${u} 0.2s ease-out;
|
|
67
69
|
}
|
|
68
70
|
|
|
69
71
|
&:checked:disabled + label:before {
|
|
70
|
-
background: ${(e) =>
|
|
72
|
+
background: ${(e) => s(e?.theme?.actionColor?.main || n, "0.3")};
|
|
71
73
|
}
|
|
72
74
|
}
|
|
73
75
|
}
|
|
74
|
-
`,
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
export {
|
|
97
|
-
T as default
|
|
98
|
-
};
|
|
99
|
-
//# sourceMappingURL=index.js.map
|
|
76
|
+
`, g = ({ isActive: e, onChange: t, containerClassName: n, controlClassName: r, elementId: i, isDisabled: a = !1 }) => /* @__PURE__ */ c(m, {
|
|
77
|
+
className: n,
|
|
78
|
+
children: /* @__PURE__ */ l(h, {
|
|
79
|
+
className: r,
|
|
80
|
+
children: [/* @__PURE__ */ c("input", {
|
|
81
|
+
type: "checkbox",
|
|
82
|
+
checked: e,
|
|
83
|
+
onChange: () => {
|
|
84
|
+
t(!e);
|
|
85
|
+
},
|
|
86
|
+
id: i,
|
|
87
|
+
disabled: a
|
|
88
|
+
}), /* @__PURE__ */ c("label", {
|
|
89
|
+
htmlFor: i,
|
|
90
|
+
role: "presentation"
|
|
91
|
+
})]
|
|
92
|
+
})
|
|
93
|
+
});
|
|
94
|
+
//#endregion
|
|
95
|
+
export { g as default };
|
|
96
|
+
|
|
97
|
+
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/style.tsx","../src/index.tsx"],"sourcesContent":["import styled, {keyframes} from 'styled-components';\nimport {gray50, gray95, actionColor, black, fontSmall, hslToHsla} from '@propellerads/stylevariables';\n\nconst switchOn = keyframes`\n 50% {\n transform: scaleX(1.1);\n }\n`;\n\nconst black15 = hslToHsla(black, '0.15');\nconst black25 = hslToHsla(black, '0.5');\nconst action50 = hslToHsla(actionColor, '0.5');\n\nconst StyledSwitch = styled.div`\n display: flex;\n align-items: center;\n`;\n\nconst SwitchControl = styled.div`\n display: block;\n font-size: ${fontSmall}px;\n color: ${gray50};\n\n label {\n position: relative;\n display: block;\n width: 40px;\n height: 20px;\n cursor: pointer;\n\n &:before {\n position: absolute;\n width: 40px;\n height: 20px;\n content: '';\n transition: background 0.1s ease;\n border-radius: 50px;\n background: ${gray95};\n box-shadow: inset 0 0 3px ${black15};\n }\n\n &:after {\n position: absolute;\n z-index: 2;\n top: 4px;\n left: 4px;\n width: 12px;\n height: 12px;\n content: '';\n transition: all 0.2s ease;\n animation: ${switchOn} 0.3s ease-out;\n border-radius: 50px;\n background: white;\n box-shadow: 0 0 3px 0 ${black25};\n }\n }\n\n input {\n &[type='checkbox'] {\n display: none;\n visibility: hidden;\n\n &:disabled + label {\n cursor: not-allowed;\n }\n\n &:checked + label:before {\n background: ${(props) => props?.theme?.actionColor?.main || actionColor};\n box-shadow: inset 0 0 1px ${action50};\n }\n\n &:checked + label:after {\n left: 24px;\n animation: ${switchOn} 0.2s ease-out;\n }\n\n &:checked:disabled + label:before {\n background: ${(props) => hslToHsla(props?.theme?.actionColor?.main || actionColor, '0.3')};\n }\n }\n }\n`;\n\nexport {StyledSwitch, SwitchControl};\n","import React from 'react';\n\nimport {StyledSwitch, SwitchControl} from './style';\n\ntype SwitchProps = {\n isActive: boolean;\n onChange: (nextValue: boolean) => void;\n containerClassName?: string;\n controlClassName?: string;\n elementId?: string;\n isDisabled?: boolean;\n};\n\nconst Switch: React.FC<SwitchProps> = ({\n isActive,\n onChange,\n containerClassName,\n controlClassName,\n elementId,\n isDisabled = false,\n}) => {\n const handleToggleCheckbox = () => {\n onChange(!isActive);\n };\n\n return (\n <StyledSwitch className={containerClassName}>\n <SwitchControl className={controlClassName}>\n <input\n type=\"checkbox\"\n checked={isActive}\n onChange={handleToggleCheckbox}\n id={elementId}\n disabled={isDisabled}\n />\n <label htmlFor={elementId} role=\"presentation\" />\n </SwitchControl>\n </StyledSwitch>\n );\n};\n\nexport default Switch;\n\nexport type {SwitchProps};\n"],"
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/style.tsx","../src/index.tsx"],"sourcesContent":["import styled, {keyframes} from 'styled-components';\nimport {gray50, gray95, actionColor, black, fontSmall, hslToHsla} from '@propellerads/stylevariables';\n\nconst switchOn = keyframes`\n 50% {\n transform: scaleX(1.1);\n }\n`;\n\nconst black15 = hslToHsla(black, '0.15');\nconst black25 = hslToHsla(black, '0.5');\nconst action50 = hslToHsla(actionColor, '0.5');\n\nconst StyledSwitch = styled.div`\n display: flex;\n align-items: center;\n`;\n\nconst SwitchControl = styled.div`\n display: block;\n font-size: ${fontSmall}px;\n color: ${gray50};\n\n label {\n position: relative;\n display: block;\n width: 40px;\n height: 20px;\n cursor: pointer;\n\n &:before {\n position: absolute;\n width: 40px;\n height: 20px;\n content: '';\n transition: background 0.1s ease;\n border-radius: 50px;\n background: ${gray95};\n box-shadow: inset 0 0 3px ${black15};\n }\n\n &:after {\n position: absolute;\n z-index: 2;\n top: 4px;\n left: 4px;\n width: 12px;\n height: 12px;\n content: '';\n transition: all 0.2s ease;\n animation: ${switchOn} 0.3s ease-out;\n border-radius: 50px;\n background: white;\n box-shadow: 0 0 3px 0 ${black25};\n }\n }\n\n input {\n &[type='checkbox'] {\n display: none;\n visibility: hidden;\n\n &:disabled + label {\n cursor: not-allowed;\n }\n\n &:checked + label:before {\n background: ${(props) => props?.theme?.actionColor?.main || actionColor};\n box-shadow: inset 0 0 1px ${action50};\n }\n\n &:checked + label:after {\n left: 24px;\n animation: ${switchOn} 0.2s ease-out;\n }\n\n &:checked:disabled + label:before {\n background: ${(props) => hslToHsla(props?.theme?.actionColor?.main || actionColor, '0.3')};\n }\n }\n }\n`;\n\nexport {StyledSwitch, SwitchControl};\n","import React from 'react';\n\nimport {StyledSwitch, SwitchControl} from './style';\n\ntype SwitchProps = {\n isActive: boolean;\n onChange: (nextValue: boolean) => void;\n containerClassName?: string;\n controlClassName?: string;\n elementId?: string;\n isDisabled?: boolean;\n};\n\nconst Switch: React.FC<SwitchProps> = ({\n isActive,\n onChange,\n containerClassName,\n controlClassName,\n elementId,\n isDisabled = false,\n}) => {\n const handleToggleCheckbox = () => {\n onChange(!isActive);\n };\n\n return (\n <StyledSwitch className={containerClassName}>\n <SwitchControl className={controlClassName}>\n <input\n type=\"checkbox\"\n checked={isActive}\n onChange={handleToggleCheckbox}\n id={elementId}\n disabled={isDisabled}\n />\n <label htmlFor={elementId} role=\"presentation\" />\n </SwitchControl>\n </StyledSwitch>\n );\n};\n\nexport default Switch;\n\nexport type {SwitchProps};\n"],"mappings":";;;;;AAGA,IAAM,IAAW,CAAS;;;;GAMpB,IAAU,EAAU,GAAO,OAAO,EAClC,IAAU,EAAU,GAAO,MAAM,EACjC,IAAW,EAAU,GAAa,MAAM,EAExC,IAAe,EAAO,GAAG;;;GAKzB,IAAgB,EAAO,GAAG;;eAEjB,EAAU;WACd,EAAO;;;;;;;;;;;;;;;;oBAgBE,EAAO;kCACO,EAAQ;;;;;;;;;;;;mBAYvB,EAAS;;;8BAGE,EAAQ;;;;;;;;;;;;;;uBAcf,MAAU,GAAO,OAAO,aAAa,QAAQ,EAAY;oCAC5C,EAAS;;;;;qBAKxB,EAAS;;;;uBAIP,MAAU,EAAU,GAAO,OAAO,aAAa,QAAQ,GAAa,MAAM,CAAC;;;;GChE5F,KAAiC,EACrC,aACA,aACA,uBACA,qBACA,cACA,gBAAa,SAOX,kBAAC,GAAD;CAAc,WAAW;WACvB,kBAAC,GAAD;EAAe,WAAW;YAA1B,CACE,kBAAC,SAAD;GACE,MAAK;GACL,SAAS;GACT,gBAV2B;IACjC,EAAS,CAAC,EAAS;;GAUb,IAAI;GACJ,UAAU;GACV,CAAA,EACF,kBAAC,SAAD;GAAO,SAAS;GAAW,MAAK;GAAiB,CAAA,CACnC;;CACH,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@propellerads/switch",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"exports": {
|
|
@@ -19,12 +19,13 @@
|
|
|
19
19
|
"url": "https://github.com/propellerads/ui-components/issues"
|
|
20
20
|
},
|
|
21
21
|
"scripts": {
|
|
22
|
-
"build": "tsc && vite build && rollup -c rollup.dts.config.mjs"
|
|
22
|
+
"build": "tsc && vite build && bunx rollup -c rollup.dts.config.mjs"
|
|
23
23
|
},
|
|
24
24
|
"homepage": "https://github.com/propellerads/ui-components#readme",
|
|
25
25
|
"private": false,
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@propellerads/stylevariables": "
|
|
27
|
+
"@propellerads/stylevariables": "workspace:^",
|
|
28
|
+
"@propellerads/theme-annotation": "workspace:^"
|
|
28
29
|
},
|
|
29
30
|
"peerDependencies": {
|
|
30
31
|
"react": "^18.0.0 || ^19.0.0",
|
|
@@ -33,10 +34,10 @@
|
|
|
33
34
|
"devDependencies": {
|
|
34
35
|
"@types/react": "^19.2.14",
|
|
35
36
|
"@types/styled-components": "^5.1.36",
|
|
36
|
-
"@vitejs/plugin-react": "^
|
|
37
|
-
"rollup": "^4.
|
|
38
|
-
"rollup-plugin-dts": "^6.
|
|
39
|
-
"typescript": "^
|
|
40
|
-
"vite": "^
|
|
37
|
+
"@vitejs/plugin-react": "^6.0.1",
|
|
38
|
+
"rollup": "^4.60.3",
|
|
39
|
+
"rollup-plugin-dts": "^6.4.1",
|
|
40
|
+
"typescript": "^6.0.3",
|
|
41
|
+
"vite": "^8.0.10"
|
|
41
42
|
}
|
|
42
43
|
}
|