@cagatayfdn/flora-components 0.0.108 → 0.0.109
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/dist/Switch.css +1 -1
- package/dist/components/Switch/Switch.js +54 -49
- package/dist/index.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/package.json +1 -1
package/dist/Switch.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.
|
|
1
|
+
._switch_5793j_1{position:relative;display:inline-block;width:58px;height:26px;border-radius:24px}._switch_5793j_1 input{opacity:0;width:0;height:0;margin:0}._switch_5793j_1._checked_5793j_14{border-color:transparent}._switch_5793j_1._disabled_5793j_17{opacity:.5}._switch__small_5793j_20{width:58px}._switch__small_5793j_20 input:checked+._slider_5793j_23:before{transform:translate(33px)}._switch__small_5793j_20 ._active_5793j_26{padding-left:7px}._switch__small_5793j_20 ._passive_5793j_29{padding-right:7px}._switch__large_5793j_32{width:82px}._switch__large_5793j_32 input:checked+._slider_5793j_23:before{transform:translate(58px)}._switch__large_5793j_32 ._passive_5793j_29{padding-right:11px}._switch__large_5793j_32 ._active_5793j_26{padding-left:11px}._slider_5793j_23{position:absolute;cursor:pointer;top:0;left:0;right:0;bottom:0;background-color:#d4d6f0;border-color:2px solid;-webkit-transition:.4s;transition:.4s;border-radius:30px;text-align:inherit!important}._slider_5793j_23 span{font-size:9px;text-transform:uppercase;font-weight:700;padding:0 5px;display:flex!important;justify-content:flex-end;align-items:center;height:100%}._slider_5793j_23:before{position:absolute;content:"";height:22px;width:22px;bottom:2px;background-color:#fff;-webkit-transition:.4s;transition:.4s;border-radius:30px;transform:translate(2px)}input:checked+._slider_5793j_23{background-color:#71d200}input:checked+._slider_5793j_23 span{justify-content:flex-start}input:focus+._slider_5793j_23{box-shadow:0 0 1px #71d200}._slider_5793j_23._round_5793j_95{border-radius:34px}._slider_5793j_23._round_5793j_95:before{border-radius:50%}
|
|
@@ -1,71 +1,76 @@
|
|
|
1
|
-
import { j as
|
|
2
|
-
import u, { useState as v, useEffect as
|
|
3
|
-
import { c as
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
import { j as e } from "../../jsx-runtime-BcAkpsdy.js";
|
|
2
|
+
import u, { useState as v, useEffect as j } from "react";
|
|
3
|
+
import { c as d } from "../../index-BHf7G3IG.js";
|
|
4
|
+
import N from "../Label/Label.js";
|
|
5
|
+
import { Size as y } from "../../enums/size.js";
|
|
6
|
+
import { u as b } from "../../useTranslation-CnCPcxVj.js";
|
|
7
|
+
import '../../Switch.css';const S = "_checked_5793j_14", O = "_disabled_5793j_17", R = "_switch__small_5793j_20", g = "_slider_5793j_23", C = "_active_5793j_26", E = "_passive_5793j_29", F = "_switch__large_5793j_32", L = "_round_5793j_95", t = {
|
|
8
|
+
switch: "_switch_5793j_1",
|
|
9
|
+
checked: S,
|
|
10
|
+
disabled: O,
|
|
11
|
+
switch__small: R,
|
|
12
|
+
slider: g,
|
|
13
|
+
active: C,
|
|
14
|
+
passive: E,
|
|
15
|
+
switch__large: F,
|
|
16
|
+
round: L
|
|
17
|
+
}, B = u.forwardRef(
|
|
15
18
|
({
|
|
16
|
-
name:
|
|
19
|
+
name: a,
|
|
17
20
|
label: r,
|
|
18
|
-
className:
|
|
21
|
+
className: p,
|
|
19
22
|
isDisabled: i,
|
|
20
|
-
value:
|
|
23
|
+
value: c,
|
|
21
24
|
onChange: o,
|
|
22
|
-
onLabelClick:
|
|
25
|
+
onLabelClick: n,
|
|
23
26
|
checkedChildren: f,
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
h(
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
27
|
+
size: l = y.SM,
|
|
28
|
+
unCheckedChildren: w,
|
|
29
|
+
..._
|
|
30
|
+
}, x) => {
|
|
31
|
+
const [s, h] = v(c), { t: m } = b();
|
|
32
|
+
j(() => {
|
|
33
|
+
!_.readOnly && !i && c !== void 0 && o && o(s);
|
|
34
|
+
}, [s, c]), j(() => {
|
|
35
|
+
c && h(c);
|
|
36
|
+
}, [c]);
|
|
37
|
+
const k = () => {
|
|
38
|
+
!i && !_.readOnly && h(!s), !i && n && n(!s);
|
|
35
39
|
};
|
|
36
|
-
return /* @__PURE__ */
|
|
37
|
-
r && /* @__PURE__ */
|
|
38
|
-
/* @__PURE__ */
|
|
40
|
+
return /* @__PURE__ */ e.jsxs("div", { className: d(t.container, p), "data-testid": "switch-container", children: [
|
|
41
|
+
r && /* @__PURE__ */ e.jsx(N, { name: a, children: r }),
|
|
42
|
+
/* @__PURE__ */ e.jsx("div", { className: t.block, children: /* @__PURE__ */ e.jsxs(
|
|
39
43
|
"label",
|
|
40
44
|
{
|
|
41
|
-
className:
|
|
42
|
-
[
|
|
43
|
-
[
|
|
45
|
+
className: d(t.switch, {
|
|
46
|
+
[t.checked]: s,
|
|
47
|
+
[t.disabled]: i,
|
|
48
|
+
[t[`switch__${l}`]]: l
|
|
44
49
|
}),
|
|
45
|
-
htmlFor:
|
|
46
|
-
onClick: () =>
|
|
50
|
+
htmlFor: a,
|
|
51
|
+
onClick: () => k(),
|
|
47
52
|
children: [
|
|
48
|
-
/* @__PURE__ */
|
|
53
|
+
/* @__PURE__ */ e.jsx(
|
|
49
54
|
"input",
|
|
50
55
|
{
|
|
51
56
|
type: "checkbox",
|
|
52
|
-
name:
|
|
53
|
-
value:
|
|
57
|
+
name: a,
|
|
58
|
+
value: c,
|
|
54
59
|
"data-testid": "switch-input",
|
|
55
|
-
ref:
|
|
56
|
-
checked:
|
|
60
|
+
ref: x,
|
|
61
|
+
checked: s,
|
|
57
62
|
readOnly: !0,
|
|
58
|
-
...
|
|
63
|
+
..._
|
|
59
64
|
}
|
|
60
65
|
),
|
|
61
|
-
/* @__PURE__ */
|
|
66
|
+
/* @__PURE__ */ e.jsx("span", { className: t.slider, children: /* @__PURE__ */ e.jsx(
|
|
62
67
|
"span",
|
|
63
68
|
{
|
|
64
|
-
className:
|
|
65
|
-
[
|
|
66
|
-
[
|
|
69
|
+
className: d({
|
|
70
|
+
[t.active]: s,
|
|
71
|
+
[t.passive]: !s
|
|
67
72
|
}),
|
|
68
|
-
children:
|
|
73
|
+
children: s ? f || m("text.active") : w || m("text.passive")
|
|
69
74
|
}
|
|
70
75
|
) })
|
|
71
76
|
]
|
|
@@ -75,5 +80,5 @@ import '../../Switch.css';const N = "_checked_ptgnt_14", y = "_disabled_ptgnt_17
|
|
|
75
80
|
}
|
|
76
81
|
);
|
|
77
82
|
export {
|
|
78
|
-
|
|
83
|
+
B as default
|
|
79
84
|
};
|
package/dist/index.d.mts
CHANGED
|
@@ -1231,6 +1231,7 @@ export declare const Switch: React_2.ForwardRefExoticComponent<{
|
|
|
1231
1231
|
label?: string | undefined;
|
|
1232
1232
|
checked?: boolean | undefined;
|
|
1233
1233
|
className?: string | undefined;
|
|
1234
|
+
size?: Size | undefined;
|
|
1234
1235
|
value?: any;
|
|
1235
1236
|
onChange?: ((value: boolean) => void) | undefined;
|
|
1236
1237
|
onLabelClick?: ((value: boolean) => void) | undefined;
|
|
@@ -1243,6 +1244,7 @@ export declare type SwitchProps = {
|
|
|
1243
1244
|
label?: string;
|
|
1244
1245
|
checked?: boolean;
|
|
1245
1246
|
className?: string;
|
|
1247
|
+
size?: Size;
|
|
1246
1248
|
value?: any;
|
|
1247
1249
|
onChange?: (value: boolean) => void;
|
|
1248
1250
|
onLabelClick?: (value: boolean) => void;
|
package/dist/index.d.ts
CHANGED
|
@@ -1231,6 +1231,7 @@ export declare const Switch: React_2.ForwardRefExoticComponent<{
|
|
|
1231
1231
|
label?: string | undefined;
|
|
1232
1232
|
checked?: boolean | undefined;
|
|
1233
1233
|
className?: string | undefined;
|
|
1234
|
+
size?: Size | undefined;
|
|
1234
1235
|
value?: any;
|
|
1235
1236
|
onChange?: ((value: boolean) => void) | undefined;
|
|
1236
1237
|
onLabelClick?: ((value: boolean) => void) | undefined;
|
|
@@ -1243,6 +1244,7 @@ export declare type SwitchProps = {
|
|
|
1243
1244
|
label?: string;
|
|
1244
1245
|
checked?: boolean;
|
|
1245
1246
|
className?: string;
|
|
1247
|
+
size?: Size;
|
|
1246
1248
|
value?: any;
|
|
1247
1249
|
onChange?: (value: boolean) => void;
|
|
1248
1250
|
onLabelClick?: (value: boolean) => void;
|