@rubenpazch/switch 0.0.0-stage → 0.1.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.
package/README.md CHANGED
@@ -1,3 +1,34 @@
1
- # Temporary Holding Version
1
+ # @rubenpazch/switch
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ <!-- catalogo:inicio (generado por pnpm catalogo, no editar) -->
4
+
5
+ Interruptor encendido/apagado (role="switch") con etiqueta y descripción.
6
+
7
+ - **Usar cuando:** Opciones que se activan al instante: notificaciones, módulo activo, mostrar en el sitio.
8
+ - **Evitar cuando:** Opciones que se guardan con un botón Enviar o selección múltiple en una lista: usa CheckboxInput.
9
+
10
+ Se recomienda instalar el paquete completo `@rubenpazch/ui` (incluye este). Por separado:
11
+
12
+ ```bash
13
+ npm install @rubenpazch/switch
14
+ ```
15
+
16
+ ## Switch
17
+
18
+ Interruptor encendido/apagado (role="switch") para opciones que se aplican al instante.
19
+
20
+ | Prop | Tipo | Req. | Por defecto | Descripción |
21
+ | ------------- | ---------------------------- | ---- | ----------- | -------------------------------- |
22
+ | `checked` | `boolean` | sí | | Encendido o apagado. |
23
+ | `label` | `ReactNode` | sí | | Etiqueta visible a la derecha. |
24
+ | `onChange` | `(checked: boolean) => void` | sí | | Recibe el nuevo estado. |
25
+ | `className` | `string` | | | Clase extra. |
26
+ | `description` | `ReactNode` | | | Texto de ayuda bajo la etiqueta. |
27
+ | `disabled` | `boolean` | | `false` | Deshabilitado. |
28
+ | `id` | `string` | | | id del interruptor. |
29
+ | `name` | `string` | | | name, para formularios. |
30
+ | `size` | `"sm" \| "md"` | | `md` | sm o md (por defecto). |
31
+
32
+ Tipos: `SwitchProps`.
33
+
34
+ <!-- catalogo:fin -->
@@ -0,0 +1,25 @@
1
+ import React from "react";
2
+ export interface SwitchProps {
3
+ /** Encendido o apagado. */
4
+ checked: boolean;
5
+ /** Recibe el nuevo estado. */
6
+ onChange: (checked: boolean) => void;
7
+ /** Etiqueta visible a la derecha. */
8
+ label: React.ReactNode;
9
+ /** Texto de ayuda bajo la etiqueta. */
10
+ description?: React.ReactNode;
11
+ /** Deshabilitado. */
12
+ disabled?: boolean;
13
+ /** sm o md (por defecto). */
14
+ size?: "sm" | "md";
15
+ /** id del interruptor. */
16
+ id?: string;
17
+ /** name, para formularios. */
18
+ name?: string;
19
+ /** Clase extra. */
20
+ className?: string;
21
+ }
22
+ /** Interruptor encendido/apagado (role="switch") para opciones que se aplican al instante. */
23
+ declare const Switch: React.ForwardRefExoticComponent<SwitchProps & React.RefAttributes<HTMLButtonElement>>;
24
+ export default Switch;
25
+ //# sourceMappingURL=Switch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Switch.d.ts","sourceRoot":"","sources":["../src/Switch.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,MAAM,WAAW,WAAW;IAC1B,2BAA2B;IAC3B,OAAO,EAAE,OAAO,CAAC;IACjB,8BAA8B;IAC9B,QAAQ,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IACrC,qCAAqC;IACrC,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC;IACvB,uCAAuC;IACvC,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC9B,qBAAqB;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,6BAA6B;IAC7B,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IACnB,0BAA0B;IAC1B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,8BAA8B;IAC9B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,mBAAmB;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAKD,8FAA8F;AAC9F,QAAA,MAAM,MAAM,uFAiDV,CAAC;AAIH,eAAe,MAAM,CAAC"}
@@ -0,0 +1,2 @@
1
+ "use strict";var e=require("react/jsx-runtime"),n=require("react"),t=require("@rubenpazch/shared");var i={wrapper:"Switch-module_wrapper__rQ6hI",disabled:"Switch-module_disabled__PI-t6",track:"Switch-module_track__evLGf",md:"Switch-module_md__-ojwx",sm:"Switch-module_sm__Cb74o",on:"Switch-module_on__DvMv4",thumb:"Switch-module_thumb__KV9xc",text:"Switch-module_text__wZ-Bf",label:"Switch-module_label__LNdDk",description:"Switch-module_description__lAzy7"};!function(e,n){void 0===n&&(n={});var t=n.insertAt;if("undefined"!=typeof document){var i=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.type="text/css","top"===t&&i.firstChild?i.insertBefore(o,i.firstChild):i.appendChild(o),o.styleSheet?o.styleSheet.cssText=e:o.appendChild(document.createTextNode(e))}}(".Switch-module_wrapper__rQ6hI {\n display: flex;\n align-items: flex-start;\n gap: var(--lb-space-3);\n font-family: var(--lb-font-sans);\n}\n\n.Switch-module_disabled__PI-t6 {\n opacity: 0.6;\n}\n\n.Switch-module_track__evLGf {\n position: relative;\n flex: none;\n padding: 0;\n border: 0;\n border-radius: var(--lb-radius-full);\n background: var(--lb-color-neutral-300);\n cursor: pointer;\n transition: background 150ms ease;\n}\n\n.Switch-module_md__-ojwx { width: 2.5rem; height: 1.5rem; }\n.Switch-module_sm__Cb74o { width: 2rem; height: 1.125rem; }\n\n.Switch-module_track__evLGf:disabled {\n cursor: not-allowed;\n}\n\n.Switch-module_track__evLGf:focus-visible {\n outline: 2px solid var(--lb-color-ring);\n outline-offset: 2px;\n}\n\n.Switch-module_on__DvMv4 {\n background: var(--lb-color-primary);\n}\n\n.Switch-module_thumb__KV9xc {\n position: absolute;\n top: 2px;\n left: 2px;\n border-radius: var(--lb-radius-full);\n background: var(--lb-color-background);\n box-shadow: var(--lb-shadow-sm);\n transition: transform 150ms ease;\n}\n\n.Switch-module_md__-ojwx .Switch-module_thumb__KV9xc { width: 1.25rem; height: 1.25rem; }\n.Switch-module_sm__Cb74o .Switch-module_thumb__KV9xc { width: 0.875rem; height: 0.875rem; }\n\n.Switch-module_md__-ojwx.Switch-module_on__DvMv4 .Switch-module_thumb__KV9xc { transform: translateX(1rem); }\n.Switch-module_sm__Cb74o.Switch-module_on__DvMv4 .Switch-module_thumb__KV9xc { transform: translateX(0.875rem); }\n\n.Switch-module_text__wZ-Bf {\n display: flex;\n flex-direction: column;\n gap: 2px;\n}\n\n.Switch-module_label__LNdDk {\n font-size: var(--lb-font-size-sm);\n font-weight: var(--lb-font-weight-medium);\n color: var(--lb-color-foreground);\n cursor: pointer;\n}\n\n.Switch-module_description__lAzy7 {\n margin: 0;\n font-size: var(--lb-font-size-xs);\n color: var(--lb-color-muted-foreground);\n}\n\n@media (prefers-reduced-motion: reduce) {\n .Switch-module_track__evLGf,\n .Switch-module_thumb__KV9xc {\n transition: none;\n }\n}\n");const o=(...e)=>e.filter(Boolean).join(" "),r=n.forwardRef(function({checked:n,onChange:r,label:d,description:l,disabled:a=!1,size:c="md",id:s,name:m,className:_},u){const h=t.useFieldIds({id:s,name:m});return e.jsxs("div",{className:o(i.wrapper,a&&i.disabled,_),children:[e.jsx("button",{ref:u,type:"button",role:"switch",id:h.inputId,name:m,"aria-checked":n,"aria-labelledby":`${h.inputId}-etiqueta`,"aria-describedby":l?h.hintId:void 0,disabled:a,onClick:()=>r(!n),className:o(i.track,i[c],n&&i.on),children:e.jsx("span",{className:i.thumb,"aria-hidden":"true"})}),e.jsxs("div",{className:i.text,children:[e.jsx("label",{id:`${h.inputId}-etiqueta`,htmlFor:h.inputId,className:i.label,children:d}),l&&e.jsx("p",{id:h.hintId,className:i.description,children:l})]}),m&&e.jsx("input",{type:"hidden",name:m,value:n?"on":""})]})});r.displayName="Switch",module.exports=r;
2
+ //# sourceMappingURL=index.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs.js","sources":["../../../node_modules/.pnpm/style-inject@0.3.0/node_modules/style-inject/dist/style-inject.es.js","../src/Switch.tsx"],"sourcesContent":["function styleInject(css, ref) {\n if ( ref === void 0 ) ref = {};\n var insertAt = ref.insertAt;\n\n if (!css || typeof document === 'undefined') { return; }\n\n var head = document.head || document.getElementsByTagName('head')[0];\n var style = document.createElement('style');\n style.type = 'text/css';\n\n if (insertAt === 'top') {\n if (head.firstChild) {\n head.insertBefore(style, head.firstChild);\n } else {\n head.appendChild(style);\n }\n } else {\n head.appendChild(style);\n }\n\n if (style.styleSheet) {\n style.styleSheet.cssText = css;\n } else {\n style.appendChild(document.createTextNode(css));\n }\n}\n\nexport default styleInject;\n","import React from \"react\";\nimport { useFieldIds } from \"@rubenpazch/shared\";\nimport styles from \"./Switch.module.css\";\n\nexport interface SwitchProps {\n /** Encendido o apagado. */\n checked: boolean;\n /** Recibe el nuevo estado. */\n onChange: (checked: boolean) => void;\n /** Etiqueta visible a la derecha. */\n label: React.ReactNode;\n /** Texto de ayuda bajo la etiqueta. */\n description?: React.ReactNode;\n /** Deshabilitado. */\n disabled?: boolean;\n /** sm o md (por defecto). */\n size?: \"sm\" | \"md\";\n /** id del interruptor. */\n id?: string;\n /** name, para formularios. */\n name?: string;\n /** Clase extra. */\n className?: string;\n}\n\nconst cx = (...c: Array<string | false | undefined>) =>\n c.filter(Boolean).join(\" \");\n\n/** Interruptor encendido/apagado (role=\"switch\") para opciones que se aplican al instante. */\nconst Switch = React.forwardRef<HTMLButtonElement, SwitchProps>(function Switch(\n {\n checked,\n onChange,\n label,\n description,\n disabled = false,\n size = \"md\",\n id,\n name,\n className,\n },\n ref,\n) {\n const field = useFieldIds({ id, name });\n return (\n <div className={cx(styles.wrapper, disabled && styles.disabled, className)}>\n <button\n ref={ref}\n type=\"button\"\n role=\"switch\"\n id={field.inputId}\n name={name}\n aria-checked={checked}\n aria-labelledby={`${field.inputId}-etiqueta`}\n aria-describedby={description ? field.hintId : undefined}\n disabled={disabled}\n onClick={() => onChange(!checked)}\n className={cx(styles.track, styles[size], checked && styles.on)}\n >\n <span className={styles.thumb} aria-hidden=\"true\" />\n </button>\n <div className={styles.text}>\n <label\n id={`${field.inputId}-etiqueta`}\n htmlFor={field.inputId}\n className={styles.label}\n >\n {label}\n </label>\n {description && (\n <p id={field.hintId} className={styles.description}>\n {description}\n </p>\n )}\n </div>\n {name && <input type=\"hidden\" name={name} value={checked ? \"on\" : \"\"} />}\n </div>\n );\n});\n\nSwitch.displayName = \"Switch\";\n\nexport default Switch;\n"],"names":["css","ref","insertAt","document","head","getElementsByTagName","style","createElement","type","firstChild","insertBefore","appendChild","styleSheet","cssText","createTextNode","cx","c","filter","Boolean","join","Switch","React","forwardRef","checked","onChange","label","description","disabled","size","id","name","className","field","useFieldIds","_jsxs","styles","wrapper","_jsx","role","inputId","hintId","undefined","onClick","track","on","children","thumb","text","htmlFor","value","displayName"],"mappings":"4cAAA,SAAqBA,EAAKC,YACnBA,IAAiBA,EAAM,CAAA,GAC5B,IAAIC,EAAWD,EAAIC,SAEnB,GAAgC,oBAAbC,SAAnB,CAEA,IAAIC,EAAOD,SAASC,MAAQD,SAASE,qBAAqB,QAAQ,GAC9DC,EAAQH,SAASI,cAAc,SACnCD,EAAME,KAAO,WAEI,QAAbN,GACEE,EAAKK,WACPL,EAAKM,aAAaJ,EAAOF,EAAKK,YAKhCL,EAAKO,YAAYL,GAGfA,EAAMM,WACRN,EAAMM,WAAWC,QAAUb,EAE3BM,EAAMK,YAAYR,SAASW,eAAed,GAnBW,CAqBzD,6/DCAA,MAAMe,EAAK,IAAIC,IACbA,EAAEC,OAAOC,SAASC,KAAK,KAGnBC,EAASC,EAAMC,WAA2C,UAC9DC,QACEA,EAAOC,SACPA,EAAQC,MACRA,EAAKC,YACLA,EAAWC,SACXA,GAAW,EAAKC,KAChBA,EAAO,KAAIC,GACXA,EAAEC,KACFA,EAAIC,UACJA,GAEF9B,GAEA,MAAM+B,EAAQC,EAAAA,YAAY,CAAEJ,KAAIC,SAChC,OACEI,EAAAA,KAAA,MAAA,CAAKH,UAAWhB,EAAGoB,EAAOC,QAAST,GAAYQ,EAAOR,SAAUI,aAC9DM,EAAAA,IAAA,SAAA,CACEpC,IAAKA,EACLO,KAAK,SACL8B,KAAK,SACLT,GAAIG,EAAMO,QACVT,KAAMA,EAAI,eACIP,EAAO,kBACJ,GAAGS,EAAMO,mBAAkB,mBAC1Bb,EAAcM,EAAMQ,YAASC,EAC/Cd,SAAUA,EACVe,QAAS,IAAMlB,GAAUD,GACzBQ,UAAWhB,EAAGoB,EAAOQ,MAAOR,EAAOP,GAAOL,GAAWY,EAAOS,IAAGC,SAE/DR,EAAAA,YAAMN,UAAWI,EAAOW,oBAAmB,WAE7CZ,OAAA,MAAA,CAAKH,UAAWI,EAAOY,KAAIF,SAAA,CACzBR,EAAAA,aACER,GAAI,GAAGG,EAAMO,mBACbS,QAAShB,EAAMO,QACfR,UAAWI,EAAOV,MAAKoB,SAEtBpB,IAEFC,GACCW,EAAAA,SAAGR,GAAIG,EAAMQ,OAAQT,UAAWI,EAAOT,qBACpCA,OAINI,GAAQO,EAAAA,IAAA,QAAA,CAAO7B,KAAK,SAASsB,KAAMA,EAAMmB,MAAO1B,EAAU,KAAO,OAGxE,GAEAH,EAAO8B,YAAc","x_google_ignoreList":[0]}
@@ -0,0 +1,27 @@
1
+ import React from 'react';
2
+
3
+ interface SwitchProps {
4
+ /** Encendido o apagado. */
5
+ checked: boolean;
6
+ /** Recibe el nuevo estado. */
7
+ onChange: (checked: boolean) => void;
8
+ /** Etiqueta visible a la derecha. */
9
+ label: React.ReactNode;
10
+ /** Texto de ayuda bajo la etiqueta. */
11
+ description?: React.ReactNode;
12
+ /** Deshabilitado. */
13
+ disabled?: boolean;
14
+ /** sm o md (por defecto). */
15
+ size?: "sm" | "md";
16
+ /** id del interruptor. */
17
+ id?: string;
18
+ /** name, para formularios. */
19
+ name?: string;
20
+ /** Clase extra. */
21
+ className?: string;
22
+ }
23
+ /** Interruptor encendido/apagado (role="switch") para opciones que se aplican al instante. */
24
+ declare const Switch: React.ForwardRefExoticComponent<SwitchProps & React.RefAttributes<HTMLButtonElement>>;
25
+
26
+ export { Switch as default };
27
+ export type { SwitchProps };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACnC,YAAY,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC"}
@@ -0,0 +1,2 @@
1
+ import{jsxs as e,jsx as n}from"react/jsx-runtime";import t from"react";import{useFieldIds as o}from"@rubenpazch/shared";var i={wrapper:"Switch-module_wrapper__rQ6hI",disabled:"Switch-module_disabled__PI-t6",track:"Switch-module_track__evLGf",md:"Switch-module_md__-ojwx",sm:"Switch-module_sm__Cb74o",on:"Switch-module_on__DvMv4",thumb:"Switch-module_thumb__KV9xc",text:"Switch-module_text__wZ-Bf",label:"Switch-module_label__LNdDk",description:"Switch-module_description__lAzy7"};!function(e,n){void 0===n&&(n={});var t=n.insertAt;if("undefined"!=typeof document){var o=document.head||document.getElementsByTagName("head")[0],i=document.createElement("style");i.type="text/css","top"===t&&o.firstChild?o.insertBefore(i,o.firstChild):o.appendChild(i),i.styleSheet?i.styleSheet.cssText=e:i.appendChild(document.createTextNode(e))}}(".Switch-module_wrapper__rQ6hI {\n display: flex;\n align-items: flex-start;\n gap: var(--lb-space-3);\n font-family: var(--lb-font-sans);\n}\n\n.Switch-module_disabled__PI-t6 {\n opacity: 0.6;\n}\n\n.Switch-module_track__evLGf {\n position: relative;\n flex: none;\n padding: 0;\n border: 0;\n border-radius: var(--lb-radius-full);\n background: var(--lb-color-neutral-300);\n cursor: pointer;\n transition: background 150ms ease;\n}\n\n.Switch-module_md__-ojwx { width: 2.5rem; height: 1.5rem; }\n.Switch-module_sm__Cb74o { width: 2rem; height: 1.125rem; }\n\n.Switch-module_track__evLGf:disabled {\n cursor: not-allowed;\n}\n\n.Switch-module_track__evLGf:focus-visible {\n outline: 2px solid var(--lb-color-ring);\n outline-offset: 2px;\n}\n\n.Switch-module_on__DvMv4 {\n background: var(--lb-color-primary);\n}\n\n.Switch-module_thumb__KV9xc {\n position: absolute;\n top: 2px;\n left: 2px;\n border-radius: var(--lb-radius-full);\n background: var(--lb-color-background);\n box-shadow: var(--lb-shadow-sm);\n transition: transform 150ms ease;\n}\n\n.Switch-module_md__-ojwx .Switch-module_thumb__KV9xc { width: 1.25rem; height: 1.25rem; }\n.Switch-module_sm__Cb74o .Switch-module_thumb__KV9xc { width: 0.875rem; height: 0.875rem; }\n\n.Switch-module_md__-ojwx.Switch-module_on__DvMv4 .Switch-module_thumb__KV9xc { transform: translateX(1rem); }\n.Switch-module_sm__Cb74o.Switch-module_on__DvMv4 .Switch-module_thumb__KV9xc { transform: translateX(0.875rem); }\n\n.Switch-module_text__wZ-Bf {\n display: flex;\n flex-direction: column;\n gap: 2px;\n}\n\n.Switch-module_label__LNdDk {\n font-size: var(--lb-font-size-sm);\n font-weight: var(--lb-font-weight-medium);\n color: var(--lb-color-foreground);\n cursor: pointer;\n}\n\n.Switch-module_description__lAzy7 {\n margin: 0;\n font-size: var(--lb-font-size-xs);\n color: var(--lb-color-muted-foreground);\n}\n\n@media (prefers-reduced-motion: reduce) {\n .Switch-module_track__evLGf,\n .Switch-module_thumb__KV9xc {\n transition: none;\n }\n}\n");const r=(...e)=>e.filter(Boolean).join(" "),d=t.forwardRef(function({checked:t,onChange:d,label:l,description:a,disabled:c=!1,size:m="md",id:_,name:s,className:u},h){const b=o({id:_,name:s});return e("div",{className:r(i.wrapper,c&&i.disabled,u),children:[n("button",{ref:h,type:"button",role:"switch",id:b.inputId,name:s,"aria-checked":t,"aria-labelledby":`${b.inputId}-etiqueta`,"aria-describedby":a?b.hintId:void 0,disabled:c,onClick:()=>d(!t),className:r(i.track,i[m],t&&i.on),children:n("span",{className:i.thumb,"aria-hidden":"true"})}),e("div",{className:i.text,children:[n("label",{id:`${b.inputId}-etiqueta`,htmlFor:b.inputId,className:i.label,children:l}),a&&n("p",{id:b.hintId,className:i.description,children:a})]}),s&&n("input",{type:"hidden",name:s,value:t?"on":""})]})});d.displayName="Switch";export{d as default};
2
+ //# sourceMappingURL=index.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.esm.js","sources":["../../../node_modules/.pnpm/style-inject@0.3.0/node_modules/style-inject/dist/style-inject.es.js","../src/Switch.tsx"],"sourcesContent":["function styleInject(css, ref) {\n if ( ref === void 0 ) ref = {};\n var insertAt = ref.insertAt;\n\n if (!css || typeof document === 'undefined') { return; }\n\n var head = document.head || document.getElementsByTagName('head')[0];\n var style = document.createElement('style');\n style.type = 'text/css';\n\n if (insertAt === 'top') {\n if (head.firstChild) {\n head.insertBefore(style, head.firstChild);\n } else {\n head.appendChild(style);\n }\n } else {\n head.appendChild(style);\n }\n\n if (style.styleSheet) {\n style.styleSheet.cssText = css;\n } else {\n style.appendChild(document.createTextNode(css));\n }\n}\n\nexport default styleInject;\n","import React from \"react\";\nimport { useFieldIds } from \"@rubenpazch/shared\";\nimport styles from \"./Switch.module.css\";\n\nexport interface SwitchProps {\n /** Encendido o apagado. */\n checked: boolean;\n /** Recibe el nuevo estado. */\n onChange: (checked: boolean) => void;\n /** Etiqueta visible a la derecha. */\n label: React.ReactNode;\n /** Texto de ayuda bajo la etiqueta. */\n description?: React.ReactNode;\n /** Deshabilitado. */\n disabled?: boolean;\n /** sm o md (por defecto). */\n size?: \"sm\" | \"md\";\n /** id del interruptor. */\n id?: string;\n /** name, para formularios. */\n name?: string;\n /** Clase extra. */\n className?: string;\n}\n\nconst cx = (...c: Array<string | false | undefined>) =>\n c.filter(Boolean).join(\" \");\n\n/** Interruptor encendido/apagado (role=\"switch\") para opciones que se aplican al instante. */\nconst Switch = React.forwardRef<HTMLButtonElement, SwitchProps>(function Switch(\n {\n checked,\n onChange,\n label,\n description,\n disabled = false,\n size = \"md\",\n id,\n name,\n className,\n },\n ref,\n) {\n const field = useFieldIds({ id, name });\n return (\n <div className={cx(styles.wrapper, disabled && styles.disabled, className)}>\n <button\n ref={ref}\n type=\"button\"\n role=\"switch\"\n id={field.inputId}\n name={name}\n aria-checked={checked}\n aria-labelledby={`${field.inputId}-etiqueta`}\n aria-describedby={description ? field.hintId : undefined}\n disabled={disabled}\n onClick={() => onChange(!checked)}\n className={cx(styles.track, styles[size], checked && styles.on)}\n >\n <span className={styles.thumb} aria-hidden=\"true\" />\n </button>\n <div className={styles.text}>\n <label\n id={`${field.inputId}-etiqueta`}\n htmlFor={field.inputId}\n className={styles.label}\n >\n {label}\n </label>\n {description && (\n <p id={field.hintId} className={styles.description}>\n {description}\n </p>\n )}\n </div>\n {name && <input type=\"hidden\" name={name} value={checked ? \"on\" : \"\"} />}\n </div>\n );\n});\n\nSwitch.displayName = \"Switch\";\n\nexport default Switch;\n"],"names":["css","ref","insertAt","document","head","getElementsByTagName","style","createElement","type","firstChild","insertBefore","appendChild","styleSheet","cssText","createTextNode","cx","c","filter","Boolean","join","Switch","React","forwardRef","checked","onChange","label","description","disabled","size","id","name","className","field","useFieldIds","_jsxs","styles","wrapper","_jsx","role","inputId","hintId","undefined","onClick","track","on","children","thumb","text","htmlFor","value","displayName"],"mappings":"ieAAA,SAAqBA,EAAKC,YACnBA,IAAiBA,EAAM,CAAA,GAC5B,IAAIC,EAAWD,EAAIC,SAEnB,GAAgC,oBAAbC,SAAnB,CAEA,IAAIC,EAAOD,SAASC,MAAQD,SAASE,qBAAqB,QAAQ,GAC9DC,EAAQH,SAASI,cAAc,SACnCD,EAAME,KAAO,WAEI,QAAbN,GACEE,EAAKK,WACPL,EAAKM,aAAaJ,EAAOF,EAAKK,YAKhCL,EAAKO,YAAYL,GAGfA,EAAMM,WACRN,EAAMM,WAAWC,QAAUb,EAE3BM,EAAMK,YAAYR,SAASW,eAAed,GAnBW,CAqBzD,6/DCAA,MAAMe,EAAK,IAAIC,IACbA,EAAEC,OAAOC,SAASC,KAAK,KAGnBC,EAASC,EAAMC,WAA2C,UAC9DC,QACEA,EAAOC,SACPA,EAAQC,MACRA,EAAKC,YACLA,EAAWC,SACXA,GAAW,EAAKC,KAChBA,EAAO,KAAIC,GACXA,EAAEC,KACFA,EAAIC,UACJA,GAEF9B,GAEA,MAAM+B,EAAQC,EAAY,CAAEJ,KAAIC,SAChC,OACEI,EAAA,MAAA,CAAKH,UAAWhB,EAAGoB,EAAOC,QAAST,GAAYQ,EAAOR,SAAUI,aAC9DM,EAAA,SAAA,CACEpC,IAAKA,EACLO,KAAK,SACL8B,KAAK,SACLT,GAAIG,EAAMO,QACVT,KAAMA,EAAI,eACIP,EAAO,kBACJ,GAAGS,EAAMO,mBAAkB,mBAC1Bb,EAAcM,EAAMQ,YAASC,EAC/Cd,SAAUA,EACVe,QAAS,IAAMlB,GAAUD,GACzBQ,UAAWhB,EAAGoB,EAAOQ,MAAOR,EAAOP,GAAOL,GAAWY,EAAOS,IAAGC,SAE/DR,UAAMN,UAAWI,EAAOW,oBAAmB,WAE7CZ,EAAA,MAAA,CAAKH,UAAWI,EAAOY,KAAIF,SAAA,CACzBR,WACER,GAAI,GAAGG,EAAMO,mBACbS,QAAShB,EAAMO,QACfR,UAAWI,EAAOV,MAAKoB,SAEtBpB,IAEFC,GACCW,OAAGR,GAAIG,EAAMQ,OAAQT,UAAWI,EAAOT,qBACpCA,OAINI,GAAQO,EAAA,QAAA,CAAO7B,KAAK,SAASsB,KAAMA,EAAMmB,MAAO1B,EAAU,KAAO,OAGxE,GAEAH,EAAO8B,YAAc","x_google_ignoreList":[0]}
package/package.json CHANGED
@@ -1,6 +1,78 @@
1
1
  {
2
2
  "name": "@rubenpazch/switch",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.1",
4
+ "description": "Interruptor encendido/apagado",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/rubenpazch/lbyte-ui-library.git",
8
+ "directory": "packages/switch"
9
+ },
10
+ "license": "MIT",
11
+ "main": "dist/index.cjs.js",
12
+ "module": "dist/index.esm.js",
13
+ "types": "dist/index.d.ts",
14
+ "exports": {
15
+ ".": {
16
+ "types": "./dist/index.d.ts",
17
+ "import": "./dist/index.esm.js",
18
+ "require": "./dist/index.cjs.js"
19
+ }
20
+ },
21
+ "files": [
22
+ "dist"
23
+ ],
24
+ "sideEffects": [
25
+ "**/*.css"
26
+ ],
27
+ "peerDependencies": {
28
+ "react": "^19.2.3",
29
+ "react-dom": "^19.2.3",
30
+ "@rubenpazch/tokens": "0.5.0"
31
+ },
32
+ "dependencies": {
33
+ "@rubenpazch/shared": "5.2.0"
34
+ },
35
+ "devDependencies": {
36
+ "@rollup/plugin-commonjs": "^29.0.3",
37
+ "@rollup/plugin-node-resolve": "^16.0.3",
38
+ "@rollup/plugin-terser": "^1.0.0",
39
+ "@rollup/plugin-typescript": "^12.3.0",
40
+ "@testing-library/react": "^16.3.3",
41
+ "@types/jest": "^30.0.0",
42
+ "@types/react": "^19.2.18",
43
+ "@types/react-dom": "^19.2.5",
44
+ "autoprefixer": "^10.5.4",
45
+ "eslint": "^9.39.5",
46
+ "identity-obj-proxy": "^3.0.0",
47
+ "jest": "^30.5.0",
48
+ "jest-environment-jsdom": "^30.5.0",
49
+ "postcss": "^8.5.26",
50
+ "prettier": "^3.9.6",
51
+ "react": "^19.2.8",
52
+ "react-dom": "^19.2.8",
53
+ "rollup": "^4.63.1",
54
+ "rollup-plugin-dts": "^6.5.1",
55
+ "rollup-plugin-postcss": "^4.0.2",
56
+ "rollup-plugin-typescript2": "^0.37.0",
57
+ "tslib": "^2.8.1",
58
+ "typescript": "^6.0.3",
59
+ "@rubenpazch/eslint-config": "4.0.0",
60
+ "@rubenpazch/typescript-config": "3.0.0"
61
+ },
62
+ "publishConfig": {
63
+ "access": "public"
64
+ },
65
+ "lbyte": {
66
+ "categoria": "formularios",
67
+ "resumen": "Interruptor encendido/apagado (role=\"switch\") con etiqueta y descripción.",
68
+ "usarCuando": "Opciones que se activan al instante: notificaciones, módulo activo, mostrar en el sitio.",
69
+ "evitarCuando": "Opciones que se guardan con un botón Enviar o selección múltiple en una lista: usa CheckboxInput."
70
+ },
71
+ "scripts": {
72
+ "build": "rollup -c",
73
+ "test": "jest --passWithNoTests",
74
+ "test:watch": "jest --watch",
75
+ "lint": "eslint src",
76
+ "clean": "rm -rf dist"
77
+ }
6
78
  }