meticulous-ui 3.8.2 → 3.8.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/cjs/components/Switch/Switch.cjs +29 -26
- package/components/Switch/Switch.js +80 -64
- package/package.json +1 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const u=require("react/jsx-runtime"),f=require("react"),x=require("styled-components"),G=require("prop-types"),b=require("../../colors/grey.cjs"),R=require("../../colors/green.cjs"),m=require("../../colors/white.cjs"),B=e=>e&&e.__esModule?e:{default:e},h=B(x),t=B(G),g=1.9,l=.28,i=g+l*2,K=.7,y=l+g,N=h.default.button`
|
|
2
2
|
position: relative;
|
|
3
3
|
isolation: isolate;
|
|
4
|
-
height: ${
|
|
4
|
+
height: ${i}rem;
|
|
5
5
|
width: ${({$hasLabel:e})=>e?"max-content":"4.8rem"};
|
|
6
6
|
min-width: 4.8rem;
|
|
7
7
|
max-width: 20rem;
|
|
8
|
-
border-radius: ${
|
|
8
|
+
border-radius: ${i/2}rem;
|
|
9
9
|
border: 0.094rem solid rgba(0, 0, 0, 0.08);
|
|
10
10
|
display: flex;
|
|
11
11
|
align-items: center;
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
cursor: ${({$disabled:e})=>e?"not-allowed":"pointer"};
|
|
15
15
|
outline: none;
|
|
16
16
|
|
|
17
|
-
padding-left: ${({$checked:e,$hasLabel:r})=>r?e?`${
|
|
18
|
-
padding-right: ${({$checked:e,$hasLabel:r})=>r?e?`${
|
|
17
|
+
padding-left: ${({$checked:e,$hasLabel:r})=>r?e?`${l}rem`:`${y}rem`:"0"};
|
|
18
|
+
padding-right: ${({$checked:e,$hasLabel:r})=>r?e?`${y}rem`:`${l}rem`:"0"};
|
|
19
19
|
|
|
20
20
|
transition:
|
|
21
21
|
background-color 0.3s ease,
|
|
@@ -23,13 +23,13 @@
|
|
|
23
23
|
padding-left 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
|
|
24
24
|
padding-right 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
|
|
25
25
|
|
|
26
|
-
background-color: ${({$checked:e,$onColor:r,$offColor:
|
|
26
|
+
background-color: ${({$checked:e,$onColor:r,$offColor:a,$disabled:d})=>d?b.default.m300:e?r||R.default.m500:a||b.default.m400};
|
|
27
27
|
|
|
28
28
|
&:focus-visible {
|
|
29
|
-
outline: 0.188rem solid ${({$onColor:e})=>e?`${e}88`:`${
|
|
29
|
+
outline: 0.188rem solid ${({$onColor:e})=>e?`${e}88`:`${R.default.m500}88`};
|
|
30
30
|
outline-offset: 0.125rem;
|
|
31
31
|
}
|
|
32
|
-
`,
|
|
32
|
+
`,X=h.default.div`
|
|
33
33
|
position: absolute;
|
|
34
34
|
top: 50%;
|
|
35
35
|
transform: translateY(-50%);
|
|
@@ -40,10 +40,13 @@
|
|
|
40
40
|
transition: all 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
|
|
41
41
|
z-index: 10;
|
|
42
42
|
|
|
43
|
-
${({$isGlass:e,$checked:r})=>e?
|
|
44
|
-
width: ${
|
|
45
|
-
height: ${
|
|
46
|
-
left:
|
|
43
|
+
${({$isGlass:e,$checked:r})=>e?x.css`
|
|
44
|
+
width: ${i*1.55}rem;
|
|
45
|
+
height: ${i*1.9}rem;
|
|
46
|
+
left: -0.75rem;
|
|
47
|
+
transform: translateY(-50%) translateX(${r?"var(--glass-travel, 0rem)":"0"});
|
|
48
|
+
transition: transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
|
|
49
|
+
will-change: transform;
|
|
47
50
|
|
|
48
51
|
/* transparent center, rim-only glass */
|
|
49
52
|
background: radial-gradient(
|
|
@@ -83,14 +86,14 @@
|
|
|
83
86
|
&::after {
|
|
84
87
|
display: none;
|
|
85
88
|
}
|
|
86
|
-
`:
|
|
87
|
-
width: ${
|
|
88
|
-
height: ${
|
|
89
|
-
left: ${r?`calc(100% - ${
|
|
90
|
-
background: ${
|
|
89
|
+
`:x.css`
|
|
90
|
+
width: ${g}rem;
|
|
91
|
+
height: ${g}rem;
|
|
92
|
+
left: ${r?`calc(100% - ${y}rem)`:`${l}rem`};
|
|
93
|
+
background: ${m.default};
|
|
91
94
|
box-shadow: 0 0.125rem 0.375rem rgba(0, 0, 0, 0.25);
|
|
92
95
|
`}
|
|
93
|
-
`,
|
|
96
|
+
`,Z=h.default.span`
|
|
94
97
|
position: relative;
|
|
95
98
|
z-index: 2;
|
|
96
99
|
font-size: 0.9rem;
|
|
@@ -102,9 +105,9 @@
|
|
|
102
105
|
text-overflow: ellipsis;
|
|
103
106
|
user-select: none;
|
|
104
107
|
pointer-events: none;
|
|
105
|
-
padding: ${({$isGlass:e,$checked:r})=>e?r?"0 1.6rem 0 0.6rem":"0 0.6rem 0 1.6rem":`0 ${
|
|
108
|
+
padding: ${({$isGlass:e,$checked:r})=>e?r?"0 1.6rem 0 0.6rem":"0 0.6rem 0 1.6rem":`0 ${K}rem`};
|
|
106
109
|
color: rgba(255, 255, 255, 0.95);
|
|
107
|
-
`,
|
|
110
|
+
`,J=h.default.span`
|
|
108
111
|
display: flex;
|
|
109
112
|
align-items: center;
|
|
110
113
|
justify-content: center;
|
|
@@ -113,9 +116,9 @@
|
|
|
113
116
|
stroke-width: 2.5;
|
|
114
117
|
}
|
|
115
118
|
|
|
116
|
-
filter: drop-shadow(0 0 0.25rem ${({$color:e})=>e||
|
|
117
|
-
drop-shadow(0 0 0.625rem ${({$color:e})=>e||
|
|
118
|
-
drop-shadow(0 0 1.25rem ${({$color:e})=>e||
|
|
119
|
-
drop-shadow(0 0 2.5rem ${({$color:e})=>e?`${e}99`:`${
|
|
120
|
-
drop-shadow(0 0 3.75rem ${({$color:e})=>e?`${e}4D`:`${
|
|
121
|
-
`,
|
|
119
|
+
filter: drop-shadow(0 0 0.25rem ${({$color:e})=>e||m.default})
|
|
120
|
+
drop-shadow(0 0 0.625rem ${({$color:e})=>e||m.default})
|
|
121
|
+
drop-shadow(0 0 1.25rem ${({$color:e})=>e||m.default})
|
|
122
|
+
drop-shadow(0 0 2.5rem ${({$color:e})=>e?`${e}99`:`${b.default.m100}99`})
|
|
123
|
+
drop-shadow(0 0 3.75rem ${({$color:e})=>e?`${e}4D`:`${b.default.m200}4D`});
|
|
124
|
+
`,C=({checked:e,defaultChecked:r=!1,onChange:a,onIcon:d,offIcon:k,onColor:_,offColor:T,onLabel:z,offLabel:j,label:I,id:P,disabled:p=!1,isGlass:o,...$})=>{const[A,E]=f.useState(r),q=e!==void 0,n=q?e:A,w=f.useRef(null),[D,H]=f.useState(null);f.useEffect(()=>{if(!o||!w.current)return;const c=w.current,s=()=>{const U=parseFloat(getComputedStyle(document.documentElement).fontSize),Y=c.getBoundingClientRect().width/U-(i*1.2+.1-.75);H(`${Y.toFixed(4)}rem`)};s();const M=new ResizeObserver(s);return M.observe(c),()=>M.disconnect()},[o]);const F=c=>{if(c.preventDefault(),p)return;const s=!n;q||E(s),a==null||a(s)},O=d!=null||k!=null,S=z!=null||j!=null,L=n?d:k,v=n?z:j;return u.jsxs(N,{...$,ref:w,id:P,type:"button",role:"switch","aria-checked":n,"aria-label":I||v||void 0,"aria-disabled":p||void 0,onClick:F,$checked:n,$disabled:p,$onColor:_,$offColor:T,$hasLabel:S,style:D!=null?{...$.style,"--glass-travel":D}:$.style,children:[u.jsx(X,{"aria-hidden":"true",$checked:n,$isGlass:o,children:o?u.jsx(J,{$color:n?_:T,children:L}):O&&L}),S&&v&&u.jsx(Z,{$isGlass:o,$checked:n,"aria-live":"polite","aria-atomic":"true",children:v})]})};C.propTypes={checked:t.default.bool,defaultChecked:t.default.bool,onChange:t.default.func,onIcon:t.default.node,offIcon:t.default.node,onColor:t.default.string,offColor:t.default.string,onLabel:t.default.string,offLabel:t.default.string,label:t.default.string,id:t.default.string,disabled:t.default.bool,isGlass:t.default.bool};exports.default=C;
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useState as
|
|
3
|
-
import
|
|
1
|
+
import { jsxs as Y, jsx as w } from "react/jsx-runtime";
|
|
2
|
+
import { useState as R, useRef as G, useEffect as K } from "react";
|
|
3
|
+
import g, { css as _ } from "styled-components";
|
|
4
4
|
import r from "prop-types";
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
const
|
|
5
|
+
import b from "../../colors/grey.js";
|
|
6
|
+
import j from "../../colors/green.js";
|
|
7
|
+
import m from "../../colors/white.js";
|
|
8
|
+
const u = 1.9, a = 0.28, l = u + a * 2, N = 0.7, v = a + u, X = g.button`
|
|
9
9
|
position: relative;
|
|
10
10
|
isolation: isolate;
|
|
11
|
-
height: ${
|
|
11
|
+
height: ${l}rem;
|
|
12
12
|
width: ${({ $hasLabel: e }) => e ? "max-content" : "4.8rem"};
|
|
13
13
|
min-width: 4.8rem;
|
|
14
14
|
max-width: 20rem;
|
|
15
|
-
border-radius: ${
|
|
15
|
+
border-radius: ${l / 2}rem;
|
|
16
16
|
border: 0.094rem solid rgba(0, 0, 0, 0.08);
|
|
17
17
|
display: flex;
|
|
18
18
|
align-items: center;
|
|
@@ -21,8 +21,8 @@ const c = 1.9, s = 0.28, n = c + s * 2, E = 0.7, u = s + c, G = m.button`
|
|
|
21
21
|
cursor: ${({ $disabled: e }) => e ? "not-allowed" : "pointer"};
|
|
22
22
|
outline: none;
|
|
23
23
|
|
|
24
|
-
padding-left: ${({ $checked: e, $hasLabel: t }) => t ? e ? `${
|
|
25
|
-
padding-right: ${({ $checked: e, $hasLabel: t }) => t ? e ? `${
|
|
24
|
+
padding-left: ${({ $checked: e, $hasLabel: t }) => t ? e ? `${a}rem` : `${v}rem` : "0"};
|
|
25
|
+
padding-right: ${({ $checked: e, $hasLabel: t }) => t ? e ? `${v}rem` : `${a}rem` : "0"};
|
|
26
26
|
|
|
27
27
|
transition:
|
|
28
28
|
background-color 0.3s ease,
|
|
@@ -30,13 +30,13 @@ const c = 1.9, s = 0.28, n = c + s * 2, E = 0.7, u = s + c, G = m.button`
|
|
|
30
30
|
padding-left 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
|
|
31
31
|
padding-right 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
|
|
32
32
|
|
|
33
|
-
background-color: ${({ $checked: e, $onColor: t, $offColor:
|
|
33
|
+
background-color: ${({ $checked: e, $onColor: t, $offColor: n, $disabled: c }) => c ? b.m300 : e ? t || j.m500 : n || b.m400};
|
|
34
34
|
|
|
35
35
|
&:focus-visible {
|
|
36
|
-
outline: 0.188rem solid ${({ $onColor: e }) => e ? `${e}88` : `${
|
|
36
|
+
outline: 0.188rem solid ${({ $onColor: e }) => e ? `${e}88` : `${j.m500}88`};
|
|
37
37
|
outline-offset: 0.125rem;
|
|
38
38
|
}
|
|
39
|
-
`,
|
|
39
|
+
`, Z = g.div`
|
|
40
40
|
position: absolute;
|
|
41
41
|
top: 50%;
|
|
42
42
|
transform: translateY(-50%);
|
|
@@ -47,10 +47,13 @@ const c = 1.9, s = 0.28, n = c + s * 2, E = 0.7, u = s + c, G = m.button`
|
|
|
47
47
|
transition: all 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
|
|
48
48
|
z-index: 10;
|
|
49
49
|
|
|
50
|
-
${({ $isGlass: e, $checked: t }) => e ?
|
|
51
|
-
width: ${
|
|
52
|
-
height: ${
|
|
53
|
-
left:
|
|
50
|
+
${({ $isGlass: e, $checked: t }) => e ? _`
|
|
51
|
+
width: ${l * 1.55}rem;
|
|
52
|
+
height: ${l * 1.9}rem;
|
|
53
|
+
left: -0.75rem;
|
|
54
|
+
transform: translateY(-50%) translateX(${t ? "var(--glass-travel, 0rem)" : "0"});
|
|
55
|
+
transition: transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
|
|
56
|
+
will-change: transform;
|
|
54
57
|
|
|
55
58
|
/* transparent center, rim-only glass */
|
|
56
59
|
background: radial-gradient(
|
|
@@ -90,14 +93,14 @@ const c = 1.9, s = 0.28, n = c + s * 2, E = 0.7, u = s + c, G = m.button`
|
|
|
90
93
|
&::after {
|
|
91
94
|
display: none;
|
|
92
95
|
}
|
|
93
|
-
` :
|
|
94
|
-
width: ${
|
|
95
|
-
height: ${
|
|
96
|
-
left: ${t ? `calc(100% - ${
|
|
97
|
-
background: ${
|
|
96
|
+
` : _`
|
|
97
|
+
width: ${u}rem;
|
|
98
|
+
height: ${u}rem;
|
|
99
|
+
left: ${t ? `calc(100% - ${v}rem)` : `${a}rem`};
|
|
100
|
+
background: ${m};
|
|
98
101
|
box-shadow: 0 0.125rem 0.375rem rgba(0, 0, 0, 0.25);
|
|
99
102
|
`}
|
|
100
|
-
`,
|
|
103
|
+
`, q = g.span`
|
|
101
104
|
position: relative;
|
|
102
105
|
z-index: 2;
|
|
103
106
|
font-size: 0.9rem;
|
|
@@ -109,9 +112,9 @@ const c = 1.9, s = 0.28, n = c + s * 2, E = 0.7, u = s + c, G = m.button`
|
|
|
109
112
|
text-overflow: ellipsis;
|
|
110
113
|
user-select: none;
|
|
111
114
|
pointer-events: none;
|
|
112
|
-
padding: ${({ $isGlass: e, $checked: t }) => e ? t ? "0 1.6rem 0 0.6rem" : "0 0.6rem 0 1.6rem" : `0 ${
|
|
115
|
+
padding: ${({ $isGlass: e, $checked: t }) => e ? t ? "0 1.6rem 0 0.6rem" : "0 0.6rem 0 1.6rem" : `0 ${N}rem`};
|
|
113
116
|
color: rgba(255, 255, 255, 0.95);
|
|
114
|
-
`,
|
|
117
|
+
`, J = g.span`
|
|
115
118
|
display: flex;
|
|
116
119
|
align-items: center;
|
|
117
120
|
justify-content: center;
|
|
@@ -120,56 +123,69 @@ const c = 1.9, s = 0.28, n = c + s * 2, E = 0.7, u = s + c, G = m.button`
|
|
|
120
123
|
stroke-width: 2.5;
|
|
121
124
|
}
|
|
122
125
|
|
|
123
|
-
filter: drop-shadow(0 0 0.25rem ${({ $color: e }) => e ||
|
|
124
|
-
drop-shadow(0 0 0.625rem ${({ $color: e }) => e ||
|
|
125
|
-
drop-shadow(0 0 1.25rem ${({ $color: e }) => e ||
|
|
126
|
-
drop-shadow(0 0 2.5rem ${({ $color: e }) => e ? `${e}99` : `${
|
|
127
|
-
drop-shadow(0 0 3.75rem ${({ $color: e }) => e ? `${e}4D` : `${
|
|
128
|
-
`,
|
|
126
|
+
filter: drop-shadow(0 0 0.25rem ${({ $color: e }) => e || m})
|
|
127
|
+
drop-shadow(0 0 0.625rem ${({ $color: e }) => e || m})
|
|
128
|
+
drop-shadow(0 0 1.25rem ${({ $color: e }) => e || m})
|
|
129
|
+
drop-shadow(0 0 2.5rem ${({ $color: e }) => e ? `${e}99` : `${b.m100}99`})
|
|
130
|
+
drop-shadow(0 0 3.75rem ${({ $color: e }) => e ? `${e}4D` : `${b.m200}4D`});
|
|
131
|
+
`, Q = ({
|
|
129
132
|
checked: e,
|
|
130
133
|
defaultChecked: t = !1,
|
|
131
|
-
onChange:
|
|
132
|
-
onIcon:
|
|
133
|
-
offIcon:
|
|
134
|
-
onColor:
|
|
135
|
-
offColor:
|
|
136
|
-
onLabel:
|
|
137
|
-
offLabel:
|
|
138
|
-
label:
|
|
139
|
-
id:
|
|
140
|
-
disabled:
|
|
141
|
-
isGlass:
|
|
142
|
-
...
|
|
134
|
+
onChange: n,
|
|
135
|
+
onIcon: c,
|
|
136
|
+
offIcon: x,
|
|
137
|
+
onColor: k,
|
|
138
|
+
offColor: y,
|
|
139
|
+
onLabel: T,
|
|
140
|
+
offLabel: z,
|
|
141
|
+
label: A,
|
|
142
|
+
id: E,
|
|
143
|
+
disabled: f = !1,
|
|
144
|
+
isGlass: s,
|
|
145
|
+
...p
|
|
143
146
|
}) => {
|
|
144
|
-
const [
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
147
|
+
const [H, S] = R(t), D = e !== void 0, o = D ? e : H, h = G(null), [L, F] = R(null);
|
|
148
|
+
K(() => {
|
|
149
|
+
if (!s || !h.current) return;
|
|
150
|
+
const d = h.current, i = () => {
|
|
151
|
+
const U = parseFloat(getComputedStyle(document.documentElement).fontSize), O = d.getBoundingClientRect().width / U - (l * 1.2 + 0.1 - 0.75);
|
|
152
|
+
F(`${O.toFixed(4)}rem`);
|
|
153
|
+
};
|
|
154
|
+
i();
|
|
155
|
+
const I = new ResizeObserver(i);
|
|
156
|
+
return I.observe(d), () => I.disconnect();
|
|
157
|
+
}, [s]);
|
|
158
|
+
const M = (d) => {
|
|
159
|
+
if (d.preventDefault(), f) return;
|
|
160
|
+
const i = !o;
|
|
161
|
+
D || S(i), n == null || n(i);
|
|
162
|
+
}, P = c != null || x != null, B = T != null || z != null, C = o ? c : x, $ = o ? T : z;
|
|
163
|
+
return /* @__PURE__ */ Y(
|
|
164
|
+
X,
|
|
151
165
|
{
|
|
152
|
-
...
|
|
153
|
-
|
|
166
|
+
...p,
|
|
167
|
+
ref: h,
|
|
168
|
+
id: E,
|
|
154
169
|
type: "button",
|
|
155
170
|
role: "switch",
|
|
156
171
|
"aria-checked": o,
|
|
157
|
-
"aria-label":
|
|
158
|
-
"aria-disabled":
|
|
159
|
-
onClick:
|
|
172
|
+
"aria-label": A || $ || void 0,
|
|
173
|
+
"aria-disabled": f || void 0,
|
|
174
|
+
onClick: M,
|
|
160
175
|
$checked: o,
|
|
161
|
-
$disabled:
|
|
162
|
-
$onColor:
|
|
163
|
-
$offColor:
|
|
164
|
-
$hasLabel:
|
|
176
|
+
$disabled: f,
|
|
177
|
+
$onColor: k,
|
|
178
|
+
$offColor: y,
|
|
179
|
+
$hasLabel: B,
|
|
180
|
+
style: L != null ? { ...p.style, "--glass-travel": L } : p.style,
|
|
165
181
|
children: [
|
|
166
|
-
/* @__PURE__ */
|
|
167
|
-
|
|
182
|
+
/* @__PURE__ */ w(Z, { "aria-hidden": "true", $checked: o, $isGlass: s, children: s ? /* @__PURE__ */ w(J, { $color: o ? k : y, children: C }) : P && C }),
|
|
183
|
+
B && $ && /* @__PURE__ */ w(q, { $isGlass: s, $checked: o, "aria-live": "polite", "aria-atomic": "true", children: $ })
|
|
168
184
|
]
|
|
169
185
|
}
|
|
170
186
|
);
|
|
171
187
|
};
|
|
172
|
-
|
|
188
|
+
Q.propTypes = {
|
|
173
189
|
checked: r.bool,
|
|
174
190
|
defaultChecked: r.bool,
|
|
175
191
|
onChange: r.func,
|
|
@@ -185,5 +201,5 @@ O.propTypes = {
|
|
|
185
201
|
isGlass: r.bool
|
|
186
202
|
};
|
|
187
203
|
export {
|
|
188
|
-
|
|
204
|
+
Q as default
|
|
189
205
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "meticulous-ui",
|
|
3
|
-
"version": "3.8.
|
|
3
|
+
"version": "3.8.3",
|
|
4
4
|
"license": "ISC",
|
|
5
5
|
"description": "A comprehensive React UI component library with a wide range of customizable components, icons, colors, and utilities for building modern web applications.",
|
|
6
6
|
"types": "./index.d.ts",
|