bmi-next-brokers 2.9.9 → 3.0.1

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.
@@ -0,0 +1 @@
1
+ ._switch_56b6x_1{--switch-bg: var(--ui-blue-100);--switch-active-bg: #2054A5;--switch-active-text: #ffffff;--switch-inactive-text: #2054A5;--switch-inset: 3px;--switch-pad-y: 10px;--switch-pad-x: 14px;--switch-font: 12px;--switch-radius: 20px;--switch-min-width: 52px;--switch-gap: 5px;--switch-max-height: 48px;position:relative;display:flex;flex-direction:row;gap:0;max-height:var(--switch-max-height);padding:var(--switch-inset);border-radius:var(--switch-radius);background:var(--switch-bg);width:fit-content}._small_56b6x_29{--switch-inset: 3px;--switch-pad-y: 6px;--switch-pad-x: 10px;--switch-font: 11px;--switch-radius: 16px;--switch-min-width: 40px;--switch-gap: 4px;--switch-max-height: 36px}._large_56b6x_40{--switch-inset: 4px;--switch-pad-y: 14px;--switch-pad-x: 18px;--switch-font: 14px;--switch-radius: 24px;--switch-min-width: 64px;--switch-gap: 6px;--switch-max-height: 58px}._switch_56b6x_1 ._indicator_56b6x_52{position:absolute;top:var(--switch-inset);bottom:var(--switch-inset);left:0;background:#2054a5;border-radius:var(--switch-radius);transition:transform .42s cubic-bezier(.34,1.56,.64,1),width .42s cubic-bezier(.34,1.56,.64,1);pointer-events:none;z-index:0}._switch_56b6x_1._simple_56b6x_68 ._indicator_56b6x_52{transition:transform .22s ease,width .22s ease}._switch_56b6x_1._simple_56b6x_68 ._option_56b6x_74._active_56b6x_74 ._label_56b6x_74{animation:none}._switch_56b6x_1 ._option_56b6x_74{position:relative;z-index:1;min-width:var(--switch-min-width);border:none;background:transparent;color:var(--switch-inactive-text);font-size:var(--switch-font);cursor:pointer;transition:color .25s ease,transform .25s ease;white-space:nowrap;display:flex;align-items:center;justify-content:center;gap:var(--switch-gap);padding:var(--switch-pad-y) var(--switch-pad-x);border-radius:var(--switch-radius)}._switch_56b6x_1 ._option_56b6x_74:active{transform:scale(.94)}._switch_56b6x_1 ._option_56b6x_74._active_56b6x_74{color:var(--switch-active-text)}._switch_56b6x_1 ._option_56b6x_74._active_56b6x_74 ._label_56b6x_74{animation:_pop_56b6x_1 .32s ease}@keyframes _pop_56b6x_1{0%{transform:scale(1)}45%{transform:scale(1.12)}to{transform:scale(1)}}._switch_56b6x_1 ._label_56b6x_74{line-height:5px}
@@ -0,0 +1,31 @@
1
+ import * as Icons from "../../icons/index";
2
+ export type IconName = keyof typeof Icons;
3
+ export type SwitchOption = string | {
4
+ label: string;
5
+ icon?: IconName;
6
+ };
7
+ export type SwitchSize = "small" | "medium" | "large";
8
+ export interface SwitchProps {
9
+ /** opciones a mostrar: strings u objetos { label, icon } */
10
+ options: SwitchOption[];
11
+ /** índice de la opción activa */
12
+ active?: number;
13
+ /** callback que recibe el índice seleccionado */
14
+ onChange?: (index: number) => void;
15
+ /** tamaño que determina el alto del control */
16
+ size?: SwitchSize;
17
+ /** si es true, usa un deslizamiento simple en vez del efecto rubber-band */
18
+ simpleAnimation?: boolean;
19
+ /** tamaño del icono en px; si se omite, escala según `size` */
20
+ iconSize?: number;
21
+ className?: string;
22
+ /** color de fondo del indicador activo (CSS var --switch-active-bg) */
23
+ activeColor?: string;
24
+ /** color del texto de la opción activa (CSS var --switch-active-text) */
25
+ activeTextColor?: string;
26
+ /** color del texto de las opciones inactivas (CSS var --switch-inactive-text) */
27
+ inactiveTextColor?: string;
28
+ /** color de fondo del contenedor (CSS var --switch-bg) */
29
+ background?: string;
30
+ }
31
+ export declare const Switch: ({ options, active, onChange, size, simpleAnimation, iconSize, className, activeColor, activeTextColor, inactiveTextColor, background, }: SwitchProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,108 @@
1
+ import { jsxs as E, jsx as m } from "react/jsx-runtime";
2
+ import { useRef as p, useState as M, useLayoutEffect as j } from "react";
3
+ import { Icon as k } from "../../icons/Icon.js";
4
+ import '../../assets/Switch.css';const D = "_small_56b6x_29", R = "_large_56b6x_40", T = "_indicator_56b6x_52", Z = "_simple_56b6x_68", z = "_option_56b6x_74", B = "_active_56b6x_74", K = "_label_56b6x_74", O = "_pop_56b6x_1", r = {
5
+ switch: "_switch_56b6x_1",
6
+ small: D,
7
+ large: R,
8
+ indicator: T,
9
+ simple: Z,
10
+ option: z,
11
+ active: B,
12
+ label: K,
13
+ pop: O
14
+ }, V = {
15
+ small: 12,
16
+ medium: 14,
17
+ large: 16
18
+ }, q = ({
19
+ options: d = [],
20
+ active: l = 0,
21
+ onChange: o,
22
+ size: h = "medium",
23
+ simpleAnimation: u = !1,
24
+ iconSize: L,
25
+ className: S = "",
26
+ activeColor: b,
27
+ activeTextColor: w,
28
+ inactiveTextColor: x,
29
+ background: y
30
+ }) => {
31
+ const a = p([]), $ = p(l), n = p(null), [v, I] = M({
32
+ left: 0,
33
+ width: 0
34
+ });
35
+ j(() => {
36
+ const t = a.current[l], e = a.current[$.current];
37
+ if (!t) return;
38
+ const i = a.current.filter(
39
+ (s) => s !== null
40
+ );
41
+ i.forEach((s) => s.style.width = "auto");
42
+ const _ = Math.max(...i.map((s) => s.offsetWidth));
43
+ i.forEach((s) => s.style.width = `${_}px`);
44
+ const f = () => I({ left: t.offsetLeft, width: t.offsetWidth });
45
+ if (!u && e && e !== t) {
46
+ const s = Math.min(e.offsetLeft, t.offsetLeft), c = Math.max(
47
+ e.offsetLeft + e.offsetWidth,
48
+ t.offsetLeft + t.offsetWidth
49
+ );
50
+ I({ left: s, width: c - s }), n.current && clearTimeout(n.current), n.current = setTimeout(f, 160);
51
+ } else
52
+ f();
53
+ return $.current = l, () => {
54
+ n.current && clearTimeout(n.current);
55
+ };
56
+ }, [l, d, u]);
57
+ const N = L ?? V[h], W = {
58
+ ...b && { "--switch-active-bg": b },
59
+ ...w && { "--switch-active-text": w },
60
+ ...x && { "--switch-inactive-text": x },
61
+ ...y && { "--switch-bg": y }
62
+ };
63
+ return /* @__PURE__ */ E(
64
+ "div",
65
+ {
66
+ className: `${r.switch} ${r[h]} ${u ? r.simple : ""} ${S}`,
67
+ style: W,
68
+ children: [
69
+ /* @__PURE__ */ m(
70
+ "span",
71
+ {
72
+ className: r.indicator,
73
+ style: {
74
+ transform: `translateX(${v.left}px)`,
75
+ width: `${v.width}px`
76
+ }
77
+ }
78
+ ),
79
+ d.map((t, e) => {
80
+ const i = typeof t == "string", _ = i ? t : t.label, f = i ? null : t.icon, s = l === e;
81
+ return /* @__PURE__ */ E(
82
+ "div",
83
+ {
84
+ ref: (c) => {
85
+ a.current[e] = c;
86
+ },
87
+ role: "button",
88
+ tabIndex: 0,
89
+ onClick: () => o == null ? void 0 : o(e),
90
+ onKeyDown: (c) => {
91
+ (c.key === "Enter" || c.key === " ") && (c.preventDefault(), o == null || o(e));
92
+ },
93
+ className: `${r.option} ${s ? r.active : ""}`,
94
+ children: [
95
+ f && /* @__PURE__ */ m(k, { name: f, size: N }),
96
+ _ && /* @__PURE__ */ m("p", { className: r.label, children: _ })
97
+ ]
98
+ },
99
+ e
100
+ );
101
+ })
102
+ ]
103
+ }
104
+ );
105
+ };
106
+ export {
107
+ q as Switch
108
+ };
@@ -0,0 +1,2 @@
1
+ export { Switch } from './Switch';
2
+ export type { SwitchProps, SwitchOption, SwitchSize } from './Switch';
@@ -0,0 +1,4 @@
1
+ import { Switch as t } from "./Switch.js";
2
+ export {
3
+ t as Switch
4
+ };
package/dist/main.d.ts CHANGED
@@ -13,6 +13,7 @@ export { ProgressBar } from './components/progressBar';
13
13
  export { Select } from './components/Select';
14
14
  export { SearchableInputGroup } from './components/SearchableInputGroup';
15
15
  export { Spinner } from './components/Spinner';
16
+ export { Switch } from './components/Switch';
16
17
  export { Stepper } from './components/stepper';
17
18
  export { Tab } from './components/tab';
18
19
  export { TabGroup } from './components/tab/tabGroup';
@@ -41,6 +42,7 @@ export type { NavbarOption } from './components/navbar';
41
42
  export type { ProgressBar as ProgressBarProps } from './components/progressBar';
42
43
  export type { SelectProps, SelectSize, SelectOption, } from './components/Select';
43
44
  export type { SpinnerProps, SpinnerColor } from './components/Spinner';
45
+ export type { SwitchProps, SwitchOption } from './components/Switch';
44
46
  export type { Step } from './components/stepper';
45
47
  export type { ToastProps, ToastType, ToastPosition } from './components/Toast';
46
48
  export type { StaticToastProps, StaticToastType, StaticToastSize, } from './components/StaticToast';
package/dist/main.js CHANGED
@@ -3,64 +3,66 @@ import { Badge as p } from "./components/badge/index.js";
3
3
  import { Button as m } from "./components/Button/Button.js";
4
4
  import { ButtonGroup as a } from "./components/ButtonGroup/ButtonGroup.js";
5
5
  import { Dialog as u } from "./components/Dialog/Dialog.js";
6
- import { FileUpload as c } from "./components/FileUpload/FileUpload.js";
6
+ import { FileUpload as i } from "./components/FileUpload/FileUpload.js";
7
7
  import { CompactFileUpload as s } from "./components/FileUpload/CompactFileUpload.js";
8
- import { Input as S } from "./components/Input/Input.js";
8
+ import { Input as B } from "./components/Input/Input.js";
9
9
  import { Checkbox as d } from "./components/Input/Checkbox/Checkbox.js";
10
10
  import { RadioButton as b } from "./components/Input/RadioButton/RadioButton.js";
11
- import { Navbar as h } from "./components/navbar/index.js";
11
+ import { Navbar as g } from "./components/navbar/index.js";
12
12
  import { ProgressBar as F } from "./components/progressBar/index.js";
13
13
  import { Select as I } from "./components/Select/Select.js";
14
- import { SearchableInputGroup as D } from "./components/SearchableInputGroup/index.js";
15
- import { Spinner as U } from "./components/Spinner/Spinner.js";
16
- import { Stepper as E } from "./components/stepper/index.js";
17
- import { Tab as L } from "./components/tab/index.js";
18
- import { TabGroup as N } from "./components/tab/tabGroup/index.js";
19
- import { Toast as R } from "./components/Toast/Toast.js";
20
- import { StaticToast as q } from "./components/StaticToast/StaticToast.js";
21
- import { Modal as z } from "./components/modal/index.js";
22
- import { Tooltip as J } from "./components/tooltip/index.js";
23
- import { useScrollLock as Q } from "./hooks/useScrollLock.js";
24
- import { ScrollContainer as W } from "./components/scrollContainer/index.js";
25
- import { FieldError as Y } from "./components/fieldError/index.js";
26
- import { HelperText as _ } from "./components/helperText/index.js";
27
- import { Drawer as oo } from "./components/drawer/index.js";
28
- import { Sheet as eo } from "./components/sheet/index.js";
29
- import { useClose as po } from "./hooks/useClose.js";
30
- import { useCloseOnBack as mo } from "./hooks/useCloseOnBack.js";
31
- import { useBTC as ao } from "./hooks/btcContext/useBtcContext.js";
32
- import { BTCProvider as uo } from "./hooks/btcContext/btcProvider.js";
14
+ import { SearchableInputGroup as w } from "./components/SearchableInputGroup/index.js";
15
+ import { Spinner as P } from "./components/Spinner/Spinner.js";
16
+ import { Switch as E } from "./components/Switch/Switch.js";
17
+ import { Stepper as L } from "./components/stepper/index.js";
18
+ import { Tab as N } from "./components/tab/index.js";
19
+ import { TabGroup as R } from "./components/tab/tabGroup/index.js";
20
+ import { Toast as q } from "./components/Toast/Toast.js";
21
+ import { StaticToast as z } from "./components/StaticToast/StaticToast.js";
22
+ import { Modal as J } from "./components/modal/index.js";
23
+ import { Tooltip as Q } from "./components/tooltip/index.js";
24
+ import { useScrollLock as W } from "./hooks/useScrollLock.js";
25
+ import { ScrollContainer as Y } from "./components/scrollContainer/index.js";
26
+ import { FieldError as _ } from "./components/fieldError/index.js";
27
+ import { HelperText as oo } from "./components/helperText/index.js";
28
+ import { Drawer as eo } from "./components/drawer/index.js";
29
+ import { Sheet as po } from "./components/sheet/index.js";
30
+ import { useClose as mo } from "./hooks/useClose.js";
31
+ import { useCloseOnBack as ao } from "./hooks/useCloseOnBack.js";
32
+ import { useBTC as uo } from "./hooks/btcContext/useBtcContext.js";
33
+ import { BTCProvider as io } from "./hooks/btcContext/btcProvider.js";
33
34
  import './assets/main.css';export {
34
- uo as BTCProvider,
35
+ io as BTCProvider,
35
36
  p as Badge,
36
37
  m as Button,
37
38
  a as ButtonGroup,
38
39
  d as Checkbox,
39
40
  s as CompactFileUpload,
40
41
  u as Dialog,
41
- oo as Drawer,
42
- Y as FieldError,
43
- c as FileUpload,
44
- _ as HelperText,
42
+ eo as Drawer,
43
+ _ as FieldError,
44
+ i as FileUpload,
45
+ oo as HelperText,
45
46
  e as Icon,
46
- S as Input,
47
- z as Modal,
48
- h as Navbar,
47
+ B as Input,
48
+ J as Modal,
49
+ g as Navbar,
49
50
  F as ProgressBar,
50
51
  b as RadioButton,
51
- W as ScrollContainer,
52
- D as SearchableInputGroup,
52
+ Y as ScrollContainer,
53
+ w as SearchableInputGroup,
53
54
  I as Select,
54
- eo as Sheet,
55
- U as Spinner,
56
- q as StaticToast,
57
- E as Stepper,
58
- L as Tab,
59
- N as TabGroup,
60
- R as Toast,
61
- J as Tooltip,
62
- ao as useBTC,
63
- po as useClose,
64
- mo as useCloseOnBack,
65
- Q as useScrollLock
55
+ po as Sheet,
56
+ P as Spinner,
57
+ z as StaticToast,
58
+ L as Stepper,
59
+ E as Switch,
60
+ N as Tab,
61
+ R as TabGroup,
62
+ q as Toast,
63
+ Q as Tooltip,
64
+ uo as useBTC,
65
+ mo as useClose,
66
+ ao as useCloseOnBack,
67
+ W as useScrollLock
66
68
  };
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": "2.9.9",
4
+ "version": "3.0.1",
5
5
  "author": "BMI Ahorro España",
6
6
  "contributors": [
7
7
  "José Ramón Jiménez <jrjimenez@bmicos.com>",