bmi-next-brokers 3.1.9 → 3.2.0

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.
@@ -1 +1 @@
1
- ._switch_1l66v_1{--switch-bg: var(--ui-blue-100);--switch-active-bg: #2054a5;--switch-active-text: #ffffff;--switch-inactive-text: #2054a5;--switch-height: 40px;--switch-inset: 4px;--switch-pad-y: 7px;--switch-pad-x: 12px;--switch-font: 16px;--switch-line-height: 19.2px;position:relative;min-height:var(--switch-height);display:flex;flex-direction:row;gap:0;padding:var(--switch-inset);border-radius:1000px;background:var(--switch-bg);width:fit-content}._switch_1l66v_1._fullWidth_1l66v_26{width:100%}._switch_1l66v_1._fullWidth_1l66v_26 ._option_1l66v_30{flex:1}._extraSmall_1l66v_35{--switch-height: 28px;--switch-inset: 3px;--switch-pad-y: 6px;--switch-pad-x: 12px;--switch-font: 12px;--switch-line-height: 14.4px}._small_1l66v_44{--switch-height: 32px;--switch-inset: 3px;--switch-pad-y: 6px;--switch-pad-x: 12px;--switch-font: 14px;--switch-line-height: 16.8px}._large_1l66v_53{--switch-height: 46px;--switch-inset: 4px;--switch-pad-y: 10px;--switch-pad-x: 16px;--switch-font: 18px;--switch-line-height: 21.6px}._extraLarge_1l66v_62{--switch-height: 52px;--switch-inset: 6px;--switch-pad-y: 6px;--switch-pad-x: 14px;--switch-font: 20px;--switch-line-height: 24px}._switch_1l66v_1 ._indicator_1l66v_72{position:absolute;top:var(--switch-inset);bottom:var(--switch-inset);left:0;background:#2054a5;border-radius:1000px;transition:transform .24s cubic-bezier(.4,0,.2,1),width .24s cubic-bezier(.4,0,.2,1);pointer-events:none;z-index:0}._switch_1l66v_1._simple_1l66v_88 ._indicator_1l66v_72,._switch_1l66v_1._simple_1l66v_88 ._option_1l66v_30{transition:none}._switch_1l66v_1 ._option_1l66v_30{position:relative;z-index:1;border:none;background:transparent;color:var(--switch-inactive-text);font-family:var(--font-medium);font-size:var(--switch-font);line-height:var(--switch-line-height);cursor:pointer;transition:color .3s ease;white-space:nowrap;display:flex;align-items:center;justify-content:center;gap:4px;padding:var(--switch-pad-y) var(--switch-pad-x);border-radius:1000px}._switch_1l66v_1 ._option_1l66v_30._active_1l66v_114{color:var(--switch-active-text)}
1
+ ._switch_1sbs8_1{--switch-bg: var(--ui-blue-100);--switch-active-bg: #2054a5;--switch-active-text: #ffffff;--switch-inactive-text: #2054a5;--switch-height: 40px;--switch-inset: 4px;--switch-pad-y: 7px;--switch-pad-x: 12px;--switch-font: 16px;--switch-line-height: 19.2px;position:relative;min-height:var(--switch-height);display:flex;flex-direction:row;gap:0;padding:var(--switch-inset);border-radius:1000px;background:var(--switch-bg);width:fit-content}._switch_1sbs8_1._fullWidth_1sbs8_26{width:100%}._switch_1sbs8_1._fullWidth_1sbs8_26 ._option_1sbs8_30{flex:1}._extraSmall_1sbs8_35{--switch-height: 28px;--switch-inset: 3px;--switch-pad-y: 6px;--switch-pad-x: 12px;--switch-font: 12px;--switch-line-height: 14.4px}._small_1sbs8_44{--switch-height: 32px;--switch-inset: 3px;--switch-pad-y: 6px;--switch-pad-x: 12px;--switch-font: 14px;--switch-line-height: 16.8px}._large_1sbs8_53{--switch-height: 46px;--switch-inset: 4px;--switch-pad-y: 10px;--switch-pad-x: 16px;--switch-font: 18px;--switch-line-height: 21.6px}._extraLarge_1sbs8_62{--switch-height: 52px;--switch-inset: 6px;--switch-pad-y: 6px;--switch-pad-x: 14px;--switch-font: 20px;--switch-line-height: 24px}._switch_1sbs8_1 ._indicator_1sbs8_72{position:absolute;top:var(--switch-inset);bottom:var(--switch-inset);left:0;background:#2054a5;border-radius:1000px;transition:transform .24s cubic-bezier(.4,0,.2,1),width .24s cubic-bezier(.4,0,.2,1);pointer-events:none;z-index:0}._switch_1sbs8_1._simple_1sbs8_88 ._indicator_1sbs8_72,._switch_1sbs8_1._simple_1sbs8_88 ._option_1sbs8_30{transition:none}._switch_1sbs8_1 ._option_1sbs8_30{position:relative;z-index:1;border:none;background:transparent;color:var(--switch-inactive-text);font-family:var(--font-medium);font-size:var(--switch-font);line-height:var(--switch-line-height);cursor:pointer;transition:color .3s ease;white-space:nowrap;display:flex;align-items:center;justify-content:center;gap:4px;padding:var(--switch-pad-y) var(--switch-pad-x);border-radius:1000px}._switch_1sbs8_1 ._option_1sbs8_30._active_1sbs8_114{color:var(--switch-active-text)}._toggleRoot_1sbs8_119{--switch-bg: #5c6b87;--switch-active-bg: #2054a5;--switch-inactive-text: #2054a5;--switch-track-h: calc(var(--switch-height, 40px) * .62);--switch-track-w: calc(var(--switch-track-h) * 1.85);--switch-knob-inset: calc(var(--switch-track-h) * .08);display:inline-flex;align-items:center;gap:12px;width:fit-content;cursor:pointer}._toggleRoot_1sbs8_119._fullWidth_1sbs8_26{width:100%;justify-content:space-between}._toggleRoot_1sbs8_119._disabled_1sbs8_141{opacity:.5;cursor:not-allowed}._toggleRoot_1sbs8_119 ._toggleLabel_1sbs8_146{color:var(--switch-label-color, #212121);font-family:var(--font-regular);font-size:var(--switch-label-font, 14px);line-height:1.2}._toggleRoot_1sbs8_119._extraSmall_1sbs8_35{--switch-label-font: 11px}._toggleRoot_1sbs8_119._small_1sbs8_44{--switch-label-font: 12px}._toggleRoot_1sbs8_119._large_1sbs8_53{--switch-label-font: 16px}._toggleRoot_1sbs8_119._extraLarge_1sbs8_62{--switch-label-font: 18px}._toggleRoot_1sbs8_119 ._track_1sbs8_170{position:relative;flex:none;border:none;padding:0;width:var(--switch-track-w);height:var(--switch-track-h);border-radius:1000px;background:var(--switch-bg);cursor:inherit;transition:background .24s cubic-bezier(.4,0,.2,1)}._toggleRoot_1sbs8_119 ._track_1sbs8_170._on_1sbs8_183{background:var(--switch-active-bg)}._toggleRoot_1sbs8_119 ._knob_1sbs8_187{position:absolute;top:var(--switch-knob-inset);left:var(--switch-knob-inset);width:calc(var(--switch-track-h) - var(--switch-knob-inset) * 2);height:calc(var(--switch-track-h) - var(--switch-knob-inset) * 2);border-radius:50%;background:#fff;display:flex;align-items:center;justify-content:center;transition:transform .24s cubic-bezier(.4,0,.2,1)}._toggleRoot_1sbs8_119 ._track_1sbs8_170._on_1sbs8_183 ._knob_1sbs8_187{transform:translate(calc(var(--switch-track-w) - var(--switch-track-h)))}._toggleRoot_1sbs8_119 ._knobIcon_1sbs8_206{width:85%;height:85%;color:var(--switch-active-bg);opacity:0;transform:scale(.6);transition:opacity .18s ease,transform .18s ease}._toggleRoot_1sbs8_119 ._track_1sbs8_170._on_1sbs8_183 ._knobIcon_1sbs8_206{opacity:1;transform:scale(1)}._toggleRoot_1sbs8_119._simple_1sbs8_88 ._track_1sbs8_170,._toggleRoot_1sbs8_119._simple_1sbs8_88 ._knob_1sbs8_187,._toggleRoot_1sbs8_119._simple_1sbs8_88 ._knobIcon_1sbs8_206{transition:none}
@@ -6,8 +6,8 @@ export type SwitchOption = string | {
6
6
  };
7
7
  export type SwitchSize = "extraSmall" | "small" | "medium" | "large" | "extraLarge";
8
8
  export interface SwitchProps {
9
- /** opciones a mostrar: strings u objetos { label, icon } */
10
- options: SwitchOption[];
9
+ /** opciones a mostrar: strings u objetos { label, icon }; no aplica en modo `toggle` */
10
+ options?: SwitchOption[];
11
11
  /** índice de la opción activa */
12
12
  active?: number;
13
13
  /** callback que recibe el índice seleccionado */
@@ -33,9 +33,23 @@ export interface SwitchProps {
33
33
  fullWidth?: boolean;
34
34
  /** estilos inline aplicados a todos los botones de opción */
35
35
  optionStyle?: React.CSSProperties;
36
+ /** modo interruptor encendido/apagado: ignora `options`, `active` y `onChange` */
37
+ toggle?: boolean;
38
+ /** estado del interruptor en modo `toggle` */
39
+ checked?: boolean;
40
+ /** callback del interruptor en modo `toggle` */
41
+ onToggle?: (checked: boolean) => void;
42
+ /** texto junto al interruptor en modo `toggle` */
43
+ label?: string;
44
+ /** lado del `label` respecto al interruptor */
45
+ labelPosition?: "left" | "right";
46
+ /** color del `label` (CSS var --switch-label-color) */
47
+ labelColor?: string;
48
+ /** deshabilita el interruptor en modo `toggle` */
49
+ disabled?: boolean;
36
50
  }
37
51
  /**
38
52
  * Control segmentado tipo píldora con indicador deslizante.
39
53
  * Todas las opciones se igualan al ancho de la más larga (salvo `equalWidth={false}`).
40
54
  */
41
- export declare const Switch: ({ options, active, onChange, size, simpleAnimation, iconSize, className, activeColor, activeTextColor, inactiveTextColor, background, equalWidth, fullWidth, optionStyle, }: SwitchProps) => import("react/jsx-runtime").JSX.Element;
55
+ export declare const Switch: ({ options, active, onChange, size, simpleAnimation, iconSize, className, activeColor, activeTextColor, inactiveTextColor, background, equalWidth, fullWidth, optionStyle, toggle, checked, onToggle, label, labelPosition, labelColor, disabled, }: SwitchProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,110 +1,151 @@
1
- import { jsxs as S, jsx as _ } from "react/jsx-runtime";
2
- import { useRef as $, useState as O, useCallback as E, useLayoutEffect as Z, useEffect as z } from "react";
3
- import { Icon as A } from "../../icons/Icon.js";
4
- import '../../assets/Switch.css';const B = "_fullWidth_1l66v_26", K = "_option_1l66v_30", M = "_extraSmall_1l66v_35", V = "_small_1l66v_44", X = "_large_1l66v_53", Y = "_extraLarge_1l66v_62", q = "_indicator_1l66v_72", F = "_simple_1l66v_88", G = "_active_1l66v_114", l = {
5
- switch: "_switch_1l66v_1",
6
- fullWidth: B,
7
- option: K,
8
- extraSmall: M,
9
- small: V,
10
- large: X,
11
- extraLarge: Y,
12
- indicator: q,
13
- simple: F,
14
- active: G
15
- }, H = {
1
+ import { jsxs as m, jsx as o } from "react/jsx-runtime";
2
+ import { useRef as D, useState as q, useCallback as O, useLayoutEffect as z, useEffect as A } from "react";
3
+ import { Icon as Z } from "../../icons/Icon.js";
4
+ import '../../assets/Switch.css';const F = "_fullWidth_1sbs8_26", G = "_option_1sbs8_30", H = "_extraSmall_1sbs8_35", J = "_small_1sbs8_44", Q = "_large_1sbs8_53", U = "_extraLarge_1sbs8_62", P = "_indicator_1sbs8_72", T = "_simple_1sbs8_88", C = "_active_1sbs8_114", tt = "_toggleRoot_1sbs8_119", st = "_disabled_1sbs8_141", et = "_toggleLabel_1sbs8_146", ct = "_track_1sbs8_170", ot = "_on_1sbs8_183", lt = "_knob_1sbs8_187", nt = "_knobIcon_1sbs8_206", s = {
5
+ switch: "_switch_1sbs8_1",
6
+ fullWidth: F,
7
+ option: G,
8
+ extraSmall: H,
9
+ small: J,
10
+ large: Q,
11
+ extraLarge: U,
12
+ indicator: P,
13
+ simple: T,
14
+ active: C,
15
+ toggleRoot: tt,
16
+ disabled: st,
17
+ toggleLabel: et,
18
+ track: ct,
19
+ on: ot,
20
+ knob: lt,
21
+ knobIcon: nt
22
+ }, at = {
16
23
  extraSmall: 15,
17
24
  small: 15,
18
25
  medium: 19,
19
26
  large: 19,
20
27
  extraLarge: 19
21
- }, U = ({
22
- options: m = [],
23
- active: i = 0,
24
- onChange: c,
25
- size: a = "medium",
26
- simpleAnimation: I = !1,
27
- iconSize: W,
28
- className: L = "",
29
- activeColor: d,
30
- activeTextColor: u,
31
- inactiveTextColor: p,
32
- background: h,
33
- equalWidth: v = !0,
34
- fullWidth: N = !1,
35
- optionStyle: R
28
+ }, ft = ({
29
+ options: u = [],
30
+ active: a = 0,
31
+ onChange: l,
32
+ size: r = "medium",
33
+ simpleAnimation: p = !1,
34
+ iconSize: B,
35
+ className: h = "",
36
+ activeColor: w,
37
+ activeTextColor: $,
38
+ inactiveTextColor: k,
39
+ background: y,
40
+ equalWidth: x = !0,
41
+ fullWidth: I = !1,
42
+ optionStyle: K,
43
+ toggle: M = !1,
44
+ checked: _ = !1,
45
+ onToggle: f,
46
+ label: g,
47
+ labelPosition: L = "left",
48
+ labelColor: S,
49
+ disabled: v = !1
36
50
  }) => {
37
- const w = $(null), n = $([]), [y, g] = O({
51
+ const N = D(null), b = D([]), [E, V] = q({
38
52
  left: 0,
39
53
  width: 0
40
- }), f = E(() => {
41
- const t = n.current.filter(
42
- (s) => s !== null
54
+ }), d = O(() => {
55
+ const t = b.current.filter(
56
+ (e) => e !== null
43
57
  );
44
- if (t.forEach((s) => s.style.width = "auto"), v) {
45
- const s = Math.max(0, ...t.map((e) => e.offsetWidth));
46
- t.forEach((e) => e.style.width = `${s}px`);
58
+ if (t.forEach((e) => e.style.width = "auto"), x) {
59
+ const e = Math.max(0, ...t.map((c) => c.offsetWidth));
60
+ t.forEach((c) => c.style.width = `${e}px`);
47
61
  }
48
- }, [v]), o = E(() => {
49
- f();
50
- const t = n.current[i];
51
- t && g({ left: t.offsetLeft, width: t.offsetWidth });
52
- }, [i, f]);
53
- Z(() => {
54
- o();
55
- }, [i, m, a, f]), z(() => {
56
- var e;
57
- const t = w.current;
62
+ }, [x]), i = O(() => {
63
+ d();
64
+ const t = b.current[a];
65
+ t && V({ left: t.offsetLeft, width: t.offsetWidth });
66
+ }, [a, d]);
67
+ z(() => {
68
+ i();
69
+ }, [a, u, r, d]), A(() => {
70
+ var c;
71
+ const t = N.current;
58
72
  if (!t) return;
59
- const s = new ResizeObserver(o);
60
- return s.observe(t), (e = document.fonts) != null && e.ready && document.fonts.ready.then(o).catch(() => {
61
- }), () => s.disconnect();
62
- }, [o]);
63
- const k = W ?? H[a], j = {
64
- ...d && { "--switch-active-bg": d },
65
- ...u && { "--switch-active-text": u },
66
- ...p && { "--switch-inactive-text": p },
67
- ...h && { "--switch-bg": h }
73
+ const e = new ResizeObserver(i);
74
+ return e.observe(t), (c = document.fonts) != null && c.ready && document.fonts.ready.then(i).catch(() => {
75
+ }), () => e.disconnect();
76
+ }, [i]);
77
+ const X = B ?? at[r], R = {
78
+ ...w && { "--switch-active-bg": w },
79
+ ...$ && { "--switch-active-text": $ },
80
+ ...k && { "--switch-inactive-text": k },
81
+ ...y && { "--switch-bg": y },
82
+ ...S && { "--switch-label-color": S }
68
83
  };
69
- return /* @__PURE__ */ S(
84
+ if (M) {
85
+ const t = g && /* @__PURE__ */ o("span", { className: s.toggleLabel, children: g });
86
+ return /* @__PURE__ */ m(
87
+ "label",
88
+ {
89
+ className: `${s.toggleRoot} ${s[r]} ${p ? s.simple : ""} ${I ? s.fullWidth : ""} ${v ? s.disabled : ""} ${h}`,
90
+ style: R,
91
+ children: [
92
+ L === "left" && t,
93
+ /* @__PURE__ */ o(
94
+ "button",
95
+ {
96
+ type: "button",
97
+ role: "switch",
98
+ "aria-checked": _,
99
+ disabled: v,
100
+ onClick: () => f == null ? void 0 : f(!_),
101
+ className: `${s.track} ${_ ? s.on : ""}`,
102
+ children: /* @__PURE__ */ o("span", { className: s.knob, children: /* @__PURE__ */ o(Z, { name: "CheckIcon", className: s.knobIcon }) })
103
+ }
104
+ ),
105
+ L === "right" && t
106
+ ]
107
+ }
108
+ );
109
+ }
110
+ return /* @__PURE__ */ m(
70
111
  "div",
71
112
  {
72
- ref: w,
73
- className: `${l.switch} ${l[a]} ${I ? l.simple : ""} ${N ? l.fullWidth : ""} ${L}`,
74
- style: j,
113
+ ref: N,
114
+ className: `${s.switch} ${s[r]} ${p ? s.simple : ""} ${I ? s.fullWidth : ""} ${h}`,
115
+ style: R,
75
116
  children: [
76
- /* @__PURE__ */ _(
117
+ /* @__PURE__ */ o(
77
118
  "span",
78
119
  {
79
- className: l.indicator,
120
+ className: s.indicator,
80
121
  style: {
81
- transform: `translateX(${y.left}px)`,
82
- width: `${y.width}px`
122
+ transform: `translateX(${E.left}px)`,
123
+ width: `${E.width}px`
83
124
  }
84
125
  }
85
126
  ),
86
- m.map((t, s) => {
87
- const e = typeof t == "string", x = e ? t : t.label, b = e ? null : t.icon, D = i === s;
88
- return /* @__PURE__ */ S(
127
+ u.map((t, e) => {
128
+ const c = typeof t == "string", W = c ? t : t.label, j = c ? null : t.icon, Y = a === e;
129
+ return /* @__PURE__ */ m(
89
130
  "div",
90
131
  {
91
- ref: (r) => {
92
- n.current[s] = r;
132
+ ref: (n) => {
133
+ b.current[e] = n;
93
134
  },
94
135
  role: "button",
95
136
  tabIndex: 0,
96
- onClick: () => c == null ? void 0 : c(s),
97
- onKeyDown: (r) => {
98
- (r.key === "Enter" || r.key === " ") && (r.preventDefault(), c == null || c(s));
137
+ onClick: () => l == null ? void 0 : l(e),
138
+ onKeyDown: (n) => {
139
+ (n.key === "Enter" || n.key === " ") && (n.preventDefault(), l == null || l(e));
99
140
  },
100
- className: `${l.option} ${D ? l.active : ""}`,
101
- style: R,
141
+ className: `${s.option} ${Y ? s.active : ""}`,
142
+ style: K,
102
143
  children: [
103
- b && /* @__PURE__ */ _(A, { name: b, size: k }),
104
- x && /* @__PURE__ */ _("span", { className: l.label, children: x })
144
+ j && /* @__PURE__ */ o(Z, { name: j, size: X }),
145
+ W && /* @__PURE__ */ o("span", { className: s.label, children: W })
105
146
  ]
106
147
  },
107
- s
148
+ e
108
149
  );
109
150
  })
110
151
  ]
@@ -112,5 +153,5 @@ import '../../assets/Switch.css';const B = "_fullWidth_1l66v_26", K = "_option_1
112
153
  );
113
154
  };
114
155
  export {
115
- U as Switch
156
+ ft as Switch
116
157
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bmi-next-brokers",
3
3
  "description": "Componentes de UI para proyecto BMI Next Brokers",
4
- "version": "3.1.9",
4
+ "version": "3.2.0",
5
5
  "author": "BMI Ahorro España",
6
6
  "contributors": [
7
7
  "José Ramón Jiménez <jrjimenez@bmicos.com>",