@propellerads/switch 5.0.1 → 5.0.3

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
@@ -6,7 +6,7 @@ Links: [NPM](https://www.npmjs.com/package/@propellerads/switch) · [GitHub](htt
6
6
 
7
7
  ## Install
8
8
 
9
- - `yarn add @propellerads/switch`
9
+ - `bun add @propellerads/switch`
10
10
  or
11
11
  - `npm install @propellerads/switch --save`
12
12
 
package/dist/index.js CHANGED
@@ -1,17 +1,19 @@
1
- import { jsx as t, jsxs as b } from "react/jsx-runtime";
2
- import n, { keyframes as p } from "styled-components";
3
- import { hslToHsla as o, black as s, actionColor as a, fontSmall as x, gray50 as k, gray95 as m } from "@propellerads/stylevariables";
4
- const l = p`
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
- `, f = o(s, "0.15"), u = o(s, "0.5"), g = o(a, "0.5"), w = n.div`
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
- `, y = n.div`
13
+ `, h = e.div`
12
14
  display: block;
13
- font-size: ${x}px;
14
- color: ${k};
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: ${m};
31
- box-shadow: inset 0 0 3px ${f};
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: ${l} 0.3s ease-out;
45
+ animation: ${u} 0.3s ease-out;
44
46
  border-radius: 50px;
45
47
  background: white;
46
- box-shadow: 0 0 3px 0 ${u};
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 || a};
61
- box-shadow: inset 0 0 1px ${g};
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: ${l} 0.2s ease-out;
68
+ animation: ${u} 0.2s ease-out;
67
69
  }
68
70
 
69
71
  &:checked:disabled + label:before {
70
- background: ${(e) => o(e?.theme?.actionColor?.main || a, "0.3")};
72
+ background: ${(e) => s(e?.theme?.actionColor?.main || n, "0.3")};
71
73
  }
72
74
  }
73
75
  }
74
- `, T = ({
75
- isActive: e,
76
- onChange: c,
77
- containerClassName: r,
78
- controlClassName: d,
79
- elementId: i,
80
- isDisabled: h = !1
81
- }) => /* @__PURE__ */ t(w, { className: r, children: /* @__PURE__ */ b(y, { className: d, children: [
82
- /* @__PURE__ */ t(
83
- "input",
84
- {
85
- type: "checkbox",
86
- checked: e,
87
- onChange: () => {
88
- c(!e);
89
- },
90
- id: i,
91
- disabled: h
92
- }
93
- ),
94
- /* @__PURE__ */ t("label", { htmlFor: i, role: "presentation" })
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"],"names":["switchOn","keyframes","black15","hslToHsla","black","black25","action50","actionColor","StyledSwitch","styled","SwitchControl","fontSmall","gray50","gray95","props","Switch","isActive","onChange","containerClassName","controlClassName","elementId","isDisabled","jsxs","jsx"],"mappings":";;;AAGA,MAAMA,IAAWC;AAAA;AAAA;AAAA;AAAA,GAMXC,IAAUC,EAAUC,GAAO,MAAM,GACjCC,IAAUF,EAAUC,GAAO,KAAK,GAChCE,IAAWH,EAAUI,GAAa,KAAK,GAEvCC,IAAeC,EAAO;AAAA;AAAA;AAAA,GAKtBC,IAAgBD,EAAO;AAAA;AAAA,eAEdE,CAAS;AAAA,WACbC,CAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAgBGC,CAAM;AAAA,kCACQX,CAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAYtBF,CAAQ;AAAA;AAAA;AAAA,8BAGGK,CAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAcf,CAACS,MAAUA,GAAO,OAAO,aAAa,QAAQP,CAAW;AAAA,oCAC3CD,CAAQ;AAAA;AAAA;AAAA;AAAA;AAAA,qBAKvBN,CAAQ;AAAA;AAAA;AAAA;AAAA,sBAIP,CAACc,MAAUX,EAAUW,GAAO,OAAO,aAAa,QAAQP,GAAa,KAAK,CAAC;AAAA;AAAA;AAAA;AAAA,GChE3FQ,IAAgC,CAAC;AAAA,EACrC,UAAAC;AAAA,EACA,UAAAC;AAAA,EACA,oBAAAC;AAAA,EACA,kBAAAC;AAAA,EACA,WAAAC;AAAA,EACA,YAAAC,IAAa;AACf,wBAMKb,GAAA,EAAa,WAAWU,GACvB,UAAA,gBAAAI,EAACZ,GAAA,EAAc,WAAWS,GACxB,UAAA;AAAA,EAAA,gBAAAI;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,MAAK;AAAA,MACL,SAASP;AAAA,MACT,UAVqB,MAAM;AACjC,QAAAC,EAAS,CAACD,CAAQ;AAAA,MACpB;AAAA,MASQ,IAAII;AAAA,MACJ,UAAUC;AAAA,IAAA;AAAA,EAAA;AAAA,EAEZ,gBAAAE,EAAC,SAAA,EAAM,SAASH,GAAW,MAAK,eAAA,CAAe;AAAA,EAAA,CACjD,EAAA,CACF;"}
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.1",
3
+ "version": "5.0.3",
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": "^2.0.2"
27
+ "@propellerads/stylevariables": "^2.0.2",
28
+ "@propellerads/theme-annotation": "^2.0.0"
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": "^5.1.4",
37
- "rollup": "^4.58.0",
38
- "rollup-plugin-dts": "^6.3.0",
39
- "typescript": "^5.9.3",
40
- "vite": "^7.3.1"
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
  }