bmi-next-brokers 3.0.2 → 3.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.
|
@@ -27,5 +27,9 @@ export interface SwitchProps {
|
|
|
27
27
|
inactiveTextColor?: string;
|
|
28
28
|
/** color de fondo del contenedor (CSS var --switch-bg) */
|
|
29
29
|
background?: string;
|
|
30
|
+
/** si false, cada opción se adapta a su contenido; por defecto true (todas al ancho de la más larga) */
|
|
31
|
+
equalWidth?: boolean;
|
|
32
|
+
/** estilos inline aplicados a todos los botones de opción */
|
|
33
|
+
optionStyle?: React.CSSProperties;
|
|
30
34
|
}
|
|
31
|
-
export declare const Switch: ({ options, active, onChange, size, simpleAnimation, iconSize, className, activeColor, activeTextColor, inactiveTextColor, background, }: SwitchProps) => import("react/jsx-runtime").JSX.Element;
|
|
35
|
+
export declare const Switch: ({ options, active, onChange, size, simpleAnimation, iconSize, className, activeColor, activeTextColor, inactiveTextColor, background, equalWidth, optionStyle, }: SwitchProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,102 +1,106 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useRef as p, useState as
|
|
3
|
-
import { Icon as
|
|
4
|
-
import '../../assets/Switch.css';const
|
|
1
|
+
import { jsxs as L, jsx as m } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as p, useState as k, useLayoutEffect as D } from "react";
|
|
3
|
+
import { Icon as R } from "../../icons/Icon.js";
|
|
4
|
+
import '../../assets/Switch.css';const T = "_small_56b6x_29", Z = "_large_56b6x_40", z = "_indicator_56b6x_52", B = "_simple_56b6x_68", K = "_option_56b6x_74", O = "_active_56b6x_74", V = "_label_56b6x_74", X = "_pop_56b6x_1", r = {
|
|
5
5
|
switch: "_switch_56b6x_1",
|
|
6
|
-
small:
|
|
7
|
-
large:
|
|
8
|
-
indicator:
|
|
9
|
-
simple:
|
|
10
|
-
option:
|
|
11
|
-
active:
|
|
12
|
-
label:
|
|
13
|
-
pop:
|
|
14
|
-
},
|
|
6
|
+
small: T,
|
|
7
|
+
large: Z,
|
|
8
|
+
indicator: z,
|
|
9
|
+
simple: B,
|
|
10
|
+
option: K,
|
|
11
|
+
active: O,
|
|
12
|
+
label: V,
|
|
13
|
+
pop: X
|
|
14
|
+
}, Y = {
|
|
15
15
|
small: 12,
|
|
16
16
|
medium: 14,
|
|
17
17
|
large: 16
|
|
18
|
-
},
|
|
18
|
+
}, G = ({
|
|
19
19
|
options: d = [],
|
|
20
20
|
active: l = 0,
|
|
21
21
|
onChange: o,
|
|
22
22
|
size: h = "medium",
|
|
23
23
|
simpleAnimation: u = !1,
|
|
24
|
-
iconSize:
|
|
25
|
-
className:
|
|
24
|
+
iconSize: S,
|
|
25
|
+
className: N = "",
|
|
26
26
|
activeColor: b,
|
|
27
27
|
activeTextColor: w,
|
|
28
28
|
inactiveTextColor: x,
|
|
29
|
-
background: y
|
|
29
|
+
background: y,
|
|
30
|
+
equalWidth: $ = !0,
|
|
31
|
+
optionStyle: W
|
|
30
32
|
}) => {
|
|
31
|
-
const
|
|
33
|
+
const _ = p([]), v = p(l), n = p(null), [I, E] = k({
|
|
32
34
|
left: 0,
|
|
33
35
|
width: 0
|
|
34
36
|
});
|
|
35
|
-
|
|
36
|
-
const t =
|
|
37
|
+
D(() => {
|
|
38
|
+
const t = _.current[l], s = _.current[v.current];
|
|
37
39
|
if (!t) return;
|
|
38
|
-
const i =
|
|
39
|
-
(
|
|
40
|
+
const i = _.current.filter(
|
|
41
|
+
(e) => e !== null
|
|
40
42
|
);
|
|
41
|
-
i.forEach((
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
43
|
+
if (i.forEach((e) => e.style.width = "auto"), $) {
|
|
44
|
+
const e = Math.max(...i.map((c) => c.offsetWidth));
|
|
45
|
+
i.forEach((c) => c.style.width = `${e}px`);
|
|
46
|
+
}
|
|
47
|
+
const f = () => E({ left: t.offsetLeft, width: t.offsetWidth });
|
|
48
|
+
if (!u && s && s !== t) {
|
|
49
|
+
const e = Math.min(s.offsetLeft, t.offsetLeft), c = Math.max(
|
|
50
|
+
s.offsetLeft + s.offsetWidth,
|
|
48
51
|
t.offsetLeft + t.offsetWidth
|
|
49
52
|
);
|
|
50
|
-
|
|
53
|
+
E({ left: e, width: c - e }), n.current && clearTimeout(n.current), n.current = setTimeout(f, 160);
|
|
51
54
|
} else
|
|
52
55
|
f();
|
|
53
|
-
return
|
|
56
|
+
return v.current = l, () => {
|
|
54
57
|
n.current && clearTimeout(n.current);
|
|
55
58
|
};
|
|
56
|
-
}, [l, d, u]);
|
|
57
|
-
const
|
|
59
|
+
}, [l, d, u, $]);
|
|
60
|
+
const M = S ?? Y[h], j = {
|
|
58
61
|
...b && { "--switch-active-bg": b },
|
|
59
62
|
...w && { "--switch-active-text": w },
|
|
60
63
|
...x && { "--switch-inactive-text": x },
|
|
61
64
|
...y && { "--switch-bg": y }
|
|
62
65
|
};
|
|
63
|
-
return /* @__PURE__ */
|
|
66
|
+
return /* @__PURE__ */ L(
|
|
64
67
|
"div",
|
|
65
68
|
{
|
|
66
|
-
className: `${r.switch} ${r[h]} ${u ? r.simple : ""} ${
|
|
67
|
-
style:
|
|
69
|
+
className: `${r.switch} ${r[h]} ${u ? r.simple : ""} ${N}`,
|
|
70
|
+
style: j,
|
|
68
71
|
children: [
|
|
69
72
|
/* @__PURE__ */ m(
|
|
70
73
|
"span",
|
|
71
74
|
{
|
|
72
75
|
className: r.indicator,
|
|
73
76
|
style: {
|
|
74
|
-
transform: `translateX(${
|
|
75
|
-
width: `${
|
|
77
|
+
transform: `translateX(${I.left}px)`,
|
|
78
|
+
width: `${I.width}px`
|
|
76
79
|
}
|
|
77
80
|
}
|
|
78
81
|
),
|
|
79
|
-
d.map((t,
|
|
80
|
-
const i = typeof t == "string",
|
|
81
|
-
return /* @__PURE__ */
|
|
82
|
+
d.map((t, s) => {
|
|
83
|
+
const i = typeof t == "string", f = i ? t : t.label, e = i ? null : t.icon, c = l === s;
|
|
84
|
+
return /* @__PURE__ */ L(
|
|
82
85
|
"div",
|
|
83
86
|
{
|
|
84
|
-
ref: (
|
|
85
|
-
|
|
87
|
+
ref: (a) => {
|
|
88
|
+
_.current[s] = a;
|
|
86
89
|
},
|
|
87
90
|
role: "button",
|
|
88
91
|
tabIndex: 0,
|
|
89
|
-
onClick: () => o == null ? void 0 : o(
|
|
90
|
-
onKeyDown: (
|
|
91
|
-
(
|
|
92
|
+
onClick: () => o == null ? void 0 : o(s),
|
|
93
|
+
onKeyDown: (a) => {
|
|
94
|
+
(a.key === "Enter" || a.key === " ") && (a.preventDefault(), o == null || o(s));
|
|
92
95
|
},
|
|
93
|
-
className: `${r.option} ${
|
|
96
|
+
className: `${r.option} ${c ? r.active : ""}`,
|
|
97
|
+
style: W,
|
|
94
98
|
children: [
|
|
95
|
-
|
|
96
|
-
|
|
99
|
+
e && /* @__PURE__ */ m(R, { name: e, size: M }),
|
|
100
|
+
f && /* @__PURE__ */ m("p", { className: r.label, children: f })
|
|
97
101
|
]
|
|
98
102
|
},
|
|
99
|
-
|
|
103
|
+
s
|
|
100
104
|
);
|
|
101
105
|
})
|
|
102
106
|
]
|
|
@@ -104,5 +108,5 @@ import '../../assets/Switch.css';const D = "_small_56b6x_29", R = "_large_56b6x_
|
|
|
104
108
|
);
|
|
105
109
|
};
|
|
106
110
|
export {
|
|
107
|
-
|
|
111
|
+
G as Switch
|
|
108
112
|
};
|
package/package.json
CHANGED